more unit tests working.
imgui drawing directly to background now
This commit is contained in:
@@ -11,7 +11,7 @@ use gemma::chip8::system_memory::Chip8SystemMemory;
|
||||
use crate::ImGuiUiState;
|
||||
use crate::support::gui_file_list::GuiFileList;
|
||||
|
||||
const ROM_ROOT: &str = "/home/tmerritt/Projects/chip8_toy/resources/roms";
|
||||
const ROM_ROOT: &str = "resources/roms";
|
||||
|
||||
pub struct GemmaImguiSupport {}
|
||||
|
||||
@@ -21,7 +21,7 @@ const CELL_HEIGHT: i32 = 5i32;
|
||||
impl GemmaImguiSupport {
|
||||
pub fn keypad_display(system_to_display: &Chip8Computer, ui: &Ui) {
|
||||
ui.window("Keypad".to_string())
|
||||
.size([100.0, 100.0], Condition::FirstUseEver)
|
||||
.position([100.0, 640.0], Condition::FirstUseEver)
|
||||
.build(|| {
|
||||
for row in CHIP8_KEYBOARD {
|
||||
for key in row {
|
||||
@@ -46,53 +46,49 @@ impl GemmaImguiSupport {
|
||||
let cell_width = ((draw_area_size[0] as i32 / width) * 6) / 10;
|
||||
let cell_height = ((draw_area_size[1] as i32 / height) * 6) / 10;
|
||||
|
||||
ui.window(format!("Display {cell_width}x{cell_height}"))
|
||||
.size([300.0, 300.0], Condition::Once)
|
||||
.build(|| {
|
||||
let origin = ui.cursor_pos();
|
||||
let fg = ui.get_window_draw_list();
|
||||
if system_to_control.video_memory.is_highres() {
|
||||
// ui.text("High Def Video here");
|
||||
for current_row in 0..=height {
|
||||
let y_offset = origin[1] as i32 + (current_row * cell_height);
|
||||
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);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for current_row in 0..height {
|
||||
let y_offset = origin[1] as i32 + (current_row * cell_height);
|
||||
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);
|
||||
}
|
||||
let origin = ui.cursor_pos();
|
||||
let fg = ui.get_foreground_draw_list();
|
||||
if system_to_control.video_memory.is_highres() {
|
||||
// ui.text("High Def Video here");
|
||||
for current_row in 0..=height {
|
||||
let y_offset = origin[1] as i32 + (current_row * cell_height);
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for current_row in 0..height {
|
||||
let y_offset = origin[1] as i32 + (current_row * cell_height);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn system_controls(system_to_control: &mut Chip8ComputerManager, gui_state: &mut ImGuiUiState, ui: &Ui) {
|
||||
// let mut state: Chip8Computer = system_to_control;
|
||||
ui.window("!!!! CONTROLS !!!!")
|
||||
.size([345.0, 200.0], Condition::FirstUseEver)
|
||||
.position([100.0, 640.0], Condition::FirstUseEver)
|
||||
.build(|| {
|
||||
/* System Step Counter */
|
||||
ui.text(format!("Step {:04x}", system_to_control.num_cycles()).as_str());
|
||||
@@ -155,7 +151,7 @@ impl GemmaImguiSupport {
|
||||
|
||||
pub fn registers_view(system: &Chip8Computer, ui: &Ui) {
|
||||
ui.window("Registers")
|
||||
.size([400.0, 500.0], Condition::FirstUseEver)
|
||||
.position([100.0, 640.0], Condition::FirstUseEver)
|
||||
.build(|| {
|
||||
ui.text("Registers");
|
||||
for i in 1..0x10 {
|
||||
@@ -179,7 +175,7 @@ impl GemmaImguiSupport {
|
||||
let rows = position.0;
|
||||
let cols = position.1;
|
||||
ui.window("System Memory")
|
||||
.size([400.0, 300.0], Condition::FirstUseEver)
|
||||
.position([100.0, 640.0], Condition::FirstUseEver)
|
||||
.build(|| {
|
||||
let mut current_x_hover: i32 = 0;
|
||||
let mut current_y_hover: i32 = 0;
|
||||
|
||||
@@ -13,6 +13,7 @@ impl GuiFileList {
|
||||
|
||||
let mut known_files: Vec<OsString> = vec![];
|
||||
|
||||
println!("STARTING AT {:?}", std::env::current_dir());
|
||||
for entry in read_dir(root.as_path()).unwrap() {
|
||||
known_files.push(entry.unwrap().file_name());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user