summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Dirk Best <mail@dirk-best.de>2018-04-08 17:12:30 +0200
committer Dirk Best <mail@dirk-best.de>2018-04-08 17:40:23 +0200
commitd2e0e1f182ace17f9e93a0a6ee99b3b79365a01f (patch)
treebaa3a8b134e3e32d07192e9119b7bcb136b588de
parent38eec74ef70b2dd1dfd1aaf1f5045ce8a4ab556e (diff)
Devicify Sega 315-5338A
-rw-r--r--scripts/target/mame/arcade.lua2
-rw-r--r--src/mame/machine/315-5338a.cpp117
-rw-r--r--src/mame/machine/315-5338a.h104
3 files changed, 223 insertions, 0 deletions
diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua
index 7bd8228683e..9f7215d24f5 100644
--- a/scripts/target/mame/arcade.lua
+++ b/scripts/target/mame/arcade.lua
@@ -3368,6 +3368,8 @@ files {
MAME_DIR .. "src/mame/video/zaxxon.cpp",
MAME_DIR .. "src/mame/machine/315_5296.cpp",
MAME_DIR .. "src/mame/machine/315_5296.h",
+ MAME_DIR .. "src/mame/machine/315-5338a.cpp",
+ MAME_DIR .. "src/mame/machine/315-55338a.h",
MAME_DIR .. "src/mame/machine/fd1089.cpp",
MAME_DIR .. "src/mame/machine/fd1089.h",
MAME_DIR .. "src/mame/machine/fd1094.cpp",
diff --git a/src/mame/machine/315-5338a.cpp b/src/mame/machine/315-5338a.cpp
new file mode 100644
index 00000000000..945c164734b
--- /dev/null
+++ b/src/mame/machine/315-5338a.cpp
@@ -0,0 +1,117 @@
+// license: BSD-3-Clause
+// copyright-holders: Dirk Best
+/***************************************************************************
+
+ Sega 315-5338A
+
+ I/O Controller
+
+***************************************************************************/
+
+#include "315-5338a.h"
+#include "emu.h"
+
+
+//**************************************************************************
+// CONSTANTS/MACROS
+//**************************************************************************
+
+#define VERBOSE 0
+
+
+//**************************************************************************
+// DEVICE DEFINITIONS
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(SEGA_315_5338A, sega_315_5338a_device, "315_5338a", "315-5338A I/O Controller")
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// sega_315_5338a_device - constructor
+//-------------------------------------------------
+
+sega_315_5338a_device::sega_315_5338a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, SEGA_315_5338A, tag, owner, clock),
+ m_an_cb{ {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this} },
+ m_di_cb{ {*this}, {*this}, {*this} },
+ m_do_cb(*this),
+ m_out(0xff)
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void sega_315_5338a_device::device_start()
+{
+ // resolve callbacks
+ for (int i = 0; i < 8; i++)
+ m_an_cb[i].resolve_safe(0xff);
+
+ for (int i = 0; i < 3; i++)
+ m_di_cb[i].resolve_safe(0xff);
+
+ m_do_cb.resolve_safe();
+}
+
+
+//**************************************************************************
+// INTERFACE
+//**************************************************************************
+
+READ8_MEMBER( sega_315_5338a_device::read )
+{
+ uint8_t data = 0xff;
+
+ switch (offset)
+ {
+ // analog inputs
+ case 0x00: data = m_an_cb[0](0); break;
+ case 0x01: data = m_an_cb[1](0); break;
+ case 0x02: data = m_an_cb[2](0); break;
+ case 0x03: data = m_an_cb[3](0); break;
+ case 0x04: data = m_an_cb[4](0); break;
+ case 0x05: data = m_an_cb[5](0); break;
+ case 0x06: data = m_an_cb[6](0); break;
+ case 0x07: data = m_an_cb[7](0); break;
+
+ // digital inputs
+ case 0x08: data = m_di_cb[0](0); break;
+ case 0x09: data = m_di_cb[1](0); break;
+ case 0x0a: data = m_di_cb[2](0); break;
+
+ // unknown
+ case 0x0b: break;
+ case 0x0c: break;
+ case 0x0d: break;
+ case 0x0e: break; // bit 7654 input (vr board 0-3)
+
+ // digital output
+ case 0x0f: data = m_out;
+ }
+
+ if (VERBOSE)
+ logerror("RD %02x = %02x\n", offset, data);
+
+ return data;
+}
+
+WRITE8_MEMBER( sega_315_5338a_device::write )
+{
+ if (VERBOSE)
+ logerror("WR %02x = %02x\n", offset, data);
+
+ switch (offset)
+ {
+ // digital output
+ case 0x0f:
+ m_out = data;
+ m_do_cb(m_out);
+ break;
+ }
+}
diff --git a/src/mame/machine/315-5338a.h b/src/mame/machine/315-5338a.h
new file mode 100644
index 00000000000..71d289e2255
--- /dev/null
+++ b/src/mame/machine/315-5338a.h
@@ -0,0 +1,104 @@
+// license: BSD-3-Clause
+// copyright-holders: Dirk Best
+/***************************************************************************
+
+ Sega 315-5338A
+
+ I/O Controller
+
+ Custom 100-pin QFP LSI. Supports 8 analog channels, 3 digital 8-bit
+ input ports, 1 digital 8-bit output port and a serial mode (and
+ probably more).
+
+ TODO:
+ - Serial/remote mode
+
+***************************************************************************/
+
+#ifndef MAME_MACHINE_315_5338A_H
+#define MAME_MACHINE_315_5338A_H
+
+#pragma once
+
+
+//**************************************************************************
+// INTERFACE CONFIGURATION MACROS
+//**************************************************************************
+
+#define MCFG_315_5338A_AN0_CB(_devcb) \
+ devcb = &downcast<sega_315_5338a_device &>(*device).set_an_callback(DEVCB_##_devcb, 0);
+
+#define MCFG_315_5338A_AN1_CB(_devcb) \
+ devcb = &downcast<sega_315_5338a_device &>(*device).set_an_callback(DEVCB_##_devcb, 1);
+
+#define MCFG_315_5338A_AN2_CB(_devcb) \
+ devcb = &downcast<sega_315_5338a_device &>(*device).set_an_callback(DEVCB_##_devcb, 2);
+
+#define MCFG_315_5338A_AN3_CB(_devcb) \
+ devcb = &downcast<sega_315_5338a_device &>(*device).set_an_callback(DEVCB_##_devcb, 3);
+
+#define MCFG_315_5338A_AN4_CB(_devcb) \
+ devcb = &downcast<sega_315_5338a_device &>(*device).set_an_callback(DEVCB_##_devcb, 4);
+
+#define MCFG_315_5338A_AN5_CB(_devcb) \
+ devcb = &downcast<sega_315_5338a_device &>(*device).set_an_callback(DEVCB_##_devcb, 5);
+
+#define MCFG_315_5338A_AN6_CB(_devcb) \
+ devcb = &downcast<sega_315_5338a_device &>(*device).set_an_callback(DEVCB_##_devcb, 6);
+
+#define MCFG_315_5338A_AN7_CB(_devcb) \
+ devcb = &downcast<sega_315_5338a_device &>(*device).set_an_callback(DEVCB_##_devcb, 7);
+
+#define MCFG_315_5338A_DI0_CB(_devcb) \
+ devcb = &downcast<sega_315_5338a_device &>(*device).set_di_callback(DEVCB_##_devcb, 0);
+
+#define MCFG_315_5338A_DI1_CB(_devcb) \
+ devcb = &downcast<sega_315_5338a_device &>(*device).set_di_callback(DEVCB_##_devcb, 1);
+
+#define MCFG_315_5338A_DI2_CB(_devcb) \
+ devcb = &downcast<sega_315_5338a_device &>(*device).set_di_callback(DEVCB_##_devcb, 2);
+
+#define MCFG_315_5338A_DO_CB(_devcb) \
+ devcb = &downcast<sega_315_5338a_device &>(*device).set_do_callback(DEVCB_##_devcb);
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+class sega_315_5338a_device : public device_t
+{
+public:
+ // construction/destruction
+ sega_315_5338a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ // configuration
+ template <class Object> devcb_base &set_an_callback(Object &&cb, int index)
+ { return m_an_cb[index].set_callback(std::forward<Object>(cb)); }
+
+ template <class Object> devcb_base &set_di_callback(Object &&cb, int index)
+ { return m_di_cb[index].set_callback(std::forward<Object>(cb)); }
+
+ template <class Object> devcb_base &set_do_callback(Object &&cb)
+ { return m_do_cb.set_callback(std::forward<Object>(cb)); }
+
+ DECLARE_READ8_MEMBER(read);
+ DECLARE_WRITE8_MEMBER(write);
+
+protected:
+ // device-level overrides
+ virtual void device_start() override;
+
+private:
+ // callbacks
+ devcb_read8 m_an_cb[8];
+ devcb_read8 m_di_cb[3];
+ devcb_write8 m_do_cb;
+
+ uint8_t m_out;
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(SEGA_315_5338A, sega_315_5338a_device)
+
+#endif // MAME_MACHINE_315_5338A_H