aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorAstatin <[email protected]>2025-05-22 14:07:19 +0200
committerAstatin <[email protected]>2025-05-22 14:07:19 +0200
commit0c7f945407561f7c4531b2780e908bb2098551d8 (patch)
tree082b5cef5430a787ca524b0f846be999e5633334 /src/main.rs
parent4fce95c86e12f91e127605d440118e1b6a64208b (diff)
Add load/save parameters to the CLI & remove errors
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs29
1 files changed, 24 insertions, 5 deletions
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<String>,
+ #[arg(long)]
+ state_file: Option<String>,
+
+ #[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();
}