Fix VGM output

This commit is contained in:
cam900 2024-07-13 13:15:40 +09:00
parent 87ac12e143
commit 26cf5bd097

View file

@ -1351,7 +1351,6 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
bool writeVOXSamples=false; bool writeVOXSamples=false;
DivDispatch* writeADPCM_OPNA[2]={NULL,NULL}; DivDispatch* writeADPCM_OPNA[2]={NULL,NULL};
DivDispatch* writeADPCM_OPNB[2]={NULL,NULL}; DivDispatch* writeADPCM_OPNB[2]={NULL,NULL};
DivDispatch* writePCM_OPL4[2]={NULL,NULL};
DivDispatch* writeADPCM_Y8950[2]={NULL,NULL}; DivDispatch* writeADPCM_Y8950[2]={NULL,NULL};
DivDispatch* writeSegaPCM[2]={NULL,NULL}; DivDispatch* writeSegaPCM[2]={NULL,NULL};
DivDispatch* writeX1010[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* writeC140[2]={NULL,NULL};
DivDispatch* writeC219[2]={NULL,NULL}; DivDispatch* writeC219[2]={NULL,NULL};
DivDispatch* writeNES[2]={NULL,NULL}; DivDispatch* writeNES[2]={NULL,NULL};
DivDispatch* writePCM_OPL4[2]={NULL,NULL};
int writeNESIndex[2]={0,0}; int writeNESIndex[2]={0,0};
@ -1804,20 +1804,6 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
howManyChips++; howManyChips++;
} }
break; 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:
case DIV_SYSTEM_SCC_PLUS: case DIV_SYSTEM_SCC_PLUS:
if (!hasK051649) { if (!hasK051649) {
@ -1977,6 +1963,22 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
howManyChips++; howManyChips++;
} }
break; 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: default:
break; break;
} }
@ -2262,16 +2264,6 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
w->writeI(0); w->writeI(0);
w->write(writeADPCM_OPNB[i]->getSampleMem(1),writeADPCM_OPNB[i]->getSampleMemUsage(1)); 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) // ADPCM (Y8950)
if (writeADPCM_Y8950[i]!=NULL && writeADPCM_Y8950[i]->getSampleMemUsage(0)>0) { if (writeADPCM_Y8950[i]!=NULL && writeADPCM_Y8950[i]->getSampleMemUsage(0)>0) {
w->writeC(0x67); w->writeC(0x67);
@ -2322,6 +2314,16 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
w->write(sampleMem,sampleMemLen); w->write(sampleMem,sampleMemLen);
delete[] sampleMem; 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++) { for (int i=0; i<2; i++) {