From 4668ae585004a312aeb3a4e0ad953d4c5f9058ee Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Wed, 7 Sep 2011 11:46:52 -0500 Subject: [PATCH] Fix save state error. --- apu/apu.cpp | 7 ++----- apu/bapu/smp/core.cpp | 1 - apu/bapu/smp/smp.hpp | 2 ++ apu/bapu/smp/smp_state.cpp | 16 ++++++++++++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/apu/apu.cpp b/apu/apu.cpp index 795dd2f7..237f3939 100644 --- a/apu/apu.cpp +++ b/apu/apu.cpp @@ -625,13 +625,9 @@ void S9xAPULoadState (uint8 *block) { uint8 *ptr = block; - S9xResetAPU(); - SNES::smp.load_state (&ptr); SNES::dsp.load_state (&ptr); - SNES::dsp.spc_dsp.set_output ((SNES::SPC_DSP::sample_t *) spc::landing_buffer, spc::buffer_size >> 1); - spc::reference_time = SNES::get_le32(ptr); ptr += sizeof(int32); spc::remainder = SNES::get_le32(ptr); @@ -655,7 +651,8 @@ bool8 S9xSPCDump (const char *filename) SNES::smp.save_spc (buf); - ignore = fwrite(buf, SPC_FILE_SIZE, 1, fs); + if ((ignore = fwrite(buf, SPC_FILE_SIZE, 1, fs)) <= 0) + fprintf (stderr, "Couldn't write file %s.\n", filename); fclose(fs); diff --git a/apu/bapu/smp/core.cpp b/apu/bapu/smp/core.cpp index b5266cec..5664da36 100644 --- a/apu/bapu/smp/core.cpp +++ b/apu/bapu/smp/core.cpp @@ -44,7 +44,6 @@ void SMP::op_step() { #define op_writeaddr(addr, data) op_write(addr, data) #define op_readstack() op_read(0x0100 | ++regs.sp) #define op_writestack(data) op_write(0x0100 | regs.sp--, data) - static unsigned rd, wr, dp, sp, ya, bit; #if defined(CYCLE_ACCURATE) diff --git a/apu/bapu/smp/smp.hpp b/apu/bapu/smp/smp.hpp index cb57f334..9d7a9ea7 100644 --- a/apu/bapu/smp/smp.hpp +++ b/apu/bapu/smp/smp.hpp @@ -50,6 +50,8 @@ public: unsigned opcode_number; unsigned opcode_cycle; + unsigned rd, wr, dp, sp, ya, bit; + struct Regs { uint16 pc; uint8 sp; diff --git a/apu/bapu/smp/smp_state.cpp b/apu/bapu/smp/smp_state.cpp index e3b9d446..adefdacb 100644 --- a/apu/bapu/smp/smp_state.cpp +++ b/apu/bapu/smp/smp_state.cpp @@ -118,11 +118,17 @@ void SMP::save_state(uint8 **block) { INT32(timer2.enable); INT32(timer2.target); - INT32(timer2.stage1_ticks); INT32(timer2.stage2_ticks); INT32(timer2.stage3_ticks); + INT32(rd); + INT32(wr); + INT32(dp); + INT32(sp); + INT32(ya); + INT32(bit); + *block = ptr; } @@ -174,11 +180,17 @@ void SMP::load_state(uint8 **block) { INT32(timer2.enable); INT32(timer2.target); - INT32(timer2.stage1_ticks); INT32(timer2.stage2_ticks); INT32(timer2.stage3_ticks); + INT32(rd); + INT32(wr); + INT32(dp); + INT32(sp); + INT32(ya); + INT32(bit); + *block = ptr; }