ezfo-disc_io
ezfo-disc_io copied to clipboard
possible solution for "PSRAM only"
in pseudo-C:
int EWRAM_CODE FindMyRompage(){
static int EWRAM cached = -1;
if(cached >= 0) return cached;
static char EWRAM romname_copy[ROMNAMELENGTH];
memcpy(romname_copy, header->romname, ROMNAMELENGTH);
static int EWRAM checksum_copy = header->checksum;
for(int i=0; i<= MAXROMPAGE; i+=0x20){ // probably actually check 0x200 first tho, because psram should only contain us if we just got booted there, since it's volatile
SetRompage(i);
if(0==memcmp(romname_copy,header->romname,ROMNAMELENGTH) && checksum_copy==header->checksum){
cached = i;
return i;
}
}
return -1; // should never happen
}
first call is gonna be a bit slower than subsequent ones (due to the static cache), and first call needs to be done from the actual rom selected to copy the game's name & checksum from the header, while subsequent ones can just use the cached value to get back to it.