Skip to content

Commit

Permalink
Fighter header (doldecomp#306)
Browse files Browse the repository at this point in the history
* added almost full fighter.h Fighter struct, including some info from decomping
  • Loading branch information
Ka-lua authored Feb 22, 2022
1 parent b4ca982 commit 9b1333d
Show file tree
Hide file tree
Showing 11 changed files with 800 additions and 352 deletions.
501 changes: 251 additions & 250 deletions include/functions.h

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions include/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,33 @@ volatile float y;

#pragma cplusplus reset

enum FloatType { FP_NAN=1, FP_INFINITE=2, FP_ZERO=3, FP_NORMAL=4, FP_SUBNORMAL=5 };

inline s32 __fpclassifyf(float x)
{
const s32 exp_mask = 0b01111111100000000000000000000000; // = 0x7F800000
const s32 mantissa_mask = 0b00000000011111111111111111111111; // = 0x007fffff
switch ((*(s32*)&x) & exp_mask)
{
case exp_mask: return ((*(s32*)&x) & mantissa_mask) ? FP_NAN : FP_INFINITE;
case 0: return ((*(s32*)&x) & mantissa_mask) ? FP_SUBNORMAL : FP_ZERO;
default: return FP_NORMAL;
}
}

inline s32 __fpclassifyd(double x)
{
switch (__HI(x) & 0x7ff00000)
{
case 0x7ff00000: return ((__HI(x) & 0x000fffff) || (__LO(x) & 0xffffffff)) ? FP_NAN : FP_INFINITE;
case 0: return ((__HI(x) & 0x000fffff) || (__LO(x) & 0xffffffff)) ? FP_SUBNORMAL : FP_ZERO;
default: return FP_NORMAL;
}
}

#define fpclassify(x) \
((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) \
: __fpclassifyd((double)(x)))


#endif
42 changes: 21 additions & 21 deletions include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -2069,28 +2069,28 @@ extern const s32 lbl_803D3984[];
// extern ? lbl_804D64EC;
// extern ? lbl_804D64F0;
// extern ? lbl_804D64F8;
// extern ? lbl_804D64FC;
// extern ? lbl_804D6500;
// extern ? lbl_804D6504;
// extern ? lbl_804D6508;
// extern ? lbl_804D650C;
// extern ? lbl_804D6510;
// extern ? lbl_804D6514;
// extern ? lbl_804D6518;
// extern ? lbl_804D651C;
// extern ? lbl_804D6520;
// extern ? lbl_804D6524;
// extern ? lbl_804D6528;
// extern ? lbl_804D652C;
// extern ? lbl_804D6530;
// extern ? lbl_804D6534;
// extern ? lbl_804D6538;
// extern ? lbl_804D653C;
extern void* lbl_804D64FC; // lbl_804D64FC..lbl_804D6550 are initialized to 0 in func_80067ABC, probably all pointers
extern void* lbl_804D6500;
extern void* lbl_804D6504;
extern void* lbl_804D6508;
extern void* lbl_804D650C;
extern void* lbl_804D6510;
extern void* lbl_804D6514;
extern void* lbl_804D6518;
extern void* lbl_804D651C;
extern void* lbl_804D6520;
extern void* lbl_804D6524;
extern void* lbl_804D6528;
extern void* lbl_804D652C;
extern void* lbl_804D6530;
extern void* lbl_804D6534;
extern void* lbl_804D6538;
extern void* lbl_804D653C;
extern s32** lbl_804D6540;
// extern ? lbl_804D6544;
// extern ? lbl_804D6548;
// extern ? lbl_804D654C;
// extern ? lbl_804D6550;
extern void* lbl_804D6544;
extern void* lbl_804D6548;
extern void* lbl_804D654C;
extern void* lbl_804D6550;
extern struct _ftCommonData* lbl_804D6554;
// extern ? lbl_804D6558;
// extern ? lbl_804D655C;
Expand Down
10 changes: 5 additions & 5 deletions src/melee/ft/chara/ftclink.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void ftCLink_OnLoad(HSD_GObj* gobj)
func_8026B3F8(items[3], attrs->xC);
func_8026B3F8(items[4], attrs->x10);
func_8026B3F8(items[5], ITEM_CLINK_MILK);
func_800753D4(ft, *lbl_804D6540[ft->x4_index], items[6]);
func_800753D4(ft, *lbl_804D6540[ft->x4_fighterKind], items[6]);
}

void func_80148DC0(HSD_GObj* gobj, s32 arg1)
Expand Down Expand Up @@ -136,13 +136,13 @@ void func_80149114(HSD_GObj* gobj)
Fighter* ft = gobj->user_data;
CLinkAttributes* temp_r4 = (void*) ft->x10C_ftData->ext_attr;
f32 ftmp = func_80092ED8(ft->x19A4, temp_r4, temp_r4->xD8);
ft->xEC = ftmp * lbl_804D6554->x294;
ft->xEC_groundVel = ftmp * lbl_804D6554->x294;
if (ft->x19AC < 0.0f) {
ftmp = ft->xEC;
ftmp = ft->xEC_groundVel;
} else {
ftmp = -ft->xEC;
ftmp = -ft->xEC_groundVel;
}
ft->xEC = ftmp;
ft->xEC_groundVel = ftmp;
func_80088148(ft, 0x111DA, 0x7F, 0x40);
}

Expand Down
8 changes: 4 additions & 4 deletions src/melee/ft/chara/ftdrmario.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ void func_801497CC(HSD_GObj* gobj)
if (gobj != NULL) {
ft = gobj->user_data;
if (ft != NULL) {
ft->x21DC = 0;
ft->x21E4 = 0;
ft->x21DC_callback_OnTakeDamage = 0;
ft->x21E4_callback_OnDeath2 = 0;
}
}
}
Expand Down Expand Up @@ -158,8 +158,8 @@ void func_801498A0(HSD_GObj* gobj)
if (gobj != NULL) {
ft = gobj->user_data;
if (ft != NULL) {
ft->x21DC = 0;
ft->x21E4 = 0;
ft->x21DC_callback_OnTakeDamage = 0;
ft->x21E4_callback_OnDeath2 = 0;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/melee/ft/chara/ftdrmario_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ void func_80149954(HSD_GObj* gobj)
tmp = func_802C0850(gobj, &sp18, tmp, 0x31, ft->x2C_facing_direction);
ft->x2240 = tmp;
if (tmp != 0) {
ft->x21E4 = (u32) func_80149540;
ft->x21DC = (u32) func_80149540;
ft->x21E4_callback_OnDeath2 = func_80149540;
ft->x21DC_callback_OnTakeDamage = func_80149540;
}
} else if (ft->x2200_ftcmd_var0 == 2) {
func_801497CC(gobj);
Expand All @@ -32,8 +32,8 @@ void func_80149954(HSD_GObj* gobj)
if (gobj != NULL) {
ft = gobj->user_data;
if (ft != NULL) {
ft->x21DC = 0;
ft->x21E4 = 0;
ft->x21DC_callback_OnTakeDamage = 0;
ft->x21E4_callback_OnDeath2 = 0;
}
}
func_8008A2BC(gobj);
Expand Down
Loading

0 comments on commit 9b1333d

Please sign in to comment.