From 4e057ed7b4f244ef14392b2765bd02f0060daa3a Mon Sep 17 00:00:00 2001 From: bladeoner Date: Wed, 10 Apr 2019 20:21:57 +0200 Subject: [PATCH] Snes9x - Add the separate echo buffer option. (#836) Snes9x - Add the separate echo buffer option. --- source/preferences.cpp | 3 ++- source/snes9x/apu/SPC_DSP.cpp | 4 +++- source/snes9x/apu/SPC_DSP.h | 2 ++ source/snes9x/snes9x.h | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/preferences.cpp b/source/preferences.cpp index 168fe4c..ed58413 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -500,6 +500,7 @@ DefaultSettings () Settings.SoundPlaybackRate = 48000; Settings.SoundInputRate = 31920; Settings.DynamicRateControl = true; + Settings.SeparateEchoBuffer = false; // Interpolation Method GCSettings.Interpolation = 0; @@ -524,7 +525,7 @@ DefaultSettings () Settings.SuperFXSpeedPerLine = 5823405; Settings.SuperFXClockMultiplier = 100; - + Settings.OverclockMode = 0; Settings.OneClockCycle = 6; Settings.OneSlowClockCycle = 8; Settings.TwoClockCycles = 12; diff --git a/source/snes9x/apu/SPC_DSP.cpp b/source/snes9x/apu/SPC_DSP.cpp index 91599c8..0cd3c5f 100644 --- a/source/snes9x/apu/SPC_DSP.cpp +++ b/source/snes9x/apu/SPC_DSP.cpp @@ -612,7 +612,7 @@ VOICE_CLOCK(V9_V6_V3) { voice_V9(v); voice_V6(v+1); voice_V3(v+2); } //// Echo // Current echo buffer pointer for left/right channel -#define ECHO_PTR( ch ) (&m.ram [m.t_echo_ptr + ch * 2]) +#define ECHO_PTR( ch ) ((Settings.SeparateEchoBuffer) ? (&m.separate_echo_buffer [m.t_echo_ptr + ch * 2]) : (&m.ram [m.t_echo_ptr + ch * 2])) // Sample in echo history buffer, where 0 is the oldest #define ECHO_FIR( i ) (m.echo_hist_pos [i]) @@ -881,6 +881,8 @@ void SPC_DSP::soft_reset_common() m.echo_offset = 0; m.phase = 0; + memset(m.separate_echo_buffer, 0, 0x10000); + init_counter(); for (int i = 0; i < voice_count; i++) diff --git a/source/snes9x/apu/SPC_DSP.h b/source/snes9x/apu/SPC_DSP.h index 61d05ab..1cdba6b 100644 --- a/source/snes9x/apu/SPC_DSP.h +++ b/source/snes9x/apu/SPC_DSP.h @@ -199,6 +199,8 @@ private: sample_t* out_end; sample_t* out_begin; sample_t extra [extra_size]; + + uint8_t separate_echo_buffer [0x10000]; }; state_t m; diff --git a/source/snes9x/snes9x.h b/source/snes9x/snes9x.h index 3558d21..d8f683d 100644 --- a/source/snes9x/snes9x.h +++ b/source/snes9x/snes9x.h @@ -300,7 +300,9 @@ struct SSettings bool8 OpenGLEnable; float SuperFXSpeedPerLine; + bool8 SeparateEchoBuffer; uint32 SuperFXClockMultiplier; + int OverclockMode; int OneClockCycle; int OneSlowClockCycle; int TwoClockCycles;