Skip to content

Commit

Permalink
Fix bootloader/bootstub install bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Nov 2, 2024
1 parent 4fd1f9f commit cbf784f
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 137 deletions.
2 changes: 1 addition & 1 deletion imageview/arm9/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void loadROMselect() {
break;
}

runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], true, false, false, true, true, false, -1);
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], sys().isRunFromSD(), true, false, false, true, true, false, -1);

fadeType = true; // Fade in from white
}
Expand Down
2 changes: 1 addition & 1 deletion manual/arm9/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void loadROMselect() {
break;
}

runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], true, false, false, true, true, false, -1);
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], sys().isRunFromSD(), true, false, false, true, true, false, -1);
fadeType = true; // Fade in from white
}

Expand Down
2 changes: 1 addition & 1 deletion quickmenu/arm9/source/gbaswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,5 @@ void gbaSwitch(void) {
loadGbaBorder((access(borderPath, F_OK)==0) ? borderPath : "nitro:/graphics/gbaborder.png");

// Switch to GBA mode
runNdsFile ("/_nds/TWiLightMenu/gbaswitch.srldr", 0, NULL, true, false, true, false, false, false, -1);
runNdsFile ("/_nds/TWiLightMenu/gbaswitch.srldr", 0, NULL, false, true, false, true, false, false, false, -1);
}
30 changes: 15 additions & 15 deletions quickmenu/arm9/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ void loadGameOnFlashcard(const char* ndsPath, bool dsGame) {
while (!screenFadedOut()) {
swiWaitForVBlank();
}
err = runNdsFile("fat:/Wfwd.dat", 0, NULL, true, true, true, runNds_boostCpu, runNds_boostVram, false, -1);
err = runNdsFile("fat:/Wfwd.dat", 0, NULL, sys().isRunFromSD(), true, true, true, runNds_boostCpu, runNds_boostVram, false, -1);
} else if (memcmp(io_dldi_data->friendlyName, "DSTWO(Slot-1)", 0xD) == 0) {
CIniFile fcrompathini("fat:/_dstwo/autoboot.ini");
fcPath = replaceAll(ndsPath, "fat:/", dstwofat);
Expand All @@ -814,7 +814,7 @@ void loadGameOnFlashcard(const char* ndsPath, bool dsGame) {
while (!screenFadedOut()) {
swiWaitForVBlank();
}
err = runNdsFile("fat:/_dstwo/autoboot.nds", 0, NULL, true, true, true, runNds_boostCpu, runNds_boostVram, false, -1);
err = runNdsFile("fat:/_dstwo/autoboot.nds", 0, NULL, sys().isRunFromSD(), true, true, true, runNds_boostCpu, runNds_boostVram, false, -1);
} else if ((memcmp(io_dldi_data->friendlyName, "TTCARD", 6) == 0)
|| (memcmp(io_dldi_data->friendlyName, "DSTT", 4) == 0)
|| (memcmp(io_dldi_data->friendlyName, "DEMON", 5) == 0)
Expand All @@ -828,7 +828,7 @@ void loadGameOnFlashcard(const char* ndsPath, bool dsGame) {
while (!screenFadedOut()) {
swiWaitForVBlank();
}
err = runNdsFile("fat:/YSMenu.nds", 0, NULL, true, true, true, runNds_boostCpu, runNds_boostVram, false, -1);
err = runNdsFile("fat:/YSMenu.nds", 0, NULL, sys().isRunFromSD(), true, true, true, runNds_boostCpu, runNds_boostVram, false, -1);
} else {
while (!screenFadedOut()) {
swiWaitForVBlank();
Expand Down Expand Up @@ -863,7 +863,7 @@ void loadROMselect()
} else {
argarray.push_back((char*)(sys().isRunFromSD() ? "sd:/_nds/TWiLightMenu/dsimenu.srldr" : "fat:/_nds/TWiLightMenu/dsimenu.srldr"));
}
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], true, false, false, true, true, false, -1);
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], sys().isRunFromSD(), true, false, false, true, true, false, -1);
}

