update shift instruction to modern behavior
This commit is contained in:
parent
e3a4c023a3
commit
8d13bd6b18
2 changed files with 3 additions and 5 deletions
|
@ -287,15 +287,13 @@ where
|
||||||
ProcessorInstruction::ShiftLeft(vx, vy) => {
|
ProcessorInstruction::ShiftLeft(vx, vy) => {
|
||||||
trace!("ShiftLeft VX={vx:04x} VY={vy:04x}");
|
trace!("ShiftLeft VX={vx:04x} VY={vy:04x}");
|
||||||
// Original chip8 behavior
|
// Original chip8 behavior
|
||||||
self.registers[0xF] = (self.registers[vy as usize] & 0x10) >> 4;
|
self.registers[0xF] = (self.registers[vx as usize] & 0x10) >> 4;
|
||||||
self.registers[vx as usize] = self.registers[vy as usize];
|
|
||||||
self.registers[vx as usize] <<= 1;
|
self.registers[vx as usize] <<= 1;
|
||||||
}
|
}
|
||||||
ProcessorInstruction::ShiftRight(vx, vy) => {
|
ProcessorInstruction::ShiftRight(vx, vy) => {
|
||||||
trace!("ShiftRight VX={vx:04x} VY={vy:04x}");
|
trace!("ShiftRight VX={vx:04x} VY={vy:04x}");
|
||||||
// Original chip8 behavior
|
// Original chip8 behavior
|
||||||
self.registers[0xF] = self.registers[vy as usize] & 0x01;
|
self.registers[0xF] = self.registers[vx as usize] & 0x01;
|
||||||
self.registers[vx as usize] = self.registers[vy as usize];
|
|
||||||
self.registers[vx as usize] >>= 1;
|
self.registers[vx as usize] >>= 1;
|
||||||
}
|
}
|
||||||
ProcessorInstruction::JumpWithOffset(address) => {
|
ProcessorInstruction::JumpWithOffset(address) => {
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
|
|
||||||
let mut emulator = Emulator::new(RatatuiDisplay::new());
|
let mut emulator = Emulator::new(RatatuiDisplay::new());
|
||||||
|
|
||||||
emulator.emulate(String::from("./roms/ibm-logo.ch8"))?;
|
emulator.emulate(String::from("./roms/3-corax+.ch8"))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue