From f7bbc4bfec3c39dc368526af24f4a30c40fd2f68 Mon Sep 17 00:00:00 2001 From: Aurora Date: Mon, 4 Apr 2016 01:08:42 +0200 Subject: [PATCH] Made the AGB_FIRM splash screen optional Apparently it causes compatibility issues --- source/firm.c | 20 ++++++++++++++------ source/utils.c | 10 +++++++--- source/utils.h | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/source/firm.c b/source/firm.c index a4b849a..0436005 100755 --- a/source/firm.c +++ b/source/firm.c @@ -38,7 +38,8 @@ static u32 firmSize, selectedFirm, usePatchedFirm, emuOffset, - emuHeader; + emuHeader, + config; void setupCFW(void) { @@ -56,8 +57,13 @@ void setupCFW(void) //Attempt to read the configuration file const char configPath[] = "/aurei/config.bin"; - u32 config = 0, - needConfig = fileRead(&config, configPath, 3) ? 1 : 2; + u32 needConfig; + if(fileRead(&config, configPath, 3)) needConfig = 1; + else + { + config = 0; + needConfig = 2; + } //Determine if A9LH is installed and the user has an updated sysNAND u32 updatedSys; @@ -114,7 +120,7 @@ void setupCFW(void) //If no configuration file exists or SELECT is held, load configuration menu if(needConfig == 2 || (pressed & BUTTON_SELECT)) - configureCFW(configPath, patchedFirms[3]); + configureCFW(configPath, patchedFirms); //If screens are inited, load splash screen if(PDN_GPU_CNT != 1) loadSplash(); @@ -261,8 +267,10 @@ static inline void patchTwlAgb(u32 mode) {{0xD7A12, 0xD8B8A}, { .type1 = 0xEF26 }, 1} }; - //Calculate the amount of patches to apply - u32 numPatches = mode ? (sizeof(agbPatches) / sizeof(struct patchData)) : (sizeof(twlPatches) / sizeof(struct patchData)); + /* Calculate the amount of patches to apply. Only count the splash screen patch for AGB_FIRM + if the matching option was enabled (keep it as last) */ + u32 numPatches = mode ? (sizeof(agbPatches) / sizeof(struct patchData)) - !((config >> 6) & 1) : + (sizeof(twlPatches) / sizeof(struct patchData)); const struct patchData *patches = mode ? agbPatches : twlPatches; //Patch diff --git a/source/utils.c b/source/utils.c index 29094f6..98604dc 100644 --- a/source/utils.c +++ b/source/utils.c @@ -46,7 +46,7 @@ static u32 waitInput(void) return key; } -void configureCFW(const char *configPath, const char *firm90Path) +void configureCFW(const char *configPath, const char *patchedFirms[]) { initScreens(); @@ -58,7 +58,8 @@ void configureCFW(const char *configPath, const char *firm90Path) "( ) Force A9LH detection", "( ) Use 9.0 FIRM as default", "( ) Use second EmuNAND as default", - "( ) Show current NAND in System Settings" }; + "( ) Show current NAND in System Settings", + "( ) Show splash screen in patched AGB_FIRM" }; u32 optionsAmount = sizeof(optionsText) / sizeof(char *); struct option options[optionsAmount]; @@ -112,7 +113,10 @@ void configureCFW(const char *configPath, const char *firm90Path) } //If the user has been using A9LH and the "Updated SysNAND" setting changed, delete the patched 9.0 FIRM - if(((tempConfig >> 16) & 1) && ((tempConfig & 1) != options[0].enabled)) fileDelete(firm90Path); + if(((tempConfig >> 16) & 1) && ((tempConfig & 1) != options[0].enabled)) fileDelete(patchedFirms[3]); + + //If the "Show splash screen in patched AGB_FIRM" setting changed, delete the patched AGB_FIRM + if(((tempConfig >> 6) & 1) != options[6].enabled) fileDelete(patchedFirms[5]); //Preserve the last-used boot options (last 12 bits) tempConfig &= 0xFFF000; diff --git a/source/utils.h b/source/utils.h index e64482a..0e257cf 100644 --- a/source/utils.h +++ b/source/utils.h @@ -10,6 +10,6 @@ #define CFG_BOOTENV (*(vu32 *)0x10010000) -void configureCFW(const char *configPath, const char *firm90Path); +void configureCFW(const char *configPath, const char *patchedFirms[]); void deleteFirms(const char *firmPaths[], u32 firms); void error(const char *message); \ No newline at end of file