/* bool ndsPreloaded = false;
Expand Down Expand Up @@ -1061,7 +1061,7 @@ void directCardLaunch() {
if (sdFound()) {
chdir("sd:/");
}
int err = runNdsFile ("/_nds/TWiLightMenu/dstwoLaunch.srldr", 0, NULL, true, true, true, DEFAULT_BOOST_CPU, DEFAULT_BOOST_VRAM, false, -1);
int err = runNdsFile ("/_nds/TWiLightMenu/dstwoLaunch.srldr", 0, NULL, sys().isRunFromSD(), true, true, true, DEFAULT_BOOST_CPU, DEFAULT_BOOST_VRAM, false, -1);
char text[64];
snprintf(text, sizeof(text), STR_START_FAILED_ERROR.c_str(), err);
ClearBrightness();
Expand All @@ -1071,7 +1071,7 @@ void directCardLaunch() {
}*/
SetWidescreen(NULL);
chdir(sys().isRunFromSD() ? "sd:/" : "fat:/");
int err = runNdsFile ("/_nds/TWiLightMenu/slot1launch.srldr", 0, NULL, true, true, false, true, true, false, -1);
int err = runNdsFile ("/_nds/TWiLightMenu/slot1launch.srldr", 0, NULL, sys().isRunFromSD(), true, true, false, true, true, false, -1);
char text[64];
snprintf(text, sizeof(text), STR_START_FAILED_ERROR.c_str(), err);
clearText();
Expand Down Expand Up @@ -1919,7 +1919,7 @@ int dsClassicMenu(void) {

if ((!dsiFeatures() || bs().b4dsMode) && ms().secondaryDevice) {
chdir(sys().isRunFromSD() ? "sd:/" : "fat:/");
int err = runNdsFile (pictochatPath, 0, NULL, true, true, true, false, false, false, ms().gameLanguage);
int err = runNdsFile (pictochatPath, 0, NULL, sys().isRunFromSD(), true, true, true, false, false, false, ms().gameLanguage);
char text[64];
snprintf (text, sizeof(text), STR_START_FAILED_ERROR.c_str(), err);
clearText();
Expand Down Expand Up @@ -1982,7 +1982,7 @@ int dsClassicMenu(void) {
bootstrapini.SetInt("NDS-BOOTSTRAP", "BOOST_CPU", 0);
bootstrapini.SetInt("NDS-BOOTSTRAP", "BOOST_VRAM", 0);
bootstrapini.SaveIniFile(bootstrapinipath);
int err = runNdsFile(argarray[0], argarray.size(), (const char **)&argarray[0], true, true, false, true, true, false, -1);
int err = runNdsFile(argarray[0], argarray.size(), (const char **)&argarray[0], sys().isRunFromSD(), true, true, false, true, true, false, -1);
char text[64];
snprintf (text, sizeof(text), STR_START_FAILED_ERROR.c_str(), err);
clearText();
Expand Down Expand Up @@ -2049,7 +2049,7 @@ int dsClassicMenu(void) {
for (int i = 0; i < 15; i++) swiWaitForVBlank();
} else if ((!dsiFeatures() || bs().b4dsMode) && ms().secondaryDevice) {
chdir(sys().isRunFromSD() ? "sd:/" : "fat:/");
int err = runNdsFile (dlplayPath, 0, NULL, true, true, true, false, false, false, ms().gameLanguage);
int err = runNdsFile (dlplayPath, 0, NULL, sys().isRunFromSD(), true, true, true, false, false, false, ms().gameLanguage);
char text[64];
snprintf (text, sizeof(text), STR_START_FAILED_ERROR.c_str(), err);
clearText();
Expand Down Expand Up @@ -2079,7 +2079,7 @@ int dsClassicMenu(void) {
bootstrapini.SetInt("NDS-BOOTSTRAP", "BOOST_CPU", 0);
bootstrapini.SetInt("NDS-BOOTSTRAP", "BOOST_VRAM", 0);
bootstrapini.SaveIniFile(bootstrapinipath);
int err = runNdsFile(argarray[0], argarray.size(), (const char **)&argarray[0], true, true, false, true, true, false, -1);
int err = runNdsFile(argarray[0], argarray.size(), (const char **)&argarray[0], sys().isRunFromSD(), true, true, false, true, true, false, -1);
char text[64];
snprintf (text, sizeof(text), STR_START_FAILED_ERROR.c_str(), err);
clearText();
Expand Down Expand Up @@ -2192,7 +2192,7 @@ int dsClassicMenu(void) {
return "fat:/_nds/TWiLightMenu/manual.srldr";
};
argarray.push_back(getLaunchArgument());
int err = runNdsFile(argarray[0], argarray.size(), &argarray[0], true, false, false, true, true, false, -1);
int err = runNdsFile(argarray[0], argarray.size(), &argarray[0], sys().isRunFromSD(), true, false, false, true, true, false, -1);
iprintf (STR_START_FAILED_ERROR.c_str(), err);
}
break;
Expand Down Expand Up @@ -2558,7 +2558,7 @@ int dsClassicMenu(void) {
}

argarray.at(0) = (char *)ndsToBoot;
int err = runNdsFile(argarray[0], argarray.size(), (const char **)&argarray[0], true, true, false, true, true, false, -1);
int err = runNdsFile(argarray[0], argarray.size(), (const char **)&argarray[0], sys().isRunFromSD(), true, true, false, true, true, false, -1);
char text[64];
snprintf (text, sizeof(text), STR_START_FAILED_ERROR.c_str(), err);
clearText();
Expand Down Expand Up @@ -2851,7 +2851,7 @@ int dsClassicMenu(void) {
}
} else {
argarray.at(0) = (char *)ndsToBoot;
err = runNdsFile (argarray[0], argarray.size(), (const char **)&argarray[0], (ms().homebrewBootstrap ? false : true), true, false, true, true, false, -1);
err = runNdsFile (argarray[0], argarray.size(), (const char **)&argarray[0], sys().isRunFromSD(), (ms().homebrewBootstrap ? false : true), true, false, true, true, false, -1);
}
char text[64];
snprintf (text, sizeof(text), STR_START_FAILED_ERROR.c_str(), err);
Expand Down Expand Up @@ -2962,7 +2962,7 @@ int dsClassicMenu(void) {
runNds_boostVram = perGameSettings_boostVram == -1 ? DEFAULT_BOOST_VRAM : perGameSettings_boostVram;
}
//iprintf ("Running %s with %d parameters\n", argarray[0], argarray.size());
int err = runNdsFile (argarray[0], argarray.size(), (const char **)&argarray[0], true, true, dsModeSwitch, runNds_boostCpu, runNds_boostVram, false, language);
int err = runNdsFile (argarray[0], argarray.size(), (const char **)&argarray[0], sys().isRunFromSD(), true, true, dsModeSwitch, runNds_boostCpu, runNds_boostVram, false, language);
char text[64];
snprintf (text, sizeof(text), STR_START_FAILED_ERROR.c_str(), err);
clearText();
Expand Down Expand Up @@ -3542,7 +3542,7 @@ int dsClassicMenu(void) {
err = 1;
}
} else {
err = runNdsFile (ndsToBoot, argarray.size(), (const char **)&argarray[0], !useNDSB, true, dsModeSwitch, boostCpu, boostVram, tscTgds, -1); // Pass ROM to emulator as argument
err = runNdsFile (ndsToBoot, argarray.size(), (const char **)&argarray[0], sys().isRunFromSD(), !useNDSB, true, dsModeSwitch, boostCpu, boostVram, tscTgds, -1); // Pass ROM to emulator as argument
}

whiteScreen = true;
Expand Down
2 changes: 1 addition & 1 deletion romsel_aktheme/arm9/source/gbaswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ void gbaSwitch(void) {
loadGbaBorder((access(borderPath, F_OK)==0) ? borderPath : "nitro:/graphics/gbaborder.png");

// Switch to GBA mode
runNdsFile ("/_nds/TWiLightMenu/gbaswitch.srldr", 0, NULL, true, false, true, false, false, false, -1);
runNdsFile ("/_nds/TWiLightMenu/gbaswitch.srldr", 0, NULL, false, true, false, true, false, false, false, -1);
}
26 changes: 13 additions & 13 deletions romsel_aktheme/arm9/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,13 +810,13 @@ void loadGameOnFlashcard(const char* ndsPath, bool dsGame) {
fcPath = replaceAll(ndsPath, "fat:/", woodfat);
fcrompathini.SetString("Save Info", "lastLoaded", fcPath);
fcrompathini.SaveIniFile("fat:/_wfwd/lastsave.ini");
err = runNdsFile("fat:/Wfwd.dat", 0, NULL, true, true, true, runNds_boostCpu, runNds_boostVram, false, -1);
err = runNdsFile("fat:/Wfwd.dat", 0, NULL, sys().isRunFromSD(), true, true, true, runNds_boostCpu, runNds_boostVram, false, -1);
} else if (memcmp(io_dldi_data->friendlyName, "DSTWO(Slot-1)", 0xD) == 0) {
CIniFile fcrompathini("fat:/_dstwo/autoboot.ini");
fcPath = replaceAll(ndsPath, "fat:/", dstwofat);
fcrompathini.SetString("Dir Info", "fullName", fcPath);
fcrompathini.SaveIniFile("fat:/_dstwo/autoboot.ini");
err = runNdsFile("fat:/_dstwo/autoboot.nds", 0, NULL, true, true, true, runNds_boostCpu, runNds_boostVram, false, -1);
err = runNdsFile("fat:/_dstwo/autoboot.nds", 0, NULL, sys().isRunFromSD(), true, true, true, runNds_boostCpu, runNds_boostVram, false, -1);
} else if ((memcmp(io_dldi_data->friendlyName, "TTCARD", 6) == 0)
|| (memcmp(io_dldi_data->friendlyName, "DSTT", 4) == 0)
|| (memcmp(io_dldi_data->friendlyName, "DEMON", 5) == 0)
Expand All @@ -827,7 +827,7 @@ void loadGameOnFlashcard(const char* ndsPath, bool dsGame) {
fcPath = replaceAll(ndsPath, "fat:/", slashchar);
fcrompathini.SetString("YSMENU", "AUTO_BOOT", fcPath);
fcrompathini.SaveIniFile("fat:/TTMenu/YSMenu.ini");
err = runNdsFile("fat:/YSMenu.nds", 0, NULL, true, true, true, runNds_boostCpu, runNds_boostVram, false, -1);
err = runNdsFile("fat:/YSMenu.nds", 0, NULL, sys().isRunFromSD(), true, true, true, runNds_boostCpu, runNds_boostVram, false, -1);
}

char text[32];
Expand All @@ -854,7 +854,7 @@ void loadGameOnFlashcard(const char* ndsPath, bool dsGame) {
} while (!(pressed & KEY_B));
vector<char *> argarray;
argarray.push_back((char*)(sys().isRunFromSD() ? "sd:/_nds/TWiLightMenu/akmenu.srldr" : "fat:/_nds/TWiLightMenu/akmenu.srldr"));
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], true, false, false, true, true, false, -1);
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], sys().isRunFromSD(), true, false, false, true, true, false, -1);
stop();
}

