summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/machine/coleco.c
blob: 82deef9aa8e0035d3fb193d740a1ddd4f587ea8d (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
// license:BSD-3-Clause
// copyright-holders:Mike Balfour, Ben Bruscella, Sean Young
#include "emu.h"
#include "machine/coleco.h"

UINT8 coleco_scan_paddles(running_machine &machine, UINT8 *joy_status0, UINT8 *joy_status1)
{
	UINT8 ctrl_sel = machine.root_device().ioport("CTRLSEL")->read_safe(0);

	/* which controller shall we read? */
	if ((ctrl_sel & 0x07) == 0x02)          // Super Action Controller P1
		*joy_status0 = machine.root_device().ioport("SAC_SLIDE1")->read_safe(0);
	else if ((ctrl_sel & 0x07) == 0x03)     // Driving Controller P1
		*joy_status0 = machine.root_device().ioport("DRIV_WHEEL1")->read_safe(0);

	if ((ctrl_sel & 0x70) == 0x20)          // Super Action Controller P2
		*joy_status1 = machine.root_device().ioport("SAC_SLIDE2")->read_safe(0);
	else if ((ctrl_sel & 0x70) == 0x30)     // Driving Controller P2
		*joy_status1 = machine.root_device().ioport("DRIV_WHEEL2")->read_safe(0);

	/* In principle, even if not supported by any game, I guess we could have two Super
	   Action Controllers plugged into the Roller controller ports. Since I found no info
	   about the behavior of sliders in such a configuration, we overwrite SAC sliders with
	   the Roller trackball inputs and actually use the latter ones, when both are selected. */
	if (ctrl_sel & 0x80)                    // Roller controller
	{
		*joy_status0 = machine.root_device().ioport("ROLLER_X")->read_safe(0);
		*joy_status1 = machine.root_device().ioport("ROLLER_Y")->read_safe(0);
	}

	return *joy_status0 | *joy_status1;
}


UINT8 coleco_paddle_read(running_machine &machine, int port, int joy_mode, UINT8 joy_status)
{
	UINT8 ctrl_sel = machine.root_device().ioport("CTRLSEL")->read_safe(0);
	UINT8 ctrl_extra = ctrl_sel & 0x80;
	ctrl_sel = ctrl_sel >> (port*4) & 7;

	/* Keypad and fire 1 (SAC Yellow Button) */
	if (joy_mode == 0)
	{
		/* No key pressed by default */
		UINT8 data = 0x0f;
		UINT16 ipt = 0xffff;

		if (ctrl_sel == 0)          // ColecoVision Controller
			ipt = machine.root_device().ioport(port ? "STD_KEYPAD2" : "STD_KEYPAD1")->read();
		else if (ctrl_sel == 2)     // Super Action Controller
			ipt = machine.root_device().ioport(port ? "SAC_KEYPAD2" : "SAC_KEYPAD1")->read();

		/* Numeric pad buttons are not independent on a real ColecoVision, if you push more
		   than one, a real ColecoVision think that it is a third button, so we are going to emulate
		   the right behaviour */
		/* Super Action Controller additional buttons are read in the same way */
		if (!(ipt & 0x0001)) data &= 0x0a; /* 0 */
		if (!(ipt & 0x0002)) data &= 0x0d; /* 1 */
		if (!(ipt & 0x0004)) data &= 0x07; /* 2 */
		if (!(ipt & 0x0008)) data &= 0x0c; /* 3 */
		if (!(ipt & 0x0010)) data &= 0x02; /* 4 */
		if (!(ipt & 0x0020)) data &= 0x03; /* 5 */
		if (!(ipt & 0x0040)) data &= 0x0e; /* 6 */
		if (!(ipt & 0x0080)) data &= 0x05; /* 7 */
		if (!(ipt & 0x0100)) data &= 0x01; /* 8 */
		if (!(ipt & 0x0200)) data &= 0x0b; /* 9 */
		if (!(ipt & 0x0400)) data &= 0x06; /* # */
		if (!(ipt & 0x0800)) data &= 0x09; /* * */
		if (!(ipt & 0x1000)) data &= 0x04; /* Blue Action Button */
		if (!(ipt & 0x2000)) data &= 0x08; /* Purple Action Button */

		return ((ipt & 0x4000) >> 8) | 0x30 | data;
	}
	/* Joystick and fire 2 (SAC Red Button) */
	else
	{
		UINT8 data = 0x7f;

		if (ctrl_sel == 0)          // ColecoVision Controller
			data = machine.root_device().ioport(port ? "STD_JOY2" : "STD_JOY1")->read();
		else if (ctrl_sel == 2)     // Super Action Controller
			data = machine.root_device().ioport(port ? "SAC_JOY2" : "SAC_JOY1")->read();
		else if (ctrl_sel == 3)     // Driving Controller
			data = machine.root_device().ioport(port ? "DRIV_PEDAL2" : "DRIV_PEDAL1")->read();

		/* If any extra analog contoller enabled */
		if (ctrl_extra || ctrl_sel == 2 || ctrl_sel == 3)
		{
			if (joy_status & 0x80) data ^= 0x30;
			else if (joy_status) data ^= 0x10;
		}

		return data & 0x7f;
	}
}


// ColecoVision Controller
static INPUT_PORTS_START( ctrl1 )
	PORT_START("STD_KEYPAD1")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("0 (pad 1)") PORT_CODE(KEYCODE_0_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("1 (pad 1)") PORT_CODE(KEYCODE_1_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("2 (pad 1)") PORT_CODE(KEYCODE_2_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("3 (pad 1)") PORT_CODE(KEYCODE_3_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("4 (pad 1)") PORT_CODE(KEYCODE_4_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("5 (pad 1)") PORT_CODE(KEYCODE_5_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("6 (pad 1)") PORT_CODE(KEYCODE_6_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("7 (pad 1)") PORT_CODE(KEYCODE_7_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("8 (pad 1)") PORT_CODE(KEYCODE_8_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("9 (pad 1)") PORT_CODE(KEYCODE_9_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("# (pad 1)") PORT_CODE(KEYCODE_MINUS_PAD)   PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("* (pad 1)") PORT_CODE(KEYCODE_PLUS_PAD)    PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)                                       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0xb000, IP_ACTIVE_LOW, IPT_UNKNOWN )                                                      PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)

	PORT_START("STD_JOY1")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)     PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)  PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)   PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)   PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)         PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
	PORT_BIT( 0xb0, IP_ACTIVE_LOW, IPT_UNKNOWN )                        PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x00)
INPUT_PORTS_END

static INPUT_PORTS_START( ctrl2 )
	PORT_START("STD_KEYPAD2")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("0 (pad 2)")    PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("1 (pad 2)")    PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("2 (pad 2)")    PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("3 (pad 2)")    PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("4 (pad 2)")    PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("5 (pad 2)")    PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("6 (pad 2)")    PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("7 (pad 2)")    PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("8 (pad 2)")    PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("9 (pad 2)")    PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("# (pad 2)")    PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("* (pad 2)")    PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)           PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0xb000, IP_ACTIVE_LOW, IPT_UNKNOWN )                          PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)

	PORT_START("STD_JOY2")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)     PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)  PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)   PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)   PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)         PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
	PORT_BIT( 0xb0, IP_ACTIVE_LOW, IPT_UNKNOWN )                        PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x00)
