diff --git a/Z80/src/Z80.cpp b/Z80/src/Z80.cpp index bef3299..87956dd 100644 --- a/Z80/src/Z80.cpp +++ b/Z80/src/Z80.cpp @@ -479,8 +479,8 @@ void EightBit::Z80::daa(uint8_t& a, uint8_t& f) { auto updated = a; - auto lowAdjust = (f & HC) | (lowNibble(a) > 9); - auto highAdjust = (f & CF) | (a > 0x99); + auto lowAdjust = (f & HC) || (lowNibble(a) > 9); + auto highAdjust = (f & CF) || (a > 0x99); if (f & NF) { if (lowAdjust) @@ -494,7 +494,7 @@ void EightBit::Z80::daa(uint8_t& a, uint8_t& f) { updated += 0x60; } - f = (f & (CF | NF)) | (a > 0x99) | ((a ^ updated) & HC); + f = (f & (CF | NF)) | (a > 0x99 ? CF : 0) | ((a ^ updated) & HC); a = updated; adjustSZPXY(f, a);