diff --git a/include/mgba/internal/gba/serialize.h b/include/mgba/internal/gba/serialize.h index 4f24198dd..691a6a711 100644 --- a/include/mgba/internal/gba/serialize.h +++ b/include/mgba/internal/gba/serialize.h @@ -194,6 +194,7 @@ mLOG_DECLARE_CATEGORY(GBA_STATE); * 0x00318 - 0x0031B: Last prefetched program counter * 0x0031C - 0x0031F: Miscellaneous flags * | bit 0: Is CPU halted? + * | bit 1: POSTFLG * 0x00320 - 0x003FF: Reserved (leave zero) * 0x00400 - 0x007FF: I/O memory * 0x00800 - 0x00BFF: Palette @@ -224,6 +225,7 @@ DECL_BIT(GBASerializedSavedataFlags, DustSettling, 5); DECL_BITFIELD(GBASerializedMiscFlags, uint32_t); DECL_BIT(GBASerializedMiscFlags, Halted, 0); +DECL_BIT(GBASerializedMiscFlags, POSTFLG, 1); struct GBASerializedState { uint32_t versionMagic; diff --git a/src/gba/serialize.c b/src/gba/serialize.c index 5917fa5f1..9360fcf8e 100644 --- a/src/gba/serialize.c +++ b/src/gba/serialize.c @@ -61,6 +61,7 @@ void GBASerialize(struct GBA* gba, struct GBASerializedState* state) { GBASerializedMiscFlags miscFlags = 0; miscFlags = GBASerializedMiscFlagsSetHalted(miscFlags, gba->cpu->halted); + miscFlags = GBASerializedMiscFlagsSetPOSTFLG(miscFlags, gba->memory.io[REG_POSTFLG >> 1] & 1); STORE_32(miscFlags, 0, &state->miscFlags); GBAMemorySerialize(&gba->memory, state); @@ -175,6 +176,7 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) { GBASerializedMiscFlags miscFlags = 0; LOAD_32(miscFlags, 0, &state->miscFlags); gba->cpu->halted = GBASerializedMiscFlagsGetHalted(miscFlags); + gba->memory.io[REG_POSTFLG >> 1] = GBASerializedMiscFlagsGetPOSTFLG(miscFlags); GBAVideoDeserialize(&gba->video, state); GBAMemoryDeserialize(&gba->memory, state);