diff options
author | 2019-02-13 20:14:00 +0100 | |
---|---|---|
committer | 2019-02-13 20:14:00 +0100 | |
commit | a560bfcc20c88505c405b6837c78d036cc8e87c6 (patch) | |
tree | db8984c1bdeb5fc40c5091d6119a9e9ef7e190e0 | |
parent | 088c214cf75e442a0e8df566f0541571b07bcb2f (diff) |
ins8154.cpp: Fixed bit register accesses
-rw-r--r-- | src/devices/machine/ins8154.cpp | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/src/devices/machine/ins8154.cpp b/src/devices/machine/ins8154.cpp index 8a134000f3f..ff1cd79906e 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 @@ -119,17 +122,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; } @@ -148,6 +157,7 @@ WRITE8_MEMBER(ins8154_device::ins8154_porta_w) WRITE8_MEMBER(ins8154_device::ins8154_portb_w) { + 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 */ @@ -193,17 +203,29 @@ 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); + ins8154_porta_w(space, 0, 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); + ins8154_portb_w(space, 0, 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); + ins8154_porta_w(space, 0, 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); + ins8154_portb_w(space, 0, m_out_b & ~(1 << (offset & 0x07))); + } } break; } |