diff options
author | jdgleaver | 2020-10-19 12:28:54 +0100 |
---|---|---|
committer | jdgleaver | 2020-10-19 12:28:54 +0100 |
commit | 799d3e5215425a0b4024e79358b17871f0fd4452 (patch) | |
tree | 6295a93c0b90f3825aecad9c183b9e860ebb63d6 | |
parent | 00d40e98c526234a36973b9814a2420eba5f7cbe (diff) | |
download | snes9x2005-799d3e5215425a0b4024e79358b17871f0fd4452.tar.gz snes9x2005-799d3e5215425a0b4024e79358b17871f0fd4452.tar.bz2 snes9x2005-799d3e5215425a0b4024e79358b17871f0fd4452.zip |
Fix save states for SA1-enhanced games
-rw-r--r-- | libretro.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -762,6 +762,8 @@ bool retro_unserialize(const void* data, size_t size) uint8_t* IAPU_RAM_current = IAPU.RAM; uintptr_t IAPU_RAM_offset; #endif + uint32_t sa1_old_flags = SA1.Flags; + SSA1 sa1_state; if (size != retro_serialize_size()) return false; @@ -803,13 +805,28 @@ bool retro_unserialize(const void* data, size_t size) buffer += SPC_SAVE_STATE_BLOCK_SIZE; #endif - memcpy(&SA1, buffer, sizeof(SA1)); - buffer += sizeof(SA1); + memcpy(&sa1_state, buffer, sizeof(sa1_state)); + buffer += sizeof(sa1_state); + + /* SA1 state must be restored 'by hand' */ + SA1.Flags = sa1_state.Flags; + SA1.NMIActive = sa1_state.NMIActive; + SA1.IRQActive = sa1_state.IRQActive; + SA1.WaitingForInterrupt = sa1_state.WaitingForInterrupt; + SA1.op1 = sa1_state.op1; + SA1.op2 = sa1_state.op2; + SA1.arithmetic_op = sa1_state.arithmetic_op; + SA1.sum = sa1_state.sum; + SA1.overflow = sa1_state.overflow; + memcpy(&SA1.Registers, &sa1_state.Registers, sizeof(SA1.Registers)); + memcpy(&s7r, buffer, sizeof(s7r)); buffer += sizeof(s7r); memcpy(&rtc_f9, buffer, sizeof(rtc_f9)); S9xFixSA1AfterSnapshotLoad(); + SA1.Flags |= sa1_old_flags & (TRACE_FLAG); + FixROMSpeed(); IPPU.ColorsChanged = true; IPPU.OBJChanged = true; |