Revamp config format, add saving of Rosalina opt.

(menu combo & 3dsx title ID)
This commit is contained in:
TuxSH 2017-06-18 22:31:21 +02:00
parent 2363817265
commit 17828273a5
18 changed files with 188 additions and 65 deletions

View File

@ -5,9 +5,9 @@
#define MAKE_BRANCH(src,dst) (0xEA000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF)) #define MAKE_BRANCH(src,dst) (0xEA000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF))
#define MAKE_BRANCH_LINK(src,dst) (0xEB000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF)) #define MAKE_BRANCH_LINK(src,dst) (0xEB000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF))
#define CONFIG(a) (((cfwInfo.config >> (a + 17)) & 1) != 0) #define CONFIG(a) (((cfwInfo.config >> (a)) & 1) != 0)
#define MULTICONFIG(a) ((cfwInfo.config >> (a * 2 + 7)) & 3) #define MULTICONFIG(a) ((cfwInfo.multiConfig >> (2 * (a))) & 3)
#define BOOTCONFIG(a, b) ((cfwInfo.config >> a) & b) #define BOOTCONFIG(a, b) ((cfwInfo.bootConfig >> (a)) & (b))
#define BOOTCFG_NAND BOOTCONFIG(0, 7) #define BOOTCFG_NAND BOOTCONFIG(0, 7)
#define BOOTCFG_FIRM BOOTCONFIG(3, 7) #define BOOTCFG_FIRM BOOTCONFIG(3, 7)

View File

@ -113,7 +113,7 @@ extern void (*initFPU)(void);
extern void (*mcuReboot)(void); extern void (*mcuReboot)(void);
extern void (*coreBarrier)(void); extern void (*coreBarrier)(void);
typedef struct PACKED CfwInfo typedef struct CfwInfo
{ {
char magic[4]; char magic[4];
@ -124,7 +124,10 @@ typedef struct PACKED CfwInfo
u32 commitHash; u32 commitHash;
u32 config; u16 configFormatVersionMajor, configFormatVersionMinor;
u32 config, multiConfig, bootConfig;
u64 hbldr3dsxTitleId;
u32 rosalinaMenuCombo;
} CfwInfo; } CfwInfo;
extern CfwInfo cfwInfo; extern CfwInfo cfwInfo;

View File

@ -278,5 +278,4 @@ void main(FcramLayout *layout, KCoreContext *ctxs)
rosalinaState = 0; rosalinaState = 0;
hasStartedRosalinaNetworkFuncsOnce = false; hasStartedRosalinaNetworkFuncsOnce = false;
//wat(0xAA, criticalSectionLock);
} }

View File

@ -46,18 +46,35 @@ Result GetSystemInfoHook(s64 *out, s32 type, s32 param)
*out = cfwInfo.commitHash; *out = cfwInfo.commitHash;
break; break;
case 2: case 2:
*out = (cfwInfo.configFormatVersionMajor << 16) | cfwInfo.configFormatVersionMinor;
break;
case 3:
*out = cfwInfo.config; *out = cfwInfo.config;
break; break;
case 3: // isRelease case 4:
*out = cfwInfo.multiConfig;
break;
case 5:
*out = cfwInfo.bootConfig;
break;
case 0x100:
*out = (s64)cfwInfo.hbldr3dsxTitleId;
break;
case 0x101:
*out = cfwInfo.rosalinaMenuCombo;
break;
case 0x200: // isRelease
*out = cfwInfo.flags & 1; *out = cfwInfo.flags & 1;
break; break;
case 4: // isN3DS case 0x201: // isN3DS
*out = (cfwInfo.flags >> 4) & 1; *out = (cfwInfo.flags >> 4) & 1;
break; break;
case 5: // isSafeMode case 0x202: // isSafeMode
*out = (cfwInfo.flags >> 5) & 1; *out = (cfwInfo.flags >> 5) & 1;
break; break;
case 6: // isSdMode case 0x203: // isSdMode
*out = (cfwInfo.flags >> 6) & 1; *out = (cfwInfo.flags >> 6) & 1;
break; break;
default: default:

View File

