summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/neogeo_ctrl/ctrl.cpp
diff options
context:
space:
mode:
author etabeta78 <doge.fabio@gmail.com>2016-04-13 23:31:07 +0200
committer etabeta78 <doge.fabio@gmail.com>2016-04-13 23:31:07 +0200
commitaf570db2d03fcdddcae52a7aa637e1f5c9b37b5d (patch)
tree50b889a40a2d5938ad708c2e332055008e0628fa /src/devices/bus/neogeo_ctrl/ctrl.cpp
parent1c80bbd4352e4a4e0e55aad292e9e7d30e80147e (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/bus/neogeo_ctrl/ctrl.cpp')
-rw-r--r--src/devices/bus/neogeo_ctrl/ctrl.cpp112
1 files changed, 112 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
+