GBA Memory: Fix jumping to invalid memory when switching from Thumb to ARM

This commit is contained in:
Jeffrey Pfau 2015-05-09 17:07:26 -07:00
parent cb3f029d9e
commit 37f5058de0
2 changed files with 7 additions and 8 deletions

View File

@ -52,6 +52,7 @@ Bugfixes:
- GBA BIOS: Initialize a variable that may be uninitialized in very rare cases
- ARM7: Fix ARM multiply instructions when PC is a destination register
- SDL: Fix potential build issues when Qt and SDL2 are in use
- GBA Memory: Fix jumping to invalid memory when switching from Thumb to ARM
Misc:
- Qt: Show multiplayer numbers in window title
- Qt: Handle saving input settings better

View File

@ -231,13 +231,7 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
}
gba->lastJump = address;
if (newRegion >= REGION_CART0 && (address & (SIZE_CART0 - 1)) >= memory->romSize) {
cpu->memory.activeRegion = _deadbeef;
cpu->memory.activeMask = 0;
GBALog(gba, GBA_LOG_FATAL, "Jumped past end of ROM");
return;
}
if (newRegion == memory->activeRegion) {
if (newRegion == memory->activeRegion && (newRegion < REGION_CART0 || (address & (SIZE_CART0 - 1)) < memory->romSize)) {
return;
}
@ -270,8 +264,12 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
case REGION_CART2_EX:
cpu->memory.activeRegion = memory->rom;
cpu->memory.activeMask = SIZE_CART0 - 1;
break;
if ((address & (SIZE_CART0 - 1)) < memory->romSize) {
break;
}
// Fall through
default:
memory->activeRegion = 0;
cpu->memory.activeRegion = _deadbeef;
cpu->memory.activeMask = 0;
GBALog(gba, GBA_LOG_FATAL, "Jumped to invalid address");