Virtual Boy: handle phase reset first

This commit is contained in:
tildearrow 2025-02-21 18:58:58 -05:00
parent 0b1e90b908
commit 41d3dcde66

View file

@ -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) {