Skip to content

Commit

Permalink
Virtual Boy: handle phase reset first
Browse files Browse the repository at this point in the history
  • Loading branch information
tildearrow committed Feb 21, 2025
1 parent 0b1e90b commit 41d3dcd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/engine/platform/vb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 41d3dcd

Please sign in to comment.