summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar arbee <rb6502@users.noreply.github.com>2019-12-10 22:56:48 -0500
committerGravatarGravatar arbee <rb6502@users.noreply.github.com>2019-12-10 22:56:48 -0500
commit24eb8d5d074f8bd4e8701dd9cdef2258926f43fd (patch)
tree2c3867399258a774029c06ff962f1b07ce2c87c3
parentcdac74dd3ac340c0fbffb1a0ec98904aa92c49cb (diff)
apple2: add support for paddles [R. Belmont]
-rw-r--r--scripts/src/bus.lua2
-rw-r--r--src/devices/bus/a2gameio/gameio.cpp3
-rwxr-xr-xsrc/devices/bus/a2gameio/paddles.cpp102
-rwxr-xr-xsrc/devices/bus/a2gameio/paddles.h48
4 files changed, 155 insertions, 0 deletions
diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua
index cddd6e13a30..d917a846642 100644
--- a/scripts/src/bus.lua
+++ b/scripts/src/bus.lua
@@ -2285,6 +2285,8 @@ if (BUSES["A2GAMEIO"]~=null) then
MAME_DIR .. "src/devices/bus/a2gameio/joystick.h",
MAME_DIR .. "src/devices/bus/a2gameio/joyport.cpp",
MAME_DIR .. "src/devices/bus/a2gameio/joyport.h",
+ MAME_DIR .. "src/devices/bus/a2gameio/paddles.cpp",
+ MAME_DIR .. "src/devices/bus/a2gameio/paddles.h",
}
end
diff --git a/src/devices/bus/a2gameio/gameio.cpp b/src/devices/bus/a2gameio/gameio.cpp
index 7704d4ff382..f16bf0ee030 100644
--- a/src/devices/bus/a2gameio/gameio.cpp
+++ b/src/devices/bus/a2gameio/gameio.cpp
@@ -52,6 +52,7 @@
#include "bus/a2gameio/joystick.h"
#include "bus/a2gameio/joyport.h"
#include "bus/a2gameio/computereyes.h"
+#include "bus/a2gameio/paddles.h"
//**************************************************************************
@@ -71,6 +72,7 @@ apple2_gameio_device::apple2_gameio_device(const machine_config &mconfig, const
void apple2_gameio_device::iiandplus_options(device_slot_interface &slot)
{
slot.option_add("joy", APPLE2_JOYSTICK);
+ slot.option_add("paddles", APPLE2_PADDLES);
slot.option_add("joyport", APPLE2_JOYPORT);
slot.option_add("compeyes", APPLE2_COMPUTEREYES);
}
@@ -78,6 +80,7 @@ void apple2_gameio_device::iiandplus_options(device_slot_interface &slot)
void apple2_gameio_device::default_options(device_slot_interface &slot)
{
slot.option_add("joy", APPLE2_JOYSTICK);
+ slot.option_add("paddles", APPLE2_PADDLES);
slot.option_add("compeyes", APPLE2_COMPUTEREYES);
}
diff --git a/src/devices/bus/a2gameio/paddles.cpp b/src/devices/bus/a2gameio/paddles.cpp
new file mode 100755
index 00000000000..95d0199a210
--- /dev/null
+++ b/src/devices/bus/a2gameio/paddles.cpp
@@ -0,0 +1,102 @@
+// license:BSD-3-Clause
+// copyright-holders:R. Belmont
+/*********************************************************************
+
+ Apple II paddles
+
+*********************************************************************/
+
+#include "emu.h"
+#include "bus/a2gameio/paddles.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+// device type definition
+DEFINE_DEVICE_TYPE(APPLE2_PADDLES, apple2_paddles_device, "a2pdls", "Apple II paddles")
+
+//**************************************************************************
+// INPUT PORTS
+//**************************************************************************
+
+static INPUT_PORTS_START( apple2_paddles )
+ PORT_START("paddle_1")
+ PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(1) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255)
+
+ PORT_START("paddle_2")
+ PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(2) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255)
+
+ PORT_START("paddle_3")
+ PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(3) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255)
+
+ PORT_START("paddle_4")
+ PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(4) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255)
+
+ PORT_START("paddle_buttons")
+ PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(1)
+ PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(2)
+ PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(3)
+ PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(4)
+INPUT_PORTS_END
+
+//**************************************************************************
+// DEVICE IMPLEMENTATION
+//**************************************************************************
+
+apple2_paddles_device::apple2_paddles_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, APPLE2_PADDLES, tag, owner, clock)
+ , device_a2gameio_interface(mconfig, *this)
+ , m_pdl(*this, "paddle_%u", 1U)
+ , m_buttons(*this, "paddle_buttons")
+{
+}
+
+ioport_constructor apple2_paddles_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME(apple2_paddles);
+}
+
+void apple2_paddles_device::device_start()
+{
+}
+
+u8 apple2_paddles_device::pdl0_r()
+{
+ return m_pdl[0]->read();
+}
+
+u8 apple2_paddles_device::pdl1_r()
+{
+ return m_pdl[1]->read();
+}
+
+u8 apple2_paddles_device::pdl2_r()
+{
+ return m_pdl[2]->read();
+}
+
+u8 apple2_paddles_device::pdl3_r()
+{
+ return m_pdl[3]->read();
+}
+
+READ_LINE_MEMBER(apple2_paddles_device::sw0_r)
+{
+ return BIT(m_buttons->read(), 4);
+}
+
+READ_LINE_MEMBER(apple2_paddles_device::sw1_r)
+{
+ return BIT(m_buttons->read(), 5);
+}
+
+READ_LINE_MEMBER(apple2_paddles_device::sw2_r)
+{
+ return BIT(m_buttons->read(), 6);
+}
+
+READ_LINE_MEMBER(apple2_paddles_device::sw3_r)
+{
+ return BIT(m_buttons->read(), 7);
+}
diff --git a/src/devices/bus/a2gameio/paddles.h b/src/devices/bus/a2gameio/paddles.h
new file mode 100755
index 00000000000..3cff10dd097
--- /dev/null
+++ b/src/devices/bus/a2gameio/paddles.h
@@ -0,0 +1,48 @@
+// license:BSD-3-Clause
+// copyright-holders:R. Belmont
+/*********************************************************************
+
+ Apple II paddles
+
+*********************************************************************/
+
+#ifndef MAME_BUS_A2GAMEIO_PADDLES_H
+#define MAME_BUS_A2GAMEIO_PADDLES_H
+
+#pragma once
+
+#include "bus/a2gameio/gameio.h"
+
+// ======================> apple2_paddles_device
+
+class apple2_paddles_device : public device_t, public device_a2gameio_interface
+{
+public:
+ // construction/destruction
+ apple2_paddles_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+
+protected:
+ // device-level overrides
+ virtual ioport_constructor device_input_ports() const override;
+ virtual void device_start() override;
+
+ // device_a2gameio_interface overrides
+ virtual u8 pdl0_r() override;
+ virtual u8 pdl1_r() override;
+ virtual u8 pdl2_r() override;
+ virtual u8 pdl3_r() override;
+ virtual DECLARE_READ_LINE_MEMBER(sw0_r) override;
+ virtual DECLARE_READ_LINE_MEMBER(sw1_r) override;
+ virtual DECLARE_READ_LINE_MEMBER(sw2_r) override;
+ virtual DECLARE_READ_LINE_MEMBER(sw3_r) override;
+
+private:
+ // input ports
+ required_ioport_array<4> m_pdl;
+ required_ioport m_buttons;
+};
+
+// device type declaration
+DECLARE_DEVICE_TYPE(APPLE2_PADDLES, apple2_paddles_device)
+
+#endif // MAME_BUS_A2GAMEIO_PADDLES_H