1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-29 00:06:33 +00:00

Pause doc: Pages drawing (#2190)

* name main fields and regs for pages drawing

* comments

* format

* more comments

* roll -> pitch (oops)

* Document `PauseContext.offsetY`, `R_PAUSE_OFFSET_VERTICAL` as "y origin 1/2"

* copypaste comment on page pitches fields

* "offset depth" -> "depth offset"

* review
This commit is contained in:
Dragorn421 2024-09-18 14:11:21 +02:00 committed by GitHub
parent 306abef46b
commit dc2ceb33f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 132 additions and 99 deletions

View file

@ -183,6 +183,8 @@
#define R_ROOM_CULL_USED_ENTRIES iREG(88)
#define R_ROOM_CULL_DEBUG_TARGET iREG(89)
#define R_B_LABEL_DD WREG(0)
#define R_PAUSE_PAGES_Y_ORIGIN_2 WREG(2) // Complements PauseContext.pagesYOrigin1
#define R_PAUSE_DEPTH_OFFSET WREG(3) // Offset position of all pages away from the camera
#if OOT_NTSC
#define R_B_LABEL_SCALE(i) WREG(8 + (i))
#define R_B_LABEL_X(i) WREG(10 + (i))

View file

@ -141,6 +141,11 @@ typedef enum WorldMapPointState {
/* 2 */ WORLD_MAP_POINT_STATE_HIGHLIGHT
} WorldMapPointState;
// Values for PauseContext.pagesYOrigin1 and R_PAUSE_PAGES_Y_ORIGIN_2 respectively,
// that make the pause pages rotate around their lower edge instead of the middle.
#define PAUSE_PAGES_Y_ORIGIN_1_LOWER 80 // PAGE_BG_ROWS * PAGE_BG_QUAD_HEIGHT / 2
#define PAUSE_PAGES_Y_ORIGIN_2_LOWER (s16)(-PAUSE_PAGES_Y_ORIGIN_1_LOWER * 0.78 * 100)
typedef struct PauseContext {
/* 0x0000 */ View view;
/* 0x0128 */ u8* iconItemSegment;
@ -174,14 +179,14 @@ typedef struct PauseContext {
/* 0x01E8 */ u16 pageIndex; // "kscp_pos"
/* 0x01EA */ u16 pageSwitchTimer;
/* 0x01EC */ u16 savePromptState;
/* 0x01F0 */ f32 unk_1F0;
/* 0x01F4 */ f32 unk_1F4;
/* 0x01F8 */ f32 unk_1F8;
/* 0x01FC */ f32 unk_1FC;
/* 0x0200 */ f32 unk_200;
/* 0x0204 */ f32 unk_204; // "angle_s"
/* 0x01F0 */ f32 promptDepthOffset; // Offset position of the prompt away from the camera
/* 0x01F4 */ f32 itemPagePitch; // Rotation of the item page around its local horizontal/sideways axis
/* 0x01F8 */ f32 equipPagePitch; // Rotation of the equip page around its local horizontal/sideways axis
/* 0x01FC */ f32 mapPagePitch; // Rotation of the map page around its local horizontal/sideways axis
/* 0x0200 */ f32 questPagePitch; // Rotation of the quest page around its local horizontal/sideways axis
/* 0x0204 */ f32 promptPitch; // Rotation of the prompt around its local horizontal/sideways axis. "angle_s"
/* 0x0208 */ u16 alpha;
/* 0x020A */ s16 offsetY;
/* 0x020A */ s16 pagesYOrigin1;
/* 0x020C */ char unk_20C[0x08];
/* 0x0214 */ s16 stickAdjX;
/* 0x0216 */ s16 stickAdjY;

View file

@ -494,8 +494,8 @@ void Regs_InitDataImpl(void) {
XREG(93) = 100;
XREG(94) = 160;
XREG(95) = 200;
WREG(2) = -6080;
WREG(3) = 9355;
R_PAUSE_PAGES_Y_ORIGIN_2 = -6080;
R_PAUSE_DEPTH_OFFSET = 9355;
WREG(4) = 8;
WREG(5) = 3;
WREG(6) = 8;

View file

@ -112,7 +112,7 @@ void KaleidoSetup_Update(PlayState* play) {
}
if (pauseCtx->state == PAUSE_STATE_WAIT_LETTERBOX) {
WREG(2) = -6240;
R_PAUSE_PAGES_Y_ORIGIN_2 = PAUSE_PAGES_Y_ORIGIN_2_LOWER;
R_UPDATE_RATE = 2;
if (Letterbox_GetSizeTarget() != 0) {
@ -132,15 +132,15 @@ void KaleidoSetup_Init(PlayState* play) {
pauseCtx->eye.x = pauseCtx->eye.y = 0.0f;
pauseCtx->eye.z = 64.0f;
pauseCtx->unk_1F0 = 936.0f;
pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = 160.0f;
pauseCtx->promptDepthOffset = 936.0f;
pauseCtx->itemPagePitch = pauseCtx->equipPagePitch = pauseCtx->mapPagePitch = pauseCtx->questPagePitch = 160.0f;
pauseCtx->alpha = 0;
// mainState = PAUSE_MAIN_STATE_IDLE , pageIndex = PAUSE_ITEM
pauseCtx->pageSwitchTimer = pauseCtx->mainState = pauseCtx->nextPageMode = pauseCtx->pageIndex = 0;
pauseCtx->unk_204 = -314.0f;
pauseCtx->promptPitch = -314.0f;
pauseCtx->cursorPoint[PAUSE_ITEM] = 0;
pauseCtx->cursorPoint[PAUSE_MAP] = VREG(30) + 3;

View file

@ -283,7 +283,8 @@ void KaleidoScope_DrawDungeonMap(PlayState* play, GraphicsContext* gfxCtx) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha);
pauseCtx->mapPageVtx[116].v.ob[1] = pauseCtx->mapPageVtx[117].v.ob[1] = pauseCtx->offsetY - (VREG(30) * 14) + 49;
pauseCtx->mapPageVtx[116].v.ob[1] = pauseCtx->mapPageVtx[117].v.ob[1] =
pauseCtx->pagesYOrigin1 - (VREG(30) * 14) + 49;
pauseCtx->mapPageVtx[118].v.ob[1] = pauseCtx->mapPageVtx[119].v.ob[1] = pauseCtx->mapPageVtx[116].v.ob[1] - 16;
gDPLoadTextureBlock(POLY_OPA_DISP++, gDungeonMapLinkHeadTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 16, 0,
@ -295,7 +296,7 @@ void KaleidoScope_DrawDungeonMap(PlayState* play, GraphicsContext* gfxCtx) {
if (CHECK_DUNGEON_ITEM(DUNGEON_COMPASS, gSaveContext.mapIndex) &&
(gMapData->skullFloorIconY[gSaveContext.mapIndex] != -99)) {
pauseCtx->mapPageVtx[120].v.ob[1] = pauseCtx->mapPageVtx[121].v.ob[1] =
gMapData->skullFloorIconY[gSaveContext.mapIndex] + pauseCtx->offsetY;
gMapData->skullFloorIconY[gSaveContext.mapIndex] + pauseCtx->pagesYOrigin1;
pauseCtx->mapPageVtx[122].v.ob[1] = pauseCtx->mapPageVtx[123].v.ob[1] = pauseCtx->mapPageVtx[120].v.ob[1] - 16;
gDPLoadTextureBlock(POLY_OPA_DISP++, gDungeonMapSkullTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 16, 0,
@ -763,7 +764,7 @@ void KaleidoScope_DrawWorldMap(PlayState* play, GraphicsContext* gfxCtx) {
pauseCtx->mapPageVtx[172].v.ob[0] + areaBoxWidths[((void)0, gSaveContext.worldMapArea)];
pauseCtx->mapPageVtx[172].v.ob[1] = pauseCtx->mapPageVtx[173].v.ob[1] =
areaBoxPosY[((void)0, gSaveContext.worldMapArea)] + pauseCtx->offsetY;
areaBoxPosY[((void)0, gSaveContext.worldMapArea)] + pauseCtx->pagesYOrigin1;
pauseCtx->mapPageVtx[174].v.ob[1] = pauseCtx->mapPageVtx[175].v.ob[1] =
pauseCtx->mapPageVtx[172].v.ob[1] - areaBoxHeights[((void)0, gSaveContext.worldMapArea)];

View file

@ -1308,13 +1308,16 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) {
}
}
// Draw non-active pages (not the one being looked at)
if (pauseCtx->pageIndex) { // pageIndex != PAUSE_ITEM
gDPPipeSync(POLY_OPA_DISP++);
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA);
Matrix_Translate(0.0f, (f32)WREG(2) / 100.0f, -(f32)WREG(3) / 100.0f, MTXMODE_NEW);
Matrix_Translate(0.0f, (f32)R_PAUSE_PAGES_Y_ORIGIN_2 / 100.0f, -(f32)R_PAUSE_DEPTH_OFFSET / 100.0f,
MTXMODE_NEW);
Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY);
Matrix_RotateX(-pauseCtx->unk_1F4 / 100.0f, MTXMODE_APPLY);
Matrix_RotateX(-pauseCtx->itemPagePitch / 100.0f, MTXMODE_APPLY);
MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, gfxCtx, "../z_kaleido_scope_PAL.c", 1173);
@ -1328,9 +1331,10 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA);
Matrix_Translate(-(f32)WREG(3) / 100.0f, (f32)WREG(2) / 100.0f, 0.0f, MTXMODE_NEW);
Matrix_Translate(-(f32)R_PAUSE_DEPTH_OFFSET / 100.0f, (f32)R_PAUSE_PAGES_Y_ORIGIN_2 / 100.0f, 0.0f,
MTXMODE_NEW);
Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY);
Matrix_RotateZ(pauseCtx->unk_1F8 / 100.0f, MTXMODE_APPLY);
Matrix_RotateZ(pauseCtx->equipPagePitch / 100.0f, MTXMODE_APPLY);
Matrix_RotateY(1.57f, MTXMODE_APPLY);
MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, gfxCtx, "../z_kaleido_scope_PAL.c", 1196);
@ -1346,9 +1350,10 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) {
gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP);
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA);
Matrix_Translate(0.0f, (f32)WREG(2) / 100.0f, (f32)WREG(3) / 100.0f, MTXMODE_NEW);
Matrix_Translate(0.0f, (f32)R_PAUSE_PAGES_Y_ORIGIN_2 / 100.0f, (f32)R_PAUSE_DEPTH_OFFSET / 100.0f,
MTXMODE_NEW);
Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY);
Matrix_RotateX(pauseCtx->unk_200 / 100.0f, MTXMODE_APPLY);
Matrix_RotateX(pauseCtx->questPagePitch / 100.0f, MTXMODE_APPLY);
Matrix_RotateY(3.14f, MTXMODE_APPLY);
MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, gfxCtx, "../z_kaleido_scope_PAL.c", 1220);
@ -1364,9 +1369,10 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) {
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA);
Matrix_Translate((f32)WREG(3) / 100.0f, (f32)WREG(2) / 100.0f, 0.0f, MTXMODE_NEW);
Matrix_Translate((f32)R_PAUSE_DEPTH_OFFSET / 100.0f, (f32)R_PAUSE_PAGES_Y_ORIGIN_2 / 100.0f, 0.0f,
MTXMODE_NEW);
Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY);
Matrix_RotateZ(-pauseCtx->unk_1FC / 100.0f, MTXMODE_APPLY);
Matrix_RotateZ(-pauseCtx->mapPagePitch / 100.0f, MTXMODE_APPLY);
Matrix_RotateY(-1.57f, MTXMODE_APPLY);
MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, gfxCtx, "../z_kaleido_scope_PAL.c", 1243);
@ -1388,14 +1394,17 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) {
}
}
// Update and draw the active page being looked at
gDPPipeSync(POLY_OPA_DISP++);
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA);
switch (pauseCtx->pageIndex) {
case PAUSE_ITEM:
Matrix_Translate(0.0f, (f32)WREG(2) / 100.0f, -(f32)WREG(3) / 100.0f, MTXMODE_NEW);
Matrix_Translate(0.0f, (f32)R_PAUSE_PAGES_Y_ORIGIN_2 / 100.0f, -(f32)R_PAUSE_DEPTH_OFFSET / 100.0f,
MTXMODE_NEW);
Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY);
Matrix_RotateX(-pauseCtx->unk_1F4 / 100.0f, MTXMODE_APPLY);
Matrix_RotateX(-pauseCtx->itemPagePitch / 100.0f, MTXMODE_APPLY);
MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, gfxCtx, "../z_kaleido_scope_PAL.c", 1281);
@ -1406,9 +1415,10 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) {
break;
case PAUSE_MAP:
Matrix_Translate((f32)WREG(3) / 100.0f, (f32)WREG(2) / 100.0f, 0.0f, MTXMODE_NEW);
Matrix_Translate((f32)R_PAUSE_DEPTH_OFFSET / 100.0f, (f32)R_PAUSE_PAGES_Y_ORIGIN_2 / 100.0f, 0.0f,
MTXMODE_NEW);
Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY);
Matrix_RotateZ(-pauseCtx->unk_1FC / 100.0f, MTXMODE_APPLY);
Matrix_RotateZ(-pauseCtx->mapPagePitch / 100.0f, MTXMODE_APPLY);
Matrix_RotateY(-1.57f, MTXMODE_APPLY);
MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, gfxCtx, "../z_kaleido_scope_PAL.c", 1303);
@ -1437,9 +1447,10 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) {
case PAUSE_QUEST:
gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP);
Matrix_Translate(0.0f, (f32)WREG(2) / 100.0f, (f32)WREG(3) / 100.0f, MTXMODE_NEW);
Matrix_Translate(0.0f, (f32)R_PAUSE_PAGES_Y_ORIGIN_2 / 100.0f, (f32)R_PAUSE_DEPTH_OFFSET / 100.0f,
MTXMODE_NEW);
Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY);
Matrix_RotateX(pauseCtx->unk_200 / 100.0f, MTXMODE_APPLY);
Matrix_RotateX(pauseCtx->questPagePitch / 100.0f, MTXMODE_APPLY);
Matrix_RotateY(3.14f, MTXMODE_APPLY);
MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, gfxCtx, "../z_kaleido_scope_PAL.c", 1343);
@ -1455,9 +1466,10 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) {
break;
case PAUSE_EQUIP:
Matrix_Translate(-(f32)WREG(3) / 100.0f, (f32)WREG(2) / 100.0f, 0.0f, MTXMODE_NEW);
Matrix_Translate(-(f32)R_PAUSE_DEPTH_OFFSET / 100.0f, (f32)R_PAUSE_PAGES_Y_ORIGIN_2 / 100.0f, 0.0f,
MTXMODE_NEW);
Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY);
Matrix_RotateZ(pauseCtx->unk_1F8 / 100.0f, MTXMODE_APPLY);
Matrix_RotateZ(pauseCtx->equipPagePitch / 100.0f, MTXMODE_APPLY);
Matrix_RotateY(1.57f, MTXMODE_APPLY);
MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, gfxCtx, "../z_kaleido_scope_PAL.c", 1367);
@ -1474,6 +1486,8 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) {
}
}
// Update and draw prompt (save or gameover)
Gfx_SetupDL_42Opa(gfxCtx);
if ((pauseCtx->state == PAUSE_STATE_SAVE_PROMPT) || IS_PAUSE_STATE_GAMEOVER(pauseCtx)) {
@ -1482,31 +1496,35 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) {
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA);
if ((u32)pauseCtx->pageIndex == PAUSE_ITEM) {
pauseCtx->unk_1F4 = pauseCtx->unk_204 + 314.0f;
pauseCtx->itemPagePitch = pauseCtx->promptPitch + 314.0f;
Matrix_Translate(0.0f, (f32)WREG(2) / 100.0f, -pauseCtx->unk_1F0 / 10.0f, MTXMODE_NEW);
Matrix_Translate(0.0f, (f32)R_PAUSE_PAGES_Y_ORIGIN_2 / 100.0f, -pauseCtx->promptDepthOffset / 10.0f,
MTXMODE_NEW);
Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY);
Matrix_RotateX(-pauseCtx->unk_204 / 100.0f, MTXMODE_APPLY);
Matrix_RotateX(-pauseCtx->promptPitch / 100.0f, MTXMODE_APPLY);
} else if (pauseCtx->pageIndex == PAUSE_MAP) {
pauseCtx->unk_1FC = pauseCtx->unk_204 + 314.0f;
pauseCtx->mapPagePitch = pauseCtx->promptPitch + 314.0f;
Matrix_Translate(pauseCtx->unk_1F0 / 10.0f, (f32)WREG(2) / 100.0f, 0.0f, MTXMODE_NEW);
Matrix_Translate(pauseCtx->promptDepthOffset / 10.0f, (f32)R_PAUSE_PAGES_Y_ORIGIN_2 / 100.0f, 0.0f,
MTXMODE_NEW);
Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY);
Matrix_RotateZ(-pauseCtx->unk_204 / 100.0f, MTXMODE_APPLY);
Matrix_RotateZ(-pauseCtx->promptPitch / 100.0f, MTXMODE_APPLY);
Matrix_RotateY(-1.57f, MTXMODE_APPLY);
} else if (pauseCtx->pageIndex == PAUSE_QUEST) {
pauseCtx->unk_200 = pauseCtx->unk_204 + 314.0f;
pauseCtx->questPagePitch = pauseCtx->promptPitch + 314.0f;
Matrix_Translate(0.0f, (f32)WREG(2) / 100.0f, pauseCtx->unk_1F0 / 10.0f, MTXMODE_NEW);
Matrix_Translate(0.0f, (f32)R_PAUSE_PAGES_Y_ORIGIN_2 / 100.0f, pauseCtx->promptDepthOffset / 10.0f,
MTXMODE_NEW);
Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY);
Matrix_RotateX(pauseCtx->unk_204 / 100.0f, MTXMODE_APPLY);
Matrix_RotateX(pauseCtx->promptPitch / 100.0f, MTXMODE_APPLY);
Matrix_RotateY(3.14f, MTXMODE_APPLY);
} else {
pauseCtx->unk_1F8 = pauseCtx->unk_204 + 314.0f;
pauseCtx->equipPagePitch = pauseCtx->promptPitch + 314.0f;
Matrix_Translate(-pauseCtx->unk_1F0 / 10.0f, (f32)WREG(2) / 100.0f, 0.0f, MTXMODE_NEW);
Matrix_Translate(-pauseCtx->promptDepthOffset / 10.0f, (f32)R_PAUSE_PAGES_Y_ORIGIN_2 / 100.0f, 0.0f,
MTXMODE_NEW);
Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY);
Matrix_RotateZ(pauseCtx->unk_204 / 100.0f, MTXMODE_APPLY);
Matrix_RotateZ(pauseCtx->promptPitch / 100.0f, MTXMODE_APPLY);
Matrix_RotateY(1.57f, MTXMODE_APPLY);
}
@ -2479,7 +2497,7 @@ s16 KaleidoScope_SetPageVertices(PlayState* play, Vtx* vtx, s16 vtxPage, s16 num
vtx[bufI + 1].v.ob[0] = vtx[bufI + 3].v.ob[0] = vtx[bufI + 0].v.ob[0] + PAGE_BG_QUAD_WIDTH;
vtx[bufI + 0].v.ob[1] = vtx[bufI + 1].v.ob[1] = pageBgQuadY + pauseCtx->offsetY;
vtx[bufI + 0].v.ob[1] = vtx[bufI + 1].v.ob[1] = pageBgQuadY + pauseCtx->pagesYOrigin1;
vtx[bufI + 2].v.ob[1] = vtx[bufI + 3].v.ob[1] = vtx[bufI + 0].v.ob[1] - PAGE_BG_QUAD_HEIGHT;
@ -2529,9 +2547,9 @@ s16 KaleidoScope_SetPageVertices(PlayState* play, Vtx* vtx, s16 vtxPage, s16 num
vtx[bufI + 1].v.ob[0] = vtx[bufI + 3].v.ob[0] = vtx[bufI + 0].v.ob[0] + quadsWidth[j];
if (!IS_PAUSE_STATE_GAMEOVER(pauseCtx)) {
vtx[bufI + 0].v.ob[1] = vtx[bufI + 1].v.ob[1] = quadsY[j] + pauseCtx->offsetY;
vtx[bufI + 0].v.ob[1] = vtx[bufI + 1].v.ob[1] = quadsY[j] + pauseCtx->pagesYOrigin1;
} else {
vtx[bufI + 0].v.ob[1] = vtx[bufI + 1].v.ob[1] = YREG(60 + j) + pauseCtx->offsetY;
vtx[bufI + 0].v.ob[1] = vtx[bufI + 1].v.ob[1] = YREG(60 + j) + pauseCtx->pagesYOrigin1;
}
vtx[bufI + 2].v.ob[1] = vtx[bufI + 3].v.ob[1] = vtx[bufI + 0].v.ob[1] - quadsHeight[j];
@ -2567,7 +2585,7 @@ s16 KaleidoScope_SetPageVertices(PlayState* play, Vtx* vtx, s16 vtxPage, s16 num
vtx[bufI + 1].v.ob[0] = vtx[bufI + 3].v.ob[0] = vtx[bufI + 0].v.ob[0] + sVtxMapWorldAreaWidth[j];
vtx[bufI + 0].v.ob[1] = vtx[bufI + 1].v.ob[1] = sVtxMapWorldAreaY[j] + pauseCtx->offsetY;
vtx[bufI + 0].v.ob[1] = vtx[bufI + 1].v.ob[1] = sVtxMapWorldAreaY[j] + pauseCtx->pagesYOrigin1;
vtx[bufI + 2].v.ob[1] = vtx[bufI + 3].v.ob[1] = vtx[bufI + 0].v.ob[1] - sVtxMapWorldAreaHeight[j];
@ -2654,14 +2672,16 @@ void KaleidoScope_SetVertices(PlayState* play, GraphicsContext* gfxCtx) {
s16 j;
s16 k;
pauseCtx->offsetY = 0;
pauseCtx->pagesYOrigin1 = 0;
if ((pauseCtx->state == PAUSE_STATE_OPENING_1) || (pauseCtx->state >= PAUSE_STATE_CLOSING) ||
((pauseCtx->state == PAUSE_STATE_SAVE_PROMPT) &&
((pauseCtx->savePromptState == PAUSE_SAVE_PROMPT_STATE_CLOSING) ||
(pauseCtx->savePromptState == PAUSE_SAVE_PROMPT_STATE_CLOSING_AFTER_SAVED))) ||
((pauseCtx->state >= PAUSE_STATE_8) && (pauseCtx->state <= PAUSE_STATE_13))) {
pauseCtx->offsetY = 80;
// When opening/closing, translate the page vertices so that the pages rotate around their lower edge
// instead of the middle.
pauseCtx->pagesYOrigin1 = PAUSE_PAGES_Y_ORIGIN_1_LOWER;
}
pauseCtx->itemPageVtx = GRAPH_ALLOC(gfxCtx, ((PAGE_BG_QUADS + VTX_PAGE_ITEM_QUADS) * 4) * sizeof(Vtx));
@ -2681,7 +2701,7 @@ void KaleidoScope_SetVertices(PlayState* play, GraphicsContext* gfxCtx) {
pauseCtx->mapPageVtx[j + 1].v.ob[0] = pauseCtx->mapPageVtx[j + 3].v.ob[0] =
pauseCtx->mapPageVtx[j + 0].v.ob[0] + WORLD_MAP_IMAGE_WIDTH;
pauseCtx->mapPageVtx[j + 0].v.ob[1] = pauseCtx->mapPageVtx[j + 1].v.ob[1] = y + pauseCtx->offsetY;
pauseCtx->mapPageVtx[j + 0].v.ob[1] = pauseCtx->mapPageVtx[j + 1].v.ob[1] = y + pauseCtx->pagesYOrigin1;
pauseCtx->mapPageVtx[j + 2].v.ob[1] = pauseCtx->mapPageVtx[j + 3].v.ob[1] =
pauseCtx->mapPageVtx[j + 0].v.ob[1] - WORLD_MAP_IMAGE_FRAG_HEIGHT;
@ -2763,7 +2783,7 @@ void KaleidoScope_SetVertices(PlayState* play, GraphicsContext* gfxCtx) {
pauseCtx->itemVtx[i + 1].v.ob[0] = pauseCtx->itemVtx[i + 3].v.ob[0] =
pauseCtx->itemVtx[i + 0].v.ob[0] + 0x1C;
pauseCtx->itemVtx[i + 0].v.ob[1] = pauseCtx->itemVtx[i + 1].v.ob[1] = y + pauseCtx->offsetY - 2;
pauseCtx->itemVtx[i + 0].v.ob[1] = pauseCtx->itemVtx[i + 1].v.ob[1] = y + pauseCtx->pagesYOrigin1 - 2;
pauseCtx->itemVtx[i + 2].v.ob[1] = pauseCtx->itemVtx[i + 3].v.ob[1] =
pauseCtx->itemVtx[i + 0].v.ob[1] - 0x1C;
@ -2886,7 +2906,7 @@ void KaleidoScope_SetVertices(PlayState* play, GraphicsContext* gfxCtx) {
pauseCtx->equipVtx[k + 1].v.ob[0] = pauseCtx->equipVtx[k + 3].v.ob[0] =
pauseCtx->equipVtx[k + 0].v.ob[0] + 28;
pauseCtx->equipVtx[k + 0].v.ob[1] = pauseCtx->equipVtx[k + 1].v.ob[1] = y + pauseCtx->offsetY - 2;
pauseCtx->equipVtx[k + 0].v.ob[1] = pauseCtx->equipVtx[k + 1].v.ob[1] = y + pauseCtx->pagesYOrigin1 - 2;
pauseCtx->equipVtx[k + 2].v.ob[1] = pauseCtx->equipVtx[k + 3].v.ob[1] =
pauseCtx->equipVtx[k + 0].v.ob[1] - 28;
@ -2960,7 +2980,7 @@ void KaleidoScope_SetVertices(PlayState* play, GraphicsContext* gfxCtx) {
pauseCtx->equipVtx[k + 1].v.ob[0] = pauseCtx->equipVtx[k + 3].v.ob[0] = pauseCtx->equipVtx[k + 0].v.ob[0] + 64;
pauseCtx->equipVtx[k + 0].v.ob[1] = pauseCtx->equipVtx[k + 1].v.ob[1] = y + pauseCtx->offsetY;
pauseCtx->equipVtx[k + 0].v.ob[1] = pauseCtx->equipVtx[k + 1].v.ob[1] = y + pauseCtx->pagesYOrigin1;
pauseCtx->equipVtx[k + 2].v.ob[1] = pauseCtx->equipVtx[k + 3].v.ob[1] = pauseCtx->equipVtx[k + 0].v.ob[1] - 32;
@ -3010,7 +3030,8 @@ void KaleidoScope_SetVertices(PlayState* play, GraphicsContext* gfxCtx) {
pauseCtx->questVtx[k + 1].v.ob[0] = pauseCtx->questVtx[k + 3].v.ob[0] =
pauseCtx->questVtx[k + 0].v.ob[0] + D_8082B1F8[j];
pauseCtx->questVtx[k + 0].v.ob[1] = pauseCtx->questVtx[k + 1].v.ob[1] = D_8082B198[j] + pauseCtx->offsetY;
pauseCtx->questVtx[k + 0].v.ob[1] = pauseCtx->questVtx[k + 1].v.ob[1] =
D_8082B198[j] + pauseCtx->pagesYOrigin1;
pauseCtx->questVtx[k + 2].v.ob[1] = pauseCtx->questVtx[k + 3].v.ob[1] =
pauseCtx->questVtx[k + 0].v.ob[1] - D_8082B1F8[j];
@ -3020,7 +3041,7 @@ void KaleidoScope_SetVertices(PlayState* play, GraphicsContext* gfxCtx) {
pauseCtx->questVtx[k + 0].v.ob[0] + 8;
pauseCtx->questVtx[k + 0].v.ob[1] = pauseCtx->questVtx[k + 1].v.ob[1] =
D_8082B198[j] + pauseCtx->offsetY - 6;
D_8082B198[j] + pauseCtx->pagesYOrigin1 - 6;
pauseCtx->questVtx[k + 2].v.ob[1] = pauseCtx->questVtx[k + 3].v.ob[1] =
pauseCtx->questVtx[k + 0].v.ob[1] - 16;
@ -3038,7 +3059,7 @@ void KaleidoScope_SetVertices(PlayState* play, GraphicsContext* gfxCtx) {
pauseCtx->questVtx[k + 0].v.ob[0] + phi_t2_2 - 4;
pauseCtx->questVtx[k + 0].v.ob[1] = pauseCtx->questVtx[k + 1].v.ob[1] =
D_8082B198[j] + pauseCtx->offsetY - 2;
D_8082B198[j] + pauseCtx->pagesYOrigin1 - 2;
pauseCtx->questVtx[k + 2].v.ob[1] = pauseCtx->questVtx[k + 3].v.ob[1] =
pauseCtx->questVtx[k + 0].v.ob[1] - D_8082B1F8[j] + 4;
@ -3412,7 +3433,7 @@ void KaleidoScope_Update(PlayState* play) {
WREG(16) = -175;
WREG(17) = 155;
pauseCtx->unk_204 = -314.0f;
pauseCtx->promptPitch = -314.0f;
//! @bug messed up alignment, should match `ALIGN64`
pauseCtx->playerSegment = (void*)(((uintptr_t)play->objectCtx.spaceStart + 0x30) & ~0x3F);
@ -3767,14 +3788,15 @@ void KaleidoScope_Update(PlayState* play) {
break;
case PAUSE_STATE_OPENING_1:
if (pauseCtx->unk_1F4 == 160.0f) {
if (pauseCtx->itemPagePitch == 160.0f) {
// First frame in this state
KaleidoScope_SetDefaultCursor(play);
KaleidoScope_ProcessPlayerPreRender();
}
pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 -= 160.0f / WREG(6);
pauseCtx->itemPagePitch = pauseCtx->equipPagePitch = pauseCtx->mapPagePitch = pauseCtx->questPagePitch -=
160.0f / WREG(6);
pauseCtx->infoPanelOffsetY += 40 / WREG(6);
interfaceCtx->startAlpha += 255 / WREG(6);
WREG(16) += WREG(25) / WREG(6);
@ -3782,9 +3804,9 @@ void KaleidoScope_Update(PlayState* play) {
XREG(5) += 150 / WREG(6);
pauseCtx->alpha += (u16)(255 / (WREG(6) + WREG(4)));
if (pauseCtx->unk_1F4 == 0) {
if (pauseCtx->itemPagePitch == 0) {
interfaceCtx->startAlpha = 255;
WREG(2) = 0;
R_PAUSE_PAGES_Y_ORIGIN_2 = 0;
pauseCtx->state = PAUSE_STATE_OPENING_2;
}
@ -3806,7 +3828,7 @@ void KaleidoScope_Update(PlayState* play) {
if (CHECK_BTN_ALL(input->press.button, BTN_START)) {
Interface_SetDoAction(play, DO_ACTION_NONE);
pauseCtx->state = PAUSE_STATE_CLOSING;
WREG(2) = -6240;
R_PAUSE_PAGES_Y_ORIGIN_2 = PAUSE_PAGES_Y_ORIGIN_2_LOWER;
func_800F64E0(0);
#if !PLATFORM_N64 && OOT_NTSC
AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF);
@ -3852,7 +3874,7 @@ void KaleidoScope_Update(PlayState* play) {
AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF);
Interface_SetDoAction(play, DO_ACTION_NONE);
pauseCtx->state = PAUSE_STATE_CLOSING;
WREG(2) = -6240;
R_PAUSE_PAGES_Y_ORIGIN_2 = PAUSE_PAGES_Y_ORIGIN_2_LOWER;
func_800F64E0(0);
pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE;
break;
@ -3903,7 +3925,7 @@ void KaleidoScope_Update(PlayState* play) {
AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF);
Interface_SetDoAction(play, DO_ACTION_NONE);
pauseCtx->state = PAUSE_STATE_CLOSING;
WREG(2) = -6240;
R_PAUSE_PAGES_Y_ORIGIN_2 = PAUSE_PAGES_Y_ORIGIN_2_LOWER;
func_800F64E0(0);
pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE;
} else if (CHECK_BTN_ALL(input->press.button, BTN_B)) {
@ -3935,11 +3957,11 @@ void KaleidoScope_Update(PlayState* play) {
case PAUSE_STATE_SAVE_PROMPT:
switch (pauseCtx->savePromptState) {
case PAUSE_SAVE_PROMPT_STATE_APPEARING:
pauseCtx->unk_204 -= 314.0f / WREG(6);
pauseCtx->promptPitch -= 314.0f / WREG(6);
WREG(16) -= WREG(25) / WREG(6);
WREG(17) -= WREG(26) / WREG(6);
if (pauseCtx->unk_204 <= -628.0f) {
pauseCtx->unk_204 = -628.0f;
if (pauseCtx->promptPitch <= -628.0f) {
pauseCtx->promptPitch = -628.0f;
pauseCtx->savePromptState = PAUSE_SAVE_PROMPT_STATE_WAIT_CHOICE;
}
break;
@ -3953,8 +3975,8 @@ void KaleidoScope_Update(PlayState* play) {
gSaveContext.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE;
Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL);
pauseCtx->savePromptState = PAUSE_SAVE_PROMPT_STATE_CLOSING;
WREG(2) = -6240;
YREG(8) = pauseCtx->unk_204;
R_PAUSE_PAGES_Y_ORIGIN_2 = PAUSE_PAGES_Y_ORIGIN_2_LOWER;
YREG(8) = pauseCtx->promptPitch;
func_800F64E0(0);
#if !PLATFORM_N64 && OOT_NTSC
AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF);
@ -3977,8 +3999,8 @@ void KaleidoScope_Update(PlayState* play) {
CHECK_BTN_ALL(input->press.button, BTN_B)) {
Interface_SetDoAction(play, DO_ACTION_NONE);
pauseCtx->savePromptState = PAUSE_SAVE_PROMPT_STATE_CLOSING;
WREG(2) = -6240;
YREG(8) = pauseCtx->unk_204;
R_PAUSE_PAGES_Y_ORIGIN_2 = PAUSE_PAGES_Y_ORIGIN_2_LOWER;
YREG(8) = pauseCtx->promptPitch;
func_800F64E0(0);
gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] =
gSaveContext.buttonStatus[3] = BTN_ENABLED;
@ -3999,46 +4021,48 @@ void KaleidoScope_Update(PlayState* play) {
gSaveContext.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE;
Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL);
pauseCtx->savePromptState = PAUSE_SAVE_PROMPT_STATE_CLOSING_AFTER_SAVED;
WREG(2) = -6240;
YREG(8) = pauseCtx->unk_204;
R_PAUSE_PAGES_Y_ORIGIN_2 = PAUSE_PAGES_Y_ORIGIN_2_LOWER;
YREG(8) = pauseCtx->promptPitch;
func_800F64E0(0);
}
break;
case PAUSE_SAVE_PROMPT_STATE_RETURN_TO_MENU:
case PAUSE_SAVE_PROMPT_STATE_RETURN_TO_MENU_2:
pauseCtx->unk_204 += 314.0f / WREG(6);
pauseCtx->promptPitch += 314.0f / WREG(6);
WREG(16) += WREG(25) / WREG(6);
WREG(17) += WREG(26) / WREG(6);
if (pauseCtx->unk_204 >= -314.0f) {
if (pauseCtx->promptPitch >= -314.0f) {
pauseCtx->state = PAUSE_STATE_MAIN;
pauseCtx->savePromptState = PAUSE_SAVE_PROMPT_STATE_APPEARING;
pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = 0.0f;
pauseCtx->unk_204 = -314.0f;
pauseCtx->itemPagePitch = pauseCtx->equipPagePitch = pauseCtx->mapPagePitch =
pauseCtx->questPagePitch = 0.0f;
pauseCtx->promptPitch = -314.0f;
}
break;
case PAUSE_SAVE_PROMPT_STATE_CLOSING:
case PAUSE_SAVE_PROMPT_STATE_CLOSING_AFTER_SAVED:
if (pauseCtx->unk_204 != (YREG(8) + 160.0f)) {
pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 +=
160.0f / WREG(6);
pauseCtx->unk_204 += 160.0f / WREG(6);
if (pauseCtx->promptPitch != (YREG(8) + 160.0f)) {
pauseCtx->itemPagePitch = pauseCtx->equipPagePitch = pauseCtx->mapPagePitch =
pauseCtx->questPagePitch += 160.0f / WREG(6);
pauseCtx->promptPitch += 160.0f / WREG(6);
pauseCtx->infoPanelOffsetY -= 40 / WREG(6);
WREG(16) -= WREG(25) / WREG(6);
WREG(17) -= WREG(26) / WREG(6);
XREG(5) -= 150 / WREG(6);
pauseCtx->alpha -= (u16)(255 / WREG(6));
if (pauseCtx->unk_204 == (YREG(8) + 160.0f)) {
if (pauseCtx->promptPitch == (YREG(8) + 160.0f)) {
pauseCtx->alpha = 0;
}
} else {
pauseCtx->debugState = 0;
pauseCtx->state = PAUSE_STATE_RESUME_GAMEPLAY;
pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = 160.0f;
pauseCtx->itemPagePitch = pauseCtx->equipPagePitch = pauseCtx->mapPagePitch =
pauseCtx->questPagePitch = 160.0f;
pauseCtx->namedItem = PAUSE_ITEM_NONE;
pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE;
pauseCtx->unk_204 = -434.0f;
pauseCtx->promptPitch = -434.0f;
}
break;
@ -4052,7 +4076,7 @@ void KaleidoScope_Update(PlayState* play) {
VREG(30) + 3;
WREG(16) = -175;
WREG(17) = 155;
pauseCtx->unk_204 = -434.0f;
pauseCtx->promptPitch = -434.0f;
Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_NOTHING);
//! @bug messed up alignment, should match `ALIGN64`
@ -4188,8 +4212,8 @@ void KaleidoScope_Update(PlayState* play) {
break;
case PAUSE_STATE_13:
pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = pauseCtx->unk_204 -=
160.0f / WREG(6);
pauseCtx->itemPagePitch = pauseCtx->equipPagePitch = pauseCtx->mapPagePitch = pauseCtx->questPagePitch =
pauseCtx->promptPitch -= 160.0f / WREG(6);
pauseCtx->infoPanelOffsetY += 40 / WREG(6);
interfaceCtx->startAlpha += 255 / WREG(6);
VREG(88) -= 3;
@ -4197,11 +4221,11 @@ void KaleidoScope_Update(PlayState* play) {
WREG(17) += WREG(26) / WREG(6);
XREG(5) += 150 / WREG(6);
pauseCtx->alpha += (u16)(255 / (WREG(6) + WREG(4)));
if (pauseCtx->unk_204 < -628.0f) {
pauseCtx->unk_204 = -628.0f;
if (pauseCtx->promptPitch < -628.0f) {
pauseCtx->promptPitch = -628.0f;
interfaceCtx->startAlpha = 255;
VREG(88) = 66;
WREG(2) = 0;
R_PAUSE_PAGES_Y_ORIGIN_2 = 0;
pauseCtx->alpha = 255;
pauseCtx->state = PAUSE_STATE_14;
gSaveContext.save.info.playerData.deaths++;
@ -4209,7 +4233,7 @@ void KaleidoScope_Update(PlayState* play) {
gSaveContext.save.info.playerData.deaths = 999;
}
}
PRINTF("kscope->angle_s = %f\n", pauseCtx->unk_204);
PRINTF("kscope->angle_s = %f\n", pauseCtx->promptPitch);
break;
case PAUSE_STATE_14:
@ -4360,24 +4384,25 @@ void KaleidoScope_Update(PlayState* play) {
break;
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);
if (pauseCtx->itemPagePitch != 160.0f) {
pauseCtx->itemPagePitch = pauseCtx->equipPagePitch = pauseCtx->mapPagePitch =
pauseCtx->questPagePitch += 160.0f / WREG(6);
pauseCtx->infoPanelOffsetY -= 40 / WREG(6);
interfaceCtx->startAlpha -= 255 / WREG(6);
WREG(16) -= WREG(25) / WREG(6);
WREG(17) -= WREG(26) / WREG(6);
XREG(5) -= 150 / WREG(6);
pauseCtx->alpha -= (u16)(255 / WREG(6));
if (pauseCtx->unk_1F4 == 160.0f) {
if (pauseCtx->itemPagePitch == 160.0f) {
pauseCtx->alpha = 0;
}
} else {
pauseCtx->debugState = 0;
pauseCtx->state = PAUSE_STATE_RESUME_GAMEPLAY;
pauseCtx->unk_200 = 160.0f;
pauseCtx->unk_1FC = 160.0f;
pauseCtx->unk_1F8 = 160.0f;
pauseCtx->unk_1F4 = 160.0f;
pauseCtx->questPagePitch = 160.0f;
pauseCtx->mapPagePitch = 160.0f;
pauseCtx->equipPagePitch = 160.0f;
pauseCtx->itemPagePitch = 160.0f;
pauseCtx->namedItem = PAUSE_ITEM_NONE;
play->interfaceCtx.startAlpha = 0;
}