From ef2615c1a7f053ee33f32cc30a16f94ce7678bed Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Tue, 29 Aug 2023 23:13:23 +0200 Subject: [PATCH] cpu/decoder - Fix build errors --- cpu/decoder.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/cpu/decoder.cpp b/cpu/decoder.cpp index 92855a4..997f746 100644 --- a/cpu/decoder.cpp +++ b/cpu/decoder.cpp @@ -176,7 +176,7 @@ void Cpu::executeInstruction() { u16 rhs = state.reg16((op >> 4) & 0x3); u16 res12 = (state.HL & 0x0FFF) + (rhs & 0x0FFF); - state.halfcarry = (res11 & 0x1000); + state.halfcarry = (res12 & 0x1000); u32 res32 = (u32)state.HL + (u32)rhs; state.carry = (res32 & 0x10000); state.subtract = false; @@ -457,16 +457,19 @@ void Cpu::executeInstruction() break; case 0xE8: // ADD SP, e8 - u32 lhs = state.SP; - s32 rhs = (s8)readPC8(); - u32 low_add = (lhs & 0x0FFF) + (rhs & 0x0FFF); - state.halfcarry = (low_add & 0x1000); - u32 res32 = lhs + rhs; - state.carry = (res32 & 0x10000); - state.SP = (u16)res32; - state.subtract = false; - state.zero = false; - mcycles = 4; + { + u32 lhs = state.SP; + s32 rhs = (s8)readPC8(); + u32 low_add = (lhs & 0x0FFF) + (rhs & 0x0FFF); + state.halfcarry = (low_add & 0x1000); + u32 res32 = lhs + rhs; + state.carry = (res32 & 0x10000); + state.SP = (u16)res32; + state.subtract = false; + state.zero = false; + mcycles = 4; + } + break; default: panic("Unknown opcode 0x%x\n",op);