From a1390d8e4540240c37d9092918368daee1731daa Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Mon, 9 Dec 2024 21:56:58 +0200 Subject: [PATCH] get rom path from command line --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index e17e50e..689c7e3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,10 @@ use crate::display::RatatuiDisplay; use crate::emulator::Emulator; +use crate::input::CrossTermInput; use crate::sound::TerminalSound; use env_logger; +use std::env; +use std::path::PathBuf; mod display; mod emulator; @@ -12,10 +15,10 @@ mod stack; fn main() -> Result<(), anyhow::Error> { env_logger::init(); + let rom_path = PathBuf::from(env::args().skip(1).next().expect("rom path not provided.")); - let mut emulator = Emulator::new(RatatuiDisplay::new(), TerminalSound); - - emulator.emulate(String::from("./roms/3-corax+.ch8"))?; + let mut emulator = Emulator::new(RatatuiDisplay::new(), TerminalSound, CrossTermInput::new()); + emulator.emulate(rom_path.to_str().unwrap())?; Ok(()) }