1 // license:BSD-3-Clause
2 // copyright-holders:Nigel Barnes
3 /**********************************************************************
4
5 Joystick
6
7 **********************************************************************/
8
9 #include "emu.h"
10 #include "joystick.h"
11
12 //**************************************************************************
13 // DEVICE DEFINITIONS
14 //**************************************************************************
15
16 DEFINE_DEVICE_TYPE(BBCMC_JOYSTICK, bbcmc_joystick_device, "bbcmc_joystick", "Master Compact Joystick")
17
18
19 //-------------------------------------------------
20 // INPUT_PORTS( joystick )
21 //-------------------------------------------------
22
INPUT_PORTS_START(joystick)23 static INPUT_PORTS_START( joystick )
24 PORT_START("JOY")
25 PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Fire")
26 PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_8WAY
27 PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_8WAY
28 PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_8WAY
29 PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_8WAY
30 INPUT_PORTS_END
31
32
33 //-------------------------------------------------
34 // input_ports - device-specific input ports
35 //-------------------------------------------------
36
37 ioport_constructor bbcmc_joystick_device::device_input_ports() const
38 {
39 return INPUT_PORTS_NAME( joystick );
40 }
41
42
43 //**************************************************************************
44 // LIVE DEVICE
45 //**************************************************************************
46
47 //-------------------------------------------------
48 // bbcmc_joystick_device - constructor
49 //-------------------------------------------------
50
bbcmc_joystick_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)51 bbcmc_joystick_device::bbcmc_joystick_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
52 : device_t(mconfig, BBCMC_JOYSTICK, tag, owner, clock)
53 , device_bbc_joyport_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 bbcmc_joystick_device::device_start()
64 {
65 }
66
67
68 //-------------------------------------------------
69 // device_reset - device-specific reset
70 //-------------------------------------------------
71
device_reset()72 void bbcmc_joystick_device::device_reset()
73 {
74 }
75
76
77 //**************************************************************************
78 // IMPLEMENTATION
79 //**************************************************************************
80
pb_r()81 uint8_t bbcmc_joystick_device::pb_r()
82 {
83 return m_joy->read();
84 }
85