GBA Serialize: Savestates now store if CPU was halted
Jeffrey Pfau jeffrey@endrift.com
Sun, 28 Aug 2016 20:36:12 -0700
3 files changed,
17 insertions(+),
2 deletions(-)
M
src/gba/serialize.c
→
src/gba/serialize.c
@@ -66,11 +66,16 @@ 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); + GBASerializedMiscFlags miscFlags = 0; + miscFlags = GBASerializedMiscFlagsSetHalted(miscFlags, gba->cpu->halted); + STORE_32(miscFlags, 0, &state->miscFlags); + GBAMemorySerialize(&gba->memory, state); GBAIOSerialize(gba, state); GBAVideoSerialize(&gba->video, state); GBAAudioSerialize(&gba->audio, state); GBASavedataSerialize(&gba->memory.savedata, state); + #ifndef _MSC_VER struct timeval tv;@@ -197,6 +202,9 @@ LOAD_32(gba->cpu->prefetch[0], (gba->cpu->gprs[ARM_PC] - WORD_SIZE_ARM) & gba->cpu->memory.activeMask, gba->cpu->memory.activeRegion);
LOAD_32(gba->cpu->prefetch[1], (gba->cpu->gprs[ARM_PC]) & gba->cpu->memory.activeMask, gba->cpu->memory.activeRegion); } } + GBASerializedMiscFlags miscFlags = 0; + LOAD_32(miscFlags, 0, &state->miscFlags); + gba->cpu->halted = GBASerializedMiscFlagsGetHalted(miscFlags); GBAVideoDeserialize(&gba->video, state); GBAMemoryDeserialize(&gba->memory, state);
M
src/gba/serialize.h
→
src/gba/serialize.h
@@ -196,7 +196,9 @@ * 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 - 0x0031B: Last prefetched program counter - * 0x0031C - 0x003FF: Reserved (leave zero) + * 0x0031C - 0x0031F: Miscellaneous flags + * | bit 0: Is CPU halted? + * 0x00320 - 0x003FF: Reserved (leave zero) * 0x00400 - 0x007FF: I/O memory * 0x00800 - 0x00BFF: Palette * 0x00C00 - 0x00FFF: OAM@@ -222,6 +224,9 @@
DECL_BITFIELD(GBASerializedSavedataFlags, uint8_t); DECL_BITS(GBASerializedSavedataFlags, FlashState, 0, 2); DECL_BIT(GBASerializedSavedataFlags, FlashBank, 4); + +DECL_BITFIELD(GBASerializedMiscFlags, uint32_t); +DECL_BIT(GBASerializedMiscFlags, Halted, 0); struct GBASerializedState { uint32_t versionMagic;@@ -313,8 +318,9 @@
uint64_t creationUsec; uint32_t lastPrefetchedPc; + GBASerializedMiscFlags miscFlags; - uint32_t reserved[57]; + uint32_t reserved[56]; uint16_t io[SIZE_IO >> 1]; uint16_t pram[SIZE_PALETTE_RAM >> 1];