From 0e5d1ffe4abf6af1deb3de896e2b72a51384df1a Mon Sep 17 00:00:00 2001 From: hap Date: Fri, 24 Mar 2017 18:26:13 +0100 Subject: tms1024: added MS pin, added write to port 0 (nw) --- src/devices/machine/tms1024.cpp | 58 ++++++++++++++++++++++------------------- src/devices/machine/tms1024.h | 9 ++++--- src/mame/drivers/hh_tms1k.cpp | 1 + 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/devices/machine/tms1024.cpp b/src/devices/machine/tms1024.cpp index 7dc30c4437a..ca47a6e79c9 100644 --- a/src/devices/machine/tms1024.cpp +++ b/src/devices/machine/tms1024.cpp @@ -4,13 +4,12 @@ Texas Instruments TMS1024/TMS1025 I/O expander - No documentation was available, just a pinout. + No documentation was available, just a pinout. But documentation + is available for pin-compatible Mitsubishi M50780SP/M50781SP. Other than more port pins, TMS1025 is assumed to be same as TMS1024. TODO: - - writes to port 0 - - what's the MS pin? - - strobe is on rising edge? or falling edge? + - x */ @@ -26,7 +25,7 @@ const device_type TMS1025 = device_creator; //------------------------------------------------- tms1024_device::tms1024_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source) - : device_t(mconfig, type, name, tag, owner, clock, shortname, source), m_h(0), m_s(0), m_std(0), + : device_t(mconfig, type, name, tag, owner, clock, shortname, source), m_h(0), m_s(0), m_std(0), m_ms(0), m_read_port{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}}, m_write_port{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}} { @@ -56,24 +55,11 @@ void tms1024_device::device_start() for (devcb_write8 &cb : m_write_port) cb.resolve_safe(); - // zerofill - m_h = 0; - m_s = 0; - m_std = 0; - // register for savestates save_item(NAME(m_h)); save_item(NAME(m_s)); save_item(NAME(m_std)); -} - - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void tms1024_device::device_reset() -{ + save_item(NAME(m_ms)); } @@ -88,6 +74,20 @@ WRITE8_MEMBER(tms1024_device::write_h) m_h = data & 0xf; } +READ8_MEMBER(tms1024_device::read_h) +{ + if (!m_ms) + { + // read selected port data + if (m_s != 0) + m_h = (m_read_port[m_s-1])((offs_t)(m_s-1)) & 0xf; + + // high-impedance otherwise + } + + return m_h; +} + WRITE8_MEMBER(tms1024_device::write_s) { // S0,1,2: select port @@ -98,21 +98,25 @@ WRITE_LINE_MEMBER(tms1024_device::write_std) { state = (state) ? 1 : 0; - // output on rising edge - if (state && !m_std) + // output on falling edge + if (m_ms && !state && m_std) { if (m_s != 0) (m_write_port[m_s-1])((offs_t)(m_s-1), m_h); + + else + { + // reset all ports + for (int i = TMS1025_PORT1; i <= TMS1025_PORT7; i++) + (m_write_port[i])((offs_t)(i), 0); + } } m_std = state; } -READ8_MEMBER(tms1024_device::read_h) +WRITE_LINE_MEMBER(tms1024_device::write_ms) { - // TODO: which pin enables read? - if (m_s != 0) - m_h = (m_read_port[m_s-1])((offs_t)(m_s-1)) & 0xf; - - return m_h; + // 0: multiplexer(read) mode, 1: latch(write) mode + m_ms = (state) ? 1 : 0; } diff --git a/src/devices/machine/tms1024.h b/src/devices/machine/tms1024.h index a5ccb5bdb78..89f6139a786 100644 --- a/src/devices/machine/tms1024.h +++ b/src/devices/machine/tms1024.h @@ -54,8 +54,8 @@ enum A5 15 | | 26 D6 B5 16 | | 25 C6 CE: Chip Enable C5 17 | | 24 B6 - MS: Master S.? D5 18 | | 23 A6 - STD: STrobe Data? A2 19 | | 22 D2 + MS: Mode Select D5 18 | | 23 A6 + STD: STrobe Data A2 19 | | 22 D2 S: Select B2 20 |___________| 21 C2 H: Hold? @@ -81,18 +81,19 @@ public: } DECLARE_WRITE8_MEMBER(write_h); + DECLARE_READ8_MEMBER(read_h); DECLARE_WRITE8_MEMBER(write_s); DECLARE_WRITE_LINE_MEMBER(write_std); - DECLARE_READ8_MEMBER(read_h); + DECLARE_WRITE_LINE_MEMBER(write_ms); protected: // device-level overrides virtual void device_start() override; - virtual void device_reset() override; u8 m_h; // 4-bit data latch u8 m_s; // 3-bit port select u8 m_std; // strobe pin + u8 m_ms; // mode select pin, default to read mode // callbacks devcb_read8 m_read_port[7]; diff --git a/src/mame/drivers/hh_tms1k.cpp b/src/mame/drivers/hh_tms1k.cpp index cbded704dde..3d273d32e69 100644 --- a/src/mame/drivers/hh_tms1k.cpp +++ b/src/mame/drivers/hh_tms1k.cpp @@ -8130,6 +8130,7 @@ void tbreakup_state::machine_reset() { hh_tms1k_state::machine_reset(); set_clock(); + m_expander->write_ms(1); // Vss } void tbreakup_state::machine_start() -- cgit v1.2.3