From 4e0c19e03e39b3c1772a6c4ab1231506adf6f69a Mon Sep 17 00:00:00 2001 From: hap Date: Mon, 24 May 2021 20:41:24 +0200 Subject: input_merger: add setter for initial state --- src/devices/machine/input_merger.cpp | 28 +++++++++++++++++++--------- src/devices/machine/input_merger.h | 13 ++++++------- src/mame/drivers/saitek_leonardo.cpp | 8 +++++++- src/mame/drivers/saitek_renaissance.cpp | 8 +++++++- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/devices/machine/input_merger.cpp b/src/devices/machine/input_merger.cpp index 28652cdb66f..3e0570d82b0 100644 --- a/src/devices/machine/input_merger.cpp +++ b/src/devices/machine/input_merger.cpp @@ -2,10 +2,20 @@ // copyright-holders:Dirk Best, Vas Crabb /*************************************************************************** - Input Merger +Input Merger - Used to connect multiple lines to a single device input while - keeping it pulled high or low +Used to connect multiple lines to a single device input while keeping it +pulled high or low. + +Default initial input pin(s) state: +- ANY_HIGH: 0 +- ALL_HIGH: 1 +- ANY_LOW: 1 +- ALL_LOW: 0 + +TODO: +- call output handler at reset? eg. a NAND gate whose inputs are low at + power-on should output 1. ***************************************************************************/ @@ -23,10 +33,10 @@ // DEVICE DEFINITIONS //************************************************************************** -DEFINE_DEVICE_TYPE(INPUT_MERGER_ANY_HIGH, input_merger_any_high_device, "ipt_merge_any_hi", "Input Merger (any high)") -DEFINE_DEVICE_TYPE(INPUT_MERGER_ALL_HIGH, input_merger_all_high_device, "ipt_merge_all_hi", "Input Merger (all high)") -DEFINE_DEVICE_TYPE(INPUT_MERGER_ANY_LOW, input_merger_any_low_device, "ipt_merge_any_lo", "Input Merger (any low)") -DEFINE_DEVICE_TYPE(INPUT_MERGER_ALL_LOW, input_merger_all_low_device, "ipt_merge_all_lo", "Input Merger (all low)") +DEFINE_DEVICE_TYPE(INPUT_MERGER_ANY_HIGH, input_merger_any_high_device, "ipt_merge_any_hi", "Input Merger (any high)") // OR +DEFINE_DEVICE_TYPE(INPUT_MERGER_ALL_HIGH, input_merger_all_high_device, "ipt_merge_all_hi", "Input Merger (all high)") // AND +DEFINE_DEVICE_TYPE(INPUT_MERGER_ANY_LOW, input_merger_any_low_device, "ipt_merge_any_lo", "Input Merger (any low)") // NAND +DEFINE_DEVICE_TYPE(INPUT_MERGER_ALL_LOW, input_merger_all_low_device, "ipt_merge_all_lo", "Input Merger (all low)") // NOR //************************************************************************** @@ -93,12 +103,12 @@ TIMER_CALLBACK_MEMBER(input_merger_device::update_state) // SPECIALISATIONS //************************************************************************** -input_merger_any_high_device::input_merger_any_high_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) +input_merger_any_high_device::input_merger_any_high_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) : input_merger_device(mconfig, INPUT_MERGER_ANY_HIGH, tag, owner, clock, u32(0), u32(0), 1) { } -input_merger_all_high_device::input_merger_all_high_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) +input_merger_all_high_device::input_merger_all_high_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) : input_merger_device(mconfig, INPUT_MERGER_ALL_HIGH, tag, owner, clock, ~u32(0), ~u32(0), 0) { } diff --git a/src/devices/machine/input_merger.h b/src/devices/machine/input_merger.h index 10c400b4a74..744b342796d 100644 --- a/src/devices/machine/input_merger.h +++ b/src/devices/machine/input_merger.h @@ -4,9 +4,6 @@ Input Merger - Used to connect multiple lines to a single device input while - keeping it pulled high or low - ***************************************************************************/ #ifndef MAME_MACHINE_INPUT_MERGER_H @@ -22,13 +19,14 @@ class input_merger_device : public device_t { public: - // callback + // configuration auto output_handler() { return m_output_handler.bind(); } + auto &initial_state(u32 val) { m_initval = val; return *this; } // initial input pin(s) state, be wary about the unused pins // input lines template DECLARE_WRITE_LINE_MEMBER(in_w) { static_assert(Bit < 32, "invalid bit"); machine().scheduler().synchronize(timer_expired_delegate(FUNC(input_merger_device::update_state), this), (Bit << 1) | (state ? 1U : 0U)); } - template void in_set(u8 data) { in_w(1); } - template void in_clear(u8 data) { in_w(0); } + template void in_set(u8 data = 0) { in_w(1); } + template void in_clear(u8 data = 0) { in_w(0); } protected: // constructor/destructor @@ -50,7 +48,8 @@ protected: devcb_write_line m_output_handler; - u32 const m_initval, m_xorval; + u32 m_initval; + u32 const m_xorval; int const m_active; u32 m_state; }; diff --git a/src/mame/drivers/saitek_leonardo.cpp b/src/mame/drivers/saitek_leonardo.cpp index 09cef526c7f..4cd603add51 100644 --- a/src/mame/drivers/saitek_leonardo.cpp +++ b/src/mame/drivers/saitek_leonardo.cpp @@ -87,6 +87,7 @@ public: protected: virtual void machine_start() override; + virtual void machine_reset() override; private: // devices/pointers @@ -124,6 +125,11 @@ void leo_state::machine_start() save_item(NAME(m_led_data)); } +void leo_state::machine_reset() +{ + m_stb->in_clear<0>(); +} + /****************************************************************************** @@ -361,7 +367,7 @@ void leo_state::leonardo(machine_config &config) m_maincpu->in_p6_cb().set(FUNC(leo_state::p6_r)); m_maincpu->out_p6_cb().set(FUNC(leo_state::p6_w)); - INPUT_MERGER_ANY_LOW(config, m_stb); + INPUT_MERGER_ANY_LOW(config, m_stb).initial_state(u32(~3)); m_stb->output_handler().set_inputline(m_maincpu, M6801_IS_LINE); config.set_maximum_quantum(attotime::from_hz(6000)); diff --git a/src/mame/drivers/saitek_renaissance.cpp b/src/mame/drivers/saitek_renaissance.cpp index 09fcabc6878..7ba1ac8c036 100644 --- a/src/mame/drivers/saitek_renaissance.cpp +++ b/src/mame/drivers/saitek_renaissance.cpp @@ -73,6 +73,7 @@ public: protected: virtual void machine_start() override; + virtual void machine_reset() override; private: // devices/pointers @@ -118,6 +119,11 @@ void ren_state::machine_start() save_item(NAME(m_led_data)); } +void ren_state::machine_reset() +{ + m_stb->in_clear<0>(); +} + template INPUT_CHANGED_MEMBER(ren_state::change_view) { if (oldval && !newval) @@ -351,7 +357,7 @@ void ren_state::ren(machine_config &config) m_maincpu->in_p6_cb().set(FUNC(ren_state::p6_r)); m_maincpu->out_p6_cb().set(FUNC(ren_state::p6_w)); - INPUT_MERGER_ANY_LOW(config, m_stb); + INPUT_MERGER_ANY_LOW(config, m_stb).initial_state(u32(~3)); m_stb->output_handler().set_inputline(m_maincpu, M6801_IS_LINE); config.set_maximum_quantum(attotime::from_hz(6000)); -- cgit v1.2.3