From 0c7f945407561f7c4531b2780e908bb2098551d8 Mon Sep 17 00:00:00 2001 From: Astatin Date: Thu, 22 May 2025 14:07:19 +0200 Subject: Add load/save parameters to the CLI & remove errors --- src/main.rs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 2e5c80c..9a48983 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,6 +35,12 @@ struct Cli { #[arg(long)] replay_input: Option, + #[arg(long)] + state_file: Option, + + #[arg(short, long, default_value_t = false)] + load_state: bool, + #[arg(short, long, default_value_t = false)] keyboard: bool, @@ -65,13 +71,26 @@ fn main() { gamepad = Box::new(GamepadRecorder::new(gamepad, record_file)); }; - io::Gameboy::<_, _, _, desktop::audio::RodioAudio, _>::new( + let mut fs_load_save = FSLoadSave::new(&cli.rom, format!("{}.sav", &cli.rom)); + if let Some(state_file) = &cli.state_file { + fs_load_save = fs_load_save.state_file(state_file); + } + + let mut gameboy = io::Gameboy::<_, _, _, desktop::audio::RodioAudio, _>::new( gamepad, window, serial, - FSLoadSave::new(&cli.rom, format!("{}.sav", &cli.rom)) - .state_file(format!("{}.dump", &cli.rom)), + fs_load_save, cli.speed as f64, - ) - .start(); + ); + + if cli.debug { + gameboy.debug(); + } + + if cli.load_state { + gameboy.load_state().unwrap(); + } + + gameboy.start(); } -- cgit v1.2.3-70-g09d2