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
|
// license:GPL-2.0+
// copyright-holders:Dirk Best
/***************************************************************************
VTech Laser/VZ Joystick Interface
VTech Laser JS 20
Dick Smith Electronics X-7315
***************************************************************************/
#include "emu.h"
#include "joystick.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(VTECH_JOYSTICK_INTERFACE, vtech_joystick_interface_device, "vtech_joystick", "Laser/VZ Joystick Interface")
//-------------------------------------------------
// io_map - memory space address map
//-------------------------------------------------
void vtech_joystick_interface_device::io_map(address_map &map)
{
map.unmap_value_high();
map(0x20, 0x2f).r(FUNC(vtech_joystick_interface_device::joystick_r));
}
//-------------------------------------------------
// input_ports - device-specific input ports
//-------------------------------------------------
static INPUT_PORTS_START( joystick )
PORT_START("joystick_0")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_PLAYER(1)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(1)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(1)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(1)
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1)
PORT_BIT(0xe0, IP_ACTIVE_LOW, IPT_UNUSED)
PORT_START("joystick_0_arm")
PORT_BIT(0x0f, IP_ACTIVE_LOW, IPT_UNUSED)
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(1)
PORT_BIT(0xe0, IP_ACTIVE_LOW, IPT_UNUSED)
PORT_START("joystick_1")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_PLAYER(2)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(2)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(2)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(2)
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(2)
PORT_BIT(0xe0, IP_ACTIVE_LOW, IPT_UNUSED)
PORT_START("joystick_1_arm")
PORT_BIT(0x0f, IP_ACTIVE_LOW, IPT_UNUSED)
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(2)
PORT_BIT(0xe0, IP_ACTIVE_LOW, IPT_UNUSED)
INPUT_PORTS_END
ioport_constructor vtech_joystick_interface_device::device_input_ports() const
{
return INPUT_PORTS_NAME( joystick );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// vtech_joystick_interface_device - constructor
//-------------------------------------------------
vtech_joystick_interface_device::vtech_joystick_interface_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
vtech_ioexp_device(mconfig, VTECH_JOYSTICK_INTERFACE, tag, owner, clock),
m_joy0(*this, "joystick_0"),
m_joy0_arm(*this, "joystick_0_arm"),
m_joy1(*this, "joystick_1"),
m_joy1_arm(*this, "joystick_1_arm")
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void vtech_joystick_interface_device::device_start()
{
vtech_ioexp_device::device_start();
}
//**************************************************************************
// IMPLEMENTATION
//**************************************************************************
uint8_t vtech_joystick_interface_device::joystick_r(offs_t offset)
{
uint8_t data = 0xff;
if (!BIT(offset, 0)) data &= m_joy0->read();
if (!BIT(offset, 1)) data &= m_joy0_arm->read();
if (!BIT(offset, 2)) data &= m_joy1->read();
if (!BIT(offset, 3)) data &= m_joy1_arm->read();
return data;
}
|