mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
Merge pull request #4637 from JoakimLarsson/ins8154
ins8154.cpp: Fixed bit register accesses
This commit is contained in:
commit
f077ba0567
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user