driveMenu: Fix text re-printing, if R button is held

This commit is contained in:
Robz8 2018-10-04 20:51:36 -06:00
parent 9cfe9e1445
commit 4228719d2a

View File

@ -33,6 +33,7 @@
using namespace std; using namespace std;
static bool dmTextPrinted = false;
static int dmCursorPosition = 0; static int dmCursorPosition = 0;
static bool sdMounted = false; static bool sdMounted = false;
@ -45,50 +46,54 @@ void driveMenu (void) {
} }
while (true) { while (true) {
consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true); if (!dmTextPrinted) {
if (dmCursorPosition == 0 && isDSiMode()) { consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true);
printf ("[sd:] SDCARD\n"); if (dmCursorPosition == 0 && isDSiMode()) {
printf ("(SD FAT)"); printf ("[sd:] SDCARD\n");
} else { printf ("(SD FAT)");
printf ("[fat:] GAMECART\n");
printf ("(Flashcart FAT)");
}
iprintf ("\x1b[%i;0H", 23-isDSiMode());
printf (titleName);
if (isDSiMode()) {
printf ("\x1b[23;0H");
if (sdMounted) {
printf ("R+B - Unmount SD card");
} else { } else {
printf ("R+B - Remount SD card"); printf ("[fat:] GAMECART\n");
printf ("(Flashcart FAT)");
}
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); consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 15, 0, true, true);
printf ("[root]"); printf ("[root]");
// Move to 2nd row // Move to 2nd row
printf ("\x1b[1;0H"); printf ("\x1b[1;0H");
// Print line of dashes // Print line of dashes
printf ("--------------------------------"); printf ("--------------------------------");
// Show cursor // Show cursor
printf ("\x1b[%d;0H*", dmCursorPosition + ENTRIES_START_ROW); printf ("\x1b[%d;0H*", dmCursorPosition + ENTRIES_START_ROW);
printf ("\x1b[2;1H"); printf ("\x1b[2;1H");
if (isDSiMode()){ if (isDSiMode()){
printf ("[sd:] SDCARD"); printf ("[sd:] SDCARD");
if (!sdMounted) { if (!sdMounted) {
printf ("\x1b[2;29H"); printf ("\x1b[2;29H");
printf ("[x]");
}
printf ("\x1b[3;1H");
}
printf ("[fat:] GAMECART");
if (!flashcardFound()) {
iprintf ("\x1b[%i;29H", 2+isDSiMode());
printf ("[x]"); printf ("[x]");
} }
printf ("\x1b[3;1H");
} dmTextPrinted = true;
printf ("[fat:] GAMECART");
if (!flashcardFound()) {
iprintf ("\x1b[%i;29H", 2+isDSiMode());
printf ("[x]");
} }
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do // Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
@ -104,8 +109,14 @@ void driveMenu (void) {
swiWaitForVBlank(); swiWaitForVBlank();
} while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN) && !(pressed & KEY_A) && !(held & KEY_R)); } while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN) && !(pressed & KEY_A) && !(held & KEY_R));
if ((pressed & KEY_UP) && isDSiMode()) dmCursorPosition -= 1; if ((pressed & KEY_UP) && isDSiMode()) {
if ((pressed & KEY_DOWN) && isDSiMode()) dmCursorPosition += 1; dmCursorPosition -= 1;
dmTextPrinted = false;
}
if ((pressed & KEY_DOWN) && isDSiMode()) {
dmCursorPosition += 1;
dmTextPrinted = false;
}
if (dmCursorPosition < 0) dmCursorPosition = 1; // Wrap around to bottom of list if (dmCursorPosition < 0) dmCursorPosition = 1; // Wrap around to bottom of list
if (dmCursorPosition > 1) dmCursorPosition = 0; // Wrap around to top of list if (dmCursorPosition > 1) dmCursorPosition = 0; // Wrap around to top of list
@ -113,6 +124,7 @@ void driveMenu (void) {
if (pressed & KEY_A) { if (pressed & KEY_A) {
if (dmCursorPosition == 0 && isDSiMode()) { if (dmCursorPosition == 0 && isDSiMode()) {
if (sdMounted) { if (sdMounted) {
dmTextPrinted = false;
chdir("sd:/"); chdir("sd:/");
screenMode = 1; screenMode = 1;
break; break;
@ -122,6 +134,7 @@ void driveMenu (void) {
flashcardMount(); flashcardMount();
} }
if (flashcardFound()) { if (flashcardFound()) {
dmTextPrinted = false;
chdir("fat:/"); chdir("fat:/");
screenMode = 1; screenMode = 1;
break; break;
@ -132,9 +145,11 @@ void driveMenu (void) {
// Unmount/Remount SD card // Unmount/Remount SD card
if ((held & KEY_R) && (pressed & KEY_B) && isDSiMode()) { if ((held & KEY_R) && (pressed & KEY_B) && isDSiMode()) {
if (sdMounted) { if (sdMounted) {
dmTextPrinted = false;
sdUnmount(); sdUnmount();
sdMounted = false; sdMounted = false;
} else { } else {
dmTextPrinted = false;
sdMounted = sdMount(); sdMounted = sdMount();
} }
} }