Show labels of both SD and flashcards

This commit is contained in:
RocketRobz 2018-10-09 08:22:17 -06:00
parent 25b2a4288f
commit 93f7433bff
3 changed files with 59 additions and 9 deletions

View File

@ -167,11 +167,11 @@ void driveMenu (void) {
if (!dmTextPrinted) {
consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true);
if (assignedOp[dmCursorPosition] == 0) {
printf ("[sd:] SDCARD\n");
iprintf ("[sd:] SDCARD (%s)\n", sdLabel);
printf ("(SD FAT)");
} else if (assignedOp[dmCursorPosition] == 1) {
printf ("[fat:] GAMECART\n");
printf ("(Flashcart FAT)");
iprintf ("[fat:] FLASHCART (%s)\n", fatLabel);
printf ("(Slot-1 SD FAT)");
} else if (assignedOp[dmCursorPosition] == 2) {
printf ("GBA GAMECART\n");
printf ("(GBA Game)");
@ -209,9 +209,9 @@ void driveMenu (void) {
for (int i = 0; i <= maxCursors; i++) {
iprintf ("\x1b[%d;1H", i + ENTRIES_START_ROW);
if (assignedOp[i] == 0) {
printf ("[sd:] SDCARD");
iprintf ("[sd:] SDCARD (%s)", sdLabel);
} else if (assignedOp[i] == 1) {
printf ("[fat:] GAMECART");
iprintf ("[fat:] FLASHCART (%s)", fatLabel);
} else if (assignedOp[i] == 2) {
printf ("GBA GAMECART");
if (gbaFixedValue != 0x96) {

View File

@ -17,6 +17,31 @@ bool nitroMounted = false;
bool secondaryDrive = false; // false == SD card, true == Flashcard
bool nitroSecondaryDrive = false; // false == SD card, true == Flashcard
char sdLabel[12];
char fatLabel[12];
void fixLabel(bool fat) {
if (fat) {
for (int i = 0; i < 12; i++) {
if (((fatLabel[i] == ' ') && (fatLabel[i+1] == ' ') && (fatLabel[i+2] == ' '))
|| ((fatLabel[i] == ' ') && (fatLabel[i+1] == ' '))
|| (fatLabel[i] == ' ')) {
fatLabel[i] = '\0';
break;
}
}
} else {
for (int i = 0; i < 12; i++) {
if (((sdLabel[i] == ' ') && (sdLabel[i+1] == ' ') && (sdLabel[i+2] == ' '))
|| ((sdLabel[i] == ' ') && (sdLabel[i+1] == ' '))
|| (sdLabel[i] == ' ')) {
sdLabel[i] = '\0';
break;
}
}
}
}
bool sdFound(void) {
if (access("sd:/", F_OK) == 0) {
return true;
@ -42,11 +67,18 @@ bool bothSDandFlashcard(void) {
}
TWL_CODE bool sdMount(void) {
return fatMountSimple("sd", get_io_dsisd());
fatMountSimple("sd", get_io_dsisd());
if (sdFound()) {
fatGetVolumeLabel("sd", sdLabel);
fixLabel(false);
return true;
}
return false;
}
TWL_CODE void sdUnmount(void) {
fatUnmount("sd");
sdLabel[0] = '\0';
sdMounted = false;
}
@ -145,10 +177,16 @@ TWL_CODE bool twl_flashcardMount(void) {
// Read a DLDI driver specific to the cart
if (!memcmp(gamename, "QMATETRIAL", 9) || !memcmp(gamename, "R4DSULTRA", 9)) {
io_dldi_data = dldiLoadFromBin(r4idsn_sd_dldi);
return fatMountSimple("fat", &io_dldi_data->ioInterface);
fatMountSimple("fat", &io_dldi_data->ioInterface);
} else if (!memcmp(gameid, "ACEK", 4) || !memcmp(gameid, "YCEP", 4) || !memcmp(gameid, "AHZH", 4)) {
io_dldi_data = dldiLoadFromBin(ak2_sd_dldi);
return fatMountSimple("fat", &io_dldi_data->ioInterface);
fatMountSimple("fat", &io_dldi_data->ioInterface);
}
if (flashcardFound()) {
fatGetVolumeLabel("fat", fatLabel);
fixLabel(true);
return true;
}
}
return false;
@ -156,9 +194,17 @@ TWL_CODE bool twl_flashcardMount(void) {
bool flashcardMount(void) {
if (flashcardFound()) {
fatGetVolumeLabel("fat", fatLabel);
fixLabel(true);
return true;
} else if (!isDSiMode()) {
return fatInitDefault();
fatInitDefault();
if (flashcardFound()) {
fatGetVolumeLabel("fat", fatLabel);
fixLabel(true);
return true;
}
return false;
} else {
return twl_flashcardMount();
}
@ -166,5 +212,6 @@ bool flashcardMount(void) {
void flashcardUnmount(void) {
fatUnmount("fat");
fatLabel[0] = '\0';
flashcardMounted = false;
}

View File

@ -10,6 +10,9 @@ extern bool nitroMounted;
extern bool secondaryDrive; // false == SD card, true == Flashcard
extern bool nitroSecondaryDrive; // false == SD card, true == Flashcard
extern char sdLabel[12];
extern char fatLabel[12];
extern bool sdFound(void);
extern bool flashcardFound(void);
extern bool bothSDandFlashcard(void);