From 82d2eea5a9452a5a6c9bf31e6c5191394a2dd686 Mon Sep 17 00:00:00 2001 From: arbee Date: Sun, 23 Aug 2020 12:01:40 -0400 Subject: 6522via.cpp: Add support for CB2 pulse mode [R. Belmont, Peter Ferrie] --- src/devices/machine/6522via.cpp | 20 +++++++++++++++++++- src/devices/machine/6522via.h | 3 +++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/devices/machine/6522via.cpp b/src/devices/machine/6522via.cpp index a0b66c138d8..37c7237db52 100644 --- a/src/devices/machine/6522via.cpp +++ b/src/devices/machine/6522via.cpp @@ -227,6 +227,7 @@ void via6522_device::device_start() m_t1 = timer_alloc(TIMER_T1); m_t2 = timer_alloc(TIMER_T2); m_ca2_timer = timer_alloc(TIMER_CA2); + m_cb2_timer = timer_alloc(TIMER_CB2); m_shift_timer = timer_alloc(TIMER_SHIFT); m_shift_irq_timer = timer_alloc(TIMER_SHIFT_IRQ); @@ -308,6 +309,7 @@ void via6522_device::device_reset() m_t1->adjust(attotime::never); m_t2->adjust(attotime::never); m_ca2_timer->adjust(attotime::never); + m_cb2_timer->adjust(attotime::never); m_shift_timer->adjust(attotime::never); m_shift_irq_timer->adjust(attotime::never); } @@ -585,6 +587,17 @@ u8 via6522_device::read(offs_t offset) { LOGINT("PB INT "); CLR_PB_INT(); + + if (m_out_cb2 && (CB2_PULSE_OUTPUT(m_pcr) || CB2_AUTO_HS(m_pcr))) + { + m_out_cb2 = 0; + m_cb2_handler(m_out_cb2); + } + + if (CB2_PULSE_OUTPUT(m_pcr)) + { + m_cb2_timer->adjust(clocks_to_attotime(1)); + } } break; @@ -780,11 +793,16 @@ void via6522_device::write(offs_t offset, u8 data) LOGINT("PB INT "); CLR_PB_INT(); - if (m_out_cb2 && CB2_AUTO_HS(m_pcr)) + if (m_out_cb2 && (CB2_PULSE_OUTPUT(m_pcr) || CB2_AUTO_HS(m_pcr))) { m_out_cb2 = 0; m_cb2_handler(m_out_cb2); } + + if (CB2_PULSE_OUTPUT(m_pcr)) + { + m_cb2_timer->adjust(clocks_to_attotime(1)); + } break; case VIA_PA: diff --git a/src/devices/machine/6522via.h b/src/devices/machine/6522via.h index c79f0fa5903..1a705ab6a29 100644 --- a/src/devices/machine/6522via.h +++ b/src/devices/machine/6522via.h @@ -105,6 +105,8 @@ private: static constexpr device_timer_id TIMER_T2 = 2; static constexpr device_timer_id TIMER_CA2 = 3; static constexpr device_timer_id TIMER_SHIFT_IRQ = 4; + static constexpr device_timer_id TIMER_CB2 = 5; + uint16_t get_counter1_value(); void counter2_decrement(); @@ -175,6 +177,7 @@ private: attotime m_time2; uint8_t m_t2_active; emu_timer *m_ca2_timer; + emu_timer *m_cb2_timer; emu_timer *m_shift_timer; emu_timer *m_shift_irq_timer; -- cgit v1.2.3