OPL/OPNA/OPNB: fix ADPCM-B freq not being clamped

This commit is contained in:
tildearrow 2023-09-06 18:39:56 -05:00
parent 8d365a2faf
commit bb4de6fcb0
4 changed files with 8 additions and 0 deletions

View file

@ -549,6 +549,8 @@ void DivPlatformOPL::tick(bool sysTick) {
chan[adpcmChan].freq=5461; // 4KHz
}
}
if (chan[adpcmChan].freq<0) chan[adpcmChan].freq=0;
if (chan[adpcmChan].freq>65535) chan[adpcmChan].freq=65535;
immWrite(16,chan[adpcmChan].freq&0xff);
immWrite(17,(chan[adpcmChan].freq>>8)&0xff);
if (chan[adpcmChan].keyOn || chan[adpcmChan].keyOff) {

View file

@ -783,6 +783,8 @@ void DivPlatformYM2608::tick(bool sysTick) {
chan[15].freq=0;
}
}
if (chan[adpcmBChanOffs].freq<0) chan[adpcmBChanOffs].freq=0;
if (chan[adpcmBChanOffs].freq>65535) chan[adpcmBChanOffs].freq=65535;
immWrite(0x109,chan[15].freq&0xff);
immWrite(0x10a,(chan[15].freq>>8)&0xff);
hardResetElapsed+=2;

View file

@ -717,6 +717,8 @@ void DivPlatformYM2610::tick(bool sysTick) {
} else {
chan[adpcmBChanOffs].freq=0;
}
if (chan[adpcmBChanOffs].freq<0) chan[adpcmBChanOffs].freq=0;
if (chan[adpcmBChanOffs].freq>65535) chan[adpcmBChanOffs].freq=65535;
immWrite(0x19,chan[adpcmBChanOffs].freq&0xff);
immWrite(0x1a,(chan[adpcmBChanOffs].freq>>8)&0xff);
hardResetElapsed+=2;

View file

@ -784,6 +784,8 @@ void DivPlatformYM2610B::tick(bool sysTick) {
} else {
chan[adpcmBChanOffs].freq=0;
}
if (chan[adpcmBChanOffs].freq<0) chan[adpcmBChanOffs].freq=0;
if (chan[adpcmBChanOffs].freq>65535) chan[adpcmBChanOffs].freq=65535;
immWrite(0x19,chan[adpcmBChanOffs].freq&0xff);
immWrite(0x1a,(chan[adpcmBChanOffs].freq>>8)&0xff);
hardResetElapsed+=2;