summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlejandro Asenjo <96613413+sonicdcer@users.noreply.github.com>2022-07-11 22:26:29 -0300
committerGitHub <noreply@github.com>2022-07-11 21:26:29 -0400
commit2bcb88c05fc8a47d61dd81db79e4e649f9ee3997 (patch)
treecaf0ff2406977423edf3d9a9585e30d2a02e4008 /src
parentc35d699d8a1a0f79ad022b09fecf22af5b65965a (diff)
ovl_Elf_Msg3 decompiled (#865)
* progress * ovl_Elf_Msg3 decompiled * pr review changes * PlayState * if else * chained assignment * pr review changes
Diffstat (limited to 'src')
-rw-r--r--src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c136
-rw-r--r--src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h8
2 files changed, 119 insertions, 25 deletions
diff --git a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c
index b81bb2963..a45d93971 100644
--- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c
+++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c
@@ -5,6 +5,7 @@
*/
#include "z_elf_msg3.h"
+#include "overlays/actors/ovl_En_Elf/z_en_elf.h"
#define FLAGS (ACTOR_FLAG_10)
@@ -14,9 +15,8 @@ void ElfMsg3_Init(Actor* thisx, PlayState* play);
void ElfMsg3_Destroy(Actor* thisx, PlayState* play);
void ElfMsg3_Update(Actor* thisx, PlayState* play);
-void ElfMsg3_SetupAction(ElfMsg3* this, ElfMsg3ActionFunc actionFunc);
+void func_80A2CF7C(ElfMsg3* this, PlayState* play);
-#if 0
const ActorInit Elf_Msg3_InitVars = {
ACTOR_ELF_MSG3,
ACTORCAT_ITEMACTION,
@@ -29,28 +29,118 @@ const ActorInit Elf_Msg3_InitVars = {
(ActorFunc)NULL,
};
-// static InitChainEntry sInitChain[] = {
-static InitChainEntry D_80A2D1E0[] = {
+static InitChainEntry sInitChain[] = {
ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP),
};
-#endif
-
-extern InitChainEntry D_80A2D1E0[];
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/D_80A2D1F0.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/ElfMsg3_SetupAction.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/func_80A2CD1C.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/ElfMsg3_Init.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/ElfMsg3_Destroy.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/func_80A2CF50.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/func_80A2CF7C.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/ElfMsg3_Update.s")
+void ElfMsg3_SetupAction(ElfMsg3* this, ElfMsg3ActionFunc actionFunc) {
+ this->actionFunc = actionFunc;
+}
+
+s32 func_80A2CD1C(ElfMsg3* 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 (ELFMSG3_GET_SWITCH(&this->actor) != 0x7F) {
+ Flags_SetSwitch(play, ELFMSG3_GET_SWITCH(&this->actor));
+ }
+ Actor_MarkForDeath(&this->actor);
+ return true;
+ }
+ if (this->actor.home.rot.y == 0x81) {
+ if (Flags_GetClear(play, this->actor.room)) {
+ if (ELFMSG3_GET_SWITCH(&this->actor) != 0x7F) {
+ Flags_SetSwitch(play, ELFMSG3_GET_SWITCH(&this->actor));
+ }
+ Actor_MarkForDeath(&this->actor);
+ return true;
+ }
+ }
+ if (ELFMSG3_GET_SWITCH(&this->actor) == 0x7F) {
+ return false;
+ }
+ if (Flags_GetSwitch(play, ELFMSG3_GET_SWITCH(&this->actor))) {
+ (void)"共倒れ"; // "Collapse together"
+ Actor_MarkForDeath(&this->actor);
+ return true;
+ }
+ return false;
+}
+
+void ElfMsg3_Init(Actor* thisx, PlayState* play) {
+ ElfMsg3* this = THIS;
+
+ if (!func_80A2CD1C(this, play)) {
+ Actor_ProcessInitChain(&this->actor, sInitChain);
+ 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;
+ }
+ ElfMsg3_SetupAction(this, func_80A2CF7C);
+ this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0;
+ }
+}
+
+void ElfMsg3_Destroy(Actor* thisx, PlayState* play) {
+}
+
+s32 func_80A2CF50(ElfMsg3* this) {
+ if (ELFMSG3_GET_8000(&this->actor) != 0) {
+ return ELFMSG3_GET_FF(&this->actor) + 0x200;
+ } else {
+ return -0x200 - ELFMSG3_GET_FF(&this->actor);
+ }
+}
+
+void func_80A2CF7C(ElfMsg3* this, PlayState* play) {
+ Player* player = GET_PLAYER(play);
+ EnElf* tatl = (EnElf*)player->tatlActor;
+
+ if (((((player->tatlActor != NULL) &&
+ (fabsf(player->actor.world.pos.x - this->actor.world.pos.x) < (100.0f * this->actor.scale.x))) &&
+ (this->actor.world.pos.y <= player->actor.world.pos.y)) &&
+ ((player->actor.world.pos.y - this->actor.world.pos.y) < (100.0f * this->actor.scale.y))) &&
+ (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) < (100.0f * this->actor.scale.z))) {
+ player->tatlTextId = func_80A2CF50(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)) {
+ ActorCutscene_Start(this->actor.cutscene, &this->actor);
+ func_800E0348(play->cameraPtrs[0]);
+ } else {
+ ActorCutscene_SetIntentToPlay(this->actor.cutscene);
+ }
+ }
+ }
+}
+
+void ElfMsg3_Update(Actor* thisx, PlayState* play) {
+ ElfMsg3* this = THIS;
+
+ if (!func_80A2CD1C(this, play)) {
+ if (Actor_ProcessTalkRequest(&this->actor, &play->state)) {
+ if (ELFMSG3_GET_SWITCH(thisx) != 0x7F) {
+ Flags_SetSwitch(play, ELFMSG3_GET_SWITCH(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);
+ }
+ }
+}
diff --git a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h
index 73b285dba..cb71166e8 100644
--- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h
+++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h
@@ -3,13 +3,17 @@
#include "global.h"
+#define ELFMSG3_GET_SWITCH(thisx) (((thisx)->params & 0x7F00) >> 8)
+#define ELFMSG3_GET_FF(thisx) ((thisx)->params & 0xFF)
+#define ELFMSG3_GET_8000(thisx) ((thisx)->params & 0x8000)
+
struct ElfMsg3;
typedef void (*ElfMsg3ActionFunc)(struct ElfMsg3*, PlayState*);
typedef struct ElfMsg3 {
- /* 0x0000 */ Actor actor;
- /* 0x0144 */ ElfMsg3ActionFunc actionFunc;
+ /* 0x000 */ Actor actor;
+ /* 0x144 */ ElfMsg3ActionFunc actionFunc;
} ElfMsg3; // size = 0x148
extern const ActorInit Elf_Msg3_InitVars;