GBA Serialize: Savestates now store if CPU was halted

This commit is contained in:
Jeffrey Pfau 2016-08-28 20:36:12 -07:00
parent c9b69bba44
commit 90edf4d1a0
3 changed files with 17 additions and 2 deletions

View File

@ -80,6 +80,7 @@ Misc:
- VFS: Improve zip file detection
- Util: Add endswith
- GUI: Only reload config if manually saved
- GBA Serialize: Savestates now store if CPU was halted
0.4.1: (2016-07-11)
Bugfixes:

View File

@ -66,12 +66,17 @@ void GBASerialize(struct GBA* gba, struct GBASerializedState* state) {
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;
if (!gettimeofday(&tv, 0)) {
@ -197,6 +202,9 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) {
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);

View File

@ -196,7 +196,9 @@ mLOG_DECLARE_CATEGORY(GBA_STATE);
* 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
@ -223,6 +225,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;
uint32_t biosChecksum;
@ -313,8 +318,9 @@ struct GBASerializedState {
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];