fix carry instruction flags
This commit is contained in:
parent
d73fbc827c
commit
c82f00c88b
|
@ -44,18 +44,24 @@ impl CPU {
|
|||
rotated += get_rotation_carry(&direction);
|
||||
self.set_flag(Flags::Carry);
|
||||
}
|
||||
self.set_or_clear_flag(Flags::Zero, rotated == 0x0);
|
||||
self.clear_flag(Flags::HalfCarry);
|
||||
self.clear_flag(Flags::NSubtract);
|
||||
return rotated;
|
||||
}
|
||||
|
||||
pub(crate) fn rotate(&mut self, byte: u8, direction: Direction) -> u8 {
|
||||
let old_carry = self.get_flag(Flags::Carry);
|
||||
let old_carry = self.is_flag(Flags::Carry);
|
||||
let (mut rotated, carry) = rotate(byte, &direction);
|
||||
if old_carry > 0 {
|
||||
if old_carry {
|
||||
rotated += get_rotation_carry(&direction);
|
||||
}
|
||||
if carry {
|
||||
self.set_flag(Flags::Carry);
|
||||
}
|
||||
self.set_or_clear_flag(Flags::Zero, rotated == 0x0);
|
||||
self.clear_flag(Flags::HalfCarry);
|
||||
self.clear_flag(Flags::NSubtract);
|
||||
return rotated;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue