aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-10-19 21:30:43 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-10-19 21:30:43 +0200
commitf64b7672745778a5cf99405707a0649e66d889b4 (patch)
treea0dbd997f6294aaccb3216546488eac9dce87896 /lib
parent821e371683886173a546533f00f8aef1c4e464bf (diff)
downloadtools.nes-f64b7672745778a5cf99405707a0649e66d889b4.tar.gz
tools.nes-f64b7672745778a5cf99405707a0649e66d889b4.zip
Use translate_rom_address() for the break mark
This was a leftover from commit 57a15f938556 ("runrom: add support for the MMC3 chip"). As a cherry on top, let's use .get() instead of directly accessing the PRG ROM slice. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/vnf/src/lib.rs23
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/vnf/src/lib.rs b/lib/vnf/src/lib.rs
index 4642afb..7b6dda8 100644
--- a/lib/vnf/src/lib.rs
+++ b/lib/vnf/src/lib.rs
@@ -1456,21 +1456,16 @@ impl Machine {
// The break mark is basically the byte which is in current PC +
// 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 = 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
- // bank mapping is done, this is not necessarily true.
+ // instruction with no break mark or something like that. In
+ // this case translate_rom_address() will give us a zero value,
+ // which is good enough.
+ self.status_register.break_mark = Some(self.translate_rom_address(self.pc + 1)?[0]);
+
+ // The next PC is the advertized IRQ one. This one is picked as
+ // the last word from PRG-ROM.
let len = self.prg_rom.len();
- let high = &(self.prg_rom[len - 1] as usize) << 8;
- let low = &(self.prg_rom[len - 2] as usize);
+ let high = &(*self.prg_rom.get(len - 1).unwrap_or(&0) as usize) << 8;
+ let low = &(*self.prg_rom.get(len - 2).unwrap_or(&0) as usize);
self.pc = high + low;
self.skip_pc = true;