summaryrefslogtreecommitdiffstats
path: root/src/mess/machine/a2ssc.c
blob: e9c93b92f06f600fdce9919f1ce0d63e19c6971d (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
/*********************************************************************

    a2ssc.c

    Apple II Super Serial Card

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

#include "emu.h"
#include "includes/apple2.h"
#include "machine/a2ssc.h"


/***************************************************************************
    PARAMETERS
***************************************************************************/

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

const device_type A2BUS_SSC = &device_creator<a2bus_ssc_device>;

#define SSC_ROM_REGION  "ssc_rom"
#define SSC_ACIA_TAG    "ssc_acia"


MACHINE_CONFIG_FRAGMENT( ssc )
	MCFG_MOS6551_ADD(SSC_ACIA_TAG, XTAL_1_8432MHz, NULL)
MACHINE_CONFIG_END

ROM_START( ssc )
	ROM_REGION(0x000800, SSC_ROM_REGION, 0)
	ROM_LOAD( "341-0065-a.bin", 0x000000, 0x000800, CRC(b7539d4c) SHA1(6dab633470c6bc4cb3e81d09fda46597caf8ee57) )
ROM_END

static INPUT_PORTS_START( ssc )
	PORT_START("DSW1")
	PORT_DIPNAME( 0xf0, 0xf0, "Baud rate" )
	PORT_DIPSETTING(    0x00, "Undefined/115200" )
	PORT_DIPSETTING(    0x10, "50" )
	PORT_DIPSETTING(    0x20, "75" )
	PORT_DIPSETTING(    0x30, "110" )
	PORT_DIPSETTING(    0x40, "135" )
	PORT_DIPSETTING(    0x50, "150" )
	PORT_DIPSETTING(    0x60, "300" )
	PORT_DIPSETTING(    0x70, "600" )
	PORT_DIPSETTING(    0x80, "1200" )
	PORT_DIPSETTING(    0x90, "1800" )
	PORT_DIPSETTING(    0xa0, "2400" )
	PORT_DIPSETTING(    0xb0, "3600" )
	PORT_DIPSETTING(    0xc0, "4800" )
	PORT_DIPSETTING(    0xd0, "7200" )
	PORT_DIPSETTING(    0xe0, "9600" )
	PORT_DIPSETTING(    0xf0, "19200" )

	PORT_DIPNAME( 0x0c, 0x00, "Mode" )
	PORT_DIPSETTING(    0x00, "Communications Mode" )
	PORT_DIPSETTING(    0x04, "SIC P8 Emulation Mode" )
	PORT_DIPSETTING(    0x08, "Printer Mode" )
	PORT_DIPSETTING(    0x0c, "SIC P8A Emulation Mode" )

	PORT_DIPNAME( 0x01, 0x00, "Clear To Send" )
	PORT_DIPSETTING(    0x00, "Normal Clear To Send" )
	PORT_DIPSETTING(    0x01, "Secondary Clear To Send" )

	PORT_START("DSW2")
	PORT_DIPNAME( 0xc0, 0x00, "Format" )
	PORT_DIPSETTING(    0x00, "8 data, 1 stop")
	PORT_DIPSETTING(    0x40, "7 data, 1 stop")
	PORT_DIPSETTING(    0x80, "8 data, 2 stop")
	PORT_DIPSETTING(    0xc0, "7 data, 2 stop")

	PORT_DIPNAME( 0x30, 0x00, "Parity" )
	PORT_DIPSETTING(    0x00, "None")
	PORT_DIPSETTING(    0x10, "Odd")
	PORT_DIPSETTING(    0x30, "Even")

	PORT_DIPNAME( 0x08, 0x08, "End of Line" )
	PORT_DIPSETTING(    0x00, "Add LF after CR")
	PORT_DIPSETTING(    0x08, "Don't add LF after CR")

	PORT_DIPNAME( 0x04, 0x04, "Interrupts" )
	PORT_DIPSETTING(    0x00, "On")
	PORT_DIPSETTING(    0x04, "Off")
INPUT_PORTS_END

//-------------------------------------------------
//  input_ports - device-specific input ports
//-------------------------------------------------

ioport_constructor a2bus_ssc_device::device_input_ports() const
{
	return INPUT_PORTS_NAME( ssc );
}

//-------------------------------------------------
//  machine_config_additions - device-specific
//  machine configurations
//-------------------------------------------------

machine_config_constructor a2bus_ssc_device::device_mconfig_additions() const
{
	return MACHINE_CONFIG_NAME( ssc );
}

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

const rom_entry *a2bus_ssc_device::device_rom_region() const
{
	return ROM_NAME( ssc );
}

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

a2bus_ssc_device::a2bus_ssc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
		device_t(mconfig, A2BUS_SSC, "Apple Super Serial Card", tag, owner, clock),
		device_a2bus_card_interface(mconfig, *this),
		m_acia(*this, SSC_ACIA_TAG)
{
	m_shortname = "a2ssc";
}

a2bus_ssc_device::a2bus_ssc_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) :
		device_t(mconfig, type, name, tag, owner, clock),
		device_a2bus_card_interface(mconfig, *this),
		m_acia(*this, SSC_ACIA_TAG)
{
	m_shortname = "a2ssc";
}

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

void a2bus_ssc_device::device_start()
{
	// set_a2bus_device makes m_slot valid
	set_a2bus_device();

	astring tempstring;
	m_rom = device().machine().root_device().memregion(this->subtag(tempstring, SSC_ROM_REGION))->base();
}

void a2bus_ssc_device::device_reset()
{
}

/*-------------------------------------------------
    read_cnxx - called for reads from this card's cnxx space
-------------------------------------------------*/

UINT8 a2bus_ssc_device::read_cnxx(address_space &space, UINT8 offset)
{
	return m_rom[offset+0x700];
}

/*-------------------------------------------------
    read_c800 - called for reads from this card's c800 space
-------------------------------------------------*/

UINT8 a2bus_ssc_device::read_c800(address_space &space, UINT16 offset)
{
	return m_rom[offset];
}

/*-------------------------------------------------
    read_c0nx - called for reads from this card's c0nx space
-------------------------------------------------*/

UINT8 a2bus_ssc_device::read_c0nx(address_space &space, UINT8 offset)
{
	// dips at C0n1/C0n2, ACIA at C0n8/9/A/B

	switch (offset)
	{
		case 1:
			return device().ioport("DSW1")->read();
		case 2:
			return device().ioport("DSW2")->read();

		case 8:
		case 9:
		case 0xa:
		case 0xb:
			return m_acia->read(space, offset-8);

	}

	return 0;
}

/*-------------------------------------------------
    write_c0nx - called for writes to this card's c0nx space
-------------------------------------------------*/

void a2bus_ssc_device::write_c0nx(address_space &space, UINT8 offset, UINT8 data)
{
	switch (offset)
	{
		case 8:
		case 9:
		case 0xa:
		case 0xb:
			m_acia->write(space, offset-8, data);
			break;

	}
}