Small changes, added a macro for reading options
This commit is contained in:
parent
e882dd7aaf
commit
4180261f1f
2
Makefile
2
Makefile
@ -95,7 +95,7 @@ $(dir_build)/main.elf: $(objects_cfw)
|
||||
# FatFs requires libgcc for __aeabi_uidiv
|
||||
$(CC) -nostartfiles $(LDFLAGS) -T linker.ld $(OUTPUT_OPTION) $^
|
||||
|
||||
$(dir_build)/memory.o : CFLAGS+=-O3
|
||||
$(dir_build)/memory.o : CFLAGS += -O3
|
||||
$(dir_build)/config.o : CFLAGS += -DCONFIG_TITLE="\"$(name) $(version) configuration\""
|
||||
|
||||
$(dir_build)/%.o: $(dir_source)/%.c $(dir_build)/patches.h $(dir_build)/loader.h $(dir_build)/screeninit.h
|
||||
|
@ -116,13 +116,13 @@ bytes_read: .word 0
|
||||
fopen: .ascii "OPEN"
|
||||
.pool
|
||||
firm_fname: .dcw "sdmc:/aurei/patched_firmware_sys.bin"
|
||||
.word 0x0
|
||||
.word 0
|
||||
.pool
|
||||
twlfirm_fname: .dcw "sdmc:/aurei/patched_firmware_twl.bin"
|
||||
.word 0x0
|
||||
.word 0
|
||||
.pool
|
||||
agbfirm_fname: .dcw "sdmc:/aurei/patched_firmware_agb.bin"
|
||||
.word 0x0
|
||||
.word 0
|
||||
|
||||
.align 4
|
||||
kernelcode_start:
|
||||
|
@ -3,7 +3,7 @@
|
||||
void main(void)
|
||||
{
|
||||
const u32 brightness[4] = {0x5F, 0x4C, 0x39, 0x26};
|
||||
u32 brightnessLevel = *(vu32 *)0x24F04000;
|
||||
u32 brightnessLevel = *(vu32 *)0x24F03008;
|
||||
vu32 *const arm11 = (u32 *)0x1FFFFFF8;
|
||||
|
||||
*(vu32 *)0x10141200 = 0x1007F;
|
||||
|
@ -6,3 +6,5 @@ _start:
|
||||
CPSID aif
|
||||
|
||||
b main
|
||||
|
||||
.word 0
|
@ -37,9 +37,9 @@ void configureCFW(const char *configPath, const char *patchedFirms[])
|
||||
} options[optionsAmount];
|
||||
|
||||
//Parse the existing configuration
|
||||
options[0].enabled = (config >> 10) & 3;
|
||||
options[0].enabled = CONFIG(10, 3);
|
||||
for(u32 i = optionsAmount; i; i--)
|
||||
options[i].enabled = (config >> (i - 1)) & 1;
|
||||
options[i].enabled = CONFIG((i - 1), 1);
|
||||
|
||||
//Pre-select the first configuration option
|
||||
u32 selectedOption = 1,
|
||||
@ -65,7 +65,7 @@ void configureCFW(const char *configPath, const char *patchedFirms[])
|
||||
u32 pressed = 0;
|
||||
|
||||
do {
|
||||
//An option changed, black out the 'x' for the previously selected option/brightness level
|
||||
//The status of the selected option changed, black out the previously visible 'x' if needed
|
||||
if(optionChanged)
|
||||
{
|
||||
if(!selectedOption)
|
||||
@ -116,9 +116,13 @@ void configureCFW(const char *configPath, const char *patchedFirms[])
|
||||
selectedOption = optionsAmount - 1;
|
||||
break;
|
||||
case BUTTON_A:
|
||||
optionChanged = 1 + options[0].enabled;
|
||||
optionChanged = 1;
|
||||
if(selectedOption) options[selectedOption].enabled = !options[selectedOption].enabled;
|
||||
else options[0].enabled = options[0].enabled == 3 ? 0 : options[0].enabled + 1;
|
||||
else
|
||||
{
|
||||
optionChanged += options[0].enabled;
|
||||
options[0].enabled = options[0].enabled == 3 ? 0 : options[0].enabled + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -126,10 +130,10 @@ void configureCFW(const char *configPath, const char *patchedFirms[])
|
||||
}
|
||||
|
||||
//If the user has been using A9LH and the "Updated SysNAND" setting changed, delete the patched 9.0 FIRM
|
||||
if(((config >> 16) & 1) && ((config & 1) != options[1].enabled)) fileDelete(patchedFirms[3]);
|
||||
if(CONFIG(16, 1) && (CONFIG(0, 1) != options[1].enabled)) fileDelete(patchedFirms[3]);
|
||||
|
||||
//If the "Show GBA boot screen in patched AGB_FIRM" setting changed, delete the patched AGB_FIRM
|
||||
if(((config >> 6) & 1) != options[7].enabled) fileDelete(patchedFirms[5]);
|
||||
if(CONFIG(6, 1) != options[7].enabled) fileDelete(patchedFirms[5]);
|
||||
|
||||
//Preserve the last-used boot options (last 12 bits)
|
||||
config &= 0xFFF000;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "types.h"
|
||||
|
||||
#define CFG_BOOTENV (*(vu32 *)0x10010000)
|
||||
#define CONFIG(a, b) ((config >> a) & b)
|
||||
|
||||
u32 config;
|
||||
|
||||
|
@ -68,7 +68,7 @@ void setupCFW(void)
|
||||
//Determine if A9LH is installed and the user has an updated sysNAND
|
||||
u32 updatedSys;
|
||||
|
||||
if(a9lhBoot || (config >> 2) & 1)
|
||||
if(a9lhBoot || CONFIG(2, 1))
|
||||
{
|
||||
if(pressed == SAFE_MODE)
|
||||
error("Using Safe Mode would brick you, or remove A9LH!");
|
||||
@ -76,7 +76,7 @@ void setupCFW(void)
|
||||
a9lhSetup = 1;
|
||||
|
||||
//Check setting for > 9.2 sysNAND
|
||||
updatedSys = config & 1;
|
||||
updatedSys = CONFIG(0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -93,7 +93,7 @@ void setupCFW(void)
|
||||
//Always force a sysNAND boot when quitting AGB_FIRM
|
||||
if(previousFirm == 7)
|
||||
{
|
||||
mode = updatedSys ? 1 : (config >> 12) & 1;
|
||||
mode = updatedSys ? 1 : CONFIG(12, 1);
|
||||
emuNAND = 0;
|
||||
needConfig = 0;
|
||||
|
||||
@ -102,10 +102,10 @@ void setupCFW(void)
|
||||
}
|
||||
/* Else, force the last used boot options unless a payload button or A/L/R are pressed
|
||||
or the no-forcing flag is set */
|
||||
else if(!(pressed & OVERRIDE_BUTTONS) && !((config >> 15) & 1))
|
||||
else if(!(pressed & OVERRIDE_BUTTONS) && !CONFIG(15, 1))
|
||||
{
|
||||
mode = (config >> 12) & 1;
|
||||
emuNAND = (config >> 13) & 3;
|
||||
mode = CONFIG(12, 1);
|
||||
emuNAND = CONFIG(13, 3);
|
||||
needConfig = 0;
|
||||
}
|
||||
}
|
||||
@ -124,12 +124,12 @@ void setupCFW(void)
|
||||
configureCFW(configPath, patchedFirms);
|
||||
|
||||
//If screens are inited or the corresponding option is set, load splash screen
|
||||
if(PDN_GPU_CNT != 1 || ((config >> 7) & 1)) loadSplash();
|
||||
if(PDN_GPU_CNT != 1 || CONFIG(7, 1)) loadSplash();
|
||||
|
||||
/* If L is pressed, or L or R are not pressed when it is the default FIRM,
|
||||
boot 9.0 FIRM */
|
||||
mode = ((config >> 3) & 1) ? ((!(pressed & BUTTON_L1R1)) ? 0 : 1) :
|
||||
((pressed & BUTTON_L1) ? 0 : 1);
|
||||
mode = CONFIG(3, 1) ? ((!(pressed & BUTTON_L1R1)) ? 0 : 1) :
|
||||
((pressed & BUTTON_L1) ? 0 : 1);
|
||||
|
||||
/* If L or R aren't pressed on a 9.0/9.2 sysNAND, or the 9.0 FIRM is selected
|
||||
or R is pressed on a > 9.2 sysNAND, boot emuNAND */
|
||||
@ -137,7 +137,7 @@ void setupCFW(void)
|
||||
{
|
||||
/* If not 9.0 FIRM and the second emuNAND is set as default and B isn't pressed, or vice-versa,
|
||||
attempt to boot it */
|
||||
emuNAND = (mode && ((!(pressed & BUTTON_B)) == ((config >> 4) & 1))) ? 2 : 1;
|
||||
emuNAND = (mode && ((!(pressed & BUTTON_B)) == CONFIG(4, 1))) ? 2 : 1;
|
||||
}
|
||||
else emuNAND = 0;
|
||||
|
||||
@ -147,7 +147,7 @@ void setupCFW(void)
|
||||
deleteFirms(patchedFirms, sizeof(patchedFirms) / sizeof(char *));
|
||||
}
|
||||
|
||||
u32 usePatchedFirmSet = ((config >> 1) & 1);
|
||||
u32 usePatchedFirmSet = CONFIG(1, 1);
|
||||
|
||||
while(1)
|
||||
{
|
||||
@ -271,7 +271,7 @@ static inline void patchTwlAgb(u32 whichFirm)
|
||||
|
||||
/* Calculate the amount of patches to apply. Only count the boot screen patch for AGB_FIRM
|
||||
if the matching option was enabled (keep it as last) */
|
||||
u32 numPatches = whichFirm ? (sizeof(agbPatches) / sizeof(patchData)) - !((config >> 6) & 1) :
|
||||
u32 numPatches = whichFirm ? (sizeof(agbPatches) / sizeof(patchData) - !CONFIG(6, 1)) :
|
||||
(sizeof(twlPatches) / sizeof(patchData));
|
||||
const patchData *patches = whichFirm ? agbPatches : twlPatches;
|
||||
|
||||
|
@ -51,11 +51,11 @@ void initScreens(void)
|
||||
{
|
||||
if(PDN_GPU_CNT == 1)
|
||||
{
|
||||
//Write brightness level for the stub to pick up
|
||||
*(vu32 *)0x24F04000 = (config >> 10) & 3;
|
||||
|
||||
memcpy((void *)SCREENINIT_ADDRESS, screeninit, screeninit_size);
|
||||
|
||||
//Write brightness level for the stub to pick up
|
||||
*(vu32 *)(SCREENINIT_ADDRESS + 8) = CONFIG(10, 3);
|
||||
|
||||
*arm11 = SCREENINIT_ADDRESS;
|
||||
while(*arm11);
|
||||
|
||||
|
Reference in New Issue
Block a user