GBA: Extend oddly-sized ROMs to full address space (fixes #722)

This commit is contained in:
Vicki Pfau 2017-07-09 09:59:05 -07:00
parent 691600902c
commit 9150a79efd
2 changed files with 11 additions and 0 deletions

View File

@ -4,6 +4,7 @@ Bugfixes:
- GB Audio: Make audio unsigned with bias (fixes mgba.io/i/749) - GB Audio: Make audio unsigned with bias (fixes mgba.io/i/749)
Misc: Misc:
- GBA Timer: Use global cycles for timers - 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) 0.6.0: (Future)
Features: Features:

View File

@ -342,6 +342,16 @@ bool GBALoadROM(struct GBA* gba, struct VFile* vf) {
gba->romCrc32 = doCrc32(gba->memory.rom, gba->memory.romSize); gba->romCrc32 = doCrc32(gba->memory.rom, gba->memory.romSize);
GBAHardwareInit(&gba->memory.hw, &((uint16_t*) gba->memory.rom)[GPIO_REG_DATA >> 1]); GBAHardwareInit(&gba->memory.hw, &((uint16_t*) gba->memory.rom)[GPIO_REG_DATA >> 1]);
GBAVFameDetect(&gba->memory.vfame, gba->memory.rom, gba->memory.romSize); 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 // TODO: error check
return true; return true;
} }