From 024e6aecc359d3392a9f6420682dfda98be3a644 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Tue, 30 Aug 2022 15:20:54 +0200 Subject: [PATCH] Emulator: Add comments to cycle waiting amount --- src/cpu.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/cpu.cpp b/src/cpu.cpp index 0130d5a..4980625 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -929,24 +929,28 @@ void CPU::ldr8() { uint8_t opcode = pcRead(); switch (opcode) { - case 0x02: // LD (BC),A - m_wait_cycles += 4; + case 0x02: /* LD (BC),A */ { + m_wait_cycles += 4; // + 4 = 8 total write(bc(), m_a); break; - case 0x0a: // LD A,(BC) - m_wait_cycles += 4; + } + case 0x0a: /* LD A,(BC) */ { + m_wait_cycles += 4; // + 4 = 8 total m_a = read(bc()); break; - case 0x12: // LD (DE),A - m_wait_cycles += 4; + } + case 0x12: /* LD (DE),A */ { + m_wait_cycles += 4; // + 4 = 8 total write(de(), m_a); break; - case 0x1a: // LD A,(DE) - m_wait_cycles += 4; + } + case 0x1a: /* LD A,(DE) */ { + m_wait_cycles += 4; // + 4 = 8 total m_a = read(de()); break; - case 0x22: { // LD (HL+),A == LD (HLI),A == LDI (HL),A - m_wait_cycles += 4; + } + case 0x22: /* LD (HL+),A == LD (HLI),A == LDI (HL),A */ { + m_wait_cycles += 4; // + 4 = 8 total // Put A into memory address in HL uint32_t address = hl(); @@ -958,8 +962,8 @@ void CPU::ldr8() m_h = address >> 8; break; } - case 0x32: { // LD (HL-),A == LD (HLD),A == LDD (HL),A - m_wait_cycles += 4; + case 0x32: /* LD (HL-),A == LD (HLD),A == LDD (HL),A */ { + m_wait_cycles += 4; // + 4 = 8 total // Put A into memory address in HL uint32_t address = hl();