diff --git a/README.md b/README.md index 05a99ad..d4691a5 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ Yet another chip8 emulator written in rust \o/ + Expand on this README + Add some documentation -+ Add delay for beeper -+ Fix input ++ Add sound for beeper ++ Fix tests for input ## System Dependencies diff --git a/src/display.rs b/src/display.rs index afd7f23..6e49487 100644 --- a/src/display.rs +++ b/src/display.rs @@ -30,7 +30,7 @@ impl Display { Display { canvas, } - } + } pub fn draw(&mut self, pixel: &[[u8; crate::SCREEN_WIDTH]; crate::SCREEN_HEIGHT]) { for (y, &row) in pixel.iter().enumerate() { diff --git a/src/processor.rs b/src/processor.rs index 6188ce2..febbc3c 100644 --- a/src/processor.rs +++ b/src/processor.rs @@ -1,6 +1,8 @@ extern crate sdl2; use rand::Rng; +use std::time::Duration; +use std::thread; use crate::fontset::FONT; use crate::display::Display; @@ -71,8 +73,8 @@ impl Processor { // play sound using sdl2 // TODO - // add delay - // TODO + // modern pc's are too fast :o + thread::sleep(Duration::from_millis(3)); } } @@ -207,7 +209,7 @@ impl Processor { // Call subroutine at nnn fn code_2nnn(&mut self, nnn: usize) { - self.stack[self.sp] = self.pc; + self.stack[self.sp] = self.pc + 2; self.sp += 1; self.pc = nnn; } @@ -519,11 +521,10 @@ mod tests{ fn test_code_2nnn() { let mut processor = new_processor(); processor.sp = 0; - let current = processor.pc; processor.decode_opcode(0x2333); assert_eq!(processor.sp, 1); assert_eq!(processor.pc, 0x0333); - assert_eq!(processor.stack[0], current); + assert_eq!(processor.stack[0], NEXT); } #[test]