Get rid of the PIN on/off toggle and add an Off status to the multi option, change the config layout to allow for more multi options, add macros for all options

This commit is contained in:
Aurora 2016-09-04 13:40:46 +02:00
parent 97ae8d2d44
commit 2b4e97bec5
9 changed files with 54 additions and 34 deletions

View File

@ -95,7 +95,7 @@ static void loadCFWInfo(void)
svcGetCFWInfo(&info);
IFile file;
if(BOOTCONFIG(5, 1) && R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, "/", FS_OPEN_READ))) //Init SD card if SAFE_MODE is being booted
if(BOOTCFG_SAFEMODE && R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, "/", FS_OPEN_READ))) //Init SD card if SAFE_MODE is being booted
IFile_Close(&file);
infoLoaded = true;
@ -360,7 +360,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
);
//Apply only if the updated NAND hasn't been booted
if((BOOTCONFIG(0, 3) != 0) == (BOOTCONFIG(2, 1) && CONFIG(1)))
if((BOOTCFG_NAND != 0) == (BOOTCFG_FIRM != 0 && CONFIG_USESYSFIRM))
{
static const u8 skipEshopUpdateCheckPattern[] = {
0x30, 0xB5, 0xF1, 0xB0
@ -404,7 +404,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
case 0x0004001000027000LL: // KOR MSET
case 0x0004001000028000LL: // TWN MSET
{
if(CONFIG(4))
if(CONFIG_SHOWNAND)
{
static const u16 verPattern[] = u"Ver.";
const u32 currentNand = BOOTCONFIG(0, 3);
@ -440,7 +440,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
sizeof(stopCartUpdatesPatch), 2
);
u32 cpuSetting = MULTICONFIG(2);
u32 cpuSetting = CONFIG_NEWCPU;
if(cpuSetting)
{
@ -539,7 +539,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
}
default:
if(CONFIG(3))
if(CONFIG_USELANGEMUANDCODE)
{
u32 tidHigh = (progId & 0xFFFFFFF000000000LL) >> 0x24;

View File

@ -4,8 +4,16 @@
#define PATH_MAX 255
#define CONFIG(a) (((info.config >> (a + 16)) & 1) != 0)
#define CONFIG(a) (((info.config >> (a + 20)) & 1) != 0)
#define MULTICONFIG(a) ((info.config >> (a * 2 + 6)) & 3)
#define BOOTCONFIG(a, b) ((info.config >> a) & b)
#define BOOTCFG_NAND BOOTCONFIG(0, 3)
#define BOOTCFG_FIRM BOOTCONFIG(2, 1)
#define BOOTCFG_SAFEMODE BOOTCONFIG(5, 1)
#define CONFIG_NEWCPU MULTICONFIG(2)
#define CONFIG_USESYSFIRM CONFIG(1)
#define CONFIG_USELANGEMUANDCODE CONFIG(3)
#define CONFIG_SHOWNAND CONFIG(4)
void patchCode(u64 progId, u8 *code, u32 size);

View File

@ -72,7 +72,7 @@ void configMenu(bool oldPinStatus)
drawString("Press A to select, START to save", 10, 30, COLOR_WHITE);
const char *multiOptionsText[] = { "Screen brightness: 4( ) 3( ) 2( ) 1( )",
"PIN length: 4( ) 5( ) 6( ) 7( )",
"PIN lock: Off( ) 4( ) 6( ) 8( ) digits",
"New 3DS CPU: Off( ) Clock( ) L2( ) Clock+L2( )" };
const char *singleOptionsText[] = { "( ) Autoboot SysNAND",
@ -81,8 +81,7 @@ void configMenu(bool oldPinStatus)
"( ) Enable region/language emu. and ext. .code",
"( ) Show current NAND in System Settings",
"( ) Show GBA boot screen in patched AGB_FIRM",
"( ) Display splash screen before payloads",
"( ) Use a PIN" };
"( ) Display splash screen before payloads" };
struct multiOption {
int posXs[4];
@ -223,7 +222,7 @@ void configMenu(bool oldPinStatus)
}
}
u32 oldPinLength = MULTICONFIG(1);
u32 oldPinLength = CONFIG_PIN;
//Preserve the last-used boot options (last 12 bits)
configData.config &= 0x3F;
@ -232,9 +231,9 @@ void configMenu(bool oldPinStatus)
for(u32 i = 0; i < multiOptionsAmount; i++)
configData.config |= multiOptions[i].enabled << (i * 2 + 6);
for(u32 i = 0; i < singleOptionsAmount; i++)
configData.config |= (singleOptions[i].enabled ? 1 : 0) << (i + 16);
configData.config |= (singleOptions[i].enabled ? 1 : 0) << (i + 20);
if(CONFIG(7)) newPin(oldPinStatus && MULTICONFIG(1) == oldPinLength);
if(CONFIG_PIN != 0) newPin(oldPinStatus && CONFIG_PIN == oldPinLength);
else if(oldPinStatus) fileDelete(PIN_PATH);
//Wait for the pressed buttons to change

View File

@ -24,13 +24,26 @@
#include "types.h"
#define CONFIG(a) (((configData.config >> (a + 16)) & 1) != 0)
#define CONFIG(a) (((configData.config >> (a + 20)) & 1) != 0)
#define MULTICONFIG(a) ((configData.config >> (a * 2 + 6)) & 3)
#define BOOTCONFIG(a, b) ((configData.config >> a) & b)
#define CONFIG_PATH "/luma/config.bin"
#define CONFIG_VERSIONMAJOR 1
#define CONFIG_VERSIONMINOR 1
#define CONFIG_VERSIONMINOR 2
#define BOOTCFG_NAND BOOTCONFIG(0, 3)
#define BOOTCFG_FIRM BOOTCONFIG(2, 1)
#define BOOTCFG_A9LH BOOTCONFIG(3, 1)
#define BOOTCFG_NOFORCEFLAG BOOTCONFIG(4, 1)
#define BOOTCFG_SAFEMODE BOOTCONFIG(5, 1)
#define CONFIG_BRIGHTNESS MULTICONFIG(0)
#define CONFIG_PIN MULTICONFIG(1)
#define CONFIG_AUTOBOOTSYS CONFIG(0)
#define CONFIG_USESYSFIRM CONFIG(1)
#define CONFIG_USESECONDEMU CONFIG(2)
#define CONFIG_SHOWGBABOOT CONFIG(5)
#define CONFIG_PAYLOADSPLASH CONFIG(6)
typedef struct __attribute__((packed))
{

View File

@ -82,9 +82,9 @@ void main(void)
//'0' = NATIVE_FIRM, '1' = TWL_FIRM, '2' = AGB_FIRM
firmType = launchedFirmTidLow[7] == u'3' ? SAFE_FIRM : (FirmwareType)(launchedFirmTidLow[5] - u'0');
nandType = (FirmwareSource)BOOTCONFIG(0, 3);
firmSource = (FirmwareSource)BOOTCONFIG(2, 1);
isA9lh = BOOTCONFIG(3, 1) != 0;
nandType = (FirmwareSource)BOOTCFG_NAND;
firmSource = (FirmwareSource)BOOTCFG_FIRM;
isA9lh = BOOTCFG_A9LH != 0;
}
else
{
@ -107,7 +107,7 @@ void main(void)
if(CFG_BOOTENV == 7)
{
nandType = FIRMWARE_SYSNAND;
firmSource = CONFIG(1) ? FIRMWARE_SYSNAND : (FirmwareSource)BOOTCONFIG(2, 1);
firmSource = CONFIG_USESYSFIRM ? FIRMWARE_SYSNAND : (FirmwareSource)BOOTCFG_FIRM;
needConfig = DONT_CONFIGURE;
//Flag to prevent multiple boot options-forcing
@ -116,10 +116,10 @@ void main(void)
/* Else, force the last used boot options unless a button is pressed
or the no-forcing flag is set */
else if(needConfig != CREATE_CONFIGURATION && !pressed && !BOOTCONFIG(4, 1))
else if(needConfig != CREATE_CONFIGURATION && !pressed && !BOOTCFG_NOFORCEFLAG)
{
nandType = (FirmwareSource)BOOTCONFIG(0, 3);
firmSource = (FirmwareSource)BOOTCONFIG(2, 1);
nandType = (FirmwareSource)BOOTCFG_NAND;
firmSource = (FirmwareSource)BOOTCFG_FIRM;
needConfig = DONT_CONFIGURE;
}
}
@ -127,7 +127,7 @@ void main(void)
//Boot options aren't being forced
if(needConfig != DONT_CONFIGURE)
{
bool pinExists = CONFIG(7) && verifyPin();
bool pinExists = CONFIG_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));
@ -157,7 +157,7 @@ void main(void)
}
else
{
if(CONFIG(6) && 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 */
@ -165,10 +165,10 @@ void main(void)
if(shouldLoadPayload) loadPayload(pressed);
if(!CONFIG(6)) 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(1) : 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)
@ -181,13 +181,13 @@ void main(void)
with their own FIRM */
else
{
nandType = (CONFIG(0) != !(pressed & BUTTON_L1)) ? FIRMWARE_EMUNAND : FIRMWARE_SYSNAND;
nandType = (CONFIG_AUTOBOOTSYS != !(pressed & BUTTON_L1)) ? FIRMWARE_EMUNAND : FIRMWARE_SYSNAND;
firmSource = nandType;
}
/* If we're booting emuNAND the second emuNAND is set as default and B isn't pressed,
or vice-versa, boot the second emuNAND */
if(nandType != FIRMWARE_SYSNAND && (CONFIG(2) == !(pressed & BUTTON_B))) nandType = FIRMWARE_EMUNAND2;
if(nandType != FIRMWARE_SYSNAND && (CONFIG_USESECONDEMU == !(pressed & BUTTON_B))) nandType = FIRMWARE_EMUNAND2;
}
}
}
@ -244,7 +244,7 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource)
if(firmSource != FIRMWARE_SYSNAND)
error("An old unsupported EmuNAND has been detected.\nLuma3DS is unable to boot it");
if(BOOTCONFIG(5, 1)) error("SAFE_MODE is not supported on 1.x/2.x FIRM");
if(BOOTCFG_SAFEMODE) error("SAFE_MODE is not supported on 1.x/2.x FIRM");
*firmType = NATIVE_FIRM1X2X;
}

