From 8dc8147ab36391508829063aa87f6f12a39ffa3f Mon Sep 17 00:00:00 2001 From: Dirk Best Date: Fri, 5 Apr 2019 09:22:13 +0200 Subject: lockon: Fix coin counters (MT05374) --- src/mame/drivers/lockon.cpp | 14 +++++++++++--- src/mame/includes/lockon.h | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/mame/drivers/lockon.cpp b/src/mame/drivers/lockon.cpp index d9474d316a1..d145b358c58 100644 --- a/src/mame/drivers/lockon.cpp +++ b/src/mame/drivers/lockon.cpp @@ -414,12 +414,20 @@ WRITE_LINE_MEMBER(lockon_state::ym2203_irq) WRITE8_MEMBER(lockon_state::ym2203_out_b) { - machine().bookkeeping().coin_counter_w(0, data & 0x80); - machine().bookkeeping().coin_counter_w(1, data & 0x40); - machine().bookkeeping().coin_counter_w(2, data & 0x20); + // we require that the value keeps stable for at least two writes + if (BIT(data, 7) == BIT(m_ym2203_port_b, 7)) + machine().bookkeeping().coin_counter_w(0, BIT(~data, 7)); + + if (BIT(data, 6) == BIT(m_ym2203_port_b, 6)) + machine().bookkeeping().coin_counter_w(1, BIT(~data, 6)); + + if (BIT(data, 5) == BIT(m_ym2203_port_b, 5)) + machine().bookkeeping().coin_counter_w(2, BIT(~data, 5)); /* 'Lock-On' lamp */ m_lamp = BIT(~data, 4); + + m_ym2203_port_b = data; } /************************************* diff --git a/src/mame/includes/lockon.h b/src/mame/includes/lockon.h index abdbbe9219c..d21db6256d6 100644 --- a/src/mame/includes/lockon.h +++ b/src/mame/includes/lockon.h @@ -36,6 +36,7 @@ public: , m_scene_ram(*this, "scene_ram") , m_ground_ram(*this, "ground_ram") , m_object_ram(*this, "object_ram") + , m_ym2203_port_b(0xff) , m_maincpu(*this, "maincpu") , m_audiocpu(*this, "audiocpu") , m_ground(*this, "ground") @@ -97,6 +98,7 @@ private: /* misc */ uint8_t m_ctrl_reg; uint32_t m_main_inten; + uint8_t m_ym2203_port_b; /* devices */ required_device m_maincpu; -- cgit v1.2.3