mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Enabled no SD mode
This commit is contained in:
parent
c0c13d2f7d
commit
37e24c1825
@ -38,7 +38,7 @@
|
||||
(((v) % (a)) ? ((v) + (a) - ((v) % (a))) : (v))
|
||||
|
||||
// GodMode9 version
|
||||
#define VERSION "0.8.9"
|
||||
#define VERSION "0.9.0"
|
||||
|
||||
// input / output paths
|
||||
#define INPUT_PATHS "0:", "0:/files9", "0:/Decrypt9"
|
||||
|
@ -18,8 +18,6 @@ bool InitSDCardFS() {
|
||||
}
|
||||
|
||||
bool InitExtFS() {
|
||||
if (!fs_mounted[0])
|
||||
return false;
|
||||
for (u32 i = 1; i < NORM_FS; i++) {
|
||||
char fsname[8];
|
||||
snprintf(fsname, 7, "%lu:", i);
|
||||
@ -62,6 +60,7 @@ bool InitImgFS(const char* path) {
|
||||
void DeinitExtFS() {
|
||||
SetupNandSdDrive(NULL, NULL, NULL, 0);
|
||||
SetupNandSdDrive(NULL, NULL, NULL, 1);
|
||||
InitImgFS(NULL);
|
||||
for (u32 i = NORM_FS - 1; i > 0; i--) {
|
||||
if (fs_mounted[i]) {
|
||||
char fsname[8];
|
||||
@ -69,26 +68,21 @@ void DeinitExtFS() {
|
||||
f_mount(NULL, fsname, 1);
|
||||
fs_mounted[i] = false;
|
||||
}
|
||||
if (i == NORM_FS - IMGN_FS) { // unmount image
|
||||
MountImage(NULL);
|
||||
InitVGameDrive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DeinitSDCardFS() {
|
||||
MountImage(NULL);
|
||||
InitVGameDrive();
|
||||
if (fs_mounted[0]) {
|
||||
f_mount(NULL, "0:", 1);
|
||||
fs_mounted[0] = false;
|
||||
}
|
||||
DismountDriveType(DRV_SDCARD|DRV_EMUNAND);
|
||||
}
|
||||
|
||||
void DismountDriveType(u32 type) { // careful with this - no safety checks
|
||||
if (type & DriveType(GetMountPath()))
|
||||
InitImgFS(NULL); // image is mounted from type -> unmount image drive, too
|
||||
for (u32 i = NORM_FS - 1; i > 0; i--) {
|
||||
if (type & DRV_SDCARD) {
|
||||
SetupNandSdDrive(NULL, NULL, NULL, 0);
|
||||
SetupNandSdDrive(NULL, NULL, NULL, 1);
|
||||
}
|
||||
for (u32 i = 0; i < NORM_FS; i++) {
|
||||
char fsname[8];
|
||||
snprintf(fsname, 7, "%lu:", i);
|
||||
if (!fs_mounted[i] || !(type & DriveType(fsname)))
|
||||
@ -98,6 +92,10 @@ void DismountDriveType(u32 type) { // careful with this - no safety checks
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckSDMountState(void) {
|
||||
return fs_mounted[0] || fs_mounted[4] || fs_mounted[5] || fs_mounted[6];
|
||||
}
|
||||
|
||||
int GetMountedFSNum(const char* path) {
|
||||
char alias[256];
|
||||
dealias_path(alias, path);
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "common.h"
|
||||
#include "ff.h"
|
||||
|
||||
// init SD card filesystem - required for everything else
|
||||
// init SD card filesystem - required(?) for everything else
|
||||
bool InitSDCardFS();
|
||||
|
||||
// init fill external fileystem
|
||||
@ -21,6 +21,9 @@ void DeinitSDCardFS();
|
||||
// dismount drives of a certain type
|
||||
void DismountDriveType(u32 type);
|
||||
|
||||
// returns the mount state of the SD card
|
||||
bool CheckSDMountState(void);
|
||||
|
||||
// get number of mounted file system (only for FATFS filesystems)
|
||||
int GetMountedFSNum(const char* path);
|
||||
|
||||
|
@ -46,7 +46,8 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* c
|
||||
u32 state_curr =
|
||||
((*curr_path) ? (1<<0) : 0) |
|
||||
((clipboard->n_entries) ? (1<<1) : 0) |
|
||||
(GetMountState()<<2) |
|
||||
((CheckSDMountState()) ? (1<<2) : 0) |
|
||||
((GetMountState()) ? (1<<3) : 0) |
|
||||
(curr_pane<<4);
|
||||
|
||||
if (state_prev != state_curr) {
|
||||
@ -129,7 +130,7 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* c
|
||||
|
||||
// bottom: inctruction block
|
||||
char instr[512];
|
||||
snprintf(instr, 512, "%s%s\n%s%s%s%s%s%s%s",
|
||||
snprintf(instr, 512, "%s%s\n%s%s%s%s%s%s%s%s",
|
||||
#ifndef SAFEMODE
|
||||
"GodMode9 Explorer v", VERSION, // generic start part
|
||||
#else
|
||||
@ -137,9 +138,9 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* c
|
||||
#endif
|
||||
(*curr_path) ? ((clipboard->n_entries == 0) ? "L - MARK files (use with \x18\x19\x1A\x1B)\nX - DELETE / [+R] RENAME file(s)\nY - COPY file(s) / [+R] CREATE dir\n" :
|
||||
"L - MARK files (use with \x18\x19\x1A\x1B)\nX - DELETE / [+R] RENAME file(s)\nY - PASTE file(s) / [+R] CREATE dir\n") :
|
||||
((GetWritePermissions() > PERM_BASE) ? "R+Y - Relock write permissions\nR+B - Unmount SD card\n" :
|
||||
"R+Y - Unlock write permissions\nR+B - Unmount SD card\n"),
|
||||
(*curr_path) ? "" : "R+X - Reinit filesystem\n",
|
||||
((GetWritePermissions() > PERM_BASE) ? "R+Y - Relock write permissions\n" : "R+Y - Unlock write permissions\n"),
|
||||
(*curr_path) ? "" : (CheckSDMountState()) ? "R+B - Unmount SD card\n" : "R+B - Remount SD card\n",
|
||||
(*curr_path) ? "" : (GetMountState()) ? "R+X - Unmount image\n" : "",
|
||||
(*curr_path) ? "R+A - Search directory\n" : "R+A - Search drive\n",
|
||||
"R+L - Make a Screenshot\n",
|
||||
"R+\x1B\x1A - Switch to prev/next pane\n",
|
||||
@ -569,7 +570,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, DirStruct* cur
|
||||
u32 drvtype = DriveType(curr_entry->path);
|
||||
|
||||
// special stuff, only available on FAT drives (see int special below)
|
||||
bool mountable = ((filetype & FTYPE_MOUNTABLE) && !(drvtype & (DRV_IMAGE|DRV_RAMDRIVE)));
|
||||
bool mountable = ((filetype & FTYPE_MOUNTABLE) && !(drvtype & DRV_IMAGE));
|
||||
bool verificable = (filetype & FYTPE_VERIFICABLE);
|
||||
bool decryptable = (filetype & FYTPE_DECRYPTABLE);
|
||||
bool decryptable_inplace = (decryptable && (drvtype & (DRV_SDCARD|DRV_RAMDRIVE)));
|
||||
@ -808,8 +809,13 @@ u32 GodMode() {
|
||||
return exit_mode;
|
||||
}
|
||||
while (!InitSDCardFS()) {
|
||||
if (!ShowPrompt(true, "Initialising SD card failed! Retry?"))
|
||||
return exit_mode;
|
||||
const char* optionstr[] = { "Retry initialising", "Poweroff system", "Reboot system", "No SD mode (exp.)", "SD format menu" };
|
||||
u32 user_select = ShowSelectPrompt(5, optionstr, "Initialising SD card failed!\nSelect action:" );
|
||||
if (user_select == 2) return GODMODE_EXIT_POWEROFF;
|
||||
else if (user_select == 3) return GODMODE_EXIT_REBOOT;
|
||||
else if (user_select == 4) break;
|
||||
else if (user_select == 5) SdFormatMenu();
|
||||
ClearScreenF(true, true, COLOR_STD_BG);
|
||||
}
|
||||
InitEmuNandBase();
|
||||
InitNandCrypto();
|
||||
@ -913,21 +919,15 @@ u32 GodMode() {
|
||||
}
|
||||
}
|
||||
} else if (switched && (pad_state & BUTTON_B)) { // unmount SD card
|
||||
if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) & (DRV_SDCARD|DRV_ALIAS|DRV_EMUNAND|DRV_IMAGE)))
|
||||
clipboard->n_entries = 0; // remove SD clipboard entries
|
||||
DeinitExtFS();
|
||||
DeinitSDCardFS();
|
||||
memset(panedata, 0x00, N_PANES * sizeof(PaneData));
|
||||
ShowString("SD card unmounted, you can eject now.\n \n<R+Y+\x1B> for format menu\n<A> to remount SD card");
|
||||
while (true) {
|
||||
u32 pad_choice = InputWait();
|
||||
if ((pad_choice & (BUTTON_R1|BUTTON_Y|BUTTON_LEFT)) == (BUTTON_R1|BUTTON_Y|BUTTON_LEFT))
|
||||
SdFormatMenu();
|
||||
else if ((pad_choice & BUTTON_B) && InitSDCardFS()) break;
|
||||
else if (pad_choice & (BUTTON_B|BUTTON_START)) return exit_mode;
|
||||
else if (!(pad_choice & BUTTON_A)) continue;
|
||||
if (InitSDCardFS()) break;
|
||||
ShowString("Reinitialising SD card failed!\n \n<R+Y+\x1B> for format menu\n<A> to retry, <B> to reboot");
|
||||
if (!CheckSDMountState()) {
|
||||
while (!InitSDCardFS() &&
|
||||
ShowPrompt(true, "Reinitialising SD card failed! Retry?"));
|
||||
} else {
|
||||
DeinitSDCardFS();
|
||||
if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) &
|
||||
(DRV_SDCARD|DRV_ALIAS|DRV_EMUNAND|DRV_IMAGE)))
|
||||
clipboard->n_entries = 0; // remove SD clipboard entries
|
||||
}
|
||||
ClearScreenF(true, true, COLOR_STD_BG);
|
||||
InitEmuNandBase();
|
||||
@ -974,13 +974,10 @@ u32 GodMode() {
|
||||
|
||||
// highly specific commands
|
||||
if (!*current_path) { // in the root folder...
|
||||
if (switched && (pad_state & BUTTON_X)) { // reinit file system / unmount image
|
||||
if (switched && (pad_state & BUTTON_X)) { // unmount image
|
||||
if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) & DRV_IMAGE))
|
||||
clipboard->n_entries = 0; // remove last mounted image clipboard entries
|
||||
DeinitExtFS();
|
||||
DeinitSDCardFS();
|
||||
InitSDCardFS();
|
||||
InitExtFS();
|
||||
InitImgFS(NULL);
|
||||
ClearScreenF(false, true, COLOR_STD_BG);
|
||||
GetDirContents(current_dir, current_path);
|
||||
} else if (switched && (pad_state & BUTTON_Y)) {
|
||||
@ -1110,7 +1107,7 @@ u32 GodMode() {
|
||||
exit_mode = GODMODE_EXIT_POWEROFF;
|
||||
break;
|
||||
} else if (pad_state & BUTTON_HOME) { // Home menu
|
||||
const char* optionstr[3] = { "Poweroff system", "Reboot system", "SD format menu" };
|
||||
const char* optionstr[] = { "Poweroff system", "Reboot system", "SD format menu" };
|
||||
u32 user_select = ShowSelectPrompt(3, optionstr, "HOME button pressed.\nSelect action:" );
|
||||
if (user_select == 1) {
|
||||
exit_mode = GODMODE_EXIT_POWEROFF;
|
||||
@ -1118,24 +1115,22 @@ u32 GodMode() {
|
||||
} else if (user_select == 2) {
|
||||
exit_mode = GODMODE_EXIT_REBOOT;
|
||||
break;
|
||||
} else if (user_select == 3) {
|
||||
} else if (user_select == 3) { // format SD card
|
||||
bool sd_state = CheckSDMountState();
|
||||
if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) & (DRV_SDCARD|DRV_ALIAS|DRV_EMUNAND|DRV_IMAGE)))
|
||||
clipboard->n_entries = 0; // remove SD clipboard entries
|
||||
DeinitExtFS();
|
||||
DeinitSDCardFS();
|
||||
clipboard->n_entries = 0;
|
||||
memset(panedata, 0x00, N_PANES * sizeof(PaneData));
|
||||
if (ShowPrompt(true, "SD card unmounted, enter format menu?"))
|
||||
SdFormatMenu();
|
||||
while (!InitSDCardFS()) {
|
||||
if (!ShowPrompt(true, "Reinitialising SD card failed! Retry?"))
|
||||
return exit_mode;
|
||||
if ((SdFormatMenu() == 0) || sd_state) {;
|
||||
while (!InitSDCardFS() &&
|
||||
ShowPrompt(true, "Reinitialising SD card failed! Retry?"));
|
||||
}
|
||||
ClearScreenF(true, true, COLOR_STD_BG);
|
||||
InitEmuNandBase();
|
||||
InitExtFS();
|
||||
GetDirContents(current_dir, current_path);
|
||||
if (cursor >= current_dir->n_entries) cursor = 0;
|
||||
if (cursor >= current_dir->n_entries)
|
||||
cursor = current_dir->n_entries - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -359,7 +359,9 @@ u64 GetNandSizeSectors(u32 nand_src)
|
||||
{
|
||||
u32 sysnand_sectors = getMMCDevice(0)->total_size;
|
||||
if (nand_src == NAND_EMUNAND) { // for EmuNAND
|
||||
u32 emunand_max_sectors = GetPartitionOffsetSector("0:") - (emunand_base_sector + 1); // +1 for safety
|
||||
u32 partition_offset = GetPartitionOffsetSector("0:");
|
||||
u32 emunand_max_sectors = (partition_offset >= (emunand_base_sector + 1)) ? // +1 for safety
|
||||
partition_offset - (emunand_base_sector + 1) : 0;
|
||||
u32 emunand_min_sectors = (emunand_base_sector % 0x200000 == 0) ? sysnand_sectors : NAND_MIN_SECTORS;
|
||||
if (emunand_max_sectors >= sysnand_sectors) return sysnand_sectors;
|
||||
else return (emunand_min_sectors > emunand_max_sectors) ? 0 : emunand_min_sectors;
|
||||
|
Loading…
x
Reference in New Issue
Block a user