diff --git a/.gitignore b/.gitignore index c787b09..67f3196 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target .idea -/roms \ No newline at end of file +/roms +.DS_Store diff --git a/src/device/instruction.rs b/src/device/instruction.rs index 1231714..c1fd0a4 100644 --- a/src/device/instruction.rs +++ b/src/device/instruction.rs @@ -170,7 +170,6 @@ impl Instruction { let x = (instruction & 0xf00) >> 8; Instruction::GetKey(x as usize) } - //TODO add tests from here 0xF if (instruction & 0xff) == 0x29 => { let x = (instruction & 0xf00) >> 8; Instruction::SetIndexToFontCharacter(x as usize) diff --git a/src/main.rs b/src/main.rs index dec3f21..b46462a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,8 @@ mod util; mod sdl_adapters; mod rom; +const WINDOW_TITLE: &str = "porcel8"; + fn main() -> EmulatorResult<()> { SimpleLogger::new().with_level(LevelFilter::Info).env().init().unwrap(); let Porcel8ProgramArgs { filename, new_chip8_behaviour, draw_scale, halt_on_invalid } = Porcel8ProgramArgs::parse(); @@ -144,7 +146,7 @@ fn try_initiate_sdl(draw_scale: f32) -> EmulatorResult<(WindowCanvas, EventPump, let window_width = (Device::FRAME_BUFFER_WIDTH as f32 * draw_scale) as u32; let window_height = (Device::FRAME_BUFFER_HEIGHT as f32 * draw_scale) as u32; - let window = video_subsystem.window("porcel8", window_width, window_height) + let window = video_subsystem.window(WINDOW_TITLE, window_width, window_height) .position_centered() .build()?; let mut canvas = window.into_canvas().build()?; diff --git a/src/sdl_adapters/sdl_graphics_adapter.rs b/src/sdl_adapters/sdl_graphics_adapter.rs index bd9a9ab..3850c4f 100644 --- a/src/sdl_adapters/sdl_graphics_adapter.rs +++ b/src/sdl_adapters/sdl_graphics_adapter.rs @@ -37,4 +37,4 @@ impl SdlGraphicsAdapter { window_canvas.copy(&tex, None, None)?; Ok(()) } -} \ No newline at end of file +} diff --git a/src/sdl_adapters/sdl_keyboard_adapter.rs b/src/sdl_adapters/sdl_keyboard_adapter.rs index 2b0962a..d539f12 100644 --- a/src/sdl_adapters/sdl_keyboard_adapter.rs +++ b/src/sdl_adapters/sdl_keyboard_adapter.rs @@ -60,3 +60,19 @@ impl SdlKeyboardAdapter { } } + +#[cfg(test)] +mod tests{ + use crate::device::keyboard::Key; + + use super::SdlKeyboardAdapter; + + #[test] + fn test_keycode_to_key(){ + assert_eq!(Some(Key::K7), SdlKeyboardAdapter::keycode_to_key(sdl2::keyboard::Keycode::A)); + } + #[test] + fn test_keycode_to_key_no_key(){ + assert_eq!(None, SdlKeyboardAdapter::keycode_to_key(sdl2::keyboard::Keycode::L)); + } +}