From ffb90132c66e39ac0f77dd3d5a4d176a608ef488 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Mon, 11 Jul 2022 22:19:45 -0300 Subject: [PATCH] ovl_Obj_Demo decompiled (#860) * ovl_Obj_Demo decompiled * pr review * pr review changes * Empty-Commit * pr review --- spec | 3 +- src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c | 88 +++++++++++++++++-- src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h | 10 ++- 3 files changed, 89 insertions(+), 12 deletions(-) diff --git a/spec b/spec index 2d6b89ea9e..a62e3ffe6c 100644 --- a/spec +++ b/spec @@ -1996,8 +1996,7 @@ beginseg name "ovl_Obj_Demo" compress include "build/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.o" - include "build/data/ovl_Obj_Demo/ovl_Obj_Demo.data.o" - include "build/data/ovl_Obj_Demo/ovl_Obj_Demo.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Demo/ovl_Obj_Demo_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c index 387ee5dbe3..ec5796b5a7 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -15,8 +15,8 @@ void ObjDemo_Update(Actor* thisx, PlayState* play); void func_80983678(ObjDemo* this, PlayState* play); void func_80983704(ObjDemo* this, PlayState* play); +void func_80983634(PlayState* play); -#if 0 const ActorInit Obj_Demo_InitVars = { ACTOR_OBJ_DEMO, ACTORCAT_PROP, @@ -29,14 +29,88 @@ const ActorInit Obj_Demo_InitVars = { (ActorFunc)NULL, }; -#endif +void ObjDemo_Init(Actor* thisx, PlayState* play) { + ObjDemo* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/ObjDemo_Init.s") + thisx->params = OBJDEMO_GET_FF(thisx); + if ((thisx->params != OBJDEMO_FF_FF) && (Flags_GetSwitch(play, thisx->params))) { + Actor_MarkForDeath(&this->actor); + return; + } + if (thisx->shape.rot.x < 0) { + this->unk_148 = 1; + thisx->shape.rot.x = -thisx->shape.rot.x; + } + if (thisx->shape.rot.x == 0) { + this->xzRange = 80.0f; + } else { + this->xzRange = thisx->shape.rot.x * 4.0f; + thisx->shape.rot.x = 0; + thisx->world.rot.x = 0; + } + if (thisx->shape.rot.z == 0) { + this->yRange = 60.0f; + } else { + this->yRange = thisx->shape.rot.z * 4.0f; + thisx->shape.rot.z = 0; + thisx->world.rot.z = 0; + } + func_80983634(play); + this->actionFunc = func_80983678; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/func_80983634.s") +void func_80983634(PlayState* play) { + if ((play->sceneNum == SCENE_CASTLE) && (func_801A8A50(0) == NA_BGM_IKANA_CASTLE)) { + Audio_QueueSeqCmd(0x100100FF); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/func_80983678.s") +void func_80983678(ObjDemo* this, PlayState* play) { + func_80983634(play); + if ((this->actor.xzDistToPlayer < this->xzRange) && (fabsf(this->actor.playerHeightRel) < this->yRange)) { + if (this->unk_148 == 1) { + ActorCutscene_Stop(0x7D); + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_80983704; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/func_80983704.s") +void func_80983704(ObjDemo* this, PlayState* play) { + if ((this->unk_148 == 1) && (ActorCutscene_GetCurrentIndex() == 0x7D)) { + ActorCutscene_Stop(0x7D); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (this->unk_148 == 1) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + func_800E0348(play->cameraPtrs[0]); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } + if (play->sceneNum == SCENE_CASTLE) { + Audio_QueueSeqCmd(NA_BGM_IKANA_CASTLE | 0x8000); + } + this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + if (this->actor.cutscene == -1) { + if (this->actor.params != 0xFF) { + Flags_SetSwitch(play, this->actor.params); + } + Actor_MarkForDeath(&this->actor); + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + func_80983634(play); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/ObjDemo_Update.s") +void ObjDemo_Update(Actor* thisx, PlayState* play) { + ObjDemo* this = THIS; + + if ((this->actor.params != 0xFF) && Flags_GetSwitch(play, this->actor.params)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc(this, play); +} diff --git a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h index 62f105c913..be774bf07a 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h @@ -3,14 +3,18 @@ #include "global.h" +#define OBJDEMO_GET_FF(thisx) ((thisx)->params & 0xFF) +#define OBJDEMO_FF_FF 0xFF struct ObjDemo; typedef void (*ObjDemoActionFunc)(struct ObjDemo*, PlayState*); typedef struct ObjDemo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjDemoActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xC]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjDemoActionFunc actionFunc; + /* 0x148 */ s32 unk_148; + /* 0x14C */ f32 xzRange; + /* 0x150 */ f32 yRange; } ObjDemo; // size = 0x154 extern const ActorInit Obj_Demo_InitVars;