fix DAA
This commit is contained in:
parent
615446faa7
commit
b659e5c77b
|
@ -188,19 +188,19 @@ impl CPU {
|
|||
if !self.is_flag(Flags::NSubtract) {
|
||||
// after an addition, adjust if (half-)carry occurred or if result is out of bounds
|
||||
if self.is_flag(Flags::Carry) || a > 0x99 {
|
||||
a += 0x60;
|
||||
a = a.wrapping_add(0x60);
|
||||
self.set_flag(Flags::Carry);
|
||||
}
|
||||
if self.is_flag(Flags::HalfCarry) || (a & 0x0f) > 0x09 {
|
||||
a += 0x6;
|
||||
a = a.wrapping_add(0x6);
|
||||
}
|
||||
} else {
|
||||
// after a subtraction, only adjust if (half-)carry occurred
|
||||
if self.is_flag(Flags::Carry) {
|
||||
a -= 0x60;
|
||||
a = a.wrapping_sub(0x60);
|
||||
}
|
||||
if self.is_flag(Flags::HalfCarry) {
|
||||
a -= 0x6;
|
||||
a = a.wrapping_sub(0x6);
|
||||
}
|
||||
}
|
||||
// these flags are always updated
|
||||
|
|
Loading…
Reference in a new issue