prevent division by zero, part 1

This commit is contained in:
tildearrow 2022-02-15 15:19:36 -05:00
parent 6960112f69
commit b24c572632
4 changed files with 6 additions and 4 deletions

View file

@ -385,7 +385,8 @@ void DivPlatformGenesis::tick() {
off=8363.0/(double)s->centerRate;
}
}
dacRate=(1280000*1.25*off)/chan[i].baseFreq;
dacRate=(1280000*1.25*off)/MIN(1,chan[i].baseFreq);
if (dacRate<1) dacRate=1;
if (dumpWrites) addWrite(0xffff0001,1280000/dacRate);
}
chan[i].freqChanged=false;
@ -514,7 +515,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
}
dacPos=0;
dacPeriod=0;
dacRate=1280000/parent->song.sample[dacSample]->rate;
dacRate=1280000/MIN(1,parent->song.sample[dacSample]->rate);
if (dumpWrites) addWrite(0xffff0001,parent->song.sample[dacSample]->rate);
chan[c.chan].furnaceDac=false;
}