@ -35,7 +35,7 @@
CfgData configData; CfgData configData;
ConfigurationStatus needConfig; ConfigurationStatus needConfig;
static u32 oldConfig; static CfgData oldConfig;
bool readConfig(void) bool readConfig(void)
{ {
@ -46,13 +46,13 @@ bool readConfig(void)
configData.formatVersionMajor != CONFIG_VERSIONMAJOR || configData.formatVersionMajor != CONFIG_VERSIONMAJOR ||
configData.formatVersionMinor != CONFIG_VERSIONMINOR) configData.formatVersionMinor != CONFIG_VERSIONMINOR)
{ {
configData.config = 0; memset(&configData, 0, sizeof(CfgData));
ret = false; ret = false;
} }
else ret = true; else ret = true;
oldConfig = configData.config; oldConfig = configData;
return ret; return ret;
} }
@ -61,8 +61,8 @@ void writeConfig(bool isConfigOptions)
{ {
/* If the configuration is different from previously, overwrite it. /* If the configuration is different from previously, overwrite it.
Just the no-forcing flag being set is not enough */ Just the no-forcing flag being set is not enough */
if(needConfig != CREATE_CONFIGURATION && ((isConfigOptions && (configData.config & 0xFFFFFF00) == (oldConfig & 0xFFFFFF00)) || if(needConfig != CREATE_CONFIGURATION && ((isConfigOptions && configData.config == oldConfig.config && configData.multiConfig == oldConfig.multiConfig) ||
(!isConfigOptions && (configData.config & 0xBF) == (oldConfig & 0xFF)))) return; (!isConfigOptions && (configData.bootConfig & ~0x40) == oldConfig.bootConfig))) return;
if(needConfig == CREATE_CONFIGURATION) if(needConfig == CREATE_CONFIGURATION)
{ {
@ -383,14 +383,15 @@ void configMenu(bool oldPinStatus, u32 oldPinMode)
else if(singleOptions[singleSelected].enabled) drawCharacter(true, 10 + SPACING_X, singleOptions[singleSelected].posY, COLOR_RED, selected); else if(singleOptions[singleSelected].enabled) drawCharacter(true, 10 + SPACING_X, singleOptions[singleSelected].posY, COLOR_RED, selected);
} }
//Preserve the last-used boot options (first 9 bits) //Preserve the last-used boot options
configData.config &= 0x7F;
//Parse and write the new configuration //Parse and write the new configuration
configData.multiConfig = 0;
for(u32 i = 0; i < multiOptionsAmount; i++) for(u32 i = 0; i < multiOptionsAmount; i++)
configData.config |= multiOptions[i].enabled << (i * 2 + 7); configData.multiConfig |= multiOptions[i].enabled << (i * 2);
configData.config = 0;
for(u32 i = 0; i < singleOptionsAmount; i++) for(u32 i = 0; i < singleOptionsAmount; i++)
configData.config |= (singleOptions[i].enabled ? 1 : 0) << (i + 17); configData.config |= (singleOptions[i].enabled ? 1 : 0) << i;
u32 newPinMode = MULTICONFIG(PIN); u32 newPinMode = MULTICONFIG(PIN);

View File

@ -28,13 +28,13 @@
#include "types.h" #include "types.h"
#define CONFIG(a) (((configData.config >> (a + 17)) & 1) != 0) #define CONFIG(a) (((configData.config >> (a)) & 1) != 0)
#define MULTICONFIG(a) ((configData.config >> (a * 2 + 7)) & 3) #define MULTICONFIG(a) ((configData.multiConfig >> (2 * (a))) & 3)
#define BOOTCONFIG(a, b) ((configData.config >> a) & b) #define BOOTCONFIG(a, b) ((configData.bootConfig >> (a)) & (b))
#define CONFIG_FILE "config.bin" #define CONFIG_FILE "config.bin"
#define CONFIG_VERSIONMAJOR 1 #define CONFIG_VERSIONMAJOR 2
#define CONFIG_VERSIONMINOR 13 #define CONFIG_VERSIONMINOR 0
#define BOOTCFG_NAND BOOTCONFIG(0, 7) #define BOOTCFG_NAND BOOTCONFIG(0, 7)
#define BOOTCFG_FIRM BOOTCONFIG(3, 7) #define BOOTCFG_FIRM BOOTCONFIG(3, 7)

View File

@ -279,7 +279,7 @@ boot:
if(!isFirmlaunch) if(!isFirmlaunch)
{ {
configData.config = (configData.config & 0xFFFFFF80) | ((u32)isNoForceFlagSet << 6) | ((u32)firmSource << 3) | (u32)nandType; configData.bootConfig = ((u32)isNoForceFlagSet << 6) | ((u32)firmSource << 3) | (u32)nandType;
writeConfig(false); writeConfig(false);
} }

View File

@ -122,8 +122,11 @@ u32 installK11Extension(u8 *pos, u32 size, bool isSafeMode, u32 baseK11VA, u32 *
u32 commitHash; u32 commitHash;
u32 config; u16 configFormatVersionMajor, configFormatVersionMinor;
} __attribute__((packed)) info; u32 config, multiConfig, bootConfig;
u64 hbldr3dsxTitleId;
u32 rosalinaMenuCombo;
} info;
}; };
static const u8 patternHook1[] = {0x02, 0xC2, 0xA0, 0xE3, 0xFF}; //MMU setup hook static const u8 patternHook1[] = {0x02, 0xC2, 0xA0, 0xE3, 0xFF}; //MMU setup hook
@ -185,7 +188,13 @@ u32 installK11Extension(u8 *pos, u32 size, bool isSafeMode, u32 baseK11VA, u32 *
struct CfwInfo *info = &p->info; struct CfwInfo *info = &p->info;
memcpy(&info->magic, "LUMA", 4); memcpy(&info->magic, "LUMA", 4);
info->commitHash = COMMIT_HASH; info->commitHash = COMMIT_HASH;
info->configFormatVersionMajor = configData.formatVersionMajor;
info->configFormatVersionMinor = configData.formatVersionMinor;
info->config = configData.config; info->config = configData.config;
info->multiConfig = configData.multiConfig;
info->bootConfig = configData.bootConfig;
info->hbldr3dsxTitleId = configData.hbldr3dsxTitleId;
info->rosalinaMenuCombo = configData.rosalinaMenuCombo;
info->versionMajor = VERSION_MAJOR; info->versionMajor = VERSION_MAJOR;
info->versionMinor = VERSION_MINOR; info->versionMinor = VERSION_MINOR;
info->versionBuild = VERSION_BUILD; info->versionBuild = VERSION_BUILD;

View File

@ -66,7 +66,9 @@ typedef struct __attribute__((packed))
char magic[4]; char magic[4];
u16 formatVersionMajor, formatVersionMinor; u16 formatVersionMajor, formatVersionMinor;
u32 config; u32 config, multiConfig, bootConfig;
u64 hbldr3dsxTitleId;
u32 rosalinaMenuCombo;
} CfgData; } CfgData;
typedef struct __attribute__((packed)) typedef struct __attribute__((packed))

