summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/rc2014/rc2014.h
blob: 2cca6e784d76efee824dd16f7c69dd2f9d619f58 (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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
// license:BSD-3-Clause
// copyright-holders:Miodrag Milanovic
/***************************************************************************

    RC2014 Bus Device

===========================================================================
 Standard Bus|        Extended Bus        |        RC80 RC2014 Bus
=============|============================|================================
 Pin Signal  |Pin Signal       Pin Signal |Pin #  Signal   Pin Signal
=============|============================|================================
 1   A15     |1   Not used     1   A15    |41  #41 (custom)  1   A15
 2   A14     |2   Not used     2   A14    |42  #42 (custom)  2   A14
 3   A13     |3   Not used     3   A13    |43  #43 (custom)  3   A13
 4   A12     |4   Not used     4   A12    |44  #44 (custom)  4   A12
 5   A11     |5   Not used     5   A11    |45  #45 (custom)  5   A11
 6   A10     |6   Not used     6   A10    |46  #46 (custom)  6   A10
 7   A9      |7   Not used     7   A9     |47  #47 (custom)  7   A9
 8   A8      |8   Not used     8   A8     |48  #48 (custom)  8   A8
 9   A7      |9   Not used     9   A7     |49  A23           9   A7
 10  A6      |10  Not used     10  A6     |50  A22           10  A6
 11  A5      |11  Not used     11  A5     |51  A21           11  A5
 12  A4      |12  Not used     12  A4     |52  A20           12  A4
 13  A3      |13  Not used     13  A3     |53  A19           13  A3
 14  A2      |14  Not used     14  A2     |54  A18           14  A2
 15  A1      |15  Not used     15  A1     |55  A17           15  A1
 16  A0      |16  Not used     16  A0     |56  A16           16  A0
 17  GND     |17  GND          17  GND    |57  GND           17  GND
 18  5V      |18  5V           18  5V     |58  5V            18  5V
 19  /M1     |19  /RFSH        19  /M1    |59  /RFSH         19  /M1
 20  /RESET  |20  PAGE(/RESET2)20  /RESET |60  PAGE          20  /RESET
 21  CLK     |21  CLK2         21  CLK    |61  CLK2          21  CLK
 22  /INT    |22  /BUSAK       22  /INT   |62  /BUSAK        22  /INT
 23  /MREQ   |23  /HALT        23  /MREQ  |63  /HALT         23  /MREQ
 24  /WR     |24  /BUSRQ       24  /WR    |64  /BUSRQ        24  /WR
 25  /RD     |25  /WAIT        25  /RD    |65  /WAIT         25  /RD
 26  /IORQ   |26  /NMI         26  /IORQ  |66  /NMI          26  /IORQ
 27  D0      |27  D8           27  D0     |67  #67 (custom)  27  D0
 28  D1      |28  D9           28  D1     |68  #68 (custom)  28  D1
 29  D2      |29  D10          29  D2     |69  #69 (custom)  29  D2
 30  D3      |30  D11          30  D3     |70  #70 (custom)  30  D3
 31  D4      |31  D12          31  D4     |71  #71 (custom)  31  D4
 32  D5      |32  D13          32  D5     |72  #72 (custom)  32  D5
 33  D6      |33  D14          33  D6     |73  #73 (custom)  33  D6
 34  D7      |34  D15          34  D7     |74  #74 (custom)  34  D7
 35  TX      |35  TX2          35  TX     |75  TX2           35  TX
 36  RX      |36  RX2          36  RX     |76  RX2           36  RX
 37  USER1   |37  USER5        37  USER1  |77  USER5         37  USER1
 38  USER2   |38  USER6        38  USER2  |78  USER6         38  USER2
 39  USER3   |39  USER7        39  USER3  |79  USER7         39  USER3
 40  USER4   |40  USER8        40  USER4  |80  USER8(IEI)    40  USER4(IEO)
===========================================================================

***************************************************************************/

#ifndef MAME_BUS_RC2014_RC2014_H
#define MAME_BUS_RC2014_RC2014_H

#pragma once

#include "machine/z80daisy.h"

#include <functional>
#include <vector>


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

//**************************************************************************
//  RC2014 Standard Bus
//**************************************************************************

// ======================> rc2014_bus_device
class device_rc2014_card_interface;

class rc2014_bus_device : public device_t
{
public:
	// construction/destruction
	rc2014_bus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
	virtual ~rc2014_bus_device();

	void clk_w(int state);
	void int_w(int state);
	void tx_w(int state);
	void rx_w(int state);
	void user1_w(int state);
	void user2_w(int state);
	void user3_w(int state);
	void user4_w(int state);

	void set_bus_clock(u32 clock);
	void set_bus_clock(const XTAL &xtal) { set_bus_clock(xtal.value()); }
	void assign_installer(int index, address_space_installer *installer);
	address_space_installer *installer(int index) const;
	void add_to_daisy_chain(std::string tag) { m_daisy.push_back(tag); }
	const z80_daisy_config* get_daisy_chain();

	void add_card(device_rc2014_card_interface &card);
protected:
	rc2014_bus_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);

	// device_t implementation
	virtual void device_start() override ATTR_COLD;
	virtual void device_reset() override ATTR_COLD;

private:
	using card_vector = std::vector<std::reference_wrapper<device_rc2014_card_interface> >;

	address_space_installer *m_installer[4];
	std::vector<std::string> m_daisy;
	char **m_daisy_chain;
	card_vector m_device_list;
};

