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,6 +46,7 @@ void driveMenu (void) {
} }
while (true) { while (true) {
if (!dmTextPrinted) {
consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true); consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true);
if (dmCursorPosition == 0 && isDSiMode()) { if (dmCursorPosition == 0 && isDSiMode()) {
printf ("[sd:] SDCARD\n"); printf ("[sd:] SDCARD\n");
@ -91,6 +93,9 @@ void driveMenu (void) {
printf ("[x]"); printf ("[x]");
} }
dmTextPrinted = true;
}
// 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
do { do {
// Move to right side of screen // Move to right side of screen
@ -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();
} }
} }