Skip to content

Commit

Permalink
Match some ftCommon functions (#1397)
Browse files Browse the repository at this point in the history
* partial matches

* fix padding on `ftNs_AttackHi4_YoyoCheckEnvColl`

* mark as matching

* fix incorrect .sdata2
  • Loading branch information
thefoxcam authored Jul 15, 2024
1 parent b4b7414 commit c7f52f4
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 960 deletions.
393 changes: 0 additions & 393 deletions asm/melee/ft/chara/ftCommon/ftCo_0C35.s

This file was deleted.

498 changes: 0 additions & 498 deletions asm/melee/ft/chara/ftCommon/ftCo_PassiveWall.s

This file was deleted.

4 changes: 2 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,11 @@ def RuntimeLib(lib_name: str, objects: Objects) -> LibDict:
Object(NonMatching, "melee/ft/ftdevice.c"),
Object(NonMatching, "melee/ft/chara/ftCommon/ftCo_Bury.c"),
Object(NonMatching, "melee/ft/chara/ftCommon/ftCo_FlyReflect.c"),
Object(NonMatching, "melee/ft/chara/ftCommon/ftCo_PassiveWall.c"),
Object(Matching, "melee/ft/chara/ftCommon/ftCo_PassiveWall.c"),
Object(Matching, "melee/ft/chara/ftCommon/ftCo_PassiveCeil.c"),
Object(NonMatching, "melee/ft/ftafterimage.c"),
Object(Matching, "melee/ft/chara/ftCommon/ftCo_DamageSong.c"),
Object(NonMatching, "melee/ft/chara/ftCommon/ftCo_0C35.c"),
Object(Matching, "melee/ft/chara/ftCommon/ftCo_0C35.c"),
Object(NonMatching, "melee/ft/chara/ftCommon/ftCo_AirCatch.c"),
Object(Matching, "melee/ft/chara/ftCommon/ftCo_DamageBind.c"),
Object(NonMatching, "melee/ft/chara/ftCommon/ftCo_WarpStar.c"),
Expand Down
4 changes: 2 additions & 2 deletions obj_files.mk
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ TEXT_O_FILES +=\
$(BUILD_DIR)/asm/melee/ft/ftdevice.s.o\
$(BUILD_DIR)/asm/melee/ft/chara/ftCommon/ftCo_Bury.s.o\
$(BUILD_DIR)/asm/melee/ft/chara/ftCommon/ftCo_FlyReflect.s.o\
$(BUILD_DIR)/asm/melee/ft/chara/ftCommon/ftCo_PassiveWall.s.o\
$(BUILD_DIR)/src/melee/ft/chara/ftCommon/ftCo_PassiveWall.c.o\
$(BUILD_DIR)/src/melee/ft/chara/ftCommon/ftCo_PassiveCeil.c.o\
$(BUILD_DIR)/asm/melee/ft/ftafterimage.s.o\
$(BUILD_DIR)/src/melee/ft/chara/ftCommon/ftCo_DamageSong.c.o\
$(BUILD_DIR)/asm/melee/ft/chara/ftCommon/ftCo_0C35.s.o\
$(BUILD_DIR)/src/melee/ft/chara/ftCommon/ftCo_0C35.c.o\
$(BUILD_DIR)/asm/melee/ft/chara/ftCommon/ftCo_AirCatch.s.o\
$(BUILD_DIR)/src/melee/ft/chara/ftCommon/ftCo_DamageBind.c.o\
$(BUILD_DIR)/asm/melee/ft/chara/ftCommon/ftCo_WarpStar.s.o\
Expand Down
14 changes: 2 additions & 12 deletions src/melee/ft/chara/ftCommon/ftCo_0C35.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@
#include <baselib/jobj.h>
#include <MSL/trigf.h>

#pragma force_active on

/* literal */ double const ftCo_804D8CD0 = S32_TO_F32;
/* literal */ float const ftCo_804D8CD8 = 0;
/* literal */ double const ftCo_804D8CE0 = M_PI;
/* literal */ double const ftCo_804D8CE8 = M_PI_2;
/* literal */ SDATA char ftCo_804D3C38[] = "jobj.h";
/* literal */ SDATA char ftCo_804D3C40[] = "jobj";
/* literal */ char lbl_803C6CA8[] = "!(jobj->flags & JOBJ_USE_QUATERNION)";

static inline void inlineA0(ftCo_GObj* gobj)
static void inlineA0(ftCo_GObj* gobj)
{
Fighter* fp = GET_FIGHTER(gobj);
fp->dmg.x18F4 = p_ftCommonData->x648;
Expand Down Expand Up @@ -79,11 +69,11 @@ void ftCo_800C37A0(ftCo_GObj* gobj)
if (fp->dmg.x18F4 != 0) {
Fighter_Part part = ftParts_8007500C(fp, FtPart_TransN);
HSD_JObj* jobj = fp->parts[part].x4_jobj2;
--fp->dmg.x18F4;
{
float rot_y = M_PI *
(float) (p_ftCommonData->x648 - fp->dmg.x18F4) /
(float) p_ftCommonData->x648;
fp->dmg.x18F4 -= 1;
ftParts_80075AF0(fp, part, rot_y);
HSD_JObjSetRotationY(jobj, rot_y);
if (fp->dmg.x18F4 == 0) {
Expand Down
38 changes: 11 additions & 27 deletions src/melee/ft/chara/ftCommon/ftCo_AirCatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,12 @@

bool ftCo_800C3A14(ftCo_GObj* gobj)
{
CollData coll = { 0 };
IntVec3 sp14;
int i = 51;
IntVec3* var_r5 = &sp14;
Fighter* fp = GET_FIGHTER(gobj);
IntVec3* var_r4 = (IntVec3*) &fp->x6E4.y;
do {
var_r4 += 8;
var_r5 += 8;
var_r5->z = var_r4->z;
var_r5->y = var_r4->y;
--i;
} while (i != 0);
var_r5->z = var_r4->z;
CollData coll = *getFtColl(fp);
PAD_STACK(8);
coll.x58 += 5.0;
coll.x5C += 5.0;
if (fp->facing_dir > 0.0f) {
if (fp->facing_dir > (f64) 0.0F) {
if (mpColl_80044164(&coll, &fp->coll_data.ledge_id_unk1)) {
fp->coll_data.env_flags |= MPCOLL_FLAGS_B24;
fp->self_vel.x = 0;
Expand Down Expand Up @@ -130,14 +119,16 @@ void ftCo_800C3BE8(ftCo_GObj* gobj)
void ftCo_800C3CC0(ftCo_GObj* gobj)
{
Fighter* fp = GET_FIGHTER(gobj);
f32 drift;
if (fp->kind == FTKIND_LINK || fp->kind == FTKIND_CLINK) {
Fighter_ChangeMotionState(gobj, ftLk_MS_AirCatchHit,
Ft_MF_KeepFastFall, 0, 1, 0, NULL);
} else {
Fighter_ChangeMotionState(gobj, ftSs_MS_AirCatchHit,
Ft_MF_KeepFastFall, 0, 1, 0, NULL);
}
ftCommon_8007D440(fp, fp->co_attrs.air_drift_max);
drift = fp->co_attrs.air_drift_max;
ftCommon_8007D440(fp, drift);
fp->mv.co.aircatchhit.x0 = 20;
fp->mv.co.aircatchhit.x4 = 0;
if (fp->ground_or_air == GA_Ground) {
Expand Down Expand Up @@ -166,7 +157,6 @@ void ftCo_AirCatch_Anim(ftCo_GObj* gobj)
fp->death1_cb = it_802A7AAC;
fp->accessory3_cb = it_802A7B34;
}
goto exit;
} else if (fp->mv.co.aircatch.x0 > da->xA4) {
if (fp->mv.co.aircatch.x0 <= da->xB0) {
Item_GObj* tether_gobj = fp->fv.lk.xC;
Expand Down Expand Up @@ -209,9 +199,8 @@ void ftCo_AirCatch_Anim(ftCo_GObj* gobj)
} else {
ft_80088148(fp, 0x27149, 0x7F, 0x40);
}
goto exit;
}
if (fp->mv.co.aircatch.x0 == (float) M2C_FIELD(da, int*, 0xAC))
} else if (fp->mv.co.aircatch.x0 ==
(float) M2C_FIELD(da, int*, 0xAC))
{
it_802A77DC(tether_gobj);
if (fp->kind == FTKIND_CLINK) {
Expand All @@ -222,7 +211,6 @@ void ftCo_AirCatch_Anim(ftCo_GObj* gobj)
} else if (fp->mv.co.aircatch.x0 == da->xB0) {
it_802A2B10(fp->fv.lk.xC);
}
goto exit;
}
}
} else if (fp->kind == FTKIND_SAMUS) {
Expand Down Expand Up @@ -268,7 +256,6 @@ void ftCo_AirCatch_Anim(ftCo_GObj* gobj)
pos.x = x + fp->pos_delta.x;
it_802BAAE4(temp_r29_2, &pos, x);
}
goto exit;
} else {
if (fp->mv.co.aircatch.x0 == da->xC4) {
it_802BAA58(temp_r29_2);
Expand All @@ -279,13 +266,10 @@ void ftCo_AirCatch_Anim(ftCo_GObj* gobj)
}
}
}
{
exit:
if (!ftAnim_IsFramesRemaining(gobj)) {
ftCo_800968C8(gobj);
}
return;
if (!ftAnim_IsFramesRemaining(gobj)) {
ftCo_800968C8(gobj);
}
return;
}

void ftCo_AirCatchHit_Anim(ftCo_GObj* gobj) {}
Expand Down
20 changes: 9 additions & 11 deletions src/melee/ft/chara/ftCommon/ftCo_PassiveWall.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

#include <common_structs.h>

#pragma force_active on

bool ftCo_800C1D38(ftCo_GObj* gobj)
{
Fighter* fp = GET_FIGHTER(gobj);
Expand Down Expand Up @@ -77,16 +75,16 @@ void ftCo_800C1E64(ftCo_GObj* gobj, int msid, int timer, int vel_y_exponent,
if (fp->coll_data.env_flags & MPCOLL_FLAGS_B11) {
ef_offset.x = coll->xA4_ecbCurrCorrect.left.x;
ef_offset.y = coll->xA4_ecbCurrCorrect.left.y;
ef_offset.z = 0;
ef_offset.z = 0.0F;
} else {
ef_offset.x = coll->xA4_ecbCurrCorrect.right.x;
ef_offset.y = coll->xA4_ecbCurrCorrect.right.y;
ef_offset.z = 0;
ef_offset.z = 0.0F;
}
}
ftKb_SpecialN_800F1F1C(gobj, &ef_offset);
Fighter_ChangeMotionState(gobj, msid, Ft_MF_None, 0, timer != 0 ? 0 : 1, 0,
NULL);
Fighter_ChangeMotionState(gobj, msid, Ft_MF_None, 0.0F,
timer != 0 ? 0.0F : 1.0F, 0.0F, NULL);
fp->x670_timer_lstick_tilt_x = 0xFE;
fp->x671_timer_lstick_tilt_y = 0xFE;
fp->mv.co.passivewall.timer = timer;
Expand All @@ -96,7 +94,7 @@ void ftCo_800C1E64(ftCo_GObj* gobj, int msid, int timer, int vel_y_exponent,
{
Vec3 ef_pos;
float pos_x_offset = fp->cur_pos.x + ef_offset.x;
u8 _[4] = { 0 };
PAD_STACK(4);
ef_pos.x = pos_x_offset;
ef_pos.y = fp->cur_pos.y + ef_offset.y;
ef_pos.z = fp->cur_pos.z;
Expand Down Expand Up @@ -127,12 +125,12 @@ static inline void inlineA0(ftCo_GObj* gobj)

void ftCo_PassiveWall_Anim(ftCo_GObj* gobj)
{
u8 _[16] = { 0 };
Fighter* fp = GET_FIGHTER(gobj);
PAD_STACK(16);
if (fp->mv.co.passivewall.timer != 0) {
--fp->mv.co.passivewall.timer;
if (fp->mv.co.passivewall.timer == 0) {
ft_80088148(fp, 8, 0x7F, 0x40);
ft_80088148(fp, 8, 127, 64);
if (fp->mv.co.passivewall.x8) {
inlineA0(gobj);
} else {
Expand Down Expand Up @@ -180,8 +178,8 @@ void ftCo_PassiveWall_IASA(ftCo_GObj* gobj)

void ftCo_PassiveWall_Phys(ftCo_GObj* gobj)
{
u8 _[8] = { 0 };
Fighter* fp = GET_FIGHTER(gobj);
PAD_STACK(8);
if (!fp->mv.co.passivewall.timer) {
ftCo_DatAttrs* co = &fp->co_attrs;
ftCommon_8007D528(fp);
Expand All @@ -190,7 +188,7 @@ void ftCo_PassiveWall_Phys(ftCo_GObj* gobj)
} else {
ftCommon_8007D494(fp, co->grav, co->terminal_vel);
}
ftCommon_8007D140(fp, 0, 0, fp->co_attrs.aerial_friction);
ftCommon_8007D140(fp, 0.0F, 0.0F, fp->co_attrs.aerial_friction);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/melee/ft/chara/ftNess/ftNs_AttackHi4.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ static inline void push_ecb(CollData* a, Vec3* b)
s32 ftNs_AttackHi4_YoyoCheckEnvColl(HSD_GObj* gobj, Vec3* ECBUnk,
Vec3* ECBUnk2, float float_unk)
{
u8 pad[4];
CollData coll;
ftCollisionBox ecb;
Fighter* fp = gobj->user_data;
Expand All @@ -121,6 +122,7 @@ s32 ftNs_AttackHi4_YoyoCheckEnvColl(HSD_GObj* gobj, Vec3* ECBUnk,
// sp34.cur_topn = ECBUnk2->x0_vec;
// guess: there is a "push ECB" function that handles moving current to
// old, that got called twice and inlined.

push_ecb(&coll, ECBUnk);
push_ecb(&coll, ECBUnk2);

Expand Down
6 changes: 3 additions & 3 deletions src/melee/ft/fighter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2457,9 +2457,9 @@ void Fighter_8006C27C(Fighter_GObj* gobj)
Fighter* fp = (Fighter*) HSD_GObjGetUserData(gobj);

if (!fp->x221F_b3) {
if (fp->coll_data.ecb_lock) {
fp->coll_data.ecb_lock--;
if (!fp->coll_data.ecb_lock) {
if (fp->ecb_lock) {
fp->ecb_lock--;
if (!fp->ecb_lock) {
ftCommon_8007D5BC(fp);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/melee/ft/ft_081B.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void ft_80081B38(HSD_GObj* arg0)
f32 temp_f3;

temp_r31 = arg0->user_data;
temp_r31->coll_data.ecb_lock = 0;
temp_r31->ecb_lock = 0;
temp_r30 = &temp_r31->coll_data;
temp_r31->coll_data.cur_topn = temp_r31->cur_pos;
temp_r31->coll_data.prev_topn = temp_r31->coll_data.cur_topn;
Expand Down
10 changes: 5 additions & 5 deletions src/melee/ft/ftcommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ bool ftCommon_8007D528(Fighter* fp)

void ftCommon_8007D5BC(Fighter* fp)
{
fp->coll_data.ecb_lock = 0;
fp->ecb_lock = 0;
fp->coll_data.x130_flags &= 0xFFFFFFEF;
}

Expand All @@ -596,7 +596,7 @@ void ftCommon_8007D5D4(Fighter* fp)
fp->cur_pos.z = 0;
fp->x74_anim_vel.y = 0;
fp->x1968_jumpsUsed = 1;
fp->coll_data.ecb_lock = 10;
fp->ecb_lock = 10;
fp->coll_data.x130_flags |= (1 << 4);
}

Expand All @@ -610,7 +610,7 @@ void ftCommon_8007D60C(Fighter* fp)
fp->gr_vel = 0;
fp->x74_anim_vel.y = 0;
fp->x1968_jumpsUsed = ca->max_jumps;
fp->coll_data.ecb_lock = 5;
fp->ecb_lock = 5;
fp->coll_data.x130_flags |= 0x10;
}

Expand All @@ -636,7 +636,7 @@ void ftCommon_8007D6A4(Fighter* fp)
fp->x1968_jumpsUsed = 0;
fp->x1969_walljumpUsed = 0;
fp->x2227_b0 = 0;
fp->coll_data.ecb_lock = 0;
fp->ecb_lock = 0;
fp->coll_data.x130_flags &= 0xFFFFFFEF;
if (!ft_80084A18(fp->gobj)) {
OSReport("fighter ground no under Id! %d %d\n", fp->player_id,
Expand Down Expand Up @@ -688,7 +688,7 @@ void ftCommon_8007D7FC(Fighter* fp)
fp->x1968_jumpsUsed = 0;
fp->x1969_walljumpUsed = 0;
fp->x2227_b0 = 0;
fp->coll_data.ecb_lock = 0;
fp->ecb_lock = 0;
fp->coll_data.x130_flags &= 0xFFFFFFEF;
if (!ft_80084A18(fp->gobj)) {
OSReport("fighter ground no under Id! %d %d\n", fp->player_id,
Expand Down
1 change: 1 addition & 0 deletions src/melee/ft/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@ struct Fighter {
/* fp+6D8 */ Vec3 x6D8;
/* fp+6E4 */ Vec3 x6E4;
/* fp+6F0 */ CollData coll_data;
/* fp+88C */ s32 ecb_lock;
/* fp+890 */ CameraBox* x890_cameraBox;
/* fp+894 */ float cur_anim_frame;
/* fp+898 */ float x898_unk;
Expand Down
10 changes: 5 additions & 5 deletions src/melee/it/item.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ static void Item_80267AA8(HSD_GObj* gobj, SpawnItem* spawnItem)
item_data->xCC_item_attr = item_data->xC4_article_data->x0_common_attr;
item_data->owner = NULL;
item_data->xDC8_word.flags.x0 = 0;
item_data->x378_itemColl.ecb_lock = -1;
item_data->ecb_lock = -1;
item_data->xDC4 = 0;
item_data->xDC8_word.flags.xF = 0;
item_data->xCC4 = 0;
Expand Down Expand Up @@ -931,8 +931,8 @@ static void foobar2(HSD_GObj* gobj)
ftLib_80086960(it->owner))
{
it->xDC8_word.flags.xE = 1;
it->x378_itemColl.ecb_lock = ftLib_800872A4(it->owner);
ftLib_8008702C(it->x378_itemColl.ecb_lock);
it->ecb_lock = ftLib_800872A4(it->owner);
ftLib_8008702C(it->ecb_lock);
}
}

Expand Down Expand Up @@ -1965,9 +1965,9 @@ static void func_8026A8EC_inline1(HSD_GObj* gobj)
Item* ip = (Item*) HSD_GObjGetUserData(gobj);

if (ip->xDC8_word.flags.xE) {
ftLib_80087050(ip->x378_itemColl.ecb_lock);
ftLib_80087050(ip->ecb_lock);
ip->xDC8_word.flags.xE = false;
ip->x378_itemColl.ecb_lock = -1;
ip->ecb_lock = -1;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/melee/it/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ struct Item {
Item_DynamicBones xD4_dynamicBones[24];
s32 x374_dynamicBonesNum;
CollData x378_itemColl;
s32 ecb_lock;

/// @at{518} @sz{4}
/// @brief Item's current owner
Expand Down Expand Up @@ -589,6 +590,7 @@ typedef struct ItemLink // user_data struct of GObj class 7
u8 flag6 : 1;
u8 flag7 : 1;
CollData x30_collData;
UNK_T unk;
HSD_GObj* x1D0_GObj;
HSD_GObj* x1D4_GObjLinkNext;

Expand Down
1 change: 0 additions & 1 deletion src/melee/lb/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ struct CollData {
/* fp+850 */ SurfaceData right_wall;
/* fp+864 */ SurfaceData left_wall;
/* fp+878 */ SurfaceData ceiling;
/* fp+88C */ int ecb_lock;
};

#endif

0 comments on commit c7f52f4

Please sign in to comment.