From fcc87b3ae29c0dca3950ee0920cf0b298f5a73a8 Mon Sep 17 00:00:00 2001 From: Zach Banks Date: Tue, 4 May 2021 22:58:47 -0400 Subject: [PATCH] ovl_Dm_Ravine (Link Riding Through Lost Woods Cutscene - Tree Trunk) (#120) * ovl_Dm_Ravine OK (Link Riding Through Lost Woods Cutscene - Tree Trunk) * ovl_Dm_Ravine: respond to PR comments * Rename/retype DmRavine_Action -> DmRavine_DoNothing * ovl_Dm_Ravine: incorporate PR feedback from kyleburnette * ovl_Dm_Ravine: rename fields; use enum for state --- linker_scripts/code_script.txt | 4 +- .../actors/ovl_Dm_Ravine/z_dm_ravine.c | 61 ++++++++++++++++--- .../actors/ovl_Dm_Ravine/z_dm_ravine.h | 12 +++- tables/functions.txt | 2 +- 4 files changed, 67 insertions(+), 12 deletions(-) diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index 23405faa93..e4269351a1 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -4345,9 +4345,9 @@ SECTIONS ovl_Dm_Ravine : AT(RomLocation) { build/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.o(.text) - build/asm/overlays/ovl_Dm_Ravine_data.o(.data) + build/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.o(.data) build/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.o(.rodata) - build/asm/overlays/ovl_Dm_Ravine_rodata.o(.rodata) + build/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine_overlay.o(.ovl) } SegmentEnd = .; SegmentSize = SegmentEnd - SegmentStart; diff --git a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c index 1220018347..abea0ce8b1 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_ravine.c + * Overlay: ovl_Dm_Ravine + * Description: Lost Woods Cutscene - Tree Trunk + */ + #include "z_dm_ravine.h" #define FLAGS 0x00000030 @@ -6,10 +12,10 @@ void DmRavine_Init(Actor* thisx, GlobalContext* globalCtx); void DmRavine_Destroy(Actor* thisx, GlobalContext* globalCtx); +void DmRavine_DoNothing(DmRavine* this, GlobalContext* globalCtx); void DmRavine_Update(Actor* thisx, GlobalContext* globalCtx); void DmRavine_Draw(Actor* thisx, GlobalContext* globalCtx); -/* const ActorInit Dm_Ravine_InitVars = { ACTOR_DM_RAVINE, ACTORCAT_ITEMACTION, @@ -19,16 +25,55 @@ const ActorInit Dm_Ravine_InitVars = { (ActorFunc)DmRavine_Init, (ActorFunc)DmRavine_Destroy, (ActorFunc)DmRavine_Update, - (ActorFunc)DmRavine_Draw + (ActorFunc)DmRavine_Draw, }; -*/ -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Ravine_0x80A2E7A0/DmRavine_Init.asm") +void DmRavine_Init(Actor* thisx, GlobalContext* globalCtx) { + DmRavine* this = THIS; + u8 flag = gSaveContext.perm.weekEventReg[0]; + if (((flag & 0x10) | cREG(0)) != 0) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Ravine_0x80A2E7A0/DmRavine_Destroy.asm") + this->isActive = false; + globalCtx->roomContext.unk7A[0] = 1; + globalCtx->roomContext.unk7A[1] = 0; + this->state = 0; + Actor_SetScale(&this->actor, 1.0f); + this->actionFunc = DmRavine_DoNothing; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Ravine_0x80A2E7A0/func_80A2E838.asm") +void DmRavine_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Ravine_0x80A2E7A0/DmRavine_Update.asm") +void DmRavine_DoNothing(DmRavine* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Ravine_0x80A2E7A0/DmRavine_Draw.asm") +void DmRavine_Update(Actor* thisx, GlobalContext* globalCtx) { + DmRavine* this = THIS; + RoomContext* roomCtx; + + switch ((DmRavineState) this->state) { + case DM_RAVINE_STATE_INITIALIZED: + return; + case DM_RAVINE_STATE_ACTIVE: + this->isActive = true; + globalCtx->roomContext.unk7A[1]++; + if (globalCtx->roomContext.unk7A[1] > 254) { + globalCtx->roomContext.unk7A[1] = 254; + if (globalCtx->csCtx.frames > 700) { + globalCtx->roomContext.unk7A[1] = 255; + globalCtx->roomContext.unk7A[0] = 0; + this->state++; // -> DM_RAVINE_STATE_PENDING_DEATH + } + } + break; + case DM_RAVINE_STATE_PENDING_DEATH: + Actor_MarkForDeath(&this->actor); + break; + } +} + +void DmRavine_Draw(Actor* thisx, GlobalContext* globalCtx) { +} diff --git a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.h b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.h index 66b86ac17c..e3ab85aa23 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.h +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.h @@ -5,9 +5,19 @@ struct DmRavine; +typedef void (*DmRavineActionFunc)(struct DmRavine*, GlobalContext*); + +typedef enum { + /* 0 */ DM_RAVINE_STATE_INITIALIZED, + /* 1 */ DM_RAVINE_STATE_ACTIVE, + /* 2 */ DM_RAVINE_STATE_PENDING_DEATH, +} DmRavineState; + typedef struct DmRavine { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x8]; + /* 0x144 */ DmRavineActionFunc actionFunc; + /* 0x148 */ u8 state; + /* 0x149 */ u8 isActive; } DmRavine; // size = 0x14C extern const ActorInit Dm_Ravine_InitVars; diff --git a/tables/functions.txt b/tables/functions.txt index 2bef920128..dd9266530e 100644 --- a/tables/functions.txt +++ b/tables/functions.txt @@ -10123,7 +10123,7 @@ 0x80A2E268:("func_80A2E268",), 0x80A2E7A0:("DmRavine_Init",), 0x80A2E828:("DmRavine_Destroy",), - 0x80A2E838:("func_80A2E838",), + 0x80A2E838:("DmRavine_DoNothing",), 0x80A2E848:("DmRavine_Update",), 0x80A2E8F4:("DmRavine_Draw",), 0x80A2E960:("func_80A2E960",),