From 7028840a10a67614a59fddd3457be274e8f03eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Wed, 2 Aug 2023 00:23:25 +0100 Subject: [PATCH] reafctor: rorder of parsing values --- frontends/sdl/src/main.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/frontends/sdl/src/main.rs b/frontends/sdl/src/main.rs index 8c32a93b..4c5ffefb 100644 --- a/frontends/sdl/src/main.rs +++ b/frontends/sdl/src/main.rs @@ -784,12 +784,6 @@ fn main() { // parses the provided command line arguments and uses them to // obtain structured values let args = Args::parse(); - let mode = if args.mode == "auto" { - GameBoyMode::Dmg - } else { - GameBoyMode::from_string(&args.mode) - }; - let auto_mode = args.mode == "auto"; // in case the default ROM path is provided and the file does not // exist then fails gracefully @@ -799,6 +793,15 @@ fn main() { return; } + // tries to build the target mode from the mode argument + // parsing it if it does not contain the "auto" value + let mode = if args.mode == "auto" { + GameBoyMode::Dmg + } else { + GameBoyMode::from_string(&args.mode) + }; + let auto_mode = args.mode == "auto"; + // creates a new Game Boy instance and loads both the boot ROM // and the initial game ROM to "start the engine" let mut game_boy = GameBoy::new(Some(mode)); -- GitLab