diff --git a/src/apu.rs b/src/apu.rs index 1b94377..9c76f76 100644 --- a/src/apu.rs +++ b/src/apu.rs @@ -101,8 +101,6 @@ impl Apu { if self.falling_edge(12, div) { use FrameSequencerState::*; - self.sequencer.next(); - match self.sequencer.state() { Length => self.handle_length(), LengthAndSweep => { @@ -112,6 +110,8 @@ impl Apu { Envelope => self.handle_envelope(), Nothing => {} } + + self.sequencer.next(); } self.div_prev = Some(div); diff --git a/src/apu/types.rs b/src/apu/types.rs index 7a36f3d..01a8016 100644 --- a/src/apu/types.rs +++ b/src/apu/types.rs @@ -531,13 +531,9 @@ pub(super) mod fs { self.step = (self.step + 1) % 8; self.state = match self.step { - 0 => Length, - 1 => Nothing, - 2 => LengthAndSweep, - 3 => Nothing, - 4 => Length, - 5 => Nothing, - 6 => LengthAndSweep, + 1 | 3 | 5 => Nothing, + 0 | 4 => Length, + 2 | 6 => LengthAndSweep, 7 => Envelope, _ => unreachable!("Step {} is invalid for the Frame Sequencer", self.step), };