ovl_Elf_Msg2 decompiled (#881)

* ovl_Elf_Msg2 decompiled

* pr review changes

* ELFMSG2_GET_SWITCHFLAG
This commit is contained in:
Alejandro Asenjo 2022-07-11 23:03:04 -03:00 committed by GitHub
parent 3ab8b60a12
commit 6dec68464f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 110 additions and 21 deletions

3
spec
View File

@ -1688,8 +1688,7 @@ beginseg
name "ovl_Elf_Msg2"
compress
include "build/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.o"
include "build/data/ovl_Elf_Msg2/ovl_Elf_Msg2.data.o"
include "build/data/ovl_Elf_Msg2/ovl_Elf_Msg2.reloc.o"
include "build/src/overlays/actors/ovl_Elf_Msg2/ovl_Elf_Msg2_reloc.o"
endseg
beginseg

View File

@ -14,11 +14,10 @@ void ElfMsg2_Init(Actor* thisx, PlayState* play);
void ElfMsg2_Destroy(Actor* thisx, PlayState* play);
void ElfMsg2_Update(Actor* thisx, PlayState* play);
s32 func_8096EE50(ElfMsg2* this);
void func_8096EF98(ElfMsg2* this, PlayState* play);
void func_8096EFD0(ElfMsg2* this, PlayState* play);
void ElfMsg2_SetupAction(ElfMsg2* this, ElfMsg2ActionFunc actionFunc);
#if 0
const ActorInit Elf_Msg2_InitVars = {
ACTOR_ELF_MSG2,
ACTORCAT_BG,
@ -31,32 +30,120 @@ const ActorInit Elf_Msg2_InitVars = {
(ActorFunc)NULL,
};
// static InitChainEntry sInitChain[] = {
static InitChainEntry D_8096F0B0[] = {
static InitChainEntry sInitChain[] = {
ICHAIN_VEC3F_DIV1000(scale, 200, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP),
};
#endif
void ElfMsg2_SetupAction(ElfMsg2* this, ElfMsg2ActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
extern InitChainEntry D_8096F0B0[];
s32 func_8096EC4C(ElfMsg2* 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 (ELFMSG2_GET_SWITCHFLAG(&this->actor) != 0x7F) {
Flags_SetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor));
}
Actor_MarkForDeath(&this->actor);
return true;
}
if (this->actor.home.rot.y == 129) {
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/D_8096F0C0.s")
if (Flags_GetClear(play, this->actor.room)) {
(void)"共倒れ2"; // "Collapse 2"
if (ELFMSG2_GET_SWITCHFLAG(&this->actor) != 0x7F) {
Flags_SetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor));
}
Actor_MarkForDeath(&this->actor);
return true;
}
}
if (ELFMSG2_GET_SWITCHFLAG(&this->actor) == 0x7F) {
return false;
}
if (Flags_GetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor))) {
(void)"共倒れ"; // "Collapse together"
Actor_MarkForDeath(&this->actor);
return true;
}
return false;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/ElfMsg2_SetupAction.s")
void ElfMsg2_Init(Actor* thisx, PlayState* play) {
ElfMsg2* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EC4C.s")
if (!func_8096EC4C(this, play)) {
if ((this->actor.home.rot.x > 0) && (this->actor.home.rot.x < 8)) {
this->actor.targetMode = this->actor.home.rot.x - 1;
}
Actor_ProcessInitChain(&this->actor, sInitChain);
if (this->actor.home.rot.y < 0) {
ElfMsg2_SetupAction(this, func_8096EFD0);
} else {
ElfMsg2_SetupAction(this, func_8096EF98);
this->actor.flags |= (ACTOR_FLAG_40000 | ACTOR_FLAG_1);
this->actor.textId = func_8096EE50(this);
}
this->actor.shape.rot.z = 0;
this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/ElfMsg2_Init.s")
void ElfMsg2_Destroy(Actor* thisx, PlayState* play) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/ElfMsg2_Destroy.s")
s32 func_8096EE50(ElfMsg2* this) {
return ELFMSG2_GET_FF(&this->actor) + 0x200;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EE50.s")
void func_8096EE64(ElfMsg2* this, PlayState* play) {
if (Actor_TextboxIsClosing(&this->actor, play)) {
if (this->actor.cutscene != -1) {
if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) {
ActorCutscene_Stop(this->actor.cutscene);
}
}
if (this->actor.home.rot.z != 1) {
Actor_MarkForDeath(&this->actor);
if (ELFMSG2_GET_SWITCHFLAG(&this->actor) != 0x7F) {
Flags_SetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor));
}
} else {
ElfMsg2_SetupAction(this, func_8096EF98);
}
} else if ((this->actor.cutscene != -1) && (ActorCutscene_GetCurrentIndex() != this->actor.cutscene)) {
if (ActorCutscene_GetCurrentIndex() == 0x7C) {
ActorCutscene_Stop(0x7C);
ActorCutscene_SetIntentToPlay(this->actor.cutscene);
} else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) {
ActorCutscene_Start(this->actor.cutscene, &this->actor);
} else {
ActorCutscene_SetIntentToPlay(this->actor.cutscene);
}
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EE64.s")
void func_8096EF98(ElfMsg2* this, PlayState* play) {
if (Actor_ProcessTalkRequest(&this->actor, &play->state)) {
ElfMsg2_SetupAction(this, func_8096EE64);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EF98.s")
void func_8096EFD0(ElfMsg2* this, PlayState* play) {
if ((this->actor.home.rot.y < 0) && (this->actor.home.rot.y >= -0x80) &&
(Flags_GetSwitch(play, -this->actor.home.rot.y - 1))) {
ElfMsg2_SetupAction(this, func_8096EF98);
this->actor.flags |= (ACTOR_FLAG_40000 | ACTOR_FLAG_1);
this->actor.textId = func_8096EE50(this);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EFD0.s")
void ElfMsg2_Update(Actor* thisx, PlayState* play) {
ElfMsg2* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/ElfMsg2_Update.s")
if (!func_8096EC4C(this, play)) {
this->actionFunc(this, play);
}
}

View File

@ -3,13 +3,16 @@
#include "global.h"
#define ELFMSG2_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F)
#define ELFMSG2_GET_FF(thisx) ((thisx)->params & 0xFF)
struct ElfMsg2;
typedef void (*ElfMsg2ActionFunc)(struct ElfMsg2*, PlayState*);
typedef struct ElfMsg2 {
/* 0x0000 */ Actor actor;
/* 0x0144 */ ElfMsg2ActionFunc actionFunc;
/* 0x000 */ Actor actor;
/* 0x144 */ ElfMsg2ActionFunc actionFunc;
} ElfMsg2; // size = 0x148
extern const ActorInit Elf_Msg2_InitVars;