Skip to content

Commit

Permalink
Add slow motion support with the F11 key.
Browse files Browse the repository at this point in the history
  • Loading branch information
uglyoldbob committed Nov 16, 2023
1 parent 462fc4a commit d961d85
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 3 additions & 0 deletions nes/rust/src/motherboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -64,6 +66,7 @@ impl NesMotherboard {
last_cpu_data: 0,
last_ppu_coordinates: (0, 0),
controllers: [NesController::default(), NesController::default()],
speed_ratio: 1.0,
}
}

Expand Down
2 changes: 1 addition & 1 deletion nes/rust/src/windows/genie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
14 changes: 13 additions & 1 deletion nes/rust/src/windows/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit d961d85

Please sign in to comment.