From fd7f0655ef004cb2222aa761896b45701b0d25a5 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sun, 27 Jun 2021 20:31:59 -0500 Subject: [PATCH] chore: satisfy clippy --- src/emu.rs | 4 ++-- src/sound.rs | 56 ++++++++++++++++++++++------------------------------ 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/emu.rs b/src/emu.rs index 84d1493..c75d6c2 100644 --- a/src/emu.rs +++ b/src/emu.rs @@ -8,8 +8,8 @@ use std::time::Duration; pub const SM83_CYCLE_TIME: Duration = Duration::from_nanos(1_000_000_000 / SM83_CLOCK_SPEED); pub const CYCLES_IN_FRAME: Cycle = Cycle::new(456 * 154); // 456 Cycles times 154 scanlines -const SM83_CLOCK_SPEED: u64 = 0x400_000; // Hz which is 4.194304Mhz -const DEFAULT_TITLE: &'static str = "DMG-01 Emulator"; +const SM83_CLOCK_SPEED: u64 = 0x40_0000; // Hz which is 4.194304Mhz +const DEFAULT_TITLE: &str = "DMG-01 Emulator"; pub fn init(boot_path: Option<&str>, rom_path: &str) -> Result { let mut cpu = match boot_path { diff --git a/src/sound.rs b/src/sound.rs index 3ab9299..1f56171 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -52,51 +52,43 @@ impl Sound { } fn handle_length(&mut self) { - if self.ch1.freq_hi.idk() { - if self.ch1.length_timer > 0 { - self.ch1.length_timer -= 1; + if self.ch1.freq_hi.idk() && self.ch1.length_timer > 0 { + self.ch1.length_timer -= 1; - // Check in this scope ensures (only) the above subtraction - // made length_timer 0 - if self.ch1.length_timer == 0 { - todo!("Disable Channel 1 until next trigger event"); - } + // Check in this scope ensures (only) the above subtraction + // made length_timer 0 + if self.ch1.length_timer == 0 { + todo!("Disable Channel 1 until next trigger event"); } } - if self.ch2.freq_hi.idk() { - if self.ch2.length_timer > 0 { - self.ch2.length_timer -= 1; + if self.ch2.freq_hi.idk() && self.ch2.length_timer > 0 { + self.ch2.length_timer -= 1; - // Check in this scope ensures (only) the above subtraction - // made length_timer 0 - if self.ch2.length_timer == 0 { - todo!("Disable Channel 2 until next trigger event"); - } + // Check in this scope ensures (only) the above subtraction + // made length_timer 0 + if self.ch2.length_timer == 0 { + todo!("Disable Channel 2 until next trigger event"); } } - if self.ch3.freq_hi.idk() { - if self.ch3.length_timer > 0 { - self.ch3.length_timer -= 1; + if self.ch3.freq_hi.idk() && self.ch3.length_timer > 0 { + self.ch3.length_timer -= 1; - // Check in this scope ensures (only) the above subtraction - // made length_timer 0 - if self.ch3.length_timer == 0 { - todo!("Disable Channel 3 until next trigger event"); - } + // Check in this scope ensures (only) the above subtraction + // made length_timer 0 + if self.ch3.length_timer == 0 { + todo!("Disable Channel 3 until next trigger event"); } } - if self.ch4.freq_data.idk() { - if self.ch4.length_timer > 0 { - self.ch4.length_timer -= 1; + if self.ch4.freq_data.idk() && self.ch4.length_timer > 0 { + self.ch4.length_timer -= 1; - // Check in this scope ensures (only) the above subtraction - // made length_timer 0 - if self.ch4.length_timer == 0 { - todo!("Disable Channel 4 until next trigger event"); - } + // Check in this scope ensures (only) the above subtraction + // made length_timer 0 + if self.ch4.length_timer == 0 { + todo!("Disable Channel 4 until next trigger event"); } } }