From 26cf5bd097b38e7b441e0504b57bea0e7061e732 Mon Sep 17 00:00:00 2001 From: cam900 Date: Sat, 13 Jul 2024 13:15:40 +0900 Subject: [PATCH] Fix VGM output --- src/engine/vgmOps.cpp | 52 ++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/src/engine/vgmOps.cpp b/src/engine/vgmOps.cpp index b3729dffe..60a22ff86 100644 --- a/src/engine/vgmOps.cpp +++ b/src/engine/vgmOps.cpp @@ -1351,7 +1351,6 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p bool writeVOXSamples=false; DivDispatch* writeADPCM_OPNA[2]={NULL,NULL}; DivDispatch* writeADPCM_OPNB[2]={NULL,NULL}; - DivDispatch* writePCM_OPL4[2]={NULL,NULL}; DivDispatch* writeADPCM_Y8950[2]={NULL,NULL}; DivDispatch* writeSegaPCM[2]={NULL,NULL}; DivDispatch* writeX1010[2]={NULL,NULL}; @@ -1365,6 +1364,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p DivDispatch* writeC140[2]={NULL,NULL}; DivDispatch* writeC219[2]={NULL,NULL}; DivDispatch* writeNES[2]={NULL,NULL}; + DivDispatch* writePCM_OPL4[2]={NULL,NULL}; int writeNESIndex[2]={0,0}; @@ -1804,20 +1804,6 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p howManyChips++; } break; - case DIV_SYSTEM_OPL4: - case DIV_SYSTEM_OPL4_DRUMS: - if (!hasOPL4) { - hasOPL4=disCont[i].dispatch->chipClock; - CHIP_VOL(12,1.0); - willExport[i]=true; - } else if (!(hasOPL4&0x40000000)) { - isSecond[i]=true; - CHIP_VOL_SECOND(12,1.0); - willExport[i]=true; - hasOPL4|=0x40000000; - howManyChips++; - } - break; case DIV_SYSTEM_SCC: case DIV_SYSTEM_SCC_PLUS: if (!hasK051649) { @@ -1977,6 +1963,22 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p howManyChips++; } break; + case DIV_SYSTEM_OPL4: + case DIV_SYSTEM_OPL4_DRUMS: + if (!hasOPL4) { + hasOPL4=disCont[i].dispatch->chipClock; + CHIP_VOL(12,1.0); + willExport[i]=true; + writePCM_OPL4[0]=disCont[i].dispatch; + } else if (!(hasOPL4&0x40000000)) { + isSecond[i]=true; + CHIP_VOL_SECOND(12,1.0); + willExport[i]=true; + writePCM_OPL4[1]=disCont[i].dispatch; + hasOPL4|=0x40000000; + howManyChips++; + } + break; default: break; } @@ -2262,16 +2264,6 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p w->writeI(0); w->write(writeADPCM_OPNB[i]->getSampleMem(1),writeADPCM_OPNB[i]->getSampleMemUsage(1)); } - // PCM (OPL4) - if (writePCM_OPL4[i]!=NULL && writePCM_OPL4[i]->getSampleMemUsage(0)>0) { - w->writeC(0x67); - w->writeC(0x66); - w->writeC(0x84); - w->writeI((writePCM_OPL4[i]->getSampleMemUsage(0)+8)|(i*0x80000000)); - w->writeI(writePCM_OPL4[i]->getSampleMemCapacity(0)); - w->writeI(0); - w->write(writePCM_OPL4[i]->getSampleMem(0),writePCM_OPL4[i]->getSampleMemUsage(0)); - } // ADPCM (Y8950) if (writeADPCM_Y8950[i]!=NULL && writeADPCM_Y8950[i]->getSampleMemUsage(0)>0) { w->writeC(0x67); @@ -2322,6 +2314,16 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p w->write(sampleMem,sampleMemLen); delete[] sampleMem; } + // PCM (OPL4) + if (writePCM_OPL4[i]!=NULL && writePCM_OPL4[i]->getSampleMemUsage(0)>0) { + w->writeC(0x67); + w->writeC(0x66); + w->writeC(0x84); + w->writeI((writePCM_OPL4[i]->getSampleMemUsage(0)+8)|(i*0x80000000)); + w->writeI(writePCM_OPL4[i]->getSampleMemCapacity(0)); + w->writeI(0); + w->write(writePCM_OPL4[i]->getSampleMem(0),writePCM_OPL4[i]->getSampleMemUsage(0)); + } } for (int i=0; i<2; i++) {