scroll down works on CHIP-8 and High-Res modes

scroll left and right work in stdef and hidef
adds octo test roms
adds schip fonts to memory
This commit is contained in:
2024-10-25 08:19:03 -04:00
parent a978ddc41e
commit e29ac45c84
65 changed files with 13342 additions and 230 deletions
+29 -19
View File
@@ -16,6 +16,8 @@ use crate::ImGuiUiState;
use crate::support::gui_file_list::GuiFileList;
use super::ui_state;
const ROM_ROOT: &str = "/home/tmerritt/Projects/trevors_chip8_toy/resources/octoroms";
pub struct GemmaImguiSupport {}
const CELL_WIDTH: i32 = 5i32;
@@ -49,23 +51,30 @@ impl GemmaImguiSupport {
ui.window(format!("Display {cell_width}x{cell_height}"))
.size([300.0, 300.0], Condition::Once)
.build(|| {
let (width, height) = system_to_control.video_memory.get_resolution();
let origin = ui.cursor_screen_pos();
let fg = ui.get_window_draw_list();
ui.text("This is the video display.");
for current_row in 0..=31 {
for current_column in 0..=63 {
let x_offset = origin[0] as i32 + (current_column * cell_width);
if (system_to_control.video_memory.is_highres()) {
ui.text("High Def Video here");
} else {
ui.text("StdDef video here.");
for current_row in 0..=height {
let y_offset = origin[1] as i32 + (current_row * cell_height);
let current_origin = [x_offset as f32, y_offset as f32];
let current_limit = [(x_offset + cell_width) as f32, (y_offset + cell_height) as f32];
let memory_offset = (current_row * 64 + current_column) as u16;
let to_render = system_to_control.video_memory.peek(memory_offset);
let color: ImColor32 = if to_render {
gui_state.on_colour
} else {
gui_state.off_colour
};
fg.add_rect_filled_multicolor(current_origin, current_limit, color, color, color, color);
for current_column in 0..=width {
let x_offset = origin[0] as i32 + (current_column * cell_width);
let current_origin = [x_offset as f32, y_offset as f32];
let current_limit = [(x_offset + cell_width) as f32, (y_offset + cell_height) as f32];
let memory_offset = (current_row * width + current_column) as u16;
let to_render = system_to_control.video_memory.peek(memory_offset);
let color: ImColor32 = if to_render {
gui_state.on_colour
} else {
gui_state.off_colour
};
fg.add_rect_filled_multicolor(current_origin, current_limit, color, color, color, color);
}
}
}
});
@@ -79,7 +88,7 @@ impl GemmaImguiSupport {
ui.text(format!("Step {:04x}", system_to_control.num_cycles()).as_str());
/* ROM Lister */
let new_filename = GuiFileList::display_path(PathBuf::from("resources/roms"), &gui_state.filename_to_load, ui);
let new_filename = GuiFileList::display_path(PathBuf::from("/home/tmerritt/Projects/trevors_chip8_toy/resources/octoroms/"), &gui_state.filename_to_load, ui);
if !new_filename.is_empty() {
if new_filename != gui_state.filename_to_load {
debug!("NEW FILENAME SELECTED -> {new_filename}");
@@ -89,22 +98,23 @@ impl GemmaImguiSupport {
let mut buffer = Vec::new();
debug!("PREPARING TO LOAD {}", gui_state.filename_to_load);
// let mut input_file = File::open(Path::new("./1-chip8-logo.ch8")).expect("put 1-chip8-logo.ch8 in this directory");
let mut input_file = File::open(Path::new(&("resources/roms/".to_string() + &gui_state.filename_to_load))).expect("put 1-chip8-logo.ch8 in this directory");
let mut input_file = File::open(Path::new(&("/home/tmerritt/Projects/trevors_chip8_toy/resources/octoroms/".to_string() + &gui_state.filename_to_load))).expect("put 1-chip8-logo.ch8 in this directory");
input_file.read_to_end(&mut buffer).expect("unable to read file");
system_to_control.load_bytes_to_system_memory((&*buffer).into());
}
}
ui.separator();
if ui.button("Step") {
system_to_control.one_step = true;
system_to_control.step();
};
ui.same_line();
if ui.button("Run") {
system_to_control.core_should_run = true;
system_to_control.start();
}
ui.same_line();
if ui.button("Stop") {
system_to_control.core_should_run = false;
system_to_control.stop();
}
ui.same_line();
if ui.button("Reset") {