diff options
author | 2020-11-12 17:42:56 +0000 | |
---|---|---|
committer | 2020-11-12 18:42:56 +0100 | |
commit | c13709f111f4c0c0982bac1b4616589ef2f7d2cc (patch) | |
tree | 652138f1764c08407e4d7415026e23a5de45ad24 | |
parent | 494b7ef63fafe62b27eb9e81dfad0db0f5c6cd65 (diff) |
st2205u: DMA required by PR #7430 (#7444)
-rw-r--r-- | src/devices/cpu/m6502/st2205u.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/devices/cpu/m6502/st2205u.cpp b/src/devices/cpu/m6502/st2205u.cpp index a9417ec2cce..31ae0ffb35f 100644 --- a/src/devices/cpu/m6502/st2205u.cpp +++ b/src/devices/cpu/m6502/st2205u.cpp @@ -926,8 +926,26 @@ u8 st2205u_base_device::dcnth_r() void st2205u_base_device::dcnth_w(u8 data) { - m_dcnt[m_dctr >> 1] = (m_dcnt[m_dctr >> 1] & 0x7f00) | data; - // TODO: start DMA here + m_dcnt[m_dctr >> 1] = (data & 0x7f) << 8 | (m_dcnt[m_dctr >> 1] & 0x00ff); + + // start DMA + int source = m_dptr[(m_dctr & 2) + 0]; + int dest = m_dptr[(m_dctr & 2) + 1]; + int length = m_dcnt[m_dctr >> 1] << 1; + + if ((m_dbkr[(m_dctr & 2) + 0] != 0x8000) || (m_dbkr[(m_dctr & 2) + 1] != 0x8000) || (m_dmod[m_dctr >> 1] != 0x30)) + logerror("%s: unhandled DMA parameter %04x %04x %02x\n", machine().describe_context(), m_dbkr[(m_dctr & 2) + 0], m_dbkr[(m_dctr & 2) + 1], m_dmod[m_dctr >> 1]); + + address_space& mem = this->space(AS_PROGRAM); + + // FIXME: DMA should be performed in the execution loop and consume bus cycles, not happen instantly + for (int i = 0; i < length; i++) + { + uint8_t byte = mem.read_byte(source); + mem.write_byte(dest, byte); + source++; + dest++; + } } u8 st2205u_base_device::dctr_r() |