From dd34840da9b16f881d8e59e3f3ba6e457cc53d52 Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Thu, 3 Apr 2014 16:29:09 +0000 Subject: [PATCH] rtc65271_device: converted to devcb2 (nw) --- src/emu/bus/ti99_peb/tn_ide.c | 10 +++------- src/emu/machine/rtc65271.c | 33 +++++++-------------------------- src/emu/machine/rtc65271.h | 19 +++++++------------ src/mame/drivers/firebeat.c | 9 ++------- src/mame/drivers/twinkle.c | 6 +----- 5 files changed, 20 insertions(+), 57 deletions(-) diff --git a/src/emu/bus/ti99_peb/tn_ide.c b/src/emu/bus/ti99_peb/tn_ide.c index 1e39c12970a..4372c62d97d 100644 --- a/src/emu/bus/ti99_peb/tn_ide.c +++ b/src/emu/bus/ti99_peb/tn_ide.c @@ -5,7 +5,7 @@ Thierry Nouspikel's IDE card emulation This card is just a prototype. It has been designed by Thierry Nouspikel, - and its description was published in 2001. The card have been revised in + and its description was published in 2001. The card has been revised in 2004. The specs have been published in . @@ -332,13 +332,9 @@ void nouspikel_ide_interface_device::device_reset() m_tms9995_mode = false; // (device->type()==TMS9995); } -static const rtc65271_interface ide_rtc_cfg = -{ - DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, nouspikel_ide_interface_device, clock_interrupt_callback) -}; - MACHINE_CONFIG_FRAGMENT( tn_ide ) - MCFG_RTC65271_ADD( "ide_rtc", ide_rtc_cfg ) + MCFG_DEVICE_ADD( "ide_rtc", RTC65271, 0 ) + MCFG_RTC65271_INTERRUPT_CB(WRITELINE(nouspikel_ide_interface_device, clock_interrupt_callback)) MCFG_ATA_INTERFACE_ADD( "ata", ata_devices, "hdd", NULL, false) MCFG_ATA_INTERFACE_IRQ_HANDLER(WRITELINE(nouspikel_ide_interface_device, ide_interrupt_callback)) MACHINE_CONFIG_END diff --git a/src/emu/machine/rtc65271.c b/src/emu/machine/rtc65271.c index 79c8dd73e27..0a5de8d09e6 100644 --- a/src/emu/machine/rtc65271.c +++ b/src/emu/machine/rtc65271.c @@ -449,14 +449,14 @@ void rtc65271_device::field_interrupts() if (m_regs[reg_C] & m_regs[reg_B] & (reg_C_PF | reg_C_AF | reg_C_UF)) { m_regs[reg_C] |= reg_C_IRQF; - if (!m_interrupt_func.isnull()) - m_interrupt_func(1); + if (!m_interrupt_cb.isnull()) + m_interrupt_cb(1); } else { m_regs[reg_C] &= ~reg_C_IRQF; - if (!m_interrupt_func.isnull()) - m_interrupt_func(0); + if (!m_interrupt_cb.isnull()) + m_interrupt_cb(0); } } @@ -672,30 +672,11 @@ const device_type RTC65271 = &device_creator; rtc65271_device::rtc65271_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, RTC65271, "RTC65271", tag, owner, clock, "rtc65271", __FILE__), - device_nvram_interface(mconfig, *this) + device_nvram_interface(mconfig, *this), + m_interrupt_cb(*this) { } -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void rtc65271_device::device_config_complete() -{ - // inherit a copy of the static data - const rtc65271_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - memset(&m_interrupt_cb, 0, sizeof(m_interrupt_cb)); - } -} - //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -704,7 +685,7 @@ void rtc65271_device::device_start() m_update_timer = machine().scheduler().timer_alloc(FUNC(rtc_begin_update_callback), (void *)this); m_update_timer->adjust(attotime::from_seconds(1), 0, attotime::from_seconds(1)); m_SQW_timer = machine().scheduler().timer_alloc(FUNC(rtc_SQW_callback), (void *)this); - m_interrupt_func.resolve(m_interrupt_cb, *this); + m_interrupt_cb.resolve(); save_item(NAME(m_regs)); save_item(NAME(m_cur_reg)); diff --git a/src/emu/machine/rtc65271.h b/src/emu/machine/rtc65271.h index c2db1cad6ca..6836bda4a62 100644 --- a/src/emu/machine/rtc65271.h +++ b/src/emu/machine/rtc65271.h @@ -9,34 +9,29 @@ // INTERFACE CONFIGURATION MACROS //************************************************************************** -#define MCFG_RTC65271_ADD(_tag, _config) \ - MCFG_DEVICE_ADD(_tag, RTC65271, 0) \ - MCFG_DEVICE_CONFIG(_config) -// ======================> rtc65271_interface +#define MCFG_RTC65271_INTERRUPT_CB(_devcb) \ + devcb = &rtc65271_device::set_interrupt_callback(*device, DEVCB2_##_devcb); -struct rtc65271_interface -{ - devcb_write_line m_interrupt_cb; -}; // ======================> rtc65271_device class rtc65271_device : public device_t, - public device_nvram_interface, - public rtc65271_interface + public device_nvram_interface { public: // construction/destruction rtc65271_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); protected: // device-level overrides - virtual void device_config_complete(); virtual void device_start(); // device_nvram_interface overrides virtual void nvram_default(); virtual void nvram_read(emu_file &file); virtual void nvram_write(emu_file &file); public: + + template static devcb2_base &set_interrupt_callback(device_t &device, _Object object) { return downcast(device).m_interrupt_cb.set_callback(object); } + DECLARE_READ8_MEMBER( rtc_r ); DECLARE_READ8_MEMBER( xram_r ); DECLARE_WRITE8_MEMBER( rtc_w ); @@ -70,7 +65,7 @@ private: UINT8 m_SQW_internal_state; /* callback called when interrupt pin state changes (may be NULL) */ - devcb_resolved_write_line m_interrupt_func; + devcb2_write_line m_interrupt_cb; }; // device type definition diff --git a/src/mame/drivers/firebeat.c b/src/mame/drivers/firebeat.c index 423553a6f72..c934b11ab4e 100644 --- a/src/mame/drivers/firebeat.c +++ b/src/mame/drivers/firebeat.c @@ -1723,11 +1723,6 @@ MACHINE_RESET_MEMBER(firebeat_state,firebeat) m_layer = 0; } -const rtc65271_interface firebeat_rtc = -{ - DEVCB_NULL -}; - WRITE_LINE_MEMBER( firebeat_state::ata_interrupt ) { m_maincpu->set_input_line(INPUT_LINE_IRQ4, state); @@ -1749,7 +1744,7 @@ static MACHINE_CONFIG_START( firebeat, firebeat_state ) MCFG_MACHINE_START_OVERRIDE(firebeat_state,firebeat) MCFG_MACHINE_RESET_OVERRIDE(firebeat_state,firebeat) - MCFG_RTC65271_ADD("rtc", firebeat_rtc) + MCFG_DEVICE_ADD("rtc", RTC65271, 0) MCFG_FUJITSU_29F016A_ADD("flash_main") MCFG_FUJITSU_29F016A_ADD("flash_snd1") @@ -1797,7 +1792,7 @@ static MACHINE_CONFIG_START( firebeat2, firebeat_state ) MCFG_MACHINE_START_OVERRIDE(firebeat_state,firebeat) MCFG_MACHINE_RESET_OVERRIDE(firebeat_state,firebeat) - MCFG_RTC65271_ADD("rtc", firebeat_rtc) + MCFG_DEVICE_ADD("rtc", RTC65271, 0) MCFG_FUJITSU_29F016A_ADD("flash_main") MCFG_FUJITSU_29F016A_ADD("flash_snd1") diff --git a/src/mame/drivers/twinkle.c b/src/mame/drivers/twinkle.c index be4e87d7c90..1a94fa58637 100644 --- a/src/mame/drivers/twinkle.c +++ b/src/mame/drivers/twinkle.c @@ -854,10 +854,6 @@ static void scsi_dma_write( twinkle_state *state, UINT32 *p_n_psxram, UINT32 n_a } } -static const rtc65271_interface twinkle_rtc = -{ - DEVCB_NULL -}; static MACHINE_CONFIG_START( twinkle, twinkle_state ) /* basic machine hardware */ @@ -883,7 +879,7 @@ static MACHINE_CONFIG_START( twinkle, twinkle_state ) MCFG_ATA_INTERFACE_ADD("ata", ata_devices, "hdd", NULL, true) MCFG_ATA_INTERFACE_IRQ_HANDLER(WRITELINE(twinkle_state, ide_interrupt)) - MCFG_RTC65271_ADD("rtc", twinkle_rtc) + MCFG_DEVICE_ADD("rtc", RTC65271, 0) /* video hardware */ MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561Q, 0x200000, XTAL_53_693175MHz )