From 1e27875dc300c7eac6ec60899095d0e7595af229 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Wed, 14 Jul 2021 21:15:52 -0500 Subject: [PATCH] fix(cpu): fix timing issue involving when the bus is clocked --- src/cpu.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cpu.rs b/src/cpu.rs index 8e821d2..2e0db76 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -122,15 +122,15 @@ impl Cpu { } }; - // FIXME: Regression, this is not a proper fix, - // the FIFO behaves weirdly using this code + // TODO: With how we currently handle audio + // this --while being correct-- incurs a performance penalty + // as our emu is audio-bound. + let mut elapsed = 0x00; let pending: u32 = cycles.into(); - let mut offset = 0; - for _ in 0..(pending + offset) { + while elapsed < pending { if !self.bus.is_mpsc_still_full() { self.bus.clock(); - } else { - offset += 1; + elapsed += 1; } }