From 7510ad13cd802a501072d9f13f21ee178522d231 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Fri, 20 Jan 2023 14:59:17 +1100 Subject: [PATCH] prevent panic on overflow when incrementing program counter --- src/processor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/processor.rs b/src/processor.rs index 1404443..25cdb31 100644 --- a/src/processor.rs +++ b/src/processor.rs @@ -1213,7 +1213,7 @@ impl CPU { fn next_opcode(&mut self) -> u8 { unsafe { let opcode = self.memory.get(self.state.pc.as_u16); - self.state.pc.as_u16 += 0x1; + self.state.pc.as_u16 = self.state.pc.as_u16.wrapping_add(0x1); return opcode; }; }