PCE: implement anti-click technology

This commit is contained in:
tildearrow 2022-07-30 01:00:51 -05:00
parent e7108c060b
commit 1921fd1759
3 changed files with 33 additions and 3 deletions

View File

@ -136,8 +136,9 @@ void DivPlatformPCE::updateWave(int ch) {
chWrite(ch,0x04,0x5f);
chWrite(ch,0x04,0x1f);
for (int i=0; i<32; i++) {
chWrite(ch,0x06,chan[ch].ws.output[i]);
chWrite(ch,0x06,chan[ch].ws.output[(i+chan[ch].antiClickWavePos)&31]);
}
chan[ch].antiClickWavePos&=31;
if (chan[ch].active) {
chWrite(ch,0x04,0x80|chan[ch].outVol);
}
@ -150,6 +151,13 @@ static unsigned char noiseFreq[12]={
void DivPlatformPCE::tick(bool sysTick) {
for (int i=0; i<6; i++) {
// anti-click
if (antiClickEnabled && sysTick && chan[i].freq>0) {
chan[i].antiClickPeriodCount+=(chipClock/MAX(parent->getCurHz(),1.0f));
chan[i].antiClickWavePos+=chan[i].antiClickPeriodCount/chan[i].freq;
chan[i].antiClickPeriodCount%=chan[i].freq;
}
chan[i].std.next();
if (chan[i].std.vol.had) {
chan[i].outVol=VOL_SCALE_LOG(chan[i].vol&31,MIN(31,chan[i].std.vol.val),31);
@ -555,6 +563,8 @@ void DivPlatformPCE::setFlags(unsigned int flags) {
} else {
chipClock=COLOR_NTSC;
}
// flags&4 will be chip revision
antiClickEnabled=!(flags&8);
rate=chipClock/12;
for (int i=0; i<6; i++) {
oscBuf[i]->rate=rate;

View File

@ -28,7 +28,7 @@
class DivPlatformPCE: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note;
int freq, baseFreq, pitch, pitch2, note, antiClickPeriodCount, antiClickWavePos;
int dacPeriod, dacRate;
unsigned int dacPos;
int dacSample, ins;
@ -47,6 +47,8 @@ class DivPlatformPCE: public DivDispatch {
pitch(0),
pitch2(0),
note(0),
antiClickPeriodCount(0),
antiClickWavePos(0),
dacPeriod(0),
dacRate(0),
dacPos(0),
@ -69,6 +71,7 @@ class DivPlatformPCE: public DivDispatch {
Channel chan[6];
DivDispatchOscBuffer* oscBuf[6];
bool isMuted[6];
bool antiClickEnabled;
struct QueuedWrite {
unsigned char addr;
unsigned char val;

View File

@ -109,6 +109,24 @@ void FurnaceGUI::drawSysConf(int chan, DivSystem type, unsigned int& flags, bool
}
break;
}
case DIV_SYSTEM_PCE: {
sysPal=flags&1;
if (ImGui::Checkbox("Pseudo-PAL",&sysPal)) {
copyOfFlags=(flags&(~1))|(unsigned int)sysPal;
}
bool antiClick=flags&8;
if (ImGui::Checkbox("Disable anti-click",&antiClick)) {
copyOfFlags=(flags&(~8))|(antiClick<<3);
}
break;
}
case DIV_SYSTEM_GB: {
bool antiClick=flags&8;
if (ImGui::Checkbox("Disable anti-click",&antiClick)) {
copyOfFlags=(flags&(~8))|(antiClick<<3);
}
break;
}
case DIV_SYSTEM_OPLL:
case DIV_SYSTEM_OPLL_DRUMS:
case DIV_SYSTEM_VRC7: {
@ -631,7 +649,6 @@ void FurnaceGUI::drawSysConf(int chan, DivSystem type, unsigned int& flags, bool
}
break;
}
case DIV_SYSTEM_GB:
case DIV_SYSTEM_SWAN:
case DIV_SYSTEM_VERA:
case DIV_SYSTEM_BUBSYS_WSG: