From e7f6290012f34678c1d1134a003a076980b50fbf Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 17 Mar 2022 01:40:03 -0500 Subject: [PATCH] OPL: possibly implement drums mode we need a good UI for it --- src/engine/platform/opl.cpp | 72 +++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 15 deletions(-) diff --git a/src/engine/platform/opl.cpp b/src/engine/platform/opl.cpp index 3c46b1f2..06bba5b5 100644 --- a/src/engine/platform/opl.cpp +++ b/src/engine/platform/opl.cpp @@ -48,6 +48,10 @@ const unsigned short chanMapOPL2[20]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, N, N, N, N, N, N, N, N, N, N, N }; +const unsigned short chanMapOPL2Drums[20]={ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 7, N, N, N, N, N, N, N, N, N +}; + const unsigned char* slotsOPL2[4]={ slotsOPL2i[0], slotsOPL2i[1], @@ -80,6 +84,10 @@ const unsigned short chanMapOPL3[20]={ 0, 3, 1, 4, 2, 5, 0x100, 0x103, 0x101, 0x104, 0x102, 0x105, 0x106, 0x107, 0x108, 6, 7, 8, N, N }; +const unsigned short chanMapOPL3Drums[20]={ + 0, 3, 1, 4, 2, 5, 0x100, 0x103, 0x101, 0x104, 0x102, 0x105, 0x106, 0x107, 0x108, 6, 7, 8, 8, 7 +}; + const unsigned char* slotsOPL3[4]={ slotsOPL3i[0], slotsOPL3i[1], @@ -224,7 +232,7 @@ void DivPlatformOPL::acquire(short* bufL, short* bufR, size_t start, size_t len) } void DivPlatformOPL::tick() { - for (int i=0; icalcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq)); if (chan[i].freq>131071) chan[i].freq=131071; @@ -387,14 +413,29 @@ void DivPlatformOPL::tick() { chan[i].freqL=freqt&0xff; immWrite(chanMap[i]+ADDR_FREQ,chan[i].freqL); } - if (chan[i].keyOn) { - immWrite(chanMap[i]+ADDR_FREQH,chan[i].freqH|(0x20)); - chan[i].keyOn=false; - } else if (chan[i].freqChanged) { - immWrite(chanMap[i]+ADDR_FREQH,chan[i].freqH|(chan[i].active<<5)); + if (i=melodicChans) return 0; + if (c.chan>=totalChans) return 0; // ineffective in 4-op mode if (oplType==3 && c.chan<14 && (c.chan&1) && c.cmd!=DIV_CMD_GET_VOLMAX && c.cmd!=DIV_ALWAYS_SET_VOLUME) { if (chan[c.chan-1].fourOp) return 0; @@ -879,6 +919,8 @@ void DivPlatformOPL::reset() { dam=false; dvb=false; delay=0; + + immWrite(0xbd,(dam<<7)|(dvb<<6)|(properDrums<<5)|drumState); } bool DivPlatformOPL::isStereo() { @@ -927,7 +969,7 @@ void DivPlatformOPL::setOPLType(int type, bool drums) { slotsNonDrums=slotsOPL2; slotsDrums=slotsOPL2Drums; slots=drums?slotsDrums:slotsNonDrums; - chanMap=chanMapOPL2; + chanMap=drums?chanMapOPL2Drums:chanMapOPL2; chipFreqBase=9440540*0.25; chans=9; melodicChans=drums?6:9; @@ -937,7 +979,7 @@ void DivPlatformOPL::setOPLType(int type, bool drums) { slotsNonDrums=slotsOPL3; slotsDrums=slotsOPL3Drums; slots=drums?slotsDrums:slotsNonDrums; - chanMap=chanMapOPL3; + chanMap=drums?chanMapOPL3Drums:chanMapOPL3; chipFreqBase=9440540; chans=18; melodicChans=drums?15:18;