Skip to content

Commit

Permalink
OPL: instant drum muting
Browse files Browse the repository at this point in the history
issue #1945
  • Loading branch information
tildearrow committed Dec 6, 2024
1 parent 4b1f993 commit 192be95
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/engine/platform/opl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ void DivPlatformOPL::tick(bool sysTick) {
unsigned short baseAddr=slotMap[slot];
DivInstrumentFM::Operator& op=chan[i].state.op[(ops==4)?orderedOpsL[j]:j];

if (isMuted[i] && i<=melodicChans) {
if (isMuted[i]) {
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
} else {
if (KVSL(i,j) || i>melodicChans) {
Expand Down Expand Up @@ -1227,7 +1227,7 @@ void DivPlatformOPL::tick(bool sysTick) {
op.ksl=m.ksl.val;
}
if (m.tl.had || m.ksl.had) {
if (isMuted[i] && i<=melodicChans) {
if (isMuted[i]) {
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
} else {
if (KVSL(i,j) || i>melodicChans) {
Expand Down Expand Up @@ -1594,7 +1594,7 @@ void DivPlatformOPL::muteChannel(int ch, bool mute) {
unsigned short baseAddr=slotMap[slot];
DivInstrumentFM::Operator& op=chan[ch].state.op[(ops==4)?orderedOpsL[i]:i];

if (isMuted[ch] && ch<=melodicChans) {
if (isMuted[ch]) {
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
} else {
if (KVSL(ch,i) || ch>melodicChans) {
Expand Down Expand Up @@ -1653,7 +1653,11 @@ void DivPlatformOPL::commitState(int ch, DivInstrument* ins) {
DivInstrumentFM::Operator& op=chan[ch].state.op[0];
chan[ch].fourOp=false;

rWrite(baseAddr+ADDR_KSL_TL,(63-VOL_SCALE_LOG_BROKEN(63-op.tl,chan[ch].outVol&0x3f,63))|(op.ksl<<6));
if (isMuted[ch]) {
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
} else {
rWrite(baseAddr+ADDR_KSL_TL,(63-VOL_SCALE_LOG_BROKEN(63-op.tl,chan[ch].outVol&0x3f,63))|(op.ksl<<6));
}

rWrite(baseAddr+ADDR_AM_VIB_SUS_KSR_MULT,(op.am<<7)|(op.vib<<6)|(op.sus<<5)|(op.ksr<<4)|op.mult);
rWrite(baseAddr+ADDR_AR_DR,(op.ar<<4)|op.dr);
Expand Down Expand Up @@ -1685,7 +1689,7 @@ void DivPlatformOPL::commitState(int ch, DivInstrument* ins) {
unsigned short baseAddr=slotMap[slot];
DivInstrumentFM::Operator& op=chan[ch].state.op[(ops==4)?orderedOpsL[i]:i];

if (isMuted[ch] && ch<=melodicChans) {
if (isMuted[ch]) {
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
} else {
if (KVSL(ch,i) || ch>melodicChans) {
Expand Down Expand Up @@ -1948,7 +1952,7 @@ int DivPlatformOPL::dispatch(DivCommand c) {
unsigned short baseAddr=slotMap[slot];
DivInstrumentFM::Operator& op=chan[c.chan].state.op[(ops==4)?orderedOpsL[i]:i];

if (isMuted[c.chan] && c.chan<=melodicChans) {
if (isMuted[c.chan]) {
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
} else {
if (KVSL(c.chan,i) || c.chan>melodicChans) {
Expand Down Expand Up @@ -2172,7 +2176,7 @@ int DivPlatformOPL::dispatch(DivCommand c) {
unsigned char slot=slots[c.value][c.chan];
if (slot==255) break;
unsigned short baseAddr=slotMap[slot];
if (isMuted[c.chan] && c.chan<=melodicChans) {
if (isMuted[c.chan]) {
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
} else {
if (KVSL(c.chan,c.value) || c.chan>melodicChans) {
Expand Down Expand Up @@ -2412,7 +2416,7 @@ int DivPlatformOPL::dispatch(DivCommand c) {
unsigned short baseAddr=slotMap[slot];
DivInstrumentFM::Operator& op=chan[c.chan].state.op[(ops==4)?orderedOpsL[i]:i];
op.ksl=c.value2&3;
if (isMuted[c.chan] && c.chan<=melodicChans) {
if (isMuted[c.chan]) {
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
} else {
if (KVSL(c.chan,i) || c.chan>melodicChans) {
Expand All @@ -2429,7 +2433,7 @@ int DivPlatformOPL::dispatch(DivCommand c) {
unsigned char slot=slots[c.value][c.chan];
if (slot==255) break;
unsigned short baseAddr=slotMap[slot];
if (isMuted[c.chan] && c.chan<=melodicChans) {
if (isMuted[c.chan]) {
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
} else {
if (KVSL(c.chan,c.value) || c.chan>melodicChans) {
Expand Down Expand Up @@ -2619,7 +2623,7 @@ void DivPlatformOPL::forceIns() {
unsigned short baseAddr=slotMap[slot];
DivInstrumentFM::Operator& op=chan[i].state.op[(ops==4)?orderedOpsL[j]:j];
if (isMuted[i] && c.chan<=melodicChans) {
if (isMuted[i]) {
rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6));
} else {
if (KVSL(i,j) || i>melodicChans) {
Expand Down

0 comments on commit 192be95

Please sign in to comment.