INPUT_PORTS_END


// Super Action Controller
static INPUT_PORTS_START( sac1 )
	PORT_START("SAC_KEYPAD1")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("0 (SAC pad 1)") PORT_CODE(KEYCODE_0_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("1 (SAC pad 1)") PORT_CODE(KEYCODE_1_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("2 (SAC pad 1)") PORT_CODE(KEYCODE_2_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("3 (SAC pad 1)") PORT_CODE(KEYCODE_3_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("4 (SAC pad 1)") PORT_CODE(KEYCODE_4_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("5 (SAC pad 1)") PORT_CODE(KEYCODE_5_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("6 (SAC pad 1)") PORT_CODE(KEYCODE_6_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("7 (SAC pad 1)") PORT_CODE(KEYCODE_7_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("8 (SAC pad 1)") PORT_CODE(KEYCODE_8_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("9 (SAC pad 1)") PORT_CODE(KEYCODE_9_PAD)       PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("# (SAC pad 1)") PORT_CODE(KEYCODE_MINUS_PAD)   PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("* (SAC pad 1)") PORT_CODE(KEYCODE_PLUS_PAD)    PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Blue Action Button P1") PORT_PLAYER(1)        PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Purple Action Button P1") PORT_PLAYER(1)      PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Orange Action Button P1") PORT_PLAYER(1)      PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )                                                          PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)

	PORT_START("SAC_JOY1")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)     PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)  PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)   PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)   PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Yellow Action Button P1") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
	PORT_BIT( 0xb0, IP_ACTIVE_LOW, IPT_UNKNOWN )                        PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)

	PORT_START("SAC_SLIDE1")    // SAC P1 slider
	PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(100) PORT_KEYDELTA(25) PORT_CODE_DEC(KEYCODE_J) PORT_CODE_INC(KEYCODE_L) PORT_REVERSE PORT_RESET PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x02)
INPUT_PORTS_END

static INPUT_PORTS_START( sac2 )
	PORT_START("SAC_KEYPAD2")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("0 (SAC pad 2)")                                PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("1 (SAC pad 2)")                                PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("2 (SAC pad 2)")                                PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("3 (SAC pad 2)")                                PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("4 (SAC pad 2)")                                PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("5 (SAC pad 2)")                                PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("6 (SAC pad 2)")                                PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("7 (SAC pad 2)")                                PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("8 (SAC pad 2)")                                PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("9 (SAC pad 2)")                                PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("# (SAC pad 2)")                                PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("* (SAC pad 2)")                                PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Blue Action Button P2") PORT_PLAYER(2)        PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Purple Action Button P2") PORT_PLAYER(2)      PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Orange Action Button P2") PORT_PLAYER(2)      PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )                                                          PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)

	PORT_START("SAC_JOY2")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)     PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)  PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)   PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)   PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Yellow Action Button P2") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
	PORT_BIT( 0xb0, IP_ACTIVE_LOW, IPT_UNKNOWN )                        PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)

	PORT_START("SAC_SLIDE2")    // SAC P2 slider
	PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(100) PORT_KEYDELTA(25) PORT_CODE_DEC(KEYCODE_I) PORT_CODE_INC(KEYCODE_K) PORT_RESET PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x20)
