diff --git a/CHANGES b/CHANGES index 3601b0fd9..923643ce4 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,7 @@ Features: - New unlicensed GB mappers: NT (older types 1 and 2), Li Cheng, GGB-81 - Debugger: Add range watchpoints Emulation fixes: + - GB Serialize: Add missing Pocket Cam state to savestates - GB Video: Implement DMG-style sprite ordering - GBA Audio: Fix improperly deserializing GB audio registers (fixes mgba.io/i/2793) - GBA Audio: Clear GB audio state when disabled diff --git a/include/mgba/internal/gb/serialize.h b/include/mgba/internal/gb/serialize.h index f4433c495..e76d0accb 100644 --- a/include/mgba/internal/gb/serialize.h +++ b/include/mgba/internal/gb/serialize.h @@ -419,6 +419,9 @@ struct GBSerializedState { uint8_t locked; uint8_t bank0; } mmm01; + struct { + uint8_t registersActive; + } pocketCam; struct { uint64_t lastLatch; uint8_t reg; @@ -484,6 +487,7 @@ struct GBSerializedState { union { uint8_t huc3Registers[0x80]; + uint8_t pocketCamRegisters[0x36]; struct { uint8_t registers[4]; uint8_t reserved[4]; diff --git a/src/gb/memory.c b/src/gb/memory.c index 325761c1c..e41050784 100644 --- a/src/gb/memory.c +++ b/src/gb/memory.c @@ -799,6 +799,10 @@ void GBMemorySerialize(const struct GB* gb, struct GBSerializedState* state) { state->huc3Registers[i] |= memory->mbcState.huc3.registers[i * 2 + 1] << 4; } break; + case GB_POCKETCAM: + state->memory.pocketCam.registersActive = memory->mbcState.pocketCam.registersActive; + memcpy(state->pocketCamRegisters, memory->mbcState.pocketCam.registers, sizeof(memory->mbcState.pocketCam.registers)); + break; case GB_MMM01: state->memory.mmm01.locked = memory->mbcState.mmm01.locked; state->memory.mmm01.bank0 = memory->mbcState.mmm01.currentBank0; @@ -950,6 +954,10 @@ void GBMemoryDeserialize(struct GB* gb, const struct GBSerializedState* state) { memory->mbcState.huc3.registers[i * 2 + 1] = state->huc3Registers[i] >> 4; } break; + case GB_POCKETCAM: + memory->mbcState.pocketCam.registersActive = state->memory.pocketCam.registersActive; + memcpy(memory->mbcState.pocketCam.registers, state->pocketCamRegisters, sizeof(memory->mbcState.pocketCam.registers)); + break; case GB_MMM01: memory->mbcState.mmm01.locked = state->memory.mmm01.locked; memory->mbcState.mmm01.currentBank0 = state->memory.mmm01.bank0;