diff options
| author | Garrett Cox <garrettjcox@gmail.com> | 2022-10-29 12:53:39 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-29 13:53:39 -0400 |
| commit | 4a686cf8002b36993a9cdc295d18ffe5877ffa90 (patch) | |
| tree | e1ea87876e8056097ecc3e96db4ef7a8afabc366 /soh/src | |
| parent | cc7f831ec1d94c717fc088263865b4cff3050e19 (diff) | |
Redone fast file select (#1854)
* Redone fast file select
* Update soh/src/overlays/gamestates/ovl_title/z_title.c
* Prevent loading incompatible saves
* Dont change cvar on incompatible file
Diffstat (limited to 'soh/src')
| -rw-r--r-- | soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c | 26 | ||||
| -rw-r--r-- | soh/src/overlays/gamestates/ovl_title/z_title.c | 123 |
2 files changed, 50 insertions, 99 deletions
diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index a11f22acc..e816670a5 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -12,6 +12,7 @@ static s16 sUnused = 106; static s16 sScreenFillAlpha = 255; +static u8 isFastFileIdIncompatible = 0; static Gfx sScreenFillSetupDL[] = { gsDPPipeSync(), @@ -1608,10 +1609,14 @@ void FileChoose_LoadGame(GameState* thisx) { u16 swordEquipMask; s32 pad; - if (this->buttonIndex == FS_BTN_SELECT_FILE_1 && CVar_GetS32("gDebugEnabled", 0)) { + if ((this->buttonIndex == FS_BTN_SELECT_FILE_1 && CVar_GetS32("gDebugEnabled", 0)) || this->buttonIndex == 0xFF) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); gSaveContext.fileNum = this->buttonIndex; - Sram_OpenSave(); + if (this->buttonIndex == 0xFF) { + Sram_InitDebugSave(); + } else { + Sram_OpenSave(); + } gSaveContext.gameMode = 0; SET_NEXT_GAMESTATE(&this->state, Select_Init, SelectContext); this->state.running = false; @@ -1627,7 +1632,9 @@ void FileChoose_LoadGame(GameState* thisx) { Randomizer_LoadSettings(""); Randomizer_LoadHintLocations(""); Randomizer_LoadItemLocations("", true); + Randomizer_LoadRequiredTrials(""); Randomizer_LoadMerchantMessages(""); + Randomizer_LoadMasterQuestDungeons(""); gSaveContext.respawn[0].entranceIndex = -1; gSaveContext.respawnFlag = 0; @@ -1785,6 +1792,20 @@ void FileChoose_Main(GameState* thisx) { gSaveContext.skyboxTime += 0x10; } + if (CVar_GetS32("gSkipLogoTitle", 0) && CVar_GetS32("gSaveFileID", 0) < 3 && !isFastFileIdIncompatible) { + if (Save_Exist(CVar_GetS32("gSaveFileID", 0)) && FileChoose_IsSaveCompatible(Save_GetSaveMetaInfo(CVar_GetS32("gSaveFileID", 0)))) { + this->buttonIndex = CVar_GetS32("gSaveFileID", 0); + this->menuMode = FS_MENU_MODE_SELECT; + this->selectMode = SM_LOAD_GAME; + } else { + isFastFileIdIncompatible = 1; + } + } else if (CVar_GetS32("gSkipLogoTitle", 0) && CVar_GetS32("gSaveFileID", 0) == 3) { + this->buttonIndex = 0xFF; + this->menuMode = FS_MENU_MODE_SELECT; + this->selectMode = SM_LOAD_GAME; + } + OPEN_DISPS(this->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x00, NULL); @@ -2099,6 +2120,7 @@ void FileChoose_Init(GameState* thisx) { size_t size = (u32)_title_staticSegmentRomEnd - (u32)_title_staticSegmentRomStart; s32 pad; fileSelectSpoilerFileLoaded = false; + isFastFileIdIncompatible = 0; CVar_SetS32("gOnFileSelectNameEntry", 0); SREG(30) = 1; diff --git a/soh/src/overlays/gamestates/ovl_title/z_title.c b/soh/src/overlays/gamestates/ovl_title/z_title.c index 99b05439d..ab88b9390 100644 --- a/soh/src/overlays/gamestates/ovl_title/z_title.c +++ b/soh/src/overlays/gamestates/ovl_title/z_title.c @@ -243,13 +243,13 @@ void Title_Main(GameState* thisx) { POLY_OPA_DISP = gfx; } - if (this->exit) { + if (this->exit || CVar_GetS32("gSkipLogoTitle", 0)) { gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.natureAmbienceId = 0xFF; gSaveContext.gameMode = 1; this->state.running = false; - if (gLoadFileSelect) + if (gLoadFileSelect || CVar_GetS32("gSkipLogoTitle", 0)) SET_NEXT_GAMESTATE(&this->state, FileChoose_Init, FileChooseContext); else SET_NEXT_GAMESTATE(&this->state, Opening_Init, OpeningContext); @@ -267,99 +267,28 @@ void Title_Destroy(GameState* thisx) { void Title_Init(GameState* thisx) { //u32 size = 0; TitleContext* this = (TitleContext*)thisx; - FileChooseContext* FileChooseCtx = (FileChooseContext*)thisx; - - if (CVar_GetS32("gSkipLogoTitle",0)) { - bool saveloading = false; - Sram_InitSram(&this->state.init); - gSaveContext.language = CVar_GetS32("gLanguages", 0); - s32 selectedfile = CVar_GetS32("gSaveFileID", 0); - if (selectedfile == 4) { - if (CVar_GetS32("gDebugEnabled",0)) { - selectedfile = 0xFF; - } else { - selectedfile = 3; - } - } - if (selectedfile < 0) { - selectedfile = 3; //If somehow the save file number under 0 revert back to 3 to prevent boot error - } - if(selectedfile == 3){ - saveloading = true; - gSaveContext.seqId = (u8)NA_BGM_DISABLED; - gSaveContext.natureAmbienceId = 0xFF; - gSaveContext.gameMode = 1; - SET_NEXT_GAMESTATE(&this->state, FileChoose_Init, FileChooseContext); - this->state.running = false; - return; - } else if (selectedfile == 0xFF || selectedfile > 3) { - saveloading = true; - Sram_InitDebugSave(); - gSaveContext.fileNum = selectedfile; - SET_NEXT_GAMESTATE(&this->state, Select_Init, SelectContext); - this->state.running = false; - return; - } else if (selectedfile >= 0 && selectedfile <= 2) { - if (Save_Exist(selectedfile) == true) { //The file exist load it - saveloading = true; - gSaveContext.fileNum = selectedfile; - Sram_OpenSave(); - Randomizer_LoadSettings(""); - Randomizer_LoadHintLocations(""); - Randomizer_LoadItemLocations("", true); - Randomizer_LoadMerchantMessages(""); - gSaveContext.gameMode = 0; - gSaveContext.magic = gSaveContext.magic; - SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext); - this->state.running = false; - return; - } else { - if (CVar_GetS32("gCreateNewSave",0)) { - //File do not exist create a new save file - saveloading = true; - Sram_InitSram(&FileChooseCtx->state.init); - gSaveContext.fileNum = selectedfile; - Sram_InitSave(FileChooseCtx); - Sram_OpenSave(); - gSaveContext.gameMode = 0; - SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext); - this->state.running = false; - return; - } else { - //File do not exist but user do not wish to auto create a save file with blank name - saveloading = true; - gSaveContext.seqId = (u8)NA_BGM_DISABLED; - gSaveContext.natureAmbienceId = 0xFF; - gSaveContext.gameMode = 1; - SET_NEXT_GAMESTATE(&this->state, FileChoose_Init, FileChooseContext); - this->state.running = false; - return; - } - } - } - } else { - quote = SetQuote(); - - this->staticSegment = NULL; - //this->staticSegment = GAMESTATE_ALLOC_MC(&this->state, size); - osSyncPrintf("z_title.c\n"); - //ASSERT(this->staticSegment != NULL); - - //ResourceMgr_CacheDirectory("nintendo_rogo_static*"); - - // Disable vismono - D_801614B0.a = 0; - R_UPDATE_RATE = 1; - Matrix_Init(&this->state); - View_Init(&this->view, this->state.gfxCtx); - this->state.main = Title_Main; - this->state.destroy = Title_Destroy; - this->exit = false; - gSaveContext.fileNum = 0xFF; - this->ult = 0; - this->unk_1D4 = 0x14; - this->coverAlpha = 255; - this->addAlpha = -3; - this->visibleDuration = 0x3C; - } + + quote = SetQuote(); + + this->staticSegment = NULL; + //this->staticSegment = GAMESTATE_ALLOC_MC(&this->state, size); + osSyncPrintf("z_title.c\n"); + //ASSERT(this->staticSegment != NULL); + + //ResourceMgr_CacheDirectory("nintendo_rogo_static*"); + + // Disable vismono + D_801614B0.a = 0; + R_UPDATE_RATE = 1; + Matrix_Init(&this->state); + View_Init(&this->view, this->state.gfxCtx); + this->state.main = Title_Main; + this->state.destroy = Title_Destroy; + this->exit = false; + gSaveContext.fileNum = 0xFF; + this->ult = 0; + this->unk_1D4 = 0x14; + this->coverAlpha = 255; + this->addAlpha = -3; + this->visibleDuration = 0x3C; } |
