summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/r10696.cpp
blob: e04484fa32e1233a0204c321f870eb91e6f0cf8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// license:BSD-3-Clause
// copyright-holders:Juergen Buchmueller
/**********************************************************************

    Rockwell 10696 General Purpose Input/Output (I/O)

    REGISTER DESCRIPTION

    HEX    Address   Select     Names
    -------------------------------------------------------
    A      x x x x   1 0 1 0    Read Group A
    9      x x x x   1 0 0 1    Read Group B
    3      x x x x   0 0 1 1    Read Group C
    0      x x x x   0 0 0 0    Read Groups A | B | C
    1      x x x x   0 0 0 1    Read Groups B | C
    2      x x x x   0 0 1 0    Read Groups A | C
    8      x x x x   1 0 0 0    Read Groups A | B

    E      x x x x   1 1 1 0    Set Group A
    D      x x x x   1 1 0 1    Set Group B
    7      x x x x   0 1 1 1    Set Group C
    4      x x x x   0 1 0 0    Set Groups A, B and C
    5      x x x x   0 1 0 1    Set Groups B and C
    6      x x x x   0 1 1 0    Set Groups A and C
    C      x x x x   1 1 0 0    Set Groups A and B

    Notes:
    Any of the I/O chips may be used to read or set any group
    (A, B, C) or combination of groups.
**********************************************************************/

#include "emu.h"
#include "machine/r10696.h"

#define VERBOSE 1
#if VERBOSE
#define LOG(x) logerror x
#else
#define LOG(x)
#endif

/*************************************
 *
 *  Device interface
 *
 *************************************/

const device_type R10696 = &device_creator<r10696_device>;

r10696_device::r10696_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, R10696, "Rockwell 10696", tag, owner, clock, "r10696", __FILE__),
		m_io_a(0), m_io_b(0), m_io_c(0),
		m_iord(*this), m_iowr(*this)
{
}

/**
 * @brief r10696_device::device_start device-specific startup
 */
void r10696_device::device_start()
{
	m_iord.resolve();
	m_iowr.resolve();

	save_item(NAME(m_io_a));
	save_item(NAME(m_io_b));
	save_item(NAME(m_io_c));
}

/**
 * @brief r10696_device::device_reset device-specific reset
 */
void r10696_device::device_reset()
{
	m_io_a = 0;
	m_io_b = 0;
	m_io_c = 0;
}

/*************************************
 *
 *  Command access handlers
 *
 *************************************/

WRITE8_MEMBER( r10696_device::io_w )
{
	assert(offset < 16);
	const uint8_t io_a = m_io_a;
	const uint8_t io_b = m_io_b;
	const uint8_t io_c = m_io_c;
	switch (offset)
	{
	case 0x0A: // Read Group A
	case 0x09: // Read Group B
	case 0x03: // Read Group C
	case 0x00: // Read Groups A | B | C
	case 0x01: // Read Groups B | C
	case 0x02: // Read Groups A | C
	case 0x08: // Read Groups A | B
		break;

	case 0x0E: // Set Group A
		m_io_a = data & 0x0f;
		break;
	case 0x0D: // Set Group B
		m_io_b = data & 0x0f;
		break;
	case 0x07: // Set Group C
		m_io_c = data & 0x0f;
		break;
	case 0x04: // Set Groups A, B and C
		m_io_a = m_io_b = m_io_c = data & 0x0f;
		break;
	case 0x05: // Set Groups B and C
		m_io_b = m_io_c = data & 0x0f;
		break;
	case 0x06: // Set Groups A and C
		m_io_a = m_io_c = data & 0x0f;
		break;
	case 0x0C: // Set Groups A and B
		m_io_a = m_io_b = data & 0x0f;
		break;
	}
	if (io_a != m_io_a)
		m_iowr(0, m_io_a, 0x0f);
	if (io_b != m_io_b)
		m_iowr(1, m_io_b, 0x0f);
	if (io_c != m_io_c)
		m_iowr(2, m_io_c, 0x0f);
}


READ8_MEMBER( r10696_device::io_r )
{
	assert(offset < 16);
	uint8_t io_a, io_b, io_c;
	uint8_t data = 0xf;
	switch (offset)
	{
	case 0x0A: // Read Group A
		io_a = m_iord(0);
		data = io_a & 0x0f;
		break;
	case 0x09: // Read Group B
		io_b = m_iord(1);
		data = io_b & 0x0f;
		break;
	case 0x03: // Read Group C
		io_c = m_iord(2);
		data = io_c & 0x0f;
		break;
	case 0x00: // Read Groups A | B | C
		io_a = m_iord(0);
		io_b = m_iord(1);
		io_c = m_iord(2);
		data = (io_a | io_b | io_c) & 0x0f;
		break;
	case 0x01: // Read Groups B | C
		io_b = m_iord(1);
		io_c = m_iord(2);
		data = (io_b | io_c) & 0x0f;
		break;
	case 0x02: // Read Groups A | C
		io_a = m_iord(0);
		io_c = m_iord(2);
		data = (io_a | io_c) & 0x0f;
		break;
	case 0x08: // Read Groups A | B
		io_a = m_iord(0);
		io_b = m_iord(1);
		data = (io_a | io_b) & 0x0f;
		break;

	case 0x0E: // Set Group A
	case 0x0D: // Set Group B
	case 0x07: // Set Group C
	case 0x04: // Set Groups A, B and C
	case 0x05: // Set Groups B and C
	case 0x06: // Set Groups A and C
	case 0x0C: // Set Groups A and B
		break;
	}
	return data;
}