mirror of
https://github.com/tildearrow/furnace.git
synced 2025-01-05 23:21:22 +00:00
prevent division by zero, part 1
This commit is contained in:
parent
6960112f69
commit
b24c572632
4 changed files with 6 additions and 4 deletions
|
@ -4017,7 +4017,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextToTouch>=0) {
|
if (nextToTouch>=0) {
|
||||||
double waitTime=totalWait+(loopTimer[nextToTouch]*(44100.0/loopFreq[nextToTouch]));
|
double waitTime=totalWait+(loopTimer[nextToTouch]*(44100.0/MIN(1,loopFreq[nextToTouch])));
|
||||||
if (waitTime>0) {
|
if (waitTime>0) {
|
||||||
w->writeC(0x61);
|
w->writeC(0x61);
|
||||||
w->writeS(waitTime);
|
w->writeS(waitTime);
|
||||||
|
|
|
@ -385,7 +385,8 @@ void DivPlatformGenesis::tick() {
|
||||||
off=8363.0/(double)s->centerRate;
|
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);
|
if (dumpWrites) addWrite(0xffff0001,1280000/dacRate);
|
||||||
}
|
}
|
||||||
chan[i].freqChanged=false;
|
chan[i].freqChanged=false;
|
||||||
|
@ -514,7 +515,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
dacPos=0;
|
dacPos=0;
|
||||||
dacPeriod=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);
|
if (dumpWrites) addWrite(0xffff0001,parent->song.sample[dacSample]->rate);
|
||||||
chan[c.chan].furnaceDac=false;
|
chan[c.chan].furnaceDac=false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ void DivPlatformPCE::tick() {
|
||||||
off=8363.0/(double)s->centerRate;
|
off=8363.0/(double)s->centerRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chan[i].dacRate=((double)chipClock/2)/(off*chan[i].freq);
|
chan[i].dacRate=((double)chipClock/2)/MIN(1,off*chan[i].freq);
|
||||||
if (dumpWrites) addWrite(0xffff0001+(i<<8),chan[i].dacRate);
|
if (dumpWrites) addWrite(0xffff0001+(i<<8),chan[i].dacRate);
|
||||||
}
|
}
|
||||||
if (chan[i].freq>4095) chan[i].freq=4095;
|
if (chan[i].freq>4095) chan[i].freq=4095;
|
||||||
|
|
|
@ -57,6 +57,7 @@ unsigned char DivPlatformTIA::dealWithFreq(unsigned char shape, int base, int pi
|
||||||
}
|
}
|
||||||
int bp=base+pitch;
|
int bp=base+pitch;
|
||||||
double mult=0.25*(parent->song.tuning*0.0625)*pow(2.0,double(768+bp)/(256.0*12.0));
|
double mult=0.25*(parent->song.tuning*0.0625)*pow(2.0,double(768+bp)/(256.0*12.0));
|
||||||
|
if (mult<0.5) mult=0.5;
|
||||||
switch (shape) {
|
switch (shape) {
|
||||||
case 1: // buzzy
|
case 1: // buzzy
|
||||||
return ceil(31400/(30.6*mult))-1;
|
return ceil(31400/(30.6*mult))-1;
|
||||||
|
|
Loading…
Reference in a new issue