From 837d30465e215d179dd560302e52a084e026a0d3 Mon Sep 17 00:00:00 2001 From: profi200 Date: Tue, 16 Jun 2020 16:56:09 +0200 Subject: [PATCH] Properly detect Classic NES Series games save type. Fixes #3. --- source/arm11/hardware/lgy.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/arm11/hardware/lgy.c b/source/arm11/hardware/lgy.c index 39d40cb..4180a51 100644 --- a/source/arm11/hardware/lgy.c +++ b/source/arm11/hardware/lgy.c @@ -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;