diff options
| author | 2016-04-13 23:31:07 +0200 | |
|---|---|---|
| committer | 2016-04-13 23:31:07 +0200 | |
| commit | af570db2d03fcdddcae52a7aa637e1f5c9b37b5d (patch) | |
| tree | 50b889a40a2d5938ad708c2e332055008e0628fa /src/devices | |
| parent | 1c80bbd4352e4a4e0e55aad292e9e7d30e80147e (diff) | |
ng_aes.cpp: converted AES controllers to work through slot devices.
Also, separated more clearly the CD component by the base unit. [Fabio Priuli]
Diffstat (limited to 'src/devices')
| -rw-r--r-- | src/devices/bus/neogeo_ctrl/ctrl.cpp | 112 | ||||
| -rw-r--r-- | src/devices/bus/neogeo_ctrl/ctrl.h | 80 | ||||
| -rw-r--r-- | src/devices/bus/neogeo_ctrl/joystick.cpp | 99 | ||||
| -rw-r--r-- | src/devices/bus/neogeo_ctrl/joystick.h | 79 | ||||
| -rw-r--r-- | src/devices/bus/neogeo_ctrl/mahjong.cpp | 155 | ||||
| -rw-r--r-- | src/devices/bus/neogeo_ctrl/mahjong.h | 55 |
6 files changed, 580 insertions, 0 deletions
diff --git a/src/devices/bus/neogeo_ctrl/ctrl.cpp b/src/devices/bus/neogeo_ctrl/ctrl.cpp new file mode 100644 index 00000000000..94d85f99b99 --- /dev/null +++ b/src/devices/bus/neogeo_ctrl/ctrl.cpp @@ -0,0 +1,112 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +/********************************************************************** + + SNK Neo Geo Controller Port emulation + +**********************************************************************/ + +#include "ctrl.h" +// slot devices +#include "joystick.h" +#include "mahjong.h" + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const device_type NEOGEO_CONTROL_PORT = &device_creator<neogeo_control_port_device>; + + +//************************************************************************** +// CARD INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_neogeo_control_port_interface - constructor +//------------------------------------------------- + +device_neogeo_control_port_interface::device_neogeo_control_port_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig,device) +{ + m_port = dynamic_cast<neogeo_control_port_device *>(device.owner()); +} + + +//------------------------------------------------- +// ~device_neogeo_control_port_interface - destructor +//------------------------------------------------- + +device_neogeo_control_port_interface::~device_neogeo_control_port_interface() +{ +} + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// neogeo_control_port_device - constructor +//------------------------------------------------- + +neogeo_control_port_device::neogeo_control_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, NEOGEO_CONTROL_PORT, "SNK Neo Geo control port", tag, owner, clock, "neogeo_control_port", __FILE__), + device_slot_interface(mconfig, *this), m_device(nullptr) +{ +} + + +//------------------------------------------------- +// ~neogeo_control_port_device - destructor +//------------------------------------------------- + +neogeo_control_port_device::~neogeo_control_port_device() +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void neogeo_control_port_device::device_start() +{ + m_device = dynamic_cast<device_neogeo_control_port_interface *>(get_card_device()); +} + + +UINT16 neogeo_control_port_device::read_ctrl() +{ + UINT16 data = 0; + if (m_device) + data |= m_device->read_ctrl(); + return data; +} + +UINT8 neogeo_control_port_device::read_start_sel() +{ + UINT8 data = 0; + if (m_device) + data |= m_device->read_start_sel(); + return data; +} + + +void neogeo_control_port_device::write_ctrlsel(UINT8 data) +{ + if (m_device) + m_device->write_ctrlsel(data); +} + + +//------------------------------------------------- +// SLOT_INTERFACE( neogeo_control_port_devices ) +//------------------------------------------------- + +SLOT_INTERFACE_START( neogeo_controls ) + SLOT_INTERFACE("joy", NEOGEO_JOYSTICK) + SLOT_INTERFACE("mahjong", NEOGEO_MJCTRL) +SLOT_INTERFACE_END + diff --git a/src/devices/bus/neogeo_ctrl/ctrl.h b/src/devices/bus/neogeo_ctrl/ctrl.h new file mode 100644 index 00000000000..82777f6fe60 --- /dev/null +++ b/src/devices/bus/neogeo_ctrl/ctrl.h @@ -0,0 +1,80 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +/********************************************************************** + + SNK Neo Geo controller port emulation + +**********************************************************************/ + + +#pragma once + +#ifndef __NEOGEO_CONTROL_PORT__ +#define __NEOGEO_CONTROL_PORT__ + +#include "emu.h" + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class neogeo_control_port_device; + +// ======================> device_neogeo_control_port_interface + +class device_neogeo_control_port_interface : public device_slot_card_interface +{ +public: + // construction/destruction + device_neogeo_control_port_interface(const machine_config &mconfig, device_t &device); + virtual ~device_neogeo_control_port_interface(); + + virtual UINT16 read_ctrl() { return 0xffff; }; + virtual UINT8 read_start_sel() { return 0xff; }; + virtual void write_ctrlsel(UINT8 data) { }; + +protected: + neogeo_control_port_device *m_port; +}; + +// ======================> neogeo_control_port_device + +class neogeo_control_port_device : public device_t, + public device_slot_interface +{ +public: + // construction/destruction + neogeo_control_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + virtual ~neogeo_control_port_device(); + + UINT16 read_ctrl(); + UINT8 read_start_sel(); + void write_ctrlsel(UINT8 data); + DECLARE_READ16_MEMBER( ctrl_r ) { return read_ctrl(); } + +protected: + // device-level overrides + virtual void device_start() override; + + device_neogeo_control_port_interface *m_device; +}; + + +// device type definition +extern const device_type NEOGEO_CONTROL_PORT; + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_NEOGEO_CONTROL_PORT_ADD(_tag, _slot_intf, _def_slot) \ + MCFG_DEVICE_ADD(_tag, NEOGEO_CONTROL_PORT, 0) \ + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) + + + +SLOT_INTERFACE_EXTERN( neogeo_controls ); + + +#endif diff --git a/src/devices/bus/neogeo_ctrl/joystick.cpp b/src/devices/bus/neogeo_ctrl/joystick.cpp new file mode 100644 index 00000000000..dc884138413 --- /dev/null +++ b/src/devices/bus/neogeo_ctrl/joystick.cpp @@ -0,0 +1,99 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +/********************************************************************** + + SNK Neo Geo Joystick emulation + +**********************************************************************/ + +#include "joystick.h" + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type NEOGEO_JOYSTICK = &device_creator<neogeo_joystick_device>; + + +static INPUT_PORTS_START( neogeo_joy ) + PORT_START("JOY") + PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_BUTTON4 ) + + PORT_START("START_SELECT") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SELECT ) +INPUT_PORTS_END + + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor neogeo_joystick_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( neogeo_joy ); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// neogeo_joystick_device - constructor +//------------------------------------------------- + +neogeo_joystick_device::neogeo_joystick_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, NEOGEO_JOYSTICK, "SNK Neo Geo Joystick", tag, owner, clock, "neogeo_joy", __FILE__), + device_neogeo_control_port_interface(mconfig, *this), + m_joy(*this, "JOY"), + m_ss(*this, "START_SELECT") +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void neogeo_joystick_device::device_start() +{ +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void neogeo_joystick_device::device_reset() +{ +} + + +//------------------------------------------------- +// read_ctrl +//------------------------------------------------- + +UINT16 neogeo_joystick_device::read_ctrl() +{ + return m_joy->read(); +} + +//------------------------------------------------- +// read_start_sel +//------------------------------------------------- + +UINT8 neogeo_joystick_device::read_start_sel() +{ + return m_ss->read(); +} + diff --git a/src/devices/bus/neogeo_ctrl/joystick.h b/src/devices/bus/neogeo_ctrl/joystick.h new file mode 100644 index 00000000000..742964a518c --- /dev/null +++ b/src/devices/bus/neogeo_ctrl/joystick.h @@ -0,0 +1,79 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +/********************************************************************** + + SNK Neo Geo Joystick emulation + +**********************************************************************/ + +#pragma once + +#ifndef __NEOGEO_JOYSTICK__ +#define __NEOGEO_JOYSTICK__ + + +#include "emu.h" +#include "ctrl.h" + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> neogeo_joystick_device + +class neogeo_joystick_device : public device_t, + public device_neogeo_control_port_interface +{ +public: + // construction/destruction + neogeo_joystick_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual ioport_constructor device_input_ports() const override; + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + + // device_intv_control_port_interface overrides + virtual UINT16 read_ctrl() override; + virtual UINT8 read_start_sel() override; + +private: + required_ioport m_joy; + required_ioport m_ss; +}; + + +// ======================> neogeo_joy_ac_device + +class neogeo_joy_ac_device : public device_t, + public device_neogeo_control_port_interface +{ +public: + // construction/destruction + neogeo_joy_ac_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual ioport_constructor device_input_ports() const override; + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + + // device_intv_control_port_interface overrides + virtual UINT16 read_ctrl() override; + +private: + required_ioport m_joy; +}; + + +// device type definition +extern const device_type NEOGEO_JOYSTICK; +extern const device_type NEOGEO_JOY_AC; + + +#endif diff --git a/src/devices/bus/neogeo_ctrl/mahjong.cpp b/src/devices/bus/neogeo_ctrl/mahjong.cpp new file mode 100644 index 00000000000..5f9768531b2 --- /dev/null +++ b/src/devices/bus/neogeo_ctrl/mahjong.cpp @@ -0,0 +1,155 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +/********************************************************************** + + SNK Neo Geo Mahjong controller emulation + +**********************************************************************/ + +#include "mahjong.h" + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type NEOGEO_MJCTRL = &device_creator<neogeo_mjctrl_device>; + + +static INPUT_PORTS_START( neogeo_joy ) + PORT_START("MJ.0") + PORT_BIT( 0x00ff, IP_ACTIVE_HIGH, IPT_UNUSED ) + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_MAHJONG_A ) + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_MAHJONG_B ) + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_MAHJONG_C ) + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_MAHJONG_D ) + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_MAHJONG_E ) + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_MAHJONG_F ) + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_MAHJONG_G ) + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN ) + + PORT_START("MJ.1") + PORT_BIT( 0x00ff, IP_ACTIVE_HIGH, IPT_UNUSED ) + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_MAHJONG_H ) + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_MAHJONG_I ) + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_MAHJONG_J ) + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_MAHJONG_K ) + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_MAHJONG_L ) + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_MAHJONG_M ) + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_MAHJONG_N ) + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_BUTTON6 ) + + // is this actually connected? + PORT_START("MJ.2") + PORT_BIT( 0x00ff, IP_ACTIVE_HIGH, IPT_UNUSED ) + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_BUTTON4 ) + + PORT_START("MJ.3") + PORT_BIT( 0x00ff, IP_ACTIVE_HIGH, IPT_UNUSED ) + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_MAHJONG_PON ) + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_MAHJONG_CHI ) + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_MAHJONG_KAN ) + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_MAHJONG_RON ) + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_MAHJONG_REACH ) + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN ) + + PORT_START("START_SELECT") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START ) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SELECT ) +INPUT_PORTS_END + + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor neogeo_mjctrl_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( neogeo_joy ); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// neogeo_joystick_device - constructor +//------------------------------------------------- + +neogeo_mjctrl_device::neogeo_mjctrl_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, NEOGEO_MJCTRL, "SNK Neo Geo Mahjong controller", tag, owner, clock, "neogeo_mjctrl", __FILE__), + device_neogeo_control_port_interface(mconfig, *this), + m_mjpanel(*this, "MJ"), + m_ss(*this, "START_SELECT") +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void neogeo_mjctrl_device::device_start() +{ + save_item(NAME(m_ctrl_sel)); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void neogeo_mjctrl_device::device_reset() +{ + m_ctrl_sel = 0; +} + + +//------------------------------------------------- +// read_ctrl +//------------------------------------------------- + +UINT16 neogeo_mjctrl_device::read_ctrl() +{ + UINT16 res = 0; + switch (m_ctrl_sel) + { + default: + case 0x00: res = 0xffff; break; + case 0x09: res = m_mjpanel[0]->read(); break; + case 0x12: res = m_mjpanel[1]->read(); break; + case 0x1b: res = m_mjpanel[2]->read(); break; + case 0x24: res = m_mjpanel[3]->read(); break; + } + + return res; +} + +//------------------------------------------------- +// read_start_sel +//------------------------------------------------- + +UINT8 neogeo_mjctrl_device::read_start_sel() +{ + return m_ss->read(); +} + +//------------------------------------------------- +// write_ctrlsel +//------------------------------------------------- + +void neogeo_mjctrl_device::write_ctrlsel(UINT8 data) +{ + m_ctrl_sel = data; +} + diff --git a/src/devices/bus/neogeo_ctrl/mahjong.h b/src/devices/bus/neogeo_ctrl/mahjong.h new file mode 100644 index 00000000000..68ceeb91268 --- /dev/null +++ b/src/devices/bus/neogeo_ctrl/mahjong.h @@ -0,0 +1,55 @@ +// license:BSD-3-Clause +// copyright-holders:Fabio Priuli +/********************************************************************** + + SNK Neo Geo Mahjong controller emulation + +**********************************************************************/ + +#pragma once + +#ifndef __NEOGEO_MJCTRL__ +#define __NEOGEO_MJCTRL__ + + +#include "emu.h" +#include "ctrl.h" + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> neogeo_mjctrl_device + +class neogeo_mjctrl_device : public device_t, + public device_neogeo_control_port_interface +{ +public: + // construction/destruction + neogeo_mjctrl_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual ioport_constructor device_input_ports() const override; + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + + // device_intv_control_port_interface overrides + virtual UINT16 read_ctrl() override; + virtual UINT8 read_start_sel() override; + virtual void write_ctrlsel(UINT8 data) override; + +private: + required_ioport_array<4> m_mjpanel; + required_ioport m_ss; + UINT8 m_ctrl_sel; +}; + + +// device type definition +extern const device_type NEOGEO_MJCTRL; + + +#endif |
