diff options
Diffstat (limited to 'src')
19 files changed, 1038 insertions, 105 deletions
diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 3a5cde395..f54fc93da 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -1,4 +1,3 @@ -//#include "prevent_bss_reordering.h" #include "global.h" #include "z64quake.h" #include "z64shrink_window.h" diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 79c50e921..4e61639fb 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -506,26 +506,324 @@ Gfx* Gfx_DrawTexQuad4b(Gfx* gfx, TexturePtr texture, s32 fmt, s16 textureWidth, return gfx; } -s16 D_801BFA04[] = { - -14, -14, -24, -8, -12, -12, -7, -8, -7, -8, -12, 0, +// Total number of non-minigame-perfect action quads +#define ACTION_QUAD_BASE_COUNT 11 + +s16 sActionVtxPosX[ACTION_QUAD_BASE_COUNT] = { + -14, // A Button + -14, // A Button Background + -24, // A Button Do-Action + -8, // Three-Day Clock's Star (for the Minute Tracker) + -12, // Three-Day Clock's Sun (for the Day-Time Hours Tracker) + -12, // Three-Day Clock's Moon (for the Night-Time Hours Tracker) + -7, // Three-Day Clock's Hour Digit Above the Sun + -8, // Three-Day Clock's Hour Digit Above the Sun + -7, // Three-Day Clock's Hour Digit Above the Moon + -8, // Three-Day Clock's Hour Digit Above the Moon + -12, // Minigame Countdown Textures }; -s16 D_801BFA1C[] = { - 0x1C, 0x1C, 0x30, 0x10, 0x18, 0x18, 0x10, 0x10, 0x10, 0x10, 0x18, 0, + +s16 sActionVtxWidths[ACTION_QUAD_BASE_COUNT] = { + 28, // A Button + 28, // A Button Background + 48, // A Button Do-Action + 16, // Three-Day Clock's Star (for the Minute Tracker) + 24, // Three-Day Clock's Sun (for the Day-Time Hours Tracker) + 24, // Three-Day Clock's Moon (for the Night-Time Hours Tracker) + 16, // Three-Day Clock's Hour Digit Above the Sun + 16, // Three-Day Clock's Hour Digit Above the Sun + 16, // Three-Day Clock's Hour Digit Above the Moon + 16, // Three-Day Clock's Hour Digit Above the Moon + 24, // Minigame Countdown Textures }; -s16 D_801BFA34[] = { - 14, 14, 8, 24, -82, -82, 58, 59, 58, 59, 32, 0, + +s16 sActionVtxPosY[ACTION_QUAD_BASE_COUNT] = { + 14, // A Button + 14, // A Button Background + 8, // A Button Do-Action + 24, // Three-Day Clock's Star (for the Minute Tracker) + -82, // Three-Day Clock's Sun (for the Day-Time Hours Tracker) + -82, // Three-Day Clock's Moon (for the Night-Time Hours Tracker) + 58, // Three-Day Clock's Hour Digit Above the Sun + 59, // Three-Day Clock's Hour Digit Above the Sun + 58, // Three-Day Clock's Hour Digit Above the Moon + 59, // Three-Day Clock's Hour Digit Above the Moon + 32, // Minigame Countdown Textures }; -s16 D_801BFA4C[] = { - 0x1C, 0x1C, 0x10, 0x10, 0x18, 0x18, 0xB, 0xB, 0xB, 0xB, 0x20, 0, + +s16 sActionVtxHeights[ACTION_QUAD_BASE_COUNT] = { + 28, // A Button + 28, // A Button Background + 16, // A Button Do-Action + 16, // Three-Day Clock's Star (for the Minute Tracker) + 24, // Three-Day Clock's Sun (for the Day-Time Hours Tracker) + 24, // Three-Day Clock's Moon (for the Night-Time Hours Tracker) + 11, // Three-Day Clock's Hour Digit Above the Sun + 11, // Three-Day Clock's Hour Digit Above the Sun + 11, // Three-Day Clock's Hour Digit Above the Moon + 11, // Three-Day Clock's Hour Digit Above the Moon + 32, // Minigame Countdown Textures }; -s16 D_801BFA64[] = { - -61, -45, 29, 104, -117, -42, 32, 55, + +#define PERFECT_LETTERS_VTX_WIDTH 32 +#define PERFECT_LETTERS_VTX_HEIGHT 33 + +// Used for PERFECT_LETTERS_TYPE_1 and only part of PERFECT_LETTERS_TYPE_3 +// Both PERFECT_LETTERS_TYPE_2 and PERFECT_LETTERS_TYPE_2 have (0, 0) as the center for all letters +s16 sPerfectLettersCenterX[PERFECT_LETTERS_NUM_LETTERS] = { + -61, // P + -45, // E + 29, // R + 104, // F + -117, // E + -42, // C + 32, // T + 55, // ! }; -s16 D_801BFA74[] = { - 1, -70, -99, -70, 71, 101, 72, 1, + +s16 sPerfectLettersCenterY[PERFECT_LETTERS_NUM_LETTERS] = { + 1, // P + -70, // E + -99, // R + -70, // F + 71, // E + 101, // C + 72, // T + 1, // ! }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E028.s") +/** + * interfaceCtx->actionVtx[0] -> A Button + * interfaceCtx->actionVtx[4] -> A Button Shadow + * interfaceCtx->actionVtx[8] -> A Button Do-Action + * interfaceCtx->actionVtx[12] -> Three-Day Clock's Star (for the Minute Tracker) + * interfaceCtx->actionVtx[16] -> Three-Day Clock's Sun (for the Day Hours Tracker) + * interfaceCtx->actionVtx[20] -> Three-Day Clock's Moon (for the Night Hours Tracker) + * interfaceCtx->actionVtx[24] -> Three-Day Clock's Hour Digit Above the Sun (uses 8 vertices) + * interfaceCtx->actionVtx[32] -> Three-Day Clock's Hour Digit Above the Moon (uses 8 vertices) + * interfaceCtx->actionVtx[40] -> Minigame Countdown Textures + * interfaceCtx->actionVtx[44] -> Minigame Perfect Letter P Shadow + * interfaceCtx->actionVtx[48] -> Minigame Perfect Letter E Shadow + * interfaceCtx->actionVtx[52] -> Minigame Perfect Letter R Shadow + * interfaceCtx->actionVtx[56] -> Minigame Perfect Letter F Shadow + * interfaceCtx->actionVtx[60] -> Minigame Perfect Letter E Shadow + * interfaceCtx->actionVtx[64] -> Minigame Perfect Letter C Shadow + * interfaceCtx->actionVtx[68] -> Minigame Perfect Letter T Shadow + * interfaceCtx->actionVtx[72] -> Minigame Perfect Letter ! Shadow + * interfaceCtx->actionVtx[76] -> Minigame Perfect Letter P Colored + * interfaceCtx->actionVtx[80] -> Minigame Perfect Letter E Colored + * interfaceCtx->actionVtx[84] -> Minigame Perfect Letter R Colored + * interfaceCtx->actionVtx[88] -> Minigame Perfect Letter F Colored + * interfaceCtx->actionVtx[92] -> Minigame Perfect Letter E Colored + * interfaceCtx->actionVtx[96] -> Minigame Perfect Letter C Colored + * interfaceCtx->actionVtx[100] -> Minigame Perfect Letter T Colored + * interfaceCtx->actionVtx[104] -> Minigame Perfect Letter ! Colored + */ + +#define BEATING_HEART_VTX_X -8 +#define BEATING_HEART_VTX_Y -8 +#define BEATING_HEART_VTX_WIDTH 16 + +void Interface_SetVertices(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 i; + s16 j; + s16 k; + s16 shadowOffset; + + play->interfaceCtx.actionVtx = + GRAPH_ALLOC(play->state.gfxCtx, (ACTION_QUAD_BASE_COUNT + (2 * PERFECT_LETTERS_NUM_LETTERS)) * 4 * sizeof(Vtx)); + + // Loop over all non-minigame perfect vertices + // where (i) is the actionVtx index, (k) is the iterator + for (k = 0, i = 0; i < (ACTION_QUAD_BASE_COUNT * 4); i += 4, k++) { + // Left vertices x Pos + interfaceCtx->actionVtx[i + 0].v.ob[0] = interfaceCtx->actionVtx[i + 2].v.ob[0] = sActionVtxPosX[k]; + + // Right vertices x Pos + interfaceCtx->actionVtx[i + 1].v.ob[0] = interfaceCtx->actionVtx[i + 3].v.ob[0] = + interfaceCtx->actionVtx[i + 0].v.ob[0] + sActionVtxWidths[k]; + + // Top vertices y Pos + interfaceCtx->actionVtx[i + 0].v.ob[1] = interfaceCtx->actionVtx[i + 1].v.ob[1] = sActionVtxPosY[k]; + + // Bottom vertices y Pos + interfaceCtx->actionVtx[i + 2].v.ob[1] = interfaceCtx->actionVtx[i + 3].v.ob[1] = + interfaceCtx->actionVtx[i + 0].v.ob[1] - sActionVtxHeights[k]; + + // All vertices z Pos + interfaceCtx->actionVtx[i + 0].v.ob[2] = interfaceCtx->actionVtx[i + 1].v.ob[2] = + interfaceCtx->actionVtx[i + 2].v.ob[2] = interfaceCtx->actionVtx[i + 3].v.ob[2] = 0; + + // Unused flag + interfaceCtx->actionVtx[i + 0].v.flag = interfaceCtx->actionVtx[i + 1].v.flag = + interfaceCtx->actionVtx[i + 2].v.flag = interfaceCtx->actionVtx[i + 3].v.flag = 0; + + // Left and Top texture coordinates + interfaceCtx->actionVtx[i + 0].v.tc[0] = interfaceCtx->actionVtx[i + 0].v.tc[1] = + interfaceCtx->actionVtx[i + 1].v.tc[1] = interfaceCtx->actionVtx[i + 2].v.tc[0] = 0; + + // Right vertices texture coordinates + interfaceCtx->actionVtx[i + 1].v.tc[0] = interfaceCtx->actionVtx[i + 3].v.tc[0] = sActionVtxWidths[k] << 5; + + // Bottom vertices texture coordinates + interfaceCtx->actionVtx[i + 2].v.tc[1] = interfaceCtx->actionVtx[i + 3].v.tc[1] = sActionVtxHeights[k] << 5; + + // Set color + interfaceCtx->actionVtx[i + 0].v.cn[0] = interfaceCtx->actionVtx[i + 1].v.cn[0] = + interfaceCtx->actionVtx[i + 2].v.cn[0] = interfaceCtx->actionVtx[i + 3].v.cn[0] = + interfaceCtx->actionVtx[i + 0].v.cn[1] = interfaceCtx->actionVtx[i + 1].v.cn[1] = + interfaceCtx->actionVtx[i + 2].v.cn[1] = interfaceCtx->actionVtx[i + 3].v.cn[1] = + interfaceCtx->actionVtx[i + 0].v.cn[2] = interfaceCtx->actionVtx[i + 1].v.cn[2] = + interfaceCtx->actionVtx[i + 2].v.cn[2] = interfaceCtx->actionVtx[i + 3].v.cn[2] = 255; + + // Set alpha + interfaceCtx->actionVtx[i + 0].v.cn[3] = interfaceCtx->actionVtx[i + 1].v.cn[3] = + interfaceCtx->actionVtx[i + 2].v.cn[3] = interfaceCtx->actionVtx[i + 3].v.cn[3] = 255; + } + + // A button right and top texture coordinates + interfaceCtx->actionVtx[1].v.tc[0] = interfaceCtx->actionVtx[3].v.tc[0] = interfaceCtx->actionVtx[2].v.tc[1] = + interfaceCtx->actionVtx[3].v.tc[1] = 32 << 5; + + // A button background right and top texture coordinates + interfaceCtx->actionVtx[5].v.tc[0] = interfaceCtx->actionVtx[7].v.tc[0] = interfaceCtx->actionVtx[6].v.tc[1] = + interfaceCtx->actionVtx[7].v.tc[1] = 32 << 5; + + // Loop over vertices for the minigame-perfect letters + // Outer loop is to loop over 2 sets of letters: shadowed letters (j = 0) and colored letters (j = 1) + for (j = 0, shadowOffset = 2; j < 2; j++, shadowOffset -= 2) { + // Inner loop is to loop over letters (k) and actionVtx index (i) + for (k = 0; k < PERFECT_LETTERS_NUM_LETTERS; k++, i += 4) { + if ((interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_1) || + ((interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_3) && + (interfaceCtx->perfectLettersState[0] == PERFECT_LETTERS_STATE_EXIT))) { + // Left vertices x Pos + interfaceCtx->actionVtx[i + 0].v.ob[0] = interfaceCtx->actionVtx[i + 2].v.ob[0] = + -((sPerfectLettersCenterX[k] - shadowOffset) + 16); + + // Right vertices x Pos + interfaceCtx->actionVtx[i + 1].v.ob[0] = interfaceCtx->actionVtx[i + 3].v.ob[0] = + interfaceCtx->actionVtx[i + 0].v.ob[0] + PERFECT_LETTERS_VTX_WIDTH; + + // Top vertices y Pos + interfaceCtx->actionVtx[i + 0].v.ob[1] = interfaceCtx->actionVtx[i + 1].v.ob[1] = + (sPerfectLettersCenterY[k] - shadowOffset) + 16; + + // Bottom vertices y Pos + interfaceCtx->actionVtx[i + 2].v.ob[1] = interfaceCtx->actionVtx[i + 3].v.ob[1] = + interfaceCtx->actionVtx[i + 0].v.ob[1] - PERFECT_LETTERS_VTX_HEIGHT; + + } else if ((interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_2) || + (interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_3)) { + // Left vertices x Pos + interfaceCtx->actionVtx[i + 0].v.ob[0] = interfaceCtx->actionVtx[i + 2].v.ob[0] = + -(interfaceCtx->perfectLettersOffsetX[k] - shadowOffset + 16); + + // Right vertices x Pos + interfaceCtx->actionVtx[i + 1].v.ob[0] = interfaceCtx->actionVtx[i + 3].v.ob[0] = + interfaceCtx->actionVtx[i + 0].v.ob[0] + PERFECT_LETTERS_VTX_WIDTH; + + // Top vertices y Pos + interfaceCtx->actionVtx[i + 0].v.ob[1] = interfaceCtx->actionVtx[i + 1].v.ob[1] = 16 - shadowOffset; + + // Bottom vertices y Pos + interfaceCtx->actionVtx[i + 2].v.ob[1] = interfaceCtx->actionVtx[i + 3].v.ob[1] = + interfaceCtx->actionVtx[i + 0].v.ob[1] - PERFECT_LETTERS_VTX_HEIGHT; + + } else { + // Left vertices x Pos + interfaceCtx->actionVtx[i + 0].v.ob[0] = interfaceCtx->actionVtx[i + 2].v.ob[0] = -(216 - shadowOffset); + + // Right vertices x Pos + interfaceCtx->actionVtx[i + 1].v.ob[0] = interfaceCtx->actionVtx[i + 3].v.ob[0] = + interfaceCtx->actionVtx[i + 0].v.ob[0] + PERFECT_LETTERS_VTX_WIDTH; + + // Top vertices y Pos + interfaceCtx->actionVtx[i + 0].v.ob[1] = interfaceCtx->actionVtx[i + 1].v.ob[1] = 24 - shadowOffset; + + // Bottom vertices y Pos + interfaceCtx->actionVtx[i + 2].v.ob[1] = interfaceCtx->actionVtx[i + 3].v.ob[1] = + interfaceCtx->actionVtx[i + 0].v.ob[1] - PERFECT_LETTERS_VTX_HEIGHT; + } + + // All vertices z Pos + interfaceCtx->actionVtx[i + 0].v.ob[2] = interfaceCtx->actionVtx[i + 1].v.ob[2] = + interfaceCtx->actionVtx[i + 2].v.ob[2] = interfaceCtx->actionVtx[i + 3].v.ob[2] = 0; + + // Unused flag + interfaceCtx->actionVtx[i + 0].v.flag = interfaceCtx->actionVtx[i + 1].v.flag = + interfaceCtx->actionVtx[i + 2].v.flag = interfaceCtx->actionVtx[i + 3].v.flag = 0; + + // Left and Top texture coordinates + interfaceCtx->actionVtx[i + 0].v.tc[0] = interfaceCtx->actionVtx[i + 0].v.tc[1] = + interfaceCtx->actionVtx[i + 1].v.tc[1] = interfaceCtx->actionVtx[i + 2].v.tc[0] = 0; + + // Right vertices texture coordinates + interfaceCtx->actionVtx[i + 1].v.tc[0] = interfaceCtx->actionVtx[i + 3].v.tc[0] = PERFECT_LETTERS_VTX_WIDTH + << 5; + + // Bottom vertices texture coordinates + interfaceCtx->actionVtx[i + 2].v.tc[1] = interfaceCtx->actionVtx[i + 3].v.tc[1] = PERFECT_LETTERS_VTX_HEIGHT + << 5; + + // Set color + interfaceCtx->actionVtx[i + 0].v.cn[0] = interfaceCtx->actionVtx[i + 1].v.cn[0] = + interfaceCtx->actionVtx[i + 2].v.cn[0] = interfaceCtx->actionVtx[i + 3].v.cn[0] = + interfaceCtx->actionVtx[i + 0].v.cn[1] = interfaceCtx->actionVtx[i + 1].v.cn[1] = + interfaceCtx->actionVtx[i + 2].v.cn[1] = interfaceCtx->actionVtx[i + 3].v.cn[1] = + interfaceCtx->actionVtx[i + 0].v.cn[2] = interfaceCtx->actionVtx[i + 1].v.cn[2] = + interfaceCtx->actionVtx[i + 2].v.cn[2] = interfaceCtx->actionVtx[i + 3].v.cn[2] = 255; + + // Set alpha + interfaceCtx->actionVtx[i + 0].v.cn[3] = interfaceCtx->actionVtx[i + 1].v.cn[3] = + interfaceCtx->actionVtx[i + 2].v.cn[3] = interfaceCtx->actionVtx[i + 3].v.cn[3] = 255; + } + } + + // Beating Hearts Vertices + interfaceCtx->beatingHeartVtx = GRAPH_ALLOC(play->state.gfxCtx, 4 * sizeof(Vtx)); + + // Left vertices x Pos + interfaceCtx->beatingHeartVtx[0].v.ob[0] = interfaceCtx->beatingHeartVtx[2].v.ob[0] = BEATING_HEART_VTX_X; + + // Right vertices x Pos + interfaceCtx->beatingHeartVtx[1].v.ob[0] = interfaceCtx->beatingHeartVtx[3].v.ob[0] = + BEATING_HEART_VTX_X + BEATING_HEART_VTX_WIDTH; + + // Top vertices y Pos + interfaceCtx->beatingHeartVtx[0].v.ob[1] = interfaceCtx->beatingHeartVtx[1].v.ob[1] = + BEATING_HEART_VTX_Y + BEATING_HEART_VTX_WIDTH; + + // Bottom vertices y Pos + interfaceCtx->beatingHeartVtx[2].v.ob[1] = interfaceCtx->beatingHeartVtx[3].v.ob[1] = BEATING_HEART_VTX_Y; + + // All vertices z Pos + interfaceCtx->beatingHeartVtx[0].v.ob[2] = interfaceCtx->beatingHeartVtx[1].v.ob[2] = + interfaceCtx->beatingHeartVtx[2].v.ob[2] = interfaceCtx->beatingHeartVtx[3].v.ob[2] = 0; + + // unused flag + interfaceCtx->beatingHeartVtx[0].v.flag = interfaceCtx->beatingHeartVtx[1].v.flag = + interfaceCtx->beatingHeartVtx[2].v.flag = interfaceCtx->beatingHeartVtx[3].v.flag = 0; + + // Texture Coordinates + interfaceCtx->beatingHeartVtx[0].v.tc[0] = interfaceCtx->beatingHeartVtx[0].v.tc[1] = + interfaceCtx->beatingHeartVtx[1].v.tc[1] = interfaceCtx->beatingHeartVtx[2].v.tc[0] = 0; + interfaceCtx->beatingHeartVtx[1].v.tc[0] = interfaceCtx->beatingHeartVtx[2].v.tc[1] = + interfaceCtx->beatingHeartVtx[3].v.tc[0] = interfaceCtx->beatingHeartVtx[3].v.tc[1] = + BEATING_HEART_VTX_WIDTH << 5; + + // Set color + interfaceCtx->beatingHeartVtx[0].v.cn[0] = interfaceCtx->beatingHeartVtx[1].v.cn[0] = + interfaceCtx->beatingHeartVtx[2].v.cn[0] = interfaceCtx->beatingHeartVtx[3].v.cn[0] = + interfaceCtx->beatingHeartVtx[0].v.cn[1] = interfaceCtx->beatingHeartVtx[1].v.cn[1] = + interfaceCtx->beatingHeartVtx[2].v.cn[1] = interfaceCtx->beatingHeartVtx[3].v.cn[1] = + interfaceCtx->beatingHeartVtx[0].v.cn[2] = interfaceCtx->beatingHeartVtx[1].v.cn[2] = + interfaceCtx->beatingHeartVtx[2].v.cn[2] = interfaceCtx->beatingHeartVtx[3].v.cn[2] = + interfaceCtx->beatingHeartVtx[0].v.cn[3] = interfaceCtx->beatingHeartVtx[1].v.cn[3] = + interfaceCtx->beatingHeartVtx[2].v.cn[3] = interfaceCtx->beatingHeartVtx[3].v.cn[3] = + 255; +} s32 sPostmanTimerInputBtnAPressed = false; @@ -1409,7 +1707,18 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112AF4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112AFC.s") +void Interface_InitMinigame(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + + gSaveContext.minigameStatus = MINIGAME_STATUS_ACTIVE; + gSaveContext.minigameScore = 0; + gSaveContext.minigameHiddenScore = 0; + + sHBAScoreTier = 0; + interfaceCtx->minigamePoints = interfaceCtx->minigameHiddenPoints = interfaceCtx->minigameUnusedPoints = 0; + + interfaceCtx->minigameAmmo = 20; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_LoadItemIconImpl.s") @@ -2826,49 +3135,556 @@ s16 D_801BFC40[] = { #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80119610.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B4E0.s") +void Interface_SetPerfectLetters(PlayState* play, s16 perfectLettersType) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 i; -u16 D_801BFC50[] = { - 0xC000, 0xE000, 0x0000, 0x2000, 0xA000, 0x8000, 0x6000, 0x4000, + interfaceCtx->perfectLettersOn = true; + interfaceCtx->perfectLettersType = perfectLettersType; + + interfaceCtx->perfectLettersPrimColor[0] = 255; + interfaceCtx->perfectLettersPrimColor[1] = 165; + interfaceCtx->perfectLettersPrimColor[2] = 55; + interfaceCtx->perfectLettersPrimColor[3] = 255; + interfaceCtx->perfectLettersColorTimer = 20; + + interfaceCtx->perfectLettersColorIndex = 0; + interfaceCtx->perfectLettersCount = 1; + interfaceCtx->perfectLettersTimer = 0; + + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersAngles[i] = 0; + interfaceCtx->perfectLettersState[i] = interfaceCtx->perfectLettersOffsetX[i] = 0; + if (interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_1) { + interfaceCtx->perfectLettersSemiAxisX[i] = 140.0f; + interfaceCtx->perfectLettersSemiAxisY[i] = 100.0f; + } else { + interfaceCtx->perfectLettersSemiAxisY[i] = 200.0f; + interfaceCtx->perfectLettersSemiAxisX[i] = 200.0f; + } + } + interfaceCtx->perfectLettersState[0] = PERFECT_LETTERS_STATE_INIT; +} + +u16 sPerfectLettersType1OffScreenAngles[PERFECT_LETTERS_NUM_LETTERS] = { + 6 * PERFECT_LETTERS_ANGLE_PER_LETTER, // P + 7 * PERFECT_LETTERS_ANGLE_PER_LETTER, // E + 0 * PERFECT_LETTERS_ANGLE_PER_LETTER, // R + 1 * PERFECT_LETTERS_ANGLE_PER_LETTER, // F + 5 * PERFECT_LETTERS_ANGLE_PER_LETTER, // E + 4 * PERFECT_LETTERS_ANGLE_PER_LETTER, // C + 3 * PERFECT_LETTERS_ANGLE_PER_LETTER, // T + 2 * PERFECT_LETTERS_ANGLE_PER_LETTER, // ! }; -s16 D_801BFC60[][3] = { - 255, 255, 255, 255, 165, 55, + +s16 sPerfectLettersType1PrimColorTargets[2][3] = { + { 255, 255, 255 }, + { 255, 165, 55 }, }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B5C0.s") +void Interface_UpdatePerfectLettersType1(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 i; + s16 count; + s16 colorStepR; + s16 colorStepG; + s16 colorStepB; + + // Update letter positions + for (count = 0, i = 0; i < interfaceCtx->perfectLettersCount; i++, count += 4) { + if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_INIT) { + // Initialize letter positions along the elliptical spirals + interfaceCtx->perfectLettersAngles[i] = sPerfectLettersType1OffScreenAngles[i] + 0xA000; + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_ENTER; + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_ENTER) { + // Swirl inwards along elliptical spirals to form the spelt-out word + interfaceCtx->perfectLettersAngles[i] -= 0x800; + if (interfaceCtx->perfectLettersAngles[i] == sPerfectLettersType1OffScreenAngles[i]) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_STATIONARY; + } + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_SPREAD) { + // Swirl outwards along elliptical spirals offscreen + interfaceCtx->perfectLettersAngles[i] -= 0x800; + if (interfaceCtx->perfectLettersAngles[i] == (u16)(sPerfectLettersType1OffScreenAngles[i] - 0x8000)) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_OFF; + } + } + } -s16 D_801BFC6C[] = { - 78, 54, 29, 5, -18, -42, -67, -85, + // Initialize the next letter in the list + // if `perfectLettersCount == PERFECT_LETTERS_NUM_LETTERS`, + // then perfectLettersState[] is accessed + if ((interfaceCtx->perfectLettersState[interfaceCtx->perfectLettersCount] == PERFECT_LETTERS_STATE_OFF) && + (interfaceCtx->perfectLettersCount < PERFECT_LETTERS_NUM_LETTERS)) { + interfaceCtx->perfectLettersState[interfaceCtx->perfectLettersCount] = PERFECT_LETTERS_STATE_INIT; + + interfaceCtx->perfectLettersSemiAxisX[interfaceCtx->perfectLettersCount] = 140.0f; + interfaceCtx->perfectLettersSemiAxisY[interfaceCtx->perfectLettersCount] = 100.0f; + interfaceCtx->perfectLettersAngles[interfaceCtx->perfectLettersCount] = + sPerfectLettersType1OffScreenAngles[interfaceCtx->perfectLettersCount] + 0xA000; + + interfaceCtx->perfectLettersCount++; + } + + // Update letter colors + if ((interfaceCtx->perfectLettersCount == PERFECT_LETTERS_NUM_LETTERS) && + (interfaceCtx->perfectLettersState[PERFECT_LETTERS_NUM_LETTERS - 1] == PERFECT_LETTERS_STATE_STATIONARY)) { + + colorStepR = ABS_ALT(interfaceCtx->perfectLettersPrimColor[0] - + sPerfectLettersType1PrimColorTargets[interfaceCtx->perfectLettersColorIndex][0]) / + interfaceCtx->perfectLettersColorTimer; + colorStepG = ABS_ALT(interfaceCtx->perfectLettersPrimColor[1] - + sPerfectLettersType1PrimColorTargets[interfaceCtx->perfectLettersColorIndex][1]) / + interfaceCtx->perfectLettersColorTimer; + colorStepB = ABS_ALT(interfaceCtx->perfectLettersPrimColor[2] - + sPerfectLettersType1PrimColorTargets[interfaceCtx->perfectLettersColorIndex][2]) / + interfaceCtx->perfectLettersColorTimer; + + if (interfaceCtx->perfectLettersPrimColor[0] >= + sPerfectLettersType1PrimColorTargets[interfaceCtx->perfectLettersColorIndex][0]) { + interfaceCtx->perfectLettersPrimColor[0] -= colorStepR; + } else { + interfaceCtx->perfectLettersPrimColor[0] += colorStepR; + } + + if (interfaceCtx->perfectLettersPrimColor[1] >= + sPerfectLettersType1PrimColorTargets[interfaceCtx->perfectLettersColorIndex][1]) { + interfaceCtx->perfectLettersPrimColor[1] -= colorStepG; + } else { + interfaceCtx->perfectLettersPrimColor[1] += colorStepG; + } + + if (interfaceCtx->perfectLettersPrimColor[2] >= + sPerfectLettersType1PrimColorTargets[interfaceCtx->perfectLettersColorIndex][2]) { + interfaceCtx->perfectLettersPrimColor[2] -= colorStepB; + } else { + interfaceCtx->perfectLettersPrimColor[2] += colorStepB; + } + + interfaceCtx->perfectLettersColorTimer--; + + if (interfaceCtx->perfectLettersColorTimer == 0) { + interfaceCtx->perfectLettersColorTimer = 20; + interfaceCtx->perfectLettersColorIndex ^= 1; + interfaceCtx->perfectLettersTimer++; + + if (interfaceCtx->perfectLettersTimer == 6) { + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_SPREAD; + } + } + } + } + + for (count = 0, i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_OFF) { + count++; + } + } + + if (count == PERFECT_LETTERS_NUM_LETTERS) { + interfaceCtx->perfectLettersOn = false; + } +} + +// Targets to offset each letter to properly spell "PERFECT!" +s16 sPerfectLettersType2SpellingOffsetsX[PERFECT_LETTERS_NUM_LETTERS] = { + 78, // P + 54, // E + 29, // R + 5, // F + -18, // E + -42, // C + -67, // T + -85, // ! }; -s16 D_801BFC7C[] = { - 180, 180, 180, 180, -180, -180, -180, -180, + +// Targets to offset each letter to sweep horizontally offscreen +s16 sPerfectLettersType2OffScreenOffsetsX[PERFECT_LETTERS_NUM_LETTERS] = { + 180, // P (offscreen left) + 180, // E (offscreen left) + 180, // R (offscreen left) + 180, // F (offscreen left) + -180, // E (offscreen right) + -180, // C (offscreen right) + -180, // T (offscreen right) + -180, // ! (offscreen right) }; -s16 D_801BFC8C[2][3] = { + +s16 sPerfectLettersType2PrimColorTargets[2][3] = { { 255, 255, 255 }, { 255, 165, 55 }, }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B9E0.s") +void Interface_UpdatePerfectLettersType2(PlayState* play) { + s16 i; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 colorStepR; + s16 colorStepG; + s16 colorStepB; + s16 colorStepA; + s16 j = 0; // unused incrementer + + // Update letter positions + for (i = 0; i < interfaceCtx->perfectLettersCount; i++, j += 4) { + if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_INIT) { + // Initialize letter positions along the elliptical spirals + interfaceCtx->perfectLettersAngles[i] = i * (0x10000 / PERFECT_LETTERS_NUM_LETTERS); + interfaceCtx->perfectLettersSemiAxisX[i] = 200.0f; + interfaceCtx->perfectLettersSemiAxisY[i] = 200.0f; + + interfaceCtx->perfectLettersOffsetX[i] = 0; + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_ENTER; + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_ENTER) { + // Swirl inwards along elliptical spirals to the center of the screen + interfaceCtx->perfectLettersAngles[i] -= 0x800; + interfaceCtx->perfectLettersSemiAxisX[i] -= 8.0f; + interfaceCtx->perfectLettersSemiAxisY[i] -= 8.0f; + + if (interfaceCtx->perfectLettersSemiAxisX[i] <= 0.0f) { + // The letter has reached the center of the screen + interfaceCtx->perfectLettersSemiAxisY[i] = 0.0f; + interfaceCtx->perfectLettersSemiAxisX[i] = 0.0f; + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_STATIONARY; + + if (i == (PERFECT_LETTERS_NUM_LETTERS - 1)) { + // The last letter has reached the center of the screen + interfaceCtx->perfectLettersColorTimer = 5; + interfaceCtx->perfectLettersState[0] = interfaceCtx->perfectLettersState[1] = + interfaceCtx->perfectLettersState[2] = interfaceCtx->perfectLettersState[3] = + interfaceCtx->perfectLettersState[4] = interfaceCtx->perfectLettersState[5] = + interfaceCtx->perfectLettersState[6] = interfaceCtx->perfectLettersState[7] = + PERFECT_LETTERS_STATE_SPREAD; + } + } + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_SPREAD) { + // Spread out the letters horizontally from the center to the spelt-out word + colorStepR = ABS_ALT(interfaceCtx->perfectLettersOffsetX[i] - sPerfectLettersType2SpellingOffsetsX[i]) / + interfaceCtx->perfectLettersColorTimer; + if (interfaceCtx->perfectLettersOffsetX[i] >= sPerfectLettersType2SpellingOffsetsX[i]) { + interfaceCtx->perfectLettersOffsetX[i] -= colorStepR; + } else { + interfaceCtx->perfectLettersOffsetX[i] += colorStepR; + } + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_EXIT) { + // Spread out the letters horizontally from the spelt-out world to offscreen + colorStepR = ABS_ALT(interfaceCtx->perfectLettersOffsetX[i] - sPerfectLettersType2OffScreenOffsetsX[i]) / + interfaceCtx->perfectLettersColorTimer; + if (interfaceCtx->perfectLettersOffsetX[i] >= sPerfectLettersType2OffScreenOffsetsX[i]) { + interfaceCtx->perfectLettersOffsetX[i] -= colorStepR; + } else { + interfaceCtx->perfectLettersOffsetX[i] += colorStepR; + } + } + } + + if ((interfaceCtx->perfectLettersState[0] == PERFECT_LETTERS_STATE_SPREAD) || + (interfaceCtx->perfectLettersState[0] == PERFECT_LETTERS_STATE_EXIT)) { + if (interfaceCtx->perfectLettersState[0] == PERFECT_LETTERS_STATE_EXIT) { + colorStepA = interfaceCtx->perfectLettersPrimColor[3] / interfaceCtx->perfectLettersColorTimer; + interfaceCtx->perfectLettersPrimColor[3] -= colorStepA; + } + interfaceCtx->perfectLettersColorTimer--; + if (interfaceCtx->perfectLettersColorTimer == 0) { + + if (interfaceCtx->perfectLettersState[0] == PERFECT_LETTERS_STATE_SPREAD) { + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_DISPLAY; + } + interfaceCtx->perfectLettersColorTimer = 20; + } else { + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_OFF; + } + interfaceCtx->perfectLettersOn = false; + } + } + } -s16 D_801BFC98[] = { - 78, 54, 29, 5, -18, -42, -67, -85, + // Initialize the next letter in the list + if (interfaceCtx->perfectLettersState[interfaceCtx->perfectLettersCount] == PERFECT_LETTERS_STATE_OFF) { + if (interfaceCtx->perfectLettersCount < PERFECT_LETTERS_NUM_LETTERS) { + interfaceCtx->perfectLettersState[interfaceCtx->perfectLettersCount] = PERFECT_LETTERS_STATE_INIT; + interfaceCtx->perfectLettersCount++; + } + } + + // Update letter colors + if (interfaceCtx->perfectLettersCount == PERFECT_LETTERS_NUM_LETTERS) { + if (interfaceCtx->perfectLettersState[PERFECT_LETTERS_NUM_LETTERS - 1] == PERFECT_LETTERS_STATE_DISPLAY) { + + colorStepR = ABS_ALT(interfaceCtx->perfectLettersPrimColor[0] - + sPerfectLettersType2PrimColorTargets[interfaceCtx->perfectLettersColorIndex][0]) / + interfaceCtx->perfectLettersColorTimer; + colorStepG = ABS_ALT(interfaceCtx->perfectLettersPrimColor[1] - + sPerfectLettersType2PrimColorTargets[interfaceCtx->perfectLettersColorIndex][1]) / + interfaceCtx->perfectLettersColorTimer; + colorStepB = ABS_ALT(interfaceCtx->perfectLettersPrimColor[2] - + sPerfectLettersType2PrimColorTargets[interfaceCtx->perfectLettersColorIndex][2]) / + interfaceCtx->perfectLettersColorTimer; + + if (interfaceCtx->perfectLettersPrimColor[0] >= + sPerfectLettersType2PrimColorTargets[interfaceCtx->perfectLettersColorIndex][0]) { + interfaceCtx->perfectLettersPrimColor[0] -= colorStepR; + } else { + interfaceCtx->perfectLettersPrimColor[0] += colorStepR; + } + + if (interfaceCtx->perfectLettersPrimColor[1] >= + sPerfectLettersType2PrimColorTargets[interfaceCtx->perfectLettersColorIndex][1]) { + interfaceCtx->perfectLettersPrimColor[1] -= colorStepG; + } else { + interfaceCtx->perfectLettersPrimColor[1] += colorStepG; + } + + if (interfaceCtx->perfectLettersPrimColor[2] >= + sPerfectLettersType2PrimColorTargets[interfaceCtx->perfectLettersColorIndex][2]) { + interfaceCtx->perfectLettersPrimColor[2] -= colorStepB; + } else { + interfaceCtx->perfectLettersPrimColor[2] += colorStepB; + } + + interfaceCtx->perfectLettersColorTimer--; + if (interfaceCtx->perfectLettersColorTimer == 0) { + interfaceCtx->perfectLettersColorTimer = 20; + interfaceCtx->perfectLettersColorIndex ^= 1; + interfaceCtx->perfectLettersTimer++; + if (interfaceCtx->perfectLettersTimer == 6) { + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_EXIT; + } + interfaceCtx->perfectLettersColorTimer = 5; + } + } + } + } +} + +// Targets to offset each letter to properly spell "PERFECT!" +s16 sPerfectLettersType3SpellingOffsetsX[PERFECT_LETTERS_NUM_LETTERS] = { + 78, // P + 54, // E + 29, // R + 5, // F + -18, // E + -42, // C + -67, // T + -85, // ! }; -u16 D_801BFCA8[] = { - 0xC000, 0xE000, 0x0000, 0x2000, 0xA000, 0x8000, 0x6000, 0x4000, + +// Targets to sweep each letter's angle along an elliptical spiral offscreen +u16 sPerfectLettersType3OffScreenAngles[PERFECT_LETTERS_NUM_LETTERS] = { + 6 * PERFECT_LETTERS_ANGLE_PER_LETTER, // P + 7 * PERFECT_LETTERS_ANGLE_PER_LETTER, // E + 0 * PERFECT_LETTERS_ANGLE_PER_LETTER, // R + 1 * PERFECT_LETTERS_ANGLE_PER_LETTER, // F + 5 * PERFECT_LETTERS_ANGLE_PER_LETTER, // E + 4 * PERFECT_LETTERS_ANGLE_PER_LETTER, // C + 3 * PERFECT_LETTERS_ANGLE_PER_LETTER, // T + 2 * PERFECT_LETTERS_ANGLE_PER_LETTER, // ! }; -s16 D_801BFCB8[2][3] = { + +s16 sPerfectLettersType3PrimColorTargets[2][3] = { { 255, 255, 255 }, { 255, 165, 55 }, }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011BF70.s") +void Interface_UpdatePerfectLettersType3(PlayState* play) { + s16 i; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 colorStepR; + s16 colorStepG; + s16 colorStepB; + s16 j = 0; + + // Update letter positions + for (i = 0; i < interfaceCtx->perfectLettersCount; i++, j += 4) { + if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_INIT) { + // Initialize letter positions along the elliptical spirals + interfaceCtx->perfectLettersAngles[i] = i * (0x10000 / PERFECT_LETTERS_NUM_LETTERS); + interfaceCtx->perfectLettersSemiAxisX[i] = 200.0f; + interfaceCtx->perfectLettersSemiAxisY[i] = 200.0f; + + interfaceCtx->perfectLettersOffsetX[i] = 0; + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_ENTER; + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_ENTER) { + // Swirl inwards along elliptical spirals to the center of the screen + interfaceCtx->perfectLettersAngles[i] -= 0x800; + interfaceCtx->perfectLettersSemiAxisX[i] -= 8.0f; + interfaceCtx->perfectLettersSemiAxisY[i] -= 8.0f; + + if (interfaceCtx->perfectLettersSemiAxisX[i] <= 0.0f) { + // The letter has reached the center of the screen + interfaceCtx->perfectLettersSemiAxisY[i] = 0.0f; + interfaceCtx->perfectLettersSemiAxisX[i] = 0.0f; + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_STATIONARY; + + if (i == (PERFECT_LETTERS_NUM_LETTERS - 1)) { + // The last letter has reached the center of the screen + interfaceCtx->perfectLettersColorTimer = 5; + interfaceCtx->perfectLettersState[0] = interfaceCtx->perfectLettersState[1] = + interfaceCtx->perfectLettersState[2] = interfaceCtx->perfectLettersState[3] = + interfaceCtx->perfectLettersState[4] = interfaceCtx->perfectLettersState[5] = + interfaceCtx->perfectLettersState[6] = interfaceCtx->perfectLettersState[7] = + PERFECT_LETTERS_STATE_SPREAD; + } + } + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_SPREAD) { + // Spread out the letters horizontally from the center to the spelt-out word + colorStepR = ABS_ALT(interfaceCtx->perfectLettersOffsetX[i] - sPerfectLettersType3SpellingOffsetsX[i]) / + interfaceCtx->perfectLettersColorTimer; + if (interfaceCtx->perfectLettersOffsetX[i] >= sPerfectLettersType3SpellingOffsetsX[i]) { + interfaceCtx->perfectLettersOffsetX[i] -= colorStepR; + } else { + interfaceCtx->perfectLettersOffsetX[i] += colorStepR; + } + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_EXIT) { + // Swirl outwards along elliptical spirals offscreen + interfaceCtx->perfectLettersAngles[i] -= 0x800; + if (interfaceCtx->perfectLettersAngles[i] == (u16)(sPerfectLettersType3OffScreenAngles[i] - 0x8000)) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_OFF; + } + } + } -TexturePtr D_801BFCC4[] = { - gMinigameLetterPTex, gMinigameLetterETex, gMinigameLetterRTex, gMinigameLetterFTex, - gMinigameLetterETex, gMinigameLetterCTex, gMinigameLetterTTex, gMinigameExclamationTex, + if (interfaceCtx->perfectLettersState[0] == PERFECT_LETTERS_STATE_SPREAD) { + interfaceCtx->perfectLettersColorTimer--; + if (interfaceCtx->perfectLettersColorTimer == 0) { + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_DISPLAY; + } + interfaceCtx->perfectLettersColorTimer = 20; + } + } + + // Initialize the next letter in the list + if ((interfaceCtx->perfectLettersState[interfaceCtx->perfectLettersCount] == PERFECT_LETTERS_STATE_OFF) && + (interfaceCtx->perfectLettersCount < PERFECT_LETTERS_NUM_LETTERS)) { + interfaceCtx->perfectLettersState[interfaceCtx->perfectLettersCount] = PERFECT_LETTERS_STATE_INIT; + interfaceCtx->perfectLettersCount++; + } + + // Update letter colors + if ((interfaceCtx->perfectLettersCount == PERFECT_LETTERS_NUM_LETTERS) && + (interfaceCtx->perfectLettersState[PERFECT_LETTERS_NUM_LETTERS - 1] == PERFECT_LETTERS_STATE_DISPLAY)) { + + colorStepR = ABS_ALT(interfaceCtx->perfectLettersPrimColor[0] - + sPerfectLettersType3PrimColorTargets[interfaceCtx->perfectLettersColorIndex][0]) / + interfaceCtx->perfectLettersColorTimer; + colorStepG = ABS_ALT(interfaceCtx->perfectLettersPrimColor[1] - + sPerfectLettersType3PrimColorTargets[interfaceCtx->perfectLettersColorIndex][1]) / + interfaceCtx->perfectLettersColorTimer; + colorStepB = ABS_ALT(interfaceCtx->perfectLettersPrimColor[2] - + sPerfectLettersType3PrimColorTargets[interfaceCtx->perfectLettersColorIndex][2]) / + interfaceCtx->perfectLettersColorTimer; + + if (interfaceCtx->perfectLettersPrimColor[0] >= + sPerfectLettersType3PrimColorTargets[interfaceCtx->perfectLettersColorIndex][0]) { + interfaceCtx->perfectLettersPrimColor[0] -= colorStepR; + } else { + interfaceCtx->perfectLettersPrimColor[0] += colorStepR; + } + + if (interfaceCtx->perfectLettersPrimColor[1] >= + sPerfectLettersType3PrimColorTargets[interfaceCtx->perfectLettersColorIndex][1]) { + interfaceCtx->perfectLettersPrimColor[1] -= colorStepG; + } else { + interfaceCtx->perfectLettersPrimColor[1] += colorStepG; + } + + if (interfaceCtx->perfectLettersPrimColor[2] >= + sPerfectLettersType3PrimColorTargets[interfaceCtx->perfectLettersColorIndex][2]) { + interfaceCtx->perfectLettersPrimColor[2] -= colorStepB; + } else { + interfaceCtx->perfectLettersPrimColor[2] += colorStepB; + } + + interfaceCtx->perfectLettersColorTimer--; + if (interfaceCtx->perfectLettersColorTimer == 0) { + interfaceCtx->perfectLettersColorTimer = 20; + interfaceCtx->perfectLettersColorIndex ^= 1; + interfaceCtx->perfectLettersTimer++; + if (interfaceCtx->perfectLettersTimer == 6) { + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersSemiAxisX[i] = 140.0f; + interfaceCtx->perfectLettersSemiAxisY[i] = 100.0f; + interfaceCtx->perfectLettersAngles[i] = sPerfectLettersType3OffScreenAngles[i]; + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_EXIT; + } + interfaceCtx->perfectLettersColorTimer = 5; + } + } + } + + j = 0; + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_OFF) { + j++; + } + } + + if (j == PERFECT_LETTERS_NUM_LETTERS) { + interfaceCtx->perfectLettersOn = false; + } +} + +TexturePtr sPerfectLettersTextures[] = { + gPerfectLetterPTex, gPerfectLetterETex, gPerfectLetterRTex, gPerfectLetterFTex, + gPerfectLetterETex, gPerfectLetterCTex, gPerfectLetterTTex, gPerfectLetterExclamationTex, }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C4C4.s") +void Interface_DrawPerfectLetters(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + f32 letterX; + f32 letterY; + s16 i; + s16 vtxOffset; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C8D4(play->state.gfxCtx); + + gSPMatrix(OVERLAY_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIMITIVE, 0); + + for (vtxOffset = 0, i = 0; i < PERFECT_LETTERS_NUM_LETTERS; vtxOffset += 4, i++) { + if (interfaceCtx->perfectLettersState[i] != PERFECT_LETTERS_STATE_OFF) { + + // The positions follow the path of an elliptical spiral + letterX = Math_SinS(interfaceCtx->perfectLettersAngles[i]) * interfaceCtx->perfectLettersSemiAxisX[i]; + letterY = Math_CosS(interfaceCtx->perfectLettersAngles[i]) * interfaceCtx->perfectLettersSemiAxisY[i]; + + // Draw Minigame Perfect Shadows + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->perfectLettersPrimColor[3]); + + Matrix_Translate(letterX, letterY, 0.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[44 + vtxOffset], 4, 0); + + OVERLAY_DISP = Gfx_DrawTexQuad4b(OVERLAY_DISP, sPerfectLettersTextures[i], 4, 32, 33, 0); + + // Draw Minigame Perfect Colored Letters + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, interfaceCtx->perfectLettersPrimColor[0], + interfaceCtx->perfectLettersPrimColor[1], interfaceCtx->perfectLettersPrimColor[2], + interfaceCtx->perfectLettersPrimColor[3]); + + Matrix_Translate(letterX, letterY, 0.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[76 + vtxOffset], 4, 0); + + OVERLAY_DISP = Gfx_DrawTexQuad4b(OVERLAY_DISP, sPerfectLettersTextures[i], 4, 32, 33, 0); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} void Interface_StartMoonCrash(PlayState* play) { if (play->actorCtx.flags & ACTORCTX_FLAG_1) { @@ -3005,7 +3821,7 @@ void Interface_DrawTimers(PlayState* play) { case TIMER_STATE_START: case TIMER_STATE_ALT_START: sTimerStateTimer = 20; - if (interfaceCtx->unk_280 != 0) { + if (interfaceCtx->minigameState != MINIGAME_STATE_NONE) { // Set the timer position gSaveContext.timerX[sTimerId] = 26; @@ -3018,7 +3834,8 @@ void Interface_DrawTimers(PlayState* play) { gSaveContext.timerY[sTimerId] = 46; } - if ((interfaceCtx->unk_280 == 8) || (interfaceCtx->unk_280 == 30)) { + if ((interfaceCtx->minigameState == MINIGAME_STATE_COUNTDOWN_GO) || + (interfaceCtx->minigameState == MINIGAME_STATE_PLAYING)) { if (gSaveContext.timerStates[sTimerId] == TIMER_STATE_START) { gSaveContext.timerStates[sTimerId] = TIMER_STATE_COUNTING; } else { @@ -3150,7 +3967,7 @@ void Interface_DrawTimers(PlayState* play) { OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerStartOsTimes[sTimerId]) - ((void)0, gSaveContext.timerPausedOsTimes[sTimerId])); - if ((gSaveContext.minigameState == 1) && + if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { if (gSaveContext.timerStopTimes[sTimerId] >= SECONDS_TO_TIMER(120)) { gSaveContext.timerStopTimes[sTimerId] = SECONDS_TO_TIMER(120); @@ -3261,7 +4078,8 @@ void Interface_DrawTimers(PlayState* play) { osTime = SECONDS_TO_TIMER(0); } - if ((gSaveContext.minigameState == 1) && (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { + if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && + (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { if (osTime >= SECONDS_TO_TIMER(120)) { osTime = SECONDS_TO_TIMER(120); } @@ -3276,7 +4094,8 @@ void Interface_DrawTimers(PlayState* play) { Interface_GetTimerDigits(osTime, sTimerDigits); // Use seconds to determine when to beep - if ((gSaveContext.minigameState == 1) && (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { + if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && + (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { if ((gSaveContext.timerCurTimes[sTimerId] > SECONDS_TO_TIMER(110)) && (sTimerBeepSfxSeconds != sTimerDigits[4])) { play_sound(NA_SE_SY_WARNING_COUNT_E); @@ -3313,7 +4132,7 @@ void Interface_DrawTimers(PlayState* play) { } else { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); } - } else if ((gSaveContext.minigameState == 1) && + } else if ((gSaveContext.minigameStatus == 1) && (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { if (gSaveContext.timerCurTimes[sTimerId] >= SECONDS_TO_TIMER(110)) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); @@ -3447,7 +4266,121 @@ void Interface_UpdateBottleTimers(PlayState* play) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011E730.s") +void Interface_DrawMinigameIcons(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 i; + s16 numDigitsDrawn; + s16 rectX; + s16 rectY; + s16 width; + s16 height; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C654(play->state.gfxCtx); + + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { + // Carrots rendering if the action corresponds to riding a horse + if (interfaceCtx->unk_212 == 8) { + // Load Carrot Icon + gDPLoadTextureBlock(OVERLAY_DISP++, gCarrotIconTex, G_IM_FMT_RGBA, G_IM_SIZ_32b, 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); + + rectX = 110; + rectY = (interfaceCtx->minigameState != MINIGAME_STATE_NONE) ? 200 : 56; + + // Draw 6 carrots + for (i = 1; i < 7; i++, rectX += 16) { + // Carrot Color (based on availability) + if ((interfaceCtx->numHorseBoosts == 0) || (interfaceCtx->numHorseBoosts < i)) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 150, 255, interfaceCtx->aAlpha); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->aAlpha); + } + + gSPTextureRectangle(OVERLAY_DISP++, rectX << 2, rectY << 2, (rectX + 16) << 2, (rectY + 16) << 2, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + } + } + + if (gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) { + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + width = 24; + height = 16; + rectX = 20; + if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + rectY = 75; // two rows of hearts + } else { + rectY = 67; // one row of hearts + } + + if (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 1)) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->bAlpha); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); + gDPLoadTextureBlock(OVERLAY_DISP++, gBeaverRingIconTex, G_IM_FMT_RGBA, G_IM_SIZ_32b, 24, 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); + } else if (play->sceneId == SCENE_DOUJOU) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 140, 50, interfaceCtx->bAlpha); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); + gDPLoadTextureBlock(OVERLAY_DISP++, gSwordTrainingLogIconTex, G_IM_FMT_IA, G_IM_SIZ_8b, 24, 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); + } else if (play->sceneId == SCENE_30GYOSON) { + width = 16; + height = 30; + rectX = 24; + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 100, 75, interfaceCtx->bAlpha); + gDPSetEnvColor(OVERLAY_DISP++, 55, 55, 0, 255); + gDPLoadTextureBlock(OVERLAY_DISP++, gFishermanMinigameTorchIconTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 30, 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); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->bAlpha); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); + gDPLoadTextureBlock(OVERLAY_DISP++, gArcheryScoreIconTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 24, 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); + } + + gSPTextureRectangle(OVERLAY_DISP++, (rectX << 2), (rectY << 2), ((rectX + width) << 2), + ((rectY + height) << 2), G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->bAlpha); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, + 0, PRIMITIVE, 0); + + if (play->sceneId == SCENE_30GYOSON) { + rectX += 20; + if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + rectY = 87; // two rows of hearts + } else { + rectY = 79; // one row of hearts + } + } else { + rectX += 26; + } + + for (i = 0, numDigitsDrawn = 0; i < 4; i++) { + if ((sMinigameScoreDigits[i] != 0) || (numDigitsDrawn != 0) || (i >= 3)) { + OVERLAY_DISP = + Gfx_DrawTexRectI8(OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * sMinigameScoreDigits[i])), + 8, 0x10, rectX, rectY - 2, 9, 0xFA, 0x370, 0x370); + rectX += 9; + numDigitsDrawn++; + } + } + + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} // rupeeDigitsFirst s16 D_801BFD1C[] = { 1, 0, 0, 0 }; @@ -3492,7 +4425,7 @@ TexturePtr D_801BFD8C[] = { gStoryGiantsLeavingTLUT, }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011F0E0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_Draw.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80120F90.s") @@ -3502,11 +4435,11 @@ u8 D_801BFD94 = 0; s16 D_801BFD98 = 0; s16 D_801BFD9C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801210E0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_Update.s") void Interface_Destroy(PlayState* play) { Map_Destroy(play); func_80174F9C(Interface_PostmanTimerCallback, NULL); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80121FC4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_Init.s") diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 0f267dccb..2ef547b48 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -342,7 +342,7 @@ void BgIngate_Init(Actor* thisx, PlayState* play2) { if (play->curSpawn == 6) { func_80953F14(this, play); if (CHECK_EVENTINF(EVENTINF_35)) { - func_80112AFC(play); + Interface_InitMinigame(play); } else { SET_EVENTINF(EVENTINF_41); } diff --git a/src/overlays/actors/ovl_En_Az/z_en_az.c b/src/overlays/actors/ovl_En_Az/z_en_az.c index 0a5056b1f..bfefb5a85 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -1482,9 +1482,9 @@ void func_80A97D5C(EnAz* this, PlayState* play) { Player* player = GET_PLAYER(play); player->stateFlags1 |= PLAYER_STATE1_20; - func_80112AFC(play); + Interface_InitMinigame(play); gSaveContext.minigameScore = (this->unk_374 & 2) ? 25 : 20; - play->interfaceCtx.unk_280 = 1; + play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3; if ((this->unk_2FA == 1) || (this->unk_2FA == 3)) { Interface_StartTimer(TIMER_ID_MINIGAME_2, 120); } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_25_01)) { @@ -1498,7 +1498,7 @@ void func_80A97D5C(EnAz* this, PlayState* play) { void func_80A97E48(EnAz* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (play->interfaceCtx.unk_280 >= 8) { + if (play->interfaceCtx.minigameState >= MINIGAME_STATE_COUNTDOWN_GO) { player->stateFlags1 &= ~PLAYER_STATE1_20; func_80A97EAC(this, play); } diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index a3d76fab7..041cadaa7 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -800,7 +800,7 @@ void func_80962F4C(EnFu* this, PlayState* play) { gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0); gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); - func_8011B4E0(play, 1); + Interface_SetPerfectLetters(play, PERFECT_LETTERS_TYPE_1); this->unk_54A = 3; func_809632D0(this); } @@ -848,7 +848,7 @@ void func_80963350(EnFu* this, PlayState* play) { D_80964C24 = 1; } - if ((this->unk_54A == 3) && (play->interfaceCtx.unk_286 == 0)) { + if ((this->unk_54A == 3) && !play->interfaceCtx.perfectLettersOn) { this->unk_54A = 2; D_80964C24 = 1; } diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 2c7eec607..5ffc364c3 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -875,7 +875,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { EnHorse_InitCutscene(this, play); } else if (thisx->params == ENHORSE_10) { EnHorse_InitHorsebackArchery(this); - func_80112AFC(play); + Interface_InitMinigame(play); } else if (thisx->params == ENHORSE_14) { func_808846F0(this, play); if ((play->sceneId == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { @@ -2917,22 +2917,23 @@ void EnHorse_UpdateHorsebackArchery(EnHorse* this, PlayState* play) { EnHorse_PlayWalkingSound(this); } - if (play->interfaceCtx.hbaAmmo == 0) { + if (play->interfaceCtx.minigameAmmo == 0) { this->hbaTimer++; } sp28 = Audio_IsSequencePlaying(NA_BGM_HORSE_GOAL); EnHorse_UpdateHbaRaceInfo(this, play, &sHbaInfo); - if (((this->hbaFlags & 1) || (this->hbaTimer > 45)) && (sp28 != 1) && (gSaveContext.minigameState != 3)) { + if (((this->hbaFlags & 1) || (this->hbaTimer > 45)) && (sp28 != 1) && + (gSaveContext.minigameStatus != MINIGAME_STATUS_END)) { gSaveContext.save.cutscene = 0; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_64; } - if (play->interfaceCtx.hbaAmmo) {} + if (play->interfaceCtx.minigameAmmo) {} - if (((play->interfaceCtx.hbaAmmo == 0) || (this->hbaFlags & 2)) && (this->hbaFlags & 4)) { + if (((play->interfaceCtx.minigameAmmo == 0) || (this->hbaFlags & 2)) && (this->hbaFlags & 4)) { this->hbaFlags &= ~4; Audio_QueueSeqCmd(0x8041); } diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index b2e745cad..5299dbaa1 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -122,7 +122,7 @@ s32 func_808F8CCC(EnHorseGameCheck* this, PlayState* play2) { } Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); - play->interfaceCtx.unk_280 = 1; + play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3; this->horse1 = (EnHorse*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, -1149.0f, -106.0f, 470.0f, 0, 0x7FFF, 0, ENHORSE_PARAMS(ENHORSE_PARAM_BANDIT, ENHORSE_4)); @@ -212,10 +212,10 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { if ((this->unk_168 > 50) && !(this->unk_164 & 2)) { this->unk_164 |= 2; - } else if ((play->interfaceCtx.unk_280 >= 8) && !(this->unk_164 & 1)) { + } else if ((play->interfaceCtx.minigameState >= MINIGAME_STATE_COUNTDOWN_GO) && !(this->unk_164 & 1)) { this->unk_164 |= 1; horse->inRace = true; - } else if ((play->interfaceCtx.unk_280 >= 8) && !(this->unk_164 & 8)) { + } else if ((play->interfaceCtx.minigameState >= MINIGAME_STATE_COUNTDOWN_GO) && !(this->unk_164 & 8)) { EnHorse* horse = this->horse1; horse->inRace = true; diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c index 9bafd7ea6..03cc41f20 100644 --- a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c +++ b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c @@ -94,7 +94,7 @@ s32 EnJcMato_CheckForHit(EnJcMato* this, PlayState* play) { if ((this->collider.base.acFlags & AC_HIT) && !this->hitFlag && (this->actor.colChkInfo.damageEffect == 0xF)) { this->collider.base.acFlags &= ~AC_HIT; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); - play->interfaceCtx.unk_25C = 1; + play->interfaceCtx.minigamePoints = 1; this->hitFlag = true; return 1; } else { diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index 8e8271658..92e918c5d 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c @@ -284,8 +284,8 @@ void func_80C1410C(EnJgameTsn* this, PlayState* play) { player->stateFlags1 |= PLAYER_STATE1_20; func_801A2BB8(0x25); - play->interfaceCtx.unk_280 = 1; - func_80112AFC(play); + play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3; + Interface_InitMinigame(play); SET_WEEKEVENTREG(WEEKEVENTREG_90_20); Interface_StartTimer(TIMER_ID_MINIGAME_2, 120); this->actionFunc = func_80C1418C; @@ -294,7 +294,7 @@ void func_80C1410C(EnJgameTsn* this, PlayState* play) { void func_80C1418C(EnJgameTsn* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (play->interfaceCtx.unk_280 == 8) { + if (play->interfaceCtx.minigameState == MINIGAME_STATE_COUNTDOWN_GO) { func_80C141DC(this); player->stateFlags1 &= ~PLAYER_STATE1_20; } @@ -478,7 +478,7 @@ void func_80C147B4(EnJgameTsn* this, PlayState* play) { case 0x10A0: case 0x10A1: func_801477B4(play); - gSaveContext.minigameState = 3; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_20); func_80C144E4(this); @@ -563,14 +563,14 @@ s32 func_80C14BCC(EnJgameTsn* this, PlayState* play) { if (phi_s3 == this->unk_218) { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); *this->unk_208[phi_s3] |= OBJLUPYGAMELIFT_DISPLAY_CORRECT; - play->interfaceCtx.unk_25C = 1; + play->interfaceCtx.minigamePoints = 1; return true; } if (*this->unk_208[phi_s3] & OBJLUPYGAMELIFT_IGNITE_FIRE) { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); *this->unk_208[phi_s3] |= OBJLUPYGAMELIFT_DISPLAY_CORRECT; - play->interfaceCtx.unk_25C = 1; + play->interfaceCtx.minigamePoints = 1; } else { *this->unk_208[phi_s3] |= OBJLUPYGAMELIFT_DISPLAY_INCORRECT; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c index 7a28cf0fc..c02b00b5a 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c @@ -297,14 +297,14 @@ void func_80B269A4(EnKendoJs* this, PlayState* play) { case 0x273B: func_801477B4(play); - func_80112AFC(play); + Interface_InitMinigame(play); player->stateFlags1 |= PLAYER_STATE1_20; func_80B273D0(this); break; case 0x272D: func_801477B4(play); - gSaveContext.minigameState = 3; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; func_80B276C4(this); func_80B276D8(this, play); break; @@ -334,7 +334,7 @@ void func_80B26AFC(EnKendoJs* this, PlayState* play) { } if ((this->unk_288 == 0x272E) || (this->unk_288 == 0x272F) || (this->unk_288 == 0x2730)) { - gSaveContext.minigameState = 3; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; } player->stateFlags1 &= ~PLAYER_STATE1_20; @@ -625,14 +625,14 @@ void func_80B274BC(EnKendoJs* this, PlayState* play) { if (this->unk_28E == 1) { if ((player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) || (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_FINISH)) { - play->interfaceCtx.unk_25C = 3; + play->interfaceCtx.minigamePoints = 3; if (gSaveContext.minigameScore >= 27) { player->stateFlags1 |= PLAYER_STATE1_20; } } else if (player->meleeWeaponAnimation == PLAYER_MWA_STAB_1H) { - play->interfaceCtx.unk_25C = 2; + play->interfaceCtx.minigamePoints = 2; } else { - play->interfaceCtx.unk_25C = 1; + play->interfaceCtx.minigamePoints = 1; } Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); this->unk_28E = 0; diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index efe754662..93f33cfed 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -688,10 +688,10 @@ void EnMa4_HorsebackGameTalking(EnMa4* this, PlayState* play) { void EnMa4_InitHorsebackGame(EnMa4* this, PlayState* play) { Player* player = GET_PLAYER(play); - play->interfaceCtx.unk_280 = 1; + play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3; Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); SET_WEEKEVENTREG(WEEKEVENTREG_08_01); - func_80112AFC(play); + Interface_InitMinigame(play); player->stateFlags1 |= PLAYER_STATE1_20; this->actionFunc = EnMa4_SetupHorsebackGameWait; } @@ -699,7 +699,7 @@ void EnMa4_InitHorsebackGame(EnMa4* this, PlayState* play) { void EnMa4_SetupHorsebackGameWait(EnMa4* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (play->interfaceCtx.unk_280 == 8) { + if (play->interfaceCtx.minigameState == MINIGAME_STATE_COUNTDOWN_GO) { this->actionFunc = EnMa4_HorsebackGameWait; player->stateFlags1 &= ~PLAYER_STATE1_20; } @@ -714,7 +714,7 @@ void EnMa4_HorsebackGameWait(EnMa4* this, PlayState* play) { if (this->poppedBalloonCounter != D_80AC0258) { D_80AC0258 = this->poppedBalloonCounter; - play->interfaceCtx.unk_25C = 1; + play->interfaceCtx.minigamePoints = 1; } if ((gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) || diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index 8d6b75fbd..a077ee1bf 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -315,11 +315,11 @@ void EnMttag_RaceStart(EnMttag* this, PlayState* play) { } else { if (DECR(this->timer) == 60) { Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); - play->interfaceCtx.unk_280 = 1; + play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3; Audio_QueueSeqCmd(NA_BGM_GORON_RACE | 0x8000); play->envCtx.unk_E4 = 0xFE; player->stateFlags1 &= ~PLAYER_STATE1_20; - } else if ((this->timer < 60) && (play->interfaceCtx.unk_280 == 8)) { + } else if ((this->timer < 60) && (play->interfaceCtx.minigameState == MINIGAME_STATE_COUNTDOWN_GO)) { this->timer = 0; SET_EVENTINF(EVENTINF_10); this->actionFunc = EnMttag_Race; diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 928d4e578..e2490bb8d 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -59,9 +59,9 @@ EnOtUnkStruct* func_80B5DF58(EnOtUnkStruct* arg0, u8 arg1, Vec3f* arg2, Vec3s* a void func_80B5E078(PlayState* play, EnOtUnkStruct* arg1, s32 arg2); void func_80B5E1D8(PlayState* play, EnOtUnkStruct* arg1, s32 arg2); -static EnOt* D_80B5E880; -static EnOt* D_80B5E884; -static EnOt* D_80B5E888; +EnOt* D_80B5E880; +EnOt* D_80B5E884; +EnOt* D_80B5E888; ActorInit En_Ot_InitVars = { ACTOR_EN_OT, diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 323494173..759e97206 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -334,7 +334,7 @@ void EnSyatekiMan_Swamp_HandleChoice(EnSyatekiMan* this, PlayState* play) { Message_StartTextbox(play, 0xA31, &this->actor); this->prevTextId = 0xA31; if (this->shootingGameState == SG_GAME_STATE_ONE_MORE_GAME) { - gSaveContext.minigameState = 3; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; } this->shootingGameState = SG_GAME_STATE_NOT_PLAYING; @@ -373,7 +373,7 @@ void EnSyatekiMan_Swamp_HandleChoice(EnSyatekiMan* this, PlayState* play) { } if (this->shootingGameState == SG_GAME_STATE_ONE_MORE_GAME) { - gSaveContext.minigameState = 3; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; } this->shootingGameState = SG_GAME_STATE_NOT_PLAYING; @@ -399,8 +399,8 @@ void EnSyatekiMan_Swamp_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; - func_80112AFC(play); - play->interfaceCtx.hbaAmmo = 80; + Interface_InitMinigame(play); + play->interfaceCtx.minigameAmmo = 80; func_80123F2C(play, 80); this->shootingGameState = SG_GAME_STATE_RUNNING; this->actionFunc = EnSyatekiMan_Swamp_StartGame; @@ -414,7 +414,7 @@ void EnSyatekiMan_Swamp_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); this->actionFunc = EnSyatekiMan_Swamp_Idle; - gSaveContext.minigameState = 3; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; this->shootingGameState = SG_GAME_STATE_NONE; } else { // Wanna play again? @@ -434,7 +434,7 @@ void EnSyatekiMan_Swamp_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; - gSaveContext.minigameState = 3; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; player->stateFlags1 |= PLAYER_STATE1_20; this->actionFunc = EnSyatekiMan_Swamp_SetupGiveReward; EnSyatekiMan_Swamp_SetupGiveReward(this, play); @@ -641,7 +641,7 @@ void EnSyatekiMan_Town_HandleChoice(EnSyatekiMan* this, PlayState* play) { if (this->shootingGameState == SG_GAME_STATE_ONE_MORE_GAME) { player->stateFlags3 &= ~PLAYER_STATE3_400; - gSaveContext.minigameState = 3; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; } this->shootingGameState = SG_GAME_STATE_NOT_PLAYING; @@ -677,7 +677,7 @@ void EnSyatekiMan_Town_HandleChoice(EnSyatekiMan* this, PlayState* play) { if (this->shootingGameState == SG_GAME_STATE_ONE_MORE_GAME) { player->stateFlags3 &= ~PLAYER_STATE3_400; - gSaveContext.minigameState = 3; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; } this->shootingGameState = SG_GAME_STATE_NOT_PLAYING; @@ -759,7 +759,7 @@ void EnSyatekiMan_Town_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; this->flagsIndex = 0; - func_80112AFC(play); + Interface_InitMinigame(play); func_80123F2C(play, 0x63); this->shootingGameState = SG_GAME_STATE_RUNNING; func_801A2BB8(NA_BGM_TIMED_MINI_GAME); @@ -808,7 +808,7 @@ void EnSyatekiMan_Town_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; - gSaveContext.minigameState = 3; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; this->actionFunc = EnSyatekiMan_Town_SetupGiveReward; EnSyatekiMan_Town_SetupGiveReward(this, play); break; @@ -1090,7 +1090,7 @@ void EnSyatekiMan_Swamp_RunGame(EnSyatekiMan* this, PlayState* play) { func_801A2C20(); this->shootingGameState = SG_GAME_STATE_GIVING_BONUS; if (this->score == 2120) { - func_8011B4E0(play, 2); + Interface_SetPerfectLetters(play, PERFECT_LETTERS_TYPE_2); gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_6; this->actionFunc = EnSyatekiMan_Swamp_AddBonusPoints; } else { @@ -1122,7 +1122,7 @@ void EnSyatekiMan_Swamp_EndGame(EnSyatekiMan* this, PlayState* play) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); this->shootingGameState = SG_GAME_STATE_NONE; - gSaveContext.minigameState = 3; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; this->actionFunc = EnSyatekiMan_Swamp_Idle; return; } @@ -1156,7 +1156,7 @@ void EnSyatekiMan_Swamp_AddBonusPoints(EnSyatekiMan* this, PlayState* play) { Player* player = GET_PLAYER(play); player->stateFlags1 |= PLAYER_STATE1_20; - if (play->interfaceCtx.unk_286 == 0) { + if (!play->interfaceCtx.perfectLettersOn) { if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; @@ -1166,7 +1166,7 @@ void EnSyatekiMan_Swamp_AddBonusPoints(EnSyatekiMan* this, PlayState* play) { sBonusTimer = 0; } else if (sBonusTimer > 10) { gSaveContext.timerStopTimes[TIMER_ID_MINIGAME_1] += SECONDS_TO_TIMER(1); - play->interfaceCtx.unk_25C += 10; + play->interfaceCtx.minigamePoints += 10; this->score += 10; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); sBonusTimer = 0; @@ -1359,7 +1359,7 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { this->actionFunc = EnSyatekiMan_Town_EndGame; if (this->score == 50) { Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); - func_8011B4E0(play, 1); + Interface_SetPerfectLetters(play, PERFECT_LETTERS_TYPE_1); } } } @@ -1368,7 +1368,7 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { void EnSyatekiMan_Town_EndGame(EnSyatekiMan* this, PlayState* play) { if (this->shootingGameState == SG_GAME_STATE_RUNNING) { this->octorokFlags = 0; - if ((this->talkWaitTimer <= 0) && (play->interfaceCtx.unk_286 == 0)) { + if ((this->talkWaitTimer <= 0) && !play->interfaceCtx.perfectLettersOn) { Flags_SetAllTreasure(play, this->score); this->talkWaitTimer = 15; if ((GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE() < this->score) || (this->score == 50)) { diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c index 5358d44cf..162a6d718 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c @@ -370,7 +370,7 @@ void EnSyatekiOkuta_Update(Actor* thisx, PlayState* play) { syatekiMan = (EnSyatekiMan*)this->actor.parent; if (this->unk_2A6 == 1) { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); - play->interfaceCtx.unk_25C++; + play->interfaceCtx.minigamePoints++; syatekiMan->score++; syatekiMan->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_RED; } else { diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index d90b83a57..e51af14ae 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -185,7 +185,7 @@ s32 func_80B761FC(EnTruMt* this, PlayState* play) { this->unk_3A4 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DAMAGE2); } - play->interfaceCtx.unk_25E = 1; + play->interfaceCtx.minigameHiddenPoints = 1; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); return true; } @@ -342,7 +342,7 @@ void func_80B76924(EnTruMt* this) { void func_80B76980(EnTruMt* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (gSaveContext.unk_3F3C >= 10) { + if (gSaveContext.minigameHiddenScore >= 10) { Message_StartTextbox(play, 0x87F, &this->actor); SET_EVENTINF(EVENTINF_36); SET_EVENTINF(EVENTINF_40); diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.c b/src/overlays/actors/ovl_En_Twig/z_en_twig.c index 31af7f8b6..5843357ee 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c @@ -198,7 +198,7 @@ void func_80AC0D2C(EnTwig* this, PlayState* play) { (s32)(Rand_ZeroOne() * 10.0f) + 20); } play_sound(NA_SE_SY_GET_ITEM); - play->interfaceCtx.unk_25C--; + play->interfaceCtx.minigamePoints--; sRingNotCollected[RACERING_GET_PARAM_FE0(&this->dyna.actor)] = true; if (sCurrentRing == RACERING_GET_PARAM_FE0(&this->dyna.actor)) { s32 i; diff --git a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c index 1ec1ab41d..bf21a8741 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c +++ b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c @@ -92,6 +92,6 @@ void EffectSsExtra_Update(PlayState* play, u32 index, EffectSs* this) { } if (this->rTimer == 1) { - play->interfaceCtx.unk_25C = sScores[this->rScoreIndex]; + play->interfaceCtx.minigamePoints = sScores[this->rScoreIndex]; } } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 3699f22cd..461192d48 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -517,7 +517,7 @@ void MapSelect_UpdateMenu(MapSelectState* this) { gSaveContext.timerStopTimes[i] = SECONDS_TO_TIMER(0); gSaveContext.timerPausedOsTimes[i] = 0; } - gSaveContext.minigameState = 0; + gSaveContext.minigameStatus = MINIGAME_STATUS_INACTIVE; if (this->scenes[this->currentScene].loadFunc != NULL) { this->scenes[this->currentScene].loadFunc(this, this->scenes[this->currentScene].entrance, this->opt); |
