Implement second SRAM bank for SuperCards.

* Implemented unused second SRAM bank for SuperCards for storing
GBA-Exploader metadata. Note that game patches are not yet updated for
this so games like Pokémon can't use it yet.
This commit is contained in:
ApacheThunder 2025-05-25 13:39:52 -05:00
parent c779a90200
commit f9251ba0ce
6 changed files with 56 additions and 20 deletions

View File

@ -9,7 +9,7 @@ export TARGET := GBA_ExpLoader
export TOPDIR := $(CURDIR) export TOPDIR := $(CURDIR)
export VERSION_MAJOR := 0 export VERSION_MAJOR := 0
export VERSION_MINOR := 66 export VERSION_MINOR := 67
export VERSTRING := $(VERSION_MAJOR).$(VERSION_MINOR) export VERSTRING := $(VERSION_MAJOR).$(VERSION_MINOR)
# GMAE_ICON is the image used to create the game icon, leave blank to use default rule # GMAE_ICON is the image used to create the game icon, leave blank to use default rule

View File

@ -265,6 +265,7 @@ u32 CheckSuperCardID() {
// _SC_changeMode16(0x1510); // _SC_changeMode16(0x1510);
*(vu16*)(FlashBase) = 0x4D54; *(vu16*)(FlashBase) = 0x4D54;
if (*(vu16*)(FlashBase) == 0x4D54) { if (*(vu16*)(FlashBase) == 0x4D54) {
_SC_changeMode(SC_MODE_RAM_RO);
ID = 0x227E2202; ID = 0x227E2202;
return 0x227E0000; return 0x227E0000;
} }

View File

@ -34,7 +34,7 @@
#endif #endif
/*----------------------------------------------------------------- /*-----------------------------------------------------------------
_SC_changeMode (was SC_Unlock) _SC_changeMode (was SC_Unlock) (toggling read/write of PSRAM also toggles SRAM bank!)
Added by MightyMax Added by MightyMax
Modified by Chishm Modified by Chishm
Modified again by loopy Modified again by loopy

View File

@ -35,16 +35,16 @@ void ctrl_get() {
memset((u8*)&ctrl, 0, sizeof(struct ctrl_tbl)); memset((u8*)&ctrl, 0, sizeof(struct ctrl_tbl));
if (((carttype != 5) && !isSuperCard && !isOmega) || isOmegaDE) { if (((carttype != 5) && /*!isSuperCard &&*/ !isOmega) || isOmegaDE) {
_RamPG(); _RamPG();
ReadSram(SRAM_ADDR, (u8*)&ctrl, sizeof(struct ctrl_tbl)); ReadSram(SRAM_ADDR, (u8*)&ctrl, sizeof(struct ctrl_tbl));
_RamSave(0); _RamSave(0);
return; return;
} }
if (isSuperCard) { /*if (isSuperCard) {
sprintf(expfile, "%s/SUPERCRD.dat", ini.sign_dir); sprintf(expfile, "%s/SUPERCRD.dat", ini.sign_dir);
} else if (isOmega) { } else */if (isOmega) {
sprintf(expfile, "%s/OMEGA.dat", ini.sign_dir); sprintf(expfile, "%s/OMEGA.dat", ini.sign_dir);
} else { } else {
sprintf(expfile, "%s/EXP128K.dat", ini.sign_dir); sprintf(expfile, "%s/EXP128K.dat", ini.sign_dir);
@ -60,16 +60,16 @@ void ctrl_set() {
FILE *exp; FILE *exp;
char expfile[64]; char expfile[64];
if (((carttype != 5) && !isSuperCard && !isOmega) || isOmegaDE) { if (((carttype != 5) && /*!isSuperCard && */!isOmega) || isOmegaDE) {
_RamPG(); _RamPG();
WriteSram(SRAM_ADDR, (u8*)&ctrl, sizeof(struct ctrl_tbl)); WriteSram(SRAM_ADDR, (u8*)&ctrl, sizeof(struct ctrl_tbl));
_RamSave(0); _RamSave(0);
return; return;
} }
if (isSuperCard) { /*if (isSuperCard) {
sprintf(expfile, "%s/SUPERCRD.dat", ini.sign_dir); sprintf(expfile, "%s/SUPERCRD.dat", ini.sign_dir);
} else if (isOmega) { } else */if (isOmega) {
sprintf(expfile, "%s/OMEGA.dat", ini.sign_dir); sprintf(expfile, "%s/OMEGA.dat", ini.sign_dir);
} else { } else {
sprintf(expfile, "%s/EXP128K.dat", ini.sign_dir); sprintf(expfile, "%s/EXP128K.dat", ini.sign_dir);

View File

@ -28,6 +28,7 @@
#include "dsCard.h" #include "dsCard.h"
#include "sc_patches.h" #include "sc_patches.h"
#include "sc_sram.h" #include "sc_sram.h"
#include "io_sc_common.h"
//#include <nds/arm9/console.h> //basic print funcionality //#include <nds/arm9/console.h> //basic print funcionality
@ -483,7 +484,7 @@ int checkFlashID() {
void _RamPG() { void _RamPG() {
if (isSuperCard)return; // if (isSuperCard)return;
switch (carttype) { switch (carttype) {
case 3: case 3:
SetRampage(USE_SRAM_PG_EZ4); SetRampage(USE_SRAM_PG_EZ4);
@ -495,7 +496,11 @@ void _RamPG() {
SetEWINRam(USE_SRAM_PG_EWN128); SetEWINRam(USE_SRAM_PG_EWN128);
return; return;
case 6: case 6:
SetM3Ram(USE_SRAM_PG_M3); if (isSuperCard) {
_SC_changeMode(SC_MODE_RAM);
} else {
SetM3Ram(USE_SRAM_PG_M3);
}
return; return;
} }
if (isOmega) { if (isOmega) {
@ -505,19 +510,27 @@ void _RamPG() {
} }
SetRampage(USE_SRAM_PG_OMEGA); SetRampage(USE_SRAM_PG_OMEGA);
} else { } else {
SetRampage(USE_SRAM_PG); SetRampage(USE_SRAM_PG);
} }
return; return;
} }
void _RamSave(int bnk) { void _RamSave(int bnk) {
if (isSuperCard)return; if (isSuperCard && (bnk > 1))return;
switch (carttype) { switch (carttype) {
case 3: case 3:
SetRampage(USE_SRAM_PSR_EZ4 + bnk * 16); SetRampage(USE_SRAM_PSR_EZ4 + bnk * 16);
return; return;
case 6: case 6:
SetM3Ram(USE_SRAM_PSR_M3 + bnk); if (isSuperCard) {
if (bnk == 0) {
_SC_changeMode(SC_MODE_RAM_RO);
} else {
_SC_changeMode(SC_MODE_RAM);
}
} else {
SetM3Ram(USE_SRAM_PSR_M3 + bnk);
}
return; return;
} }
@ -590,6 +603,7 @@ int checkSRAM(char *name) {
} }
// if (isOmega && (savesize > 0x10000))savesize = 0x10000; // if (isOmega && (savesize > 0x10000))savesize = 0x10000;
if (isSuperCard && (savesize > 0x10000))savesize = 0x10000;
strcpy(name, (char *)ctrl.sav_nam[GBAmode]); strcpy(name, (char *)ctrl.sav_nam[GBAmode]);
ln = strlen(name) - 3; ln = strlen(name) - 3;
@ -708,8 +722,11 @@ void SRAMdump(int cmd) {
case 4: mx = 4; break; case 4: mx = 4; break;
case 5: mx = 2; break; case 5: mx = 2; break;
case 6: case 6:
mx = 16; if (isSuperCard) {
if (isSuperCard)mx = 1; mx = 2;
} else {
mx = 16;
}
break; break;
} }
@ -719,8 +736,16 @@ void SRAMdump(int cmd) {
dsp_bar(4, -1); dsp_bar(4, -1);
dmp = fopen(name, "wb"); dmp = fopen(name, "wb");
for(i = 0; i < mx; i++) { for(i = 0; i < mx; i++) {
if((carttype == 6) && !isSuperCard) { if (carttype == 6) {
SetM3Ram(i); if (isSuperCard) {
if (i == 0) {
_SC_changeMode(SC_MODE_RAM_RO);
} else {
_SC_changeMode(SC_MODE_RAM);
}
} else {
SetM3Ram(i);
}
} else if (!isSuperCard) { } else if (!isSuperCard) {
if((carttype >= 4)) { if((carttype >= 4)) {
SetEWINRam(8 + i); SetEWINRam(8 + i);
@ -767,8 +792,16 @@ void SRAMdump(int cmd) {
memset(rwbuf, 0, USE_SRAM / 2); memset(rwbuf, 0, USE_SRAM / 2);
if(dmp != NULL) if(dmp != NULL)
fread(rwbuf, 1, USE_SRAM / 2, dmp); fread(rwbuf, 1, USE_SRAM / 2, dmp);
if((carttype == 6) && !isSuperCard) { if (carttype == 6) {
SetM3Ram(i); if (isSuperCard) {
if (i == 0) {
_SC_changeMode(SC_MODE_RAM_RO);
} else {
_SC_changeMode(SC_MODE_RAM);
}
} else {
SetM3Ram(i);
}
} else { } else {
if((carttype >= 4) && !isSuperCard) { if((carttype >= 4) && !isSuperCard) {
SetEWINRam(8 + i); SetEWINRam(8 + i);
@ -1081,6 +1114,8 @@ int writeFileToRam(int sel) {
Set_RTC_status(1); Set_RTC_status(1);
SetPSRampage(0); SetPSRampage(0);
// Omega_InitFatBuffer(OMEGA_UNKNOWN, Omega_SetSaveSize(OMEGA_UNKNOWN), fs[sel].filesize); // Omega_InitFatBuffer(OMEGA_UNKNOWN, Omega_SetSaveSize(OMEGA_UNKNOWN), fs[sel].filesize);
} else if (isSuperCard) {
_SC_changeMode(SC_MODE_RAM);
} }
// savesize = gba_check(gbaFile, fs[sel].filesize, rwbuf, 0x100000); // savesize = gba_check(gbaFile, fs[sel].filesize, rwbuf, 0x100000);

View File

@ -49,7 +49,7 @@ extern uint16* SubScreen;
#define BG_256_COLOR (BIT(7)) #define BG_256_COLOR (BIT(7))
#define VERSTRING "v0.66" #define VERSTRING "v0.67"
int numFiles = 0; int numFiles = 0;
int numGames = 0; int numGames = 0;