From 6b0e6c7a1ce5515ebed1f5bda2b27b2a23b49bc6 Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Mon, 24 Mar 2014 18:38:12 +0000 Subject: [PATCH] bfmdm01_device: converted to devcb2 (nw) --- src/mame/drivers/bfm_sc2.c | 14 +++++--------- src/mame/drivers/bfm_sc4h.c | 12 +++--------- src/mame/includes/bfm_sc45.h | 2 ++ src/mame/video/bfm_dm01.c | 30 +++++++----------------------- src/mame/video/bfm_dm01.h | 21 +++++++-------------- 5 files changed, 24 insertions(+), 55 deletions(-) diff --git a/src/mame/drivers/bfm_sc2.c b/src/mame/drivers/bfm_sc2.c index f81bf7e5de9..3b337703a29 100644 --- a/src/mame/drivers/bfm_sc2.c +++ b/src/mame/drivers/bfm_sc2.c @@ -237,6 +237,7 @@ public: int m_e2data_to_read; UINT8 m_codec_data[256]; void e2ram_init(nvram_device &nvram, void *data, size_t size); + DECLARE_WRITE_LINE_MEMBER(bfmdm01_busy); DECLARE_WRITE8_MEMBER(bankswitch_w); DECLARE_WRITE8_MEMBER(reel12_vid_w); DECLARE_WRITE8_MEMBER(reel12_w); @@ -2605,17 +2606,11 @@ WRITE8_MEMBER(bfm_sc2_state::sc3_expansion_w) } #endif -static void bfmdm01_busy(running_machine &machine, int state) +WRITE_LINE_MEMBER(bfm_sc2_state::bfmdm01_busy) { - bfm_sc2_state *drvstate = machine.driver_data(); - drvstate->Scorpion2_SetSwitchState(4,4, state?0:1); + Scorpion2_SetSwitchState(4,4, state?0:1); } -static const bfmdm01_interface dm01_interface = -{ - bfmdm01_busy -}; - /* machine init (called only once) */ MACHINE_RESET_MEMBER(bfm_sc2_state,awp_init) { @@ -3772,7 +3767,8 @@ static MACHINE_CONFIG_START( scorpion2_dm01, bfm_sc2_state ) /* video hardware */ MCFG_DEFAULT_LAYOUT(layout_sc2_dmd) - MCFG_DM01_ADD("dm01", dm01_interface) + MCFG_DEVICE_ADD("dm01", BF_DM01, 0) + MCFG_BF_DM01_BUSY_CB(WRITELINE(bfm_sc2_state, bfmdm01_busy)) MCFG_CPU_ADD("matrix", M6809, 2000000 ) /* matrix board 6809 CPU at 2 Mhz ?? I don't know the exact freq.*/ MCFG_CPU_PROGRAM_MAP(bfm_dm01_memmap) MCFG_CPU_PERIODIC_INT_DRIVER(bfm_sc2_state, nmi_line_assert, 1500 ) /* generate 1500 NMI's per second ?? what is the exact freq?? */ diff --git a/src/mame/drivers/bfm_sc4h.c b/src/mame/drivers/bfm_sc4h.c index b6b785c37e7..bff324c4a56 100644 --- a/src/mame/drivers/bfm_sc4h.c +++ b/src/mame/drivers/bfm_sc4h.c @@ -698,18 +698,11 @@ WRITE8_MEMBER(sc4_state::m68307_duart_output_w) } /* default dmd */ -static void bfmdm01_busy(running_machine &machine, int state) +WRITE_LINE_MEMBER(sc4_state::bfmdm01_busy) { // Must tie back to inputs somehow! } -static const bfmdm01_interface dm01_interface = -{ - bfmdm01_busy -}; - - - MACHINE_CONFIG_START( sc4, sc4_state ) MCFG_CPU_ADD("maincpu", M68307, 16000000) // 68307! (EC000 core) MCFG_CPU_PROGRAM_MAP(sc4_map) @@ -765,7 +758,8 @@ MACHINE_CONFIG_DERIVED_CLASS( sc4dmd, sc4, sc4_state ) /* video hardware */ MCFG_DEFAULT_LAYOUT(layout_sc4_dmd) - MCFG_DM01_ADD("dm01", dm01_interface) + MCFG_DEVICE_ADD("dm01", BF_DM01, 0) + MCFG_BF_DM01_BUSY_CB(WRITELINE(sc4_state, bfmdm01_busy)) MCFG_CPU_ADD("matrix", M6809, 2000000 ) /* matrix board 6809 CPU at 2 Mhz ?? I don't know the exact freq.*/ MCFG_CPU_PROGRAM_MAP(bfm_dm01_memmap) MCFG_CPU_PERIODIC_INT_DRIVER(sc4_state, nmi_line_assert, 1500 ) /* generate 1500 NMI's per second ?? what is the exact freq?? */ diff --git a/src/mame/includes/bfm_sc45.h b/src/mame/includes/bfm_sc45.h index 3896a9d6d81..efc6debfd86 100644 --- a/src/mame/includes/bfm_sc45.h +++ b/src/mame/includes/bfm_sc45.h @@ -101,6 +101,8 @@ public: UINT8 read_input_matrix(running_machine &machine, int row); + DECLARE_WRITE_LINE_MEMBER(bfmdm01_busy); + DECLARE_READ16_MEMBER(sc4_mem_r); DECLARE_WRITE16_MEMBER(sc4_mem_w); diff --git a/src/mame/video/bfm_dm01.c b/src/mame/video/bfm_dm01.c index 5cdc72d1c63..ed0a3572f4e 100644 --- a/src/mame/video/bfm_dm01.c +++ b/src/mame/video/bfm_dm01.c @@ -59,7 +59,8 @@ bfmdm01_device::bfmdm01_device(const machine_config &mconfig, const char *tag, d m_control(0), m_xcounter(0), m_busy(0), - m_comdata(0) + m_comdata(0), + m_busy_cb(*this) { for (int i = 0; i < 65; i++) m_segbuffer[i] = 0; @@ -68,31 +69,14 @@ bfmdm01_device::bfmdm01_device(const machine_config &mconfig, const char *tag, d m_scanline[i] = 0; } -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void bfmdm01_device::device_config_complete() -{ - // inherit a copy of the static data - const bfmdm01_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - } -} - //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- void bfmdm01_device::device_start() { + m_busy_cb.resolve_safe(); + save_item(NAME(m_data_avail)); save_item(NAME(m_control)); save_item(NAME(m_xcounter)); @@ -116,8 +100,8 @@ void bfmdm01_device::device_reset() m_control = 0; m_xcounter = 0; m_data_avail = 0; - - m_busy_func(machine(), m_busy); + + m_busy_cb(m_busy); } /////////////////////////////////////////////////////////////////////////// @@ -161,7 +145,7 @@ WRITE8_MEMBER( bfmdm01_device::control_w ) if ( data & 8 ) m_busy = 0; else m_busy = 1; - m_busy_func(machine(), m_busy); + m_busy_cb(m_busy); } } diff --git a/src/mame/video/bfm_dm01.h b/src/mame/video/bfm_dm01.h index dd461b10c3a..0e73dfd19f5 100644 --- a/src/mame/video/bfm_dm01.h +++ b/src/mame/video/bfm_dm01.h @@ -8,17 +8,16 @@ #define DM_BYTESPERROW 9 -struct bfmdm01_interface -{ - void (*m_busy_func)(running_machine &machine, int state); -}; +#define MCFG_BF_DM01_BUSY_CB(_devcb) \ + devcb = &bfmdm01_device::set_busy_callback(*device, DEVCB2_##_devcb); -class bfmdm01_device : public device_t, - public bfmdm01_interface +class bfmdm01_device : public device_t { public: bfmdm01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ~bfmdm01_device() {} + + template static devcb2_base &set_busy_callback(device_t &device, _Object object) { return downcast(device).m_busy_cb.set_callback(object); } DECLARE_READ8_MEMBER( control_r ); DECLARE_WRITE8_MEMBER( control_w ); @@ -32,10 +31,8 @@ public: void writedata(UINT8 data); int busy(void); - protected: // device-level overrides - virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); @@ -49,18 +46,14 @@ private: UINT8 m_scanline[DM_BYTESPERROW]; UINT8 m_comdata; + + devcb2_write_line m_busy_cb; int read_data(void); - }; extern const device_type BF_DM01; ADDRESS_MAP_EXTERN( bfm_dm01_memmap,8 ); - -#define MCFG_DM01_ADD(_tag, _interface) \ - MCFG_DEVICE_ADD(_tag, BF_DM01, 0) \ - MCFG_DEVICE_CONFIG(_interface) - #endif