From de4ac4e41da44c05d3e2545cf541648ee1e989de Mon Sep 17 00:00:00 2001 From: smf- Date: Fri, 17 Dec 2021 13:48:28 +0000 Subject: Z80 CTC ZC/TO goes high for one clock cycle [smf] --- src/devices/machine/z80ctc.cpp | 13 ++++++++++--- src/devices/machine/z80ctc.h | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/devices/machine/z80ctc.cpp b/src/devices/machine/z80ctc.cpp index c3004b1fade..654591e64e0 100644 --- a/src/devices/machine/z80ctc.cpp +++ b/src/devices/machine/z80ctc.cpp @@ -295,7 +295,8 @@ z80ctc_channel_device::z80ctc_channel_device(const machine_config &mconfig, cons m_down(0), m_extclk(0), m_timer(nullptr), - m_int_state(0) + m_int_state(0), + m_zc_to_timer(nullptr) { } @@ -308,6 +309,7 @@ void z80ctc_channel_device::device_start() { // initialize state m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(z80ctc_channel_device::timer_callback), this)); + m_zc_to_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(z80ctc_channel_device::zc_to_callback), this)); // register for save states save_item(NAME(m_mode)); @@ -529,10 +531,15 @@ TIMER_CALLBACK_MEMBER(z80ctc_channel_device::timer_callback) m_device->interrupt_check(); } - // generate the clock pulse (FIXME: pulse width is based on bus clock) + // generate the clock pulse m_device->m_zc_cb[m_index](1); - m_device->m_zc_cb[m_index](0); + m_zc_to_timer->adjust(m_device->clocks_to_attotime(1)); // reset the down counter m_down = m_tconst; } + +TIMER_CALLBACK_MEMBER(z80ctc_channel_device::zc_to_callback) +{ + m_device->m_zc_cb[m_index](0); +} diff --git a/src/devices/machine/z80ctc.h b/src/devices/machine/z80ctc.h index c70f1394acb..2e61a80df1b 100644 --- a/src/devices/machine/z80ctc.h +++ b/src/devices/machine/z80ctc.h @@ -60,6 +60,7 @@ protected: attotime period() const; void trigger(bool state); TIMER_CALLBACK_MEMBER(timer_callback); + TIMER_CALLBACK_MEMBER(zc_to_callback); required_device m_device; // pointer back to our device int m_index; // our channel index @@ -69,6 +70,7 @@ protected: bool m_extclk; // current signal from the external clock emu_timer * m_timer; // array of active timers u8 m_int_state; // interrupt status (for daisy chain) + emu_timer * m_zc_to_timer; // zc to pulse timer }; // ======================> z80ctc_device -- cgit v1.2.3