summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/nubus/quadralink.cpp
blob: 0e6ecd1a567da1f42c090694328d89bd98f4732b (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
// license:BSD-3-Clause
// copyright-holders:R. Belmont
/***************************************************************************

  Applied Engineering Quadralink 4-port serial card

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

#include "emu.h"
#include "quadralink.h"
#include "bus/rs232/rs232.h"
#include "bus/rs232/terminal.h"
#include "bus/rs232/null_modem.h"
#include "screen.h"

static void isa_com(device_slot_interface &device)
{
	device.option_add("terminal", SERIAL_TERMINAL);
	device.option_add("null_modem", NULL_MODEM);
}

#define QUADRALINK_ROM_REGION  "qdlink_rom"

ROM_START( quadralink )
	ROM_REGION(0x4000, QUADRALINK_ROM_REGION, 0)
	ROM_LOAD( "ql_2.2.bin",   0x000000, 0x004000, CRC(88c323b8) SHA1(d70bc32ad50ceb5cb75c6251293cacd65d8313aa) )
ROM_END

//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

DEFINE_DEVICE_TYPE(NUBUS_QUADRALINK, nubus_quadralink_device, "nb_qdlink", "Applied Engineering Quadralink serial card")


//-------------------------------------------------
//  device_add_mconfig - add device configuration
//-------------------------------------------------

void nubus_quadralink_device::device_add_mconfig(machine_config &config)
{
	SCC8530N(config, m_scc1, 3.6864_MHz_XTAL);
	m_scc1->out_txda_callback().set("serport0", FUNC(rs232_port_device::write_txd));
	m_scc1->out_txdb_callback().set("serport1", FUNC(rs232_port_device::write_txd));

	SCC8530N(config, m_scc2, 3.6864_MHz_XTAL);
	m_scc2->out_txda_callback().set("serport2", FUNC(rs232_port_device::write_txd));
	m_scc2->out_txdb_callback().set("serport3", FUNC(rs232_port_device::write_txd));

	rs232_port_device &serport0(RS232_PORT(config, "serport0", isa_com, nullptr));
	serport0.rxd_handler().set(m_scc1, FUNC(z80scc_device::rxa_w));
	serport0.dcd_handler().set(m_scc1, FUNC(z80scc_device::dcda_w));
	serport0.cts_handler().set(m_scc1, FUNC(z80scc_device::ctsa_w));

	rs232_port_device &serport1(RS232_PORT(config, "serport1", isa_com, nullptr));
	serport1.rxd_handler().set(m_scc1, FUNC(z80scc_device::rxb_w));
	serport1.dcd_handler().set(m_scc1, FUNC(z80scc_device::dcdb_w));
	serport1.cts_handler().set(m_scc1, FUNC(z80scc_device::ctsb_w));

	rs232_port_device &serport2(RS232_PORT(config, "serport2", isa_com, nullptr));
	serport2.rxd_handler().set(m_scc2, FUNC(z80scc_device::rxa_w));
	serport2.dcd_handler().set(m_scc2, FUNC(z80scc_device::dcda_w));
	serport2.cts_handler().set(m_scc2, FUNC(z80scc_device::ctsa_w));

	rs232_port_device &serport3(RS232_PORT(config, "serport3", isa_com, nullptr));
	serport3.rxd_handler().set(m_scc2, FUNC(z80scc_device::rxb_w));
	serport3.dcd_handler().set(m_scc2, FUNC(z80scc_device::dcdb_w));
	serport3.cts_handler().set(m_scc2, FUNC(z80scc_device::ctsb_w));
}

//-------------------------------------------------
//  rom_region - device-specific ROM region
//-------------------------------------------------

const tiny_rom_entry *nubus_quadralink_device::device_rom_region() const
{
	return ROM_NAME( quadralink );
}

//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

//-------------------------------------------------
//  nubus_quadralink_device - constructor
//-------------------------------------------------

nubus_quadralink_device::nubus_quadralink_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	nubus_quadralink_device(mconfig, NUBUS_QUADRALINK, tag, owner, clock)
{
}

nubus_quadralink_device::nubus_quadralink_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, type, tag, owner, clock),
	device_nubus_card_interface(mconfig, *this),
	m_scc1(*this, "scc1"),
	m_scc2(*this, "scc2")
{
}

//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void nubus_quadralink_device::device_start()
{
	uint32_t slotspace;

	install_declaration_rom(QUADRALINK_ROM_REGION);

	slotspace = get_slotspace();

	nubus().install_device(slotspace, slotspace+0xefffff, read32s_delegate(*this, FUNC(nubus_quadralink_device::dev_r)), write32s_delegate(*this, FUNC(nubus_quadralink_device::dev_w)));
}

//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void nubus_quadralink_device::device_reset()
{
}

void nubus_quadralink_device::dev_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
	//printf("write %x to QL space @ %x, mask %08x\n", data, offset, mem_mask);
	switch (offset)
	{
		case 0x0000:    // SCC 2 A control
			m_scc2->ca_w(0, data & 0xff);
			break;

		case 0x0002:    // SCC 2 A data
			m_scc2->da_w(0, data & 0xff);
			break;

		case 0x0004:    // SCC 2 B control
			m_scc2->cb_w(0, data & 0xff);
			break;

		case 0x0006:    // SCC 2 B data
			m_scc2->db_w(0, data & 0xff);
			break;

		case 0x10000:   // SCC 1 A control
			m_scc1->ca_w(0, data & 0xff);
			break;

		case 0x10002:   // SCC 1 A data
			m_scc1->da_w(0, data & 0xff);
			break;

		case 0x10004:   // SCC 1 B control
			m_scc1->cb_w(0, data & 0xff);
			break;

		case 0x10006:   // SCC 1 B data
			m_scc1->db_w(0, data & 0xff);
			break;
	}
}

uint32_t nubus_quadralink_device::dev_r(offs_t offset, uint32_t mem_mask)
{
	//printf("read QL space @ %x, mask %08x\n", offset, mem_mask);
	switch (offset)
	{
		case 0x0000:
			return m_scc2->ca_r(0);

		case 0x0002:
			return m_scc2->da_r(0);

		case 0x0004:
			return m_scc2->cb_r(0);

		case 0x0006:
			return m_scc2->db_r(0);

		case 0x10000:
			return m_scc1->ca_r(0);

		case 0x10002:
			return m_scc1->da_r(0);

		case 0x10004:
			return m_scc1->cb_r(0);

		case 0x10006:
			return m_scc1->db_r(0);
	}
	return 0xffffffff;
}