From 0e18d5e91f13b06f75b18acb81494167e8aea4f5 Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 6 Dec 2022 20:57:22 -0500 Subject: [PATCH] fireshrk: Soundlatch modernization --- src/mame/toaplan/toaplan1.cpp | 27 ++++++--------------------- src/mame/toaplan/toaplan1.h | 12 ++++++------ src/mame/toaplan/toaplan1_m.cpp | 15 +++++++-------- 3 files changed, 19 insertions(+), 35 deletions(-) diff --git a/src/mame/toaplan/toaplan1.cpp b/src/mame/toaplan/toaplan1.cpp index 9a11da14dc0..b751e442725 100644 --- a/src/mame/toaplan/toaplan1.cpp +++ b/src/mame/toaplan/toaplan1.cpp @@ -755,7 +755,7 @@ void toaplan1_samesame_state::main_map(address_map &map) map(0x140008, 0x140009).portr("SYSTEM"); map(0x14000b, 0x14000b).r(FUNC(toaplan1_samesame_state::port_6_word_r)); /* Territory, and MCU ready */ map(0x14000d, 0x14000d).w(FUNC(toaplan1_samesame_state::coin_w)); /* Coin counter/lockout */ - map(0x14000f, 0x14000f).w(FUNC(toaplan1_samesame_state::mcu_w)); /* Commands sent to HD647180 */ + map(0x14000f, 0x14000f).w(m_soundlatch, FUNC(generic_latch_8_device::write)); /* Commands sent to HD647180 */ map(0x180001, 0x180001).w(FUNC(toaplan1_samesame_state::bcu_flipscreen_w)); map(0x180002, 0x180003).rw(FUNC(toaplan1_samesame_state::tileram_offs_r), FUNC(toaplan1_samesame_state::tileram_offs_w)); map(0x180004, 0x180007).rw(FUNC(toaplan1_samesame_state::tileram_r), FUNC(toaplan1_samesame_state::tileram_w)); @@ -987,26 +987,9 @@ u8 toaplan1_state::vimana_tjump_invert_r() return (m_tjump_io->read() ^ 0xff) | 0xc0; // high 2 bits of port G always read as 1 } -void toaplan1_samesame_state::mcu_w(u8 data) -{ - m_to_mcu = data; - m_cmdavailable = 1; -} - -u8 toaplan1_samesame_state::soundlatch_r() -{ - return m_to_mcu; -} - -void toaplan1_samesame_state::sound_done_w(u8 data) -{ - m_to_mcu = data; - m_cmdavailable = 0; -} - u8 toaplan1_samesame_state::cmdavailable_r() { - if (m_cmdavailable) return 0xff; + if (m_soundlatch->pending_r()) return 0xff; else return 0x00; } @@ -1015,8 +998,8 @@ void toaplan1_samesame_state::hd647180_io_map(address_map &map) map.global_mask(0xff); map(0x63, 0x63).nopr(); // read port D - map(0xa0, 0xa0).r(FUNC(toaplan1_samesame_state::soundlatch_r)); - map(0xb0, 0xb0).w(FUNC(toaplan1_samesame_state::sound_done_w)); + map(0xa0, 0xa0).r(m_soundlatch, FUNC(generic_latch_8_device::read)); + map(0xb0, 0xb0).w(m_soundlatch, FUNC(generic_latch_8_device::acknowledge_w)); map(0x80, 0x81).rw("ymsnd", FUNC(ym3812_device::read), FUNC(ym3812_device::write)); } @@ -2123,6 +2106,8 @@ void toaplan1_samesame_state::samesame(machine_config &config) audiocpu.set_addrmap(AS_IO, &toaplan1_samesame_state::hd647180_io_map); audiocpu.in_pd_callback().set(FUNC(toaplan1_samesame_state::cmdavailable_r)); + GENERIC_LATCH_8(config, m_soundlatch).set_separate_acknowledge(true); + config.set_perfect_quantum(m_maincpu); /* video hardware */ diff --git a/src/mame/toaplan/toaplan1.h b/src/mame/toaplan/toaplan1.h index 40c70544cda..9b643ab2e34 100644 --- a/src/mame/toaplan/toaplan1.h +++ b/src/mame/toaplan/toaplan1.h @@ -11,6 +11,7 @@ #include "cpu/m68000/m68000.h" #include "cpu/tms32010/tms32010.h" +#include "machine/gen_latch.h" #include "sound/ymopl.h" #include "toaplan_scu.h" #include "emupal.h" @@ -134,7 +135,7 @@ protected: void register_common(); void log_vram(); void draw_sprites(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - void reset_sound(); + virtual void reset_sound(); DECLARE_WRITE_LINE_MEMBER(reset_callback); required_device m_maincpu; required_device m_audiocpu; @@ -230,21 +231,20 @@ class toaplan1_samesame_state : public toaplan1_state { public: toaplan1_samesame_state(const machine_config &mconfig, device_type type, const char *tag) : - toaplan1_state(mconfig, type, tag) + toaplan1_state(mconfig, type, tag), + m_soundlatch(*this, "soundlatch") { } void samesame(machine_config &config); protected: - virtual void machine_start() override; + virtual void reset_sound() override; private: // Fire Shark sound - u8 m_to_mcu = 0; - u8 m_cmdavailable = 0; + required_device m_soundlatch; - void mcu_w(u8 data); u8 soundlatch_r(); void sound_done_w(u8 data); u8 cmdavailable_r(); diff --git a/src/mame/toaplan/toaplan1_m.cpp b/src/mame/toaplan/toaplan1_m.cpp index 08c55f876ca..4d432088958 100644 --- a/src/mame/toaplan/toaplan1_m.cpp +++ b/src/mame/toaplan/toaplan1_m.cpp @@ -143,7 +143,7 @@ u8 toaplan1_samesame_state::port_6_word_r() { /* Bit 0x80 is secondary CPU (HD647180) ready signal */ logerror("PC:%08x Warning !!! IO reading from $14000b\n",m_maincpu->pcbase()); - return (0x80 | m_tjump_io->read()) & 0xff; + return (m_soundlatch->pending_r() ? 0 : 0x80) | m_tjump_io->read(); } u8 toaplan1_state::shared_r(offs_t offset) @@ -166,6 +166,12 @@ void toaplan1_state::reset_sound() m_audiocpu->pulse_input_line(INPUT_LINE_RESET, attotime::zero); } +void toaplan1_samesame_state::reset_sound() +{ + toaplan1_state::reset_sound(); + m_soundlatch->acknowledge_w(); +} + void toaplan1_state::reset_sound_w(u8 data) { if (data == 0) reset_sound(); @@ -258,10 +264,3 @@ void toaplan1_demonwld_state::machine_start() save_item(NAME(m_dsp_bio)); save_item(NAME(m_dsp_execute)); } - -void toaplan1_samesame_state::machine_start() -{ - toaplan1_state::machine_start(); - save_item(NAME(m_to_mcu)); - save_item(NAME(m_cmdavailable)); -}