From 86f3a897f12938d842c48cd6a636ece5415d0a57 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Wed, 2 Jun 2021 02:44:32 -0500 Subject: [PATCH] feat(egui): add timer window --- src/bus.rs | 4 ++++ src/gui.rs | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/bus.rs b/src/bus.rs index e37fb6c..adb19fd 100644 --- a/src/bus.rs +++ b/src/bus.rs @@ -72,6 +72,10 @@ impl Bus { self.timer.step(cycles); self.sound.step(cycles); } + + pub fn timer(&self) -> Timer { + self.timer + } } impl Bus { diff --git a/src/gui.rs b/src/gui.rs index f7b8087..06daaec 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -143,6 +143,30 @@ impl Egui { }); }); + egui::Window::new("Timer").show(ctx, |ui| { + let timer = game_boy.bus.timer(); + + ui.horizontal(|ui| { + ui.label("DIV"); + ui.monospace(format!("{:#06X}", timer.divider)); + }); + + ui.horizontal(|ui| { + ui.label("TIMA"); + ui.monospace(format!("{:#04X}", timer.counter)); + }); + + ui.horizontal(|ui| { + ui.label("TMA"); + ui.monospace(format!("{:#04X}", timer.modulo)); + }); + + ui.horizontal(|ui| { + ui.label("TAC"); + ui.monospace(format!("{:?}", timer.control)); + }); + }); + egui::Window::new("Registers") .open(&mut self.show_registers) .show(ctx, |ui| {