get rom path from command line

This commit is contained in:
Denis-Cosmin Nutiu 2024-12-09 21:56:58 +02:00
parent 0112138b78
commit a1390d8e45

View file

@ -1,7 +1,10 @@
use crate::display::RatatuiDisplay; use crate::display::RatatuiDisplay;
use crate::emulator::Emulator; use crate::emulator::Emulator;
use crate::input::CrossTermInput;
use crate::sound::TerminalSound; use crate::sound::TerminalSound;
use env_logger; use env_logger;
use std::env;
use std::path::PathBuf;
mod display; mod display;
mod emulator; mod emulator;
@ -12,10 +15,10 @@ mod stack;
fn main() -> Result<(), anyhow::Error> { fn main() -> Result<(), anyhow::Error> {
env_logger::init(); 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); let mut emulator = Emulator::new(RatatuiDisplay::new(), TerminalSound, CrossTermInput::new());
emulator.emulate(rom_path.to_str().unwrap())?;
emulator.emulate(String::from("./roms/3-corax+.ch8"))?;
Ok(()) Ok(())
} }