mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
Devicify Sega 315-5649
This commit is contained in:
parent
5a95391388
commit
02004c6c51
@ -3372,6 +3372,8 @@ files {
|
||||
MAME_DIR .. "src/mame/machine/315_5296.h",
|
||||
MAME_DIR .. "src/mame/machine/315_5338a.cpp",
|
||||
MAME_DIR .. "src/mame/machine/315_5338a.h",
|
||||
MAME_DIR .. "src/mame/machine/315_5649.cpp",
|
||||
MAME_DIR .. "src/mame/machine/315_5649.h",
|
||||
MAME_DIR .. "src/mame/machine/model1io.cpp",
|
||||
MAME_DIR .. "src/mame/machine/model1io.h",
|
||||
MAME_DIR .. "src/mame/machine/fd1089.cpp",
|
||||
|
149
src/mame/machine/315_5649.cpp
Normal file
149
src/mame/machine/315_5649.cpp
Normal file
@ -0,0 +1,149 @@
|
||||
// license: BSD-3-Clause
|
||||
// copyright-holders: Dirk Best
|
||||
/***************************************************************************
|
||||
|
||||
Sega 315-5649
|
||||
|
||||
I/O Controller
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "315_5649.h"
|
||||
|
||||
#define VERBOSE 1
|
||||
#include "logmacro.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
DEFINE_DEVICE_TYPE(SEGA_315_5649, sega_315_5649_device, "315_5649", "Sega 315-5649 I/O Controller")
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// sega_315_5649_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
sega_315_5649_device::sega_315_5649_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||
device_t(mconfig, SEGA_315_5649, tag, owner, clock),
|
||||
m_in_port_cb{ {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this} },
|
||||
m_out_port_cb{ {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this} },
|
||||
m_an_port_cb{ {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this} },
|
||||
m_serial_rd_cb{ {*this}, {*this} }, m_serial_wr_cb{ {*this}, {*this} },
|
||||
m_port_config(0),
|
||||
m_analog_channel(0)
|
||||
{
|
||||
std::fill(std::begin(m_port_value), std::end(m_port_value), 0xff);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void sega_315_5649_device::device_start()
|
||||
{
|
||||
// resolve callbacks
|
||||
for (unsigned i = 0; i < 7; i++)
|
||||
{
|
||||
m_in_port_cb[i].resolve_safe(0xff);
|
||||
m_out_port_cb[i].resolve_safe();
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 8; i++)
|
||||
m_an_port_cb[i].resolve_safe(0xff);
|
||||
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
{
|
||||
m_serial_rd_cb[i].resolve_safe(0xff);
|
||||
m_serial_wr_cb[i].resolve_safe();
|
||||
}
|
||||
|
||||
// register for save states
|
||||
save_pointer(NAME(m_port_value), 7);
|
||||
save_item(NAME(m_port_config));
|
||||
save_item(NAME(m_analog_channel));
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// INTERFACE
|
||||
//**************************************************************************
|
||||
|
||||
READ8_MEMBER( sega_315_5649_device::read )
|
||||
{
|
||||
uint8_t data = 0xff;
|
||||
|
||||
switch (offset)
|
||||
{
|
||||
// port a to g
|
||||
case 0x00:
|
||||
case 0x01:
|
||||
case 0x02:
|
||||
case 0x03:
|
||||
case 0x04:
|
||||
case 0x05:
|
||||
case 0x06:
|
||||
if (BIT(m_port_config, offset))
|
||||
data = m_in_port_cb[offset](0);
|
||||
else
|
||||
data = m_port_value[offset];
|
||||
break;
|
||||
|
||||
// serial channel 1/2 input
|
||||
case 0x0b: data = m_serial_rd_cb[0](0); break;
|
||||
case 0x0c: data = m_serial_rd_cb[1](0); break;
|
||||
|
||||
// status
|
||||
case 0x0d: break;
|
||||
|
||||
// analog input, auto-increments
|
||||
case 0x0f:
|
||||
data = m_an_port_cb[m_analog_channel++](0);
|
||||
m_analog_channel &= 0x07;
|
||||
}
|
||||
|
||||
LOG("RD %02x = %02x\n", offset, data);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER( sega_315_5649_device::write )
|
||||
{
|
||||
LOG("WR %02x = %02x\n", offset, data);
|
||||
|
||||
switch (offset)
|
||||
{
|
||||
// port a-g
|
||||
case 0x00:
|
||||
case 0x01:
|
||||
case 0x02:
|
||||
case 0x03:
|
||||
case 0x04:
|
||||
case 0x05:
|
||||
case 0x06:
|
||||
m_port_value[offset] = data;
|
||||
m_out_port_cb[offset](data);
|
||||
break;
|
||||
|
||||
// port direction register (0 = output, 1 = input)
|
||||
case 0x08: m_port_config = data; break;
|
||||
|
||||
// serial channel 1/2 output
|
||||
case 0x09: m_serial_wr_cb[0](data); break;
|
||||
case 0x0a: m_serial_wr_cb[1](data); break;
|
||||
|
||||
// mode register
|
||||
case 0x0e: break;
|
||||
|
||||
// analog mux select
|
||||
case 0x0f:
|
||||
m_analog_channel = data & 0x07;
|
||||
break;
|
||||
}
|
||||
}
|
149
src/mame/machine/315_5649.h
Normal file
149
src/mame/machine/315_5649.h
Normal file
@ -0,0 +1,149 @@
|
||||
// license: BSD-3-Clause
|
||||
// copyright-holders: Dirk Best
|
||||
/***************************************************************************
|
||||
|
||||
Sega 315-5649
|
||||
|
||||
I/O Controller
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef MAME_MACHINE_315_5649_H
|
||||
#define MAME_MACHINE_315_5649_H
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
//**************************************************************************
|
||||
|
||||
#define MCFG_315_5649_IN_PA_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_in_port_callback(DEVCB_##_devcb, 0);
|
||||
|
||||
#define MCFG_315_5649_OUT_PA_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_out_port_callback(DEVCB_##_devcb, 0);
|
||||
|
||||
#define MCFG_315_5649_IN_PB_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_in_port_callback(DEVCB_##_devcb, 1);
|
||||
|
||||
#define MCFG_315_5649_OUT_PB_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_out_port_callback(DEVCB_##_devcb, 1);
|
||||
|
||||
#define MCFG_315_5649_IN_PC_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_in_port_callback(DEVCB_##_devcb, 2);
|
||||
|
||||
#define MCFG_315_5649_OUT_PC_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_out_port_callback(DEVCB_##_devcb, 2);
|
||||
|
||||
#define MCFG_315_5649_IN_PD_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_in_port_callback(DEVCB_##_devcb, 3);
|
||||
|
||||
#define MCFG_315_5649_OUT_PD_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_out_port_callback(DEVCB_##_devcb, 3);
|
||||
|
||||
#define MCFG_315_5649_IN_PE_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_in_port_callback(DEVCB_##_devcb, 4);
|
||||
|
||||
#define MCFG_315_5649_OUT_PE_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_out_port_callback(DEVCB_##_devcb, 4);
|
||||
|
||||
#define MCFG_315_5649_IN_PF_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_in_port_callback(DEVCB_##_devcb, 5);
|
||||
|
||||
#define MCFG_315_5649_OUT_PF_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_out_port_callback(DEVCB_##_devcb, 5);
|
||||
|
||||
#define MCFG_315_5649_IN_PG_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_in_port_callback(DEVCB_##_devcb, 6);
|
||||
|
||||
#define MCFG_315_5649_OUT_PG_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_out_port_callback(DEVCB_##_devcb, 6);
|
||||
|
||||
#define MCFG_315_5649_AN0_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_an_port_callback(DEVCB_##_devcb, 0);
|
||||
|
||||
#define MCFG_315_5649_AN1_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_an_port_callback(DEVCB_##_devcb, 1);
|
||||
|
||||
#define MCFG_315_5649_AN2_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_an_port_callback(DEVCB_##_devcb, 2);
|
||||
|
||||
#define MCFG_315_5649_AN3_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_an_port_callback(DEVCB_##_devcb, 3);
|
||||
|
||||
#define MCFG_315_5649_AN4_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_an_port_callback(DEVCB_##_devcb, 4);
|
||||
|
||||
#define MCFG_315_5649_AN5_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_an_port_callback(DEVCB_##_devcb, 5);
|
||||
|
||||
#define MCFG_315_5649_AN6_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_an_port_callback(DEVCB_##_devcb, 6);
|
||||
|
||||
#define MCFG_315_5649_AN7_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_an_port_callback(DEVCB_##_devcb, 7);
|
||||
|
||||
#define MCFG_315_5649_SERIAL_CH1_READ_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_serial_rd_callback(DEVCB_##_devcb, 0);
|
||||
|
||||
#define MCFG_315_5649_SERIAL_CH1_WRITE_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_serial_wr_callback(DEVCB_##_devcb, 0);
|
||||
|
||||
#define MCFG_315_5649_SERIAL_CH2_READ_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_serial_rd_callback(DEVCB_##_devcb, 1);
|
||||
|
||||
#define MCFG_315_5649_SERIAL_CH2_WRITE_CB(_devcb) \
|
||||
devcb = &downcast<sega_315_5649_device &>(*device).set_serial_wr_callback(DEVCB_##_devcb, 1);
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
class sega_315_5649_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
sega_315_5649_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
// configuration
|
||||
template <class Object> devcb_base &set_in_port_callback(Object &&cb, int index)
|
||||
{ return m_in_port_cb[index].set_callback(std::forward<Object>(cb)); }
|
||||
|
||||
template <class Object> devcb_base &set_out_port_callback(Object &&cb, int index)
|
||||
{ return m_out_port_cb[index].set_callback(std::forward<Object>(cb)); }
|
||||
|
||||
template <class Object> devcb_base &set_an_port_callback(Object &&cb, int index)
|
||||
{ return m_an_port_cb[index].set_callback(std::forward<Object>(cb)); }
|
||||
|
||||
template <class Object> devcb_base &set_serial_rd_callback(Object &&cb, int index)
|
||||
{ return m_serial_rd_cb[index].set_callback(std::forward<Object>(cb)); }
|
||||
|
||||
template <class Object> devcb_base &set_serial_wr_callback(Object &&cb, int index)
|
||||
{ return m_serial_wr_cb[index].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_in_port_cb[7];
|
||||
devcb_write8 m_out_port_cb[7];
|
||||
devcb_read8 m_an_port_cb[8];
|
||||
devcb_read8 m_serial_rd_cb[2];
|
||||
devcb_write8 m_serial_wr_cb[2];
|
||||
|
||||
uint8_t m_port_value[7];
|
||||
uint8_t m_port_config;
|
||||
int m_analog_channel;
|
||||
};
|
||||
|
||||
// device type definition
|
||||
DECLARE_DEVICE_TYPE(SEGA_315_5649, sega_315_5649_device)
|
||||
|
||||
#endif // MAME_MACHINE_315_5649_H
|
Loading…
Reference in New Issue
Block a user