mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-24 13:35:11 +00:00
SoundUnit: add 1-bit PDM rev emulation
This commit is contained in:
parent
fcb8fba77b
commit
976e193309
4 changed files with 53 additions and 8 deletions
|
@ -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));
|
*l=minval(32767,maxval(-32767,tnsL));
|
||||||
*r=minval(32767,maxval(-32767,tnsR));
|
*r=minval(32767,maxval(-32767,tnsR));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SoundUnit::Init(int sampleMemSize) {
|
void SoundUnit::Init(int sampleMemSize, bool dsOutMode) {
|
||||||
pcmSize=sampleMemSize;
|
pcmSize=sampleMemSize;
|
||||||
|
dsOut=dsOutMode;
|
||||||
Reset();
|
Reset();
|
||||||
memset(pcm,0,pcmSize);
|
memset(pcm,0,pcmSize);
|
||||||
for (int i=0; i<256; i++) {
|
for (int i=0; i<256; i++) {
|
||||||
|
@ -346,6 +380,8 @@ void SoundUnit::Reset() {
|
||||||
oldflags[i]=0;
|
oldflags[i]=0;
|
||||||
pcmdec[i]=0;
|
pcmdec[i]=0;
|
||||||
}
|
}
|
||||||
|
dsCounterL=0;
|
||||||
|
dsCounterR=0;
|
||||||
tnsL=0;
|
tnsL=0;
|
||||||
tnsR=0;
|
tnsR=0;
|
||||||
ilBufPos=0;
|
ilBufPos=0;
|
||||||
|
|
|
@ -27,6 +27,8 @@ class SoundUnit {
|
||||||
unsigned short oldfreq[8];
|
unsigned short oldfreq[8];
|
||||||
unsigned short oldflags[8];
|
unsigned short oldflags[8];
|
||||||
unsigned int pcmSize;
|
unsigned int pcmSize;
|
||||||
|
bool dsOut;
|
||||||
|
short dsCounterL, dsCounterR;
|
||||||
public:
|
public:
|
||||||
unsigned short resetfreq[8];
|
unsigned short resetfreq[8];
|
||||||
unsigned short voldcycles[8];
|
unsigned short voldcycles[8];
|
||||||
|
@ -99,7 +101,7 @@ class SoundUnit {
|
||||||
if (ret>32767) ret=32767;
|
if (ret>32767) ret=32767;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
void Init(int sampleMemSize=8192);
|
void Init(int sampleMemSize=8192, bool dsOutMode=false);
|
||||||
void Reset();
|
void Reset();
|
||||||
SoundUnit();
|
SoundUnit();
|
||||||
};
|
};
|
||||||
|
|
|
@ -596,7 +596,7 @@ void DivPlatformSoundUnit::setFlags(unsigned int flags) {
|
||||||
|
|
||||||
sampleMemSize=flags&16;
|
sampleMemSize=flags&16;
|
||||||
|
|
||||||
su->Init(sampleMemSize?65536:8192);
|
su->Init(sampleMemSize?65536:8192,flags&32);
|
||||||
renderSamples();
|
renderSamples();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,13 +135,20 @@ void FurnaceGUI::drawSysConf(int chan, DivSystem type, unsigned int& flags, bool
|
||||||
if (ImGui::RadioButton("5.95MHz (PAL)",(flags&3)==1)) {
|
if (ImGui::RadioButton("5.95MHz (PAL)",(flags&3)==1)) {
|
||||||
copyOfFlags=(flags&(~3))|1;
|
copyOfFlags=(flags&(~3))|1;
|
||||||
}
|
}
|
||||||
ImGui::Text("Chip revision (sample memory):");
|
ImGui::Text("Sample memory:");
|
||||||
if (ImGui::RadioButton("A/B/E (8K)",(flags&16)==0)) {
|
if (ImGui::RadioButton("8K (rev A/B/E)",(flags&16)==0)) {
|
||||||
copyOfFlags=(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;
|
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;
|
bool echo=flags&4;
|
||||||
if (ImGui::Checkbox("Enable echo",&echo)) {
|
if (ImGui::Checkbox("Enable echo",&echo)) {
|
||||||
copyOfFlags=(flags&(~4))|(echo<<2);
|
copyOfFlags=(flags&(~4))|(echo<<2);
|
||||||
|
|
Loading…
Reference in a new issue