// ======================> device_rc2014_card_interface

class rc2014_slot_device;

class device_rc2014_card_interface : public device_interface
{
	friend class rc2014_slot_device;
	friend class rc2014_bus_device;

public:
	// construction/destruction
	device_rc2014_card_interface(const machine_config &mconfig, device_t &device);

	virtual void card_clk_w(int state) { }
	virtual void card_int_w(int state) { }
	virtual void card_tx_w(int state) { }
	virtual void card_rx_w(int state) { }
	virtual void card_user1_w(int state) { }
	virtual void card_user2_w(int state) { }
	virtual void card_user3_w(int state) { }
	virtual void card_user4_w(int state) { }

protected:
	rc2014_bus_device  *m_bus;
};

// ======================> rc2014_slot_device

class rc2014_slot_device : public device_t, public device_slot_interface
{
public:
	rc2014_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock);

	template <typename T, typename U>
	rc2014_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&bus_tag, U &&slot_options, char const *default_option, bool fixed = false)
		: rc2014_slot_device(mconfig, tag, owner, DERIVED_CLOCK(1,1))
	{
		m_bus.set_tag(std::forward<T>(bus_tag));
		option_reset();
		slot_options(*this);
		set_default_option(default_option);
		set_fixed(fixed);
	}

protected:
	rc2014_slot_device(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, u32 clock);

	// device_t implementation
	virtual void device_start() override ATTR_COLD;
	virtual void device_resolve_objects() override ATTR_COLD;

	required_device<rc2014_bus_device> m_bus;
};

//**************************************************************************
//  RC2014 Extended Bus
//**************************************************************************

// ======================> rc2014_ext_bus_device
class device_rc2014_ext_card_interface;

class rc2014_ext_bus_device : public rc2014_bus_device
{
public:
	// construction/destruction
	rc2014_ext_bus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	void clk2_w(int state);
	void page_w(int state);
	void nmi_w(int state);
	void tx2_w(int state);
	void rx2_w(int state);
	void user5_w(int state);
	void user6_w(int state);
	void user7_w(int state);
	void user8_w(int state);

	void add_card(device_rc2014_ext_card_interface &card);

protected:
	rc2014_ext_bus_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);

private:
	using card_vector = std::vector<std::reference_wrapper<device_rc2014_ext_card_interface> >;
	card_vector m_device_list;
};

// ======================> device_rc2014_ext_card_interface

