From 5645884702f0e61149956d24dd289c5f0e386bab Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Sun, 4 Jul 2021 14:56:00 -0700 Subject: ymfm: Remove dead code in MAME interface. Remove ay8910.h include from ymfm_mame.h and add it to places that still need it. --- src/devices/bus/cbus/pc9801_86.cpp | 2 - src/devices/sound/ymfm_mame.h | 183 ++----------------------------------- src/mame/drivers/multi8.cpp | 1 + src/mame/drivers/spdheat.cpp | 1 + src/mame/drivers/vgmplay.cpp | 4 - src/mame/includes/fm7.h | 1 + 6 files changed, 9 insertions(+), 183 deletions(-) diff --git a/src/devices/bus/cbus/pc9801_86.cpp b/src/devices/bus/cbus/pc9801_86.cpp index 6f4f14c6224..2b8b9c8d1af 100644 --- a/src/devices/bus/cbus/pc9801_86.cpp +++ b/src/devices/bus/cbus/pc9801_86.cpp @@ -61,7 +61,6 @@ void pc9801_86_device::pc9801_86_config(machine_config &config) SPEAKER(config, "rspeaker").front_right(); YM2608(config, m_opna, 7.987_MHz_XTAL); // actually YM2608B m_opna->irq_handler().set(FUNC(pc9801_86_device::sound_irq)); - m_opna->set_flags(AY8910_SINGLE_OUTPUT); m_opna->port_a_read_callback().set(FUNC(pc9801_86_device::opn_porta_r)); //m_opna->port_b_read_callback().set(FUNC(pc8801_state::opn_portb_r)); //m_opna->port_a_write_callback().set(FUNC(pc8801_state::opn_porta_w)); @@ -404,7 +403,6 @@ void pc9801_speakboard_device::device_add_mconfig(machine_config &config) m_opna->add_route(2, "rspeaker", 0.50); YM2608(config, m_opna_slave, 7.987_MHz_XTAL); - m_opna_slave->set_flags(AY8910_SINGLE_OUTPUT); m_opna_slave->add_route(0, "lspeaker", 0.50); m_opna_slave->add_route(0, "rspeaker", 0.50); m_opna_slave->add_route(1, "lspeaker", 0.50); diff --git a/src/devices/sound/ymfm_mame.h b/src/devices/sound/ymfm_mame.h index 27114f7371b..d55be4f35f2 100644 --- a/src/devices/sound/ymfm_mame.h +++ b/src/devices/sound/ymfm_mame.h @@ -8,13 +8,8 @@ #include "ymfm/src/ymfm.h" #include "ymfm/src/ymfm_ssg.h" -#include "ay8910.h" -// set this to 1 to use ymfm's built-in SSG implementation -// set it to 0 to use MAME's ay8910 as the SSG implementation -#define USE_BUILTIN_SSG (1) - // set this to control the output sample rate for SSG-based chips #define SSG_FIDELITY (ymfm::OPN_FIDELITY_MED) @@ -173,18 +168,12 @@ protected: // ======================> ymfm_device_base // this template provides most of the basics used by device objects in MAME -// that wrap ymfm chips; it provides basic read/write functions; however, this -// class is not intended to be used directly -- rather, devices should inherit -// from either ymfm_device_base or ymfm_ssg_device_base, depending on whether -// they include an SSG or not -template +// that wrap ymfm chips; it provides basic read/write functions +template class ymfm_device_base : public ym_generic_device { protected: - // for SSG chips, we only create a subset of outputs here: - // YM2203 is 4 outputs: 1 mono FM + 3 SSG - // YM2608/2610 is 3 outputs: 2 stereo FM + 1 SSG - static constexpr int OUTPUTS = FMOnly ? ((ChipClass::OUTPUTS == 4) ? 1 : 2) : ChipClass::OUTPUTS; + static constexpr int OUTPUTS = ChipClass::OUTPUTS; public: // constructor @@ -303,25 +292,22 @@ protected: }; -// ======================> ymfm_ssg_internal_device_base +// ======================> ymfm_ssg_device_base // this template adds SSG support to the base template, using ymfm's internal // SSG implementation template -class ymfm_ssg_internal_device_base : public ymfm_device_base +class ymfm_ssg_device_base : public ymfm_device_base { using parent = ymfm_device_base; public: // constructor - ymfm_ssg_internal_device_base(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, device_type type) : + ymfm_ssg_device_base(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, device_type type) : ymfm_device_base(mconfig, tag, owner, clock, type) { } - // configuration helpers - void set_flags(int flags) { /* not supported when using internal SSG */ } - protected: // sound overrides virtual void sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) override @@ -338,161 +324,4 @@ protected: } }; - -// ======================> ymfm_ssg_external_device_base - -// this template adds SSG support to the base template, using MAME's YM2149 -// implementation in ay8910.cpp; this is the "classic" way to do it in MAME -// and is more flexible in terms of output handling -template -class ymfm_ssg_external_device_base : public ymfm_device_base, public ymfm::ssg_override -{ - using parent = ymfm_device_base; - -public: - // constructor - ymfm_ssg_external_device_base(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, device_type type) : - ymfm_device_base(mconfig, tag, owner, clock, type), - m_ssg_stream(nullptr), - m_ssg(*this, "ssg"), - m_ssg_flags(((ChipClass::SSG_OUTPUTS == 1) ? AY8910_SINGLE_OUTPUT : 0) | AY8910_LEGACY_OUTPUT) - { - } - - // configuration helpers - void set_flags(int flags) - { - // don't allow some flags to be changed: there is no pin26 in the embedded chip, - // and the number of outputs is configured by the chip itself - flags &= ~(AY8910_SINGLE_OUTPUT | YM2149_PIN26_LOW); - flags |= m_ssg_flags & AY8910_SINGLE_OUTPUT; - m_ssg_flags = flags; - if (m_ssg) - m_ssg->set_flags(m_ssg_flags); - } - -protected: - using parent::m_chip; - using parent::m_io_read; - using parent::m_io_write; - - // SSG overrides - virtual void ssg_reset() override - { - m_ssg->reset(); - } - - virtual uint8_t ssg_read(uint32_t offset) override - { - m_ssg->address_w(offset); - return m_ssg->data_r(); - } - - virtual void ssg_write(uint32_t offset, uint8_t data) override - { - m_ssg->address_w(offset); - m_ssg->data_w(data); - } - - virtual void ssg_prescale_changed() override - { - device_clock_changed(); - } - - // device-level overrides - virtual void device_add_mconfig(machine_config &config) override - { - YM2149(config, m_ssg, device_t::clock()); - m_ssg->set_flags(m_ssg_flags); - - // configure the callbacks to route through our callbacks - m_ssg->port_a_read_callback().set(FUNC(ymfm_ssg_external_device_base::io_reader<0>)); - m_ssg->port_a_write_callback().set(FUNC(ymfm_ssg_external_device_base::io_writer<0>)); - m_ssg->port_b_read_callback().set(FUNC(ymfm_ssg_external_device_base::io_reader<1>)); - m_ssg->port_b_write_callback().set(FUNC(ymfm_ssg_external_device_base::io_writer<1>)); - - // route outputs through us - m_ssg->add_route(0, *this, 1.0, 0); - if (ChipClass::SSG_OUTPUTS > 1) - { - m_ssg->add_route(1, *this, 1.0, 1); - m_ssg->add_route(2, *this, 1.0, 2); - } - } - - // handle device start - virtual void device_start() override - { - // to use the YM2149 in MAME, we allocate our stream with the same number of inputs - // and outputs; in our update handler we'll just forward each output from the - // embedded YM2149 device through our stream to make it look like it used to when - // we were inheriting from ay8910_device - m_ssg_stream = device_sound_interface::stream_alloc(ChipClass::SSG_OUTPUTS, ChipClass::SSG_OUTPUTS, SAMPLE_RATE_INPUT_ADAPTIVE); - - // also tell the chip we want to override reads & writes - m_chip.ssg_override(*this); - - // SSG streams are expected to be first, so call the parent afterwards - parent::device_start(); - } - - // handle clock changed - virtual void device_clock_changed() override - { - parent::device_clock_changed(); - - // derive the effective clock from the computed sample rate - m_ssg->set_unscaled_clock(m_chip.ssg_effective_clock(device_t::clock())); - } - - // sound overrides - virtual void sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) override - { - // if not the SSG stream, pass it along to our parent - if (&stream != m_ssg_stream) - return parent::sound_stream_update(stream, inputs, outputs); - - // just copy the streams from the SSG - for (int index = 0; index < ChipClass::SSG_OUTPUTS; index++) - outputs[index] = inputs[index]; - } - - // internal helper to update all our streams - virtual ChipClass &update_streams() override - { - m_ssg_stream->update(); - return parent::update_streams(); - } - - // I/O reader trampoline - template - uint8_t io_reader() - { - return m_io_read[Index].isnull() ? 0 : m_io_read[Index](0); - } - - // I/O writer trampoline - template - void io_writer(uint8_t data) - { - if (!m_io_write[Index].isnull()) - m_io_write[Index](0, data); - } - - // internal state - sound_stream *m_ssg_stream; // SSG sound stream - required_device m_ssg; // our embedded SSG device - int m_ssg_flags; // SSG flags -}; - - -// now pick the right one -#if USE_BUILTIN_SSG -template -using ymfm_ssg_device_base = ymfm_ssg_internal_device_base; -#else -template -using ymfm_ssg_device_base = ymfm_ssg_external_device_base; -#endif - #endif // MAME_SOUND_YMFM_H diff --git a/src/mame/drivers/multi8.cpp b/src/mame/drivers/multi8.cpp index 9db426d4f28..1db7c5ea2fe 100644 --- a/src/mame/drivers/multi8.cpp +++ b/src/mame/drivers/multi8.cpp @@ -25,6 +25,7 @@ #include "machine/timer.h" #include "machine/upd765.h" #include "imagedev/cassette.h" +#include "sound/ay8910.h" #include "sound/beep.h" #include "sound/ymopn.h" #include "video/mc6845.h" diff --git a/src/mame/drivers/spdheat.cpp b/src/mame/drivers/spdheat.cpp index cf8c800b7f2..a83fa021e52 100644 --- a/src/mame/drivers/spdheat.cpp +++ b/src/mame/drivers/spdheat.cpp @@ -19,6 +19,7 @@ #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "machine/watchdog.h" +#include "sound/ay8910.h" #include "sound/flt_vol.h" #include "sound/ymopn.h" diff --git a/src/mame/drivers/vgmplay.cpp b/src/mame/drivers/vgmplay.cpp index 3a80f633a10..32130823ff5 100644 --- a/src/mame/drivers/vgmplay.cpp +++ b/src/mame/drivers/vgmplay.cpp @@ -2938,10 +2938,6 @@ QUICKLOAD_LOAD_MEMBER(vgmplay_state::load_file) m_ay8910[1]->set_psg_type(vgm_ay8910_type(version >= 0x151 && header_size >= 0x7c ? r8(0x78) : 0)); m_ay8910[0]->set_flags(vgm_ay8910_flags(version >= 0x151 && header_size >= 0x7a ? r8(0x79) : 0)); m_ay8910[1]->set_flags(vgm_ay8910_flags(version >= 0x151 && header_size >= 0x7a ? r8(0x79) : 0)); - m_ym2203[0]->set_flags(vgm_ay8910_flags(version >= 0x151 && header_size >= 0x7b ? r8(0x7a) : 0)); - m_ym2203[1]->set_flags(vgm_ay8910_flags(version >= 0x151 && header_size >= 0x7b ? r8(0x7a) : 0)); - m_ym2608[0]->set_flags(vgm_ay8910_flags(version >= 0x151 && header_size >= 0x7c ? r8(0x7b) : 0)); - m_ym2608[1]->set_flags(vgm_ay8910_flags(version >= 0x151 && header_size >= 0x7c ? r8(0x7b) : 0)); setup_device(*m_dmg[0], 0, CT_GAMEBOY, 0x80, 0x161); setup_device(*m_dmg[1], 1, CT_GAMEBOY, 0x80, 0x161); diff --git a/src/mame/includes/fm7.h b/src/mame/includes/fm7.h index d74e3b9c08a..64fb82393d5 100644 --- a/src/mame/includes/fm7.h +++ b/src/mame/includes/fm7.h @@ -15,6 +15,7 @@ #include "bus/centronics/ctronics.h" #include "imagedev/cassette.h" #include "imagedev/floppy.h" +#include "sound/ay8910.h" #include "sound/beep.h" #include "sound/ymopn.h" #include "machine/wd_fdc.h" -- cgit v1.2.3