mirror of
https://github.com/holub/mame
synced 2025-06-05 12:26:35 +03:00
Devicify Sega 315-5338A
This commit is contained in:
parent
38eec74ef7
commit
d2e0e1f182
@ -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",
|
||||
|
117
src/mame/machine/315-5338a.cpp
Normal file
117
src/mame/machine/315-5338a.cpp
Normal file
@ -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;
|
||||
}
|
||||
}
|
104
src/mame/machine/315-5338a.h
Normal file
104
src/mame/machine/315-5338a.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user