From 3d87782c0d9b2ff459291e92e70e7afa35ca5216 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 23 Mar 2014 11:54:19 +0000 Subject: [PATCH] upd7759 use devcb2 now (nw) --- src/emu/sound/upd7759.c | 35 ++++++++++------------------------- src/emu/sound/upd7759.h | 18 ++++++++++-------- src/mame/drivers/segas16b.c | 18 +++--------------- src/mame/drivers/system16.c | 15 +++------------ src/mame/includes/segas16b.h | 2 +- src/mame/includes/system16.h | 1 + src/mess/drivers/segapico.c | 20 ++++++-------------- 7 files changed, 34 insertions(+), 75 deletions(-) diff --git a/src/emu/sound/upd7759.c b/src/emu/sound/upd7759.c index 14249c69da6..68788ae5861 100644 --- a/src/emu/sound/upd7759.c +++ b/src/emu/sound/upd7759.c @@ -189,7 +189,8 @@ upd775x_device::upd775x_device(const machine_config &mconfig, device_type type, m_rom(NULL), m_rombase(NULL), m_romoffset(0), - m_rommask(0) + m_rommask(0), + m_drqcallback(*this) { } @@ -208,26 +209,6 @@ upd7756_device::upd7756_device(const machine_config &mconfig, const char *tag, d { } -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void upd775x_device::device_config_complete() -{ - // inherit a copy of the static data - const upd775x_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - m_drqcallback = NULL; - } -} - //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -238,6 +219,8 @@ void upd775x_device::device_start() void upd7759_device::device_start() { + m_drqcallback.resolve_safe(); + /* chip configuration */ m_sample_offset_shift = (type() == UPD7759) ? 1 : 0; @@ -268,7 +251,7 @@ void upd7759_device::device_start() if (romsize >= 0x20000) m_rommask = 0x1ffff; else m_rommask = romsize - 1; - m_drqcallback = NULL; + m_drqcallback.set_callback(DEVCB2_NULL); } /* assume /RESET and /START are both high */ @@ -311,6 +294,8 @@ void upd7759_device::device_start() void upd7756_device::device_start() { + m_drqcallback.resolve_safe(); + /* chip configuration */ m_sample_offset_shift = (type() == UPD7759) ? 1 : 0; @@ -339,7 +324,7 @@ void upd7756_device::device_start() if (romsize >= 0x20000) m_rommask = 0x1ffff; else m_rommask = romsize - 1; - m_drqcallback = NULL; + m_drqcallback.set_callback(DEVCB2_NULL); } /* assume /RESET and /START are both high */ @@ -720,8 +705,8 @@ void upd7759_device::device_timer(emu_timer &timer, device_timer_id id, int para /* if the DRQ changed, update it */ logerror("upd7759_slave_update: DRQ %d->%d\n", olddrq, m_drq); - if (olddrq != m_drq && m_drqcallback) - (*m_drqcallback)(this, m_drq); + if (olddrq != m_drq) + m_drqcallback(m_drq); /* set a timer to go off when that is done */ if (m_state != STATE_IDLE) diff --git a/src/emu/sound/upd7759.h b/src/emu/sound/upd7759.h index 83e9d0f62c5..ae315315bbb 100644 --- a/src/emu/sound/upd7759.h +++ b/src/emu/sound/upd7759.h @@ -14,19 +14,15 @@ #define UPD7759_STANDARD_CLOCK XTAL_640kHz -struct upd775x_interface -{ - void (*m_drqcallback)(device_t *device, int param); /* drq callback (per chip, slave mode only) */ -}; - class upd775x_device : public device_t, - public device_sound_interface, - public upd775x_interface + public device_sound_interface { public: upd775x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); ~upd775x_device() {} + template static devcb2_base &set_drq_callback(device_t &device, _Object object) { return downcast(device).m_drqcallback.set_callback(object); } + void set_bank_base(offs_t base); void reset_w(UINT8 data); @@ -36,7 +32,6 @@ public: protected: // device-level overrides - virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); @@ -86,6 +81,8 @@ protected: UINT32 m_romoffset; /* ROM offset to make save/restore easier */ UINT32 m_rommask; /* maximum address offset */ + devcb2_write_line m_drqcallback; + void update_adpcm(int data); void advance_state(); }; @@ -125,5 +122,10 @@ public: extern const device_type UPD7759; extern const device_type UPD7756; +#define MCFG_UPD7759_DRQ_CALLBACK(_write) \ + devcb = &upd7759_device::set_drq_callback(*device, DEVCB2_##_write); + +#define MCFG_UPD7756_DRQ_CALLBACK(_write) \ + devcb = &upd7756_device::set_drq_callback(*device, DEVCB2_##_write); #endif /* __UPD7759_H__ */ diff --git a/src/mame/drivers/segas16b.c b/src/mame/drivers/segas16b.c index b6eca03babc..43a216b6963 100644 --- a/src/mame/drivers/segas16b.c +++ b/src/mame/drivers/segas16b.c @@ -1249,11 +1249,10 @@ READ8_MEMBER( segas16b_state::upd7759_status_r ) // NMI to the sound CPU //------------------------------------------------- -void segas16b_state::upd7759_generate_nmi(device_t *device, int state) +WRITE_LINE_MEMBER(segas16b_state::upd7759_generate_nmi) { - segas16b_state *driver = device->machine().driver_data(); if (state) - driver->m_soundcpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); + m_soundcpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); } @@ -3231,17 +3230,6 @@ INPUT_PORTS_END -//************************************************************************** -// SOUND CONFIGURATIONS -//************************************************************************** - -static const upd775x_interface upd7759_config = -{ - &segas16b_state::upd7759_generate_nmi -}; - - - //************************************************************************** // GRAPHICS DECODING //************************************************************************** @@ -3291,7 +3279,7 @@ static MACHINE_CONFIG_START( system16b, segas16b_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.43) MCFG_SOUND_ADD("upd", UPD7759, UPD7759_STANDARD_CLOCK) - MCFG_SOUND_CONFIG(upd7759_config) + MCFG_UPD7759_DRQ_CALLBACK(WRITELINE(segas16b_state,upd7759_generate_nmi)) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.48) MACHINE_CONFIG_END diff --git a/src/mame/drivers/system16.c b/src/mame/drivers/system16.c index 8e237a15cfb..6d967cd1c4b 100644 --- a/src/mame/drivers/system16.c +++ b/src/mame/drivers/system16.c @@ -2022,21 +2022,12 @@ static MACHINE_CONFIG_START( system16, segas1x_bootleg_state ) MACHINE_CONFIG_END -static void sound_cause_nmi( device_t *device, int chip ) +WRITE_LINE_MEMBER(segas1x_bootleg_state::sound_cause_nmi) { - segas1x_bootleg_state *state = device->machine().driver_data(); - /* upd7759 callback */ - state->m_soundcpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); + m_soundcpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); } - -const upd775x_interface sys16_upd7759_interface = -{ - sound_cause_nmi -}; - - static MACHINE_CONFIG_DERIVED( system16_7759, system16 ) /* basic machine hardware */ @@ -2047,7 +2038,7 @@ static MACHINE_CONFIG_DERIVED( system16_7759, system16 ) /* sound hardware */ MCFG_SOUND_ADD("7759", UPD7759, UPD7759_STANDARD_CLOCK) - MCFG_SOUND_CONFIG(sys16_upd7759_interface) + MCFG_UPD7759_DRQ_CALLBACK(WRITELINE(segas1x_bootleg_state,sound_cause_nmi)) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.48) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.48) MACHINE_CONFIG_END diff --git a/src/mame/includes/segas16b.h b/src/mame/includes/segas16b.h index fd204fca657..b039c508c5f 100644 --- a/src/mame/includes/segas16b.h +++ b/src/mame/includes/segas16b.h @@ -72,7 +72,7 @@ public: DECLARE_READ8_MEMBER( upd7759_status_r ); // other callbacks - static void upd7759_generate_nmi(device_t *device, int state); + DECLARE_WRITE_LINE_MEMBER(upd7759_generate_nmi); INTERRUPT_GEN_MEMBER( i8751_main_cpu_vblank ); // ROM board-specific driver init diff --git a/src/mame/includes/system16.h b/src/mame/includes/system16.h index eaae6ef949b..4afdb614516 100644 --- a/src/mame/includes/system16.h +++ b/src/mame/includes/system16.h @@ -214,4 +214,5 @@ public: void datsu_set_pages( ); DECLARE_WRITE_LINE_MEMBER(tturfbl_msm5205_callback); DECLARE_WRITE_LINE_MEMBER(shdancbl_msm5205_callback); + DECLARE_WRITE_LINE_MEMBER(sound_cause_nmi); }; diff --git a/src/mess/drivers/segapico.c b/src/mess/drivers/segapico.c index 2a6f3166755..c6767cd3d8c 100644 --- a/src/mess/drivers/segapico.c +++ b/src/mess/drivers/segapico.c @@ -145,6 +145,7 @@ public: UINT16 pico_read_penpos(int pen); DECLARE_READ16_MEMBER(pico_68k_io_read); DECLARE_WRITE16_MEMBER(pico_68k_io_write); + DECLARE_WRITE_LINE_MEMBER(sound_cause_irq); }; class pico_state : public pico_base_state @@ -156,7 +157,6 @@ public: optional_device m_picocart; DECLARE_MACHINE_START(pico); - }; @@ -268,21 +268,13 @@ READ16_MEMBER(pico_base_state::pico_68k_io_read ) } -static void sound_cause_irq( device_t *device, int chip ) +WRITE_LINE_MEMBER(pico_base_state::sound_cause_irq) { - pico_base_state *state = device->machine().driver_data(); // printf("sound irq\n"); /* upd7759 callback */ - state->m_maincpu->set_input_line(3, HOLD_LINE); + m_maincpu->set_input_line(3, HOLD_LINE); } - -const upd775x_interface pico_upd7759_interface = -{ - sound_cause_irq -}; - - WRITE16_MEMBER(pico_base_state::pico_68k_io_write ) { // printf("pico_68k_io_write %04x %04x %04x\n", offset*2, data, mem_mask); @@ -369,7 +361,7 @@ static MACHINE_CONFIG_START( pico, pico_state ) MCFG_SOFTWARE_LIST_ADD("cart_list","pico") MCFG_SOUND_ADD("7759", UPD7759, UPD7759_STANDARD_CLOCK) - MCFG_SOUND_CONFIG(pico_upd7759_interface) + MCFG_UPD7759_DRQ_CALLBACK(WRITELINE(pico_state,sound_cause_irq)) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.48) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.48) MACHINE_CONFIG_END @@ -389,7 +381,7 @@ static MACHINE_CONFIG_START( picopal, pico_state ) MCFG_SOFTWARE_LIST_ADD("cart_list","pico") MCFG_SOUND_ADD("7759", UPD7759, UPD7759_STANDARD_CLOCK) - MCFG_SOUND_CONFIG(pico_upd7759_interface) + MCFG_UPD7759_DRQ_CALLBACK(WRITELINE(pico_state,sound_cause_irq)) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.48) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.48) MACHINE_CONFIG_END @@ -559,7 +551,7 @@ static MACHINE_CONFIG_START( copera, copera_state ) MCFG_SOFTWARE_LIST_ADD("cart_list","copera") MCFG_SOUND_ADD("7759", UPD7759, UPD7759_STANDARD_CLOCK) - MCFG_SOUND_CONFIG(pico_upd7759_interface) + MCFG_UPD7759_DRQ_CALLBACK(WRITELINE(copera_state,sound_cause_irq)) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.48) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.48) MACHINE_CONFIG_END