From 88433152568416f0a3a91b2cbbe34008b4cd2a99 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 2 Mar 2022 00:58:49 -0500 Subject: [PATCH] OPLL: 99.99% VGM export --- src/engine/sysDef.cpp | 3 +++ src/engine/vgmOps.cpp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index a0d211c6..52a4cb89 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -1601,6 +1601,9 @@ bool DivEngine::isVGMExportable(DivSystem which) { case DIV_SYSTEM_QSOUND: case DIV_SYSTEM_SEGAPCM: case DIV_SYSTEM_SEGAPCM_COMPAT: + case DIV_SYSTEM_OPLL: + case DIV_SYSTEM_OPLL_DRUMS: + case DIV_SYSTEM_VRC7: return true; default: return false; diff --git a/src/engine/vgmOps.cpp b/src/engine/vgmOps.cpp index 71f313e4..97f42737 100644 --- a/src/engine/vgmOps.cpp +++ b/src/engine/vgmOps.cpp @@ -214,6 +214,21 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write w->writeC(0); w->writeC(0xbf); break; + case DIV_SYSTEM_OPLL: + case DIV_SYSTEM_OPLL_DRUMS: + case DIV_SYSTEM_VRC7: + for (int i=0; i<9; i++) { + w->writeC(isSecond?0xa1:0x51); + w->writeC(0x20+i); + w->writeC(0); + w->writeC(isSecond?0xa1:0x51); + w->writeC(0x30+i); + w->writeC(0); + w->writeC(isSecond?0xa1:0x51); + w->writeC(0x10+i); + w->writeC(0); + } + break; case DIV_SYSTEM_AY8910: w->writeC(0xa0); w->writeC(isSecond?0x87:7); @@ -395,6 +410,13 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write break; } break; + case DIV_SYSTEM_OPLL: + case DIV_SYSTEM_OPLL_DRUMS: + case DIV_SYSTEM_VRC7: + w->writeC(isSecond?0xa1:0x51); + w->writeC(write.addr&0xff); + w->writeC(write.val); + break; case DIV_SYSTEM_AY8910: case DIV_SYSTEM_AY8930: w->writeC(0xa0); @@ -682,6 +704,19 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) { howManyChips++; } break; + case DIV_SYSTEM_OPLL: + case DIV_SYSTEM_OPLL_DRUMS: + case DIV_SYSTEM_VRC7: + if (!hasOPLL) { + hasOPLL=disCont[i].dispatch->chipClock; + willExport[i]=true; + } else if (!(hasOPLL&0x40000000)) { + isSecond[i]=true; + willExport[i]=true; + hasOPLL|=0x40000000; + howManyChips++; + } + break; case DIV_SYSTEM_LYNX: if (!hasLynx) { hasLynx=disCont[i].dispatch->chipClock;