diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-09-07 16:38:48 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-09-07 16:38:48 +0200 |
| commit | 2f4caa8e39ac39969522c4a2a285256c9a13b2c6 (patch) | |
| tree | 35b3b2408472ee47c03ad2f562beff8dd4b0b13f /lib/vnf/src | |
| parent | 44f98890a6d91cd9f0b64dec743a22a6e0013590 (diff) | |
| download | tools.nes-2f4caa8e39ac39969522c4a2a285256c9a13b2c6.tar.gz tools.nes-2f4caa8e39ac39969522c4a2a285256c9a13b2c6.zip | |
vnf: convert StatusRegister.break_mark to Option<u8>
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à <mssola@mssola.com>
Diffstat (limited to 'lib/vnf/src')
| -rw-r--r-- | lib/vnf/src/lib.rs | 18 |
1 files changed, 10 insertions, 8 deletions
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<u8>, } 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 |
