From 2f4caa8e39ac39969522c4a2a285256c9a13b2c6 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Mon, 7 Sep 2026 16:38:48 +0200 Subject: vnf: convert StatusRegister.break_mark to Option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of assuming a default value, it's safer to just implement it in Rust's native Option<_> type. Signed-off-by: Miquel Sabaté Solà --- lib/vnf/src/lib.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/vnf') diff --git a/lib/vnf/src/lib.rs b/lib/vnf/src/lib.rs index dfa2f7f..61f117d 100644 --- a/lib/vnf/src/lib.rs +++ b/lib/vnf/src/lib.rs @@ -44,8 +44,8 @@ pub struct StatusRegister { pub zero: bool, pub carry: bool, - /// The byte after a 'brk' instruction. - pub break_mark: u8, + /// The byte after the a 'brk' instruction. + pub break_mark: Option, } impl Default for StatusRegister { @@ -58,7 +58,7 @@ impl Default for StatusRegister { interrupt: true, zero: false, carry: false, - break_mark: 0, + break_mark: None, } } } @@ -857,7 +857,7 @@ impl Machine { // BRK is always cleared. We also clear the break mark now. self.status_register.brk = false; - self.status_register.break_mark = 0; + self.status_register.break_mark = None; Ok(()) } @@ -1205,10 +1205,12 @@ impl Machine { // 1. If that's not possible, then we have a 'brk' as the last // instruction with no break mark or something like that, which // is just nonsense. - self.status_register.break_mark = *self - .prg_rom - .get(self.pc - 0x8000 + 1) - .expect("you need to reserve a byte for the break mark"); + self.status_register.break_mark = Some( + *self + .prg_rom + .get(self.pc - 0x8000 + 1) + .expect("you need to reserve a byte for the break mark"), + ); // TODO: the next PC is the advertized IRQ one. This one is // picked as the last byte from PRG-ROM, but depending on how -- cgit v1.2.3