1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 /**********************************************************************
4 
5     Atari Video Computer System analog paddles emulation
6 
7 **********************************************************************/
8 
9 #include "emu.h"
10 #include "paddles.h"
11 
12 
13 
14 //**************************************************************************
15 //  DEVICE DEFINITIONS
16 //**************************************************************************
17 
18 DEFINE_DEVICE_TYPE(VCS_PADDLES, vcs_paddles_device, "vcs_paddles", "Atari / CBM Dual paddles")
19 
20 
INPUT_PORTS_START(vcs_paddles)21 static INPUT_PORTS_START( vcs_paddles )
22 	PORT_START("JOY")
23 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
24 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
25 	PORT_BIT( 0xf3, IP_ACTIVE_LOW, IPT_UNUSED )
26 
27 	PORT_START("POTX")
28 	PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(1) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255)
29 
30 	PORT_START("POTY")
31 	PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(2) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255)
32 INPUT_PORTS_END
33 
34 
35 //-------------------------------------------------
36 //  input_ports - device-specific input ports
37 //-------------------------------------------------
38 
39 ioport_constructor vcs_paddles_device::device_input_ports() const
40 {
41 	return INPUT_PORTS_NAME( vcs_paddles );
42 }
43 
44 
45 
46 //**************************************************************************
47 //  LIVE DEVICE
48 //**************************************************************************
49 
50 //-------------------------------------------------
51 //  vcs_paddles_device - constructor
52 //-------------------------------------------------
53 
vcs_paddles_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)54 vcs_paddles_device::vcs_paddles_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
55 	device_t(mconfig, VCS_PADDLES, tag, owner, clock),
56 	device_vcs_control_port_interface(mconfig, *this),
57 	m_joy(*this, "JOY"),
58 	m_potx(*this, "POTX"),
59 	m_poty(*this, "POTY")
60 {
61 }
62 
63 
64 //-------------------------------------------------
65 //  device_start - device-specific startup
66 //-------------------------------------------------
67 
device_start()68 void vcs_paddles_device::device_start()
69 {
70 }
71 
72 
73 //-------------------------------------------------
74 //  vcs_joy_r - joystick read
75 //-------------------------------------------------
76 
vcs_joy_r()77 uint8_t vcs_paddles_device::vcs_joy_r()
78 {
79 	return m_joy->read();
80 }
81 
82 
83 //-------------------------------------------------
84 //  vcs_pot_x_r - potentiometer X read
85 //-------------------------------------------------
86 
vcs_pot_x_r()87 uint8_t vcs_paddles_device::vcs_pot_x_r()
88 {
89 	return m_potx->read();
90 }
91 
92 
93 //-------------------------------------------------
94 //  vcs_pot_y_r - potentiometer Y read
95 //-------------------------------------------------
96 
vcs_pot_y_r()97 uint8_t vcs_paddles_device::vcs_pot_y_r()
98 {
99 	return m_poty->read();
100 }
101