From d314cfe92395172612676a8ad007a0639c8d5666 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Wed, 6 Sep 2023 17:14:15 +0200 Subject: [PATCH] Document pause states (excluding gameover) (#1483) * Document PauseContext.state * Very light docs surrounding pause states * PAUSE_STATE_UNPAUSE -> PAUSE_STATE_RESUME_GAMEPLAY and comment on purpose in the enum * PAUSE_STATE_MAIN -> PAUSE_STATE_6 * format * Player_InitDrawPause -> Player_InitPauseDrawData --- include/functions.h | 2 +- include/z64pause.h | 29 ++++ src/code/z_bgcheck.c | 9 +- src/code/z_game_over.c | 2 +- src/code/z_kaleido_scope_call.c | 22 +-- src/code/z_kaleido_setup.c | 9 +- src/code/z_kankyo.c | 6 +- src/code/z_lifemeter.c | 3 +- src/code/z_map_exp.c | 4 +- src/code/z_parameter.c | 36 +++-- src/code/z_play.c | 14 +- src/code/z_player_lib.c | 4 +- .../z_en_okarina_effect.c | 2 +- .../ovl_kaleido_scope/z_kaleido_collect.c | 8 +- .../ovl_kaleido_scope/z_kaleido_equipment.c | 8 +- .../misc/ovl_kaleido_scope/z_kaleido_item.c | 4 +- .../ovl_kaleido_scope/z_kaleido_map_PAL.c | 4 +- .../misc/ovl_kaleido_scope/z_kaleido_prompt.c | 3 +- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 142 ++++++++++-------- .../misc/ovl_kaleido_scope/z_lmap_mark.c | 2 +- 20 files changed, 174 insertions(+), 139 deletions(-) diff --git a/include/functions.h b/include/functions.h index 0484c66c13..8f83176af1 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1039,7 +1039,7 @@ s32 Player_OverrideLimbDrawGameplayCrawling(PlayState* play, s32 limbIndex, Gfx* u8 func_80090480(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* newTip, Vec3f* newBase); void Player_DrawGetItem(PlayState* play, Player* this); void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx); -u32 func_80091738(PlayState* play, u8* segment, SkelAnime* skelAnime); +u32 Player_InitPauseDrawData(PlayState* play, u8* segment, SkelAnime* skelAnime); void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale, s32 sword, s32 tunic, s32 shield, s32 boots); void PreNMI_Init(GameState* thisx); diff --git a/include/z64pause.h b/include/z64pause.h index 79db8ea4b3..f25d5c6ed1 100644 --- a/include/z64pause.h +++ b/include/z64pause.h @@ -26,6 +26,35 @@ typedef enum { #define PAUSE_EQUIP_BUFFER_SIZE sizeof(u16[PAUSE_EQUIP_PLAYER_HEIGHT][PAUSE_EQUIP_PLAYER_WIDTH]) #define PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE 0x5000 +typedef enum { + /* 0 */ PAUSE_STATE_OFF, + /* 1 */ PAUSE_STATE_WAIT_LETTERBOX, // Request no letterboxing and wait for it. + /* 2 */ PAUSE_STATE_WAIT_BG_PRERENDER, // Wait for the pause background prerender to be done. + /* 3 */ PAUSE_STATE_INIT, // Load data and initialize/setup various things. + /* 4 */ PAUSE_STATE_OPENING_1, // Animate the pause menu coming together with rotations and other animations. + /* 5 */ PAUSE_STATE_OPENING_2, // Finish some animations for opening the menu. + /* 6 */ PAUSE_STATE_6, // Pause menu ready for player inputs. + /* 7 */ PAUSE_STATE_SAVE_PROMPT, // Save prompt in the pause menu + /* 8 */ PAUSE_STATE_8, + /* 9 */ PAUSE_STATE_9, + /* 10 */ PAUSE_STATE_10, + /* 11 */ PAUSE_STATE_11, + /* 12 */ PAUSE_STATE_12, + /* 13 */ PAUSE_STATE_13, + /* 14 */ PAUSE_STATE_14, + /* 15 */ PAUSE_STATE_15, + /* 16 */ PAUSE_STATE_16, + /* 17 */ PAUSE_STATE_17, + /* 18 */ PAUSE_STATE_CLOSING, // Animate the pause menu closing + /* 19 */ PAUSE_STATE_RESUME_GAMEPLAY // Handles returning to normal gameplay once the pause menu is visually closed +} PauseState; + +#define IS_PAUSE_STATE_GAMEOVER(pauseCtx) \ + (((pauseCtx)->state >= PAUSE_STATE_8) && ((pauseCtx)->state <= PAUSE_STATE_17)) + +#define IS_PAUSED(pauseCtx) \ + (((pauseCtx)->state != PAUSE_STATE_OFF) || ((pauseCtx)->debugState != 0)) + typedef struct { /* 0x0000 */ View view; /* 0x0128 */ u8* iconItemSegment; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index e0634028c1..0525c89874 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -3154,7 +3154,7 @@ f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown) { f32 result; f32 intersect2; s32 i2; - s32 pauseState; + s32 isPaused; DynaPolyActor* dynaActor; s32 pad; Vec3f polyVtx[3]; @@ -3223,11 +3223,8 @@ f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown) { dynaActor = DynaPoly_GetActor(dynaRaycastDown->colCtx, *dynaRaycastDown->bgId); if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycastDown->play != NULL)) { - pauseState = dynaRaycastDown->play->pauseCtx.state != 0; - if (pauseState == 0) { - pauseState = dynaRaycastDown->play->pauseCtx.debugState != 0; - } - if (!pauseState && (dynaRaycastDown->colCtx->dyna.bgActorFlags[*dynaRaycastDown->bgId] & BGACTOR_1)) { + isPaused = IS_PAUSED(&dynaRaycastDown->play->pauseCtx); + if (!isPaused && (dynaRaycastDown->colCtx->dyna.bgActorFlags[*dynaRaycastDown->bgId] & BGACTOR_1)) { curTransform = &dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].curTransform; polyMin = &dynaRaycastDown->dyna diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 14f71fc6e7..796ce358d2 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -95,7 +95,7 @@ void GameOver_Update(PlayState* play) { gGameOverTimer--; if (gGameOverTimer == 0) { - play->pauseCtx.state = 8; + play->pauseCtx.state = PAUSE_STATE_8; gameOverCtx->state++; Rumble_Reset(); } diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 1f22ebdad5..4278b12efb 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -56,30 +56,30 @@ void KaleidoScopeCall_Update(PlayState* play) { KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; PauseContext* pauseCtx = &play->pauseCtx; - if ((pauseCtx->state != 0) || (pauseCtx->debugState != 0)) { - if (pauseCtx->state == 1) { + if (IS_PAUSED(pauseCtx)) { + if (pauseCtx->state == PAUSE_STATE_WAIT_LETTERBOX) { if (Letterbox_GetSize() == 0) { R_HREG_MODE = HREG_MODE_UCODE_DISAS; R_UCODE_DISAS_LOG_MODE = 3; R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP; pauseCtx->unk_1E4 = 0; pauseCtx->unk_1EC = 0; - pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; + pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; // PAUSE_STATE_WAIT_BG_PRERENDER } - } else if (pauseCtx->state == 8) { + } else if (pauseCtx->state == PAUSE_STATE_8) { R_HREG_MODE = HREG_MODE_UCODE_DISAS; R_UCODE_DISAS_LOG_MODE = 3; R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP; pauseCtx->unk_1E4 = 0; pauseCtx->unk_1EC = 0; - pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; - } else if ((pauseCtx->state == 2) || (pauseCtx->state == 9)) { + pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; // PAUSE_STATE_9 + } else if ((pauseCtx->state == PAUSE_STATE_WAIT_BG_PRERENDER) || (pauseCtx->state == PAUSE_STATE_9)) { osSyncPrintf("PR_KAREIDOSCOPE_MODE=%d\n", R_PAUSE_BG_PRERENDER_STATE); if (R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_READY) { - pauseCtx->state++; + pauseCtx->state++; // PAUSE_STATE_INIT or PAUSE_STATE_10 } - } else if (pauseCtx->state != 0) { + } else if (pauseCtx->state != PAUSE_STATE_OFF) { if (gKaleidoMgrCurOvl != kaleidoScopeOvl) { if (gKaleidoMgrCurOvl != NULL) { osSyncPrintf(VT_FGCOL(GREEN)); @@ -101,7 +101,7 @@ void KaleidoScopeCall_Update(PlayState* play) { if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { sKaleidoScopeUpdateFunc(play); - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { + if (!IS_PAUSED(&play->pauseCtx)) { osSyncPrintf(VT_FGCOL(GREEN)); // "Kaleido area Kaleidoscope Emission" osSyncPrintf("カレイド領域 カレイドスコープ排出\n"); @@ -119,8 +119,8 @@ void KaleidoScopeCall_Draw(PlayState* play) { KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; if (R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_READY) { - if (((play->pauseCtx.state >= 4) && (play->pauseCtx.state <= 7)) || - ((play->pauseCtx.state >= 11) && (play->pauseCtx.state <= 18))) { + if (((play->pauseCtx.state >= PAUSE_STATE_OPENING_1) && (play->pauseCtx.state <= PAUSE_STATE_SAVE_PROMPT)) || + ((play->pauseCtx.state >= PAUSE_STATE_11) && (play->pauseCtx.state <= PAUSE_STATE_CLOSING))) { if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { sKaleidoScopeDrawFunc(play); } diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 1e7af416d6..554282ba15 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -12,7 +12,7 @@ void KaleidoSetup_Update(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; Input* input = &play->state.input[0]; - if (pauseCtx->state == 0 && pauseCtx->debugState == 0 && play->gameOverCtx.state == GAMEOVER_INACTIVE && + if (!IS_PAUSED(pauseCtx) && play->gameOverCtx.state == GAMEOVER_INACTIVE && play->transitionTrigger == TRANS_TRIGGER_OFF && play->transitionMode == TRANS_MODE_OFF && gSaveContext.save.cutsceneIndex < 0xFFF0 && gSaveContext.nextCutsceneIndex < 0xFFF0 && !Play_InCsMode(play) && play->shootingGalleryStatus <= 1 && gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY && @@ -24,6 +24,7 @@ void KaleidoSetup_Update(PlayState* play) { pauseCtx->debugState = 3; } } else if (CHECK_BTN_ALL(input->press.button, BTN_START)) { + // The start button was pressed, pause gSaveContext.prevHudVisibilityMode = gSaveContext.hudVisibilityMode; WREG(16) = -175; @@ -43,13 +44,13 @@ void KaleidoSetup_Update(PlayState* play) { } pauseCtx->mode = (u16)(pauseCtx->pageIndex * 2) + 1; - pauseCtx->state = 1; + pauseCtx->state = PAUSE_STATE_WAIT_LETTERBOX; osSyncPrintf("Mode=%d eye.x=%f, eye.z=%f kscp_pos=%d\n", pauseCtx->mode, pauseCtx->eye.x, pauseCtx->eye.z, pauseCtx->pageIndex); } - if (pauseCtx->state == 1) { + if (pauseCtx->state == PAUSE_STATE_WAIT_LETTERBOX) { WREG(2) = -6240; R_UPDATE_RATE = 2; @@ -66,7 +67,7 @@ void KaleidoSetup_Init(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; u64 temp = 0; // Necessary to match - pauseCtx->state = 0; + pauseCtx->state = PAUSE_STATE_OFF; pauseCtx->debugState = 0; pauseCtx->alpha = 0; pauseCtx->unk_1EA = 0; diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 97e15a6e25..0cd66f64df 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -888,8 +888,8 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex Rumble_ClearRequests(); } - if (pauseCtx->state == 0) { - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { + if (pauseCtx->state == PAUSE_STATE_OFF) { + if (!IS_PAUSED(&play->pauseCtx)) { if (play->skyboxId == SKYBOX_NORMAL_SKY) { play->skyboxCtx.rot.y -= 0.001f; } else if (play->skyboxId == SKYBOX_CUTSCENE_MAP) { @@ -920,7 +920,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex } } - if ((pauseCtx->state == 0) && (gameOverCtx->state == GAMEOVER_INACTIVE)) { + if ((pauseCtx->state == PAUSE_STATE_OFF) && (gameOverCtx->state == GAMEOVER_INACTIVE)) { if (((msgCtx->msgLength == 0) && (msgCtx->msgMode == MSGMODE_NONE)) || (((void)0, gSaveContext.gameMode) == GAMEMODE_END_CREDITS)) { if ((envCtx->changeSkyboxTimer == 0) && !FrameAdvance_IsEnabled(play) && diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index a1f04093bb..42edcb102c 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -506,8 +506,7 @@ void Health_UpdateBeatingHeart(PlayState* play) { if (interfaceCtx->beatingHeartOscillator <= 0) { interfaceCtx->beatingHeartOscillator = 0; interfaceCtx->beatingHeartOscillatorDirection = 0; - if (!Player_InCsMode(play) && (play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && - Health_IsCritical() && !Play_InCsMode(play)) { + if (!Player_InCsMode(play) && !IS_PAUSED(&play->pauseCtx) && Health_IsCritical() && !Play_InCsMode(play)) { Sfx_PlaySfxCentered(NA_SE_SY_HITPOINT_ALARM); } } diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 0cd53e31d4..c5d5f177b9 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -365,7 +365,7 @@ void Minimap_Draw(PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_map_exp.c", 626); - if (play->pauseCtx.state < 4) { + if (play->pauseCtx.state <= PAUSE_STATE_INIT) { switch (play->sceneId) { case SCENE_DEKU_TREE: case SCENE_DODONGOS_CAVERN: @@ -523,7 +523,7 @@ void Map_Update(PlayState* play) { s16 floor; s16 i; - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { + if (!IS_PAUSED(&play->pauseCtx)) { switch (play->sceneId) { case SCENE_DEKU_TREE: case SCENE_DODONGOS_CAVERN: diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index dec9597d5b..28a7ef06e8 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2139,7 +2139,7 @@ void Interface_SetDoAction(PlayState* play, u16 action) { interfaceCtx->unk_1EC = 1; interfaceCtx->unk_1F4 = 0.0f; Interface_LoadActionLabel(interfaceCtx, action, 1); - if (pauseCtx->state != 0) { + if (pauseCtx->state != PAUSE_STATE_OFF) { interfaceCtx->unk_1EC = 3; } } @@ -2556,7 +2556,7 @@ void Magic_Update(PlayState* play) { case MAGIC_STATE_CONSUME_LENS: // Slowly consume magic while lens is on - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && (msgCtx->msgMode == MSGMODE_NONE) && + if (!IS_PAUSED(&play->pauseCtx) && (msgCtx->msgMode == MSGMODE_NONE) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play)) { if ((gSaveContext.save.info.playerData.magic == 0) || @@ -2812,8 +2812,8 @@ void Interface_DrawItemButtons(PlayState* play) { (R_ITEM_BTN_X(3) + R_ITEM_BTN_WIDTH(3)) << 2, (R_ITEM_BTN_Y(3) + R_ITEM_BTN_WIDTH(3)) << 2, G_TX_RENDERTILE, 0, 0, R_ITEM_BTN_DD(3) << 1, R_ITEM_BTN_DD(3) << 1); - if ((pauseCtx->state < 8) || (pauseCtx->state >= 18)) { - if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugState != 0)) { + if (!IS_PAUSE_STATE_GAMEOVER(pauseCtx)) { + if (IS_PAUSED(&play->pauseCtx)) { // Start Button Texture, Color & Label gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 120, 120, 120, interfaceCtx->startAlpha); @@ -2841,8 +2841,7 @@ void Interface_DrawItemButtons(PlayState* play) { } } - if (interfaceCtx->naviCalling && (play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && - (play->csCtx.state == CS_STATE_IDLE)) { + if (interfaceCtx->naviCalling && !IS_PAUSED(&play->pauseCtx) && (play->csCtx.state == CS_STATE_IDLE)) { if (!sCUpInvisible) { // C-Up Button Texture, Color & Label (Navi Text) gDPPipeSync(OVERLAY_DISP++); @@ -3372,7 +3371,7 @@ void Interface_Draw(PlayState* play) { func_8008A994(interfaceCtx); - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 3)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 3)) { // Inventory Equip Effects gSPSegment(OVERLAY_DISP++, 0x08, pauseCtx->iconItemSegment); Gfx_SetupDL_42Overlay(play->state.gfxCtx); @@ -3423,7 +3422,7 @@ void Interface_Draw(PlayState* play) { Gfx_SetupDL_39Overlay(play->state.gfxCtx); - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { + if (!IS_PAUSED(&play->pauseCtx)) { if (gSaveContext.minigameState != 1) { // Carrots rendering if the action corresponds to riding a horse if (interfaceCtx->unk_1EE == 8) { @@ -3520,11 +3519,10 @@ void Interface_Draw(PlayState* play) { } } - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && - (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (msgCtx->msgMode == MSGMODE_NONE) && - !(player->stateFlags2 & PLAYER_STATE2_24) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && - (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play) && (gSaveContext.minigameState != 1) && - (play->shootingGalleryStatus <= 1) && + if (!IS_PAUSED(&play->pauseCtx) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (msgCtx->msgMode == MSGMODE_NONE) && !(player->stateFlags2 & PLAYER_STATE2_24) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && + !Play_InCsMode(play) && (gSaveContext.minigameState != 1) && (play->shootingGalleryStatus <= 1) && !((play->sceneId == SCENE_BOMBCHU_BOWLING_ALLEY) && Flags_GetSwitch(play, 0x38))) { timerId = TIMER_ID_MAIN; @@ -3977,7 +3975,7 @@ void Interface_Update(PlayState* play) { osSyncPrintf("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language); } - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { + if (!IS_PAUSED(&play->pauseCtx)) { if ((gSaveContext.minigameState == 1) || !IS_CUTSCENE_LAYER || ((play->sceneId == SCENE_LON_LON_RANCH) && (gSaveContext.sceneLayer == 4))) { if ((msgCtx->msgMode == MSGMODE_NONE) || @@ -4130,10 +4128,10 @@ void Interface_Update(PlayState* play) { Health_UpdateMeter(play); - if ((gSaveContext.timerState >= TIMER_STATE_ENV_HAZARD_MOVE) && (play->pauseCtx.state == 0) && - (play->pauseCtx.debugState == 0) && (msgCtx->msgMode == MSGMODE_NONE) && - !(player->stateFlags2 & PLAYER_STATE2_24) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && - (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play)) {} + if ((gSaveContext.timerState >= TIMER_STATE_ENV_HAZARD_MOVE) && !IS_PAUSED(&play->pauseCtx) && + (msgCtx->msgMode == MSGMODE_NONE) && !(player->stateFlags2 & PLAYER_STATE2_24) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && + !Play_InCsMode(play)) {} if (gSaveContext.rupeeAccumulator != 0) { if (gSaveContext.rupeeAccumulator > 0) { @@ -4216,7 +4214,7 @@ void Interface_Update(PlayState* play) { WREG(7) = interfaceCtx->unk_1F4; // Update Magic - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && (msgCtx->msgMode == MSGMODE_NONE) && + if (!IS_PAUSED(&play->pauseCtx) && (msgCtx->msgMode == MSGMODE_NONE) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->transitionMode == TRANS_MODE_OFF) && ((play->csCtx.state == CS_STATE_IDLE) || !Player_InCsMode(play))) { diff --git a/src/code/z_play.c b/src/code/z_play.c index 4e3a7b2869..c1840037e1 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -447,7 +447,7 @@ void Play_Init(GameState* thisx) { void Play_Update(PlayState* this) { s32 pad1; - s32 sp80; + s32 isPaused; Input* input; u32 i; s32 pad2; @@ -849,7 +849,7 @@ void Play_Update(PlayState* this) { } PLAY_LOG(3551); - sp80 = (this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0); + isPaused = IS_PAUSED(&this->pauseCtx); PLAY_LOG(3555); AnimationContext_Reset(&this->animationCtx); @@ -859,7 +859,7 @@ void Play_Update(PlayState* this) { PLAY_LOG(3577); - if ((sp80 == 0) && (IREG(72) == 0)) { + if (!isPaused && (IREG(72) == 0)) { PLAY_LOG(3580); this->gameplayFrames++; @@ -926,7 +926,7 @@ void Play_Update(PlayState* this) { if (this->viewpoint != VIEWPOINT_NONE) { if (CHECK_BTN_ALL(input[0].press.button, BTN_CUP)) { - if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0)) { + if (IS_PAUSED(&this->pauseCtx)) { // "Changing viewpoint is prohibited due to the kaleidoscope" osSyncPrintf(VT_FGCOL(CYAN) "カレイドスコープ中につき視点変更を禁止しております\n" VT_RST); } else if (Player_InCsMode(this)) { @@ -950,7 +950,7 @@ void Play_Update(PlayState* this) { PLAY_LOG(3716); - if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0)) { + if (IS_PAUSED(&this->pauseCtx)) { PLAY_LOG(3721); KaleidoScopeCall_Update(this); } else if (this->gameOverCtx.state != GAMEOVER_INACTIVE) { @@ -987,7 +987,7 @@ void Play_Update(PlayState* this) { skip: PLAY_LOG(3801); - if ((sp80 == 0) || gDebugCamEnabled) { + if (!isPaused || gDebugCamEnabled) { s32 pad3[5]; s32 i; @@ -1013,7 +1013,7 @@ skip: } void Play_DrawOverlayElements(PlayState* this) { - if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0)) { + if (IS_PAUSED(&this->pauseCtx)) { KaleidoScopeCall_Draw(this); } diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 981bcf761d..ad90fed5a0 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1641,7 +1641,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve } } -u32 func_80091738(PlayState* play, u8* segment, SkelAnime* skelAnime) { +u32 Player_InitPauseDrawData(PlayState* play, u8* segment, SkelAnime* skelAnime) { s16 linkObjectId = gLinkObjectIds[(void)0, gSaveContext.save.linkAge]; u32 size; void* ptr; @@ -1663,7 +1663,7 @@ u32 func_80091738(PlayState* play, u8* segment, SkelAnime* skelAnime) { SkelAnime_InitLink(play, skelAnime, gPlayerSkelHeaders[(void)0, gSaveContext.save.linkAge], &gPlayerAnim_link_normal_wait, 9, ptr, ptr, PLAYER_LIMB_MAX); - return size + PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE + + return PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE + size + sizeof(Vec3s[PLAYER_LIMB_BUF_COUNT]); } 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 585ccc088e..687401745e 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 @@ -72,7 +72,7 @@ void EnOkarinaEffect_TriggerStorm(EnOkarinaEffect* this, PlayState* play) { void EnOkarinaEffect_ManageStorm(EnOkarinaEffect* this, PlayState* play) { CutsceneFlags_Unset(play, 5); - if (((play->pauseCtx.state == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + if (((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->msgCtx.msgLength == 0) && (!FrameAdvance_IsEnabled(play)) && ((play->transitionMode == TRANS_MODE_OFF) || (gSaveContext.gameMode != GAMEMODE_NORMAL))) || (this->timer >= 250)) { diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c index 031657f4e2..77cd9b4e14 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c @@ -86,7 +86,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { if (pauseCtx->cursorSpecialPos == 0) { pauseCtx->nameColorSet = 0; - if ((pauseCtx->state != 6) || ((pauseCtx->stickAdjX == 0) && (pauseCtx->stickAdjY == 0))) { + if ((pauseCtx->state != PAUSE_STATE_6) || ((pauseCtx->stickAdjX == 0) && (pauseCtx->stickAdjY == 0))) { sp216 = pauseCtx->cursorSlot[PAUSE_QUEST]; } else { phi_s3 = pauseCtx->cursorPoint[PAUSE_QUEST]; @@ -178,7 +178,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { KaleidoScope_SetCursorVtx(pauseCtx, sp216 * 4, pauseCtx->questVtx); - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->cursorSpecialPos == 0)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->cursorSpecialPos == 0)) { if ((sp216 >= QUEST_SONG_MINUET) && (sp216 < QUEST_KOKIRI_EMERALD)) { if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { sp216 = pauseCtx->cursorSlot[PAUSE_QUEST]; @@ -444,7 +444,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - if ((pauseCtx->state == 4) || (pauseCtx->state == 0x12)) { + if ((pauseCtx->state == PAUSE_STATE_OPENING_1) || (pauseCtx->state == PAUSE_STATE_CLOSING)) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, D_8082A070[0][0], D_8082A070[0][1], D_8082A070[0][2], pauseCtx->alpha); } else { @@ -462,7 +462,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { 48, 48, 0); } - if (pauseCtx->state == 6) { + if (pauseCtx->state == PAUSE_STATE_6) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index 4cf5d53f3e..e3e5997a51 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -152,7 +152,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { } } - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_EQUIP)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_EQUIP)) { oldCursorPoint = pauseCtx->cursorPoint[PAUSE_EQUIP]; pauseCtx->cursorColorSet = 0; @@ -469,9 +469,9 @@ void KaleidoScope_DrawEquipment(PlayState* play) { KaleidoScope_SetCursorVtx(pauseCtx, cursorSlot * 4, pauseCtx->equipVtx); - if ((pauseCtx->cursorSpecialPos == 0) && (cursorItem != PAUSE_ITEM_NONE) && (pauseCtx->state == 6) && - (pauseCtx->unk_1E4 == 0) && CHECK_BTN_ALL(input->press.button, BTN_A) && - (pauseCtx->cursorX[PAUSE_EQUIP] != 0)) { + if ((pauseCtx->cursorSpecialPos == 0) && (cursorItem != PAUSE_ITEM_NONE) && + (pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && + CHECK_BTN_ALL(input->press.button, BTN_A) && (pauseCtx->cursorX[PAUSE_EQUIP] != 0)) { if ((gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == 9) || (gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c index 3f9655d2ce..5294bfdcb3 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c @@ -103,7 +103,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { pauseCtx->cursorColorSet = 0; pauseCtx->nameColorSet = 0; - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM)) { moveCursorResult = 0; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; @@ -349,7 +349,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { index = cursorSlot * 4; // required to match? KaleidoScope_SetCursorVtx(pauseCtx, index, pauseCtx->itemVtx); - if ((pauseCtx->debugState == 0) && (pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0)) { + if ((pauseCtx->debugState == 0) && (pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0)) { if (CHECK_BTN_ANY(input->press.button, BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { if (((gSlotAgeReqs[cursorSlot] == 9) || (gSlotAgeReqs[cursorSlot] == ((void)0, gSaveContext.save.linkAge))) && diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c index 771038ae54..b14003eed8 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c @@ -46,7 +46,7 @@ void KaleidoScope_DrawDungeonMap(PlayState* play, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx, "../z_kaleido_map_PAL.c", 123); - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { pauseCtx->cursorColorSet = 0; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_MAP]; @@ -410,7 +410,7 @@ void KaleidoScope_DrawWorldMap(PlayState* play, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx, "../z_kaleido_map_PAL.c", 556); - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { pauseCtx->cursorColorSet = 0; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c index 0fd3310bda..ca2017e335 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_prompt.c @@ -8,7 +8,8 @@ void KaleidoScope_UpdatePrompt(PlayState* play) { s8 stickAdjX = input->rel.stick_x; s16 step; - if (((pauseCtx->state == 7) && (pauseCtx->unk_1EC == 1)) || (pauseCtx->state == 0xE) || (pauseCtx->state == 0x10)) { + if (((pauseCtx->state == PAUSE_STATE_SAVE_PROMPT) && (pauseCtx->unk_1EC == 1)) || + (pauseCtx->state == PAUSE_STATE_14) || (pauseCtx->state == PAUSE_STATE_16)) { if ((pauseCtx->promptChoice == 0) && (stickAdjX >= 30)) { Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 3d36920f88..0ea6f38ed4 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -436,7 +436,7 @@ void KaleidoScope_DrawCursor(PlayState* play, u16 pageIndex) { temp = pauseCtx->unk_1E4; - if ((((pauseCtx->unk_1E4 == 0) || (temp == 8)) && (pauseCtx->state == 6)) || + if ((((pauseCtx->unk_1E4 == 0) || (temp == 8)) && (pauseCtx->state == PAUSE_STATE_6)) || ((pauseCtx->pageIndex == PAUSE_QUEST) && ((temp < 3) || (temp == 5) || (temp == 8)))) { if (pauseCtx->pageIndex == pageIndex) { @@ -519,8 +519,8 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx, "../z_kaleido_scope_PAL.c", 1100); - if ((pauseCtx->state < 8) || (pauseCtx->state > 0x11)) { - if (pauseCtx->state != 7) { + if (!IS_PAUSE_STATE_GAMEOVER(pauseCtx)) { + if (pauseCtx->state != PAUSE_STATE_SAVE_PROMPT) { stepR = ABS(D_8082AB8C - D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][0]) / D_8082AD3C; stepG = ABS(D_8082AB90 - D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][1]) / D_8082AD3C; stepB = ABS(D_8082AB94 - D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][2]) / D_8082AD3C; @@ -785,7 +785,7 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { Gfx_SetupDL_42Opa(gfxCtx); - if ((pauseCtx->state == 7) || ((pauseCtx->state >= 8) && (pauseCtx->state < 0x12))) { + if ((pauseCtx->state == PAUSE_STATE_SAVE_PROMPT) || IS_PAUSE_STATE_GAMEOVER(pauseCtx)) { KaleidoScope_UpdatePrompt(play); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); @@ -822,16 +822,17 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1424), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if ((pauseCtx->state >= 8) && (pauseCtx->state <= 0x11)) { + if (IS_PAUSE_STATE_GAMEOVER(pauseCtx)) { POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->saveVtx, sGameOverTexs); - } else { + } else { // PAUSE_STATE_SAVE_PROMPT POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->saveVtx, sSaveTexs[gSaveContext.language]); } gSPVertex(POLY_OPA_DISP++, &pauseCtx->saveVtx[60], 32, 0); - if (((pauseCtx->state == 7) && (pauseCtx->unk_1EC < 4)) || (pauseCtx->state == 0xE)) { + if (((pauseCtx->state == PAUSE_STATE_SAVE_PROMPT) && (pauseCtx->unk_1EC < 4)) || + (pauseCtx->state == PAUSE_STATE_14)) { POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, sSavePromptTexs[gSaveContext.language], 152, 16, 0); @@ -854,8 +855,9 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, sPromptChoiceTexs[gSaveContext.language][1], 48, 16, 16); - } else if ((pauseCtx->state != 7) || (pauseCtx->unk_1EC < 4)) { - if ((pauseCtx->state != 0xF) && ((pauseCtx->state == 0x10) || (pauseCtx->state == 0x11))) { + } else if ((pauseCtx->state != PAUSE_STATE_SAVE_PROMPT) || (pauseCtx->unk_1EC < 4)) { + if ((pauseCtx->state != PAUSE_STATE_15) && + ((pauseCtx->state == PAUSE_STATE_16) || (pauseCtx->state == PAUSE_STATE_17))) { POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, sContinuePromptTexs[gSaveContext.language], 152, 16, 0); @@ -885,7 +887,7 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - if ((pauseCtx->state != 0x10) && (pauseCtx->state != 0x11)) { + if ((pauseCtx->state != PAUSE_STATE_16) && (pauseCtx->state != PAUSE_STATE_17)) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, pauseCtx->alpha); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); } @@ -1119,7 +1121,8 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); gDPSetEnvColor(POLY_OPA_DISP++, 20, 30, 40, 0); - if ((pauseCtx->state == 6) && (pauseCtx->namedItem != PAUSE_ITEM_NONE) && (pauseCtx->nameDisplayTimer < WREG(89)) && + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->namedItem != PAUSE_ITEM_NONE) && + (pauseCtx->nameDisplayTimer < WREG(89)) && (((u32)pauseCtx->unk_1E4 == 0) || (pauseCtx->unk_1E4 == 2) || ((pauseCtx->unk_1E4 >= 4) && (pauseCtx->unk_1E4 <= 7)) || (pauseCtx->unk_1E4 == 8)) && (pauseCtx->cursorSpecialPos == 0)) { @@ -1198,7 +1201,7 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { gSPVertex(POLY_OPA_DISP++, &pauseCtx->infoPanelVtx[16], 8, 0); - if (pauseCtx->state == 7) { + if (pauseCtx->state == PAUSE_STATE_SAVE_PROMPT) { pauseCtx->infoPanelVtx[16].v.ob[0] = pauseCtx->infoPanelVtx[18].v.ob[0] = WREG(61 + gSaveContext.language); pauseCtx->infoPanelVtx[17].v.ob[0] = pauseCtx->infoPanelVtx[19].v.ob[0] = @@ -1223,7 +1226,7 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, D_8082AD60[gSaveContext.language], D_8082ADE0[gSaveContext.language], 16, 4); } else if (pauseCtx->cursorSpecialPos != 0) { - if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0)) { + if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0)) { pauseCtx->infoPanelVtx[16].v.ob[0] = pauseCtx->infoPanelVtx[18].v.ob[0] = -63; pauseCtx->infoPanelVtx[17].v.ob[0] = pauseCtx->infoPanelVtx[19].v.ob[0] = @@ -1655,7 +1658,7 @@ s16 func_80823A0C(PlayState* play, Vtx* vtx, s16 arg2, s16 arg3) { vtx[phi_t1 + 1].v.ob[0] = vtx[phi_t1 + 3].v.ob[0] = vtx[phi_t1 + 0].v.ob[0] + ptr2[phi_t3]; - if (!((pauseCtx->state >= 8) && (pauseCtx->state <= 0x11))) { + if (!IS_PAUSE_STATE_GAMEOVER(pauseCtx)) { vtx[phi_t1 + 0].v.ob[1] = vtx[phi_t1 + 1].v.ob[1] = ptr3[phi_t3] + pauseCtx->offsetY; } else { vtx[phi_t1 + 0].v.ob[1] = vtx[phi_t1 + 1].v.ob[1] = YREG(60 + phi_t3) + pauseCtx->offsetY; @@ -1786,9 +1789,9 @@ void KaleidoScope_InitVertices(PlayState* play, GraphicsContext* gfxCtx) { pauseCtx->offsetY = 0; - if ((pauseCtx->state == 4) || (pauseCtx->state >= 0x12) || - ((pauseCtx->state == 7) && ((pauseCtx->unk_1EC == 2) || (pauseCtx->unk_1EC == 5))) || - ((pauseCtx->state >= 8) && (pauseCtx->state <= 0xD))) { + if ((pauseCtx->state == PAUSE_STATE_OPENING_1) || (pauseCtx->state >= PAUSE_STATE_CLOSING) || + ((pauseCtx->state == PAUSE_STATE_SAVE_PROMPT) && ((pauseCtx->unk_1EC == 2) || (pauseCtx->unk_1EC == 5))) || + ((pauseCtx->state >= PAUSE_STATE_8) && (pauseCtx->state <= PAUSE_STATE_13))) { pauseCtx->offsetY = 80; } @@ -2296,12 +2299,12 @@ void KaleidoScope_Draw(PlayState* play) { KaleidoScope_SetView(pauseCtx, 0.0f, 0.0f, 64.0f); - if (!((pauseCtx->state >= 8) && (pauseCtx->state <= 0x11))) { + if (!IS_PAUSE_STATE_GAMEOVER(pauseCtx)) { KaleidoScope_DrawInfoPanel(play); } } - if ((pauseCtx->state >= 0xB) && (pauseCtx->state <= 0x11)) { + if ((pauseCtx->state >= PAUSE_STATE_11) && (pauseCtx->state <= PAUSE_STATE_17)) { KaleidoScope_DrawGameOver(play); } @@ -2333,7 +2336,7 @@ void KaleidoScope_GrayOutTextureRGBA32(u32* texture, u16 pixelCount) { } } -void func_808265BC(PlayState* play) { +void KaleidoScope_UpdateOpening(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; pauseCtx->eye.x += D_8082ABAC[pauseCtx->mode] * ZREG(46); @@ -2341,6 +2344,8 @@ void func_808265BC(PlayState* play) { pauseCtx->unk_1EA += 4 * ZREG(46); if (pauseCtx->unk_1EA == (64 * ZREG(47))) { + // Finished opening + func_80084BF4(play, 1); gSaveContext.buttonStatus[0] = D_8082AB6C[pauseCtx->pageIndex][0]; gSaveContext.buttonStatus[1] = D_8082AB6C[pauseCtx->pageIndex][1]; @@ -2349,10 +2354,11 @@ void func_808265BC(PlayState* play) { gSaveContext.buttonStatus[4] = D_8082AB6C[pauseCtx->pageIndex][4]; pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; pauseCtx->unk_1E4 = 0; - pauseCtx->state++; + pauseCtx->state++; // PAUSE_STATE_6 pauseCtx->alpha = 255; Interface_LoadActionLabelB(play, DO_ACTION_SAVE); } else if (pauseCtx->unk_1EA == 64) { + // `ZREG(47)` is always 1 so this normally never happens pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; pauseCtx->mode = (u16)(pauseCtx->pageIndex * 2) + 1; } @@ -2501,10 +2507,10 @@ void KaleidoScope_Update(PlayState* play) { s32 pad; if ((R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_READY) && - (((pauseCtx->state >= 4) && (pauseCtx->state <= 7)) || - ((pauseCtx->state >= 0xA) && (pauseCtx->state <= 0x12)))) { + (((pauseCtx->state >= PAUSE_STATE_OPENING_1) && (pauseCtx->state <= PAUSE_STATE_SAVE_PROMPT)) || + ((pauseCtx->state >= PAUSE_STATE_10) && (pauseCtx->state <= PAUSE_STATE_CLOSING)))) { - if ((((u32)pauseCtx->unk_1E4 == 0) || (pauseCtx->unk_1E4 == 8)) && (pauseCtx->state == 6)) { + if ((((u32)pauseCtx->unk_1E4 == 0) || (pauseCtx->unk_1E4 == 8)) && (pauseCtx->state == PAUSE_STATE_6)) { pauseCtx->stickAdjX = input->rel.stick_x; pauseCtx->stickAdjY = input->rel.stick_y; KaleidoScope_UpdateCursorSize(play); @@ -2513,13 +2519,13 @@ void KaleidoScope_Update(PlayState* play) { KaleidoScope_UpdateCursorSize(play); } - if (pauseCtx->state == 6) { + if (pauseCtx->state == PAUSE_STATE_6) { KaleidoScope_UpdateNamePanel(play); } } switch (pauseCtx->state) { - case 3: + case PAUSE_STATE_INIT: D_808321A8[0] = gSaveContext.buttonStatus[0]; D_808321A8[1] = gSaveContext.buttonStatus[1]; D_808321A8[2] = gSaveContext.buttonStatus[2]; @@ -2538,7 +2544,7 @@ void KaleidoScope_Update(PlayState* play) { //! @bug messed up alignment, should match `ALIGN64` pauseCtx->playerSegment = (void*)(((uintptr_t)play->objectCtx.spaceStart + 0x30) & ~0x3F); - size1 = func_80091738(play, pauseCtx->playerSegment, &pauseCtx->playerSkelAnime); + size1 = Player_InitPauseDrawData(play, pauseCtx->playerSegment, &pauseCtx->playerSkelAnime); osSyncPrintf("プレイヤー size1=%x\n", size1); pauseCtx->iconItemSegment = (void*)ALIGN16((uintptr_t)pauseCtx->playerSegment + size1); @@ -2888,11 +2894,13 @@ void KaleidoScope_Update(PlayState* play) { } } - pauseCtx->state = 4; + pauseCtx->state = PAUSE_STATE_OPENING_1; break; - case 4: + case PAUSE_STATE_OPENING_1: if (pauseCtx->unk_1F4 == 160.0f) { + // First frame in this state + KaleidoScope_SetDefaultCursor(play); KaleidoScope_ProcessPlayerPreRender(); } @@ -2908,26 +2916,27 @@ void KaleidoScope_Update(PlayState* play) { if (pauseCtx->unk_1F4 == 0) { interfaceCtx->startAlpha = 255; WREG(2) = 0; - pauseCtx->state = 5; + pauseCtx->state = PAUSE_STATE_OPENING_2; } - func_808265BC(play); + KaleidoScope_UpdateOpening(play); break; - case 5: + case PAUSE_STATE_OPENING_2: pauseCtx->alpha += (u16)(255 / (WREG(6) + WREG(4))); - func_808265BC(play); - if (pauseCtx->state == 6) { + KaleidoScope_UpdateOpening(play); + + if (pauseCtx->state == PAUSE_STATE_6) { KaleidoScope_UpdateNamePanel(play); } break; - case 6: + case PAUSE_STATE_6: switch (pauseCtx->unk_1E4) { case 0: if (CHECK_BTN_ALL(input->press.button, BTN_START)) { Interface_SetDoAction(play, DO_ACTION_NONE); - pauseCtx->state = 0x12; + pauseCtx->state = PAUSE_STATE_CLOSING; WREG(2) = -6240; func_800F64E0(0); } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { @@ -2941,7 +2950,7 @@ void KaleidoScope_Update(PlayState* play) { gSaveContext.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE; Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL); pauseCtx->unk_1EC = 0; - pauseCtx->state = 7; + pauseCtx->state = PAUSE_STATE_SAVE_PROMPT; } break; @@ -2970,7 +2979,7 @@ void KaleidoScope_Update(PlayState* play) { if (CHECK_BTN_ALL(input->press.button, BTN_START)) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); Interface_SetDoAction(play, DO_ACTION_NONE); - pauseCtx->state = 0x12; + pauseCtx->state = PAUSE_STATE_CLOSING; WREG(2) = -6240; func_800F64E0(0); pauseCtx->unk_1E4 = 0; @@ -2988,7 +2997,7 @@ void KaleidoScope_Update(PlayState* play) { gSaveContext.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE; Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL); pauseCtx->unk_1EC = 0; - pauseCtx->state = 7; + pauseCtx->state = PAUSE_STATE_SAVE_PROMPT; } else if (pauseCtx->ocarinaStaff->state == pauseCtx->ocarinaSongIdx) { Audio_PlaySfxGeneral(NA_SE_SY_TRE_BOX_APPEAR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -3021,7 +3030,7 @@ void KaleidoScope_Update(PlayState* play) { if (CHECK_BTN_ALL(input->press.button, BTN_START)) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); Interface_SetDoAction(play, DO_ACTION_NONE); - pauseCtx->state = 0x12; + pauseCtx->state = PAUSE_STATE_CLOSING; WREG(2) = -6240; func_800F64E0(0); pauseCtx->unk_1E4 = 0; @@ -3038,7 +3047,7 @@ void KaleidoScope_Update(PlayState* play) { gSaveContext.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE; Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL); pauseCtx->unk_1EC = 0; - pauseCtx->state = 7; + pauseCtx->state = PAUSE_STATE_SAVE_PROMPT; } break; @@ -3051,7 +3060,7 @@ void KaleidoScope_Update(PlayState* play) { } break; - case 7: + case PAUSE_STATE_SAVE_PROMPT: switch (pauseCtx->unk_1EC) { case 0: pauseCtx->unk_204 -= 314.0f / WREG(6); @@ -3120,7 +3129,7 @@ void KaleidoScope_Update(PlayState* play) { WREG(16) += WREG(25) / WREG(6); WREG(17) += WREG(26) / WREG(6); if (pauseCtx->unk_204 >= -314.0f) { - pauseCtx->state = 6; + pauseCtx->state = PAUSE_STATE_6; pauseCtx->unk_1EC = 0; pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = 0.0f; pauseCtx->unk_204 = -314.0f; @@ -3143,7 +3152,7 @@ void KaleidoScope_Update(PlayState* play) { } } else { pauseCtx->debugState = 0; - pauseCtx->state = 0x13; + pauseCtx->state = PAUSE_STATE_RESUME_GAMEPLAY; pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = 160.0f; pauseCtx->namedItem = PAUSE_ITEM_NONE; pauseCtx->unk_1E4 = 0; @@ -3153,7 +3162,7 @@ void KaleidoScope_Update(PlayState* play) { } break; - case 0xA: + case PAUSE_STATE_10: pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->dungeonMapSlot = VREG(30) + 3; WREG(16) = -175; @@ -3210,10 +3219,10 @@ void KaleidoScope_Update(PlayState* play) { D_8082B260 = 30; VREG(88) = 98; pauseCtx->promptChoice = 0; - pauseCtx->state++; + pauseCtx->state++; // PAUSE_STATE_11 break; - case 0xB: + case PAUSE_STATE_11: stepR = ABS(D_8082AB8C - 30) / D_8082B260; stepG = ABS(D_8082AB90) / D_8082B260; stepB = ABS(D_8082AB94) / D_8082B260; @@ -3269,19 +3278,19 @@ void KaleidoScope_Update(PlayState* play) { D_8082ABA0 = 130; D_8082ABA4 = 0; - pauseCtx->state++; + pauseCtx->state++; // PAUSE_STATE_12 D_8082B260 = 40; } break; - case 0xC: + case PAUSE_STATE_12: D_8082B260--; if (D_8082B260 == 0) { - pauseCtx->state = 0xD; + pauseCtx->state = PAUSE_STATE_13; } break; - case 0xD: + case PAUSE_STATE_13: pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = pauseCtx->unk_204 -= 160.0f / WREG(6); pauseCtx->infoPanelOffsetY += 40 / WREG(6); @@ -3297,7 +3306,7 @@ void KaleidoScope_Update(PlayState* play) { VREG(88) = 66; WREG(2) = 0; pauseCtx->alpha = 255; - pauseCtx->state = 0xE; + pauseCtx->state = PAUSE_STATE_14; gSaveContext.save.info.playerData.deaths++; if (gSaveContext.save.info.playerData.deaths > 999) { gSaveContext.save.info.playerData.deaths = 999; @@ -3306,13 +3315,13 @@ void KaleidoScope_Update(PlayState* play) { osSyncPrintf("kscope->angle_s = %f\n", pauseCtx->unk_204); break; - case 0xE: + case PAUSE_STATE_14: if (CHECK_BTN_ALL(input->press.button, BTN_A)) { if (pauseCtx->promptChoice != 0) { pauseCtx->promptChoice = 0; Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - pauseCtx->state = 0x10; + pauseCtx->state = PAUSE_STATE_16; gameOverCtx->state++; } else { Audio_PlaySfxGeneral(NA_SE_SY_PIECE_OF_HEART, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, @@ -3321,26 +3330,26 @@ void KaleidoScope_Update(PlayState* play) { Play_SaveSceneFlags(play); gSaveContext.save.info.playerData.savedSceneId = play->sceneId; Sram_WriteSave(&play->sramCtx); - pauseCtx->state = 0xF; + pauseCtx->state = PAUSE_STATE_15; D_8082B25C = 3; } } break; - case 0xF: + case PAUSE_STATE_15: D_8082B25C--; if (D_8082B25C == 0) { - pauseCtx->state = 0x10; + pauseCtx->state = PAUSE_STATE_16; gameOverCtx->state++; } else if ((D_8082B25C <= 80) && (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_START))) { - pauseCtx->state = 0x10; + pauseCtx->state = PAUSE_STATE_16; gameOverCtx->state++; func_800F64E0(0); } break; - case 0x10: + case PAUSE_STATE_16: if (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_START)) { if (pauseCtx->promptChoice == 0) { Audio_PlaySfxGeneral(NA_SE_SY_PIECE_OF_HEART, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, @@ -3406,16 +3415,16 @@ void KaleidoScope_Update(PlayState* play) { &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } - pauseCtx->state = 0x11; + pauseCtx->state = PAUSE_STATE_17; } break; - case 0x11: + case PAUSE_STATE_17: if (interfaceCtx->unk_244 != 255) { interfaceCtx->unk_244 += 10; if (interfaceCtx->unk_244 >= 255) { interfaceCtx->unk_244 = 255; - pauseCtx->state = 0; + pauseCtx->state = PAUSE_STATE_OFF; R_UPDATE_RATE = 3; R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_OFF; func_800981B8(&play->objectCtx); @@ -3449,7 +3458,7 @@ void KaleidoScope_Update(PlayState* play) { } break; - case 0x12: + case PAUSE_STATE_CLOSING: if (pauseCtx->unk_1F4 != 160.0f) { pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 += 160.0f / WREG(6); pauseCtx->infoPanelOffsetY -= 40 / WREG(6); @@ -3463,7 +3472,7 @@ void KaleidoScope_Update(PlayState* play) { } } else { pauseCtx->debugState = 0; - pauseCtx->state = 0x13; + pauseCtx->state = PAUSE_STATE_RESUME_GAMEPLAY; pauseCtx->unk_200 = 160.0f; pauseCtx->unk_1FC = 160.0f; pauseCtx->unk_1F8 = 160.0f; @@ -3473,10 +3482,11 @@ void KaleidoScope_Update(PlayState* play) { } break; - case 0x13: - pauseCtx->state = 0; + case PAUSE_STATE_RESUME_GAMEPLAY: + pauseCtx->state = PAUSE_STATE_OFF; R_UPDATE_RATE = 3; R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_OFF; + func_800981B8(&play->objectCtx); func_800418D0(&play->colCtx, play); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c b/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c index 56d27d4cba..4e1ab85d45 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark.c @@ -80,7 +80,7 @@ void PauseMapMark_DrawForDungeon(PlayState* play) { Matrix_Push(); - if ((play->pauseCtx.state == 4) || (play->pauseCtx.state >= 0x12)) { + if ((play->pauseCtx.state == PAUSE_STATE_OPENING_1) || (play->pauseCtx.state >= PAUSE_STATE_CLOSING)) { Matrix_Translate(-36.0f, 101.0f, 0.0f, MTXMODE_APPLY); } else { Matrix_Translate(-36.0f, 21.0f, 0.0f, MTXMODE_APPLY);