diff --git a/arm11/Makefile b/arm11/Makefile index 1ffe172..dbc4ac0 100644 --- a/arm11/Makefile +++ b/arm11/Makefile @@ -131,7 +131,7 @@ @$(OBJCOPY) --gap-fill 0xFF -O binary $< $@ @echo built ... $(notdir $@) -$(OFILES_SOURCES) : $(HFILES) +$(OFILES_SOURCES) : $(HFILES) $(INTERMEDIATE_ASSETS) $(OUTPUT).elf : $(OFILES) diff --git a/include/arm11/menu/menu_color.h b/include/arm11/menu/menu_color.h index 82abb22..c53ae9a 100644 --- a/include/arm11/menu/menu_color.h +++ b/include/arm11/menu/menu_color.h @@ -33,6 +33,7 @@ // colors for color scheme #define ESC_SCHEME_STD ESC_RESET ESC_FGCOLOR(7) ESC_BGCOLOR(0) +#define ESC_SCHEME_GOOD ESC_RESET ESC_FGCOLOR(2) ESC_BGCOLOR(0) ESC_BOLD #define ESC_SCHEME_WEAK ESC_RESET ESC_FGCOLOR(7) ESC_BGCOLOR(0) ESC_BOLD #define ESC_SCHEME_ACCENT0 ESC_RESET ESC_FGCOLOR(4) ESC_BGCOLOR(0) ESC_BOLD #define ESC_SCHEME_ACCENT1 ESC_RESET ESC_FGCOLOR(3) ESC_BGCOLOR(0) ESC_BOLD diff --git a/include/arm11/menu/menu_fb3ds.h b/include/arm11/menu/menu_fb3ds.h index e0464cc..e327f8f 100644 --- a/include/arm11/menu/menu_fb3ds.h +++ b/include/arm11/menu/menu_fb3ds.h @@ -112,8 +112,8 @@ "Boot Mode Setup", 3, &menuPresetBootMode, MENU_FLAG_CONFIG, { { "Set normal boot", DESC_BOOT_NORMAL, &menuSetBootMode, 0 }, - { "Set quiet boot", DESC_BOOT_QUIET, &menuSetBootMode, 1 }, - { "Set quick boot", DESC_BOOT_QUICK, &menuSetBootMode, 2 } + { "Set quick boot", DESC_BOOT_QUICK, &menuSetBootMode, 1 }, + { "Set quiet boot", DESC_BOOT_QUIET, &menuSetBootMode, 2 } } }, { // 7 diff --git a/source/arm11/console.c b/source/arm11/console.c index 9d60536..2ad6be7 100644 --- a/source/arm11/console.c +++ b/source/arm11/console.c @@ -25,8 +25,8 @@ RGB8_to_565( 64, 64, 64), // almost black RGB8_to_565(255, 0, 0), // bright red - RGB8_to_565( 0,255, 0), // bright green - RGB8_to_565(255,255, 32), // acccent yellow + RGB8_to_565( 64,255, 64), // accent green + RGB8_to_565(255,255, 32), // accent yellow RGB8_to_565( 64, 64,255), // accent blue RGB8_to_565(255, 0,255), // bright magenta RGB8_to_565( 0,255,255), // bright cyan diff --git a/source/arm11/hardware/hid.c b/source/arm11/hardware/hid.c index 897763e..77d4d02 100644 --- a/source/arm11/hardware/hid.c +++ b/source/arm11/hardware/hid.c @@ -39,8 +39,11 @@ void hidInit(void) { - const u32 mcuInterruptMask = 0xFFFF1800u; // Standard bitmask at cold boot - I2C_writeRegBuf(I2C_DEV_MCU, 0x18, (const u8*)&mcuInterruptMask, 4); + // When set after a reboot from TWL_FIRM while holding the HOME button this will + // cause the MCU to spam IRQs infinitely after releasing the HOME button. + // mcuBugs++ + //const u32 mcuInterruptMask = 0xFFFF1800u; // Standard bitmask at cold boot + //I2C_writeRegBuf(I2C_DEV_MCU, 0x18, (const u8*)&mcuInterruptMask, 4); IRQ_registerHandler(IRQ_MCU_HID, 14, 0, true, hidIrqHandler); GPIO_setBit(19, 9); // This enables the MCU HID IRQ diff --git a/source/arm11/main.c b/source/arm11/main.c index 7d8286c..23904c5 100644 --- a/source/arm11/main.c +++ b/source/arm11/main.c @@ -19,21 +19,23 @@ #include #include "types.h" #include "arm11/hardware/hardware.h" -#include "arm11/hardware/interrupt.h" #include "arm11/hardware/hid.h" -#include "arm11/power.h" +#include "arm11/hardware/interrupt.h" #include "arm11/hardware/i2c.h" #include "arm11/menu/menu.h" #include "arm11/menu/menu_fb3ds.h" #include "arm11/menu/menu_util.h" +#include "arm11/menu/splash.h" +#include "arm11/console.h" +#include "arm11/config.h" +#include "arm11/debug.h" +#include "arm11/firm.h" +#include "arm11/fmt.h" +#include "arm11/power.h" #include "hardware/pxi.h" #include "hardware/gfx.h" -#include "arm11/firm.h" -#include "arm11/console.h" -#include "arm11/debug.h" -#include "arm11/fmt.h" +#include "banner_spla.h" #include "fsutils.h" -#include "arm11/config.h" volatile bool g_continueBootloader = true; @@ -108,24 +110,44 @@ // ... or not if we already got a firmware waiting in line show_menu = show_menu || (!g_startFirmLaunch && ((bootmode == BootModeNormal) || hidIsHomeButtonHeldRaw())); + + // show splash if (bootmode != BootModeSilent) + if(show_menu || (bootmode != BootModeQuiet)) + { + u32 w, h; + s32 x, y; + + GFX_init(); + gfx_initialized = true; + + getSplashDimensions(banner_spla, &w, &h); + x = (SCREEN_WIDTH_TOP - w) >> 1; + y = (SCREEN_HEIGHT_TOP - h) >> 1; + + if (drawSplashscreen(banner_spla, x, y)) + { + for (u32 i = 0; i < 64; i++) // VBlank * 64 + GFX_waitForEvent(GFX_EVENT_PDC0, true); + } + } // main loop PrintConsole term_con; while(!g_startFirmLaunch) { - // init screens (if we'll need them below) - if((show_menu || err_string) && !gfx_initialized) + // init screens / console (if we'll need them below) + if(show_menu || err_string) { - GFX_init(); - // init and select terminal console - consoleInit(SCREEN_TOP, &term_con, true); - consoleSelect(&term_con); + if (!gfx_initialized) GFX_init(); gfx_initialized = true; + // init and select terminal console + consoleInit(SCREEN_TOP, &term_con, false); // <-- maybe not do this everytime? (!!!) + consoleSelect(&term_con); } // if there is an error, output it to screen - if (err_string) + if(err_string) { ee_printf("%s\nPress B or HOME to enter menu.\n", err_string); updateScreens(); diff --git a/source/arm11/menu/menu_func.c b/source/arm11/menu/menu_func.c index 1d05c05..a643273 100644 --- a/source/arm11/menu/menu_func.c +++ b/source/arm11/menu/menu_func.c @@ -267,7 +267,6 @@ if (param < 3) // loading from bootslot { // check if bootslot exists - ee_printf("Checking bootslot...\n"); if (!configDataExist(KBootOption1 + param)) { ee_printf("Bootslot does not exist!\n"); @@ -368,7 +367,7 @@ ee_snprintf(fpath, 64, NAND_BACKUP_PATH "/%02X%02X%02X%02X%02X%02X_%s_nand.bin", rtc[6], rtc[5], rtc[4], rtc[2], rtc[1], rtc[0], serial); - ee_printf("Creating NAND backup:\n%s\n\nPreparing NAND backup...\n", fpath); + ee_printf(ESC_SCHEME_ACCENT1 "Creating NAND backup:\n%s\n" ESC_RESET "\nPreparing NAND backup...\n", fpath); updateScreens(); @@ -382,7 +381,8 @@ } // reserve space for NAND backup - ee_printf("NAND size: %lli MiB\nReserving space...\n", nand_size / 0x0100000); + ee_printf("NAND size: %lli MiB\nBuffer size: %lu kiB\nReserving space...\n", + nand_size / 0x0100000, (u32) DEVICE_BUFSIZE / 0x400); updateScreens(); if ((fLseek(fHandle, nand_size) != 0) || (fTell(fHandle) != nand_size)) { @@ -415,7 +415,8 @@ { s64 readBytes = (nand_size - p > DEVICE_BUFSIZE) ? DEVICE_BUFSIZE : nand_size - p; s32 errcode = 0; - ee_printf_progress("NAND backup", PROGRESS_WIDTH, p, nand_size); + if (!(p % (DEVICE_BUFSIZE*4))) + ee_printf_progress("NAND backup", PROGRESS_WIDTH, p, nand_size); updateScreens(); if ((errcode = fReadToDeviceBuffer(devHandle, p, readBytes, dbufHandle)) != 0) @@ -443,7 +444,7 @@ // NAND access finalized ee_printf_progress("NAND backup", PROGRESS_WIDTH, nand_size, nand_size); - ee_printf("\n\nNAND backup finished.\n"); + ee_printf("\n" ESC_SCHEME_GOOD "NAND backup finished.\n" ESC_RESET); result = 0; @@ -462,6 +463,7 @@ if (result != 0) fUnlink(fpath); + hidScanInput(); // throw away any input from impatient users return result; } @@ -512,7 +514,7 @@ goto fail; } - ee_printf("Restoring NAND backup:\n%s\n\nPreparing NAND restore...\n", fpath); + ee_printf(ESC_SCHEME_ACCENT1 "Restoring NAND backup:\n%s\n" ESC_RESET "\nPreparing NAND restore...\n", fpath); updateScreens(); @@ -541,10 +543,12 @@ // check file size - ee_printf("File size: %lu MiB\n", fSize(fHandle) / 0x100000); + const s64 file_size = fSize(fHandle); + ee_printf("File size: %lu MiB\n", file_size / 0x100000); ee_printf("NAND size: %lli MiB\n", nand_size / 0x100000); + ee_printf("Buffer size: %lu kiB\n", (u32) DEVICE_BUFSIZE / 0x400); updateScreens(); - if (fSize(fHandle) > nand_size) + if (file_size > nand_size) { ee_printf("Size exceeds available space!\n"); goto fail_close_handles; @@ -560,11 +564,12 @@ // all done, ready to do the NAND backup ee_printf("\n"); - for (s64 p = 0; p < nand_size; p += DEVICE_BUFSIZE) + for (s64 p = 0; p < file_size; p += DEVICE_BUFSIZE) { - s64 readBytes = (nand_size - p > DEVICE_BUFSIZE) ? DEVICE_BUFSIZE : nand_size - p; + s64 readBytes = (file_size - p > DEVICE_BUFSIZE) ? DEVICE_BUFSIZE : file_size - p; s32 errcode = 0; - ee_printf_progress("NAND restore", PROGRESS_WIDTH, p, nand_size); + if (!(p % (DEVICE_BUFSIZE*4))) + ee_printf_progress("NAND restore", PROGRESS_WIDTH, p, file_size); updateScreens(); if ((errcode = fReadToDeviceBuffer(fHandle, p, readBytes, dbufHandle)) != 0) @@ -585,8 +590,8 @@ } // NAND access finalized - ee_printf_progress("NAND restore", PROGRESS_WIDTH, nand_size, nand_size); - ee_printf("\n\nNAND restore finished.\n"); + ee_printf_progress("NAND restore", PROGRESS_WIDTH, file_size, file_size); + ee_printf("\n" ESC_SCHEME_GOOD "NAND restore finished.\n" ESC_RESET); result = 0; diff --git a/source/arm11/menu/menu_util.c b/source/arm11/menu/menu_util.c index 80fef90..95c2ff1 100644 --- a/source/arm11/menu/menu_util.c +++ b/source/arm11/menu/menu_util.c @@ -195,7 +195,9 @@ for (; i < w; i++) res += ee_printf("\xB1"); ee_printf(ESC_RESET); - res += ee_printf(" | %lu%% || %llu / %llu MiB\r", prog_p, curr / 0x100000, max / 0x100000); + res += ee_printf(" | %s%lu%%%s | %s%llu / %llu MiB%s\r", + (curr == max) ? ESC_SCHEME_GOOD : "", prog_p, (curr == max) ? ESC_RESET : "", + (curr == max) ? ESC_SCHEME_GOOD : "", curr / 0x100000, max / 0x100000, (curr == max) ? ESC_RESET : ""); return res;