diff --git a/src/processor/instructions/primitives.rs b/src/processor/instructions/primitives.rs index d3fbd8c..9582333 100644 --- a/src/processor/instructions/primitives.rs +++ b/src/processor/instructions/primitives.rs @@ -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; }