From ea357be47755e6e1cc5f481454e681e698a4bbc6 Mon Sep 17 00:00:00 2001 From: John Breaux Date: Sat, 29 Apr 2023 18:20:49 -0500 Subject: [PATCH] Monotonic: This flag is being deprecated soon, switch it for bool --- src/bin/chirp-minifb/main.rs | 1 - src/cpu.rs | 4 ++-- src/cpu/flags.rs | 4 ++-- src/cpu/tests.rs | 5 ++--- tests/integration.rs | 1 - 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/bin/chirp-minifb/main.rs b/src/bin/chirp-minifb/main.rs index f1d51c7..0e6741d 100644 --- a/src/bin/chirp-minifb/main.rs +++ b/src/bin/chirp-minifb/main.rs @@ -145,7 +145,6 @@ impl State { quirks: options.mode.unwrap_or_default().into(), debug: options.debug, pause: options.pause, - monotonic: options.speed, ..Default::default() }, )?, diff --git a/src/cpu.rs b/src/cpu.rs index 7c2ba9c..2539f22 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -451,7 +451,7 @@ impl CPU { /// # use chirp::error::Error; /// let mut cpu = CPU::default(); /// # cpu.flags.debug = true; // enable live disassembly - /// # cpu.flags.monotonic = Some(8); // enable monotonic/test timing + /// # cpu.flags.monotonic = true; // enable monotonic/test timing /// let mut bus = bus!{ /// Program [0x0200..0x0f00] = &[ /// 0xff, 0xff, // invalid! @@ -466,7 +466,7 @@ impl CPU { // Do nothing if paused if self.flags.is_paused() { // always tick in test mode - if self.flags.monotonic.is_some() { + if self.flags.monotonic { self.cycle += 1; } return Ok(self); diff --git a/src/cpu/flags.rs b/src/cpu/flags.rs index 7bb1fd5..a8748ab 100644 --- a/src/cpu/flags.rs +++ b/src/cpu/flags.rs @@ -23,8 +23,8 @@ pub struct Flags { pub mode: Mode, /// Represents the set of emulator [Quirks] to enable, independent of the [Mode] pub quirks: Quirks, - /// Represents the number of instructions to run per tick of the internal timer - pub monotonic: Option, + /// Set when the interpreter should increase the cycle count during a pause + pub monotonic: bool, } impl Flags { diff --git a/src/cpu/tests.rs b/src/cpu/tests.rs index e7f9a80..4f13510 100644 --- a/src/cpu/tests.rs +++ b/src/cpu/tests.rs @@ -27,7 +27,6 @@ fn setup_environment() -> (CPU, Bus) { flags: Flags { debug: true, pause: false, - monotonic: Some(8), ..Default::default() }, ..CPU::default() @@ -1076,8 +1075,8 @@ mod behavior { #[test] fn delay() { let (mut cpu, mut bus) = setup_environment(); - cpu.flags.monotonic = None; cpu.delay = 10.0; + cpu.flags.monotonic = false; for _ in 0..2 { cpu.multistep(&mut bus, 8) .expect("Running valid instructions should always succeed"); @@ -1102,7 +1101,7 @@ mod behavior { #[test] fn vbi_wait() { let (mut cpu, mut bus) = setup_environment(); - cpu.flags.monotonic = None; // disable monotonic timing + cpu.flags.monotonic = false; // disable monotonic timing cpu.flags.draw_wait = true; for _ in 0..2 { cpu.multistep(&mut bus, 8) diff --git a/tests/integration.rs b/tests/integration.rs index ad46355..e908060 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -133,7 +133,6 @@ mod cpu { pause: false, keypause: false, draw_wait: false, - monotonic: None, ..Default::default() }; let cf2 = cf1.clone();