printer_image_device: converted to devcb2 (nw)

This commit is contained in:
Ivan Vangelista 2014-04-11 16:30:02 +00:00
parent d707a9d54c
commit 0b4e78bc26
11 changed files with 32 additions and 54 deletions

View File

@ -8,17 +8,10 @@
// device type definition
const device_type CENTRONICS_PRINTER_IMAGE = &device_creator<centronics_printer_image_device>;
/*****************************************************************************
PRINTER INTERFACE
*****************************************************************************/
const struct printer_interface centronics_printer_config =
{
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, centronics_printer_image_device, printer_online)
};
static MACHINE_CONFIG_FRAGMENT( centronics_printer )
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_CONFIG(centronics_printer_config)
MCFG_DEVICE_ADD("printer", PRINTER, 0)
MCFG_PRINTER_ONLINE_CB(WRITELINE(centronics_printer_image_device, printer_online))
MACHINE_CONFIG_END

View File

@ -34,7 +34,7 @@ static I8255_INTERFACE( iq151_staper_ppi_intf )
static MACHINE_CONFIG_FRAGMENT( iq151_staper )
MCFG_I8255A_ADD("ppi8255", iq151_staper_ppi_intf)
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
MACHINE_CONFIG_END
//**************************************************************************

View File

@ -19,7 +19,8 @@ const device_type PRINTER = &device_creator<printer_image_device>;
printer_image_device::printer_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, PRINTER, "Printer", tag, owner, clock, "printer_image", __FILE__),
device_image_interface(mconfig, *this)
device_image_interface(mconfig, *this),
m_online_cb(*this)
{
}
@ -39,17 +40,6 @@ printer_image_device::~printer_image_device()
void printer_image_device::device_config_complete()
{
// inherit a copy of the static data
const printer_interface *intf = reinterpret_cast<const printer_interface *>(static_config());
if (intf != NULL)
*static_cast<printer_interface *>(this) = *intf;
// or initialize to defaults if none provided
else
{
memset(&m_online, 0, sizeof(m_online));
}
// set brief and instance name
update_names();
}
@ -61,7 +51,7 @@ void printer_image_device::device_config_complete()
void printer_image_device::device_start()
{
m_online_func.resolve(m_online, *this);
m_online_cb.resolve();
}
/***************************************************************************
@ -107,8 +97,8 @@ bool printer_image_device::call_create(int format_type, option_resolution *forma
bool printer_image_device::call_load()
{
/* send notify that the printer is now online */
if (!m_online_func.isnull())
m_online_func(TRUE);
if (!m_online_cb.isnull())
m_online_cb(TRUE);
/* we don't need to do anything special */
return IMAGE_INIT_PASS;
@ -121,6 +111,6 @@ bool printer_image_device::call_load()
void printer_image_device::call_unload()
{
/* send notify that the printer is now offline */
if (!m_online_func.isnull())
m_online_func(FALSE);
if (!m_online_cb.isnull())
m_online_cb(FALSE);
}

View File

