diff options
Diffstat (limited to 'src/devices/bus/ti8x/tispeaker.cpp')
-rw-r--r-- | src/devices/bus/ti8x/tispeaker.cpp | 149 |
1 files changed, 82 insertions, 67 deletions
diff --git a/src/devices/bus/ti8x/tispeaker.cpp b/src/devices/bus/ti8x/tispeaker.cpp index ed9ec36a5ec..36ab34caae9 100644 --- a/src/devices/bus/ti8x/tispeaker.cpp +++ b/src/devices/bus/ti8x/tispeaker.cpp @@ -4,99 +4,114 @@ #include "emu.h" #include "tispeaker.h" -#include "speaker.h" - +#include "sound/spkrdev.h" -DEFINE_DEVICE_TYPE_NS(TI8X_SPEAKER_STEREO, bus::ti8x, stereo_speaker_device, "ti8x_stspkr", "TI-8x Speaker (Stereo)") -DEFINE_DEVICE_TYPE_NS(TI8X_SPEAKER_MONO, bus::ti8x, mono_speaker_device, "ti8x_mspkr", "TI-8x Speaker (Mono)") +#include "speaker.h" -namespace bus { namespace ti8x { +namespace { -stereo_speaker_device::stereo_speaker_device( - machine_config const &mconfig, - char const *tag, - device_t *owner, - uint32_t clock) - : device_t(mconfig, TI8X_SPEAKER_STEREO, tag, owner, clock) - , device_ti8x_link_port_interface(mconfig, *this) - , m_left_speaker(*this, "lspkr") - , m_right_speaker(*this, "rspkr") +class stereo_speaker_device : public device_t, public device_ti8x_link_port_interface { -} +public: + stereo_speaker_device( + machine_config const &mconfig, + char const *tag, + device_t *owner, + uint32_t clock) + : device_t(mconfig, TI8X_SPEAKER_STEREO, tag, owner, clock) + , device_ti8x_link_port_interface(mconfig, *this) + , m_left_speaker(*this, "lspkr") + , m_right_speaker(*this, "rspkr") + { + } +protected: + virtual void device_add_mconfig(machine_config &config) override + { + SPEAKER(config, "outl").front_left(); + SPEAKER(config, "outr").front_right(); -void stereo_speaker_device::device_add_mconfig(machine_config &config) -{ - SPEAKER(config, "outl").front_left(); - SPEAKER(config, "outr").front_right(); + SPEAKER_SOUND(config, m_left_speaker, 0).add_route(ALL_OUTPUTS, "outl", 0.50); - SPEAKER_SOUND(config, m_left_speaker, 0).add_route(ALL_OUTPUTS, "outl", 0.50); + SPEAKER_SOUND(config, m_right_speaker, 0).add_route(ALL_OUTPUTS, "outr", 0.50); + } - SPEAKER_SOUND(config, m_right_speaker, 0).add_route(ALL_OUTPUTS, "outr", 0.50); -} + virtual void device_start() override + { + } -void stereo_speaker_device::device_start() -{ -} + virtual void input_tip(int state) override + { + m_left_speaker->level_w(state); + } + virtual void input_ring(int state) override + { + m_right_speaker->level_w(state); + } -WRITE_LINE_MEMBER(stereo_speaker_device::input_tip) -{ - m_left_speaker->level_w(state); -} + required_device<speaker_sound_device> m_left_speaker; + required_device<speaker_sound_device> m_right_speaker; +}; -WRITE_LINE_MEMBER(stereo_speaker_device::input_ring) -{ - m_right_speaker->level_w(state); -} +class mono_speaker_device : public device_t, public device_ti8x_link_port_interface +{ +public: + mono_speaker_device( + machine_config const &mconfig, + char const *tag, + device_t *owner, + uint32_t clock) + : device_t(mconfig, TI8X_SPEAKER_MONO, tag, owner, clock) + , device_ti8x_link_port_interface(mconfig, *this) + , m_speaker(*this, "spkr") + , m_tip_state(true) + , m_ring_state(true) + { + } +protected: + virtual void device_add_mconfig(machine_config &config) override + { + SPEAKER(config, "mono").front_center(); -mono_speaker_device::mono_speaker_device( - machine_config const &mconfig, - char const *tag, - device_t *owner, - uint32_t clock) - : device_t(mconfig, TI8X_SPEAKER_MONO, tag, owner, clock) - , device_ti8x_link_port_interface(mconfig, *this) - , m_speaker(*this, "spkr") - , m_tip_state(true) - , m_ring_state(true) -{ -} + SPEAKER_SOUND(config, m_speaker, 0).add_route(ALL_OUTPUTS, "mono", 0.50); + } + virtual void device_start() override + { + save_item(NAME(m_tip_state)); + save_item(NAME(m_ring_state)); -void mono_speaker_device::device_add_mconfig(machine_config &config) -{ - SPEAKER(config, "mono").front_center(); + m_tip_state = m_ring_state = true; + } - SPEAKER_SOUND(config, m_speaker, 0).add_route(ALL_OUTPUTS, "mono", 0.50); -} + virtual void input_tip(int state) override + { + m_tip_state = bool(state); + m_speaker->level_w((m_tip_state || m_ring_state) ? 1 : 0); + } -void mono_speaker_device::device_start() -{ - save_item(NAME(m_tip_state)); - save_item(NAME(m_ring_state)); + virtual void input_ring(int state) override + { + m_ring_state = bool(state); + m_speaker->level_w((m_tip_state || m_ring_state) ? 1 : 0); + } - m_tip_state = m_ring_state = true; -} + required_device<speaker_sound_device> m_speaker; -WRITE_LINE_MEMBER(mono_speaker_device::input_tip) -{ - m_tip_state = bool(state); - m_speaker->level_w((m_tip_state || m_ring_state) ? 1 : 0); -} +private: + bool m_tip_state, m_ring_state; +}; +} // anonymous namespace -WRITE_LINE_MEMBER(mono_speaker_device::input_ring) -{ - m_ring_state = bool(state); - m_speaker->level_w((m_tip_state || m_ring_state) ? 1 : 0); -} -} } // namespace bus::ti8x +DEFINE_DEVICE_TYPE_PRIVATE(TI8X_SPEAKER_STEREO, device_ti8x_link_port_interface, stereo_speaker_device, "ti8x_stspkr", "TI-8x Speaker (Stereo)") +DEFINE_DEVICE_TYPE_PRIVATE(TI8X_SPEAKER_MONO, device_ti8x_link_port_interface, mono_speaker_device, "ti8x_mspkr", "TI-8x Speaker (Mono)") |