From 962b2af282320e47e23e2e7aed1b2f709584f909 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Fri, 10 Mar 2023 15:26:59 +1100 Subject: [PATCH] get rid of cycle_count --- gb-emu/src/main.rs | 1 - gb-vst/src/lib.rs | 1 - lib/src/lib.rs | 38 ++------------------------------------ 3 files changed, 2 insertions(+), 38 deletions(-) diff --git a/gb-emu/src/main.rs b/gb-emu/src/main.rs index 14d75c7..930a860 100644 --- a/gb-emu/src/main.rs +++ b/gb-emu/src/main.rs @@ -82,7 +82,6 @@ fn main() { bootrom: args.bootrom.map(RomFile::Path), connect_serial: args.connect_serial, verbose: args.verbose, - cycle_count: args.cycle_count, }; let tile_window: Option>> = if args.tile_window { diff --git a/gb-vst/src/lib.rs b/gb-vst/src/lib.rs index 4272a0f..6d68144 100644 --- a/gb-vst/src/lib.rs +++ b/gb-vst/src/lib.rs @@ -125,7 +125,6 @@ impl Plugin for GameboyEmu { bootrom, connect_serial: false, verbose: false, - cycle_count: false, }; if let Some(ref mut vars) = self.vars { diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 10c9b1d..0adeb07 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -29,7 +29,6 @@ pub struct Options { pub bootrom: Option, pub connect_serial: bool, pub verbose: bool, - pub cycle_count: bool, } static mut PAUSE_ENABLED: bool = false; @@ -43,8 +42,6 @@ pub const HEIGHT: usize = 144; pub struct EmulatorCore + Clone> { receiver: Receiver, cpu: Cpu, - cycle_num: usize, - cycle_count: bool, } impl + Clone> EmulatorCore { @@ -110,17 +107,11 @@ impl + Clone> EmulatorCore { ), bootrom_enabled, ), - options.cycle_count, ) } - fn new(receiver: Receiver, cpu: Cpu, cycle_count: bool) -> Self { - Self { - receiver, - cpu, - cycle_num: 0, - cycle_count, - } + fn new(receiver: Receiver, cpu: Cpu) -> Self { + Self { receiver, cpu } } pub fn replace_output(&mut self, new: AudioOutput) { @@ -129,10 +120,6 @@ impl + Clone> EmulatorCore { pub fn run(&mut self) { self.process_messages(); - self.cycle_num += 1; - if self.cycle_count { - self.print_cycles(); - } self.run_cycle(); } @@ -140,16 +127,8 @@ impl + Clone> EmulatorCore { loop { self.process_messages(); for _ in 0..step_size { - self.cycle_num += 1; - if self.cycle_count { - self.print_cycles(); - } self.run_cycle(); } - print!( - " ...{} cycles - press enter to continue\r", - self.cycle_num - ); stdout().flush().unwrap(); pause(); } @@ -183,17 +162,4 @@ impl + Clone> EmulatorCore { } } } - - fn print_cycles(&self) { - if self.cycle_num % 45678 != 0 { - return; - } - let instructions_per_second = 400000; - print!( - "cycle {} - approx {} seconds on real hardware\r", - self.cycle_num, - self.cycle_num / instructions_per_second - ); - stdout().flush().unwrap(); - } }