I'm currently working in my own game and I want to use SRAM to keep top3 scores in cartridge.
Of course using severals emulators to check if everything is working properly.
I wrote some functions that are working well in GensKmod but i.e. they failed in KFusion.
I.e. I make this function to try to know if I can use SRAM.
Just try to save somewhere in SRAM, after that try to read same info and compare.
Then return 1 if success, if not return 0
Code: Select all
int thereis_sram() // any SRAM there???
{
u32 testSRAMoffset = 0x0100;
char testSRAMtext[]="SEGADOES";
SYS_disableInts();
SRAM_enable();
for(int i=0; i<8;i++) SRAM_writeByte(testSRAMoffset++, testSRAMtext[i]);
SRAM_disable();
SYS_enableInts();
//now read
SYS_disableInts();
SRAM_enable();
testSRAMoffset = 0x0100;
char testSRAMtextREAD[9]={'X','X','X','X','X','X','X','X'};
for(int i=0; i<8;i++) testSRAMtextREAD[i] = SRAM_readByte(testSRAMoffset++);
SRAM_disable();
SYS_enableInts();
if(strcmp(testSRAMtext,testSRAMtextREAD)==0) return 1; //strcmp: A zero value indicates that both strings are equal.
else return 0;
}
ONLY if thereis_sram() returns 1.
If not, I just create my own "fake top3 scores" and don't read from SRAM.
All it's working in GensKMod or Blastem.
But then I put KFusion... and show me top3 with strange scores.... not sure what is happening.
Maybe I'm doing wrong.