summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorquaantuum <96855062+quaantuum@users.noreply.github.com>2022-03-27 08:14:55 -0700
committerGitHub <noreply@github.com>2022-03-27 12:14:55 -0300
commit95c6ddbcc89992b527f270e80d1e2397b146a2ff (patch)
tree0ecc113902e162b468d4894cb6a848f31fb9e484 /src
parent4f3202fd7e5313ab7b777eb3be162283fe5ea142 (diff)
Decompile obj_wturn (#564)
* Decompile obj_wturn * Format * Rename struct member * Make suggestions * Format * Fix warning Co-authored-by: Elliptic Ellipsis <elliptic.ellipsis@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c136
-rw-r--r--src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h3
2 files changed, 107 insertions, 32 deletions
diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c
index 225587cdc..34d82523f 100644
--- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c
+++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c
@@ -13,42 +13,116 @@
void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx);
void ObjWturn_Update(Actor* thisx, GlobalContext* globalCtx);
+void func_808A7954(ObjWturn* this);
void func_808A7968(ObjWturn* this, GlobalContext* globalCtx);
+void func_808A7A24(ObjWturn* this);
void func_808A7A5C(ObjWturn* this, GlobalContext* globalCtx);
+void func_808A7AAC(ObjWturn* this, GlobalContext* globalCtx);
void func_808A7BA0(ObjWturn* this, GlobalContext* globalCtx);
+void func_808A7C04(ObjWturn* this, GlobalContext* globalCtx);
void func_808A7C78(ObjWturn* this, GlobalContext* globalCtx);
-#if 0
const ActorInit Obj_Wturn_InitVars = {
- ACTOR_OBJ_WTURN,
- ACTORCAT_ITEMACTION,
- FLAGS,
- GAMEPLAY_KEEP,
- sizeof(ObjWturn),
- (ActorFunc)ObjWturn_Init,
- (ActorFunc)Actor_Noop,
- (ActorFunc)ObjWturn_Update,
- (ActorFunc)NULL,
+ ACTOR_OBJ_WTURN, ACTORCAT_ITEMACTION, FLAGS,
+ GAMEPLAY_KEEP, sizeof(ObjWturn), (ActorFunc)ObjWturn_Init,
+ (ActorFunc)Actor_Noop, (ActorFunc)ObjWturn_Update, (ActorFunc)NULL,
};
-#endif
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/ObjWturn_Init.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7954.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7968.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7A24.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7A5C.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7AAC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7BA0.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7C04.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7C78.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/ObjWturn_Update.s")
+void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx) {
+ ObjWturn* this = THIS;
+
+ func_808A7954(this);
+}
+
+void func_808A7954(ObjWturn* this) {
+ this->actionFunc = func_808A7968;
+}
+
+void func_808A7968(ObjWturn* this, GlobalContext* globalCtx) {
+ if (globalCtx->msgCtx.ocarinaMode >= 28 && globalCtx->msgCtx.ocarinaMode < 39) {
+ Flags_UnsetSwitch(globalCtx, this->actor.params);
+ Actor_MarkForDeath(&this->actor);
+ } else if ((Flags_GetSwitch(globalCtx, this->actor.params) && (globalCtx->sceneNum == SCENE_F40)) ||
+ (!Flags_GetSwitch(globalCtx, this->actor.params) && (globalCtx->sceneNum == SCENE_F41))) {
+ func_808A7A24(this);
+ }
+}
+
+void func_808A7A24(ObjWturn* this) {
+ ActorCutscene_SetIntentToPlay(this->actor.cutscene);
+ this->actionFunc = func_808A7A5C;
+}
+
+void func_808A7A5C(ObjWturn* this, GlobalContext* globalCtx) {
+ if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) {
+ func_808A7AAC(this, globalCtx);
+ } else {
+ ActorCutscene_SetIntentToPlay(this->actor.cutscene);
+ }
+}
+
+void func_808A7AAC(ObjWturn* this, GlobalContext* globalCtx) {
+ Player* player = GET_PLAYER(globalCtx);
+ Vec3f eye;
+ Vec3f at;
+
+ ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor);
+ func_8016566C(140);
+ this->camId = ActorCutscene_GetCurrentCamera(this->actor.cutscene);
+ func_800B7298(globalCtx, &this->actor, 21);
+ at.x = player->actor.focus.pos.x;
+ at.z = player->actor.focus.pos.z;
+ at.y = player->actor.focus.pos.y;
+ eye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + at.x;
+ eye.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + at.z;
+ eye.y = at.y + 4.0f;
+ Play_CameraSetAtEye(globalCtx, this->camId, &at, &eye);
+ this->actionFunc = func_808A7BA0;
+}
+
+void func_808A7BA0(ObjWturn* this, GlobalContext* globalCtx) {
+ if (Math_ScaledStepToS(&this->actor.shape.rot.z, -0x8000, 0x0200)) {
+ func_808A7C04(this, globalCtx);
+ }
+ func_800B8FE8(&this->actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG);
+ Play_CameraSetRoll(globalCtx, this->camId, this->actor.shape.rot.z);
+}
+
+void func_808A7C04(ObjWturn* this, GlobalContext* globalCtx) {
+ Player* player = GET_PLAYER(globalCtx);
+
+ this->actor.world.pos.y += this->actor.playerHeightRel;
+ player->actor.shape.shadowAlpha = 0;
+ func_800B7298(globalCtx, &this->actor, 0x54);
+ func_800B8E58(player, NA_SE_VO_NAVY_ENEMY);
+ this->unk_14A = 0;
+ func_80165690();
+ this->actionFunc = func_808A7C78;
+}
+
+void func_808A7C78(ObjWturn* this, GlobalContext* globalCtx) {
+ static Vec3f D_808A7DC0 = { 0.0f, -1.0f, 0.0f };
+ Camera* camera = Play_GetCamera(globalCtx, this->camId);
+ Player* player = GET_PLAYER(globalCtx);
+
+ this->unk_14A++;
+ player->actor.world.pos.y = this->actor.world.pos.y + this->unk_14A * 4.0f;
+ Play_CameraSetAtEyeUp(globalCtx, this->camId, &player->actor.focus.pos, &camera->eye, &D_808A7DC0);
+ if (this->unk_14A == 1) {
+ globalCtx->unk_1887F = 0x40;
+ gSaveContext.nextTransition = 3;
+ gSaveContext.nextCutsceneIndex = 0;
+ if (globalCtx->sceneNum == 0x58) {
+ globalCtx->nextEntranceIndex = 0xAC00;
+ } else {
+ globalCtx->nextEntranceIndex = 0xAA10;
+ }
+ globalCtx->sceneLoadFlag = 0x14;
+ }
+}
+
+void ObjWturn_Update(Actor* thisx, GlobalContext* globalCtx) {
+ ObjWturn* this = THIS;
+
+ this->actionFunc(this, globalCtx);
+}
diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h
index 0b0b8b375..0390ac7a8 100644
--- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h
+++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h
@@ -10,7 +10,8 @@ typedef void (*ObjWturnActionFunc)(struct ObjWturn*, GlobalContext*);
typedef struct ObjWturn {
/* 0x0000 */ Actor actor;
/* 0x0144 */ ObjWturnActionFunc actionFunc;
- /* 0x0148 */ char unk_148[0x4];
+ /* 0x0148 */ s16 camId;
+ /* 0x014A */ s16 unk_14A;
} ObjWturn; // size = 0x14C
extern const ActorInit Obj_Wturn_InitVars;