diff options
Diffstat (limited to 'src/devices')
-rw-r--r-- | src/devices/bus/a2gameio/gameio.cpp | 197 | ||||
-rw-r--r-- | src/devices/bus/a2gameio/gameio.h | 108 | ||||
-rw-r--r-- | src/devices/bus/a2gameio/joystick.cpp | 133 | ||||
-rw-r--r-- | src/devices/bus/a2gameio/joystick.h | 49 |
4 files changed, 487 insertions, 0 deletions
diff --git a/src/devices/bus/a2gameio/gameio.cpp b/src/devices/bus/a2gameio/gameio.cpp new file mode 100644 index 00000000000..4fe1bc67c7c --- /dev/null +++ b/src/devices/bus/a2gameio/gameio.cpp @@ -0,0 +1,197 @@ +// license:BSD-3-Clause +// copyright-holders:AJR +/********************************************************************* + + Apple II Game I/O Connector + + This 16-pin DIP socket is described in the Apple II Reference + Manual (January 1978) as "a means of connecting paddle controls, + lights and switches to the APPLE II for use in controlling video + games, etc." The connector provides for four analog "paddle" + input signals (0-150KΩ resistance) which are converted to + digital pulses by a NE558 quad timer on the main board. The + connector also provides several digital switch inputs and + "annunciator" outputs, all LS/TTL compatible. + + While pins 9 and 16 are unconnected on the Apple II, they provide + additional digital output and input pins respectively on the Sanyo + MBC-550/555 (which uses 74LS123 monostables instead of a NE558). + The Apple //gs also recognizes a switch input 3, though this is + placed on pin 9 of the internal connector rather than 16. + + The Apple IIe, IIc and IIgs also have an external DE-9 connector + that carries a subset of the signals, excluding the annunciator + outputs and utility strobe (which the IIc and IIgs do not have). + +********************************************************************** + ____________ + +5V 1 |* | 16 (SW3) + SW0 2 | | 15 AN0 + SW1 3 | | 14 AN1 + SW2 4 | | 13 AN2 + /STB 5 | GAME I/O | 12 AN3 + PDL0 6 | | 11 PDL3 + PDL2 7 | | 10 PDL1 + GND 8 | | 9 (AN4/SW3) + ------------ + + --------------------------------- + \ PDL0 PDL2 GND +5V SW1 / + \ (5) (4) (3) (2) (1) / + \ (9) (8) (7) (6) / + \ PDL3 PDL1 SW0 SW2 / + \_______________________/ + +*********************************************************************/ + +#include "emu.h" +#include "bus/a2gameio/gameio.h" +#include "bus/a2gameio/joystick.h" + + +//************************************************************************** +// CONNECTOR DEVICE IMPLEMENTATION +//************************************************************************** + +// device type definition +DEFINE_DEVICE_TYPE(APPLE2_GAMEIO, apple2_gameio_device, "a2gameio", "Apple II Game I/O Connector") + +apple2_gameio_device::apple2_gameio_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, APPLE2_GAMEIO, tag, owner, clock) + , device_slot_interface(mconfig, *this) + , m_intf(nullptr) +{ +} + +void apple2_gameio_device::default_options(device_slot_interface &slot) +{ + slot.option_add("joy", APPLE2_JOYSTICK); +} + +void apple2_gameio_device::device_config_complete() +{ + m_intf = dynamic_cast<device_a2gameio_interface *>(get_card_device()); +} + +void apple2_gameio_device::device_start() +{ +} + + +//************************************************************************** +// PASSTHROUGH HANDLERS +//************************************************************************** + +u8 apple2_gameio_device::pdl0_r() +{ + if (m_intf != nullptr) + return m_intf->pdl0_r(); + + return 0; +} + +u8 apple2_gameio_device::pdl1_r() +{ + if (m_intf != nullptr) + return m_intf->pdl1_r(); + + return 0; +} + +u8 apple2_gameio_device::pdl2_r() +{ + if (m_intf != nullptr) + return m_intf->pdl2_r(); + + return 0; +} + +u8 apple2_gameio_device::pdl3_r() +{ + if (m_intf != nullptr) + return m_intf->pdl3_r(); + + return 0; +} + +READ_LINE_MEMBER(apple2_gameio_device::sw0_r) +{ + if (m_intf != nullptr) + return m_intf->sw0_r(); + + return 1; +} + +READ_LINE_MEMBER(apple2_gameio_device::sw1_r) +{ + if (m_intf != nullptr) + return m_intf->sw1_r(); + + return 1; +} + +READ_LINE_MEMBER(apple2_gameio_device::sw2_r) +{ + if (m_intf != nullptr) + return m_intf->sw2_r(); + + return 1; +} + +READ_LINE_MEMBER(apple2_gameio_device::sw3_r) +{ + if (m_intf != nullptr) + return m_intf->sw3_r(); + + return 1; +} + +WRITE_LINE_MEMBER(apple2_gameio_device::an0_w) +{ + if (m_intf != nullptr) + m_intf->an0_w(state); +} + +WRITE_LINE_MEMBER(apple2_gameio_device::an1_w) +{ + if (m_intf != nullptr) + m_intf->an1_w(state); +} + +WRITE_LINE_MEMBER(apple2_gameio_device::an2_w) +{ + if (m_intf != nullptr) + m_intf->an2_w(state); +} + +WRITE_LINE_MEMBER(apple2_gameio_device::an3_w) +{ + if (m_intf != nullptr) + m_intf->an3_w(state); +} + +WRITE_LINE_MEMBER(apple2_gameio_device::an4_w) +{ + if (m_intf != nullptr) + m_intf->an4_w(state); +} + +WRITE_LINE_MEMBER(apple2_gameio_device::strobe_w) +{ + if (m_intf != nullptr) + m_intf->strobe_w(state); +} + + +//************************************************************************** +// GAME I/O DEVICE INTERFACE +//************************************************************************** + +device_a2gameio_interface::device_a2gameio_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig, device) +{ +} + +device_a2gameio_interface::~device_a2gameio_interface() +{ +} diff --git a/src/devices/bus/a2gameio/gameio.h b/src/devices/bus/a2gameio/gameio.h new file mode 100644 index 00000000000..618a874b186 --- /dev/null +++ b/src/devices/bus/a2gameio/gameio.h @@ -0,0 +1,108 @@ +// license:BSD-3-Clause +// copyright-holders:AJR +/********************************************************************* + + Apple II Game I/O Connector + +*********************************************************************/ + +#ifndef MAME_BUS_A2GAMEIO_GAMEIO_H +#define MAME_BUS_A2GAMEIO_GAMEIO_H 1 + +#pragma once + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// forward declaration +class device_a2gameio_interface; + +// ======================> apple2_gameio_device + +class apple2_gameio_device : public device_t, public device_slot_interface +{ +public: + // construction/destruction + apple2_gameio_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + + template <typename T> + apple2_gameio_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt) + : apple2_gameio_device(mconfig, tag, owner, 0U) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + + // standard options + static void default_options(device_slot_interface &slot); + + // analog paddles + u8 pdl0_r(); + u8 pdl1_r(); + u8 pdl2_r(); + u8 pdl3_r(); + + // digital switches + DECLARE_READ_LINE_MEMBER(sw0_r); + DECLARE_READ_LINE_MEMBER(sw1_r); + DECLARE_READ_LINE_MEMBER(sw2_r); + DECLARE_READ_LINE_MEMBER(sw3_r); + + // annunciator outputs + DECLARE_WRITE_LINE_MEMBER(an0_w); + DECLARE_WRITE_LINE_MEMBER(an1_w); + DECLARE_WRITE_LINE_MEMBER(an2_w); + DECLARE_WRITE_LINE_MEMBER(an3_w); + DECLARE_WRITE_LINE_MEMBER(an4_w); + + // utility strobe (active low) + DECLARE_WRITE_LINE_MEMBER(strobe_w); + +protected: + // device-level overrides + virtual void device_config_complete() override; + virtual void device_start() override; + +private: + // selected device + device_a2gameio_interface *m_intf; +}; + +// ======================> device_a2gameio_interface + +class device_a2gameio_interface : public device_slot_card_interface +{ + friend class apple2_gameio_device; + +protected: + // construction/destruction + device_a2gameio_interface(const machine_config &mconfig, device_t &device); + virtual ~device_a2gameio_interface(); + + // optional input overrides + virtual u8 pdl0_r() { return 0; } + virtual u8 pdl1_r() { return 0; } + virtual u8 pdl2_r() { return 0; } + virtual u8 pdl3_r() { return 0; } + virtual DECLARE_READ_LINE_MEMBER(sw0_r) { return 1; } + virtual DECLARE_READ_LINE_MEMBER(sw1_r) { return 1; } + virtual DECLARE_READ_LINE_MEMBER(sw2_r) { return 1; } + virtual DECLARE_READ_LINE_MEMBER(sw3_r) { return 1; } + + // optional output overrides + virtual DECLARE_WRITE_LINE_MEMBER(an0_w) { } + virtual DECLARE_WRITE_LINE_MEMBER(an1_w) { } + virtual DECLARE_WRITE_LINE_MEMBER(an2_w) { } + virtual DECLARE_WRITE_LINE_MEMBER(an3_w) { } + virtual DECLARE_WRITE_LINE_MEMBER(an4_w) { } + virtual DECLARE_WRITE_LINE_MEMBER(strobe_w) { } +}; + +// device type declaration +DECLARE_DEVICE_TYPE(APPLE2_GAMEIO, apple2_gameio_device) + +#endif // MAME_BUS_A2GAMEIO_GAMEIO_H diff --git a/src/devices/bus/a2gameio/joystick.cpp b/src/devices/bus/a2gameio/joystick.cpp new file mode 100644 index 00000000000..02f256c8303 --- /dev/null +++ b/src/devices/bus/a2gameio/joystick.cpp @@ -0,0 +1,133 @@ +// license:BSD-3-Clause +// copyright-holders:R. Belmont +/********************************************************************* + + Apple II analog joysticks + +*********************************************************************/ + +#include "emu.h" +#include "bus/a2gameio/joystick.h" + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +// device type definition +DEFINE_DEVICE_TYPE(APPLE2_JOYSTICK, apple2_joystick_device, "a2joy", "Apple II analog joysticks") + +//************************************************************************** +// PARAMETERS +//************************************************************************** + +#define JOYSTICK_DELTA 80 +#define JOYSTICK_SENSITIVITY 50 +#define JOYSTICK_AUTOCENTER 80 + +//************************************************************************** +// INPUT PORTS +//************************************************************************** + +static INPUT_PORTS_START( apple2_joystick ) + PORT_START("joystick_1_x") /* Joystick 1 X Axis */ + PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X) PORT_NAME("P1 Joystick X") + PORT_SENSITIVITY(JOYSTICK_SENSITIVITY) + PORT_KEYDELTA(JOYSTICK_DELTA) + PORT_CENTERDELTA(JOYSTICK_AUTOCENTER) + PORT_MINMAX(0,0xff) PORT_PLAYER(1) + PORT_CODE_DEC(KEYCODE_4_PAD) PORT_CODE_INC(KEYCODE_6_PAD) + PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) + + PORT_START("joystick_1_y") /* Joystick 1 Y Axis */ + PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y) PORT_NAME("P1 Joystick Y") + PORT_SENSITIVITY(JOYSTICK_SENSITIVITY) + PORT_KEYDELTA(JOYSTICK_DELTA) + PORT_CENTERDELTA(JOYSTICK_AUTOCENTER) + PORT_MINMAX(0,0xff) PORT_PLAYER(1) + PORT_CODE_DEC(KEYCODE_8_PAD) PORT_CODE_INC(KEYCODE_2_PAD) + PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) + + PORT_START("joystick_2_x") /* Joystick 2 X Axis */ + PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X) PORT_NAME("P2 Joystick X") + PORT_SENSITIVITY(JOYSTICK_SENSITIVITY) + PORT_KEYDELTA(JOYSTICK_DELTA) + PORT_CENTERDELTA(JOYSTICK_AUTOCENTER) + PORT_MINMAX(0,0xff) PORT_PLAYER(2) + PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) + + PORT_START("joystick_2_y") /* Joystick 2 Y Axis */ + PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y) PORT_NAME("P2 Joystick Y") + PORT_SENSITIVITY(JOYSTICK_SENSITIVITY) + PORT_KEYDELTA(JOYSTICK_DELTA) + PORT_CENTERDELTA(JOYSTICK_AUTOCENTER) + PORT_MINMAX(0,0xff) PORT_PLAYER(2) + PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) + + PORT_START("joystick_buttons") + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(1) PORT_CODE(KEYCODE_0_PAD) PORT_CODE(JOYCODE_BUTTON1) + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_PLAYER(1) PORT_CODE(KEYCODE_ENTER_PAD)PORT_CODE(JOYCODE_BUTTON2) + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_PLAYER(2) PORT_CODE(JOYCODE_BUTTON1) + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_PLAYER(2) PORT_CODE(JOYCODE_BUTTON2) +INPUT_PORTS_END + +//************************************************************************** +// DEVICE IMPLEMENTATION +//************************************************************************** + +apple2_joystick_device::apple2_joystick_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, APPLE2_JOYSTICK, tag, owner, clock) + , device_a2gameio_interface(mconfig, *this) + , m_joy_x(*this, "joystick_%u_x", 1U) + , m_joy_y(*this, "joystick_%u_y", 1U) + , m_buttons(*this, "joystick_buttons") +{ +} + +ioport_constructor apple2_joystick_device::device_input_ports() const +{ + return INPUT_PORTS_NAME(apple2_joystick); +} + +void apple2_joystick_device::device_start() +{ +} + +u8 apple2_joystick_device::pdl0_r() +{ + return m_joy_x[0]->read(); +} + +u8 apple2_joystick_device::pdl1_r() +{ + return m_joy_y[0]->read(); +} + +u8 apple2_joystick_device::pdl2_r() +{ + return m_joy_x[1]->read(); +} + +u8 apple2_joystick_device::pdl3_r() +{ + return m_joy_x[1]->read(); +} + +READ_LINE_MEMBER(apple2_joystick_device::sw0_r) +{ + return BIT(m_buttons->read(), 4); +} + +READ_LINE_MEMBER(apple2_joystick_device::sw1_r) +{ + return BIT(m_buttons->read(), 5); +} + +READ_LINE_MEMBER(apple2_joystick_device::sw2_r) +{ + return BIT(m_buttons->read(), 6); +} + +READ_LINE_MEMBER(apple2_joystick_device::sw3_r) +{ + return BIT(m_buttons->read(), 7); +} diff --git a/src/devices/bus/a2gameio/joystick.h b/src/devices/bus/a2gameio/joystick.h new file mode 100644 index 00000000000..20a17177a32 --- /dev/null +++ b/src/devices/bus/a2gameio/joystick.h @@ -0,0 +1,49 @@ +// license:BSD-3-Clause +// copyright-holders:R. Belmont +/********************************************************************* + + Apple II analog joysticks + +*********************************************************************/ + +#ifndef MAME_BUS_A2GAMEIO_JOYSTICK_H +#define MAME_BUS_A2GAMEIO_JOYSTICK_H 1 + +#pragma once + +#include "bus/a2gameio/gameio.h" + +// ======================> apple2_joystick_device + +class apple2_joystick_device : public device_t, public device_a2gameio_interface +{ +public: + // construction/destruction + apple2_joystick_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<2> m_joy_x; + required_ioport_array<2> m_joy_y; + required_ioport m_buttons; +}; + +// device type declaration +DECLARE_DEVICE_TYPE(APPLE2_JOYSTICK, apple2_joystick_device) + +#endif // MAME_BUS_A2GAMEIO_JOYSTICK_H |