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;