From 1acb5af23e38001f579f66a18ed7b788a29b7277 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Tue, 23 Aug 2022 15:53:13 +0200 Subject: [PATCH] Emulator: Add function to retrieve AF/PC/SP register --- src/cpu.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cpu.h b/src/cpu.h index c5c6996..106a9cb 100644 --- a/src/cpu.h +++ b/src/cpu.h @@ -57,6 +57,15 @@ public: // ------------------------------------- // Miscellaneous Instructions + // ------------------------------------- + + uint32_t af() const { return (m_cf << 4 | m_hf << 5 | m_nf << 6 | m_zf << 7) | m_a << 8; } + uint32_t bc() const { return m_c | m_b << 8; } + uint32_t de() const { return m_e | m_d << 8; } + uint32_t hl() const { return m_l | m_h << 8; } + uint32_t pc() const { return m_pc; } + uint32_t sp() const { return m_sp; } + private: uint32_t pcRead(); uint32_t pcRead16() { return pcRead() | (pcRead() << 8); } @@ -67,10 +76,6 @@ private: void ffWrite(uint32_t address, uint32_t value); uint32_t ffRead(uint32_t address); - uint32_t bc() const { return m_b << 8 | m_c; } - uint32_t de() const { return m_b << 8 | m_c; } - uint32_t hl() const { return m_b << 8 | m_c; } - // Registers uint32_t m_a { 0 }; // Accumulator uint32_t m_b { 0 }; // B