View File

@ -6,7 +6,7 @@
#include "ifile.h" #include "ifile.h"
#include "../build/bundled.h" #include "../build/bundled.h"
static u32 config; static u32 config, multiConfig, bootConfig;
static bool isN3DS, isSafeMode, isSdMode; static bool isN3DS, isSafeMode, isSdMode;
static u32 patchMemory(u8 *start, u32 size, const void *pattern, u32 patSize, s32 offset, const void *replace, u32 repSize, u32 count) static u32 patchMemory(u8 *start, u32 size, const void *pattern, u32 patSize, s32 offset, const void *replace, u32 repSize, u32 count)
@ -80,13 +80,18 @@ static inline void loadCFWInfo(void)
if(infoLoaded) return; if(infoLoaded) return;
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 2))) svcBreak(USERBREAK_ASSERT); if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 3))) svcBreak(USERBREAK_ASSERT);
config = (u32)out; config = (u32)out;
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 4))) svcBreak(USERBREAK_ASSERT); if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 4))) svcBreak(USERBREAK_ASSERT);
isN3DS = (bool)out; multiConfig = (u32)out;
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 5))) svcBreak(USERBREAK_ASSERT); if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 5))) svcBreak(USERBREAK_ASSERT);
bootConfig = (u32)out;
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 0x201))) svcBreak(USERBREAK_ASSERT);
isN3DS = (bool)out;
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 0x202))) svcBreak(USERBREAK_ASSERT);
isSafeMode = (bool)out; isSafeMode = (bool)out;
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 6))) svcBreak(USERBREAK_ASSERT); if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 0x203))) svcBreak(USERBREAK_ASSERT);
isSdMode = (bool)out; isSdMode = (bool)out;
IFile file; IFile file;

