ovl_Elf_Msg4 decompiled (#884)

* ovl_Elf_Msg4 decompiled

* pr review

* GET_PLAYER

* actorPtr should stay Actor*

* pr review

* SWITCHFLAG

* ELFMSG5_GET_FF

* parenthesis

* pr review

* conflict
This commit is contained in:
Alejandro Asenjo 2022-07-11 23:40:17 -03:00 committed by GitHub
parent a2f78fbc44
commit 6616f542f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 134 additions and 20 deletions

3
spec
View File

@ -3648,8 +3648,7 @@ beginseg
name "ovl_Elf_Msg4"
compress
include "build/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.o"
include "build/data/ovl_Elf_Msg4/ovl_Elf_Msg4.data.o"
include "build/data/ovl_Elf_Msg4/ovl_Elf_Msg4.reloc.o"
include "build/src/overlays/actors/ovl_Elf_Msg4/ovl_Elf_Msg4_reloc.o"
endseg
beginseg

View File

@ -5,6 +5,8 @@
*/
#include "z_elf_msg4.h"
#include "overlays/actors/ovl_En_Elf/z_en_elf.h"
#include "overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h"
#define FLAGS (ACTOR_FLAG_10)
@ -16,8 +18,10 @@ void ElfMsg4_Update(Actor* thisx, PlayState* play);
void func_80AFD668(ElfMsg4* this, PlayState* play);
void func_80AFD770(ElfMsg4* this, PlayState* play);
s32 func_80AFD380(ElfMsg4* this, PlayState* play);
s32 ElfMsg4_GetTextId(ElfMsg4* this);
s32 func_80AFD5E0(ElfMsg4* this);
#if 0
const ActorInit Elf_Msg4_InitVars = {
ACTOR_ELF_MSG4,
ACTORCAT_ITEMACTION,
@ -30,30 +34,137 @@ const ActorInit Elf_Msg4_InitVars = {
(ActorFunc)NULL,
};
// static InitChainEntry sInitChain[] = {
static InitChainEntry D_80AFD8F0[] = {
static InitChainEntry sInitChain[] = {
ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP),
};
#endif
s32 func_80AFD380(ElfMsg4* 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 (ELFMSG4_GET_SWITCHFLAG(&this->actor) != 0x7F) {
Flags_SetSwitch(play, ELFMSG4_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 (ELFMSG4_GET_SWITCHFLAG(&this->actor) != 0x7F) {
Flags_SetSwitch(play, ELFMSG4_GET_SWITCHFLAG(&this->actor));
}
Actor_MarkForDeath(&this->actor);
return true;
}
}
if (ELFMSG4_GET_SWITCHFLAG(&this->actor) == 0x7F) {
return false;
}
if (Flags_GetSwitch(play, ELFMSG4_GET_SWITCHFLAG(&this->actor))) {
(void)"共倒れ"; // "Collapse together"
Actor_MarkForDeath(&this->actor);
return true;
}
return false;
}
extern InitChainEntry D_80AFD8F0[];
void ElfMsg4_Init(Actor* thisx, PlayState* play) {
ElfMsg4* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/D_80AFD900.s")
if (!func_80AFD380(this, play)) {
Actor_ProcessInitChain(&this->actor, sInitChain);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD380.s")
if (ABS_ALT(this->actor.home.rot.x) == 0) {
this->actor.scale.z = 0.4f;
this->actor.scale.x = 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;
}
this->actor.shape.rot.z = 0;
this->actionFunc = func_80AFD770;
this->elfMsg5 = NULL;
this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/ElfMsg4_Init.s")
void ElfMsg4_Destroy(Actor* thisx, PlayState* play) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/ElfMsg4_Destroy.s")
s32 ElfMsg4_GetTextId(ElfMsg4* this) {
if (ELFMSG4_GET_8000(&this->actor) != 0) {
return ELFMSG4_GET_TEXT(&this->actor) + 0x200;
} else {
return -ELFMSG4_GET_TEXT(&this->actor) - 0x200;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD5B4.s")
s32 func_80AFD5E0(ElfMsg4* 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_Msg4/func_80AFD5E0.s")
void func_80AFD668(ElfMsg4* this, PlayState* play) {
Player* player = GET_PLAYER(play);
EnElf* tatl = (EnElf*)player->tatlActor;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD668.s")
if ((player->tatlActor != NULL) && func_80AFD5E0(this)) {
player->tatlTextId = ElfMsg4_GetTextId(this);
ActorCutscene_SetIntentToPlay(0x7C);
tatl->elfMsg = this->elfMsg5;
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((s16)this->actor.cutscene);
} else if (ActorCutscene_GetCanPlayNext((s16)this->actor.cutscene)) {
ActorCutscene_Start(this->actor.cutscene, &this->actor);
func_800E0348(play->cameraPtrs[0]);
} else {
ActorCutscene_SetIntentToPlay((s16)this->actor.cutscene);
}
}
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD770.s")
void func_80AFD770(ElfMsg4* this, PlayState* play) {
Actor* bgActor = play->actorCtx.actorLists[ACTORCAT_BG].first;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/ElfMsg4_Update.s")
while (bgActor != NULL) {
if ((bgActor->id != ACTOR_ELF_MSG5) || (ELFMSG4_GET_TEXT(&this->actor) != ELFMSG5_GET_FF(bgActor)) ||
(this->actor.cutscene != bgActor->cutscene)) {
bgActor = bgActor->next;
} else {
this->elfMsg5 = bgActor;
this->actionFunc = func_80AFD668;
bgActor = bgActor->next;
}
}
}
void ElfMsg4_Update(Actor* thisx, PlayState* play) {
Actor* bgActor;
ElfMsg4* this = THIS;
if (!func_80AFD380(this, play)) {
bgActor = this->elfMsg5;
if ((bgActor != NULL) && (bgActor->update == NULL)) {
Actor_MarkForDeath(&this->actor);
} else if ((bgActor != NULL) && (Actor_ProcessTalkRequest(bgActor, &play->state))) {
if (ELFMSG4_GET_SWITCHFLAG(thisx) != 0x7F) {
Flags_SetSwitch(play, ELFMSG4_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,14 +3,18 @@
#include "global.h"
#define ELFMSG4_GET_SWITCHFLAG(thisx) (((thisx)->params & 0x7F00) >> 8)
#define ELFMSG4_GET_8000(thisx) ((thisx)->params & 0x8000)
#define ELFMSG4_GET_TEXT(thisx) ((thisx)->params & 0xFF)
struct ElfMsg4;
typedef void (*ElfMsg4ActionFunc)(struct ElfMsg4*, PlayState*);
typedef struct ElfMsg4 {
/* 0x0000 */ Actor actor;
/* 0x0144 */ char unk_144[0x4];
/* 0x0148 */ ElfMsg4ActionFunc actionFunc;
/* 0x000 */ Actor actor;
/* 0x144 */ Actor* elfMsg5;
/* 0x148 */ ElfMsg4ActionFunc actionFunc;
} ElfMsg4; // size = 0x14C
extern const ActorInit Elf_Msg4_InitVars;

View File

@ -12791,7 +12791,7 @@
0x80AFD380:("func_80AFD380",),
0x80AFD4B8:("ElfMsg4_Init",),
0x80AFD5A4:("ElfMsg4_Destroy",),
0x80AFD5B4:("func_80AFD5B4",),
0x80AFD5B4:("ElfMsg4_GetTextId",),
0x80AFD5E0:("func_80AFD5E0",),
0x80AFD668:("func_80AFD668",),
0x80AFD770:("func_80AFD770",),