all repos — mgba @ 5002cf44f4b7ecea134cf96d70bd7f5e02c10526

mGBA Game Boy Advance Emulator

Fix savestate loading after prefetch changes
Jeffrey Pfau jeffrey@endrift.com
Fri, 29 Aug 2014 00:34:12 -0700
commit

5002cf44f4b7ecea134cf96d70bd7f5e02c10526

parent

baa71027e38ff1b91546c65b7b799883b98d3c3e

1 files changed, 7 insertions(+), 1 deletions(-)

jump to
M src/gba/gba-serialize.csrc/gba/gba-serialize.c

@@ -70,9 +70,15 @@ gba->cpu->cycles = state->cpu.cycles;

gba->cpu->nextEvent = state->cpu.nextEvent; memcpy(gba->cpu->bankedRegisters, state->cpu.bankedRegisters, 6 * 7 * sizeof(int32_t)); memcpy(gba->cpu->bankedSPSRs, state->cpu.bankedSPSRs, 6 * sizeof(int32_t)); - gba->cpu->executionMode = gba->cpu->cpsr.t ? MODE_THUMB : MODE_ARM; gba->cpu->privilegeMode = gba->cpu->cpsr.priv; gba->cpu->memory.setActiveRegion(gba->cpu, gba->cpu->gprs[ARM_PC]); + if (gba->cpu->cpsr.t) { + gba->cpu->executionMode = MODE_THUMB; + LOAD_16(gba->cpu->prefetch, (gba->cpu->gprs[ARM_PC] - WORD_SIZE_THUMB) & gba->cpu->memory.activeMask, gba->cpu->memory.activeRegion); + } else { + gba->cpu->executionMode = MODE_ARM; + LOAD_32(gba->cpu->prefetch, (gba->cpu->gprs[ARM_PC] - WORD_SIZE_ARM) & gba->cpu->memory.activeMask, gba->cpu->memory.activeRegion); + } GBAMemoryDeserialize(&gba->memory, state); GBAIODeserialize(gba, state);