Skip to content

Commit 4453d97

Browse files
committed
Add autobooting TWLMenu++ via Luma
1 parent fe9dd36 commit 4453d97

File tree

1 file changed

+46
-7
lines changed

1 file changed

+46
-7
lines changed

settings/arm9/source/main.cpp

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,53 @@ void opt_update()
698698

699699
void opt_set_luma_autoboot()
700700
{
701-
std::string currentString = "";
701+
// Commented code is disabled due to saving Luma's .ini file clearing comments, causing the settings to reset
702+
/* std::string currentString = "";
702703
703704
CIniFile lumaConfig("sd:/luma/config.ini");
704705
currentString = lumaConfig.GetString("boot", "autoboot_mode", "0"); // Work around a bug
705706
lumaConfig.SetString("boot", "autoboot_mode", "2");
706707
lumaConfig.SetString("autoboot", "autoboot_dsi_titleid", "0003000453524c41");
707-
lumaConfig.SaveIniFile("sd:/luma/config.ini");
708+
lumaConfig.SaveIniFile("sd:/luma/config.ini"); */
709+
710+
FILE* file = fopen("sd:/luma/config.ini", "r+");
711+
712+
u8* lumaConfig = new u8[0x2000];
713+
fread(lumaConfig, 1, 0x2000, file);
714+
715+
int pos = 0;
716+
while (1) {
717+
if (memcmp(lumaConfig+pos, "autoboot_mode = ", 16) == 0) {
718+
const char *dsiString = "dsi";
719+
tonccpy(lumaConfig+pos+16, dsiString, 3);
720+
fseek(file, pos+16, SEEK_SET);
721+
fwrite(lumaConfig+pos+16, 1, 3, file);
722+
break;
723+
}
724+
pos++;
725+
if (pos == 0x2000) {
726+
delete[] lumaConfig;
727+
return;
728+
}
729+
}
730+
731+
while (1) {
732+
if (memcmp(lumaConfig+pos, "autoboot_dsi_titleid = ", 23) == 0) {
733+
const char *tidString = "0003000453524c41";
734+
tonccpy(lumaConfig+pos+23, tidString, 16);
735+
fseek(file, pos+23, SEEK_SET);
736+
fwrite(lumaConfig+pos+23, 1, 16, file);
737+
break;
738+
}
739+
pos++;
740+
if (pos == 0x2000) {
741+
delete[] lumaConfig;
742+
return;
743+
}
744+
}
745+
746+
delete[] lumaConfig;
747+
fclose(file);
708748

709749
clearText(false);
710750
if (ms().rtl()) {
@@ -952,9 +992,9 @@ int settingsMode(void)
952992
wasBacklightOff = sys().isRegularDS() && (REG_POWERCNT & 0xC) == 0;
953993

954994
bool widescreenFound = false;
955-
// bool lumaFound = false;
995+
bool lumaFound = false;
956996
if (sdFound() && ms().consoleModel >= 2 && (!isDSiMode() || !sys().arm7SCFGLocked())) {
957-
// lumaFound = (access("sd:/luma/config.ini", F_OK) == 0);
997+
lumaFound = (access("sd:/luma/config.ini", F_OK) == 0);
958998

959999
CIniFile lumaConfig("sd:/luma/config.ini");
9601000
widescreenFound = ((access("sd:/_nds/TWiLightMenu/TwlBg/Widescreen.cxi", F_OK) == 0) && (lumaConfig.GetInt("boot", "enable_external_firm_and_modules", 0) == true));
@@ -1538,11 +1578,10 @@ int settingsMode(void)
15381578
.option(STR_SYSTEMSETTINGS, STR_DESCRIPTION_SYSTEMSETTINGS_1, Option::Nul(opt_reboot_system_menu), {}, {});
15391579
}
15401580

1541-
// Disabled due to saving Luma's .ini file clearing comments, causing the settings to reset
1542-
/* if (lumaFound) {
1581+
if (lumaFound) {
15431582
miscPage
15441583
.option(STR_SET_LUMA_AUTOBOOT, STR_DESCRIPTION_SET_LUMA_AUTOBOOT, Option::Nul(opt_set_luma_autoboot), {}, {});
1545-
} */
1584+
}
15461585

15471586
/*SettingsPage twlfirmPage(STR_TWLFIRM_SETTINGS);
15481587
if (isDSiMode() && ms().consoleModel >= 2) {

0 commit comments

Comments
 (0)