From 7e54e1263b2e5ea705f5241c9ece591effb76ab0 Mon Sep 17 00:00:00 2001 From: AJR Date: Mon, 10 Jun 2019 16:32:11 -0400 Subject: apple2, apple2e, apple2gs: Generic emulation of Game I/O connector. Joysticks are now slot devices. mbc55x: Add Game I/O port --- scripts/src/bus.lua | 14 +++ scripts/target/mame/mess.lua | 1 + src/devices/bus/a2gameio/gameio.cpp | 197 ++++++++++++++++++++++++++++++++++ src/devices/bus/a2gameio/gameio.h | 108 +++++++++++++++++++ src/devices/bus/a2gameio/joystick.cpp | 133 +++++++++++++++++++++++ src/devices/bus/a2gameio/joystick.h | 49 +++++++++ src/mame/drivers/apple2.cpp | 114 ++++---------------- src/mame/drivers/apple2e.cpp | 135 ++++++++++------------- src/mame/drivers/apple2gs.cpp | 116 ++++++++------------ src/mame/drivers/mbc55x.cpp | 44 ++++++-- src/mame/includes/mbc55x.h | 8 +- 11 files changed, 671 insertions(+), 248 deletions(-) create mode 100644 src/devices/bus/a2gameio/gameio.cpp create mode 100644 src/devices/bus/a2gameio/gameio.h create mode 100644 src/devices/bus/a2gameio/joystick.cpp create mode 100644 src/devices/bus/a2gameio/joystick.h diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index e646f61ff36..780df068e5c 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -2124,6 +2124,20 @@ if (BUSES["A2BUS"]~=null) then } end +--------------------------------------------------- +-- +--@src/devices/bus/a2gameio/gameio.h,BUSES["A2GAMEIO"] = true +--------------------------------------------------- + +if (BUSES["A2GAMEIO"]~=null) then + files { + MAME_DIR .. "src/devices/bus/a2gameio/gameio.cpp", + MAME_DIR .. "src/devices/bus/a2gameio/gameio.h", + MAME_DIR .. "src/devices/bus/a2gameio/joystick.cpp", + MAME_DIR .. "src/devices/bus/a2gameio/joystick.h", + } +end + --------------------------------------------------- -- --@src/devices/bus/nubus/nubus.h,BUSES["NUBUS"] = true diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index 9b073cf4480..61441c002cc 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -707,6 +707,7 @@ MACHINES["XC1700E"] = true BUSES["A1BUS"] = true BUSES["A2BUS"] = true +BUSES["A2GAMEIO"] = true BUSES["A7800"] = true BUSES["A800"] = true BUSES["ABCBUS"] = true 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(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 + 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 diff --git a/src/mame/drivers/apple2.cpp b/src/mame/drivers/apple2.cpp index 4f4e9f3ba35..8cfa9355a11 100644 --- a/src/mame/drivers/apple2.cpp +++ b/src/mame/drivers/apple2.cpp @@ -87,6 +87,8 @@ II Plus: RAM options reduced to 16/32/48 KB. #include "bus/a2bus/ssprite.h" #include "bus/a2bus/ssbapple.h" +#include "bus/a2gameio/gameio.h" + #include "screen.h" #include "softlist.h" #include "speaker.h" @@ -114,11 +116,7 @@ public: m_video(*this, A2_VIDEO_TAG), m_a2common(*this, "a2common"), m_a2bus(*this, "a2bus"), - m_joy1x(*this, "joystick_1_x"), - m_joy1y(*this, "joystick_1_y"), - m_joy2x(*this, "joystick_2_x"), - m_joy2y(*this, "joystick_2_y"), - m_joybuttons(*this, "joystick_buttons"), + m_gameio(*this, "gameio"), m_kbspecial(*this, "keyb_special"), m_kbrepeat(*this, "keyb_repeat"), m_resetdip(*this, "reset_dip"), @@ -137,7 +135,7 @@ public: required_device m_video; required_device m_a2common; required_device m_a2bus; - required_ioport m_joy1x, m_joy1y, m_joy2x, m_joy2y, m_joybuttons; + required_device m_gameio; required_ioport m_kbspecial; required_ioport m_kbrepeat; optional_ioport m_resetdip; @@ -175,10 +173,7 @@ public: DECLARE_WRITE_LINE_MEMBER(mix_w); DECLARE_WRITE_LINE_MEMBER(scr_w); DECLARE_WRITE_LINE_MEMBER(res_w); - 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_READ8_MEMBER(c080_r); DECLARE_WRITE8_MEMBER(c080_w); DECLARE_READ8_MEMBER(c100_r); @@ -219,7 +214,6 @@ private: int m_cnxx_slot; bool m_page2; - bool m_an0, m_an1, m_an2, m_an3; uint8_t *m_ram_ptr; int m_ram_size; @@ -352,10 +346,6 @@ void apple2_state::machine_start() save_item(NAME(m_inh_bank)); save_item(NAME(m_cnxx_slot)); save_item(NAME(m_page2)); - save_item(NAME(m_an0)); - save_item(NAME(m_an1)); - save_item(NAME(m_an2)); - save_item(NAME(m_an3)); save_item(NAME(m_anykeydown)); // setup video pointers @@ -370,7 +360,6 @@ void apple2_state::machine_reset() m_inh_slot = 0; m_cnxx_slot = -1; m_page2 = false; - m_an0 = m_an1 = m_an2 = m_an3 = false; m_anykeydown = false; } @@ -553,27 +542,11 @@ WRITE_LINE_MEMBER(apple2_state::res_w) m_video->m_hires = state; } -WRITE_LINE_MEMBER(apple2_state::an0_w) -{ - m_an0 = state; -} - -WRITE_LINE_MEMBER(apple2_state::an1_w) -{ - m_an1 = state; -} - WRITE_LINE_MEMBER(apple2_state::an2_w) { - m_an2 = state; m_video->m_an2 = state; } -WRITE_LINE_MEMBER(apple2_state::an3_w) -{ - m_an3 = state; -} - READ8_MEMBER(apple2_state::keyb_data_r) { // keyboard latch @@ -630,7 +603,9 @@ READ8_MEMBER(apple2_state::utility_strobe_r) WRITE8_MEMBER(apple2_state::utility_strobe_w) { - // pulses pin 5 of game I/O connector + // low pulse on pin 5 of game I/O connector + m_gameio->strobe_w(0); + m_gameio->strobe_w(1); } READ8_MEMBER(apple2_state::switches_r) @@ -651,18 +626,18 @@ READ8_MEMBER(apple2_state::flags_r) return (m_cassette->input() > 0.0 ? 0x80 : 0) | uFloatingBus7; case 1: // button 0 - return ((m_joybuttons->read() & 0x10) ? 0x80 : 0) | uFloatingBus7; + return (m_gameio->sw0_r() ? 0x80 : 0) | uFloatingBus7; case 2: // button 1 - return ((m_joybuttons->read() & 0x20) ? 0x80 : 0) | uFloatingBus7; + return (m_gameio->sw1_r() ? 0x80 : 0) | uFloatingBus7; case 3: // button 2 // check if SHIFT key mod configured if (m_sysconfig->read() & 0x04) { - return (((m_joybuttons->read() & 0x40) || (m_kbspecial->read() & 0x06)) ? 0x80 : 0) | uFloatingBus7; + return ((m_gameio->sw2_r() || (m_kbspecial->read() & 0x06)) ? 0x80 : 0) | uFloatingBus7; } - return ((m_joybuttons->read() & 0x40) ? 0x80 : 0) | (read_floatingbus() & 0x7f); + return (m_gameio->sw2_r() ? 0x80 : 0) | (read_floatingbus() & 0x7f); case 4: // joy 1 X axis return ((machine().time().as_double() < m_joystick_x1_time) ? 0x80 : 0) | uFloatingBus7; @@ -690,10 +665,10 @@ READ8_MEMBER(apple2_state::controller_strobe_r) WRITE8_MEMBER(apple2_state::controller_strobe_w) { - m_joystick_x1_time = machine().time().as_double() + m_x_calibration * m_joy1x->read(); - m_joystick_y1_time = machine().time().as_double() + m_y_calibration * m_joy1y->read(); - m_joystick_x2_time = machine().time().as_double() + m_x_calibration * m_joy2x->read(); - m_joystick_y2_time = machine().time().as_double() + m_y_calibration * m_joy2y->read(); + m_joystick_x1_time = machine().time().as_double() + m_x_calibration * m_gameio->pdl0_r(); + m_joystick_y1_time = machine().time().as_double() + m_y_calibration * m_gameio->pdl1_r(); + m_joystick_x2_time = machine().time().as_double() + m_x_calibration * m_gameio->pdl2_r(); + m_joystick_y2_time = machine().time().as_double() + m_y_calibration * m_gameio->pdl3_r(); } READ8_MEMBER(apple2_state::c080_r) @@ -1116,51 +1091,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple2_state::ay3600_repeat) 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) -INPUT_PORTS_END - -INPUT_PORTS_START( apple2_gameport ) - PORT_INCLUDE( apple2_joystick ) -INPUT_PORTS_END - INPUT_PORTS_START( apple2_sysconfig ) PORT_START("a2_config") PORT_CONFNAME(0x03, 0x00, "Composite monitor type") @@ -1317,9 +1247,6 @@ static INPUT_PORTS_START( apple2 ) PORT_START("keyb_repeat") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("REPT") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') - /* other devices */ - PORT_INCLUDE( apple2_gameport ) - PORT_INCLUDE(apple2_sysconfig) INPUT_PORTS_END @@ -1419,10 +1346,13 @@ void apple2_state::apple2_common(machine_config &config) m_softlatch->q_out_cb<1>().set(FUNC(apple2_state::mix_w)); m_softlatch->q_out_cb<2>().set(FUNC(apple2_state::scr_w)); m_softlatch->q_out_cb<3>().set(FUNC(apple2_state::res_w)); - m_softlatch->q_out_cb<4>().set(FUNC(apple2_state::an0_w)); - m_softlatch->q_out_cb<5>().set(FUNC(apple2_state::an1_w)); - m_softlatch->q_out_cb<6>().set(FUNC(apple2_state::an2_w)); - m_softlatch->q_out_cb<7>().set(FUNC(apple2_state::an3_w)); + m_softlatch->q_out_cb<4>().set(m_gameio, FUNC(apple2_gameio_device::an0_w)); + m_softlatch->q_out_cb<5>().set(m_gameio, FUNC(apple2_gameio_device::an1_w)); + m_softlatch->q_out_cb<6>().set(m_gameio, FUNC(apple2_gameio_device::an2_w)); + m_softlatch->q_out_cb<6>().append(FUNC(apple2_state::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); /* keyboard controller */ AY3600(config, m_ay3600, 0); diff --git a/src/mame/drivers/apple2e.cpp b/src/mame/drivers/apple2e.cpp index f958f919a1a..94b03ee875c 100644 --- a/src/mame/drivers/apple2e.cpp +++ b/src/mame/drivers/apple2e.cpp @@ -156,6 +156,8 @@ Address bus A0-A11 is Y0-Y11 #include "bus/a2bus/transwarp.h" #include "bus/a2bus/a2vulcan.h" +#include "bus/a2gameio/gameio.h" + #include "bus/rs232/rs232.h" #include "screen.h" @@ -220,11 +222,7 @@ public: m_video(*this, A2_VIDEO_TAG), m_a2bus(*this, A2_BUS_TAG), m_a2eauxslot(*this, A2_AUXSLOT_TAG), - m_joy1x(*this, "joystick_1_x"), - m_joy1y(*this, "joystick_1_y"), - m_joy2x(*this, "joystick_2_x"), - m_joy2y(*this, "joystick_2_y"), - m_joybuttons(*this, "joystick_buttons"), + m_gameio(*this, "gameio"), m_mouseb(*this, MOUSE_BUTTON_TAG), m_mousex(*this, MOUSE_XAXIS_TAG), m_mousey(*this, MOUSE_YAXIS_TAG), @@ -263,7 +261,7 @@ public: required_device m_video; required_device m_a2bus; optional_device m_a2eauxslot; - required_ioport m_joy1x, m_joy1y, m_joy2x, m_joy2y, m_joybuttons; + required_device m_gameio; optional_ioport m_mouseb, m_mousex, m_mousey; optional_memory_region m_kbdrom; required_ioport m_kbspecial; @@ -977,6 +975,10 @@ void apple2e_state::machine_reset() m_video->m_monohgr = false; if(m_iscecm) m_video->m_monohgr = true; m_an0 = m_an1 = m_an2 = m_an3 = false; + m_gameio->an0_w(0); + m_gameio->an1_w(0); + m_gameio->an2_w(0); + m_gameio->an3_w(0); m_vbl = m_vblmask = false; m_slotc3rom = false; m_romswitch = false; @@ -1534,6 +1536,14 @@ void apple2e_state::do_io(int offset, bool is_iic) } break; + case 0x40: // utility strobe (not available on IIc) + if (!is_iic) + { + m_gameio->strobe_w(0); + m_gameio->strobe_w(1); + } + break; + case 0x48: // (IIc only) clear mouse X/Y interrupt flags m_xirq = m_yirq = false; lower_irq(IRQ_MOUSEXY); @@ -1595,28 +1605,44 @@ void apple2e_state::do_io(int offset, bool is_iic) break; case 0x58: // AN0 off - m_an0 = false; break; + m_an0 = false; + m_gameio->an0_w(0); + break; case 0x59: // AN0 on - m_an0 = true; break; + m_an0 = true; + m_gameio->an0_w(1); + break; case 0x5a: // AN1 off - m_an1 = false; break; + m_an1 = false; + m_gameio->an1_w(0); + break; case 0x5b: // AN1 on - m_an1 = true; break; + m_an1 = true; + m_gameio->an1_w(1); + break; case 0x5c: // AN2 off - m_an2 = false; break; + m_an2 = false; + m_gameio->an2_w(0); + break; case 0x5d: // AN2 on - m_an2 = true; break; + m_an2 = true; + m_gameio->an2_w(1); + break; case 0x5e: // AN3 off - m_an3 = false; break; + m_an3 = false; + m_gameio->an3_w(0); + break; case 0x5f: // AN3 on - m_an3 = true; break; + m_an3 = true; + m_gameio->an3_w(1); + break; case 0x68: // IIgs STATE register, which ProDOS touches break; @@ -1630,10 +1656,10 @@ void apple2e_state::do_io(int offset, bool is_iic) lower_irq(IRQ_VBL); } - m_joystick_x1_time = machine().time().as_double() + m_x_calibration * m_joy1x->read(); - m_joystick_y1_time = machine().time().as_double() + m_y_calibration * m_joy1y->read(); - m_joystick_x2_time = machine().time().as_double() + m_x_calibration * m_joy2x->read(); - m_joystick_y2_time = machine().time().as_double() + m_y_calibration * m_joy2y->read(); + m_joystick_x1_time = machine().time().as_double() + m_x_calibration * m_gameio->pdl0_r(); + m_joystick_y1_time = machine().time().as_double() + m_y_calibration * m_gameio->pdl1_r(); + m_joystick_x2_time = machine().time().as_double() + m_x_calibration * m_gameio->pdl2_r(); + m_joystick_y2_time = machine().time().as_double() + m_y_calibration * m_gameio->pdl3_r(); break; default: @@ -1716,15 +1742,15 @@ READ8_MEMBER(apple2e_state::c000_r) case 0x61: // button 0 or Open Apple case 0x69: - return (((m_joybuttons->read() & 0x10) || (m_kbspecial->read() & 0x10)) ? 0x80 : 0) | uFloatingBus7; + return ((m_gameio->sw0_r() || (m_kbspecial->read() & 0x10)) ? 0x80 : 0) | uFloatingBus7; case 0x62: // button 1 or Solid Apple case 0x6a: - return (((m_joybuttons->read() & 0x20) || (m_kbspecial->read() & 0x20)) ? 0x80 : 0) | uFloatingBus7; + return ((m_gameio->sw1_r() || (m_kbspecial->read() & 0x20)) ? 0x80 : 0) | uFloatingBus7; case 0x63: // button 2 or SHIFT key case 0x6b: - return (((m_joybuttons->read() & 0x40) || (m_kbspecial->read() & 0x06)) ? 0x80 : 0) | uFloatingBus7; + return ((m_gameio->sw2_r() || (m_kbspecial->read() & 0x06)) ? 0x80 : 0) | uFloatingBus7; case 0x64: // joy 1 X axis case 0x6c: @@ -1967,11 +1993,11 @@ READ8_MEMBER(apple2e_state::c000_iic_r) case 0x61: // button 0 or Open Apple or mouse button 1 case 0x69: - return (((m_joybuttons->read() & 0x10) || (m_kbspecial->read() & 0x10)) ? 0x80 : 0) | uFloatingBus7; + return ((m_gameio->sw0_r() || (m_kbspecial->read() & 0x10)) ? 0x80 : 0) | uFloatingBus7; case 0x62: // button 1 or Solid Apple case 0x6a: - return (((m_joybuttons->read() & 0x20) || (m_kbspecial->read() & 0x20)) ? 0x80 : 0) | uFloatingBus7; + return ((m_gameio->sw1_r() || (m_kbspecial->read() & 0x20)) ? 0x80 : 0) | uFloatingBus7; case 0x63: // mouse button 2 (no other function on IIc) case 0x6b: @@ -3125,51 +3151,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple2e_state::ay3600_repeat) 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) -INPUT_PORTS_END - -static INPUT_PORTS_START( apple2_gameport ) - PORT_INCLUDE( apple2_joystick ) -INPUT_PORTS_END - static INPUT_PORTS_START( apple2_sysconfig ) PORT_START("a2_config") PORT_CONFNAME(0x03, 0x00, "Composite monitor type") @@ -3470,7 +3451,7 @@ static INPUT_PORTS_START( ceci ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE( apple2_gameport ) + PORT_INCLUDE( apple2_sysconfig ) INPUT_PORTS_END @@ -3583,7 +3564,7 @@ static INPUT_PORTS_START( cece ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE( apple2_gameport ) + PORT_INCLUDE( apple2_sysconfig ) INPUT_PORTS_END @@ -3696,7 +3677,7 @@ static INPUT_PORTS_START( cecg ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE( apple2_gameport ) + PORT_INCLUDE( apple2_sysconfig ) INPUT_PORTS_END @@ -3809,7 +3790,7 @@ static INPUT_PORTS_START( cecm ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE( apple2_gameport ) + PORT_INCLUDE( apple2_sysconfig ) INPUT_PORTS_END @@ -3922,19 +3903,17 @@ static INPUT_PORTS_START( cec2000 ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE( apple2_gameport ) + PORT_INCLUDE( apple2_sysconfig ) INPUT_PORTS_END static INPUT_PORTS_START( apple2e ) PORT_INCLUDE( apple2e_common ) - PORT_INCLUDE( apple2_gameport ) PORT_INCLUDE( apple2_sysconfig ) INPUT_PORTS_END static INPUT_PORTS_START( apple2c ) PORT_INCLUDE( apple2e_common ) - PORT_INCLUDE( apple2_gameport ) PORT_INCLUDE( apple2c_sysconfig ) PORT_START(MOUSE_BUTTON_TAG) /* Mouse - button */ @@ -4065,7 +4044,6 @@ static INPUT_PORTS_START( apple2euk ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Solid Apple") PORT_CODE(KEYCODE_RALT) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE( apple2_gameport ) PORT_INCLUDE(apple2_sysconfig) INPUT_PORTS_END @@ -4187,7 +4165,6 @@ static INPUT_PORTS_START( apple2ees ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Solid Apple") PORT_CODE(KEYCODE_RALT) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE( apple2_gameport ) PORT_INCLUDE(apple2_sysconfig) INPUT_PORTS_END @@ -4309,7 +4286,6 @@ static INPUT_PORTS_START( apple2efr ) // French AZERTY keyboard (Apple uses th PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Solid Apple") PORT_CODE(KEYCODE_RALT) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE( apple2_gameport ) PORT_INCLUDE(apple2_sysconfig) INPUT_PORTS_END @@ -4431,7 +4407,6 @@ INPUT_PORTS_START( apple2ep ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Solid Apple") PORT_CODE(KEYCODE_RALT) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE( apple2_gameport ) PORT_INCLUDE(apple2_sysconfig) INPUT_PORTS_END @@ -4602,6 +4577,8 @@ void apple2e_state::apple2e(machine_config &config) m_a2eauxslot->out_nmi_callback().set(FUNC(apple2e_state::a2bus_nmi_w)); A2EAUXSLOT_SLOT(config, "aux", m_a2eauxslot, apple2eaux_cards, "ext80"); + APPLE2_GAMEIO(config, m_gameio, apple2_gameio_device::default_options, nullptr); + /* softlist config for baseline A2E By default, filter lists where possible to compatible disks for A2E */ SOFTWARE_LIST(config, "flop525_clean").set_original("apple2_flop_clcracked"); diff --git a/src/mame/drivers/apple2gs.cpp b/src/mame/drivers/apple2gs.cpp index 5c9623ac4b9..c58acfc8983 100644 --- a/src/mame/drivers/apple2gs.cpp +++ b/src/mame/drivers/apple2gs.cpp @@ -89,6 +89,8 @@ #include "bus/a2bus/a2vulcan.h" //#include "bus/a2bus/pc_xporter.h" +#include "bus/a2gameio/gameio.h" + // various timing standards #define A2GS_MASTER_CLOCK (XTAL(28'636'363)) #define A2GS_14M (A2GS_MASTER_CLOCK/2) @@ -161,11 +163,7 @@ public: m_video(*this, A2GS_VIDEO_TAG), m_a2bus(*this, A2GS_BUS_TAG), m_a2common(*this, "a2common"), - m_joy1x(*this, "joystick_1_x"), - m_joy1y(*this, "joystick_1_y"), - m_joy2x(*this, "joystick_2_x"), - m_joy2y(*this, "joystick_2_y"), - m_joybuttons(*this, "joystick_buttons"), + m_gameio(*this, "gameio"), m_speaker(*this, A2GS_SPEAKER_TAG), m_upperbank(*this, A2GS_UPPERBANK_TAG), m_upperaux(*this, A2GS_AUXUPPER_TAG), @@ -219,7 +217,7 @@ public: required_device m_video; required_device m_a2bus; required_device m_a2common; - required_ioport m_joy1x, m_joy1y, m_joy2x, m_joy2y, m_joybuttons; + required_device m_gameio; required_device m_speaker; required_device m_upperbank, m_upperaux, m_upper00, m_upper01; required_device m_c100bank, m_c300bank, m_c400bank, m_c800bank; @@ -1339,6 +1337,10 @@ void apple2gs_state::machine_reset() m_page2 = false; m_video->m_page2 = false; m_an0 = m_an1 = m_an2 = m_an3 = false; + m_gameio->an0_w(0); + m_gameio->an1_w(0); + m_gameio->an2_w(0); + m_gameio->an3_w(0); m_vbl = false; m_slotc3rom = false; m_irqmask = 0; @@ -1868,28 +1870,44 @@ void apple2gs_state::do_io(address_space &space, int offset) break; case 0x58: // AN0 off - m_an0 = false; break; + m_an0 = false; + m_gameio->an0_w(0); + break; case 0x59: // AN0 on - m_an0 = true; break; + m_an0 = true; + m_gameio->an0_w(1); + break; case 0x5a: // AN1 off - m_an1 = false; break; + m_an1 = false; + m_gameio->an1_w(0); + break; case 0x5b: // AN1 on - m_an1 = true; break; + m_an1 = true; + m_gameio->an1_w(1); + break; case 0x5c: // AN2 off - m_an2 = false; break; + m_an2 = false; + m_gameio->an2_w(0); + break; case 0x5d: // AN2 on - m_an2 = true; break; + m_an2 = true; + m_gameio->an2_w(1); + break; case 0x5e: // AN3 off - m_an3 = false; break; + m_an3 = false; + m_gameio->an3_w(0); + break; case 0x5f: // AN3 on - m_an3 = true; break; + m_an3 = true; + m_gameio->an3_w(1); + break; case 0x68: // STATE break; @@ -1897,10 +1915,10 @@ void apple2gs_state::do_io(address_space &space, int offset) // trigger joypad read case 0x70: case 0x71: case 0x72: case 0x73: case 0x74: case 0x75: case 0x76: case 0x77: case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: - m_joystick_x1_time = machine().time().as_double() + m_x_calibration * m_joy1x->read(); - m_joystick_y1_time = machine().time().as_double() + m_y_calibration * m_joy1y->read(); - m_joystick_x2_time = machine().time().as_double() + m_x_calibration * m_joy2x->read(); - m_joystick_y2_time = machine().time().as_double() + m_y_calibration * m_joy2y->read(); + m_joystick_x1_time = machine().time().as_double() + m_x_calibration * m_gameio->pdl0_r(); + m_joystick_y1_time = machine().time().as_double() + m_y_calibration * m_gameio->pdl1_r(); + m_joystick_x2_time = machine().time().as_double() + m_x_calibration * m_gameio->pdl2_r(); + m_joystick_y2_time = machine().time().as_double() + m_y_calibration * m_gameio->pdl3_r(); break; default: @@ -2285,16 +2303,16 @@ READ8_MEMBER(apple2gs_state::c000_r) return (m_an3 ? INTFLAG_AN3 : 0x00) | m_intflag; case 0x60: // button 3 on IIgs - return (m_joybuttons->read() & 0x80) | uFloatingBus7; + return m_gameio->sw3_r() | uFloatingBus7; case 0x61: // button 0 or Open Apple - return (((m_joybuttons->read() & 0x10) || (m_kbspecial->read() & 0x10)) ? 0x80 : 0) | uFloatingBus7; + return ((m_gameio->sw0_r() || (m_kbspecial->read() & 0x10)) ? 0x80 : 0) | uFloatingBus7; case 0x62: // button 1 or Solid Apple - return (((m_joybuttons->read() & 0x20) || (m_kbspecial->read() & 0x20)) ? 0x80 : 0) | uFloatingBus7; + return ((m_gameio->sw1_r() || (m_kbspecial->read() & 0x20)) ? 0x80 : 0) | uFloatingBus7; case 0x63: // button 2 or SHIFT key - return (((m_joybuttons->read() & 0x40) || (m_kbspecial->read() & 0x06)) ? 0x80 : 0) | uFloatingBus7; + return ((m_gameio->sw2_r() || (m_kbspecial->read() & 0x06)) ? 0x80 : 0) | uFloatingBus7; case 0x64: // joy 1 X axis return ((machine().time().as_double() < m_joystick_x1_time) ? 0x80 : 0) | uFloatingBus7; @@ -2322,10 +2340,10 @@ READ8_MEMBER(apple2gs_state::c000_r) // todo: does reading these on the IIgs also trigger the joysticks? if (!machine().side_effects_disabled()) { - m_joystick_x1_time = machine().time().as_double() + m_x_calibration * m_joy1x->read(); - m_joystick_y1_time = machine().time().as_double() + m_y_calibration * m_joy1y->read(); - m_joystick_x2_time = machine().time().as_double() + m_x_calibration * m_joy2x->read(); - m_joystick_y2_time = machine().time().as_double() + m_y_calibration * m_joy2y->read(); + m_joystick_x1_time = machine().time().as_double() + m_x_calibration * m_gameio->pdl0_r(); + m_joystick_y1_time = machine().time().as_double() + m_y_calibration * m_gameio->pdl1_r(); + m_joystick_x2_time = machine().time().as_double() + m_x_calibration * m_gameio->pdl2_r(); + m_joystick_y2_time = machine().time().as_double() + m_y_calibration * m_gameio->pdl3_r(); } return m_rom[offset + 0x3c000]; @@ -4202,48 +4220,6 @@ static const floppy_interface apple2gs_floppy525_floppy_interface = INPUT PORTS ***************************************************************************/ -static INPUT_PORTS_START( apple2gs_gameport ) - 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_BUTTON1) PORT_PLAYER(2) PORT_CODE(JOYCODE_BUTTON2) -INPUT_PORTS_END - /* Apple IIe platinum and IIgs upgrade key matrix @@ -4488,8 +4464,6 @@ INPUT_PORTS_START( apple2gs ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Solid Apple") PORT_CODE(KEYCODE_RALT) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RESET") PORT_CODE(KEYCODE_F12) - PORT_INCLUDE(apple2gs_gameport) - PORT_START("adb_mouse_x") PORT_BIT( 0x7f, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("Mouse Button 1") @@ -4598,6 +4572,8 @@ void apple2gs_state::apple2gs(machine_config &config) APPLE2_COMMON(config, m_a2common, A2GS_14M); m_a2common->set_GS_cputag(m_maincpu); + APPLE2_GAMEIO(config, m_gameio, apple2_gameio_device::default_options, nullptr); + SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_refresh_hz(60); m_screen->set_size(704, 262); // 640+32+32 for the borders diff --git a/src/mame/drivers/mbc55x.cpp b/src/mame/drivers/mbc55x.cpp index f1d2aab493d..ab6305680f0 100644 --- a/src/mame/drivers/mbc55x.cpp +++ b/src/mame/drivers/mbc55x.cpp @@ -15,7 +15,6 @@ #include "includes/mbc55x.h" #include "bus/isa/isa.h" #include "bus/isa/isa_cards.h" -//#include "bus/pc_joy/pc_joy.h" #include "bus/rs232/rs232.h" #include "machine/clock.h" #include "machine/i8087.h" @@ -81,11 +80,16 @@ void mbc55x_state::iodecode_w(offs_t offset, uint8_t data) uint8_t mbc55x_state::game_io_r() { - return 0xff; -} + u8 result = m_gameio->sw3_r(); + result |= m_gameio->sw2_r() << 1; + result |= m_gameio->sw1_r() << 2; + result |= m_gameio->sw0_r() << 3; -void mbc55x_state::game_io_w(uint8_t data) -{ + for (int i = 0; i < 4; i++) + if (machine().time().as_double() < m_ls123_clear_time[i]) + result |= 1 << (4 + i); + + return result; } uint8_t mbc55x_state::printer_status_r() @@ -103,6 +107,26 @@ void mbc55x_state::printer_data_w(uint8_t data) m_printer->write_data2(!BIT(data, 2)); m_printer->write_data1(!BIT(data, 1)); m_printer->write_data0(!BIT(data, 0)); + + m_gameio->an0_w(!BIT(data, 0)); + m_gameio->an1_w(!BIT(data, 1)); + m_gameio->an2_w(!BIT(data, 2)); + m_gameio->an3_w(!BIT(data, 3)); + m_gameio->an4_w(!BIT(data, 4)); + m_gameio->strobe_w(!BIT(data, 5)); + + if (m_ls123_strobe != BIT(data, 7)) + { + if (BIT(data, 7)) + { + m_ls123_clear_time[0] = machine().time().as_double() + m_x_calibration * m_gameio->pdl0_r(); + m_ls123_clear_time[1] = machine().time().as_double() + m_y_calibration * m_gameio->pdl1_r(); + m_ls123_clear_time[2] = machine().time().as_double() + m_x_calibration * m_gameio->pdl2_r(); + m_ls123_clear_time[3] = machine().time().as_double() + m_y_calibration * m_gameio->pdl3_r(); + } + + m_ls123_strobe = BIT(data, 7); + } } void mbc55x_state::disk_select_w(uint8_t data) @@ -194,8 +218,15 @@ void mbc55x_state::machine_reset() void mbc55x_state::machine_start() { + // FIXME: values copied from apple2.cpp + m_x_calibration = attotime::from_nsec(10800).as_double(); + m_y_calibration = attotime::from_nsec(10800).as_double(); + m_printer_status = 0xff; + m_ls123_strobe = true; + std::fill(std::begin(m_ls123_clear_time), std::end(m_ls123_clear_time), 0.0); + m_kb_uart->write_cts(0); } @@ -284,7 +315,6 @@ void mbc55x_state::mbc55x(machine_config &config) I8255(config, m_ppi); m_ppi->in_pa_callback().set(FUNC(mbc55x_state::game_io_r)); - m_ppi->out_pa_callback().set(FUNC(mbc55x_state::game_io_w)); m_ppi->out_pb_callback().set(FUNC(mbc55x_state::printer_data_w)); m_ppi->in_pc_callback().set(FUNC(mbc55x_state::printer_status_r)); m_ppi->out_pc_callback().set(FUNC(mbc55x_state::disk_select_w)); @@ -331,6 +361,8 @@ void mbc55x_state::mbc55x(machine_config &config) INPUT_MERGER_ANY_HIGH(config, "sioint").output_handler().set(m_pic, FUNC(pic8259_device::ir2_w)); + APPLE2_GAMEIO(config, m_gameio, apple2_gameio_device::default_options, nullptr); + CENTRONICS(config, m_printer, centronics_devices, nullptr); m_printer->busy_handler().set(FUNC(mbc55x_state::printer_busy_w)).invert(); // LS14 Schmitt trigger m_printer->busy_handler().append(m_pic, FUNC(pic8259_device::ir4_w)).invert(); diff --git a/src/mame/includes/mbc55x.h b/src/mame/includes/mbc55x.h index 77fd7e28caf..055420ad260 100644 --- a/src/mame/includes/mbc55x.h +++ b/src/mame/includes/mbc55x.h @@ -12,6 +12,7 @@ #pragma once +#include "bus/a2gameio/gameio.h" #include "bus/centronics/ctronics.h" #include "cpu/i86/i86.h" #include "imagedev/floppy.h" @@ -81,6 +82,7 @@ public: m_pic(*this, PIC8259_TAG), m_fdc(*this, FDC_TAG), m_floppy(*this, FDC_TAG ":%u", 0U), + m_gameio(*this, "gameio"), m_printer(*this, "printer"), m_speaker(*this, "speaker"), m_ram(*this, RAM_TAG), @@ -108,7 +110,6 @@ private: uint8_t vram_page_r(); void vram_page_w(uint8_t data); uint8_t game_io_r(); - void game_io_w(uint8_t data); uint8_t printer_status_r(); void printer_data_w(uint8_t data); void disk_select_w(uint8_t data); @@ -135,6 +136,7 @@ private: required_device m_pic; required_device m_fdc; required_device_array m_floppy; + required_device m_gameio; required_device m_printer; required_device m_speaker; required_device m_ram; @@ -145,6 +147,10 @@ private: uint8_t m_vram_page; uint8_t m_printer_status; + double m_x_calibration, m_y_calibration; + bool m_ls123_strobe; + double m_ls123_clear_time[4]; + void video_debug(int ref, const std::vector ¶ms); }; -- cgit v1.2.3-70-g09d2