prevent panic on overflow when incrementing program counter

This commit is contained in:
Alex Janka 2023-01-20 14:59:17 +11:00
parent ac023fdc31
commit 7510ad13cd

View file

@ -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;
};
}