@ -10,27 +10,25 @@
#define __PRINTER_H__
#define MCFG_PRINTER_ONLINE_CB(_devcb) \
devcb = &printer_image_device::set_online_callback(*device, DEVCB2_##_devcb);
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
// ======================> printer_interface
struct printer_interface
{
devcb_write_line m_online;
};
// ======================> printer_image_device
class printer_image_device : public device_t,
public printer_interface,
public device_image_interface
{
public:
// construction/destruction
printer_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
virtual ~printer_image_device();
template<class _Object> static devcb2_base &set_online_callback(device_t &device, _Object object) { return downcast<printer_image_device &>(device).m_online_cb.set_callback(object); }
// image-level overrides
virtual bool call_load();
@ -56,17 +54,14 @@ public:
void output(UINT8 data);
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_config_complete();
devcb_resolved_write_line m_online_func;
devcb2_write_line m_online_cb;
};
// device type definition
extern const device_type PRINTER;
#define MCFG_PRINTER_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, PRINTER, 0)
#endif /* __PRINTER_H__ */

View File

@ -162,7 +162,7 @@ static MACHINE_CONFIG_START( dragon_base, dragon_state )
MCFG_SAM6883_ADD(SAM_TAG, XTAL_4_433619MHz, dragon_state::sam6883_config)
MCFG_SAM6883_RES_CALLBACK(READ8(dragon_state, sam_read))
MCFG_CASSETTE_ADD("cassette", dragon_state::coco_cassette_interface)
MCFG_PRINTER_ADD(PRINTER_TAG)
MCFG_DEVICE_ADD(PRINTER_TAG, PRINTER, 0)
// video hardware
MCFG_SCREEN_MC6847_PAL_ADD(SCREEN_TAG, VDG_TAG)

View File

@ -466,7 +466,7 @@ static MACHINE_CONFIG_START( hec2hr, hec2hrp_state )
MCFG_CASSETTE_ADD( "cassette", hector_cassette_interface )
/* printer */
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
MACHINE_CONFIG_END
@ -510,7 +510,7 @@ static MACHINE_CONFIG_START( hec2hrp, hec2hrp_state )
MCFG_CASSETTE_ADD( "cassette", hector_cassette_interface )
/* printer */
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
MACHINE_CONFIG_END
@ -568,7 +568,7 @@ static MACHINE_CONFIG_START( hec2mx40, hec2hrp_state )
MCFG_CASSETTE_ADD( "cassette", hector_cassette_interface )
/* printer */
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
MACHINE_CONFIG_END
/*****************************************************************************/
@ -621,7 +621,7 @@ static MACHINE_CONFIG_START( hec2hrx, hec2hrp_state )
MCFG_CASSETTE_ADD( "cassette", hector_cassette_interface )
/* printer */
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
MACHINE_CONFIG_END
/*****************************************************************************/
@ -670,7 +670,7 @@ static MACHINE_CONFIG_START( hec2mdhrx, hec2hrp_state )
MCFG_CASSETTE_ADD( "cassette", hector_cassette_interface )
/* printer */
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
MACHINE_CONFIG_END
@ -724,7 +724,7 @@ static MACHINE_CONFIG_START( hec2mx80, hec2hrp_state )
MCFG_CASSETTE_ADD( "cassette", hector_cassette_interface )
/* printer */
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
MACHINE_CONFIG_END

View File

@ -176,7 +176,7 @@ static MACHINE_CONFIG_START( interact, interact_state )
MCFG_SOFTWARE_LIST_ADD("cass_list","interact")
/* printer */
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
MACHINE_CONFIG_END
@ -218,7 +218,7 @@ static MACHINE_CONFIG_START( hector1, interact_state )
MCFG_CASSETTE_ADD( "cassette", interact_cassette_interface )
/* printer */
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
MACHINE_CONFIG_END

View File

@ -520,7 +520,7 @@ static MACHINE_CONFIG_START( mc10, mc10_state )
MCFG_CASSETTE_ADD("cassette", mc10_cassette_interface)
/* printer */
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
/* internal ram */
MCFG_RAM_ADD(RAM_TAG)
@ -555,7 +555,7 @@ static MACHINE_CONFIG_START( alice32, mc10_state )
MCFG_CASSETTE_ADD("cassette", alice32_cassette_interface)
/* printer */
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
/* internal ram */
MCFG_RAM_ADD(RAM_TAG)

View File

@ -1175,7 +1175,7 @@ static MACHINE_CONFIG_START( ql, ql_state )
MCFG_RAM_EXTRA_OPTIONS("192K,256K,384K,640K,896K")
// Parallel printer port on Sandy disk interface
MCFG_PRINTER_ADD(PRINTER_TAG)
MCFG_DEVICE_ADD(PRINTER_TAG, PRINTER, 0)
MACHINE_CONFIG_END

View File

@ -405,7 +405,7 @@ static MACHINE_CONFIG_START( vg5k, vg5k_state )
MCFG_CASSETTE_ADD( "cassette", vg5k_cassette_interface )
/* printer */
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
/* internal ram */
MCFG_RAM_ADD(RAM_TAG)

View File

@ -1495,7 +1495,7 @@ static MACHINE_CONFIG_START( x07, x07_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
/* printer */
MCFG_PRINTER_ADD("printer")
MCFG_DEVICE_ADD("printer", PRINTER, 0)
MCFG_TIMER_DRIVER_ADD_PERIODIC("blink_timer", x07_state, blink_timer, attotime::from_msec(300))