From 77922aea5d34574ab7ea09ecb827917bcdb4be1d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 1 Aug 2016 02:32:02 -0700 Subject: [PATCH] GBA Serialize: Savestates now properly store prefetch --- CHANGES | 1 + src/gba/serialize.c | 4 +++- src/gba/serialize.h | 7 +++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 760234219..86fc08cbc 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,7 @@ Bugfixes: - PSP2: Fix GPU crash while exiting - PSP2: Fix VSync - ARM7: Fix decoding of Thumb ADD (variants 5 and 6) + - GBA Serialize: Savestates now properly store prefetch Misc: - 3DS: Use blip_add_delta_fast for a small speed improvement - OpenGL: Log shader compilation failure diff --git a/src/gba/serialize.c b/src/gba/serialize.c index 469b616a7..53ebf83ba 100644 --- a/src/gba/serialize.c +++ b/src/gba/serialize.c @@ -61,9 +61,10 @@ void GBASerialize(struct GBA* gba, struct GBASerializedState* state) { STORE_32(gba->cpu->bankedSPSRs[i], i * sizeof(gba->cpu->bankedSPSRs[0]), state->cpu.bankedSPSRs); } - state->biosPrefetch = gba->memory.biosPrefetch; + STORE_32(gba->memory.biosPrefetch, 0, &state->biosPrefetch); STORE_32(gba->cpu->prefetch[0], 0, state->cpuPrefetch); STORE_32(gba->cpu->prefetch[1], 4, state->cpuPrefetch); + STORE_32(gba->memory.lastPrefetchedPc, 0, &state->lastPrefetchedPc); GBAMemorySerialize(&gba->memory, state); GBAIOSerialize(gba, state); @@ -172,6 +173,7 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) { if (state->biosPrefetch) { LOAD_32(gba->memory.biosPrefetch, 0, &state->biosPrefetch); } + LOAD_32(gba->memory.lastPrefetchedPc, 0, &state->lastPrefetchedPc); if (gba->cpu->cpsr.t) { gba->cpu->executionMode = MODE_THUMB; if (state->cpuPrefetch[0] && state->cpuPrefetch[1]) { diff --git a/src/gba/serialize.h b/src/gba/serialize.h index 05a1053e1..2e324744b 100644 --- a/src/gba/serialize.h +++ b/src/gba/serialize.h @@ -195,7 +195,8 @@ mLOG_DECLARE_CATEGORY(GBA_STATE); * 0x00300 - 0x00303: Associated movie stream ID for record/replay (or 0 if no stream) * 0x00304 - 0x0030F: Reserved (leave zero) * 0x00310 - 0x00317: Savestate creation time (usec since 1970) - * 0x00318 - 0x003FF: Reserved (leave zero) + * 0x00318 - 0x0031B: Last prefetched program counter + * 0x0031C - 0x003FF: Reserved (leave zero) * 0x00400 - 0x007FF: I/O memory * 0x00800 - 0x00BFF: Palette * 0x00C00 - 0x00FFF: OAM @@ -311,7 +312,9 @@ struct GBASerializedState { uint64_t creationUsec; - uint32_t reserved[58]; + uint32_t lastPrefetchedPc; + + uint32_t reserved[57]; uint16_t io[SIZE_IO >> 1]; uint16_t pram[SIZE_PALETTE_RAM >> 1];