summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-02-05 12:41:58 +1100
committer Vas Crabb <vas@vastheman.com>2020-02-05 12:41:58 +1100
commit601034c8d71b64262b257e47797f3a315ed16fcb (patch)
tree12aa75b291e4de3b5399e6fabb39e035adf79bc8
parente204d878f8dd2a222821a81f6773e69529ce83e8 (diff)
devcb.cpp: syntactic sugar for constructing/resolving arrays of callbacks (nw)
Saves a lot of typing { *this }, { *this }... Could be applied in more places, I just did a few devices to demonstrate it.
-rw-r--r--src/devices/machine/am9517a.cpp25
-rw-r--r--src/devices/machine/am9517a.h10
-rw-r--r--src/devices/machine/latch8.cpp4
-rw-r--r--src/devices/machine/latch8.h4
-rw-r--r--src/devices/machine/mc14411.cpp2
-rw-r--r--src/devices/machine/mc14411.h2
-rw-r--r--src/devices/machine/mos6530n.cpp20
-rw-r--r--src/devices/machine/mos6530n.h8
-rw-r--r--src/devices/machine/phi.cpp14
-rw-r--r--src/devices/machine/phi.h2
-rw-r--r--src/devices/machine/saa1043.cpp9
-rw-r--r--src/devices/machine/saa1043.h2
-rw-r--r--src/devices/machine/scc2698b.cpp21
-rw-r--r--src/devices/machine/scc2698b.h8
-rw-r--r--src/devices/machine/te7750.cpp10
-rw-r--r--src/devices/machine/te7750.h4
-rw-r--r--src/devices/machine/tms9901.cpp5
-rw-r--r--src/devices/machine/tms9901.h2
-rw-r--r--src/devices/machine/tms9914.cpp14
-rw-r--r--src/devices/machine/tms9914.h2
-rw-r--r--src/devices/machine/z80scc.cpp35
-rw-r--r--src/devices/machine/z80scc.h14
-rw-r--r--src/devices/machine/z80sio.cpp35
-rw-r--r--src/devices/machine/z80sio.h18
-rw-r--r--src/devices/sound/astrocde.cpp10
-rw-r--r--src/devices/sound/astrocde.h4
-rw-r--r--src/devices/sound/huc6230.cpp5
-rw-r--r--src/devices/sound/huc6230.h2
-rw-r--r--src/devices/sound/pokey.cpp5
-rw-r--r--src/devices/sound/pokey.h2
-rw-r--r--src/emu/devcb.h54
-rw-r--r--src/emu/devdelegate.h5
32 files changed, 179 insertions, 178 deletions
diff --git a/src/devices/machine/am9517a.cpp b/src/devices/machine/am9517a.cpp
index 5036f8e9dab..b2751e1a06f 100644
--- a/src/devices/machine/am9517a.cpp
+++ b/src/devices/machine/am9517a.cpp
@@ -429,9 +429,9 @@ am9517a_device::am9517a_device(const machine_config &mconfig, device_type type,
m_out_eop_cb(*this),
m_in_memr_cb(*this),
m_out_memw_cb(*this),
- m_in_ior_cb{ { *this }, { *this }, { *this }, { *this } },
- m_out_iow_cb{ { *this }, { *this }, { *this }, { *this } },
- m_out_dack_cb{ { *this }, { *this }, { *this }, { *this } }
+ m_in_ior_cb(*this),
+ m_out_iow_cb(*this),
+ m_out_dack_cb(*this)
{
}
@@ -445,8 +445,8 @@ v5x_dmau_device::v5x_dmau_device(const machine_config &mconfig, const char *tag,
: am9517a_device(mconfig, V5X_DMAU, tag, owner, clock)
, m_in_mem16r_cb(*this)
, m_out_mem16w_cb(*this)
- , m_in_io16r_cb{ { *this },{ *this },{ *this },{ *this } }
- , m_out_io16w_cb{ { *this },{ *this },{ *this },{ *this } }
+ , m_in_io16r_cb(*this)
+ , m_out_io16w_cb(*this)
{
}
@@ -470,12 +470,9 @@ void am9517a_device::device_start()
m_out_eop_cb.resolve_safe();
m_in_memr_cb.resolve_safe(0);
m_out_memw_cb.resolve_safe();
- for(auto &cb : m_in_ior_cb)
- cb.resolve_safe(0);
- for(auto &cb : m_out_iow_cb)
- cb.resolve_safe();
- for(auto &cb : m_out_dack_cb)
- cb.resolve_safe();
+ m_in_ior_cb.resolve_all_safe(0);
+ m_out_iow_cb.resolve_all_safe();
+ m_out_dack_cb.resolve_all_safe();
for(auto &elem : m_channel)
{
@@ -1000,10 +997,8 @@ void v5x_dmau_device::device_start()
m_in_mem16r_cb.resolve_safe(0);
m_out_mem16w_cb.resolve_safe();
- for (auto &cb : m_in_io16r_cb)
- cb.resolve_safe(0);
- for (auto &cb : m_out_io16w_cb)
- cb.resolve_safe();
+ m_in_io16r_cb.resolve_all_safe(0);
+ m_out_io16w_cb.resolve_all_safe();
m_selected_channel = 0;
m_base = 0;
diff --git a/src/devices/machine/am9517a.h b/src/devices/machine/am9517a.h
index 224170701ac..54afb057dae 100644
--- a/src/devices/machine/am9517a.h
+++ b/src/devices/machine/am9517a.h
@@ -131,9 +131,9 @@ private:
devcb_read8 m_in_memr_cb;
devcb_write8 m_out_memw_cb;
- devcb_read8 m_in_ior_cb[4];
- devcb_write8 m_out_iow_cb[4];
- devcb_write_line m_out_dack_cb[4];
+ devcb_read8::array<4> m_in_ior_cb;
+ devcb_write8::array<4> m_out_iow_cb;
+ devcb_write_line::array<4> m_out_dack_cb;
};
@@ -165,8 +165,8 @@ protected:
// 16 bit transfer callbacks
devcb_read16 m_in_mem16r_cb;
devcb_write16 m_out_mem16w_cb;
- devcb_read16 m_in_io16r_cb[4];
- devcb_write16 m_out_io16w_cb[4];
+ devcb_read16::array<4> m_in_io16r_cb;
+ devcb_write16::array<4> m_out_io16w_cb;
int m_selected_channel;
int m_base;
diff --git a/src/devices/machine/latch8.cpp b/src/devices/machine/latch8.cpp
index 7b10bed2df6..4ca9782405a 100644
--- a/src/devices/machine/latch8.cpp
+++ b/src/devices/machine/latch8.cpp
@@ -109,8 +109,8 @@ latch8_device::latch8_device(const machine_config &mconfig, const char *tag, dev
, m_maskout(0)
, m_xorvalue(0)
, m_nosync(0)
- , m_write_cb{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}}
- , m_read_cb{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}}
+ , m_write_cb(*this)
+ , m_read_cb(*this)
{
}
diff --git a/src/devices/machine/latch8.h b/src/devices/machine/latch8.h
index 1dac7dcc4c8..d940c84cfa7 100644
--- a/src/devices/machine/latch8.h
+++ b/src/devices/machine/latch8.h
@@ -104,8 +104,8 @@ private:
uint32_t m_xorvalue; /* after mask */
uint32_t m_nosync;
- devcb_write_line m_write_cb[8];
- devcb_read_line m_read_cb[8];
+ devcb_write_line::array<8> m_write_cb;
+ devcb_read_line::array<8> m_read_cb;
};
DECLARE_DEVICE_TYPE(LATCH8, latch8_device)
diff --git a/src/devices/machine/mc14411.cpp b/src/devices/machine/mc14411.cpp
index d8ce720a0f3..cab994ca89c 100644
--- a/src/devices/machine/mc14411.cpp
+++ b/src/devices/machine/mc14411.cpp
@@ -102,7 +102,7 @@ mc14411_device::mc14411_device(const machine_config &mconfig, const char *tag, d
mc14411_device::mc14411_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, type, tag, owner, clock)
- , m_out_fx_cbs{*this, *this, *this, *this, *this, *this, *this, *this, *this, *this, *this, *this, *this, *this, *this, *this }
+ , m_out_fx_cbs(*this)
, m_divider(0)
, m_reset(CLEAR_LINE)
{
diff --git a/src/devices/machine/mc14411.h b/src/devices/machine/mc14411.h
index 6012e679d03..6755df220e2 100644
--- a/src/devices/machine/mc14411.h
+++ b/src/devices/machine/mc14411.h
@@ -92,7 +92,7 @@ private:
static const int s_counter_divider[16];
static const int s_divider_select[4];
- devcb_write_line m_out_fx_cbs[16];
+ devcb_write_line::array<16> m_out_fx_cbs;
uint32_t m_divider; // main divider to use, 0-3 column index into counter_divider
uint32_t m_reset; // Reset line state
diff --git a/src/devices/machine/mos6530n.cpp b/src/devices/machine/mos6530n.cpp
index 23ec8c408fb..88fce0bfc44 100644
--- a/src/devices/machine/mos6530n.cpp
+++ b/src/devices/machine/mos6530n.cpp
@@ -127,10 +127,10 @@ mos6530_device_base::mos6530_device_base(const machine_config &mconfig, device_t
m_out8_pa_cb(*this),
m_in8_pb_cb(*this),
m_out8_pb_cb(*this),
- m_in_pa_cb{ { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this } },
- m_out_pa_cb{ { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this } },
- m_in_pb_cb{ { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this } },
- m_out_pb_cb{ { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this } },
+ m_in_pa_cb(*this),
+ m_out_pa_cb(*this),
+ m_in_pb_cb(*this),
+ m_out_pb_cb(*this),
m_pa_in(0xff),
m_pa_out(0),
m_pa_ddr(0),
@@ -178,14 +178,10 @@ void mos6530_device_base::device_start()
m_out8_pa_cb.resolve();
m_in8_pb_cb.resolve();
m_out8_pb_cb.resolve();
- for (auto &cb : m_in_pa_cb)
- cb.resolve();
- for (auto &cb : m_out_pa_cb)
- cb.resolve_safe();
- for (auto &cb : m_in_pb_cb)
- cb.resolve();
- for (auto &cb : m_out_pb_cb)
- cb.resolve_safe();
+ m_in_pa_cb.resolve_all();
+ m_out_pa_cb.resolve_all_safe();
+ m_in_pb_cb.resolve_all();
+ m_out_pb_cb.resolve_all_safe();
// allocate timer
t_gen = timer_alloc(0);
diff --git a/src/devices/machine/mos6530n.h b/src/devices/machine/mos6530n.h
index 5de5bba9338..ca0ca1f1aa7 100644
--- a/src/devices/machine/mos6530n.h
+++ b/src/devices/machine/mos6530n.h
@@ -145,10 +145,10 @@ protected:
devcb_write8 m_out8_pa_cb;
devcb_read8 m_in8_pb_cb;
devcb_write8 m_out8_pb_cb;
- devcb_read_line m_in_pa_cb[8];
- devcb_write_line m_out_pa_cb[8];
- devcb_read_line m_in_pb_cb[8];
- devcb_write_line m_out_pb_cb[8];
+ devcb_read_line::array<8> m_in_pa_cb;
+ devcb_write_line::array<8> m_out_pa_cb;
+ devcb_read_line::array<8> m_in_pb_cb;
+ devcb_write_line::array<8> m_out_pb_cb;
uint8_t m_pa_in;
uint8_t m_pa_out;
diff --git a/src/devices/machine/phi.cpp b/src/devices/machine/phi.cpp
index 65610b06faa..4e1e4ea8c6b 100644
--- a/src/devices/machine/phi.cpp
+++ b/src/devices/machine/phi.cpp
@@ -191,15 +191,7 @@ phi_device::phi_device(const machine_config &mconfig, device_type type, const ch
: device_t(mconfig, type, tag, owner, clock),
m_dio_read_func(*this),
m_dio_write_func(*this),
- m_signal_wr_fns{
- devcb_write_line(*this),
- devcb_write_line(*this),
- devcb_write_line(*this),
- devcb_write_line(*this),
- devcb_write_line(*this),
- devcb_write_line(*this),
- devcb_write_line(*this),
- devcb_write_line(*this) },
+ m_signal_wr_fns(*this),
m_int_write_func(*this),
m_dmarq_write_func(*this),
m_sys_cntrl_read_func(*this)
@@ -384,9 +376,7 @@ void phi_device::device_start()
m_dio_read_func.resolve_safe(0xff);
m_dio_write_func.resolve_safe();
- for (auto& f : m_signal_wr_fns) {
- f.resolve_safe();
- }
+ m_signal_wr_fns.resolve_all_safe();
m_int_write_func.resolve_safe();
m_dmarq_write_func.resolve_safe();
m_sys_cntrl_read_func.resolve_safe(0);
diff --git a/src/devices/machine/phi.h b/src/devices/machine/phi.h
index 5e9eb0782e3..33def593315 100644
--- a/src/devices/machine/phi.h
+++ b/src/devices/machine/phi.h
@@ -103,7 +103,7 @@ private:
devcb_read8 m_dio_read_func;
devcb_write8 m_dio_write_func;
- devcb_write_line m_signal_wr_fns[ PHI_488_SIGNAL_COUNT ];
+ devcb_write_line::array<PHI_488_SIGNAL_COUNT> m_signal_wr_fns;
devcb_write_line m_int_write_func;
devcb_write_line m_dmarq_write_func;
devcb_read_line m_sys_cntrl_read_func;
diff --git a/src/devices/machine/saa1043.cpp b/src/devices/machine/saa1043.cpp
index 48b1f168639..7e480ddcf4b 100644
--- a/src/devices/machine/saa1043.cpp
+++ b/src/devices/machine/saa1043.cpp
@@ -12,17 +12,18 @@
#include "emu.h"
#include "saa1043.h"
+#include <algorithm>
+
+
DEFINE_DEVICE_TYPE(SAA1043, saa1043_device, "saa1043", "Philips SAA1043")
/*static*/ const uint32_t saa1043_device::s_line_counts[4] = { 624, 624, 524, 524 };
saa1043_device::saa1043_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, SAA1043, tag, owner, clock)
- , m_outputs{ *this, *this, *this, *this, *this, *this,
- *this, *this, *this, *this, *this, *this,
- *this, *this, *this, *this, *this, *this }
+ , m_outputs(*this)
{
- memset(m_outputs_hooked, 0, sizeof(bool) * OUT_COUNT);
+ std::fill(std::begin(m_outputs_hooked), std::end(m_outputs_hooked), false);
}
void saa1043_device::device_start()
diff --git a/src/devices/machine/saa1043.h b/src/devices/machine/saa1043.h
index e601ebcf197..32591d58300 100644
--- a/src/devices/machine/saa1043.h
+++ b/src/devices/machine/saa1043.h
@@ -104,7 +104,7 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
private:
- devcb_write_line m_outputs[OUT_COUNT];
+ devcb_write_line::array<OUT_COUNT> m_outputs;
bool m_outputs_hooked[OUT_COUNT];
emu_timer *m_timers[OUT_COUNT];
signal_type m_type;
diff --git a/src/devices/machine/scc2698b.cpp b/src/devices/machine/scc2698b.cpp
index 8a362e26d45..5be0dc9b08c 100644
--- a/src/devices/machine/scc2698b.cpp
+++ b/src/devices/machine/scc2698b.cpp
@@ -359,11 +359,10 @@ scc2698b_device::scc2698b_device(const machine_config &mconfig, const char *tag,
write_intr_B(*this),
write_intr_C(*this),
write_intr_D(*this),
- write_tx{ { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this} },
- write_mpp1{ { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this } },
- write_mpp2{ { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this } },
- write_mpo{ { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this }, { *this } }
-
+ write_tx(*this),
+ write_mpp1(*this),
+ write_mpp2(*this),
+ write_mpo(*this)
{
}
@@ -383,14 +382,10 @@ void scc2698b_device::device_start()
write_intr_C.resolve_safe();
write_intr_D.resolve_safe();
- for (auto &cb : write_tx)
- cb.resolve_safe();
- for (auto &cb : write_mpp1)
- cb.resolve_safe();
- for (auto &cb : write_mpp2)
- cb.resolve_safe();
- for (auto &cb : write_mpo)
- cb.resolve_safe();
+ write_tx.resolve_all_safe();
+ write_mpp1.resolve_all_safe();
+ write_mpp2.resolve_all_safe();
+ write_mpo.resolve_all_safe();
for (int i = 0; i < 8; i++)
{
diff --git a/src/devices/machine/scc2698b.h b/src/devices/machine/scc2698b.h
index fe045aee1b6..f693c6df50a 100644
--- a/src/devices/machine/scc2698b.h
+++ b/src/devices/machine/scc2698b.h
@@ -121,10 +121,10 @@ protected:
virtual void device_add_mconfig(machine_config &config) override;
devcb_write_line write_intr_A, write_intr_B, write_intr_C, write_intr_D;
- devcb_write_line write_tx[8];
- devcb_write_line write_mpp1[8];
- devcb_write_line write_mpp2[8];
- devcb_write_line write_mpo[8];
+ devcb_write_line::array<8> write_tx;
+ devcb_write_line::array<8> write_mpp1;
+ devcb_write_line::array<8> write_mpp2;
+ devcb_write_line::array<8> write_mpo;
scc2698b_channel* get_channel(int port);
diff --git a/src/devices/machine/te7750.cpp b/src/devices/machine/te7750.cpp
index a59c25ea8a1..2fa70bebf56 100644
--- a/src/devices/machine/te7750.cpp
+++ b/src/devices/machine/te7750.cpp
@@ -189,8 +189,8 @@ DEFINE_DEVICE_TYPE(TE7752, te7752_device, "te7752", "TE7752 Super I/O Expander")
te7750_device::te7750_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, type, tag, owner, clock)
- , m_input_cb{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}}
- , m_output_cb{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}}
+ , m_input_cb(*this)
+ , m_output_cb(*this)
, m_ios_cb(*this)
{
std::fill(std::begin(m_data_dir), std::end(m_data_dir), 0xff);
@@ -217,10 +217,8 @@ te7752_device::te7752_device(const machine_config &mconfig, const char *tag, dev
void te7750_device::device_start()
{
// resolve port callbacks
- for (auto &cb : m_input_cb)
- cb.resolve_safe(0xff);
- for (auto &cb : m_output_cb)
- cb.resolve_safe();
+ m_input_cb.resolve_all_safe(0xff);
+ m_output_cb.resolve_all_safe();
// resolve IOS (assume soft mode unless specified)
m_ios_cb.resolve_safe(0);
diff --git a/src/devices/machine/te7750.h b/src/devices/machine/te7750.h
index 4310a6e2bf5..03a4df68366 100644
--- a/src/devices/machine/te7750.h
+++ b/src/devices/machine/te7750.h
@@ -62,8 +62,8 @@ private:
void set_ios();
// input/output callbacks
- devcb_read8 m_input_cb[9];
- devcb_write8 m_output_cb[9];
+ devcb_read8::array<9> m_input_cb;
+ devcb_write8::array<9> m_output_cb;
// mode callback
devcb_read8 m_ios_cb;
diff --git a/src/devices/machine/tms9901.cpp b/src/devices/machine/tms9901.cpp
index b5ec6278865..fe38f72fe22 100644
--- a/src/devices/machine/tms9901.cpp
+++ b/src/devices/machine/tms9901.cpp
@@ -172,7 +172,7 @@ tms9901_device::tms9901_device(const machine_config &mconfig, const char *tag, d
m_clockdiv(0),
m_timer_int_pending(false),
m_read_port(*this),
- m_write_p{{*this},{*this},{*this},{*this},{*this},{*this},{*this},{*this},{*this},{*this},{*this},{*this},{*this},{*this},{*this},{*this}},
+ m_write_p(*this),
m_interrupt(*this)
{
}
@@ -599,8 +599,7 @@ void tms9901_device::device_start()
}
m_read_port.resolve();
- for (auto &cb : m_write_p)
- cb.resolve_safe();
+ m_write_p.resolve_all_safe();
m_interrupt.resolve();
m_clock_register = 0;
diff --git a/src/devices/machine/tms9901.h b/src/devices/machine/tms9901.h
index a962ceb28f7..5e838fcad10 100644
--- a/src/devices/machine/tms9901.h
+++ b/src/devices/machine/tms9901.h
@@ -163,7 +163,7 @@ private:
devcb_read8 m_read_port;
// I/O lines, used for output. When used as inputs, the levels are delivered via the m_read_block
- devcb_write_line m_write_p[16];
+ devcb_write_line::array<16> m_write_p;
// INTREQ pin
devcb_write_line m_interrupt;
diff --git a/src/devices/machine/tms9914.cpp b/src/devices/machine/tms9914.cpp
index eef06895493..421bee35590 100644
--- a/src/devices/machine/tms9914.cpp
+++ b/src/devices/machine/tms9914.cpp
@@ -177,15 +177,7 @@ tms9914_device::tms9914_device(const machine_config &mconfig, const char *tag, d
: device_t(mconfig , TMS9914 , tag , owner , clock),
m_dio_read_func(*this),
m_dio_write_func(*this),
- m_signal_wr_fns{
- devcb_write_line(*this),
- devcb_write_line(*this),
- devcb_write_line(*this),
- devcb_write_line(*this),
- devcb_write_line(*this),
- devcb_write_line(*this),
- devcb_write_line(*this),
- devcb_write_line(*this) },
+ m_signal_wr_fns(*this),
m_int_write_func(*this),
m_accrq_write_func(*this)
{
@@ -481,9 +473,7 @@ void tms9914_device::device_start()
m_dio_read_func.resolve_safe(0xff);
m_dio_write_func.resolve_safe();
- for (auto& f : m_signal_wr_fns) {
- f.resolve_safe();
- }
+ m_signal_wr_fns.resolve_all_safe();
m_int_write_func.resolve_safe();
m_accrq_write_func.resolve_safe();
diff --git a/src/devices/machine/tms9914.h b/src/devices/machine/tms9914.h
index 9fda5aa2ebb..39a6c8d5632 100644
--- a/src/devices/machine/tms9914.h
+++ b/src/devices/machine/tms9914.h
@@ -98,7 +98,7 @@ private:
devcb_read8 m_dio_read_func;
devcb_write8 m_dio_write_func;
- devcb_write_line m_signal_wr_fns[ IEEE_488_SIGNAL_COUNT ];
+ devcb_write_line::array<IEEE_488_SIGNAL_COUNT> m_signal_wr_fns;
devcb_write_line m_int_write_func;
devcb_write_line m_accrq_write_func;
bool m_int_line;
diff --git a/src/devices/machine/z80scc.cpp b/src/devices/machine/z80scc.cpp
index 9dfe0e462ff..31807925847 100644
--- a/src/devices/machine/z80scc.cpp
+++ b/src/devices/machine/z80scc.cpp
@@ -428,13 +428,13 @@ z80scc_device::z80scc_device(const machine_config &mconfig, device_type type, co
m_txca(0),
m_rxcb(0),
m_txcb(0),
- m_out_txd_cb{ { *this }, { *this } },
- m_out_dtr_cb{ { *this }, { *this } },
- m_out_rts_cb{ { *this }, { *this } },
- m_out_wreq_cb{ { *this }, { *this } },
- m_out_sync_cb{ { *this }, { *this } },
- m_out_rxdrq_cb{ { *this }, { *this } },
- m_out_txdrq_cb{ { *this }, { *this } },
+ m_out_txd_cb(*this),
+ m_out_dtr_cb(*this),
+ m_out_rts_cb(*this),
+ m_out_wreq_cb(*this),
+ m_out_sync_cb(*this),
+ m_out_rxdrq_cb(*this),
+ m_out_txdrq_cb(*this),
m_out_int_cb(*this),
m_out_int_state(CLEAR_LINE),
m_variant(variant),
@@ -493,20 +493,13 @@ void z80scc_device::device_resolve_objects()
LOG("%s\n", FUNCNAME);
// resolve callbacks
- m_out_txd_cb[CHANNEL_A].resolve_safe();
- m_out_dtr_cb[CHANNEL_A].resolve_safe();
- m_out_rts_cb[CHANNEL_A].resolve_safe();
- m_out_wreq_cb[CHANNEL_A].resolve_safe();
- m_out_sync_cb[CHANNEL_A].resolve_safe();
- m_out_txd_cb[CHANNEL_B].resolve_safe();
- m_out_dtr_cb[CHANNEL_B].resolve_safe();
- m_out_rts_cb[CHANNEL_B].resolve_safe();
- m_out_wreq_cb[CHANNEL_B].resolve_safe();
- m_out_sync_cb[CHANNEL_B].resolve_safe();
- m_out_rxdrq_cb[CHANNEL_A].resolve_safe();
- m_out_txdrq_cb[CHANNEL_A].resolve_safe();
- m_out_rxdrq_cb[CHANNEL_B].resolve_safe();
- m_out_txdrq_cb[CHANNEL_B].resolve_safe();
+ m_out_txd_cb.resolve_all_safe();
+ m_out_dtr_cb.resolve_all_safe();
+ m_out_rts_cb.resolve_all_safe();
+ m_out_wreq_cb.resolve_all_safe();
+ m_out_sync_cb.resolve_all_safe();
+ m_out_rxdrq_cb.resolve_all_safe();
+ m_out_txdrq_cb.resolve_all_safe();
m_out_int_cb.resolve_safe();
}
diff --git a/src/devices/machine/z80scc.h b/src/devices/machine/z80scc.h
index a02477b6544..4a44c3c9c2c 100644
--- a/src/devices/machine/z80scc.h
+++ b/src/devices/machine/z80scc.h
@@ -453,13 +453,13 @@ protected:
int m_txcb;
// internal state
- devcb_write_line m_out_txd_cb[2];
- devcb_write_line m_out_dtr_cb[2];
- devcb_write_line m_out_rts_cb[2];
- devcb_write_line m_out_wreq_cb[2];
- devcb_write_line m_out_sync_cb[2];
- devcb_write_line m_out_rxdrq_cb[2];
- devcb_write_line m_out_txdrq_cb[2];
+ devcb_write_line::array<2> m_out_txd_cb;
+ devcb_write_line::array<2> m_out_dtr_cb;
+ devcb_write_line::array<2> m_out_rts_cb;
+ devcb_write_line::array<2> m_out_wreq_cb;
+ devcb_write_line::array<2> m_out_sync_cb;
+ devcb_write_line::array<2> m_out_rxdrq_cb;
+ devcb_write_line::array<2> m_out_txdrq_cb;
devcb_write_line m_out_int_cb;
diff --git a/src/devices/machine/z80sio.cpp b/src/devices/machine/z80sio.cpp
index fe3e3dc016b..ae8b39a8195 100644
--- a/src/devices/machine/z80sio.cpp
+++ b/src/devices/machine/z80sio.cpp
@@ -384,14 +384,14 @@ z80sio_device::z80sio_device(const machine_config &mconfig, device_type type, co
m_chanA(*this, CHANA_TAG),
m_chanB(*this, CHANB_TAG),
m_hostcpu(*this, finder_base::DUMMY_TAG),
- m_out_txd_cb{ { *this }, { *this } },
- m_out_dtr_cb{ { *this }, { *this } },
- m_out_rts_cb{ { *this }, { *this } },
- m_out_wrdy_cb{ { *this }, { *this } },
- m_out_sync_cb{ { *this }, { *this } },
+ m_out_txd_cb(*this),
+ m_out_dtr_cb(*this),
+ m_out_rts_cb(*this),
+ m_out_wrdy_cb(*this),
+ m_out_sync_cb(*this),
m_out_int_cb(*this),
- m_out_rxdrq_cb{ { *this }, { *this } },
- m_out_txdrq_cb{ { *this }, { *this } }
+ m_out_rxdrq_cb(*this),
+ m_out_txdrq_cb(*this)
{
for (auto & elem : m_int_state)
elem = 0;
@@ -439,21 +439,14 @@ void z80sio_device::device_resolve_objects()
LOG("%s\n", FUNCNAME);
// resolve callbacks
- m_out_txd_cb[CHANNEL_A].resolve_safe();
- m_out_dtr_cb[CHANNEL_A].resolve_safe();
- m_out_rts_cb[CHANNEL_A].resolve_safe();
- m_out_wrdy_cb[CHANNEL_A].resolve_safe();
- m_out_sync_cb[CHANNEL_A].resolve_safe();
- m_out_txd_cb[CHANNEL_B].resolve_safe();
- m_out_dtr_cb[CHANNEL_B].resolve_safe();
- m_out_rts_cb[CHANNEL_B].resolve_safe();
- m_out_wrdy_cb[CHANNEL_B].resolve_safe();
- m_out_sync_cb[CHANNEL_B].resolve_safe();
+ m_out_txd_cb.resolve_all_safe();
+ m_out_dtr_cb.resolve_all_safe();
+ m_out_rts_cb.resolve_all_safe();
+ m_out_wrdy_cb.resolve_all_safe();
+ m_out_sync_cb.resolve_all_safe();
m_out_int_cb.resolve_safe();
- m_out_rxdrq_cb[CHANNEL_A].resolve_safe();
- m_out_txdrq_cb[CHANNEL_A].resolve_safe();
- m_out_rxdrq_cb[CHANNEL_B].resolve_safe();
- m_out_txdrq_cb[CHANNEL_B].resolve_safe();
+ m_out_rxdrq_cb.resolve_all_safe();
+ m_out_txdrq_cb.resolve_all_safe();
}
//-------------------------------------------------
diff --git a/src/devices/machine/z80sio.h b/src/devices/machine/z80sio.h
index 0f73998aa05..1c0b9affd4a 100644
--- a/src/devices/machine/z80sio.h
+++ b/src/devices/machine/z80sio.h
@@ -474,15 +474,15 @@ protected:
optional_device<cpu_device> m_hostcpu;
// internal state
- devcb_write_line m_out_txd_cb[2];
- devcb_write_line m_out_dtr_cb[2];
- devcb_write_line m_out_rts_cb[2];
- devcb_write_line m_out_wrdy_cb[2];
- devcb_write_line m_out_sync_cb[2];
-
- devcb_write_line m_out_int_cb;
- devcb_write_line m_out_rxdrq_cb[2];
- devcb_write_line m_out_txdrq_cb[2];
+ devcb_write_line::array<2> m_out_txd_cb;
+ devcb_write_line::array<2> m_out_dtr_cb;
+ devcb_write_line::array<2> m_out_rts_cb;
+ devcb_write_line::array<2> m_out_wrdy_cb;
+ devcb_write_line::array<2> m_out_sync_cb;
+
+ devcb_write_line m_out_int_cb;
+ devcb_write_line::array<2> m_out_rxdrq_cb;
+ devcb_write_line::array<2> m_out_txdrq_cb;
int m_int_state[8]; // interrupt state
int m_int_source[8]; // interrupt source
diff --git a/src/devices/sound/astrocde.cpp b/src/devices/sound/astrocde.cpp
index 8a99a9f3988..797d5920176 100644
--- a/src/devices/sound/astrocde.cpp
+++ b/src/devices/sound/astrocde.cpp
@@ -84,8 +84,8 @@ astrocade_io_device::astrocade_io_device(const machine_config &mconfig, const ch
, m_c_count(0)
, m_c_state(0)
, m_si_callback(*this)
- , m_so_callback{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}}
- , m_pots{{*this}, {*this}, {*this}, {*this}}
+ , m_so_callback(*this)
+ , m_pots(*this)
{
memset(m_reg, 0, sizeof(uint8_t)*8);
memset(m_bitswap, 0, sizeof(uint8_t)*256);
@@ -101,10 +101,8 @@ astrocade_io_device::astrocade_io_device(const machine_config &mconfig, const ch
void astrocade_io_device::device_resolve_objects()
{
m_si_callback.resolve_safe(0);
- for (auto &cb : m_so_callback)
- cb.resolve_safe();
- for (auto &pot : m_pots)
- pot.resolve_safe(0);
+ m_so_callback.resolve_all_safe();
+ m_pots.resolve_all_safe(0);
}
diff --git a/src/devices/sound/astrocde.h b/src/devices/sound/astrocde.h
index eddde3a12bb..398a3648d3d 100644
--- a/src/devices/sound/astrocde.h
+++ b/src/devices/sound/astrocde.h
@@ -89,8 +89,8 @@ private:
uint8_t m_bitswap[256]; /* bitswap table */
devcb_read8 m_si_callback;
- devcb_write8 m_so_callback[8];
- devcb_read8 m_pots[4];
+ devcb_write8::array<8> m_so_callback;
+ devcb_read8::array<4> m_pots;
};
DECLARE_DEVICE_TYPE(ASTROCADE_IO, astrocade_io_device)
diff --git a/src/devices/sound/huc6230.cpp b/src/devices/sound/huc6230.cpp
index 5537f3ffea6..57e3b77ab26 100644
--- a/src/devices/sound/huc6230.cpp
+++ b/src/devices/sound/huc6230.cpp
@@ -147,7 +147,7 @@ huc6230_device::huc6230_device(const machine_config &mconfig, const char *tag, d
, m_adpcm_freq(0)
, m_pcm_lvol(0)
, m_pcm_rvol(0)
- , m_adpcm_update_cb{{*this}, {*this}}
+ , m_adpcm_update_cb(*this)
, m_vca_cb(*this)
{
}
@@ -168,8 +168,7 @@ void huc6230_device::device_add_mconfig(machine_config &config)
void huc6230_device::device_start()
{
- for (auto &cb : m_adpcm_update_cb)
- cb.resolve_safe(0);
+ m_adpcm_update_cb.resolve_all_safe(0);
m_vca_cb.resolve_safe();
diff --git a/src/devices/sound/huc6230.h b/src/devices/sound/huc6230.h
index d94c59fcb26..a8ccfcf12ae 100644
--- a/src/devices/sound/huc6230.h
+++ b/src/devices/sound/huc6230.h
@@ -55,7 +55,7 @@ private:
TIMER_CALLBACK_MEMBER(adpcm_timer);
- devcb_read8 m_adpcm_update_cb[2];
+ devcb_read8::array<2> m_adpcm_update_cb;
devcb_write8 m_vca_cb;
};
diff --git a/src/devices/sound/pokey.cpp b/src/devices/sound/pokey.cpp
index d157745fca5..43e8d6f3398 100644
--- a/src/devices/sound/pokey.cpp
+++ b/src/devices/sound/pokey.cpp
@@ -174,7 +174,7 @@ pokey_device::pokey_device(const machine_config &mconfig, const char *tag, devic
device_state_interface(mconfig, *this),
m_icount(0),
m_stream(nullptr),
- m_pot_r_cb{ {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this} },
+ m_pot_r_cb(*this),
m_allpot_r_cb(*this),
m_serin_r_cb(*this),
m_serout_w_cb(*this),
@@ -251,8 +251,7 @@ void pokey_device::device_start()
std::fill(std::begin(m_clock_cnt), std::end(m_clock_cnt), 0);
std::fill(std::begin(m_POTx), std::end(m_POTx), 0);
- for (devcb_read8 &cb : m_pot_r_cb)
- cb.resolve();
+ m_pot_r_cb.resolve_all();
m_allpot_r_cb.resolve();
m_serin_r_cb.resolve();
m_serout_w_cb.resolve_safe();
diff --git a/src/devices/sound/pokey.h b/src/devices/sound/pokey.h
index 4a373b2d1f7..75a62df413f 100644
--- a/src/devices/sound/pokey.h
+++ b/src/devices/sound/pokey.h
@@ -278,7 +278,7 @@ private:
uint32_t m_p9; /* poly9 index */
uint32_t m_p17; /* poly17 index */
- devcb_read8 m_pot_r_cb[8];
+ devcb_read8::array<8> m_pot_r_cb;
devcb_read8 m_allpot_r_cb;
devcb_read8 m_serin_r_cb;
devcb_write8 m_serout_w_cb;
diff --git a/src/emu/devcb.h b/src/emu/devcb.h
index 321d0831fe1..0ed064fbf12 100644
--- a/src/emu/devcb.h
+++ b/src/emu/devcb.h
@@ -12,6 +12,7 @@
#pragma once
+#include <array>
#include <cassert>
#include <functional>
#include <memory>
@@ -171,6 +172,33 @@ protected:
bool m_inherited_mask = true;
};
+ /// \brief Callback array helper
+ ///
+ /// Simplifies construction and resolution of arrays of callbacks.
+ template <typename T, unsigned Count>
+ class array : public std::array<T, Count>
+ {
+ private:
+ template <unsigned... V>
+ array(device_t &owner, std::integer_sequence<unsigned, V...> const &)
+ : std::array<T, Count>{{ { make_one<V>(owner) }... }}
+ {
+ }
+
+ template <unsigned N> device_t &make_one(device_t &owner) { return owner; }
+
+ public:
+ using std::array<T, Count>::array;
+
+ array(device_t &owner) : array(owner, std::make_integer_sequence<unsigned, Count>()) { }
+
+ void resolve_all()
+ {
+ for (T &elem : *this)
+ elem.resolve();
+ }
+ };
+
devcb_base(device_t &owner);
~devcb_base();
@@ -845,6 +873,19 @@ private:
std::vector<typename creator::ptr> m_creators;
public:
+ template <unsigned Count>
+ class array : public devcb_read_base::array<devcb_read<Result, DefaultMask>, Count>
+ {
+ public:
+ using devcb_read_base::array<devcb_read<Result, DefaultMask>, Count>::array;
+
+ void resolve_all_safe(Result dflt)
+ {
+ for (devcb_read<Result, DefaultMask> &elem : *this)
+ elem.resolve_safe(dflt);
+ }
+ };
+
devcb_read(device_t &owner);
binder bind();
@@ -2310,6 +2351,19 @@ private:
std::vector<typename creator::ptr> m_creators;
public:
+ template <unsigned Count>
+ class array : public devcb_write_base::array<devcb_write<Input, DefaultMask>, Count>
+ {
+ public:
+ using devcb_write_base::array<devcb_write<Input, DefaultMask>, Count>::array;
+
+ void resolve_all_safe()
+ {
+ for (devcb_write<Input, DefaultMask> &elem : *this)
+ elem.resolve_safe();
+ }
+ };
+
devcb_write(device_t &owner);
binder bind();
diff --git a/src/emu/devdelegate.h b/src/emu/devdelegate.h
index bbb94930d43..e6ae4fbb86e 100644
--- a/src/emu/devdelegate.h
+++ b/src/emu/devdelegate.h
@@ -243,11 +243,12 @@ class device_delegate_array : public std::array<device_delegate<Signature>, Coun
private:
template <unsigned... V>
device_delegate_array(device_t &owner, std::integer_sequence<unsigned, V...> const &)
- : std::array<device_delegate<Signature>, Count>{ make_one<V>(owner)... }
+ : std::array<device_delegate<Signature>, Count>{{ make_one<V>(owner)... }}
{
}
- template <unsigned N> device_delegate<Signature> make_one(device_t &owner)
+ template <unsigned N>
+ device_delegate<Signature> make_one(device_t &owner)
{
return device_delegate<Signature>(owner);
}