View File

@ -189,7 +189,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(5));
(sizeof(agbPatches) / sizeof(patchData) - !CONFIG_SHOWGBABOOT);
const patchData *patches = firmType == TWL_FIRM ? twlPatches : agbPatches;
//Patch

View File

@ -56,7 +56,7 @@ void newPin(bool allowSkipping)
//Pad to AES block length with zeroes
u8 __attribute__((aligned(4))) enteredPassword[0x10] = {0};
u8 length = 4 + MULTICONFIG(1),
u8 length = 4 + 2 * (CONFIG_PIN - 1),
cnt = 0;
int charDrawPos = 5 * SPACING_X;
@ -113,7 +113,7 @@ bool verifyPin(void)
memcmp(pin.magic, "PINF", 4) != 0 ||
pin.formatVersionMajor != PIN_VERSIONMAJOR ||
pin.formatVersionMinor != PIN_VERSIONMINOR ||
pin.length != 4 + MULTICONFIG(1))
pin.length != 4 + 2 * (CONFIG_PIN - 1))
return false;
u8 __attribute__((aligned(4))) zeroes[0x10] = {0};

View File

@ -32,7 +32,7 @@
#define PIN_PATH "/luma/pin.bin"
#define PIN_VERSIONMAJOR 1
#define PIN_VERSIONMINOR 1
#define PIN_VERSIONMINOR 2
typedef struct __attribute__((packed))
{

View File

@ -147,7 +147,7 @@ void initScreens(void)
//Disable interrupts
__asm(".word 0xF10C01C0");
u32 brightnessLevel = brightness[MULTICONFIG(0)];
u32 brightnessLevel = brightness[CONFIG_BRIGHTNESS];
*(vu32 *)0x10141200 = 0x1007F;
*(vu32 *)0x10202014 = 0x00000001;
@ -254,6 +254,6 @@ void initScreens(void)
else
{
clearScreens();
updateBrightness(MULTICONFIG(0));
updateBrightness(CONFIG_BRIGHTNESS);
}
}