diff --git a/assets/bootfail.png b/assets/bootfail.png new file mode 100644 index 0000000..d2ab652 --- /dev/null +++ b/assets/bootfail.png Binary files differ diff --git a/assets/bootwarning.png b/assets/bootwarning.png new file mode 100644 index 0000000..21651f1 --- /dev/null +++ b/assets/bootwarning.png Binary files differ diff --git a/data/bootfail.ppm.bin b/data/bootfail.ppm.bin new file mode 100644 index 0000000..1d6b929 --- /dev/null +++ b/data/bootfail.ppm.bin Binary files differ diff --git a/data/bootwarning.ppm.bin b/data/bootwarning.ppm.bin new file mode 100644 index 0000000..808647f --- /dev/null +++ b/data/bootwarning.ppm.bin Binary files differ diff --git a/include/arm9/console.h b/include/arm9/console.h index 3ad9d42..b49476a 100644 --- a/include/arm9/console.h +++ b/include/arm9/console.h @@ -179,6 +179,7 @@ void consoleSetCursor(PrintConsole* console, int x, int y); +void drawConsoleWindow(PrintConsole* console, int thickness, u8 colorIndex); #ifdef __cplusplus } diff --git a/include/arm9/ui.h b/include/arm9/ui.h index b508d83..6375076 100644 --- a/include/arm9/ui.h +++ b/include/arm9/ui.h @@ -26,3 +26,5 @@ //void uiShowMessageWindow(format, args...); void uiPrintProgressBar(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int cur, unsigned int max); +void uiPrintBootWarning(); +void uiPrintBootFailure(); diff --git a/source/arm9/dev.c b/source/arm9/dev.c index b855eef..ccd73d3 100644 --- a/source/arm9/dev.c +++ b/source/arm9/dev.c @@ -128,7 +128,7 @@ if(!sdmmc_sd_is_active()) { - TIMER_sleep(250.4f); // Wait until the SD bus times out + TIMER_sleep(300); // Wait until the SD bus times out if(!sdmmc_sd_is_active()) return false; // Check again if a SD card is inserted } diff --git a/source/arm9/menu_firmloader.c b/source/arm9/menu_firmloader.c index f2907df..08d248d 100644 --- a/source/arm9/menu_firmloader.c +++ b/source/arm9/menu_firmloader.c @@ -133,7 +133,8 @@ firmLoaded = 0; - printf("Loading FIRM from settings\n\n"); + if(fromMenu) + uiPrintCenteredInLine(2, "Loading FIRM from settings"); // No Boot Option set up? if(!configDataExist(KBootOption1) && @@ -163,12 +164,14 @@ path = (const char *)configGetData(keyBootOption); if(path) { - printf("\nBoot Option #%i:\n%s\n", i + 1, path); + if(fromMenu) + printf("\nBoot Option #%i:\n%s\n", i + 1, path); // check if fw still exists if(!statFirmware(path)) { - printf("Couldn't find firmware...\n"); + if(fromMenu) + printf("Couldn't find firmware...\n"); goto try_next; } @@ -182,8 +185,11 @@ padValue = HID_KEY_MASK_ALL & hidKeysHeld(); if(padValue != expectedPadValue) { - printf("Skipping, right buttons are not pressed.\n"); - printf("%" PRIX32 " %" PRIX32 "\n", padValue, expectedPadValue); + if(fromMenu) + { + printf("Skipping, right buttons are not pressed.\n"); + printf("%" PRIX32 " %" PRIX32 "\n", padValue, expectedPadValue); + } goto try_next; } } @@ -204,7 +210,8 @@ break; else { - printf("Bad firmware, trying next one...\n"); + if(keyBootMode != BootModeQuiet) + uiPrintBootWarning(); } } } @@ -223,6 +230,8 @@ { if(fromMenu) menuSetReturnToState(STATE_PREVIOUS); + else if(keyBootMode != BootModeQuiet) + uiPrintBootFailure(); return false; } diff --git a/source/arm9/ui.c b/source/arm9/ui.c index c2ae7ac..645fe30 100644 --- a/source/arm9/ui.c +++ b/source/arm9/ui.c @@ -10,12 +10,16 @@ #include "arm9/ui.h" #include "arm9/console.h" #include "banner_ppm_bin.h" +#include "bootwarning_ppm_bin.h" +#include "bootfail_ppm_bin.h" static u8 randomColor; static bool verbose = false; static const void *bannerData = banner_ppm_bin; +static const void *bootWarningData = bootwarning_ppm_bin; +static const void *bootFailureData = bootfail_ppm_bin; static void uiGetPPMInfo(const u8 *data, unsigned *width, unsigned *height); @@ -294,11 +298,7 @@ unsigned width, height; /* get image dimensions */ - const char *ptr = (const char *) data + 3; - while(*ptr != 0x0A) ptr++; - ptr++; - - sscanf(ptr, "%i %i", &width, &height); + uiGetPPMInfo(data, &width, &height); const u8 *imagedata = data + 0x26; // skip ppm header @@ -314,3 +314,41 @@ } } } + +static void clearPPM(unsigned start_x, unsigned start_y, const u8 *data) +{ + unsigned width, height; + + /* get image dimensions */ + uiGetPPMInfo(data, &width, &height); + + u16 color = 0; + + for(unsigned x = 0; x < width; x++) + { + for(unsigned y = height; y > 0; y--) + { + drawPixel(start_x + x, start_y + height - y, color); + } + } +} + +void uiPrintBootWarning() +{ + unsigned width, height; + + uiGetPPMInfo(bootWarningData, &width, &height); + uiDrawPPM((SCREEN_WIDTH_TOP - width) / 2, SCREEN_HEIGHT_TOP + 10, bootWarningData); + TIMER_sleep(400); +} + +void uiPrintBootFailure() +{ + unsigned width, height; + + uiGetPPMInfo(bootWarningData, &width, &height); + clearPPM((SCREEN_WIDTH_TOP - width) / 2, SCREEN_HEIGHT_TOP + 10, bootWarningData); + uiGetPPMInfo(bootFailureData, &width, &height); + uiDrawPPM((SCREEN_WIDTH_TOP - width) / 2, SCREEN_HEIGHT_TOP + 10, bootFailureData); + TIMER_sleep(400); +}