SoundUnit: add 1-bit PDM rev emulation

This commit is contained in:
tildearrow 2022-08-16 02:08:10 -05:00
parent fcb8fba77b
commit 976e193309
4 changed files with 53 additions and 8 deletions

View file

@ -300,12 +300,46 @@ void SoundUnit::NextSample(short* l, short* r) {
}
}
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;

View file

@ -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();
};

View file

@ -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();
}

View file

@ -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);