CLEANUP: standardizes on pretty_env_logger NEWBIN: Adds gemmarat to use Ratatui as an interface CLEANUP: removes debugging display from computer.rs ENHANCEMENT: Constants for locations of test roms built from environment BUGFIX: SoundTimer was using i32 internally when it needs to be u8 CLEANUP: removes commented code used during diagnostics
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
use ratatui::prelude::*;
|
|
use ratatui::widgets::{Block, Paragraph};
|
|
use ratatui::text::Line;
|
|
|
|
pub struct TimerWidget {
|
|
sound_timer_value: u8,
|
|
delay_timer_value: u8
|
|
}
|
|
|
|
impl TimerWidget {
|
|
pub fn new() -> TimerWidget {
|
|
TimerWidget { sound_timer_value: 0, delay_timer_value: 0 }
|
|
}
|
|
|
|
pub fn with_values(sound: u8, delay: u8) -> TimerWidget {
|
|
TimerWidget {
|
|
sound_timer_value: sound,
|
|
delay_timer_value: delay
|
|
}
|
|
}
|
|
}
|
|
|
|
impl StatefulWidget for TimerWidget {
|
|
type State = TimerWidget;
|
|
|
|
fn render(self, area: Rect, buf: &mut Buffer, state: &mut TimerWidget) {
|
|
let line_1 = Span::raw(format!("Sound Timer: {} [{:02x}]", state.sound_timer_value, state.sound_timer_value));
|
|
let line_2 = Span::raw(format!("Delay Timer: {} [{:02x}]", state.delay_timer_value, state.delay_timer_value));
|
|
|
|
let text = vec![
|
|
Line::from(vec![line_1]),
|
|
Line::from(vec![line_2])
|
|
];
|
|
|
|
let line = Paragraph::new(text)
|
|
.block(Block::bordered().title("Timers"));
|
|
line.render(area, buf);
|
|
}
|
|
}
|