From 91e69af029d2e8d213f92119ec986bb70d18468a Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Mon, 27 Jun 2011 15:41:17 -0500 Subject: [PATCH] Loosen SMP<->DSP synchronization. --- apu/apu.cpp | 1 + apu/bapu/dsp/sdsp.hpp | 10 ++++++++++ apu/bapu/smp/core.cpp | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apu/apu.cpp b/apu/apu.cpp index 8072c19e..d9c214b9 100644 --- a/apu/apu.cpp +++ b/apu/apu.cpp @@ -560,6 +560,7 @@ void S9xAPUExecute (void) void S9xAPUEndScanline (void) { S9xAPUExecute(); + SNES::dsp.synchronize(); if (SNES::dsp.spc_dsp.sample_count() >= APU_MINIMUM_SAMPLE_BLOCK || !spc::sound_in_sync) S9xLandSamples(); diff --git a/apu/bapu/dsp/sdsp.hpp b/apu/bapu/dsp/sdsp.hpp index 83d51eb5..baf1e88b 100644 --- a/apu/bapu/dsp/sdsp.hpp +++ b/apu/bapu/dsp/sdsp.hpp @@ -1,12 +1,22 @@ #include "SPC_DSP.h" +#include class DSP : public Processor { public: inline uint8 read(uint8 addr) { + synchronize (); return spc_dsp.read(addr); } + inline void synchronize (void) { + if (clock) { + spc_dsp.run (clock); + clock = 0; + } + } + inline void write(uint8 addr, uint8 data) { + synchronize (); spc_dsp.write(addr, data); } diff --git a/apu/bapu/smp/core.cpp b/apu/bapu/smp/core.cpp index df4076c1..b5266cec 100644 --- a/apu/bapu/smp/core.cpp +++ b/apu/bapu/smp/core.cpp @@ -9,7 +9,7 @@ void SMP::tick() { synchronize_dsp(); #else clock++; - dsp.spc_dsp.run(1); + dsp.clock++; #endif } @@ -82,7 +82,7 @@ void SMP::op_step() { synchronize_dsp(); #else clock += cycle_count_table[opcode]; - dsp.spc_dsp.run(cycle_count_table[opcode]); + dsp.clock += cycle_count_table[opcode]; #endif