Allow boot on DS/DS Lite if from slot2.

* Allowed booting on DS/DS lite if booted from a slot2 flashcart.
* Halt condition added if trying to use DSi Enhanced games on NitroHax
booted on DS/DS Lite.
This commit is contained in:
ApacheThunder 2024-11-24 02:57:57 -06:00
parent 6281aee7cc
commit 80f35f9aa4
3 changed files with 25 additions and 16 deletions

View File

@ -343,6 +343,10 @@ void arm7_main (void) {
REG_MBK8=0x09C03980;
}
u8 scfgUnlocked = 0x00;
if ((REG_SCFG_EXT & BIT(31)))scfgUnlocked = 0xFF;
u32 errorCode;
int I;
@ -360,7 +364,7 @@ void arm7_main (void) {
// Get ARM7 to clear RAM
arm7_resetMemory();
if ((REG_SNDEXTCNT != 0) && (REG_SCFG_EXT & BIT(31)))REG_SCFG_ROM = 0x703;
if ((REG_SNDEXTCNT != 0) && (scfgUnlocked > 0))REG_SCFG_ROM = 0x703;
errorOutput(ERR_STS_LOAD_BIN, false);
@ -370,7 +374,7 @@ void arm7_main (void) {
errorCode = arm7_loadBinary();
if (errorCode)errorOutput(errorCode, true);
if (REG_SNDEXTCNT != 0 && (REG_SCFG_EXT & BIT(31))) {
if (REG_SNDEXTCNT != 0 && (scfgUnlocked > 0)) {
*(u16*)0x4000500 = 0x807F;
REG_GPIO_WIFI |= BIT(8); // Old NDS-Wifi mode
REG_SCFG_EXT = 0x92A40000;
@ -389,7 +393,7 @@ void arm7_main (void) {
// Load the cheat engine and hook it into the ARM7 binary
// errorCode = arm7_hookGame(ndsHeader, (const u32*)CHEAT_DATA_LOCATION, (u32*)CHEAT_ENGINE_LOCATION);
if (ndsHeader->unitCode > 0) {
if ((ndsHeader->unitCode > 0) && (scfgUnlocked > 0)) {
errorCode = hookNdsRetail(ndsHeader, (const u32*)CHEAT_DATA_LOCATION, (u32*)CHEAT_ENGINE_LOCATION_TWL);
} else {
errorCode = hookNdsRetail(ndsHeader, (const u32*)CHEAT_DATA_LOCATION, (u32*)CHEAT_ENGINE_LOCATION);
@ -401,7 +405,7 @@ void arm7_main (void) {
}
setMemoryAddress(ndsHeader);
if (ndsHeader->unitCode > 0)setMemoryAddressTWL(ndsHeader);
if ((ndsHeader->unitCode > 0) && (scfgUnlocked > 0))setMemoryAddressTWL(ndsHeader);
ipcSendState(ARM7_BOOTBIN);

View File

@ -11,7 +11,7 @@ export TARGET := NitroHax
export TOPDIR := $(CURDIR)
export VERSION_MAJOR := 0
export VERSION_MINOR := 98
export VERSION_MINOR := 99
export VERSTRING := $(VERSION_MAJOR).$(VERSION_MINOR)

View File

@ -17,6 +17,7 @@
*/
#include <nds.h>
#include <nds/arm9/dldi.h>
#include <stdio.h>
#include <fat.h>
#include <string.h>
@ -97,11 +98,13 @@ int main(int argc, const char* argv[]) {
while(1);
#endif
// ensure(!isDSiMode() || (REG_SCFG_EXT & BIT(31)), "Nitrohax (for DSi) doesn't have the required permissions to run.");
ensure(isDSiMode(), "This version of NitroHax requires DSi/3DS!");
ensure((REG_SCFG_EXT & BIT(31)), "Nitrohax doesn't have the required SCFG permissions to run.");
ensure(!isDSiMode() || (REG_SCFG_EXT & BIT(31)), "Nitrohax (for DSi) doesn't have the required permissions to run.");
// ensure(isDSiMode(), "This version of NitroHax requires DSi/3DS!");
// ensure((REG_SCFG_EXT & BIT(31)), "Nitrohax doesn't have the required SCFG permissions to run.");
ensure (fatInitDefault(), "FAT init failed");
if (!isDSiMode())ensure((io_dldi_data->ioInterface.features & FEATURE_SLOT_GBA), "Must boot from SLOT2 if on DS/DS Lite!");
ui.showMessage (UserInterface::TEXT_TITLE, TITLE_STRING);
@ -124,13 +127,13 @@ int main(int argc, const char* argv[]) {
sysSetCardOwner (BUS_OWNER_ARM9);
// Check if on DSi with unlocked SCFG, if not, then assume standard NTR precedure.
// if (isDSiMode()) {
ui.showMessage ("Checking if a cart is inserted...");
if (REG_SCFG_MC != 0x18)ui.showMessage ("Insert Game...");
while (REG_SCFG_MC != 0x18)DoCartCheck();
cardInit(ndsHeaderExt);
/* } else {
// Check if on DSi with unlocked SCFG, if not, then assume standard NTR precedure.
if (isDSiMode()) {
ui.showMessage ("Checking if a cart is inserted...");
if (REG_SCFG_MC != 0x18)ui.showMessage ("Insert Game...");
while (REG_SCFG_MC != 0x18)DoCartCheck();
cardInit(ndsHeaderExt);
} else {
ui.showMessage ("Loaded codes\nYou can remove your flash card\nRemove DS Card");
do {
swiWaitForVBlank();
@ -142,7 +145,7 @@ int main(int argc, const char* argv[]) {
swiWaitForVBlank();
getHeader (ndsHeader);
} while (ndsHeader[0] == 0xffffffff);
}*/
}
// Delay half a second for the DS card to stabilise
DoWait();
@ -154,6 +157,8 @@ int main(int argc, const char* argv[]) {
ensure(!ROMisDSiExclusive((const tNDSHeader*)ndsHeader), "TWL exclusive games are not supported!");
if (!isDSiMode())ensure(!ROMisDSiEnhanced((const tNDSHeader*)ndsHeader), "TWL Enhanced games not supported on DS/DS Lite!");
gameid = ndsHeader[3];
headerCRC = crc32((const char*)ndsHeader, sizeof(ndsHeader));