diff options
author | Ben Bridle <ben@derelict.engineering> | 2025-01-12 10:52:59 +1300 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2025-01-12 10:52:59 +1300 |
commit | 8bfc20d44d3a0d040c6f7031f4975afd515e7424 (patch) | |
tree | 8c32aa0be4af33b4041b2084e1322aceec3d0c49 | |
parent | bd9b53d9cf976539ed977e0535325ee12091543c (diff) | |
download | bedrock-pc-8bfc20d44d3a0d040c6f7031f4975afd515e7424.zip |
Only print halt messages if the verbose flag is set
This required passing the verbose flag state down into the DebugState
structure.
-rw-r--r-- | src/bin/br.rs | 4 | ||||
-rw-r--r-- | src/debug.rs | 6 | ||||
-rw-r--r-- | src/emulators/graphical_emulator.rs | 4 | ||||
-rw-r--r-- | src/emulators/headless_emulator.rs | 4 |
4 files changed, 10 insertions, 8 deletions
diff --git a/src/bin/br.rs b/src/bin/br.rs index 9f6c10e..431ae39 100644 --- a/src/bin/br.rs +++ b/src/bin/br.rs @@ -83,7 +83,7 @@ fn main_run(args: Run) { false => None, }; - let mut graphical = GraphicalEmulator::new(&config, args.debug); + let mut graphical = GraphicalEmulator::new(&config, args.debug, unsafe {VERBOSE}); graphical.load_program(&bytecode); if let EmulatorSignal::Promote = graphical.run() { let program_name = match &metadata { @@ -109,7 +109,7 @@ fn main_run(args: Run) { } } else { verbose!("Starting headless emulator"); - let mut headless = HeadlessEmulator::new(&config, args.debug); + let mut headless = HeadlessEmulator::new(&config, args.debug, unsafe {VERBOSE}); headless.load_program(&bytecode); headless.run(args.debug); }; diff --git a/src/debug.rs b/src/debug.rs index c01ee15..6270948 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -13,15 +13,17 @@ const BLUE: &str = "\x1b[34m"; pub struct DebugState { pub enabled: bool, + pub verbose: bool, last_cycle: usize, last_mark: Instant, symbols: DebugSymbols, } impl DebugState { - pub fn new<P: AsRef<Path>>(enabled: bool, symbols_path: Option<P>) -> Self { + pub fn new<P: AsRef<Path>>(enabled: bool, verbose: bool, symbols_path: Option<P>) -> Self { Self { enabled, + verbose, last_cycle: 0, last_mark: Instant::now(), symbols: DebugSymbols::from_path_opt(symbols_path), @@ -29,7 +31,7 @@ impl DebugState { } pub fn info(&self, string: &str) { - if self.enabled { + if self.verbose { eprintln!("{BOLD}{BLUE}[INFO]{NORMAL}: {string}{NORMAL}"); } } diff --git a/src/emulators/graphical_emulator.rs b/src/emulators/graphical_emulator.rs index 008214c..14848c6 100644 --- a/src/emulators/graphical_emulator.rs +++ b/src/emulators/graphical_emulator.rs @@ -111,11 +111,11 @@ pub struct GraphicalEmulator { } impl GraphicalEmulator { - pub fn new(config: &EmulatorConfig, debug: bool) -> Self { + pub fn new(config: &EmulatorConfig, debug: bool, verbose: bool) -> Self { let devices = GraphicalDeviceBus::new(config); Self { br: BedrockEmulator::new(devices), - debug: DebugState::new(debug, config.symbols_path.as_ref()), + debug: DebugState::new(debug, verbose, config.symbols_path.as_ref()), dimensions: config.dimensions, fullscreen: config.fullscreen, scale: config.scale, diff --git a/src/emulators/headless_emulator.rs b/src/emulators/headless_emulator.rs index c508037..f215db3 100644 --- a/src/emulators/headless_emulator.rs +++ b/src/emulators/headless_emulator.rs @@ -86,10 +86,10 @@ pub struct HeadlessEmulator { } impl HeadlessEmulator { - pub fn new(config: &EmulatorConfig, debug: bool) -> Self { + pub fn new(config: &EmulatorConfig, debug: bool, verbose: bool) -> Self { Self { br: BedrockEmulator::new(HeadlessDeviceBus::new(config)), - debug: DebugState::new(debug, config.symbols_path.as_ref()), + debug: DebugState::new(debug, verbose, config.symbols_path.as_ref()), } } |