View File

@ -5,9 +5,9 @@
#define MAKE_BRANCH(src,dst) (0xEA000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF)) #define MAKE_BRANCH(src,dst) (0xEA000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF))
#define MAKE_BRANCH_LINK(src,dst) (0xEB000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF)) #define MAKE_BRANCH_LINK(src,dst) (0xEB000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF))
#define CONFIG(a) (((config >> (a + 17)) & 1) != 0) #define CONFIG(a) (((config >> (a)) & 1) != 0)
#define MULTICONFIG(a) ((config >> (a * 2 + 7)) & 3) #define MULTICONFIG(a) ((multiConfig >> (2 * (a))) & 3)
#define BOOTCONFIG(a, b) ((config >> a) & b) #define BOOTCONFIG(a, b) ((bootConfig >> (a)) & (b))
#define BOOTCFG_NAND BOOTCONFIG(0, 7) #define BOOTCFG_NAND BOOTCONFIG(0, 7)
#define BOOTCFG_FIRM BOOTCONFIG(3, 7) #define BOOTCFG_FIRM BOOTCONFIG(3, 7)

View File

@ -33,6 +33,7 @@ extern Menu miscellaneousMenu;
void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void); void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void);
void MiscellaneousMenu_ChangeMenuCombo(void); void MiscellaneousMenu_ChangeMenuCombo(void);
void MiscellaneousMenu_SaveSettings(void);
void MiscellaneousMenu_InputRedirection(void); void MiscellaneousMenu_InputRedirection(void);
void MiscellaneousMenu_PowerOff(void); void MiscellaneousMenu_PowerOff(void);
void MiscellaneousMenu_Reboot(void); void MiscellaneousMenu_Reboot(void);

View File

@ -78,7 +78,7 @@ GDB_DECLARE_XFER_OSDATA_HANDLER(CfwVersion)
svcGetSystemInfo(&out, 0x10000, 1); svcGetSystemInfo(&out, 0x10000, 1);
commitHash = (u32)out; commitHash = (u32)out;
svcGetSystemInfo(&out, 0x10000, 3); svcGetSystemInfo(&out, 0x10000, 0x200);
isRelease = (bool)out; isRelease = (bool)out;
if(GET_VERSION_REVISION(version) == 0) if(GET_VERSION_REVISION(version) == 0)

View File

@ -34,6 +34,7 @@
#include "utils.h" #include "utils.h"
#include "MyThread.h" #include "MyThread.h"
#include "menus/process_patches.h" #include "menus/process_patches.h"
#include "menus/miscellaneous.h"
// this is called before main // this is called before main
bool isN3DS; bool isN3DS;
@ -43,9 +44,6 @@ void __appInit()
fsregInit(); fsregInit();
fsSysInit(); fsSysInit();
s64 dummy;
isN3DS = svcGetSystemInfo(&dummy, 0x10001, 0) == 0;
} }
// this is called after main exits // this is called after main exits
@ -74,8 +72,19 @@ void __ctru_exit()
void initSystem() void initSystem()
{ {
HBLDR_3DSX_TID = HBLDR_DEFAULT_3DSX_TID;
__libc_init_array(); __libc_init_array();
s64 out;
isN3DS = svcGetSystemInfo(&out, 0x10001, 0) == 0;
svcGetSystemInfo(&out, 0x10000, 0x100);
HBLDR_3DSX_TID = out == 0 ? HBLDR_DEFAULT_3DSX_TID : (u64)out;
svcGetSystemInfo(&out, 0x10000, 0x101);
menuCombo = out == 0 ? DEFAULT_MENU_COMBO : (u32)out;
miscellaneousMenu.items[0].title = HBLDR_3DSX_TID == HBLDR_DEFAULT_3DSX_TID ? "Switch the hb. title to the current app." :
"Switch the hb. title to hblauncher_loader";
__sync_init(); __sync_init();
__appInit(); __appInit();
} }

View File

