GBA: Extend oddly-sized ROMs to full address space (fixes #722)
Vicki Pfau vi@endrift.com
Sun, 09 Jul 2017 09:59:05 -0700
2 files changed,
11 insertions(+),
0 deletions(-)
M
src/gba/gba.c
→
src/gba/gba.c
@@ -342,6 +342,16 @@ gba->memory.mirroring = false;
gba->romCrc32 = doCrc32(gba->memory.rom, gba->memory.romSize); GBAHardwareInit(&gba->memory.hw, &((uint16_t*) gba->memory.rom)[GPIO_REG_DATA >> 1]); GBAVFameDetect(&gba->memory.vfame, gba->memory.rom, gba->memory.romSize); + if (popcount32(gba->memory.romSize) != 1) { + // This ROM is either a bad dump or homebrew. Emulate flash cart behavior. +#ifndef _3DS + void* newRom = anonymousMemoryMap(SIZE_CART0); + memcpy(newRom, gba->memory.rom, gba->pristineRomSize); + gba->memory.rom = newRom; +#endif + gba->memory.romSize = SIZE_CART0; + gba->isPristine = false; + } // TODO: error check return true; }