From 631225a626187be9cbbda3c1be075c1234194b51 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 2 Jun 2021 15:57:19 -0700 Subject: [PATCH] Ovl_Obj_HsStump Ok but one function does not match (#156) * Everything matches but func_80BDABCC * Better names, still stuck on func_80BDABCC * Some cleanup * Add param macros and document not matching * format * PR suggestions * Bring over data to c file * Retry Jenkins * Retry Jenkins take 2 * PR suggestions for comments * PR comments --- linker_scripts/code_script.txt | 8 +- linker_scripts/object_script.txt | 4 + .../actors/ovl_Obj_HsStump/z_obj_hsstump.c | 128 ++++++++++++++++-- .../actors/ovl_Obj_HsStump/z_obj_hsstump.h | 14 +- tables/functions.txt | 8 +- tables/variables.txt | 2 +- 6 files changed, 145 insertions(+), 19 deletions(-) diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index fa24accc7b..32f8879b97 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -8240,9 +8240,13 @@ SECTIONS ovl_Obj_HsStump : AT(RomLocation) { build/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.o(.text) - build/asm/overlays/ovl_Obj_HsStump_data.o(.data) + build/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.o(.data) build/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.o(.rodata) - build/asm/overlays/ovl_Obj_HsStump_rodata.o(.rodata) + #ifdef NON_MATCHING + build/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump_overlay.o(.ovl) + #else + build/asm/overlays/ovl_Obj_HsStump_rodata.o(.rodata) + #endif } SegmentEnd = .; SegmentSize = SegmentEnd - SegmentStart; diff --git a/linker_scripts/object_script.txt b/linker_scripts/object_script.txt index 1800002d24..9a3a9f4d50 100644 --- a/linker_scripts/object_script.txt +++ b/linker_scripts/object_script.txt @@ -65,6 +65,10 @@ D_06001470 = 0x06001470; /* z_en_nnh */ D_06001510 = 0x06001510; +/* obj_hsstump */ +D_060003B8 = 0x060003B8; +D_060011B0 = 0x060011B0; + /* en_encount2 */ D_06000A00 = 0x6000A00; D_06000D78 = 0x6000D78; diff --git a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c index 26fdfe2266..1c0088ae66 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c @@ -9,7 +9,11 @@ void ObjHsStump_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHsStump_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHsStump_Draw(Actor* thisx, GlobalContext* globalCtx); -/* +void ObjHsStump_SetupIdle(ObjHsStump* this, GlobalContext* globalCtx); +void ObjHsStump_Idle(ObjHsStump* this, GlobalContext* globalCtx); +void ObjHsStump_SetupAppear(ObjHsStump* this, GlobalContext* globalCtx); +void ObjHsStump_Appear(ObjHsStump* this, GlobalContext* globalCtx); + const ActorInit Obj_HsStump_InitVars = { ACTOR_OBJ_HSSTUMP, ACTORCAT_BG, @@ -21,20 +25,124 @@ const ActorInit Obj_HsStump_InitVars = { (ActorFunc)ObjHsStump_Update, (ActorFunc)ObjHsStump_Draw, }; -*/ -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Obj_HsStump_0x80BDAA30/ObjHsStump_Init.asm") +extern Gfx D_060003B8[]; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Obj_HsStump_0x80BDAA30/func_80BDAB00.asm") +extern CollisionHeader D_060011B0; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Obj_HsStump_0x80BDAA30/func_80BDAB18.asm") +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 180, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Obj_HsStump_0x80BDAA30/func_80BDAB6C.asm") +Vec3f iceSmokeAccel = {0.0f, 0.0f, 0.0f}; // Readd as static when possible -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Obj_HsStump_0x80BDAA30/func_80BDABCC.asm") +void ObjHsStump_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjHsStump* this = THIS; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Obj_HsStump_0x80BDAA30/ObjHsStump_Destroy.asm") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->isHidden = OBJHSSTUMP_GET_ISHIDDEN(thisx); + this->switchFlag = OBJHSSTUMP_GET_SWITCHFLAG(thisx); // Must be thisx to match + BcCheck3_BgActorInit(&this->dyna, 1); + BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_060011B0); + switch (this->isHidden) { + case true: + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->isHidden = false; + } else { + this->dyna.actor.draw = NULL; + Actor_SetScale(&this->dyna.actor, 0.0f); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + case false: + ObjHsStump_SetupIdle(this, globalCtx); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Obj_HsStump_0x80BDAA30/ObjHsStump_Update.asm") +void ObjHsStump_SetupIdle(ObjHsStump* this, GlobalContext* globalCtx) { + this->actionFunc = ObjHsStump_Idle; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Obj_HsStump_0x80BDAA30/ObjHsStump_Draw.asm") +void ObjHsStump_Idle(ObjHsStump* this, GlobalContext* globalCtx) { + if (this->isHidden == true && Flags_GetSwitch(globalCtx, this->switchFlag)) { + ObjHsStump_SetupAppear(this, globalCtx); + } +} + +void ObjHsStump_SetupAppear(ObjHsStump* this, GlobalContext* globalCtx) { + this->dyna.actor.draw = ObjHsStump_Draw; + this->framesAppeared = 0; + this->rotAngle = 0; + this->rotFactor = 3640.0f; + func_8019F128(0x3A86); + this->actionFunc = ObjHsStump_Appear; +} + +#ifdef NON_MATCHING +// Correct instructions, but they are all out of order in the (this->framesAppeared) < 11 branch +// Loop looks fine, it's everything before +void ObjHsStump_Appear(ObjHsStump* this, GlobalContext* globalCtx) { + s16 i; + f32 angle; + s16 numDirections; + Vec3f iceSmokePosOffset; + Vec3f iceSmokeVelOffset; + s16 offsetAngle; + Vec3f iceSmokeVel; + f32 angleBAMS; + Vec3f iceSmokePos; + + if (this->framesAppeared >= 0) { + Math_SmoothStepToF(&this->rotFactor, 0.0f, 1.0f, this->framesAppeared + 18.0f, 0.01f); + this->dyna.actor.shape.rot.x = (Math_SinS(this->rotAngle) * this->rotFactor) + this->dyna.actor.home.rot.x; + this->dyna.actor.shape.rot.z = (Math_SinS(this->rotAngle * 2) * this->rotFactor) + this->dyna.actor.home.rot.z; + this->rotAngle += 0x2000; + } + if (this->framesAppeared < 11) { + if (this->framesAppeared == 0) { + iceSmokePosOffset.x = iceSmokeVelOffset.x = 1.0f; + iceSmokePosOffset.y = iceSmokeVelOffset.y = 0.5f; + iceSmokePosOffset.z = iceSmokeVelOffset.z = 0.0f; + + numDirections = 4; + angle = 360.0f / numDirections; + angleBAMS = angle * (0x10000 / 360.0f); + + for (i = 0; i < numDirections; i++) { + offsetAngle = i * angleBAMS; + Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.world.pos, offsetAngle, &iceSmokePosOffset, + &iceSmokePos); + Lib_Vec3f_TranslateAndRotateY(&D_801D15B0, offsetAngle, &iceSmokeVelOffset, &iceSmokeVel); + EffectSsIceSmoke_Spawn(globalCtx, &iceSmokePos, &iceSmokeVel, &iceSmokeAccel, 100); + } + } + } + if (this->framesAppeared >= 10) { + Math_SmoothStepToF(&this->dyna.actor.scale.x, 0.17999999f, 1.0f, 0.01f, 0.001f); + Actor_SetScale(&this->dyna.actor, this->dyna.actor.scale.x); + } + if (this->dyna.actor.scale.x == 0.17999999f) { + this->isHidden = false; + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + ObjHsStump_SetupIdle(this, globalCtx); + } + this->framesAppeared++; +} +#else +#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Obj_HsStump_0x80BDAA30/ObjHsStump_Appear.asm") +#endif + +void ObjHsStump_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjHsStump* this = THIS; + + BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void ObjHsStump_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHsStump* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjHsStump_Draw(Actor* thisx, GlobalContext* globalCtx) { + func_800BDFC0(globalCtx, D_060003B8); +} diff --git a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.h b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.h index b8ce0529d9..5ae69972db 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.h +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.h @@ -3,11 +3,21 @@ #include +#define OBJHSSTUMP_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define OBJHSSTUMP_GET_ISHIDDEN(thisx) (((thisx)->params >> 12) & 0xF) + struct ObjHsStump; +typedef void (*ObjHsStumpActionFunc)(struct ObjHsStump*, GlobalContext*); + typedef struct ObjHsStump { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x28]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjHsStumpActionFunc actionFunc; + /* 0x160 */ s16 switchFlag; + /* 0x162 */ u8 isHidden; + /* 0x164 */ s16 framesAppeared; + /* 0x166 */ s16 rotAngle; + /* 0x168 */ f32 rotFactor; } ObjHsStump; // size = 0x16C extern const ActorInit Obj_HsStump_InitVars; diff --git a/tables/functions.txt b/tables/functions.txt index 0d79e0d7b7..a4a5a6155a 100644 --- a/tables/functions.txt +++ b/tables/functions.txt @@ -15955,10 +15955,10 @@ 0x80BDA2E0:("func_80BDA2E0",), 0x80BDA344:("func_80BDA344",), 0x80BDAA30:("ObjHsStump_Init",), - 0x80BDAB00:("func_80BDAB00",), - 0x80BDAB18:("func_80BDAB18",), - 0x80BDAB6C:("func_80BDAB6C",), - 0x80BDABCC:("func_80BDABCC",), + 0x80BDAB00:("ObjHsStump_SetupIdle",), + 0x80BDAB18:("ObjHsStump_Idle",), + 0x80BDAB6C:("ObjHsStump_SetupAppear",), + 0x80BDABCC:("ObjHsStump_Appear",), 0x80BDAECC:("ObjHsStump_Destroy",), 0x80BDAF00:("ObjHsStump_Update",), 0x80BDAF24:("ObjHsStump_Draw",), diff --git a/tables/variables.txt b/tables/variables.txt index 9a610c1ba1..0887a1a0a6 100644 --- a/tables/variables.txt +++ b/tables/variables.txt @@ -17869,7 +17869,7 @@ 0x80BDAA2C:("enPameraOverlayInfoOffset","u32","",0x4), 0x80BDAF60:("Obj_HsStump_InitVars","UNK_TYPE1","",0x1), 0x80BDAF80:("D_80BDAF80","UNK_TYPE1","",0x1), - 0x80BDAF84:("D_80BDAF84","UNK_TYPE1","",0x1), + 0x80BDAF84:("iceSmokeAccel","Vec3f","",0xc), 0x80BDAF90:("D_80BDAF90","f32","",0x4), 0x80BDAF94:("D_80BDAF94","f32","",0x4), 0x80BDAF98:("D_80BDAF98","f32","",0x4),