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