GB Serialize: Add missing Pocket Cam state to savestates

This commit is contained in:
Vicki Pfau 2023-04-13 02:56:12 -07:00
parent b876f13cb2
commit 5bf048e380
3 changed files with 13 additions and 0 deletions

View File

@ -5,6 +5,7 @@ Features:
- New unlicensed GB mappers: NT (older types 1 and 2), Li Cheng, GGB-81 - New unlicensed GB mappers: NT (older types 1 and 2), Li Cheng, GGB-81
- Debugger: Add range watchpoints - Debugger: Add range watchpoints
Emulation fixes: Emulation fixes:
- GB Serialize: Add missing Pocket Cam state to savestates
- GB Video: Implement DMG-style sprite ordering - GB Video: Implement DMG-style sprite ordering
- GBA Audio: Fix improperly deserializing GB audio registers (fixes mgba.io/i/2793) - GBA Audio: Fix improperly deserializing GB audio registers (fixes mgba.io/i/2793)
- GBA Audio: Clear GB audio state when disabled - GBA Audio: Clear GB audio state when disabled

View File

@ -419,6 +419,9 @@ struct GBSerializedState {
uint8_t locked; uint8_t locked;
uint8_t bank0; uint8_t bank0;
} mmm01; } mmm01;
struct {
uint8_t registersActive;
} pocketCam;
struct { struct {
uint64_t lastLatch; uint64_t lastLatch;
uint8_t reg; uint8_t reg;
@ -484,6 +487,7 @@ struct GBSerializedState {
union { union {
uint8_t huc3Registers[0x80]; uint8_t huc3Registers[0x80];
uint8_t pocketCamRegisters[0x36];
struct { struct {
uint8_t registers[4]; uint8_t registers[4];
uint8_t reserved[4]; uint8_t reserved[4];

View File

@ -799,6 +799,10 @@ void GBMemorySerialize(const struct GB* gb, struct GBSerializedState* state) {
state->huc3Registers[i] |= memory->mbcState.huc3.registers[i * 2 + 1] << 4; state->huc3Registers[i] |= memory->mbcState.huc3.registers[i * 2 + 1] << 4;
} }
break; 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: case GB_MMM01:
state->memory.mmm01.locked = memory->mbcState.mmm01.locked; state->memory.mmm01.locked = memory->mbcState.mmm01.locked;
state->memory.mmm01.bank0 = memory->mbcState.mmm01.currentBank0; 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; memory->mbcState.huc3.registers[i * 2 + 1] = state->huc3Registers[i] >> 4;
} }
break; 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: case GB_MMM01:
memory->mbcState.mmm01.locked = state->memory.mmm01.locked; memory->mbcState.mmm01.locked = state->memory.mmm01.locked;
memory->mbcState.mmm01.currentBank0 = state->memory.mmm01.bank0; memory->mbcState.mmm01.currentBank0 = state->memory.mmm01.bank0;