diff --git a/CHANGES b/CHANGES index d10243b3a..e8e5a9c46 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ Bugfixes: - GB Audio: Make audio unsigned with bias (fixes mgba.io/i/749) Misc: - GBA Timer: Use global cycles for timers + - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722) 0.6.0: (Future) Features: diff --git a/src/gba/gba.c b/src/gba/gba.c index a6d9467ae..d5f5e2113 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -342,6 +342,16 @@ bool GBALoadROM(struct GBA* gba, struct VFile* vf) { 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; }