From 93bbf6743395679dc4821e1f8876a5e71f2bf74c Mon Sep 17 00:00:00 2001 From: John Breaux Date: Sun, 2 Apr 2023 14:48:34 -0500 Subject: [PATCH] cpu.rs: Double max IPF in dynamic timing by only getting the time once --- src/cpu.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cpu.rs b/src/cpu.rs index 3668995..6af16ce 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -507,8 +507,9 @@ impl CPU { }; // Convert the elapsed time to 60ths of a second - let time = self.timers.frame.elapsed().as_secs_f64() * 60.0; - self.timers.frame = Instant::now(); + let frame = Instant::now(); + let time = (frame - self.timers.frame).as_secs_f64() * 60.0; + self.timers.frame = frame; if time > 1.0 { self.flags.draw_wait = false; }