class device_rc2014_ext_card_interface : public device_rc2014_card_interface
{
	friend class rc2014_ext_bus_device;

protected:
	// construction/destruction
	device_rc2014_ext_card_interface(const machine_config &mconfig, device_t &device);

public:
	virtual void card_clk2_w(int state) { }
	virtual void card_page_w(int state) { }
	virtual void card_nmi_w(int state) { }
	virtual void card_tx2_w(int state) { }
	virtual void card_rx2_w(int state) { }
	virtual void card_user5_w(int state) { }
	virtual void card_user6_w(int state) { }
	virtual void card_user7_w(int state) { }
	virtual void card_user8_w(int state) { }

protected:
	rc2014_ext_bus_device  *m_bus;
};

// ======================> rc2014_ext_slot_device

class rc2014_ext_slot_device : public rc2014_slot_device
{
public:
	rc2014_ext_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock);

	template <typename T, typename U>
	rc2014_ext_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&bus_tag, U &&slot_options, char const *default_option, bool fixed = false)
		: rc2014_ext_slot_device(mconfig, tag, owner, DERIVED_CLOCK(1,1))
	{
		m_bus.set_tag(std::forward<T>(bus_tag));
		option_reset();
		slot_options(*this);
		set_default_option(default_option);
		set_fixed(fixed);
	}

protected:
	rc2014_ext_slot_device(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, u32 clock);

	// device_t implementation
	virtual void device_start() override ATTR_COLD;
	virtual void device_resolve_objects() override ATTR_COLD;
};

//**************************************************************************
//  RC2014 RC80 Bus
//**************************************************************************

// ======================> rc2014_rc80_bus_device
class device_rc2014_rc80_card_interface;

class rc2014_rc80_bus_device : public rc2014_ext_bus_device
{
public:
	// construction/destruction
	rc2014_rc80_bus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	void add_card(device_rc2014_rc80_card_interface &card);

protected:
	rc2014_rc80_bus_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);

	// device_t implementation
	virtual void device_start() override ATTR_COLD;

private:
	using card_vector = std::vector<std::reference_wrapper<device_rc2014_rc80_card_interface> >;
	card_vector m_device_list;
};

// ======================> device_rc2014_rc80_card_interface

class device_rc2014_rc80_card_interface : public device_rc2014_ext_card_interface
{
	friend class rc2014_rc80_bus_device;

protected:
	// construction/destruction
	device_rc2014_rc80_card_interface(const machine_config &mconfig, device_t &device);

	rc2014_rc80_bus_device  *m_bus;
};

// ======================> rc2014_rc80_slot_device

class rc2014_rc80_slot_device : public rc2014_ext_slot_device
{
public:
	rc2014_rc80_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock);

	template <typename T, typename U>
	rc2014_rc80_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&bus_tag, U &&slot_options, char const *default_option, bool fixed = false)
		: rc2014_rc80_slot_device(mconfig, tag, owner, DERIVED_CLOCK(1,1))
	{
		m_bus.set_tag(std::forward<T>(bus_tag));
		option_reset();
		slot_options(*this);
		set_default_option(default_option);
		set_fixed(fixed);
	}

protected:
	// device_t implementation
	virtual void device_start() override ATTR_COLD;
	virtual void device_resolve_objects() override ATTR_COLD;
};


// device type declarations
DECLARE_DEVICE_TYPE(RC2014_BUS,  rc2014_bus_device)
DECLARE_DEVICE_TYPE(RC2014_SLOT, rc2014_slot_device)

DECLARE_DEVICE_TYPE(RC2014_EXT_BUS,  rc2014_ext_bus_device)
DECLARE_DEVICE_TYPE(RC2014_EXT_SLOT, rc2014_ext_slot_device)

DECLARE_DEVICE_TYPE(RC2014_RC80_BUS,  rc2014_rc80_bus_device)
DECLARE_DEVICE_TYPE(RC2014_RC80_SLOT, rc2014_rc80_slot_device)

#endif // MAME_BUS_RC2014_RC2014_H