From 0f8532eeb556a51b5c64ec6cddda490a20b46409 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Thu, 21 Sep 2023 23:01:47 +0200 Subject: [PATCH 01/14] Document pause page switching --- include/regs.h | 1 + include/z64pause.h | 19 ++- src/code/z_kaleido_setup.c | 11 +- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 156 ++++++++++++------ 4 files changed, 125 insertions(+), 62 deletions(-) diff --git a/include/regs.h b/include/regs.h index 7806afc966e..5d9e6bed5f8 100644 --- a/include/regs.h +++ b/include/regs.h @@ -108,6 +108,7 @@ #define R_C_UP_ICON_Y YREG(89) #define R_EPONAS_SONG_PLAYED DREG(53) #define R_MAGIC_FILL_COLOR(i) ZREG(0 + (i)) +#define R_PAUSE_SWITCH_PAGE_FRAME_ADVANCE_ON ZREG(13) #define R_C_BTN_COLOR(i) ZREG(39 + (i)) #define R_B_BTN_COLOR(i) ZREG(43 + (i)) #define R_START_LABEL_DD(i) ZREG(48 + (i)) diff --git a/include/z64pause.h b/include/z64pause.h index f25d5c6ed16..12a31108db6 100644 --- a/include/z64pause.h +++ b/include/z64pause.h @@ -20,6 +20,21 @@ typedef enum { /* 0x04 */ PAUSE_WORLD_MAP } PauseMenuPage; +// The XZ coordinates in which direction each pause page is at +// e.g. the item page is in the -z direction +#define PAUSE_ITEM_X (0) +#define PAUSE_ITEM_Z (-1) +#define PAUSE_MAP_X (1) +#define PAUSE_MAP_Z (0) +#define PAUSE_QUEST_X (0) +#define PAUSE_QUEST_Z (1) +#define PAUSE_EQUIP_X (-1) +#define PAUSE_EQUIP_Z (0) + +// The pause camera looks at x=0,z=0, +// with the eye being PAUSE_EYE_DIST away in the direction opposite to the active page. +#define PAUSE_EYE_DIST (64.0f) + #define PAUSE_EQUIP_PLAYER_WIDTH 64 #define PAUSE_EQUIP_PLAYER_HEIGHT 112 @@ -84,9 +99,9 @@ typedef struct { /* 0x01D6 */ u16 debugState; /* 0x01D8 */ Vec3f eye; /* 0x01E4 */ u16 unk_1E4; - /* 0x01E6 */ u16 mode; + /* 0x01E6 */ u16 nextPageMode; // (2 * prev pageIndex) + (scroll left ? 1 : 0) /* 0x01E8 */ u16 pageIndex; // "kscp_pos" - /* 0x01EA */ u16 unk_1EA; + /* 0x01EA */ u16 switchPageTimer; /* 0x01EC */ u16 unk_1EC; /* 0x01F0 */ f32 unk_1F0; /* 0x01F4 */ f32 unk_1F4; diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 554282ba15f..cb1ee67d0c9 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -30,7 +30,7 @@ void KaleidoSetup_Update(PlayState* play) { WREG(16) = -175; WREG(17) = 155; - pauseCtx->unk_1EA = 0; + pauseCtx->switchPageTimer = 0; pauseCtx->unk_1E4 = 1; if (ZREG(48) == 0) { @@ -43,10 +43,11 @@ void KaleidoSetup_Update(PlayState* play) { pauseCtx->pageIndex = sKaleidoSetupKscpPos1[pauseCtx->pageIndex]; } - pauseCtx->mode = (u16)(pauseCtx->pageIndex * 2) + 1; + // Set next page mode to scroll left + pauseCtx->nextPageMode = (u16)(pauseCtx->pageIndex * 2) + 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, + osSyncPrintf("Mode=%d eye.x=%f, eye.z=%f kscp_pos=%d\n", pauseCtx->nextPageMode, pauseCtx->eye.x, pauseCtx->eye.z, pauseCtx->pageIndex); } @@ -70,9 +71,9 @@ void KaleidoSetup_Init(PlayState* play) { pauseCtx->state = PAUSE_STATE_OFF; pauseCtx->debugState = 0; pauseCtx->alpha = 0; - pauseCtx->unk_1EA = 0; + pauseCtx->switchPageTimer = 0; pauseCtx->unk_1E4 = 0; - pauseCtx->mode = 0; + pauseCtx->nextPageMode = 0; pauseCtx->pageIndex = PAUSE_ITEM; pauseCtx->unk_1F4 = 160.0f; 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 0ea6f38ed41..655b66c99b5 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 @@ -135,12 +135,30 @@ s16 D_8082AB2C[] = { 24, 72, 13, 22, 19, 20, 19, 27, 14, 26, 22, 21, 49, 32, 45, 60, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 32, 8, }; -static u8 D_8082AB6C[][5] = { +static u8 gPageSwitchNextButtonStatus[][5] = { + // PAUSE_ITEM + SWITCH_PAGE_LEFT_PT + // + // -> PAUSE_EQUIP { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_ENABLED }, + // PAUSE_MAP + SWITCH_PAGE_LEFT_PT + // + // -> PAUSE_ITEM { BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_DISABLED }, + // PAUSE_QUEST + SWITCH_PAGE_LEFT_PT + // PAUSE_ITEM + SWITCH_PAGE_RIGHT_PT + // -> PAUSE_MAP { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED }, + // PAUSE_EQUIP + SWITCH_PAGE_LEFT_PT + // PAUSE_MAP + SWITCH_PAGE_RIGHT_PT + // -> PAUSE_QUEST { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_ENABLED }, + // + // PAUSE_QUEST + SWITCH_PAGE_RIGHT_PT + // -> PAUSE_EQUIP { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_ENABLED }, + // + // PAUSE_EQUIP + SWITCH_PAGE_RIGHT_PT + // -> PAUSE_ITEM { BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_DISABLED }, }; @@ -155,16 +173,37 @@ static s16 D_8082ABA4 = 0; static s16 sInDungeonScene = false; -static f32 D_8082ABAC[] = { - -4.0f, 4.0f, 4.0f, 4.0f, 4.0f, -4.0f, -4.0f, -4.0f, -}; - -static f32 D_8082ABCC[] = { - -4.0f, -4.0f, -4.0f, 4.0f, 4.0f, 4.0f, 4.0f, -4.0f, -}; - -static u16 D_8082ABEC[] = { - PAUSE_MAP, PAUSE_EQUIP, PAUSE_QUEST, PAUSE_ITEM, PAUSE_EQUIP, PAUSE_MAP, PAUSE_ITEM, PAUSE_QUEST, +static f32 sPageSwitchEyeDx[] = { + -PAUSE_EYE_DIST * (PAUSE_MAP_X - PAUSE_ITEM_X) / 16, // PAUSE_ITEM right + -PAUSE_EYE_DIST*(PAUSE_EQUIP_X - PAUSE_ITEM_X) / 16, // PAUSE_ITEM left + -PAUSE_EYE_DIST*(PAUSE_QUEST_X - PAUSE_MAP_X) / 16, // PAUSE_MAP right + -PAUSE_EYE_DIST*(PAUSE_ITEM_X - PAUSE_MAP_X) / 16, // PAUSE_MAP left + -PAUSE_EYE_DIST*(PAUSE_EQUIP_X - PAUSE_QUEST_X) / 16, // PAUSE_QUEST right + -PAUSE_EYE_DIST*(PAUSE_MAP_X - PAUSE_QUEST_X) / 16, // PAUSE_QUEST left + -PAUSE_EYE_DIST*(PAUSE_ITEM_X - PAUSE_EQUIP_X) / 16, // PAUSE_EQUIP right + -PAUSE_EYE_DIST*(PAUSE_QUEST_X - PAUSE_EQUIP_X) / 16, // PAUSE_EQUIP left +}; + +static f32 sPageSwitchEyeDz[] = { + -PAUSE_EYE_DIST * (PAUSE_MAP_Z - PAUSE_ITEM_Z) / 16, // PAUSE_ITEM right + -PAUSE_EYE_DIST*(PAUSE_EQUIP_Z - PAUSE_ITEM_Z) / 16, // PAUSE_ITEM left + -PAUSE_EYE_DIST*(PAUSE_QUEST_Z - PAUSE_MAP_Z) / 16, // PAUSE_MAP right + -PAUSE_EYE_DIST*(PAUSE_ITEM_Z - PAUSE_MAP_Z) / 16, // PAUSE_MAP left + -PAUSE_EYE_DIST*(PAUSE_EQUIP_Z - PAUSE_QUEST_Z) / 16, // PAUSE_QUEST right + -PAUSE_EYE_DIST*(PAUSE_MAP_Z - PAUSE_QUEST_Z) / 16, // PAUSE_QUEST left + -PAUSE_EYE_DIST*(PAUSE_ITEM_Z - PAUSE_EQUIP_Z) / 16, // PAUSE_EQUIP right + -PAUSE_EYE_DIST*(PAUSE_QUEST_Z - PAUSE_EQUIP_Z) / 16, // PAUSE_EQUIP left +}; + +static u16 sPageSwitchNextPageIndex[] = { + PAUSE_MAP, // PAUSE_ITEM right + PAUSE_EQUIP, // PAUSE_ITEM left + PAUSE_QUEST, // PAUSE_MAP right + PAUSE_ITEM, // PAUSE_MAP left + PAUSE_EQUIP, // PAUSE_QUEST right + PAUSE_MAP, // PAUSE_QUEST left + PAUSE_ITEM, // PAUSE_EQUIP right + PAUSE_QUEST, // PAUSE_EQUIP left }; u8 gSlotAgeReqs[] = { @@ -364,26 +403,29 @@ void KaleidoScope_SetDefaultCursor(PlayState* play) { } } +#define SWITCH_PAGE_LEFT_PT 0 +#define SWITCH_PAGE_RIGHT_PT 2 + void KaleidoScope_SwitchPage(PauseContext* pauseCtx, u8 pt) { pauseCtx->unk_1E4 = 1; - pauseCtx->unk_1EA = 0; + pauseCtx->switchPageTimer = 0; - if (!pt) { - pauseCtx->mode = pauseCtx->pageIndex * 2 + 1; + if (!pt) { // SWITCH_PAGE_LEFT_PT + pauseCtx->nextPageMode = pauseCtx->pageIndex * 2 + 1; Audio_PlaySfxGeneral(NA_SE_SY_WIN_SCROLL_LEFT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); pauseCtx->cursorSpecialPos = PAUSE_CURSOR_PAGE_RIGHT; - } else { - pauseCtx->mode = pauseCtx->pageIndex * 2; + } else { // SWITCH_PAGE_RIGHT_PT + pauseCtx->nextPageMode = pauseCtx->pageIndex * 2; Audio_PlaySfxGeneral(NA_SE_SY_WIN_SCROLL_RIGHT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); pauseCtx->cursorSpecialPos = PAUSE_CURSOR_PAGE_LEFT; } - gSaveContext.buttonStatus[1] = D_8082AB6C[pauseCtx->pageIndex + pt][1]; - gSaveContext.buttonStatus[2] = D_8082AB6C[pauseCtx->pageIndex + pt][2]; - gSaveContext.buttonStatus[3] = D_8082AB6C[pauseCtx->pageIndex + pt][3]; - gSaveContext.buttonStatus[4] = D_8082AB6C[pauseCtx->pageIndex + pt][4]; + gSaveContext.buttonStatus[1] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex + pt][1]; + gSaveContext.buttonStatus[2] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex + pt][2]; + gSaveContext.buttonStatus[3] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex + pt][3]; + gSaveContext.buttonStatus[4] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex + pt][4]; osSyncPrintf("kscope->kscp_pos+pt = %d\n", pauseCtx->pageIndex + pt); @@ -398,12 +440,12 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { } if (CHECK_BTN_ALL(input->press.button, BTN_R)) { - KaleidoScope_SwitchPage(pauseCtx, 2); + KaleidoScope_SwitchPage(pauseCtx, SWITCH_PAGE_RIGHT_PT); return; } if (CHECK_BTN_ALL(input->press.button, BTN_Z)) { - KaleidoScope_SwitchPage(pauseCtx, 0); + KaleidoScope_SwitchPage(pauseCtx, SWITCH_PAGE_LEFT_PT); return; } @@ -411,7 +453,7 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { if (pauseCtx->stickAdjX < -30) { pauseCtx->pageSwitchInputTimer++; if ((pauseCtx->pageSwitchInputTimer >= 10) || (pauseCtx->pageSwitchInputTimer == 0)) { - KaleidoScope_SwitchPage(pauseCtx, 0); + KaleidoScope_SwitchPage(pauseCtx, SWITCH_PAGE_LEFT_PT); } } else { pauseCtx->pageSwitchInputTimer = -1; @@ -420,7 +462,7 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { if (pauseCtx->stickAdjX > 30) { pauseCtx->pageSwitchInputTimer++; if ((pauseCtx->pageSwitchInputTimer >= 10) || (pauseCtx->pageSwitchInputTimer == 0)) { - KaleidoScope_SwitchPage(pauseCtx, 2); + KaleidoScope_SwitchPage(pauseCtx, SWITCH_PAGE_RIGHT_PT); } } else { pauseCtx->pageSwitchInputTimer = -1; @@ -1400,21 +1442,21 @@ void KaleidoScope_UpdateNamePanel(PlayState* play) { } } -void func_808237B4(PlayState* play, Input* input) { +void KaleidoScope_UpdateSwitchPage(PlayState* play, Input* input) { PauseContext* pauseCtx = &play->pauseCtx; - s32 cond = false; - s32 mode; + s32 frameAdvanceFreeze = false; + s32 nextPageMode; - if (ZREG(13) && !CHECK_BTN_ALL(input->press.button, BTN_L)) { - cond = true; + if (R_PAUSE_SWITCH_PAGE_FRAME_ADVANCE_ON && !CHECK_BTN_ALL(input->press.button, BTN_L)) { + frameAdvanceFreeze = true; } - if (!cond) { - mode = pauseCtx->mode; - pauseCtx->eye.x += D_8082ABAC[mode]; - pauseCtx->eye.z += D_8082ABCC[mode]; + if (!frameAdvanceFreeze) { + nextPageMode = pauseCtx->nextPageMode; + pauseCtx->eye.x += sPageSwitchEyeDx[nextPageMode]; + pauseCtx->eye.z += sPageSwitchEyeDz[nextPageMode]; - if (pauseCtx->unk_1EA < 32) { + if (pauseCtx->switchPageTimer < ((4 * 16) / 2)) { WREG(16) -= WREG(25) / WREG(6); WREG(17) -= WREG(26) / WREG(6); } else { @@ -1422,11 +1464,11 @@ void func_808237B4(PlayState* play, Input* input) { WREG(17) += WREG(26) / WREG(6); } - pauseCtx->unk_1EA += 4; + pauseCtx->switchPageTimer += 4; - if (pauseCtx->unk_1EA == 64) { - pauseCtx->unk_1EA = 0; - pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; + if (pauseCtx->switchPageTimer == (4 * 16)) { + pauseCtx->switchPageTimer = 0; + pauseCtx->pageIndex = sPageSwitchNextPageIndex[pauseCtx->nextPageMode]; pauseCtx->unk_1E4 = 0; } } @@ -2339,28 +2381,32 @@ void KaleidoScope_GrayOutTextureRGBA32(u32* texture, u16 pixelCount) { void KaleidoScope_UpdateOpening(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; - pauseCtx->eye.x += D_8082ABAC[pauseCtx->mode] * ZREG(46); - pauseCtx->eye.z += D_8082ABCC[pauseCtx->mode] * ZREG(46); - pauseCtx->unk_1EA += 4 * ZREG(46); + pauseCtx->eye.x += sPageSwitchEyeDx[pauseCtx->nextPageMode] * ZREG(46); + pauseCtx->eye.z += sPageSwitchEyeDz[pauseCtx->nextPageMode] * ZREG(46); + pauseCtx->switchPageTimer += 4 * ZREG(46); - if (pauseCtx->unk_1EA == (64 * ZREG(47))) { + if (pauseCtx->switchPageTimer == (4 * 16 * ZREG(47))) { // Finished opening func_80084BF4(play, 1); - gSaveContext.buttonStatus[0] = D_8082AB6C[pauseCtx->pageIndex][0]; - gSaveContext.buttonStatus[1] = D_8082AB6C[pauseCtx->pageIndex][1]; - gSaveContext.buttonStatus[2] = D_8082AB6C[pauseCtx->pageIndex][2]; - gSaveContext.buttonStatus[3] = D_8082AB6C[pauseCtx->pageIndex][3]; - gSaveContext.buttonStatus[4] = D_8082AB6C[pauseCtx->pageIndex][4]; - pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; + + gSaveContext.buttonStatus[0] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex][0]; + gSaveContext.buttonStatus[1] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex][1]; + gSaveContext.buttonStatus[2] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex][2]; + gSaveContext.buttonStatus[3] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex][3]; + gSaveContext.buttonStatus[4] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex][4]; + + pauseCtx->pageIndex = sPageSwitchNextPageIndex[pauseCtx->nextPageMode]; + pauseCtx->unk_1E4 = 0; pauseCtx->state++; // PAUSE_STATE_6 + pauseCtx->alpha = 255; Interface_LoadActionLabelB(play, DO_ACTION_SAVE); - } else if (pauseCtx->unk_1EA == 64) { + } else if (pauseCtx->switchPageTimer == (4 * 16 * 1)) { // `ZREG(47)` is always 1 so this normally never happens - pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; - pauseCtx->mode = (u16)(pauseCtx->pageIndex * 2) + 1; + pauseCtx->pageIndex = sPageSwitchNextPageIndex[pauseCtx->nextPageMode]; + pauseCtx->nextPageMode = (u16)(pauseCtx->pageIndex * 2) + 1; } } @@ -2940,7 +2986,7 @@ void KaleidoScope_Update(PlayState* play) { WREG(2) = -6240; func_800F64E0(0); } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - pauseCtx->mode = 0; + pauseCtx->nextPageMode = 0; pauseCtx->promptChoice = 0; Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -2955,7 +3001,7 @@ void KaleidoScope_Update(PlayState* play) { break; case 1: - func_808237B4(play, play->state.input); + KaleidoScope_UpdateSwitchPage(play, play->state.input); break; case 2: @@ -2987,7 +3033,7 @@ void KaleidoScope_Update(PlayState* play) { } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); pauseCtx->unk_1E4 = 0; - pauseCtx->mode = 0; + pauseCtx->nextPageMode = 0; pauseCtx->promptChoice = 0; Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -3037,7 +3083,7 @@ void KaleidoScope_Update(PlayState* play) { } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); pauseCtx->unk_1E4 = 0; - pauseCtx->mode = 0; + pauseCtx->nextPageMode = 0; pauseCtx->promptChoice = 0; Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); From 14935facc5eed969f69d0afa653add99c0f8ff7d Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Fri, 22 Sep 2023 19:56:48 +0200 Subject: [PATCH 02/14] document initial scroll left setup, when opening the pause menu --- src/code/z_kaleido_setup.c | 60 +++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index cb1ee67d0c9..aeb457b9ed2 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -1,12 +1,42 @@ #include "global.h" -s16 sKaleidoSetupKscpPos0[] = { PAUSE_QUEST, PAUSE_EQUIP, PAUSE_ITEM, PAUSE_MAP }; -f32 sKaleidoSetupEyeX0[] = { 0.0f, 64.0f, 0.0f, -64.0f }; -f32 sKaleidoSetupEyeZ0[] = { -64.0f, 0.0f, 64.0f, 0.0f }; - -s16 sKaleidoSetupKscpPos1[] = { PAUSE_MAP, PAUSE_QUEST, PAUSE_EQUIP, PAUSE_ITEM }; -f32 sKaleidoSetupEyeX1[] = { -64.0f, 0.0f, 64.0f, 0.0f }; -f32 sKaleidoSetupEyeZ1[] = { 0.0f, -64.0f, 0.0f, 64.0f }; +s16 sKaleidoSetupUnusedPageIndex[] = { + PAUSE_QUEST, // PAUSE_ITEM + PAUSE_EQUIP, // PAUSE_MAP + PAUSE_ITEM, // PAUSE_QUEST + PAUSE_MAP, // PAUSE_EQUIP +}; +f32 sKaleidoSetupUnusedEyeX[] = { + PAUSE_EYE_DIST * -PAUSE_QUEST_X, // PAUSE_ITEM + PAUSE_EYE_DIST * -PAUSE_EQUIP_X, // PAUSE_MAP + PAUSE_EYE_DIST * -PAUSE_ITEM_X, // PAUSE_QUEST + PAUSE_EYE_DIST * -PAUSE_MAP_X, // PAUSE_EQUIP +}; +f32 sKaleidoSetupUnusedEyeZ[] = { + PAUSE_EYE_DIST * -PAUSE_QUEST_Z, // PAUSE_ITEM + PAUSE_EYE_DIST * -PAUSE_EQUIP_Z, // PAUSE_MAP + PAUSE_EYE_DIST * -PAUSE_ITEM_Z, // PAUSE_QUEST + PAUSE_EYE_DIST * -PAUSE_MAP_Z, // PAUSE_EQUIP +}; + +s16 sKaleidoSetupRightPageIndex[] = { + PAUSE_MAP, // PAUSE_ITEM + PAUSE_QUEST, // PAUSE_MAP + PAUSE_EQUIP, // PAUSE_QUEST + PAUSE_ITEM, // PAUSE_EQUIP +}; +f32 sKaleidoSetupRightPageEyeX[] = { + PAUSE_EYE_DIST * -PAUSE_MAP_X, // PAUSE_ITEM + PAUSE_EYE_DIST * -PAUSE_QUEST_X, // PAUSE_MAP + PAUSE_EYE_DIST * -PAUSE_EQUIP_X, // PAUSE_QUEST + PAUSE_EYE_DIST * -PAUSE_ITEM_X, // PAUSE_EQUIP +}; +f32 sKaleidoSetupRightPageEyeZ[] = { + PAUSE_EYE_DIST * -PAUSE_MAP_Z, // PAUSE_ITEM + PAUSE_EYE_DIST * -PAUSE_QUEST_Z, // PAUSE_MAP + PAUSE_EYE_DIST * -PAUSE_EQUIP_Z, // PAUSE_QUEST + PAUSE_EYE_DIST * -PAUSE_ITEM_Z, // PAUSE_EQUIP +}; void KaleidoSetup_Update(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; @@ -33,14 +63,16 @@ void KaleidoSetup_Update(PlayState* play) { pauseCtx->switchPageTimer = 0; pauseCtx->unk_1E4 = 1; - if (ZREG(48) == 0) { - pauseCtx->eye.x = sKaleidoSetupEyeX0[pauseCtx->pageIndex]; - pauseCtx->eye.z = sKaleidoSetupEyeZ0[pauseCtx->pageIndex]; - pauseCtx->pageIndex = sKaleidoSetupKscpPos0[pauseCtx->pageIndex]; + if (R_START_LABEL_DD(0) == 0) { + // Never reached, unused, and the data would be wrong anyway + pauseCtx->eye.x = sKaleidoSetupUnusedEyeX[pauseCtx->pageIndex]; + pauseCtx->eye.z = sKaleidoSetupUnusedEyeZ[pauseCtx->pageIndex]; + pauseCtx->pageIndex = sKaleidoSetupUnusedPageIndex[pauseCtx->pageIndex]; } else { - pauseCtx->eye.x = sKaleidoSetupEyeX1[pauseCtx->pageIndex]; - pauseCtx->eye.z = sKaleidoSetupEyeZ1[pauseCtx->pageIndex]; - pauseCtx->pageIndex = sKaleidoSetupKscpPos1[pauseCtx->pageIndex]; + // Set eye position and pageIndex such that scrolling left brings to the desired page + pauseCtx->eye.x = sKaleidoSetupRightPageEyeX[pauseCtx->pageIndex]; + pauseCtx->eye.z = sKaleidoSetupRightPageEyeZ[pauseCtx->pageIndex]; + pauseCtx->pageIndex = sKaleidoSetupRightPageIndex[pauseCtx->pageIndex]; } // Set next page mode to scroll left From b82915a62edb36a315008f36b3c2034c9a9983ee Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Fri, 22 Sep 2023 22:01:28 +0200 Subject: [PATCH 03/14] `PAUSE_MAIN_STATE_1` -> `PAUSE_MAIN_STATE_SWITCHING_PAGE` --- include/z64pause.h | 2 +- src/code/z_kaleido_setup.c | 2 +- src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/z64pause.h b/include/z64pause.h index ccba546782e..57a13145f85 100644 --- a/include/z64pause.h +++ b/include/z64pause.h @@ -73,7 +73,7 @@ typedef enum { // Sub-states of PAUSE_STATE_MAIN typedef enum { /* 0 */ PAUSE_MAIN_STATE_IDLE, - /* 1 */ PAUSE_MAIN_STATE_1, + /* 1 */ PAUSE_MAIN_STATE_SWITCHING_PAGE, /* 2 */ PAUSE_MAIN_STATE_2, /* 3 */ PAUSE_MAIN_STATE_3, /* 4 */ PAUSE_MAIN_STATE_4, diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 2b6680a0133..5d483d67fa8 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -61,7 +61,7 @@ void KaleidoSetup_Update(PlayState* play) { WREG(17) = 155; pauseCtx->switchPageTimer = 0; - pauseCtx->mainState = PAUSE_MAIN_STATE_1; + pauseCtx->mainState = PAUSE_MAIN_STATE_SWITCHING_PAGE; // irrelevant if (R_START_LABEL_DD(0) == 0) { // Never reached, unused, and the data would be wrong anyway 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 7860fe1eb10..b93a87be191 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 @@ -533,7 +533,7 @@ void KaleidoScope_SetDefaultCursor(PlayState* play) { #define SWITCH_PAGE_RIGHT_PT 2 void KaleidoScope_SwitchPage(PauseContext* pauseCtx, u8 pt) { - pauseCtx->mainState = PAUSE_MAIN_STATE_1; + pauseCtx->mainState = PAUSE_MAIN_STATE_SWITCHING_PAGE; pauseCtx->switchPageTimer = 0; if (!pt) { // SWITCH_PAGE_LEFT_PT @@ -3133,7 +3133,7 @@ void KaleidoScope_Update(PlayState* play) { } break; - case PAUSE_MAIN_STATE_1: + case PAUSE_MAIN_STATE_SWITCHING_PAGE: KaleidoScope_UpdateSwitchPage(play, play->state.input); break; From 8aa25de64258fd474fe6ba83469de8a557339cbe Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Fri, 22 Sep 2023 22:10:42 +0200 Subject: [PATCH 04/14] try a diagram of the pages layout in world space as a comment --- include/z64pause.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/z64pause.h b/include/z64pause.h index 57a13145f85..4a493b85a9a 100644 --- a/include/z64pause.h +++ b/include/z64pause.h @@ -22,6 +22,17 @@ typedef enum { // The XZ coordinates in which direction each pause page is at // e.g. the item page is in the -z direction +/* + * [item] + * [ + * e x [ + * q o--> m + * u | a + * i z v p + * p ] + * ] + * [quest] + */ #define PAUSE_ITEM_X (0) #define PAUSE_ITEM_Z (-1) #define PAUSE_MAP_X (1) From 411a158c34697827495529c0e9ec01d31498f597 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sat, 9 Mar 2024 17:22:33 +0100 Subject: [PATCH 05/14] expand `nextPageMode` comment --- include/z64pause.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/z64pause.h b/include/z64pause.h index 4a493b85a9a..cb60abddeef 100644 --- a/include/z64pause.h +++ b/include/z64pause.h @@ -124,7 +124,7 @@ typedef struct { /* 0x01D6 */ u16 debugState; /* 0x01D8 */ Vec3f eye; /* 0x01E4 */ u16 mainState; - /* 0x01E6 */ u16 nextPageMode; // (2 * prev pageIndex) + (scroll left ? 1 : 0) + /* 0x01E6 */ u16 nextPageMode; // During a page switch, indicates the page before switching and the direction to scroll in. Value is `(2 * prev pageIndex) + (scroll left ? 1 : 0)` /* 0x01E8 */ u16 pageIndex; // "kscp_pos" /* 0x01EA */ u16 switchPageTimer; /* 0x01EC */ u16 unk_1EC; From ff4ce7541eec4ef0937a3b3ae9d48fd351fd64db Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sat, 9 Mar 2024 17:44:26 +0100 Subject: [PATCH 06/14] touch up pause camera header comments --- include/z64pause.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/include/z64pause.h b/include/z64pause.h index cb60abddeef..a658b3d83ae 100644 --- a/include/z64pause.h +++ b/include/z64pause.h @@ -23,15 +23,15 @@ typedef enum { // The XZ coordinates in which direction each pause page is at // e.g. the item page is in the -z direction /* - * [item] - * [ - * e x [ - * q o--> m - * u | a - * i z v p - * p ] - * ] - * [quest] + * [ item ] + * + * [ [ + * x + * equip o--> map + * | + * ] z v ] + * + * [ quest ] */ #define PAUSE_ITEM_X (0) #define PAUSE_ITEM_Z (-1) @@ -43,7 +43,8 @@ typedef enum { #define PAUSE_EQUIP_Z (0) // The pause camera looks at x=0,z=0, -// with the eye being PAUSE_EYE_DIST away in the direction opposite to the active page. +// with the eye being PAUSE_EYE_DIST away in the direction opposite to the active page, +// which results in the camera being pointed (through x=0,z=0) towards the active page. #define PAUSE_EYE_DIST (64.0f) #define PAUSE_EQUIP_PLAYER_WIDTH 64 From 3a55a78a143f3721c3649f4de3a64b28a21d1696 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sat, 9 Mar 2024 17:44:59 +0100 Subject: [PATCH 07/14] expand comment on irrelevant init `mainState = PAUSE_MAIN_STATE_SWITCHING_PAGE` --- src/code/z_kaleido_setup.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 2c298769c90..87cc3738310 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -61,7 +61,11 @@ void KaleidoSetup_Update(PlayState* play) { WREG(17) = 155; pauseCtx->switchPageTimer = 0; - pauseCtx->mainState = PAUSE_MAIN_STATE_SWITCHING_PAGE; // irrelevant + + // Setting mainState here is irrelevant, mainState is only used under PAUSE_STATE_MAIN, + // which isn't involved in the initial pause menu opening page scrolling animation. + // mainState is also overwritten later before being used. + pauseCtx->mainState = PAUSE_MAIN_STATE_SWITCHING_PAGE; if (R_START_LABEL_DD(0) == 0) { // Never reached, unused, and the data would be wrong anyway From 2d85c7530fcbf68a3bd7d1045f47e64d124cc2a2 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sat, 9 Mar 2024 17:58:20 +0100 Subject: [PATCH 08/14] expand doc on `sKaleidoSetup*` data --- src/code/z_kaleido_setup.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 87cc3738310..bce8fee4165 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -1,17 +1,25 @@ #include "global.h" +/* + * The following three arrays are effectively unused. + * They are partly equivalent to the `sKaleidoSetupRightPage*` arrays below, + * but make each page correspond to the opposite page instead of the page to the right. + */ + s16 sKaleidoSetupUnusedPageIndex[] = { PAUSE_QUEST, // PAUSE_ITEM PAUSE_EQUIP, // PAUSE_MAP PAUSE_ITEM, // PAUSE_QUEST PAUSE_MAP, // PAUSE_EQUIP }; + f32 sKaleidoSetupUnusedEyeX[] = { PAUSE_EYE_DIST * -PAUSE_QUEST_X, // PAUSE_ITEM PAUSE_EYE_DIST * -PAUSE_EQUIP_X, // PAUSE_MAP PAUSE_EYE_DIST * -PAUSE_ITEM_X, // PAUSE_QUEST PAUSE_EYE_DIST * -PAUSE_MAP_X, // PAUSE_EQUIP }; + f32 sKaleidoSetupUnusedEyeZ[] = { PAUSE_EYE_DIST * -PAUSE_QUEST_Z, // PAUSE_ITEM PAUSE_EYE_DIST * -PAUSE_EQUIP_Z, // PAUSE_MAP @@ -19,18 +27,26 @@ f32 sKaleidoSetupUnusedEyeZ[] = { PAUSE_EYE_DIST * -PAUSE_MAP_Z, // PAUSE_EQUIP }; +/* + * The following three arrays are used when opening the pause menu to set up a page switch such that scrolling left + * brings to the initial page. + * For example to open the menu on page PAUSE_ITEM, the menu would open on PAUSE_MAP and scroll left to PAUSE_ITEM. + */ + s16 sKaleidoSetupRightPageIndex[] = { PAUSE_MAP, // PAUSE_ITEM PAUSE_QUEST, // PAUSE_MAP PAUSE_EQUIP, // PAUSE_QUEST PAUSE_ITEM, // PAUSE_EQUIP }; + f32 sKaleidoSetupRightPageEyeX[] = { PAUSE_EYE_DIST * -PAUSE_MAP_X, // PAUSE_ITEM PAUSE_EYE_DIST * -PAUSE_QUEST_X, // PAUSE_MAP PAUSE_EYE_DIST * -PAUSE_EQUIP_X, // PAUSE_QUEST PAUSE_EYE_DIST * -PAUSE_ITEM_X, // PAUSE_EQUIP }; + f32 sKaleidoSetupRightPageEyeZ[] = { PAUSE_EYE_DIST * -PAUSE_MAP_Z, // PAUSE_ITEM PAUSE_EYE_DIST * -PAUSE_QUEST_Z, // PAUSE_MAP @@ -67,8 +83,10 @@ void KaleidoSetup_Update(PlayState* play) { // mainState is also overwritten later before being used. pauseCtx->mainState = PAUSE_MAIN_STATE_SWITCHING_PAGE; + //! @bug REG collision if (R_START_LABEL_DD(0) == 0) { // Never reached, unused, and the data would be wrong anyway + // (scrolling left from this would not bring to the initial page) pauseCtx->eye.x = sKaleidoSetupUnusedEyeX[pauseCtx->pageIndex]; pauseCtx->eye.z = sKaleidoSetupUnusedEyeZ[pauseCtx->pageIndex]; pauseCtx->pageIndex = sKaleidoSetupUnusedPageIndex[pauseCtx->pageIndex]; From e6b8142c2bdcfcecd96ac911c7bbfafc70b816eb Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sat, 9 Mar 2024 18:24:16 +0100 Subject: [PATCH 09/14] expand docs on `gPageSwitchNextButtonStatus` --- .../misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 acf79fb1d45..d30df6eff08 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 @@ -135,6 +135,21 @@ s16 D_8082AB2C[] = { 24, 72, 13, 22, 19, 20, 19, 27, 14, 26, 22, 21, 49, 32, 45, 60, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 32, 8, }; +/** + * Contains the status of buttons for each page. + * + * Indexed by `pageIndex + pt` values, + * where pageIndex is from the `PauseMenuPage` enum + * and pt is 0 or 2 (respectively `SWITCH_PAGE_LEFT_PT` and `SWITCH_PAGE_RIGHT_PT`). + * + * `PauseMenuPage` enum values are ordered clockwise, starting at PAUSE_ITEM. That means adding 1 to a page index + * produces (modulo 4) the index of the page to the right, and similar with subtracting 1 for the left page. + * The indexing of this array relies on this property, but without modulo operations. Instead, the data for the first + * and last pages (PAUSE_ITEM, PAUSE_EQUIP) is duplicated. + * + * For example when scrolling left from the quest page PAUSE_QUEST (so, to PAUSE_MAP), + * the index is `PAUSE_QUEST + SWITCH_PAGE_LEFT_PT` and the data is button status for the map page. + */ static u8 gPageSwitchNextButtonStatus[][5] = { // PAUSE_ITEM + SWITCH_PAGE_LEFT_PT // From 6ff98ee25578f98189deeacb294954630e6194e4 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sat, 9 Mar 2024 18:30:14 +0100 Subject: [PATCH 10/14] add some doc on `sPageSwitch*` arrays --- .../misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 d30df6eff08..1ca3247feb9 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 @@ -188,6 +188,16 @@ static s16 D_8082ABA4 = 0; static s16 sInDungeonScene = false; +/* + * The following three `sPageSwitch*` arrays are indexed by nextPageMode values, + * which encode the page to switch from and the scroll direction. + * + * sPageSwitchEyeDx/Dz describe how to move the camera eye so that the pages appear scrolling and the next active page + * is switched into view. + * + * sPageSwitchNextPageIndex contains the page a nextPageMode leads to once scrolling is done. + */ + static f32 sPageSwitchEyeDx[] = { -PAUSE_EYE_DIST * (PAUSE_MAP_X - PAUSE_ITEM_X) / 16, // PAUSE_ITEM right -PAUSE_EYE_DIST*(PAUSE_EQUIP_X - PAUSE_ITEM_X) / 16, // PAUSE_ITEM left From da753255276002460bae0449a779fb237e8f8223 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sat, 9 Mar 2024 18:37:02 +0100 Subject: [PATCH 11/14] SwitchPage -> PageSwitch --- include/regs.h | 2 +- include/z64pause.h | 2 +- src/code/z_kaleido_setup.c | 4 +-- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 32 +++++++++---------- tools/disasm/gc-eu-mq/functions.txt | 4 +-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/regs.h b/include/regs.h index 19ef2d579e0..36c36c4190b 100644 --- a/include/regs.h +++ b/include/regs.h @@ -109,7 +109,7 @@ #define R_C_UP_ICON_Y YREG(89) #define R_EPONAS_SONG_PLAYED DREG(53) #define R_MAGIC_FILL_COLOR(i) ZREG(0 + (i)) -#define R_PAUSE_SWITCH_PAGE_FRAME_ADVANCE_ON ZREG(13) +#define R_PAUSE_PAGE_SWITCH_FRAME_ADVANCE_ON ZREG(13) #define R_C_BTN_COLOR(i) ZREG(39 + (i)) #define R_B_BTN_COLOR(i) ZREG(43 + (i)) #define R_START_LABEL_DD(i) ZREG(48 + (i)) diff --git a/include/z64pause.h b/include/z64pause.h index a658b3d83ae..f54a40cdb91 100644 --- a/include/z64pause.h +++ b/include/z64pause.h @@ -127,7 +127,7 @@ typedef struct { /* 0x01E4 */ u16 mainState; /* 0x01E6 */ u16 nextPageMode; // During a page switch, indicates the page before switching and the direction to scroll in. Value is `(2 * prev pageIndex) + (scroll left ? 1 : 0)` /* 0x01E8 */ u16 pageIndex; // "kscp_pos" - /* 0x01EA */ u16 switchPageTimer; + /* 0x01EA */ u16 pageSwitchTimer; /* 0x01EC */ u16 unk_1EC; /* 0x01F0 */ f32 unk_1F0; /* 0x01F4 */ f32 unk_1F4; diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index bce8fee4165..36a01c12393 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -76,7 +76,7 @@ void KaleidoSetup_Update(PlayState* play) { WREG(16) = -175; WREG(17) = 155; - pauseCtx->switchPageTimer = 0; + pauseCtx->pageSwitchTimer = 0; // Setting mainState here is irrelevant, mainState is only used under PAUSE_STATE_MAIN, // which isn't involved in the initial pause menu opening page scrolling animation. @@ -132,7 +132,7 @@ void KaleidoSetup_Init(PlayState* play) { pauseCtx->alpha = 0; // mainState = PAUSE_MAIN_STATE_IDLE , pageIndex = PAUSE_ITEM - pauseCtx->switchPageTimer = pauseCtx->mainState = pauseCtx->nextPageMode = pauseCtx->pageIndex = 0; + pauseCtx->pageSwitchTimer = pauseCtx->mainState = pauseCtx->nextPageMode = pauseCtx->pageIndex = 0; pauseCtx->unk_204 = -314.0f; 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 1ca3247feb9..4bfd558bde0 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 @@ -557,9 +557,9 @@ void KaleidoScope_SetDefaultCursor(PlayState* play) { #define SWITCH_PAGE_LEFT_PT 0 #define SWITCH_PAGE_RIGHT_PT 2 -void KaleidoScope_SwitchPage(PauseContext* pauseCtx, u8 pt) { +void KaleidoScope_SetupPageSwitch(PauseContext* pauseCtx, u8 pt) { pauseCtx->mainState = PAUSE_MAIN_STATE_SWITCHING_PAGE; - pauseCtx->switchPageTimer = 0; + pauseCtx->pageSwitchTimer = 0; if (!pt) { // SWITCH_PAGE_LEFT_PT pauseCtx->nextPageMode = pauseCtx->pageIndex * 2 + 1; @@ -591,12 +591,12 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { } if (CHECK_BTN_ALL(input->press.button, BTN_R)) { - KaleidoScope_SwitchPage(pauseCtx, SWITCH_PAGE_RIGHT_PT); + KaleidoScope_SetupPageSwitch(pauseCtx, SWITCH_PAGE_RIGHT_PT); return; } if (CHECK_BTN_ALL(input->press.button, BTN_Z)) { - KaleidoScope_SwitchPage(pauseCtx, SWITCH_PAGE_LEFT_PT); + KaleidoScope_SetupPageSwitch(pauseCtx, SWITCH_PAGE_LEFT_PT); return; } @@ -604,7 +604,7 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { if (pauseCtx->stickAdjX < -30) { pauseCtx->pageSwitchInputTimer++; if ((pauseCtx->pageSwitchInputTimer >= 10) || (pauseCtx->pageSwitchInputTimer == 0)) { - KaleidoScope_SwitchPage(pauseCtx, SWITCH_PAGE_LEFT_PT); + KaleidoScope_SetupPageSwitch(pauseCtx, SWITCH_PAGE_LEFT_PT); } } else { pauseCtx->pageSwitchInputTimer = -1; @@ -613,7 +613,7 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { if (pauseCtx->stickAdjX > 30) { pauseCtx->pageSwitchInputTimer++; if ((pauseCtx->pageSwitchInputTimer >= 10) || (pauseCtx->pageSwitchInputTimer == 0)) { - KaleidoScope_SwitchPage(pauseCtx, SWITCH_PAGE_RIGHT_PT); + KaleidoScope_SetupPageSwitch(pauseCtx, SWITCH_PAGE_RIGHT_PT); } } else { pauseCtx->pageSwitchInputTimer = -1; @@ -1598,12 +1598,12 @@ void KaleidoScope_UpdateNamePanel(PlayState* play) { } } -void KaleidoScope_UpdateSwitchPage(PlayState* play, Input* input) { +void KaleidoScope_UpdatePageSwitch(PlayState* play, Input* input) { PauseContext* pauseCtx = &play->pauseCtx; s32 frameAdvanceFreeze = false; s32 nextPageMode; - if (R_PAUSE_SWITCH_PAGE_FRAME_ADVANCE_ON && !CHECK_BTN_ALL(input->press.button, BTN_L)) { + if (R_PAUSE_PAGE_SWITCH_FRAME_ADVANCE_ON && !CHECK_BTN_ALL(input->press.button, BTN_L)) { frameAdvanceFreeze = true; } @@ -1612,7 +1612,7 @@ void KaleidoScope_UpdateSwitchPage(PlayState* play, Input* input) { pauseCtx->eye.x += sPageSwitchEyeDx[nextPageMode]; pauseCtx->eye.z += sPageSwitchEyeDz[nextPageMode]; - if (pauseCtx->switchPageTimer < ((4 * 16) / 2)) { + if (pauseCtx->pageSwitchTimer < ((4 * 16) / 2)) { WREG(16) -= WREG(25) / WREG(6); WREG(17) -= WREG(26) / WREG(6); } else { @@ -1620,10 +1620,10 @@ void KaleidoScope_UpdateSwitchPage(PlayState* play, Input* input) { WREG(17) += WREG(26) / WREG(6); } - pauseCtx->switchPageTimer += 4; + pauseCtx->pageSwitchTimer += 4; - if (pauseCtx->switchPageTimer == (4 * 16)) { - pauseCtx->switchPageTimer = 0; + if (pauseCtx->pageSwitchTimer == (4 * 16)) { + pauseCtx->pageSwitchTimer = 0; pauseCtx->pageIndex = sPageSwitchNextPageIndex[pauseCtx->nextPageMode]; pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; } @@ -2539,9 +2539,9 @@ void KaleidoScope_UpdateOpening(PlayState* play) { pauseCtx->eye.x += sPageSwitchEyeDx[pauseCtx->nextPageMode] * ZREG(46); pauseCtx->eye.z += sPageSwitchEyeDz[pauseCtx->nextPageMode] * ZREG(46); - pauseCtx->switchPageTimer += 4 * ZREG(46); + pauseCtx->pageSwitchTimer += 4 * ZREG(46); - if (pauseCtx->switchPageTimer == (4 * 16 * ZREG(47))) { + if (pauseCtx->pageSwitchTimer == (4 * 16 * ZREG(47))) { // Finished opening func_80084BF4(play, 1); @@ -2559,7 +2559,7 @@ void KaleidoScope_UpdateOpening(PlayState* play) { pauseCtx->alpha = 255; Interface_LoadActionLabelB(play, DO_ACTION_SAVE); - } else if (pauseCtx->switchPageTimer == (4 * 16 * 1)) { + } else if (pauseCtx->pageSwitchTimer == (4 * 16 * 1)) { // `ZREG(47)` is always 1 so this normally never happens pauseCtx->pageIndex = sPageSwitchNextPageIndex[pauseCtx->nextPageMode]; pauseCtx->nextPageMode = (u16)(pauseCtx->pageIndex * 2) + 1; @@ -3156,7 +3156,7 @@ void KaleidoScope_Update(PlayState* play) { break; case PAUSE_MAIN_STATE_SWITCHING_PAGE: - KaleidoScope_UpdateSwitchPage(play, play->state.input); + KaleidoScope_UpdatePageSwitch(play, play->state.input); break; case PAUSE_MAIN_STATE_2: diff --git a/tools/disasm/gc-eu-mq/functions.txt b/tools/disasm/gc-eu-mq/functions.txt index 88a45efc38a..7a70f34779d 100644 --- a/tools/disasm/gc-eu-mq/functions.txt +++ b/tools/disasm/gc-eu-mq/functions.txt @@ -3230,14 +3230,14 @@ KaleidoScope_OverridePalIndexCI4 = 0x8081DA30; // type:func KaleidoScope_MoveCursorToSpecialPos = 0x8081DB68; // type:func KaleidoScope_DrawQuadTextureRGBA32 = 0x8081DBCC; // type:func KaleidoScope_SetDefaultCursor = 0x8081DDBC; // type:func -KaleidoScope_SwitchPage = 0x8081DE7C; // type:func +KaleidoScope_SetupPageSwitch = 0x8081DE7C; // type:func KaleidoScope_HandlePageToggles = 0x8081DFD8; // type:func KaleidoScope_DrawCursor = 0x8081E108; // type:func KaleidoScope_DrawPageSections = 0x8081E454; // type:func KaleidoScope_DrawPages = 0x8081E700; // type:func KaleidoScope_DrawInfoPanel = 0x8081FE78; // type:func KaleidoScope_UpdateNamePanel = 0x8082165C; // type:func -func_808237B4 = 0x80821878; // type:func +KaleidoScope_UpdatePageSwitch = 0x80821878; // type:func KaleidoScope_SetView = 0x80821A58; // type:func func_80823A0C = 0x80821AD4; // type:func KaleidoScope_InitVertices = 0x80822164; // type:func From 387803325ebc95621710c3bb26dde8dcd85817e1 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sat, 9 Mar 2024 18:42:41 +0100 Subject: [PATCH 12/14] add `PAGE_SWITCH_NSTEPS` --- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) 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 4bfd558bde0..86088b8eccd 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 @@ -198,26 +198,28 @@ static s16 sInDungeonScene = false; * sPageSwitchNextPageIndex contains the page a nextPageMode leads to once scrolling is done. */ +#define PAGE_SWITCH_NSTEPS 16 + static f32 sPageSwitchEyeDx[] = { - -PAUSE_EYE_DIST * (PAUSE_MAP_X - PAUSE_ITEM_X) / 16, // PAUSE_ITEM right - -PAUSE_EYE_DIST*(PAUSE_EQUIP_X - PAUSE_ITEM_X) / 16, // PAUSE_ITEM left - -PAUSE_EYE_DIST*(PAUSE_QUEST_X - PAUSE_MAP_X) / 16, // PAUSE_MAP right - -PAUSE_EYE_DIST*(PAUSE_ITEM_X - PAUSE_MAP_X) / 16, // PAUSE_MAP left - -PAUSE_EYE_DIST*(PAUSE_EQUIP_X - PAUSE_QUEST_X) / 16, // PAUSE_QUEST right - -PAUSE_EYE_DIST*(PAUSE_MAP_X - PAUSE_QUEST_X) / 16, // PAUSE_QUEST left - -PAUSE_EYE_DIST*(PAUSE_ITEM_X - PAUSE_EQUIP_X) / 16, // PAUSE_EQUIP right - -PAUSE_EYE_DIST*(PAUSE_QUEST_X - PAUSE_EQUIP_X) / 16, // PAUSE_EQUIP left + -PAUSE_EYE_DIST * (PAUSE_MAP_X - PAUSE_ITEM_X) / PAGE_SWITCH_NSTEPS, // PAUSE_ITEM right + -PAUSE_EYE_DIST*(PAUSE_EQUIP_X - PAUSE_ITEM_X) / PAGE_SWITCH_NSTEPS, // PAUSE_ITEM left + -PAUSE_EYE_DIST*(PAUSE_QUEST_X - PAUSE_MAP_X) / PAGE_SWITCH_NSTEPS, // PAUSE_MAP right + -PAUSE_EYE_DIST*(PAUSE_ITEM_X - PAUSE_MAP_X) / PAGE_SWITCH_NSTEPS, // PAUSE_MAP left + -PAUSE_EYE_DIST*(PAUSE_EQUIP_X - PAUSE_QUEST_X) / PAGE_SWITCH_NSTEPS, // PAUSE_QUEST right + -PAUSE_EYE_DIST*(PAUSE_MAP_X - PAUSE_QUEST_X) / PAGE_SWITCH_NSTEPS, // PAUSE_QUEST left + -PAUSE_EYE_DIST*(PAUSE_ITEM_X - PAUSE_EQUIP_X) / PAGE_SWITCH_NSTEPS, // PAUSE_EQUIP right + -PAUSE_EYE_DIST*(PAUSE_QUEST_X - PAUSE_EQUIP_X) / PAGE_SWITCH_NSTEPS, // PAUSE_EQUIP left }; static f32 sPageSwitchEyeDz[] = { - -PAUSE_EYE_DIST * (PAUSE_MAP_Z - PAUSE_ITEM_Z) / 16, // PAUSE_ITEM right - -PAUSE_EYE_DIST*(PAUSE_EQUIP_Z - PAUSE_ITEM_Z) / 16, // PAUSE_ITEM left - -PAUSE_EYE_DIST*(PAUSE_QUEST_Z - PAUSE_MAP_Z) / 16, // PAUSE_MAP right - -PAUSE_EYE_DIST*(PAUSE_ITEM_Z - PAUSE_MAP_Z) / 16, // PAUSE_MAP left - -PAUSE_EYE_DIST*(PAUSE_EQUIP_Z - PAUSE_QUEST_Z) / 16, // PAUSE_QUEST right - -PAUSE_EYE_DIST*(PAUSE_MAP_Z - PAUSE_QUEST_Z) / 16, // PAUSE_QUEST left - -PAUSE_EYE_DIST*(PAUSE_ITEM_Z - PAUSE_EQUIP_Z) / 16, // PAUSE_EQUIP right - -PAUSE_EYE_DIST*(PAUSE_QUEST_Z - PAUSE_EQUIP_Z) / 16, // PAUSE_EQUIP left + -PAUSE_EYE_DIST * (PAUSE_MAP_Z - PAUSE_ITEM_Z) / PAGE_SWITCH_NSTEPS, // PAUSE_ITEM right + -PAUSE_EYE_DIST*(PAUSE_EQUIP_Z - PAUSE_ITEM_Z) / PAGE_SWITCH_NSTEPS, // PAUSE_ITEM left + -PAUSE_EYE_DIST*(PAUSE_QUEST_Z - PAUSE_MAP_Z) / PAGE_SWITCH_NSTEPS, // PAUSE_MAP right + -PAUSE_EYE_DIST*(PAUSE_ITEM_Z - PAUSE_MAP_Z) / PAGE_SWITCH_NSTEPS, // PAUSE_MAP left + -PAUSE_EYE_DIST*(PAUSE_EQUIP_Z - PAUSE_QUEST_Z) / PAGE_SWITCH_NSTEPS, // PAUSE_QUEST right + -PAUSE_EYE_DIST*(PAUSE_MAP_Z - PAUSE_QUEST_Z) / PAGE_SWITCH_NSTEPS, // PAUSE_QUEST left + -PAUSE_EYE_DIST*(PAUSE_ITEM_Z - PAUSE_EQUIP_Z) / PAGE_SWITCH_NSTEPS, // PAUSE_EQUIP right + -PAUSE_EYE_DIST*(PAUSE_QUEST_Z - PAUSE_EQUIP_Z) / PAGE_SWITCH_NSTEPS, // PAUSE_EQUIP left }; static u16 sPageSwitchNextPageIndex[] = { @@ -1612,7 +1614,7 @@ void KaleidoScope_UpdatePageSwitch(PlayState* play, Input* input) { pauseCtx->eye.x += sPageSwitchEyeDx[nextPageMode]; pauseCtx->eye.z += sPageSwitchEyeDz[nextPageMode]; - if (pauseCtx->pageSwitchTimer < ((4 * 16) / 2)) { + if (pauseCtx->pageSwitchTimer < ((4 * PAGE_SWITCH_NSTEPS) / 2)) { WREG(16) -= WREG(25) / WREG(6); WREG(17) -= WREG(26) / WREG(6); } else { @@ -1622,7 +1624,7 @@ void KaleidoScope_UpdatePageSwitch(PlayState* play, Input* input) { pauseCtx->pageSwitchTimer += 4; - if (pauseCtx->pageSwitchTimer == (4 * 16)) { + if (pauseCtx->pageSwitchTimer == (4 * PAGE_SWITCH_NSTEPS)) { pauseCtx->pageSwitchTimer = 0; pauseCtx->pageIndex = sPageSwitchNextPageIndex[pauseCtx->nextPageMode]; pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; @@ -2541,7 +2543,7 @@ void KaleidoScope_UpdateOpening(PlayState* play) { pauseCtx->eye.z += sPageSwitchEyeDz[pauseCtx->nextPageMode] * ZREG(46); pauseCtx->pageSwitchTimer += 4 * ZREG(46); - if (pauseCtx->pageSwitchTimer == (4 * 16 * ZREG(47))) { + if (pauseCtx->pageSwitchTimer == (4 * PAGE_SWITCH_NSTEPS * ZREG(47))) { // Finished opening func_80084BF4(play, 1); @@ -2559,7 +2561,7 @@ void KaleidoScope_UpdateOpening(PlayState* play) { pauseCtx->alpha = 255; Interface_LoadActionLabelB(play, DO_ACTION_SAVE); - } else if (pauseCtx->pageSwitchTimer == (4 * 16 * 1)) { + } else if (pauseCtx->pageSwitchTimer == (4 * PAGE_SWITCH_NSTEPS * 1)) { // `ZREG(47)` is always 1 so this normally never happens pauseCtx->pageIndex = sPageSwitchNextPageIndex[pauseCtx->nextPageMode]; pauseCtx->nextPageMode = (u16)(pauseCtx->pageIndex * 2) + 1; From 7330cb9c49b7c066269fd82c730566d4a16dbce7 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sat, 9 Mar 2024 18:44:48 +0100 Subject: [PATCH 13/14] `SWITCH_PAGE_*_PT` -> `PAGE_SWITCH_PT_*` --- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) 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 86088b8eccd..351d8dfeaa3 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 @@ -140,7 +140,7 @@ s16 D_8082AB2C[] = { * * Indexed by `pageIndex + pt` values, * where pageIndex is from the `PauseMenuPage` enum - * and pt is 0 or 2 (respectively `SWITCH_PAGE_LEFT_PT` and `SWITCH_PAGE_RIGHT_PT`). + * and pt is 0 or 2 (respectively `PAGE_SWITCH_PT_LEFT` and `PAGE_SWITCH_PT_RIGHT`). * * `PauseMenuPage` enum values are ordered clockwise, starting at PAUSE_ITEM. That means adding 1 to a page index * produces (modulo 4) the index of the page to the right, and similar with subtracting 1 for the left page. @@ -148,31 +148,31 @@ s16 D_8082AB2C[] = { * and last pages (PAUSE_ITEM, PAUSE_EQUIP) is duplicated. * * For example when scrolling left from the quest page PAUSE_QUEST (so, to PAUSE_MAP), - * the index is `PAUSE_QUEST + SWITCH_PAGE_LEFT_PT` and the data is button status for the map page. + * the index is `PAUSE_QUEST + PAGE_SWITCH_PT_LEFT` and the data is button status for the map page. */ static u8 gPageSwitchNextButtonStatus[][5] = { - // PAUSE_ITEM + SWITCH_PAGE_LEFT_PT + // PAUSE_ITEM + PAGE_SWITCH_PT_LEFT // // -> PAUSE_EQUIP { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_ENABLED }, - // PAUSE_MAP + SWITCH_PAGE_LEFT_PT + // PAUSE_MAP + PAGE_SWITCH_PT_LEFT // // -> PAUSE_ITEM { BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_DISABLED }, - // PAUSE_QUEST + SWITCH_PAGE_LEFT_PT - // PAUSE_ITEM + SWITCH_PAGE_RIGHT_PT + // PAUSE_QUEST + PAGE_SWITCH_PT_LEFT + // PAUSE_ITEM + PAGE_SWITCH_PT_RIGHT // -> PAUSE_MAP { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED }, - // PAUSE_EQUIP + SWITCH_PAGE_LEFT_PT - // PAUSE_MAP + SWITCH_PAGE_RIGHT_PT + // PAUSE_EQUIP + PAGE_SWITCH_PT_LEFT + // PAUSE_MAP + PAGE_SWITCH_PT_RIGHT // -> PAUSE_QUEST { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_ENABLED }, // - // PAUSE_QUEST + SWITCH_PAGE_RIGHT_PT + // PAUSE_QUEST + PAGE_SWITCH_PT_RIGHT // -> PAUSE_EQUIP { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_ENABLED }, // - // PAUSE_EQUIP + SWITCH_PAGE_RIGHT_PT + // PAUSE_EQUIP + PAGE_SWITCH_PT_RIGHT // -> PAUSE_ITEM { BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_DISABLED }, }; @@ -556,19 +556,19 @@ void KaleidoScope_SetDefaultCursor(PlayState* play) { } } -#define SWITCH_PAGE_LEFT_PT 0 -#define SWITCH_PAGE_RIGHT_PT 2 +#define PAGE_SWITCH_PT_LEFT 0 +#define PAGE_SWITCH_PT_RIGHT 2 void KaleidoScope_SetupPageSwitch(PauseContext* pauseCtx, u8 pt) { pauseCtx->mainState = PAUSE_MAIN_STATE_SWITCHING_PAGE; pauseCtx->pageSwitchTimer = 0; - if (!pt) { // SWITCH_PAGE_LEFT_PT + if (!pt) { // PAGE_SWITCH_PT_LEFT pauseCtx->nextPageMode = pauseCtx->pageIndex * 2 + 1; Audio_PlaySfxGeneral(NA_SE_SY_WIN_SCROLL_LEFT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); pauseCtx->cursorSpecialPos = PAUSE_CURSOR_PAGE_RIGHT; - } else { // SWITCH_PAGE_RIGHT_PT + } else { // PAGE_SWITCH_PT_RIGHT pauseCtx->nextPageMode = pauseCtx->pageIndex * 2; Audio_PlaySfxGeneral(NA_SE_SY_WIN_SCROLL_RIGHT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -593,12 +593,12 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { } if (CHECK_BTN_ALL(input->press.button, BTN_R)) { - KaleidoScope_SetupPageSwitch(pauseCtx, SWITCH_PAGE_RIGHT_PT); + KaleidoScope_SetupPageSwitch(pauseCtx, PAGE_SWITCH_PT_RIGHT); return; } if (CHECK_BTN_ALL(input->press.button, BTN_Z)) { - KaleidoScope_SetupPageSwitch(pauseCtx, SWITCH_PAGE_LEFT_PT); + KaleidoScope_SetupPageSwitch(pauseCtx, PAGE_SWITCH_PT_LEFT); return; } @@ -606,7 +606,7 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { if (pauseCtx->stickAdjX < -30) { pauseCtx->pageSwitchInputTimer++; if ((pauseCtx->pageSwitchInputTimer >= 10) || (pauseCtx->pageSwitchInputTimer == 0)) { - KaleidoScope_SetupPageSwitch(pauseCtx, SWITCH_PAGE_LEFT_PT); + KaleidoScope_SetupPageSwitch(pauseCtx, PAGE_SWITCH_PT_LEFT); } } else { pauseCtx->pageSwitchInputTimer = -1; @@ -615,7 +615,7 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { if (pauseCtx->stickAdjX > 30) { pauseCtx->pageSwitchInputTimer++; if ((pauseCtx->pageSwitchInputTimer >= 10) || (pauseCtx->pageSwitchInputTimer == 0)) { - KaleidoScope_SetupPageSwitch(pauseCtx, SWITCH_PAGE_RIGHT_PT); + KaleidoScope_SetupPageSwitch(pauseCtx, PAGE_SWITCH_PT_RIGHT); } } else { pauseCtx->pageSwitchInputTimer = -1; From 611ee08c3ab0026b711adf1297f19260b2e0285f Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sun, 10 Mar 2024 00:23:44 +0100 Subject: [PATCH 14/14] peepoArtist --- include/z64pause.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/z64pause.h b/include/z64pause.h index f54a40cdb91..9e19936da03 100644 --- a/include/z64pause.h +++ b/include/z64pause.h @@ -23,15 +23,15 @@ typedef enum { // The XZ coordinates in which direction each pause page is at // e.g. the item page is in the -z direction /* - * [ item ] + * < item > * - * [ [ + * ^ ^ * x * equip o--> map * | - * ] z v ] + * v z v v * - * [ quest ] + * < quest > */ #define PAUSE_ITEM_X (0) #define PAUSE_ITEM_Z (-1)