summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com>2022-03-05 14:57:28 +0000
committerGitHub <noreply@github.com>2022-03-05 11:57:28 -0300
commit7fcefd8d3fa60a13c1229bf4a1bdc5f2c59f0d75 (patch)
treee6d62de9f42d5f8c6eb2606c009a95de2af40cc3 /src
parent6017869b1e2f369fa2c27a17a5e1b8f29b4aaf41 (diff)
Decompile and partially document some functions in z_play (#582)
* Decomp 10 functions in z_play, start documentation * Add numbers to enums in z_en_torch2.h * Decompile a 5 more functions (56 unattempted) * Add more details, name some more variables * Bit more Doxygen * Format * Fix arguments * Add symbols to actorfixer.py * Merge branch 'master' into play * Fix z_actor * Review * Deduplicate CycleSceneFlags * Fix warning * Fix unk4 * Review
Diffstat (limited to 'src')
-rw-r--r--src/code/z_actor.c6
-rw-r--r--src/code/z_collision_check.c14
-rw-r--r--src/code/z_effect.c2
-rw-r--r--src/code/z_effect_soft_sprite.c2
-rw-r--r--src/code/z_game_over.c2
-rw-r--r--src/code/z_play.c278
-rw-r--r--src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c2
-rw-r--r--src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c2
-rw-r--r--src/overlays/actors/ovl_Door_Ana/z_door_ana.c2
-rw-r--r--src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c24
-rw-r--r--src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c2
-rw-r--r--src/overlays/actors/ovl_En_Gs/z_en_gs.c4
-rw-r--r--src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c6
-rw-r--r--src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c2
-rw-r--r--src/overlays/actors/ovl_En_Test4/z_en_test4.c16
-rw-r--r--src/overlays/actors/ovl_En_Torch2/z_en_torch2.c3
-rw-r--r--src/overlays/actors/ovl_En_Torch2/z_en_torch2.h20
-rw-r--r--src/overlays/actors/ovl_En_Tru/z_en_tru.c2
-rw-r--r--src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c2
-rw-r--r--src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c2
-rw-r--r--src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c2
21 files changed, 308 insertions, 87 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index 064ee0a88..08a230e16 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -2016,7 +2016,7 @@ s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRa
player->getItemDirection = absYawDiff;
if ((getItemId > GI_NONE) && (getItemId < GI_MAX)) {
- ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[1]);
+ ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[1]);
}
return true;
@@ -2237,7 +2237,7 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn
s32 i;
gSaveContext.weekEventReg[92] |= 0x80;
- cycleFlags = &gSaveContext.cycleSceneFlags[convert_scene_number_among_shared_scenes(globalCtx->sceneNum)];
+ cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)];
bzero(actorCtx, sizeof(ActorContext));
ActorOverlayTable_Init();
@@ -3037,7 +3037,7 @@ void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) {
actorCtx->absoluteSpace = NULL;
}
- func_80169D40(globalCtx);
+ Play_SaveCycleSceneFlags(&globalCtx->state);
ActorOverlayTable_Cleanup();
}
diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c
index ddf21fe17..a08e3f822 100644
--- a/src/code/z_collision_check.c
+++ b/src/code/z_collision_check.c
@@ -1145,7 +1145,7 @@ ColChkResetFunc sATResetFuncs[] = {
s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
s32 index;
- if (FrameAdvance_IsEnabled(globalCtx)) {
+ if (FrameAdvance_IsEnabled(&globalCtx->state)) {
return -1;
}
sATResetFuncs[collider->shape](globalCtx, collider);
@@ -1171,7 +1171,7 @@ s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtx
* will be inserted into the next slot.
*/
s32 CollisionCheck_SetAT_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) {
- if (FrameAdvance_IsEnabled(globalCtx)) {
+ if (FrameAdvance_IsEnabled(&globalCtx->state)) {
return -1;
}
sATResetFuncs[collider->shape](globalCtx, collider);
@@ -1205,7 +1205,7 @@ ColChkResetFunc sACResetFuncs[] = {
s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
s32 index;
- if (FrameAdvance_IsEnabled(globalCtx)) {
+ if (FrameAdvance_IsEnabled(&globalCtx->state)) {
return -1;
}
sACResetFuncs[collider->shape](globalCtx, collider);
@@ -1231,7 +1231,7 @@ s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtx
* will be inserted into the next slot
*/
s32 CollisionCheck_SetAC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) {
- if (FrameAdvance_IsEnabled(globalCtx)) {
+ if (FrameAdvance_IsEnabled(&globalCtx->state)) {
return -1;
}
sACResetFuncs[collider->shape](globalCtx, collider);
@@ -1265,7 +1265,7 @@ ColChkResetFunc sOCResetFuncs[] = {
s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
s32 index;
- if (FrameAdvance_IsEnabled(globalCtx)) {
+ if (FrameAdvance_IsEnabled(&globalCtx->state)) {
return -1;
}
sOCResetFuncs[collider->shape](globalCtx, collider);
@@ -1291,7 +1291,7 @@ s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtx
* will be inserted into the next slot.
*/
s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) {
- if (FrameAdvance_IsEnabled(globalCtx)) {
+ if (FrameAdvance_IsEnabled(&globalCtx->state)) {
return -1;
}
sOCResetFuncs[collider->shape](globalCtx, collider);
@@ -1323,7 +1323,7 @@ s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* co
s32 CollisionCheck_SetOCLine(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, OcLine* line) {
s32 index;
- if (FrameAdvance_IsEnabled(globalCtx)) {
+ if (FrameAdvance_IsEnabled(&globalCtx->state)) {
return -1;
}
diff --git a/src/code/z_effect.c b/src/code/z_effect.c
index dd696393f..4c446b650 100644
--- a/src/code/z_effect.c
+++ b/src/code/z_effect.c
@@ -124,7 +124,7 @@ void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg
*pIndex = TOTAL_EFFECT_COUNT;
- if (FrameAdvance_IsEnabled(globalCtx) != true) {
+ if (FrameAdvance_IsEnabled(&globalCtx->state) != true) {
slotFound = false;
switch (type) {
case EFFECT_SPARK:
diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c
index 43307bbc8..fd1d0212c 100644
--- a/src/code/z_effect_soft_sprite.c
+++ b/src/code/z_effect_soft_sprite.c
@@ -152,7 +152,7 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) {
void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) {
s32 index;
- if (FrameAdvance_IsEnabled(globalCtx) != true) {
+ if (FrameAdvance_IsEnabled(&globalCtx->state) != true) {
if (EffectSS_FindFreeSpace(effectsSs->priority, &index) == 0) {
sEffectSsInfo.searchIndex = index + 1;
sEffectSsInfo.data_table[index] = *effectsSs;
diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c
index 15f3a6693..6b375ecf8 100644
--- a/src/code/z_game_over.c
+++ b/src/code/z_game_over.c
@@ -67,7 +67,7 @@ void GameOver_Update(GlobalContext* globalCtx) {
break;
case GAMEOVER_DEATH_FADE_OUT:
if (func_801A8A50(1) != NA_BGM_GAME_OVER) {
- func_80169F78(globalCtx);
+ func_80169F78(&globalCtx->state);
if (gSaveContext.respawnFlag != -7) {
gSaveContext.respawnFlag = -6;
}
diff --git a/src/code/z_play.c b/src/code/z_play.c
index a14359be7..b5c2b15c8 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -110,34 +110,254 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCsCamDataVec3s.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/convert_scene_number_among_shared_scenes.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169D40.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169DCC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169E6C.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169ECC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169EFC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169F78.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169FDC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169FFC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/FrameAdvance_IsEnabled.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A02C.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A0AC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A168.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A178.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A268.s")
+/**
+ * Converts the number of a scene to its "original" equivalent, the default version of the area which the player first
+ * enters.
+ */
+s16 Play_GetOriginalSceneNumber(s16 sceneNum) {
+ // Inverted Stone Tower Temple -> Stone Tower Temple
+ if (sceneNum == SCENE_INISIE_R) {
+ return SCENE_INISIE_N;
+ }
+
+ // Purified Southern Swamp -> Poisoned Sothern Swamp
+ if (sceneNum == SCENE_20SICHITAI2) {
+ return SCENE_20SICHITAI;
+ }
+
+ // Spring Mountain Village -> Winter Mountain Village
+ if (sceneNum == SCENE_10YUKIYAMANOMURA2) {
+ return SCENE_10YUKIYAMANOMURA;
+ }
+
+ // Spring Goron Village -> Winter Goron Village
+ if (sceneNum == SCENE_11GORONNOSATO2) {
+ return SCENE_11GORONNOSATO;
+ }
+
+ // Spring Path to Goron Village -> Winter Path to Goron Village
+ if (sceneNum == SCENE_17SETUGEN2) {
+ return SCENE_17SETUGEN;
+ }
+
+ // Inverted Stone Tower -> Stone Tower
+ if (sceneNum == SCENE_F41) {
+ return SCENE_F40;
+ }
+
+ return sceneNum;
+}
+
+/**
+ * Copies the flags set in ActorContext over to the current scene's CycleSceneFlags, usually using the original scene
+ * number. Exception for Inverted Stone Tower Temple, which uses its own.
+ */
+void Play_SaveCycleSceneFlags(GameState* gameState) {
+ GlobalContext* globalCtx = (GlobalContext*)gameState;
+ CycleSceneFlags* cycleSceneFlags;
+
+ cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)];
+ cycleSceneFlags->chest = globalCtx->actorCtx.flags.chest;
+ cycleSceneFlags->swch0 = globalCtx->actorCtx.flags.switches[0];
+ cycleSceneFlags->swch1 = globalCtx->actorCtx.flags.switches[1];
+
+ if (globalCtx->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple
+ cycleSceneFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum];
+ }
+
+ cycleSceneFlags->collectible = globalCtx->actorCtx.flags.collectible[0];
+ cycleSceneFlags->clearedRoom = globalCtx->actorCtx.flags.clearedRoom;
+}
+
+void Play_SetRespawnData(GameState* gameState, s32 respawnMode, u16 entranceIndex, s32 roomIndex, s32 playerParams,
+ Vec3f* pos, s16 yaw) {
+ GlobalContext* globalCtx = (GlobalContext*)gameState;
+
+ gSaveContext.respawn[respawnMode].entranceIndex = Entrance_CreateIndex(entranceIndex >> 9, 0, entranceIndex & 0xF);
+ gSaveContext.respawn[respawnMode].roomIndex = roomIndex;
+ gSaveContext.respawn[respawnMode].pos = *pos;
+ gSaveContext.respawn[respawnMode].yaw = yaw;
+ gSaveContext.respawn[respawnMode].playerParams = playerParams;
+ gSaveContext.respawn[respawnMode].tempSwchFlags = globalCtx->actorCtx.flags.switches[2];
+ gSaveContext.respawn[respawnMode].unk_18 = globalCtx->actorCtx.flags.collectible[1];
+ gSaveContext.respawn[respawnMode].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2];
+}
+
+void Play_SetupRespawnPoint(GameState* gameState, s32 respawnMode, s32 playerParams) {
+ GlobalContext* globalCtx = (GlobalContext*)gameState;
+ Player* player = GET_PLAYER(globalCtx);
+
+ if (globalCtx->sceneNum != SCENE_KAKUSIANA) { // Grottos
+ Play_SetRespawnData(&globalCtx->state, respawnMode, (u16)((void)0, gSaveContext.entranceIndex),
+ globalCtx->roomCtx.currRoom.num, playerParams, &player->actor.world.pos,
+ player->actor.shape.rot.y);
+ }
+}
+
+// Override respawn data in Sakon's Hideout
+void func_80169ECC(GlobalContext* globalCtx) {
+ if (globalCtx->sceneNum == SCENE_SECOM) {
+ globalCtx->nextEntranceIndex = 0x2060;
+ gSaveContext.respawnFlag = -7;
+ }
+}
+
+// Gameplay_TriggerVoidOut ?
+// Used by Player, Ikana_Rotaryroom, Bji01, Kakasi, LiftNuts, Test4, Warptag, WarpUzu, Roomtimer
+void func_80169EFC(GameState* gameState) {
+ GlobalContext* globalCtx = (GlobalContext*)gameState;
+
+ gSaveContext.respawn[0].tempSwchFlags = globalCtx->actorCtx.flags.switches[2];
+ gSaveContext.respawn[0].unk_18 = globalCtx->actorCtx.flags.collectible[1];
+ gSaveContext.respawn[0].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2];
+ globalCtx->nextEntranceIndex = gSaveContext.respawn[0].entranceIndex;
+ gSaveContext.respawnFlag = 1;
+ func_80169ECC(globalCtx);
+ globalCtx->sceneLoadFlag = 0x14;
+ globalCtx->unk_1887F = 2;
+}
+
+// Gameplay_LoadToLastEntrance ?
+// Used by game_over and Test7
+void func_80169F78(GameState* gameState) {
+ GlobalContext* globalCtx = (GlobalContext*)gameState;
+
+ globalCtx->nextEntranceIndex = gSaveContext.respawn[2].entranceIndex;
+ gSaveContext.respawnFlag = -1;
+ func_80169ECC(globalCtx);
+ globalCtx->sceneLoadFlag = 0x14;
+ globalCtx->unk_1887F = 2;
+}
+
+// Gameplay_TriggerRespawn ?
+// Used for void by Wallmaster, Deku Shrine doors. Also used by Player, Kaleido, DoorWarp1
+void func_80169FDC(GameState* gameState) {
+ func_80169F78(gameState);
+}
+
+// Used by Kankyo to determine how to change the lighting, e.g. for game over.
+s32 func_80169FFC(GameState* gameState) {
+ GlobalContext* globalCtx = (GlobalContext*)gameState;
+
+ return globalCtx->roomCtx.currRoom.mesh->type0.type != 1;
+}
+
+s32 FrameAdvance_IsEnabled(GameState* gameState) {
+ GlobalContext* globalCtx = (GlobalContext*)gameState;
+
+ return globalCtx->frameAdvCtx.enabled != 0;
+}
+
+// Unused, unchanged from OoT, which uses it only in one Camera function.
+/**
+ * @brief Tests if \p actor is a door and the sides are different rooms.
+ *
+ * @param[in] gameState GameState, promoted to globalCtx inside.
+ * @param[in] actor Actor to test.
+ * @param[out] yaw Facing angle of the actor, or reverse if in the back room.
+ * @return true if \p actor is a door and the sides are in different rooms, false otherwise
+ */
+s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw) {
+ GlobalContext* globalCtx = (GlobalContext*)gameState;
+ TransitionActorEntry* transitionActor;
+ s8 frontRoom;
+
+ if (actor->category != ACTORCAT_DOOR) {
+ return false;
+ }
+
+ transitionActor = &globalCtx->doorCtx.transitionActorList[(u16)actor->params >> 10];
+ frontRoom = transitionActor->sides[0].room;
+ if (frontRoom == transitionActor->sides[1].room) {
+ return false;
+ }
+
+ if (frontRoom == actor->room) {
+ *yaw = actor->shape.rot.y;
+ } else {
+ *yaw = actor->shape.rot.y + 0x8000;
+ }
+
+ return true;
+}
+
+// Unused
+/**
+ * @brief Tests if \p pos is underwater.
+ *
+ * @param[in] globalCtx GlobalContext
+ * @param[in] pos position to test
+ * @return true if inside a waterbox and not above a void.
+ */
+s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos) {
+ WaterBox* waterBox;
+ CollisionPoly* poly;
+ Vec3f waterSurfacePos;
+ s32 bgId;
+
+ waterSurfacePos = *pos;
+
+ if ((WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y,
+ &waterBox) == true) &&
+ (pos->y < waterSurfacePos.y) &&
+ (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// z_demo and EnTest4
+// This data appears to be a boolean. It is only set by Play_Init.
+s32 func_8016A168(void) {
+ return D_801D0D50;
+}
+
+// A mapping from playerActorCsIds to sGlobalCamDataSettings indices.
+extern s16 D_801D0D64[];
+// s16 D_801D0D64[] = { -3, -2, -4, -5, -7, -11, -8, -9, -6, -16 };
+
+// Used by Player
+/**
+ * Extract the common actor cutscene ids used by Player from the scene and set the actor cutscene ids in
+ * globalCtx->playerActorCsIds. If a playerActorCsId is not present in the scene, then that particular id is set
+ * to -1. Otherwise, if there is an ActorCutscene where csCamSceneDataId matches the appropriate element of D_801D0D64,
+ * set the corresponding playerActorCsId (and possibly change its priority for the zeroth one)
+ */
+void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 startActorCsId) {
+ GlobalContext* globalCtx = (GlobalContext*)gameState;
+ s32 i;
+ s16* curPlayerActorCsId = globalCtx->playerActorCsIds;
+ s16* phi_s1 = D_801D0D64;
+
+ for (i = 0; i < ARRAY_COUNT(globalCtx->playerActorCsIds); i++, curPlayerActorCsId++, phi_s1++) {
+ ActorCutscene* actorCutscene;
+ s32 curActorCsId;
+
+ *curPlayerActorCsId = -1;
+
+ for (curActorCsId = startActorCsId; curActorCsId != -1; curActorCsId = actorCutscene->additionalCutscene) {
+ actorCutscene = ActorCutscene_GetCutscene(curActorCsId);
+
+ if (actorCutscene->csCamSceneDataId == *phi_s1) {
+ if ((actorCutscene->csCamSceneDataId == -3) &&
+ (actorCutscene->priority == 700)) { // override ocarina cs priority
+ actorCutscene->priority = 550;
+ }
+ *curPlayerActorCsId = curActorCsId;
+ break;
+ }
+ }
+ }
+}
+
+// These regs are used by Gameplay_Draw, and several actors, purpose as yet unclear.
+void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5) {
+ MREG(64) = arg1;
+ MREG(65) = arg2;
+ MREG(66) = arg3;
+ MREG(67) = arg4;
+ MREG(68) = arg5;
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Init.s")
diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c
index 13d8161e2..a3b234392 100644
--- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c
+++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c
@@ -647,7 +647,7 @@ void func_80B814B8(BgIkanaRotaryroom* this, GlobalContext* globalCtx) {
if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) {
if (player->actor.bgCheckFlags & 0x100) {
func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92);
- func_80169EFC(globalCtx);
+ func_80169EFC(&globalCtx->state);
func_800B8E58(player, NA_SE_VO_LI_TAKEN_AWAY + player->ageProperties->unk_92);
globalCtx->unk_18845 = 1;
play_sound(NA_SE_OC_ABYSS);
diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c
index 2017e960b..b32140c83 100644
--- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c
+++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c
@@ -1566,7 +1566,7 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) {
}
if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) &&
- (globalCtx->msgCtx.unk11F04 == 0x5E6) && !FrameAdvance_IsEnabled(globalCtx) &&
+ (globalCtx->msgCtx.unk11F04 == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) &&
(globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) &&
(globalCtx->csCtx.state == 0)) {
time = gSaveContext.time;
diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c
index 85a7a9bc8..73d9911f9 100644
--- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c
+++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c
@@ -147,7 +147,7 @@ void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) {
// unused in vanilla, the highest params bits can directly index an address
entranceIndex = GET_DOORANA_DIRECT_ENTRANCE(this);
- func_80169E6C(globalCtx, 3, 0x4FF);
+ Play_SetupRespawnPoint(&globalCtx->state, 3, 0x4FF);
gSaveContext.respawn[3].pos.y = this->actor.world.pos.y;
gSaveContext.respawn[3].yaw = this->actor.home.rot.y;
diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c
index a1a738fee..56f39772a 100644
--- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c
+++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c
@@ -376,7 +376,7 @@ void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx) {
}
void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx) {
- if (!func_808B866C(this, globalCtx) && (ActorCutscene_GetCurrentIndex() != globalCtx->unk_1879C[8])) {
+ if (!func_808B866C(this, globalCtx) && (ActorCutscene_GetCurrentIndex() != globalCtx->playerActorCsIds[8])) {
DoorWarp1_SetupAction(this, func_808B921C);
}
func_808BB8D4(this, globalCtx, 1);
@@ -384,10 +384,10 @@ void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx) {
}
void func_808B9524(DoorWarp1* this, GlobalContext* globalCtx) {
- if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) {
- ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]);
+ if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) {
+ ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]);
} else {
- ActorCutscene_Start(globalCtx->unk_1879C[9], NULL);
+ ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL);
DoorWarp1_SetupAction(this, func_808B958C);
}
}
@@ -456,10 +456,10 @@ void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx) {
}
void func_808B9840(DoorWarp1* this, GlobalContext* globalCtx) {
- if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) {
- ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]);
+ if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) {
+ ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]);
} else {
- ActorCutscene_Start(globalCtx->unk_1879C[9], NULL);
+ ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL);
DoorWarp1_SetupAction(this, func_808B98A8);
}
}
@@ -488,7 +488,7 @@ void func_808B98A8(DoorWarp1* this, GlobalContext* globalCtx) {
Scene_SetExitFade(globalCtx);
globalCtx->sceneLoadFlag = 0x14;
} else {
- func_80169FDC(globalCtx);
+ func_80169FDC(&globalCtx->state);
}
}
}
@@ -615,10 +615,10 @@ void func_808B9FD0(DoorWarp1* this, GlobalContext* globalCtx) {
return;
}
- if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) {
- ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]);
+ if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) {
+ ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]);
} else {
- ActorCutscene_Start(globalCtx->unk_1879C[9], NULL);
+ ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL);
Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8);
Animation_ChangeImpl(&this->skelAnime, &object_warp1_Anim_001374, 1.0f,
Animation_GetLastFrame(&object_warp1_Anim_001374.common),
@@ -767,7 +767,7 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) {
Scene_SetExitFade(globalCtx);
globalCtx->sceneLoadFlag = 0x14;
} else {
- func_80169FDC(globalCtx);
+ func_80169FDC(&globalCtx->state);
}
}
diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c
index 53bdc0995..8faf1cdba 100644
--- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c
+++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c
@@ -299,7 +299,7 @@ void func_809CD634(EnBji01* this, GlobalContext* globalCtx) {
Audio_QueueSeqCmd(0xE0000101);
globalCtx->nextEntranceIndex = 0x54A0; /* Termina Field from telescope */
gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex;
- func_80169EFC(globalCtx); /* Load new entrance? */
+ func_80169EFC(&globalCtx->state); /* Load new entrance? */
gSaveContext.respawnFlag = -2;
this->actionFunc = EnBji01_DoNothing;
}
diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c
index 9f4bdb728..c04cd1e9e 100644
--- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c
+++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c
@@ -262,7 +262,7 @@ void func_80997E4C(EnGs* this, GlobalContext* globalCtx) {
}
void func_80997FF0(EnGs* this, GlobalContext* globalCtx) {
- if (SubS_StartActorCutscene(&this->actor, globalCtx->unk_1879C[0], -1, SUBS_CUTSCENE_NORMAL)) {
+ if (SubS_StartActorCutscene(&this->actor, globalCtx->playerActorCsIds[0], -1, SUBS_CUTSCENE_NORMAL)) {
func_80998040(this, globalCtx);
}
}
@@ -339,7 +339,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) {
void func_80998300(EnGs* this, GlobalContext* globalCtx) {
if (this->actor.cutscene != -1) {
- ActorCutscene_Stop(globalCtx->unk_1879C[0]);
+ ActorCutscene_Stop(globalCtx->playerActorCsIds[0]);
}
}
diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c
index f1d1737e4..2107be0b3 100644
--- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c
+++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c
@@ -934,9 +934,9 @@ void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) {
if (this->unk204 == 0) {
player = GET_PLAYER(globalCtx);
- func_80169DCC(globalCtx, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, &player->unk_3C0,
- player->unk_3CC);
- func_80169EFC(globalCtx);
+ Play_SetRespawnData(&globalCtx->state, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF,
+ &player->unk_3C0, player->unk_3CC);
+ func_80169EFC(&globalCtx->state);
if (0) {}
if (gSaveContext.time > CLOCK_TIME(18, 0) || gSaveContext.time < CLOCK_TIME(6, 0)) {
diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c
index 8ce550773..c87e30329 100644
--- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c
+++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c
@@ -58,7 +58,7 @@ void func_8096B104(EnOkarinaEffect* this, GlobalContext* globalCtx) {
void func_8096B174(EnOkarinaEffect* this, GlobalContext* globalCtx) {
DECR(this->unk144);
if (!globalCtx->pauseCtx.state && !globalCtx->gameOverCtx.state && !globalCtx->msgCtx.unk11F10 &&
- !FrameAdvance_IsEnabled(globalCtx) && this->unk144 == 0) {
+ !FrameAdvance_IsEnabled(&globalCtx->state) && this->unk144 == 0) {
EnOkarinaEffect_SetupAction(this, func_8096B1FC);
}
}
diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c
index 791323123..6886d2b29 100644
--- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c
+++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c
@@ -399,9 +399,9 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) {
func_80A41FA4(this, globalCtx);
} else {
gSaveContext.unk_3F64 = 0.0f;
- func_80169DCC(globalCtx, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF,
- &player->unk_3C0, player->unk_3CC);
- func_80169EFC(globalCtx);
+ Play_SetRespawnData(&globalCtx->state, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF,
+ &player->unk_3C0, player->unk_3CC);
+ func_80169EFC(&globalCtx->state);
if (player->stateFlags1 & 0x800000) {
EnHorse* rideActor = (EnHorse*)player->rideActor;
@@ -440,16 +440,16 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) {
if ((this->nextBellTime == CLOCK_TIME(0, 0)) &&
((gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) ||
(globalCtx->sceneNum == SCENE_CLOCKTOWER))) {
- s32 phi_v0;
+ s32 playerParams;
u32 entranceIndex = gSaveContext.entranceIndex;
if ((globalCtx->actorCtx.unk5 & 2)) {
- phi_v0 = 0xCFF;
+ playerParams = 0xCFF;
} else {
- phi_v0 = 0xBFF;
+ playerParams = 0xBFF;
}
- func_80169DCC(globalCtx, 1, entranceIndex, player->unk_3CE, phi_v0, &player->unk_3C0,
- player->unk_3CC);
+ Play_SetRespawnData(&globalCtx->state, 1, entranceIndex, player->unk_3CE, playerParams,
+ &player->unk_3C0, player->unk_3CC);
if ((globalCtx->sceneNum == SCENE_TENMON_DAI) || (globalCtx->sceneNum == SCENE_00KEIKOKU)) {
globalCtx->nextEntranceIndex = 0x5400;
diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c
index 98ea88f83..22ebc78b5 100644
--- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c
+++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c
@@ -74,7 +74,8 @@ void EnTorch2_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnTorch2* this = THIS;
Collider_DestroyCylinder(globalCtx, &this->collider);
- func_80169DCC(globalCtx, this->actor.params + 3, 0xFF, 0, 0xBFF, &this->actor.world.pos, this->actor.shape.rot.y);
+ Play_SetRespawnData(&globalCtx->state, this->actor.params + 3, 0xFF, 0, 0xBFF, &this->actor.world.pos,
+ this->actor.shape.rot.y);
globalCtx->actorCtx.unk254[this->actor.params] = 0;
}
diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h
index 70e5cd7cf..744a7975c 100644
--- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h
+++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h
@@ -14,19 +14,19 @@ typedef struct EnTorch2 {
} EnTorch2; // size = 0x194
typedef enum {
- TORCH2_PARAM_HUMAN,
- TORCH2_PARAM_GORON,
- TORCH2_PARAM_ZORA,
- TORCH2_PARAM_DEKU,
- TORCH2_PARAM_FIERCE_DEITY,
+ /* 0 */ TORCH2_PARAM_HUMAN,
+ /* 1 */ TORCH2_PARAM_GORON,
+ /* 2 */ TORCH2_PARAM_ZORA,
+ /* 3 */ TORCH2_PARAM_DEKU,
+ /* 4 */ TORCH2_PARAM_FIERCE_DEITY,
} EnTorch2Param;
typedef enum {
- TORCH2_STATE_INITIALIZED,
- TORCH2_STATE_FADING_IN,
- TORCH2_STATE_SOLID,
- TORCH2_STATE_IDLE,
- TORCH2_STATE_DYING,
+ /* 0 */ TORCH2_STATE_INITIALIZED,
+ /* 1 */ TORCH2_STATE_FADING_IN,
+ /* 2 */ TORCH2_STATE_SOLID,
+ /* 3 */ TORCH2_STATE_IDLE,
+ /* 4 */ TORCH2_STATE_DYING,
} EnTorch2State;
extern const ActorInit En_Torch2_InitVars;
diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c
index db7b7a1fc..7a4a22170 100644
--- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c
+++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c
@@ -944,7 +944,7 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) {
sp4C.z = 40.0f;
Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, sp3E, &sp4C, &sp40);
func_80A85620(this->unk_394, &sp40, 2.0f, 0.08f, 60.0f);
- func_8016A268(globalCtx, 1, 160, 160, 160, 0);
+ func_8016A268(&globalCtx->state, 1, 160, 160, 160, 0);
this->unk_370 = 20;
this->unk_372 = 10;
this->unk_364++;
diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c
index 3c19559af..ffbb9526b 100644
--- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c
+++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c
@@ -113,7 +113,7 @@ void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx) {
void func_80A66384(EnWarpUzu* this, GlobalContext* globalCtx) {
globalCtx->nextEntranceIndex = 0x22A0;
gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex;
- func_80169EFC(globalCtx);
+ func_80169EFC(&globalCtx->state);
gSaveContext.respawnFlag = -2;
this->actionFunc = EnWarpUzu_DoNothing;
}
diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c
index b15cb5119..3334164bc 100644
--- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c
+++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c
@@ -485,7 +485,7 @@ void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx) {
this->actionFunc(this, globalCtx);
if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && (globalCtx->msgCtx.unk11F04 == 0x5E6) &&
- (!FrameAdvance_IsEnabled(globalCtx)) && (globalCtx->sceneLoadFlag == 0) &&
+ (!FrameAdvance_IsEnabled(&globalCtx->state)) && (globalCtx->sceneLoadFlag == 0) &&
(ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) {
oldTime = gSaveContext.time;
diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c
index a1cc93b9f..ff0c8d270 100644
--- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c
+++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c
@@ -68,7 +68,7 @@ void func_80973D3C(ObjRoomtimer* this, GlobalContext* globalCtx) {
this->actionFunc = func_80973DE0;
} else if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] == 0) {
play_sound(NA_SE_OC_ABYSS);
- func_80169EFC(globalCtx);
+ func_80169EFC(&globalCtx->state);
Actor_MarkForDeath(&this->actor);
}
}