more roms
This commit is contained in:
parent
683b0fc51a
commit
5e290d825b
@ -96,6 +96,7 @@ impl Chip8Computer {
|
|||||||
Chip8CpuStates::WaitingForInstruction => {
|
Chip8CpuStates::WaitingForInstruction => {
|
||||||
self.sound_timer.tick();
|
self.sound_timer.tick();
|
||||||
self.delay_timer.tick();
|
self.delay_timer.tick();
|
||||||
|
self.video_memory.tick();
|
||||||
}
|
}
|
||||||
Chip8CpuStates::WaitingForKey => {
|
Chip8CpuStates::WaitingForKey => {
|
||||||
println!("waiting for a key press...");
|
println!("waiting for a key press...");
|
||||||
|
|||||||
@ -695,7 +695,7 @@ impl Chip8CpuInstructions {
|
|||||||
|
|
||||||
debug!("PPOOSSTT -> CHIP8CPUINSTRUCTION:DRAWVXNIBBLE -> {}", input.video_memory.format_as_string());
|
debug!("PPOOSSTT -> CHIP8CPUINSTRUCTION:DRAWVXNIBBLE -> {}", input.video_memory.format_as_string());
|
||||||
|
|
||||||
let mut did_change: bool = false;
|
let mut did_change: bool = input.video_memory.has_frame_changed;
|
||||||
|
|
||||||
if did_change {
|
if did_change {
|
||||||
input.registers.poke(0xf, 1u8);
|
input.registers.poke(0xf, 1u8);
|
||||||
|
|||||||
@ -42,22 +42,22 @@ impl Chip8Video {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn poke(&mut self, address: u16, new_value: bool) -> Self {
|
pub fn poke(&mut self, address: u16, new_value: bool) -> Self {
|
||||||
trace!("OFFSET: {address} - POKING {new_value}");
|
// println!("OFFSET: {address} - POKING {new_value}");
|
||||||
|
|
||||||
|
// Loop the address
|
||||||
let effective_address = if address >= 2048 {
|
let effective_address = if address >= 2048 {
|
||||||
address - 2048
|
address - 2048
|
||||||
} else {
|
} else {
|
||||||
address
|
address
|
||||||
};
|
};
|
||||||
let old_value = self.memory[effective_address as usize];
|
|
||||||
let value_to_poke = new_value ^ old_value;
|
|
||||||
|
|
||||||
if old_value != value_to_poke {
|
let old_value = self.memory[effective_address as usize];
|
||||||
trace!("**VIDEO** TOGGLING");
|
let xored_value = new_value ^ old_value; // XOR of the video
|
||||||
self.has_frame_changed = true;
|
let value_changed = old_value != xored_value; // From True to False is a change.
|
||||||
} else {
|
|
||||||
trace!("NOT TOGGLING");
|
self.has_frame_changed = if xored_value && value_changed { false } else { true };
|
||||||
}
|
|
||||||
self.memory[effective_address as usize] = new_value ^ old_value;
|
self.memory[effective_address as usize] = xored_value;
|
||||||
self.to_owned()
|
self.to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,6 +369,7 @@ mod test {
|
|||||||
fn verify_change_registered() {
|
fn verify_change_registered() {
|
||||||
let mut v = Chip8Video::default();
|
let mut v = Chip8Video::default();
|
||||||
v.poke(0x01, true);
|
v.poke(0x01, true);
|
||||||
|
v.poke(0x01, true);
|
||||||
assert!(v.has_frame_changed);
|
assert!(v.has_frame_changed);
|
||||||
|
|
||||||
v.start_frame();
|
v.start_frame();
|
||||||
@ -423,4 +424,34 @@ mod test {
|
|||||||
x = x.reset();
|
x = x.reset();
|
||||||
assert_eq!(x.format_as_string(), read_test_result("test_reset_clears_video.asc"));
|
assert_eq!(x.format_as_string(), read_test_result("test_reset_clears_video.asc"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn collision_test() {
|
||||||
|
// Setup: Set 0xFF to 0x00 with a new frame ready
|
||||||
|
// Action: Run Poke to the same area
|
||||||
|
// Test: Verify the 'changed' flag is tripped
|
||||||
|
let mut x = Chip8Video::default();
|
||||||
|
x.poke_byte(0x00, 0xff);
|
||||||
|
x.tick();
|
||||||
|
// set the cell thats already set...
|
||||||
|
x.poke(0x00, true);
|
||||||
|
// it becomes unset and theres a frame changed
|
||||||
|
assert_eq!(false, x.peek(0x00));
|
||||||
|
|
||||||
|
assert_eq!(true, x.has_frame_changed);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn collision_test2() {
|
||||||
|
let mut x = Chip8Video::default();
|
||||||
|
x.poke_byte(0x00, 0b11110000);
|
||||||
|
assert_eq!(true, x.has_frame_changed);
|
||||||
|
x.tick();
|
||||||
|
assert_eq!(false, x.has_frame_changed);
|
||||||
|
// clear the 'has changed' flag
|
||||||
|
|
||||||
|
// now set a no-collision value
|
||||||
|
x.poke_byte(0x00, 0b00001111);
|
||||||
|
assert_eq!(false, x.has_frame_changed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ pub struct GemmaEguiSupport {}
|
|||||||
|
|
||||||
impl GemmaEguiSupport {
|
impl GemmaEguiSupport {
|
||||||
pub fn controls_view(mut system: &mut Chip8Computer, state: &mut GemmaEGuiState, ui: &mut Ui) {
|
pub fn controls_view(mut system: &mut Chip8Computer, state: &mut GemmaEGuiState, ui: &mut Ui) {
|
||||||
ui.with_layout(egui::Layout::left_to_right(egui::Align::TOP), |ui| {
|
ui.with_layout(egui::Layout::left_to_right(egui::Align::TOP), |ui| {
|
||||||
if ui.button("Start").clicked() {
|
if ui.button("Start").clicked() {
|
||||||
println!("Start");
|
println!("Start");
|
||||||
|
|
||||||
@ -62,9 +62,12 @@ impl GemmaEguiSupport {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.checkbox(&mut state.display_memory, "Display Memory");
|
|
||||||
ui.checkbox(&mut state.display_video, "Display Video");
|
ui.with_layout(egui::Layout::left_to_right(Align::TOP), |ui| {
|
||||||
ui.checkbox(&mut state.display_registers, "Display Registers");
|
ui.checkbox(&mut state.display_memory, "Display Memory");
|
||||||
|
ui.checkbox(&mut state.display_video, "Display Video");
|
||||||
|
ui.checkbox(&mut state.display_registers, "Display Registers");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn registers_view(system: &Chip8Computer, ui: &mut Ui) {
|
pub fn registers_view(system: &Chip8Computer, ui: &mut Ui) {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ use gemma::{
|
|||||||
use imgui::*;
|
use imgui::*;
|
||||||
use sys::{ImColor, ImVec2, ImVector_ImU32};
|
use sys::{ImColor, ImVec2, ImVector_ImU32};
|
||||||
use rand::random;
|
use rand::random;
|
||||||
|
use gemma::chip8::cpu_states::Chip8CpuStates::WaitingForInstruction;
|
||||||
use gemma::chip8::system_memory::Chip8SystemMemory;
|
use gemma::chip8::system_memory::Chip8SystemMemory;
|
||||||
use support::{emmagui_support::GemmaImguiSupport, ui_state::ImGuiUiState};
|
use support::{emmagui_support::GemmaImguiSupport, ui_state::ImGuiUiState};
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ fn main() {
|
|||||||
for (key_code, key_reg) in LIN_KEYS {
|
for (key_code, key_reg) in LIN_KEYS {
|
||||||
if down_keys[key_code as usize] {
|
if down_keys[key_code as usize] {
|
||||||
system.keypad.push_key(key_reg);
|
system.keypad.push_key(key_reg);
|
||||||
|
system.state = WaitingForInstruction;
|
||||||
} else {
|
} else {
|
||||||
// do we need to release it?
|
// do we need to release it?
|
||||||
if system.keypad.pressed(key_reg) {
|
if system.keypad.pressed(key_reg) {
|
||||||
|
|||||||
@ -2,7 +2,6 @@ use gemma::constants::CHIP8_KEYBOARD;
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::thread::sleep;
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use imgui::{Condition, ImColor32, Ui};
|
use imgui::{Condition, ImColor32, Ui};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
@ -61,7 +60,7 @@ impl GemmaImguiSupport {
|
|||||||
pub fn video_display(system_to_control: &Chip8Computer, gui_state: &ImGuiUiState, ui: &Ui) {
|
pub fn video_display(system_to_control: &Chip8Computer, gui_state: &ImGuiUiState, ui: &Ui) {
|
||||||
// draw area size
|
// draw area size
|
||||||
let draw_area_size = ui.io().display_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_width = ((draw_area_size[0] as i32 / 64) * 6) / 10;
|
||||||
let cell_height = ((draw_area_size[1] as i32 / 32) * 6) / 10;
|
let cell_height = ((draw_area_size[1] as i32 / 32) * 6) / 10;
|
||||||
|
|
||||||
@ -177,7 +176,6 @@ impl GemmaImguiSupport {
|
|||||||
let cols = position.1;
|
let cols = position.1;
|
||||||
ui.window("System Memory")
|
ui.window("System Memory")
|
||||||
.size([400.0, 300.0], Condition::FirstUseEver)
|
.size([400.0, 300.0], Condition::FirstUseEver)
|
||||||
.position([500.0, 300.0], Condition::Always)
|
|
||||||
.build(|| {
|
.build(|| {
|
||||||
let mut current_x_hover: i32 = 0;
|
let mut current_x_hover: i32 = 0;
|
||||||
let mut current_y_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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
BIN
resources/roms/Chip8 Picture.ch8
Normal file
BIN
resources/roms/Chip8 Picture.ch8
Normal file
Binary file not shown.
BIN
resources/roms/Chip8 emulator Logo [Garstyciuks].ch8
Normal file
BIN
resources/roms/Chip8 emulator Logo [Garstyciuks].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Clock Program [Bill Fisher, 1981].ch8
Normal file
BIN
resources/roms/Clock Program [Bill Fisher, 1981].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Delay Timer Test [Matthew Mikolay, 2010].ch8
Normal file
BIN
resources/roms/Delay Timer Test [Matthew Mikolay, 2010].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Division Test [Sergey Naydenov, 2010].ch8
Normal file
BIN
resources/roms/Division Test [Sergey Naydenov, 2010].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Fishie [Hap, 2005].ch8
Normal file
BIN
resources/roms/Fishie [Hap, 2005].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Framed MK1 [GV Samways, 1980].ch8
Normal file
BIN
resources/roms/Framed MK1 [GV Samways, 1980].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Framed MK2 [GV Samways, 1980].ch8
Normal file
BIN
resources/roms/Framed MK2 [GV Samways, 1980].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Jumping X and O [Harry Kleinberg, 1977].ch8
Normal file
BIN
resources/roms/Jumping X and O [Harry Kleinberg, 1977].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Keypad Test [Hap, 2006].ch8
Normal file
BIN
resources/roms/Keypad Test [Hap, 2006].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Life [GV Samways, 1980].ch8
Normal file
BIN
resources/roms/Life [GV Samways, 1980].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Maze (alt) [David Winter, 199x].ch8
Normal file
BIN
resources/roms/Maze (alt) [David Winter, 199x].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Maze [David Winter, 199x].ch8
Normal file
BIN
resources/roms/Maze [David Winter, 199x].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Minimal game [Revival Studios, 2007].ch8
Normal file
BIN
resources/roms/Minimal game [Revival Studios, 2007].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Particle Demo [zeroZshadow, 2008].ch8
Normal file
BIN
resources/roms/Particle Demo [zeroZshadow, 2008].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Random Number Test [Matthew Mikolay, 2010].ch8
Normal file
BIN
resources/roms/Random Number Test [Matthew Mikolay, 2010].ch8
Normal file
Binary file not shown.
BIN
resources/roms/SQRT Test [Sergey Naydenov, 2010].ch8
Normal file
BIN
resources/roms/SQRT Test [Sergey Naydenov, 2010].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Sierpinski [Sergey Naydenov, 2010].ch8
Normal file
BIN
resources/roms/Sierpinski [Sergey Naydenov, 2010].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Stars [Sergey Naydenov, 2010].ch8
Normal file
BIN
resources/roms/Stars [Sergey Naydenov, 2010].ch8
Normal file
Binary file not shown.
BIN
resources/roms/Trip8 Demo (2008) [Revival Studios].ch8
Normal file
BIN
resources/roms/Trip8 Demo (2008) [Revival Studios].ch8
Normal file
Binary file not shown.
11
resources/roms/Zero Demo [zeroZshadow, 2007].ch8
Normal file
11
resources/roms/Zero Demo [zeroZshadow, 2007].ch8
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
`
|
||||||
|
ef
|
||||||
|
ghabcd`
|
||||||
|
¢xÐVp
|
||||||
|
¢~Ðfp
|
||||||
|
¢„Ðvp
|
||||||
|
¢ŠÐ†jú`
|
||||||
|
¢xÐVEaÿEa…ÐVp
|
||||||
|
¢~ÐfFbÿFb†$Ðfp
|
||||||
|
¢„ÐvGcÿGc‡4Ðvp
|
||||||
|
¢ŠÐ†HdÿHdˆDІ*ÿ0ÀÿÿÀÀüÀÿðÌÌðÌÃ<ÃÃÃÃ<
|
||||||
Loading…
x
Reference in New Issue
Block a user