From c8ad40c128187e620c24436e6981f2bf7e9906b8 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Thu, 1 Sep 2022 11:06:13 +0200 Subject: [PATCH] Emulator: Fix LD A,a16 opcode: 0xfa --- src/cpu.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cpu.cpp b/src/cpu.cpp index a1ab3eb..c2bfa35 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -878,7 +878,9 @@ void CPU::lda8() break; case 0xfa: // LD A,a16 m_wait_cycles += 16; - m_a = pcRead16(); + + // Load value in register A from the byte pointed to by register r16 + m_a = read(pcRead16()); break; default: VERIFY_NOT_REACHED(); @@ -1167,6 +1169,8 @@ void CPU::ldr8() } case 0xea: /* LD a16,A */ { m_wait_cycles += 12; // + 4 = 16 total + + // Store value in register A into the byte at address a16 write(pcRead16(), m_a); break; }