37 lines
1.1 KiB
Rust
37 lines
1.1 KiB
Rust
use ratatui::{style::Stylize, widgets::{List, Paragraph}, Frame};
|
|
|
|
use crate::{AppState, Chip8CpuData, CHIP8_REGISTER_COUNT};
|
|
|
|
|
|
pub fn render_cpu_state(cpu_state: Chip8CpuData, frame: &mut Frame) {
|
|
let mut area = frame.area();
|
|
|
|
let mut current_state: Vec<String> = vec![];
|
|
|
|
current_state.push(format!("Delay Timer {:X}", cpu_state.delay_timer));
|
|
current_state.push(format!("Sound Timer {:X}", cpu_state.sound_timer));
|
|
current_state.push(format!("PC {:X}", cpu_state.pc));
|
|
for i in 0 .. CHIP8_REGISTER_COUNT {
|
|
current_state.push(format!("V{}: {}", i, cpu_state.registers[i as usize]));
|
|
}
|
|
|
|
frame.render_widget(
|
|
List::new(current_state).blue().on_white(), area)
|
|
}
|
|
|
|
pub fn render_menu_list(state: AppState, frame: &mut Frame) {
|
|
let mut area = frame.area();
|
|
|
|
frame.render_widget(List::new(state.menu_items).blue().on_white(), area);
|
|
}
|
|
|
|
pub fn render_hello_world(frame: &mut Frame) {
|
|
let area = frame.area();
|
|
frame.render_widget(
|
|
Paragraph::new("Hello Ratatui! (press 'q' to quit)")
|
|
.white()
|
|
.on_blue(),
|
|
area,
|
|
);
|
|
}
|