From 9dd876b62299a3bbc4384ba75938eab601580176 Mon Sep 17 00:00:00 2001 From: Denis-Cosmin NUTIU Date: Sat, 7 Dec 2024 22:13:58 +0200 Subject: [PATCH] fix shift --- src/emulator.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/emulator.rs b/src/emulator.rs index 0c2fa58..760b679 100644 --- a/src/emulator.rs +++ b/src/emulator.rs @@ -286,14 +286,12 @@ where } ProcessorInstruction::ShiftLeft(vx, vy) => { trace!("ShiftLeft VX={vx:04x} VY={vy:04x}"); - // Original chip8 behavior - self.registers[0xF] = (self.registers[vx as usize] & 0x10) >> 4; + self.registers[0xF] = (self.registers[vx as usize] >> 7) & 1; self.registers[vx as usize] <<= 1; } ProcessorInstruction::ShiftRight(vx, vy) => { trace!("ShiftRight VX={vx:04x} VY={vy:04x}"); - // Original chip8 behavior - self.registers[0xF] = self.registers[vx as usize] & 0x01; + self.registers[0xF] = self.registers[vx as usize] & 0x1; self.registers[vx as usize] >>= 1; } ProcessorInstruction::JumpWithOffset(address) => {