From 1d33382074c70263a870536d08c68debc10abd84 Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Wed, 19 Mar 2014 13:08:02 +0000 Subject: [PATCH] (MESS) upd65031: devcb2. (nw) --- src/mess/drivers/z88.c | 8 ++++---- src/mess/machine/upd65031.c | 30 +++++++++++++++--------------- src/mess/machine/upd65031.h | 29 +++++++++++++++++++++-------- 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/mess/drivers/z88.c b/src/mess/drivers/z88.c index 4467c32a223..6b1afe8640e 100644 --- a/src/mess/drivers/z88.c +++ b/src/mess/drivers/z88.c @@ -621,10 +621,6 @@ static UPD65031_INTERFACE( z88_blink_intf ) { z88_screen_update, // callback for update the LCD z88_bankswitch_update, // callback for update the bankswitch - DEVCB_DRIVER_MEMBER(z88_state, kb_r), // kb read input - DEVCB_CPU_INPUT_LINE("maincpu", 0), // INT line out - DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_NMI), // NMI line out - DEVCB_DEVICE_LINE_MEMBER("speaker", speaker_sound_device, level_w) // Speaker line out }; static const z88cart_interface z88_cart_interface = @@ -664,6 +660,10 @@ static MACHINE_CONFIG_START( z88, z88_state ) MCFG_DEFAULT_LAYOUT(layout_lcd) MCFG_UPD65031_ADD("blink", XTAL_9_8304MHz, z88_blink_intf) + MCFG_UPD65031_KB_CALLBACK(READ8(z88_state, kb_r)) + MCFG_UPD65031_INT_CALLBACK(INPUTLINE("maincpu", INPUT_LINE_IRQ0)) + MCFG_UPD65031_NMI_CALLBACK(INPUTLINE("maincpu", INPUT_LINE_NMI)) + MCFG_UPD65031_SPKR_CALLBACK(DEVWRITELINE("speaker", speaker_sound_device, level_w)) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mess/machine/upd65031.c b/src/mess/machine/upd65031.c index 822a2d3822c..983fd70aeaa 100644 --- a/src/mess/machine/upd65031.c +++ b/src/mess/machine/upd65031.c @@ -142,13 +142,13 @@ inline void upd65031_device::interrupt_refresh() { if (LOG) logerror("uPD65031 '%s': set int\n", tag()); - m_out_int_func(ASSERT_LINE); + m_write_int(ASSERT_LINE); } else { if (LOG) logerror("uPD65031 '%s': clear int\n", tag()); - m_out_int_func(CLEAR_LINE); + m_write_int(CLEAR_LINE); } } @@ -194,7 +194,11 @@ inline void upd65031_device::set_mode(int mode) //------------------------------------------------- upd65031_device::upd65031_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, UPD65031, "NEC uPD65031", tag, owner, clock, "upd65031", __FILE__) + : device_t(mconfig, UPD65031, "NEC uPD65031", tag, owner, clock, "upd65031", __FILE__), + m_read_kb(*this), + m_write_int(*this), + m_write_nmi(*this), + m_write_spkr(*this) { } @@ -218,10 +222,6 @@ void upd65031_device::device_config_complete() { m_screen_update_cb = NULL; m_out_mem_cb = NULL; - memset(&m_in_kb_cb, 0, sizeof(m_in_kb_cb)); - memset(&m_out_int_cb, 0, sizeof(m_out_int_cb)); - memset(&m_out_nmi_cb, 0, sizeof(m_out_nmi_cb)); - memset(&m_out_spkr_cb, 0, sizeof(m_out_spkr_cb)); } } @@ -233,10 +233,10 @@ void upd65031_device::device_config_complete() void upd65031_device::device_start() { // resolve callbacks - m_out_int_func.resolve(m_out_int_cb, *this); - m_out_nmi_func.resolve(m_out_nmi_cb, *this); - m_out_spkr_func.resolve(m_out_spkr_cb, *this); - m_int_kb_func.resolve(m_in_kb_cb, *this); + m_read_kb.resolve_safe(0); + m_write_int.resolve_safe(); + m_write_nmi.resolve_safe(); + m_write_spkr.resolve_safe(); // allocate timers m_rtc_timer = timer_alloc(TIMER_RTC); @@ -304,7 +304,7 @@ void upd65031_device::device_timer(emu_timer &timer, device_timer_id id, int par case TIMER_RTC: // if a key is pressed sets the interrupt - if ((m_int & INT_GINT) && (m_int & INT_KEY) && m_int_kb_func(0) != 0xff) + if ((m_int & INT_GINT) && (m_int & INT_KEY) && m_read_kb(0) != 0xff) { if (LOG) logerror("uPD65031 '%s': Keyboard interrupt!\n", tag()); @@ -393,7 +393,7 @@ void upd65031_device::device_timer(emu_timer &timer, device_timer_id id, int par break; case TIMER_SPEAKER: m_speaker_state = !m_speaker_state; - m_out_spkr_func(m_speaker_state ? 1 : 0); + m_write_spkr(m_speaker_state ? 1 : 0); break; } } @@ -436,7 +436,7 @@ READ8_MEMBER( upd65031_device::read ) if (LOG) logerror("uPD65031 '%s': entering snooze!\n", tag()); } - UINT8 data = m_int_kb_func(offset>>8); + UINT8 data = m_read_kb(offset>>8); if (LOG) logerror("uPD65031 '%s': key r %02x: %02x\n", tag(), offset>>8, data); @@ -516,7 +516,7 @@ WRITE8_MEMBER( upd65031_device::write ) { // speaker controlled by SBIT m_speaker_state = BIT(data, 6); - m_out_spkr_func(m_speaker_state); + m_write_spkr(m_speaker_state); } else { diff --git a/src/mess/machine/upd65031.h b/src/mess/machine/upd65031.h index 1744079614c..70401c06485 100644 --- a/src/mess/machine/upd65031.h +++ b/src/mess/machine/upd65031.h @@ -24,6 +24,18 @@ #define UPD65031_INTERFACE(name) \ const upd65031_interface (name) = +#define MCFG_UPD65031_KB_CALLBACK(_read) \ + devcb = &upd65031_device::set_kb_rd_callback(*device, DEVCB2_##_read); + +#define MCFG_UPD65031_INT_CALLBACK(_write) \ + devcb = &upd65031_device::set_int_wr_callback(*device, DEVCB2_##_write); + +#define MCFG_UPD65031_NMI_CALLBACK(_write) \ + devcb = &upd65031_device::set_nmi_wr_callback(*device, DEVCB2_##_write); + +#define MCFG_UPD65031_SPKR_CALLBACK(_write) \ + devcb = &upd65031_device::set_spkr_wr_callback(*device, DEVCB2_##_write); + //************************************************************************** // TYPE DEFINITIONS @@ -42,10 +54,6 @@ struct upd65031_interface { upd65031_screen_update_func m_screen_update_cb; // callback for update the LCD upd65031_memory_update_func m_out_mem_cb; // callback for update bankswitch - devcb_read8 m_in_kb_cb; // kb read input - devcb_write_line m_out_int_cb; // INT line out - devcb_write_line m_out_nmi_cb; // NMI line out - devcb_write_line m_out_spkr_cb; // Speaker line out }; @@ -58,6 +66,11 @@ public: // construction/destruction upd65031_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + template static devcb2_base &set_kb_rd_callback(device_t &device, _Object object) { return downcast(device).m_read_kb.set_callback(object); } + template static devcb2_base &set_int_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_int.set_callback(object); } + template static devcb2_base &set_nmi_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_nmi.set_callback(object); } + template static devcb2_base &set_spkr_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_spkr.set_callback(object); } + DECLARE_READ8_MEMBER( read ); DECLARE_WRITE8_MEMBER( write ); DECLARE_WRITE_LINE_MEMBER( flp_w ); @@ -79,10 +92,10 @@ private: static const device_timer_id TIMER_FLASH = 1; static const device_timer_id TIMER_SPEAKER = 2; - devcb_resolved_write_line m_out_int_func; - devcb_resolved_write_line m_out_nmi_func; - devcb_resolved_write_line m_out_spkr_func; - devcb_resolved_read8 m_int_kb_func; + devcb2_read8 m_read_kb; + devcb2_write_line m_write_int; + devcb2_write_line m_write_nmi; + devcb2_write_line m_write_spkr; int m_mode; UINT16 m_lcd_regs[5]; // LCD registers