Improve netlist initialization in drivers. (nw)

This commit is contained in:
couriersud 2019-04-14 13:36:46 +02:00
parent 209848fefb
commit 993a9ad032
15 changed files with 68 additions and 57 deletions

View File

@ -31,7 +31,7 @@ namespace netlist {
// MAME specific configuration
#define MCFG_NETLIST_SETUP(_setup) \
downcast<netlist_mame_device &>(*device).set_constructor(NETLIST_NAME(_setup));
downcast<netlist_mame_device &>(*device).set_setup_func(NETLIST_NAME(_setup));
#if 0
#define MCFG_NETLIST_SETUP_MEMBER(_obj, _setup) \
@ -112,18 +112,10 @@ public:
// construction/destruction
netlist_mame_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual ~netlist_mame_device();
void set_constructor(void (*setup_func)(netlist::nlparse_t &))
{
m_setup_func = func_type(setup_func);
}
template <typename T, typename F>
void set_constructor(T *obj, F && f)
{
m_setup_func = std::move(std::bind(std::forward<F>(f), obj, std::placeholders::_1));
}
void set_setup_func(func_type &&func) { m_setup_func = std::move(func); }
ATTR_HOT inline netlist::setup_t &setup();
ATTR_HOT inline netlist_mame_t &netlist() { return *m_netlist; }
@ -196,6 +188,19 @@ public:
offs_t genPC() const { return m_genPC; }
netlist_mame_cpu_device & set_source(void (*setup_func)(netlist::nlparse_t &))
{
set_setup_func(func_type(setup_func));
return *this;
}
template <typename T, typename F>
netlist_mame_cpu_device & set_source(T *obj, F && f)
{
set_setup_func(std::move(std::bind(std::forward<F>(f), obj, std::placeholders::_1)));
return *this;
}
protected:
// netlist_mame_device
virtual void nl_register_devices() override;
@ -235,6 +240,20 @@ public:
// construction/destruction
netlist_mame_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
netlist_mame_sound_device & set_source(void (*setup_func)(netlist::nlparse_t &))
{
set_setup_func(func_type(setup_func));
return *this;
}
template <typename T, typename F>
netlist_mame_sound_device & set_source(T *obj, F && f)
{
set_setup_func(std::move(std::bind(std::forward<F>(f), obj, std::placeholders::_1)));
return *this;
}
inline sound_stream *get_stream() { return m_stream; }

View File

@ -40,10 +40,9 @@ WRITE_LINE_MEMBER(cheekyms_audio_device::coin_extra_w) { m_coin_extra->write_li
MACHINE_CONFIG_START(cheekyms_audio_device::device_add_mconfig)
SPEAKER(config, "mono").front_center();
auto &sound_nl(NETLIST_SOUND(config, "sound_nl", 48000));
sound_nl.set_constructor(NETLIST_NAME(cheekyms));
sound_nl.add_route(ALL_OUTPUTS, "mono", 1.0);
NETLIST_SOUND(config, "sound_nl", 48000)
.set_source(NETLIST_NAME(cheekyms))
.add_route(ALL_OUTPUTS, "mono", 1.0);
NETLIST_LOGIC_INPUT(config, "sound_nl:mute", "I_MUTE.IN", 0);
NETLIST_LOGIC_INPUT(config, "sound_nl:cheese", "I_CHEESE.IN", 0);

View File

@ -440,9 +440,9 @@ void m62_audio_device::device_add_mconfig(machine_config &config)
/* NETLIST configuration using internal AY8910 resistor values */
netlist_mame_sound_device &snd_nl(NETLIST_SOUND(config, "snd_nl", 48000));
snd_nl.set_constructor(netlist_kidniki);
snd_nl.add_route(ALL_OUTPUTS, "mono", 1.0);
NETLIST_SOUND(config, "snd_nl", 48000)
.set_source(netlist_kidniki)
.add_route(ALL_OUTPUTS, "mono", 1.0);
NETLIST_LOGIC_INPUT(config, "snd_nl:ibd", "I_BD0.IN", 0);
NETLIST_LOGIC_INPUT(config, "snd_nl:isd", "I_SD0.IN", 0);

View File

@ -661,9 +661,9 @@ void mario_state::mario_audio(machine_config &config)
m_discrete->set_intf(mario_discrete);
m_discrete->add_route(ALL_OUTPUTS, "mono", 1);
#else
netlist_mame_sound_device &snd_nl(NETLIST_SOUND(config, "snd_nl", 48000));
snd_nl.set_constructor(netlist_mario);
snd_nl.add_route(ALL_OUTPUTS, "mono", 1.0);
NETLIST_SOUND(config, "snd_nl", 48000)
.set_source(netlist_mario)
.add_route(ALL_OUTPUTS, "mono", 1.0);
NETLIST_LOGIC_INPUT(config, m_audio_snd0, "SOUND0.IN", 0);
NETLIST_LOGIC_INPUT(config, m_audio_snd1, "SOUND1.IN", 0);

View File

@ -450,11 +450,10 @@ void zac1b11142_audio_device::device_add_mconfig(machine_config &config)
m_speech->irq_cb().set(m_pia_1i, FUNC(pia6821_device::cb1_w));
m_speech->ready_cb().set(m_pia_1i, FUNC(pia6821_device::ca2_w));
m_speech->add_route(0, "sound_nl", 1.0, 6);
//m_speech->add_route(ALL_OUTPUTS, *this, 0.60, AUTO_ALLOC_INPUT, 0);
netlist_mame_sound_device &sound_nl(NETLIST_SOUND(config, "sound_nl", 48000));
sound_nl.set_constructor(netlist_zac1b11142);
sound_nl.add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0);
NETLIST_SOUND(config, "sound_nl", 48000)
.set_source(netlist_zac1b11142)
.add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0);
NETLIST_LOGIC_INPUT(config, "sound_nl:ioa0", "I_IOA0.IN", 0);
NETLIST_LOGIC_INPUT(config, "sound_nl:ioa1", "I_IOA1.IN", 0);

