summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/a2gameio/gameio.cpp
blob: 7704d4ff38203e7eac0190c7c21cc4db30f837f9 (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
// license:BSD-3-Clause
// copyright-holders:AJR
/*********************************************************************

    Apple II Game I/O Connector

    This 16-pin DIP socket is described in the Apple II Reference
    Manual (January 1978) as "a means of connecting paddle controls,
    lights and switches to the APPLE II for use in controlling video
    games, etc." The connector provides for four analog "paddle"
    input signals (0-150KΩ resistance) which are converted to
    digital pulses by a NE558 quad timer on the main board. The
    connector also provides several digital switch inputs and
    "annunciator" outputs, all LS/TTL compatible. Apple joysticks
    provide active high switches (though at least one third-party
    product treats them as active low) and Apple main boards have no
    pullups on these inputs, which thus read 0 if disconnected.

    While pins 9 and 16 are unconnected on the Apple II, they provide
    additional digital output and input pins respectively on the Sanyo
    MBC-550/555 (which uses 74LS123 monostables instead of a NE558).
    The Apple IIgs also recognizes a switch input 3, though this is
    placed on pin 9 of the internal connector rather than 16.

    The Apple IIe, IIc and IIgs also have an external DE-9 connector
    that carries a subset of the signals, excluding the annunciator
    outputs and utility strobe (which the IIc and IIgs do not have).

**********************************************************************
                            ____________
                   +5V   1 |*           | 16  (SW3)
                   SW0   2 |            | 15  AN0
                   SW1   3 |            | 14  AN1
                   SW2   4 |            | 13  AN2
                  /STB   5 |  GAME I/O  | 12  AN3
                  PDL0   6 |            | 11  PDL3
                  PDL2   7 |            | 10  PDL1
                   GND   8 |            |  9  (AN4/SW3)
                            ------------

                  ---------------------------------
                  \  PDL0  PDL2  GND   +5V   SW1  /
                   \ (5)   (4)   (3)   (2)   (1) /
                    \   (9)   (8)   (7)   (6)   /
                     \  PDL3  PDL1  SW0   SW2  /
                      \_______________________/

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

#include "emu.h"
#include "bus/a2gameio/gameio.h"
#include "bus/a2gameio/joystick.h"
#include "bus/a2gameio/joyport.h"
#include "bus/a2gameio/computereyes.h"


//**************************************************************************
//  CONNECTOR DEVICE IMPLEMENTATION
//**************************************************************************

// device type definition
DEFINE_DEVICE_TYPE(APPLE2_GAMEIO, apple2_gameio_device, "a2gameio", "Apple II Game I/O Connector")

apple2_gameio_device::apple2_gameio_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: device_t(mconfig, APPLE2_GAMEIO, tag, owner, clock)
	, device_single_card_slot_interface<device_a2gameio_interface>(mconfig, *this)
	, m_intf(nullptr)
{
}

void apple2_gameio_device::iiandplus_options(device_slot_interface &slot)
{
	slot.option_add("joy", APPLE2_JOYSTICK);
	slot.option_add("joyport", APPLE2_JOYPORT);
	slot.option_add("compeyes", APPLE2_COMPUTEREYES);
}

void apple2_gameio_device::default_options(device_slot_interface &slot)
{
	slot.option_add("joy", APPLE2_JOYSTICK);
	slot.option_add("compeyes", APPLE2_COMPUTEREYES);
}

void apple2_gameio_device::device_config_complete()
{
	m_intf = get_card_device();
}

void apple2_gameio_device::device_resolve_objects()
{
	if (m_intf)
		m_intf->m_connector = this;
}

void apple2_gameio_device::device_start()
{
}


//**************************************************************************
//  PASSTHROUGH HANDLERS
//**************************************************************************

u8 apple2_gameio_device::pdl0_r()
{
	if (m_intf != nullptr)
		return m_intf->pdl0_r();

	return 0;
}

u8 apple2_gameio_device::pdl1_r()
{
	if (m_intf != nullptr)
		return m_intf->pdl1_r();

	return 0;
}

u8 apple2_gameio_device::pdl2_r()
{
	if (m_intf != nullptr)
		return m_intf->pdl2_r();

	return 0;
}

u8 apple2_gameio_device::pdl3_r()
{
	if (m_intf != nullptr)
		return m_intf->pdl3_r();

	return 0;
}

READ_LINE_MEMBER(apple2_gameio_device::sw0_r)
{
	if (m_intf != nullptr)
		return m_intf->sw0_r();

	return m_sw_pullups ? 1 : 0;
}

READ_LINE_MEMBER(apple2_gameio_device::sw1_r)
{
	if (m_intf != nullptr)
		return m_intf->sw1_r();

	return m_sw_pullups ? 1 : 0;
}

READ_LINE_MEMBER(apple2_gameio_device::sw2_r)
{
	if (m_intf != nullptr)
		return m_intf->sw2_r();

	return m_sw_pullups ? 1 : 0;
}

READ_LINE_MEMBER(apple2_gameio_device::sw3_r)
{
	if (m_intf != nullptr)
		return m_intf->sw3_r();

	return m_sw_pullups ? 1 : 0;
}

WRITE_LINE_MEMBER(apple2_gameio_device::an0_w)
{
	if (m_intf != nullptr)
		m_intf->an0_w(state);
}

WRITE_LINE_MEMBER(apple2_gameio_device::an1_w)
{
	if (m_intf != nullptr)
		m_intf->an1_w(state);
}

WRITE_LINE_MEMBER(apple2_gameio_device::an2_w)
{
	if (m_intf != nullptr)
		m_intf->an2_w(state);
}

WRITE_LINE_MEMBER(apple2_gameio_device::an3_w)
{
	if (m_intf != nullptr)
		m_intf->an3_w(state);
}

WRITE_LINE_MEMBER(apple2_gameio_device::an4_w)
{
	if (m_intf != nullptr)
		m_intf->an4_w(state);
}

WRITE_LINE_MEMBER(apple2_gameio_device::strobe_w)
{
	if (m_intf != nullptr)
		m_intf->strobe_w(state);
}


//**************************************************************************
//  GAME I/O DEVICE INTERFACE
//**************************************************************************

device_a2gameio_interface::device_a2gameio_interface(const machine_config &mconfig, device_t &device)
	: device_interface(device, "a2gameio")
	, m_connector(nullptr)
{
}

device_a2gameio_interface::~device_a2gameio_interface()
{
}