mirror of
https://github.com/holub/mame
synced 2025-05-24 06:30:04 +03:00
Implemented centronics as slot device and file printer as default output (no whatsnew)
This commit is contained in:
parent
791c1bd94a
commit
d8b59a82d2
@ -7,6 +7,9 @@
|
||||
#include "emu.h"
|
||||
#include "ctronics.h"
|
||||
|
||||
//**************************************************************************
|
||||
// CENTRONICS SLOT DEVICE
|
||||
//**************************************************************************
|
||||
|
||||
// device type definition
|
||||
const device_type CENTRONICS = &device_creator<centronics_device>;
|
||||
@ -16,7 +19,9 @@ const device_type CENTRONICS = &device_creator<centronics_device>;
|
||||
//-------------------------------------------------
|
||||
|
||||
centronics_device::centronics_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, CENTRONICS, "Centronics", tag, owner, clock)
|
||||
: device_t(mconfig, CENTRONICS, "Centronics", tag, owner, clock),
|
||||
device_slot_interface(mconfig, *this),
|
||||
m_dev(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
@ -49,6 +54,8 @@ void centronics_device::device_config_complete()
|
||||
memset(&m_out_busy_func, 0, sizeof(m_out_busy_func));
|
||||
memset(&m_out_not_busy_func, 0, sizeof(m_out_not_busy_func));
|
||||
}
|
||||
|
||||
m_dev = dynamic_cast<device_centronics_peripheral_interface *>(get_card_device());
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -57,27 +64,10 @@ void centronics_device::device_config_complete()
|
||||
|
||||
void centronics_device::device_start()
|
||||
{
|
||||
/* set some initial values */
|
||||
m_pe = FALSE;
|
||||
m_fault = FALSE;
|
||||
m_busy = TRUE;
|
||||
m_strobe = TRUE;
|
||||
|
||||
/* get printer device */
|
||||
m_printer = subdevice<printer_image_device>("printer");
|
||||
|
||||
/* resolve callbacks */
|
||||
m_out_ack_func.resolve(m_out_ack_cb, *this);
|
||||
m_out_busy_func.resolve(m_out_busy_cb, *this);
|
||||
m_out_not_busy_func.resolve(m_out_not_busy_cb, *this);
|
||||
|
||||
/* register for state saving */
|
||||
save_item(NAME(m_auto_fd));
|
||||
save_item(NAME(m_strobe));
|
||||
save_item(NAME(m_busy));
|
||||
save_item(NAME(m_ack));
|
||||
save_item(NAME(m_data));
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@ -91,16 +81,50 @@ const centronics_interface standard_centronics =
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE CENTRONICS PERIPHERAL INTERFACE
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_centronics_peripheral_interface - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
device_centronics_peripheral_interface::device_centronics_peripheral_interface(const machine_config &mconfig, device_t &device)
|
||||
: device_slot_card_interface(mconfig, device)
|
||||
{
|
||||
/* set some initial values */
|
||||
m_pe = FALSE;
|
||||
m_fault = FALSE;
|
||||
m_busy = TRUE;
|
||||
m_strobe = TRUE;
|
||||
m_data = 0x00;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// ~device_centronics_peripheral_interface - destructor
|
||||
//-------------------------------------------------
|
||||
|
||||
device_centronics_peripheral_interface::~device_centronics_peripheral_interface()
|
||||
{
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
// CENTRONICS PRINTER DEVICE
|
||||
//**************************************************************************
|
||||
|
||||
// device type definition
|
||||
const device_type CENTRONICS_PRINTER = &device_creator<centronics_printer_device>;
|
||||
|
||||
/*****************************************************************************
|
||||
PRINTER INTERFACE
|
||||
*****************************************************************************/
|
||||
const struct printer_interface centronics_printer_config =
|
||||
{
|
||||
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, centronics_device, printer_online)
|
||||
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, centronics_printer_device, printer_online)
|
||||
};
|
||||
|
||||
static MACHINE_CONFIG_FRAGMENT( centronics )
|
||||
static MACHINE_CONFIG_FRAGMENT( centronics_printer )
|
||||
MCFG_PRINTER_ADD("printer")
|
||||
MCFG_DEVICE_CONFIG(centronics_printer_config)
|
||||
MACHINE_CONFIG_END
|
||||
@ -109,15 +133,23 @@ MACHINE_CONFIG_END
|
||||
/***************************************************************************
|
||||
IMPLEMENTATION
|
||||
***************************************************************************/
|
||||
//-------------------------------------------------
|
||||
// centronics_printer_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
centronics_printer_device::centronics_printer_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, CENTRONICS_PRINTER, "Centronics Printer", tag, owner, clock),
|
||||
device_centronics_peripheral_interface( mconfig, *this )
|
||||
{
|
||||
}
|
||||
//-------------------------------------------------
|
||||
// machine_config_additions - device-specific
|
||||
// machine configurations
|
||||
//-------------------------------------------------
|
||||
|
||||
machine_config_constructor centronics_device::device_mconfig_additions() const
|
||||
machine_config_constructor centronics_printer_device::device_mconfig_additions() const
|
||||
{
|
||||
return MACHINE_CONFIG_NAME( centronics );
|
||||
return MACHINE_CONFIG_NAME( centronics_printer );
|
||||
}
|
||||
|
||||
|
||||
@ -126,7 +158,7 @@ machine_config_constructor centronics_device::device_mconfig_additions() const
|
||||
sets us busy when the printer goes offline
|
||||
-------------------------------------------------*/
|
||||
|
||||
WRITE_LINE_MEMBER(centronics_device::printer_online)
|
||||
WRITE_LINE_MEMBER(centronics_printer_device::printer_online)
|
||||
{
|
||||
/* when going online, set PE and FAULT high and BUSY low */
|
||||
m_pe = state;
|
||||
@ -136,20 +168,20 @@ WRITE_LINE_MEMBER(centronics_device::printer_online)
|
||||
|
||||
static TIMER_CALLBACK( timer_ack_callback )
|
||||
{
|
||||
centronics_device *cent = reinterpret_cast<centronics_device *>(ptr);
|
||||
cent->ack_callback(param);
|
||||
centronics_printer_device *printer = reinterpret_cast<centronics_printer_device *>(ptr);
|
||||
printer->ack_callback(param);
|
||||
}
|
||||
|
||||
static TIMER_CALLBACK( timer_busy_callback )
|
||||
{
|
||||
centronics_device *cent = reinterpret_cast<centronics_device *>(ptr);
|
||||
cent->busy_callback(param);
|
||||
centronics_printer_device *printer = reinterpret_cast<centronics_printer_device *>(ptr);
|
||||
printer->busy_callback(param);
|
||||
}
|
||||
|
||||
void centronics_device::ack_callback(UINT8 param)
|
||||
void centronics_printer_device::ack_callback(UINT8 param)
|
||||
{
|
||||
/* signal change */
|
||||
m_out_ack_func(param);
|
||||
m_owner->out_ack(param);
|
||||
m_ack = param;
|
||||
|
||||
if (param == FALSE)
|
||||
@ -163,11 +195,11 @@ void centronics_device::ack_callback(UINT8 param)
|
||||
}
|
||||
|
||||
|
||||
void centronics_device::busy_callback(UINT8 param)
|
||||
void centronics_printer_device::busy_callback(UINT8 param)
|
||||
{
|
||||
/* signal change */
|
||||
m_out_busy_func(param);
|
||||
m_out_not_busy_func(!param);
|
||||
m_owner->out_busy(param);
|
||||
m_owner->out_not_busy(!param);
|
||||
m_busy = param;
|
||||
|
||||
if (param == TRUE)
|
||||
@ -182,26 +214,32 @@ void centronics_device::busy_callback(UINT8 param)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
set_line - helper to set individual bits
|
||||
-------------------------------------------------*/
|
||||
|
||||
void centronics_device::set_line(int line, int state)
|
||||
void centronics_printer_device::device_start()
|
||||
{
|
||||
if (state)
|
||||
m_data |= 1 << line;
|
||||
else
|
||||
m_data &= ~(1 << line);
|
||||
m_owner = dynamic_cast<centronics_device *>(owner());
|
||||
|
||||
/* get printer device */
|
||||
m_printer = subdevice<printer_image_device>("printer");
|
||||
|
||||
/* register for state saving */
|
||||
save_item(NAME(m_auto_fd));
|
||||
save_item(NAME(m_strobe));
|
||||
save_item(NAME(m_busy));
|
||||
save_item(NAME(m_ack));
|
||||
save_item(NAME(m_data));
|
||||
}
|
||||
|
||||
void centronics_printer_device::device_reset()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
centronics_strobe_w - signal that data is
|
||||
ready
|
||||
-------------------------------------------------*/
|
||||
|
||||
WRITE_LINE_MEMBER( centronics_device::strobe_w )
|
||||
void centronics_printer_device::strobe_w(UINT8 state)
|
||||
{
|
||||
/* look for a high -> low transition */
|
||||
if (m_strobe == TRUE && state == FALSE && m_busy == FALSE)
|
||||
@ -219,9 +257,14 @@ WRITE_LINE_MEMBER( centronics_device::strobe_w )
|
||||
printer (centronics mode)
|
||||
-------------------------------------------------*/
|
||||
|
||||
WRITE_LINE_MEMBER( centronics_device::init_prime_w )
|
||||
void centronics_printer_device::init_prime_w(UINT8 state)
|
||||
{
|
||||
/* reset printer if line is low */
|
||||
if (state == FALSE)
|
||||
device_reset();
|
||||
}
|
||||
|
||||
|
||||
SLOT_INTERFACE_START(centronics_printer)
|
||||
SLOT_INTERFACE("printer", CENTRONICS_PRINTER)
|
||||
SLOT_INTERFACE_END
|
@ -12,6 +12,38 @@
|
||||
/***************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
// ======================> device_centronics_peripheral_interface
|
||||
|
||||
class device_centronics_peripheral_interface : public device_slot_card_interface
|
||||
{
|
||||
public:
|
||||
device_centronics_peripheral_interface(const machine_config &mconfig, device_t &device);
|
||||
virtual ~device_centronics_peripheral_interface();
|
||||
public:
|
||||
virtual void write(UINT8 data) { m_data = data; }
|
||||
virtual UINT8 read() { return m_data; }
|
||||
|
||||
virtual void strobe_w(UINT8 state) { m_strobe = state; }
|
||||
virtual void init_prime_w(UINT8 state) { m_init = state; }
|
||||
virtual void autofeed_w(UINT8 state) { m_auto_fd = state; }
|
||||
|
||||
virtual UINT8 ack_r() { return m_ack;}
|
||||
virtual UINT8 busy_r(){ return m_busy; }
|
||||
virtual UINT8 pe_r() { return m_pe;}
|
||||
virtual UINT8 not_busy_r() { return !m_busy; }
|
||||
virtual UINT8 vcc_r() { return TRUE; }
|
||||
virtual UINT8 fault_r() { return m_fault; }
|
||||
virtual void set_line(int line, int state) { if (state) m_data |= 1 << line; else m_data &= ~(1 << line); }
|
||||
protected:
|
||||
UINT8 m_strobe;
|
||||
UINT8 m_busy;
|
||||
UINT8 m_ack;
|
||||
UINT8 m_auto_fd;
|
||||
UINT8 m_pe;
|
||||
UINT8 m_fault;
|
||||
UINT8 m_init;
|
||||
UINT8 m_data;
|
||||
};
|
||||
|
||||
// ======================> centronics_interface
|
||||
struct centronics_interface
|
||||
@ -23,79 +55,105 @@ struct centronics_interface
|
||||
|
||||
// ======================> centronics_device
|
||||
class centronics_device : public device_t,
|
||||
public centronics_interface
|
||||
public centronics_interface,
|
||||
public device_slot_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
centronics_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~centronics_device();
|
||||
// optional information overrides
|
||||
virtual machine_config_constructor device_mconfig_additions() const;
|
||||
|
||||
DECLARE_WRITE8_MEMBER( write ) { m_data = data; }
|
||||
DECLARE_READ8_MEMBER( read ) { return m_data; }
|
||||
DECLARE_WRITE8_MEMBER( write ) { if (m_dev) m_dev->write(data); }
|
||||
DECLARE_READ8_MEMBER( read ) { return (m_dev) ? m_dev->read() : 0x00; }
|
||||
|
||||
/* access to the individual bits */
|
||||
DECLARE_WRITE_LINE_MEMBER( d0_w ) { set_line(0, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d1_w ) { set_line(1, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d2_w ) { set_line(2, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d3_w ) { set_line(3, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d4_w ) { set_line(4, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d5_w ) { set_line(5, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d6_w ) { set_line(6, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d7_w ) { set_line(7, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d0_w ) { if (m_dev) m_dev->set_line(0, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d1_w ) { if (m_dev) m_dev->set_line(1, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d2_w ) { if (m_dev) m_dev->set_line(2, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d3_w ) { if (m_dev) m_dev->set_line(3, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d4_w ) { if (m_dev) m_dev->set_line(4, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d5_w ) { if (m_dev) m_dev->set_line(5, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d6_w ) { if (m_dev) m_dev->set_line(6, state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( d7_w ) { if (m_dev) m_dev->set_line(7, state); }
|
||||
|
||||
DECLARE_WRITE_LINE_MEMBER( strobe_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( init_prime_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( autofeed_w ) { m_auto_fd = state; }
|
||||
DECLARE_WRITE_LINE_MEMBER( strobe_w ) { if (m_dev) m_dev->strobe_w(state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( init_prime_w ) { if (m_dev) m_dev->init_prime_w(state); }
|
||||
DECLARE_WRITE_LINE_MEMBER( autofeed_w ) { if (m_dev) m_dev->autofeed_w(state); }
|
||||
|
||||
DECLARE_READ_LINE_MEMBER( ack_r ) { return m_ack; }
|
||||
DECLARE_READ_LINE_MEMBER( busy_r ){ return m_busy; }
|
||||
DECLARE_READ_LINE_MEMBER( pe_r ) { return m_pe; }
|
||||
DECLARE_READ_LINE_MEMBER( not_busy_r ) { return !m_busy; }
|
||||
DECLARE_READ_LINE_MEMBER( vcc_r ) { return TRUE; }
|
||||
DECLARE_READ_LINE_MEMBER( fault_r ) { return m_fault; }
|
||||
DECLARE_READ_LINE_MEMBER( ack_r ) { return (m_dev) ? m_dev->ack_r() : 0;}
|
||||
DECLARE_READ_LINE_MEMBER( busy_r ){ return (m_dev) ? m_dev->busy_r() : 1; }
|
||||
DECLARE_READ_LINE_MEMBER( pe_r ) { return (m_dev) ? m_dev->pe_r() : 0;}
|
||||
DECLARE_READ_LINE_MEMBER( not_busy_r ) { return (m_dev) ? m_dev->not_busy_r() : 0; }
|
||||
DECLARE_READ_LINE_MEMBER( vcc_r ) { return (m_dev) ? m_dev->vcc_r() : 0; }
|
||||
DECLARE_READ_LINE_MEMBER( fault_r ) { return (m_dev) ? m_dev->fault_r() : 0; }
|
||||
|
||||
// for printer
|
||||
DECLARE_WRITE_LINE_MEMBER(printer_online);
|
||||
void out_ack(UINT8 param) { m_out_ack_func(param); }
|
||||
void out_busy(UINT8 param) { m_out_busy_func(param); }
|
||||
void out_not_busy(UINT8 param) { m_out_not_busy_func(param); }
|
||||
|
||||
void ack_callback(UINT8 param);
|
||||
void busy_callback(UINT8 param);
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
|
||||
void set_line(int line, int state);
|
||||
private:
|
||||
printer_image_device *m_printer;
|
||||
device_centronics_peripheral_interface *m_dev;
|
||||
|
||||
devcb_resolved_write_line m_out_ack_func;
|
||||
devcb_resolved_write_line m_out_busy_func;
|
||||
devcb_resolved_write_line m_out_not_busy_func;
|
||||
|
||||
UINT8 m_strobe;
|
||||
UINT8 m_busy;
|
||||
UINT8 m_ack;
|
||||
UINT8 m_auto_fd;
|
||||
UINT8 m_pe;
|
||||
UINT8 m_fault;
|
||||
|
||||
UINT8 m_data;
|
||||
};
|
||||
|
||||
// device type definition
|
||||
extern const device_type CENTRONICS;
|
||||
|
||||
// ======================> centronics_printer_device
|
||||
|
||||
class centronics_printer_device :
|
||||
public device_t,
|
||||
public device_centronics_peripheral_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
centronics_printer_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
// optional information overrides
|
||||
virtual machine_config_constructor device_mconfig_additions() const;
|
||||
// for printer
|
||||
DECLARE_WRITE_LINE_MEMBER(printer_online);
|
||||
|
||||
void ack_callback(UINT8 param);
|
||||
void busy_callback(UINT8 param);
|
||||
|
||||
// optional centronics overrides
|
||||
virtual void strobe_w(UINT8 state);
|
||||
virtual void init_prime_w(UINT8 state);
|
||||
virtual UINT8 read() { return 0x00; }
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
private:
|
||||
printer_image_device *m_printer;
|
||||
centronics_device *m_owner;
|
||||
};
|
||||
// device type definition
|
||||
extern const device_type CENTRONICS_PRINTER;
|
||||
|
||||
SLOT_INTERFACE_EXTERN(centronics_printer);
|
||||
|
||||
/***************************************************************************
|
||||
DEVICE CONFIGURATION MACROS
|
||||
***************************************************************************/
|
||||
|
||||
#define MCFG_CENTRONICS_ADD(_tag, _intf) \
|
||||
#define MCFG_CENTRONICS_ADD(_tag, _intf, _slot_intf, _def_slot, _def_inp) \
|
||||
MCFG_DEVICE_ADD(_tag, CENTRONICS, 0) \
|
||||
MCFG_DEVICE_CONFIG(_intf)
|
||||
MCFG_DEVICE_CONFIG(_intf) \
|
||||
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp) \
|
||||
|
||||
#define MCFG_CENTRONICS_PRINTER_ADD(_tag, _intf) \
|
||||
MCFG_CENTRONICS_ADD(_tag, _intf, centronics_printer, "printer", NULL) \
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
DEFAULT INTERFACES
|
||||
***************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user