fix flags again

This commit is contained in:
Alex Janka 2023-02-24 16:45:24 +11:00
parent ce76c32a21
commit a760fecd05
2 changed files with 7 additions and 2 deletions

View file

@ -47,7 +47,7 @@ impl Cpu {
rotated += get_rotation_carry(&direction);
self.set_flag(Flags::Carry);
}
self.clear_flag(Flags::Zero);
self.set_or_clear_flag(Flags::Zero, rotated == 0);
self.clear_flag(Flags::HalfCarry);
self.clear_flag(Flags::NSubtract);
rotated
@ -64,7 +64,7 @@ impl Cpu {
} else {
self.clear_flag(Flags::Carry);
}
self.clear_flag(Flags::Zero);
self.set_or_clear_flag(Flags::Zero, rotated == 0);
self.clear_flag(Flags::HalfCarry);
self.clear_flag(Flags::NSubtract);
rotated
@ -72,6 +72,7 @@ impl Cpu {
pub(crate) fn shift(&mut self, byte: u8, direction: Direction) -> u8 {
let (rotated, carry) = rotate(byte, &direction);
self.clear_flag(Flags::Carry);
if carry {
self.set_flag(Flags::Carry);
}

View file

@ -40,6 +40,7 @@ impl Cpu {
}
0x07 => {
let val = self.rlc(self.reg.get_8(Reg8::A));
self.clear_flag(Flags::Zero);
self.reg.set_8(Reg8::A, val);
1
}
@ -77,6 +78,7 @@ impl Cpu {
}
0x0F => {
let val = self.rrc(self.reg.get_8(Reg8::A));
self.clear_flag(Flags::Zero);
self.reg.set_8(Reg8::A, val);
1
}
@ -112,6 +114,7 @@ impl Cpu {
}
0x17 => {
let val = self.rl(self.reg.get_8(Reg8::A));
self.clear_flag(Flags::Zero);
self.reg.set_8(Reg8::A, val);
1
}
@ -147,6 +150,7 @@ impl Cpu {
}
0x1F => {
let val = self.rr(self.reg.get_8(Reg8::A));
self.clear_flag(Flags::Zero);
self.reg.set_8(Reg8::A, val);
2
}