From 69b4bd89987a0181baac89ff39a67411af78794f Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Mon, 11 Jul 2022 23:10:29 -0300 Subject: [PATCH] ovl_Bg_F40_Flift decompiled (#885) * ovl_Bg_F40_Flift decompiled * format * pr reviews * pr review --- spec | 3 +- .../actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c | 66 +++++++++++++++---- .../actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h | 7 +- 3 files changed, 57 insertions(+), 19 deletions(-) diff --git a/spec b/spec index b5c806fb9c..f2a7ad9cd2 100644 --- a/spec +++ b/spec @@ -1129,8 +1129,7 @@ beginseg name "ovl_Bg_F40_Flift" compress include "build/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.o" - include "build/data/ovl_Bg_F40_Flift/ovl_Bg_F40_Flift.data.o" - include "build/data/ovl_Bg_F40_Flift/ovl_Bg_F40_Flift.reloc.o" + include "build/src/overlays/actors/ovl_Bg_F40_Flift/ovl_Bg_F40_Flift_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c index 4e323cbf92..3974b2fc53 100644 --- a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c +++ b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c @@ -5,6 +5,7 @@ */ #include "z_bg_f40_flift.h" +#include "objects/object_f40_obj/object_f40_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,9 @@ void BgF40Flift_Destroy(Actor* thisx, PlayState* play); void BgF40Flift_Update(Actor* thisx, PlayState* play); void BgF40Flift_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_808D75F0(BgF40Flift* this, PlayState* play); +void func_808D7714(BgF40Flift* this, PlayState* play); + const ActorInit Bg_F40_Flift_InitVars = { ACTOR_BG_F40_FLIFT, ACTORCAT_BG, @@ -28,28 +31,65 @@ const ActorInit Bg_F40_Flift_InitVars = { (ActorFunc)BgF40Flift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808D7830[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 5000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgF40Flift_Init(Actor* thisx, PlayState* play) { + BgF40Flift* this = THIS; -extern InitChainEntry D_808D7830[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_f40_obj_Colheader_004240); + this->dyna.actor.params = 1; + this->actionFunc = func_808D75F0; +} -extern UNK_TYPE D_06004038; -extern UNK_TYPE D_06004240; +void BgF40Flift_Destroy(Actor* thisx, PlayState* play) { + BgF40Flift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/BgF40Flift_Init.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/BgF40Flift_Destroy.s") +void func_808D75F0(BgF40Flift* this, PlayState* play) { + if (((this->dyna.actor.params == 1) && (DynaPolyActor_IsInRidingMovingState(&this->dyna))) || + ((this->dyna.actor.params == -1) && (!DynaPolyActor_IsInRidingMovingState(&this->dyna)))) { + this->timer = 96; + this->actionFunc = func_808D7714; + } else { + if (this->timer == 0) { + this->timer = 48; + } + this->timer--; + if (this->dyna.actor.params == 1) { + this->dyna.actor.world.pos.y = (sin_rad(this->timer * (M_PI / 24.0f)) * 5.0f) + this->dyna.actor.home.pos.y; + } else { + this->dyna.actor.world.pos.y = + (sin_rad(this->timer * (M_PI / 24.0f)) * 5.0f) + (926.8f + this->dyna.actor.home.pos.y); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/func_808D75F0.s") +void func_808D7714(BgF40Flift* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + this->dyna.actor.world.pos.y = + (((cos_rad(this->timer * (M_PI / 96.0f)) * this->dyna.actor.params) + 1.0f) * 463.4f) + + this->dyna.actor.home.pos.y; + } else { + this->dyna.actor.params = -this->dyna.actor.params; + this->actionFunc = func_808D75F0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/func_808D7714.s") +void BgF40Flift_Update(Actor* thisx, PlayState* play) { + BgF40Flift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/BgF40Flift_Update.s") + this->actionFunc(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/BgF40Flift_Draw.s") +void BgF40Flift_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_f40_obj_DL_004038); +} diff --git a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h index 5aa6b46602..95b2e9073a 100644 --- a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h +++ b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h @@ -8,10 +8,9 @@ struct BgF40Flift; typedef void (*BgF40FliftActionFunc)(struct BgF40Flift*, PlayState*); typedef struct BgF40Flift { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgF40FliftActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgF40FliftActionFunc actionFunc; + /* 0x160 */ s32 timer; } BgF40Flift; // size = 0x164 extern const ActorInit Bg_F40_Flift_InitVars;