Fix MultiPCM sample OOB issue
This commit is contained in:
parent
957b57f3d9
commit
ffc681b8fa
|
@ -630,7 +630,7 @@ void DivPlatformMultiPCM::renderSamples(int sysID) {
|
||||||
memPos+=length;
|
memPos+=length;
|
||||||
}
|
}
|
||||||
if (actualLength<length) {
|
if (actualLength<length) {
|
||||||
logW("out of OPL4 PCM memory for sample %d!",i);
|
logW("out of MultiPCM memory for sample %d!",i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sampleLoaded[i]=true;
|
sampleLoaded[i]=true;
|
||||||
|
@ -640,10 +640,12 @@ void DivPlatformMultiPCM::renderSamples(int sysID) {
|
||||||
int insCount=parent->song.insLen;
|
int insCount=parent->song.insLen;
|
||||||
for (int i=0; i<insCount; i++) {
|
for (int i=0; i<insCount; i++) {
|
||||||
DivInstrument* ins=parent->song.ins[i];
|
DivInstrument* ins=parent->song.ins[i];
|
||||||
DivSample* s=parent->song.sample[ins->amiga.initSample];
|
|
||||||
unsigned int insAddr=(i*12);
|
unsigned int insAddr=(i*12);
|
||||||
|
short sample=ins->amiga.initSample;
|
||||||
|
if (sample>=0 && sample<parent->song.sampleLen) {
|
||||||
|
DivSample* s=parent->song.sample[sample];
|
||||||
unsigned char bitDepth;
|
unsigned char bitDepth;
|
||||||
int startPos=sampleOff[ins->amiga.initSample];
|
int startPos=sampleOff[sample];
|
||||||
int endPos=CLAMP(s->isLoopable()?s->loopEnd:(s->samples+1),1,0x10000);
|
int endPos=CLAMP(s->isLoopable()?s->loopEnd:(s->samples+1),1,0x10000);
|
||||||
int loop=s->isLoopable()?CLAMP(s->loopStart,0,endPos-2):(endPos-2);
|
int loop=s->isLoopable()?CLAMP(s->loopStart,0,endPos-2):(endPos-2);
|
||||||
switch (s->depth) {
|
switch (s->depth) {
|
||||||
|
@ -681,8 +683,22 @@ void DivPlatformMultiPCM::renderSamples(int sysID) {
|
||||||
pcmMem[10+insAddr]=(0xf<<4)|(0xf<<0); // RC, RR
|
pcmMem[10+insAddr]=(0xf<<4)|(0xf<<0); // RC, RR
|
||||||
pcmMem[11+insAddr]=0; // AM
|
pcmMem[11+insAddr]=0; // AM
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// fill to dummy instrument
|
||||||
|
pcmMem[insAddr]=0;
|
||||||
|
pcmMem[1+insAddr]=0;
|
||||||
|
pcmMem[2+insAddr]=0;
|
||||||
|
pcmMem[3+insAddr]=0;
|
||||||
|
pcmMem[4+insAddr]=0;
|
||||||
|
pcmMem[5+insAddr]=0xff;
|
||||||
|
pcmMem[6+insAddr]=0xff;
|
||||||
|
pcmMem[7+insAddr]=0; // LFO, VIB
|
||||||
|
pcmMem[8+insAddr]=(0xf<<4)|(0xf<<0); // AR, D1R
|
||||||
|
pcmMem[9+insAddr]=(0xf<<4); // DL, D2R
|
||||||
|
pcmMem[10+insAddr]=(0xf<<4)|(0xf<<0); // RC, RR
|
||||||
|
pcmMem[11+insAddr]=0; // AM
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memCompo.used=pcmMemLen;
|
memCompo.used=pcmMemLen;
|
||||||
}
|
}
|
||||||
memCompo.capacity=getSampleMemCapacity(0);
|
memCompo.capacity=getSampleMemCapacity(0);
|
||||||
|
|
Loading…
Reference in a new issue