GBA Memory: Fix prefetch mask when swapping modes within a region

This commit is contained in:
Vicki Pfau 2021-06-18 01:00:18 -07:00
parent 3f4d2f6086
commit 34fed8086c
3 changed files with 8 additions and 0 deletions

View File

@ -11,6 +11,7 @@ Emulation fixes:
- GBA SIO: Add missing NORMAL8 implementation bits (fixes mgba.io/i/2172)
- GBA SIO: Fix missing interrupt on an unattached NORMAL transfer
- GBA SIO: Fix SI value for unattached MULTI mode
- GBA Memory: Fix prefetch mask when swapping modes within a region
- GBA Video: Revert scanline latching changes (fixes mgba.io/i/2153, mgba.io/i/2149)
Other fixes:
- 3DS: Fix disabling "wide" mode on 2DS (fixes mgba.io/i/2167)

View File

@ -127,6 +127,7 @@ void GBAMemoryReset(struct GBA* gba) {
memset(gba->memory.io, 0, sizeof(gba->memory.io));
GBAAdjustWaitstates(gba, 0);
gba->memory.activeRegion = -1;
gba->memory.agbPrintProtect = 0;
gba->memory.agbPrintBase = 0;
memset(&gba->memory.agbPrintCtx, 0, sizeof(gba->memory.agbPrintCtx));
@ -266,6 +267,11 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
gba->lastJump = address;
memory->lastPrefetchedPc = 0;
if (newRegion == memory->activeRegion) {
if (cpu->cpsr.t) {
cpu->memory.activeMask |= WORD_SIZE_THUMB;
} else {
cpu->memory.activeMask &= -WORD_SIZE_ARM;
}
if (newRegion < REGION_CART0 || (address & (SIZE_CART0 - 1)) < memory->romSize) {
return;
}

View File

@ -158,6 +158,7 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) {
mLOG(GBA_STATE, WARN, "Savestate has unaligned PC and is probably corrupted");
gba->cpu->gprs[ARM_PC] &= ~1;
}
gba->memory.activeRegion = -1;
gba->cpu->memory.setActiveRegion(gba->cpu, gba->cpu->gprs[ARM_PC]);
if (state->biosPrefetch) {
LOAD_32(gba->memory.biosPrefetch, 0, &state->biosPrefetch);