From 184e4c33418878d837bbea68bf7211cf9451d12f Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Sun, 19 Feb 2023 09:23:28 +1100 Subject: [PATCH] back to clock cycles for now --- src/processor/memory/mmio/apu.rs | 6 +++--- src/processor/memory/mmio/apu/channels.rs | 3 +-- src/processor/timer.rs | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/processor/memory/mmio/apu.rs b/src/processor/memory/mmio/apu.rs index fc31530..53281f4 100644 --- a/src/processor/memory/mmio/apu.rs +++ b/src/processor/memory/mmio/apu.rs @@ -108,8 +108,8 @@ impl Default for Apu { let config = config.config(); let converter = Samplerate::new( - ConverterType::Linear, - CLOCK_SPEED as u32 / 4, + ConverterType::SincBestQuality, + CLOCK_SPEED as u32, config.sample_rate.0, 2, ) @@ -133,7 +133,7 @@ impl Default for Apu { } } -const CYCLES_PER_FRAME: usize = 70224 / 4; +const CYCLES_PER_FRAME: usize = 70224; impl Apu { pub fn init(&mut self) { diff --git a/src/processor/memory/mmio/apu/channels.rs b/src/processor/memory/mmio/apu/channels.rs index 35d491b..e167af9 100644 --- a/src/processor/memory/mmio/apu/channels.rs +++ b/src/processor/memory/mmio/apu/channels.rs @@ -266,8 +266,7 @@ impl PwmChannel { } fn set_wave_timer(wavelength: u16) -> u16 { - 2048 - wavelength - // (2048 - wavelength) * 4 + (2048 - wavelength) * 4 } pub(super) struct WaveChannel { diff --git a/src/processor/timer.rs b/src/processor/timer.rs index 6358c0b..fcce700 100644 --- a/src/processor/timer.rs +++ b/src/processor/timer.rs @@ -28,7 +28,7 @@ impl Cpu { let clock_cycles = (machine_cycles as usize) * 4; self.advance_gpu_clock(clock_cycles); - self.advance_apu_clock(machine_cycles as usize); + self.advance_apu_clock(clock_cycles); self.timers.div_counter += clock_cycles; let mut div_diff = (self.timers.div_counter / 256) as u8;