ovl_Elf_Msg decompiled (#880)

* ovl_Elf_Msg decompiled

* pr review

* ELFMSG_GET_SWITCHFLAG
This commit is contained in:
Alejandro Asenjo 2022-07-11 22:59:29 -03:00 committed by GitHub
parent d352761bb6
commit 3ab8b60a12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 111 additions and 18 deletions

3
spec
View File

@ -1397,8 +1397,7 @@ beginseg
name "ovl_Elf_Msg"
compress
include "build/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.o"
include "build/data/ovl_Elf_Msg/ovl_Elf_Msg.data.o"
include "build/data/ovl_Elf_Msg/ovl_Elf_Msg.reloc.o"
include "build/src/overlays/actors/ovl_Elf_Msg/ovl_Elf_Msg_reloc.o"
endseg
beginseg

View File

@ -5,6 +5,7 @@
*/
#include "z_elf_msg.h"
#include "overlays/actors/ovl_En_Elf/z_en_elf.h"
#define FLAGS (ACTOR_FLAG_10)
@ -15,8 +16,8 @@ void ElfMsg_Destroy(Actor* thisx, PlayState* play);
void ElfMsg_Update(Actor* thisx, PlayState* play);
void ElfMsg_SetupAction(ElfMsg* this, ElfMsgActionFunc actionFunc);
void func_8092E284(ElfMsg* this, PlayState* play);
#if 0
const ActorInit Elf_Msg_InitVars = {
ACTOR_ELF_MSG,
ACTORCAT_ITEMACTION,
@ -29,30 +30,119 @@ const ActorInit Elf_Msg_InitVars = {
(ActorFunc)NULL,
};
// static InitChainEntry sInitChain[] = {
static InitChainEntry D_8092E470[] = {
static InitChainEntry sInitChain[] = {
ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP),
};
#endif
void ElfMsg_SetupAction(ElfMsg* this, ElfMsgActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
extern InitChainEntry D_8092E470[];
s32 func_8092DF9C(ElfMsg* 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 (ELFMSG_GET_SWITCHFLAG(&this->actor) != 0x7F) {
Flags_SetSwitch(play, ELFMSG_GET_SWITCHFLAG(&this->actor));
}
Actor_MarkForDeath(&this->actor);
return true;
}
if (this->actor.home.rot.y == 0x81) {
if (Flags_GetClear(play, this->actor.room)) {
if (ELFMSG_GET_SWITCHFLAG(&this->actor) != 0x7F) {
Flags_SetSwitch(play, ELFMSG_GET_SWITCHFLAG(&this->actor));
}
Actor_MarkForDeath(&this->actor);
return true;
}
}
if (ELFMSG_GET_SWITCHFLAG(&this->actor) == 0x7F) {
return false;
}
if (Flags_GetSwitch(play, ELFMSG_GET_SWITCHFLAG(&this->actor))) {
(void)"共倒れ"; // "Collapse together"
Actor_MarkForDeath(&this->actor);
return true;
}
return false;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/D_8092E480.s")
void ElfMsg_Init(Actor* thisx, PlayState* play) {
ElfMsg* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_SetupAction.s")
if (!func_8092DF9C(this, play)) {
Actor_ProcessInitChain(&this->actor, sInitChain);
if (ABS_ALT(this->actor.home.rot.x) == 0) {
this->actor.scale.x = this->actor.scale.z = 0.4f;
} else {
this->actor.scale.x = this->actor.scale.z = ABS_ALT(this->actor.home.rot.x) * 0.04f;
}
if (this->actor.home.rot.z == 0) {
this->actor.scale.y = 0.4f;
} else {
this->actor.scale.y = this->actor.home.rot.z * 0.04f;
}
ElfMsg_SetupAction(this, func_8092E284);
this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092DF9C.s")
void ElfMsg_Destroy(Actor* thisx, PlayState* play) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_Init.s")
s32 func_8092E1D0(ElfMsg* this) {
if (ELFMSG_GET_8000(&this->actor) != 0) {
return ELFMSG_GET_FF(&this->actor) + 0x200;
} else {
return -0x200 - ELFMSG_GET_FF(&this->actor);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_Destroy.s")
s32 func_8092E1FC(ElfMsg* this) {
return (this->actor.xzDistToPlayer < (100.0f * this->actor.scale.x)) && (this->actor.playerHeightRel >= 0.0f) &&
(this->actor.playerHeightRel < (100.0f * this->actor.scale.y));
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092E1D0.s")
void func_8092E284(ElfMsg* this, PlayState* play) {
Player* player = GET_PLAYER(play);
EnElf* tatl = (EnElf*)player->tatlActor;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092E1FC.s")
if ((player->tatlActor != NULL) && ((func_8092E1FC(this)))) {
player->tatlTextId = func_8092E1D0(this);
ActorCutscene_SetIntentToPlay(0x7C);
tatl->elfMsg = &this->actor;
if (this->actor.cutscene == -1) {
this->actor.cutscene = 0x7C;
}
if ((player->tatlTextId < 0) && (this->actor.home.rot.x < 0)) {
if (ActorCutscene_GetCurrentIndex() == 0x7D) {
ActorCutscene_Stop(0x7D);
ActorCutscene_SetIntentToPlay(this->actor.cutscene);
} else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) {
this->actor.home.rot.x = 0;
ActorCutscene_Start(this->actor.cutscene, &this->actor);
func_800E0348(play->cameraPtrs[0]);
} else {
ActorCutscene_SetIntentToPlay(this->actor.cutscene);
}
}
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092E284.s")
void ElfMsg_Update(Actor* thisx, PlayState* play) {
ElfMsg* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_Update.s")
if (func_8092DF9C(this, play) == 0) {
if (Actor_ProcessTalkRequest(&this->actor, &play->state)) {
if (ELFMSG_GET_SWITCHFLAG(thisx) != 0x7F) {
Flags_SetSwitch(play, ELFMSG_GET_SWITCHFLAG(thisx));
}
Actor_MarkForDeath(&this->actor);
} else if ((this->actor.home.rot.y >= 0) || (this->actor.home.rot.y < -0x80) ||
(Flags_GetSwitch(play, -1 - this->actor.home.rot.y))) {
this->actionFunc(this, play);
}
}
}

View File

@ -3,13 +3,17 @@
#include "global.h"
#define ELFMSG_GET_FF(thisx) ((thisx)->params & 0xFF)
#define ELFMSG_GET_SWITCHFLAG(thisx) (((thisx)->params & 0x7F00) >> 8)
#define ELFMSG_GET_8000(thisx) ((thisx)->params & 0x8000)
struct ElfMsg;
typedef void (*ElfMsgActionFunc)(struct ElfMsg*, PlayState*);
typedef struct ElfMsg {
/* 0x0000 */ Actor actor;
/* 0x0144 */ ElfMsgActionFunc actionFunc;
/* 0x000 */ Actor actor;
/* 0x144 */ ElfMsgActionFunc actionFunc;
} ElfMsg; // size = 0x148
extern const ActorInit Elf_Msg_InitVars;