/* SPDX-License-Identifier: Unlicense */ #include "vdp.hpp" uint32_t VDP::Read(const uint32_t offset, const enum bitness bitness) { const uint32_t res{}; if (DEBUG_TRACE_VDP_ACCESS) { printf( "VDP r%d%s @0x%08x 0x%0*x\n", bitness * 8, (bitness <= 1 ? " " : ""), base_address + offset, bitness * 2, res); } if (bitness == BITNESS_32) { // TODO } else if (bitness == BITNESS_16) { // TODO } // Ignore 8-bit reads for now return 0; } void VDP::Write(const uint32_t offset, const enum bitness bitness, const uint32_t value) { if (DEBUG_TRACE_VDP_ACCESS) { printf( "VDP w%d%s @0x%08x 0x%0*x", bitness * 8, (bitness <= 1 ? " " : ""), base_address + offset, bitness * 2, value); } if (bitness == BITNESS_32) { if (offset == 4 || offset == 6) { writeControl((value >> 16) & 0xffff); writeControl(value & 0xffff); } } else if (bitness == BITNESS_16) { if (offset == 4 || offset == 6) { writeControl(value & 0xffff); } } if (DEBUG_TRACE_VDP_ACCESS) { printf("\n"); } // Ignore 8-bit writes for now } void VDP::writeControl(const uint16_t value) { if (((value >> 13) & 0x7) == 4) { const uint8_t reg_num = (value >> 8) & 0x1f; const uint8_t reg_val = value & 0xff; if (DEBUG_TRACE_VDP_ACCESS) { printf(": reg 0x%02x w 0x%02x", reg_num, reg_val); } _reg[reg_num] = reg_val; } }