View File

@ -611,9 +611,9 @@ MACHINE_CONFIG_START(_1942_state::_1942)
/* NETLIST configuration using internal AY8910 resistor values */
/* Minimize resampling between ay8910 and netlist */
auto &snd_nl(NETLIST_SOUND(config, "snd_nl", AUDIO_CLOCK / 8 / 2));
snd_nl.set_constructor(NETLIST_NAME(nl_1942));
snd_nl.add_route(ALL_OUTPUTS, "mono", 5.0);
NETLIST_SOUND(config, "snd_nl", AUDIO_CLOCK / 8 / 2)
.set_source(NETLIST_NAME(nl_1942))
.add_route(ALL_OUTPUTS, "mono", 5.0);
NETLIST_STREAM_INPUT(config, "snd_nl:cin0", 0, "R_AY1_1.R");
NETLIST_STREAM_INPUT(config, "snd_nl:cin1", 1, "R_AY1_2.R");
NETLIST_STREAM_INPUT(config, "snd_nl:cin2", 2, "R_AY1_3.R");
@ -653,7 +653,6 @@ void _1942p_state::_1942p(machine_config &config)
screen.set_screen_update(FUNC(_1942p_state::screen_update));
screen.set_palette(m_palette);
/* sound hardware */
SPEAKER(config, "mono").front_center();

View File

