diff --git a/Makefile b/Makefile index ee0ded9..6dfe26e 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ export TARGET := GBA_ExpLoader export TOPDIR := $(CURDIR) export VERSION_MAJOR := 0 -export VERSION_MINOR := 64 +export VERSION_MINOR := 65 export VERSTRING := $(VERSION_MAJOR).$(VERSION_MINOR) # GMAE_ICON is the image used to create the game icon, leave blank to use default rule diff --git a/arm9/include/dsCard.h b/arm9/include/dsCard.h index a002902..7004c5d 100644 --- a/arm9/include/dsCard.h +++ b/arm9/include/dsCard.h @@ -78,6 +78,13 @@ typedef bool BOOL; void Omega_Bank_Switching(u8 bank); void Omega_InitFatBuffer(BYTE saveMODE, u32 saveSize, u32 gameSize); u32 Omega_SetSaveSize(u8 SaveMode); + void SetSPIWrite(u16 control); + void SetSPIControl(u16 control); + void SPI_Enable(); + void SPI_Disable(); + void SPI_Write_Enable(); + void SPI_Write_Disable(); + u16 Read_FPGA_ver(); void OpenRamWrite(); void CloseRamWrite(); void SetSerialMode(); diff --git a/arm9/include/dsCard.itcm.cpp b/arm9/include/dsCard.itcm.cpp index 856f831..d8c376f 100644 --- a/arm9/include/dsCard.itcm.cpp +++ b/arm9/include/dsCard.itcm.cpp @@ -204,6 +204,40 @@ u32 Omega_SetSaveSize(u8 SaveMode) { } } +void SetSPIWrite(u16 control) { + *(u16*)0x9fe0000 = 0xd200; + *(u16*)0x8000000 = 0x1500; + *(u16*)0x8020000 = 0xd200; + *(u16*)0x8040000 = 0x1500; + *(u16*)0x9680000 = control; + *(u16*)0x9fc0000 = 0x1500; +} + +void SetSPIControl(u16 control) { + *(u16*)0x9fe0000 = 0xd200; + *(u16*)0x8000000 = 0x1500; + *(u16*)0x8020000 = 0xd200; + *(u16*)0x8040000 = 0x1500; + *(u16*)0x9660000 = control; + *(u16*)0x9fc0000 = 0x1500; +} + +void SPI_Enable() { SetSPIControl(1); } + +void SPI_Disable() { SetSPIControl(0); } + +void SPI_Write_Enable() { SetSPIWrite(1); } + +void SPI_Write_Disable() { SetSPIWrite(0); } + +u16 Read_FPGA_ver() { + u16 Read_SPI; + SPI_Enable(); + Read_SPI = *(vu16*)0x9E00000; + SPI_Disable(); + return Read_SPI; +} + void SetRampage(u16 page) { diff --git a/arm9/source/ctrl_tbl.cpp b/arm9/source/ctrl_tbl.cpp index b8617ae..c02e00f 100644 --- a/arm9/source/ctrl_tbl.cpp +++ b/arm9/source/ctrl_tbl.cpp @@ -21,6 +21,7 @@ extern "C" { extern void _RamPG(void); extern void _RamSave(int bnk); extern bool isOmega; +extern bool isOmegaDE; extern bool isSuperCard; #ifdef __cplusplus @@ -34,18 +35,18 @@ void ctrl_get() { memset((u8*)&ctrl, 0, sizeof(struct ctrl_tbl)); - if(carttype != 5 && !isSuperCard/* && !isOmega*/) { + if (((carttype != 5) && !isSuperCard && !isOmega) || isOmegaDE) { _RamPG(); ReadSram(SRAM_ADDR, (u8*)&ctrl, sizeof(struct ctrl_tbl)); _RamSave(0); return; } - + if (isSuperCard) { sprintf(expfile, "%s/SUPERCRD.dat", ini.sign_dir); - } else /*if (isOmega) { + } else if (isOmega) { sprintf(expfile, "%s/OMEGA.dat", ini.sign_dir); - } else*/ { + } else { sprintf(expfile, "%s/EXP128K.dat", ini.sign_dir); } exp = fopen(expfile, "rb"); @@ -59,7 +60,7 @@ void ctrl_set() { FILE *exp; char expfile[64]; - if(carttype != 5 && !isSuperCard/* && !isOmega*/) { + if (((carttype != 5) && !isSuperCard && !isOmega) || isOmegaDE) { _RamPG(); WriteSram(SRAM_ADDR, (u8*)&ctrl, sizeof(struct ctrl_tbl)); _RamSave(0); @@ -68,9 +69,9 @@ void ctrl_set() { if (isSuperCard) { sprintf(expfile, "%s/SUPERCRD.dat", ini.sign_dir); - } else/* if (isOmega) { + } else if (isOmega) { sprintf(expfile, "%s/OMEGA.dat", ini.sign_dir); - } else*/ { + } else { sprintf(expfile, "%s/EXP128K.dat", ini.sign_dir); } exp = fopen(expfile, "wb"); diff --git a/arm9/source/ctrl_tbl.h b/arm9/source/ctrl_tbl.h index d5ceec2..8670994 100644 --- a/arm9/source/ctrl_tbl.h +++ b/arm9/source/ctrl_tbl.h @@ -4,6 +4,7 @@ struct GBA_File { char gamecode[5]; u32 type; u32 filesize; + int isNDSFile; }; diff --git a/arm9/source/gbaldr.itcm.cpp b/arm9/source/gbaldr.itcm.cpp index fdc68da..43c7e86 100644 --- a/arm9/source/gbaldr.itcm.cpp +++ b/arm9/source/gbaldr.itcm.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -30,25 +31,26 @@ //#include //basic print funcionality -#define MAX_NOR 0x2000000 // 32MByte -#define MAX_NORPLUS 0x4000000 // 64MByte (3 in 1 Plus) -#define MAX_PSRAM 0x1000000 // 16MByte -#define SRAM_PAGE_SIZE 0x10000 // SRAM Page Size -#define MAX_SRAM 0x80000 // 4MBit/512KByte total SRAM +#define MAX_NOR 0x2000000 // 32MByte +#define MAX_NORPLUS 0x4000000 // 64MByte (3 in 1 Plus) +#define MAX_PSRAM 0x1000000 // 16MByte +#define SRAM_PAGE_SIZE 0x10000 // SRAM Page Size +#define MAX_SRAM 0x80000 // 4MBit/512KByte total SRAM -#define USE_SRAM 0x20000 // 128KByte -#define USE_SRAM_PG 48 // 0x0A030000-0A031FFF -#define USE_SRAM_PG_EZ4 11 // 0x0A008000-0A00FFFF -#define USE_SRAM_PG_EWN 10 // 0x0A020000-0A02FFFF -#define USE_SRAM_PG_EWN128 9 // 0x0A010000-0A01FFFF -#define USE_SRAM_PG_M3 6 +#define USE_SRAM 0x20000 // 128KByte +#define USE_SRAM_PG 48 // 0x0A030000-0A031FFF +#define USE_SRAM_PG_EZ4 11 // 0x0A008000-0A00FFFF +#define USE_SRAM_PG_EWN 10 // 0x0A020000-0A02FFFF +#define USE_SRAM_PG_EWN128 9 // 0x0A010000-0A01FFFF +#define USE_SRAM_PG_M3 6 -#define USE_SRAM_NOR 16 // 0x0A010000-0A02FFFF -#define USE_SRAM_PSR 50 // 0x0A032000-0A051FFF -#define USE_SRAM_PSR_EZ4 16 // 0x0A010000-0A02FFFF -#define USE_SRAM_PSR_EWN 8 // 0x0A000000-0A01FFFF -#define USE_SRAM_PSR_M3 4 -#define USE_SRAM_PSR_OMEGA 0 +#define USE_SRAM_NOR 16 // 0x0A010000-0A02FFFF +#define USE_SRAM_PSR 50 // 0x0A032000-0A051FFF +#define USE_SRAM_PSR_EZ4 16 // 0x0A010000-0A02FFFF +#define USE_SRAM_PSR_EWN 8 // 0x0A000000-0A01FFFF +#define USE_SRAM_PSR_M3 4 +#define USE_SRAM_PSR_OMEGA 40 +#define USE_SRAM_PSR_OMEGA_DE 0 #define PSRAM_BUF 0x8000 // 32KB @@ -76,10 +78,17 @@ extern int GBAmode; static u32 savesize; +static const char *validExtensions[3] = { + ".GBA", + ".BIN", + ".NDS" +}; + int carttype = 0; bool isSuperCard = false; bool is3in1Plus = false; bool isOmega = false; +bool isOmegaDE = false; extern int save_sel(int mod, char *name); extern u16 gl_ingame_RTC_open_status; @@ -390,7 +399,7 @@ int check_M3() { static bool CheckForSuperCard() { if (CheckSuperCardID() == 0x227E0000) { - carttype = 6; + carttype = 6; is3in1Plus = false; isSuperCard = true; return true; @@ -401,11 +410,21 @@ static bool CheckForSuperCard() { static bool CheckForOmega() { // EZFlash Omega SetRompage(0x8002); if (CheckOmegaID() == 0x227EEA00) { + Set_AUTO_save(0); carttype = 1; is3in1Plus = false; isSuperCard = false; isOmega = true; - // Set_AUTO_save(0); + isOmegaDE = false; + /*char ct[4]; + ct[0] = (io_dldi_data->ioInterface.ioType & 0xFF); + ct[1] = ((io_dldi_data->ioInterface.ioType >> 8) & 0xFF); + ct[2] = ((io_dldi_data->ioInterface.ioType >> 16) & 0xFF); + ct[3] = ((io_dldi_data->ioInterface.ioType >> 24) & 0xFF); + ct[4] = 0; + if ((ct[0] != 'E') && (ct[1] != 'Z') && (ct[2] != '5') && (ct[3] != 'N'))isOmegaDE = true;*/ + /*u16 fpgaVer = (Read_FPGA_ver() & 0xF000); + if (fpgaVer != 0 && fpgaVer != 0xE000)isOmegaDE = true;*/ return true; } return false; @@ -481,7 +500,15 @@ void _RamPG() { SetM3Ram(USE_SRAM_PG_M3); return; } - if (isOmega) { SetRampage(16); } else { SetRampage(USE_SRAM_PG); } + if (isOmega) { + if (isOmegaDE) { + SetRampage(16); + return; + } + SetRampage(96); + } else { + SetRampage(USE_SRAM_PG); + } return; } @@ -503,13 +530,24 @@ void _RamSave(int bnk) { if(GBAmode == 0) { if (isOmega) { + if (isOmegaDE) { + SetRampage(USE_SRAM_PSR_OMEGA_DE + (bnk * 16)); + return; + } SetRampage(USE_SRAM_PSR_OMEGA + (bnk * 16)); } else { SetRampage(USE_SRAM_PSR + bnk * 16); } } else { - if (isOmega) { SetRampage(USE_SRAM_PSR_OMEGA + (bnk * 16)); return; } - SetRampage(USE_SRAM_NOR + bnk * 16); + if (isOmega) { + if (isOmegaDE) { + SetRampage(USE_SRAM_PSR_OMEGA_DE + (bnk * 16)); + return; + } + SetRampage(USE_SRAM_PSR_OMEGA + (bnk * 16)); + } else { + SetRampage(USE_SRAM_NOR + bnk * 16); + } } return; } @@ -547,11 +585,13 @@ int checkSRAM(char *name) { } savesize = ctrl.save_siz[GBAmode]; - // if (isOmega && savesize > 0x10000)savesize = 0x10000; - if((savesize < 0x2000) || (savesize > USE_SRAM)) { + + if ((savesize < 0x2000) || (savesize > USE_SRAM)) { savesize = 0x10000; ctrl.save_siz[GBAmode] = savesize; } + + if (isOmega && (savesize > 0x10000))savesize = 0x10000; strcpy(name, (char *)ctrl.sav_nam[GBAmode]); ln = strlen(name) - 3; @@ -664,9 +704,7 @@ void SRAMdump(int cmd) { mx = 8; switch (carttype) { - case 1: - if (isOmega)mx = 2; - break; + case 1: if (isOmega)mx = 2; break; case 4: mx = 4; break; case 5: mx = 2; break; case 6: @@ -681,15 +719,17 @@ void SRAMdump(int cmd) { dsp_bar(4, -1); dmp = fopen(name, "wb"); for(i = 0; i < mx; i++) { - if(carttype == 6 && !isSuperCard) { + if((carttype == 6) && !isSuperCard) { SetM3Ram(i); } else if (!isSuperCard) { if((carttype >= 4)) { SetEWINRam(8 + i); - } else if (isOmega) { + } else if (isOmega && !isOmegaDE) { SetRampage(USE_SRAM_PSR_OMEGA + (i * 16)); + } else if (isOmegaDE) { + SetRampage(USE_SRAM_PSR_OMEGA_DE + (i * 16)); } else { - SetRampage(i * 16); + if(!isSuperCard)SetRampage(i * 16); } } @@ -727,15 +767,17 @@ void SRAMdump(int cmd) { memset(rwbuf, 0, USE_SRAM / 2); if(dmp != NULL) fread(rwbuf, 1, USE_SRAM / 2, dmp); - if(carttype == 6) { + if((carttype == 6) && !isSuperCard) { SetM3Ram(i); } else { if((carttype >= 4) && !isSuperCard) { SetEWINRam(8 + i); - } else if (isOmega) { + } else if (isOmega && !isOmegaDE) { SetRampage(USE_SRAM_PSR_OMEGA + (i * 16)); + } else if (isOmegaDE) { + SetRampage(USE_SRAM_PSR_OMEGA_DE + (i * 16)); } else { - SetRampage(i * 16); + if (!isSuperCard)SetRampage(i * 16); } } @@ -1225,13 +1267,19 @@ bool nameEndsWith (const string& name, const string& extension) { return false; } +bool isValidFile(const string& name) { + for (int i = 0; i < 3; i++) { + if (nameEndsWith(name, validExtensions[i]))return true; + } + return false; +} + + void FileListGBA() { DIR *dir; struct stat st; FILE *gbaFile; int i; - const char* GBAEXT = ".GBA"; - const char* BINEXT = ".BIN"; numFiles = 0; numGames = 0; @@ -1253,10 +1301,12 @@ void FileListGBA() { // if(pent == NULL)break; if(!pent)break; stat(pent->d_name, &st); - if ((((st.st_mode & S_IFMT) == S_IFDIR) && (((string)pent->d_name).compare(".") != 0)) || nameEndsWith(pent->d_name, GBAEXT) || nameEndsWith(pent->d_name, BINEXT)) { + if ((((st.st_mode & S_IFMT) == S_IFDIR) && (((string)pent->d_name).compare(".") != 0)) || isValidFile(pent->d_name)) { strcpy(fs[numFiles].filename, pent->d_name); // strcpy(fs[numFiles].Alias, pent->d_name); fs[numFiles].type = st.st_mode; + fs[numFiles].isNDSFile = 0; + if (nameEndsWith(pent->d_name, validExtensions[2]))fs[numFiles].isNDSFile = 1; if ((((string)pent->d_name).compare(".") != 0) && (((string)pent->d_name).compare("..") != 0) && ((st.st_mode & S_IFMT) != S_IFDIR)) { FILE *file = fopen(pent->d_name, "rb"); if (file) { @@ -1282,11 +1332,19 @@ void FileListGBA() { gbaFile = fopen(tbuf, "rb"); memset(tbuf, 0, 256); if(gbaFile != NULL) { - fread(tbuf, 1, 256, gbaFile); - tbuf[0xB0] = 0; - strcpy(fs[i].gamecode, tbuf + 0xAC); - tbuf[0xAC] = 0; - strcpy(fs[i].gametitle, tbuf + 0xA0); + if (fs[i].isNDSFile == 1) { + fread(tbuf, 1, 256, gbaFile); + tbuf[0x10] = 0; + strcpy(fs[i].gamecode, tbuf + 0x0C); + tbuf[0x0C] = 0; + strcpy(fs[i].gametitle, tbuf); // 0x0 + } else { + fread(tbuf, 1, 256, gbaFile); + tbuf[0xB0] = 0; + strcpy(fs[i].gamecode, tbuf + 0xAC); + tbuf[0xAC] = 0; + strcpy(fs[i].gametitle, tbuf + 0xA0); + } fclose(gbaFile); } else { fs[i].gamecode[0] = 0; diff --git a/arm9/source/main.c b/arm9/source/main.c index 7e7b144..2b9e5e1 100644 --- a/arm9/source/main.c +++ b/arm9/source/main.c @@ -43,18 +43,20 @@ #include "skin.h" #include "message.h" #include "tonccpy.h" +#include "nds_loader_arm9.h" extern uint16* MainScreen; extern uint16* SubScreen; #define BG_256_COLOR (BIT(7)) -#define VERSTRING "v0.64" +#define VERSTRING "v0.65" int numFiles = 0; int numGames = 0; char curpath[256]; +char* currentNDSFilePath[256]; int sortfile[200]; struct GBA_File fs[200]; @@ -70,6 +72,7 @@ extern int carttype; extern bool isSuperCard; extern bool is3in1Plus; extern bool isOmega; +extern bool isOmegaDE; extern u16 gl_ingame_RTC_open_status; extern void SetSDControl(u16 control); @@ -299,6 +302,53 @@ int cnf_inp(int n1, int n2) { return(ky); } +int cnf_inp2(int n1, int n2) { + int len; + int x1, x2; + int y1, y2; + int xi, yi; + u16 *gback; + int gsiz; + u32 ky; + + len = strlen(cnfmsg2[n1]); + if(len < strlen(cnfmsg2[n2]))len = strlen(cnfmsg2[n2]); + if(len < 20) len = 20; + + x1 = (256 - len * 6) / 2 - 4; + y1 = 4*12-6; + x2 = x1 + len * 6 + 9; + y2 = 8*12+3; + + gsiz = (x2-x1+1) * (y2-y1+1); + gback = (u16*)malloc(sizeof(u16*) * gsiz); + for( yi=y1; yi