Skip to content

Commit 872eeff

Browse files
committed
OPL: fix some OPL3 chan osc bugs
- 4-op muting being broken - output channel inconsistencies between Nuked-OPL3 and ymfm thanks Forte!
1 parent 314b7d4 commit 872eeff

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/engine/platform/opl.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,10 @@ void DivPlatformOPL::acquire_nuked(short** buf, size_t len) {
270270
if (properDrums) {
271271
for (int i=0; i<melodicChans+1; i++) {
272272
unsigned char ch=outChanMap[i];
273+
unsigned char chMute=(i<12 && chan[i&(~1)].fourOp)?(i^1):i;
273274
int chOut=0;
274275
if (ch==255) continue;
275-
if (isMuted[i]) continue;
276+
if (isMuted[chMute]) continue;
276277
if (fm.channel[i].out[0]!=NULL) {
277278
chOut+=*fm.channel[ch].out[0];
278279
}
@@ -295,9 +296,10 @@ void DivPlatformOPL::acquire_nuked(short** buf, size_t len) {
295296
} else {
296297
for (int i=0; i<chans; i++) {
297298
unsigned char ch=outChanMap[i];
299+
unsigned char chMute=(i<12 && chan[i&(~1)].fourOp)?(i^1):i;
298300
int chOut=0;
299301
if (ch==255) continue;
300-
if (isMuted[i]) continue;
302+
if (isMuted[chMute]) continue;
301303
if (fm.channel[i].out[0]!=NULL) {
302304
chOut+=*fm.channel[ch].out[0];
303305
}
@@ -587,8 +589,9 @@ void DivPlatformOPL::acquire_ymfm3(short** buf, size_t len) {
587589
if (properDrums) {
588590
for (int i=0; i<16; i++) {
589591
unsigned char ch=(i<12 && chan[i&(~1)].fourOp)?outChanMap[i^1]:outChanMap[i];
592+
unsigned char chMute=(i<12 && chan[i&(~1)].fourOp)?(i^1):i;
590593
if (ch==255) continue;
591-
if (isMuted[i]) continue;
594+
if (isMuted[chMute]) continue;
592595
int chOut=fmChan[ch]->debug_output(0)+fmChan[ch]->debug_output(1);
593596
if (chOut==0) {
594597
chOut=fmChan[ch]->debug_output(2);
@@ -608,9 +611,10 @@ void DivPlatformOPL::acquire_ymfm3(short** buf, size_t len) {
608611
oscBuf[19]->putSample(h,CLAMP(fmChan[7]->debug_special1()<<1,-32768,32767));
609612
} else {
610613
for (int i=0; i<18; i++) {
611-
unsigned char ch=outChanMap[i];
614+
unsigned char ch=(i<12 && chan[i&(~1)].fourOp)?outChanMap[i^1]:outChanMap[i];
615+
unsigned char chMute=(i<12 && chan[i&(~1)].fourOp)?(i^1):i;
612616
if (ch==255) continue;
613-
if (isMuted[i]) continue;
617+
if (isMuted[chMute]) continue;
614618
int chOut=fmChan[ch]->debug_output(0)+fmChan[ch]->debug_output(1);
615619
if (chOut==0) {
616620
chOut=fmChan[ch]->debug_output(2);
@@ -683,8 +687,9 @@ void DivPlatformOPL::acquire_ymfm4(short** buf, size_t len) {
683687
if (properDrums) {
684688
for (int i=0; i<16; i++) {
685689
unsigned char ch=(i<12 && chan[i&(~1)].fourOp)?outChanMap[i^1]:outChanMap[i];
690+
unsigned char chMute=(i<12 && chan[i&(~1)].fourOp)?(i^1):i;
686691
if (ch==255) continue;
687-
if (isMuted[i]) continue;
692+
if (isMuted[chMute]) continue;
688693
int chOut=fmChan[ch]->debug_output(0);
689694
if (chOut==0) {
690695
chOut=fmChan[ch]->debug_output(1);
@@ -707,9 +712,10 @@ void DivPlatformOPL::acquire_ymfm4(short** buf, size_t len) {
707712
oscBuf[19]->putSample(h,CLAMP(fmChan[7]->debug_special1()<<1,-32768,32767));
708713
} else {
709714
for (int i=0; i<18; i++) {
710-
unsigned char ch=outChanMap[i];
715+
unsigned char ch=(i<12 && chan[i&(~1)].fourOp)?outChanMap[i^1]:outChanMap[i];
716+
unsigned char chMute=(i<12 && chan[i&(~1)].fourOp)?(i^1):i;
711717
if (ch==255) continue;
712-
if (isMuted[i]) continue;
718+
if (isMuted[chMute]) continue;
713719
int chOut=fmChan[ch]->debug_output(0);
714720
if (chOut==0) {
715721
chOut=fmChan[ch]->debug_output(1);
@@ -1019,7 +1025,8 @@ void DivPlatformOPL::acquire_nukedLLE3(short** buf, size_t len) {
10191025
}
10201026

10211027
for (int i=0; i<20; i++) {
1022-
if (isMuted[i]) continue;
1028+
unsigned char chMute=(i<12 && chan[i&(~1)].fourOp)?(i^1):i;
1029+
if (isMuted[chMute]) continue;
10231030
if (chOut[i]<-32768) chOut[i]=-32768;
10241031
if (chOut[i]>32767) chOut[i]=32767;
10251032
oscBuf[i]->putSample(h,chOut[i]);

0 commit comments

Comments
 (0)