From 36eaea0fa731c1d01aed1a92844e8641b42785a3 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 17 Feb 2022 22:07:20 -0500 Subject: [PATCH] OPN: apply max freq limit --- src/engine/platform/genesis.cpp | 1 + src/engine/platform/genesisext.cpp | 1 + src/engine/platform/ym2610.cpp | 1 + src/engine/platform/ym2610ext.cpp | 1 + 4 files changed, 4 insertions(+) diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index e2d883f82..8787d0552 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -372,6 +372,7 @@ void DivPlatformGenesis::tick() { if (i==2 && extMode) continue; if (chan[i].freqChanged) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq)); + if (chan[i].freq>262143) chan[i].freq=262143; int freqt=toFreq(chan[i].freq); immWrite(chanOffs[i]+ADDR_FREQH,freqt>>8); immWrite(chanOffs[i]+ADDR_FREQ,freqt&0xff); diff --git a/src/engine/platform/genesisext.cpp b/src/engine/platform/genesisext.cpp index bc418e901..382c89f53 100644 --- a/src/engine/platform/genesisext.cpp +++ b/src/engine/platform/genesisext.cpp @@ -270,6 +270,7 @@ void DivPlatformGenesisExt::tick() { if (extMode) for (int i=0; i<4; i++) { if (opChan[i].freqChanged) { opChan[i].freq=parent->calcFreq(opChan[i].baseFreq,opChan[i].pitch); + if (opChan[i].freq>262143) opChan[i].freq=262143; if (opChan[i].freq>=82432) { opChan[i].freqH=((opChan[i].freq>>15)&7)|0x38; opChan[i].freqL=(opChan[i].freq>>7)&0xff; diff --git a/src/engine/platform/ym2610.cpp b/src/engine/platform/ym2610.cpp index a9d59f63c..135e73fef 100644 --- a/src/engine/platform/ym2610.cpp +++ b/src/engine/platform/ym2610.cpp @@ -368,6 +368,7 @@ void DivPlatformYM2610::tick() { if (i==1 && extMode) continue; if (chan[i].freqChanged) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq)); + if (chan[i].freq>262143) chan[i].freq=262143; int freqt=toFreq(chan[i].freq); immWrite(chanOffs[i]+ADDR_FREQH,freqt>>8); immWrite(chanOffs[i]+ADDR_FREQ,freqt&0xff); diff --git a/src/engine/platform/ym2610ext.cpp b/src/engine/platform/ym2610ext.cpp index 567c24146..1cd17945b 100644 --- a/src/engine/platform/ym2610ext.cpp +++ b/src/engine/platform/ym2610ext.cpp @@ -234,6 +234,7 @@ void DivPlatformYM2610Ext::tick() { if (extMode) for (int i=0; i<4; i++) { if (opChan[i].freqChanged) { opChan[i].freq=parent->calcFreq(opChan[i].baseFreq,opChan[i].pitch); + if (opChan[i].freq>262143) opChan[i].freq=262143; int freqt=toFreq(opChan[i].freq); opChan[i].freqH=freqt>>8; opChan[i].freqL=freqt&0xff;