diff --git a/sysmodules/rosalina/include/luma_config.h b/sysmodules/rosalina/include/luma_config.h
new file mode 100644
index 000000000..81ea50a93
--- /dev/null
+++ b/sysmodules/rosalina/include/luma_config.h
@@ -0,0 +1,58 @@
+/*
+* This file is part of Luma3DS
+* Copyright (C) 2023 Aurora Wright, TuxSH
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*
+* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
+* * Requiring preservation of specified reasonable legal notices or
+* author attributions in that material or in the Appropriate Legal
+* Notices displayed by works containing it.
+* * Prohibiting misrepresentation of the origin of that material,
+* or requiring that modified versions of such material be marked in
+* reasonable ways as different from the original version.
+*/
+
+#include <3ds/types.h>
+
+#define CONFIG(a) (((cfg->config >> (a)) & 1) != 0)
+#define MULTICONFIG(a) ((cfg->multiConfig >> (2 * (a))) & 3)
+#define BOOTCONFIG(a, b) ((cfg->bootConfig >> (a)) & (b))
+
+enum singleOptions
+{
+ AUTOBOOTEMU = 0,
+ USEEMUFIRM,
+ LOADEXTFIRMSANDMODULES,
+ PATCHGAMES,
+ REDIRECTAPPTHREADS,
+ PATCHVERSTRING,
+ SHOWGBABOOT,
+ PATCHUNITINFO,
+ DISABLEARM11EXCHANDLERS,
+ ENABLESAFEFIRMROSALINA,
+};
+
+enum multiOptions
+{
+ DEFAULTEMU = 0,
+ BRIGHTNESS,
+ SPLASH,
+ PIN,
+ NEWCPU,
+ AUTOBOOTMODE,
+};
+
+void LumaConfig_ConvertComboToString(char *out, u32 combo);
+Result LumaConfig_SaveSettings(void);
diff --git a/sysmodules/rosalina/include/menus.h b/sysmodules/rosalina/include/menus.h
index 88fede16b..3b7a662a6 100644
--- a/sysmodules/rosalina/include/menus.h
+++ b/sysmodules/rosalina/include/menus.h
@@ -36,6 +36,7 @@ void RosalinaMenu_TakeScreenshot(void);
void RosalinaMenu_ChangeScreenBrightness(void);
void RosalinaMenu_ShowCredits(void);
void RosalinaMenu_ProcessList(void);
+void RosalinaMenu_SaveSettings(void);
void RosalinaMenu_PowerOff(void);
void RosalinaMenu_Reboot(void);
void RosalinaMenu_Cheats(void);
diff --git a/sysmodules/rosalina/include/menus/miscellaneous.h b/sysmodules/rosalina/include/menus/miscellaneous.h
index c6fd1ff1d..676f6f3cd 100644
--- a/sysmodules/rosalina/include/menus/miscellaneous.h
+++ b/sysmodules/rosalina/include/menus/miscellaneous.h
@@ -34,7 +34,6 @@ extern int lastNtpTzOffset;
void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void);
void MiscellaneousMenu_ChangeMenuCombo(void);
-void MiscellaneousMenu_SaveSettings(void);
void MiscellaneousMenu_InputRedirection(void);
void MiscellaneousMenu_UpdateTimeDateNtp(void);
void MiscellaneousMenu_NullifyUserTimeOffset(void);
diff --git a/sysmodules/rosalina/source/luma_config.c b/sysmodules/rosalina/source/luma_config.c
new file mode 100644
index 000000000..1cba607d0
--- /dev/null
+++ b/sysmodules/rosalina/source/luma_config.c
@@ -0,0 +1,245 @@
+/*
+* This file is part of Luma3DS
+* Copyright (C) 2023 Aurora Wright, TuxSH
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*
+* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
+* * Requiring preservation of specified reasonable legal notices or
+* author attributions in that material or in the Appropriate Legal
+* Notices displayed by works containing it.
+* * Prohibiting misrepresentation of the origin of that material,
+* or requiring that modified versions of such material be marked in
+* reasonable ways as different from the original version.
+*/
+
+#include <3ds.h>
+#include "memory.h"
+#include "fmt.h"
+#include "luma_config.h"
+#include "screen_filters.h"
+#include "config_template_ini.h"
+#include "ifile.h"
+#include "menus/miscellaneous.h"
+
+typedef struct CfgData {
+ u16 formatVersionMajor, formatVersionMinor;
+
+ u32 config, multiConfig, bootConfig;
+ u32 splashDurationMsec;
+
+ u64 hbldr3dsxTitleId;
+ u32 rosalinaMenuCombo;
+ s16 ntpTzOffetMinutes;
+
+ ScreenFilter topScreenFilter;
+ ScreenFilter bottomScreenFilter;
+
+ u64 autobootTwlTitleId;
+ u8 autobootCtrAppmemtype;
+} CfgData;
+
+void LumaConfig_ConvertComboToString(char *out, u32 combo)
+{
+ static const char *keys[] = {
+ "A", "B", "Select", "Start", "Right", "Left", "Up", "Down", "R", "L", "X", "Y",
+ "?", "?",
+ "ZL", "ZR",
+ "?", "?", "?", "?",
+ "Touch",
+ "?", "?", "?",
+ "CStick Right", "CStick Left", "CStick Up", "CStick Down",
+ "CPad Right", "CPad Left", "CPad Up", "CPad Down",
+ };
+
+ char *outOrig = out;
+ out[0] = 0;
+ for(s32 i = 31; i >= 0; i--)
+ {
+ if(combo & (1 << i))
+ {
+ strcpy(out, keys[i]);
+ out += strlen(keys[i]);
+ *out++ = '+';
+ }
+ }
+
+ if (out != outOrig)
+ out[-1] = 0;
+}
+
+static size_t LumaConfig_SaveLumaIniConfigToStr(char *out, const CfgData *cfg)
+{
+ char lumaVerStr[64];
+ char lumaRevSuffixStr[16];
+ char rosalinaMenuComboStr[128];
+
+ const char *splashPosStr;
+ const char *n3dsCpuStr;
+
+ s64 outInfo;
+ svcGetSystemInfo(&outInfo, 0x10000, 0);
+ u32 version = (u32)outInfo;
+
+ svcGetSystemInfo(&outInfo, 0x10000, 1);
+ u32 commitHash = (u32)outInfo;
+
+ svcGetSystemInfo(&outInfo, 0x10000, 0x200);
+ bool isRelease = (bool)outInfo;
+
+ switch (MULTICONFIG(SPLASH)) {
+ default: case 0: splashPosStr = "off"; break;
+ case 1: splashPosStr = "before payloads"; break;
+ case 2: splashPosStr = "after payloads"; break;
+ }
+
+ switch (MULTICONFIG(NEWCPU)) {
+ default: case 0: n3dsCpuStr = "off"; break;
+ case 1: n3dsCpuStr = "clock"; break;
+ case 2: n3dsCpuStr = "l2"; break;
+ case 3: n3dsCpuStr = "clock+l2"; break;
+ }
+
+ if (GET_VERSION_REVISION(version) != 0) {
+ sprintf(lumaVerStr, "Luma3DS v%d.%d.%d", (int)GET_VERSION_MAJOR(version), (int)GET_VERSION_MINOR(version), (int)GET_VERSION_REVISION(version));
+ } else {
+ sprintf(lumaVerStr, "Luma3DS v%d.%d", (int)GET_VERSION_MAJOR(version), (int)GET_VERSION_MINOR(version));
+ }
+
+ if (isRelease) {
+ strcpy(lumaRevSuffixStr, "");
+ } else {
+ sprintf(lumaRevSuffixStr, "-%08lx", (u32)commitHash);
+ }
+
+ LumaConfig_ConvertComboToString(rosalinaMenuComboStr, cfg->rosalinaMenuCombo);
+
+ static const int pinOptionToDigits[] = { 0, 4, 6, 8 };
+ int pinNumDigits = pinOptionToDigits[MULTICONFIG(PIN)];
+
+ char topScreenFilterGammaStr[32];
+ char topScreenFilterContrastStr[32];
+ char topScreenFilterBrightnessStr[32];
+ floatToString(topScreenFilterGammaStr, cfg->topScreenFilter.gamma, 6, false);
+ floatToString(topScreenFilterContrastStr, cfg->topScreenFilter.contrast, 6, false);
+ floatToString(topScreenFilterBrightnessStr, cfg->topScreenFilter.brightness, 6, false);
+
+ char bottomScreenFilterGammaStr[32];
+ char bottomScreenFilterContrastStr[32];
+ char bottomScreenFilterBrightnessStr[32];
+ floatToString(bottomScreenFilterGammaStr, cfg->bottomScreenFilter.gamma, 6, false);
+ floatToString(bottomScreenFilterContrastStr, cfg->bottomScreenFilter.contrast, 6, false);
+ floatToString(bottomScreenFilterBrightnessStr, cfg->bottomScreenFilter.brightness, 6, false);
+
+ int n = sprintf(
+ out, (const char *)config_template_ini,
+ lumaVerStr, lumaRevSuffixStr,
+
+ (int)cfg->formatVersionMajor, (int)cfg->formatVersionMinor,
+ (int)CONFIG(AUTOBOOTEMU), (int)CONFIG(USEEMUFIRM),
+ (int)CONFIG(LOADEXTFIRMSANDMODULES), (int)CONFIG(PATCHGAMES),
+ (int)CONFIG(REDIRECTAPPTHREADS), (int)CONFIG(PATCHVERSTRING),
+ (int)CONFIG(SHOWGBABOOT),
+
+ 1 + (int)MULTICONFIG(DEFAULTEMU), 4 - (int)MULTICONFIG(BRIGHTNESS),
+ splashPosStr, (unsigned int)cfg->splashDurationMsec,
+ pinNumDigits, n3dsCpuStr, (int)MULTICONFIG(AUTOBOOTMODE),
+
+ cfg->hbldr3dsxTitleId, rosalinaMenuComboStr,
+ (int)cfg->ntpTzOffetMinutes,
+
+ (int)cfg->topScreenFilter.cct, (int)cfg->bottomScreenFilter.cct,
+ topScreenFilterGammaStr, bottomScreenFilterGammaStr,
+ topScreenFilterContrastStr, bottomScreenFilterContrastStr,
+ topScreenFilterBrightnessStr, bottomScreenFilterBrightnessStr,
+ (int)cfg->topScreenFilter.invert, (int)cfg->bottomScreenFilter.invert,
+
+ cfg->autobootTwlTitleId, (int)cfg->autobootCtrAppmemtype,
+
+ (int)CONFIG(PATCHUNITINFO), (int)CONFIG(DISABLEARM11EXCHANDLERS),
+ (int)CONFIG(ENABLESAFEFIRMROSALINA)
+ );
+
+ return n < 0 ? 0 : (size_t)n;
+}
+
+Result LumaConfig_SaveSettings(void)
+{
+ char inibuf[0x2000];
+
+ Result res;
+
+ IFile file;
+ u64 total;
+
+ CfgData configData;
+
+ u32 formatVersion;
+ u32 config, multiConfig, bootConfig;
+ u32 splashDurationMsec;
+
+ u8 autobootCtrAppmemtype;
+ u64 autobootTwlTitleId;
+
+ s64 out;
+ bool isSdMode;
+
+ svcGetSystemInfo(&out, 0x10000, 2);
+ formatVersion = (u32)out;
+ svcGetSystemInfo(&out, 0x10000, 3);
+ config = (u32)out;
+ svcGetSystemInfo(&out, 0x10000, 4);
+ multiConfig = (u32)out;
+ svcGetSystemInfo(&out, 0x10000, 5);
+ bootConfig = (u32)out;
+ svcGetSystemInfo(&out, 0x10000, 6);
+ splashDurationMsec = (u32)out;
+
+ svcGetSystemInfo(&out, 0x10000, 0x10);
+ autobootTwlTitleId = (u64)out;
+ svcGetSystemInfo(&out, 0x10000, 0x11);
+ autobootCtrAppmemtype = (u8)out;
+
+ svcGetSystemInfo(&out, 0x10000, 0x203);
+ isSdMode = (bool)out;
+
+ configData.formatVersionMajor = (u16)(formatVersion >> 16);
+ configData.formatVersionMinor = (u16)formatVersion;
+ configData.config = config;
+ configData.multiConfig = multiConfig;
+ configData.bootConfig = bootConfig;
+ configData.splashDurationMsec = splashDurationMsec;
+ configData.hbldr3dsxTitleId = Luma_SharedConfig->hbldr_3dsx_tid;
+ configData.rosalinaMenuCombo = menuCombo;
+ configData.ntpTzOffetMinutes = (s16)lastNtpTzOffset;
+ configData.topScreenFilter = topScreenFilter;
+ configData.bottomScreenFilter = bottomScreenFilter;
+ configData.autobootTwlTitleId = autobootTwlTitleId;
+ configData.autobootCtrAppmemtype = autobootCtrAppmemtype;
+
+ size_t n = LumaConfig_SaveLumaIniConfigToStr(inibuf, &configData);
+ FS_ArchiveID archiveId = isSdMode ? ARCHIVE_SDMC : ARCHIVE_NAND_RW;
+ if (n > 0)
+ res = IFile_Open(&file, archiveId, fsMakePath(PATH_EMPTY, ""), fsMakePath(PATH_ASCII, "/luma/config.ini"), FS_OPEN_CREATE | FS_OPEN_WRITE);
+ else
+ res = -1;
+
+ if(R_SUCCEEDED(res))
+ res = IFile_SetSize(&file, n);
+ if(R_SUCCEEDED(res))
+ res = IFile_Write(&file, &total, inibuf, n, 0);
+ IFile_Close(&file);
+
+ return res;
+}
diff --git a/sysmodules/rosalina/source/menus.c b/sysmodules/rosalina/source/menus.c
index 02e3af1ae..48e627c34 100644
--- a/sysmodules/rosalina/source/menus.c
+++ b/sysmodules/rosalina/source/menus.c
@@ -40,6 +40,7 @@
#include "fmt.h"
#include "process_patches.h"
#include "luminance.h"
+#include "luma_config.h"
Menu rosalinaMenu = {
"Rosalina menu",
@@ -53,6 +54,7 @@ Menu rosalinaMenu = {
{ "Screen filters...", MENU, .menu = &screenFiltersMenu },
{ "New 3DS menu...", MENU, .menu = &N3DSMenu, .visibility = &menuCheckN3ds },
{ "Miscellaneous options...", MENU, .menu = &miscellaneousMenu },
+ { "Save settings", METHOD, .method = &RosalinaMenu_SaveSettings },
{ "Power off", METHOD, .method = &RosalinaMenu_PowerOff },
{ "Reboot", METHOD, .method = &RosalinaMenu_Reboot },
{ "Credits", METHOD, .method = &RosalinaMenu_ShowCredits },
@@ -70,6 +72,28 @@ bool rosalinaMenuShouldShowDebugInfo(void)
return out == 0;
}
+void RosalinaMenu_SaveSettings(void)
+{
+ Result res = LumaConfig_SaveSettings();
+ Draw_Lock();
+ Draw_ClearFramebuffer();
+ Draw_FlushFramebuffer();
+ Draw_Unlock();
+
+ do
+ {
+ Draw_Lock();
+ Draw_DrawString(10, 10, COLOR_TITLE, "Save settings");
+ if(R_SUCCEEDED(res))
+ Draw_DrawString(10, 30, COLOR_WHITE, "Operation succeeded.");
+ else
+ Draw_DrawFormattedString(10, 30, COLOR_WHITE, "Operation failed (0x%08lx).", res);
+ Draw_FlushFramebuffer();
+ Draw_Unlock();
+ }
+ while(!(waitInput() & KEY_B) && !menuShouldExit);
+}
+
void RosalinaMenu_ShowDebugInfo(void)
{
Draw_Lock();
@@ -147,7 +171,7 @@ void RosalinaMenu_ShowCredits(void)
Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "Rosalina -- Luma3DS credits");
- u32 posY = Draw_DrawString(10, 30, COLOR_WHITE, "Luma3DS (c) 2016-2022 AuroraWright, TuxSH") + SPACING_Y;
+ u32 posY = Draw_DrawString(10, 30, COLOR_WHITE, "Luma3DS (c) 2016-2023 AuroraWright, TuxSH") + SPACING_Y;
posY = Draw_DrawString(10, posY + SPACING_Y, COLOR_WHITE, "3DSX loading code by fincs");
posY = Draw_DrawString(10, posY + SPACING_Y, COLOR_WHITE, "Networking code & basic GDB functionality by Stary");
diff --git a/sysmodules/rosalina/source/menus/miscellaneous.c b/sysmodules/rosalina/source/menus/miscellaneous.c
index 0d51e226c..acfc4241c 100644
--- a/sysmodules/rosalina/source/menus/miscellaneous.c
+++ b/sysmodules/rosalina/source/menus/miscellaneous.c
@@ -26,6 +26,7 @@
#include <3ds.h>
#include "menus/miscellaneous.h"
+#include "luma_config.h"
#include "input_redirection.h"
#include "ntp.h"
#include "memory.h"
@@ -36,36 +37,7 @@
#include "ifile.h"
#include "pmdbgext.h"
#include "process_patches.h"
-#include "screen_filters.h"
-#include "config_template_ini.h"
-#define CONFIG(a) (((cfg->config >> (a)) & 1) != 0)
-#define MULTICONFIG(a) ((cfg->multiConfig >> (2 * (a))) & 3)
-#define BOOTCONFIG(a, b) ((cfg->bootConfig >> (a)) & (b))
-
-enum singleOptions
-{
- AUTOBOOTEMU = 0,
- USEEMUFIRM,
- LOADEXTFIRMSANDMODULES,
- PATCHGAMES,
- REDIRECTAPPTHREADS,
- PATCHVERSTRING,
- SHOWGBABOOT,
- PATCHUNITINFO,
- DISABLEARM11EXCHANDLERS,
- ENABLESAFEFIRMROSALINA,
-};
-
-enum multiOptions
-{
- DEFAULTEMU = 0,
- BRIGHTNESS,
- SPLASH,
- PIN,
- NEWCPU,
- AUTOBOOTMODE,
-};
typedef struct DspFirmSegmentHeader {
u32 offset;
u32 loadAddrHalfwords;
@@ -91,23 +63,6 @@ typedef struct DspFirm {
u8 data[];
} DspFirm;
-typedef struct CfgData {
- u16 formatVersionMajor, formatVersionMinor;
-
- u32 config, multiConfig, bootConfig;
- u32 splashDurationMsec;
-
- u64 hbldr3dsxTitleId;
- u32 rosalinaMenuCombo;
- s16 ntpTzOffetMinutes;
-
- ScreenFilter topScreenFilter;
- ScreenFilter bottomScreenFilter;
-
- u64 autobootTwlTitleId;
- u8 autobootCtrAppmemtype;
-} CfgData;
-
Menu miscellaneousMenu = {
"Miscellaneous options menu",
{
@@ -117,10 +72,10 @@ Menu miscellaneousMenu = {
{ "Update time and date via NTP", METHOD, .method = &MiscellaneousMenu_UpdateTimeDateNtp },
{ "Nullify user time offset", METHOD, .method = &MiscellaneousMenu_NullifyUserTimeOffset },
{ "Dump DSP firmware", METHOD, .method = &MiscellaneousMenu_DumpDspFirm },
- { "Save settings", METHOD, .method = &MiscellaneousMenu_SaveSettings },
{},
}
};
+
int lastNtpTzOffset = 0;
static inline bool compareTids(u64 tidA, u64 tidB)
@@ -185,35 +140,6 @@ void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void)
while(!(waitInput() & KEY_B) && !menuShouldExit);
}
-static void MiscellaneousMenu_ConvertComboToString(char *out, u32 combo)
-{
- static const char *keys[] = {
- "A", "B", "Select", "Start", "Right", "Left", "Up", "Down", "R", "L", "X", "Y",
- "?", "?",
- "ZL", "ZR",
- "?", "?", "?", "?",
- "Touch",
- "?", "?", "?",
- "CStick Right", "CStick Left", "CStick Up", "CStick Down",
- "CPad Right", "CPad Left", "CPad Up", "CPad Down",
- };
-
- char *outOrig = out;
- out[0] = 0;
- for(s32 i = 31; i >= 0; i--)
- {
- if(combo & (1 << i))
- {
- strcpy(out, keys[i]);
- out += strlen(keys[i]);
- *out++ = '+';
- }
- }
-
- if (out != outOrig)
- out[-1] = 0;
-}
-
void MiscellaneousMenu_ChangeMenuCombo(void)
{
char comboStrOrig[128], comboStr[128];
@@ -224,7 +150,7 @@ void MiscellaneousMenu_ChangeMenuCombo(void)
Draw_FlushFramebuffer();
Draw_Unlock();
- MiscellaneousMenu_ConvertComboToString(comboStrOrig, menuCombo);
+ LumaConfig_ConvertComboToString(comboStrOrig, menuCombo);
Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "Miscellaneous options menu");
@@ -233,7 +159,7 @@ void MiscellaneousMenu_ChangeMenuCombo(void)
posY = Draw_DrawString(10, posY + SPACING_Y, COLOR_WHITE, "Please enter the new combo:");
menuCombo = waitCombo();
- MiscellaneousMenu_ConvertComboToString(comboStr, menuCombo);
+ LumaConfig_ConvertComboToString(comboStr, menuCombo);
do
{
@@ -251,187 +177,6 @@ void MiscellaneousMenu_ChangeMenuCombo(void)
while(!(waitInput() & KEY_B) && !menuShouldExit);
}
-static size_t saveLumaIniConfigToStr(char *out, const CfgData *cfg)
-{
- char lumaVerStr[64];
- char lumaRevSuffixStr[16];
- char rosalinaMenuComboStr[128];
-
- const char *splashPosStr;
- const char *n3dsCpuStr;
-
- s64 outInfo;
- svcGetSystemInfo(&outInfo, 0x10000, 0);
- u32 version = (u32)outInfo;
-
- svcGetSystemInfo(&outInfo, 0x10000, 1);
- u32 commitHash = (u32)outInfo;
-
- svcGetSystemInfo(&outInfo, 0x10000, 0x200);
- bool isRelease = (bool)outInfo;
-
- switch (MULTICONFIG(SPLASH)) {
- default: case 0: splashPosStr = "off"; break;
- case 1: splashPosStr = "before payloads"; break;
- case 2: splashPosStr = "after payloads"; break;
- }
-
- switch (MULTICONFIG(NEWCPU)) {
- default: case 0: n3dsCpuStr = "off"; break;
- case 1: n3dsCpuStr = "clock"; break;
- case 2: n3dsCpuStr = "l2"; break;
- case 3: n3dsCpuStr = "clock+l2"; break;
- }
-
- if (GET_VERSION_REVISION(version) != 0) {
- sprintf(lumaVerStr, "Luma3DS v%d.%d.%d", (int)GET_VERSION_MAJOR(version), (int)GET_VERSION_MINOR(version), (int)GET_VERSION_REVISION(version));
- } else {
- sprintf(lumaVerStr, "Luma3DS v%d.%d", (int)GET_VERSION_MAJOR(version), (int)GET_VERSION_MINOR(version));
- }
-
- if (isRelease) {
- strcpy(lumaRevSuffixStr, "");
- } else {
- sprintf(lumaRevSuffixStr, "-%08lx", (u32)commitHash);
- }
-
- MiscellaneousMenu_ConvertComboToString(rosalinaMenuComboStr, cfg->rosalinaMenuCombo);
-
- static const int pinOptionToDigits[] = { 0, 4, 6, 8 };
- int pinNumDigits = pinOptionToDigits[MULTICONFIG(PIN)];
-
- char topScreenFilterGammaStr[32];
- char topScreenFilterContrastStr[32];
- char topScreenFilterBrightnessStr[32];
- floatToString(topScreenFilterGammaStr, cfg->topScreenFilter.gamma, 6, false);
- floatToString(topScreenFilterContrastStr, cfg->topScreenFilter.contrast, 6, false);
- floatToString(topScreenFilterBrightnessStr, cfg->topScreenFilter.brightness, 6, false);
-
- char bottomScreenFilterGammaStr[32];
- char bottomScreenFilterContrastStr[32];
- char bottomScreenFilterBrightnessStr[32];
- floatToString(bottomScreenFilterGammaStr, cfg->bottomScreenFilter.gamma, 6, false);
- floatToString(bottomScreenFilterContrastStr, cfg->bottomScreenFilter.contrast, 6, false);
- floatToString(bottomScreenFilterBrightnessStr, cfg->bottomScreenFilter.brightness, 6, false);
-
- int n = sprintf(
- out, (const char *)config_template_ini,
- lumaVerStr, lumaRevSuffixStr,
-
- (int)cfg->formatVersionMajor, (int)cfg->formatVersionMinor,
- (int)CONFIG(AUTOBOOTEMU), (int)CONFIG(USEEMUFIRM),
- (int)CONFIG(LOADEXTFIRMSANDMODULES), (int)CONFIG(PATCHGAMES),
- (int)CONFIG(REDIRECTAPPTHREADS), (int)CONFIG(PATCHVERSTRING),
- (int)CONFIG(SHOWGBABOOT),
-
- 1 + (int)MULTICONFIG(DEFAULTEMU), 4 - (int)MULTICONFIG(BRIGHTNESS),
- splashPosStr, (unsigned int)cfg->splashDurationMsec,
- pinNumDigits, n3dsCpuStr, (int)MULTICONFIG(AUTOBOOTMODE),
-
- cfg->hbldr3dsxTitleId, rosalinaMenuComboStr,
- (int)cfg->ntpTzOffetMinutes,
-
- (int)cfg->topScreenFilter.cct, (int)cfg->bottomScreenFilter.cct,
- topScreenFilterGammaStr, bottomScreenFilterGammaStr,
- topScreenFilterContrastStr, bottomScreenFilterContrastStr,
- topScreenFilterBrightnessStr, bottomScreenFilterBrightnessStr,
- (int)cfg->topScreenFilter.invert, (int)cfg->bottomScreenFilter.invert,
-
- cfg->autobootTwlTitleId, (int)cfg->autobootCtrAppmemtype,
-
- (int)CONFIG(PATCHUNITINFO), (int)CONFIG(DISABLEARM11EXCHANDLERS),
- (int)CONFIG(ENABLESAFEFIRMROSALINA)
- );
-
- return n < 0 ? 0 : (size_t)n;
-}
-
-void MiscellaneousMenu_SaveSettings(void)
-{
- char inibuf[0x2000];
-
- Result res;
-
- IFile file;
- u64 total;
-
- CfgData configData;
-
- u32 formatVersion;
- u32 config, multiConfig, bootConfig;
- u32 splashDurationMsec;
-
- u8 autobootCtrAppmemtype;
- u64 autobootTwlTitleId;
-
- s64 out;
- bool isSdMode;
-
- svcGetSystemInfo(&out, 0x10000, 2);
- formatVersion = (u32)out;
- svcGetSystemInfo(&out, 0x10000, 3);
- config = (u32)out;
- svcGetSystemInfo(&out, 0x10000, 4);
- multiConfig = (u32)out;
- svcGetSystemInfo(&out, 0x10000, 5);
- bootConfig = (u32)out;
- svcGetSystemInfo(&out, 0x10000, 6);
- splashDurationMsec = (u32)out;
-
- svcGetSystemInfo(&out, 0x10000, 0x10);
- autobootTwlTitleId = (u64)out;
- svcGetSystemInfo(&out, 0x10000, 0x11);
- autobootCtrAppmemtype = (u8)out;
-
- svcGetSystemInfo(&out, 0x10000, 0x203);
- isSdMode = (bool)out;
-
- configData.formatVersionMajor = (u16)(formatVersion >> 16);
- configData.formatVersionMinor = (u16)formatVersion;
- configData.config = config;
- configData.multiConfig = multiConfig;
- configData.bootConfig = bootConfig;
- configData.splashDurationMsec = splashDurationMsec;
- configData.hbldr3dsxTitleId = Luma_SharedConfig->hbldr_3dsx_tid;
- configData.rosalinaMenuCombo = menuCombo;
- configData.ntpTzOffetMinutes = (s16)lastNtpTzOffset;
- configData.topScreenFilter = topScreenFilter;
- configData.bottomScreenFilter = bottomScreenFilter;
- configData.autobootTwlTitleId = autobootTwlTitleId;
- configData.autobootCtrAppmemtype = autobootCtrAppmemtype;
-
- size_t n = saveLumaIniConfigToStr(inibuf, &configData);
- FS_ArchiveID archiveId = isSdMode ? ARCHIVE_SDMC : ARCHIVE_NAND_RW;
- if (n > 0)
- res = IFile_Open(&file, archiveId, fsMakePath(PATH_EMPTY, ""), fsMakePath(PATH_ASCII, "/luma/config.ini"), FS_OPEN_CREATE | FS_OPEN_WRITE);
- else
- res = -1;
-
- if(R_SUCCEEDED(res))
- res = IFile_SetSize(&file, n);
- if(R_SUCCEEDED(res))
- res = IFile_Write(&file, &total, inibuf, n, 0);
- IFile_Close(&file);
-
- Draw_Lock();
- Draw_ClearFramebuffer();
- Draw_FlushFramebuffer();
- Draw_Unlock();
-
- do
- {
- Draw_Lock();
- Draw_DrawString(10, 10, COLOR_TITLE, "Miscellaneous options menu");
- if(R_SUCCEEDED(res))
- Draw_DrawString(10, 30, COLOR_WHITE, "Operation succeeded.");
- else
- Draw_DrawFormattedString(10, 30, COLOR_WHITE, "Operation failed (0x%08lx).", res);
- Draw_FlushFramebuffer();
- Draw_Unlock();
- }
- while(!(waitInput() & KEY_B) && !menuShouldExit);
-}
-
void MiscellaneousMenu_InputRedirection(void)
{
bool done = false;