Switch to enums for the options
This commit is contained in:
parent
63160a22a6
commit
da0adeb39e
@ -28,7 +28,7 @@ static void patchMemory(u8 *start, u32 size, const void *pattern, u32 patSize, i
|
||||
|
||||
static int fileOpen(IFile *file, FS_ArchiveID archiveId, const char *path, int flags)
|
||||
{
|
||||
FS_Path filePath = {PATH_ASCII, strnlen(path, PATH_MAX) + 1, path},
|
||||
FS_Path filePath = {PATH_ASCII, strnlen(path, 255) + 1, path},
|
||||
archivePath = {PATH_EMPTY, 1, (u8 *)""};
|
||||
|
||||
return IFile_Open(file, archiveId, archivePath, filePath, flags);
|
||||
@ -342,7 +342,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
case 0x0004001000027000LL: // KOR MSET
|
||||
case 0x0004001000028000LL: // TWN MSET
|
||||
{
|
||||
if(CONFIG_SHOWNAND)
|
||||
if(CONFIG(SHOWNAND))
|
||||
{
|
||||
static const u16 verPattern[] = u"Ver.";
|
||||
const u32 currentNand = BOOTCFG_NAND;
|
||||
@ -397,7 +397,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
sizeof(stopCartUpdatesPatch), 2
|
||||
);
|
||||
|
||||
u32 cpuSetting = CONFIG_NEWCPU;
|
||||
u32 cpuSetting = MULTICONFIG(NEWCPU);
|
||||
|
||||
if(cpuSetting != 0)
|
||||
{
|
||||
@ -498,7 +498,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
#ifdef DEV
|
||||
case 0x0004003000008A02LL: // ErrDisp
|
||||
{
|
||||
if(CONFIG_DEVOPTIONS == 0)
|
||||
if(MULTICONFIG(DEVOPTIONS) == 0)
|
||||
{
|
||||
static const u8 unitinfoCheckPattern1[] = {
|
||||
0x14, 0x00, 0xD0, 0xE5, 0xDB
|
||||
@ -532,7 +532,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
#endif
|
||||
|
||||
default:
|
||||
if(CONFIG_USELANGEMUANDCODE)
|
||||
if(CONFIG(USELANGEMUANDCODE))
|
||||
{
|
||||
u32 tidHigh = (progId & 0xFFFFFFF000000000LL) >> 0x24;
|
||||
|
||||
|
@ -2,21 +2,38 @@
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
#define PATH_MAX 255
|
||||
|
||||
#define CONFIG(a) (((info.config >> (a + 21)) & 1) != 0)
|
||||
#define MULTICONFIG(a) ((info.config >> (a * 2 + 7)) & 3)
|
||||
#define BOOTCONFIG(a, b) ((info.config >> a) & b)
|
||||
|
||||
#define BOOTCFG_NAND BOOTCONFIG(0, 7)
|
||||
#define BOOTCFG_FIRM BOOTCONFIG(3, 1)
|
||||
#define BOOTCFG_SAFEMODE BOOTCONFIG(6, 1)
|
||||
#define CONFIG_NEWCPU MULTICONFIG(3)
|
||||
#define CONFIG_USELANGEMUANDCODE CONFIG(2)
|
||||
#define CONFIG_SHOWNAND CONFIG(3)
|
||||
#define BOOTCFG_NAND BOOTCONFIG(0, 7)
|
||||
#define BOOTCFG_FIRM BOOTCONFIG(3, 1)
|
||||
#define BOOTCFG_A9LH BOOTCONFIG(4, 1)
|
||||
#define BOOTCFG_NOFORCEFLAG BOOTCONFIG(5, 1)
|
||||
#define BOOTCFG_SAFEMODE BOOTCONFIG(6, 1)
|
||||
|
||||
enum multiOptions
|
||||
{
|
||||
DEFAULTEMU = 0,
|
||||
BRIGHTNESS,
|
||||
PIN,
|
||||
NEWCPU
|
||||
#ifdef DEV
|
||||
#define CONFIG_DEVOPTIONS MULTICONFIG(4)
|
||||
, DEVOPTIONS
|
||||
#endif
|
||||
};
|
||||
|
||||
enum singleOptions
|
||||
{
|
||||
AUTOBOOTSYS = 0,
|
||||
USESYSFIRM,
|
||||
USELANGEMUANDCODE,
|
||||
SHOWNAND,
|
||||
SHOWGBABOOT,
|
||||
PAYLOADSPLASH
|
||||
#ifdef DEV
|
||||
, PATCHACCESS
|
||||
#endif
|
||||
};
|
||||
|
||||
void patchCode(u64 progId, u8 *code, u32 size);
|
@ -130,7 +130,7 @@ void configMenu(bool oldPinStatus)
|
||||
//Display all the multiple choice options in white
|
||||
for(u32 i = 0; i < multiOptionsAmount; i++)
|
||||
{
|
||||
if(!(i == CONFIG_NEWCPUINDEX && !isN3DS))
|
||||
if(!(i == NEWCPU && !isN3DS))
|
||||
{
|
||||
multiOptions[i].posY = endPos + SPACING_Y;
|
||||
endPos = drawString(multiOptionsText[i], 10, multiOptions[i].posY, COLOR_WHITE);
|
||||
@ -170,11 +170,11 @@ void configMenu(bool oldPinStatus)
|
||||
{
|
||||
case BUTTON_UP:
|
||||
if(!selectedOption) selectedOption = totalIndexes;
|
||||
else selectedOption = (selectedOption == CONFIG_NEWCPUINDEX + 1 && !isN3DS) ? selectedOption - 2 : selectedOption - 1;
|
||||
else selectedOption = (selectedOption == NEWCPU + 1 && !isN3DS) ? selectedOption - 2 : selectedOption - 1;
|
||||
break;
|
||||
case BUTTON_DOWN:
|
||||
if(selectedOption == totalIndexes) selectedOption = 0;
|
||||
else selectedOption = (selectedOption == CONFIG_NEWCPUINDEX - 1 && !isN3DS) ? selectedOption + 2 : selectedOption + 1;
|
||||
else selectedOption = (selectedOption == NEWCPU - 1 && !isN3DS) ? selectedOption + 2 : selectedOption + 1;
|
||||
break;
|
||||
case BUTTON_LEFT:
|
||||
selectedOption = 0;
|
||||
@ -218,7 +218,7 @@ void configMenu(bool oldPinStatus)
|
||||
drawCharacter(selected, 10 + multiOptions[selectedOption].posXs[oldEnabled] * SPACING_X, multiOptions[selectedOption].posY, COLOR_BLACK);
|
||||
multiOptions[selectedOption].enabled = (oldEnabled == 3 || !multiOptions[selectedOption].posXs[oldEnabled + 1]) ? 0 : oldEnabled + 1;
|
||||
|
||||
if(selectedOption == CONFIG_BRIGHTNESSINDEX) updateBrightness(multiOptions[CONFIG_BRIGHTNESSINDEX].enabled);
|
||||
if(selectedOption == BRIGHTNESS) updateBrightness(multiOptions[BRIGHTNESS].enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -238,7 +238,7 @@ void configMenu(bool oldPinStatus)
|
||||
}
|
||||
}
|
||||
|
||||
u32 oldPinLength = CONFIG_PIN;
|
||||
u32 oldPinLength = MULTICONFIG(PIN);
|
||||
|
||||
//Preserve the last-used boot options (last 12 bits)
|
||||
configData.config &= 0x3F;
|
||||
@ -249,7 +249,7 @@ void configMenu(bool oldPinStatus)
|
||||
for(u32 i = 0; i < singleOptionsAmount; i++)
|
||||
configData.config |= (singleOptions[i].enabled ? 1 : 0) << (i + 21);
|
||||
|
||||
if(CONFIG_PIN != 0) newPin(oldPinStatus && CONFIG_PIN == oldPinLength);
|
||||
if(MULTICONFIG(PIN) != 0) newPin(oldPinStatus && MULTICONFIG(PIN) == oldPinLength);
|
||||
else if(oldPinStatus) fileDelete(PIN_PATH);
|
||||
|
||||
//Wait for the pressed buttons to change
|
||||
|
@ -32,26 +32,35 @@
|
||||
#define CONFIG_VERSIONMAJOR 1
|
||||
#define CONFIG_VERSIONMINOR 3
|
||||
|
||||
#define CONFIG_BRIGHTNESSINDEX 1
|
||||
#define CONFIG_NEWCPUINDEX 3
|
||||
|
||||
#define BOOTCFG_NAND BOOTCONFIG(0, 7)
|
||||
#define BOOTCFG_FIRM BOOTCONFIG(3, 1)
|
||||
#define BOOTCFG_A9LH BOOTCONFIG(4, 1)
|
||||
#define BOOTCFG_NOFORCEFLAG BOOTCONFIG(5, 1)
|
||||
#define BOOTCFG_SAFEMODE BOOTCONFIG(6, 1)
|
||||
#define CONFIG_DEFAULTEMU MULTICONFIG(0)
|
||||
#define CONFIG_BRIGHTNESS MULTICONFIG(CONFIG_BRIGHTNESSINDEX)
|
||||
#define CONFIG_PIN MULTICONFIG(2)
|
||||
#define CONFIG_AUTOBOOTSYS CONFIG(0)
|
||||
#define CONFIG_USESYSFIRM CONFIG(1)
|
||||
#define CONFIG_SHOWGBABOOT CONFIG(4)
|
||||
#define CONFIG_PAYLOADSPLASH CONFIG(5)
|
||||
|
||||
enum multiOptions
|
||||
{
|
||||
DEFAULTEMU = 0,
|
||||
BRIGHTNESS,
|
||||
PIN,
|
||||
NEWCPU
|
||||
#ifdef DEV
|
||||
#define CONFIG_DEVOPTIONS MULTICONFIG(4)
|
||||
#define CONFIG_PATCHACCESS CONFIG(6)
|
||||
, DEVOPTIONS
|
||||
#endif
|
||||
};
|
||||
|
||||
enum singleOptions
|
||||
{
|
||||
AUTOBOOTSYS = 0,
|
||||
USESYSFIRM,
|
||||
USELANGEMUANDCODE,
|
||||
SHOWNAND,
|
||||
SHOWGBABOOT,
|
||||
PAYLOADSPLASH
|
||||
#ifdef DEV
|
||||
, PATCHACCESS
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
@ -64,8 +73,8 @@ typedef struct __attribute__((packed))
|
||||
typedef enum ConfigurationStatus
|
||||
{
|
||||
DONT_CONFIGURE = 0,
|
||||
MODIFY_CONFIGURATION = 1,
|
||||
CREATE_CONFIGURATION = 2
|
||||
MODIFY_CONFIGURATION,
|
||||
CREATE_CONFIGURATION
|
||||
} ConfigurationStatus;
|
||||
|
||||
extern CfgData configData;
|
||||
|
@ -120,7 +120,7 @@ void main(void)
|
||||
if(CFG_BOOTENV == 7)
|
||||
{
|
||||
nandType = FIRMWARE_SYSNAND;
|
||||
firmSource = CONFIG_USESYSFIRM ? FIRMWARE_SYSNAND : (FirmwareSource)BOOTCFG_FIRM;
|
||||
firmSource = CONFIG(USESYSFIRM) ? FIRMWARE_SYSNAND : (FirmwareSource)BOOTCFG_FIRM;
|
||||
needConfig = DONT_CONFIGURE;
|
||||
|
||||
//Flag to prevent multiple boot options-forcing
|
||||
@ -140,7 +140,7 @@ void main(void)
|
||||
//Boot options aren't being forced
|
||||
if(needConfig != DONT_CONFIGURE)
|
||||
{
|
||||
bool pinExists = CONFIG_PIN != 0 && verifyPin();
|
||||
bool pinExists = MULTICONFIG(PIN) != 0 && verifyPin();
|
||||
|
||||
//If no configuration file exists or SELECT is held, load configuration menu
|
||||
bool shouldLoadConfigMenu = needConfig == CREATE_CONFIGURATION || ((pressed & BUTTON_SELECT) && !(pressed & BUTTON_L1));
|
||||
@ -170,7 +170,7 @@ void main(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(CONFIG_PAYLOADSPLASH && loadSplash()) pressed = HID_PAD;
|
||||
if(CONFIG(PAYLOADSPLASH) && loadSplash()) pressed = HID_PAD;
|
||||
|
||||
/* If L and R/A/Select or one of the single payload buttons are pressed,
|
||||
chainload an external payload */
|
||||
@ -179,10 +179,10 @@ void main(void)
|
||||
|
||||
if(shouldLoadPayload) loadPayload(pressed);
|
||||
|
||||
if(!CONFIG_PAYLOADSPLASH) loadSplash();
|
||||
if(!CONFIG(PAYLOADSPLASH)) loadSplash();
|
||||
|
||||
//Determine if the user chose to use the SysNAND FIRM as default for a R boot
|
||||
bool useSysAsDefault = isA9lh ? CONFIG_USESYSFIRM : false;
|
||||
bool useSysAsDefault = isA9lh ? CONFIG(USESYSFIRM) : false;
|
||||
|
||||
//If R is pressed, boot the non-updated NAND with the FIRM of the opposite one
|
||||
if(pressed & BUTTON_R1)
|
||||
@ -195,7 +195,7 @@ void main(void)
|
||||
with their own FIRM */
|
||||
else
|
||||
{
|
||||
nandType = (CONFIG_AUTOBOOTSYS != !(pressed & BUTTON_L1)) ? FIRMWARE_EMUNAND : FIRMWARE_SYSNAND;
|
||||
nandType = (CONFIG(AUTOBOOTSYS) != !(pressed & BUTTON_L1)) ? FIRMWARE_EMUNAND : FIRMWARE_SYSNAND;
|
||||
firmSource = nandType;
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ void main(void)
|
||||
nandType = FIRMWARE_EMUNAND4;
|
||||
break;
|
||||
default:
|
||||
nandType = (FirmwareSource)(1 + CONFIG_DEFAULTEMU);
|
||||
nandType = (FirmwareSource)(1 + MULTICONFIG(DEFAULTEMU));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -407,9 +407,9 @@ static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32
|
||||
|
||||
#ifdef DEV
|
||||
//Apply UNITINFO patch
|
||||
if(CONFIG_DEVOPTIONS == 1) patchUnitInfoValueSet(arm9Section, section[2].size);
|
||||
if(MULTICONFIG(DEVOPTIONS) == 1) patchUnitInfoValueSet(arm9Section, section[2].size);
|
||||
|
||||
if(isA9lh && CONFIG_DEVOPTIONS != 2)
|
||||
if(isA9lh && MULTICONFIG(DEVOPTIONS) != 2)
|
||||
{
|
||||
//Install ARM11 exception handlers
|
||||
u32 codeSetOffset;
|
||||
@ -428,7 +428,7 @@ static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32
|
||||
patchKernel11Panic(arm11Section1, section[1].size);
|
||||
}
|
||||
|
||||
if(CONFIG_PATCHACCESS)
|
||||
if(CONFIG(PATCHACCESS))
|
||||
{
|
||||
patchArm11SvcAccessChecks(arm11SvcHandler);
|
||||
patchK11ModuleChecks(arm11Section1, section[1].size, &freeK11Space);
|
||||
@ -452,7 +452,7 @@ static inline void patchLegacyFirm(FirmwareType firmType)
|
||||
|
||||
#ifdef DEV
|
||||
//Apply UNITINFO patch
|
||||
if(CONFIG_DEVOPTIONS == 1) patchUnitInfoValueSet(arm9Section, section[3].size);
|
||||
if(MULTICONFIG(DEVOPTIONS) == 1) patchUnitInfoValueSet(arm9Section, section[3].size);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -471,7 +471,7 @@ static inline void patch1x2xNativeAndSafeFirm(void)
|
||||
else patchOldFirmWrites(arm9Section, section[2].size);
|
||||
|
||||
#ifdef DEV
|
||||
if(CONFIG_DEVOPTIONS != 2)
|
||||
if(MULTICONFIG(DEVOPTIONS) != 2)
|
||||
{
|
||||
//Kernel9/Process9 debugging
|
||||
patchArm9ExceptionHandlersInstall(arm9Section, section[2].size);
|
||||
|
@ -226,7 +226,7 @@ void applyLegacyFirmPatches(u8 *pos, FirmwareType firmType)
|
||||
/* 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 = firmType == TWL_FIRM ? (sizeof(twlPatches) / sizeof(patchData)) :
|
||||
(sizeof(agbPatches) / sizeof(patchData) - !CONFIG_SHOWGBABOOT);
|
||||
(sizeof(agbPatches) / sizeof(patchData) - !CONFIG(SHOWGBABOOT));
|
||||
const patchData *patches = firmType == TWL_FIRM ? twlPatches : agbPatches;
|
||||
|
||||
//Patch
|
||||
|
@ -55,7 +55,7 @@ void newPin(bool allowSkipping)
|
||||
//Pad to AES block length with zeroes
|
||||
u8 __attribute__((aligned(4))) enteredPassword[0x10] = {0};
|
||||
|
||||
u8 length = 4 + 2 * (CONFIG_PIN - 1),
|
||||
u8 length = 4 + 2 * (MULTICONFIG(PIN) - 1),
|
||||
cnt = 0;
|
||||
int charDrawPos = 5 * SPACING_X;
|
||||
|
||||
@ -112,7 +112,7 @@ bool verifyPin(void)
|
||||
memcmp(pin.magic, "PINF", 4) != 0 ||
|
||||
pin.formatVersionMajor != PIN_VERSIONMAJOR ||
|
||||
pin.formatVersionMinor != PIN_VERSIONMINOR ||
|
||||
pin.length != 4 + 2 * (CONFIG_PIN - 1))
|
||||
pin.length != 4 + 2 * (MULTICONFIG(PIN) - 1))
|
||||
return false;
|
||||
|
||||
u8 __attribute__((aligned(4))) zeroes[0x10] = {0};
|
||||
|
@ -147,7 +147,7 @@ void initScreens(void)
|
||||
//Disable interrupts
|
||||
__asm(".word 0xF10C01C0");
|
||||
|
||||
u32 brightnessLevel = brightness[CONFIG_BRIGHTNESS];
|
||||
u32 brightnessLevel = brightness[MULTICONFIG(BRIGHTNESS)];
|
||||
|
||||
*(vu32 *)0x10141200 = 0x1007F;
|
||||
*(vu32 *)0x10202014 = 0x00000001;
|
||||
@ -254,6 +254,6 @@ void initScreens(void)
|
||||
else
|
||||
{
|
||||
clearScreens();
|
||||
updateBrightness(CONFIG_BRIGHTNESS);
|
||||
updateBrightness(MULTICONFIG(BRIGHTNESS));
|
||||
}
|
||||
}
|
@ -40,17 +40,17 @@ typedef volatile u64 vu64;
|
||||
typedef enum FirmwareSource
|
||||
{
|
||||
FIRMWARE_SYSNAND = 0,
|
||||
FIRMWARE_EMUNAND = 1,
|
||||
FIRMWARE_EMUNAND2 = 2,
|
||||
FIRMWARE_EMUNAND3 = 3,
|
||||
FIRMWARE_EMUNAND4 = 4
|
||||
FIRMWARE_EMUNAND,
|
||||
FIRMWARE_EMUNAND2,
|
||||
FIRMWARE_EMUNAND3,
|
||||
FIRMWARE_EMUNAND4
|
||||
} FirmwareSource;
|
||||
|
||||
typedef enum FirmwareType
|
||||
{
|
||||
NATIVE_FIRM = 0,
|
||||
TWL_FIRM = 1,
|
||||
AGB_FIRM = 2,
|
||||
SAFE_FIRM = 3,
|
||||
NATIVE_FIRM1X2X = 4
|
||||
TWL_FIRM,
|
||||
AGB_FIRM,
|
||||
SAFE_FIRM,
|
||||
NATIVE_FIRM1X2X
|
||||
} FirmwareType;
|
Reference in New Issue
Block a user