From 897c498b543f88d9b97f39e7a8f3aa691d11cc37 Mon Sep 17 00:00:00 2001 From: Oxore Date: Sun, 2 Oct 2022 13:15:54 +0300 Subject: Refactor VDP read tracing --- vdp.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'vdp.cpp') diff --git a/vdp.cpp b/vdp.cpp index 0ac6e1b..74b9f65 100644 --- a/vdp.cpp +++ b/vdp.cpp @@ -8,32 +8,36 @@ uint32_t VDP::Read(const uint32_t offset, const enum bitness bitness) { + uint32_t ret{}; if (DEBUG_TRACE_VDP_ACCESS) { printf( - "VDP r%d%s @0x%08x\n", + "VDP r%d%s @0x%08x", bitness * 8, (bitness <= 1 ? " " : ""), base_address + offset); } if (bitness == BITNESS_32) { if (offset == 0) { - const uint16_t ret = readData(_address_mode, _address & 0xfffe); + ret = readData(_address_mode, _address & 0xfffe) << 16; + _address += _reg[static_cast(RegID::kAutoIncrement)]; + ret |= readData(_address_mode, _address & 0xfffe); _address += _reg[static_cast(RegID::kAutoIncrement)]; - return ret; } else if (offset == 4) { - return readStatusRegister() | (readStatusRegister() << 16); + ret = readStatusRegister() | (readStatusRegister() << 16); } } else if (bitness == BITNESS_16) { if (offset == 0 || offset == 2) { - const uint16_t ret = readData(_address_mode, _address & 0xfffe); + ret = readData(_address_mode, _address & 0xfffe); _address += _reg[static_cast(RegID::kAutoIncrement)]; - return ret; } else if (offset == 4 || offset == 6) { - return readStatusRegister(); + ret = readStatusRegister(); } } // XXX: Ignore 8-bit reads for now - return 0; + if (DEBUG_TRACE_VDP_ACCESS) { + printf("\n"); + } + return ret; } void VDP::Write(const uint32_t offset, const enum bitness bitness, const uint32_t value) @@ -241,7 +245,7 @@ uint16_t VDP::readData(const uint8_t address_mode, const uint16_t address) uint16_t VDP::readStatusRegister() const { - return 0 + const uint16_t value = 0 | (!_status.fifo_not_empty << 9) | (_status.fifo_full << 8) | (_status.v_irq << 7) @@ -253,6 +257,10 @@ uint16_t VDP::readStatusRegister() const | (_status.dma_busy << 1) | (_status.pal_mode << 0) ; + if (DEBUG_TRACE_VDP_ACCESS) { + printf(": Status %04x", value); + } + return value; } const char* VDP::addressModeToString(const uint8_t address_mode) -- cgit v1.2.3