summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlejandro Asenjo <96613413+sonicdcer@users.noreply.github.com>2022-07-11 22:59:29 -0300
committerGitHub <noreply@github.com>2022-07-11 21:59:29 -0400
commit3ab8b60a126038cd1475c53d4c8ca117f771cc52 (patch)
treeb25a0c97417ff7b9c9d63320850538ec4a8e960d /src
parentd352761bb62ab2a43dde168f55510ddb83f0c018 (diff)
ovl_Elf_Msg decompiled (#880)
* ovl_Elf_Msg decompiled * pr review * ELFMSG_GET_SWITCHFLAG
Diffstat (limited to 'src')
-rw-r--r--src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c138
-rw-r--r--src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h8
2 files changed, 120 insertions, 26 deletions
diff --git a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c
index 5cd49cbb8..2dc6f934b 100644
--- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c
+++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c
@@ -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
-
-extern InitChainEntry D_8092E470[];
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/D_8092E480.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_SetupAction.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092DF9C.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_Init.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_Destroy.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092E1D0.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092E1FC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092E284.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_Update.s")
+void ElfMsg_SetupAction(ElfMsg* this, ElfMsgActionFunc actionFunc) {
+ this->actionFunc = actionFunc;
+}
+
+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;
+}
+
+void ElfMsg_Init(Actor* thisx, PlayState* play) {
+ ElfMsg* this = THIS;
+
+ 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;
+ }
+}
+
+void ElfMsg_Destroy(Actor* thisx, PlayState* play) {
+}
+
+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);
+ }
+}
+
+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));
+}
+
+void func_8092E284(ElfMsg* this, PlayState* play) {
+ Player* player = GET_PLAYER(play);
+ EnElf* tatl = (EnElf*)player->tatlActor;
+
+ 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);
+ }
+ }
+ }
+}
+
+void ElfMsg_Update(Actor* thisx, PlayState* play) {
+ ElfMsg* this = THIS;
+
+ 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);
+ }
+ }
+}
diff --git a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h
index dd9accf93..f335f0158 100644
--- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h
+++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h
@@ -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;