1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-02-09 14:06:54 +00:00

Match KaleidoScope_DrawEquipment and KaleidoScope_DrawItemSelect (#2125)

This commit is contained in:
cadmic 2024-09-03 23:12:33 -07:00 committed by GitHub
parent e7cf2fceac
commit 27ba989511
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 65 additions and 92 deletions

View file

@ -120,22 +120,22 @@ void KaleidoScope_ProcessPlayerPreRender(PlayState* play);
void KaleidoScope_DrawEquipment(PlayState* play) { void KaleidoScope_DrawEquipment(PlayState* play) {
static s16 sEquipTimer = 0; static s16 sEquipTimer = 0;
PauseContext* pauseCtx = &play->pauseCtx; PauseContext* pauseCtx = &play->pauseCtx;
InterfaceContext* interfaceCtx = &play->interfaceCtx;
Input* input = &play->state.input[0]; Input* input = &play->state.input[0];
u16 i; u16 i;
u16 j; u16 j;
u16 k; u16 k;
u16 bit; u16 bit;
u16 rowStart;
u16 temp; u16 temp;
u16 point; u16 point;
u16 rowStart;
u16 pad;
s16 cursorMoveResult; s16 cursorMoveResult;
u16 cursorItem;
u16 cursorSlot; u16 cursorSlot;
s16 cursorPoint; u16 cursorItem;
s16 cursorX; s16 cursorX;
s16 cursorY; s16 cursorY;
volatile s16 oldCursorPoint; s16 oldCursorPoint;
s16 cursorPoint;
OPEN_DISPS(play->state.gfxCtx, "../z_kaleido_equipment.c", 219); OPEN_DISPS(play->state.gfxCtx, "../z_kaleido_equipment.c", 219);
@ -170,7 +170,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) {
cursorY = pauseCtx->cursorY[PAUSE_EQUIP]; cursorY = pauseCtx->cursorY[PAUSE_EQUIP];
cursorMoveResult = 0; cursorMoveResult = 0;
while (cursorMoveResult == 0) { do {
if (pauseCtx->stickAdjX < -30) { if (pauseCtx->stickAdjX < -30) {
if (pauseCtx->cursorX[PAUSE_EQUIP] != 0) { if (pauseCtx->cursorX[PAUSE_EQUIP] != 0) {
pauseCtx->cursorX[PAUSE_EQUIP]--; pauseCtx->cursorX[PAUSE_EQUIP]--;
@ -254,15 +254,13 @@ void KaleidoScope_DrawEquipment(PlayState* play) {
} else { } else {
cursorMoveResult = 4; cursorMoveResult = 4;
} }
} } while (cursorMoveResult == 0);
cursorPoint = pauseCtx->cursorPoint[PAUSE_EQUIP]; cursorPoint = pauseCtx->cursorPoint[PAUSE_EQUIP];
cursorY = pauseCtx->cursorY[PAUSE_EQUIP]; cursorY = pauseCtx->cursorY[PAUSE_EQUIP];
if (cursorMoveResult) {}
cursorMoveResult = 0; cursorMoveResult = 0;
while (cursorMoveResult == 0) { do {
if (pauseCtx->stickAdjY > 30) { if (pauseCtx->stickAdjY > 30) {
if (pauseCtx->cursorY[PAUSE_EQUIP] != 0) { if (pauseCtx->cursorY[PAUSE_EQUIP] != 0) {
pauseCtx->cursorY[PAUSE_EQUIP]--; pauseCtx->cursorY[PAUSE_EQUIP]--;
@ -306,7 +304,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) {
} else { } else {
cursorMoveResult = 4; cursorMoveResult = 4;
} }
} } while (cursorMoveResult == 0);
} else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) {
if (pauseCtx->stickAdjX > 30) { if (pauseCtx->stickAdjX > 30) {
pauseCtx->nameDisplayTimer = 0; pauseCtx->nameDisplayTimer = 0;
@ -340,21 +338,17 @@ void KaleidoScope_DrawEquipment(PlayState* play) {
cursorY = cursorY + 1; cursorY = cursorY + 1;
cursorPoint = cursorPoint + 4; cursorPoint = cursorPoint + 4;
if (cursorY < 4) { if (cursorY >= 4) {
continue;
}
cursorY = 0; cursorY = 0;
cursorPoint = cursorX + 1; cursorPoint = cursorX + 1;
cursorX = cursorPoint; cursorX = cursorPoint;
if (cursorX < 4) { if (cursorX >= 4) {
continue;
}
KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT);
break; break;
} }
} }
}
}
} else { } else {
if (pauseCtx->stickAdjX < -30) { if (pauseCtx->stickAdjX < -30) {
pauseCtx->nameDisplayTimer = 0; pauseCtx->nameDisplayTimer = 0;
@ -381,22 +375,18 @@ void KaleidoScope_DrawEquipment(PlayState* play) {
cursorY = cursorY + 1; cursorY = cursorY + 1;
cursorPoint = cursorPoint + 4; cursorPoint = cursorPoint + 4;
if (cursorY < 4) { if (cursorY >= 4) {
continue;
}
cursorY = 0; cursorY = 0;
cursorPoint = cursorX - 1; cursorPoint = cursorX - 1;
cursorX = cursorPoint; cursorX = cursorPoint;
if (cursorX >= 0) { if (cursorX < 0) {
continue;
}
KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT);
break; break;
} }
} }
} }
}
}
if (pauseCtx->cursorX[PAUSE_EQUIP] == 0) { if (pauseCtx->cursorX[PAUSE_EQUIP] == 0) {
pauseCtx->cursorColorSet = 0; pauseCtx->cursorColorSet = 0;
@ -599,7 +589,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) {
gSPSegment(POLY_OPA_DISP++, 0x08, pauseCtx->iconItemSegment); gSPSegment(POLY_OPA_DISP++, 0x08, pauseCtx->iconItemSegment);
gSPSegment(POLY_OPA_DISP++, 0x09, pauseCtx->iconItem24Segment); gSPSegment(POLY_OPA_DISP++, 0x09, pauseCtx->iconItem24Segment);
gSPSegment(POLY_OPA_DISP++, 0x0A, pauseCtx->nameSegment); gSPSegment(POLY_OPA_DISP++, 0x0A, pauseCtx->nameSegment);
gSPSegment(POLY_OPA_DISP++, 0x0B, play->interfaceCtx.mapSegment); gSPSegment(POLY_OPA_DISP++, 0x0B, interfaceCtx->mapSegment);
gSPSegment(POLY_OPA_DISP++, 0x0C, pauseCtx->iconItemAltSegment); gSPSegment(POLY_OPA_DISP++, 0x0C, pauseCtx->iconItemAltSegment);
Gfx_SetupDL_42Opa(play->state.gfxCtx); Gfx_SetupDL_42Opa(play->state.gfxCtx);

View file

@ -92,7 +92,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
s16 cursorX; s16 cursorX;
s16 cursorY; s16 cursorY;
s16 oldCursorPoint; s16 oldCursorPoint;
s16 moveCursorResult; s16 cursorMoveResult;
OPEN_DISPS(play->state.gfxCtx, "../z_kaleido_item.c", 234); OPEN_DISPS(play->state.gfxCtx, "../z_kaleido_item.c", 234);
@ -105,7 +105,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) &&
(pauseCtx->pageIndex == PAUSE_ITEM)) { (pauseCtx->pageIndex == PAUSE_ITEM)) {
moveCursorResult = 0; cursorMoveResult = 0;
oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM];
cursorItem = pauseCtx->cursorItem[PAUSE_ITEM]; cursorItem = pauseCtx->cursorItem[PAUSE_ITEM];
@ -118,10 +118,6 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
pauseCtx->stickAdjX = 40; pauseCtx->stickAdjX = 40;
} }
#if !OOT_DEBUG
if (&gSaveContext) {}
#endif
if (ABS(pauseCtx->stickAdjX) > 30) { if (ABS(pauseCtx->stickAdjX) > 30) {
cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM];
cursorX = pauseCtx->cursorX[PAUSE_ITEM]; cursorX = pauseCtx->cursorX[PAUSE_ITEM];
@ -129,13 +125,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
PRINTF("now=%d ccc=%d\n", cursorPoint, cursorItem); PRINTF("now=%d ccc=%d\n", cursorPoint, cursorItem);
#if OOT_DEBUG do {
// Seems necessary to match
if (pauseCtx->cursorX[PAUSE_ITEM]) {}
if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]) {}
#endif
while (moveCursorResult == 0) {
if (pauseCtx->stickAdjX < -30) { if (pauseCtx->stickAdjX < -30) {
if (pauseCtx->cursorX[PAUSE_ITEM] != 0) { if (pauseCtx->cursorX[PAUSE_ITEM] != 0) {
pauseCtx->cursorX[PAUSE_ITEM]--; pauseCtx->cursorX[PAUSE_ITEM]--;
@ -143,7 +133,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] !=
ITEM_NONE) { ITEM_NONE) {
moveCursorResult = 1; cursorMoveResult = 1;
} }
} else { } else {
pauseCtx->cursorX[PAUSE_ITEM] = cursorX; pauseCtx->cursorX[PAUSE_ITEM] = cursorX;
@ -166,7 +156,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT);
moveCursorResult = 2; cursorMoveResult = 2;
} }
} }
} else if (pauseCtx->stickAdjX > 30) { } else if (pauseCtx->stickAdjX > 30) {
@ -176,7 +166,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] !=
ITEM_NONE) { ITEM_NONE) {
moveCursorResult = 1; cursorMoveResult = 1;
} }
} else { } else {
pauseCtx->cursorX[PAUSE_ITEM] = cursorX; pauseCtx->cursorX[PAUSE_ITEM] = cursorX;
@ -199,18 +189,18 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT);
moveCursorResult = 2; cursorMoveResult = 2;
}
} }
} }
} }
} while (cursorMoveResult == 0);
if (moveCursorResult == 1) { if (cursorMoveResult == 1) {
cursorItem = gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; cursorItem = gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]];
} }
PRINTF("【X cursor=%d(%) (cur_xpt=%d)(ok_fg=%d)(ccc=%d)(key_angle=%d)】 ", PRINTF("【X cursor=%d(%) (cur_xpt=%d)(ok_fg=%d)(ccc=%d)(key_angle=%d)】 ",
pauseCtx->cursorPoint[PAUSE_ITEM], pauseCtx->cursorX[PAUSE_ITEM], moveCursorResult, cursorItem, pauseCtx->cursorPoint[PAUSE_ITEM], pauseCtx->cursorX[PAUSE_ITEM], cursorMoveResult, cursorItem,
pauseCtx->cursorSpecialPos); pauseCtx->cursorSpecialPos);
} }
} else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) {
@ -227,27 +217,23 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint;
pauseCtx->cursorX[PAUSE_ITEM] = cursorX; pauseCtx->cursorX[PAUSE_ITEM] = cursorX;
pauseCtx->cursorY[PAUSE_ITEM] = cursorY; pauseCtx->cursorY[PAUSE_ITEM] = cursorY;
moveCursorResult = 1; cursorMoveResult = 1;
break; break;
} }
cursorY = cursorY + 1; cursorY = cursorY + 1;
cursorPoint = cursorPoint + 6; cursorPoint = cursorPoint + 6;
if (cursorY < 4) { if (cursorY >= 4) {
continue;
}
cursorY = 0; cursorY = 0;
cursorPoint = cursorX + 1; cursorPoint = cursorX + 1;
cursorX = cursorPoint; cursorX = cursorPoint;
if (cursorX < 6) { if (cursorX >= 6) {
continue;
}
KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT);
break; break;
} }
} }
}
}
} else { } else {
if (pauseCtx->stickAdjX < -30) { if (pauseCtx->stickAdjX < -30) {
pauseCtx->nameDisplayTimer = 0; pauseCtx->nameDisplayTimer = 0;
@ -263,37 +249,33 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint;
pauseCtx->cursorX[PAUSE_ITEM] = cursorX; pauseCtx->cursorX[PAUSE_ITEM] = cursorX;
pauseCtx->cursorY[PAUSE_ITEM] = cursorY; pauseCtx->cursorY[PAUSE_ITEM] = cursorY;
moveCursorResult = 1; cursorMoveResult = 1;
break; break;
} }
cursorY = cursorY + 1; cursorY = cursorY + 1;
cursorPoint = cursorPoint + 6; cursorPoint = cursorPoint + 6;
if (cursorY < 4) { if (cursorY >= 4) {
continue;
}
cursorY = 0; cursorY = 0;
cursorPoint = cursorX - 1; cursorPoint = cursorX - 1;
cursorX = cursorPoint; cursorX = cursorPoint;
if (cursorX >= 0) { if (cursorX < 0) {
continue;
}
KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT);
break; break;
} }
} }
} }
}
}
if (pauseCtx->cursorSpecialPos == 0) { if (pauseCtx->cursorSpecialPos == 0) {
if (cursorItem != PAUSE_ITEM_NONE) { if (cursorItem != PAUSE_ITEM_NONE) {
if (ABS(pauseCtx->stickAdjY) > 30) { if (ABS(pauseCtx->stickAdjY) > 30) {
moveCursorResult = 0; cursorMoveResult = 0;
cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM];
cursorY = pauseCtx->cursorY[PAUSE_ITEM]; cursorY = pauseCtx->cursorY[PAUSE_ITEM];
while (moveCursorResult == 0) { do {
if (pauseCtx->stickAdjY > 30) { if (pauseCtx->stickAdjY > 30) {
if (pauseCtx->cursorY[PAUSE_ITEM] != 0) { if (pauseCtx->cursorY[PAUSE_ITEM] != 0) {
pauseCtx->cursorY[PAUSE_ITEM]--; pauseCtx->cursorY[PAUSE_ITEM]--;
@ -301,13 +283,13 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] !=
ITEM_NONE) { ITEM_NONE) {
moveCursorResult = 1; cursorMoveResult = 1;
} }
} else { } else {
pauseCtx->cursorY[PAUSE_ITEM] = cursorY; pauseCtx->cursorY[PAUSE_ITEM] = cursorY;
pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint;
moveCursorResult = 2; cursorMoveResult = 2;
} }
} else if (pauseCtx->stickAdjY < -30) { } else if (pauseCtx->stickAdjY < -30) {
if (pauseCtx->cursorY[PAUSE_ITEM] < 3) { if (pauseCtx->cursorY[PAUSE_ITEM] < 3) {
@ -316,20 +298,20 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] !=
ITEM_NONE) { ITEM_NONE) {
moveCursorResult = 1; cursorMoveResult = 1;
} }
} else { } else {
pauseCtx->cursorY[PAUSE_ITEM] = cursorY; pauseCtx->cursorY[PAUSE_ITEM] = cursorY;
pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint;
moveCursorResult = 2; cursorMoveResult = 2;
}
} }
} }
} while (cursorMoveResult == 0);
cursorPoint = PAUSE_ITEM; cursorPoint = PAUSE_ITEM;
PRINTF("【Y cursor=%d(%) (cur_ypt=%d)(ok_fg=%d)(ccc=%d)】 ", pauseCtx->cursorPoint[cursorPoint], PRINTF("【Y cursor=%d(%) (cur_ypt=%d)(ok_fg=%d)(ccc=%d)】 ", pauseCtx->cursorPoint[cursorPoint],
pauseCtx->cursorY[PAUSE_ITEM], moveCursorResult, cursorItem); pauseCtx->cursorY[PAUSE_ITEM], cursorMoveResult, cursorItem);
} }
} }
@ -337,9 +319,9 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
pauseCtx->cursorColorSet = 4; pauseCtx->cursorColorSet = 4;
if (moveCursorResult == 1) { if (cursorMoveResult == 1) {
cursorItem = gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; cursorItem = gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]];
} else if (moveCursorResult != 2) { } else if (cursorMoveResult != 2) {
cursorItem = gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; cursorItem = gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]];
} }
@ -418,6 +400,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
} }
} else if ((pauseCtx->mainState == PAUSE_MAIN_STATE_3) && (pauseCtx->pageIndex == PAUSE_ITEM)) { } else if ((pauseCtx->mainState == PAUSE_MAIN_STATE_3) && (pauseCtx->pageIndex == PAUSE_ITEM)) {
//! @bug cursorSlot is uninitialized
KaleidoScope_SetCursorVtx(pauseCtx, cursorSlot * 4, pauseCtx->itemVtx); KaleidoScope_SetCursorVtx(pauseCtx, cursorSlot * 4, pauseCtx->itemVtx);
pauseCtx->cursorColorSet = 4; pauseCtx->cursorColorSet = 4;
} }