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
|
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************
Henson CFA 3000 Keyboard
240 Pattern Right 0000
241 Pattern Left 0001
242 Patient Response 0010
243 Present Stimuli 0011
244 Up 0100
245 Down 0101
246 Left 0110
247 Right 0111
248 D 1000
249 C 1001
250 B 1010
251 A 1011
252 Mode 1100
253 Erase 1101
254 Restart 1110
255 Print 1111
**********************************************************************/
#include "emu.h"
#include "cfa3000kbd.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(CFA3000_KBD, cfa3000_kbd_device, "cfa3000kbd", "Henson CFA 3000 Keyboard")
//-------------------------------------------------
// INPUT_PORTS( cfa3000kbd )
//-------------------------------------------------
static INPUT_PORTS_START( cfa3000kbd )
PORT_START("KBD.0")
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Pattern ->") PORT_CODE(KEYCODE_STOP)
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Pattern <-") PORT_CODE(KEYCODE_COMMA)
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Patient Response") PORT_CODE(KEYCODE_SPACE)
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Present Stimuli") PORT_CODE(KEYCODE_S)
PORT_START("KBD.1")
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Up") PORT_CODE(KEYCODE_UP)
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Down") PORT_CODE(KEYCODE_DOWN)
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left/Menu") PORT_CODE(KEYCODE_LEFT)
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right/Extend") PORT_CODE(KEYCODE_RIGHT)
PORT_START("KBD.2")
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D)
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C)
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B)
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A)
PORT_START("KBD.3")
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Mode") PORT_CODE(KEYCODE_M)
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Erase") PORT_CODE(KEYCODE_E)
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Restart") PORT_CODE(KEYCODE_R)
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Print") PORT_CODE(KEYCODE_P)
INPUT_PORTS_END
//-------------------------------------------------
// input_ports - device-specific input ports
//-------------------------------------------------
ioport_constructor cfa3000_kbd_device::device_input_ports() const
{
return INPUT_PORTS_NAME( cfa3000kbd );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// cfa3000_kbd_device - constructor
//-------------------------------------------------
cfa3000_kbd_device::cfa3000_kbd_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock)
: device_t(mconfig, CFA3000_KBD, tag, owner, clock),
device_bbc_userport_interface(mconfig, *this),
m_kbd(*this, "KBD.%u", 0)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void cfa3000_kbd_device::device_start()
{
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void cfa3000_kbd_device::device_reset()
{
}
//**************************************************************************
// IMPLEMENTATION
//**************************************************************************
uint8_t cfa3000_kbd_device::pb_r()
{
uint8_t data = 0x00;
if (m_kbd[0]->read())
{
data = m_kbd[0]->read() >> 1;
data = 0xf0 | (BIT(data, 2) ? 0x03 : data);
}
if (m_kbd[1]->read())
{
data = m_kbd[1]->read() >> 1;
data = 0xf4 | (BIT(data, 2) ? 0x03 : data);
}
if (m_kbd[2]->read())
{
data = m_kbd[2]->read() >> 1;
data = 0xf8 | (BIT(data, 2) ? 0x03 : data);
}
if (m_kbd[3]->read())
{
data = m_kbd[3]->read() >> 1;
data = 0xfc | (BIT(data, 2) ? 0x03 : data);
}
return data;
}
|