diff --git a/src/main.rs b/src/main.rs index a46a0ea..a5c6b5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -172,7 +172,7 @@ struct Lsdpack { setlist: &'static [usize], current_ptr: usize, sample_ptr: usize, - repeat_cmd: Option, + repeat_cmd: Option<(LsdpackCmd, bool)>, repeat_cmd_counter: usize, sample_pitch: u16, stopped: bool, @@ -243,10 +243,11 @@ impl Lsdpack { } let mut ongoing = true; while ongoing { - if let Some(cmd) = self.repeat_cmd { + if let Some((cmd, flagged_ongoing)) = self.repeat_cmd { if self.repeat_cmd_counter > 0 { self.repeat_cmd_counter -= 1; - ongoing = self.apply_cmd(cmd); + ongoing = flagged_ongoing; + ongoing &= self.apply_cmd(cmd); continue; } else { self.repeat_cmd = None; @@ -270,7 +271,7 @@ impl Lsdpack { } if cmd & FLAG_REPEAT != 0 { cmd &= !FLAG_REPEAT; - self.repeat_cmd = Some(cmd.into()); + self.repeat_cmd = Some((cmd.into(), ongoing)); self.repeat_cmd_counter = self.next_byte() as usize; } (cmd.into(), ongoing)