From e78bbc6566817e3519762800404aaa7277f55b1f Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Aug 2022 00:31:08 -0400 Subject: [PATCH] more timer docs --- include/variables.h | 4 +- include/z64save.h | 31 ++-- src/code/z_parameter.c | 161 +++++++++--------- src/code/z_sram_NES.c | 8 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 4 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 25 +-- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 10 +- .../z_en_horse_game_check.c | 14 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 8 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 21 +-- .../actors/ovl_En_Mt_tag/z_en_mt_tag.c | 14 +- .../z_en_syateki_dekunuts.c | 2 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 36 ++-- .../ovl_Obj_Roomtimer/z_obj_roomtimer.c | 10 +- src/overlays/gamestates/ovl_select/z_select.c | 2 +- tools/disasm/variables.txt | 4 +- 16 files changed, 175 insertions(+), 179 deletions(-) diff --git a/include/variables.h b/include/variables.h index 263ee8cfe..6438a9d49 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1146,8 +1146,8 @@ extern UNK_PTR D_801BF5C0; // extern UNK_TYPE2 D_801BFCF2; // extern UNK_TYPE2 D_801BFCF4; // extern UNK_TYPE2 sTimerBeepSfxSeconds; -// extern UNK_TYPE2 D_801BFCFC; -// extern UNK_TYPE2 D_801BFD0C; +// extern UNK_TYPE2 sTimerDigitsOffsetX; +// extern UNK_TYPE2 sTimerDigitsWidth; // extern UNK_TYPE1 D_801BFD1C; // extern UNK_TYPE1 D_801BFD24; // extern UNK_TYPE1 D_801BFD2C; diff --git a/include/z64save.h b/include/z64save.h index cfaf07e5a..a76b11339 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -57,15 +57,18 @@ typedef enum { #define SECONDS_TO_TIMER(seconds) ((seconds) * 100) +#define OSTIME_TO_TIMER(osTime) ((osTime) * 64 / 3000 / 10000) +#define OSTIME_TO_TIMER_ALT(osTime) ((osTime) / 10000 * 64 / 3000) + // 1 centiSecond = 10 milliSeconds = 1/100 seconds #define SECONDS_TO_TIMER_PRECISE(seconds, centiSeconds) ((seconds) * 100 + (centiSeconds)) typedef enum { /* 0 */ TIMER_ID_POSTMAN, // postman's counting minigame - /* 1 */ TIMER_ID_1, // minigame timer + /* 1 */ TIMER_ID_MINIGAME_1, // minigame timer /* 2 */ TIMER_ID_2, /* 3 */ TIMER_ID_FINAL_HOURS, // countdown until mooncrash - /* 4 */ TIMER_ID_4, + /* 4 */ TIMER_ID_MINIGAME_2, // minigame timer /* 5 */ TIMER_ID_ENV, // environmental timer (underwater or hot room) /* 6 */ TIMER_ID_GORON_RACE_UNUSED, /* 7 */ TIMER_ID_MAX, @@ -79,18 +82,18 @@ typedef enum { typedef enum { /* 0 */ TIMER_STATE_OFF, - /* 1 */ TIMER_STATE_1, - /* 2 */ TIMER_STATE_2, - /* 3 */ TIMER_STATE_MOVING_TIMER, - /* 4 */ TIMER_STATE_4, + /* 1 */ TIMER_STATE_START, + /* 2 */ TIMER_STATE_HOLD_TIMER, // Hold timer frozen at the screen center + /* 3 */ TIMER_STATE_MOVING_TIMER, // Move timer to a target location + /* 4 */ TIMER_STATE_COUNTING, /* 5 */ TIMER_STATE_STOP, - /* 6 */ TIMER_STATE_6, - /* 7 */ TIMER_STATE_7, + /* 6 */ TIMER_STATE_6, // like `TIMER_STATE_STOP` but with extra minigame checks + /* 7 */ TIMER_STATE_7, // stopped but still update `timerCurTime` /* 8 */ TIMER_STATE_ENV_START, - /* 9 */ TIMER_STATE_9, - /* 10 */ TIMER_STATE_10, - /* 11 */ TIMER_STATE_11, - /* 12 */ TIMER_STATE_12, + /* 9 */ TIMER_STATE_ALT_START, + /* 10 */ TIMER_STATE_10, // precursor to `TIMER_STATE_ALT_COUNTING` + /* 11 */ TIMER_STATE_ALT_COUNTING, + /* 12 */ TIMER_STATE_12, // Updated paused time? /* 13 */ TIMER_STATE_POSTMAN_START, /* 14 */ TIMER_STATE_POSTMAN_COUNTING, /* 15 */ TIMER_STATE_POSTMAN_STOP, @@ -292,7 +295,7 @@ typedef struct SaveContext { /* 0x1018 */ s16 rupeeAccumulator; // "lupy_udct" /* 0x101A */ u8 bottleTimerState[BOTTLE_MAX]; // "bottle_status", one entry for each bottle /* 0x1020 */ OSTime bottleTimerStartOsTime[BOTTLE_MAX]; // "bottle_ostime", one entry for each bottle - /* 0x1050 */ u64 bottleTimerCurSubTime[BOTTLE_MAX]; // "bottle_sub", one entry for each bottle + /* 0x1050 */ u64 bottleTimerCurTimeLimit[BOTTLE_MAX]; // "bottle_sub", one entry for each bottle /* 0x1080 */ u64 bottleTimerCurTime[BOTTLE_MAX]; // "bottle_time", one entry for each bottle /* 0x10B0 */ OSTime bottleTimerPausedOsTime[BOTTLE_MAX]; // "bottle_stop_time", one entry for each bottle /* 0x10E0 */ u64 pictoPhoto[1400]; // buffer containing the pictograph photo @@ -317,7 +320,7 @@ typedef struct SaveContext { /* 0x3DD0 */ u8 timerState[TIMER_ID_MAX]; // "event_fg" /* 0x3DD7 */ u8 timerDirection[TIMER_ID_MAX]; // "calc_flag" /* 0x3DE0 */ u64 timerCurTime[TIMER_ID_MAX]; // "event_ostime" - /* 0x3E18 */ u64 timerCurSubTime[TIMER_ID_MAX]; // "event_sub" + /* 0x3E18 */ u64 timerTimeLimit[TIMER_ID_MAX]; // "event_sub" /* 0x3E50 */ OSTime timerStartOsTime[TIMER_ID_MAX]; // "func_time" /* 0x3E88 */ OSTime timerEndOsTime[TIMER_ID_MAX]; // "func_end_time" /* 0x3EC0 */ OSTime timerPausedOsTime[TIMER_ID_MAX]; // "func_stop_time" diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index cd848a957..eea8fc922 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -186,7 +186,6 @@ s16 sExtraItemBases[] = { s16 sEnvTimerType = PLAYER_ENV_TIMER_NONE; s16 sEnvTimerActive = false; s16 sPostmanBunnyHoodState = 0; - OSTime sTimerPausedOsTime = 0; OSTime sBottleTimerPausedOsTime = 0; OSTime D_801BF8F8[] = { @@ -195,11 +194,10 @@ OSTime D_801BF8F8[] = { OSTime D_801BF930[] = { 0, 0, 0, 0, 0, 0, 0, }; - u8 sIsTimerPaused = false; u8 sIsBottleTimerPaused = false; - s16 sTimerId = TIMER_ID_NONE; + s16 D_801BF974 = 0; s16 D_801BF978 = 10; s16 D_801BF97C = 255; @@ -603,7 +601,7 @@ void Interface_StartTimer(s16 timerId, s16 seconds) { sEnvTimerActive = false; gSaveContext.timerCurTime[timerId] = SECONDS_TO_TIMER(seconds); - gSaveContext.timerCurSubTime[timerId] = gSaveContext.timerCurTime[timerId]; + gSaveContext.timerTimeLimit[timerId] = gSaveContext.timerCurTime[timerId]; if (gSaveContext.timerCurTime[timerId] != SECONDS_TO_TIMER(0)) { gSaveContext.timerDirection[timerId] = TIMER_COUNT_DOWN; @@ -611,7 +609,7 @@ void Interface_StartTimer(s16 timerId, s16 seconds) { gSaveContext.timerDirection[timerId] = TIMER_COUNT_UP; } - gSaveContext.timerState[timerId] = TIMER_STATE_1; + gSaveContext.timerState[timerId] = TIMER_STATE_START; } void Interface_StartPostmanTimer(s16 seconds, s16 bunnyHoodState) { @@ -621,7 +619,7 @@ void Interface_StartPostmanTimer(s16 seconds, s16 bunnyHoodState) { sPostmanBunnyHoodState = bunnyHoodState; gSaveContext.timerCurTime[TIMER_ID_POSTMAN] = SECONDS_TO_TIMER(seconds); - gSaveContext.timerCurSubTime[TIMER_ID_POSTMAN] = gSaveContext.timerCurTime[TIMER_ID_POSTMAN]; + gSaveContext.timerTimeLimit[TIMER_ID_POSTMAN] = gSaveContext.timerCurTime[TIMER_ID_POSTMAN]; if (gSaveContext.timerCurTime[TIMER_ID_POSTMAN] != SECONDS_TO_TIMER(0)) { gSaveContext.timerDirection[TIMER_ID_POSTMAN] = TIMER_COUNT_DOWN; @@ -634,7 +632,7 @@ void Interface_StartPostmanTimer(s16 seconds, s16 bunnyHoodState) { gSaveContext.timerPausedOsTime[TIMER_ID_POSTMAN] = 0; } -// Unused, goron race actually uses TIMER_ID_4 +// Unused, goron race actually uses TIMER_ID_MINIGAME_2 void Interface_StartGoronRaceTimer(s32 arg0) { if (gSaveContext.timerState[TIMER_ID_GORON_RACE_UNUSED] != TIMER_STATE_OFF) { // Goron race started @@ -648,8 +646,8 @@ void Interface_StartGoronRaceTimer(s32 arg0) { void Interface_StartBottleTimer(s16 seconds, s16 timerId) { gSaveContext.bottleTimerState[timerId] = BOTTLE_TIMER_STATE_COUNTING; - gSaveContext.bottleTimerCurTime[timerId] = seconds * 100; - gSaveContext.bottleTimerCurSubTime[timerId] = gSaveContext.bottleTimerCurTime[timerId]; + gSaveContext.bottleTimerCurTime[timerId] = SECONDS_TO_TIMER(seconds); + gSaveContext.bottleTimerCurTimeLimit[timerId] = gSaveContext.bottleTimerCurTime[timerId]; gSaveContext.bottleTimerStartOsTime[timerId] = osGetTime(); gSaveContext.bottleTimerPausedOsTime[timerId] = 0; sBottleTimerPausedOsTime = 0; @@ -5232,12 +5230,10 @@ void Interface_DrawTimers(PlayState* play) { static s16 sTimerStateTimer = 0; static s16 sTimerDigits[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static s16 sTimerBeepSfxSeconds = 99; - static s16 D_801BFCFC[] = { - // timer digit width - 0x10, 0x19, 0x22, 0x2A, 0x33, 0x3C, 0x44, 0x4D, + static s16 sTimerDigitsOffsetX[] = { + 16, 25, 34, 42, 51, 60, 68, 77, }; - static s16 D_801BFD0C[] = { - // digit width + static s16 sTimerDigitsWidth[] = { 9, 9, 8, 9, 9, 8, 9, 9, }; InterfaceContext* interfaceCtx = &play->interfaceCtx; @@ -5263,7 +5259,7 @@ void Interface_DrawTimers(PlayState* play) { osTime = osGetTime(); for (j = 0; j < TIMER_ID_MAX; j++) { - if (gSaveContext.timerState[j] == TIMER_STATE_4) { + if (gSaveContext.timerState[j] == TIMER_STATE_COUNTING) { gSaveContext.timerPausedOsTime[j] = gSaveContext.timerPausedOsTime[j] + (osTime - sTimerPausedOsTime); } @@ -5296,9 +5292,8 @@ void Interface_DrawTimers(PlayState* play) { case TIMER_STATE_POSTMAN_STOP: timerOsTime = gSaveContext.timerOsTime; gSaveContext.timerCurTime[TIMER_ID_POSTMAN] = - (timerOsTime - ((void)0, gSaveContext.timerStartOsTime[TIMER_ID_POSTMAN]) - - ((void)0, gSaveContext.timerPausedOsTime[TIMER_ID_POSTMAN])) * - 64 / 3000 / 10000; + OSTIME_TO_TIMER(timerOsTime - ((void)0, gSaveContext.timerStartOsTime[TIMER_ID_POSTMAN]) - + ((void)0, gSaveContext.timerPausedOsTime[TIMER_ID_POSTMAN])); gSaveContext.timerState[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_END; func_80174F9C(Interface_PostmanTimerCallback, NULL); break; @@ -5312,8 +5307,8 @@ void Interface_DrawTimers(PlayState* play) { // process the remaining timers switch (gSaveContext.timerState[sTimerId]) { - case TIMER_STATE_1: - case TIMER_STATE_9: + case TIMER_STATE_START: + case TIMER_STATE_ALT_START: sTimerStateTimer = 20; if (interfaceCtx->minigameState != MINIGAME_STATE_NONE) { gSaveContext.timerX[sTimerId] = 26; @@ -5328,10 +5323,10 @@ void Interface_DrawTimers(PlayState* play) { if ((interfaceCtx->minigameState == MINIGAME_STATE_COUNTDOWN_GO) || (interfaceCtx->minigameState == MINIGAME_STATE_30)) { - if (gSaveContext.timerState[sTimerId] == TIMER_STATE_1) { - gSaveContext.timerState[sTimerId] = TIMER_STATE_4; + if (gSaveContext.timerState[sTimerId] == TIMER_STATE_START) { + gSaveContext.timerState[sTimerId] = TIMER_STATE_COUNTING; } else { - gSaveContext.timerState[sTimerId] = TIMER_STATE_11; + gSaveContext.timerState[sTimerId] = TIMER_STATE_ALT_COUNTING; D_801BF8F8[sTimerId] = osGetTime(); D_801BF930[sTimerId] = 0; } @@ -5341,11 +5336,11 @@ void Interface_DrawTimers(PlayState* play) { gSaveContext.timerPausedOsTime[sTimerId] = 0; } } else { - gSaveContext.timerState[sTimerId] = TIMER_STATE_2; + gSaveContext.timerState[sTimerId] = TIMER_STATE_HOLD_TIMER; } break; - case TIMER_STATE_2: + case TIMER_STATE_HOLD_TIMER: sTimerStateTimer--; if (sTimerStateTimer == 0) { sTimerStateTimer = 20; @@ -5384,14 +5379,15 @@ void Interface_DrawTimers(PlayState* play) { } } - gSaveContext.timerState[sTimerId] = TIMER_STATE_4; + gSaveContext.timerState[sTimerId] = TIMER_STATE_COUNTING; gSaveContext.timerStartOsTime[sTimerId] = osGetTime(); gSaveContext.timerEndOsTime[sTimerId] = 0; gSaveContext.timerPausedOsTime[sTimerId] = 0; } // fallthrough - case TIMER_STATE_4: - if ((gSaveContext.timerState[sTimerId] == TIMER_STATE_4) && (sTimerId == TIMER_ID_FINAL_HOURS)) { + case TIMER_STATE_COUNTING: + if ((gSaveContext.timerState[sTimerId] == TIMER_STATE_COUNTING) && + (sTimerId == TIMER_ID_FINAL_HOURS)) { gSaveContext.timerX[TIMER_ID_FINAL_HOURS] = R_FINAL_HOURS_TIMER_X; gSaveContext.timerY[TIMER_ID_FINAL_HOURS] = R_FINAL_HOURS_TIMER_Y; } @@ -5400,9 +5396,9 @@ void Interface_DrawTimers(PlayState* play) { case TIMER_STATE_10: D_801BF8F8[sTimerId] = osGetTime(); D_801BF930[sTimerId] = 0; - gSaveContext.timerState[sTimerId] = TIMER_STATE_11; + gSaveContext.timerState[sTimerId] = TIMER_STATE_ALT_COUNTING; // fallthrough - case TIMER_STATE_11: + case TIMER_STATE_ALT_COUNTING: D_801BF930[sTimerId] = osGetTime() - D_801BF8F8[sTimerId]; break; @@ -5412,13 +5408,13 @@ void Interface_DrawTimers(PlayState* play) { gSaveContext.timerPausedOsTime[sTimerId] = gSaveContext.timerPausedOsTime[sTimerId] + osTime - D_801BF8F8[sTimerId]; D_801BF930[sTimerId] = 0; - gSaveContext.timerState[sTimerId] = TIMER_STATE_4; + gSaveContext.timerState[sTimerId] = TIMER_STATE_COUNTING; break; case TIMER_STATE_ENV_START: gSaveContext.timerCurTime[sTimerId] = SECONDS_TO_TIMER(gSaveContext.save.playerData.health >> 1); gSaveContext.timerDirection[sTimerId] = TIMER_COUNT_DOWN; - gSaveContext.timerCurSubTime[sTimerId] = gSaveContext.timerCurTime[sTimerId]; + gSaveContext.timerTimeLimit[sTimerId] = gSaveContext.timerCurTime[sTimerId]; sTimerStateTimer = 20; gSaveContext.timerState[sTimerId] = TIMER_STATE_MOVING_TIMER; break; @@ -5427,9 +5423,8 @@ void Interface_DrawTimers(PlayState* play) { osTime = osGetTime(); gSaveContext.timerEndOsTime[sTimerId] = - (osTime - ((void)0, gSaveContext.timerStartOsTime[sTimerId]) - - ((void)0, gSaveContext.timerPausedOsTime[sTimerId])) * - 64 / 3000 / 10000; + OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerStartOsTime[sTimerId]) - + ((void)0, gSaveContext.timerPausedOsTime[sTimerId])); gSaveContext.timerState[sTimerId] = TIMER_STATE_OFF; @@ -5455,9 +5450,8 @@ void Interface_DrawTimers(PlayState* play) { osTime = osGetTime(); gSaveContext.timerEndOsTime[sTimerId] = - (osTime - ((void)0, gSaveContext.timerStartOsTime[sTimerId]) - - ((void)0, gSaveContext.timerPausedOsTime[sTimerId])) * - 64 / 3000 / 10000; + OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerStartOsTime[sTimerId]) - + ((void)0, gSaveContext.timerPausedOsTime[sTimerId])); if ((gSaveContext.minigameState == 1) && (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { @@ -5491,14 +5485,13 @@ void Interface_DrawTimers(PlayState* play) { // used to index the counter colon sTimerDigits[2] = sTimerDigits[5] = 10; - if ((gSaveContext.timerState[sTimerId] == TIMER_STATE_4) || + if ((gSaveContext.timerState[sTimerId] == TIMER_STATE_COUNTING) || (gSaveContext.timerState[sTimerId] == TIMER_STATE_10) || - (gSaveContext.timerState[sTimerId] == TIMER_STATE_11) || + (gSaveContext.timerState[sTimerId] == TIMER_STATE_ALT_COUNTING) || (gSaveContext.timerState[sTimerId] == TIMER_STATE_POSTMAN_COUNTING)) { osTime = osGetTime(); - osTime = (osTime - ((void)0, gSaveContext.timerPausedOsTime[sTimerId]) - D_801BF930[sTimerId] - - ((void)0, gSaveContext.timerStartOsTime[sTimerId])) * - 64 / 3000 / 10000; + osTime = OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerPausedOsTime[sTimerId]) - + D_801BF930[sTimerId] - ((void)0, gSaveContext.timerStartOsTime[sTimerId])); } else if (gSaveContext.timerState[sTimerId] == TIMER_STATE_7) { osTime = gSaveContext.timerEndOsTime[sTimerId]; } else { @@ -5506,12 +5499,12 @@ void Interface_DrawTimers(PlayState* play) { } if (osTime == 0) { - gSaveContext.timerCurTime[sTimerId] = gSaveContext.timerCurSubTime[sTimerId] - osTime; - } else if (gSaveContext.timerCurSubTime[sTimerId] >= osTime) { - if (gSaveContext.timerCurSubTime[sTimerId] <= osTime) { + gSaveContext.timerCurTime[sTimerId] = gSaveContext.timerTimeLimit[sTimerId] - osTime; + } else if (osTime <= gSaveContext.timerTimeLimit[sTimerId]) { + if (osTime >= gSaveContext.timerTimeLimit[sTimerId]) { gSaveContext.timerCurTime[sTimerId] = SECONDS_TO_TIMER(0); } else { - gSaveContext.timerCurTime[sTimerId] = gSaveContext.timerCurSubTime[sTimerId] - osTime; + gSaveContext.timerCurTime[sTimerId] = gSaveContext.timerTimeLimit[sTimerId] - osTime; } } else { gSaveContext.timerCurTime[sTimerId] = SECONDS_TO_TIMER(0); @@ -5546,12 +5539,12 @@ void Interface_DrawTimers(PlayState* play) { // used to index the counter colon sTimerDigits[2] = sTimerDigits[5] = 10; - if ((gSaveContext.timerState[sTimerId] == TIMER_STATE_4) || + if ((gSaveContext.timerState[sTimerId] == TIMER_STATE_COUNTING) || (gSaveContext.timerState[sTimerId] == TIMER_STATE_POSTMAN_COUNTING)) { osTime = osGetTime(); - osTime = (osTime - ((void)0, gSaveContext.timerStartOsTime[sTimerId]) - - ((void)0, gSaveContext.timerPausedOsTime[sTimerId]) - D_801BF930[sTimerId]) * - 64 / 3000 / 10000; + osTime = + OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerStartOsTime[sTimerId]) - + ((void)0, gSaveContext.timerPausedOsTime[sTimerId]) - D_801BF930[sTimerId]); } else if (gSaveContext.timerState[sTimerId] == TIMER_STATE_7) { osTime = gSaveContext.timerEndOsTime[sTimerId]; } else if (sTimerId == TIMER_ID_POSTMAN) { @@ -5575,7 +5568,8 @@ void Interface_DrawTimers(PlayState* play) { // Use seconds to determine when to beep if ((gSaveContext.minigameState == 1) && (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { - if ((gSaveContext.timerCurTime[sTimerId] > 11000) && (sTimerBeepSfxSeconds != sTimerDigits[4])) { + if ((gSaveContext.timerCurTime[sTimerId] > SECONDS_TO_TIMER(110)) && + (sTimerBeepSfxSeconds != sTimerDigits[4])) { play_sound(NA_SE_SY_WARNING_COUNT_E); sTimerBeepSfxSeconds = sTimerDigits[4]; } @@ -5604,7 +5598,7 @@ void Interface_DrawTimers(PlayState* play) { if (gSaveContext.timerState[sTimerId]) { // != TIMER_STATE_OFF if (sTimerId == TIMER_ID_2) { if ((gSaveContext.timerCurTime[sTimerId] == SECONDS_TO_TIMER(0)) || - (gSaveContext.timerState[sTimerId] == TIMER_STATE_4)) { + (gSaveContext.timerState[sTimerId] == TIMER_STATE_COUNTING)) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); } else { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); @@ -5629,7 +5623,7 @@ void Interface_DrawTimers(PlayState* play) { } } else if ((gSaveContext.timerCurTime[sTimerId] < SECONDS_TO_TIMER(10)) && (gSaveContext.timerDirection[sTimerId] == TIMER_COUNT_DOWN) && - (gSaveContext.timerState[sTimerId] != TIMER_STATE_11)) { + (gSaveContext.timerState[sTimerId] != TIMER_STATE_ALT_COUNTING)) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); } else { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); @@ -5643,25 +5637,25 @@ void Interface_DrawTimers(PlayState* play) { for (j = 0; j < 4; j++) { OVERLAY_DISP = Gfx_TextureI8( OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * sTimerDigits[j + 3])), 8, 0x10, - ((void)0, gSaveContext.timerX[sTimerId]) + D_801BFCFC[j], - ((void)0, gSaveContext.timerY[sTimerId]), D_801BFD0C[j], 0xFA, 0x370, 0x370); + ((void)0, gSaveContext.timerX[sTimerId]) + sTimerDigitsOffsetX[j], + ((void)0, gSaveContext.timerY[sTimerId]), sTimerDigitsWidth[j], 0xFA, 0x370, 0x370); } } else { // draw sTimerDigits[3] (10s of seconds) to sTimerDigits[7] (10s of milliseconds) for (j = 0; j < 5; j++) { OVERLAY_DISP = Gfx_TextureI8( OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * sTimerDigits[j + 3])), 8, 0x10, - ((void)0, gSaveContext.timerX[sTimerId]) + D_801BFCFC[j], - ((void)0, gSaveContext.timerY[sTimerId]), D_801BFD0C[j], 0xFA, 0x370, 0x370); + ((void)0, gSaveContext.timerX[sTimerId]) + sTimerDigitsOffsetX[j], + ((void)0, gSaveContext.timerY[sTimerId]), sTimerDigitsWidth[j], 0xFA, 0x370, 0x370); } } } else { // draw sTimerDigits[3] (6s of minutes) to sTimerDigits[7] (10s of milliseconds) for (j = 0; j < 8; j++) { - OVERLAY_DISP = - Gfx_TextureI8(OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * sTimerDigits[j])), 8, 0x10, - ((void)0, gSaveContext.timerX[sTimerId]) + D_801BFCFC[j], - ((void)0, gSaveContext.timerY[sTimerId]), D_801BFD0C[j], 0xFA, 0x370, 0x370); + OVERLAY_DISP = Gfx_TextureI8( + OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * sTimerDigits[j])), 8, 0x10, + ((void)0, gSaveContext.timerX[sTimerId]) + sTimerDigitsOffsetX[j], + ((void)0, gSaveContext.timerY[sTimerId]), sTimerDigitsWidth[j], 0xFA, 0x370, 0x370); } } } @@ -5708,18 +5702,15 @@ void Interface_UpdateBottleTimers(PlayState* play) { for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { if (gSaveContext.bottleTimerState[i] == BOTTLE_TIMER_STATE_COUNTING) { osTime = osGetTime(); - osTime = (((osTime - ((void)0, gSaveContext.bottleTimerPausedOsTime[i]) - - ((void)0, gSaveContext.bottleTimerStartOsTime[i])) / - 10000) * - 64) / - 3000; + osTime = OSTIME_TO_TIMER_ALT(osTime - ((void)0, gSaveContext.bottleTimerPausedOsTime[i]) - + ((void)0, gSaveContext.bottleTimerStartOsTime[i])); if (osTime == 0) { - gSaveContext.bottleTimerCurTime[i] = gSaveContext.bottleTimerCurSubTime[i] - osTime; - } else if (gSaveContext.bottleTimerCurSubTime[i] >= osTime) { - if (gSaveContext.bottleTimerCurSubTime[i] <= osTime) { + gSaveContext.bottleTimerCurTime[i] = gSaveContext.bottleTimerCurTimeLimit[i] - osTime; + } else if (osTime <= gSaveContext.bottleTimerCurTimeLimit[i]) { + if (osTime >= gSaveContext.bottleTimerCurTimeLimit[i]) { gSaveContext.bottleTimerCurTime[i] = 0; } else { - gSaveContext.bottleTimerCurTime[i] = gSaveContext.bottleTimerCurSubTime[i] - osTime; + gSaveContext.bottleTimerCurTime[i] = gSaveContext.bottleTimerCurTimeLimit[i] - osTime; } } else { gSaveContext.bottleTimerCurTime[i] = 0; @@ -6664,7 +6655,7 @@ void Interface_Update(PlayState* play) { } } } else if (((sEnvTimerType == PLAYER_ENV_TIMER_NONE) || (sEnvTimerType == PLAYER_ENV_TIMER_SWIMMING)) && - (gSaveContext.timerState[TIMER_ID_ENV] <= TIMER_STATE_4)) { + (gSaveContext.timerState[TIMER_ID_ENV] <= TIMER_STATE_COUNTING)) { gSaveContext.timerState[TIMER_ID_ENV] = TIMER_STATE_OFF; } @@ -6829,13 +6820,13 @@ void Interface_Init(PlayState* play) { Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_RIGHT); } - if (((gSaveContext.timerState[TIMER_ID_4] == TIMER_STATE_4) || - (gSaveContext.timerState[TIMER_ID_GORON_RACE_UNUSED] == TIMER_STATE_4)) && + if (((gSaveContext.timerState[TIMER_ID_MINIGAME_2] == TIMER_STATE_COUNTING) || + (gSaveContext.timerState[TIMER_ID_GORON_RACE_UNUSED] == TIMER_STATE_COUNTING)) && ((gSaveContext.respawnFlag == -1) || (gSaveContext.respawnFlag == 1)) && - (gSaveContext.timerState[TIMER_ID_4] == TIMER_STATE_4)) { - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_1; - gSaveContext.timerX[TIMER_ID_4] = 115; - gSaveContext.timerY[TIMER_ID_4] = 80; + (gSaveContext.timerState[TIMER_ID_MINIGAME_2] == TIMER_STATE_COUNTING)) { + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_START; + gSaveContext.timerX[TIMER_ID_MINIGAME_2] = 115; + gSaveContext.timerY[TIMER_ID_MINIGAME_2] = 80; } LifeMeter_Init(play); @@ -6848,15 +6839,15 @@ void Interface_Init(PlayState* play) { if (gSaveContext.eventInf[3] & 0x10) { gSaveContext.eventInf[3] &= (u8)~0x10; - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_OFF; + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; } - gSaveContext.timerState[TIMER_ID_1] = TIMER_STATE_OFF; - gSaveContext.timerCurTime[TIMER_ID_1] = SECONDS_TO_TIMER(0); - gSaveContext.timerCurSubTime[TIMER_ID_1] = SECONDS_TO_TIMER(0); - gSaveContext.timerStartOsTime[TIMER_ID_1] = 0; - gSaveContext.timerEndOsTime[TIMER_ID_1] = 0; - gSaveContext.timerPausedOsTime[TIMER_ID_1] = 0; + gSaveContext.timerState[TIMER_ID_MINIGAME_1] = TIMER_STATE_OFF; + gSaveContext.timerCurTime[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerTimeLimit[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerStartOsTime[TIMER_ID_MINIGAME_1] = 0; + gSaveContext.timerEndOsTime[TIMER_ID_MINIGAME_1] = 0; + gSaveContext.timerPausedOsTime[TIMER_ID_MINIGAME_1] = 0; for (i = 0; i < TIMER_ID_MAX; i++) { if (gSaveContext.timerState[i] == TIMER_STATE_7) { diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 09c20d507..61167cb7e 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -897,7 +897,7 @@ void func_80144A94(SramContext* sramCtx) { for (i = 0; i < ARRAY_COUNT(gSaveContext.timerState); i++) { gSaveContext.timerState[i] = TIMER_STATE_OFF; gSaveContext.timerCurTime[i] = SECONDS_TO_TIMER(0); - gSaveContext.timerCurSubTime[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerTimeLimit[i] = SECONDS_TO_TIMER(0); gSaveContext.timerStartOsTime[i] = 0; gSaveContext.timerEndOsTime[i] = 0; gSaveContext.timerPausedOsTime[i] = 0; @@ -972,7 +972,7 @@ void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { for (i = 0; i < ARRAY_COUNT(gSaveContext.timerState); i++) { gSaveContext.timerState[i] = TIMER_STATE_OFF; gSaveContext.timerCurTime[i] = SECONDS_TO_TIMER(0); - gSaveContext.timerCurSubTime[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerTimeLimit[i] = SECONDS_TO_TIMER(0); gSaveContext.timerStartOsTime[i] = 0; gSaveContext.timerEndOsTime[i] = 0; gSaveContext.timerPausedOsTime[i] = 0; @@ -1602,7 +1602,7 @@ void func_80147068(SramContext* sramCtx) { sramCtx->status = 4; } } - } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + } else if (OSTIME_TO_TIMER(osGetTime() - sramCtx->unk_18) >= SECONDS_TO_TIMER(2)) { sramCtx->status = 0; } } @@ -1639,7 +1639,7 @@ void func_80147198(SramContext* sramCtx) { sramCtx->status = 4; } } - } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + } else if (OSTIME_TO_TIMER(osGetTime() - sramCtx->unk_18) >= SECONDS_TO_TIMER(2)) { sramCtx->status = 0; bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); gSaveContext.save.isOwlSave = false; diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index 69f5082ae..babc32728 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -216,7 +216,7 @@ void EnDno_Init(Actor* thisx, PlayState* play) { } else { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); thisx->room = -1; - gSaveContext.timerState[TIMER_ID_1] = TIMER_STATE_STOP; + gSaveContext.timerState[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); this->unk_3B0 |= 1; this->actionFunc = func_80A72438; @@ -817,7 +817,7 @@ void func_80A73244(EnDno* this, PlayState* play) { this->unk_328 = 2; this->actor.speedXZ = 0.0f; Flags_UnsetSwitch(play, ENDNO_GET_3F80(&this->actor)); - gSaveContext.timerState[TIMER_ID_1] = TIMER_STATE_STOP; + gSaveContext.timerState[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->unk_44E = 0; this->actionFunc = func_80A732C8; } 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 92126dfdf..eae76da51 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -401,7 +401,8 @@ void func_80962340(EnFu* this, PlayState* play) { Message_StartTextbox(play, 0x287E, &this->actor); this->unk_552 = 0x287E; } - } else if ((gSaveContext.timerCurTime[TIMER_ID_4] == SECONDS_TO_TIMER(0)) && (this->unk_552 != 0x2888)) { + } else if ((gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] == SECONDS_TO_TIMER(0)) && + (this->unk_552 != 0x2888)) { Message_StartTextbox(play, 0x2886, &this->actor); this->unk_552 = 0x2886; } else { @@ -644,7 +645,7 @@ void func_80962A10(EnFu* this, PlayState* play) { play_sound(NA_SE_SY_FOUND); player->stateFlags1 &= ~0x20; - Interface_StartTimer(TIMER_ID_4, 60); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 60); if (this->unk_546 == 1) { func_809616E0(this, play); } else { @@ -682,7 +683,7 @@ void func_80962BCC(EnFu* this, PlayState* play) { play_sound(NA_SE_SY_FOUND); player->stateFlags1 &= ~0x20; player->stateFlags3 |= 0x400000; - Interface_StartTimer(TIMER_ID_4, 60); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 60); if (this->unk_546 == 1) { func_809616E0(this, play); @@ -713,7 +714,7 @@ void func_80962D60(EnFu* this, PlayState* play) { play_sound(NA_SE_SY_FOUND); player->stateFlags1 &= ~0x20; player->stateFlags3 |= 0x400000; - Interface_StartTimer(TIMER_ID_4, 60); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 60); if (this->unk_546 == 1) { func_809616E0(this, play); @@ -761,11 +762,11 @@ void func_80962F4C(EnFu* this, PlayState* play) { break; } - if (gSaveContext.timerCurTime[TIMER_ID_4] < SECONDS_TO_TIMER(20)) { + if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] < SECONDS_TO_TIMER(20)) { s16 val = D_80964B00[this->unk_542] + 200; Math_SmoothStepToS(&fuKaiten->rotationSpeed, val, 10, 5, 5); - } else if (gSaveContext.timerCurTime[TIMER_ID_4] < SECONDS_TO_TIMER(40)) { + } else if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] < SECONDS_TO_TIMER(40)) { s16 val = D_80964B00[this->unk_542] + 100; Math_SmoothStepToS(&fuKaiten->rotationSpeed, val, 10, 5, 5); @@ -777,12 +778,12 @@ void func_80962F4C(EnFu* this, PlayState* play) { if ((!DynaPolyActor_IsInRidingRotatingState((DynaPolyActor*)this->actor.child) && (player->actor.bgCheckFlags & 1)) || - (gSaveContext.timerCurTime[TIMER_ID_4] <= SECONDS_TO_TIMER(0)) || (this->unk_548 == this->unk_54C)) { + (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] <= SECONDS_TO_TIMER(0)) || (this->unk_548 == this->unk_54C)) { player->stateFlags3 &= ~0x400000; func_80961E88(play); player->stateFlags1 |= 0x20; if (this->unk_548 < this->unk_54C) { - if (gSaveContext.timerCurTime[TIMER_ID_4] == SECONDS_TO_TIMER(0)) { + if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] == SECONDS_TO_TIMER(0)) { Message_StartTextbox(play, 0x2885, &this->actor); this->unk_552 = 0x2885; } else { @@ -790,15 +791,15 @@ void func_80962F4C(EnFu* this, PlayState* play) { this->unk_552 = 0x2888; } func_801A2C20(); - gSaveContext.timerCurTime[TIMER_ID_4] = SECONDS_TO_TIMER(0); - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_STOP; + gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0); + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; this->unk_548 = 0; func_809632D0(this); } else { this->unk_548 = 0; func_801A2C20(); - gSaveContext.timerCurTime[TIMER_ID_4] = SECONDS_TO_TIMER(0); - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_STOP; + gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0); + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; func_801A3098(NA_BGM_GET_ITEM | 0x900); Interface_SetPerfectMinigame(play, 1); this->unk_54A = 3; diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c index 8c9956ca9..f489f766a 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -459,7 +459,7 @@ void func_80B10240(EnGb2* this, PlayState* play) { D_80B119B0[this->unk_280].unk_04.y, D_80B119B0[this->unk_280].unk_04.z, 0, 0, 0, this->unk_27E); if (this->unk_280 == 0) { - Interface_StartTimer(TIMER_ID_1, 180); + Interface_StartTimer(TIMER_ID_MINIGAME_1, 180); } this->actionFunc = func_80B10344; } else { @@ -487,7 +487,7 @@ void func_80B10344(EnGb2* this, PlayState* play) { if (this->unk_26C & 0x200) { if (this->unk_280 == 3) { this->unk_26C &= ~0x200; - gSaveContext.timerState[TIMER_ID_1] = TIMER_STATE_STOP; + gSaveContext.timerState[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; func_800FE498(); gSaveContext.eventInf[4] |= 0x40; func_80B0FE7C(play); @@ -506,7 +506,7 @@ void func_80B10344(EnGb2* this, PlayState* play) { } if (gSaveContext.save.playerData.health < 49) { - gSaveContext.timerState[TIMER_ID_1] = TIMER_STATE_STOP; + gSaveContext.timerState[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; gSaveContext.eventInf[4] |= 0x40; gSaveContext.eventInf[4] |= 0x20; @@ -519,8 +519,8 @@ void func_80B10344(EnGb2* this, PlayState* play) { } func_80B0FE7C(play); - } else if (gSaveContext.timerCurTime[TIMER_ID_1] == SECONDS_TO_TIMER(0)) { - gSaveContext.timerState[TIMER_ID_1] = TIMER_STATE_STOP; + } else if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { + gSaveContext.timerState[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; gSaveContext.eventInf[4] |= 0x40; gSaveContext.eventInf[4] |= 0x10; 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 129595b28..50da9c4db 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 @@ -121,7 +121,7 @@ s32 func_808F8CCC(EnHorseGameCheck* this, PlayState* play2) { return false; } - Interface_StartTimer(TIMER_ID_4, 0); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); play->interfaceCtx.minigameState = 1; this->horse1 = (EnHorse*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, -1149.0f, -106.0f, 470.0f, 0, 0x7FFF, 0, @@ -145,7 +145,7 @@ s32 func_808F8CCC(EnHorseGameCheck* this, PlayState* play2) { } s32 func_808F8E94(EnHorseGameCheck* this, PlayState* play) { - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_OFF; + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; return true; } @@ -247,11 +247,11 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { return true; } - if (gSaveContext.timerCurTime[TIMER_ID_4] >= SECONDS_TO_TIMER(180)) { + if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(180)) { Audio_QueueSeqCmd(0x8041); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_6; + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; SET_RACE_FLAGS(RACE_FLAG_4); this->unk_174 = 60; } @@ -284,7 +284,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { Audio_QueueSeqCmd(0x8041); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_6; + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; SET_RACE_FLAGS(RACE_FLAG_3); this->unk_174 = 60; } @@ -317,7 +317,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { Audio_QueueSeqCmd(0x8041); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x02000000; - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_6; + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; SET_RACE_FLAGS(RACE_FLAG_3); this->unk_174 = 60; } @@ -346,7 +346,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { Audio_QueueSeqCmd(0x8041); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x800; - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_6; + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; SET_RACE_FLAGS(RACE_FLAG_2); this->unk_174 = 60; } 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 9eef37c08..c24c03360 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 @@ -155,7 +155,7 @@ void func_80C13BB8(EnJgameTsn* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->actor.flags & ACTOR_FLAG_10000) { this->actor.flags &= ~ACTOR_FLAG_10000; - if (gSaveContext.timerCurTime[TIMER_ID_4] > SECONDS_TO_TIMER(0)) { + if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] > SECONDS_TO_TIMER(0)) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); Message_StartTextbox(play, 0x10A2, &this->actor); this->unk_300 = 0x10A2; @@ -287,7 +287,7 @@ void func_80C1410C(EnJgameTsn* this, PlayState* play) { play->interfaceCtx.minigameState = 1; Interface_InitMinigame(play); gSaveContext.save.weekEventReg[90] |= 0x20; - Interface_StartTimer(TIMER_ID_4, 120); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 120); this->actionFunc = func_80C1418C; } @@ -352,7 +352,7 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) { func_80C14030(this); } - if (gSaveContext.timerCurTime[TIMER_ID_4] == SECONDS_TO_TIMER(0)) { + if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] == SECONDS_TO_TIMER(0)) { Message_StartTextbox(play, 0x10A1, &this->actor); this->unk_300 = 0x10A1; player->stateFlags1 |= 0x20; @@ -479,7 +479,7 @@ void func_80C147B4(EnJgameTsn* this, PlayState* play) { case 0x10A1: func_801477B4(play); gSaveContext.minigameState = 3; - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_STOP; + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; gSaveContext.save.weekEventReg[90] &= (u8)~0x20; func_80C144E4(this); break; 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 abb37120b..687d3ca50 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -674,7 +674,7 @@ void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, PlayState* play) { // "You're feeling confident" Message_StartTextbox(play, 0x336E, &this->actor); this->actionFunc = EnMa4_HorsebackGameTalking; - } else if (gSaveContext.timerCurTime[TIMER_ID_4] < SECONDS_TO_TIMER(115)) { + } else if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] < SECONDS_TO_TIMER(115)) { func_800B8614(&this->actor, play, 100.0f); } } @@ -689,7 +689,7 @@ void EnMa4_InitHorsebackGame(EnMa4* this, PlayState* play) { Player* player = GET_PLAYER(play); play->interfaceCtx.minigameState = 1; - Interface_StartTimer(TIMER_ID_4, 0); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); gSaveContext.save.weekEventReg[8] |= 1; Interface_InitMinigame(play); player->stateFlags1 |= 0x20; @@ -717,8 +717,9 @@ void EnMa4_HorsebackGameWait(EnMa4* this, PlayState* play) { play->interfaceCtx.unk_25C = 1; } - if ((gSaveContext.timerCurTime[TIMER_ID_4] >= SECONDS_TO_TIMER(120)) || (this->poppedBalloonCounter == 10)) { - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_6; + if ((gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) || + (this->poppedBalloonCounter == 10)) { + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; EnMa4_SetupHorsebackGameEnd(this, play); D_80AC0258 = 0; } @@ -897,13 +898,13 @@ void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { gSaveContext.save.weekEventReg[21] |= 0x40; } } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { - if (gSaveContext.timerCurTime[TIMER_ID_4] >= SECONDS_TO_TIMER(120)) { + if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) { // "Too bad Grasshopper" EnMa4_SetFaceExpression(this, 0, 0); Message_StartTextbox(play, 0x336D, &this->actor); this->textId = 0x336D; } else { - time = gSaveContext.timerCurTime[TIMER_ID_4]; + time = gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2]; if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // [Score] New record! gSaveContext.save.horseBackBalloonHighScore = time; @@ -942,12 +943,12 @@ void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { Message_StartTextbox(play, 0x3354, &this->actor); this->textId = 0x3354; } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { - if (gSaveContext.timerCurTime[TIMER_ID_4] >= SECONDS_TO_TIMER(120)) { + if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) { // "Try again?" Message_StartTextbox(play, 0x3356, &this->actor); this->textId = 0x3356; } else { - time = gSaveContext.timerCurTime[TIMER_ID_4]; + time = gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2]; if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { gSaveContext.save.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); @@ -969,12 +970,12 @@ void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { Message_StartTextbox(play, 0x3358, &this->actor); this->textId = 0x3358; } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { - if (gSaveContext.timerCurTime[TIMER_ID_4] >= SECONDS_TO_TIMER(120)) { + if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) { // "Try again?" Message_StartTextbox(play, 0x3356, &this->actor); this->textId = 0x3356; } else { - time = gSaveContext.timerCurTime[TIMER_ID_4]; + time = gSaveContext.timerCurTime[TIMER_ID_MINIGAME_2]; if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // New record gSaveContext.save.horseBackBalloonHighScore = time; 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 d81e74836..a7313f808 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 @@ -253,7 +253,7 @@ s32 EnMttag_ExitRace(PlayState* play, s32 transitionType, s32 nextTransitionType * Displays the text which says that the player has made a false start. */ void EnMttag_ShowFalseStartMessage(EnMttag* this, PlayState* play) { - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_OFF; + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; Message_StartTextbox(play, 0xE95, NULL); // An entrant made a false start func_800B7298(play, &this->actor, 7); Audio_QueueSeqCmd(0x101400FF); @@ -314,7 +314,7 @@ void EnMttag_RaceStart(EnMttag* this, PlayState* play) { gSaveContext.eventInf[1] |= 8; } else { if (DECR(this->timer) == 60) { - Interface_StartTimer(TIMER_ID_4, 0); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); play->interfaceCtx.minigameState = 1; Audio_QueueSeqCmd(NA_BGM_GORON_RACE | 0x8000); play->envCtx.unk_E4 = 0xFE; @@ -359,14 +359,14 @@ void EnMttag_Race(EnMttag* this, PlayState* play) { s32 playerCheatStatus; if (EnMttag_IsInFinishLine(playerPos)) { - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_6; + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; play_sound(NA_SE_SY_START_SHOT); Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); this->timer = 55; gSaveContext.eventInf[1] |= 2; this->actionFunc = EnMttag_RaceFinish; } else if (EnMttag_IsAnyRaceGoronOverFinishLine(this)) { - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_6; + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; play_sound(NA_SE_SY_START_SHOT); Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); this->timer = 55; @@ -457,7 +457,7 @@ void EnMttag_HandleCantWinChoice(EnMttag* this, PlayState* play) { if (play->msgCtx.choiceIndex != 0) { // Exit the race func_8019F230(); - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_OFF; + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; EnMttag_ExitRace(play, TRANS_TYPE_02, TRANS_TYPE_02); gSaveContext.eventInf[1] &= (u8)~8; gSaveContext.eventInf[1] |= 4; @@ -503,8 +503,8 @@ void EnMttag_Init(Actor* thisx, PlayState* play) { void EnMttag_Destroy(Actor* thisx, PlayState* play) { EnMttag* this = THIS; - if (gSaveContext.timerState[TIMER_ID_4] != TIMER_STATE_6) { - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_STOP; + if (gSaveContext.timerState[TIMER_ID_MINIGAME_2] != TIMER_STATE_6) { + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; } } diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 65200e44e..b87244aaf 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -271,7 +271,7 @@ void func_80A2C2E0(EnSyatekiDekunuts* this, PlayState* play) { void func_80A2C33C(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((gSaveContext.timerCurTime[TIMER_ID_1] <= SECONDS_TO_TIMER(0)) || + if ((gSaveContext.timerCurTime[TIMER_ID_MINIGAME_1] <= SECONDS_TO_TIMER(0)) || (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { func_80A2C3AC(this); } 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 05471caef..85ebfb3a4 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 @@ -1012,7 +1012,7 @@ void EnSyatekiMan_Swamp_StartGame(EnSyatekiMan* this, PlayState* play) { this->guayHitCounter = 0; this->currentWave = 0; this->perGameVar2.bonusDekuScrubHitCounter = 0; - Interface_StartTimer(TIMER_ID_1, 100); + Interface_StartTimer(TIMER_ID_MINIGAME_1, 100); this->actor.draw = NULL; this->actionFunc = EnSyatekiMan_Swamp_RunGame; } @@ -1061,9 +1061,9 @@ void EnSyatekiMan_Swamp_RunGame(EnSyatekiMan* this, PlayState* play) { this->perGameVar1.guaySpawnTimer++; - if (gSaveContext.timerCurTime[TIMER_ID_1] == SECONDS_TO_TIMER(0)) { - gSaveContext.timerCurTime[TIMER_ID_1] = SECONDS_TO_TIMER(0); - gSaveContext.timerState[TIMER_ID_1] = TIMER_STATE_STOP; + if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { + gSaveContext.timerCurTime[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerState[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->actor.draw = EnSyatekiMan_Draw; this->flagsIndex = 0; this->currentWave = 0; @@ -1082,10 +1082,10 @@ void EnSyatekiMan_Swamp_RunGame(EnSyatekiMan* this, PlayState* play) { this->shootingGameState = SG_GAME_STATE_GIVING_BONUS; if (this->score == 2120) { Interface_SetPerfectMinigame(play, 2); - gSaveContext.timerState[TIMER_ID_1] = TIMER_STATE_6; + gSaveContext.timerState[TIMER_ID_MINIGAME_1] = TIMER_STATE_6; this->actionFunc = EnSyatekiMan_Swamp_AddBonusPoints; } else { - gSaveContext.timerState[TIMER_ID_1] = TIMER_STATE_STOP; + gSaveContext.timerState[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->actionFunc = EnSyatekiMan_Swamp_EndGame; } } @@ -1148,15 +1148,15 @@ void EnSyatekiMan_Swamp_AddBonusPoints(EnSyatekiMan* this, PlayState* play) { player->stateFlags1 |= 0x20; if (!play->interfaceCtx.isMinigamePerfect) { - if (gSaveContext.timerCurTime[TIMER_ID_1] == SECONDS_TO_TIMER(0)) { - gSaveContext.timerCurTime[TIMER_ID_1] = SECONDS_TO_TIMER(0); - gSaveContext.timerState[TIMER_ID_1] = TIMER_STATE_STOP; + if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { + gSaveContext.timerCurTime[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerState[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->flagsIndex = 0; this->currentWave = 0; this->actionFunc = EnSyatekiMan_Swamp_EndGame; sBonusTimer = 0; } else if (sBonusTimer > 10) { - gSaveContext.timerEndOsTime[TIMER_ID_1] += 100; + gSaveContext.timerEndOsTime[TIMER_ID_MINIGAME_1] += 100; play->interfaceCtx.unk_25C += 10; this->score += 10; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); @@ -1220,7 +1220,7 @@ void EnSyatekiMan_Town_StartGame(EnSyatekiMan* this, PlayState* play) { this->perGameVar1.octorokState = SG_OCTO_STATE_INITIAL; this->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_NONE; sGameStartTimer = 30; - Interface_StartTimer(TIMER_ID_1, 75); + Interface_StartTimer(TIMER_ID_MINIGAME_1, 75); this->actor.draw = NULL; this->actionFunc = EnSyatekiMan_Town_RunGame; } @@ -1292,7 +1292,7 @@ static const s32 sOctorokFlagsPerWave[] = { void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { static s32 sModFromLosingTime = 0; Player* player = GET_PLAYER(play); - s32 timer = (((void)0, gSaveContext.timerCurTime[TIMER_ID_1]) * 0.1f) + 1.0f; // unit is tenths of a second + s32 timer = (((void)0, gSaveContext.timerCurTime[TIMER_ID_MINIGAME_1]) * 0.1f) + 1.0f; // unit is tenths of a second if (timer <= 750) { s32 waveTimer; // unit is hundredths of a second @@ -1302,9 +1302,9 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { // begin hiding. This code will ultimately correct waveTimer such that its value is not affected by // hitting Blue Octoroks. if (sModFromLosingTime == 0) { - waveTimer = ((void)0, gSaveContext.timerCurTime[TIMER_ID_1]) % SECONDS_TO_TIMER(5); + waveTimer = ((void)0, gSaveContext.timerCurTime[TIMER_ID_MINIGAME_1]) % SECONDS_TO_TIMER(5); } else { - waveTimer = (((void)0, gSaveContext.timerCurTime[TIMER_ID_1]) + SECONDS_TO_TIMER_PRECISE(2, 50)) % + waveTimer = (((void)0, gSaveContext.timerCurTime[TIMER_ID_MINIGAME_1]) + SECONDS_TO_TIMER_PRECISE(2, 50)) % SECONDS_TO_TIMER(5); } @@ -1315,7 +1315,7 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { if (this->perGameVar2.octorokHitType != SG_OCTO_HIT_TYPE_NONE) { if (this->perGameVar2.octorokHitType == SG_OCTO_HIT_TYPE_BLUE) { - gSaveContext.timerCurSubTime[TIMER_ID_1] -= SECONDS_TO_TIMER_PRECISE(2, 50); + gSaveContext.timerTimeLimit[TIMER_ID_MINIGAME_1] -= SECONDS_TO_TIMER_PRECISE(2, 50); sModFromLosingTime = (sModFromLosingTime + 25) % 50; } @@ -1337,11 +1337,11 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { } } - if (gSaveContext.timerCurTime[TIMER_ID_1] == SECONDS_TO_TIMER(0)) { + if (gSaveContext.timerCurTime[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { this->flagsIndex = 0; this->perGameVar1.octorokState = SG_OCTO_STATE_HIDING; - gSaveContext.timerCurTime[TIMER_ID_1] = SECONDS_TO_TIMER(0); - gSaveContext.timerState[TIMER_ID_1] = TIMER_STATE_STOP; + gSaveContext.timerCurTime[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerState[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; player->stateFlags1 |= 0x20; sModFromLosingTime = 0; this->actor.draw = EnSyatekiMan_Draw; diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c index 59696baec..8c1e953c6 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c @@ -45,14 +45,14 @@ void ObjRoomtimer_Init(Actor* thisx, PlayState* play) { void ObjRoomtimer_Destroy(Actor* thisx, PlayState* play) { ObjRoomtimer* this = THIS; - if (this->actor.params != 0x1FF && gSaveContext.timerState[TIMER_ID_4] >= TIMER_STATE_1) { - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_STOP; + if (this->actor.params != 0x1FF && gSaveContext.timerState[TIMER_ID_MINIGAME_2] >= TIMER_STATE_START) { + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; } } void func_80973CD8(ObjRoomtimer* this, PlayState* play) { if (this->actor.params != 0x1FF) { - Interface_StartTimer(TIMER_ID_4, this->actor.params); + Interface_StartTimer(TIMER_ID_MINIGAME_2, this->actor.params); } func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_PROP); @@ -62,11 +62,11 @@ void func_80973CD8(ObjRoomtimer* this, PlayState* play) { void func_80973D3C(ObjRoomtimer* this, PlayState* play) { if (Flags_GetClearTemp(play, this->actor.room)) { if (this->actor.params != 0x1FF) { - gSaveContext.timerState[TIMER_ID_4] = TIMER_STATE_STOP; + gSaveContext.timerState[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; } ActorCutscene_SetIntentToPlay(this->actor.cutscene); this->actionFunc = func_80973DE0; - } else if (this->actor.params != 0x1FF && gSaveContext.timerState[TIMER_ID_4] == TIMER_STATE_OFF) { + } else if (this->actor.params != 0x1FF && gSaveContext.timerState[TIMER_ID_MINIGAME_2] == TIMER_STATE_OFF) { play_sound(NA_SE_OC_ABYSS); func_80169EFC(&play->state); Actor_MarkForDeath(&this->actor); diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 6653daacd..7daf61521 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) { for (i = 0; i < ARRAY_COUNT(gSaveContext.timerPausedOsTime); i++) { gSaveContext.timerState[i] = TIMER_STATE_OFF; gSaveContext.timerCurTime[i] = 0; - gSaveContext.timerCurSubTime[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerTimeLimit[i] = SECONDS_TO_TIMER(0); gSaveContext.timerStartOsTime[i] = 0; gSaveContext.timerEndOsTime[i] = 0; gSaveContext.timerPausedOsTime[i] = 0; diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index c8e1781ae..4a8f47044 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -1164,8 +1164,8 @@ 0x801BFCE4:("sTimerStateTimer","UNK_TYPE4","",0x4), 0x801BFCE8:("sTimerDigits","u16","[8]",0x10), 0x801BFCF8:("sTimerBeepSfxSeconds","UNK_TYPE4","",0x4), - 0x801BFCFC:("D_801BFCFC","UNK_TYPE4","",0x4), - 0x801BFD0C:("D_801BFD0C","UNK_TYPE4","",0x4), + 0x801BFCFC:("sTimerDigitsOffsetX","UNK_TYPE4","",0x4), + 0x801BFD0C:("sTimerDigitsWidth","UNK_TYPE4","",0x4), 0x801BFD1C:("D_801BFD1C","UNK_TYPE1","",0x1), 0x801BFD24:("D_801BFD24","UNK_TYPE1","",0x1), 0x801BFD2C:("D_801BFD2C","UNK_TYPE1","",0x1),