diff --git a/include/regs.h b/include/regs.h index b5c39ea632..b708c79af8 100644 --- a/include/regs.h +++ b/include/regs.h @@ -134,6 +134,7 @@ #define R_START_LABEL_Y(i) ZREG(51 + (i)) #define R_START_LABEL_X(i) ZREG(54 + (i)) #endif +#define R_PAUSE_QUEST_MEDALLION_SHINE_TIME(i) ZREG(61 + (i)) // i = 0..3 (clashes with ZREG(62) and ZREG(63)) #define R_C_UP_BTN_X ZREG(62) #define R_C_UP_BTN_Y ZREG(63) #define R_START_BTN_X ZREG(68) diff --git a/src/code/z_construct.c b/src/code/z_construct.c index 7041ac2307..e190e19d20 100644 --- a/src/code/z_construct.c +++ b/src/code/z_construct.c @@ -373,10 +373,12 @@ void Regs_InitDataImpl(void) { R_START_LABEL_X(2) = 119; #endif - ZREG(61) = 1; - R_C_UP_BTN_X = C_UP_BUTTON_X; - R_C_UP_BTN_Y = C_UP_BUTTON_Y; - ZREG(64) = 20; + R_PAUSE_QUEST_MEDALLION_SHINE_TIME(0) = 1; + //! @bug Overlapping reg usage + R_C_UP_BTN_X = C_UP_BUTTON_X; // R_PAUSE_QUEST_MEDALLION_SHINE_TIME(1) + R_C_UP_BTN_Y = C_UP_BUTTON_Y; // R_PAUSE_QUEST_MEDALLION_SHINE_TIME(2) + R_PAUSE_QUEST_MEDALLION_SHINE_TIME(3) = 20; + ZREG(65) = 21; ZREG(66) = 122; R_ITEM_BTN_X(1) = C_LEFT_BUTTON_X; diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c index 7856b520b0..0847ea5546 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_collect.c @@ -13,27 +13,44 @@ #endif void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { - static s16 D_8082A070[][4] = { + static s16 sHpPrimColors[][4] = { { 255, 0, 0, 255 }, { 255, 70, 0, 150 }, { 255, 70, 0, 150 }, { 255, 0, 0, 255 }, }; - static s16 D_8082A090[][3] = { - { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, - { 0, 60, 0 }, { 90, 0, 0 }, { 0, 40, 110 }, { 80, 40, 0 }, { 70, 0, 90 }, { 90, 90, 0 }, + + // Shining medallions + static s16 sMedallionsEnvColors[6 + 6][3] = { + // Target env color when sMedEnvShineState == 0 + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + // Target env color when sMedEnvShineState == 2 + { 0, 60, 0 }, + { 90, 0, 0 }, + { 0, 40, 110 }, + { 80, 40, 0 }, + { 70, 0, 90 }, + { 90, 90, 0 }, }; - static s16 D_8082A0D8[] = { 255, 255, 255, 255, 255, 255 }; - static s16 D_8082A0E4[] = { 255, 255, 255, 255, 255, 255 }; - static s16 D_8082A0F0[] = { 150, 150, 150, 150, 150, 150 }; - static s16 D_8082A0FC = 20; - static s16 D_8082A100 = 0; - static s16 D_8082A104 = 0; - static s16 D_8082A108 = 0; - static s16 D_8082A10C = 0; - static s16 D_8082A110 = 0; - static s16 D_8082A114 = 20; - static s16 D_8082A118 = 0; + // Current (animated) env color for each medallion + static s16 sMedallionsEnvRed[6] = { 255, 255, 255, 255, 255, 255 }; + static s16 sMedallionsEnvGreen[6] = { 255, 255, 255, 255, 255, 255 }; + static s16 sMedallionsEnvBlue[6] = { 150, 150, 150, 150, 150, 150 }; + static s16 sMedallionsEnvTimer = 20; + static s16 sMedallionsEnvShineState = 0; + + static s16 sHpPrimRed = 0; + static s16 sHpPrimGreen = 0; + static s16 sHpPrimBlue = 0; + static s16 sHpPrimAlpha = 0; + static s16 sHpPrimTimer = 20; + static s16 sHpPrimState = 0; + static s16 D_8082A11C = 0; static s16 D_8082A120 = 0; static u8 D_8082A124[] = { @@ -52,15 +69,17 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { static s16 D_8082A150[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; - static s16 D_8082A164[] = { + + static s16 sSongsPrimRed[] = { 150, 255, 100, 255, 255, 255, 255, 255, 255, 255, 255, 255, }; - static s16 D_8082A17C[] = { + static s16 sSongsPrimGreen[] = { 255, 80, 150, 160, 100, 240, 255, 255, 255, 255, 255, 255, }; - static s16 D_8082A194[] = { + static s16 sSongsPrimBlue[] = { 100, 40, 255, 0, 255, 100, 255, 255, 255, 255, 255, 255, }; + static s8 D_8082A1AC[][4] = { { 0x05, 0x01, 0x05, 0xFE }, { 0x00, 0x02, 0x02, 0xFE }, { 0xFF, 0x13, 0x03, 0x01 }, { 0x04, 0x02, 0x11, 0x02 }, { 0x05, 0x03, 0x18, 0x05 }, { 0xFF, 0xFF, 0x04, 0x00 }, { 0x0C, 0xFF, 0xFD, 0x07 }, { 0x0D, 0xFF, 0x06, 0x08 }, @@ -70,22 +89,23 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { { 0x02, 0xFF, 0x13, 0xFE }, { 0xFF, 0x17, 0xFD, 0x16 }, { 0xFF, 0x17, 0x15, 0x18 }, { 0x15, 0x0C, 0xFD, 0x18 }, { 0xFF, 0x10, 0x16, 0x04 }, { 0x00, 0x00, 0x00, 0x00 }, }; + PauseContext* pauseCtx = &play->pauseCtx; Input* input = &play->state.input[0]; - s16 sp226; - s16 sp224; - s16 sp222; - s16 sp220; + s16 stepRed; + s16 stepGreen; + s16 stepBlue; + s16 stepAlpha; s16 phi_s0; s16 phi_s3; - s16 sp21A; - s16 sp218; + s16 bufI; + s16 j; s16 sp216; - s16 phi_s7; - s16 phi_v1; + s16 i; + s16 targetColorIndex; s16 pad2; s16 cursorItem; - s16 sp208[3]; + s16 gsTokenDigits[3]; OPEN_DISPS(gfxCtx, "../z_kaleido_collect.c", 248); @@ -196,9 +216,9 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { pauseCtx->ocarinaSongIdx = gOcarinaSongItemMap[sp216 - QUEST_SONG_MINUET]; D_8082A120 = 10; - for (phi_s7 = 0; phi_s7 < 8; phi_s7++) { - D_8082A124[phi_s7] = 0xFF; - D_8082A150[phi_s7] = 0; + for (i = 0; i < 8; i++) { + D_8082A124[i] = 0xFF; + D_8082A150[i] = 0; } D_8082A11C = 0; @@ -277,9 +297,9 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { pauseCtx->cursorColorSet = 8; if (--D_8082A120 == 0) { - for (phi_s7 = 0; phi_s7 < 8; phi_s7++) { - D_8082A124[phi_s7] = 0xFF; - D_8082A150[phi_s7] = 0; + for (i = 0; i < 8; i++) { + D_8082A124[i] = 0xFF; + D_8082A150[i] = 0; } D_8082A11C = 0; @@ -305,61 +325,68 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { } } + // Draw medallions + // QUEST_MEDALLION_FOREST to QUEST_MEDALLION_LIGHT + gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - D_8082A0FC--; + sMedallionsEnvTimer--; - for (sp218 = 0, sp21A = 0; sp218 < 6; sp218++, sp21A += 4) { - if ((D_8082A100 != 1) && (D_8082A100 != 3)) { - phi_v1 = (D_8082A100 != 0) ? sp218 + 6 : sp218; + for (j = 0, bufI = 0; j < 6; j++, bufI += 4) { + if ((sMedallionsEnvShineState != 1) && (sMedallionsEnvShineState != 3)) { + targetColorIndex = (sMedallionsEnvShineState != 0) ? j + 6 : j; - if (D_8082A0FC != 0) { - sp226 = ABS(D_8082A0D8[sp218] - D_8082A090[phi_v1][0]) / D_8082A0FC; - sp224 = ABS(D_8082A0E4[sp218] - D_8082A090[phi_v1][1]) / D_8082A0FC; - sp222 = ABS(D_8082A0F0[sp218] - D_8082A090[phi_v1][2]) / D_8082A0FC; - if (D_8082A0D8[sp218] >= D_8082A090[phi_v1][0]) { - D_8082A0D8[sp218] -= sp226; + if (sMedallionsEnvTimer != 0) { + stepRed = ABS(sMedallionsEnvRed[j] - sMedallionsEnvColors[targetColorIndex][0]) / sMedallionsEnvTimer; + stepGreen = + ABS(sMedallionsEnvGreen[j] - sMedallionsEnvColors[targetColorIndex][1]) / sMedallionsEnvTimer; + stepBlue = ABS(sMedallionsEnvBlue[j] - sMedallionsEnvColors[targetColorIndex][2]) / sMedallionsEnvTimer; + if (sMedallionsEnvRed[j] >= sMedallionsEnvColors[targetColorIndex][0]) { + sMedallionsEnvRed[j] -= stepRed; } else { - D_8082A0D8[sp218] += sp226; + sMedallionsEnvRed[j] += stepRed; } - if (D_8082A0E4[sp218] >= D_8082A090[phi_v1][1]) { - D_8082A0E4[sp218] -= sp224; + if (sMedallionsEnvGreen[j] >= sMedallionsEnvColors[targetColorIndex][1]) { + sMedallionsEnvGreen[j] -= stepGreen; } else { - D_8082A0E4[sp218] += sp224; + sMedallionsEnvGreen[j] += stepGreen; } - if (D_8082A0F0[sp218] >= D_8082A090[phi_v1][2]) { - D_8082A0F0[sp218] -= sp222; + if (sMedallionsEnvBlue[j] >= sMedallionsEnvColors[targetColorIndex][2]) { + sMedallionsEnvBlue[j] -= stepBlue; } else { - D_8082A0F0[sp218] += sp222; + sMedallionsEnvBlue[j] += stepBlue; } } else { - D_8082A0D8[sp218] = D_8082A090[phi_v1][0]; - D_8082A0E4[sp218] = D_8082A090[phi_v1][1]; - D_8082A0F0[sp218] = D_8082A090[phi_v1][2]; + sMedallionsEnvRed[j] = sMedallionsEnvColors[targetColorIndex][0]; + sMedallionsEnvGreen[j] = sMedallionsEnvColors[targetColorIndex][1]; + sMedallionsEnvBlue[j] = sMedallionsEnvColors[targetColorIndex][2]; } } - if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FOREST + sp218)) { + if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FOREST + j)) { gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); - gDPSetEnvColor(POLY_OPA_DISP++, D_8082A0D8[sp218], D_8082A0E4[sp218], D_8082A0F0[sp218], 0); - gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + gDPSetEnvColor(POLY_OPA_DISP++, sMedallionsEnvRed[j], sMedallionsEnvGreen[j], sMedallionsEnvBlue[j], 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[bufI], 4, 0); - KaleidoScope_DrawQuadTextureRGBA32(gfxCtx, gItemIcons[ITEM_MEDALLION_FOREST + sp218], QUEST_ICON_WIDTH, + KaleidoScope_DrawQuadTextureRGBA32(gfxCtx, gItemIcons[ITEM_MEDALLION_FOREST + j], QUEST_ICON_WIDTH, QUEST_ICON_HEIGHT, 0); } } - if (D_8082A0FC == 0) { - D_8082A0FC = ZREG(61 + D_8082A100); - if (++D_8082A100 >= 4) { - D_8082A100 = 0; + if (sMedallionsEnvTimer == 0) { + sMedallionsEnvTimer = R_PAUSE_QUEST_MEDALLION_SHINE_TIME(sMedallionsEnvShineState); + if (++sMedallionsEnvShineState >= 4) { + sMedallionsEnvShineState = 0; } } + // Draw songs + // QUEST_SONG_MINUET to QUEST_SONG_STORMS + gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); @@ -367,86 +394,93 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { gDPLoadTextureBlock(POLY_OPA_DISP++, gSongNoteTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - for (sp218 = 0; sp218 < QUEST_KOKIRI_EMERALD - QUEST_SONG_MINUET; sp218++, sp21A += 4) { - if (CHECK_QUEST_ITEM(QUEST_SONG_MINUET + sp218)) { - if ((QUEST_SONG_MINUET + sp218) == sp216) { - pauseCtx->questVtx[sp21A + 0].v.ob[0] = pauseCtx->questVtx[sp21A + 2].v.ob[0] = - pauseCtx->questVtx[sp21A + 0].v.ob[0] - 2; + for (j = 0; j < QUEST_KOKIRI_EMERALD - QUEST_SONG_MINUET; j++, bufI += 4) { + if (CHECK_QUEST_ITEM(QUEST_SONG_MINUET + j)) { + if ((QUEST_SONG_MINUET + j) == sp216) { + pauseCtx->questVtx[bufI + 0].v.ob[0] = pauseCtx->questVtx[bufI + 2].v.ob[0] = + pauseCtx->questVtx[bufI + 0].v.ob[0] - 2; - pauseCtx->questVtx[sp21A + 1].v.ob[0] = pauseCtx->questVtx[sp21A + 3].v.ob[0] = - pauseCtx->questVtx[sp21A + 1].v.ob[0] + 4; + pauseCtx->questVtx[bufI + 1].v.ob[0] = pauseCtx->questVtx[bufI + 3].v.ob[0] = + pauseCtx->questVtx[bufI + 1].v.ob[0] + 4; - pauseCtx->questVtx[sp21A + 0].v.ob[1] = pauseCtx->questVtx[sp21A + 1].v.ob[1] = - pauseCtx->questVtx[sp21A + 0].v.ob[1] + 2; + pauseCtx->questVtx[bufI + 0].v.ob[1] = pauseCtx->questVtx[bufI + 1].v.ob[1] = + pauseCtx->questVtx[bufI + 0].v.ob[1] + 2; - pauseCtx->questVtx[sp21A + 2].v.ob[1] = pauseCtx->questVtx[sp21A + 3].v.ob[1] = - pauseCtx->questVtx[sp21A + 2].v.ob[1] - 4; + pauseCtx->questVtx[bufI + 2].v.ob[1] = pauseCtx->questVtx[bufI + 3].v.ob[1] = + pauseCtx->questVtx[bufI + 2].v.ob[1] - 4; } - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, D_8082A164[sp218], D_8082A17C[sp218], D_8082A194[sp218], + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sSongsPrimRed[j], sSongsPrimGreen[j], sSongsPrimBlue[j], pauseCtx->alpha); - gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[bufI], 4, 0); gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); } } + // Draw spiritual stones + // QUEST_KOKIRI_EMERALD, QUEST_GORON_RUBY, QUEST_ZORA_SAPPHIRE + gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - for (sp218 = 0; sp218 < 3; sp218++, sp21A += 4) { - if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD + sp218)) { - gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); - KaleidoScope_DrawQuadTextureRGBA32(gfxCtx, gItemIcons[ITEM_KOKIRI_EMERALD + sp218], QUEST_ICON_WIDTH, + for (j = 0; j < 3; j++, bufI += 4) { + if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD + j)) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[bufI], 4, 0); + KaleidoScope_DrawQuadTextureRGBA32(gfxCtx, gItemIcons[ITEM_KOKIRI_EMERALD + j], QUEST_ICON_WIDTH, QUEST_ICON_HEIGHT, 0); } } + // Draw QUEST_STONE_OF_AGONY, QUEST_GERUDOS_CARD, QUEST_SKULL_TOKEN + gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); - for (sp218 = 0; sp218 < 3; sp218++, sp21A += 4) { - if (CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY + sp218)) { - gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + for (j = 0; j < 3; j++, bufI += 4) { + if (CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY + j)) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[bufI], 4, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); - KaleidoScope_DrawQuadTextureRGBA32(gfxCtx, gItemIcons[ITEM_STONE_OF_AGONY + sp218], QUEST_ICON_WIDTH, + KaleidoScope_DrawQuadTextureRGBA32(gfxCtx, gItemIcons[ITEM_STONE_OF_AGONY + j], QUEST_ICON_WIDTH, QUEST_ICON_HEIGHT, 0); } } - sp226 = ABS(D_8082A104 - D_8082A070[D_8082A118][0]) / D_8082A114; - sp224 = ABS(D_8082A108 - D_8082A070[D_8082A118][1]) / D_8082A114; - sp222 = ABS(D_8082A10C - D_8082A070[D_8082A118][2]) / D_8082A114; - sp220 = ABS(D_8082A110 - D_8082A070[D_8082A118][3]) / D_8082A114; - if (D_8082A104 >= D_8082A070[D_8082A118][0]) { - D_8082A104 -= sp226; + // Draw heart pieces + + stepRed = ABS(sHpPrimRed - sHpPrimColors[sHpPrimState][0]) / sHpPrimTimer; + stepGreen = ABS(sHpPrimGreen - sHpPrimColors[sHpPrimState][1]) / sHpPrimTimer; + stepBlue = ABS(sHpPrimBlue - sHpPrimColors[sHpPrimState][2]) / sHpPrimTimer; + stepAlpha = ABS(sHpPrimAlpha - sHpPrimColors[sHpPrimState][3]) / sHpPrimTimer; + if (sHpPrimRed >= sHpPrimColors[sHpPrimState][0]) { + sHpPrimRed -= stepRed; } else { - D_8082A104 += sp226; + sHpPrimRed += stepRed; } - if (D_8082A108 >= D_8082A070[D_8082A118][1]) { - D_8082A108 -= sp224; + if (sHpPrimGreen >= sHpPrimColors[sHpPrimState][1]) { + sHpPrimGreen -= stepGreen; } else { - D_8082A108 += sp224; + sHpPrimGreen += stepGreen; } - if (D_8082A10C >= D_8082A070[D_8082A118][2]) { - D_8082A10C -= sp222; + if (sHpPrimBlue >= sHpPrimColors[sHpPrimState][2]) { + sHpPrimBlue -= stepBlue; } else { - D_8082A10C += sp222; + sHpPrimBlue += stepBlue; } - if (D_8082A110 >= D_8082A070[D_8082A118][3]) { - D_8082A110 -= sp220; + if (sHpPrimAlpha >= sHpPrimColors[sHpPrimState][3]) { + sHpPrimAlpha -= stepAlpha; } else { - D_8082A110 += sp220; + sHpPrimAlpha += stepAlpha; } - if (--D_8082A114 == 0) { - D_8082A104 = D_8082A070[D_8082A118][0]; - D_8082A108 = D_8082A070[D_8082A118][1]; - D_8082A10C = D_8082A070[D_8082A118][2]; - D_8082A110 = D_8082A070[D_8082A118][3]; - D_8082A114 = ZREG(24 + D_8082A118); - if (++D_8082A118 >= 4) { - D_8082A118 = 0; + if (--sHpPrimTimer == 0) { + sHpPrimRed = sHpPrimColors[sHpPrimState][0]; + sHpPrimGreen = sHpPrimColors[sHpPrimState][1]; + sHpPrimBlue = sHpPrimColors[sHpPrimState][2]; + sHpPrimAlpha = sHpPrimColors[sHpPrimState][3]; + sHpPrimTimer = ZREG(24 + sHpPrimState); + if (++sHpPrimState >= 4) { + sHpPrimState = 0; } } @@ -456,14 +490,14 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); if ((pauseCtx->state == PAUSE_STATE_OPENING_1) || (pauseCtx->state == PAUSE_STATE_CLOSING)) { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, D_8082A070[0][0], D_8082A070[0][1], D_8082A070[0][2], + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sHpPrimColors[0][0], sHpPrimColors[0][1], sHpPrimColors[0][2], pauseCtx->alpha); } else { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, D_8082A104, D_8082A108, D_8082A10C, D_8082A110); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sHpPrimRed, sHpPrimGreen, sHpPrimBlue, sHpPrimAlpha); } gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[bufI], 4, 0); POLY_OPA_DISP = KaleidoScope_QuadTextureIA8( POLY_OPA_DISP, @@ -473,8 +507,10 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { 48, 48, 0); } + // + if (pauseCtx->state == PAUSE_STATE_MAIN) { - sp21A += 4; + bufI += 4; gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); @@ -500,59 +536,60 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { D_8082A124[pauseCtx->ocarinaStaff->pos - 1] = pauseCtx->ocarinaStaff->buttonIndex; } - for (sp218 = 0, phi_s7 = 0; sp218 < 8; sp218++, phi_s7 += 4, sp21A += 4) { - if (D_8082A124[sp218] == 0xFF) { + for (j = 0, i = 0; j < 8; j++, i += 4, bufI += 4) { + if (D_8082A124[j] == 0xFF) { break; } - if (D_8082A150[sp218] != 255) { - D_8082A150[sp218] += VREG(50); - if (D_8082A150[sp218] >= 255) { - D_8082A150[sp218] = 255; + if (D_8082A150[j] != 255) { + D_8082A150[j] += VREG(50); + if (D_8082A150[j] >= 255) { + D_8082A150[j] = 255; } } - pauseCtx->questVtx[sp21A + 0].v.ob[1] = pauseCtx->questVtx[sp21A + 1].v.ob[1] = - VREG(21 + D_8082A124[sp218]); + pauseCtx->questVtx[bufI + 0].v.ob[1] = pauseCtx->questVtx[bufI + 1].v.ob[1] = + VREG(21 + D_8082A124[j]); - pauseCtx->questVtx[sp21A + 2].v.ob[1] = pauseCtx->questVtx[sp21A + 3].v.ob[1] = - pauseCtx->questVtx[sp21A + 0].v.ob[1] - 12; + pauseCtx->questVtx[bufI + 2].v.ob[1] = pauseCtx->questVtx[bufI + 3].v.ob[1] = + pauseCtx->questVtx[bufI + 0].v.ob[1] - 12; gDPPipeSync(POLY_OPA_DISP++); - if (D_8082A124[sp218] == 0) { + if (D_8082A124[j] == 0) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, KALEIDO_COLOR_COLLECT_UNK_R, KALEIDO_COLOR_COLLECT_UNK_G, - KALEIDO_COLOR_COLLECT_UNK_B, D_8082A150[sp218]); + KALEIDO_COLOR_COLLECT_UNK_B, D_8082A150[j]); } else { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, D_8082A150[sp218]); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, D_8082A150[j]); } gDPSetEnvColor(POLY_OPA_DISP++, 10, 10, 10, 0); - gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[bufI], 4, 0); - gDPLoadTextureBlock(POLY_OPA_DISP++, D_8082A130[D_8082A124[sp218]], G_IM_FMT_IA, G_IM_SIZ_8b, 16, - 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(POLY_OPA_DISP++, D_8082A130[D_8082A124[j]], G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); } } } else if (((pauseCtx->mainState >= PAUSE_MAIN_STATE_4) && (pauseCtx->mainState <= PAUSE_MAIN_STATE_6)) || (pauseCtx->mainState == PAUSE_MAIN_STATE_8)) { - sp224 = pauseCtx->ocarinaSongIdx; - sp226 = gOcarinaSongButtons[sp224].numButtons; + // temps reused, fake? + stepGreen = pauseCtx->ocarinaSongIdx; + stepRed = gOcarinaSongButtons[stepGreen].numButtons; - for (sp218 = sp21A, phi_s7 = 0; phi_s7 < sp226; phi_s7++, sp21A += 4) { - pauseCtx->questVtx[sp21A + 0].v.ob[1] = pauseCtx->questVtx[sp21A + 1].v.ob[1] = - VREG(21 + gOcarinaSongButtons[sp224].buttonsIndex[phi_s7]); + for (j = bufI, i = 0; i < stepRed; i++, bufI += 4) { + pauseCtx->questVtx[bufI + 0].v.ob[1] = pauseCtx->questVtx[bufI + 1].v.ob[1] = + VREG(21 + gOcarinaSongButtons[stepGreen].buttonsIndex[i]); - pauseCtx->questVtx[sp21A + 2].v.ob[1] = pauseCtx->questVtx[sp21A + 3].v.ob[1] = - pauseCtx->questVtx[sp21A + 0].v.ob[1] - 12; + pauseCtx->questVtx[bufI + 2].v.ob[1] = pauseCtx->questVtx[bufI + 3].v.ob[1] = + pauseCtx->questVtx[bufI + 0].v.ob[1] - 12; gDPPipeSync(POLY_OPA_DISP++); if (pauseCtx->mainState == PAUSE_MAIN_STATE_8) { - if (gOcarinaSongButtons[sp224].buttonsIndex[phi_s7] == OCARINA_BTN_A) { + if (gOcarinaSongButtons[stepGreen].buttonsIndex[i] == OCARINA_BTN_A) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, KALEIDO_COLOR_COLLECT_UNK_R, KALEIDO_COLOR_COLLECT_UNK_G, KALEIDO_COLOR_COLLECT_UNK_B, 200); } else { @@ -564,9 +601,9 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { gDPSetEnvColor(POLY_OPA_DISP++, 10, 10, 10, 0); - gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[bufI], 4, 0); - gDPLoadTextureBlock(POLY_OPA_DISP++, D_8082A130[gOcarinaSongButtons[sp224].buttonsIndex[phi_s7]], + gDPLoadTextureBlock(POLY_OPA_DISP++, D_8082A130[gOcarinaSongButtons[stepGreen].buttonsIndex[i]], G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -587,49 +624,49 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { } } - sp21A = sp218 + 32; - phi_s7 = 0; - for (; phi_s7 < 8; phi_s7++, sp21A += 4) { - if (D_8082A124[phi_s7] == 0xFF) { + bufI = j + 32; + i = 0; + for (; i < 8; i++, bufI += 4) { + if (D_8082A124[i] == 0xFF) { continue; } - if (D_8082A150[phi_s7] != 255) { - D_8082A150[phi_s7] += VREG(50); - if (D_8082A150[phi_s7] >= 255) { - D_8082A150[phi_s7] = 255; + if (D_8082A150[i] != 255) { + D_8082A150[i] += VREG(50); + if (D_8082A150[i] >= 255) { + D_8082A150[i] = 255; } } - pauseCtx->questVtx[sp21A + 0].v.ob[1] = pauseCtx->questVtx[sp21A + 1].v.ob[1] = - VREG(21 + D_8082A124[phi_s7]); + pauseCtx->questVtx[bufI + 0].v.ob[1] = pauseCtx->questVtx[bufI + 1].v.ob[1] = + VREG(21 + D_8082A124[i]); - pauseCtx->questVtx[sp21A + 2].v.ob[1] = pauseCtx->questVtx[sp21A + 3].v.ob[1] = - pauseCtx->questVtx[sp21A + 0].v.ob[1] - 12; + pauseCtx->questVtx[bufI + 2].v.ob[1] = pauseCtx->questVtx[bufI + 3].v.ob[1] = + pauseCtx->questVtx[bufI + 0].v.ob[1] - 12; gDPPipeSync(POLY_OPA_DISP++); - if (D_8082A124[phi_s7] == 0) { + if (D_8082A124[i] == 0) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, KALEIDO_COLOR_COLLECT_UNK_R, KALEIDO_COLOR_COLLECT_UNK_G, - KALEIDO_COLOR_COLLECT_UNK_B, D_8082A150[phi_s7]); + KALEIDO_COLOR_COLLECT_UNK_B, D_8082A150[i]); } else { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, D_8082A150[phi_s7]); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, D_8082A150[i]); } gDPSetEnvColor(POLY_OPA_DISP++, 10, 10, 10, 0); - gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[bufI], 4, 0); - gDPLoadTextureBlock(POLY_OPA_DISP++, D_8082A130[D_8082A124[phi_s7]], G_IM_FMT_IA, G_IM_SIZ_8b, 16, - 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(POLY_OPA_DISP++, D_8082A130[D_8082A124[i]], G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); } if (pauseCtx->mainState == PAUSE_MAIN_STATE_4) { - for (phi_s7 = 0; phi_s7 < 8; phi_s7++) { - D_8082A124[phi_s7] = 0xFF; - D_8082A150[phi_s7] = 0; + for (i = 0; i < 8; i++) { + D_8082A124[i] = 0xFF; + D_8082A150[i] = 0; } D_8082A11C = 0; @@ -644,29 +681,31 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { } } + // Draw amount of gold skulltula tokens + if (CHECK_QUEST_ITEM(QUEST_SKULL_TOKEN)) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - sp208[0] = sp208[1] = 0; - sp208[2] = gSaveContext.save.info.inventory.gsTokens; + gsTokenDigits[0] = gsTokenDigits[1] = 0; + gsTokenDigits[2] = gSaveContext.save.info.inventory.gsTokens; - while (sp208[2] >= 100) { - sp208[0]++; - sp208[2] -= 100; + while (gsTokenDigits[2] >= 100) { + gsTokenDigits[0]++; + gsTokenDigits[2] -= 100; } - while (sp208[2] >= 10) { - sp208[1]++; - sp208[2] -= 10; + while (gsTokenDigits[2] >= 10) { + gsTokenDigits[1]++; + gsTokenDigits[2] -= 10; } gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[164], 24, 0); - for (phi_s7 = 0, sp218 = 0, sp21A = 0; phi_s7 < 2; phi_s7++) { - if (phi_s7 == 0) { + for (i = 0, j = 0; i < 2; i++) { + if (i == 0) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, pauseCtx->alpha); } else if (gSaveContext.save.info.inventory.gsTokens == 100) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 200, 50, 50, pauseCtx->alpha); @@ -675,13 +714,13 @@ void KaleidoScope_DrawQuestStatus(PlayState* play, GraphicsContext* gfxCtx) { } cursorItem = 0; - for (sp21A = 0; sp21A < 3; sp21A++, sp218 += 4) { - if ((sp21A >= 2) || (sp208[sp21A] != 0) || (cursorItem != 0)) { - gDPLoadTextureBlock(POLY_OPA_DISP++, ((u8*)gCounterDigit0Tex + (8 * 16 * sp208[sp21A])), G_IM_FMT_I, - G_IM_SIZ_8b, 8, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + for (bufI = 0; bufI < 3; bufI++, j += 4) { + if ((bufI >= 2) || (gsTokenDigits[bufI] != 0) || (cursorItem != 0)) { + gDPLoadTextureBlock(POLY_OPA_DISP++, ((u8*)gCounterDigit0Tex + (8 * 16 * gsTokenDigits[bufI])), + G_IM_FMT_I, G_IM_SIZ_8b, 8, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, sp218, sp218 + 2, sp218 + 3, sp218 + 1, 0); + gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); cursorItem = 1; }