summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author arbee <rb6502@users.noreply.github.com>2019-07-28 21:43:18 -0400
committer arbee <rb6502@users.noreply.github.com>2019-07-28 21:43:18 -0400
commit908be5577523a69bcd7e1a0fbe102c910b9aa832 (patch)
treea088237b9142db7584545d931a4f6933ec8ff466
parentacbc95ebb53ded8b3aaa43258da360f0d18aee58 (diff)
apple2: support Sirius JoyPort on compatible Apple II models. [R. Belmont]
-rw-r--r--scripts/src/bus.lua2
-rw-r--r--src/devices/bus/a2gameio/gameio.cpp7
-rw-r--r--src/devices/bus/a2gameio/gameio.h1
-rw-r--r--src/devices/bus/a2gameio/joyport.cpp106
-rw-r--r--src/devices/bus/a2gameio/joyport.h45
-rw-r--r--src/mame/drivers/apple2.cpp2
6 files changed, 162 insertions, 1 deletions
diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua
index 2ca74db3c79..c713f87cd94 100644
--- a/scripts/src/bus.lua
+++ b/scripts/src/bus.lua
@@ -2145,6 +2145,8 @@ if (BUSES["A2GAMEIO"]~=null) then
MAME_DIR .. "src/devices/bus/a2gameio/gameio.h",
MAME_DIR .. "src/devices/bus/a2gameio/joystick.cpp",
MAME_DIR .. "src/devices/bus/a2gameio/joystick.h",
+ MAME_DIR .. "src/devices/bus/a2gameio/joyport.cpp",
+ MAME_DIR .. "src/devices/bus/a2gameio/joyport.h",
}
end
diff --git a/src/devices/bus/a2gameio/gameio.cpp b/src/devices/bus/a2gameio/gameio.cpp
index bac60f87213..0fbe103916a 100644
--- a/src/devices/bus/a2gameio/gameio.cpp
+++ b/src/devices/bus/a2gameio/gameio.cpp
@@ -50,6 +50,7 @@
#include "emu.h"
#include "bus/a2gameio/gameio.h"
#include "bus/a2gameio/joystick.h"
+#include "bus/a2gameio/joyport.h"
//**************************************************************************
@@ -66,6 +67,12 @@ 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("joyport", APPLE2_JOYPORT);
+}
+
void apple2_gameio_device::default_options(device_slot_interface &slot)
{
slot.option_add("joy", APPLE2_JOYSTICK);
diff --git a/src/devices/bus/a2gameio/gameio.h b/src/devices/bus/a2gameio/gameio.h
index 939c9660b7d..fa0c1b5eb52 100644
--- a/src/devices/bus/a2gameio/gameio.h
+++ b/src/devices/bus/a2gameio/gameio.h
@@ -43,6 +43,7 @@ public:
// standard options
static void default_options(device_slot_interface &slot);
+ static void iiandplus_options(device_slot_interface &slot);
// analog paddles
u8 pdl0_r();
diff --git a/src/devices/bus/a2gameio/joyport.cpp b/src/devices/bus/a2gameio/joyport.cpp
new file mode 100644
index 00000000000..987724adb91
--- /dev/null
+++ b/src/devices/bus/a2gameio/joyport.cpp
@@ -0,0 +1,106 @@
+// license:BSD-3-Clause
+// copyright-holders:R. Belmont
+/*********************************************************************
+
+ Sirius JoyPort - connects 2 digital joysticks to Apple II and II Plus
+
+ This doesn't work on the IIe or IIgs because the buttons are
+ active low, meaning those systems always go into self-test if a
+ JoyPort is connected. Also, the annunciator useage could clash
+ with double-hi-res on those systems.
+
+ IIc and IIc Plus are out because they don't have annunciator outputs.
+
+*********************************************************************/
+
+#include "emu.h"
+#include "bus/a2gameio/joyport.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+// device type definition
+DEFINE_DEVICE_TYPE(APPLE2_JOYPORT, apple2_joyport_device, "a2joyprt", "Sirius JoyPort")
+
+//**************************************************************************
+// PARAMETERS
+//**************************************************************************
+
+#define JOYSTICK_DELTA 80
+#define JOYSTICK_SENSITIVITY 50
+#define JOYSTICK_AUTOCENTER 80
+
+//**************************************************************************
+// INPUT PORTS
+//**************************************************************************
+
+static INPUT_PORTS_START( apple2_joyport )
+ PORT_START("joystick_p1")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
+ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
+
+ PORT_START("joystick_p2")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
+ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
+INPUT_PORTS_END
+
+//**************************************************************************
+// DEVICE IMPLEMENTATION
+//**************************************************************************
+
+apple2_joyport_device::apple2_joyport_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, APPLE2_JOYPORT, tag, owner, clock)
+ , device_a2gameio_interface(mconfig, *this)
+ , m_player1(*this, "joystick_p1")
+ , m_player2(*this, "joystick_p2")
+{
+}
+
+ioport_constructor apple2_joyport_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME(apple2_joyport);
+}
+
+void apple2_joyport_device::device_start()
+{
+ save_item(NAME(m_an0));
+ save_item(NAME(m_an1));
+}
+
+READ_LINE_MEMBER(apple2_joyport_device::sw0_r)
+{
+ u8 port_read = m_an1 ? m_player2->read() : m_player1->read();
+
+ return BIT(port_read, 4);
+}
+
+READ_LINE_MEMBER(apple2_joyport_device::sw1_r)
+{
+ u8 port_read = m_an1 ? m_player2->read() : m_player1->read();
+
+ return m_an1 ? BIT(port_read, 0) : BIT(port_read, 3);
+}
+
+READ_LINE_MEMBER(apple2_joyport_device::sw2_r)
+{
+ u8 port_read = m_an1 ? m_player2->read() : m_player1->read();
+
+ return m_an1 ? BIT(port_read, 2) : BIT(port_read, 1);
+}
+
+WRITE_LINE_MEMBER(apple2_joyport_device::an0_w)
+{
+ m_an0 = state;
+}
+
+WRITE_LINE_MEMBER(apple2_joyport_device::an1_w)
+{
+ m_an1 = state;
+}
diff --git a/src/devices/bus/a2gameio/joyport.h b/src/devices/bus/a2gameio/joyport.h
new file mode 100644
index 00000000000..e138358d87e
--- /dev/null
+++ b/src/devices/bus/a2gameio/joyport.h
@@ -0,0 +1,45 @@
+// license:BSD-3-Clause
+// copyright-holders:R. Belmont
+/*********************************************************************
+
+ Sirius JoyPort
+
+*********************************************************************/
+
+#ifndef MAME_BUS_A2GAMEIO_JOYPORT_H
+#define MAME_BUS_A2GAMEIO_JOYPORT_H 1
+
+#pragma once
+
+#include "bus/a2gameio/gameio.h"
+
+// ======================> apple2_joyport_device
+
+class apple2_joyport_device : public device_t, public device_a2gameio_interface
+{
+public:
+ // construction/destruction
+ apple2_joyport_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 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_WRITE_LINE_MEMBER(an0_w) override;
+ virtual DECLARE_WRITE_LINE_MEMBER(an1_w) override;
+
+private:
+ // input ports
+ required_ioport m_player1, m_player2;
+ int m_an0, m_an1;
+};
+
+// device type declaration
+DECLARE_DEVICE_TYPE(APPLE2_JOYPORT, apple2_joyport_device)
+
+#endif // MAME_BUS_A2GAMEIO_JOYPORT_H
diff --git a/src/mame/drivers/apple2.cpp b/src/mame/drivers/apple2.cpp
index 49167213275..deea9b6e3ed 100644
--- a/src/mame/drivers/apple2.cpp
+++ b/src/mame/drivers/apple2.cpp
@@ -1305,7 +1305,7 @@ void apple2_state::apple2_common(machine_config &config)
m_softlatch->q_out_cb<6>().append(m_video, FUNC(a2_video_device::an2_w));
m_softlatch->q_out_cb<7>().set(m_gameio, FUNC(apple2_gameio_device::an3_w));
- APPLE2_GAMEIO(config, m_gameio, apple2_gameio_device::default_options, nullptr);
+ APPLE2_GAMEIO(config, m_gameio, apple2_gameio_device::iiandplus_options, nullptr);
/* keyboard controller */
AY3600(config, m_ay3600, 0);