From 08f5601c5f1615ac22c193f487c519978d5179c3 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Thu, 23 Jun 2011 06:14:14 -0500 Subject: [PATCH] Reduce the sync footprint slightly with less indirection. --- apu/bapu/dsp/dsp.cpp | 13 ------------- apu/bapu/dsp/dsp.hpp | 2 -- apu/bapu/smp/core.cpp | 15 +++++++++------ apu/bapu/smp/smp.cpp | 2 ++ 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/apu/bapu/dsp/dsp.cpp b/apu/bapu/dsp/dsp.cpp index c0a2a9c8..0a6137c4 100644 --- a/apu/bapu/dsp/dsp.cpp +++ b/apu/bapu/dsp/dsp.cpp @@ -7,19 +7,6 @@ DSP dsp; #include "SPC_DSP.cpp" -void DSP::step(unsigned clocks) { - clock += clocks; -} - -void DSP::synchronize_smp() { - while(clock >= 0) smp.enter(); -} - -void DSP::enter() { - spc_dsp.run(1); - step(24); -} - uint8 DSP::read(uint8 addr) { return spc_dsp.read(addr); } diff --git a/apu/bapu/dsp/dsp.hpp b/apu/bapu/dsp/dsp.hpp index ef2dc7c7..1109bda8 100644 --- a/apu/bapu/dsp/dsp.hpp +++ b/apu/bapu/dsp/dsp.hpp @@ -3,13 +3,11 @@ class DSP : public Processor { public: enum { Threaded = false }; - alwaysinline void step(unsigned clocks); alwaysinline void synchronize_smp(); uint8 read(uint8 addr); void write(uint8 addr, uint8 data); - void enter(); void power(); void reset(); diff --git a/apu/bapu/smp/core.cpp b/apu/bapu/smp/core.cpp index 01f265a5..df4076c1 100644 --- a/apu/bapu/smp/core.cpp +++ b/apu/bapu/smp/core.cpp @@ -5,11 +5,12 @@ void SMP::tick() { #ifndef SNES9X clock += cycle_step_cpu; -#else - clock++; -#endif dsp.clock -= 24; synchronize_dsp(); +#else + clock++; + dsp.spc_dsp.run(1); +#endif } void SMP::op_io() { @@ -77,11 +78,13 @@ void SMP::op_step() { #ifndef SNES9X clock += cycle_table_cpu[opcode]; -#else - clock += cycle_count_table[opcode]; -#endif dsp.clock -= cycle_table_dsp[opcode]; synchronize_dsp(); +#else + clock += cycle_count_table[opcode]; + dsp.spc_dsp.run(cycle_count_table[opcode]); +#endif + #endif } diff --git a/apu/bapu/smp/smp.cpp b/apu/bapu/smp/smp.cpp index 49556f3f..e0bb9019 100644 --- a/apu/bapu/smp/smp.cpp +++ b/apu/bapu/smp/smp.cpp @@ -34,11 +34,13 @@ void SMP::synchronize_cpu() { } void SMP::synchronize_dsp() { +#ifndef SNES9X if(DSP::Threaded == true) { //if(dsp.clock < 0 && scheduler.sync != Scheduler::SynchronizeMode::All) co_switch(dsp.thread); } else { while(dsp.clock < 0) dsp.enter(); } +#endif } void SMP::enter() {