Expand Down Expand Up @@ -1277,7 +1277,7 @@ int akTheme(void) {

vector<char *> argarray;
argarray.push_back((char*)(sys().isRunFromSD() ? "sd:/_nds/TWiLightMenu/mainmenu.srldr" : "fat:/_nds/TWiLightMenu/mainmenu.srldr"));
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], true, false, false, true, true, false, -1);
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], sys().isRunFromSD(), true, false, false, true, true, false, -1);
stop();
} else {
std::vector<std::string_view> extensionList = {
Expand Down Expand Up @@ -1668,7 +1668,7 @@ int akTheme(void) {
}

argarray.at(0) = (char *)ndsToBoot;
int err = runNdsFile(argarray[0], argarray.size(), (const char **)&argarray[0], true, true, false, true, true, false, -1);
int err = runNdsFile(argarray[0], argarray.size(), (const char **)&argarray[0], sys().isRunFromSD(), true, true, false, true, true, false, -1);
char text[32];
snprintf (text, sizeof(text), "Start failed. Error %i", err);
clearText(false);
Expand All @@ -1691,7 +1691,7 @@ int akTheme(void) {
} while (!(pressed & KEY_B));
vector<char *> argarray;
argarray.push_back((char*)(sys().isRunFromSD() ? "sd:/_nds/TWiLightMenu/akmenu.srldr" : "fat:/_nds/TWiLightMenu/akmenu.srldr"));
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], true, false, false, true, true, false, -1);
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], sys().isRunFromSD(), true, false, false, true, true, false, -1);
stop();
}

