all repos — mgba @ 9d8f99295b0864543599724814228d2767831494

mGBA Game Boy Advance Emulator

GBA: Reset active region as needed when loading a ROM
Vicki Pfau vi@endrift.com
Fri, 21 Jul 2017 17:15:24 -0700
commit

9d8f99295b0864543599724814228d2767831494

parent

38e56597b5f6ef471f2b18e5eb268b8cdeed016a

2 files changed, 11 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -4,6 +4,7 @@ - ELF support

Bugfixes: - GB Audio: Make audio unsigned with bias (fixes mgba.io/i/749) - Python: Fix importing .gb or .gba before .core + - GBA: Reset active region as needed when loading a ROM Misc: - GBA Timer: Use global cycles for timers - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)
M src/gba/gba.csrc/gba/gba.c

@@ -312,6 +312,10 @@ gba->memory.romSize = SIZE_CART0;

gba->memory.romMask = SIZE_CART0 - 1; gba->memory.mirroring = false; gba->romCrc32 = 0; + + if (gba->cpu) { + gba->cpu->memory.setActiveRegion(gba->cpu, gba->cpu->gprs[ARM_PC]); + } return true; }

@@ -335,6 +339,9 @@ gba->yankedRomSize = 0;

gba->memory.romSize = 0; gba->memory.romMask = 0; gba->romCrc32 = doCrc32(gba->memory.wram, gba->pristineRomSize); + if (gba->cpu && gba->memory.activeRegion == REGION_WORKING_RAM) { + gba->cpu->memory.setActiveRegion(gba->cpu, gba->cpu->gprs[ARM_PC]); + } return true; }

@@ -378,6 +385,9 @@ gba->memory.rom = newRom;

#endif gba->memory.romSize = SIZE_CART0; gba->isPristine = false; + } + if (gba->cpu && gba->memory.activeRegion >= REGION_CART0) { + gba->cpu->memory.setActiveRegion(gba->cpu, gba->cpu->gprs[ARM_PC]); } // TODO: error check return true;