From 6ec9cceb091dbd70966f099510f72d4be0db662e Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 6 Aug 2022 00:34:28 -0500 Subject: [PATCH] PCE: remove some sample playback clicking --- src/engine/platform/pce.cpp | 9 ++++++++- src/engine/platform/pce.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/engine/platform/pce.cpp b/src/engine/platform/pce.cpp index d46e012c..757cff15 100644 --- a/src/engine/platform/pce.cpp +++ b/src/engine/platform/pce.cpp @@ -133,6 +133,10 @@ void DivPlatformPCE::acquire(short* bufL, short* bufR, size_t start, size_t len) } void DivPlatformPCE::updateWave(int ch) { + if (chan[ch].pcm) { + chan[ch].deferredWaveUpdate=true; + return; + } chWrite(ch,0x04,0x5f); chWrite(ch,0x04,0x1f); for (int i=0; i<32; i++) { @@ -142,6 +146,9 @@ void DivPlatformPCE::updateWave(int ch) { if (chan[ch].active) { chWrite(ch,0x04,0x80|chan[ch].outVol); } + if (chan[ch].deferredWaveUpdate) { + chan[ch].deferredWaveUpdate=false; + } } // TODO: in octave 6 the noise table changes to a tonal one @@ -227,7 +234,7 @@ void DivPlatformPCE::tick(bool sysTick) { chan[i].freqChanged=true; } if (chan[i].active) { - if (chan[i].ws.tick() || (chan[i].std.phaseReset.had && chan[i].std.phaseReset.val==1)) { + if (chan[i].ws.tick() || (chan[i].std.phaseReset.had && chan[i].std.phaseReset.val==1) || chan[i].deferredWaveUpdate) { updateWave(i); } } diff --git a/src/engine/platform/pce.h b/src/engine/platform/pce.h index 22a24ddf..17e191d4 100644 --- a/src/engine/platform/pce.h +++ b/src/engine/platform/pce.h @@ -33,7 +33,7 @@ class DivPlatformPCE: public DivDispatch { unsigned int dacPos; int dacSample, ins; unsigned char pan; - bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise, pcm, furnaceDac; + bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise, pcm, furnaceDac, deferredWaveUpdate; signed char vol, outVol, wave; DivMacroInt std; DivWaveSynth ws; @@ -64,6 +64,7 @@ class DivPlatformPCE: public DivDispatch { noise(false), pcm(false), furnaceDac(false), + deferredWaveUpdate(false), vol(31), outVol(31), wave(-1) {}