From ffb979f9cd7d8029251e5bb244428ddaa6724d04 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Tue, 29 Oct 2024 09:10:07 +1300 Subject: Make configuration code less confusing The unwrap_or for the the dimensions value was to get around the fact that we don't have guaranteed dimensions at this point. It makes it look like something more important is happening though, so instead we just make the config struct mutable and overwrite the dimensions field with the real value when we get access to it. --- src/bin/br.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/bin/br.rs') diff --git a/src/bin/br.rs b/src/bin/br.rs index d0ed067..77bf3ee 100644 --- a/src/bin/br.rs +++ b/src/bin/br.rs @@ -51,8 +51,8 @@ fn main_run(args: Run) { // TODO: Load and parse symbols file into debug state, use nearest symbol // path when debugging. - let config = EmulatorConfig { - dimensions: args.dimensions().unwrap_or(ScreenDimensions::ZERO), + let mut config = EmulatorConfig { + dimensions: ScreenDimensions::ZERO, fullscreen: args.fullscreen, scale: args.scale(), debug_palette: args.palette(), @@ -65,6 +65,8 @@ fn main_run(args: Run) { if phosphor.is_ok() && args.dimensions().is_some() { verbose!("Starting graphical emulator"); let mut phosphor = phosphor.unwrap(); + config.dimensions = args.dimensions().unwrap(); + let mut graphical = GraphicalEmulator::new(&config, args.debug); graphical.load_program(&bytecode); if let EmulatorSignal::Promote = graphical.run() { -- cgit v1.2.3-70-g09d2