more roms to play with

egui now renders the video correctly
This commit is contained in:
2024-10-12 14:16:14 -04:00
parent 6be443fa2b
commit 683b0fc51a
7 changed files with 35 additions and 21 deletions
+5 -4
View File
@@ -19,13 +19,14 @@ fn main() -> eframe::Result {
eframe::run_simple_native("EGUI Emma", options, move |ctx, _frame| {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("EGUI Gemma");
GemmaEguiSupport::controls_view(&mut computer, &mut state, ui);
if state.display_video {
GemmaEguiSupport::video_view(&computer, ui);
}
ui.heading("EGUI Gemma");
GemmaEguiSupport::controls_view(&mut computer, &mut state, ui);
if state.display_memory {
GemmaEguiSupport::memory_view(&computer, &mut state, ui);
}
+10 -10
View File
@@ -1,6 +1,8 @@
use std::fs::read_dir;
use std::ops::Index;
use std::path::{Display, PathBuf};
use std::thread;
use std::time::Duration;
use egui::{Align, Color32, ComboBox, Direction, Pos2};
use egui::Rect;
use egui::Vec2;
@@ -90,11 +92,10 @@ impl GemmaEguiSupport {
}
pub fn video_view(system: &Chip8Computer, ui: &mut Ui) {
ui.label("Video goes here");
let (resp, painter) = ui.allocate_painter(Vec2::new(400.0, 500.0), egui::Sense::hover());
for current_row in 0..64 {
for current_col in 0..32 {
let data_offset = current_row * 32 + current_col;
let (_resp, painter) = ui.allocate_painter(Vec2::new(350.0, 165.0), egui::Sense::hover());
for current_row in 0..32 {
for current_col in 0..64 {
let data_offset = current_row * 64 + current_col;
let x_offset = current_col as f32 * CELL_WIDTH;
let y_offset = current_row as f32 * CELL_HEIGHT;
let origin = Pos2::new(x_offset, y_offset);
@@ -105,13 +106,12 @@ impl GemmaEguiSupport {
};
let rect = Rect::from_min_size(origin, Vec2::new(CELL_WIDTH, CELL_HEIGHT));
painter.rect_filled(rect, 0.0, colour);
// println!("DataOffset: [{:04x}] X_Offset: [{:04x}] Y_Offset: [{:04x}] Origin: [{:04x}]x[{:04x}]",
// data_offset as u16,
// x_offset as u16,
// y_offset as u16,
// origin.x as u16, origin.y as u16);
// println!("Cell {current_col}x{current_row} at {}x{} -> {}",
// origin.x, origin.y,
// system.video_memory.peek(data_offset));
}
}
// thread::sleep(Duration::from_secs(1));
}
pub fn memory_view(system: &Chip8Computer, gui_state: &mut GemmaEGuiState, ui: &mut Ui) {