diff --git a/gemma/tests/computer_tests.rs b/gemma/tests/computer_tests.rs index 73c6dbe..f0035f9 100644 --- a/gemma/tests/computer_tests.rs +++ b/gemma/tests/computer_tests.rs @@ -6,4 +6,11 @@ fn smoke() { assert!(true) } #[test] fn test_rom_1_works() { let mut x = Chip8Computer::new(); + // Load the IBM rom and run it... + + // ...then verify that the current video memory of the chip-8 + // simulator matches what we expect it to be + + assert_eq!(x.dump_video_to_string(), ); + } diff --git a/gemmaimgui/src/bin/gemmaimgui.rs b/gemmaimgui/src/bin/gemmaimgui.rs index cc8c48f..24b2324 100644 --- a/gemmaimgui/src/bin/gemmaimgui.rs +++ b/gemmaimgui/src/bin/gemmaimgui.rs @@ -10,6 +10,7 @@ use sys::{ImColor, ImVec2, ImVector_ImU32}; use rand::random; use gemma::chip8::system_memory::Chip8SystemMemory; use support::emmagui_support::EmmaGui; + mod support; struct UiState { @@ -17,10 +18,10 @@ struct UiState { pub show_memory: bool, pub show_video: bool, pub filename_to_load: String, - pub on_colour: ImColor32, - pub off_colour: ImColor32, + pub on_colour: ImColor32, + pub off_colour: ImColor32, pub is_running: bool, - pub frame_time: f32 + pub frame_time: f32, } impl Clone for UiState { @@ -33,7 +34,7 @@ impl Clone for UiState { on_colour: self.on_colour, off_colour: self.off_colour, is_running: self.is_running, - frame_time: self.frame_time + frame_time: self.frame_time, } } } @@ -48,7 +49,7 @@ impl Default for UiState { on_colour: ImColor32::from_rgb(0xff, 0xff, 0x00), off_colour: ImColor32::from_rgb(0x00, 0xff, 0xff), is_running: false, - frame_time: 10.0 + frame_time: 10.0, } } } diff --git a/gemmaimgui/src/bin/support/emmagui_support.rs b/gemmaimgui/src/bin/support/emmagui_support.rs index e71281f..7b11fb7 100644 --- a/gemmaimgui/src/bin/support/emmagui_support.rs +++ b/gemmaimgui/src/bin/support/emmagui_support.rs @@ -10,7 +10,6 @@ use gemma::chip8::system_memory::Chip8SystemMemory; use gemma::constants::{CHIP8_VIDEO_HEIGHT, CHIP8_VIDEO_WIDTH}; use crate::UiState; - pub struct EmmaGui {} const CELL_WIDTH: i32 = 5i32; @@ -78,13 +77,13 @@ impl EmmaGui { let new_filename = GuiFileList::display_path(PathBuf::from("resources/roms"), &gui_state.filename_to_load, ui); if !new_filename.is_empty() { if new_filename != gui_state.filename_to_load { - println!("NEW FILENAME SELECTED -> {new_filename}"); + debug!("NEW FILENAME SELECTED -> {new_filename}"); gui_state.filename_to_load = new_filename; } if ui.button("Load Program") { let mut buffer = Vec::new(); - println!("PREPARING TO LOAD {}", gui_state.filename_to_load); + 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"); input_file.read_to_end(&mut buffer).expect("unable to read file"); @@ -97,26 +96,26 @@ impl EmmaGui { }; if ui.button("Run") { gui_state.is_running = true; - println!("STARTING THE SYSTEM"); + debug!("STARTING THE SYSTEM"); } if ui.button("Stop") { gui_state.is_running = false; - println!("STOPPING THE SYSTEM"); + debug!("STOPPING THE SYSTEM"); } ui.same_line(); if ui.button("Reset") { *system_to_control = Chip8Computer::new(); } if ui.button("Dump Video Memory") { - println!("{}", system_to_control.dump_video_to_string()); + debug!("{}", system_to_control.dump_video_to_string()); } ui.same_line(); if ui.button("Dump Keypad State") { - println!("{}", system_to_control.dump_keypad_to_string()); + debug!("{}", system_to_control.dump_keypad_to_string()); } ui.same_line(); if ui.button("Dump Registers") { - println!("{}", system_to_control.dump_registers_to_string()); + debug!("{}", system_to_control.dump_registers_to_string()); } ui.separator(); @@ -193,7 +192,7 @@ impl EmmaGui { // Check if the left mouse button is clicked while hovering over the text if ui.is_mouse_clicked(imgui::MouseButton::Left) { - println!("Offset: [{}] [0x{:02x}] Value: [{}]", data_offset, data_offset, formatted_text.clone()); + debug!("Offset: [{}] [0x{:02x}] Value: [{}]", data_offset, data_offset, formatted_text.clone()); // Perform any action here, e.g., call a function, trigger an event, etc. } } diff --git a/resources/test/gemma_integration_ibm_rom_output.asc b/resources/test/gemma_integration_ibm_rom_output.asc new file mode 100644 index 0000000..f66cb76 --- /dev/null +++ b/resources/test/gemma_integration_ibm_rom_output.asc @@ -0,0 +1,32 @@ + + + + + + + + + ******** ********* ***** ***** * * + * * + ******** *********** ****** ****** * + + **** *** *** ***** ***** * * + *** + **** ******* ******* ******* * + * + **** ******* *** ******* *** + * + **** *** *** *** ***** *** + *** + ******** *********** ***** *** ***** * + ** + ******** ********* ***** * ***** *** + + + + + + + + +