CLEANUP: cleans up dependencies to use workspace version
CLEANUP: standardizes on pretty_env_logger NEWBIN: Adds gemmarat to use Ratatui as an interface CLEANUP: removes debugging display from computer.rs ENHANCEMENT: Constants for locations of test roms built from environment BUGFIX: SoundTimer was using i32 internally when it needs to be u8 CLEANUP: removes commented code used during diagnostics
This commit is contained in:
@@ -103,7 +103,7 @@ fn decompress_file(input_path: &PathBuf) -> io::Result<()> {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
pretty_env_logger::init();
|
||||
|
||||
let cli = Cli::parse();
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ impl Chip8Computer {
|
||||
|
||||
|
||||
pub fn step_system(&mut self) -> &mut Chip8Computer {
|
||||
println!("Stepping System 1 Step");
|
||||
// println!("Stepping System 1 Step");
|
||||
// read the next instruction
|
||||
let local_memory = &self.memory;
|
||||
|
||||
|
||||
@@ -1019,7 +1019,7 @@ impl Chip8CpuInstructions {
|
||||
}
|
||||
Chip8CpuInstructions::LDIS(new_time) => {
|
||||
let new_value = input.registers.peek(*new_time);
|
||||
input.sound_timer.set_timer(new_value as i32);
|
||||
input.sound_timer.set_timer(new_value);
|
||||
}
|
||||
Chip8CpuInstructions::ADDI(x) => {
|
||||
// Fx1E - ADD I, Vx
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
use log::trace;
|
||||
extern crate pretty_env_logger;
|
||||
|
||||
use log::warn;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
|
||||
pub struct SoundTimer {
|
||||
counter: i32,
|
||||
counter: u8,
|
||||
}
|
||||
|
||||
impl Default for SoundTimer {
|
||||
@@ -13,32 +15,25 @@ impl Default for SoundTimer {
|
||||
}
|
||||
|
||||
impl SoundTimer {
|
||||
pub fn current(&self) -> i32 {
|
||||
pub fn current(&self) -> u8 {
|
||||
self.counter
|
||||
}
|
||||
pub fn new() -> Self {
|
||||
SoundTimer { counter: 0 }
|
||||
}
|
||||
pub fn set_timer(&mut self, new_value: i32) {
|
||||
trace!("SETTING SOUND TIMER TO {new_value}");
|
||||
pub fn set_timer(&mut self, new_value: u8) {
|
||||
warn!("SETTING SOUND TIMER TO {new_value}");
|
||||
self.counter = new_value
|
||||
}
|
||||
|
||||
pub fn tick(&mut self) {
|
||||
trace!(
|
||||
warn!(
|
||||
"TICKING SOUND FROM {} to {}",
|
||||
self.counter,
|
||||
self.counter - 1
|
||||
);
|
||||
if self.counter > 0 {
|
||||
self.counter -= 1;
|
||||
/*
|
||||
todo: this breaks tests. maybe its wrong?
|
||||
if let good_thread = thread::spawn(|| {
|
||||
beep(440).expect("Unable to beep");
|
||||
thread::sleep(time::Duration::from_millis(500));
|
||||
}).join().unwrap().
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
use std::borrow::ToOwned;
|
||||
use std::clone::Clone;
|
||||
use std::net::ToSocketAddrs;
|
||||
use std::string::ToString;
|
||||
|
||||
pub const CHIP8_REGISTER_COUNT: i32 = 16;
|
||||
pub const CHIP8_MEMORY_SIZE: i32 = 4096i32;
|
||||
pub const CHIP8_VIDEO_WIDTH: i32 = 64i32;
|
||||
@@ -9,9 +14,10 @@ pub const LABEL_QUIRK_CHIP8: &str = "Chip8";
|
||||
pub const LABEL_QUIRK_XOCHIP: &str = "XO Chip";
|
||||
pub const LABEL_QUIRK_SCHIP: &str = "SChip-Modern";
|
||||
|
||||
pub const RESOURCES_ROOT: &str = "../resources";
|
||||
pub const TESTS_ROOT: &str = "../resources/test/";
|
||||
pub const TEST_ROM_ROOT: &str = "../resources/test/roms";
|
||||
pub const BASE_ROOT: &'static str = &(env!("CARGO_MANIFEST_DIR"));
|
||||
pub const RESOURCES_ROOT: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/../resources");
|
||||
pub const TESTS_ROOT: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/../resources/test");
|
||||
pub const TEST_ROM_ROOT: &'static str =concat!(env!("CARGO_MANIFEST_DIR"), "/../resources/test/roms");
|
||||
|
||||
pub const CHIP8_KEYBOARD: [[u8; 4]; 4] = [
|
||||
[0x01, 0x02, 0x03, 0x0C],
|
||||
|
||||
Reference in New Issue
Block a user