summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2022-10-02 13:15:54 +0300
committerOxore <oxore@protonmail.com>2022-10-02 13:15:54 +0300
commit897c498b543f88d9b97f39e7a8f3aa691d11cc37 (patch)
tree73e47d867a9da8aa35ae58927ab4a867449ec47a
parentcb7f668b0acbb79fe4360186b87206f582ca5c23 (diff)
Refactor VDP read tracing
-rw-r--r--vdp.cpp26
1 files changed, 17 insertions, 9 deletions
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<size_t>(RegID::kAutoIncrement)];
+ ret |= readData(_address_mode, _address & 0xfffe);
_address += _reg[static_cast<size_t>(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<size_t>(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)