fix the crashes

This commit is contained in:
tildearrow 2022-09-26 02:51:16 -05:00
parent c23b504d79
commit 607e3c9339
4 changed files with 18 additions and 11 deletions

View file

@ -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;