From 899cebb6984a5c9a0d6981d17e196c8bd707820b Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Fri, 1 Sep 2023 23:19:31 +0200 Subject: [PATCH] cpu/cpu - Fix carry and halfcarry in aluop8 Found by Gameboy Doctor --- cpu/cpu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu/cpu.cpp b/cpu/cpu.cpp index 11393d9..11e37a0 100644 --- a/cpu/cpu.cpp +++ b/cpu/cpu.cpp @@ -219,7 +219,7 @@ void Cpu::aluop8(AluOp op, u8 lhs, u8 rhs, u8& out, bool update_carry) break; } - state.halfcarry = (res16 & 0x10 != 0) || op == AND; + state.halfcarry = ((res16 & 0x10) != 0) || op == AND; state.subtract = (op == SUB) || (op == SBC) || (op == CP); switch(op) @@ -247,7 +247,7 @@ void Cpu::aluop8(AluOp op, u8 lhs, u8 rhs, u8& out, bool update_carry) res = (u8)(res16 & 0xFF); if(update_carry) - state.carry = (res16 & 0x100 != 0); + state.carry = ((res16 & 0x100) != 0); state.zero = (res == 0);