mirror of https://github.com/mgba-emu/mgba.git
GBA Memory: Soft-crash if jumping past the end of a ROM
This commit is contained in:
parent
c01dfa3f83
commit
244f0e362a
1
CHANGES
1
CHANGES
|
@ -29,6 +29,7 @@ Bugfixes:
|
|||
Misc:
|
||||
- Qt: Show multiplayer numbers in window title
|
||||
- Qt: Solar sensor can have shortcuts set
|
||||
- GBA Memory: Soft-crash if jumping past the end of a ROM
|
||||
|
||||
0.2.0: (2015-04-03)
|
||||
Features:
|
||||
|
|
|
@ -225,6 +225,12 @@ 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) {
|
||||
return;
|
||||
}
|
||||
|
@ -233,29 +239,29 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
|
|||
memory->biosPrefetch = cpu->prefetch[1];
|
||||
}
|
||||
memory->activeRegion = newRegion;
|
||||
switch (address & ~OFFSET_MASK) {
|
||||
case BASE_BIOS:
|
||||
switch (newRegion) {
|
||||
case REGION_BIOS:
|
||||
cpu->memory.activeRegion = memory->bios;
|
||||
cpu->memory.activeMask = SIZE_BIOS - 1;
|
||||
break;
|
||||
case BASE_WORKING_RAM:
|
||||
case REGION_WORKING_RAM:
|
||||
cpu->memory.activeRegion = memory->wram;
|
||||
cpu->memory.activeMask = SIZE_WORKING_RAM - 1;
|
||||
break;
|
||||
case BASE_WORKING_IRAM:
|
||||
case REGION_WORKING_IRAM:
|
||||
cpu->memory.activeRegion = memory->iwram;
|
||||
cpu->memory.activeMask = SIZE_WORKING_IRAM - 1;
|
||||
break;
|
||||
case BASE_VRAM:
|
||||
case REGION_VRAM:
|
||||
cpu->memory.activeRegion = (uint32_t*) gba->video.renderer->vram;
|
||||
cpu->memory.activeMask = 0x0000FFFF;
|
||||
break;
|
||||
case BASE_CART0:
|
||||
case BASE_CART0_EX:
|
||||
case BASE_CART1:
|
||||
case BASE_CART1_EX:
|
||||
case BASE_CART2:
|
||||
case BASE_CART2_EX:
|
||||
case REGION_CART0:
|
||||
case REGION_CART0_EX:
|
||||
case REGION_CART1:
|
||||
case REGION_CART1_EX:
|
||||
case REGION_CART2:
|
||||
case REGION_CART2_EX:
|
||||
cpu->memory.activeRegion = memory->rom;
|
||||
cpu->memory.activeMask = SIZE_CART0 - 1;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue