Browse Source

Emulator: Change register af 16-bit => a 8-bit

master
Riyyi 2 years ago
parent
commit
e95e7452fe
  1. 8
      src/cpu.cpp
  2. 6
      src/cpu.h

8
src/cpu.cpp

@ -33,13 +33,13 @@ void CPU::add(uint8_t byte, uint8_t immediate)
// clock += 8; // clock += 8;
// Flags: Z0HC // Flags: Z0HC
m_z = (m_af >> 8) + immediate == 0; m_z = m_a + immediate == 0;
m_n = 0; m_n = 0;
m_h = (m_af >> 8) + immediate > 16; m_h = m_a + immediate > 16;
m_c = (m_af >> 8) + immediate > 255; m_c = m_a + immediate > 255;
// A = A + r // A = A + r
m_af = m_af + (immediate << 8); m_a += immediate;
break; break;
default: default:
break; break;

6
src/cpu.h

@ -37,15 +37,15 @@ public:
// Miscellaneous Instructions // Miscellaneous Instructions
private: private:
// 16-bit registers // Registers
uint16_t m_af { 0 }; // Accumulator & Flags uint8_t m_a { 0 }; // Accumulator
uint16_t m_bc { 0 }; // BC uint16_t m_bc { 0 }; // BC
uint16_t m_de { 0 }; // DE uint16_t m_de { 0 }; // DE
uint16_t m_hl { 0 }; // HL uint16_t m_hl { 0 }; // HL
uint16_t m_sp { 0 }; // Stack Pointer uint16_t m_sp { 0 }; // Stack Pointer
uint16_t m_pc { 0 }; // Program Counter uint16_t m_pc { 0 }; // Program Counter
// 8-bit registers (flags) // Flags
uint8_t m_z { 0 }; // Zero flag uint8_t m_z { 0 }; // Zero flag
uint8_t m_n { 0 }; // Subtraction flag (BCD) uint8_t m_n { 0 }; // Subtraction flag (BCD)
uint8_t m_h { 0 }; // Half Carry flag (BCD) uint8_t m_h { 0 }; // Half Carry flag (BCD)

Loading…
Cancel
Save