From 07d6b33bca2d3dc21c7d8d967b73e71a6cbf93b3 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Wed, 9 Oct 2019 03:19:58 +1100 Subject: [PATCH] mw8080bw: fix duplicate save state, put things back in the order they were (nw) --- src/mame/audio/mw8080bw.cpp | 174 ++++++++++++++++++------------------ src/mame/audio/mw8080bw.h | 40 ++++----- 2 files changed, 107 insertions(+), 107 deletions(-) diff --git a/src/mame/audio/mw8080bw.cpp b/src/mame/audio/mw8080bw.cpp index 70e0b59e2ff..876169de5b3 100644 --- a/src/mame/audio/mw8080bw.cpp +++ b/src/mame/audio/mw8080bw.cpp @@ -103,9 +103,9 @@ static discrete_lfsr_desc const midway_lfsr = DEFINE_DEVICE_TYPE(SEAWOLF_AUDIO, seawolf_audio_device, "seawolf_audio", "Nutting Sea Wolf Audio") DEFINE_DEVICE_TYPE(GUNFIGHT_AUDIO, gunfight_audio_device, "gunfight_audio", "Nutting Gun Fight Audio") DEFINE_DEVICE_TYPE(GMISSILE_AUDIO, gmissile_audio_device, "gmissile_audio", "Midway Guided Missile Audio") +DEFINE_DEVICE_TYPE(M4_AUDIO, m4_audio_device, "m4_audio", "Midway M-4 Audio") DEFINE_DEVICE_TYPE(CLOWNS_AUDIO, clowns_audio_device, "clowns_audio", "Midway Clowns Audio") DEFINE_DEVICE_TYPE(SPCENCTR_AUDIO, spcenctr_audio_device, "spcenctr_audio", "Midway Space Encounters Audio") -DEFINE_DEVICE_TYPE(M4_AUDIO, m4_audio_device, "m4_audio", "Midway M-4 Audio") DEFINE_DEVICE_TYPE(PHANTOM2_AUDIO, phantom2_audio_device, "pantom2_audio", "Midway Phantom 2 Audio") @@ -331,6 +331,91 @@ void gmissile_audio_device::device_start() } +/************************************* + * + * M-4 + * + *************************************/ + +// Noise clock was breadboarded and measured at 3760Hz + +m4_audio_device::m4_audio_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock) : + device_t(mconfig, M4_AUDIO, tag, owner, clock), + m_samples(*this, "samples%u", 1U), + m_p1(0U), + m_p2(0U) +{ +} + +void m4_audio_device::p1_w(u8 data) +{ + u8 const rising(data & ~m_p1); + m_p1 = data; + + // D0 and D1 are not connected + + machine().bookkeeping().coin_counter_w(0, BIT(data, 2)); + + machine().sound().system_enable(BIT(data, 3)); + + if (BIT(rising, 4)) m_samples[0]->start(0, 0); // LEFT PLAYER SHOT sound (goes to left speaker) + if (BIT(rising, 5)) m_samples[1]->start(0, 0); // RIGHT PLAYER SHOT sound (goes to right speaker) + if (BIT(rising, 6)) m_samples[0]->start(1, 1); // LEFT PLAYER EXPLOSION sound via 300K res (goes to left speaker) + if (BIT(rising, 7)) m_samples[1]->start(1, 1); // RIGHT PLAYER EXPLOSION sound via 300K res (goes to right speaker) +} + + +void m4_audio_device::p2_w(u8 data) +{ + u8 const rising(data & ~m_p2); + m_p2 = data; + + if (BIT(rising, 0)) m_samples[0]->start(1, 1); // LEFT PLAYER EXPLOSION sound via 510K res (goes to left speaker) + if (BIT(rising, 1)) m_samples[1]->start(1, 1); // RIGHT PLAYER EXPLOSION sound via 510K res (goes to right speaker) + + // if (data & 0x04) enable LEFT TANK MOTOR sound (goes to left speaker) + + // if (data & 0x08) enable RIGHT TANK MOTOR sound (goes to right speaker) + + // if (data & 0x10) enable sound that is playing while the right plane is flying. Circuit not named on schematics (goes to left speaker) + + // if (data & 0x20) enable sound that is playing while the left plane is flying. Circuit not named on schematics (goes to right speaker) + + // D6 and D7 are not connected +} + +void m4_audio_device::device_add_mconfig(machine_config &config) +{ + static char const *const sample_names[] = { + "*m4", + "1", // missle + "2", // explosion + nullptr }; + + SPEAKER(config, "lspeaker").front_left(); + SPEAKER(config, "rspeaker").front_right(); + + SAMPLES(config, m_samples[0]); + m_samples[0]->set_channels(2); + m_samples[0]->set_samples_names(sample_names); + m_samples[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); + + SAMPLES(config, m_samples[1]); + m_samples[1]->set_channels(2); + m_samples[1]->set_samples_names(sample_names); + m_samples[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); +} + +void m4_audio_device::device_start() +{ + m_p1 = 0U; + m_p2 = 0U; + + save_item(NAME(m_p1)); + save_item(NAME(m_p2)); +} + + /************************************* * * Clowns @@ -568,7 +653,7 @@ void clowns_audio_device::device_start() m_p1 = 0U; m_p2 = 0U; - save_item(NAME(m_p2)); + save_item(NAME(m_p1)); save_item(NAME(m_p2)); } @@ -1128,91 +1213,6 @@ TIMER_CALLBACK_MEMBER(spcenctr_audio_device::strobe_callback) } -/************************************* - * - * M-4 - * - *************************************/ - -// Noise clock was breadboarded and measured at 3760Hz - -m4_audio_device::m4_audio_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock) : - device_t(mconfig, M4_AUDIO, tag, owner, clock), - m_samples(*this, "samples%u", 1U), - m_p1(0U), - m_p2(0U) -{ -} - -void m4_audio_device::p1_w(u8 data) -{ - u8 const rising(data & ~m_p1); - m_p1 = data; - - // D0 and D1 are not connected - - machine().bookkeeping().coin_counter_w(0, BIT(data, 2)); - - machine().sound().system_enable(BIT(data, 3)); - - if (BIT(rising, 4)) m_samples[0]->start(0, 0); // LEFT PLAYER SHOT sound (goes to left speaker) - if (BIT(rising, 5)) m_samples[1]->start(0, 0); // RIGHT PLAYER SHOT sound (goes to right speaker) - if (BIT(rising, 6)) m_samples[0]->start(1, 1); // LEFT PLAYER EXPLOSION sound via 300K res (goes to left speaker) - if (BIT(rising, 7)) m_samples[1]->start(1, 1); // RIGHT PLAYER EXPLOSION sound via 300K res (goes to right speaker) -} - - -void m4_audio_device::p2_w(u8 data) -{ - u8 const rising(data & ~m_p2); - m_p2 = data; - - if (BIT(rising, 0)) m_samples[0]->start(1, 1); // LEFT PLAYER EXPLOSION sound via 510K res (goes to left speaker) - if (BIT(rising, 1)) m_samples[1]->start(1, 1); // RIGHT PLAYER EXPLOSION sound via 510K res (goes to right speaker) - - // if (data & 0x04) enable LEFT TANK MOTOR sound (goes to left speaker) - - // if (data & 0x08) enable RIGHT TANK MOTOR sound (goes to right speaker) - - // if (data & 0x10) enable sound that is playing while the right plane is flying. Circuit not named on schematics (goes to left speaker) - - // if (data & 0x20) enable sound that is playing while the left plane is flying. Circuit not named on schematics (goes to right speaker) - - // D6 and D7 are not connected -} - -void m4_audio_device::device_add_mconfig(machine_config &config) -{ - static char const *const sample_names[] = { - "*m4", - "1", // missle - "2", // explosion - nullptr }; - - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - - SAMPLES(config, m_samples[0]); - m_samples[0]->set_channels(2); - m_samples[0]->set_samples_names(sample_names); - m_samples[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - - SAMPLES(config, m_samples[1]); - m_samples[1]->set_channels(2); - m_samples[1]->set_samples_names(sample_names); - m_samples[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); -} - -void m4_audio_device::device_start() -{ - m_p1 = 0U; - m_p2 = 0U; - - save_item(NAME(m_p1)); - save_item(NAME(m_p2)); -} - - /************************************* * * Phantom II diff --git a/src/mame/audio/mw8080bw.h b/src/mame/audio/mw8080bw.h index c65ee8b2a9d..59f1610fe0d 100644 --- a/src/mame/audio/mw8080bw.h +++ b/src/mame/audio/mw8080bw.h @@ -71,6 +71,25 @@ private: }; +class m4_audio_device : public device_t +{ +public: + m4_audio_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock = 0); + + void p1_w(u8 data); + void p2_w(u8 data); + +protected: + virtual void device_add_mconfig(machine_config &config) override; + virtual void device_start() override; + +private: + required_device_array m_samples; + u8 m_p1; + u8 m_p2; +}; + + class clowns_audio_device : public device_t { public: @@ -119,25 +138,6 @@ private: }; -class m4_audio_device : public device_t -{ -public: - m4_audio_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock = 0); - - void p1_w(u8 data); - void p2_w(u8 data); - -protected: - virtual void device_add_mconfig(machine_config &config) override; - virtual void device_start() override; - -private: - required_device_array m_samples; - u8 m_p1; - u8 m_p2; -}; - - class phantom2_audio_device : public device_t { public: @@ -161,9 +161,9 @@ private: DECLARE_DEVICE_TYPE(SEAWOLF_AUDIO, seawolf_audio_device) DECLARE_DEVICE_TYPE(GUNFIGHT_AUDIO, gunfight_audio_device) DECLARE_DEVICE_TYPE(GMISSILE_AUDIO, gmissile_audio_device) +DECLARE_DEVICE_TYPE(M4_AUDIO, m4_audio_device) DECLARE_DEVICE_TYPE(CLOWNS_AUDIO, clowns_audio_device) DECLARE_DEVICE_TYPE(SPCENCTR_AUDIO, spcenctr_audio_device) -DECLARE_DEVICE_TYPE(M4_AUDIO, m4_audio_device) DECLARE_DEVICE_TYPE(PHANTOM2_AUDIO, phantom2_audio_device) #endif // MAME_AUDIO_MW8080BW_H