From fefeb369dd19172d5eb419f8c8373cfb10d59d19 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Fri, 22 Sep 2023 20:48:09 +0200 Subject: [PATCH] Name the main pause state and add placeholder enum for main (sub)states (#1551) --- include/z64pause.h | 18 ++- src/code/z_kaleido_scope_call.c | 4 +- src/code/z_kaleido_setup.c | 4 +- src/code/z_parameter.c | 2 +- .../ovl_kaleido_scope/z_kaleido_collect.c | 48 ++++---- .../ovl_kaleido_scope/z_kaleido_equipment.c | 15 +-- .../misc/ovl_kaleido_scope/z_kaleido_item.c | 15 ++- .../ovl_kaleido_scope/z_kaleido_map_PAL.c | 6 +- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 107 ++++++++++-------- 9 files changed, 125 insertions(+), 94 deletions(-) diff --git a/include/z64pause.h b/include/z64pause.h index f25d5c6ed1..1cc810c318 100644 --- a/include/z64pause.h +++ b/include/z64pause.h @@ -33,7 +33,7 @@ typedef enum { /* 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. + /* 6 */ PAUSE_STATE_MAIN, // 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, @@ -55,6 +55,20 @@ typedef enum { #define IS_PAUSED(pauseCtx) \ (((pauseCtx)->state != PAUSE_STATE_OFF) || ((pauseCtx)->debugState != 0)) +// Sub-states of PAUSE_STATE_MAIN +typedef enum { + /* 0 */ PAUSE_MAIN_STATE_IDLE, + /* 1 */ PAUSE_MAIN_STATE_1, + /* 2 */ PAUSE_MAIN_STATE_2, + /* 3 */ PAUSE_MAIN_STATE_3, + /* 4 */ PAUSE_MAIN_STATE_4, + /* 5 */ PAUSE_MAIN_STATE_5, + /* 6 */ PAUSE_MAIN_STATE_6, + /* 7 */ PAUSE_MAIN_STATE_7, + /* 8 */ PAUSE_MAIN_STATE_8, + /* 9 */ PAUSE_MAIN_STATE_9 +} PauseMainState; + typedef struct { /* 0x0000 */ View view; /* 0x0128 */ u8* iconItemSegment; @@ -83,7 +97,7 @@ typedef struct { /* 0x01D4 */ u16 state; /* 0x01D6 */ u16 debugState; /* 0x01D8 */ Vec3f eye; - /* 0x01E4 */ u16 unk_1E4; + /* 0x01E4 */ u16 mainState; /* 0x01E6 */ u16 mode; /* 0x01E8 */ u16 pageIndex; // "kscp_pos" /* 0x01EA */ u16 unk_1EA; diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 4278b12efb..c61eb33546 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -62,7 +62,7 @@ void KaleidoScopeCall_Update(PlayState* play) { 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->mainState = PAUSE_MAIN_STATE_IDLE; pauseCtx->unk_1EC = 0; pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; // PAUSE_STATE_WAIT_BG_PRERENDER } @@ -70,7 +70,7 @@ void KaleidoScopeCall_Update(PlayState* play) { 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->mainState = PAUSE_MAIN_STATE_IDLE; pauseCtx->unk_1EC = 0; pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; // PAUSE_STATE_9 } else if ((pauseCtx->state == PAUSE_STATE_WAIT_BG_PRERENDER) || (pauseCtx->state == PAUSE_STATE_9)) { diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 554282ba15..9f264378b8 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -31,7 +31,7 @@ void KaleidoSetup_Update(PlayState* play) { WREG(17) = 155; pauseCtx->unk_1EA = 0; - pauseCtx->unk_1E4 = 1; + pauseCtx->mainState = PAUSE_MAIN_STATE_1; if (ZREG(48) == 0) { pauseCtx->eye.x = sKaleidoSetupEyeX0[pauseCtx->pageIndex]; @@ -71,7 +71,7 @@ void KaleidoSetup_Init(PlayState* play) { pauseCtx->debugState = 0; pauseCtx->alpha = 0; pauseCtx->unk_1EA = 0; - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; pauseCtx->mode = 0; pauseCtx->pageIndex = PAUSE_ITEM; diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 28a7ef06e8..86687ca92d 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -3371,7 +3371,7 @@ void Interface_Draw(PlayState* play) { func_8008A994(interfaceCtx); - if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 3)) { + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_3)) { // Inventory Equip Effects gSPSegment(OVERLAY_DISP++, 0x08, pauseCtx->iconItemSegment); Gfx_SetupDL_42Overlay(play->state.gfxCtx); 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 77cd9b4e14..bad87200ab 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c @@ -79,14 +79,15 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx, "../z_kaleido_collect.c", 248); - if ((((u32)pauseCtx->unk_1E4 == 0) || (pauseCtx->unk_1E4 == 5) || (pauseCtx->unk_1E4 == 8)) && + if ((((u32)pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) || (pauseCtx->mainState == PAUSE_MAIN_STATE_5) || + (pauseCtx->mainState == PAUSE_MAIN_STATE_8)) && (pauseCtx->pageIndex == PAUSE_QUEST)) { pauseCtx->cursorColorSet = 0; if (pauseCtx->cursorSpecialPos == 0) { pauseCtx->nameColorSet = 0; - if ((pauseCtx->state != PAUSE_STATE_6) || ((pauseCtx->stickAdjX == 0) && (pauseCtx->stickAdjY == 0))) { + if ((pauseCtx->state != PAUSE_STATE_MAIN) || ((pauseCtx->stickAdjX == 0) && (pauseCtx->stickAdjY == 0))) { sp216 = pauseCtx->cursorSlot[PAUSE_QUEST]; } else { phi_s3 = pauseCtx->cursorPoint[PAUSE_QUEST]; @@ -95,7 +96,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { phi_s0 = D_8082A1AC[phi_s3][2]; if (phi_s0 == -3) { KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; } else { while (phi_s0 >= 0) { if ((s16)KaleidoScope_UpdateQuestStatusPoint(pauseCtx, phi_s0) != 0) { @@ -108,7 +109,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { phi_s0 = D_8082A1AC[phi_s3][3]; if (phi_s0 == -2) { KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; } else { while (phi_s0 >= 0) { if ((s16)KaleidoScope_UpdateQuestStatusPoint(pauseCtx, phi_s0) != 0) { @@ -138,7 +139,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { } if (phi_s3 != pauseCtx->cursorPoint[PAUSE_QUEST]) { - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } @@ -178,7 +179,8 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { KaleidoScope_SetCursorVtx(pauseCtx, sp216 * 4, pauseCtx->questVtx); - if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->cursorSpecialPos == 0)) { + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + (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]; @@ -201,19 +203,19 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { VREG(23) = -49; VREG(24) = -46; VREG(25) = -41; - pauseCtx->unk_1E4 = 8; + pauseCtx->mainState = PAUSE_MAIN_STATE_8; AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); } } - } else if (pauseCtx->unk_1E4 == 5) { + } else if (pauseCtx->mainState == PAUSE_MAIN_STATE_5) { if ((pauseCtx->stickAdjX != 0) || (pauseCtx->stickAdjY != 0)) { - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); } - } else if (pauseCtx->unk_1E4 == 8) { + } else if (pauseCtx->mainState == PAUSE_MAIN_STATE_8) { if (CHECK_BTN_ALL(input->press.button, BTN_A) && (sp216 >= QUEST_SONG_MINUET) && (sp216 < QUEST_KOKIRI_EMERALD)) { - pauseCtx->unk_1E4 = 9; + pauseCtx->mainState = PAUSE_MAIN_STATE_9; D_8082A120 = 10; } } @@ -262,7 +264,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { } } else { - if (pauseCtx->unk_1E4 == 9) { + if (pauseCtx->mainState == PAUSE_MAIN_STATE_9) { pauseCtx->cursorColorSet = 8; if (--D_8082A120 == 0) { @@ -282,7 +284,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); pauseCtx->ocarinaSongIdx = gOcarinaSongItemMap[sp216 - QUEST_SONG_MINUET]; AudioOcarina_SetPlaybackSong(pauseCtx->ocarinaSongIdx + 1, 1); - pauseCtx->unk_1E4 = 2; + pauseCtx->mainState = PAUSE_MAIN_STATE_2; pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); pauseCtx->ocarinaStaff->pos = 0; sp216 = pauseCtx->cursorSlot[PAUSE_QUEST]; @@ -462,23 +464,24 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { 48, 48, 0); } - if (pauseCtx->state == PAUSE_STATE_6) { + if (pauseCtx->state == PAUSE_STATE_MAIN) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); sp21A += 4; if ((pauseCtx->cursorSpecialPos == 0) && (sp216 >= 6) && (sp216 < 0x12)) { - if ((pauseCtx->unk_1E4 < 3) || (pauseCtx->unk_1E4 == 5) || (pauseCtx->unk_1E4 == 8)) { + if ((pauseCtx->mainState < PAUSE_MAIN_STATE_3) || (pauseCtx->mainState == PAUSE_MAIN_STATE_5) || + (pauseCtx->mainState == PAUSE_MAIN_STATE_8)) { if (pauseCtx->cursorItem[pauseCtx->pageIndex] != PAUSE_ITEM_NONE) { pauseCtx->cursorColorSet = 8; - if ((pauseCtx->unk_1E4 >= 2) && (pauseCtx->unk_1E4 < 7)) { + if ((pauseCtx->mainState >= PAUSE_MAIN_STATE_2) && (pauseCtx->mainState < PAUSE_MAIN_STATE_7)) { pauseCtx->cursorColorSet = 0; } } } } - if (pauseCtx->unk_1E4 == 2) { + if (pauseCtx->mainState == PAUSE_MAIN_STATE_2) { pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); if (pauseCtx->ocarinaStaff->pos != 0) { @@ -523,7 +526,8 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); } } - } else if (((pauseCtx->unk_1E4 >= 4) && (pauseCtx->unk_1E4 <= 6)) || (pauseCtx->unk_1E4 == 8)) { + } else if (((pauseCtx->mainState >= PAUSE_MAIN_STATE_4) && (pauseCtx->mainState <= PAUSE_MAIN_STATE_6)) || + (pauseCtx->mainState == PAUSE_MAIN_STATE_8)) { sp224 = pauseCtx->ocarinaSongIdx; sp226 = gOcarinaSongButtons[sp224].numButtons; @@ -536,7 +540,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { gDPPipeSync(POLY_OPA_DISP++); - if (pauseCtx->unk_1E4 == 8) { + if (pauseCtx->mainState == PAUSE_MAIN_STATE_8) { if (gOcarinaSongButtons[sp224].buttonsIndex[phi_s3] == OCARINA_BTN_A) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 80, 255, 150, 200); } else { @@ -557,7 +561,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); } - if (pauseCtx->unk_1E4 != 8) { + if (pauseCtx->mainState != PAUSE_MAIN_STATE_8) { pauseCtx->ocarinaStaff = AudioOcarina_GetPlayingStaff(); if (pauseCtx->ocarinaStaff->pos != 0) { @@ -609,7 +613,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); } - if (pauseCtx->unk_1E4 == 4) { + if (pauseCtx->mainState == PAUSE_MAIN_STATE_4) { for (phi_s3 = 0; phi_s3 < 8; phi_s3++) { D_8082A124[phi_s3] = 0xFF; D_8082A150[phi_s3] = 0; @@ -621,7 +625,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); pauseCtx->ocarinaStaff->pos = 0; pauseCtx->ocarinaStaff->state = 0xFE; - pauseCtx->unk_1E4 = 5; + pauseCtx->mainState = PAUSE_MAIN_STATE_5; } } } 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 1af28c4a72..3dd50e6fa9 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,8 @@ void KaleidoScope_DrawEquipment(PlayState* play) { } } - if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_EQUIP)) { + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + (pauseCtx->pageIndex == PAUSE_EQUIP)) { oldCursorPoint = pauseCtx->cursorPoint[PAUSE_EQUIP]; pauseCtx->cursorColorSet = 0; @@ -468,7 +469,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { KaleidoScope_SetCursorVtx(pauseCtx, cursorSlot * 4, pauseCtx->equipVtx); if ((pauseCtx->cursorSpecialPos == 0) && (cursorItem != PAUSE_ITEM_NONE) && - (pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && + (pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && CHECK_BTN_ALL(input->press.button, BTN_A) && (pauseCtx->cursorX[PAUSE_EQUIP] != 0)) { if (CHECK_AGE_REQ_EQUIP(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP])) { @@ -498,7 +499,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - pauseCtx->unk_1E4 = 7; + pauseCtx->mainState = PAUSE_MAIN_STATE_7; sEquipTimer = 10; } else { Audio_PlaySfxGeneral(NA_SE_SY_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, @@ -510,13 +511,13 @@ void KaleidoScope_DrawEquipment(PlayState* play) { Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } - } else if ((pauseCtx->unk_1E4 == 7) && (pauseCtx->pageIndex == PAUSE_EQUIP)) { + } else if ((pauseCtx->mainState == PAUSE_MAIN_STATE_7) && (pauseCtx->pageIndex == PAUSE_EQUIP)) { KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_EQUIP] * 4, pauseCtx->equipVtx); pauseCtx->cursorColorSet = 8; sEquipTimer--; if (sEquipTimer == 0) { - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; } } @@ -586,11 +587,11 @@ void KaleidoScope_DrawEquipment(PlayState* play) { KaleidoScope_DrawPlayerWork(play); - if ((pauseCtx->unk_1E4 == 7) && (sEquipTimer == 10)) { + if ((pauseCtx->mainState == PAUSE_MAIN_STATE_7) && (sEquipTimer == 10)) { KaleidoScope_SetupPlayerPreRender(play); } - if ((pauseCtx->unk_1E4 == 7) && (sEquipTimer == 9)) { + if ((pauseCtx->mainState == PAUSE_MAIN_STATE_7) && (sEquipTimer == 9)) { //! @bug: This function shouldn't take any arguments KaleidoScope_ProcessPlayerPreRender(play); } 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 6d8a846c96..7a0c995036 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,8 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { pauseCtx->cursorColorSet = 0; pauseCtx->nameColorSet = 0; - if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM)) { + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + (pauseCtx->pageIndex == PAUSE_ITEM)) { moveCursorResult = 0; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; @@ -348,7 +349,8 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { index = cursorSlot * 4; // required to match? KaleidoScope_SetCursorVtx(pauseCtx, index, pauseCtx->itemVtx); - if ((pauseCtx->debugState == 0) && (pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0)) { + if ((pauseCtx->debugState == 0) && (pauseCtx->state == PAUSE_STATE_MAIN) && + (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE)) { if (CHECK_BTN_ANY(input->press.button, BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { if (CHECK_AGE_REQ_SLOT(cursorSlot) && (cursorItem != ITEM_SOLD_OUT)) { if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { @@ -361,7 +363,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { pauseCtx->equipTargetItem = cursorItem; pauseCtx->equipTargetSlot = cursorSlot; - pauseCtx->unk_1E4 = 3; + pauseCtx->mainState = PAUSE_MAIN_STATE_3; pauseCtx->equipAnimX = pauseCtx->itemVtx[index].v.ob[0] * 10; pauseCtx->equipAnimY = pauseCtx->itemVtx[index].v.ob[1] * 10; pauseCtx->equipAnimAlpha = 255; @@ -410,7 +412,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } - } else if ((pauseCtx->unk_1E4 == 3) && (pauseCtx->pageIndex == PAUSE_ITEM)) { + } else if ((pauseCtx->mainState == PAUSE_MAIN_STATE_3) && (pauseCtx->pageIndex == PAUSE_ITEM)) { KaleidoScope_SetCursorVtx(pauseCtx, cursorSlot * 4, pauseCtx->itemVtx); pauseCtx->cursorColorSet = 4; } @@ -434,7 +436,8 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); if (gSaveContext.save.info.inventory.items[i] != ITEM_NONE) { - if ((pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM) && (pauseCtx->cursorSpecialPos == 0)) { + if ((pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && (pauseCtx->pageIndex == PAUSE_ITEM) && + (pauseCtx->cursorSpecialPos == 0)) { if (CHECK_AGE_REQ_SLOT(i)) { if ((sEquipState == 2) && (i == 3)) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, magicArrowEffectsR[pauseCtx->equipTargetItem - 0xBF], @@ -815,7 +818,7 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) { gSaveContext.save.info.equips.cButtonSlots[2]); } - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; sEquipMoveTimer = 10; WREG(90) = 320; WREG(87) = WREG(91); 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 b14003eed8..91ed62d4b8 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,8 @@ void KaleidoScope_DrawDungeonMap(PlayState* play, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx, "../z_kaleido_map_PAL.c", 123); - if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + (pauseCtx->pageIndex == PAUSE_MAP)) { pauseCtx->cursorColorSet = 0; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_MAP]; @@ -410,7 +411,8 @@ void KaleidoScope_DrawWorldMap(PlayState* play, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx, "../z_kaleido_map_PAL.c", 556); - if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + (pauseCtx->pageIndex == PAUSE_MAP)) { pauseCtx->cursorColorSet = 0; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; 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 839372999c..8b54f595ef 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 @@ -491,7 +491,7 @@ void KaleidoScope_SetDefaultCursor(PlayState* play) { } void KaleidoScope_SwitchPage(PauseContext* pauseCtx, u8 pt) { - pauseCtx->unk_1E4 = 1; + pauseCtx->mainState = PAUSE_MAIN_STATE_1; pauseCtx->unk_1EA = 0; if (!pt) { @@ -560,10 +560,12 @@ void KaleidoScope_DrawCursor(PlayState* play, u16 pageIndex) { OPEN_DISPS(play->state.gfxCtx, "../z_kaleido_scope_PAL.c", 955); - temp = pauseCtx->unk_1E4; + temp = pauseCtx->mainState; - if ((((pauseCtx->unk_1E4 == 0) || (temp == 8)) && (pauseCtx->state == PAUSE_STATE_6)) || - ((pauseCtx->pageIndex == PAUSE_QUEST) && ((temp < 3) || (temp == 5) || (temp == 8)))) { + if ((((pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) || (temp == PAUSE_MAIN_STATE_8)) && + (pauseCtx->state == PAUSE_STATE_MAIN)) || + ((pauseCtx->pageIndex == PAUSE_QUEST) && + ((temp < PAUSE_MAIN_STATE_3) || (temp == PAUSE_MAIN_STATE_5) || (temp == PAUSE_MAIN_STATE_8)))) { if (pauseCtx->pageIndex == pageIndex) { s16 i; @@ -1153,7 +1155,7 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { pauseCtx->infoPanelVtx[5].v.ob[0] = pauseCtx->infoPanelVtx[7].v.ob[0] = pauseCtx->infoPanelVtx[4].v.ob[0] + 72; - if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) && (pauseCtx->unk_1E4 == 0)) { + if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE)) { pauseCtx->infoPanelVtx[8].v.ob[0] = pauseCtx->infoPanelVtx[10].v.ob[0] = WREG(16); pauseCtx->infoPanelVtx[9].v.ob[0] = pauseCtx->infoPanelVtx[11].v.ob[0] = pauseCtx->infoPanelVtx[8].v.ob[0] + 24; @@ -1173,7 +1175,7 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { pauseCtx->infoPanelVtx[8].v.ob[1] - 26; } - if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) && (pauseCtx->unk_1E4 == 0)) { + if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE)) { pauseCtx->infoPanelVtx[12].v.ob[0] = pauseCtx->infoPanelVtx[14].v.ob[0] = WREG(17); pauseCtx->infoPanelVtx[13].v.ob[0] = pauseCtx->infoPanelVtx[15].v.ob[0] = @@ -1214,7 +1216,7 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { gSPDisplayList(POLY_OPA_DISP++, gItemNamePanelDL); - if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) && (pauseCtx->unk_1E4 == 0)) { + if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE)) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, D_808321A0, D_808321A2, D_808321A4, D_808321A6); } @@ -1222,7 +1224,7 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 210, 255, 220); - if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) && (pauseCtx->unk_1E4 == 0)) { + if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE)) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, D_808321A0, D_808321A2, D_808321A4, D_808321A6); } @@ -1247,13 +1249,15 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); gDPSetEnvColor(POLY_OPA_DISP++, 20, 30, 40, 0); - if ((pauseCtx->state == PAUSE_STATE_6) && (pauseCtx->namedItem != PAUSE_ITEM_NONE) && + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (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)) && + (((u32)pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) || (pauseCtx->mainState == PAUSE_MAIN_STATE_2) || + ((pauseCtx->mainState >= PAUSE_MAIN_STATE_4) && (pauseCtx->mainState <= PAUSE_MAIN_STATE_7)) || + (pauseCtx->mainState == PAUSE_MAIN_STATE_8)) && (pauseCtx->cursorSpecialPos == 0)) { - if (((u32)pauseCtx->unk_1E4 == 0) || (pauseCtx->unk_1E4 == 2) || - ((pauseCtx->unk_1E4 >= 4) && (pauseCtx->unk_1E4 <= 7)) || (pauseCtx->unk_1E4 == 8)) { + if (((u32)pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) || (pauseCtx->mainState == PAUSE_MAIN_STATE_2) || + ((pauseCtx->mainState >= PAUSE_MAIN_STATE_4) && (pauseCtx->mainState <= PAUSE_MAIN_STATE_7)) || + (pauseCtx->mainState == PAUSE_MAIN_STATE_8)) { 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] = @@ -1317,7 +1321,8 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { QUEST_ICON_HEIGHT, 0); } } - } else if ((pauseCtx->unk_1E4 < 3) || (pauseCtx->unk_1E4 == 7) || (pauseCtx->unk_1E4 == 8)) { + } else if ((pauseCtx->mainState < PAUSE_MAIN_STATE_3) || (pauseCtx->mainState == PAUSE_MAIN_STATE_7) || + (pauseCtx->mainState == PAUSE_MAIN_STATE_8)) { pauseCtx->infoPanelVtx[20].v.ob[1] = pauseCtx->infoPanelVtx[21].v.ob[1] = temp; pauseCtx->infoPanelVtx[22].v.ob[1] = pauseCtx->infoPanelVtx[23].v.ob[1] = @@ -1352,7 +1357,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 == PAUSE_STATE_6) && (pauseCtx->unk_1E4 == 0)) { + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE)) { 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] = @@ -1509,7 +1514,7 @@ void KaleidoScope_UpdateNamePanel(PlayState* play) { } } else if (pauseCtx->nameColorSet == 0) { if (((pauseCtx->pageIndex == PAUSE_QUEST) && (pauseCtx->cursorSlot[PAUSE_QUEST] >= 6) && - (pauseCtx->cursorSlot[PAUSE_QUEST] <= 0x11) && (pauseCtx->unk_1E4 == 8)) || + (pauseCtx->cursorSlot[PAUSE_QUEST] <= 0x11) && (pauseCtx->mainState == PAUSE_MAIN_STATE_8)) || (pauseCtx->pageIndex == PAUSE_ITEM) || ((pauseCtx->pageIndex == PAUSE_EQUIP) && (pauseCtx->cursorX[PAUSE_EQUIP] != 0))) { if (pauseCtx->namedItem != ITEM_SOLD_OUT) { @@ -1553,7 +1558,7 @@ void func_808237B4(PlayState* play, Input* input) { if (pauseCtx->unk_1EA == 64) { pauseCtx->unk_1EA = 0; pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; } } } @@ -2479,8 +2484,8 @@ void KaleidoScope_UpdateOpening(PlayState* play) { gSaveContext.buttonStatus[3] = D_8082AB6C[pauseCtx->pageIndex][3]; gSaveContext.buttonStatus[4] = D_8082AB6C[pauseCtx->pageIndex][4]; pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; - pauseCtx->unk_1E4 = 0; - pauseCtx->state++; // PAUSE_STATE_6 + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + pauseCtx->state++; // PAUSE_STATE_MAIN pauseCtx->alpha = 255; Interface_LoadActionLabelB(play, DO_ACTION_SAVE); } else if (pauseCtx->unk_1EA == 64) { @@ -2613,7 +2618,7 @@ void KaleidoScope_UpdateDungeonMap(PlayState* play) { } void KaleidoScope_Update(PlayState* play) { - static s16 D_8082B258 = 0; + static s16 D_8082B258 = PAUSE_MAIN_STATE_IDLE; static s16 D_8082B25C = 10; static s16 D_8082B260 = 0; PauseContext* pauseCtx = &play->pauseCtx; @@ -2636,16 +2641,18 @@ void KaleidoScope_Update(PlayState* play) { (((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 == PAUSE_STATE_6)) { + if ((((u32)pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) || (pauseCtx->mainState == PAUSE_MAIN_STATE_8)) && + (pauseCtx->state == PAUSE_STATE_MAIN)) { pauseCtx->stickAdjX = input->rel.stick_x; pauseCtx->stickAdjY = input->rel.stick_y; KaleidoScope_UpdateCursorSize(play); KaleidoScope_HandlePageToggles(pauseCtx, input); - } else if ((pauseCtx->pageIndex == PAUSE_QUEST) && ((pauseCtx->unk_1E4 < 3) || (pauseCtx->unk_1E4 == 5))) { + } else if ((pauseCtx->pageIndex == PAUSE_QUEST) && + ((pauseCtx->mainState < PAUSE_MAIN_STATE_3) || (pauseCtx->mainState == PAUSE_MAIN_STATE_5))) { KaleidoScope_UpdateCursorSize(play); } - if (pauseCtx->state == PAUSE_STATE_6) { + if (pauseCtx->state == PAUSE_STATE_MAIN) { KaleidoScope_UpdateNamePanel(play); } } @@ -3052,14 +3059,14 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->alpha += (u16)(255 / (WREG(6) + WREG(4))); KaleidoScope_UpdateOpening(play); - if (pauseCtx->state == PAUSE_STATE_6) { + if (pauseCtx->state == PAUSE_STATE_MAIN) { KaleidoScope_UpdateNamePanel(play); } break; - case PAUSE_STATE_6: - switch (pauseCtx->unk_1E4) { - case 0: + case PAUSE_STATE_MAIN: + switch (pauseCtx->mainState) { + case PAUSE_MAIN_STATE_IDLE: if (CHECK_BTN_ALL(input->press.button, BTN_START)) { Interface_SetDoAction(play, DO_ACTION_NONE); pauseCtx->state = PAUSE_STATE_CLOSING; @@ -3080,26 +3087,26 @@ void KaleidoScope_Update(PlayState* play) { } break; - case 1: + case PAUSE_MAIN_STATE_1: func_808237B4(play, play->state.input); break; - case 2: + case PAUSE_MAIN_STATE_2: pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); if (pauseCtx->ocarinaStaff->state == 0) { - pauseCtx->unk_1E4 = 4; + pauseCtx->mainState = PAUSE_MAIN_STATE_4; AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); } break; - case 3: + case PAUSE_MAIN_STATE_3: KaleidoScope_UpdateItemEquip(play); break; - case 4: + case PAUSE_MAIN_STATE_4: break; - case 5: + case PAUSE_MAIN_STATE_5: pauseCtx->ocarinaStaff = AudioOcarina_GetPlayingStaff(); if (CHECK_BTN_ALL(input->press.button, BTN_START)) { @@ -3108,11 +3115,11 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->state = PAUSE_STATE_CLOSING; WREG(2) = -6240; func_800F64E0(0); - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; break; } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; pauseCtx->mode = 0; pauseCtx->promptChoice = 0; Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, @@ -3127,42 +3134,42 @@ void KaleidoScope_Update(PlayState* play) { } else if (pauseCtx->ocarinaStaff->state == pauseCtx->ocarinaSongIdx) { Audio_PlaySfxGeneral(NA_SE_SY_TRE_BOX_APPEAR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - D_8082B258 = 0; + D_8082B258 = PAUSE_MAIN_STATE_IDLE; D_8082B25C = 30; - pauseCtx->unk_1E4 = 6; + pauseCtx->mainState = PAUSE_MAIN_STATE_6; } else if (pauseCtx->ocarinaStaff->state == 0xFF) { Audio_PlaySfxGeneral(NA_SE_SY_OCARINA_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - D_8082B258 = 4; + D_8082B258 = PAUSE_MAIN_STATE_4; D_8082B25C = 20; - pauseCtx->unk_1E4 = 6; + pauseCtx->mainState = PAUSE_MAIN_STATE_6; } break; - case 6: + case PAUSE_MAIN_STATE_6: D_8082B25C--; if (D_8082B25C == 0) { - pauseCtx->unk_1E4 = D_8082B258; - if (pauseCtx->unk_1E4 == 0) { + pauseCtx->mainState = D_8082B258; + if (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); } } break; - case 7: + case PAUSE_MAIN_STATE_7: break; - case 8: + case PAUSE_MAIN_STATE_8: if (CHECK_BTN_ALL(input->press.button, BTN_START)) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); Interface_SetDoAction(play, DO_ACTION_NONE); pauseCtx->state = PAUSE_STATE_CLOSING; WREG(2) = -6240; func_800F64E0(0); - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; pauseCtx->mode = 0; pauseCtx->promptChoice = 0; Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, @@ -3177,11 +3184,11 @@ void KaleidoScope_Update(PlayState* play) { } break; - case 9: + case PAUSE_MAIN_STATE_9: break; default: - pauseCtx->unk_1E4 = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; break; } break; @@ -3255,7 +3262,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 = PAUSE_STATE_6; + pauseCtx->state = PAUSE_STATE_MAIN; pauseCtx->unk_1EC = 0; pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = 0.0f; pauseCtx->unk_204 = -314.0f; @@ -3281,7 +3288,7 @@ void KaleidoScope_Update(PlayState* play) { 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; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; pauseCtx->unk_204 = -434.0f; } break;