move tests to unit_tests to clean up individual files
adds start of font characters
This commit is contained in:
@@ -33,6 +33,7 @@ fn main() {
|
||||
|
||||
support::simple_init(file!(), move |_, ui| {
|
||||
let current_time = Instant::now();
|
||||
let mut num_cycles = 0;
|
||||
|
||||
// Key Checks
|
||||
let down_keys = ui.io().keys_down;
|
||||
@@ -58,9 +59,10 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
system.tick();
|
||||
|
||||
|
||||
while Instant::now().duration_since(current_time).as_millis() < 16 && num_cycles < 1000 {
|
||||
system.tick();
|
||||
num_cycles += 1;
|
||||
}
|
||||
// GUI Parts
|
||||
if ui_state.show_video {
|
||||
GemmaImguiSupport::video_display(&system.state(), &ui_state, ui);
|
||||
|
||||
@@ -16,7 +16,7 @@ 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";
|
||||
const ROM_ROOT: &str = "/home/tmerritt/Projects/trevors_chip8_toy/resources/roms";
|
||||
|
||||
pub struct GemmaImguiSupport {}
|
||||
|
||||
@@ -43,23 +43,37 @@ impl GemmaImguiSupport {
|
||||
|
||||
pub fn video_display(system_to_control: &Chip8Computer, gui_state: &ImGuiUiState, ui: &Ui) {
|
||||
// draw area size
|
||||
let (width, height) = system_to_control.video_memory.get_resolution();
|
||||
let draw_area_size = ui.io().display_size;
|
||||
// println!("DRAW_AREA_SIZE = {}x{}", draw_area_size[0], draw_area_size[1]);
|
||||
let cell_width = ((draw_area_size[0] as i32 / 64) * 6) / 10;
|
||||
let cell_height = ((draw_area_size[1] as i32 / 32) * 6) / 10;
|
||||
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 (width, height) = system_to_control.video_memory.get_resolution();
|
||||
let origin = ui.cursor_screen_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 {
|
||||
ui.text("StdDef 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 {
|
||||
@@ -88,7 +102,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("/home/tmerritt/Projects/trevors_chip8_toy/resources/octoroms/"), &gui_state.filename_to_load, ui);
|
||||
let new_filename = GuiFileList::display_path(PathBuf::from("/home/tmerritt/Projects/trevors_chip8_toy/resources/roms/"), &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}");
|
||||
@@ -98,7 +112,7 @@ 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(&("/home/tmerritt/Projects/trevors_chip8_toy/resources/octoroms/".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/roms/".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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user