From f4a50aa85038e6ffbea62dc80a58f9bd642c5b0b Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 19 Nov 2024 19:16:08 -0500 Subject: cdp1852: Fixes and enhancements - Fix clock write handler - Add write handler for automatically clocking 8-bit data into input-mode latch - Add line read handler for SR output --- src/devices/machine/cdp1852.cpp | 36 ++++++++++++++++++++++++++++++++---- src/devices/machine/cdp1852.h | 2 ++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/devices/machine/cdp1852.cpp b/src/devices/machine/cdp1852.cpp index caa4f2517ad..8957590f4e4 100644 --- a/src/devices/machine/cdp1852.cpp +++ b/src/devices/machine/cdp1852.cpp @@ -103,7 +103,7 @@ void cdp1852_device::device_reset() void cdp1852_device::clock_w(int state) { - if (m_clock_active != bool(state)) + if (m_clock_active == bool(state)) return; m_clock_active = bool(state); @@ -116,7 +116,7 @@ void cdp1852_device::clock_w(int state) m_data = m_read_data(0); // signal processor - set_sr_line(0); + set_sr_line(false); } else { @@ -159,7 +159,18 @@ void cdp1852_device::set_sr_line(bool state) TIMER_CALLBACK_MEMBER(cdp1852_device::update_do) { - m_write_data(param); + if (!m_read_mode()) + { + // input data into register + m_data = param; + + // signal processor + set_sr_line(false); + } + else + { + m_write_data(param); + } } @@ -192,7 +203,7 @@ uint8_t cdp1852_device::read() //------------------------------------------------- -// write - data write +// write - data write (synchronous) //------------------------------------------------- void cdp1852_device::write(uint8_t data) @@ -205,3 +216,20 @@ void cdp1852_device::write(uint8_t data) m_new_data = true; } } + + +//------------------------------------------------- +// write_strobe - data write with asynchronous +// clock strobe +//------------------------------------------------- + +void cdp1852_device::write_strobe(uint8_t data) +{ + if (!m_read_mode()) + { + // output data + m_update_do_timer->adjust(attotime::zero, data); + + m_clock_active = false; + } +} diff --git a/src/devices/machine/cdp1852.h b/src/devices/machine/cdp1852.h index 7727715ee47..04ada134986 100644 --- a/src/devices/machine/cdp1852.h +++ b/src/devices/machine/cdp1852.h @@ -39,10 +39,12 @@ public: uint8_t read(); void write(uint8_t data); + void write_strobe(uint8_t data); void clock_w(int state); uint8_t do_r() { return m_data; } + int sr_r() { return m_sr; } protected: // device-level overrides -- cgit v1.2.3