diff options
-rw-r--r-- | src/devices/machine/k054321.cpp | 63 | ||||
-rw-r--r-- | src/devices/machine/k054321.h | 23 |
2 files changed, 17 insertions, 69 deletions
diff --git a/src/devices/machine/k054321.cpp b/src/devices/machine/k054321.cpp index be7fed6d438..ec59ae89d94 100644 --- a/src/devices/machine/k054321.cpp +++ b/src/devices/machine/k054321.cpp @@ -43,23 +43,24 @@ void k054321_device::main_map(address_map &map) map(0x2, 0x2).w(FUNC(k054321_device::volume_reset_w)); map(0x3, 0x3).w(FUNC(k054321_device::volume_up_w)); map(0x4, 0x4).w(FUNC(k054321_device::dummy_w)); - map(0x6, 0x6).w(FUNC(k054321_device::main1_w)); - map(0x7, 0x7).w(FUNC(k054321_device::main2_w)); + map(0x6, 0x6).w(m_soundlatch[0], FUNC(generic_latch_8_device::write)); + map(0x7, 0x7).w(m_soundlatch[1], FUNC(generic_latch_8_device::write)); map(0x8, 0x8).r(FUNC(k054321_device::busy_r)); - map(0xa, 0xa).r(FUNC(k054321_device::sound1_r)); + map(0xa, 0xa).r(m_soundlatch[2], FUNC(generic_latch_8_device::read)); } void k054321_device::sound_map(address_map &map) { - map(0x0, 0x0).w(FUNC(k054321_device::sound1_w)); - map(0x2, 0x2).r(FUNC(k054321_device::main1_r)); - map(0x3, 0x3).r(FUNC(k054321_device::main2_r)); + map(0x0, 0x0).w(m_soundlatch[2], FUNC(generic_latch_8_device::write)); + map(0x2, 0x2).r(m_soundlatch[0], FUNC(generic_latch_8_device::read)); + map(0x3, 0x3).r(m_soundlatch[1], FUNC(generic_latch_8_device::read)); } k054321_device::k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, K054321, tag, owner, clock), m_left(*this, finder_base::DUMMY_TAG), - m_right(*this, finder_base::DUMMY_TAG) + m_right(*this, finder_base::DUMMY_TAG), + m_soundlatch(*this, "soundlatch%u", 0) { } @@ -79,56 +80,14 @@ void k054321_device::device_start() m_right_gains[i] = m_right->input_gain(i); // register for savestates - save_item(NAME(m_main1)); - save_item(NAME(m_main2)); - save_item(NAME(m_sound1)); save_item(NAME(m_volume)); save_item(NAME(m_active)); } -TIMER_CALLBACK_MEMBER(k054321_device::write_main1) +void k054321_device::device_add_mconfig(machine_config &config) { - m_main1 = param; -} - -TIMER_CALLBACK_MEMBER(k054321_device::write_main2) -{ - m_main2 = param; -} - -TIMER_CALLBACK_MEMBER(k054321_device::write_sound1) -{ - m_sound1 = param; -} - -READ8_MEMBER( k054321_device::main1_r) -{ - return m_main1; -} - -WRITE8_MEMBER(k054321_device::main1_w) -{ - machine().scheduler().synchronize(timer_expired_delegate(FUNC(k054321_device::write_main1), this), data & 0xff); -} - -READ8_MEMBER( k054321_device::main2_r) -{ - return m_main2; -} - -WRITE8_MEMBER(k054321_device::main2_w) -{ - machine().scheduler().synchronize(timer_expired_delegate(FUNC(k054321_device::write_main2), this), data & 0xff); -} - -READ8_MEMBER( k054321_device::sound1_r) -{ - return m_sound1; -} - -WRITE8_MEMBER(k054321_device::sound1_w) -{ - machine().scheduler().synchronize(timer_expired_delegate(FUNC(k054321_device::write_sound1), this), data & 0xff); + for (int i = 0; i < 3; i++) + GENERIC_LATCH_8(config, m_soundlatch[i]); } WRITE8_MEMBER(k054321_device::volume_reset_w) diff --git a/src/devices/machine/k054321.h b/src/devices/machine/k054321.h index d108b6563c5..92d0874dc54 100644 --- a/src/devices/machine/k054321.h +++ b/src/devices/machine/k054321.h @@ -6,12 +6,14 @@ #pragma once +#include "machine/gen_latch.h" + class k054321_device : public device_t { public: template<typename T, typename U> - k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&left, U &&right) - : k054321_device(mconfig, tag, owner, 0) + k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&left, U &&right) : + k054321_device(mconfig, tag, owner, 0) { m_left.set_tag(std::forward<T>(left)); m_right.set_tag(std::forward<U>(right)); @@ -24,40 +26,27 @@ public: protected: void device_start() override; + virtual void device_add_mconfig(machine_config &config) override; private: required_device<device_sound_interface> m_left; required_device<device_sound_interface> m_right; + required_device_array<generic_latch_8_device, 3> m_soundlatch; std::unique_ptr<float[]> m_left_gains; std::unique_ptr<float[]> m_right_gains; - u8 m_main1; - u8 m_main2; - u8 m_sound1; - u8 m_volume; u8 m_active; void propagate_volume(); - DECLARE_READ8_MEMBER( main1_r); - DECLARE_WRITE8_MEMBER(main1_w); - DECLARE_READ8_MEMBER( main2_r); - DECLARE_WRITE8_MEMBER(main2_w); - DECLARE_READ8_MEMBER( sound1_r); - DECLARE_WRITE8_MEMBER(sound1_w); - DECLARE_WRITE8_MEMBER(volume_reset_w); DECLARE_WRITE8_MEMBER(volume_up_w); DECLARE_WRITE8_MEMBER(active_w); DECLARE_READ8_MEMBER(busy_r); DECLARE_WRITE8_MEMBER(dummy_w); - - TIMER_CALLBACK_MEMBER(write_main1); - TIMER_CALLBACK_MEMBER(write_main2); - TIMER_CALLBACK_MEMBER(write_sound1); }; DECLARE_DEVICE_TYPE(K054321, k054321_device) |