mirror of
https://github.com/holub/mame
synced 2025-06-24 13:26:36 +03:00
cdp1852: devcb2. (nw)
This commit is contained in:
parent
eef8f45e9a
commit
66c4a91fef
@ -12,10 +12,15 @@
|
||||
#include "cdp1852.h"
|
||||
|
||||
|
||||
// device type definition
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
const device_type CDP1852 = &device_creator<cdp1852_device>;
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// MACROS / CONSTANTS
|
||||
//**************************************************************************
|
||||
@ -28,36 +33,6 @@ enum
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// INLINE HELPERS
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// get_mode -
|
||||
//-------------------------------------------------
|
||||
|
||||
int cdp1852_device::get_mode()
|
||||
{
|
||||
return m_in_mode_func();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// set_sr_line -
|
||||
//-------------------------------------------------
|
||||
|
||||
void cdp1852_device::set_sr_line(int state)
|
||||
{
|
||||
if (m_sr != state)
|
||||
{
|
||||
m_sr = state;
|
||||
|
||||
m_out_sr_func(m_sr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
@ -66,36 +41,16 @@ void cdp1852_device::set_sr_line(int state)
|
||||
// cdp1852_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
cdp1852_device::cdp1852_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, CDP1852, "CDP1852", tag, owner, clock, "cdp1852", __FILE__)
|
||||
cdp1852_device::cdp1852_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
device_t(mconfig, CDP1852, "CDP1852", tag, owner, clock, "cdp1852", __FILE__),
|
||||
m_read_mode(*this),
|
||||
m_write_sr(*this),
|
||||
m_read_data(*this),
|
||||
m_write_data(*this)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void cdp1852_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const cdp1852_interface *intf = reinterpret_cast<const cdp1852_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<cdp1852_interface *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_in_mode_cb, 0, sizeof(m_in_mode_cb));
|
||||
memset(&m_out_sr_cb, 0, sizeof(m_out_sr_cb));
|
||||
memset(&m_in_data_cb, 0, sizeof(m_in_data_cb));
|
||||
memset(&m_out_data_cb, 0, sizeof(m_out_data_cb));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
@ -103,10 +58,10 @@ void cdp1852_device::device_config_complete()
|
||||
void cdp1852_device::device_start()
|
||||
{
|
||||
// resolve callbacks
|
||||
m_in_mode_func.resolve(m_in_mode_cb, *this);
|
||||
m_out_sr_func.resolve(m_out_sr_cb, *this);
|
||||
m_in_data_func.resolve(m_in_data_cb, *this);
|
||||
m_out_data_func.resolve(m_out_data_cb, *this);
|
||||
m_read_mode.resolve_safe(0);
|
||||
m_write_sr.resolve_safe();
|
||||
m_read_data.resolve_safe(0);
|
||||
m_write_data.resolve_safe();
|
||||
|
||||
// allocate timers
|
||||
if (clock() > 0)
|
||||
@ -133,7 +88,7 @@ void cdp1852_device::device_reset()
|
||||
// reset data register
|
||||
m_data = 0;
|
||||
|
||||
if (get_mode() == MODE_INPUT)
|
||||
if (!m_read_mode())
|
||||
{
|
||||
// reset service request flip-flop
|
||||
set_sr_line(1);
|
||||
@ -141,7 +96,7 @@ void cdp1852_device::device_reset()
|
||||
else
|
||||
{
|
||||
// output data
|
||||
m_out_data_func(0, m_data);
|
||||
m_write_data((offs_t)0, m_data);
|
||||
|
||||
// reset service request flip-flop
|
||||
set_sr_line(0);
|
||||
@ -155,17 +110,16 @@ void cdp1852_device::device_reset()
|
||||
|
||||
void cdp1852_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
switch (get_mode())
|
||||
if (!m_read_mode())
|
||||
{
|
||||
case MODE_INPUT:
|
||||
// input data into register
|
||||
m_data = m_in_data_func(0);
|
||||
m_data = m_read_data(0);
|
||||
|
||||
// signal processor
|
||||
set_sr_line(0);
|
||||
break;
|
||||
|
||||
case MODE_OUTPUT:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_new_data)
|
||||
{
|
||||
m_new_data = 0;
|
||||
@ -174,7 +128,7 @@ void cdp1852_device::device_timer(emu_timer &timer, device_timer_id id, int para
|
||||
m_data = m_next_data;
|
||||
|
||||
// output data
|
||||
m_out_data_func(0, m_data);
|
||||
m_write_data((offs_t)0, m_data);
|
||||
|
||||
// signal peripheral device
|
||||
set_sr_line(1);
|
||||
@ -185,7 +139,21 @@ void cdp1852_device::device_timer(emu_timer &timer, device_timer_id id, int para
|
||||
{
|
||||
set_sr_line(m_next_sr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// set_sr_line -
|
||||
//-------------------------------------------------
|
||||
|
||||
void cdp1852_device::set_sr_line(int state)
|
||||
{
|
||||
if (m_sr != state)
|
||||
{
|
||||
m_sr = state;
|
||||
|
||||
m_write_sr(m_sr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,10 +164,10 @@ void cdp1852_device::device_timer(emu_timer &timer, device_timer_id id, int para
|
||||
|
||||
READ8_MEMBER( cdp1852_device::read )
|
||||
{
|
||||
if ((get_mode() == MODE_INPUT) && (clock() == 0))
|
||||
if (!m_read_mode() && !clock())
|
||||
{
|
||||
// input data into register
|
||||
m_data = m_in_data_func(0);
|
||||
m_data = m_read_data(0);
|
||||
}
|
||||
|
||||
set_sr_line(1);
|
||||
@ -214,7 +182,7 @@ READ8_MEMBER( cdp1852_device::read )
|
||||
|
||||
WRITE8_MEMBER( cdp1852_device::write )
|
||||
{
|
||||
if (get_mode() == MODE_OUTPUT)
|
||||
if (m_read_mode())
|
||||
{
|
||||
m_next_data = data;
|
||||
m_new_data = 1;
|
||||
|
@ -33,31 +33,21 @@
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// MACROS / CONSTANTS
|
||||
//**************************************************************************
|
||||
|
||||
#define CDP1852_CLOCK_HIGH 0
|
||||
|
||||
#define CDP1852_MODE_INPUT \
|
||||
DEVCB_LINE_GND
|
||||
|
||||
#define CDP1852_MODE_OUTPUT \
|
||||
DEVCB_LINE_VCC
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
//**************************************************************************
|
||||
|
||||
#define MCFG_CDP1852_ADD(_tag, _clock, _config) \
|
||||
MCFG_DEVICE_ADD(_tag, CDP1852, _clock) \
|
||||
MCFG_DEVICE_CONFIG(_config)
|
||||
#define MCFG_CDP1852_MODE_CALLBACK(_read) \
|
||||
devcb = &cdp1852_device::set_mode_rd_callback(*device, DEVCB2_##_read);
|
||||
|
||||
#define MCFG_CDP1852_SR_CALLBACK(_write) \
|
||||
devcb = &cdp1852_device::set_sr_wr_callback(*device, DEVCB2_##_write);
|
||||
|
||||
#define CDP1852_INTERFACE(name) \
|
||||
const cdp1852_interface (name)=
|
||||
#define MCFG_CDP1852_DI_CALLBACK(_read) \
|
||||
devcb = &cdp1852_device::set_data_rd_callback(*device, DEVCB2_##_read);
|
||||
|
||||
#define MCFG_CDP1852_DO_CALLBACK(_write) \
|
||||
devcb = &cdp1852_device::set_data_wr_callback(*device, DEVCB2_##_write);
|
||||
|
||||
|
||||
|
||||
@ -65,46 +55,35 @@
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
// ======================> cdp1852_interface
|
||||
|
||||
struct cdp1852_interface
|
||||
{
|
||||
devcb_read_line m_in_mode_cb;
|
||||
|
||||
devcb_read8 m_in_data_cb;
|
||||
devcb_write8 m_out_data_cb;
|
||||
|
||||
devcb_write_line m_out_sr_cb;
|
||||
};
|
||||
|
||||
|
||||
// ======================> cdp1852_device
|
||||
|
||||
class cdp1852_device : public device_t,
|
||||
public cdp1852_interface
|
||||
class cdp1852_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
cdp1852_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
template<class _Object> static devcb2_base &set_mode_rd_callback(device_t &device, _Object object) { return downcast<cdp1852_device &>(device).m_read_mode.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_sr_wr_callback(device_t &device, _Object object) { return downcast<cdp1852_device &>(device).m_write_sr.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_data_rd_callback(device_t &device, _Object object) { return downcast<cdp1852_device &>(device).m_read_data.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_data_wr_callback(device_t &device, _Object object) { return downcast<cdp1852_device &>(device).m_write_data.set_callback(object); }
|
||||
|
||||
DECLARE_READ8_MEMBER( read );
|
||||
DECLARE_WRITE8_MEMBER( write );
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
private:
|
||||
int get_mode();
|
||||
inline void set_sr_line(int state);
|
||||
void set_sr_line(int state);
|
||||
|
||||
devcb_resolved_read_line m_in_mode_func;
|
||||
devcb_resolved_write_line m_out_sr_func;
|
||||
devcb_resolved_read8 m_in_data_func;
|
||||
devcb_resolved_write8 m_out_data_func;
|
||||
devcb2_read_line m_read_mode;
|
||||
devcb2_write_line m_write_sr;
|
||||
devcb2_read8 m_read_data;
|
||||
devcb2_write8 m_write_data;
|
||||
|
||||
int m_new_data; // new data written
|
||||
UINT8 m_data; // data latch
|
||||
|
@ -136,47 +136,6 @@ WRITE8_MEMBER( draco_state::out1_w )
|
||||
m_sound = (data & 0xe0) >> 5;
|
||||
}
|
||||
|
||||
static CDP1852_INTERFACE( cidelsa_cdp1852_in0_intf )
|
||||
{
|
||||
CDP1852_MODE_INPUT,
|
||||
DEVCB_INPUT_PORT("IN0"),
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
static CDP1852_INTERFACE( cidelsa_cdp1852_in1_intf )
|
||||
{
|
||||
CDP1852_MODE_INPUT,
|
||||
DEVCB_INPUT_PORT("IN1"),
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
static CDP1852_INTERFACE( cidelsa_cdp1852_in2_intf )
|
||||
{
|
||||
CDP1852_MODE_INPUT,
|
||||
DEVCB_INPUT_PORT("IN2"),
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
static CDP1852_INTERFACE( altair_cdp1852_out1_intf )
|
||||
{
|
||||
CDP1852_MODE_OUTPUT,
|
||||
DEVCB_NULL,
|
||||
DEVCB_DRIVER_MEMBER(cidelsa_state, altair_out1_w),
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
static CDP1852_INTERFACE( draco_cdp1852_out1_intf )
|
||||
{
|
||||
CDP1852_MODE_OUTPUT,
|
||||
DEVCB_NULL,
|
||||
DEVCB_DRIVER_MEMBER(draco_state, out1_w),
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
|
||||
/* Memory Maps */
|
||||
|
||||
// Destroyer
|
||||
@ -485,10 +444,18 @@ static MACHINE_CONFIG_START( altair, cidelsa_state )
|
||||
MCFG_NVRAM_ADD_0FILL("nvram")
|
||||
|
||||
/* input/output hardware */
|
||||
MCFG_CDP1852_ADD("ic23", CDP1852_CLOCK_HIGH, cidelsa_cdp1852_in0_intf) /* clock is really tied to CDP1869 CMSEL (pin 37) */
|
||||
MCFG_CDP1852_ADD("ic24", CDP1852_CLOCK_HIGH, cidelsa_cdp1852_in1_intf)
|
||||
MCFG_CDP1852_ADD("ic25", CDP1852_CLOCK_HIGH, cidelsa_cdp1852_in2_intf)
|
||||
MCFG_CDP1852_ADD("ic26", ALTAIR_CHR1 / 8, altair_cdp1852_out1_intf) /* clock is CDP1802 TPB */
|
||||
MCFG_DEVICE_ADD("ic23", CDP1852, 0) // clock is really tied to CDP1869 CMSEL (pin 37)
|
||||
MCFG_CDP1852_MODE_CALLBACK(GND)
|
||||
MCFG_CDP1852_DI_CALLBACK(IOPORT("IN0"))
|
||||
MCFG_DEVICE_ADD("ic24", CDP1852, 0)
|
||||
MCFG_CDP1852_MODE_CALLBACK(GND)
|
||||
MCFG_CDP1852_DI_CALLBACK(IOPORT("IN1"))
|
||||
MCFG_DEVICE_ADD("ic25", CDP1852, 0)
|
||||
MCFG_CDP1852_MODE_CALLBACK(GND)
|
||||
MCFG_CDP1852_DI_CALLBACK(IOPORT("IN2"))
|
||||
MCFG_DEVICE_ADD("ic26", CDP1852, ALTAIR_CHR1 / 8) // clock is CDP1802 TPB
|
||||
MCFG_CDP1852_MODE_CALLBACK(VCC)
|
||||
MCFG_CDP1852_DO_CALLBACK(WRITE8(cidelsa_state, altair_out1_w))
|
||||
|
||||
/* sound and video hardware */
|
||||
MCFG_FRAGMENT_ADD(altair_video)
|
||||
@ -511,10 +478,18 @@ static MACHINE_CONFIG_START( draco, draco_state )
|
||||
MCFG_COP400_CONFIG( COP400_CKI_DIVISOR_16, COP400_CKO_OSCILLATOR_OUTPUT, COP400_MICROBUS_DISABLED )
|
||||
|
||||
/* input/output hardware */
|
||||
MCFG_CDP1852_ADD("ic29", CDP1852_CLOCK_HIGH, cidelsa_cdp1852_in0_intf) /* clock is really tied to CDP1876 CMSEL (pin 32) */
|
||||
MCFG_CDP1852_ADD("ic30", CDP1852_CLOCK_HIGH, cidelsa_cdp1852_in1_intf)
|
||||
MCFG_CDP1852_ADD("ic31", CDP1852_CLOCK_HIGH, cidelsa_cdp1852_in2_intf)
|
||||
MCFG_CDP1852_ADD("ic32", DRACO_CHR1 / 8, draco_cdp1852_out1_intf) /* clock is CDP1802 TPB */
|
||||
MCFG_DEVICE_ADD("ic29", CDP1852, 0) // clock is really tied to CDP1869 CMSEL (pin 37)
|
||||
MCFG_CDP1852_MODE_CALLBACK(GND)
|
||||
MCFG_CDP1852_DI_CALLBACK(IOPORT("IN0"))
|
||||
MCFG_DEVICE_ADD("ic30", CDP1852, 0)
|
||||
MCFG_CDP1852_MODE_CALLBACK(GND)
|
||||
MCFG_CDP1852_DI_CALLBACK(IOPORT("IN1"))
|
||||
MCFG_DEVICE_ADD("ic31", CDP1852, 0)
|
||||
MCFG_CDP1852_MODE_CALLBACK(GND)
|
||||
MCFG_CDP1852_DI_CALLBACK(IOPORT("IN2"))
|
||||
MCFG_DEVICE_ADD("ic32", CDP1852, ALTAIR_CHR1 / 8) // clock is CDP1802 TPB
|
||||
MCFG_CDP1852_MODE_CALLBACK(VCC)
|
||||
MCFG_CDP1852_DO_CALLBACK(WRITE8(draco_state, out1_w))
|
||||
|
||||
/* sound and video hardware */
|
||||
MCFG_FRAGMENT_ADD(draco_video)
|
||||
|
Loading…
Reference in New Issue
Block a user