start of computer integration tests

This commit is contained in:
Trevor Merritt 2024-10-11 08:51:44 -04:00
parent 4fc0bfd3d8
commit 2ef8a78c32
4 changed files with 53 additions and 14 deletions

View File

@ -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(), );
}

View File

@ -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 {
@ -20,7 +21,7 @@ struct UiState {
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,
}
}
}

View File

@ -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.
}
}

View File

@ -0,0 +1,32 @@
******** ********* ***** ***** * *
* *
******** *********** ****** ****** *
**** *** *** ***** ***** * *
***
**** ******* ******* ******* *
*
**** ******* *** ******* ***
*
**** *** *** *** ***** ***
***
******** *********** ***** *** ***** *
**
******** ********* ***** * ***** ***