diff --git a/src/emu/machine/netlist.c b/src/emu/machine/netlist.c index 119c259984e..4d18be597d1 100644 --- a/src/emu/machine/netlist.c +++ b/src/emu/machine/netlist.c @@ -66,7 +66,7 @@ const device_type NETLIST_LOGIC_INPUT = &device_creator(this->owner())->setup().find_param(m_param_name); + netlist_param_t *p = this->nl_owner().setup().find_param(m_param_name); m_param = dynamic_cast(p); if (m_param == NULL) { @@ -103,7 +103,7 @@ void netlist_mame_analog_input_t::device_start() netlist_mame_logic_input_t::netlist_mame_logic_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, NETLIST_ANALOG_INPUT, "netlist analog input", tag, owner, clock, "netlist_analog_input", __FILE__), - netlist_mame_sub_interface(*this), + netlist_mame_sub_interface(*owner), m_param(0), m_mask(0xffffffff), m_shift(0), diff --git a/src/emu/machine/netlist.h b/src/emu/machine/netlist.h index 6968b64aea4..3f274f2df69 100644 --- a/src/emu/machine/netlist.h +++ b/src/emu/machine/netlist.h @@ -281,6 +281,9 @@ public: static void static_set_constructor(device_t &device, void (*setup_func)(netlist_setup_t &)); + inline sound_stream *get_stream() { return m_stream; } + + // device_sound_interface overrides virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); @@ -318,14 +321,29 @@ class netlist_mame_sub_interface { public: // construction/destruction - netlist_mame_sub_interface(netlist_mame_device_t &obj) : m_object(obj) {} + netlist_mame_sub_interface(device_t &aowner) + { + m_owner = dynamic_cast(&aowner); + m_sound = dynamic_cast(&aowner); + } virtual ~netlist_mame_sub_interface() { } virtual void custom_netlist_additions(netlist_base_t &netlist) { } - inline netlist_mame_device_t &object() { return m_object; } + inline netlist_mame_device_t &nl_owner() const { return *m_owner; } + + inline bool is_sound_device() const { return (m_sound != NULL); } + + inline void update_to_current_time() + { + printf("%p\n", m_sound); + printf("%p\n", m_sound->get_stream()); + m_sound->get_stream()->update(); + } + private: - netlist_mame_device_t &m_object; + netlist_mame_device_t *m_owner; + netlist_mame_sound_device_t *m_sound; }; // ---------------------------------------------------------------------------------------- @@ -344,7 +362,19 @@ public: static void static_set_name(device_t &device, const char *param_name); static void static_set_mult_offset(device_t &device, const double mult, const double offset); - inline void write(const double val) { m_param->setTo(val * m_mult + m_offset); } + inline void write(const double val) + { + if (is_sound_device()) + { + update_to_current_time(); + m_param->setTo(val * m_mult + m_offset); + } + else + { + // FIXME: use device timer .... + m_param->setTo(val * m_mult + m_offset); + } + } inline DECLARE_INPUT_CHANGED_MEMBER(input_changed) { @@ -386,7 +416,19 @@ public: static void static_set_params(device_t &device, const char *param_name, const UINT32 mask, const UINT32 shift); - inline void write(const UINT32 val) { m_param->setTo((val >> m_shift) & m_mask); } + inline void write(const UINT32 val) + { + if (is_sound_device()) + { + update_to_current_time(); + m_param->setTo((val >> m_shift) & m_mask); + } + else + { + // FIXME: use device timer .... + m_param->setTo((val >> m_shift) & m_mask); + } + } inline DECLARE_INPUT_CHANGED_MEMBER(input_changed) { write(newval); } DECLARE_WRITE_LINE_MEMBER(write_line) { write(state); } @@ -510,7 +552,7 @@ public: NETLIB_NAME(sound_in)() : netlist_device_t() { } - static const int BUFSIZE = 2048; + static const int MAX_INPUT_CHANNELS = 10; ATTR_COLD void start() { @@ -522,7 +564,7 @@ public: m_inc = netlist_time::from_nsec(1); - for (int i=0; i<10; i++) + for (int i = 0; i < MAX_INPUT_CHANNELS; i++) register_param(pstring::sprintf("CHAN%d", i), m_param_name[i], ""); m_num_channel = 0; } @@ -530,14 +572,14 @@ public: ATTR_COLD void reset() { m_pos = 0; - for (int i=0; i<10; i++) + for (int i = 0; i < MAX_INPUT_CHANNELS; i++) m_buffer[i] = NULL; } ATTR_COLD int resolve() { m_pos = 0; - for (int i=0; i<10; i++) + for (int i = 0; i < MAX_INPUT_CHANNELS; i++) { if (m_param_name[i].Value() != "") { @@ -568,9 +610,9 @@ public: m_pos = 0; } - netlist_param_str_t m_param_name[10]; - netlist_param_double_t *m_param[10]; - stream_sample_t *m_buffer[10]; + netlist_param_str_t m_param_name[MAX_INPUT_CHANNELS]; + netlist_param_double_t *m_param[MAX_INPUT_CHANNELS]; + stream_sample_t *m_buffer[MAX_INPUT_CHANNELS]; netlist_time m_inc; private: diff --git a/src/emu/netlist/devices/nld_7400.c b/src/emu/netlist/devices/nld_7400.c index 874874ae8b6..e4a3731cd49 100644 --- a/src/emu/netlist/devices/nld_7400.c +++ b/src/emu/netlist/devices/nld_7400.c @@ -31,6 +31,11 @@ NETLIB_START(7400_dip) NETLIB_UPDATE(7400_dip) { + /* only called during startup */ + m_1.update_dev(); + m_2.update_dev(); + m_3.update_dev(); + m_4.update_dev(); } NETLIB_RESET(7400_dip) diff --git a/src/emu/netlist/devices/nld_7402.c b/src/emu/netlist/devices/nld_7402.c index 32fb32c1fab..cf744f70ba2 100644 --- a/src/emu/netlist/devices/nld_7402.c +++ b/src/emu/netlist/devices/nld_7402.c @@ -31,6 +31,11 @@ NETLIB_START(7402_dip) NETLIB_UPDATE(7402_dip) { + /* only called during startup */ + m_1.update_dev(); + m_2.update_dev(); + m_3.update_dev(); + m_4.update_dev(); } NETLIB_RESET(7402_dip) diff --git a/src/emu/netlist/devices/nld_7404.c b/src/emu/netlist/devices/nld_7404.c index 6e65b6ba43a..99591d961f8 100644 --- a/src/emu/netlist/devices/nld_7404.c +++ b/src/emu/netlist/devices/nld_7404.c @@ -52,6 +52,14 @@ NETLIB_START(7404_dip) NETLIB_UPDATE(7404_dip) { + /* only called during startup */ + + m_1.update_dev(); + m_2.update_dev(); + m_3.update_dev(); + m_4.update_dev(); + m_5.update_dev(); + m_6.update_dev(); } NETLIB_RESET(7404_dip) diff --git a/src/emu/netlist/devices/nld_7410.c b/src/emu/netlist/devices/nld_7410.c index 56d545b9997..933a2b0fb07 100644 --- a/src/emu/netlist/devices/nld_7410.c +++ b/src/emu/netlist/devices/nld_7410.c @@ -29,6 +29,10 @@ NETLIB_START(7410_dip) NETLIB_UPDATE(7410_dip) { + /* only called during startup */ + m_1.update_dev(); + m_2.update_dev(); + m_3.update_dev(); } NETLIB_RESET(7410_dip) diff --git a/src/emu/netlist/devices/nld_74107.c b/src/emu/netlist/devices/nld_74107.c index 30f08f0c3a4..7c145b29815 100644 --- a/src/emu/netlist/devices/nld_74107.c +++ b/src/emu/netlist/devices/nld_74107.c @@ -19,6 +19,8 @@ NETLIB_START(74107Asub) NETLIB_RESET(74107Asub) { m_clk.set_state(netlist_input_t::STATE_INP_HL); + m_Q.initial(0); + m_QQ.initial(1); m_Q1 = 0; m_Q2 = 0; @@ -133,4 +135,7 @@ NETLIB_RESET(74107_dip) NETLIB_UPDATE(74107_dip) { + /* only called during startup */ + m_1.update_dev(); + m_2.update_dev(); } diff --git a/src/emu/netlist/devices/nld_7420.c b/src/emu/netlist/devices/nld_7420.c index f163bdaa872..edfb536d3a8 100644 --- a/src/emu/netlist/devices/nld_7420.c +++ b/src/emu/netlist/devices/nld_7420.c @@ -28,6 +28,9 @@ NETLIB_START(7420_dip) NETLIB_UPDATE(7420_dip) { + /* only called during startup */ + m_1.update_dev(); + m_2.update_dev(); } NETLIB_RESET(7420_dip) diff --git a/src/emu/netlist/devices/nld_7425.c b/src/emu/netlist/devices/nld_7425.c index c2c83f25204..bb903544485 100644 --- a/src/emu/netlist/devices/nld_7425.c +++ b/src/emu/netlist/devices/nld_7425.c @@ -32,6 +32,9 @@ NETLIB_START(7425_dip) NETLIB_UPDATE(7425_dip) { + /* only called during startup */ + m_1.update_dev(); + m_2.update_dev(); } NETLIB_RESET(7425_dip) diff --git a/src/emu/netlist/devices/nld_7427.c b/src/emu/netlist/devices/nld_7427.c index 0fbf1e02f0f..7867aa5bad2 100644 --- a/src/emu/netlist/devices/nld_7427.c +++ b/src/emu/netlist/devices/nld_7427.c @@ -29,6 +29,10 @@ NETLIB_START(7427_dip) NETLIB_UPDATE(7427_dip) { + /* only called during startup */ + m_1.update_dev(); + m_2.update_dev(); + m_3.update_dev(); } NETLIB_RESET(7427_dip) diff --git a/src/emu/netlist/devices/nld_7430.c b/src/emu/netlist/devices/nld_7430.c index 1d16fe0bc1f..e6ef3624b8b 100644 --- a/src/emu/netlist/devices/nld_7430.c +++ b/src/emu/netlist/devices/nld_7430.c @@ -24,6 +24,8 @@ NETLIB_START(7430_dip) NETLIB_UPDATE(7430_dip) { + /* only called during startup */ + m_1.update_dev(); } NETLIB_RESET(7430_dip) diff --git a/src/emu/netlist/devices/nld_7450.c b/src/emu/netlist/devices/nld_7450.c index 615d9f36e90..bcd1000d43a 100644 --- a/src/emu/netlist/devices/nld_7450.c +++ b/src/emu/netlist/devices/nld_7450.c @@ -76,6 +76,9 @@ NETLIB_START(7450_dip) NETLIB_UPDATE(7450_dip) { + /* only called during startup */ + m_1.update_dev(); + m_2.update_dev(); } NETLIB_RESET(7450_dip) diff --git a/src/emu/netlist/devices/nld_7474.c b/src/emu/netlist/devices/nld_7474.c index 0dbf45f0cb7..7ac8aa60ff5 100644 --- a/src/emu/netlist/devices/nld_7474.c +++ b/src/emu/netlist/devices/nld_7474.c @@ -5,33 +5,38 @@ #include "nld_7474.h" -ATTR_HOT inline void NETLIB_NAME(7474sub)::newstate(const UINT8 state) +ATTR_HOT inline void NETLIB_NAME(7474sub)::newstate(const UINT8 stateQ, const UINT8 stateQQ) { static const netlist_time delay[2] = { NLTIME_FROM_NS(25), NLTIME_FROM_NS(40) }; - OUTLOGIC(m_Q, state, delay[state]); - OUTLOGIC(m_QQ, !state, delay[!state]); + OUTLOGIC(m_Q, stateQ, delay[stateQ]); + OUTLOGIC(m_QQ, stateQQ, delay[stateQQ]); } NETLIB_UPDATE(7474sub) { - //if (!INP_LAST(m_clk) & INP(m_clk)) + //if (INP_LH(m_CLK)) { - newstate(m_nextD); + newstate(m_nextD, !m_nextD); m_CLK.inactivate(); } } NETLIB_UPDATE(7474) { + if (!INPLOGIC(m_PREQ) && !INPLOGIC(m_CLRQ)) + { + sub.newstate(1, 1); + sub.m_CLK.inactivate(); + } if (!INPLOGIC(m_PREQ)) { - sub.newstate(1); + sub.newstate(1, 0); sub.m_CLK.inactivate(); m_D.inactivate(); } else if (!INPLOGIC(m_CLRQ)) { - sub.newstate(0); + sub.newstate(0, 1); sub.m_CLK.inactivate(); m_D.inactivate(); } @@ -77,6 +82,9 @@ NETLIB_RESET(7474sub) m_CLK.set_state(netlist_input_t::STATE_INP_LH); m_nextD = 0; + /* FIXME: required by pong doubles - need a mechanism to set this from netlist */ + m_Q.initial(1); + m_QQ.initial(0); } NETLIB_START(7474_dip) @@ -109,4 +117,6 @@ NETLIB_RESET(7474_dip) NETLIB_UPDATE(7474_dip) { + m_1.update_dev(); + m_2.update_dev(); } diff --git a/src/emu/netlist/devices/nld_7474.h b/src/emu/netlist/devices/nld_7474.h index 931d339f1ea..7dab3f673e9 100644 --- a/src/emu/netlist/devices/nld_7474.h +++ b/src/emu/netlist/devices/nld_7474.h @@ -61,7 +61,7 @@ NETLIB_SUBDEVICE(7474sub, netlist_ttl_output_t m_Q; netlist_ttl_output_t m_QQ; - ATTR_HOT inline void newstate(const UINT8 state); + ATTR_HOT inline void newstate(const UINT8 stateQ, const UINT8 stateQQ); ); NETLIB_DEVICE(7474, diff --git a/src/emu/netlist/devices/nld_7486.c b/src/emu/netlist/devices/nld_7486.c index 367419c71fa..4234e1e5400 100644 --- a/src/emu/netlist/devices/nld_7486.c +++ b/src/emu/netlist/devices/nld_7486.c @@ -49,6 +49,11 @@ NETLIB_START(7486_dip) NETLIB_UPDATE(7486_dip) { + /* only called during startup */ + m_1.update_dev(); + m_2.update_dev(); + m_3.update_dev(); + m_4.update_dev(); } NETLIB_RESET(7486_dip) diff --git a/src/emu/netlist/devices/nld_legacy.c b/src/emu/netlist/devices/nld_legacy.c index e6a0d83569d..529d5325651 100644 --- a/src/emu/netlist/devices/nld_legacy.c +++ b/src/emu/netlist/devices/nld_legacy.c @@ -16,6 +16,8 @@ NETLIB_START(nicRSFF) NETLIB_RESET(nicRSFF) { + m_Q.initial(0); + m_QQ.initial(1); } NETLIB_UPDATE(nicRSFF) diff --git a/src/emu/netlist/devices/nld_signal.h b/src/emu/netlist/devices/nld_signal.h index 5065e13a281..e8e2b240bcb 100644 --- a/src/emu/netlist/devices/nld_signal.h +++ b/src/emu/netlist/devices/nld_signal.h @@ -47,6 +47,7 @@ public: ATTR_COLD void reset() { + m_Q.initial(1); m_active = 1; } @@ -99,6 +100,7 @@ public: ATTR_COLD void reset() { + m_Q.initial(1); m_active = 1; } @@ -171,6 +173,7 @@ public: ATTR_COLD void reset() { + m_Q.initial(1); m_active = 1; } @@ -241,7 +244,7 @@ public: { register_input(sIN[i], m_i[i], netlist_input_t::STATE_INP_ACTIVE); } - m_Q.initial(1); + //m_Q.initial(1); } ATTR_HOT ATTR_ALIGN void update()