INPUT_PORTS_END


// Driving Controller
static INPUT_PORTS_START( driv1 )
	PORT_START("DRIV_WHEEL1")
	PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(100) PORT_KEYDELTA(25) PORT_CODE_DEC(KEYCODE_J) PORT_CODE_INC(KEYCODE_L) PORT_REVERSE PORT_RESET PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x03)

	PORT_START("DRIV_PEDAL1")
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)         PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x03)
	PORT_BIT( 0xbf, IP_ACTIVE_LOW, IPT_UNUSED )                         PORT_CONDITION("CTRLSEL", 0x07, EQUALS, 0x03)
INPUT_PORTS_END

static INPUT_PORTS_START( driv2 )
	PORT_START("DRIV_WHEEL2")
	PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(100) PORT_KEYDELTA(25) PORT_CODE_DEC(KEYCODE_I) PORT_CODE_INC(KEYCODE_K) PORT_RESET PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x30)

	PORT_START("DRIV_PEDAL2")
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)         PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x30)
	PORT_BIT( 0xbf, IP_ACTIVE_LOW, IPT_UNUSED )                         PORT_CONDITION("CTRLSEL", 0x70, EQUALS, 0x30)
INPUT_PORTS_END


// Roller Controller
static INPUT_PORTS_START( roller )
	PORT_START("ROLLER_X")  // Roller Controller X Axis
	PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(100) PORT_KEYDELTA(25) PORT_CODE_DEC(KEYCODE_J) PORT_CODE_INC(KEYCODE_L) PORT_REVERSE PORT_RESET PORT_CONDITION("CTRLSEL", 0x80, EQUALS, 0x80)

	PORT_START("ROLLER_Y")  // Roller Controller Y Axis
	PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(25) PORT_CODE_DEC(KEYCODE_I) PORT_CODE_INC(KEYCODE_K) PORT_RESET PORT_CONDITION("CTRLSEL", 0x80, EQUALS, 0x80)
INPUT_PORTS_END


INPUT_PORTS_START( coleco )
	PORT_START("CTRLSEL")  /* Select Controller Type */
	PORT_CONFNAME( 0x07, 0x00, "Port 1 Controller" )
	PORT_CONFSETTING(  0x01, DEF_STR( None ) )
	PORT_CONFSETTING(  0x00, "ColecoVision Controller" )
	PORT_CONFSETTING(  0x02, "Super Action Controller" )
	PORT_CONFSETTING(  0x03, "Driving Controller" )
	PORT_CONFNAME( 0x70, 0x00, "Port 2 Controller" )
	PORT_CONFSETTING(  0x10, DEF_STR( None ) )
	PORT_CONFSETTING(  0x00, "ColecoVision Controller" )
	PORT_CONFSETTING(  0x20, "Super Action Controller" )
	PORT_CONFSETTING(  0x30, "Driving Controller" )
	PORT_CONFNAME( 0x80, 0x00, "Extra Controller" )
	PORT_CONFSETTING(  0x00, DEF_STR( None ) )
	PORT_CONFSETTING(  0x80, "Roller Controller" )

	PORT_INCLUDE( ctrl1 )
	PORT_INCLUDE( ctrl2 )
	PORT_INCLUDE( sac1 )
	PORT_INCLUDE( sac2 )
	PORT_INCLUDE( driv1 )
	PORT_INCLUDE( driv2 )
	PORT_INCLUDE( roller )
INPUT_PORTS_END