@ -328,8 +328,7 @@ uint32_t stuntcyc_state::screen_update_stuntcyc(screen_device &screen, bitmap_rg
void atarikee_state::atarikee(machine_config &config)
{
/* basic machine hardware */
NETLIST_CPU(config, m_maincpu, NETLIST_CLOCK);
m_maincpu->set_constructor(netlist_atarikee);
NETLIST_CPU(config, m_maincpu, NETLIST_CLOCK).set_source(netlist_atarikee);
/* video hardware */
SCREEN(config, "screen", SCREEN_TYPE_RASTER);
@ -346,8 +345,7 @@ void atarikee_state::atarikee(machine_config &config)
MACHINE_CONFIG_START(stuntcyc_state::stuntcyc)
/* basic machine hardware */
NETLIST_CPU(config, m_maincpu, STUNTCYC_NL_CLOCK);
m_maincpu->set_constructor(netlist_stuntcyc);
NETLIST_CPU(config, m_maincpu, STUNTCYC_NL_CLOCK).set_source(netlist_stuntcyc);
//MCFG_NETLIST_ANALOG_OUTPUT("maincpu", "vid0", "VIDEO_OUT", fixedfreq_device, update_vid, "fixfreq")
NETLIST_LOGIC_OUTPUT(config, "maincpu:probe_bit0", 0).set_params("probe_bit0", FUNC(stuntcyc_state::probe_bit0_cb));
@ -373,7 +371,7 @@ MACHINE_CONFIG_END
MACHINE_CONFIG_START(gtrak10_state::gtrak10)
/* basic machine hardware */
NETLIST_CPU(config, "maincpu", NETLIST_CLOCK).set_constructor(netlist_gtrak10);
NETLIST_CPU(config, "maincpu", NETLIST_CLOCK).set_source(netlist_gtrak10);
NETLIST_ANALOG_OUTPUT(config, "maincpu:vid0", 0).set_params("VIDEO_OUT", FUNC(fixedfreq_device::update_composite_monochrome), "fixfreq");

View File

@ -537,9 +537,9 @@ MACHINE_CONFIG_START(cocoloco_state::cocoloco)
/* NETLIST configuration using internal AY8910 resistor values */
auto &snd_nl(NETLIST_SOUND(config, "snd_nl", 48000));
snd_nl.set_constructor(NETLIST_NAME(nl_cocoloco));
snd_nl.add_route(ALL_OUTPUTS, "mono", 1.0);
NETLIST_SOUND(config, "snd_nl", 48000)
.set_source(NETLIST_NAME(nl_cocoloco))
.add_route(ALL_OUTPUTS, "mono", 1.0);
NETLIST_STREAM_INPUT(config, "snd_nl:cin0", 0, "R_AY1_1.R");
NETLIST_STREAM_INPUT(config, "snd_nl:cin1", 1, "R_AY1_2.R");

View File

@ -379,10 +379,9 @@ void tgm_state::tgm(machine_config &config)
/* sound hardware */
SPEAKER(config, "speaker").front_center();
netlist_mame_sound_device &snd_nl(NETLIST_SOUND(config, "snd_nl", 48000));
snd_nl.set_constructor(netlist_nl_gamemachine);
snd_nl.add_route(ALL_OUTPUTS, "speaker", 1.0);
NETLIST_SOUND(config, "snd_nl", 48000)
.set_source(netlist_nl_gamemachine)
.add_route(ALL_OUTPUTS, "speaker", 1.0);
NETLIST_STREAM_OUTPUT(config, "snd_nl:cout0", 0, "SPK1.2").set_mult_offset(-10000.0, 10000.0 * 3.75);

View File

@ -722,7 +722,7 @@ MACHINE_CONFIG_START(hazl1500_state::hazl1500)
AY51013(config, m_uart);
m_uart->write_dav_callback().set("mainint", FUNC(input_merger_device::in_w<0>));
NETLIST_CPU(config, NETLIST_TAG, VIDEOBRD_CLOCK).set_constructor(NETLIST_NAME(hazelvid));
NETLIST_CPU(config, NETLIST_TAG, VIDEOBRD_CLOCK).set_source(NETLIST_NAME(hazelvid));
// First 1K
NETLIST_RAM_POINTER(config, NETLIST_TAG ":u22", "u22.m_RAM");

View File

@ -72,8 +72,8 @@ INPUT_PORTS_END
MACHINE_CONFIG_START(palestra_state::palestra)
NETLIST_CPU(config, m_maincpu, NETLIST_CLOCK);
m_maincpu->set_constructor(netlist_palestra);
NETLIST_CPU(config, m_maincpu, NETLIST_CLOCK)
.set_source(netlist_palestra);
NETLIST_ANALOG_OUTPUT(config, "maincpu:vid0").set_params("videomix", FUNC(fixedfreq_device::update_composite_monochrome), "fixfreq");

View File

@ -470,7 +470,7 @@ MACHINE_CONFIG_START(pong_state::pong)
//MCFG_NETLIST_SETUP(pong)
//MCFG_NETLIST_SETUP_MEMBER(this, &pong_state::NETLIST_NAME(pong))
NETLIST_CPU(config, "maincpu", NETLIST_CLOCK).set_constructor(this, &pong_state::NETLIST_NAME(pong));
NETLIST_CPU(config, "maincpu", NETLIST_CLOCK).set_source(this, &pong_state::NETLIST_NAME(pong));
NETLIST_ANALOG_INPUT(config, "maincpu:vr0", "ic_b9_R.R").set_mult_offset(1.0 / 100.0 * RES_K(50), RES_K(56) );
NETLIST_ANALOG_INPUT(config, "maincpu:vr1", "ic_a9_R.R").set_mult_offset(1.0 / 100.0 * RES_K(50), RES_K(56) );
@ -504,7 +504,7 @@ MACHINE_CONFIG_END
MACHINE_CONFIG_START(breakout_state::breakout)
/* basic machine hardware */
NETLIST_CPU(config, "maincpu", NETLIST_CLOCK).set_constructor(NETLIST_NAME(breakout));
NETLIST_CPU(config, "maincpu", NETLIST_CLOCK).set_source(NETLIST_NAME(breakout));
NETLIST_ANALOG_INPUT(config, "maincpu:pot1", "POTP1.DIAL");
NETLIST_ANALOG_INPUT(config, "maincpu:pot2", "POTP2.DIAL");
@ -568,7 +568,7 @@ MACHINE_CONFIG_END
MACHINE_CONFIG_START(pong_state::pongd)
/* basic machine hardware */
NETLIST_CPU(config, "maincpu", NETLIST_CLOCK).set_constructor(NETLIST_NAME(pongdoubles));
NETLIST_CPU(config, "maincpu", NETLIST_CLOCK).set_source(NETLIST_NAME(pongdoubles));
NETLIST_ANALOG_INPUT(config, "maincpu:pot0", "A10_POT.DIAL");
NETLIST_ANALOG_INPUT(config, "maincpu:pot1", "B10_POT.DIAL");
@ -606,7 +606,7 @@ MACHINE_CONFIG_END
MACHINE_CONFIG_START(rebound_state::rebound)
/* basic machine hardware */
NETLIST_CPU(config, "maincpu", NETLIST_CLOCK).set_constructor(NETLIST_NAME(rebound_schematics));
NETLIST_CPU(config, "maincpu", NETLIST_CLOCK).set_source(NETLIST_NAME(rebound_schematics));
// FIXME: Later
NETLIST_ANALOG_INPUT(config, "maincpu:pot1", "POTP1.DIAL");

View File

@ -628,9 +628,9 @@ void tpp2_state::config(machine_config &config)
/* NETLIST configuration using internal AY8910 resistor values */
netlist_mame_sound_device &snd_nl(NETLIST_SOUND(config, "snd_nl", 48000));
snd_nl.set_constructor(netlist_nl_popeye);
snd_nl.add_route(ALL_OUTPUTS, "mono", 1.0);
NETLIST_SOUND(config, "snd_nl", 48000)
.set_source(netlist_nl_popeye)
.add_route(ALL_OUTPUTS, "mono", 1.0);
NETLIST_STREAM_INPUT(config, "snd_nl:cin0", 0, "R_AY1_1.R");
NETLIST_STREAM_INPUT(config, "snd_nl:cin1", 1, "R_AY1_2.R");

View File

@ -659,8 +659,8 @@ void prodigy_state::prodigy(machine_config &config)
m_via->cb1_handler().set(FUNC(prodigy_state::via_cb1_w));
m_via->cb2_handler().set(FUNC(prodigy_state::via_cb2_w));
NETLIST_CPU(config, m_bcd, XTAL(2'000'000) * 30);
m_bcd->set_constructor(netlist_prodigy);
NETLIST_CPU(config, m_bcd, XTAL(2'000'000) * 30)
.set_source(netlist_prodigy);
NETLIST_LOGIC_INPUT(config, m_cb1); m_cb1->set_params("cb1.IN", 0);
NETLIST_LOGIC_INPUT(config, m_cb2); m_cb2->set_params("cb2.IN", 0);

View File

@ -103,8 +103,7 @@ INPUT_PORTS_END
MACHINE_CONFIG_START(tp1983_state::tp1983)
NETLIST_CPU(config, m_maincpu, NETLIST_CLOCK);
m_maincpu->set_constructor(netlist_tp1983);
NETLIST_CPU(config, m_maincpu, NETLIST_CLOCK).set_source(netlist_tp1983);
NETLIST_ANALOG_OUTPUT(config, "maincpu:vid0").set_params("videomix", FUNC(fixedfreq_device::update_composite_monochrome), "fixfreq");
@ -119,8 +118,7 @@ MACHINE_CONFIG_START(tp1983_state::tp1983)
MACHINE_CONFIG_END
MACHINE_CONFIG_START(tp1985_state::tp1985)
NETLIST_CPU(config, m_maincpu, NETLIST_CLOCK);
m_maincpu->set_constructor(netlist_tp1985);
NETLIST_CPU(config, m_maincpu, NETLIST_CLOCK).set_source(netlist_tp1985);
NETLIST_ANALOG_OUTPUT(config, "maincpu:vid0").set_params("videomix", FUNC(tp1985_state::video_out_cb), "");