diff --git a/src/engine/platform/opl.cpp b/src/engine/platform/opl.cpp index 476138143..41e04f9dc 100644 --- a/src/engine/platform/opl.cpp +++ b/src/engine/platform/opl.cpp @@ -1218,11 +1218,12 @@ void DivPlatformOPL::tick(bool sysTick) { memset(weWillWriteRRLater,0,64*sizeof(bool)); + unsigned char opMask=(int)(chan[0].fourOp)|(chan[2].fourOp<<1)|(chan[4].fourOp<<2)|(chan[6].fourOp<<3)|(chan[8].fourOp<<4)|(chan[10].fourOp<<5); + + // write ops which are being enabled if (update4OpMask) { - update4OpMask=false; if (oplType==3) { - unsigned char opMask=(int)(chan[0].fourOp)|(chan[2].fourOp<<1)|(chan[4].fourOp<<2)|(chan[6].fourOp<<3)|(chan[8].fourOp<<4)|(chan[10].fourOp<<5); - immWrite(0x104,opMask); + immWrite(0x104,opMask|oldOpMask); //printf("updating opMask to %.2x\n",opMask); } } @@ -1251,6 +1252,16 @@ void DivPlatformOPL::tick(bool sysTick) { } } + // and now the ones being disabled + if (update4OpMask) { + update4OpMask=false; + if (oplType==3) { + immWrite(0x104,opMask); + //printf("updating opMask to %.2x\n",opMask); + } + oldOpMask=opMask; + } + // update drums if (properDrums) { bool updateDrums=false; @@ -2719,6 +2730,7 @@ void DivPlatformOPL::reset() { while (!writes.empty()) writes.pop(); memset(regPool,0,768); + oldOpMask=0; dacVal=0; dacVal2=0; dacOut=0; diff --git a/src/engine/platform/opl.h b/src/engine/platform/opl.h index 7a6826c5a..e7ea41183 100644 --- a/src/engine/platform/opl.h +++ b/src/engine/platform/opl.h @@ -115,6 +115,7 @@ class DivPlatformOPL: public DivDispatch { bool lastSY; bool waitingBusy; int downsamplerStep; + unsigned char oldOpMask; unsigned char* adpcmBMem; size_t adpcmBMemLen;