VGM export: QSound ADPCM fix, for real this time

This commit is contained in:
tildearrow 2024-09-25 13:12:34 -05:00
parent 09689a3b78
commit 60d01de6fc

View file

@ -2283,8 +2283,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
w->writeI(0);
w->write(writeADPCM_Y8950[i]->getSampleMem(0),writeADPCM_Y8950[i]->getSampleMemUsage(0));
}
if (writeQSound[i]!=NULL && writeQSound[i]->getSampleMemUsage(1)>0) {
unsigned int blockSize=(writeQSound[i]->getSampleMemUsage(1)+0xffff)&(~0xffff);
// QSound has two sample types sharing the same memory.
// however, they are prepresented as separate memories in Furnace.
// we find the largest one to see how much memory is being used in total.
if (writeQSound[i]!=NULL && (writeQSound[i]->getSampleMemUsage(0)>0 || writeQSound[i]->getSampleMemUsage(1)>0)) {
unsigned int blockSize=(writeQSound[i]->getSampleMemUsage(0)+writeQSound[i]->getSampleMemUsage(1)+0xffff)&(~0xffff);
if (blockSize > 0x1000000) {
blockSize = 0x1000000;
}
@ -2292,7 +2295,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
w->writeC(0x66);
w->writeC(0x8F);
w->writeI((blockSize+8)|(i*0x80000000));
w->writeI(writeQSound[i]->getSampleMemCapacity(1));
w->writeI(writeQSound[i]->getSampleMemCapacity(0));
w->writeI(0);
w->write(writeQSound[i]->getSampleMem(),blockSize);
}