diff options
author | 2014-04-17 20:03:43 +0000 | |
---|---|---|
committer | 2014-04-17 20:03:43 +0000 | |
commit | 91d6f66ccb674bdaa9b78889b6b66cc228dbd3b5 (patch) | |
tree | a0ef4efcd6b4d892c2bf9b2f0d8c1ba7e7048bee | |
parent | 3c801d80bb475e400686a8abed92e55a138443d1 (diff) |
ttl74123_device: converted to devcb2 (nw)
-rw-r--r-- | src/emu/machine/74123.c | 42 | ||||
-rw-r--r-- | src/emu/machine/74123.h | 59 | ||||
-rw-r--r-- | src/mame/drivers/m10.c | 43 | ||||
-rw-r--r-- | src/mame/drivers/nyny.c | 25 | ||||
-rw-r--r-- | src/mame/drivers/r2dtank.c | 23 | ||||
-rw-r--r-- | src/mame/drivers/spiders.c | 23 |
6 files changed, 89 insertions, 126 deletions
diff --git a/src/emu/machine/74123.c b/src/emu/machine/74123.c index abbee0e4438..869a7eadb28 100644 --- a/src/emu/machine/74123.c +++ b/src/emu/machine/74123.c @@ -27,44 +27,24 @@ const device_type TTL74123 = &device_creator<ttl74123_device>; //------------------------------------------------- ttl74123_device::ttl74123_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, TTL74123, "74123 TTL", tag, owner, clock, "ttl74123", __FILE__) + : device_t(mconfig, TTL74123, "74123 TTL", tag, owner, clock, "ttl74123", __FILE__), + m_connection_type(TTL74123_NOT_GROUNDED_NO_DIODE), + m_res(1.0), + m_cap(1.0), + m_a(0), + m_b(0), + m_clear(0), + m_output_changed_cb(*this) { } - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void ttl74123_device::device_config_complete() -{ - // inherit a copy of the static data - const ttl74123_interface *intf = reinterpret_cast<const ttl74123_interface *>(static_config()); - if (intf != NULL) - *static_cast<ttl74123_interface *>(this) = *intf; - - // or initialize to defaults if none provided - else - { - m_connection_type = TTL74123_NOT_GROUNDED_NO_DIODE; - m_res = 1.0; - m_cap = 1.0; - m_a = 0; - m_b = 0; - m_clear = 0; - } -} - - //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- void ttl74123_device::device_start() { - m_output_changed.resolve(m_output_changed_cb, *this); + m_output_changed_cb.resolve_safe(); m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ttl74123_device::clear_callback),this)); @@ -139,7 +119,7 @@ int ttl74123_device::timer_running() TIMER_CALLBACK_MEMBER( ttl74123_device::output_callback ) { - m_output_changed(0, param); + m_output_changed_cb((offs_t)0, param); } @@ -165,7 +145,7 @@ TIMER_CALLBACK_MEMBER( ttl74123_device::clear_callback ) { int output = timer_running(); - m_output_changed(0, output); + m_output_changed_cb((offs_t)0, output); } //------------------------------------------------- diff --git a/src/emu/machine/74123.h b/src/emu/machine/74123.h index a000b43a516..14967940257 100644 --- a/src/emu/machine/74123.h +++ b/src/emu/machine/74123.h @@ -56,9 +56,26 @@ DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define MCFG_TTL74123_ADD(_tag, _config) \ - MCFG_DEVICE_ADD(_tag, TTL74123, 0) \ - MCFG_DEVICE_CONFIG(_config) +#define MCFG_TTL74123_CONNECTION_TYPE(_ctype) \ + ttl74123_device::set_connection_type(*device, _ctype); + +#define MCFG_TTL74123_RESISTOR_VALUE(_value) \ + ttl74123_device::set_resistor_value(*device, _value); + +#define MCFG_TTL74123_CAPACITOR_VALUE(_value) \ + ttl74123_device::set_capacitor_value(*device, _value); + +#define MCFG_TTL74123_A_PIN_VALUE(_value) \ + ttl74123_device::set_a_pin_value(*device, _value); + +#define MCFG_TTL74123_B_PIN_VALUE(_value) \ + ttl74123_device::set_b_pin_value(*device, _value); + +#define MCFG_TTL74123_CLEAR_PIN_VALUE(_value) \ + ttl74123_device::set_clear_pin_value(*device, _value); + +#define MCFG_TTL74123_OUTPUT_CHANGED_CB(_devcb) \ + devcb = &ttl74123_device::set_output_changed_callback(*device, DEVCB2_##_devcb); /* constants for the different ways the cap/res can be connected. This determines the formula for calculating the pulse width */ @@ -71,31 +88,22 @@ TYPE DEFINITIONS ***************************************************************************/ - -// ======================> ttl74123_interface - -struct ttl74123_interface -{ - int m_connection_type; /* the hook up type - one of the constants above */ - double m_res; /* resistor connected to RCext */ - double m_cap; /* capacitor connected to Cext and RCext */ - int m_a; /* initial/constant value of the A pin */ - int m_b; /* initial/constant value of the B pin */ - int m_clear; /* initial/constant value of the Clear pin */ - devcb_write8 m_output_changed_cb; -}; - - - // ======================> ttl74123_device -class ttl74123_device : public device_t, - public ttl74123_interface +class ttl74123_device : public device_t { public: // construction/destruction ttl74123_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + static void set_connection_type(device_t &device, int type) { downcast<ttl74123_device &>(device).m_connection_type = type; } + static void set_resistor_value(device_t &device, double value) { downcast<ttl74123_device &>(device).m_res = value; } + static void set_capacitor_value(device_t &device, double value) { downcast<ttl74123_device &>(device).m_cap = value; } + static void set_a_pin_value(device_t &device, int value) { downcast<ttl74123_device &>(device).m_a = value; } + static void set_b_pin_value(device_t &device, int value) { downcast<ttl74123_device &>(device).m_b = value; } + static void set_clear_pin_value(device_t &device, int value) { downcast<ttl74123_device &>(device).m_clear = value; } + template<class _Object> static devcb2_base &set_output_changed_callback(device_t &device, _Object object) { return downcast<ttl74123_device &>(device).m_output_changed_cb.set_callback(object); } + DECLARE_WRITE8_MEMBER(a_w); DECLARE_WRITE8_MEMBER(b_w); DECLARE_WRITE8_MEMBER(clear_w); @@ -103,7 +111,6 @@ public: protected: // device-level overrides - virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); virtual void device_post_load() { } @@ -122,7 +129,13 @@ private: void clear(); emu_timer *m_timer; - devcb_resolved_write8 m_output_changed; + int m_connection_type; /* the hook up type - one of the constants above */ + double m_res; /* resistor connected to RCext */ + double m_cap; /* capacitor connected to Cext and RCext */ + int m_a; /* initial/constant value of the A pin */ + int m_b; /* initial/constant value of the B pin */ + int m_clear; /* initial/constant value of the Clear pin */ + devcb2_write8 m_output_changed_cb; }; diff --git a/src/mame/drivers/m10.c b/src/mame/drivers/m10.c index 09dc664eaed..4b126a8b8e3 100644 --- a/src/mame/drivers/m10.c +++ b/src/mame/drivers/m10.c @@ -141,30 +141,6 @@ WRITE8_MEMBER(m10_state::ic8j2_output_changed) m_ic8j1->a_w(space, 0, data); } -static const ttl74123_interface ic8j1_intf = -{ - /* completely illegible */ - TTL74123_NOT_GROUNDED_DIODE, /* the hook up type */ - RES_K(1), /* resistor connected to RCext */ - CAP_U(1), /* capacitor connected to Cext and RCext */ - 1, /* A pin - driven by the CRTC */ - 1, /* B pin - pulled high */ - 1, /* Clear pin - pulled high */ - DEVCB_DRIVER_MEMBER(m10_state,ic8j1_output_changed) -}; - -static const ttl74123_interface ic8j2_intf = -{ - TTL74123_NOT_GROUNDED_DIODE, /* the hook up type */ - /* 10k + 20k variable resistor */ - RES_K(22), /* resistor connected to RCext */ - CAP_U(2.2), /* capacitor connected to Cext and RCext */ - 1, /* A pin - driven by the CRTC */ - 1, /* B pin - pulled high */ - 1, /* Clear pin - pulled high */ - DEVCB_DRIVER_MEMBER(m10_state,ic8j2_output_changed) -}; - /************************************* * * Initialization @@ -859,8 +835,23 @@ static MACHINE_CONFIG_START( m10, m10_state ) /* 74LS123 */ - MCFG_TTL74123_ADD("ic8j1", ic8j1_intf) - MCFG_TTL74123_ADD("ic8j2", ic8j2_intf) + MCFG_DEVICE_ADD("ic8j1", TTL74123, 0) /* completely illegible */ + MCFG_TTL74123_CONNECTION_TYPE(TTL74123_NOT_GROUNDED_DIODE) /* the hook up type */ + MCFG_TTL74123_RESISTOR_VALUE(RES_K(1)) /* resistor connected to RCext */ + MCFG_TTL74123_CAPACITOR_VALUE(CAP_U(1)) /* capacitor connected to Cext and RCext */ + MCFG_TTL74123_A_PIN_VALUE(1) /* A pin - driven by the CRTC */ + MCFG_TTL74123_B_PIN_VALUE(1) /* B pin - pulled high */ + MCFG_TTL74123_CLEAR_PIN_VALUE(1) /* Clear pin - pulled high */ + MCFG_TTL74123_OUTPUT_CHANGED_CB(WRITE8(m10_state, ic8j1_output_changed)) + MCFG_DEVICE_ADD("ic8j2", TTL74123, 0) + MCFG_TTL74123_CONNECTION_TYPE(TTL74123_NOT_GROUNDED_DIODE) /* the hook up type */ + /* 10k + 20k variable resistor */ + MCFG_TTL74123_RESISTOR_VALUE(RES_K(22)) /* resistor connected to RCext */ + MCFG_TTL74123_CAPACITOR_VALUE(CAP_U(2.2)) /* capacitor connected to Cext and RCext */ + MCFG_TTL74123_A_PIN_VALUE(1) /* A pin - driven by the CRTC */ + MCFG_TTL74123_B_PIN_VALUE(1) /* B pin - pulled high */ + MCFG_TTL74123_CLEAR_PIN_VALUE(1) /* Clear pin - pulled high */ + MCFG_TTL74123_OUTPUT_CHANGED_CB(WRITE8(m10_state, ic8j2_output_changed)) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mame/drivers/nyny.c b/src/mame/drivers/nyny.c index 27cc1e49d31..4abe2a18cf0 100644 --- a/src/mame/drivers/nyny.c +++ b/src/mame/drivers/nyny.c @@ -239,20 +239,6 @@ WRITE8_MEMBER(nyny_state::ic48_1_74123_output_changed) m_pia2->ca1_w(data); } - -static const ttl74123_interface ic48_1_config = -{ - TTL74123_GROUNDED, /* the hook up type */ - RES_K(22), /* resistor connected to RCext */ - CAP_U(0.01), /* capacitor connected to Cext and RCext */ - 1, /* A pin - driven by the CRTC */ - 1, /* B pin - pulled high */ - 1, /* Clear pin - pulled high */ - DEVCB_DRIVER_MEMBER(nyny_state,ic48_1_74123_output_changed) -}; - - - /************************************* * * Video system @@ -688,8 +674,15 @@ static MACHINE_CONFIG_START( nyny, nyny_state ) MCFG_MC6845_ADD("crtc", MC6845, "screen", CRTC_CLOCK, mc6845_intf) /* 74LS123 */ - MCFG_TTL74123_ADD("ic48_1", ic48_1_config) - + MCFG_DEVICE_ADD("ic48_1", TTL74123, 0) + MCFG_TTL74123_CONNECTION_TYPE(TTL74123_GROUNDED) /* the hook up type */ + MCFG_TTL74123_RESISTOR_VALUE(RES_K(22)) /* resistor connected to RCext */ + MCFG_TTL74123_CAPACITOR_VALUE(CAP_U(0.01)) /* capacitor connected to Cext and RCext */ + MCFG_TTL74123_A_PIN_VALUE(1) /* A pin - driven by the CRTC */ + MCFG_TTL74123_B_PIN_VALUE(1) /* B pin - pulled high */ + MCFG_TTL74123_CLEAR_PIN_VALUE(1) /* Clear pin - pulled high */ + MCFG_TTL74123_OUTPUT_CHANGED_CB(WRITE8(nyny_state, ic48_1_74123_output_changed)) + MCFG_DEVICE_ADD("pia1", PIA6821, 0) MCFG_PIA_READPA_HANDLER(IOPORT("IN0")) MCFG_PIA_READPB_HANDLER(IOPORT("IN1")) diff --git a/src/mame/drivers/r2dtank.c b/src/mame/drivers/r2dtank.c index 395fd946a3f..c74182aee7a 100644 --- a/src/mame/drivers/r2dtank.c +++ b/src/mame/drivers/r2dtank.c @@ -247,20 +247,6 @@ CUSTOM_INPUT_MEMBER(r2dtank_state::get_ttl74123_output) return m_ttl74123_output; } - -static const ttl74123_interface ttl74123_intf = -{ - TTL74123_GROUNDED, /* the hook up type */ - RES_K(22), /* resistor connected to RCext */ - CAP_U(0.01), /* capacitor connected to Cext and RCext */ - 1, /* A pin - driven by the CRTC */ - 1, /* B pin - pulled high */ - 1, /* Clear pin - pulled high */ - DEVCB_DRIVER_MEMBER(r2dtank_state,ttl74123_output_changed) -}; - - - /************************************* * * Machine start @@ -521,7 +507,14 @@ static MACHINE_CONFIG_START( r2dtank, r2dtank_state ) /* 74LS123 */ - MCFG_TTL74123_ADD("74123", ttl74123_intf) + MCFG_DEVICE_ADD("74123", TTL74123, 0) + MCFG_TTL74123_CONNECTION_TYPE(TTL74123_GROUNDED) /* the hook up type */ + MCFG_TTL74123_RESISTOR_VALUE(RES_K(22)) /* resistor connected to RCext */ + MCFG_TTL74123_CAPACITOR_VALUE(CAP_U(0.01)) /* capacitor connected to Cext and RCext */ + MCFG_TTL74123_A_PIN_VALUE(1) /* A pin - driven by the CRTC */ + MCFG_TTL74123_B_PIN_VALUE(1) /* B pin - pulled high */ + MCFG_TTL74123_CLEAR_PIN_VALUE(1) /* Clear pin - pulled high */ + MCFG_TTL74123_OUTPUT_CHANGED_CB(WRITE8(r2dtank_state, ttl74123_output_changed)) MCFG_DEVICE_ADD("pia_main", PIA6821, 0) MCFG_PIA_READPA_HANDLER(IOPORT("IN0")) diff --git a/src/mame/drivers/spiders.c b/src/mame/drivers/spiders.c index 9371b691d52..36ecdff41fc 100644 --- a/src/mame/drivers/spiders.c +++ b/src/mame/drivers/spiders.c @@ -290,20 +290,6 @@ WRITE8_MEMBER(spiders_state::ic60_74123_output_changed) pia2->ca1_w(data); } - -static const ttl74123_interface ic60_intf = -{ - TTL74123_GROUNDED, /* the hook up type */ - RES_K(22), /* resistor connected to RCext */ - CAP_U(0.01), /* capacitor connected to Cext and RCext */ - 1, /* A pin - driven by the CRTC */ - 1, /* B pin - pulled high */ - 1, /* Clear pin - pulled high */ - DEVCB_DRIVER_MEMBER(spiders_state,ic60_74123_output_changed) -}; - - - /************************************* * * Machine start @@ -645,7 +631,14 @@ static MACHINE_CONFIG_START( spiders, spiders_state ) MCFG_PIA_WRITEPB_HANDLER(WRITE8(spiders_state, spiders_audio_b_w)) MCFG_PIA_IRQA_HANDLER(WRITELINE(spiders_state, audio_cpu_irq)) - MCFG_TTL74123_ADD("ic60", ic60_intf) + MCFG_DEVICE_ADD("ic60", TTL74123, 0) + MCFG_TTL74123_CONNECTION_TYPE(TTL74123_GROUNDED) /* the hook up type */ + MCFG_TTL74123_RESISTOR_VALUE(RES_K(22)) /* resistor connected to RCext */ + MCFG_TTL74123_CAPACITOR_VALUE(CAP_U(0.01)) /* capacitor connected to Cext and RCext */ + MCFG_TTL74123_A_PIN_VALUE(1) /* A pin - driven by the CRTC */ + MCFG_TTL74123_B_PIN_VALUE(1) /* B pin - pulled high */ + MCFG_TTL74123_CLEAR_PIN_VALUE(1) /* Clear pin - pulled high */ + MCFG_TTL74123_OUTPUT_CHANGED_CB(WRITE8(spiders_state, ic60_74123_output_changed)) /* audio hardware */ MCFG_FRAGMENT_ADD(spiders_audio) |