@ -156,7 +156,7 @@ MyThread *menuCreateThread(void)
} }
extern bool isN3DS; extern bool isN3DS;
u32 menuCombo = DEFAULT_MENU_COMBO; u32 menuCombo;
void menuThreadMain(void) void menuThreadMain(void)
{ {
@ -224,7 +224,7 @@ static void menuDraw(Menu *menu, u32 selected)
svcGetSystemInfo(&out, 0x10000, 1); svcGetSystemInfo(&out, 0x10000, 1);
commitHash = (u32)out; commitHash = (u32)out;
svcGetSystemInfo(&out, 0x10000, 3); svcGetSystemInfo(&out, 0x10000, 0x200);
isRelease = (bool)out; isRelease = (bool)out;
if(GET_VERSION_REVISION(version) == 0) if(GET_VERSION_REVISION(version) == 0)

View File

@ -102,7 +102,7 @@ void RosalinaMenu_TakeScreenshot(void)
s64 out; s64 out;
bool isSdMode; bool isSdMode;
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 6))) svcBreak(USERBREAK_ASSERT); if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 0x203))) svcBreak(USERBREAK_ASSERT);
isSdMode = (bool)out; isSdMode = (bool)out;
archiveId = isSdMode ? ARCHIVE_SDMC : ARCHIVE_NAND_RW; archiveId = isSdMode ? ARCHIVE_SDMC : ARCHIVE_NAND_RW;

View File

