diff --git a/README.md b/README.md index 911a0f3..ec9c8ab 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Repository for emulation of old game systems and other old computing systems - [ ] Support for more controller types - [x] Full support for controllers 3 and 4 - [x] Implement battery backed cartridge ram -- [ ] Network play +- [x] Network play - [ ] More mapper support - [x] Rewind support - [x] Recording support @@ -16,7 +16,7 @@ Repository for emulation of old game systems and other old computing systems - [x] wix installer for windows - [ ] Add a list of instructions to the debugger - [x] Create link to recordings folder -- [ ] Slow motion +- [x] Slow motion - [x] Rom ranking system - [x] Game genie code support - [x] Full screen support diff --git a/nes/rust/src/motherboard.rs b/nes/rust/src/motherboard.rs index 7ead46a..7dd9fe2 100644 --- a/nes/rust/src/motherboard.rs +++ b/nes/rust/src/motherboard.rs @@ -34,6 +34,8 @@ pub struct NesMotherboard { #[serde(skip)] /// The controllers for the system controllers: [NesController; 2], + /// The speed ratio applied to the emulator + pub speed_ratio: f32, } impl NesMotherboard { @@ -64,6 +66,7 @@ impl NesMotherboard { last_cpu_data: 0, last_ppu_coordinates: (0, 0), controllers: [NesController::default(), NesController::default()], + speed_ratio: 1.0, } } diff --git a/nes/rust/src/windows/genie.rs b/nes/rust/src/windows/genie.rs index 2658a5d..2b47e01 100644 --- a/nes/rust/src/windows/genie.rs +++ b/nes/rust/src/windows/genie.rs @@ -6,7 +6,7 @@ use crate::NesEmulatorData; use eframe::egui; #[cfg(feature = "egui-multiwin")] -use egui_multiwin::{arboard, egui, egui_glow::EguiGlow}; +use egui_multiwin::{arboard, egui_glow::EguiGlow}; #[cfg(feature = "egui-multiwin")] use crate::egui_multiwin_dynamic::{ diff --git a/nes/rust/src/windows/main.rs b/nes/rust/src/windows/main.rs index 56549f5..c6fedd9 100644 --- a/nes/rust/src/windows/main.rs +++ b/nes/rust/src/windows/main.rs @@ -365,7 +365,8 @@ impl TrackedWindow for MainNesWindow { c.mb.get_controller_mut(2).rapid_fire(frame_time); c.mb.get_controller_mut(3).rapid_fire(frame_time); - let emulator_frame = std::time::Duration::from_nanos(1_000_000_000u64 / 60); + let nanos = 1_000_000_000.0 / (60.0 * c.mb.speed_ratio); + let emulator_frame = std::time::Duration::from_nanos(nanos as u64); let mut render = false; self.emulator_time += frame_time; while self.emulator_time > emulator_frame { @@ -774,6 +775,17 @@ impl TrackedWindow for MainNesWindow { rewind_state = true; } + if egui + .egui_ctx + .input(|i| i.key_pressed(egui_multiwin::egui::Key::F11)) + { + if c.mb.speed_ratio < 1.0 { + c.mb.speed_ratio = 1.0; + } else { + c.mb.speed_ratio = 0.5; + } + } + if egui .egui_ctx .input(|i| i.key_pressed(egui_multiwin::egui::Key::F12))