Properly detect Classic NES Series games save type. Fixes #3.

This commit is contained in:
profi200 2020-06-16 16:56:09 +02:00
parent cd99d80e42
commit 837d30465e
No known key found for this signature in database
GPG Key ID: 17B42AE5911139F3
1 changed files with 6 additions and 0 deletions

View File

@ -71,12 +71,18 @@ static Result loadGbaRom(const char *const path, u32 *const rsOut)
// Code based on: https://github.com/Gericom/GBARunner2/blob/master/arm9/source/save/Save.vram.cpp
static u16 tryDetectSaveType(u32 romSize)
{
// TODO: Make a proper override list instead of if/else.
const u32 *romPtr = (u32*)ROM_LOC;
if(romPtr[0xAC / 4] == 0) // If Game Code all zeros --> Homebrew.
{
debug_printf("Detected homebrew. Using SRAM save type.\n");
return SAVE_TYPE_SRAM_256k;
}
else if((romPtr[0xAC / 4] & 0xFFu) == 'F') // Classic NES Series.
{
debug_printf("Detected Classic NES Series game. Using EEPROM 8k save type.\n");
return SAVE_TYPE_EEPROM_8k;
}
romPtr += 0xE4 / 4; // Skip headers.
u16 saveType = SAVE_TYPE_NONE;