richer test suite
Updates imgui to have target ips and limits correctly.
Initial IPS = 1000, plan to expose to user
More tests for encode/decode of instructions
Adding text to instruction parsing
This commit is contained in:
2024-10-28 14:42:14 -04:00
parent 1694157e27
commit b492eb5f49
25 changed files with 1347 additions and 239 deletions
+1
View File
@@ -7,3 +7,4 @@ edition = "2021"
gemma = { path = "../gemma" }
egui.workspace = true
eframe.workspace = true
catppuccin-egui = { version = "5.3.0", default-features = false, features = ["egui29"] }
+10 -1
View File
@@ -58,8 +58,10 @@ fn main() -> eframe::Result {
};
eframe::run_simple_native("EGUI Gemma", options, move |ctx, _frame| {
catppuccin_egui::set_theme(&ctx, catppuccin_egui::MOCHA);
egui::CentralPanel::default().show(ctx, |ui| {
computer.tick();
let frame_start_time = Instant::now();
let local_computer = computer.state();
//if state.display_video {
GemmaEguiSupport::video_view(local_computer, ui);
@@ -116,6 +118,13 @@ fn main() -> eframe::Result {
}
});
// run our target number of ticks in the amount of available time.
let time_consumed = Instant::now().duration_since(frame_start_time).as_millis();
let mut num_ticks = 0;
while num_ticks < 1000 {
computer.tick();
num_ticks += 1;
}
ctx.request_repaint();
});
})
-61
View File
@@ -1,61 +0,0 @@
use egui::Ui;
use gemma::chip8::instructions::Chip8CpuInstructions;
/// GemmaEGui - Viewer
///
///
/// This program lets a user open a CH8 file and it will be decoded
/// as Chip-8 Instructions.
/// Colour variants for instructions show colours for
/// -> Jumps
/// -> Load
/// -> Store
/// -> Timers
/// -> Math (Add, Sub)
/// -> Logic
/// -> Video
fn display_instruction(offset: i32, to_display: &Chip8CpuInstructions, ui: &mut Ui) {
ui.label(format!("{offset:04x} {}", to_display.name()));
ui.label(format!("{}", to_display.operands()));
ui.end_row();
}
fn display_instructions(base_offset: i32, instructions: Vec<Chip8CpuInstructions>, ui: &mut Ui) {
egui::Grid::new("my_grid")
.min_col_width(200.0)
.show(ui, |ui| {
for (index, instruction) in instructions.iter().enumerate() {
display_instruction(base_offset + index as i32, instruction, ui);
}
});
}
fn main() -> eframe::Result {
let mut edit_space: String = String::new();
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([640.0, 480.0]),
..Default::default()
};
eframe::run_simple_native("Gemma - Chip8 Machine Code Viewer", options, move |ctx, frame| {
egui::CentralPanel::default().show(ctx, |ui| {
ui.label("Taxation is Theft");
// file picker
ui.vertical_centered(|ui| {
if ui.button("Load File").clicked() {
println!("Clicked load file");
}
});
ui.label("File Picker Herre");
ui.label("display of file here");
ui.vertical(|ui| {
display_instruction(0x010, &Chip8CpuInstructions::ADDI(0x01), ui);
display_instruction(0x012, &Chip8CpuInstructions::RND(0x01, 0x02), ui);
});
ui.text_edit_multiline(&mut edit_space);
});
})
}