summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorengineer124 <47598039+engineer124@users.noreply.github.com>2023-11-27 20:04:54 +1100
committerGitHub <noreply@github.com>2023-11-27 20:04:54 +1100
commitc04aaab6a1d0bdaf6071fadc649385fd3e71e774 (patch)
tree0ecf2ff0bd2282cc6b2844665dd527f60e2eca68 /src/code
parent6dd16009361b2561f77b7933981611a9b975fa21 (diff)
Use `CURRENT_TIME` Macro (#1514)
* use CURRENT_TIME macro * add comment * cleanup brackets
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_actor.c2
-rw-r--r--src/code/z_camera.c2
-rw-r--r--src/code/z_demo.c9
-rw-r--r--src/code/z_kankyo.c95
-rw-r--r--src/code/z_message.c4
-rw-r--r--src/code/z_message_nes.c4
-rw-r--r--src/code/z_message_staff.c2
-rw-r--r--src/code/z_parameter.c24
-rw-r--r--src/code/z_play.c2
-rw-r--r--src/code/z_play_hireso.c9
-rw-r--r--src/code/z_scene.c8
-rw-r--r--src/code/z_sram_NES.c14
-rw-r--r--src/code/z_sub_s.c6
13 files changed, 83 insertions, 98 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index 0a5d51e22..ca6267ff4 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -2402,7 +2402,7 @@ void Actor_DeactivateLens(PlayState* play) {
void Actor_InitHalfDaysBit(ActorContext* actorCtx) {
s32 halfDayCount = CURRENT_DAY * 2;
- if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) || (gSaveContext.save.time > CLOCK_TIME(18, 0))) {
+ if ((CURRENT_TIME < CLOCK_TIME(6, 0)) || (CURRENT_TIME > CLOCK_TIME(18, 0))) {
halfDayCount++;
}
diff --git a/src/code/z_camera.c b/src/code/z_camera.c
index b9123a718..399b1db26 100644
--- a/src/code/z_camera.c
+++ b/src/code/z_camera.c
@@ -7229,7 +7229,7 @@ void Camera_EarthquakeDay3(Camera* camera) {
};
if ((CURRENT_DAY == 3) && (CutsceneManager_GetCurrentCsId() == -1)) {
- time = gSaveContext.save.time;
+ time = CURRENT_TIME;
timeSpeedOffset = gSaveContext.save.timeSpeedOffset;
// Large earthquake created
diff --git a/src/code/z_demo.c b/src/code/z_demo.c
index 0ef8fed95..c2624dfd8 100644
--- a/src/code/z_demo.c
+++ b/src/code/z_demo.c
@@ -273,9 +273,9 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) {
case CS_MISC_FREEZE_TIME:
if (!gSaveContext.save.isNight) {
- gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)R_TIME_SPEED;
+ gSaveContext.save.time = CURRENT_TIME - (u16)R_TIME_SPEED;
} else {
- gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)(2 * R_TIME_SPEED);
+ gSaveContext.save.time = CURRENT_TIME - (u16)(2 * R_TIME_SPEED);
}
break;
@@ -364,9 +364,8 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) {
D_801BB15C = csCtx->curFrame;
if (R_TIME_SPEED != 0) {
- gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)R_TIME_SPEED;
- gSaveContext.save.time =
- ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.timeSpeedOffset);
+ gSaveContext.save.time = CURRENT_TIME + (u16)R_TIME_SPEED;
+ gSaveContext.save.time = CURRENT_TIME + (u16)((void)0, gSaveContext.save.timeSpeedOffset);
}
}
break;
diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c
index 894daa37f..de4ad150a 100644
--- a/src/code/z_kankyo.c
+++ b/src/code/z_kankyo.c
@@ -572,12 +572,11 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 arg2) {
gSaveContext.sunsSongState = SUNSSONG_INACTIVE;
- gSaveContext.skyboxTime = ((void)0, gSaveContext.save.time);
+ gSaveContext.skyboxTime = CURRENT_TIME;
Environment_JumpForwardInTime();
- if ((((void)0, gSaveContext.save.time) >= CLOCK_TIME(18, 0)) ||
- (((void)0, gSaveContext.save.time) < CLOCK_TIME(6, 0))) {
+ if ((CURRENT_TIME >= CLOCK_TIME(18, 0)) || (CURRENT_TIME < CLOCK_TIME(6, 0))) {
gSaveContext.save.isNight = true;
} else {
gSaveContext.save.isNight = false;
@@ -677,9 +676,9 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 arg2) {
envCtx->adjLightSettings.fogNear = 0;
envCtx->adjLightSettings.zFar = 0;
- envCtx->sunPos.x = -(Math_SinS(((void)0, gSaveContext.save.time) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f;
- envCtx->sunPos.y = (Math_CosS(((void)0, gSaveContext.save.time) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f;
- envCtx->sunPos.z = (Math_CosS(((void)0, gSaveContext.save.time) - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f;
+ envCtx->sunPos.x = -(Math_SinS(CURRENT_TIME - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f;
+ envCtx->sunPos.y = (Math_CosS(CURRENT_TIME - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f;
+ envCtx->sunPos.z = (Math_CosS(CURRENT_TIME - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f;
envCtx->windDirection.x = 80;
envCtx->windDirection.y = 80;
@@ -775,8 +774,7 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 arg2) {
play->envCtx.precipitation[PRECIP_SNOW_MAX] = 0;
if (gWeatherMode == WEATHER_MODE_RAIN) {
- if (((u32)CURRENT_DAY == 2) && (((void)0, gSaveContext.save.time) >= CLOCK_TIME(7, 0)) &&
- (((void)0, gSaveContext.save.time) < CLOCK_TIME(17, 30))) {
+ if (((u32)CURRENT_DAY == 2) && (CURRENT_TIME >= CLOCK_TIME(7, 0)) && (CURRENT_TIME < CLOCK_TIME(17, 30))) {
if (Environment_GetStormState(play) != STORM_STATE_OFF) {
play->envCtx.precipitation[PRECIP_RAIN_MAX] = 60;
}
@@ -1209,10 +1207,9 @@ void Environment_UpdateTime(PlayState* play, EnvironmentContext* envCtx, PauseCo
((play->transitionMode == TRANS_MODE_OFF) || (gSaveContext.gameMode != GAMEMODE_NORMAL))) {
if (play->transitionTrigger == TRANS_TRIGGER_OFF) {
if ((CutsceneManager_GetCurrentCsId() == CS_ID_NONE) && !Play_InCsMode(play)) {
- gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)R_TIME_SPEED;
+ gSaveContext.save.time = CURRENT_TIME + (u16)R_TIME_SPEED;
if (R_TIME_SPEED != 0) {
- gSaveContext.save.time =
- ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.timeSpeedOffset);
+ gSaveContext.save.time = CURRENT_TIME + (u16)((void)0, gSaveContext.save.timeSpeedOffset);
}
}
}
@@ -1220,13 +1217,12 @@ void Environment_UpdateTime(PlayState* play, EnvironmentContext* envCtx, PauseCo
}
}
- if ((((void)0, gSaveContext.skyboxTime) >= CLOCK_TIME(6, 0)) ||
- (((void)0, gSaveContext.save.time) < CLOCK_TIME(6, 0)) ||
- (((void)0, gSaveContext.save.time) >= (CLOCK_TIME(6, 0) + 0x10))) {
- gSaveContext.skyboxTime = gSaveContext.save.time;
+ if ((((void)0, gSaveContext.skyboxTime) >= CLOCK_TIME(6, 0)) || (CURRENT_TIME < CLOCK_TIME(6, 0)) ||
+ (CURRENT_TIME >= (CLOCK_TIME(6, 0) + 0x10))) {
+ gSaveContext.skyboxTime = CURRENT_TIME;
}
- time = ((void)0, gSaveContext.save.time);
+ time = CURRENT_TIME;
if ((time >= CLOCK_TIME(18, 0)) || (time < CLOCK_TIME(6, 0))) {
gSaveContext.save.isNight = true;
@@ -1386,9 +1382,9 @@ void Environment_UpdateLights(PlayState* play, EnvironmentContext* envCtx, Light
}
if (Environment_IsSceneUpsideDown(play)) {
- var_v0 = ((void)0, gSaveContext.save.time) + CLOCK_TIME(12, 0);
+ var_v0 = CURRENT_TIME + CLOCK_TIME(12, 0);
} else {
- var_v0 = ((void)0, gSaveContext.save.time);
+ var_v0 = CURRENT_TIME;
}
temp_s0_2 = var_v0 - CLOCK_TIME(12, 0);
@@ -1615,9 +1611,9 @@ void Environment_UpdateSun(PlayState* play) {
}
if (Environment_IsSceneUpsideDown(play)) {
- phi_v0 = ((void)0, gSaveContext.save.time) + CLOCK_TIME(12, 0);
+ phi_v0 = CURRENT_TIME + CLOCK_TIME(12, 0);
} else {
- phi_v0 = ((void)0, gSaveContext.save.time);
+ phi_v0 = CURRENT_TIME;
}
temp_a0 = phi_v0 - CLOCK_TIME(12, 0);
@@ -1747,7 +1743,7 @@ void Environment_UpdatePostmanEvents(PlayState* play) {
}
if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_90_01)) {
- temp_a2_2 = ((void)0, gSaveContext.save.time) - D_801F4E78;
+ temp_a2_2 = CURRENT_TIME - D_801F4E78;
if (CHECK_WEEKEVENTREG(WEEKEVENTREG_89_40) && ((u16)SCHEDULE_TIME_NOW >= (u16)SCHEDULE_TIME(5, 0))) {
SET_WEEKEVENTREG(WEEKEVENTREG_90_01);
} else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_89_08) && (temp_a2_2 >= CLOCK_TIME(0, 23))) {
@@ -1755,7 +1751,7 @@ void Environment_UpdatePostmanEvents(PlayState* play) {
D_801F4E78 = 0;
} else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_85_80) && (temp_a2_2 >= (CLOCK_TIME(1, 39) - 1))) {
SET_WEEKEVENTREG(WEEKEVENTREG_89_08);
- D_801F4E78 = gSaveContext.save.time;
+ D_801F4E78 = CURRENT_TIME;
} else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_86_01) && (temp_a2_2 >= (CLOCK_TIME(1, 9) - 1))) {
SET_WEEKEVENTREG(WEEKEVENTREG_85_80);
}
@@ -1788,7 +1784,7 @@ void Environment_DrawSun(PlayState* play) {
if ((play->envCtx.sunPos.y > -800.0f) || Environment_IsSceneUpsideDown(play)) {
Matrix_Translate(play->view.eye.x + play->envCtx.sunPos.x, play->view.eye.y + play->envCtx.sunPos.y,
play->view.eye.z + play->envCtx.sunPos.z, MTXMODE_NEW);
- if (((void)0, gSaveContext.save.time) < CLOCK_TIME(12, 0)) {
+ if (CURRENT_TIME < CLOCK_TIME(12, 0)) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, (u8)((u8)(sSunColor * 52.0f) + 203),
(u8)((u8)(sSunColor * 19.0f) + 181), (u8)sSunPrimAlpha);
gDPSetEnvColor(POLY_OPA_DISP++, (u8)(-(u8)(sSunColor * 5.0f) + 175),
@@ -1813,7 +1809,7 @@ void Environment_DrawSunLensFlare(PlayState* play, EnvironmentContext* envCtx, V
Vec3f vec) {
if ((play->envCtx.precipitation[PRECIP_RAIN_CUR] == 0) &&
!(GET_ACTIVE_CAM(play)->stateFlags & CAM_STATE_UNDERWATER) && (play->skyboxId == SKYBOX_NORMAL_SKY)) {
- f32 v0 = Math_CosS(((void)0, gSaveContext.save.time) - CLOCK_TIME(12, 0));
+ f32 v0 = Math_CosS(CURRENT_TIME - CLOCK_TIME(12, 0));
Environment_DrawLensFlare(play, &play->envCtx, &play->view, play->state.gfxCtx, vec, 370.0f, v0 * 120.0f, 0x190,
true);
@@ -2450,11 +2446,10 @@ void Environment_PlaySceneSequence(PlayState* play) {
if (play->sequenceCtx.seqId != ((void)0, gSaveContext.seqId)) {
Audio_PlaySceneSequence(play->sequenceCtx.seqId, dayMinusOne);
}
- } else if ((((void)0, gSaveContext.save.time) >= CLOCK_TIME(6, 0)) &&
- (((void)0, gSaveContext.save.time) <= CLOCK_TIME(17, 10))) {
+ } else if ((CURRENT_TIME >= CLOCK_TIME(6, 0)) && (CURRENT_TIME <= CLOCK_TIME(17, 10))) {
if (gSceneSeqState != SCENESEQ_DEFAULT) {
Audio_PlayMorningSceneSequence(play->sequenceCtx.seqId, dayMinusOne);
- } else if ((((void)0, gSaveContext.save.time) >= CLOCK_TIME(6, 1)) &&
+ } else if ((CURRENT_TIME >= CLOCK_TIME(6, 1)) &&
(play->sequenceCtx.seqId != ((void)0, gSaveContext.seqId))) {
Audio_PlaySceneSequence(play->sequenceCtx.seqId, dayMinusOne);
}
@@ -2463,11 +2458,9 @@ void Environment_PlaySceneSequence(PlayState* play) {
if (play->sequenceCtx.ambienceId != ((void)0, gSaveContext.ambienceId)) {
Audio_PlayAmbience(play->sequenceCtx.ambienceId);
}
- if ((((void)0, gSaveContext.save.time) > CLOCK_TIME(17, 10)) &&
- (((void)0, gSaveContext.save.time) < CLOCK_TIME(19, 0))) {
+ if ((CURRENT_TIME > CLOCK_TIME(17, 10)) && (CURRENT_TIME < CLOCK_TIME(19, 0))) {
play->envCtx.timeSeqState = TIMESEQ_EARLY_NIGHT_CRITTERS;
- } else if ((((void)0, gSaveContext.save.time) > CLOCK_TIME(19, 0)) ||
- (((void)0, gSaveContext.save.time) < CLOCK_TIME(5, 0))) {
+ } else if ((CURRENT_TIME > CLOCK_TIME(19, 0)) || (CURRENT_TIME < CLOCK_TIME(5, 0))) {
play->envCtx.timeSeqState = TIMESEQ_NIGHT_CRITTERS;
} else {
play->envCtx.timeSeqState = TIMESEQ_MORNING_CRITTERS;
@@ -2491,14 +2484,14 @@ void Environment_UpdateTimeBasedSequence(PlayState* play) {
break;
case TIMESEQ_FADE_DAY_BGM:
- if (((void)0, gSaveContext.save.time) > CLOCK_TIME(17, 10)) {
+ if (CURRENT_TIME > CLOCK_TIME(17, 10)) {
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 240);
play->envCtx.timeSeqState++;
}
break;
case TIMESEQ_NIGHT_BEGIN_SFX:
- if (((void)0, gSaveContext.save.time) >= CLOCK_TIME(18, 0)) {
+ if (CURRENT_TIME >= CLOCK_TIME(18, 0)) {
play->envCtx.timeSeqState++;
}
break;
@@ -2512,7 +2505,7 @@ void Environment_UpdateTimeBasedSequence(PlayState* play) {
break;
case TIMESEQ_NIGHT_DELAY:
- if (((void)0, gSaveContext.save.time) >= CLOCK_TIME(19, 0)) {
+ if (CURRENT_TIME >= CLOCK_TIME(19, 0)) {
play->envCtx.timeSeqState++;
}
break;
@@ -2524,8 +2517,7 @@ void Environment_UpdateTimeBasedSequence(PlayState* play) {
break;
case TIMESEQ_DAY_BEGIN_SFX:
- if ((((void)0, gSaveContext.save.time) < CLOCK_TIME(19, 0)) &&
- (((void)0, gSaveContext.save.time) >= CLOCK_TIME(5, 0))) {
+ if ((CURRENT_TIME < CLOCK_TIME(19, 0)) && (CURRENT_TIME >= CLOCK_TIME(5, 0))) {
play->envCtx.timeSeqState++;
}
break;
@@ -2545,9 +2537,9 @@ void Environment_UpdateTimeBasedSequence(PlayState* play) {
}
if ((play->envCtx.timeSeqState != TIMESEQ_REQUEST) && (((void)0, gSaveContext.save.day) == 3) &&
- (((void)0, gSaveContext.save.time) < CLOCK_TIME(6, 0)) && !func_800FE5D0(play) &&
- (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) &&
- (play->csCtx.state == 0) && ((play->sceneId != SCENE_00KEIKOKU) || (((void)0, gSaveContext.sceneLayer) != 1)) &&
+ (CURRENT_TIME < CLOCK_TIME(6, 0)) && !func_800FE5D0(play) && (play->transitionTrigger == TRANS_TRIGGER_OFF) &&
+ (play->transitionMode == TRANS_MODE_OFF) && (play->csCtx.state == 0) &&
+ ((play->sceneId != SCENE_00KEIKOKU) || (((void)0, gSaveContext.sceneLayer) != 1)) &&
(CutsceneManager_GetCurrentCsId() == CS_ID_NONE) &&
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_FINAL_HOURS) &&
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_SONG_OF_SOARING)) {
@@ -3061,8 +3053,7 @@ void Environment_PlayStormNatureAmbience(PlayState* play) {
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS)) {
Audio_PlayAmbience(AMBIENCE_ID_07);
} else if ((play->sequenceCtx.seqId != NA_BGM_NO_MUSIC) && (play->sequenceCtx.ambienceId != AMBIENCE_ID_13)) {
- if ((((void)0, gSaveContext.save.time) >= CLOCK_TIME(6, 0)) &&
- (((void)0, gSaveContext.save.time) < CLOCK_TIME(18, 0))) {
+ if ((CURRENT_TIME >= CLOCK_TIME(6, 0)) && (CURRENT_TIME < CLOCK_TIME(18, 0))) {
Audio_PlayAmbience(play->sequenceCtx.ambienceId);
}
}
@@ -3076,8 +3067,7 @@ void Environment_StopStormNatureAmbience(PlayState* play) {
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS)) {
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, 20);
} else if ((play->sequenceCtx.seqId != NA_BGM_NO_MUSIC) && (play->sequenceCtx.ambienceId != AMBIENCE_ID_13)) {
- if ((((void)0, gSaveContext.save.time) >= CLOCK_TIME(6, 0)) &&
- (((void)0, gSaveContext.save.time) < CLOCK_TIME(18, 0))) {
+ if ((CURRENT_TIME >= CLOCK_TIME(6, 0)) && (CURRENT_TIME < CLOCK_TIME(18, 0))) {
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, 20);
}
}
@@ -3100,13 +3090,12 @@ void Environment_SetupSkyboxStars(PlayState* play) {
f32 phi_f0;
if ((play->envCtx.skybox1Index == 0) && (play->skyboxId == SKYBOX_NORMAL_SKY)) {
- if ((((void)0, gSaveContext.save.time) >= CLOCK_TIME(21, 0)) ||
- (((void)0, gSaveContext.save.time) < CLOCK_TIME(2, 0))) {
+ if ((CURRENT_TIME >= CLOCK_TIME(21, 0)) || (CURRENT_TIME < CLOCK_TIME(2, 0))) {
phi_f0 = 1.0f;
- } else if (((void)0, gSaveContext.save.time) > CLOCK_TIME(19, 0)) {
- phi_f0 = 1.0f - ((CLOCK_TIME(21, 0) - ((void)0, gSaveContext.save.time)) * (1.0f / (CLOCK_TIME(2, 0) + 1)));
- } else if (((void)0, gSaveContext.save.time) < CLOCK_TIME(3, 0)) {
- phi_f0 = (CLOCK_TIME(3, 0) - ((void)0, gSaveContext.save.time)) * (1.0f / (CLOCK_TIME(1, 0) + 1));
+ } else if (CURRENT_TIME > CLOCK_TIME(19, 0)) {
+ phi_f0 = 1.0f - ((CLOCK_TIME(21, 0) - CURRENT_TIME) * (1.0f / (CLOCK_TIME(2, 0) + 1)));
+ } else if (CURRENT_TIME < CLOCK_TIME(3, 0)) {
+ phi_f0 = (CLOCK_TIME(3, 0) - CURRENT_TIME) * (1.0f / (CLOCK_TIME(1, 0) + 1));
} else {
phi_f0 = 0.0f;
}
@@ -3385,7 +3374,7 @@ u32 Environment_GetStormState(PlayState* play) {
u8 Environment_IsFinalHours(PlayState* play) {
u8 ret = false;
- if ((gSaveContext.save.day == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) {
+ if ((gSaveContext.save.day == 3) && (CURRENT_TIME < CLOCK_TIME(6, 0))) {
ret = true;
}
@@ -3425,8 +3414,8 @@ u8 func_800FE6F8(PlayState* play, s16 timeAdvanceScaling, s16 nextTimeLimit) {
u8 ret = false;
if (R_TIME_SPEED != 0) {
- nextTime = ((void)0, gSaveContext.save.time) +
- (R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset)) * timeAdvanceScaling * 20;
+ nextTime =
+ CURRENT_TIME + (R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset)) * timeAdvanceScaling * 20;
if (nextTime > nextTimeLimit) {
ret = true;
}
@@ -3518,7 +3507,7 @@ void func_800FEAB0() {
void Environment_JumpForwardInTime(void) {
if (sTimeJump != 0) {
- gSaveContext.save.time = ((void)0, gSaveContext.save.time) + sTimeJump;
+ gSaveContext.save.time = CURRENT_TIME + sTimeJump;
sTimeJump = 0;
}
}
diff --git a/src/code/z_message.c b/src/code/z_message.c
index ca0288817..4e541de2e 100644
--- a/src/code/z_message.c
+++ b/src/code/z_message.c
@@ -2316,7 +2316,7 @@ void Message_Decode(PlayState* play) {
decodedBufPos--;
} else if (curChar == 0x20A) {
digits[0] = 0;
- timeInSeconds = TIME_TO_MINUTES_F(gSaveContext.save.time);
+ timeInSeconds = TIME_TO_MINUTES_F(CURRENT_TIME);
digits[1] = timeInSeconds / 60.0f;
while (digits[1] >= 10) {
digits[0]++;
@@ -5908,7 +5908,7 @@ void Message_Update(PlayState* play) {
case MSGMODE_NEW_CYCLE_0:
play->state.unk_A3 = 1;
sp44 = gSaveContext.save.cutsceneIndex;
- sp3E = gSaveContext.save.time;
+ sp3E = CURRENT_TIME;
sp40 = gSaveContext.save.day;
Sram_SaveEndOfCycle(play);
diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c
index ceb921bae..86a644849 100644
--- a/src/code/z_message_nes.c
+++ b/src/code/z_message_nes.c
@@ -1130,14 +1130,14 @@ void Message_DecodeNES(PlayState* play) {
decodedBufPos--;
} else if (curChar == 0xCA) {
digits[0] = 0;
- digits[1] = TIME_TO_MINUTES_F(gSaveContext.save.time) / 60.0f;
+ digits[1] = TIME_TO_MINUTES_F(CURRENT_TIME) / 60.0f;
while (digits[1] >= 10) {
digits[0]++;
digits[1] -= 10;
}
digits[2] = 0;
- digits[3] = (s32)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60;
+ digits[3] = (s32)TIME_TO_MINUTES_F(CURRENT_TIME) % 60;
while (digits[3] >= 10) {
digits[2]++;
digits[3] -= 10;
diff --git a/src/code/z_message_staff.c b/src/code/z_message_staff.c
index 392266d81..1219f3dc7 100644
--- a/src/code/z_message_staff.c
+++ b/src/code/z_message_staff.c
@@ -594,7 +594,7 @@ void Message_DecodeCredits(PlayState* play) {
}
} else if (curChar == 0x1F) {
digits[0] = 0;
- timeInSeconds = TIME_TO_MINUTES_F(gSaveContext.save.time);
+ timeInSeconds = TIME_TO_MINUTES_F(CURRENT_TIME);
digits[1] = timeInSeconds / 60.0f;
while (digits[1] >= 10) {
diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c
index 9bf52c4e4..c1098f23a 100644
--- a/src/code/z_parameter.c
+++ b/src/code/z_parameter.c
@@ -4477,9 +4477,8 @@ void Interface_DrawClock(PlayState* play) {
OVERLAY_DISP = Gfx_DrawTexRect4b(OVERLAY_DISP, gThreeDayClockBorderTex, 4, 64, 50, 96, 168, 128, 50, 1, 6,
0, 1 << 10, 1 << 10);
- if (((CURRENT_DAY >= 4) ||
- ((CURRENT_DAY == 3) && (((void)0, gSaveContext.save.time) >= (CLOCK_TIME(0, 0) + 5)) &&
- (((void)0, gSaveContext.save.time) < CLOCK_TIME(6, 0))))) {
+ if (((CURRENT_DAY >= 4) || ((CURRENT_DAY == 3) && (CURRENT_TIME >= (CLOCK_TIME(0, 0) + 5)) &&
+ (CURRENT_TIME < CLOCK_TIME(6, 0))))) {
Gfx_SetupDL42_Overlay(play->state.gfxCtx);
gSPMatrix(OVERLAY_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
} else {
@@ -4601,7 +4600,7 @@ void Interface_DrawClock(PlayState* play) {
D_801BF974 ^= 1;
}
- timeInSeconds = TIME_TO_SECONDS_F(gSaveContext.save.time);
+ timeInSeconds = TIME_TO_SECONDS_F(CURRENT_TIME);
timeInSeconds -= ((s16)(timeInSeconds / 3600.0f)) * 3600.0f;
Gfx_SetupDL42_Overlay(play->state.gfxCtx);
@@ -4640,7 +4639,7 @@ void Interface_DrawClock(PlayState* play) {
// determines the current hour
for (sp1C6 = 0; sp1C6 <= 24; sp1C6++) {
- if (((void)0, gSaveContext.save.time) < sThreeDayClockHours[sp1C6 + 1]) {
+ if (CURRENT_TIME < sThreeDayClockHours[sp1C6 + 1]) {
break;
}
}
@@ -4648,7 +4647,7 @@ void Interface_DrawClock(PlayState* play) {
/**
* Section: Draw Three-Day Clock's Sun (for the Day-Time Hours Tracker)
*/
- time = gSaveContext.save.time;
+ time = CURRENT_TIME;
sp1D8 = Math_SinS(time) * -40.0f;
temp_f14 = Math_CosS(time) * -34.0f;
@@ -4691,7 +4690,7 @@ void Interface_DrawClock(PlayState* play) {
/**
* Section: Draws Three-Day Clock's Hour Digit Above the Sun
*/
- sp1CC = gSaveContext.save.time * 0.000096131f; // (2.0f * 3.15f / 0x10000)
+ sp1CC = CURRENT_TIME * 0.000096131f; // (2.0f * 3.15f / 0x10000)
// Rotates Three-Day Clock's Hour Digit To Above the Sun
Matrix_Translate(0.0f, R_THREE_DAY_CLOCK_Y_POS / 10.0f, 0.0f, MTXMODE_NEW);
@@ -4741,9 +4740,8 @@ void Interface_DrawClock(PlayState* play) {
// Final Hours
if ((CURRENT_DAY >= 4) ||
- ((CURRENT_DAY == 3) && (((void)0, gSaveContext.save.time) >= (CLOCK_TIME(0, 0) + 5)) &&
- (((void)0, gSaveContext.save.time) < CLOCK_TIME(6, 0)))) {
- if (((void)0, gSaveContext.save.time) >= CLOCK_TIME(5, 0)) {
+ ((CURRENT_DAY == 3) && (CURRENT_TIME >= (CLOCK_TIME(0, 0) + 5)) && (CURRENT_TIME < CLOCK_TIME(6, 0)))) {
+ if (CURRENT_TIME >= CLOCK_TIME(5, 0)) {
// The Final Hours clock will flash red
colorStep = ABS_ALT(sFinalHoursClockDigitsRed -
@@ -7033,7 +7031,7 @@ void Interface_Update(PlayState* play) {
if (play->envCtx.sceneTimeSpeed != 0) {
if (gSaveContext.sunsSongState != SUNSSONG_SPEED_TIME) {
sIsSunsPlayedAtDay = false;
- if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) {
+ if ((CURRENT_TIME >= CLOCK_TIME(6, 0)) && (CURRENT_TIME <= CLOCK_TIME(18, 0))) {
sIsSunsPlayedAtDay = true;
}
@@ -7042,7 +7040,7 @@ void Interface_Update(PlayState* play) {
R_TIME_SPEED = 400;
} else if (!sIsSunsPlayedAtDay) {
// Nighttime
- if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) {
+ if ((CURRENT_TIME >= CLOCK_TIME(6, 0)) && (CURRENT_TIME <= CLOCK_TIME(18, 0))) {
// Daytime has been reached. End suns song effect
gSaveContext.sunsSongState = SUNSSONG_INACTIVE;
R_TIME_SPEED = sPrevTimeSpeed;
@@ -7050,7 +7048,7 @@ void Interface_Update(PlayState* play) {
}
} else {
// Daytime
- if (gSaveContext.save.time > CLOCK_TIME(18, 0)) {
+ if (CURRENT_TIME > CLOCK_TIME(18, 0)) {
// Nighttime has been reached. End suns song effect
gSaveContext.sunsSongState = SUNSSONG_INACTIVE;
R_TIME_SPEED = sPrevTimeSpeed;
diff --git a/src/code/z_play.c b/src/code/z_play.c
index ca4fb500d..83a2d25ce 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -2213,7 +2213,7 @@ void Play_Init(GameState* thisx) {
gSaveContext.skyboxTime = gSaveContext.nextDayTime;
}
- if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 30))) {
+ if ((CURRENT_TIME >= CLOCK_TIME(18, 0)) || (CURRENT_TIME < CLOCK_TIME(6, 30))) {
gSaveContext.save.isNight = true;
} else {
gSaveContext.save.isNight = false;
diff --git a/src/code/z_play_hireso.c b/src/code/z_play_hireso.c
index e9610039f..1871bc67f 100644
--- a/src/code/z_play_hireso.c
+++ b/src/code/z_play_hireso.c
@@ -698,13 +698,12 @@ void BombersNotebook_DrawTimeOfDay(Gfx** gfxP) {
s32 tensDigit;
s32 hours;
- time = (((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0));
+ time = CURRENT_TIME - CLOCK_TIME(6, 0);
if (CURRENT_DAY == 0) {
time = 0;
}
timeOfDayRectLeft = sBombersNotebookDayRectRectLeft[CURRENT_DAY] + (time / CLOCK_TIME(0, 10));
- if ((CURRENT_DAY_CLAMP_MIN_1 == 1) ||
- ((CURRENT_DAY_CLAMP_MIN_1 == 2) && (((void)0, gSaveContext.save.time) < CLOCK_TIME(12, 0)))) {
+ if ((CURRENT_DAY_CLAMP_MIN_1 == 1) || ((CURRENT_DAY_CLAMP_MIN_1 == 2) && (CURRENT_TIME < CLOCK_TIME(12, 0)))) {
timeOfDayRectLeft -= 32;
lineRectLeft = timeOfDayRectLeft + 32;
} else if ((CURRENT_DAY_CLAMP_MIN_1 == 2) && (time >= (CLOCK_TIME(17, 0) - CLOCK_TIME(6, 0))) &&
@@ -772,7 +771,7 @@ void BombersNotebook_DrawTimeOfDay(Gfx** gfxP) {
gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 255);
tensDigit = 0;
- onesDigit = ((void)0, gSaveContext.save.time) / CLOCK_TIME_HOUR;
+ onesDigit = CURRENT_TIME / CLOCK_TIME_HOUR;
if (CURRENT_DAY == 0) {
onesDigit = 6;
}
@@ -809,7 +808,7 @@ void BombersNotebook_DrawTimeOfDay(Gfx** gfxP) {
if (CURRENT_DAY == 0) {
onesDigit = TIME_TO_MINUTES_ALT_F((CLOCK_TIME_F(6, 0) - (hours * CLOCK_TIME_HOUR_F)));
} else {
- onesDigit = TIME_TO_MINUTES_ALT_F(((void)0, gSaveContext.save.time) - (hours * CLOCK_TIME_HOUR_F));
+ onesDigit = TIME_TO_MINUTES_ALT_F(CURRENT_TIME - (hours * CLOCK_TIME_HOUR_F));
}
do {
if (onesDigit >= 10) {
diff --git a/src/code/z_scene.c b/src/code/z_scene.c
index 1798e55bf..8f2fe0cf6 100644
--- a/src/code/z_scene.c
+++ b/src/code/z_scene.c
@@ -411,12 +411,12 @@ void Scene_CommandTimeSettings(PlayState* play, SceneCmd* cmd) {
R_TIME_SPEED = play->envCtx.sceneTimeSpeed;
}
- play->envCtx.sunPos.x = -(Math_SinS(((void)0, gSaveContext.save.time) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f;
- play->envCtx.sunPos.y = (Math_CosS(((void)0, gSaveContext.save.time) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f;
- play->envCtx.sunPos.z = (Math_CosS(((void)0, gSaveContext.save.time) - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f;
+ play->envCtx.sunPos.x = -(Math_SinS(CURRENT_TIME - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f;
+ play->envCtx.sunPos.y = (Math_CosS(CURRENT_TIME - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f;
+ play->envCtx.sunPos.z = (Math_CosS(CURRENT_TIME - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f;
if ((play->envCtx.sceneTimeSpeed == 0) && (gSaveContext.save.cutsceneIndex < 0xFFF0)) {
- gSaveContext.skyboxTime = gSaveContext.save.time;
+ gSaveContext.skyboxTime = CURRENT_TIME;
if ((gSaveContext.skyboxTime >= CLOCK_TIME(4, 0)) && (gSaveContext.skyboxTime < CLOCK_TIME(6, 30))) {
gSaveContext.skyboxTime = CLOCK_TIME(5, 0);
diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c
index e4eb1ef9a..e4a74e04c 100644
--- a/src/code/z_sram_NES.c
+++ b/src/code/z_sram_NES.c
@@ -1389,7 +1389,7 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) {
u16 maskCount;
if (gSaveContext.flashSaveAvailable) {
- D_801F6AF0 = gSaveContext.save.time;
+ D_801F6AF0 = CURRENT_TIME;
D_801F6AF2 = gSaveContext.flashSaveAvailable;
sp64 = 0;
@@ -1482,7 +1482,7 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) {
fileSelect->health[sp76] = gSaveContext.save.saveInfo.playerData.health;
fileSelect->defenseHearts[sp76] = gSaveContext.save.saveInfo.inventory.defenseHearts;
fileSelect->questItems[sp76] = gSaveContext.save.saveInfo.inventory.questItems;
- fileSelect->time[sp76] = gSaveContext.save.time;
+ fileSelect->time[sp76] = CURRENT_TIME;
fileSelect->day[sp76] = gSaveContext.save.day;
fileSelect->isOwlSave[sp76] = gSaveContext.save.isOwlSave;
fileSelect->rupees[sp76] = gSaveContext.save.saveInfo.playerData.rupees;
@@ -1596,7 +1596,7 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) {
fileSelect->health[sp76] = gSaveContext.save.saveInfo.playerData.health;
fileSelect->defenseHearts[sp76] = gSaveContext.save.saveInfo.inventory.defenseHearts;
fileSelect->questItems[sp76] = gSaveContext.save.saveInfo.inventory.questItems;
- fileSelect->time[sp76] = gSaveContext.save.time;
+ fileSelect->time[sp76] = CURRENT_TIME;
fileSelect->day[sp76] = gSaveContext.save.day;
fileSelect->isOwlSave[sp76] = gSaveContext.save.isOwlSave;
fileSelect->rupees[sp76] = gSaveContext.save.saveInfo.playerData.rupees;
@@ -1713,7 +1713,7 @@ void Sram_CopySave(FileSelectState* fileSelect2, SramContext* sramCtx) {
fileSelect->defenseHearts[fileSelect->copyDestFileIndex + 2] =
gSaveContext.save.saveInfo.inventory.defenseHearts;
fileSelect->questItems[fileSelect->copyDestFileIndex + 2] = gSaveContext.save.saveInfo.inventory.questItems;
- fileSelect->time[fileSelect->copyDestFileIndex + 2] = gSaveContext.save.time;
+ fileSelect->time[fileSelect->copyDestFileIndex + 2] = CURRENT_TIME;
fileSelect->day[fileSelect->copyDestFileIndex + 2] = gSaveContext.save.day;
fileSelect->isOwlSave[fileSelect->copyDestFileIndex + 2] = gSaveContext.save.isOwlSave;
fileSelect->rupees[fileSelect->copyDestFileIndex + 2] = gSaveContext.save.saveInfo.playerData.rupees;
@@ -1754,7 +1754,7 @@ void Sram_CopySave(FileSelectState* fileSelect2, SramContext* sramCtx) {
fileSelect->health[fileSelect->copyDestFileIndex] = gSaveContext.save.saveInfo.playerData.health;
fileSelect->defenseHearts[fileSelect->copyDestFileIndex] = gSaveContext.save.saveInfo.inventory.defenseHearts;
fileSelect->questItems[fileSelect->copyDestFileIndex] = gSaveContext.save.saveInfo.inventory.questItems;
- fileSelect->time[fileSelect->copyDestFileIndex] = gSaveContext.save.time;
+ fileSelect->time[fileSelect->copyDestFileIndex] = CURRENT_TIME;
fileSelect->day[fileSelect->copyDestFileIndex] = gSaveContext.save.day;
fileSelect->isOwlSave[fileSelect->copyDestFileIndex] = gSaveContext.save.isOwlSave;
fileSelect->rupees[fileSelect->copyDestFileIndex] = gSaveContext.save.saveInfo.playerData.rupees;
@@ -1818,7 +1818,7 @@ void Sram_InitSave(FileSelectState* fileSelect2, SramContext* sramCtx) {
fileSelect->health[fileSelect->buttonIndex] = gSaveContext.save.saveInfo.playerData.health;
fileSelect->defenseHearts[fileSelect->buttonIndex] = gSaveContext.save.saveInfo.inventory.defenseHearts;
fileSelect->questItems[fileSelect->buttonIndex] = gSaveContext.save.saveInfo.inventory.questItems;
- fileSelect->time[fileSelect->buttonIndex] = gSaveContext.save.time;
+ fileSelect->time[fileSelect->buttonIndex] = CURRENT_TIME;
fileSelect->day[fileSelect->buttonIndex] = gSaveContext.save.day;
fileSelect->isOwlSave[fileSelect->buttonIndex] = gSaveContext.save.isOwlSave;
fileSelect->rupees[fileSelect->buttonIndex] = gSaveContext.save.saveInfo.playerData.rupees;
@@ -1890,7 +1890,7 @@ void Sram_SaveSpecialEnterClockTown(PlayState* play) {
void Sram_SaveSpecialNewDay(PlayState* play) {
s32 cutsceneIndex = gSaveContext.save.cutsceneIndex;
s32 day;
- u16 time = gSaveContext.save.time;
+ u16 time = CURRENT_TIME;
day = gSaveContext.save.day;
diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c
index f5a233ede..9e19c1dad 100644
--- a/src/code/z_sub_s.c
+++ b/src/code/z_sub_s.c
@@ -588,9 +588,9 @@ s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) {
Path* SubS_GetDayDependentPath(PlayState* play, u8 pathIndex, u8 pathIndexNone, s32* startPointIndex) {
Path* path = NULL;
s32 found = false;
- s32 time = (((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60) +
- ((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) / 60) * 60) /
- 30;
+ s16 time1 = TIME_TO_MINUTES_F(CURRENT_TIME);
+ s16 time2 = TIME_TO_MINUTES_F(CURRENT_TIME);
+ s32 time = ((time1 % 60) + (time2 / 60) * 60) / 30;
s32 day = CURRENT_DAY;
if (pathIndex == pathIndexNone) {