OPLL: fix possible overflow

This commit is contained in:
tildearrow 2022-12-24 18:29:01 -05:00
parent 1ac19ed61f
commit 89e057a2ba
1 changed files with 2 additions and 1 deletions

View File

@ -248,6 +248,7 @@ void DivPlatformOPLL::tick(bool sysTick) {
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq>65535) chan[i].freq=65535;
int freqt=toFreq(chan[i].freq);
if (freqt>2047) freqt=2047;
chan[i].freqL=freqt&0xff;
if (i>=6 && properDrums && (i<9 || !noTopHatFreq)) {
immWrite(0x10+drumSlot[i],freqt&0xff);
@ -257,7 +258,7 @@ void DivPlatformOPLL::tick(bool sysTick) {
immWrite(0x10+i,freqt&0xff);
}
}
chan[i].freqH=freqt>>8;
chan[i].freqH=(freqt>>8)&15;
}
if (chan[i].keyOn && i>=6 && properDrums) {
if (!isMuted[i]) {