diff --git a/source/fs/fsinit.c b/source/fs/fsinit.c index 7d43b5d..b50dc4b 100644 --- a/source/fs/fsinit.c +++ b/source/fs/fsinit.c @@ -45,10 +45,6 @@ bool InitImgFS(const char* path) { // (re)mount image, done if path == NULL MountImage(path); InitVirtualImageDrive(); - if (!GetMountState()) { - fs_mounted[9] = (f_mount(fs + 9, "9:", 1) == FR_OK); // ram drive - return false; - } // reinit image filesystem for (u32 i = NORM_FS - IMGN_FS; i < NORM_FS; i++) { char fsname[8]; @@ -56,7 +52,7 @@ bool InitImgFS(const char* path) { if (fs_mounted[i]) continue; fs_mounted[i] = (f_mount(fs + i, fsname, 1) == FR_OK); } - return true; + return GetMountState(); } void DeinitExtFS() { diff --git a/source/godmode.c b/source/godmode.c index dae1275..d0b2c0c 100644 --- a/source/godmode.c +++ b/source/godmode.c @@ -1356,8 +1356,11 @@ u32 GodMode() { break; } else if (pad_state & BUTTON_HOME) { // Home menu const char* optionstr[] = { "Poweroff system", "Reboot system", "SD format menu", "Bonus drive setup", "Switch EmuNAND" }; - u32 user_select = ShowSelectPrompt(CheckMultiEmuNand() ? 5 : 4, optionstr, - "HOME button pressed.\nSelect action:" ); + u32 n_opt = 3; + int bonus = (GetNandUnusedSectors(NAND_SYSNAND) > 0x10000) ? (int) ++n_opt : -1; + int multi = (CheckMultiEmuNand()) ? (int) ++n_opt : -1; + if (bonus < 0) optionstr[3] = "Switch EmuNAND"; + u32 user_select = ShowSelectPrompt(n_opt, optionstr, "HOME button pressed.\nSelect action:" ); if (user_select == 1) { exit_mode = GODMODE_EXIT_POWEROFF; break; @@ -1378,13 +1381,13 @@ u32 GodMode() { InitEmuNandBase(true); InitExtFS(); GetDirContents(current_dir, current_path); - } else if (user_select == 4) { // setup bonus drive + } else if (user_select == (u32) bonus) { // setup bonus drive if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) & (DRV_BONUS|DRV_IMAGE))) clipboard->n_entries = 0; // remove bonus drive clipboard entries if (!SetupBonusDrive()) ShowPrompt(false, "Setup failed!"); ClearScreenF(true, true, COLOR_STD_BG); GetDirContents(current_dir, current_path); - } else if (user_select == 5) { // switch EmuNAND offset + } else if (user_select == (u32) multi) { // switch EmuNAND offset while (ShowPrompt(true, "Current EmuNAND offset is %06X.\nSwitch to next offset?", GetEmuNandBase())) { if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) & DRV_EMUNAND)) clipboard->n_entries = 0; // remove SD clipboard entries diff --git a/source/nand/nand.c b/source/nand/nand.c index 5af752b..f01983f 100644 --- a/source/nand/nand.c +++ b/source/nand/nand.c @@ -411,6 +411,11 @@ u64 GetNandSizeSectors(u32 nand_src) return 0; } +u64 GetNandUnusedSectors(u32 nand_src) +{ + return GetNandSizeSectors(nand_src) - NAND_MIN_SECTORS; +} + bool CheckMultiEmuNand(void) { // this only checks for the theoretical possibility diff --git a/source/nand/nand.h b/source/nand/nand.h index 3500d8c..faa08ca 100644 --- a/source/nand/nand.h +++ b/source/nand/nand.h @@ -47,6 +47,7 @@ int ReadNandSectors(u8* buffer, u32 sector, u32 count, u32 keyslot, u32 src); int WriteNandSectors(const u8* buffer, u32 sector, u32 count, u32 keyslot, u32 dest); u64 GetNandSizeSectors(u32 src); +u64 GetNandUnusedSectors(u32 src); u32 CheckNandHeader(u8* header); u32 CheckNandType(u32 src);