From bd25c625599d568e980ab8c907936494dbe74025 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Tue, 6 Oct 2020 01:41:07 -0700 Subject: [PATCH] cinemat: Remove redundant code, move speakers to game drivers --- src/mame/audio/cinemat.cpp | 74 +++++++++++------------------- src/mame/audio/cinemat.h | 13 +----- src/mame/drivers/cinemat.cpp | 89 ++++++++++++++++++++++++++++++------ 3 files changed, 102 insertions(+), 74 deletions(-) diff --git a/src/mame/audio/cinemat.cpp b/src/mame/audio/cinemat.cpp index 4b9168aa949..3d9cb981888 100644 --- a/src/mame/audio/cinemat.cpp +++ b/src/mame/audio/cinemat.cpp @@ -45,16 +45,17 @@ * *************************************/ -cinemat_audio_device_base::cinemat_audio_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 inputs_mask, void (*netlist)(netlist::nlparse_t &), double output_scale) - : device_t(mconfig, type, tag, owner, clock) - , m_out_input(*this, "sound_nl:out_%u", 0) - , m_inputs_mask(inputs_mask) - , m_netlist(netlist) - , m_output_scale(output_scale) +cinemat_audio_device_base::cinemat_audio_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 inputs_mask, void (*netlist)(netlist::nlparse_t &), double output_scale) : + device_t(mconfig, type, tag, owner, clock), + device_mixer_interface(mconfig, *this), + m_out_input(*this, "sound_nl:out_%u", 0), + m_inputs_mask(inputs_mask), + m_netlist(netlist), + m_output_scale(output_scale) { } -void cinemat_audio_device_base::configure_latch_inputs(ls259_device &latch, u8 mask) +cinemat_audio_device_base &cinemat_audio_device_base::configure_latch_inputs(ls259_device &latch, u8 mask) { if (mask == 0) mask = m_inputs_mask; @@ -70,48 +71,34 @@ void cinemat_audio_device_base::configure_latch_inputs(ls259_device &latch, u8 m latch.q_out_cb<4>().set(write_line_delegate(*this, FUNC(cinemat_audio_device_base::sound_w<4>))); if (BIT(mask, 7)) latch.q_out_cb<7>().set(write_line_delegate(*this, FUNC(cinemat_audio_device_base::sound_w<7>))); + return *this; } void cinemat_audio_device_base::device_add_mconfig(machine_config &config) { - SPEAKER(config, "mono").front_center(); + NETLIST_SOUND(config, "sound_nl", 48000) + .set_source(m_netlist) + .add_route(ALL_OUTPUTS, *this, 1.0); - if (m_netlist != nullptr) - { - NETLIST_SOUND(config, "sound_nl", 48000) - .set_source(m_netlist) - .add_route(ALL_OUTPUTS, "mono", 1.0); + if ((m_inputs_mask & 0x01) != 0) + NETLIST_LOGIC_INPUT(config, m_out_input[0], "I_OUT_0.IN", 0); + if ((m_inputs_mask & 0x02) != 0) + NETLIST_LOGIC_INPUT(config, m_out_input[1], "I_OUT_1.IN", 0); + if ((m_inputs_mask & 0x04) != 0) + NETLIST_LOGIC_INPUT(config, m_out_input[2], "I_OUT_2.IN", 0); + if ((m_inputs_mask & 0x08) != 0) + NETLIST_LOGIC_INPUT(config, m_out_input[3], "I_OUT_3.IN", 0); + if ((m_inputs_mask & 0x10) != 0) + NETLIST_LOGIC_INPUT(config, m_out_input[4], "I_OUT_4.IN", 0); + if ((m_inputs_mask & 0x80) != 0) + NETLIST_LOGIC_INPUT(config, m_out_input[7], "I_OUT_7.IN", 0); - if ((m_inputs_mask & 0x01) != 0) - NETLIST_LOGIC_INPUT(config, m_out_input[0], "I_OUT_0.IN", 0); - if ((m_inputs_mask & 0x02) != 0) - NETLIST_LOGIC_INPUT(config, m_out_input[1], "I_OUT_1.IN", 0); - if ((m_inputs_mask & 0x04) != 0) - NETLIST_LOGIC_INPUT(config, m_out_input[2], "I_OUT_2.IN", 0); - if ((m_inputs_mask & 0x08) != 0) - NETLIST_LOGIC_INPUT(config, m_out_input[3], "I_OUT_3.IN", 0); - if ((m_inputs_mask & 0x10) != 0) - NETLIST_LOGIC_INPUT(config, m_out_input[4], "I_OUT_4.IN", 0); - if ((m_inputs_mask & 0x80) != 0) - NETLIST_LOGIC_INPUT(config, m_out_input[7], "I_OUT_7.IN", 0); - - NETLIST_STREAM_OUTPUT(config, "sound_nl:cout0", 0, "OUTPUT").set_mult_offset(m_output_scale, 0.0); - } + NETLIST_STREAM_OUTPUT(config, "sound_nl:cout0", 0, "OUTPUT").set_mult_offset(m_output_scale, 0.0); } void cinemat_audio_device_base::device_start() { -#if ENABLE_NETLIST_LOGGING - m_logfile = fopen("cinemat.csv", "w"); -#endif -} - -void cinemat_audio_device_base::device_stop() -{ -#if ENABLE_NETLIST_LOGGING - if (m_logfile != nullptr) - fclose(m_logfile); -#endif + save_item(NAME(m_inputs)); } void cinemat_audio_device_base::input_set(int bit, int state) @@ -119,18 +106,9 @@ void cinemat_audio_device_base::input_set(int bit, int state) u8 oldvals = m_inputs; m_inputs = (m_inputs & ~(1 << bit)) | ((state & 1) << bit); if (oldvals != m_inputs) - { -#if ENABLE_NETLIST_LOGGING - attotime time = machine().scheduler().time(); - for (int bit = 0; bit < 8; bit++) - if (((m_inputs_mask >> bit) & 1) != 0) - if ((((m_inputs ^ oldvals) >> bit) & 1) != 0) - fprintf(m_logfile, "%s,I_OUT_%u.IN,%d\n", time.as_string(), bit, (m_inputs >> bit) & 1); -#endif for (int index = 0; index < 8; index++) if (m_out_input[index] != nullptr) m_out_input[index]->write_line(BIT(m_inputs, index)); - } } diff --git a/src/mame/audio/cinemat.h b/src/mame/audio/cinemat.h index 6859154850d..dd7791668f9 100644 --- a/src/mame/audio/cinemat.h +++ b/src/mame/audio/cinemat.h @@ -9,21 +9,17 @@ #include "machine/netlist.h" #include "netlist/nl_setup.h" -// log to cinemat.csv for nltool playback/analysis -#define ENABLE_NETLIST_LOGGING (0) - -class cinemat_audio_device_base : public device_t +class cinemat_audio_device_base : public device_t, public device_mixer_interface { public: - void configure_latch_inputs(ls259_device &latch, u8 mask = 0); + cinemat_audio_device_base &configure_latch_inputs(ls259_device &latch, u8 mask = 0); protected: cinemat_audio_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 inputs_mask, void (*netlist)(netlist::nlparse_t &), double output_scale); virtual void device_add_mconfig(machine_config &config) override; virtual void device_start() override; - virtual void device_stop() override; template DECLARE_WRITE_LINE_MEMBER(sound_w) { input_set(_Index, state); } void input_set(int bit, int state); @@ -35,11 +31,6 @@ private: u8 const m_inputs_mask; void (*const m_netlist)(netlist::nlparse_t &); double const m_output_scale; - -#if ENABLE_NETLIST_LOGGING - FILE *m_logfile = nullptr; -#endif - }; diff --git a/src/mame/drivers/cinemat.cpp b/src/mame/drivers/cinemat.cpp index cdf9babd997..863ef360e7f 100644 --- a/src/mame/drivers/cinemat.cpp +++ b/src/mame/drivers/cinemat.cpp @@ -31,6 +31,7 @@ #include "emu.h" #include "includes/cinemat.h" +#include "speaker.h" #include "armora.lh" #include "barrier.lh" @@ -1069,14 +1070,23 @@ void cinemat_state::cinemat_jmi_32k(machine_config &config) void cinemat_state::spacewar(machine_config &config) { cinemat_nojmi_4k(config); - SPACE_WARS_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + SPACE_WARS_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); + m_screen->set_screen_update(FUNC(cinemat_state::screen_update_spacewar)); } void cinemat_state::barrier(machine_config &config) { cinemat_jmi_4k(config); - BARRIER_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + BARRIER_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); } WRITE_LINE_MEMBER(cinemat_state::speedfrk_start_led_w) @@ -1088,78 +1098,127 @@ WRITE_LINE_MEMBER(cinemat_state::speedfrk_start_led_w) void cinemat_state::speedfrk(machine_config &config) { cinemat_nojmi_8k(config); - SPEED_FREAK_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + SPEED_FREAK_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); // m_outlatch->q_out_cb<1>().set(FUNC(cinemat_state::speedfrk_start_led_w)); } void cinemat_state::starhawk(machine_config &config) { cinemat_jmi_4k(config); - STAR_HAWK_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + STAR_HAWK_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); } void cinemat_16level_state::sundance(machine_config &config) { cinemat_jmi_8k(config); - SUNDANCE_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + SUNDANCE_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); } void cinemat_state::tailg(machine_config &config) { cinemat_nojmi_8k(config); - TAIL_GUNNER_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + TAIL_GUNNER_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); m_outlatch->q_out_cb<7>().set(FUNC(cinemat_state::mux_select_w)); } void cinemat_state::warrior(machine_config &config) { cinemat_jmi_8k(config); - WARRIOR_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + WARRIOR_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); } void cinemat_state::armora(machine_config &config) { cinemat_jmi_16k(config); - ARMOR_ATTACK_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + ARMOR_ATTACK_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); } void cinemat_state::ripoff(machine_config &config) { cinemat_jmi_8k(config); - RIPOFF_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + RIPOFF_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); } void cinemat_state::starcas(machine_config &config) { cinemat_jmi_8k(config); - STAR_CASTLE_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + STAR_CASTLE_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); } void cinemat_64level_state::solarq(machine_config &config) { cinemat_jmi_16k(config); - SOLAR_QUEST_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + SOLAR_QUEST_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); } void cinemat_color_state::boxingb(machine_config &config) { cinemat_jmi_32k(config); - BOXING_BUGS_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); - m_screen->set_visarea(0, 1024, 0, 788); + + SPEAKER(config, "mono").front_center(); + BOXING_BUGS_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); m_outlatch->q_out_cb<7>().append(FUNC(cinemat_state::mux_select_w)); + + m_screen->set_visarea(0, 1024, 0, 788); } void cinemat_state::wotw(machine_config &config) { cinemat_jmi_16k(config); m_screen->set_visarea(0, 1120, 0, 767); - WAR_OF_THE_WORLDS_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + WAR_OF_THE_WORLDS_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); } void cinemat_color_state::wotwc(machine_config &config) { cinemat_jmi_16k(config); - WAR_OF_THE_WORLDS_AUDIO(config, "soundboard", 0).configure_latch_inputs(*m_outlatch); + + SPEAKER(config, "mono").front_center(); + WAR_OF_THE_WORLDS_AUDIO(config, "soundboard", 0) + .configure_latch_inputs(*m_outlatch) + .add_route(ALL_OUTPUTS, "mono", 1.0); } void demon_state::demon(machine_config &config)