Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions web/src/emulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub struct Emulator {
emulator: GameBoyEmulator,
ops: GameBoyOps<EguiBackRenderer, CpalSoundStream, WebStorage>,
underclocker: Underclocker,
running: bool,
}

impl Emulator {
Expand All @@ -72,6 +73,7 @@ impl Emulator {
emulator,
ops,
underclocker,
running: false,
}
}

Expand All @@ -83,6 +85,7 @@ impl Emulator {
self.ops.plug_in_joy_pad(ControllerJoyPad::new());
self.underclocker =
Underclocker::new(self.emulator.elapsed_cycles(), self.ops.clock_speed_hz);
self.running = true;
}

pub fn loaded_rom(&self) -> Option<&str> {
Expand All @@ -102,6 +105,10 @@ impl Emulator {
}

pub fn tick(&mut self) -> i32 {
if !self.running {
return 0;
}

for _ in 0..SLEEP_INPUT_TICKS {
self.emulator.tick(&mut self.ops);
}
Expand Down
Loading