From f619dafff1cbdeee506ba7e0eacda2346811c13f Mon Sep 17 00:00:00 2001 From: Aurora Wright Date: Sun, 20 Aug 2017 17:00:47 +0200 Subject: [PATCH] Added displaying boot source and loader on the bottom screen in the config --- source/config.c | 8 +++++++- source/config.h | 2 +- source/main.c | 28 +++++++++++++++++++--------- source/types.h | 13 +++++++++++-- 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/source/config.c b/source/config.c index 6cf4516..49ded2e 100644 --- a/source/config.c +++ b/source/config.c @@ -239,8 +239,14 @@ void configMenu(bool oldPinStatus, u32 oldPinMode) initScreens(); - drawFormattedString(true, 10, 10, COLOR_TITLE, "%s%s", CONFIG_TITLE, isNtrcardBoot ? " (ntrboot)" : ""); + static const char *bootTypes[] = { "B9S", + "B9S (ntrboothax)", + "FIRM0", + "FIRM1" }; + + drawString(true, 10, 10, COLOR_TITLE, CONFIG_TITLE); drawString(true, 10, 10 + SPACING_Y, COLOR_TITLE, "Press A to select, START to save"); + drawFormattedString(false, 10, SCREEN_HEIGHT - 2 * SPACING_Y, COLOR_YELLOW, "Booted from %s via %s", isSdMode ? "SD" : "CTRNAND", bootTypes[(u32)bootType]); //Character to display a selected option char selected = 'x'; diff --git a/source/config.h b/source/config.h index 730b269..ae913dd 100644 --- a/source/config.h +++ b/source/config.h @@ -34,7 +34,7 @@ #define CONFIG_FILE "config.bin" #define CONFIG_VERSIONMAJOR 2 -#define CONFIG_VERSIONMINOR 0 +#define CONFIG_VERSIONMINOR 1 #define BOOTCFG_NAND BOOTCONFIG(0, 7) #define BOOTCFG_FIRM BOOTCONFIG(3, 7) diff --git a/source/main.c b/source/main.c index 8499b29..1e14cf7 100644 --- a/source/main.c +++ b/source/main.c @@ -43,9 +43,9 @@ extern ConfigurationStatus needConfig; extern FirmwareSource firmSource; bool isFirmlaunch = false, - isSdMode, - isNtrcardBoot; + isSdMode; u16 launchedPath[41]; +BootType bootType; void main(int argc, char **argv, u32 magicWord) { @@ -58,7 +58,7 @@ void main(int argc, char **argv, u32 magicWord) const vu32 *bootPartitionsStatus = (const vu32 *)0x1FFFE010; //Shell closed, no error booting NTRCARD, NAND paritions not even considered - isNtrcardBoot = bootMediaStatus[3] == 2 && !bootMediaStatus[1] && !bootPartitionsStatus[0] && !bootPartitionsStatus[1]; + bootType = (bootMediaStatus[3] == 2 && !bootMediaStatus[1] && !bootPartitionsStatus[0] && !bootPartitionsStatus[1]) ? NTR : B9S; if((magicWord & 0xFFFF) == 0xBEEF && argc >= 1) //Normal (B9S) boot { @@ -79,9 +79,19 @@ void main(int argc, char **argv, u32 magicWord) } else if(magicWord == 0xB002) //FIRM/NTRCARD boot { - if(!isNtrcardBoot) + if(bootType != NTR) { - const char *path = !((vu8 *)bootPartitionsStatus)[2] ? "firm1:" : "firm0:"; + const char *path; + if(!((vu8 *)bootPartitionsStatus)[2]) + { + bootType = FIRM0; + path = "firm0:"; + } + else + { + bootType = FIRM1; + path = "firm1:"; + } for(u32 i = 0; i < 7; i++) //Copy and convert the path to UTF-16 launchedPath[i] = path[i]; @@ -100,7 +110,7 @@ void main(int argc, char **argv, u32 magicWord) if(!mountFs(false, true)) error("Failed to mount CTRNAND."); isSdMode = false; } - else if(memcmp(launchedPath, u"firm", 8) == 0 || isNtrcardBoot) + else if(bootType != B9S) { setupKeyslots(); @@ -120,7 +130,7 @@ void main(int argc, char **argv, u32 magicWord) error("Launched from an unsupported location: %s.", mountPoint); } - if(isNtrcardBoot && magicWord == 0xB002) + if(bootType == NTR && magicWord == 0xB002) { loadHomebrewFirm(0); mcuPowerOff(); @@ -158,7 +168,7 @@ void main(int argc, char **argv, u32 magicWord) installArm9Handlers(); firmType = NATIVE_FIRM; - isFirmProtEnabled = !isNtrcardBoot; + isFirmProtEnabled = bootType != NTR; //Get pressed buttons u32 pressed = HID_PAD; @@ -301,7 +311,7 @@ boot: if(!isFirmlaunch) { - configData.bootConfig = ((u32)isNtrcardBoot << 7) | ((u32)isNoForceFlagSet << 6) | ((u32)firmSource << 3) | (u32)nandType; + configData.bootConfig = ((bootType == NTR ? 1 : 0) << 7) | ((u32)isNoForceFlagSet << 6) | ((u32)firmSource << 3) | (u32)nandType; writeConfig(false); } diff --git a/source/types.h b/source/types.h index f3ec2e7..c80952d 100644 --- a/source/types.h +++ b/source/types.h @@ -114,9 +114,18 @@ typedef enum FirmwareType NATIVE_FIRM1X2X } FirmwareType; +typedef enum bootType +{ + B9S = 0, + NTR, + FIRM0, + FIRM1 +} BootType; + extern bool isFirmlaunch, - isSdMode, - isNtrcardBoot; + isSdMode; + +extern BootType bootType; extern u16 launchedFirmTidLow[8]; extern u16 launchedPath[41];