diff --git a/source/config.c b/source/config.c index 69387170..671ef422 100644 --- a/source/config.c +++ b/source/config.c @@ -29,9 +29,9 @@ #include "buttons.h" #include "pin.h" -bool readConfig(const char *configPath) +bool readConfig(void) { - if(fileRead(&configData, configPath) != sizeof(cfgData) || + if(fileRead(&configData, CONFIG_PATH) != sizeof(cfgData) || memcmp(configData.magic, "CONF", 4) != 0 || configData.formatVersionMajor != CONFIG_VERSIONMAJOR || configData.formatVersionMinor != CONFIG_VERSIONMINOR) @@ -43,7 +43,7 @@ bool readConfig(const char *configPath) return true; } -void writeConfig(const char *configPath, u32 configTemp, ConfigurationStatus needConfig) +void writeConfig(ConfigurationStatus needConfig, u32 configTemp) { /* If the configuration is different from previously, overwrite it. Just the no-forcing flag being set is not enough */ @@ -59,7 +59,7 @@ void writeConfig(const char *configPath, u32 configTemp, ConfigurationStatus nee //Merge the new options and new boot configuration configData.config = (configData.config & 0xFFFFFFC0) | (configTemp & 0x3F); - if(!fileWrite(&configData, configPath, sizeof(cfgData))) + if(!fileWrite(&configData, CONFIG_PATH, sizeof(cfgData))) error("Error writing the configuration file"); } } diff --git a/source/config.h b/source/config.h index a9f0036c..74e5128c 100644 --- a/source/config.h +++ b/source/config.h @@ -24,11 +24,13 @@ #include "types.h" -#define CONFIG(a) (((configData.config >> (a + 16)) & 1) != 0) -#define MULTICONFIG(a) ((configData.config >> (a * 2 + 6)) & 3) +#define CONFIG(a) (((configData.config >> (a + 16)) & 1) != 0) +#define MULTICONFIG(a) ((configData.config >> (a * 2 + 6)) & 3) #define BOOTCONFIG(a, b) ((configData.config >> a) & b) #define DEV_OPTIONS MULTICONFIG(2) + +#define CONFIG_PATH "/luma/config.bin" #define CONFIG_VERSIONMAJOR 1 #define CONFIG_VERSIONMINOR 0 @@ -49,6 +51,6 @@ typedef enum ConfigurationStatus extern cfgData configData; -bool readConfig(const char *configPath); -void writeConfig(const char *configPath, u32 configTemp, ConfigurationStatus needConfig); +bool readConfig(void); +void writeConfig(ConfigurationStatus needConfig, u32 configTemp); void configMenu(bool oldPinStatus); \ No newline at end of file diff --git a/source/firm.c b/source/firm.c index 8fa6e8a7..15933204 100755 --- a/source/firm.c +++ b/source/firm.c @@ -71,10 +71,8 @@ void main(void) //Mount filesystems. CTRNAND will be mounted only if/when needed mountFs(); - const char configPath[] = "/luma/config.bin"; - //Attempt to read the configuration file - needConfig = readConfig(configPath) ? MODIFY_CONFIGURATION : CREATE_CONFIGURATION; + needConfig = readConfig() ? MODIFY_CONFIGURATION : CREATE_CONFIGURATION; if(DEV_OPTIONS != 2) { @@ -216,7 +214,7 @@ void main(void) if(!isFirmlaunch) { configTemp |= (u32)nandType | ((u32)firmSource << 2); - writeConfig(configPath, configTemp, needConfig); + writeConfig(needConfig, configTemp); } u32 firmVersion = loadFirm(&firmType, firmSource); diff --git a/source/fs.h b/source/fs.h index feba3ab8..c7e3d432 100644 --- a/source/fs.h +++ b/source/fs.h @@ -24,7 +24,7 @@ #include "types.h" -#define PATTERN(a) a "_*.bin" +#define PATTERN(a) a "_*.bin" extern bool isN3DS; diff --git a/source/pin.c b/source/pin.c index e46a1d3e..8b30d757 100644 --- a/source/pin.c +++ b/source/pin.c @@ -95,7 +95,7 @@ void newPin(bool allowSkipping) computePinHash(tmp, enteredPassword, (PIN_LENGTH + 15) / 16); memcpy(pin.hash, tmp, 32); - if(!fileWrite(&pin, "/luma/pin.bin", sizeof(PINData))) + if(!fileWrite(&pin, PIN_PATH, sizeof(PINData))) error("Error writing the PIN file"); } @@ -105,7 +105,7 @@ bool verifyPin(void) PINData pin; - if(fileRead(&pin, "/luma/pin.bin") != sizeof(PINData) || + if(fileRead(&pin, PIN_PATH) != sizeof(PINData) || memcmp(pin.magic, "PINF", 4) != 0 || pin.formatVersionMajor != PIN_VERSIONMAJOR || pin.formatVersionMinor != PIN_VERSIONMINOR) diff --git a/source/pin.h b/source/pin.h index b8aa6ded..65acd14a 100644 --- a/source/pin.h +++ b/source/pin.h @@ -30,7 +30,8 @@ #include "types.h" -#define PIN_LENGTH 4 +#define PIN_LENGTH 4 +#define PIN_PATH "/luma/pin.bin" #define PIN_VERSIONMAJOR 1 #define PIN_VERSIONMINOR 0 diff --git a/source/screen.h b/source/screen.h index 720d01e1..a7cb528f 100644 --- a/source/screen.h +++ b/source/screen.h @@ -29,10 +29,10 @@ #include "types.h" -#define PDN_GPU_CNT (*(vu8 *)0x10141200) +#define PDN_GPU_CNT (*(vu8 *)0x10141200) -#define ARM11_STUB_ADDRESS (0x25000000 - 0x30) //It's currently only 0x28 bytes large. We're putting 0x30 just to be sure here -#define WAIT_FOR_ARM9() *arm11Entry = 0; while(!*arm11Entry); ((void (*)())*arm11Entry)(); +#define ARM11_STUB_ADDRESS (0x25000000 - 0x30) //It's currently only 0x28 bytes large. We're putting 0x30 just to be sure here +#define WAIT_FOR_ARM9() *arm11Entry = 0; while(!*arm11Entry); ((void (*)())*arm11Entry)(); static volatile struct fb { u8 *top_left;