diff --git a/src/engine/platform/vb.cpp b/src/engine/platform/vb.cpp index 1f6744f4e..75529e644 100644 --- a/src/engine/platform/vb.cpp +++ b/src/engine/platform/vb.cpp @@ -152,6 +152,14 @@ void DivPlatformVB::tick(bool sysTick) { } chan[i].std.next(); + // this is handled first to work around an envelope problem + // once envelope is over, you cannot enable it again unless you retrigger the channel + if (chan[i].std.phaseReset.had && chan[i].std.phaseReset.val==1) { + chWrite(i,0x00,0x80); + chan[i].intWritten=true; + chan[i].antiClickWavePos=0; + chan[i].antiClickPeriodCount=0; + } if (chan[i].std.vol.had) { chan[i].outVol=VOL_SCALE_LINEAR(chan[i].vol&15,MIN(15,chan[i].std.vol.val),15); writeEnv(i); @@ -201,12 +209,6 @@ void DivPlatformVB::tick(bool sysTick) { } chan[i].freqChanged=true; } - if (chan[i].std.phaseReset.had && chan[i].std.phaseReset.val==1) { - chWrite(i,0x00,0x80); - chan[i].intWritten=true; - chan[i].antiClickWavePos=0; - chan[i].antiClickPeriodCount=0; - } if (chan[i].active) { if (chan[i].ws.tick() || (chan[i].std.phaseReset.had && chan[i].std.phaseReset.val==1)) { if (!romMode) {