fix the crashes
This commit is contained in:
parent
c23b504d79
commit
607e3c9339
|
@ -122,9 +122,6 @@ void DivPlatformRF5C68::tick(bool sysTick) {
|
|||
} else {
|
||||
chan[i].audPos=0;
|
||||
}
|
||||
// TODO: BANG BANG BANG
|
||||
// AAAAAAAAAAAAAAAAAAA
|
||||
// ASGDJFJFSDGL;ASDHFKJLSHFLKAJSFHKLJVSJ
|
||||
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
|
||||
unsigned char keyon=regPool[8]&~(1<<i);
|
||||
unsigned char keyoff=keyon|(1<<i);
|
||||
|
@ -133,8 +130,12 @@ void DivPlatformRF5C68::tick(bool sysTick) {
|
|||
chan[i].freq=(int)(off*parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,2,chan[i].pitch2,chipClock,CHIP_FREQBASE));
|
||||
if (chan[i].freq>65535) chan[i].freq=65535;
|
||||
if (chan[i].keyOn) {
|
||||
unsigned int start=sampleOffRFC[chan[i].sample];
|
||||
unsigned int loop=start+s->length8;
|
||||
unsigned int start=0;
|
||||
unsigned int loop=0;
|
||||
if (chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen) {
|
||||
start=sampleOffRFC[chan[i].sample];
|
||||
loop=start+s->length8;
|
||||
}
|
||||
if (chan[i].audPos>0) {
|
||||
start=start+MIN(chan[i].audPos,s->length8);
|
||||
}
|
||||
|
|
|
@ -178,7 +178,6 @@ void DivPlatformSNES::tick(bool sysTick) {
|
|||
updateWave(i);
|
||||
}
|
||||
}
|
||||
// TODO: THIS WILL CRASH IF THE SAMPLE IS INVALID!!!
|
||||
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
|
||||
DivSample* s=parent->getSample(chan[i].sample);
|
||||
double off=(s->centerRate>=1)?((double)s->centerRate/8363.0):1.0;
|
||||
|
@ -191,7 +190,7 @@ void DivPlatformSNES::tick(bool sysTick) {
|
|||
if (chan[i].useWave) {
|
||||
start=waveTableAddr(i);
|
||||
loop=start;
|
||||
} else {
|
||||
} else if (chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen) {
|
||||
start=sampleOff[chan[i].sample];
|
||||
end=MIN(start+MAX(s->lengthBRR,1),getSampleMemCapacity());
|
||||
loop=MAX(start,end-1);
|
||||
|
@ -201,6 +200,10 @@ void DivPlatformSNES::tick(bool sysTick) {
|
|||
if (s->loopStart>=0) {
|
||||
loop=start+s->loopStart/16*9;
|
||||
}
|
||||
} else {
|
||||
start=0;
|
||||
end=0;
|
||||
loop=0;
|
||||
}
|
||||
sampleMem[tabAddr+0]=start&0xff;
|
||||
sampleMem[tabAddr+1]=start>>8;
|
||||
|
|
|
@ -163,7 +163,7 @@ void DivPlatformSoundUnit::tick(bool sysTick) {
|
|||
DivInstrument* ins=parent->getIns(chan[i].ins,DIV_INS_SU);
|
||||
int sNum=ins->amiga.getSample(chan[i].note);
|
||||
DivSample* sample=parent->getSample(sNum);
|
||||
if (sample!=NULL) {
|
||||
if (sample!=NULL && sNum>=0 && sNum<parent->song.sampleLen) {
|
||||
unsigned int sampleEnd=sampleOffSU[sNum]+(sample->getLoopEndPosition());
|
||||
unsigned int off=sampleOffSU[sNum]+chan[i].hasOffset;
|
||||
chan[i].hasOffset=0;
|
||||
|
|
|
@ -145,12 +145,15 @@ void DivPlatformYMZ280B::tick(bool sysTick) {
|
|||
// ADPCM has half the range
|
||||
if (s->depth==DIV_SAMPLE_DEPTH_YMZ_ADPCM && chan[i].freq>255) chan[i].freq=255;
|
||||
ctrl|=(chan[i].active?0x80:0)|((s->isLoopable())?0x10:0)|(chan[i].freq>>8);
|
||||
// TODO: AGAIN THIS WILL CRASH IF THE SAMPLE IS INVALID!!!
|
||||
if (chan[i].keyOn) {
|
||||
unsigned int start=sampleOff[chan[i].sample];
|
||||
unsigned int start=0;
|
||||
unsigned int loopStart=0;
|
||||
unsigned int loopEnd=0;
|
||||
unsigned int end=MIN(start+s->getCurBufLen(),getSampleMemCapacity()-1);
|
||||
unsigned int end=0;
|
||||
if (chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen) {
|
||||
start=sampleOff[chan[i].sample];
|
||||
end=MIN(start+s->getCurBufLen(),getSampleMemCapacity()-1);
|
||||
}
|
||||
if (chan[i].audPos>0) {
|
||||
switch (s->depth) {
|
||||
case DIV_SAMPLE_DEPTH_YMZ_ADPCM: start+=chan[i].audPos/2; break;
|
||||
|
|
Loading…
Reference in a new issue