diff --git a/include/IO.h b/include/IO.h index b0eac38..5122831 100644 --- a/include/IO.h +++ b/include/IO.h @@ -1,6 +1,10 @@ #pragma once +/* CFG */ +#define CFG_REGS_BASE 0x10000000 +#define CFG_BOOTENV *((vu32 *)(CFG_REGS_BASE+0x10000)) +#define CFG_UNITINFO *((vu32 *)(CFG_REGS_BASE+0x10010)) /* PDN */ #define PDN_REGS_BASE 0x10140000 diff --git a/include/arm9/main.h b/include/arm9/main.h index e736639..ffa4377 100644 --- a/include/arm9/main.h +++ b/include/arm9/main.h @@ -6,8 +6,6 @@ };*/ - -extern bool unit_is_new3ds; // PrintConsole for each screen extern PrintConsole con_top, con_bottom; // SD card FAT fs instance @@ -15,6 +13,10 @@ // same for all NAND filesystems extern FATFS nand_twlnfs, nand_twlpfs, nand_fs; +extern bool unit_is_new3ds; +extern u8 boot_env; + + void heap_init(); void devs_init(); void devs_close(); diff --git a/source/arm9/main.c b/source/arm9/main.c index 7df9d08..05e9377 100644 --- a/source/arm9/main.c +++ b/source/arm9/main.c @@ -21,12 +21,14 @@ // same for all NAND fss FATFS nand_twlnfs, nand_twlpfs, nand_fs; -bool unit_is_new3ds; - +bool unit_is_new3ds; +u8 boot_env; int main(void) { u32 keys; + + hashCodeRoData(); // TODO: remove after debugging //Initialize console for both screen using the two different PrintConsole we have defined consoleInit(SCREEN_TOP, &con_top); @@ -140,7 +142,16 @@ if(PDN_MPCORE_CLKCNT != 0) unit_is_new3ds = true; - printf("%s3DS detected!\n", unit_is_new3ds ? "New " : ""); + bool is_panda = CFG_UNITINFO != 0; + + printf("%s%s 3DS detected!\n", is_panda ? "Dev " : "", + unit_is_new3ds ? "New" : "Original"); +} + +void boot_env_detect() +{ + boot_env = CFG_BOOTENV; + if(boot_env > 3) boot_env = 2; } u8 rng_get_byte() diff --git a/source/arm9/menu.c b/source/arm9/menu.c index 6f49e18..8eee1ab 100644 --- a/source/arm9/menu.c +++ b/source/arm9/menu.c @@ -25,8 +25,15 @@ static void menu_main_draw_top() { - const char *sd_res[2] = {"\x1B[31mNo ", "\x1B[32mYes"}; - const char *nand_res[2] = {"\x1B[31mError ", "\x1B[32mOK "}; + const char *sd_res[2] = {"\x1B[31mNo ", "\x1B[32mYes"}; + const char *nand_res[2] = {"\x1B[31mError ", "\x1B[32mOK "}; + const char *unit[2] = {"Original 3DS", "New 3DS"}; + const char *boot_environment [2] = { "Cold boot", // 0 + "Booted from Native FIRM", // 1 + "Booted from ", // 2, etc + "Booted from Legacy FIRM" // 3 + }; + bool sd_status, nand_status, wififlash_status; sd_status = dev_sdcard->is_active(); @@ -35,7 +42,10 @@ consoleSelect(&con_top); drawConsoleWindow(&con_top, 2, color); - printf("\n\t\t\t\t3DS Bootloader v0.1\n\n\n\n"); + printf("\n\t\t\t\t\t3DS Bootloader v0.1\n\n\n\n"); + + printf(" Model: %s\n", unit[unit_is_new3ds]); + printf(" \x1B[33m%s\e[0m\n\n", boot_environment[boot_env]); printf(" SD card inserted: %s\e[0m\n", sd_res[sd_status]); printf(" NAND status: %s\e[0m\n", nand_res[nand_status]); printf(" Wifi flash status: %s\e[0m", nand_res[wififlash_status]); @@ -64,7 +74,7 @@ int cursor_pos; // randomize color - color = (rng_get_byte() % 9) + 7; + color = (rng_get_byte() % 6) + 1; previous_states_count = 0;