Entrance Macro (#987)

* POC

* fix

* Fix typo

* token POC

* The rest

* small cleanup

* More small cleanup

* ENTRANCE

* arg renames

* EntranceIndex -> Entrance

* format

* PR

* PR2

* Remove layer from entrance macro

* namefixer plus comments

* format
This commit is contained in:
Derek Hensley
2022-08-15 11:45:28 -07:00
committed by GitHub
parent 82fe521721
commit 132dd6a373
69 changed files with 687 additions and 419 deletions
+31 -50
View File
@@ -290,7 +290,7 @@ void Cutscene_Command_Misc(PlayState* play2, CutsceneContext* csCtx, CsCmdBase*
break;
case 0x1B:
if (isStartFrame) {
play->nextEntranceIndex = 0x1C00;
play->nextEntrance = ENTRANCE(CUTSCENE, 0);
gSaveContext.nextCutsceneIndex = 0xFFF8;
play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_03;
@@ -569,7 +569,7 @@ void Cutscene_TerminatorImpl(PlayState* play, CutsceneContext* csCtx, CsCmdBase*
gSaveContext.save.cutscene = 0;
if (cmd->base == 1) {
play->nextEntranceIndex = play->csCtx.sceneCsList[play->csCtx.currentCsIndex].nextEntranceIndex;
play->nextEntrance = play->csCtx.sceneCsList[play->csCtx.currentCsIndex].nextEntrance;
gSaveContext.nextCutsceneIndex = 0;
play->transitionTrigger = TRANS_TRIGGER_START;
if (gSaveContext.gameMode != 1) {
@@ -582,11 +582,11 @@ void Cutscene_TerminatorImpl(PlayState* play, CutsceneContext* csCtx, CsCmdBase*
play->transitionType = TRANS_TYPE_04;
}
if ((play->nextEntranceIndex & 0xF) > 0) {
gSaveContext.nextCutsceneIndex = (play->nextEntranceIndex & 0xF) + 0xFFEF;
if ((play->nextEntrance & 0xF) > 0) {
gSaveContext.nextCutsceneIndex = (play->nextEntrance & 0xF) + 0xFFEF;
}
play->nextEntranceIndex &= ~0xF;
play->nextEntrance &= ~0xF;
}
}
@@ -603,11 +603,11 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
switch (D_801F4DE2) {
case 0x1F:
if (gSaveContext.save.weekEventReg[20] & 2) {
play->nextEntranceIndex = 0x3010;
play->nextEntrance = ENTRANCE(WOODFALL_TEMPLE, 1);
play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_03;
} else {
play->nextEntranceIndex = 0x8600;
play->nextEntrance = ENTRANCE(WOODFALL, 0);
gSaveContext.nextCutsceneIndex = 0xFFF0;
play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_03;
@@ -616,11 +616,11 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
case 0x44:
if (gSaveContext.save.weekEventReg[33] & 0x80) {
play->nextEntranceIndex = 0xAE70;
play->nextEntrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 7);
play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_03;
} else {
play->nextEntranceIndex = 0xAE00;
play->nextEntrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 0);
gSaveContext.nextCutsceneIndex = 0xFFF0;
play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_03;
@@ -629,7 +629,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
case 0x5F:
gSaveContext.save.weekEventReg[55] |= 0x80;
play->nextEntranceIndex = 0x6A80;
play->nextEntrance = ENTRANCE(ZORA_CAPE, 8);
gSaveContext.nextCutsceneIndex = 0xFFF0;
play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_03;
@@ -637,7 +637,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
case 0x36:
gSaveContext.save.weekEventReg[52] |= 0x20;
play->nextEntranceIndex = 0x2000;
play->nextEntrance = ENTRANCE(IKANA_CANYON, 0);
gSaveContext.nextCutsceneIndex = 0xFFF1;
play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_03;
@@ -658,12 +658,10 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt
case 2:
if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) {
// Milk bar
play->nextEntranceIndex = 0x2400;
play->nextEntrance = ENTRANCE(MILK_BAR, 0);
gSaveContext.nextCutsceneIndex = 0xFFF0;
} else {
// SPOT00
play->nextEntranceIndex = 0x1C00;
play->nextEntrance = ENTRANCE(CUTSCENE, 0);
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
play->transitionTrigger = TRANS_TRIGGER_START;
@@ -671,12 +669,10 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt
case 3:
if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) {
// Fairy's fountain
play->nextEntranceIndex = 0x4600;
play->nextEntrance = ENTRANCE(FAIRY_FOUNTAIN, 0);
gSaveContext.nextCutsceneIndex = 0xFFF0;
} else {
// SPOT00
play->nextEntranceIndex = 0x1C10;
play->nextEntrance = ENTRANCE(CUTSCENE, 1);
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
play->transitionTrigger = TRANS_TRIGGER_START;
@@ -684,12 +680,10 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt
case 4:
if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) {
// Romani ranch
play->nextEntranceIndex = 0x6400;
play->nextEntrance = ENTRANCE(ROMANI_RANCH, 0);
gSaveContext.nextCutsceneIndex = 0xFFF1;
} else {
// SPOT00
play->nextEntranceIndex = 0x1C20;
play->nextEntrance = ENTRANCE(CUTSCENE, 2);
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
play->transitionTrigger = TRANS_TRIGGER_START;
@@ -697,12 +691,10 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt
case 5:
if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) {
// West clock town
play->nextEntranceIndex = 0xD400;
play->nextEntrance = ENTRANCE(WEST_CLOCK_TOWN, 0);
gSaveContext.nextCutsceneIndex = 0xFFF0;
} else {
// SPOT00
play->nextEntranceIndex = 0x1C30;
play->nextEntrance = ENTRANCE(CUTSCENE, 3);
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
play->transitionTrigger = TRANS_TRIGGER_START;
@@ -710,12 +702,10 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt
case 6:
if (INV_CONTENT(ITEM_MASK_CIRCUS_LEADER) == ITEM_MASK_CIRCUS_LEADER) {
// Milk bar
play->nextEntranceIndex = 0x2400;
play->nextEntrance = ENTRANCE(MILK_BAR, 0);
gSaveContext.nextCutsceneIndex = 0xFFF1;
} else {
// SPOT00
play->nextEntranceIndex = 0x1C50;
play->nextEntrance = ENTRANCE(CUTSCENE, 5);
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
play->transitionTrigger = TRANS_TRIGGER_START;
@@ -723,32 +713,27 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt
case 7:
if (INV_CONTENT(ITEM_MASK_BREMEN) == ITEM_MASK_BREMEN) {
// Milk bar
play->nextEntranceIndex = 0x2400;
play->nextEntrance = ENTRANCE(MILK_BAR, 0);
gSaveContext.nextCutsceneIndex = 0xFFF3;
} else {
// SPOT00
play->nextEntranceIndex = 0x1C60;
play->nextEntrance = ENTRANCE(CUTSCENE, 6);
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
play->transitionTrigger = TRANS_TRIGGER_START;
break;
case 8:
// Ikana canyon
play->nextEntranceIndex = 0x2000;
play->nextEntrance = ENTRANCE(IKANA_CANYON, 0);
gSaveContext.nextCutsceneIndex = 0xFFF3;
play->transitionTrigger = TRANS_TRIGGER_START;
break;
case 9:
if (INV_CONTENT(ITEM_MASK_COUPLE) == ITEM_MASK_COUPLE) {
// Termina field
play->nextEntranceIndex = 0x5400;
play->nextEntrance = ENTRANCE(TERMINA_FIELD, 0);
gSaveContext.nextCutsceneIndex = 0xFFF8;
} else {
// SPOT00
play->nextEntranceIndex = 0x1C70;
play->nextEntrance = ENTRANCE(CUTSCENE, 7);
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
play->transitionTrigger = TRANS_TRIGGER_START;
@@ -756,12 +741,10 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt
case 10:
if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) {
// Cucco shack
play->nextEntranceIndex = 0x7E00;
play->nextEntrance = ENTRANCE(CUCCO_SHACK, 0);
gSaveContext.nextCutsceneIndex = 0xFFF0;
} else {
// SPOT00
play->nextEntranceIndex = 0x1C40;
play->nextEntrance = ENTRANCE(CUTSCENE, 4);
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
play->transitionTrigger = TRANS_TRIGGER_START;
@@ -769,12 +752,10 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt
case 11:
if (INV_CONTENT(ITEM_MASK_POSTMAN) == ITEM_MASK_POSTMAN) {
// Termina field
play->nextEntranceIndex = 0x5410;
play->nextEntrance = ENTRANCE(TERMINA_FIELD, 1);
gSaveContext.nextCutsceneIndex = 0xFFF8;
} else {
// SPOT00
play->nextEntranceIndex = 0x1C80;
play->nextEntrance = ENTRANCE(CUTSCENE, 8);
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
play->transitionTrigger = TRANS_TRIGGER_START;
@@ -1528,7 +1509,7 @@ void func_800EDBE0(PlayState* play) {
if ((gSaveContext.respawnFlag == 0) || (gSaveContext.respawnFlag == -2)) {
sp24 = play->loadedScene;
if ((sp24->titleTextId != 0) && gSaveContext.showTitleCard) {
if ((Entrance_GetTransitionFlags(((void)0, gSaveContext.save.entranceIndex) +
if ((Entrance_GetTransitionFlags(((void)0, gSaveContext.save.entrance) +
((void)0, gSaveContext.sceneSetupIndex)) &
0x4000) != 0) {
func_80151A68(play, sp24->titleTextId);
+7 -7
View File
@@ -357,11 +357,11 @@ void Play_SaveCycleSceneFlags(GameState* thisx) {
cycleSceneFlags->clearedRoom = this->actorCtx.flags.clearedRoom;
}
void Play_SetRespawnData(GameState* thisx, s32 respawnMode, u16 entranceIndex, s32 roomIndex, s32 playerParams,
Vec3f* pos, s16 yaw) {
void Play_SetRespawnData(GameState* thisx, s32 respawnMode, u16 entrance, s32 roomIndex, s32 playerParams, Vec3f* pos,
s16 yaw) {
PlayState* this = (PlayState*)thisx;
gSaveContext.respawn[respawnMode].entranceIndex = Entrance_CreateIndex(entranceIndex >> 9, 0, entranceIndex & 0xF);
gSaveContext.respawn[respawnMode].entrance = Entrance_Create(entrance >> 9, 0, entrance & 0xF);
gSaveContext.respawn[respawnMode].roomIndex = roomIndex;
gSaveContext.respawn[respawnMode].pos = *pos;
gSaveContext.respawn[respawnMode].yaw = yaw;
@@ -376,7 +376,7 @@ void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams)
Player* player = GET_PLAYER(this);
if (this->sceneNum != SCENE_KAKUSIANA) { // Grottos
Play_SetRespawnData(&this->state, respawnMode, (u16)((void)0, gSaveContext.save.entranceIndex),
Play_SetRespawnData(&this->state, respawnMode, (u16)((void)0, gSaveContext.save.entrance),
this->roomCtx.currRoom.num, playerParams, &player->actor.world.pos,
player->actor.shape.rot.y);
}
@@ -385,7 +385,7 @@ void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams)
// Override respawn data in Sakon's Hideout
void func_80169ECC(PlayState* this) {
if (this->sceneNum == SCENE_SECOM) {
this->nextEntranceIndex = 0x2060;
this->nextEntrance = ENTRANCE(IKANA_CANYON, 6);
gSaveContext.respawnFlag = -7;
}
}
@@ -398,7 +398,7 @@ void func_80169EFC(GameState* thisx) {
gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwitchFlags = this->actorCtx.flags.switches[2];
gSaveContext.respawn[RESPAWN_MODE_DOWN].unk_18 = this->actorCtx.flags.collectible[1];
gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags = this->actorCtx.flags.collectible[2];
this->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex;
this->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance;
gSaveContext.respawnFlag = 1;
func_80169ECC(this);
this->transitionTrigger = TRANS_TRIGGER_START;
@@ -410,7 +410,7 @@ void func_80169EFC(GameState* thisx) {
void func_80169F78(GameState* thisx) {
PlayState* this = (PlayState*)thisx;
this->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_TOP].entranceIndex;
this->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_TOP].entrance;
gSaveContext.respawnFlag = -1;
func_80169ECC(this);
this->transitionTrigger = TRANS_TRIGGER_START;
+8 -8
View File
@@ -454,7 +454,7 @@ void Scene_HeaderCmdAltHeaderList(PlayState* play, SceneCmd* cmd) {
SceneCmd** altHeaderList;
SceneCmd* altHeader;
if (gSaveContext.sceneSetupIndex) {
if (gSaveContext.sceneSetupIndex != 0) {
altHeaderList = Lib_SegmentedToVirtual(cmd->altHeaders.segment);
altHeader = altHeaderList[gSaveContext.sceneSetupIndex - 1];
@@ -527,7 +527,7 @@ void Scene_HeaderCmdAnimatedMaterials(PlayState* play, SceneCmd* cmd) {
* Sets the exit fade from the next entrance index.
*/
void Scene_SetExitFade(PlayState* play) {
play->transitionType = Entrance_GetTransitionFlags(play->nextEntranceIndex) & 0x7F;
play->transitionType = Entrance_GetTransitionFlags(play->nextEntrance) & 0x7F;
}
/**
@@ -587,15 +587,15 @@ s32 Scene_ProcessHeader(PlayState* play, SceneCmd* header) {
}
/**
* Creates an entrance index from the scene index, spawn index, and scene setup.
* Creates an entrance from the scene, spawn, and lyaer.
*/
u16 Entrance_CreateIndex(s32 sceneIndex, s32 spawnIndex, s32 sceneSetup) {
return (((sceneIndex << 9) | (spawnIndex << 4)) | sceneSetup) & 0xFFFF;
u16 Entrance_Create(s32 scene, s32 spawn, s32 layer) {
return (scene << 9) | (spawn << 4) | layer;
}
/**
* Creates an entrance index from the current entrance index with the given spawn index.
* Creates an layer 0 entranace from the current entrance and the given spawn.
*/
u16 Entrance_CreateIndexFromSpawn(s32 spawnIndex) {
return Entrance_CreateIndex(gSaveContext.save.entranceIndex >> 9, spawnIndex, 0);
u16 Entrance_CreateFromSpawn(s32 spawn) {
return Entrance_Create(gSaveContext.save.entrance >> 9, spawn, 0);
}
+21 -21
View File
@@ -486,22 +486,22 @@ static EntranceTableEntry* sTreasureChestShopEntranceTable[] = {
sTreasureChestShopEntrance1,
};
static EntranceTableEntry sStoneTowerTempleReversedEntrance0[] = {
static EntranceTableEntry sStoneTowerTempleInvertedEntrance0[] = {
{ 0xE8, 0x00, 0xC102 },
};
static EntranceTableEntry sStoneTowerTempleReversedEntrance1[] = {
static EntranceTableEntry sStoneTowerTempleInvertedEntrance1[] = {
{ 0xE8, 0x01, 0x8102 },
};
static EntranceTableEntry sStoneTowerTempleReversedEntrance2[] = {
static EntranceTableEntry sStoneTowerTempleInvertedEntrance2[] = {
{ 0xE8, 0x02, 0x8102 },
};
static EntranceTableEntry* sStoneTowerTempleReversedEntranceTable[] = {
sStoneTowerTempleReversedEntrance0,
sStoneTowerTempleReversedEntrance1,
sStoneTowerTempleReversedEntrance2,
static EntranceTableEntry* sStoneTowerTempleInvertedEntranceTable[] = {
sStoneTowerTempleInvertedEntrance0,
sStoneTowerTempleInvertedEntrance1,
sStoneTowerTempleInvertedEntrance2,
};
static EntranceTableEntry sClockTowerRooftopEntrance0[] = {
@@ -2678,7 +2678,7 @@ static SceneEntranceTableEntry sSceneEntranceTable[] = {
/* 0x12 */ SCENE_ENTRANCE(sMilkBarEntranceTable, "Z2_MILK_BAR"),
/* 0x13 */ SCENE_ENTRANCE(sStoneTowerTempleEntranceTable, "Z2_INISIE_N"),
/* 0x14 */ SCENE_ENTRANCE(sTreasureChestShopEntranceTable, "Z2_TAKARAYA"),
/* 0x15 */ SCENE_ENTRANCE(sStoneTowerTempleReversedEntranceTable, "Z2_INISIE_R"),
/* 0x15 */ SCENE_ENTRANCE(sStoneTowerTempleInvertedEntranceTable, "Z2_INISIE_R"),
/* 0x16 */ SCENE_ENTRANCE(sClockTowerRooftopEntranceTable, "Z2_OKUJOU"),
/* 0x17 */ SCENE_ENTRANCE(sOpeningDungeonEntranceTable, "Z2_OPENINGDAN"),
/* 0x18 */ SCENE_ENTRANCE(sWoodfallTempleEntranceTable, "Z2_MITURIN"),
@@ -2772,19 +2772,19 @@ static SceneEntranceTableEntry sSceneEntranceTable[] = {
/**
* Returns a pointer to an entrance table from a given entrance index.
*/
EntranceTableEntry* Entrance_GetTableEntry(u16 entranceIndex) {
u32 entranceIndex2 = entranceIndex;
EntranceTableEntry** tableEntryP = sSceneEntranceTable[entranceIndex2 >> 9].table;
EntranceTableEntry* tableEntry = tableEntryP[(entranceIndex2 >> 4) & 0x1F];
EntranceTableEntry* Entrance_GetTableEntry(u16 entrance) {
u32 entranceIndex = entrance;
EntranceTableEntry** tableEntryP = sSceneEntranceTable[entranceIndex >> 9].table;
EntranceTableEntry* tableEntry = tableEntryP[(entranceIndex >> 4) & 0x1F];
return &tableEntry[entranceIndex2 & 0xF];
return &tableEntry[entranceIndex & 0xF];
}
/**
* Returns the scene index from a given entrance index.
*/
s32 Entrance_GetSceneNum(u16 entranceIndex) {
EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entranceIndex);
s32 Entrance_GetSceneNum(u16 entrance) {
EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entrance);
return tableEntry->sceneNum;
}
@@ -2792,8 +2792,8 @@ s32 Entrance_GetSceneNum(u16 entranceIndex) {
/**
* Returns the absolute value scene index (since for some reason some of them are negative) from a given entrance index.
*/
s32 Entrance_GetSceneNumAbsolute(u16 entranceIndex) {
EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entranceIndex);
s32 Entrance_GetSceneNumAbsolute(u16 entrance) {
EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entrance);
return ABS_ALT(tableEntry->sceneNum);
}
@@ -2801,8 +2801,8 @@ s32 Entrance_GetSceneNumAbsolute(u16 entranceIndex) {
/**
* Returns the spawn index from a given entrance index.
*/
s32 Entrance_GetSpawnNum(u16 entranceIndex) {
EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entranceIndex);
s32 Entrance_GetSpawnNum(u16 entrance) {
EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entrance);
return tableEntry->spawnNum;
}
@@ -2810,8 +2810,8 @@ s32 Entrance_GetSpawnNum(u16 entranceIndex) {
/**
* Returns the transition effect flags from a given entrance index.
*/
s32 Entrance_GetTransitionFlags(u16 entranceIndex) {
EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entranceIndex);
s32 Entrance_GetTransitionFlags(u16 entrance) {
EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entrance);
return tableEntry->flags;
}
+19 -11
View File
@@ -501,7 +501,7 @@ u16 Sram_CalcChecksum(void* data, size_t count) {
// Resets `Save` substruct
void Sram_ResetSave(void) {
gSaveContext.save.entranceIndex = 0x1C00;
gSaveContext.save.entrance = ENTRANCE(CUTSCENE, 0);
gSaveContext.save.equippedMask = 0;
gSaveContext.save.isFirstCycle = false;
gSaveContext.save.unk_06 = 0;
@@ -845,7 +845,7 @@ void Sram_InitDebugSave(void) {
gSaveContext.save.horseData.pos.z = -1285;
gSaveContext.save.horseData.yaw = -0x7554;
gSaveContext.save.entranceIndex = 0x1C00;
gSaveContext.save.entrance = ENTRANCE(CUTSCENE, 0);
gSaveContext.save.isFirstCycle = true;
//
@@ -910,7 +910,13 @@ void func_80144A94(SramContext* sramCtx) {
gSaveContext.jinxTimer = 0;
}
u16 D_801C6A58[] = { 0x68B0, 0x6A60, 0xB230, 0x9A80, 0xD890, 0x3E40, 0x8640, 0x84A0, 0x2040, 0xAA30 };
u16 D_801C6A58[] = {
ENTRANCE(GREAT_BAY_COAST, 11), ENTRANCE(ZORA_CAPE, 6),
ENTRANCE(SNOWHEAD, 3), ENTRANCE(MOUNTAIN_VILLAGE_WINTER, 8),
ENTRANCE(SOUTH_CLOCK_TOWN, 9), ENTRANCE(MILK_ROAD, 4),
ENTRANCE(WOODFALL, 4), ENTRANCE(SOUTHERN_SWAMP_POISONED, 10),
ENTRANCE(IKANA_CANYON, 4), ENTRANCE(STONE_TOWER, 3),
};
void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) {
s32 i;
@@ -973,22 +979,24 @@ void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) {
}
if (gSaveContext.save.isFirstCycle) {
gSaveContext.save.entranceIndex = 0xD800;
gSaveContext.save.entrance = ENTRANCE(SOUTH_CLOCK_TOWN, 0);
gSaveContext.save.day = 0;
gSaveContext.save.time = 0x3FFF;
} else {
gSaveContext.save.entranceIndex = 0x1C00;
gSaveContext.save.entrance = ENTRANCE(CUTSCENE, 0);
gSaveContext.nextCutsceneIndex = 0;
gSaveContext.save.playerForm = PLAYER_FORM_HUMAN;
}
} else {
gSaveContext.save.entranceIndex = D_801C6A58[(void)0, gSaveContext.save.owlSaveLocation];
if ((gSaveContext.save.entranceIndex == 0x84A0) && (gSaveContext.save.weekEventReg[20] & 2)) {
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"
gSaveContext.save.entranceIndex = 0xCA0;
} else if ((gSaveContext.save.entranceIndex == 0x9A80) && (gSaveContext.save.weekEventReg[33] & 0x80)) {
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"
gSaveContext.save.entranceIndex = 0xAE80;
gSaveContext.save.entrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 8);
}
for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) {
@@ -1513,7 +1521,7 @@ void func_80146DF8(SramContext* sramCtx) {
}
void Sram_InitSram(GameState* gameState, SramContext* sramCtx) {
if (gSaveContext.save.entranceIndex) {} // Required to match
if (gSaveContext.save.entrance) {} // Required to match
func_801A3D98(gSaveContext.options.audioSetting);
}