diff --git a/src/engine/platform/opl.cpp b/src/engine/platform/opl.cpp index 2894428e8..00d40b17e 100644 --- a/src/engine/platform/opl.cpp +++ b/src/engine/platform/opl.cpp @@ -3279,7 +3279,7 @@ void DivPlatformOPL::renderSamples(int sysID) { break; case DIV_SAMPLE_DEPTH_12BIT: sampleLength=s->getLoopEndPosition(DIV_SAMPLE_DEPTH_12BIT); - length=MIN(98303,sampleLength+1); + length=MIN(98303,sampleLength+3); break; case DIV_SAMPLE_DEPTH_16BIT: sampleLength=s->getLoopEndPosition(DIV_SAMPLE_DEPTH_16BIT); @@ -3294,21 +3294,21 @@ void DivPlatformOPL::renderSamples(int sysID) { if (sampleLength<1) length=0; int actualLength=MIN((int)(getSampleMemCapacity(0)-memPos),length); if (actualLength>0) { - #ifdef TA_BIG_ENDIAN - memcpy(&pcmMem[memPos],src,actualLength); - #else if (s->depth==DIV_SAMPLE_DEPTH_16BIT) { for (int i=0, j=0; i=sampleLength) j=sampleLength-2; +#ifdef TA_BIG_ENDIAN + pcmMem[memPos+i]=src[j]; +#else pcmMem[memPos+i]=src[j^1]; +#endif } } else { for (int i=0, j=0; i=sampleLength) j=sampleLength-1; + if (j>=sampleLength && s->depth!=DIV_SAMPLE_DEPTH_12BIT) j=sampleLength-1; pcmMem[memPos+i]=src[j]; } } - #endif sampleOffPCM[i]=memPos; memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+length)); memPos+=length; @@ -3334,6 +3334,10 @@ void DivPlatformOPL::renderSamples(int sysID) { break; case DIV_SAMPLE_DEPTH_12BIT: bitDepth=1; + if (!s->isLoopable()) { + endPos++; + loop++; + } break; case DIV_SAMPLE_DEPTH_16BIT: bitDepth=2; diff --git a/src/engine/sample.cpp b/src/engine/sample.cpp index 87fb2a186..59e97891a 100644 --- a/src/engine/sample.cpp +++ b/src/engine/sample.cpp @@ -619,8 +619,8 @@ bool DivSample::initInternal(DivSampleDepth d, int count) { case DIV_SAMPLE_DEPTH_12BIT: // 12-bit PCM (MultiPCM) if (data12!=NULL) delete[] data12; length12=((count*3)+1)/2; - data12=new unsigned char[length12]; - memset(data12,0,length12); + data12=new unsigned char[length12+8]; + memset(data12,0,length12+8); break; case DIV_SAMPLE_DEPTH_16BIT: // 16-bit if (data16!=NULL) delete[] data16; @@ -1513,6 +1513,8 @@ void DivSample::render(unsigned int formatMask) { data12[j+1]=((data16[i+0]>>4)&0xf)|(i+1>4)&0xf:0); if (i+1>8; + } else { + data12[j+2]=0; } } }