From e2fc3f0cbe6998072f9c4500c6904ff9e92b1c21 Mon Sep 17 00:00:00 2001 From: AJR Date: Fri, 18 Oct 2019 22:57:40 -0400 Subject: [PATCH] i8257: Various small improvements (nw) - Synchronize at a couple of critical points - Allow read side effects to be suppressed while debugging - Improve TC timing - Allow HLDA to abort DMA cycle - Don't clear request input state when device is reset --- src/devices/machine/i8257.cpp | 43 +++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/devices/machine/i8257.cpp b/src/devices/machine/i8257.cpp index fb3c1a692ed..c51de689087 100644 --- a/src/devices/machine/i8257.cpp +++ b/src/devices/machine/i8257.cpp @@ -82,7 +82,7 @@ enum inline void i8257_device::dma_request(int channel, int state) { - LOG("I8257 Channel %u DMA Request: %u\n", channel, state); + LOG("I8257 Channel %u DMA Request: %u (%sabled)\n", channel, state, MODE_CHAN_ENABLE(channel) ? "en" : "dis"); if (state) m_request |= 1 << channel; @@ -114,6 +114,7 @@ inline void i8257_device::set_hreq(int state) { m_out_hrq_cb(state); m_hreq = state; + abort_timeslice(); } } @@ -212,13 +213,13 @@ inline void i8257_device::dma_write() inline void i8257_device::advance() { LOG("%s\n", FUNCNAME); - bool tc = (m_channel[m_current_channel].m_count == 0); + bool tc = m_tc; bool al = (MODE_AUTOLOAD && (m_current_channel == 2)); + set_tc(0); if(tc) { m_status |= 1 << m_current_channel; - set_tc(1); if(al) { @@ -337,7 +338,6 @@ void i8257_device::device_reset() m_state = STATE_SI; m_transfer_mode = 0; m_status = 0; - m_request = 0; m_msb = 0; m_current_channel = -1; m_last_channel = 3; @@ -400,8 +400,8 @@ void i8257_device::execute_run() m_state = STATE_S0; else { - suspend_until_trigger(1, true); m_icount = 0; + suspend_until_trigger(1, true); } break; @@ -414,8 +414,8 @@ void i8257_device::execute_run() } else { - suspend_until_trigger(1, true); m_icount = 0; + suspend_until_trigger(1, true); } break; @@ -437,11 +437,23 @@ void i8257_device::execute_run() dma_write(); } - m_state = m_ready ? STATE_S4 : STATE_SW; + if (m_ready) + { + m_state = STATE_S4; + if (m_channel[m_current_channel].m_count == 0) + set_tc(1); + } + else + m_state = STATE_SW; break; case STATE_SW: - m_state = m_ready ? STATE_S4 : STATE_SW; + if (m_ready) + { + m_state = STATE_S4; + if (m_channel[m_current_channel].m_count == 0) + set_tc(1); + } break; case STATE_S4: @@ -451,7 +463,7 @@ void i8257_device::execute_run() } advance(); - if(next_channel()) + if(m_hack && next_channel()) m_state = STATE_S1; else { @@ -509,14 +521,16 @@ READ8_MEMBER( i8257_device::read ) break; } - m_msb = !m_msb; + if (!machine().side_effects_disabled()) + m_msb = !m_msb; } else if(offset == REGISTER_STATUS) { data = m_status; // clear TC bits - m_status &= 0xf0; + if (!machine().side_effects_disabled()) + m_status &= 0xf0; } return data; @@ -585,7 +599,12 @@ WRITE8_MEMBER( i8257_device::write ) LOGSETUP("I8257 Command Register: %02x\n", m_transfer_mode); } - trigger(1); + + if ((m_transfer_mode & m_request & 0x0f) != 0) + { + machine().scheduler().eat_all_cycles(); + trigger(1); + } }