1 // license:BSD-3-Clause
2 // copyright-holders:Nigel Barnes
3 /**********************************************************************
4
5 Kempston Joystick Interface
6
7 **********************************************************************/
8
9 #include "emu.h"
10 #include "kempjoy.h"
11
12 //**************************************************************************
13 // DEVICE DEFINITIONS
14 //**************************************************************************
15
16 DEFINE_DEVICE_TYPE(SPECTRUM_KEMPJOY, spectrum_kempjoy_device, "spectrum_kempjoy", "Kempston Joystick Interface")
17
18
19 //-------------------------------------------------
20 // INPUT_PORTS( kempjoy )
21 //-------------------------------------------------
22
INPUT_PORTS_START(kempjoy)23 static INPUT_PORTS_START( kempjoy )
24 PORT_START("JOY")
25 PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT) PORT_8WAY
26 PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT) PORT_8WAY
27 PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN) PORT_8WAY
28 PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP) PORT_8WAY
29 PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_BUTTON1)
30 INPUT_PORTS_END
31
32
33 //-------------------------------------------------
34 // input_ports - device-specific input ports
35 //-------------------------------------------------
36
37 ioport_constructor spectrum_kempjoy_device::device_input_ports() const
38 {
39 return INPUT_PORTS_NAME( kempjoy );
40 }
41
42
43 //**************************************************************************
44 // LIVE DEVICE
45 //**************************************************************************
46
47 //-------------------------------------------------
48 // spectrum_kempjoy_device - constructor
49 //-------------------------------------------------
50
spectrum_kempjoy_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)51 spectrum_kempjoy_device::spectrum_kempjoy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
52 : device_t(mconfig, SPECTRUM_KEMPJOY, tag, owner, clock)
53 , device_spectrum_expansion_interface(mconfig, *this)
54 , m_joy(*this, "JOY")
55 {
56 }
57
58
59 //-------------------------------------------------
60 // device_start - device-specific startup
61 //-------------------------------------------------
62
device_start()63 void spectrum_kempjoy_device::device_start()
64 {
65 }
66
67
68 //**************************************************************************
69 // IMPLEMENTATION
70 //**************************************************************************
71
iorq_r(offs_t offset)72 uint8_t spectrum_kempjoy_device::iorq_r(offs_t offset)
73 {
74 uint8_t data = 0xff;
75
76 if ((offset & 0x00ff) == 0x1f)
77 {
78 data = m_joy->read() & 0x1f;
79 }
80 return data;
81 }
82