aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-09-07 22:31:33 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-09-07 23:03:55 +0200
commita17bd972a99007099057d7901b88732b22d08270 (patch)
treefd278e8863d1123598b697751e514051c83f2335 /lib
parent2f4caa8e39ac39969522c4a2a285256c9a13b2c6 (diff)
downloadtools.nes-a17bd972a99007099057d7901b88732b22d08270.tar.gz
tools.nes-a17bd972a99007099057d7901b88732b22d08270.zip
vnf: add the 'Machine.halt_on_brk' field
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à <mssola@mssola.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/vnf/src/lib.rs9
1 files changed, 9 insertions, 0 deletions
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()?;