summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2024-10-29 09:10:07 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2024-10-29 09:10:07 +1300
commitffb979f9cd7d8029251e5bb244428ddaa6724d04 (patch)
treecd500b1c35966c1aefb2c58c372f8bdb80bcf7ef
parentcbb20c667c8c13fe1d14d1ef146ea0f815e619cc (diff)
downloadbedrock-pc-ffb979f9cd7d8029251e5bb244428ddaa6724d04.zip
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.
-rw-r--r--src/bin/br.rs6
1 files changed, 4 insertions, 2 deletions
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() {