From 43cba38b7e3b19eb11d527dd4f86579df72fa1f8 Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Thu, 6 Sep 2018 15:18:33 +0200 Subject: [PATCH] -latch8: De-MCFG, nw --- src/devices/machine/latch8.h | 86 ++++-------------------------------- src/mame/audio/dkong.cpp | 71 +++++++++++++++-------------- src/mame/drivers/dbox.cpp | 5 ++- 3 files changed, 46 insertions(+), 116 deletions(-) diff --git a/src/devices/machine/latch8.h b/src/devices/machine/latch8.h index ee00fbdc38d..1dac7dcc4c8 100644 --- a/src/devices/machine/latch8.h +++ b/src/devices/machine/latch8.h @@ -18,11 +18,6 @@ #include "sound/discrete.h" - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - class latch8_device : public device_t { public: @@ -73,13 +68,19 @@ public: DECLARE_WRITE8_MEMBER( bit6_w ); DECLARE_WRITE8_MEMBER( bit7_w ); + /* Bit mask specifying bits to be masked *out* */ void set_maskout(uint32_t maskout) { m_maskout = maskout; } + + /* Bit mask specifying bits to be inverted */ void set_xorvalue(uint32_t xorvalue) { m_xorvalue = xorvalue; } + + /* Bit mask specifying bits not needing cpu synchronization. */ void set_nosync(uint32_t nosync) { m_nosync = nosync; } - template devcb_base &set_write_cb(Object &&cb) { return m_write_cb[N].set_callback(std::forward(cb)); } - template devcb_base &set_read_cb(Object &&cb) { return m_read_cb[N].set_callback(std::forward(cb)); } + /* Write bit to discrete node */ template auto write_cb() { return m_write_cb[N].bind(); } + + /* Upon read, replace bits by reading from another device handler */ template auto read_cb() { return m_read_cb[N].bind(); } protected: @@ -109,75 +110,4 @@ private: DECLARE_DEVICE_TYPE(LATCH8, latch8_device) -/*************************************************************************** - DEVICE CONFIGURATION MACROS -***************************************************************************/ - -/* add device */ -#define MCFG_LATCH8_ADD(_tag) \ - MCFG_DEVICE_ADD(_tag, LATCH8, 0) - -/* Bit mask specifying bits to be masked *out* */ -#define MCFG_LATCH8_MASKOUT(_maskout) \ - downcast(*device).set_maskout(_maskout); - -/* Bit mask specifying bits to be inverted */ -#define MCFG_LATCH8_INVERT(_xor) \ - downcast(*device).set_xorvalue(_xor); - -/* Bit mask specifying bits not needing cpu synchronization. */ -#define MCFG_LATCH8_NOSYNC(_nosync) \ - downcast(*device).set_nosync(_nosync); - -/* Write bit to discrete node */ -#define MCFG_LATCH8_WRITE_0(_devcb) \ - downcast(*device).set_write_cb<0>(DEVCB_##_devcb); - -#define MCFG_LATCH8_WRITE_1(_devcb) \ - downcast(*device).set_write_cb<1>(DEVCB_##_devcb); - -#define MCFG_LATCH8_WRITE_2(_devcb) \ - downcast(*device).set_write_cb<2>(DEVCB_##_devcb); - -#define MCFG_LATCH8_WRITE_3(_devcb) \ - downcast(*device).set_write_cb<3>(DEVCB_##_devcb); - -#define MCFG_LATCH8_WRITE_4(_devcb) \ - downcast(*device).set_write_cb<4>(DEVCB_##_devcb); - -#define MCFG_LATCH8_WRITE_5(_devcb) \ - downcast(*device).set_write_cb<5>(DEVCB_##_devcb); - -#define MCFG_LATCH8_WRITE_6(_devcb) \ - downcast(*device).set_write_cb<6>(DEVCB_##_devcb); - -#define MCFG_LATCH8_WRITE_7(_devcb) \ - downcast(*device).set_write_cb<7>(DEVCB_##_devcb); - -/* Upon read, replace bits by reading from another device handler */ -#define MCFG_LATCH8_READ_0(_devcb) \ - downcast(*device).set_read_cb<0>(DEVCB_##_devcb); - -#define MCFG_LATCH8_READ_1(_devcb) \ - downcast(*device).set_read_cb<1>(DEVCB_##_devcb); - -#define MCFG_LATCH8_READ_2(_devcb) \ - downcast(*device).set_read_cb<2>(DEVCB_##_devcb); - -#define MCFG_LATCH8_READ_3(_devcb) \ - downcast(*device).set_read_cb<3>(DEVCB_##_devcb); - -#define MCFG_LATCH8_READ_4(_devcb) \ - downcast(*device).set_read_cb<4>(DEVCB_##_devcb); - -#define MCFG_LATCH8_READ_5(_devcb) \ - downcast(*device).set_read_cb<5>(DEVCB_##_devcb); - -#define MCFG_LATCH8_READ_6(_devcb) \ - downcast(*device).set_read_cb<6>(DEVCB_##_devcb); - -#define MCFG_LATCH8_READ_7(_devcb) \ - downcast(*device).set_read_cb<7>(DEVCB_##_devcb); - - #endif // MAME_MACHINE_LATCH8_H diff --git a/src/mame/audio/dkong.cpp b/src/mame/audio/dkong.cpp index f65b03b5a2d..d79231d629a 100644 --- a/src/mame/audio/dkong.cpp +++ b/src/mame/audio/dkong.cpp @@ -1315,16 +1315,16 @@ void dkong_state::dkong3_sound2_map(address_map &map) MACHINE_CONFIG_START(dkong_state::dkong2b_audio) /* sound latches */ - MCFG_LATCH8_ADD("ls175.3d") /* sound cmd latch */ - MCFG_LATCH8_MASKOUT(0xf0) - MCFG_LATCH8_INVERT(0x0F) + LATCH8(config, m_ls175_3d); /* sound cmd latch */ + m_ls175_3d->set_maskout(0xf0); + m_ls175_3d->set_xorvalue(0x0f); - MCFG_LATCH8_ADD("ls259.6h") - MCFG_LATCH8_WRITE_0(WRITELINE("discrete", discrete_device, write_line)) - MCFG_LATCH8_WRITE_1(WRITELINE("discrete", discrete_device, write_line)) - MCFG_LATCH8_WRITE_2(WRITELINE("discrete", discrete_device, write_line)) - MCFG_LATCH8_WRITE_6(WRITELINE("discrete", discrete_device, write_line)) - MCFG_LATCH8_WRITE_7(WRITELINE("discrete", discrete_device, write_line)) + LATCH8(config, m_dev_6h); + m_dev_6h->write_cb<0>().set("discrete", FUNC(discrete_device::write_line)); + m_dev_6h->write_cb<1>().set("discrete", FUNC(discrete_device::write_line)); + m_dev_6h->write_cb<2>().set("discrete", FUNC(discrete_device::write_line)); + m_dev_6h->write_cb<6>().set("discrete", FUNC(discrete_device::write_line)); + m_dev_6h->write_cb<7>().set("discrete", FUNC(discrete_device::write_line)); /* If P2.Bit7 -> is apparently an external signal decay or other output control * If P2.Bit6 -> activates the external compressed sample ROM (not radarscp1) @@ -1333,10 +1333,10 @@ MACHINE_CONFIG_START(dkong_state::dkong2b_audio) * P2.Bit2-0 -> select the 256 byte bank for external ROM */ - MCFG_LATCH8_ADD( "virtual_p2" ) /* virtual latch for port B */ - MCFG_LATCH8_INVERT( 0x20 ) /* signal is inverted */ - MCFG_LATCH8_READ_5(READLINE("ls259.6h", latch8_device, bit3_r)) - MCFG_LATCH8_WRITE_7(WRITELINE("discrete", discrete_device, write_line)) + LATCH8(config, m_dev_vp2); /* virtual latch for port B */ + m_dev_vp2->set_xorvalue(0x20); /* signal is inverted */ + m_dev_vp2->read_cb<5>().set(m_dev_6h, FUNC(latch8_device::bit3_r)); + m_dev_vp2->write_cb<7>().set("discrete", FUNC(discrete_device::write_line)); MCFG_DEVICE_ADD("soundcpu", MB8884, I8035_CLOCK) MCFG_DEVICE_PROGRAM_MAP(dkong_sound_map) @@ -1372,10 +1372,10 @@ MACHINE_CONFIG_START(dkong_state::radarscp1_audio) MCFG_MCS48_PORT_P2_IN_CB(CONSTANT(0)) /* virtual_p2 is not read -see memory map-, all bits are output bits */ - MCFG_LATCH8_ADD( "virtual_p1" ) /* virtual latch for port A */ - MCFG_LATCH8_INVERT( 0x80 ) /* signal is inverted */ - MCFG_LATCH8_READ_7(READLINE("ls259.6h", latch8_device, bit3_r)) - MCFG_LATCH8_READ_6(READ8("tms", m58817_device, status_r)) + latch8_device &vp1(LATCH8(config, "virtual_p1")); /* virtual latch for port A */ + vp1.set_xorvalue(0x80); /* signal is inverted */ + vp1.read_cb<7>().set(m_dev_6h, FUNC(latch8_device::bit3_r)); + vp1.read_cb<6>().set("tms", FUNC(m58817_device::status_r)); /* tms memory controller */ MCFG_DEVICE_ADD("m58819", M58819, 0) @@ -1392,26 +1392,25 @@ MACHINE_CONFIG_END MACHINE_CONFIG_START(dkong_state::dkongjr_audio) /* sound latches */ - MCFG_LATCH8_ADD("ls174.3d") - MCFG_LATCH8_MASKOUT(0xE0) + LATCH8(config, "ls174.3d").set_maskout(0xe0); - MCFG_LATCH8_ADD( "ls259.6h") - MCFG_LATCH8_WRITE_0(WRITELINE("discrete", discrete_device, write_line)) - MCFG_LATCH8_WRITE_1(WRITELINE("discrete", discrete_device, write_line)) - MCFG_LATCH8_WRITE_2(WRITELINE("discrete", discrete_device, write_line)) - MCFG_LATCH8_WRITE_7(WRITELINE("discrete", discrete_device, write_line)) + LATCH8(config, m_dev_6h); + m_dev_6h->write_cb<0>().set("discrete", FUNC(discrete_device::write_line)); + m_dev_6h->write_cb<1>().set("discrete", FUNC(discrete_device::write_line)); + m_dev_6h->write_cb<2>().set("discrete", FUNC(discrete_device::write_line)); + m_dev_6h->write_cb<7>().set("discrete", FUNC(discrete_device::write_line)); - MCFG_LATCH8_ADD( "ls259.5h") - MCFG_LATCH8_WRITE_1(WRITELINE("discrete", discrete_device, write_line)) + latch8_device &dev_5h(LATCH8(config, "ls259.5h")); + dev_5h.write_cb<1>().set("discrete", FUNC(discrete_device::write_line)); - MCFG_LATCH8_ADD( "ls259.4h") + latch8_device &dev_4h(LATCH8(config, "ls259.4h")); - MCFG_LATCH8_ADD( "virtual_p2" ) /* virtual latch for port B */ - MCFG_LATCH8_INVERT( 0x70 ) /* all signals are inverted */ - MCFG_LATCH8_READ_6(READLINE("ls259.4h", latch8_device, bit1_r)) - MCFG_LATCH8_READ_5(READLINE("ls259.6h", latch8_device, bit3_r)) - MCFG_LATCH8_READ_4(READLINE("ls259.6h", latch8_device, bit6_r)) - MCFG_LATCH8_WRITE_7(WRITELINE("discrete", discrete_device, write_line)) + LATCH8(config, m_dev_vp2); /* virtual latch for port B */ + m_dev_vp2->set_xorvalue(0x70); /* all signals are inverted */ + m_dev_vp2->read_cb<6>().set(dev_4h, FUNC(latch8_device::bit1_r)); + m_dev_vp2->read_cb<5>().set(m_dev_6h, FUNC(latch8_device::bit3_r)); + m_dev_vp2->read_cb<4>().set(m_dev_6h, FUNC(latch8_device::bit6_r)); + m_dev_vp2->write_cb<7>().set("discrete", FUNC(discrete_device::write_line)); MCFG_DEVICE_ADD("soundcpu", MB8884, I8035_CLOCK) MCFG_DEVICE_PROGRAM_MAP(dkong_sound_map) @@ -1437,9 +1436,9 @@ MACHINE_CONFIG_START(dkong_state::dkong3_audio) MCFG_DEVICE_PROGRAM_MAP(dkong3_sound2_map) /* sound latches */ - MCFG_LATCH8_ADD( "latch1") - MCFG_LATCH8_ADD( "latch2") - MCFG_LATCH8_ADD( "latch3") + LATCH8(config, "latch1"); + LATCH8(config, "latch2"); + LATCH8(config, "latch3"); SPEAKER(config, "mono").front_center(); MACHINE_CONFIG_END diff --git a/src/mame/drivers/dbox.cpp b/src/mame/drivers/dbox.cpp index 0959fe35e6e..6b16eed4b63 100644 --- a/src/mame/drivers/dbox.cpp +++ b/src/mame/drivers/dbox.cpp @@ -628,9 +628,10 @@ MACHINE_CONFIG_START(dbox_state::dbox) /* LED Matrix Display */ MCFG_SDA5708_ADD("display") config.set_default_layout(layout_sda5708); + /* IP16 74256 8 bit latch */ - MCFG_LATCH8_ADD("hct259.ip16") - MCFG_LATCH8_WRITE_4(WRITELINE("display", sda5708_device, reset_w)) + LATCH8(config, m_ip16_74259); + m_ip16_74259->write_cb<4>().set("display", FUNC(sda5708_device::reset_w)); MACHINE_CONFIG_END void dbox_state::init_dbox()