From cd72a2580fb4651e2b5f22874ecb749cb70208ed Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Fri, 2 Feb 2024 00:06:00 -0500 Subject: [PATCH] Warnings --- src/blip/buffer.rs | 19 +++++++------------ src/components/ppu.rs | 2 +- src/context.rs | 2 +- src/sound/apu.rs | 5 ++++- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/blip/buffer.rs b/src/blip/buffer.rs index 16fe4a3..21349fa 100644 --- a/src/blip/buffer.rs +++ b/src/blip/buffer.rs @@ -1,3 +1,6 @@ +#![allow(unused)] +// TODO: Remove this allow + /// A Rust based re-implementation of blip-buf /// https://code.google.com/p/blip-buf @@ -66,8 +69,6 @@ pub struct BlipBuf { impl BlipBuf { pub fn new(size: usize) -> Self { - assert!(size >= 0); - let blip = Self { factor: TIME_UNIT / BLIP_MAX_RATIO, offset: 0, @@ -92,17 +93,13 @@ impl BlipBuf { let factor = (TIME_UNIT as f32 * sample_rate as f32 / clock_rate as f32) as u32; self.factor = factor; - assert!(0 <= factor - self.factor && factor - self.factor < 1); - if self.factor < factor { self.factor += 1; } } pub fn clocks_needed(&self, samples: u32) -> u32 { - let mut needed: u32; - - assert!(samples >= 0 && self.avail + samples as usize <= self.size); + let needed: u32; needed = samples * TIME_UNIT; if needed < self.offset { @@ -130,8 +127,6 @@ impl BlipBuf { } pub fn read_samples(&mut self, out: &mut [i32], count: usize, stereo: bool) -> usize { - assert!(count >= 0); - let mut count = count; if count > self.avail { @@ -174,7 +169,7 @@ impl BlipBuf { { // TODO: Fix this let fixed = (time as f32 * self.factor as f32) as u32 + self.offset; - let mut out = &mut self.samples[self.avail + (fixed >> FRAC_BITS) as usize..].as_mut(); + let out = &mut self.samples[self.avail + (fixed >> FRAC_BITS) as usize..].as_mut(); let phase_shift = FRAC_BITS - PHASE_BITS; let phase: usize = fixed as usize >> phase_shift & (PHASE_COUNT - 1); @@ -202,10 +197,10 @@ impl BlipBuf { out[7] += BL_STEP[PHASE_COUNT - phase][0] * delta + BL_STEP[PHASE_COUNT - phase - 1][0] * delta2; } - pub fn add_delta_fast(&mut self, time: u32, mut delta: i32) + pub fn add_delta_fast(&mut self, time: u32, delta: i32) { let fixed = time * self.factor + self.offset; - let mut out = &mut self.samples[self.avail + (fixed >> FRAC_BITS) as usize..].as_mut(); + let out = &mut self.samples[self.avail + (fixed >> FRAC_BITS) as usize..].as_mut(); let interp = fixed >> (FRAC_BITS - DELTA_BITS) & (DELTA_UNIT - 1); let delta2 = delta * interp as i32; diff --git a/src/components/ppu.rs b/src/components/ppu.rs index 290e338..a0847a0 100644 --- a/src/components/ppu.rs +++ b/src/components/ppu.rs @@ -1,6 +1,6 @@ use crate::components::prelude::*; use crate::config::{Color, Config, Palette}; -use bitflags::{bitflags, Flags}; +use bitflags::bitflags; pub const SCREEN_W: usize = 160; pub const SCREEN_H: usize = 144; diff --git a/src/context.rs b/src/context.rs index 477f8a9..d867b61 100644 --- a/src/context.rs +++ b/src/context.rs @@ -331,7 +331,7 @@ impl Context { self.window.request_redraw(); } - pub fn recalculate_vertex_buffer(size: PhysicalSize) -> [Vertex; 4] { + fn recalculate_vertex_buffer(size: PhysicalSize) -> [Vertex; 4] { let context_aspect = size.width as f32 / size.height as f32; let image_aspect = SCREEN_W as f32 / SCREEN_H as f32; diff --git a/src/sound/apu.rs b/src/sound/apu.rs index ea07779..319af92 100644 --- a/src/sound/apu.rs +++ b/src/sound/apu.rs @@ -1,3 +1,6 @@ +#![allow(unused)] +// TODO: Remove this allow + use crate::components::memory::Memory; use crate::sound::prelude::*; use crate::blip::buffer::BlipBuf; @@ -63,7 +66,7 @@ impl APU { pub fn new(sample_rate: usize) -> Self { let mut blip_buf = BlipBuf::new(sample_rate); blip_buf.set_rates(CLOCK_FREQUENCY, sample_rate as u32); - let mut blip = Blip::new(blip_buf); + let blip = Blip::new(blip_buf); Self { audio_enabled: true,