summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/astrocde
diff options
context:
space:
mode:
author mooglyguy <therealmogminer@gmail.com>2019-03-17 00:28:28 +0100
committer MooglyGuy <therealmogminer@gmail.com>2019-03-17 00:28:54 +0100
commitb5c19e9fb2ebcbc061702dc99befeab38af94b42 (patch)
treec36d546fcdea20b90e3f62a809194a19bc175ebf /src/devices/bus/astrocde
parent06fd6e6cff12039d26fb5bb6c3b4e9b73b47f55d (diff)
-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)
Diffstat (limited to 'src/devices/bus/astrocde')
-rw-r--r--src/devices/bus/astrocde/cassette.cpp47
-rw-r--r--src/devices/bus/astrocde/cassette.h47
-rw-r--r--src/devices/bus/astrocde/ctrl.cpp109
-rw-r--r--src/devices/bus/astrocde/ctrl.h91
-rw-r--r--src/devices/bus/astrocde/joy.cpp56
-rw-r--r--src/devices/bus/astrocde/joy.h45
6 files changed, 395 insertions, 0 deletions
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<cassette_image_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 <cassert>
+
+
+//**************************************************************************
+// 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<astrocade_ctrl_port_device *>(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<device_astrocade_ctrl_interface *>(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<device_astrocade_ctrl_interface *>(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 <typename T>
+ 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