From f8796f8ec9d749615e9f9c3dd7bb1477d67083d1 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 28 May 2022 18:15:26 -0500 Subject: [PATCH] MSM6295: VGM export! --- src/engine/platform/msm6295.cpp | 29 ++++++++++++++++++-------- src/engine/platform/msm6295.h | 1 + src/engine/sysDef.cpp | 2 +- src/engine/vgmOps.cpp | 36 +++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 9 deletions(-) diff --git a/src/engine/platform/msm6295.cpp b/src/engine/platform/msm6295.cpp index 950f80a7..f1d4e997 100644 --- a/src/engine/platform/msm6295.cpp +++ b/src/engine/platform/msm6295.cpp @@ -57,7 +57,7 @@ void DivPlatformMSM6295::acquire(short* bufL, short* bufR, size_t start, size_t case 11: break; case 12: // rate select - msm->ss_w(w.val); + msm->ss_w(!w.val); break; case 14: // enable bankswitch break; @@ -181,7 +181,7 @@ int DivPlatformMSM6295::dispatch(DivCommand c) { } case DIV_CMD_SAMPLE_FREQ: rateSel=c.value; - rWrite(12,rateSel); + rWrite(12,!rateSel); break; case DIV_CMD_SAMPLE_BANK: sampleBank=c.value; @@ -220,7 +220,7 @@ void DivPlatformMSM6295::forceIns() { for (int i=0; i<4; i++) { chan[i].insChanged=true; } - rWrite(12,rateSel); + rWrite(12,!rateSel); } void* DivPlatformMSM6295::getChanState(int ch) { @@ -273,6 +273,10 @@ bool DivPlatformMSM6295::keyOffAffectsArp(int ch) { return false; } +float DivPlatformMSM6295::getPostAmp() { + return 3.0f; +} + void DivPlatformMSM6295::notifyInsChange(int ins) { for (int i=0; i<4; i++) { if (chan[i].ins==ins) { @@ -335,12 +339,21 @@ void DivPlatformMSM6295::renderSamples() { } void DivPlatformMSM6295::setFlags(unsigned int flags) { - if (flags&1) { - chipClock=8448000; - } else { - chipClock=8000000; + switch (flags) { + case 0: + chipClock=4000000/4; + break; + case 1: + chipClock=4224000/4; + break; + case 2: + chipClock=4000000; + break; + case 3: + chipClock=4224000; + break; } - rate=chipClock/((flags&2)?6:24); + rate=chipClock/3; for (int i=0; i<4; i++) { isMuted[i]=false; oscBuf[i]->rate=rate/22; diff --git a/src/engine/platform/msm6295.h b/src/engine/platform/msm6295.h index d63a01dc..2930a169 100644 --- a/src/engine/platform/msm6295.h +++ b/src/engine/platform/msm6295.h @@ -120,6 +120,7 @@ class DivPlatformMSM6295: public DivDispatch { void tick(bool sysTick=true); void muteChannel(int ch, bool mute); bool keyOffAffectsArp(int ch); + float getPostAmp(); void notifyInsChange(int ins); void notifyInsDeletion(void* ins); void poke(unsigned int addr, unsigned short val); diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index 2ef13df2..45fde718 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -1949,7 +1949,7 @@ void DivEngine::registerSystems() { ); sysDefs[DIV_SYSTEM_MSM6295]=new DivSysDef( - "OKI MSM6295", NULL, 0xaa, 0, 4, false, true, 0, false, + "OKI MSM6295", NULL, 0xaa, 0, 4, false, true, 0x161, false, "an ADPCM sound chip manufactured by OKI and used in many arcade boards.", {"Channel 1", "Channel 2", "Channel 3", "Channel 4"}, {"CH1", "CH2", "CH3", "CH4"}, diff --git a/src/engine/vgmOps.cpp b/src/engine/vgmOps.cpp index 0ba6bd28..e2754bb6 100644 --- a/src/engine/vgmOps.cpp +++ b/src/engine/vgmOps.cpp @@ -488,6 +488,14 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write w->writeC(rf5c68Addr); w->writeC(8); w->writeC(0xff); + case DIV_SYSTEM_MSM6295: + w->writeC(0xb8); // disable all channels + w->writeC(baseAddr2|0); + w->writeC(0x78); + w->writeC(0xb8); // select rate + w->writeC(baseAddr2|12); + w->writeC(1); + break; default: break; } @@ -782,6 +790,11 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write w->writeC(write.addr&0xff); w->writeC(write.val); break; + case DIV_SYSTEM_MSM6295: + w->writeC(0xb8); + w->writeC(baseAddr2|(write.addr&0x7f)); + w->writeC(write.val); + break; default: logW("write not handled!"); break; @@ -907,6 +920,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version) { DivDispatch* writeQSound[2]={NULL,NULL}; DivDispatch* writeZ280[2]={NULL,NULL}; DivDispatch* writeRF5C68[2]={NULL,NULL}; + DivDispatch* writeMSM6295[2]={NULL,NULL}; for (int i=0; ichipClock; + willExport[i]=true; + writeMSM6295[0]=disCont[i].dispatch; + } else if (!(hasOKIM6295&0x40000000)) { + isSecond[i]=true; + willExport[i]=true; + writeMSM6295[1]=disCont[i].dispatch; + hasOKIM6295|=0x40000000; + howManyChips++; + } + break; default: break; } @@ -1645,6 +1672,15 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version) { w->writeI(0); w->write(writeRF5C68[i]->getSampleMem(),writeRF5C68[i]->getSampleMemUsage()); } + if (writeMSM6295[i]!=NULL && writeMSM6295[i]->getSampleMemUsage()>0) { + w->writeC(0x67); + w->writeC(0x66); + w->writeC(0x8b); + w->writeI((writeMSM6295[i]->getSampleMemUsage()+8)|(i*0x80000000)); + w->writeI(writeMSM6295[i]->getSampleMemCapacity()); + w->writeI(0); + w->write(writeMSM6295[i]->getSampleMem(),writeMSM6295[i]->getSampleMemUsage()); + } } // initialize streams