1 // license:BSD-3-Clause
2 // copyright-holders:R. Belmont
3 /*********************************************************************
4
5 Apple II paddles
6
7 *********************************************************************/
8
9 #include "emu.h"
10 #include "bus/a2gameio/paddles.h"
11
12 //**************************************************************************
13 // GLOBAL VARIABLES
14 //**************************************************************************
15
16 // device type definition
17 DEFINE_DEVICE_TYPE(APPLE2_PADDLES, apple2_paddles_device, "a2pdls", "Apple II paddles")
18
19 //**************************************************************************
20 // INPUT PORTS
21 //**************************************************************************
22
INPUT_PORTS_START(apple2_paddles)23 static INPUT_PORTS_START( apple2_paddles )
24 PORT_START("paddle_1")
25 PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(1) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255)
26
27 PORT_START("paddle_2")
28 PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(2) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255)
29
30 PORT_START("paddle_3")
31 PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(3) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255)
32
33 PORT_START("paddle_4")
34 PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(4) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255)
35
36 PORT_START("paddle_buttons")
37 PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(1)
38 PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(2)
39 PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(3)
40 PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(4)
41 INPUT_PORTS_END
42
43 //**************************************************************************
44 // DEVICE IMPLEMENTATION
45 //**************************************************************************
46
47 apple2_paddles_device::apple2_paddles_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
48 : device_t(mconfig, APPLE2_PADDLES, tag, owner, clock)
49 , device_a2gameio_interface(mconfig, *this)
50 , m_pdl(*this, "paddle_%u", 1U)
51 , m_buttons(*this, "paddle_buttons")
52 {
53 }
54
device_input_ports() const55 ioport_constructor apple2_paddles_device::device_input_ports() const
56 {
57 return INPUT_PORTS_NAME(apple2_paddles);
58 }
59
device_start()60 void apple2_paddles_device::device_start()
61 {
62 }
63
pdl0_r()64 u8 apple2_paddles_device::pdl0_r()
65 {
66 return m_pdl[0]->read();
67 }
68
pdl1_r()69 u8 apple2_paddles_device::pdl1_r()
70 {
71 return m_pdl[1]->read();
72 }
73
pdl2_r()74 u8 apple2_paddles_device::pdl2_r()
75 {
76 return m_pdl[2]->read();
77 }
78
pdl3_r()79 u8 apple2_paddles_device::pdl3_r()
80 {
81 return m_pdl[3]->read();
82 }
83
READ_LINE_MEMBER(apple2_paddles_device::sw0_r)84 READ_LINE_MEMBER(apple2_paddles_device::sw0_r)
85 {
86 return BIT(m_buttons->read(), 4);
87 }
88
READ_LINE_MEMBER(apple2_paddles_device::sw1_r)89 READ_LINE_MEMBER(apple2_paddles_device::sw1_r)
90 {
91 return BIT(m_buttons->read(), 5);
92 }
93
READ_LINE_MEMBER(apple2_paddles_device::sw2_r)94 READ_LINE_MEMBER(apple2_paddles_device::sw2_r)
95 {
96 return BIT(m_buttons->read(), 6);
97 }
98
READ_LINE_MEMBER(apple2_paddles_device::sw3_r)99 READ_LINE_MEMBER(apple2_paddles_device::sw3_r)
100 {
101 return BIT(m_buttons->read(), 7);
102 }
103