From b5c19e9fb2ebcbc061702dc99befeab38af94b42 Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Sun, 17 Mar 2019 00:28:28 +0100 Subject: -astrocade: Various changes. [Ryan Holtz] * Removed inaccurate comment from astrocde.xml regarding the 2000-baud tape interface. * Converted astrohome controllers to slot devices. * Added preliminary (not yet working) 300-baud cassette tape slot device. * Changed potentiometer callbacks from tagged IO ports to devcb3. -device: Added feature flag to indicate lack of, or support for, cassette. (nw) --- src/devices/bus/astrocde/cassette.cpp | 47 +++++++++++++++ src/devices/bus/astrocde/cassette.h | 47 +++++++++++++++ src/devices/bus/astrocde/ctrl.cpp | 109 ++++++++++++++++++++++++++++++++++ src/devices/bus/astrocde/ctrl.h | 91 ++++++++++++++++++++++++++++ src/devices/bus/astrocde/joy.cpp | 56 +++++++++++++++++ src/devices/bus/astrocde/joy.h | 45 ++++++++++++++ src/devices/sound/astrocde.cpp | 6 +- src/devices/sound/astrocde.h | 4 +- 8 files changed, 401 insertions(+), 4 deletions(-) create mode 100644 src/devices/bus/astrocde/cassette.cpp create mode 100644 src/devices/bus/astrocde/cassette.h create mode 100644 src/devices/bus/astrocde/ctrl.cpp create mode 100644 src/devices/bus/astrocde/ctrl.h create mode 100644 src/devices/bus/astrocde/joy.cpp create mode 100644 src/devices/bus/astrocde/joy.h (limited to 'src/devices') diff --git a/src/devices/bus/astrocde/cassette.cpp b/src/devices/bus/astrocde/cassette.cpp new file mode 100644 index 00000000000..789b0d7e175 --- /dev/null +++ b/src/devices/bus/astrocde/cassette.cpp @@ -0,0 +1,47 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz + +#include "emu.h" +#include "cassette.h" + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +DEFINE_DEVICE_TYPE(ASTROCADE_CASSETTE, astrocade_cassette_device, "astrocade_cass", "Bally Astrocade Cassette") + + +//************************************************************************** +// Bally Astrocade cassette input +//************************************************************************** + +astrocade_cassette_device::astrocade_cassette_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, ASTROCADE_CASSETTE, tag, owner, clock) + , device_astrocade_ctrl_interface(mconfig, *this) + , m_cassette(*this, "cassette") +{ +} + +astrocade_cassette_device::~astrocade_cassette_device() +{ +} + +uint8_t astrocade_cassette_device::read_handle() +{ + uint8_t data = m_cassette->input() > 0.0 ? 0 : 1; + logerror("%s: Cassette Handle Read: %d\n", machine().describe_context(), data); + return data; +} + +uint8_t astrocade_cassette_device::read_knob() +{ + logerror("%s: Cassette Knob Read\n", machine().describe_context()); + return 0; +} + +void astrocade_cassette_device::device_add_mconfig(machine_config &config) +{ + CASSETTE(config, m_cassette); + m_cassette->set_default_state(CASSETTE_STOPPED); + m_cassette->set_interface("astrocade_cass"); +} diff --git a/src/devices/bus/astrocde/cassette.h b/src/devices/bus/astrocde/cassette.h new file mode 100644 index 00000000000..15635dee3bf --- /dev/null +++ b/src/devices/bus/astrocde/cassette.h @@ -0,0 +1,47 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +#ifndef MAME_BUS_ASTROCDE_CASSETTE_H +#define MAME_BUS_ASTROCDE_CASSETTE_H + +#pragma once + +#include "ctrl.h" +#include "imagedev/cassette.h" + +/*************************************************************************** + TYPE DEFINITIONS + ***************************************************************************/ + +// ======================> astrocade_cassette_device + +class astrocade_cassette_device : public device_t, + public device_astrocade_ctrl_interface +{ +public: + static constexpr feature_type imperfect_features() { return feature::CASSETTE; } + + // construction/destruction + astrocade_cassette_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0U); + virtual ~astrocade_cassette_device(); + + // device_astrocade_ctrl_interface implementation + virtual uint8_t read_handle() override; + virtual uint8_t read_knob() override; + +protected: + // device_t implementation + virtual void device_start() override { } + virtual void device_add_mconfig(machine_config &config) override; + +private: + required_device m_cassette; +}; + + +/*************************************************************************** + DEVICE TYPES + ***************************************************************************/ + +DECLARE_DEVICE_TYPE(ASTROCADE_CASSETTE, astrocade_cassette_device) + +#endif // MAME_BUS_ASTROCDE_CASSETTE_H diff --git a/src/devices/bus/astrocde/ctrl.cpp b/src/devices/bus/astrocde/ctrl.cpp new file mode 100644 index 00000000000..16b8537eae4 --- /dev/null +++ b/src/devices/bus/astrocde/ctrl.cpp @@ -0,0 +1,109 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz + +#include "emu.h" +#include "ctrl.h" + +#include + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +DEFINE_DEVICE_TYPE(ASTROCADE_CTRL_PORT, astrocade_ctrl_port_device, "astrocade_ctrl_port", "Bally Astrocade Control Port") + + +//************************************************************************** +// Bally Astrocade controller interface +//************************************************************************** + +device_astrocade_ctrl_interface::device_astrocade_ctrl_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig, device) + , m_port(dynamic_cast(device.owner())) +{ +} + +device_astrocade_ctrl_interface::~device_astrocade_ctrl_interface() +{ +} + +void device_astrocade_ctrl_interface::interface_validity_check(validity_checker &valid) const +{ + device_slot_card_interface::interface_validity_check(valid); + + if (device().owner() && !m_port) + { + osd_printf_error("Owner device %s (%s) is not an astrocade_ctrl_port_device\n", device().owner()->tag(), device().owner()->name()); + } +} + +void device_astrocade_ctrl_interface::interface_pre_start() +{ + device_slot_card_interface::interface_pre_start(); + + if (m_port && !m_port->started()) + throw device_missing_dependencies(); +} + + +//************************************************************************** +// Bally Astrocade controller port +//************************************************************************** + +astrocade_ctrl_port_device::astrocade_ctrl_port_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, ASTROCADE_CTRL_PORT, tag, owner, clock) + , device_slot_interface(mconfig, *this) +{ +} + +astrocade_ctrl_port_device::~astrocade_ctrl_port_device() +{ +} + +void astrocade_ctrl_port_device::device_validity_check(validity_checker &valid) const +{ + device_t *const card(get_card_device()); + if (card && !dynamic_cast(card)) + { + osd_printf_error("Card device %s (%s) does not implement device_astrocade_ctrl_interface\n", card->tag(), card->name()); + } +} + +void astrocade_ctrl_port_device::device_resolve_objects() +{ + device_astrocade_ctrl_interface *const card(dynamic_cast(get_card_device())); + if (card) + m_device = card; +} + +void astrocade_ctrl_port_device::device_start() +{ + device_t *const card(get_card_device()); + if (card) + { + if (!m_device) + { + throw emu_fatalerror("astrocade_ctrl_port_device: card device %s (%s) does not implement device_astrocade_ctrl_interface\n", card->tag(), card->name()); + } + } +} + +uint8_t astrocade_ctrl_port_device::read_handle() +{ + return m_device ? m_device->read_handle() : 0; +} + +uint8_t astrocade_ctrl_port_device::read_knob() +{ + return m_device ? m_device->read_knob() : 0; +} + +#include "joy.h" +#include "cassette.h" + +void astrocade_controllers(device_slot_interface &device) +{ + device.option_add("joy", ASTROCADE_JOY); + device.option_add("cassette", ASTROCADE_CASSETTE); +} diff --git a/src/devices/bus/astrocde/ctrl.h b/src/devices/bus/astrocde/ctrl.h new file mode 100644 index 00000000000..7ff8acbde52 --- /dev/null +++ b/src/devices/bus/astrocde/ctrl.h @@ -0,0 +1,91 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +#ifndef MAME_BUS_ASTROCDE_CTRL_H +#define MAME_BUS_ASTROCDE_CTRL_H + +#pragma once + + +/*************************************************************************** + FORWARD DECLARATIONS + ***************************************************************************/ + +class astrocade_ctrl_port_device; + + +/*************************************************************************** + TYPE DEFINITIONS + ***************************************************************************/ + +// ======================> device_astrocade_ctrl_interface + +class device_astrocade_ctrl_interface : public device_slot_card_interface +{ +public: + virtual ~device_astrocade_ctrl_interface(); + + virtual uint8_t read_handle() { return 0; } + virtual uint8_t read_knob() { return 0; } + +protected: + device_astrocade_ctrl_interface(machine_config const &mconfig, device_t &device); + + // device_interface implementation + virtual void interface_validity_check(validity_checker &valid) const override ATTR_COLD; + virtual void interface_pre_start() override; + +private: + astrocade_ctrl_port_device *const m_port; + + friend class astrocade_ctrl_port_device; +}; + + +// ======================> astrocade_ctrl_port_device + +class astrocade_ctrl_port_device : public device_t, public device_slot_interface +{ +public: + // construction/destruction + template + astrocade_ctrl_port_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt) + : astrocade_ctrl_port_device(mconfig, tag, owner, 0U) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + astrocade_ctrl_port_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0U); + virtual ~astrocade_ctrl_port_device(); + + uint8_t read_handle(); + uint8_t read_knob(); + +protected: + // device_t implementation + virtual void device_validity_check(validity_checker &valid) const override ATTR_COLD; + virtual void device_resolve_objects() override; + virtual void device_start() override; + +private: + device_astrocade_ctrl_interface *m_device; + + friend class device_astrocade_ctrl_interface; +}; + + +/*************************************************************************** + FUNCTIONS + ***************************************************************************/ + +void astrocade_controllers(device_slot_interface &device); + + +/*************************************************************************** + DEVICE TYPES + ***************************************************************************/ + +DECLARE_DEVICE_TYPE(ASTROCADE_CTRL_PORT, astrocade_ctrl_port_device) + +#endif // MAME_BUS_ASTROCDE_CTRL_H diff --git a/src/devices/bus/astrocde/joy.cpp b/src/devices/bus/astrocde/joy.cpp new file mode 100644 index 00000000000..cbf75da0c5c --- /dev/null +++ b/src/devices/bus/astrocde/joy.cpp @@ -0,0 +1,56 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz + +#include "emu.h" +#include "joy.h" + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +DEFINE_DEVICE_TYPE(ASTROCADE_JOY, astrocade_joy_device, "astrocade_joy", "Bally Astrocade Joystick") + + +//************************************************************************** +// Bally Astrocade joystick control +//************************************************************************** + +astrocade_joy_device::astrocade_joy_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, ASTROCADE_JOY, tag, owner, clock) + , device_astrocade_ctrl_interface(mconfig, *this) + , m_handle(*this, "HANDLE") + , m_knob(*this, "KNOB") +{ +} + +astrocade_joy_device::~astrocade_joy_device() +{ +} + +uint8_t astrocade_joy_device::read_handle() +{ + return m_handle->read(); +} + +uint8_t astrocade_joy_device::read_knob() +{ + return m_knob->read(); +} + +static INPUT_PORTS_START( astrocade_joy ) + PORT_START("HANDLE") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP) PORT_8WAY + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN) PORT_8WAY + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT) PORT_8WAY + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT) PORT_8WAY + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_BUTTON1) + PORT_BIT(0xe0, IP_ACTIVE_HIGH, IPT_UNUSED) + + PORT_START("KNOB") + PORT_BIT(0xff, 0x00, IPT_PADDLE) PORT_INVERT PORT_SENSITIVITY(85) PORT_KEYDELTA(10) PORT_CENTERDELTA(0) PORT_MINMAX(0,255) PORT_CODE_DEC(KEYCODE_Z) PORT_CODE_INC(KEYCODE_X) +INPUT_PORTS_END + +ioport_constructor astrocade_joy_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( astrocade_joy ); +} diff --git a/src/devices/bus/astrocde/joy.h b/src/devices/bus/astrocde/joy.h new file mode 100644 index 00000000000..1db02b9d28f --- /dev/null +++ b/src/devices/bus/astrocde/joy.h @@ -0,0 +1,45 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +#ifndef MAME_BUS_ASTROCDE_JOY_H +#define MAME_BUS_ASTROCDE_JOY_H + +#pragma once + +#include "ctrl.h" + +/*************************************************************************** + TYPE DEFINITIONS + ***************************************************************************/ + +// ======================> astrocade_joy_device + +class astrocade_joy_device : public device_t, + public device_astrocade_ctrl_interface +{ +public: + // construction/destruction + astrocade_joy_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0U); + virtual ~astrocade_joy_device(); + + // device_astrocade_ctrl_interface implementation + virtual uint8_t read_handle() override; + virtual uint8_t read_knob() override; + +protected: + // device_t implementation + virtual ioport_constructor device_input_ports() const override; + virtual void device_start() override { } + +private: + required_ioport m_handle; + required_ioport m_knob; +}; + + +/*************************************************************************** + DEVICE TYPES + ***************************************************************************/ + +DECLARE_DEVICE_TYPE(ASTROCADE_JOY, astrocade_joy_device) + +#endif // MAME_BUS_ASTROCDE_JOY_H diff --git a/src/devices/sound/astrocde.cpp b/src/devices/sound/astrocde.cpp index e3600a88286..33ae926f34c 100644 --- a/src/devices/sound/astrocde.cpp +++ b/src/devices/sound/astrocde.cpp @@ -86,7 +86,7 @@ astrocade_io_device::astrocade_io_device(const machine_config &mconfig, const ch , m_c_state(0) , m_si_callback(*this) , m_so_callback{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}} - , m_pots(*this, {finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG}) + , m_pots{{*this}, {*this}, {*this}, {*this}} { memset(m_reg, 0, sizeof(uint8_t)*8); memset(m_bitswap, 0, sizeof(uint8_t)*256); @@ -104,6 +104,8 @@ void astrocade_io_device::device_resolve_objects() m_si_callback.resolve_safe(0); for (auto &cb : m_so_callback) cb.resolve_safe(); + for (auto &pot : m_pots) + pot.resolve_safe(0); } @@ -323,7 +325,7 @@ READ8_MEMBER(astrocade_io_device::read) return m_si_callback(space, offset & 7); } else if ((offset & 0x0f) >= 0x0c) - return m_pots[offset & 3].read_safe(0); + return m_pots[offset & 3](); else return 0xff; } diff --git a/src/devices/sound/astrocde.h b/src/devices/sound/astrocde.h index 7eaae126f4f..eddde3a12bb 100644 --- a/src/devices/sound/astrocde.h +++ b/src/devices/sound/astrocde.h @@ -49,7 +49,7 @@ public: // configuration access auto si_cb() { return m_si_callback.bind(); } template auto so_cb() { return m_so_callback[Bit].bind(); } - template void set_pot_tag(const char *tag) { m_pots[Pot].set_tag(tag); } + template auto pot_cb() { return m_pots[Pot].bind(); } protected: // device-level overrides @@ -90,7 +90,7 @@ private: devcb_read8 m_si_callback; devcb_write8 m_so_callback[8]; - optional_ioport_array<4> m_pots; + devcb_read8 m_pots[4]; }; DECLARE_DEVICE_TYPE(ASTROCADE_IO, astrocade_io_device) -- cgit v1.2.3