diff --git a/include/arm9/menu.h b/include/arm9/menu.h index f00f514..4dbd2c4 100644 --- a/include/arm9/menu.h +++ b/include/arm9/menu.h @@ -65,7 +65,8 @@ // This must be called once in each (sub-) menu iteration, // after menuUpdateGlobalState has been called. void menuActState(void); - +// Shows a windowed text, updates menu state. void menuPrintPrompt(const char *text); +// Waits for any key being pressed, updates menu state. void menuWaitForAnyPadkey(); diff --git a/include/arm9/ui.h b/include/arm9/ui.h index 98fbbe3..3f0415c 100644 --- a/include/arm9/ui.h +++ b/include/arm9/ui.h @@ -29,3 +29,4 @@ void uiPrintBootWarning(); void uiPrintBootFailure(); bool uiCheckHomePressed(u32 msTimeout); +void uiWaitForAnyPadkey(); diff --git a/source/arm9/console.c b/source/arm9/console.c index 7c42884..95246b6 100644 --- a/source/arm9/console.c +++ b/source/arm9/console.c @@ -736,13 +736,6 @@ int starty = (console->windowY - 1) * 8 - thickness; int endy = console->windowHeight * 8 + thickness; - - /* - printf("startx: %i\n", startx); - printf("endx: %i\n", endx); - printf("endy: %i\n", endy); - printf("starty: %i\n", starty); - */ u16 color = colorTable[colorIndex]; diff --git a/source/arm9/main.c b/source/arm9/main.c index 7999d5c..8c4b8ce 100644 --- a/source/arm9/main.c +++ b/source/arm9/main.c @@ -213,7 +213,7 @@ if(res[3] == FR_OK) uiPrintIfVerbose("%s\e[0m\n", res_str[1]); else uiPrintIfVerbose("%s ERROR 0x%d\e[0m\n", res_str[0], res[3]); - finalRes &= res[3] == res[2] == res[1] == FR_OK; + finalRes &= ((res[3] == res[2]) == res[1]) == FR_OK; } else finalRes = false; diff --git a/source/arm9/menu.c b/source/arm9/menu.c index e5029d9..75660b8 100644 --- a/source/arm9/menu.c +++ b/source/arm9/menu.c @@ -73,15 +73,6 @@ uiPrintTextAt(1, 10, "Wifi flash status: %s\e[0m", nand_res[bootInfo.wififlash_status]); } -static void rewindConsole() -{ - // get ready to repaint - consoleSelect(&con_top); - printf("\033[0;0H"); // set cursor to the upper left corner - consoleSelect(&con_bottom); - printf("\033[0;0H"); -} - int enter_menu(int initial_state) { u32 keys; @@ -121,8 +112,6 @@ hidScanInput(); keys = hidKeysDown(); - - rewindConsole(); menu_main_draw_top(); @@ -206,7 +195,8 @@ goto exitAndLaunchFirm; break; - default: printf("OOPS!\n"); break; + /* this should never happen */ + default: uiPrintIfVerbose("OOPS!\n"); break; } switch(menuUpdateGlobalState()) @@ -383,7 +373,8 @@ void menuPrintPrompt(const char *text) { - printf(text); + // TODO: use uiShowMessageWindow + uiPrintInfo(text); } void menuWaitForAnyPadkey() diff --git a/source/arm9/menu_filebrowse.c b/source/arm9/menu_filebrowse.c index 9895eea..700bc7e 100644 --- a/source/arm9/menu_filebrowse.c +++ b/source/arm9/menu_filebrowse.c @@ -119,10 +119,10 @@ { // clear old '*' char consoleSetCursor(&con_bottom, 0, (old_cursor_pos % (maxEntries)) + 1); - printf(" "); + uiPrintInfo(" "); consoleSetCursor(&con_bottom, 0, (cursor_pos % (maxEntries)) + 1); - printf("*"); + uiPrintInfo("*"); } static void updateScreen(int cursor_pos, bool dirChange) @@ -151,9 +151,9 @@ // print the current path in the first line formatEntry(entry, curPath, (u32) maxLen - 3, false); - printf("%s :", entry); + uiPrintInfo("%s :", entry); - if(cursor_pos < (u32) maxEntries) + if(cursor_pos < (int) maxEntries) { start = 0; end = min(maxEntries, curEntriesCount); @@ -167,7 +167,7 @@ for(unsigned i = start; i < end; i++) { formatEntry(entry, dirEntries[i].name, (u32) maxLen - 2, true); - printf("\n%s %s", i == (unsigned) cursor_pos ? "*" : " ", entry); + uiPrintInfo("\n%s %s", i == (unsigned) cursor_pos ? "*" : " ", entry); } } diff --git a/source/arm9/menu_firmloader.c b/source/arm9/menu_firmloader.c index c4e2721..9f07452 100644 --- a/source/arm9/menu_firmloader.c +++ b/source/arm9/menu_firmloader.c @@ -33,7 +33,7 @@ uiClearConsoles(); consoleSelect(&con_top); - printf("FIRM Loader\n\n"); + uiPrintCenteredInLine(1, "FIRM Loader"); menuUpdateGlobalState(); @@ -41,8 +41,8 @@ { if(!quick) { - printf("\n\x1B[31mBad firmware.\e[0m\n\n"); - printf("Press any key...\n"); + uiPrintError("Bad firmware.\n"); + uiPrintInfo("Press any key...\n"); menuWaitForAnyPadkey(); } @@ -51,7 +51,7 @@ firmLoaded = 1; - printf("\n\x1B[32mFirmware verification SUCCESS!\e[0m\n\n"); + uiPrint("Firmware verification SUCCESS!", 32, true); menuSetReturnToState(MENU_STATE_EXIT); @@ -59,7 +59,7 @@ fail: - printf("FIRM-Launch aborted.\n"); + uiPrintCenteredInLine(25, "FIRM-Launch aborted."); TIMER_sleep(500); @@ -149,13 +149,13 @@ if(path) { if(fromMenu) - printf("\nBoot Option #%i:\n%s\n", i + 1, path); + uiPrintInfo("Boot Option #%i:\n%s\n", i + 1, path); // check if fw still exists if(!statFirmware(path)) { if(fromMenu) - printf("Couldn't find firmware...\n"); + uiPrintInfo("Couldn't find firmware...\n"); goto try_next; } @@ -171,8 +171,8 @@ { if(fromMenu) { - printf("Skipping, right buttons are not pressed.\n"); - printf("%" PRIX32 " %" PRIX32 "\n", padValue, expectedPadValue); + uiPrintInfo("Skipping, right buttons are not pressed.\n"); + uiPrintInfo("%" PRIX32 " %" PRIX32 "\n", padValue, expectedPadValue); } goto try_next; } @@ -239,7 +239,7 @@ if(f_stat(filePath, &fileStat) != FR_OK) { - printf("Failed to get file status!\n"); + uiPrintInfo("Failed to get file status!\n"); return 0; } @@ -247,7 +247,7 @@ if(f_open(&file, filePath, FA_READ) != FR_OK) { - printf("Failed to open '%s'!\n", filePath); + uiPrintInfo("Failed to open '%s'!\n", filePath); return 0; } @@ -259,7 +259,7 @@ if(f_read(&file, (u8*)FIRM_LOAD_ADDR, fileSize, &bytesRead) != FR_OK) { - printf("Failed to read from file!\n"); + uiPrintInfo("Failed to read from file!\n"); fileSize = 0; } diff --git a/source/arm9/menu_options.c b/source/arm9/menu_options.c index bdfaecf..2305e18 100644 --- a/source/arm9/menu_options.c +++ b/source/arm9/menu_options.c @@ -69,7 +69,7 @@ { if(i #include +#include #include "arm9/nandimage.h" #include "fatfs/ff.h" #include "util.h"