mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Add feature to unmount/remount the SD card
This commit is contained in:
parent
78e96a571f
commit
9cfe9e1445
@ -33,9 +33,16 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
static int dmCursorPosition = 0;
|
||||
static bool sdMounted = false;
|
||||
|
||||
void driveMenu (void) {
|
||||
int pressed = 0;
|
||||
int dmCursorPosition = 0;
|
||||
int held = 0;
|
||||
|
||||
if (isDSiMode()) {
|
||||
sdMounted = sdFound();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true);
|
||||
@ -46,39 +53,56 @@ void driveMenu (void) {
|
||||
printf ("[fat:] GAMECART\n");
|
||||
printf ("(Flashcart FAT)");
|
||||
}
|
||||
iprintf ("\x1b[23;0H");
|
||||
iprintf ("\x1b[%i;0H", 23-isDSiMode());
|
||||
printf (titleName);
|
||||
if (isDSiMode()) {
|
||||
printf ("\x1b[23;0H");
|
||||
if (sdMounted) {
|
||||
printf ("R+B - Unmount SD card");
|
||||
} else {
|
||||
printf ("R+B - Remount SD card");
|
||||
}
|
||||
}
|
||||
|
||||
consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 15, 0, true, true);
|
||||
|
||||
iprintf ("[root]");
|
||||
printf ("[root]");
|
||||
|
||||
// Move to 2nd row
|
||||
iprintf ("\x1b[1;0H");
|
||||
printf ("\x1b[1;0H");
|
||||
// Print line of dashes
|
||||
iprintf ("--------------------------------");
|
||||
printf ("--------------------------------");
|
||||
|
||||
// Show cursor
|
||||
iprintf ("\x1b[%d;0H*", dmCursorPosition + ENTRIES_START_ROW);
|
||||
printf ("\x1b[%d;0H*", dmCursorPosition + ENTRIES_START_ROW);
|
||||
|
||||
iprintf ("\x1b[2;1H");
|
||||
printf ("\x1b[2;1H");
|
||||
if (isDSiMode()){
|
||||
iprintf ("[sd:] SDCARD");
|
||||
iprintf ("\x1b[3;1H");
|
||||
printf ("[sd:] SDCARD");
|
||||
if (!sdMounted) {
|
||||
printf ("\x1b[2;29H");
|
||||
printf ("[x]");
|
||||
}
|
||||
printf ("\x1b[3;1H");
|
||||
}
|
||||
printf ("[fat:] GAMECART");
|
||||
if (!flashcardFound()) {
|
||||
iprintf ("\x1b[%i;29H", 2+isDSiMode());
|
||||
printf ("[x]");
|
||||
}
|
||||
iprintf ("[fat:] GAMECART");
|
||||
|
||||
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
|
||||
do {
|
||||
// Move to right side of screen
|
||||
iprintf ("\x1b[0;27H");
|
||||
printf ("\x1b[0;27H");
|
||||
// Print time
|
||||
printf (RetTime().c_str());
|
||||
|
||||
scanKeys();
|
||||
pressed = keysDownRepeat();
|
||||
held = keysHeld();
|
||||
swiWaitForVBlank();
|
||||
} while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN) && !(pressed & KEY_A));
|
||||
} while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN) && !(pressed & KEY_A) && !(held & KEY_R));
|
||||
|
||||
if ((pressed & KEY_UP) && isDSiMode()) dmCursorPosition -= 1;
|
||||
if ((pressed & KEY_DOWN) && isDSiMode()) dmCursorPosition += 1;
|
||||
@ -88,9 +112,11 @@ void driveMenu (void) {
|
||||
|
||||
if (pressed & KEY_A) {
|
||||
if (dmCursorPosition == 0 && isDSiMode()) {
|
||||
chdir("sd:/");
|
||||
screenMode = 1;
|
||||
break;
|
||||
if (sdMounted) {
|
||||
chdir("sd:/");
|
||||
screenMode = 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (isDSiMode()) {
|
||||
flashcardMount();
|
||||
@ -102,5 +128,15 @@ void driveMenu (void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Unmount/Remount SD card
|
||||
if ((held & KEY_R) && (pressed & KEY_B) && isDSiMode()) {
|
||||
if (sdMounted) {
|
||||
sdUnmount();
|
||||
sdMounted = false;
|
||||
} else {
|
||||
sdMounted = sdMount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +33,14 @@ bool bothSDandFlashcard(void) {
|
||||
}
|
||||
}
|
||||
|
||||
bool sdMount(void) {
|
||||
return fatMountSimple("sd", get_io_dsisd());
|
||||
}
|
||||
|
||||
void sdUnmount(void) {
|
||||
fatUnmount("sd");
|
||||
}
|
||||
|
||||
DLDI_INTERFACE* dldiLoadFromBin (const u8 dldiAddr[]) {
|
||||
DLDI_INTERFACE* device;
|
||||
size_t dldiSize;
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
bool sdFound(void);
|
||||
bool flashcardFound(void);
|
||||
bool bothSDandFlashcard(void);
|
||||
bool sdMount(void);
|
||||
void sdUnmount(void);
|
||||
void flashcardMount(void);
|
||||
|
||||
#endif //FLASHCARD_H
|
||||
|
||||
@ -102,11 +102,13 @@ int main(int argc, char **argv) {
|
||||
swiWaitForVBlank();
|
||||
}
|
||||
|
||||
if (!fatInitDefault()) {
|
||||
/*if (!fatInitDefault()) {
|
||||
consoleClear();
|
||||
iprintf ("fatinitDefault failed!\n");
|
||||
stop();
|
||||
}
|
||||
}*/
|
||||
|
||||
fatInitDefault();
|
||||
|
||||
// Top screen as a console
|
||||
videoSetMode(MODE_0_2D);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user