more roms

This commit is contained in:
2024-10-14 12:13:33 -04:00
parent 683b0fc51a
commit 5e290d825b
27 changed files with 64 additions and 47 deletions
+2
View File
@@ -8,6 +8,7 @@ use gemma::{
use imgui::*;
use sys::{ImColor, ImVec2, ImVector_ImU32};
use rand::random;
use gemma::chip8::cpu_states::Chip8CpuStates::WaitingForInstruction;
use gemma::chip8::system_memory::Chip8SystemMemory;
use support::{emmagui_support::GemmaImguiSupport, ui_state::ImGuiUiState};
@@ -42,6 +43,7 @@ fn main() {
for (key_code, key_reg) in LIN_KEYS {
if down_keys[key_code as usize] {
system.keypad.push_key(key_reg);
system.state = WaitingForInstruction;
} else {
// do we need to release it?
if system.keypad.pressed(key_reg) {
+1 -32
View File
@@ -2,7 +2,6 @@ use gemma::constants::CHIP8_KEYBOARD;
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
use std::thread::sleep;
use std::time::Duration;
use imgui::{Condition, ImColor32, Ui};
use log::debug;
@@ -61,7 +60,7 @@ impl GemmaImguiSupport {
pub fn video_display(system_to_control: &Chip8Computer, gui_state: &ImGuiUiState, ui: &Ui) {
// draw area size
let draw_area_size = ui.io().display_size;
println!("DRAW_AREA_SIZE = {}x{}", draw_area_size[0], draw_area_size[1]);
// 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;
@@ -177,7 +176,6 @@ impl GemmaImguiSupport {
let cols = position.1;
ui.window("System Memory")
.size([400.0, 300.0], Condition::FirstUseEver)
.position([500.0, 300.0], Condition::Always)
.build(|| {
let mut current_x_hover: i32 = 0;
let mut current_y_hover: i32 = 0;
@@ -230,33 +228,4 @@ impl GemmaImguiSupport {
});
}
pub fn system_memory_render(memory: Chip8SystemMemory, ui: &Ui) {
ui.window("System Memory")
.size([300.0, 100.0], Condition::FirstUseEver)
.build(|| {
ui.text("Rendering System Memory Here");
let draw_list = ui.get_foreground_draw_list();
let mut idx = 0;
for row in 0..CHIP8_VIDEO_HEIGHT {
for column in 0..CHIP8_VIDEO_WIDTH {
let x_offset = column * CELL_WIDTH;
let y_offset = row * CELL_WIDTH;
let start_point = [x_offset as f32, y_offset as f32];
let end_point = [(x_offset + CELL_WIDTH) as f32,
(y_offset + CELL_HEIGHT) as f32
];
let memory_offset = (row * CHIP8_VIDEO_WIDTH) + column;
let target_color = if memory.peek(memory_offset as u16) == 0 {
ImColor32::BLACK
} else {
ImColor32::WHITE
};
draw_list.add_rect([x_offset as f32, y_offset as f32],
[(x_offset + CELL_WIDTH) as f32, (y_offset + CELL_HEIGHT) as f32],
target_color).build();
idx += 1;
}
}
});
}
}