diff options
author | Oxore <oxore@protonmail.com> | 2022-09-30 01:21:52 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2022-09-30 01:21:52 +0300 |
commit | f125cc7018ed32b7f919ff71ea3c7d9d2e6565de (patch) | |
tree | 0cb150b6e712b000fc334f07f426e01ed2f60cd7 /vdp.cpp | |
parent | dedd5c981ee95d9667f1f2e5d0b419f08bee3908 (diff) |
Begin implementing VDP
Diffstat (limited to 'vdp.cpp')
-rw-r--r-- | vdp.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
@@ -0,0 +1,64 @@ +/* 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; + } +} |