From 9bcd3e2fea3a3a2853a5c7802ea4744681f6338e Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Mon, 11 Jul 2022 23:06:44 -0300 Subject: [PATCH] ovl_Elf_Msg5 decompiled (#882) * ovl_Elf_Msg5 decompiled * pr review changes * pr reviews * ELFMSG5_GET_FF --- spec | 3 +- src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c | 65 +++++++++++++++---- src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h | 7 +- 3 files changed, 59 insertions(+), 16 deletions(-) diff --git a/spec b/spec index 14791c5e80..b5c806fb9c 100644 --- a/spec +++ b/spec @@ -3660,8 +3660,7 @@ beginseg name "ovl_Elf_Msg5" compress include "build/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.o" - include "build/data/ovl_Elf_Msg5/ovl_Elf_Msg5.data.o" - include "build/data/ovl_Elf_Msg5/ovl_Elf_Msg5.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg5/ovl_Elf_Msg5_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c index 1400291631..bcc88ad5d5 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c @@ -15,8 +15,8 @@ void ElfMsg5_Destroy(Actor* thisx, PlayState* play); void ElfMsg5_Update(Actor* thisx, PlayState* play); void func_80AFDB38(ElfMsg5* this, PlayState* play); +s32 func_80AFD990(ElfMsg5* this, PlayState* play); -#if 0 const ActorInit Elf_Msg5_InitVars = { ACTOR_ELF_MSG5, ACTORCAT_BG, @@ -29,24 +29,65 @@ const ActorInit Elf_Msg5_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AFDBD0[] = { +static InitChainEntry sInitChainsInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +s32 func_80AFD990(ElfMsg5* this, PlayState* play) { + if ((this->actor.home.rot.y > 0) && (this->actor.home.rot.y < 0x81) && + (Flags_GetSwitch(play, this->actor.home.rot.y - 1))) { + (void)"共倒れ"; // Collapse together + if (ELFMSG5_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG5_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + if (this->actor.home.rot.y == 0x81) { + if (Flags_GetClear(play, this->actor.room)) { + (void)"共倒れ2"; // Collapse 2 + if (ELFMSG5_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG5_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + } + if (ELFMSG5_GET_SWITCHFLAG(&this->actor) == 0x7F) { + return false; + } + if (Flags_GetSwitch(play, ELFMSG5_GET_SWITCHFLAG(&this->actor))) { + (void)"共倒れ"; // Collapse together + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -extern InitChainEntry D_80AFDBD0[]; +void ElfMsg5_Init(Actor* thisx, PlayState* play) { + ElfMsg5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/D_80AFDBE0.s") + if (!func_80AFD990(this, play)) { + Actor_ProcessInitChain(&this->actor, sInitChainsInitChain); + this->actor.shape.rot.z = 0; + this->actionFunc = func_80AFDB38; + this->actor.home.rot.x = -0x961; + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/func_80AFD990.s") +void ElfMsg5_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/ElfMsg5_Init.s") +void func_80AFDB38(ElfMsg5* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/ElfMsg5_Destroy.s") +void ElfMsg5_Update(Actor* thisx, PlayState* play) { + ElfMsg5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/func_80AFDB38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/ElfMsg5_Update.s") + if ((this->actor.home.rot.y >= 0) || (this->actor.home.rot.y < -0x80) || + (Flags_GetSwitch(play, -this->actor.home.rot.y - 1))) { + this->actionFunc(this, play); + } +} diff --git a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h index be4ff4116c..af25894345 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h @@ -3,13 +3,16 @@ #include "global.h" +#define ELFMSG5_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) +#define ELFMSG5_GET_FF(thisx) ((thisx)->params & 0xFF) + struct ElfMsg5; typedef void (*ElfMsg5ActionFunc)(struct ElfMsg5*, PlayState*); typedef struct ElfMsg5 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ElfMsg5ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ElfMsg5ActionFunc actionFunc; } ElfMsg5; // size = 0x148 extern const ActorInit Elf_Msg5_InitVars;