summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_actor.c6
-rw-r--r--src/code/z_demo.c9
-rw-r--r--src/code/z_elf_message.c24
-rw-r--r--src/code/z_game_over.c2
-rw-r--r--src/code/z_kaleido_setup.c2
-rw-r--r--src/code/z_message.c11
-rw-r--r--src/code/z_parameter.c50
-rw-r--r--src/code/z_schedule.c8
-rw-r--r--src/code/z_sram_NES.c172
9 files changed, 181 insertions, 103 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index ced233c54..a5d72e4a1 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -2237,7 +2237,7 @@ void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* acto
CycleSceneFlags* cycleFlags;
s32 i;
- gSaveContext.save.weekEventReg[92] |= 0x80;
+ SET_WEEKEVENTREG(WEEKEVENTREG_92_80);
cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneId(play->sceneId)];
bzero(actorCtx, sizeof(ActorContext));
@@ -2297,7 +2297,7 @@ void Actor_SpawnSetupActors(PlayState* play, ActorContext* actorCtx) {
}
if (!(phi_v0 & temp_fp) && (phi_v0 & actorCtx->unkC) &&
- (!(gSaveContext.eventInf[1] & 0x80) || !(phi_v0 & temp_s1) || !(actorEntry->id & 0x800))) {
+ (!CHECK_EVENTINF(EVENTINF_17) || !(phi_v0 & temp_s1) || !(actorEntry->id & 0x800))) {
Actor_SpawnEntry(&play->actorCtx, actorEntry, play);
}
actorEntry++;
@@ -4230,7 +4230,7 @@ s16 func_800BDB6C(Actor* actor, PlayState* play, s16 arg2, f32 arg3) {
Player* player = GET_PLAYER(play);
f32 phi_f2;
- if ((play->csCtx.state != 0) || gDbgCamEnabled) {
+ if ((play->csCtx.state != CS_STATE_0) || gDbgCamEnabled) {
phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &play->view.eye) * 0.25f;
} else {
phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos);
diff --git a/src/code/z_demo.c b/src/code/z_demo.c
index 646b91522..647354028 100644
--- a/src/code/z_demo.c
+++ b/src/code/z_demo.c
@@ -598,7 +598,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
switch (D_801F4DE2) {
case 0x1F:
- if (gSaveContext.save.weekEventReg[20] & 2) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) {
play->nextEntrance = ENTRANCE(WOODFALL_TEMPLE, 1);
play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_03;
@@ -611,7 +611,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
break;
case 0x44:
- if (gSaveContext.save.weekEventReg[33] & 0x80) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) {
play->nextEntrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 7);
play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_03;
@@ -624,7 +624,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
break;
case 0x5F:
- gSaveContext.save.weekEventReg[55] |= 0x80;
+ SET_WEEKEVENTREG(WEEKEVENTREG_55_80);
play->nextEntrance = ENTRANCE(ZORA_CAPE, 8);
gSaveContext.nextCutsceneIndex = 0xFFF0;
play->transitionTrigger = TRANS_TRIGGER_START;
@@ -632,7 +632,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
break;
case 0x36:
- gSaveContext.save.weekEventReg[52] |= 0x20;
+ SET_WEEKEVENTREG(WEEKEVENTREG_52_20);
play->nextEntrance = ENTRANCE(IKANA_CANYON, 0);
gSaveContext.nextCutsceneIndex = 0xFFF1;
play->transitionTrigger = TRANS_TRIGGER_START;
@@ -1482,6 +1482,7 @@ void func_800EDBE0(PlayState* play) {
} else if (!(((void)0,
gSaveContext.save.weekEventReg[(play->csCtx.sceneCsList[temp_v0_3].unk7 / 8)]) &
(1 << (play->csCtx.sceneCsList[temp_v0_3].unk7 % 8)))) {
+ // TODO: macros for this kind of weekEventReg access
gSaveContext.save.weekEventReg[(play->csCtx.sceneCsList[temp_v0_3].unk7 / 8)] =
((void)0, gSaveContext.save.weekEventReg[(play->csCtx.sceneCsList[temp_v0_3].unk7 / 8)]) |
(1 << (play->csCtx.sceneCsList[temp_v0_3].unk7 % 8));
diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c
index a5a4890a7..830824024 100644
--- a/src/code/z_elf_message.c
+++ b/src/code/z_elf_message.c
@@ -21,20 +21,20 @@ u16 QuestHint_GetTatlTextId(PlayState* play) {
return 0;
}
- if (gSaveContext.save.weekEventReg[88] & 0x20) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_88_20)) {
return 0;
}
- if (gSaveContext.save.weekEventReg[79] & 0x10) {
- if (gSaveContext.save.weekEventReg[8] & 0x40) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_10)) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_40)) {
return 0;
}
return 0x224;
}
- if (!(gSaveContext.save.weekEventReg[8] & 0x80)) {
- if (gSaveContext.save.weekEventReg[9] & 1) {
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_08_80)) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_09_01)) {
return 0x21E;
}
@@ -58,34 +58,34 @@ u16 QuestHint_GetTatlTextId(PlayState* play) {
}
if (INV_CONTENT(ITEM_MOON_TEAR) == ITEM_MOON_TEAR) {
- if (gSaveContext.save.weekEventReg[86] & 4) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_86_04)) {
return 0x242;
}
return 0x243;
}
- if (gSaveContext.save.weekEventReg[74] & 0x20) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_74_20)) {
return 0x223;
}
- if (gSaveContext.save.weekEventReg[73] & 0x80) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_80)) {
return 0x222;
}
- if (gSaveContext.save.weekEventReg[73] & 0x20) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_20)) {
return 0x221;
}
- if (gSaveContext.save.weekEventReg[77] & 2) {
- if (gSaveContext.save.weekEventReg[73] & 0x10) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_02)) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10)) {
return 0x240;
}
return 0x241;
}
- if ((gSaveContext.save.weekEventReg[86] & 2) || (gSaveContext.save.weekEventReg[73] & 0x40)) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_86_02) || CHECK_WEEKEVENTREG(WEEKEVENTREG_73_40)) {
return 0x23F;
}
diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c
index 857250eec..5609a4727 100644
--- a/src/code/z_game_over.c
+++ b/src/code/z_game_over.c
@@ -29,7 +29,7 @@ void GameOver_Update(PlayState* play) {
gSaveContext.timerStates[timerId] = TIMER_STATE_OFF;
}
- gSaveContext.eventInf[1] &= ~1;
+ CLEAR_EVENTINF_ALT(EVENTINF_10);
if (CUR_FORM == 0) {
if (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI &&
diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c
index 475de9819..712096446 100644
--- a/src/code/z_kaleido_setup.c
+++ b/src/code/z_kaleido_setup.c
@@ -96,7 +96,7 @@ void KaleidoSetup_Update(PlayState* play) {
if (!Play_InCsMode(play) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) {
if ((play->unk_1887C < 2) && (gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY) &&
(gSaveContext.magicState != MAGIC_STATE_FILL)) {
- if (!(gSaveContext.eventInf[1] & 0x80) && !(player->stateFlags1 & PLAYER_STATE1_20)) {
+ if (!CHECK_EVENTINF(EVENTINF_17) && !(player->stateFlags1 & PLAYER_STATE1_20)) {
if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) &&
!(play->actorCtx.flags & ACTORCTX_FLAG_2)) {
if ((play->actorCtx.unk268 == 0) && CHECK_BTN_ALL(input->press.button, BTN_START)) {
diff --git a/src/code/z_message.c b/src/code/z_message.c
index 5b3598617..44fff9f9f 100644
--- a/src/code/z_message.c
+++ b/src/code/z_message.c
@@ -370,12 +370,12 @@ void func_80151BB4(PlayState* play, u8 arg1) {
u8 temp = arg1;
if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) {
- if ((gSaveContext.save.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) {
+ if (!CHECK_WEEKEVENTREG(D_801C6B28[arg1])) {
msgCtx->unk120B2[msgCtx->unk120B1] = temp;
msgCtx->unk120B1++;
}
} else if (arg1 >= 20) {
- if ((gSaveContext.save.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) {
+ if (!CHECK_WEEKEVENTREG(D_801C6B28[arg1])) {
msgCtx->unk120B2[msgCtx->unk120B1] = temp;
msgCtx->unk120B1++;
}
@@ -391,11 +391,8 @@ u32 func_80151C9C(PlayState* play) {
}
msgCtx->unk120B1--;
- if ((gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] &
- (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]) == 0) {
- gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] =
- ((void)0, gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]) |
- (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]];
+ if (!CHECK_WEEKEVENTREG(D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]])) {
+ SET_WEEKEVENTREG(D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]);
if ((D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]] != 0) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) {
func_80151938(play, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]);
diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c
index a49844e5b..db3cce0bb 100644
--- a/src/code/z_parameter.c
+++ b/src/code/z_parameter.c
@@ -322,7 +322,7 @@ void Interface_StartPostmanTimer(s16 seconds, s16 bunnyHoodState) {
void Interface_StartGoronRaceTimer(s32 arg0) {
if (gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] != TIMER_STATE_OFF) {
// Goron race started
- if (gSaveContext.eventInf[1] & 1) {
+ if (CHECK_EVENTINF(EVENTINF_10)) {
gSaveContext.timerCurTimes[TIMER_ID_GORON_RACE_UNUSED] = SECONDS_TO_TIMER_PRECISE(2, 39);
} else {
gSaveContext.timerCurTimes[TIMER_ID_GORON_RACE_UNUSED] = SECONDS_TO_TIMER_PRECISE(0, 1);
@@ -1457,16 +1457,16 @@ u8 Item_Give(PlayState* play, u8 item) {
} else if (item == ITEM_MAGIC_SMALL) {
Magic_Add(play, MAGIC_NORMAL_METER / 2);
- if (!(gSaveContext.save.weekEventReg[12] & 0x80)) {
- gSaveContext.save.weekEventReg[12] |= 0x80;
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_80)) {
+ SET_WEEKEVENTREG(WEEKEVENTREG_12_80);
return ITEM_NONE;
}
return item;
} else if (item == ITEM_MAGIC_LARGE) {
Magic_Add(play, MAGIC_NORMAL_METER);
- if (!(gSaveContext.save.weekEventReg[12] & 0x80)) {
- gSaveContext.save.weekEventReg[12] |= 0x80;
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_80)) {
+ SET_WEEKEVENTREG(WEEKEVENTREG_12_80);
return ITEM_NONE;
}
return item;
@@ -1676,7 +1676,7 @@ u8 Item_CheckObtainabilityImpl(u8 item) {
return ITEM_RECOVERY_HEART;
} else if ((item == ITEM_MAGIC_SMALL) || (item == ITEM_MAGIC_LARGE)) {
- if (!(gSaveContext.save.weekEventReg[12] & 0x80)) {
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_80)) {
return ITEM_NONE;
}
return item;
@@ -2047,7 +2047,7 @@ s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type) {
if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) {
play->actorCtx.lensActive = false;
}
- if (gSaveContext.save.weekEventReg[14] & 8) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
// Drank Chateau Romani
magicToConsume = 0;
}
@@ -2067,7 +2067,7 @@ s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type) {
if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) {
play->actorCtx.lensActive = false;
}
- if (gSaveContext.save.weekEventReg[14] & 8) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
// Drank Chateau Romani
magicToConsume = 0;
}
@@ -2144,7 +2144,7 @@ s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type) {
if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) {
play->actorCtx.lensActive = false;
}
- if (gSaveContext.save.weekEventReg[14] & 8) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
// Drank Chateau Romani
magicToConsume = 0;
}
@@ -2233,7 +2233,7 @@ void Magic_Update(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
s16 magicCapacityTarget;
- if (gSaveContext.save.weekEventReg[14] & 8) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
// Drank Chateau Romani
Magic_FlashMeterBorder();
}
@@ -2284,7 +2284,7 @@ void Magic_Update(PlayState* play) {
case MAGIC_STATE_CONSUME:
// Consume magic until target is reached or no more magic is available
- if (!(gSaveContext.save.weekEventReg[14] & 8)) {
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
gSaveContext.save.playerData.magic =
((void)0, gSaveContext.save.playerData.magic) - ((void)0, gSaveContext.magicToConsume);
if (gSaveContext.save.playerData.magic <= 0) {
@@ -2297,7 +2297,7 @@ void Magic_Update(PlayState* play) {
case MAGIC_STATE_METER_FLASH_1:
case MAGIC_STATE_METER_FLASH_2:
case MAGIC_STATE_METER_FLASH_3:
- if (!(gSaveContext.save.weekEventReg[14] & 8)) {
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
Magic_FlashMeterBorder();
}
break;
@@ -2331,19 +2331,19 @@ void Magic_Update(PlayState* play) {
interfaceCtx->magicConsumptionTimer--;
if (interfaceCtx->magicConsumptionTimer == 0) {
- if (!(gSaveContext.save.weekEventReg[14] & 8)) {
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
gSaveContext.save.playerData.magic--;
}
interfaceCtx->magicConsumptionTimer = 80;
}
}
- if (!(gSaveContext.save.weekEventReg[14] & 8)) {
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
Magic_FlashMeterBorder();
}
break;
case MAGIC_STATE_CONSUME_GORON_ZORA_SETUP:
- if (!(gSaveContext.save.weekEventReg[14] & 8)) {
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
gSaveContext.save.playerData.magic -= 2;
}
if (gSaveContext.save.playerData.magic <= 0) {
@@ -2358,7 +2358,7 @@ void Magic_Update(PlayState* play) {
if (!Play_InCsMode(play)) {
interfaceCtx->magicConsumptionTimer--;
if (interfaceCtx->magicConsumptionTimer == 0) {
- if (!(gSaveContext.save.weekEventReg[14] & 8)) {
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
gSaveContext.save.playerData.magic--;
}
if (gSaveContext.save.playerData.magic <= 0) {
@@ -2368,7 +2368,7 @@ void Magic_Update(PlayState* play) {
}
}
}
- if (!(gSaveContext.save.weekEventReg[14] & 8)) {
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
Magic_FlashMeterBorder();
}
break;
@@ -2380,7 +2380,7 @@ void Magic_Update(PlayState* play) {
if (!Play_InCsMode(play)) {
interfaceCtx->magicConsumptionTimer--;
if (interfaceCtx->magicConsumptionTimer == 0) {
- if (!(gSaveContext.save.weekEventReg[14] & 8)) {
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
gSaveContext.save.playerData.magic--;
}
if (gSaveContext.save.playerData.magic <= 0) {
@@ -2390,7 +2390,7 @@ void Magic_Update(PlayState* play) {
}
}
}
- if (!(gSaveContext.save.weekEventReg[14] & 8)) {
+ if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
Magic_FlashMeterBorder();
}
break;
@@ -2446,7 +2446,7 @@ void Magic_DrawMeter(PlayState* play) {
// Fill the rest of the meter with the normal magic color
gDPPipeSync(OVERLAY_DISP++);
- if (gSaveContext.save.weekEventReg[14] & 8) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
// Blue magic (drank Chateau Romani)
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 200, interfaceCtx->magicAlpha);
} else {
@@ -2460,7 +2460,7 @@ void Magic_DrawMeter(PlayState* play) {
(magicBarY + 10) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10);
} else {
// Fill the whole meter with the normal magic color
- if (gSaveContext.save.weekEventReg[14] & 8) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_08)) {
// Blue magic (drank Chateau Romani)
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 200, interfaceCtx->magicAlpha);
} else {
@@ -2894,7 +2894,7 @@ void Interface_DrawTimers(PlayState* play) {
gSaveContext.timerStopTimes[sTimerId] = SECONDS_TO_TIMER(120);
gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(120);
}
- } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneId == SCENE_DEKUTES) &&
+ } else if (CHECK_EVENTINF(EVENTINF_34) && (play->sceneId == SCENE_DEKUTES) &&
(gSaveContext.timerStopTimes[sTimerId] >= SECONDS_TO_TIMER(120))) {
gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(120);
}
@@ -3003,7 +3003,7 @@ void Interface_DrawTimers(PlayState* play) {
if (osTime >= SECONDS_TO_TIMER(120)) {
osTime = SECONDS_TO_TIMER(120);
}
- } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneId == SCENE_DEKUTES) &&
+ } else if (CHECK_EVENTINF(EVENTINF_34) && (play->sceneId == SCENE_DEKUTES) &&
(osTime >= SECONDS_TO_TIMER(120))) {
osTime = SECONDS_TO_TIMER(120);
}
@@ -3020,7 +3020,7 @@ void Interface_DrawTimers(PlayState* play) {
play_sound(NA_SE_SY_WARNING_COUNT_E);
sTimerBeepSfxSeconds = sTimerDigits[4];
}
- } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneId == SCENE_DEKUTES)) {
+ } else if (CHECK_EVENTINF(EVENTINF_34) && (play->sceneId == SCENE_DEKUTES)) {
if ((((void)0, gSaveContext.timerCurTimes[sTimerId]) >
(gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] - SECONDS_TO_TIMER(9))) &&
(sTimerBeepSfxSeconds != sTimerDigits[4])) {
@@ -3058,7 +3058,7 @@ void Interface_DrawTimers(PlayState* play) {
} else {
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255);
}
- } else if ((gSaveContext.eventInf[3] & 0x10) && (play->sceneId == SCENE_DEKUTES)) {
+ } else if (CHECK_EVENTINF(EVENTINF_34) && (play->sceneId == SCENE_DEKUTES)) {
if (((void)0, gSaveContext.timerCurTimes[sTimerId]) >=
gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) {
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255);
diff --git a/src/code/z_schedule.c b/src/code/z_schedule.c
index 6a2492631..fdefb0f42 100644
--- a/src/code/z_schedule.c
+++ b/src/code/z_schedule.c
@@ -8,9 +8,9 @@
s32 Schedule_CheckFlagS(PlayState* play, u8** script, ScheduleOutput* output) {
ScheduleCmdCheckFlagS* cmd = (ScheduleCmdCheckFlagS*)*script;
- u16 flag = (cmd->flagByte << 8) | cmd->flagMask;
+ u16 flag = PACK_WEEKEVENTREG_FLAG(cmd->flagByte, cmd->flagMask);
- if (gSaveContext.save.weekEventReg[flag >> 8] & (flag & 0xFF)) {
+ if (CHECK_WEEKEVENTREG(flag)) {
*script += cmd->offset;
}
@@ -19,9 +19,9 @@ s32 Schedule_CheckFlagS(PlayState* play, u8** script, ScheduleOutput* output) {
s32 Schedule_CheckFlagL(PlayState* play, u8** script, ScheduleOutput* output) {
ScheduleCmdCheckFlagL* cmd = (ScheduleCmdCheckFlagL*)*script;
- u16 flag = (cmd->flagByte << 8) | cmd->flagMask;
+ u16 flag = PACK_WEEKEVENTREG_FLAG(cmd->flagByte, cmd->flagMask);
- if (gSaveContext.save.weekEventReg[flag >> 8] & (flag & 0xFF)) {
+ if (CHECK_WEEKEVENTREG(flag)) {
*script += (s16)((cmd->offsetH << 8) | cmd->offsetL);
}
diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c
index 6f9006146..e027c115f 100644
--- a/src/code/z_sram_NES.c
+++ b/src/code/z_sram_NES.c
@@ -131,16 +131,109 @@ u32 D_801C5FC0[SCENE_MAX][4] = {
{ 0, 0, 1, 0 }, // SCENE_ALLEY
};
-// Related to weekEventReg
+// TODO: figure out a way to use the WEEKEVENTREG defines here
+// weekEventReg flags which will be not be cleared on a cycle reset
u16 D_801C66D0[ARRAY_COUNT(gSaveContext.save.weekEventReg)] = {
- 0xFFFC, 0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0, 0xC000, 0xC00, 0, 0xC0, 0, 0x300,
- 0x3000, 0xC000, 0xC00, 0, 0, 0, 0, 0, 0, 0xC00C, 0xC00C, 0xC008, 3,
- 0x3000, 0, 0, 0, 0xFF00, 0xC3F, 0x3F, 0, 0, 0xCFFF, 0, 0, 0xC00,
- 0xC00, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3C, 0x20,
- 0, 0x300C, 0x3000, 0, 0xC, 0xC0, 0, 0xFF0, 0x300, 0, 0, 0xC00, 0,
- 0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xC0, 0, 0xC000, 0, 3,
- 0, 0xC000, 0, 0xC0, 0x300, 0, 0, 0, 0xC000, 0xFFF0, 0, 0, 0x300,
- 0, 0xC000, 0xF0, 0, 0, 0, 0, 0, 0,
+ /* 0 */ 0xFFFC,
+ /* 1 */ 0xFFFF,
+ /* 2 */ 0xFFFF,
+ /* 3 */ 0xFFFF,
+ /* 4 */ 0,
+ /* 5 */ 0,
+ /* 6 */ 0,
+ /* 7 */ 0xC000,
+ /* 8 */ 0xC00,
+ /* 9 */ 0,
+ /* 10 */ 0xC0,
+ /* 11 */ 0,
+ /* 12 */ 0x300,
+ /* 13 */ 0x3000,
+ /* 14 */ 0xC000,
+ /* 15 */ 0xC00,
+ /* 16 */ 0,
+ /* 17 */ 0,
+ /* 18 */ 0,
+ /* 19 */ 0,
+ /* 20 */ 0,
+ /* 21 */ 0,
+ /* 22 */ 0xC00C,
+ /* 23 */ 0xC00C,
+ /* 24 */ 0xC008,
+ /* 25 */ 3,
+ /* 26 */ 0x3000,
+ /* 27 */ 0,
+ /* 28 */ 0,
+ /* 29 */ 0,
+ /* 30 */ 0xFF00,
+ /* 31 */ 0xC3F,
+ /* 32 */ 0x3F,
+ /* 33 */ 0,
+ /* 34 */ 0,
+ /* 35 */ 0xCFFF,
+ /* 36 */ 0,
+ /* 37 */ 0,
+ /* 38 */ 0xC00,
+ /* 39 */ 0xC00,
+ /* 40 */ 0,
+ /* 41 */ 0xC0,
+ /* 42 */ 0,
+ /* 43 */ 0,
+ /* 44 */ 0,
+ /* 45 */ 0,
+ /* 46 */ 0,
+ /* 47 */ 0,
+ /* 48 */ 0,
+ /* 49 */ 0,
+ /* 50 */ 0x3C,
+ /* 51 */ 0x20,
+ /* 52 */ 0,
+ /* 53 */ 0x300C,
+ /* 54 */ 0x3000,
+ /* 55 */ 0,
+ /* 56 */ 0xC,
+ /* 57 */ 0xC0,
+ /* 58 */ 0,
+ /* 59 */ 0xFF0,
+ /* 60 */ 0x300,
+ /* 61 */ 0,
+ /* 62 */ 0,
+ /* 63 */ 0xC00,
+ /* 64 */ 0,
+ /* 65 */ 0,
+ /* 66 */ 0xFFFF,
+ /* 67 */ 0xFFFF,
+ /* 68 */ 0xFFFF,
+ /* 69 */ 0xFFFF,
+ /* 70 */ 0xFFFF,
+ /* 71 */ 0xFFFF,
+ /* 72 */ 0xFFFF,
+ /* 73 */ 0xC0,
+ /* 74 */ 0,
+ /* 75 */ 0xC000,
+ /* 76 */ 0,
+ /* 77 */ 3,
+ /* 78 */ 0,
+ /* 79 */ 0xC000,
+ /* 80 */ 0,
+ /* 81 */ 0xC0,
+ /* 82 */ 0x300,
+ /* 83 */ 0,
+ /* 84 */ 0,
+ /* 85 */ 0,
+ /* 86 */ 0xC000,
+ /* 87 */ 0xFFF0,
+ /* 88 */ 0,
+ /* 89 */ 0,
+ /* 90 */ 0x300,
+ /* 91 */ 0,
+ /* 92 */ 0xC000,
+ /* 93 */ 0xF0,
+ /* 94 */ 0,
+ /* 95 */ 0,
+ /* 96 */ 0,
+ /* 97 */ 0,
+ /* 98 */ 0,
+ /* 99 */ 0,
};
// used in other files
@@ -232,16 +325,11 @@ void Sram_ClearHighscores(void) {
* Clears specific weekEventReg flags. Used by the "Dawn of the First Day" message
*/
void Sram_ClearFlagsAtDawnOfTheFirstDay(void) {
- // Unconfirmed: "Link the Goron Claims His Reservation: 4:30 PM"
- gSaveContext.save.weekEventReg[55] &= (u8)~2;
- // Unconfirmed: "Postman fleeing town"
- gSaveContext.save.weekEventReg[90] &= (u8)~1;
- // Unconfirmed: "Postman is about to flee"
- gSaveContext.save.weekEventReg[89] &= (u8)~0x40;
- // Unconfirmed: "Postman has delivered priority mail"
- gSaveContext.save.weekEventReg[89] &= (u8)~8;
- // Unconfirmed: "Postman showing priority mail to Madame"
- gSaveContext.save.weekEventReg[85] &= (u8)~0x80;
+ CLEAR_WEEKEVENTREG(WEEKEVENTREG_55_02);
+ CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_01);
+ CLEAR_WEEKEVENTREG(WEEKEVENTREG_89_40);
+ CLEAR_WEEKEVENTREG(WEEKEVENTREG_89_08);
+ CLEAR_WEEKEVENTREG(WEEKEVENTREG_85_80);
}
/**
@@ -296,7 +384,7 @@ void Sram_SaveEndOfCycle(PlayState* play) {
gSaveContext.masksGivenOnMoon[i] = 0;
}
- if (gSaveContext.save.weekEventReg[84] & 0x20) {
+ if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_20)) {
Inventory_DeleteItem(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY));
}
@@ -316,38 +404,38 @@ void Sram_SaveEndOfCycle(PlayState* play) {
gSaveContext.eventInf[i] = 0;
}
- gSaveContext.eventInf[7] &= (u8)~1;
- gSaveContext.eventInf[7] &= (u8)~2;
- gSaveContext.eventInf[7] &= (u8)~4;
- gSaveContext.eventInf[7] &= (u8)~8;
- gSaveContext.eventInf[7] &= (u8)~0x10;
+ CLEAR_EVENTINF(EVENTINF_70);
+ CLEAR_EVENTINF(EVENTINF_71);
+ CLEAR_EVENTINF(EVENTINF_72);
+ CLEAR_EVENTINF(EVENTINF_73);
+ CLEAR_EVENTINF(EVENTINF_74);
if (gSaveContext.save.playerData.rupees != 0) {
- gSaveContext.eventInf[7] |= 1;
+ SET_EVENTINF(EVENTINF_70);
}
if (INV_CONTENT(ITEM_BOMB) == ITEM_BOMB) {
item = INV_CONTENT(ITEM_BOMB);
if (AMMO(item) != 0) {
- gSaveContext.eventInf[7] |= 2;
+ SET_EVENTINF(EVENTINF_71);
}
}
if (INV_CONTENT(ITEM_NUT) == ITEM_NUT) {
item = INV_CONTENT(ITEM_NUT);
if (AMMO(item) != 0) {
- gSaveContext.eventInf[7] |= 4;
+ SET_EVENTINF(EVENTINF_72);
}
}
if (INV_CONTENT(ITEM_STICK) == ITEM_STICK) {
item = INV_CONTENT(ITEM_STICK);
if (AMMO(item) != 0) {
- gSaveContext.eventInf[7] |= 8;
+ SET_EVENTINF(EVENTINF_73);
}
}
if (INV_CONTENT(ITEM_BOW) == ITEM_BOW) {
item = INV_CONTENT(ITEM_BOW);
if (AMMO(item) != 0) {
- gSaveContext.eventInf[7] |= 0x10;
+ SET_EVENTINF(EVENTINF_74);
}
}
@@ -482,10 +570,8 @@ void Sram_IncrementDay(void) {
gSaveContext.save.bombersCaughtOrder[3] = 0;
gSaveContext.save.bombersCaughtOrder[4] = 0;
- // Unconfirmed: "Bombers Hide & Seek started on Day 1???"
- gSaveContext.save.weekEventReg[73] &= (u8)~0x10;
- // Unconfirmed: "Bombers Hide & Seek in Progress"
- gSaveContext.save.weekEventReg[85] &= (u8)~2;
+ CLEAR_WEEKEVENTREG(WEEKEVENTREG_73_10);
+ CLEAR_WEEKEVENTREG(WEEKEVENTREG_85_02);
}
u16 Sram_CalcChecksum(void* data, size_t count) {
@@ -848,12 +934,9 @@ void Sram_InitDebugSave(void) {
gSaveContext.save.entrance = ENTRANCE(CUTSCENE, 0);
gSaveContext.save.isFirstCycle = true;
- //
- gSaveContext.save.weekEventReg[0x0F] |= 0x20;
- // Unconfirmed: "Entered South Clock Town"
- gSaveContext.save.weekEventReg[0x3B] |= 0x04;
- // Unconfirmed: "Tatl's Second Cycle Text?"
- gSaveContext.save.weekEventReg[0x1F] |= 0x04;
+ SET_WEEKEVENTREG(WEEKEVENTREG_15_20);
+ SET_WEEKEVENTREG(WEEKEVENTREG_59_04);
+ SET_WEEKEVENTREG(WEEKEVENTREG_31_04);
gSaveContext.cycleSceneFlags[SCENE_INSIDETOWER].switch0 = 1;
gSaveContext.save.permanentSceneFlags[SCENE_INSIDETOWER].switch0 = 1;
@@ -990,12 +1073,10 @@ void Sram_OpenSave(FileSelectState* fileSelect, SramContext* sramCtx) {
} else {
gSaveContext.save.entrance = D_801C6A58[(void)0, gSaveContext.save.owlSaveLocation];
if ((gSaveContext.save.entrance == ENTRANCE(SOUTHERN_SWAMP_POISONED, 10)) &&
- (gSaveContext.save.weekEventReg[20] & 2)) {
- // Unconfirmed weekEventReg: "Woodfall Temple Prison Entrance raised / Water cleansed"
+ CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) {
gSaveContext.save.entrance = ENTRANCE(SOUTHERN_SWAMP_CLEARED, 10);
} else if ((gSaveContext.save.entrance == ENTRANCE(MOUNTAIN_VILLAGE_WINTER, 8)) &&
- (gSaveContext.save.weekEventReg[33] & 0x80)) {
- // Unconfirmed weekEventReg: "Mountain Village Unfrozen"
+ CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) {
gSaveContext.save.entrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 8);
}
@@ -1561,8 +1642,7 @@ void Sram_SaveSpecialNewDay(PlayState* play) {
day = gSaveContext.save.day;
- // Unconfirmed: "Obtained Fierce Deity Mask?"
- gSaveContext.save.weekEventReg[84] &= (u8)~0x20;
+ CLEAR_WEEKEVENTREG(WEEKEVENTREG_84_20);
Sram_SaveEndOfCycle(play);
func_8014546C(&play->sramCtx);