update shift instruction to modern behavior

This commit is contained in:
Denis-Cosmin NUTIU 2024-12-07 21:43:57 +02:00
parent e3a4c023a3
commit 8d13bd6b18
2 changed files with 3 additions and 5 deletions

View file

@ -287,15 +287,13 @@ where
ProcessorInstruction::ShiftLeft(vx, vy) => {
trace!("ShiftLeft VX={vx:04x} VY={vy:04x}");
// Original chip8 behavior
self.registers[0xF] = (self.registers[vy as usize] & 0x10) >> 4;
self.registers[vx as usize] = self.registers[vy as usize];
self.registers[0xF] = (self.registers[vx as usize] & 0x10) >> 4;
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[vy as usize] & 0x01;
self.registers[vx as usize] = self.registers[vy as usize];
self.registers[0xF] = self.registers[vx as usize] & 0x01;
self.registers[vx as usize] >>= 1;
}
ProcessorInstruction::JumpWithOffset(address) => {

View file

@ -13,7 +13,7 @@ fn main() -> Result<(), anyhow::Error> {
let mut emulator = Emulator::new(RatatuiDisplay::new());
emulator.emulate(String::from("./roms/ibm-logo.ch8"))?;
emulator.emulate(String::from("./roms/3-corax+.ch8"))?;
Ok(())
}