From 0e2738b81af2ae78b962e9a3d573bed9ae823e2c Mon Sep 17 00:00:00 2001 From: kyleburnette Date: Sat, 20 Mar 2021 19:45:22 -0700 Subject: [PATCH] bg_ikana_shutter OK (#56) * Initial shutter work * Fixed types.h * bg_ikana_shutter OK * Reverted errant change to ultratypes * Adjusted to use new actor field names * fixed submodules * Cleaned up a comment I left by accident Co-authored-by: fullgrowngaming --- linker_scripts/code_script.txt | 4 +- linker_scripts/object_script.txt | 3 + .../ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c | 191 +++++++++++++++--- .../ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.h | 6 +- tables/functions.txt | 6 +- 5 files changed, 178 insertions(+), 32 deletions(-) diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index 853f86b475..58c6202175 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -8057,9 +8057,9 @@ SECTIONS ovl_Bg_Ikana_Shutter : AT(RomLocation) { build/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.o(.text) - build/asm/overlays/ovl_Bg_Ikana_Shutter_data.o(.data) + build/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.o(.data) build/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.o(.rodata) - build/asm/overlays/ovl_Bg_Ikana_Shutter_rodata.o(.rodata) + build/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter_overlay.o(.ovl) } SegmentEnd = .; SegmentSize = SegmentEnd - SegmentStart; diff --git a/linker_scripts/object_script.txt b/linker_scripts/object_script.txt index 636adb9d7d..aaf9dbafb1 100644 --- a/linker_scripts/object_script.txt +++ b/linker_scripts/object_script.txt @@ -94,3 +94,6 @@ D_06007750 = 0x06007750; D_0600A390 = 0x0600A390; D_0600A490 = 0x0600A490; +/* bg_ikana_shutter */ +D_06000F28 = 0x06000F28; +D_06000CE8 = 0x06000CE8; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c index a6bb45e8d5..b73cfe2c8c 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c @@ -9,7 +9,25 @@ void BgIkanaShutter_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkanaShutter_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkanaShutter_Draw(Actor* thisx, GlobalContext* globalCtx); -/* +void func_80BD5828(BgIkanaShutter* this); +void func_80BD5844(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD5878(BgIkanaShutter* this); +void func_80BD5894(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD58F0(BgIkanaShutter* this); +void func_80BD5910(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD599C(BgIkanaShutter* this); +void func_80BD59C4(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD59F8(BgIkanaShutter* this); +void func_80BD5A18(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD5AE8(BgIkanaShutter* this); +void func_80BD5B04(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD5B44(BgIkanaShutter* this); +void func_80BD5B60(BgIkanaShutter* this, GlobalContext* globalCtx); +void func_80BD5BC4(BgIkanaShutter* this); +void func_80BD5BD8(BgIkanaShutter* this, GlobalContext* globalCtx); +void BgIkanaShutter_SetupDoNothing(BgIkanaShutter* this); +void BgIkanaShutter_DoNothing(BgIkanaShutter* this, GlobalContext* globalCtx); + const ActorInit Bg_Ikana_Shutter_InitVars = { ACTOR_BG_IKANA_SHUTTER, ACTORCAT_SWITCH, @@ -21,50 +39,173 @@ const ActorInit Bg_Ikana_Shutter_InitVars = { (ActorFunc)BgIkanaShutter_Update, (ActorFunc)BgIkanaShutter_Draw }; -*/ -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5690.asm") +static InitChainEntry D_80BD5D10[] = { + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/BgIkanaShutter_Init.asm") +extern BgMeshHeader D_06000F28; +extern UNK_PTR D_06000CE8; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/BgIkanaShutter_Destroy.asm") +s32 BgIkanaShutter_AllSwitchesPressed(BgIkanaShutter* this, GlobalContext* globalCtx) { + return Actor_GetSwitchFlag(globalCtx, this->dyna.actor.params & 0x7F) && + Actor_GetSwitchFlag(globalCtx, (this->dyna.actor.params & 0x7F) + 1) && + Actor_GetSwitchFlag(globalCtx, (this->dyna.actor.params & 0x7F) + 2) && + Actor_GetSwitchFlag(globalCtx, (this->dyna.actor.params & 0x7F) + 3); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5828.asm") +void BgIkanaShutter_Init(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaShutter* this = THIS; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5844.asm") + Actor_ProcessInitChain(&this->dyna.actor, D_80BD5D10); + BcCheck3_BgActorInit(&this->dyna, 0); + BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000F28); + if (!((this->dyna.actor.params >> 8) & 1)) { + if (BgIkanaShutter_AllSwitchesPressed(this, globalCtx)) { + func_80BD599C(this); + return; + } + func_80BD5828(this); + return; + } + if (Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + BgIkanaShutter_SetupDoNothing(this); + return; + } + func_80BD5AE8(this); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5878.asm") +void BgIkanaShutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaShutter* this = THIS; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5894.asm") + BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD58F0.asm") +void func_80BD5828(BgIkanaShutter* this) { + this->actionFunc = func_80BD5844; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5910.asm") +void func_80BD5844(BgIkanaShutter* this, GlobalContext* globalCtx) { + if (BgIkanaShutter_AllSwitchesPressed(this, globalCtx)) { + func_80BD5878(this); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD599C.asm") +void func_80BD5878(BgIkanaShutter* this) { + this->actionFunc = func_80BD5894; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD59C4.asm") +void func_80BD5894(BgIkanaShutter* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + func_80BD58F0(this); + return; + } + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD59F8.asm") +void func_80BD58F0(BgIkanaShutter* this) { + this->dyna.actor.velocity.y = 0.6f; + this->actionFunc = func_80BD5910; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5A18.asm") +void func_80BD5910(BgIkanaShutter* this, GlobalContext* globalCtx) { + Lib_StepTowardsCheck_f(&this->dyna.actor.velocity.y, 4.0f, 0.5f); + if (Math_SmoothScaleMaxMinF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 220.0f, 0.5f, + this->dyna.actor.velocity.y, 1.0f) < 0.5f) { + func_80BD599C(this); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5AE8.asm") +void func_80BD599C(BgIkanaShutter* this) { + this->actionFunc = func_80BD59C4; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 220.0f; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5B04.asm") +void func_80BD59C4(BgIkanaShutter* this, GlobalContext* globalCtx) { + if (BgIkanaShutter_AllSwitchesPressed(this, globalCtx) == 0) { + func_80BD59F8(this); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5B44.asm") +void func_80BD59F8(BgIkanaShutter* this) { + this->actionFunc = func_80BD5A18; + this->dyna.actor.velocity.y = -23.0f; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5B60.asm") +void func_80BD5A18(BgIkanaShutter* this, GlobalContext* globalCtx) { + s32 pad[2]; + s16 quake; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5BC4.asm") + this->dyna.actor.velocity.y += -5.0f; + this->dyna.actor.velocity.y *= 0.978f; + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + if (this->dyna.actor.world.pos.y <= this->dyna.actor.home.pos.y) { + quake = Quake_Add(ACTIVE_CAM, 3); + Quake_SetSpeed(quake, 0x5420); + Quake_SetQuakeValues(quake, 4, 0, 0, 0); + Quake_SetCountdown(quake, 12); + func_80BD5828(this); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5BD8.asm") +void func_80BD5AE8(BgIkanaShutter* this) { + this->actionFunc = func_80BD5B04; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5C64.asm") +void func_80BD5B04(BgIkanaShutter* this, GlobalContext* globalCtx) { + if (Actor_GetRoomClearedTemp(globalCtx, this->dyna.actor.room)) { + func_80BD5B44(this); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/func_80BD5C8C.asm") +void func_80BD5B44(BgIkanaShutter* this) { + this->actionFunc = func_80BD5B60; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/BgIkanaShutter_Update.asm") +void func_80BD5B60(BgIkanaShutter* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + Actor_SetRoomCleared(globalCtx, this->dyna.actor.room); + func_80BD5BC4(this); + return; + } + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ikana_Shutter_0x80BD5690/BgIkanaShutter_Draw.asm") +void func_80BD5BC4(BgIkanaShutter* this) { + this->actionFunc = func_80BD5BD8; +} + +void func_80BD5BD8(BgIkanaShutter* this, GlobalContext* globalCtx) { + Lib_StepTowardsCheck_f(&this->dyna.actor.velocity.y, 4.0f, 0.5f); + if (Math_SmoothScaleMaxMinF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + -220.0f, 0.5f, + this->dyna.actor.velocity.y, 1.0f) < 0.5f) { + BgIkanaShutter_SetupDoNothing(this); + } +} + +void BgIkanaShutter_SetupDoNothing(BgIkanaShutter* this) { + this->actionFunc = BgIkanaShutter_DoNothing; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + -220.0f; +} + +void BgIkanaShutter_DoNothing(BgIkanaShutter* this, GlobalContext* globalCtx) { +} + +void BgIkanaShutter_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaShutter* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgIkanaShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { + func_800BDFC0(globalCtx, &D_06000CE8); +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.h b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.h index d689dc823e..db35cf19ca 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.h @@ -5,9 +5,11 @@ struct BgIkanaShutter; +typedef void (*BgIkanaShutterActionFunc)(struct BgIkanaShutter*, GlobalContext*); + typedef struct BgIkanaShutter { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x1C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgIkanaShutterActionFunc actionFunc; } BgIkanaShutter; // size = 0x160 extern const ActorInit Bg_Ikana_Shutter_InitVars; diff --git a/tables/functions.txt b/tables/functions.txt index 41190224bb..98a7695d34 100644 --- a/tables/functions.txt +++ b/tables/functions.txt @@ -15750,7 +15750,7 @@ 0x80BD5530:("BgIkanaRay_UpdateActivated",), 0x80BD556C:("BgIkanaRay_Update",), 0x80BD5590:("BgIkanaRay_Draw",), - 0x80BD5690:("func_80BD5690",), + 0x80BD5690:("BgIkanaShutter_AllSwitchesPressed",), 0x80BD5728:("BgIkanaShutter_Init",), 0x80BD57F4:("BgIkanaShutter_Destroy",), 0x80BD5828:("func_80BD5828",), @@ -15769,8 +15769,8 @@ 0x80BD5B60:("func_80BD5B60",), 0x80BD5BC4:("func_80BD5BC4",), 0x80BD5BD8:("func_80BD5BD8",), - 0x80BD5C64:("func_80BD5C64",), - 0x80BD5C8C:("func_80BD5C8C",), + 0x80BD5C64:("BgIkanaShutter_SetupDoNothing",), + 0x80BD5C8C:("BgIkanaShutter_DoNothing",), 0x80BD5C9C:("BgIkanaShutter_Update",), 0x80BD5CC0:("BgIkanaShutter_Draw",), 0x80BD5E00:("func_80BD5E00",),