From 7ce405acac340ff506e22b43cc75f8d978ce9407 Mon Sep 17 00:00:00 2001 From: ApacheThunder Date: Sat, 1 Jun 2024 01:17:31 -0500 Subject: [PATCH] Partial fix for 3in1 Plus reset after NorFlash... * Partial fix for 3 in 1 Plus. 4MB games mostly boot up fine after intial reset after hitting X after writing them to NorFlash. Larger games almost boot but hang after Ninteno logo. Further testing and fixes still needed. --- arm9/Makefile | 2 +- arm9/include/dsCard.itcm.cpp | 4 ++-- arm9/source/gbaldr.itcm.cpp | 6 ++++-- arm9/source/main.c | 8 +++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arm9/Makefile b/arm9/Makefile index 0d75b06..4da893e 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -33,7 +33,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lfat -lnds9 +LIBS := -lfat -lnds329 #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing diff --git a/arm9/include/dsCard.itcm.cpp b/arm9/include/dsCard.itcm.cpp index fd516c5..d61d3b2 100644 --- a/arm9/include/dsCard.itcm.cpp +++ b/arm9/include/dsCard.itcm.cpp @@ -381,8 +381,8 @@ void WriteNorFlashINTEL(u32 address,u8 *buffer,u32 size) { OpenNorWrite(); } - if(size>0x4000) { - size2 = size >>1; + if(size > 0x4000) { + size2 = size >> 1; lop = 2; } else { size2 = size; diff --git a/arm9/source/gbaldr.itcm.cpp b/arm9/source/gbaldr.itcm.cpp index 149e288..f146cf4 100644 --- a/arm9/source/gbaldr.itcm.cpp +++ b/arm9/source/gbaldr.itcm.cpp @@ -877,8 +877,11 @@ int writeFileToNor(int sel) { dsp_bar(1, 100); fclose(gbaFile); + + if (is3in1Plus)chip_reset(); + CloseNorWrite(); - + // getSaveFilename(sel, savName); if(cmd >= 0) { writeSramFromFile(savName); } else { blankSRAM(savName); } @@ -1053,7 +1056,6 @@ bool nameEndsWith (const string& name, const string& extension) { return false; } -// TODO: Fix Filelist to use new code based on port of NDS_Backup_Tool void FileListGBA() { DIR *dir; struct stat st; diff --git a/arm9/source/main.c b/arm9/source/main.c index 0a57560..88bc33b 100644 --- a/arm9/source/main.c +++ b/arm9/source/main.c @@ -861,7 +861,7 @@ int gba_sel() { if(ky & KEY_X) { if(GBAmode == 1) { - SetRompage(0); + if (!is3in1Plus)SetRompage(0); SetRampage(16); gbaMode(); } else { @@ -873,8 +873,7 @@ int gba_sel() { if(GBAmode == 1) { if(checkSRAM(filename)) { // if(cnf_inp(3, 4) & KEY_A) - if(save_sel(0, filename) >= 0) - writeSramFromFile(filename); + if(save_sel(0, filename) >= 0)writeSramFromFile(filename); _gba_sel_dsp(sel, yc, 0); } else err_cnf(4, 5); } else { @@ -1130,6 +1129,9 @@ inp_key(); //--------------------------------------------------------------------------------- int main(void) { //--------------------------------------------------------------------------------- + extern u64 *fake_heap_end; + *fake_heap_end = 0; + defaultExceptionHandler(); int i;