Expand Down Expand Up @@ -1934,7 +1934,7 @@ int akTheme(void) {
}

argarray.at(0) = (char *)ndsToBoot;
int err = runNdsFile (argarray[0], argarray.size(), (const char **)&argarray[0], (ms().homebrewBootstrap ? false : true), true, false, true, true, false, -1);
int err = runNdsFile (argarray[0], argarray.size(), (const char **)&argarray[0], sys().isRunFromSD(), (ms().homebrewBootstrap ? false : true), true, false, true, true, false, -1);
char text[32];
snprintf (text, sizeof(text), "Start failed. Error %i", err);
clearText(false);
Expand All @@ -1961,7 +1961,7 @@ int akTheme(void) {
} while (!(pressed & KEY_B));
vector<char *> argarray;
argarray.push_back((char*)(sys().isRunFromSD() ? "sd:/_nds/TWiLightMenu/akmenu.srldr" : "fat:/_nds/TWiLightMenu/akmenu.srldr"));
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], true, false, false, true, true, false, -1);
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], sys().isRunFromSD(), true, false, false, true, true, false, -1);
} else {
ms().romPath[ms().secondaryDevice] = argarray[0];
ms().launchType[ms().secondaryDevice] = TWLSettings::ESDFlashcardLaunch;
Expand Down Expand Up @@ -2061,7 +2061,7 @@ int akTheme(void) {
runNds_boostCpu = perGameSettings_boostCpu == -1 ? DEFAULT_BOOST_CPU : perGameSettings_boostCpu;
runNds_boostVram = perGameSettings_boostVram == -1 ? DEFAULT_BOOST_VRAM : perGameSettings_boostVram;
}
int err = runNdsFile (argarray[0], argarray.size(), (const char **)&argarray[0], true, true, dsModeSwitch, runNds_boostCpu, runNds_boostVram, false, runNds_language);
int err = runNdsFile (argarray[0], argarray.size(), (const char **)&argarray[0], sys().isRunFromSD(), true, true, dsModeSwitch, runNds_boostCpu, runNds_boostVram, false, runNds_language);
char text[32];
snprintf (text, sizeof(text), "Start failed. Error %i", err);
clearText(false);
Expand All @@ -2080,7 +2080,7 @@ int akTheme(void) {
} while (!(pressed & KEY_B));
vector<char *> argarray;
argarray.push_back((char*)(sys().isRunFromSD() ? "sd:/_nds/TWiLightMenu/akmenu.srldr" : "fat:/_nds/TWiLightMenu/akmenu.srldr"));
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], true, false, false, true, true, false, -1);
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], sys().isRunFromSD(), true, false, false, true, true, false, -1);
}
} else {
bool useNDSB = false;
Expand Down Expand Up @@ -2560,7 +2560,7 @@ int akTheme(void) {
argarray.push_back(ROMpath);
argarray.at(0) = (char *)(tgdsMode ? tgdsNdsPath : ndsToBoot);

int err = runNdsFile (ndsToBoot, argarray.size(), (const char **)&argarray[0], !useNDSB, true, dsModeSwitch, boostCpu, boostVram, tscTgds, -1); // Pass ROM to emulator as argument
int err = runNdsFile (ndsToBoot, argarray.size(), (const char **)&argarray[0], sys().isRunFromSD(), !useNDSB, true, dsModeSwitch, boostCpu, boostVram, tscTgds, -1); // Pass ROM to emulator as argument
char text[32];
snprintf (text, sizeof(text), "Start failed. Error %i", err);
clearText(false);
Expand All @@ -2583,7 +2583,7 @@ int akTheme(void) {
} while (!(pressed & KEY_B));
vector<char *> argarray;
argarray.push_back((char*)(sys().isRunFromSD() ? "sd:/_nds/TWiLightMenu/akmenu.srldr" : "fat:/_nds/TWiLightMenu/akmenu.srldr"));
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], true, false, false, true, true, false, -1);
runNdsFile(argarray[0], argarray.size(), (const char**)&argarray[0], sys().isRunFromSD(), true, false, false, true, true, false, -1);
}

while (argarray.size() !=0 ) {
Expand Down
Loading

0 comments on commit cbf784f

Please sign in to comment.