mirror of https://github.com/mgba-emu/mgba.git
GBA Memory: Fix jumping to invalid memory when switching from Thumb to ARM
This commit is contained in:
parent
cb3f029d9e
commit
37f5058de0
1
CHANGES
1
CHANGES
|
@ -52,6 +52,7 @@ Bugfixes:
|
||||||
- GBA BIOS: Initialize a variable that may be uninitialized in very rare cases
|
- GBA BIOS: Initialize a variable that may be uninitialized in very rare cases
|
||||||
- ARM7: Fix ARM multiply instructions when PC is a destination register
|
- ARM7: Fix ARM multiply instructions when PC is a destination register
|
||||||
- SDL: Fix potential build issues when Qt and SDL2 are in use
|
- 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:
|
Misc:
|
||||||
- Qt: Show multiplayer numbers in window title
|
- Qt: Show multiplayer numbers in window title
|
||||||
- Qt: Handle saving input settings better
|
- Qt: Handle saving input settings better
|
||||||
|
|
|
@ -231,13 +231,7 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gba->lastJump = address;
|
gba->lastJump = address;
|
||||||
if (newRegion >= REGION_CART0 && (address & (SIZE_CART0 - 1)) >= memory->romSize) {
|
if (newRegion == memory->activeRegion && (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) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,8 +264,12 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
|
||||||
case REGION_CART2_EX:
|
case REGION_CART2_EX:
|
||||||
cpu->memory.activeRegion = memory->rom;
|
cpu->memory.activeRegion = memory->rom;
|
||||||
cpu->memory.activeMask = SIZE_CART0 - 1;
|
cpu->memory.activeMask = SIZE_CART0 - 1;
|
||||||
|
if ((address & (SIZE_CART0 - 1)) < memory->romSize) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
// Fall through
|
||||||
default:
|
default:
|
||||||
|
memory->activeRegion = 0;
|
||||||
cpu->memory.activeRegion = _deadbeef;
|
cpu->memory.activeRegion = _deadbeef;
|
||||||
cpu->memory.activeMask = 0;
|
cpu->memory.activeMask = 0;
|
||||||
GBALog(gba, GBA_LOG_FATAL, "Jumped to invalid address");
|
GBALog(gba, GBA_LOG_FATAL, "Jumped to invalid address");
|
||||||
|
|
Loading…
Reference in New Issue