diff --git a/src/engine/platform/sound/su.cpp b/src/engine/platform/sound/su.cpp index 6637bfa7d..a87205457 100644 --- a/src/engine/platform/sound/su.cpp +++ b/src/engine/platform/sound/su.cpp @@ -300,12 +300,46 @@ void SoundUnit::NextSample(short* l, short* r) { } } - *l=minval(32767,maxval(-32767,tnsL)); - *r=minval(32767,maxval(-32767,tnsR)); + if (dsOut) { + tnsL=minval(32767,maxval(-32767,tnsL<<1)); + tnsR=minval(32767,maxval(-32767,tnsR<<1)); + + short accumL=0; + short accumR=0; + + for (int i=0; i<4; i++) { + if ((tnsL>>8)==0 && dsCounterL>0) dsCounterL=0; + dsCounterL+=tnsL>>8; + if (dsCounterL>=0) { + accumL+=4095; + dsCounterL-=127; + } else { + accumL+=-4095; + dsCounterL+=127; + } + + if ((tnsR>>8)==0 && dsCounterR>0) dsCounterR=0; + dsCounterR+=tnsR>>8; + if (dsCounterR>=0) { + accumR+=4095; + dsCounterR-=127; + } else { + accumR+=-4095; + dsCounterR+=127; + } + } + + *l=accumL; + *r=accumR; + } else { + *l=minval(32767,maxval(-32767,tnsL)); + *r=minval(32767,maxval(-32767,tnsR)); + } } -void SoundUnit::Init(int sampleMemSize) { +void SoundUnit::Init(int sampleMemSize, bool dsOutMode) { pcmSize=sampleMemSize; + dsOut=dsOutMode; Reset(); memset(pcm,0,pcmSize); for (int i=0; i<256; i++) { @@ -346,6 +380,8 @@ void SoundUnit::Reset() { oldflags[i]=0; pcmdec[i]=0; } + dsCounterL=0; + dsCounterR=0; tnsL=0; tnsR=0; ilBufPos=0; diff --git a/src/engine/platform/sound/su.h b/src/engine/platform/sound/su.h index 0ee843481..546acfc9c 100644 --- a/src/engine/platform/sound/su.h +++ b/src/engine/platform/sound/su.h @@ -27,6 +27,8 @@ class SoundUnit { unsigned short oldfreq[8]; unsigned short oldflags[8]; unsigned int pcmSize; + bool dsOut; + short dsCounterL, dsCounterR; public: unsigned short resetfreq[8]; unsigned short voldcycles[8]; @@ -99,7 +101,7 @@ class SoundUnit { if (ret>32767) ret=32767; return ret; } - void Init(int sampleMemSize=8192); + void Init(int sampleMemSize=8192, bool dsOutMode=false); void Reset(); SoundUnit(); }; diff --git a/src/engine/platform/su.cpp b/src/engine/platform/su.cpp index 8cd6d3abc..afcdba242 100644 --- a/src/engine/platform/su.cpp +++ b/src/engine/platform/su.cpp @@ -596,7 +596,7 @@ void DivPlatformSoundUnit::setFlags(unsigned int flags) { sampleMemSize=flags&16; - su->Init(sampleMemSize?65536:8192); + su->Init(sampleMemSize?65536:8192,flags&32); renderSamples(); } diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index 484490348..a6bbcb921 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -135,13 +135,20 @@ void FurnaceGUI::drawSysConf(int chan, DivSystem type, unsigned int& flags, bool if (ImGui::RadioButton("5.95MHz (PAL)",(flags&3)==1)) { copyOfFlags=(flags&(~3))|1; } - ImGui::Text("Chip revision (sample memory):"); - if (ImGui::RadioButton("A/B/E (8K)",(flags&16)==0)) { + ImGui::Text("Sample memory:"); + if (ImGui::RadioButton("8K (rev A/B/E)",(flags&16)==0)) { copyOfFlags=(flags&(~16))|0; } - if (ImGui::RadioButton("D/F (64K)",(flags&16)==16)) { + if (ImGui::RadioButton("64K (rev D/F)",(flags&16)==16)) { copyOfFlags=(flags&(~16))|16; } + ImGui::Text("DAC resolution"); + if (ImGui::RadioButton("16-bit (rev A/B/D/F)",(flags&32)==0)) { + copyOfFlags=(flags&(~32))|0; + } + if (ImGui::RadioButton("1-bit PDM (rev C/E)",(flags&32)==32)) { + copyOfFlags=(flags&(~32))|32; + } bool echo=flags&4; if (ImGui::Checkbox("Enable echo",&echo)) { copyOfFlags=(flags&(~4))|(echo<<2);