From a17bd972a99007099057d7901b88732b22d08270 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Mon, 7 Sep 2026 22:31:33 +0200 Subject: vnf: add the 'Machine.halt_on_brk' field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows developers to use 'brk' as asserts which can then be debugged. This is true by default but it can be turned off via the --no-halting-brk option from runrom. Signed-off-by: Miquel Sabaté Solà --- lib/vnf/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/vnf/src') diff --git a/lib/vnf/src/lib.rs b/lib/vnf/src/lib.rs index 61f117d..c9ae1a0 100644 --- a/lib/vnf/src/lib.rs +++ b/lib/vnf/src/lib.rs @@ -378,6 +378,10 @@ pub struct Machine { /// The status of both Joypads. joypads: [Joypad; 2], + + /// Whether execution should be halted _after_ a 'brk' instruction no matter + /// what. The break mark will be set accordingly. + pub halt_on_brk: bool, } // Returns a vector of MemoryCell representing the RAM for a Machine, which @@ -487,6 +491,7 @@ impl Machine { should_report_ppu: false, policy, joypads: [Joypad::default(), Joypad::default()], + halt_on_brk: true, }) } @@ -1220,6 +1225,10 @@ impl Machine { let low = &(self.prg_rom[len - 2] as usize); self.pc = high + low; self.skip_pc = true; + + if self.halt_on_brk { + self.active = false; + } } InstructionIdentifier::Rti => { self.pop_status_register()?; -- cgit v1.2.3