X1-010: fix frequency overflow

issue #843
This commit is contained in:
tildearrow 2023-01-13 01:15:55 -05:00
parent 7b14175e45
commit 8d0090b0f3
1 changed files with 2 additions and 1 deletions

View File

@ -362,7 +362,7 @@ void DivPlatformX1_010::tick(bool sysTick) {
if (chan[i].std.pitch.had) {
if (chan[i].std.pitch.mode) {
chan[i].pitch2+=chan[i].std.pitch.val;
CLAMP_VAR(chan[i].pitch2,-32768,32767);
CLAMP_VAR(chan[i].pitch2,-65535,65535);
} else {
chan[i].pitch2=chan[i].std.pitch.val;
}
@ -484,6 +484,7 @@ void DivPlatformX1_010::tick(bool sysTick) {
if (chan[i].freq>255) chan[i].freq=255;
chWrite(i,2,chan[i].freq&0xff);
} else {
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq>65535) chan[i].freq=65535;
chWrite(i,2,chan[i].freq&0xff);
chWrite(i,3,(chan[i].freq>>8)&0xff);