From cca632430b57438805f77023d79ef1bbb9aee26b Mon Sep 17 00:00:00 2001 From: Richard Dymond Date: Tue, 13 Aug 2024 17:39:34 -0300 Subject: [PATCH] CSimulator: Fix how 'BIT n,(IX/Y+d)' affects bits 3 and 5 of the flags --- c/csimulator.c | 2 +- sphinx/source/changelog.rst | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/c/csimulator.c b/c/csimulator.c index fba761bc..4d43eb45 100644 --- a/c/csimulator.c +++ b/c/csimulator.c @@ -1347,7 +1347,7 @@ static void bit_xy(CSimulatorObject* self, void* lookup, int args[]) { } #endif byte value = BIT[REG(F) & 1][b][PEEK(addr)]; - LD(F, (value & 0xD7) + ((xy / 256) & 0x28)); + LD(F, (value & 0xD7) + ((addr / 256) & 0x28)); INC_R(2); INC_T(20); diff --git a/sphinx/source/changelog.rst b/sphinx/source/changelog.rst index 028c79b6..94cd39c7 100644 --- a/sphinx/source/changelog.rst +++ b/sphinx/source/changelog.rst @@ -5,6 +5,8 @@ Changelog ----- * Fixed how the 'ADC A,*', 'SBC A,*', 'ADC HL,rr' and 'SBC HL,rr' instructions affect the half-carry flag +* Fixed how 'BIT n,(IX/Y+d)' affects bits 3 and 5 of the flags in the C version + of the Z80 simulator 9.3 (2024-08-10) ----------------