diff options
author | aliaspider | 2015-11-02 11:25:46 +0100 |
---|---|---|
committer | aliaspider | 2015-11-02 11:25:46 +0100 |
commit | 142828109928254b7945820449b4272dc35f9225 (patch) | |
tree | b3c3cbf0b176383a8db06c9e4cfdf9cd01cb1bf0 | |
parent | ab91b8e2097e84dc215c192584eddbfecac1a1f8 (diff) | |
download | snesemu-142828109928254b7945820449b4272dc35f9225.tar.gz snesemu-142828109928254b7945820449b4272dc35f9225.tar.bz2 snesemu-142828109928254b7945820449b4272dc35f9225.zip |
fix savestates when using blargg's apu.
-rw-r--r-- | libretro.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -664,9 +664,11 @@ size_t retro_serialize_size(void) return sizeof(CPU) + sizeof(ICPU) + sizeof(PPU) + sizeof(DMA) + 0x10000 + 0x20000 + 0x20000 + 0x8000 + #ifndef USE_BLARGG_APU - sizeof(APU) + sizeof(IAPU) + sizeof(APU) + sizeof(IAPU) + 0x10000 +#else + SPC_SAVE_STATE_BLOCK_SIZE #endif - + 0x10000 + sizeof(SA1) + + + sizeof(SA1) + sizeof(s7r) + sizeof(rtc_f9); } @@ -709,6 +711,9 @@ bool retro_serialize(void* data, size_t size) buffer += sizeof(IAPU); memcpy(buffer, IAPU.RAM, 0x10000); buffer += 0x10000; +#else + S9xAPUSaveState(buffer); + buffer += SPC_SAVE_STATE_BLOCK_SIZE; #endif SA1.Registers.PC = SA1.PC - SA1.PCBase; @@ -733,6 +738,7 @@ bool retro_unserialize(const void* data, size_t size) S9xReset(); #ifndef USE_BLARGG_APU uint8_t* IAPU_RAM_current = IAPU.RAM; + uintptr_t IAPU_RAM_offset; #endif memcpy(&CPU, buffer, sizeof(CPU)); buffer += sizeof(CPU); @@ -755,11 +761,17 @@ bool retro_unserialize(const void* data, size_t size) buffer += sizeof(APU); memcpy(&IAPU, buffer, sizeof(IAPU)); buffer += sizeof(IAPU); - IAPU.PC = IAPU_RAM_current + (IAPU.PC - IAPU.RAM); - IAPU.DirectPage = IAPU_RAM_current + (IAPU.DirectPage - IAPU.RAM); + IAPU_RAM_offset = IAPU_RAM_current - IAPU.RAM; + IAPU.PC += IAPU_RAM_offset; + IAPU.DirectPage += IAPU_RAM_offset; + IAPU.WaitAddress1 += IAPU_RAM_offset; + IAPU.WaitAddress2 += IAPU_RAM_offset; IAPU.RAM = IAPU_RAM_current; memcpy(IAPU.RAM, buffer, 0x10000); buffer += 0x10000; +#else + S9xAPULoadState(buffer); + buffer += SPC_SAVE_STATE_BLOCK_SIZE; #endif memcpy(&SA1, buffer, sizeof(SA1)); @@ -775,7 +787,6 @@ bool retro_unserialize(const void* data, size_t size) IPPU.OBJChanged = true; CPU.InDMA = false; S9xFixColourBrightness(); - S9xSA1UnpackStatus(); #ifndef USE_BLARGG_APU S9xAPUUnpackStatus(); |