@ -33,13 +33,15 @@
#include "fmt.h" #include "fmt.h"
#include "utils.h" // for makeARMBranch #include "utils.h" // for makeARMBranch
#include "minisoc.h" #include "minisoc.h"
#include "ifile.h"
Menu miscellaneousMenu = { Menu miscellaneousMenu = {
"Miscellaneous options menu", "Miscellaneous options menu",
.nbItems = 5, .nbItems = 6,
{ {
{ "Switch the hb. title to the current app.", METHOD, .method = &MiscellaneousMenu_SwitchBoot3dsxTargetTitle }, { "Switch the hb. title to the current app.", METHOD, .method = &MiscellaneousMenu_SwitchBoot3dsxTargetTitle },
{ "Change the menu combo", METHOD, .method = MiscellaneousMenu_ChangeMenuCombo }, { "Change the menu combo", METHOD, .method = MiscellaneousMenu_ChangeMenuCombo },
{ "Save settings", METHOD, .method = &MiscellaneousMenu_SaveSettings },
{ "Start InputRedirection", METHOD, .method = &MiscellaneousMenu_InputRedirection }, { "Start InputRedirection", METHOD, .method = &MiscellaneousMenu_InputRedirection },
{ "Power off", METHOD, .method = &MiscellaneousMenu_PowerOff }, { "Power off", METHOD, .method = &MiscellaneousMenu_PowerOff },
{ "Reboot", METHOD, .method = &MiscellaneousMenu_Reboot }, { "Reboot", METHOD, .method = &MiscellaneousMenu_Reboot },
@ -167,6 +169,72 @@ void MiscellaneousMenu_ChangeMenuCombo(void)
while(!(waitInput() & BUTTON_B) && !terminationRequest); while(!(waitInput() & BUTTON_B) && !terminationRequest);
} }
void MiscellaneousMenu_SaveSettings(void)
{
Result res;
IFile file;
u64 total;
struct PACKED
{
char magic[4];
u16 formatVersionMajor, formatVersionMinor;
u32 config, multiConfig, bootConfig;
u64 hbldr3dsxTitleId;
u32 rosalinaMenuCombo;
} configData;
u32 formatVersion;
u32 config, multiConfig, bootConfig;
s64 out;
bool isSdMode;
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 2))) svcBreak(USERBREAK_ASSERT);
formatVersion = (u32)out;
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 3))) svcBreak(USERBREAK_ASSERT);
config = (u32)out;
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 4))) svcBreak(USERBREAK_ASSERT);
multiConfig = (u32)out;
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 5))) svcBreak(USERBREAK_ASSERT);
bootConfig = (u32)out;
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 0x203))) svcBreak(USERBREAK_ASSERT);
isSdMode = (bool)out;
memcpy(configData.magic, "CONF", 4);
configData.formatVersionMajor = (u16)(formatVersion >> 16);
configData.formatVersionMinor = (u16)formatVersion;
configData.config = config;
configData.multiConfig = multiConfig;
configData.bootConfig = bootConfig;
configData.hbldr3dsxTitleId = HBLDR_3DSX_TID;
configData.rosalinaMenuCombo = menuCombo;
FS_ArchiveID archiveId = isSdMode ? ARCHIVE_SDMC : ARCHIVE_NAND_RW;
res = IFile_Open(&file, archiveId, fsMakePath(PATH_EMPTY, ""), fsMakePath(PATH_ASCII, "/luma/config.bin"), FS_OPEN_CREATE | FS_OPEN_WRITE);
if(R_SUCCEEDED(res))
res = IFile_Write(&file, &total, &configData, sizeof(configData), 0);
Draw_Lock();
Draw_ClearFramebuffer();
Draw_FlushFramebuffer();
Draw_Unlock();
do
{
Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "Process patches menu");
if(R_SUCCEEDED(res))
Draw_DrawString(10, 30, COLOR_WHITE, "Operation succeeded.");
else
Draw_DrawFormattedString(10, 30, COLOR_WHITE, "Operation failed (0x%08x).", res);
Draw_FlushFramebuffer();
Draw_Unlock();
}
while(!(waitInput() & BUTTON_B) && !terminationRequest);
}
void MiscellaneousMenu_InputRedirection(void) void MiscellaneousMenu_InputRedirection(void)
{ {
static MyThread *inputRedirectionThread = NULL; static MyThread *inputRedirectionThread = NULL;
@ -207,6 +275,11 @@ void MiscellaneousMenu_InputRedirection(void)
} }
} }
Draw_Lock();
Draw_ClearFramebuffer();
Draw_FlushFramebuffer();
Draw_Unlock();
do do
{ {
Draw_Lock(); Draw_Lock();
@ -262,40 +335,46 @@ void MiscellaneousMenu_InputRedirection(void)
while(!(waitInput() & BUTTON_B) && !terminationRequest); while(!(waitInput() & BUTTON_B) && !terminationRequest);
} }
void MiscellaneousMenu_Reboot() void MiscellaneousMenu_Reboot(void)
{ {
Draw_Lock(); Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "Miscellaneous options menu"); Draw_ClearFramebuffer();
Draw_DrawString(10, 30, COLOR_WHITE, "Press A to reboot, press B to go back.");
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
do do
{ {
Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "Miscellaneous options menu");
Draw_DrawString(10, 30, COLOR_WHITE, "Press A to reboot, press B to go back.");
Draw_FlushFramebuffer();
Draw_Unlock();
u32 pressed = waitInputWithTimeout(1000); u32 pressed = waitInputWithTimeout(1000);
if(pressed & BUTTON_A) if(pressed & BUTTON_A)
{
svcKernelSetState(7); svcKernelSetState(7);
}
else if(pressed & BUTTON_B) else if(pressed & BUTTON_B)
{
return; return;
}
} }
while(!terminationRequest); while(!terminationRequest);
} }
void MiscellaneousMenu_PowerOff() // Soft shutdown. void MiscellaneousMenu_PowerOff(void) // Soft shutdown.
{ {
Draw_Lock(); Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "Miscellaneous options menu"); Draw_ClearFramebuffer();
Draw_DrawString(10, 30, COLOR_WHITE, "Press A to power off, press B to go back.");
Draw_FlushFramebuffer(); Draw_FlushFramebuffer();
Draw_Unlock(); Draw_Unlock();
do do
{ {
Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "Miscellaneous options menu");
Draw_DrawString(10, 30, COLOR_WHITE, "Press A to power off, press B to go back.");
Draw_FlushFramebuffer();
Draw_Unlock();
u32 pressed = waitInputWithTimeout(1000); u32 pressed = waitInputWithTimeout(1000);
if(pressed & BUTTON_A) if(pressed & BUTTON_A)
@ -304,9 +383,7 @@ void MiscellaneousMenu_PowerOff() // Soft shutdown.
srvPublishToSubscriber(0x203, 0); srvPublishToSubscriber(0x203, 0);
} }
else if(pressed & BUTTON_B) else if(pressed & BUTTON_B)
{
return; return;
}
} }
while(!terminationRequest); while(!terminationRequest);
} }