diff --git a/src/engine/platform/ay.cpp b/src/engine/platform/ay.cpp index 602fada4..41fd89ec 100644 --- a/src/engine/platform/ay.cpp +++ b/src/engine/platform/ay.cpp @@ -61,8 +61,12 @@ void DivPlatformAY8910::tick() { rWrite(0x06,31-chan[i].std.duty); } if (chan[i].std.hadWave) { - chan[i].psgMode&=4; - chan[i].psgMode|=(chan[i].std.wave+1)&3; + chan[i].psgMode=(chan[i].std.wave+1)&7; + if (isMuted[i]) { + rWrite(0x08+i,0); + } else { + rWrite(0x08+i,(chan[i].outVol&15)|((chan[i].psgMode&4)<<2)); + } } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); @@ -197,6 +201,11 @@ int DivPlatformAY8910::dispatch(DivCommand c) { } case DIV_CMD_STD_NOISE_MODE: chan[c.chan].psgMode=(c.value+1)&7; + if (isMuted[c.chan]) { + rWrite(0x08+c.chan,0); + } else if (chan[c.chan].active) { + rWrite(0x08+c.chan,(chan[c.chan].outVol&15)|((chan[c.chan].psgMode&4)<<2)); + } break; case DIV_CMD_STD_NOISE_FREQ: rWrite(0x06,31-c.value); diff --git a/src/engine/platform/ay8930.cpp b/src/engine/platform/ay8930.cpp index 77ebf64c..18417056 100644 --- a/src/engine/platform/ay8930.cpp +++ b/src/engine/platform/ay8930.cpp @@ -82,8 +82,12 @@ void DivPlatformAY8930::tick() { rWrite(0x06,chan[i].std.duty); } if (chan[i].std.hadWave) { - chan[i].psgMode&=4; - chan[i].psgMode|=(chan[i].std.wave+1)&3; + chan[i].psgMode=(chan[i].std.wave+1)&7; + if (isMuted[i]) { + rWrite(0x08+i,0); + } else { + rWrite(0x08+i,(chan[i].outVol&31)|((chan[i].psgMode&4)<<3)); + } } if (chan[i].std.hadEx1) { // duty rWrite(0x16+i,chan[i].std.ex1); @@ -225,6 +229,11 @@ int DivPlatformAY8930::dispatch(DivCommand c) { case DIV_CMD_STD_NOISE_MODE: if (c.value<0x10) { chan[c.chan].psgMode=(c.value+1)&7; + if (isMuted[c.chan]) { + rWrite(0x08+c.chan,0); + } else if (chan[c.chan].active) { + rWrite(0x08+c.chan,(chan[c.chan].outVol&31)|((chan[c.chan].psgMode&4)<<3)); + } } else { chan[c.chan].duty=c.value&15; immWrite(0x16,chan[c.chan].duty); diff --git a/src/engine/platform/ym2610.cpp b/src/engine/platform/ym2610.cpp index 04be3485..f0f13d57 100644 --- a/src/engine/platform/ym2610.cpp +++ b/src/engine/platform/ym2610.cpp @@ -71,8 +71,12 @@ void DivPlatformYM2610::tick() { rWrite(0x06,31-chan[i].std.duty); } if (chan[i].std.hadWave) { - chan[i].psgMode&=4; - chan[i].psgMode|=(chan[i].std.wave+1)&3; + chan[i].psgMode=(chan[i].std.wave+1)&7; + if (isMuted[i]) { + rWrite(0x04+i,0); + } else { + rWrite(0x04+i,(chan[i].outVol&15)|((chan[i].psgMode&4)<<2)); + } } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); @@ -450,7 +454,13 @@ int DivPlatformYM2610::dispatch(DivCommand c) { break; } case DIV_CMD_STD_NOISE_MODE: + if (c.chan<4 || c.chan>6) break; chan[c.chan].psgMode=(c.value+1)&7; + if (isMuted[c.chan]) { + rWrite(0x04+c.chan,0); + } else if (chan[c.chan].active) { + rWrite(0x04+c.chan,(chan[c.chan].outVol&15)|((chan[c.chan].psgMode&4)<<2)); + } break; case DIV_CMD_STD_NOISE_FREQ: if (c.chan<4 || c.chan>6) break;