From 20f7e2199ac4c53095f3bc60ec30958f1bfb5e41 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 28 May 2023 12:19:53 -0600 Subject: [PATCH] ovl_Bg_Tobira01 OK and documented (#1247) * Decompiled source of tobira01 * Documented and formatted in prep for merge request * Added spacing, renamed unused back to what it was, added definitions, changed 1.6666 to division * Ran weekeventreg script, added additional spaces throughout the file, removed the macros for 0 and 60, updated some missed this casts, renamed spot11 out names * Converted gSaveContext calls over to CLEAR_WEEKEVENTREG calls from review feedback * Reformatted some files * More review feedback * Removed _tex --- assets/xml/objects/object_spot11_obj.xml | 18 ++--- spec | 3 +- .../actors/ovl_Bg_Breakwall/z_bg_breakwall.c | 3 +- .../actors/ovl_Bg_Tobira01/z_bg_tobira01.c | 79 +++++++++++++++++-- .../actors/ovl_Bg_Tobira01/z_bg_tobira01.h | 11 ++- undefined_syms.txt | 4 - 6 files changed, 92 insertions(+), 26 deletions(-) diff --git a/assets/xml/objects/object_spot11_obj.xml b/assets/xml/objects/object_spot11_obj.xml index c049bb3379..58d146203c 100644 --- a/assets/xml/objects/object_spot11_obj.xml +++ b/assets/xml/objects/object_spot11_obj.xml @@ -1,13 +1,13 @@  - - - - - - - - - + + + + + + + + + diff --git a/spec b/spec index 4b8481a730..81f25e3745 100644 --- a/spec +++ b/spec @@ -3589,8 +3589,7 @@ beginseg name "ovl_Bg_Tobira01" compress include "build/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.o" - include "build/data/ovl_Bg_Tobira01/ovl_Bg_Tobira01.data.o" - include "build/data/ovl_Bg_Tobira01/ovl_Bg_Tobira01.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Tobira01/ovl_Bg_Tobira01_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c index b2e59a51b6..be94135675 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -84,8 +84,7 @@ BgBreakwallStruct D_808B8140[] = { func_808B77D0, NULL }, { OBJECT_IKNINSIDE_OBJ, NULL, object_ikninside_obj_DL_00AEC0, object_ikninside_obj_Matanimheader_00BCB8, NULL, func_808B751C, func_808B7A10, func_808B7D34 }, - { OBJECT_SPOT11_OBJ, object_spot11_obj_DL_0013F0, NULL, NULL, &object_spot11_obj_Colheader_001EB8, func_808B736C, - func_808B77D0, NULL }, + { OBJECT_SPOT11_OBJ, gWoodStepDL, NULL, NULL, &gWoodStepCol, func_808B736C, func_808B77D0, NULL }, }; static InitChainEntry sInitChain[] = { diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c index 17722bda21..2eb95f6bb3 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -16,7 +16,6 @@ void BgTobira01_Destroy(Actor* thisx, PlayState* play); void BgTobira01_Update(Actor* thisx, PlayState* play); void BgTobira01_Draw(Actor* thisx, PlayState* play); -/* const ActorInit Bg_Tobira01_InitVars = { ACTOR_BG_TOBIRA01, ACTORCAT_PROP, @@ -28,14 +27,80 @@ const ActorInit Bg_Tobira01_InitVars = { (ActorFunc)BgTobira01_Update, (ActorFunc)BgTobira01_Draw, }; -*/ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Tobira01/func_80B12430.s") +void BgTobira01_Action(BgTobira01* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s16 csId = this->dyna.actor.csId; + s16 prevPosYTick; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Tobira01/BgTobira01_Init.s") + if (this->cutsceneRequested) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + } else if (CutsceneManager_IsNext(csId)) { + CutsceneManager_StartWithPlayerCs(csId, &this->dyna.actor); + SET_WEEKEVENTREG(WEEKEVENTREG_88_40); + this->cutsceneRequested = false; + } else { + CutsceneManager_Queue(csId); + } + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_88_40) && (this->posYTick == 0) && + (play->actorCtx.playerImpact.timer != 0) && + (play->actorCtx.playerImpact.type == PLAYER_IMPACT_GORON_GROUND_POUND) && + (SurfaceType_GetSceneExitIndex(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId) == 6)) { + this->cutsceneRequested = true; + this->unk16C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Tobira01/BgTobira01_Destroy.s") + prevPosYTick = this->posYTick; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_88_40)) { + this->posYTick++; + } else { + this->posYTick--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Tobira01/BgTobira01_Update.s") + this->posYTick = CLAMP(this->posYTick, 0, 60); + if (prevPosYTick != this->posYTick) { + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); + this->dyna.actor.world.pos.y = this->posY = (this->posYTick * (5.0f / 3.0f)) + this->dyna.actor.home.pos.y; + this->timer = 180; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Tobira01/BgTobira01_Draw.s") + if (!(player->stateFlags1 & PLAYER_STATE1_40) && CHECK_WEEKEVENTREG(WEEKEVENTREG_88_40) && + (DECR(this->timer) == 0)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_88_40); + } +} + +void BgTobira01_Init(Actor* thisx, PlayState* play) { + BgTobira01* this = THIS; + + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); + DynaPolyActor_LoadMesh(play, &this->dyna, &gGoronDoorCol); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_88_40); + Actor_SetScale(&this->dyna.actor, 1.0f); + this->timer = gSaveContext.save.isNight; + this->posYTick = 0; + this->actionFunc = BgTobira01_Action; +} + +void BgTobira01_Destroy(Actor* thisx, PlayState* play) { + BgTobira01* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} + +void BgTobira01_Update(Actor* thisx, PlayState* play) { + BgTobira01* this = THIS; + + this->actionFunc(this, play); +} + +void BgTobira01_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGoronDoorDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.h b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.h index 9ddd0233d2..b53c2302e3 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.h +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.h @@ -5,9 +5,16 @@ struct BgTobira01; +typedef void (*BgTobira01ActionFunc)(struct BgTobira01*, PlayState*); + typedef struct BgTobira01 { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x2C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgTobira01ActionFunc actionFunc; + /* 0x160 */ s16 posYTick; + /* 0x162 */ s16 timer; + /* 0x164 */ f32 posY; + /* 0x168 */ s32 cutsceneRequested; + /* 0x16C */ s32 unk16C; } BgTobira01; // size = 0x170 #endif // Z_BG_TOBIRA01_H diff --git a/undefined_syms.txt b/undefined_syms.txt index 1e09ceaab0..2187673fcd 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -586,10 +586,6 @@ D_060005F8 = 0x060005F8; D_06000A20 = 0x06000A20; D_06000040 = 0x06000040; -/* ovl_Bg_Tobira01 */ -D_060011C0 = 0x060011C0; -D_06000088 = 0x06000088; - // ovl_Boss_01 D_06000C44 = 0x06000C44;