diff options
Diffstat (limited to 'src/devices/machine/ins8154.cpp')
-rw-r--r-- | src/devices/machine/ins8154.cpp | 71 |
1 files changed, 52 insertions, 19 deletions
diff --git a/src/devices/machine/ins8154.cpp b/src/devices/machine/ins8154.cpp index 8a134000f3f..11943cdee2c 100644 --- a/src/devices/machine/ins8154.cpp +++ b/src/devices/machine/ins8154.cpp @@ -1,21 +1,24 @@ // license:GPL-2.0+ // copyright-holders:Dirk Best -/*************************************************************************** +/****************************************************************************** National Semiconductor INS8154 N-Channel 128-by-8 Bit RAM Input/Output (RAM I/O) TODO: Strobed modes + TODO: Check the ODRx register for where to get pin values, _cb() vs m_out_x -***************************************************************************/ +*******************************************************************************/ #include "emu.h" #include "ins8154.h" -#define VERBOSE 1 +#define LOG_BITS (1U << 1) +//#define VERBOSE (LOG_BITS) // (LOG_GENERAL|LOG_BITS) #include "logmacro.h" +#define LOGBITS(...) LOGMASKED(LOG_BITS, __VA_ARGS__) /*************************************************************************** CONSTANTS @@ -75,6 +78,7 @@ void ins8154_device::device_start() save_item(NAME(m_mdr)); save_item(NAME(m_odra)); save_item(NAME(m_odrb)); + save_item(NAME(m_ram)); } @@ -94,7 +98,7 @@ void ins8154_device::device_reset() } -READ8_MEMBER(ins8154_device::ins8154_r) +uint8_t ins8154_device::read_io(offs_t offset) { uint8_t val = 0xff; @@ -119,17 +123,23 @@ READ8_MEMBER(ins8154_device::ins8154_r) break; default: - if (offset < 0x08) + val = 0; + if (offset < 0x08) // Read a bit in Port A { if (!m_in_a_cb.isnull()) - val = (m_in_a_cb(0) << (8 - offset)) & 0x80; - m_in_a = val; + { + //val = (m_in_a_cb(0) << (8 - offset)) & 0x80; + val = (m_in_a_cb(0) & ~m_odra & (1 << (offset & 0x07))) ? 0x80 : 0x00; + } + LOGBITS("%s: INS8154 Port A read bit %02x: %02x\n", machine().describe_context(), offset & 0x07, val); } - else + else // Read a bit in Port B { if (!m_in_b_cb.isnull()) - val = (m_in_b_cb(0) << (8 - (offset >> 4))) & 0x80; - m_in_b = val; + { + val = (m_in_b_cb(0) & ~m_odrb & (1 << (offset & 0x07))) ? 0x80 : 0x00; + } + LOGBITS("%s: INS8154 Port B read bit %02x: %02x\n", machine().describe_context(), offset & 0x07, val); } break; } @@ -137,7 +147,12 @@ READ8_MEMBER(ins8154_device::ins8154_r) return val; } -WRITE8_MEMBER(ins8154_device::ins8154_porta_w) +uint8_t ins8154_device::read_ram(offs_t offset) +{ + return m_ram[offset & 0x7f]; +} + +void ins8154_device::porta_w(uint8_t data) { m_out_a = data; @@ -146,8 +161,9 @@ WRITE8_MEMBER(ins8154_device::ins8154_porta_w) m_out_a_cb(offs_t(0), (data & m_odra) | (m_odra ^ 0xff)); } -WRITE8_MEMBER(ins8154_device::ins8154_portb_w) +void ins8154_device::portb_w(uint8_t data) { + LOG("%s: INS8154 Write PortB %02x with odrb: %02x\n", machine().describe_context(), data, m_odrb); m_out_b = data; /* Test if any pins are set as outputs */ @@ -155,7 +171,7 @@ WRITE8_MEMBER(ins8154_device::ins8154_portb_w) m_out_b_cb(offs_t(0), (data & m_odrb) | (m_odrb ^ 0xff)); } -WRITE8_MEMBER(ins8154_device::ins8154_w) +void ins8154_device::write_io(offs_t offset, uint8_t data) { if (offset > 0x24) { @@ -166,11 +182,11 @@ WRITE8_MEMBER(ins8154_device::ins8154_w) switch (offset) { case 0x20: - ins8154_porta_w(space, 0, data); + porta_w(data); break; case 0x21: - ins8154_portb_w(space, 0, data); + portb_w(data); break; case 0x22: @@ -193,18 +209,35 @@ WRITE8_MEMBER(ins8154_device::ins8154_w) { /* Set bit */ if (offset < 0x08) - ins8154_porta_w(space, 0, m_out_a |= offset & 0x07); + { + LOGBITS("%s: INS8154 Port A set bit %02x\n", machine().describe_context(), offset & 0x07); + porta_w(m_out_a |= (1 << (offset & 0x07))); + } else - ins8154_portb_w(space, 0, m_out_b |= (offset >> 4) & 0x07); + { + LOGBITS("%s: INS8154 Port B set bit %02x\n", machine().describe_context(), offset & 0x07); + portb_w(m_out_b |= (1 << (offset & 0x07))); + } } else { /* Clear bit */ if (offset < 0x08) - ins8154_porta_w(space, 0, m_out_a & ~(offset & 0x07)); + { + LOGBITS("%s: INS8154 Port A clear bit %02x\n", machine().describe_context(), offset & 0x07); + porta_w(m_out_a & ~(1 << (offset & 0x07))); + } else - ins8154_portb_w(space, 0, m_out_b & ~((offset >> 4) & 0x07)); + { + LOGBITS("%s: INS8154 Port B clear bit %02x\n", machine().describe_context(), offset & 0x07); + portb_w(m_out_b & ~(1 << (offset & 0x07))); + } } break; } } + +void ins8154_device::write_ram(offs_t offset, uint8_t data) +{ + m_ram[offset & 0x7f] = data; +} |