trunk/src/mame/drivers/pong.c
| r26422 | r26423 | |
| 465 | 465 | NETDEV_PARAM(videomix.R2, RES_K(1.2)) |
| 466 | 466 | NETDEV_PARAM(videomix.R3, RES_K(22)) |
| 467 | 467 | |
| 468 | | #if 0 |
| 469 | 468 | NETDEV_SOLVER(Solver) |
| 470 | 469 | NETDEV_ANALOG_CONST(V5, 5) |
| 471 | 470 | NETDEV_ANALOG_CONST(V1, 1) |
| 472 | 471 | NETDEV_ANALOG_CONST(V0, 0) |
| 473 | 472 | |
| 473 | #if 0 |
| 474 | 474 | NETDEV_R(R1, 10) |
| 475 | 475 | NETDEV_R(R2, 10) |
| 476 | 476 | NETDEV_R(R3, 10) |
| r26422 | r26423 | |
| 516 | 516 | //NETDEV_LOG(log1, D1.A) |
| 517 | 517 | #endif |
| 518 | 518 | |
| 519 | | #if 0 |
| 519 | #if 1 |
| 520 | 520 | // astable NAND Multivibrator |
| 521 | 521 | NETDEV_R(R1, 1000) |
| 522 | 522 | NETDEV_C(C1, 1e-6) |
| r26422 | r26423 | |
| 583 | 583 | netlist_mame_device::required_output<netlist_logic_output_t> m_srst; |
| 584 | 584 | netlist_mame_device::required_output<netlist_analog_output_t> m_p_V0; |
| 585 | 585 | netlist_mame_device::required_output<netlist_analog_output_t> m_p_V1; |
| 586 | | netlist_mame_device::required_param m_sw1a; |
| 587 | | netlist_mame_device::required_param m_sw1b; |
| 588 | | netlist_mame_device::required_param m_p_R0; |
| 589 | | netlist_mame_device::required_param m_p_R1; |
| 586 | netlist_mame_device::required_param<netlist_param_int_t> m_sw1a; |
| 587 | netlist_mame_device::required_param<netlist_param_int_t> m_sw1b; |
| 588 | netlist_mame_device::required_param<netlist_param_double_t> m_p_R0; |
| 589 | netlist_mame_device::required_param<netlist_param_double_t> m_p_R1; |
| 590 | 590 | |
| 591 | 591 | UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 592 | 592 | |
trunk/src/emu/machine/netlist.h
| r26422 | r26423 | |
| 102 | 102 | |
| 103 | 103 | template<bool _Required, class _NETClass> |
| 104 | 104 | class output_finder; |
| 105 | template<class C> |
| 105 | 106 | class optional_output; |
| 106 | 107 | template<class C> |
| 107 | 108 | class required_output; |
| 109 | template<class C> |
| 108 | 110 | class optional_param; |
| 111 | template<class C> |
| 109 | 112 | class required_param; |
| 110 | 113 | class on_device_start; |
| 111 | 114 | |
| r26422 | r26423 | |
| 190 | 193 | }; |
| 191 | 194 | |
| 192 | 195 | // optional device finder |
| 193 | | class netlist_mame_device::optional_output : public netlist_mame_device::output_finder<false, netlist_output_t> |
| 196 | template<class C> |
| 197 | class netlist_mame_device::optional_output : public netlist_mame_device::output_finder<false, C> |
| 194 | 198 | { |
| 195 | 199 | public: |
| 196 | | optional_output(device_t &base, const char *tag, const char *output) : output_finder<false, netlist_output_t>(base, tag, output) { } |
| 200 | optional_output(device_t &base, const char *tag, const char *output) : output_finder<false, C>(base, tag, output) { } |
| 197 | 201 | |
| 198 | 202 | virtual ~optional_output() {}; |
| 199 | 203 | |
| 200 | 204 | virtual bool OnDeviceStart() |
| 201 | 205 | { |
| 202 | | this->m_target = dynamic_cast<netlist_output_t *>(&m_netlist->setup().find_terminal(m_output, netlist_object_t::OUTPUT)); |
| 206 | this->m_target = dynamic_cast<C *>(&this->m_netlist->setup().find_terminal(this->m_output, netlist_object_t::OUTPUT)); |
| 203 | 207 | return this->report_missing(this->m_target != NULL, "output", false); |
| 204 | 208 | } |
| 205 | 209 | |
| r26422 | r26423 | |
| 216 | 220 | |
| 217 | 221 | virtual bool OnDeviceStart() |
| 218 | 222 | { |
| 219 | | this->m_target = (C *) &(this->m_netlist->setup().find_terminal(this->m_output, netlist_object_t::OUTPUT)); |
| 223 | this->m_target = dynamic_cast<C *>(&this->m_netlist->setup().find_terminal(this->m_output, netlist_object_t::OUTPUT)); |
| 220 | 224 | return this->report_missing(this->m_target != NULL, "output", true); |
| 221 | 225 | } |
| 222 | 226 | |
| 223 | 227 | }; |
| 224 | 228 | |
| 225 | 229 | // optional device finder |
| 226 | | class netlist_mame_device::optional_param : public netlist_mame_device::output_finder<false, netlist_param_t> |
| 230 | template<class C> |
| 231 | class netlist_mame_device::optional_param : public netlist_mame_device::output_finder<false, C> |
| 227 | 232 | { |
| 228 | 233 | public: |
| 229 | | optional_param(device_t &base, const char *tag, const char *output) : output_finder<false, netlist_param_t>(base, tag, output) { } |
| 234 | optional_param(device_t &base, const char *tag, const char *output) : output_finder<false, C>(base, tag, output) { } |
| 230 | 235 | |
| 231 | 236 | virtual bool OnDeviceStart() |
| 232 | 237 | { |
| 233 | | this->m_target = &m_netlist->setup().find_param(m_output); |
| 238 | this->m_target = dynamic_cast<C *>(&this->m_netlist->setup().find_param(this->m_output)); |
| 234 | 239 | return this->report_missing(this->m_target != NULL, "parameter", false); |
| 235 | 240 | } |
| 236 | 241 | |
| 237 | 242 | }; |
| 238 | 243 | |
| 239 | 244 | // required devices are similar but throw an error if they are not found |
| 240 | | class netlist_mame_device::required_param : public netlist_mame_device::output_finder<true, netlist_param_t> |
| 245 | template<class C> |
| 246 | class netlist_mame_device::required_param : public netlist_mame_device::output_finder<true, C> |
| 241 | 247 | { |
| 242 | 248 | public: |
| 243 | | required_param(device_t &base, const char *tag, const char *output) : output_finder<true, netlist_param_t>(base, tag, output) { } |
| 249 | required_param(device_t &base, const char *tag, const char *output) : output_finder<true, C>(base, tag, output) { } |
| 244 | 250 | |
| 245 | 251 | virtual bool OnDeviceStart() |
| 246 | 252 | { |
| 247 | | this->m_target = &m_netlist->setup().find_param(m_output); |
| 253 | this->m_target = dynamic_cast<C *>( &this->m_netlist->setup().find_param(this->m_output)); |
| 248 | 254 | return this->report_missing(this->m_target != NULL, "parameter", true); |
| 249 | 255 | } |
| 250 | 256 | }; |
trunk/src/emu/netlist/devices/net_lib.c
| r26422 | r26423 | |
| 93 | 93 | m_low.net().register_con(m_I[i]); |
| 94 | 94 | //m_I[i].set_net(m_low.m_net); |
| 95 | 95 | } |
| 96 | | register_param("POS", m_POS); |
| 96 | register_param("POS", m_POS, 0); |
| 97 | 97 | register_output("Q", m_Q); |
| 98 | 98 | |
| 99 | 99 | m_variable_input_count = true; |
| r26422 | r26423 | |
| 107 | 107 | |
| 108 | 108 | NETLIB_UPDATE_PARAM(nicMultiSwitch) |
| 109 | 109 | { |
| 110 | | m_position = m_POS.ValueInt(); |
| 110 | m_position = m_POS.Value(); |
| 111 | 111 | //update(); |
| 112 | 112 | } |
| 113 | 113 | |
| r26422 | r26423 | |
| 189 | 189 | register_input("CV", m_CV); |
| 190 | 190 | |
| 191 | 191 | register_output("Q", m_Q); |
| 192 | | register_param("R", m_R); |
| 193 | | register_param("C", m_C); |
| 192 | register_param("R", m_R, 0.0); |
| 193 | register_param("C", m_C, 0.0); |
| 194 | 194 | register_param("VS", m_VS, 5.0); |
| 195 | 195 | register_param("VL", m_VL, 0.0 *5.0); |
| 196 | 196 | |
trunk/src/emu/netlist/devices/net_lib.h
| r26422 | r26423 | |
| 218 | 218 | netlist_analog_output_t m_Q; |
| 219 | 219 | netlist_analog_output_t m_low; |
| 220 | 220 | |
| 221 | | netlist_param_t m_POS; |
| 221 | netlist_param_int_t m_POS; |
| 222 | 222 | |
| 223 | 223 | int m_position; |
| 224 | 224 | ); |
| r26422 | r26423 | |
| 237 | 237 | netlist_analog_output_t m_Q; |
| 238 | 238 | netlist_analog_output_t m_low; |
| 239 | 239 | |
| 240 | | netlist_param_t m_R[8]; |
| 240 | netlist_param_double_t m_R[8]; |
| 241 | 241 | |
| 242 | 242 | double m_w[8]; |
| 243 | 243 | ); |
| r26422 | r26423 | |
| 260 | 260 | netlist_analog_output_t m_THRESHOLD_OUT; /* internal */ |
| 261 | 261 | |
| 262 | 262 | //netlist_base_timer_t *m_timer; |
| 263 | | netlist_param_t m_R; |
| 264 | | netlist_param_t m_C; |
| 265 | | netlist_param_t m_VS; |
| 266 | | netlist_param_t m_VL; |
| 263 | netlist_param_double_t m_R; |
| 264 | netlist_param_double_t m_C; |
| 265 | netlist_param_double_t m_VS; |
| 266 | netlist_param_double_t m_VL; |
| 267 | 267 | |
| 268 | 268 | double nicNE555N_cv(); |
| 269 | 269 | double nicNE555N_clamp(const double v, const double a, const double b); |
trunk/src/emu/netlist/devices/nld_system.c
| r26422 | r26423 | |
| 12 | 12 | NETLIB_START(ttl_const) |
| 13 | 13 | { |
| 14 | 14 | register_output("Q", m_Q); |
| 15 | | register_param("CONST", m_const, 0.0); |
| 15 | register_param("CONST", m_const, 0); |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | NETLIB_UPDATE(ttl_const) |
| r26422 | r26423 | |
| 21 | 21 | |
| 22 | 22 | NETLIB_UPDATE_PARAM(ttl_const) |
| 23 | 23 | { |
| 24 | | OUTLOGIC(m_Q, m_const.ValueInt(), NLTIME_IMMEDIATE); |
| 24 | OUTLOGIC(m_Q, m_const.Value(), NLTIME_IMMEDIATE); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | NETLIB_START(analog_const) |
| r26422 | r26423 | |
| 59 | 59 | register_output("Q", m_Q); |
| 60 | 60 | //register_input("FB", m_feedback); |
| 61 | 61 | |
| 62 | | register_param("FREQ", m_freq, 7159000.0 * 5); |
| 62 | register_param("FREQ", m_freq, 7159000.0 * 5.0); |
| 63 | 63 | m_inc = netlist_time::from_hz(m_freq.Value()*2); |
| 64 | 64 | |
| 65 | 65 | register_link_internal(m_feedback, m_Q, netlist_input_t::STATE_INP_ACTIVE); |
| r26422 | r26423 | |
| 85 | 85 | register_output("Q", m_Q); |
| 86 | 86 | //register_input("FB", m_feedback); |
| 87 | 87 | |
| 88 | | register_param("FREQ", m_freq, 50000); |
| 88 | register_param("FREQ", m_freq, 50000.0); |
| 89 | 89 | m_inc = netlist_time::from_hz(m_freq.Value()); |
| 90 | 90 | |
| 91 | 91 | register_link_internal(m_feedback, m_Q, netlist_input_t::STATE_INP_ACTIVE); |
trunk/src/emu/netlist/devices/nld_system.h
| r26422 | r26423 | |
| 57 | 57 | |
| 58 | 58 | NETLIB_DEVICE_WITH_PARAMS(ttl_const, |
| 59 | 59 | netlist_ttl_output_t m_Q; |
| 60 | | netlist_param_t m_const; |
| 60 | netlist_param_logic_t m_const; |
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | 63 | NETLIB_DEVICE_WITH_PARAMS(analog_const, |
| 64 | 64 | netlist_analog_output_t m_Q; |
| 65 | | netlist_param_t m_const; |
| 65 | netlist_param_double_t m_const; |
| 66 | 66 | ); |
| 67 | 67 | |
| 68 | 68 | // ---------------------------------------------------------------------------------------- |
| r26422 | r26423 | |
| 73 | 73 | public: |
| 74 | 74 | netlist_ttl_output_t m_Q; |
| 75 | 75 | |
| 76 | | netlist_param_t m_freq; |
| 76 | netlist_param_double_t m_freq; |
| 77 | 77 | netlist_time m_inc; |
| 78 | 78 | |
| 79 | 79 | ATTR_HOT inline static void mc_update(netlist_net_t &net, const netlist_time curtime); |
| r26422 | r26423 | |
| 87 | 87 | netlist_ttl_input_t m_feedback; |
| 88 | 88 | netlist_ttl_output_t m_Q; |
| 89 | 89 | |
| 90 | | netlist_param_t m_freq; |
| 90 | netlist_param_double_t m_freq; |
| 91 | 91 | netlist_time m_inc; |
| 92 | 92 | ); |
| 93 | 93 | |
| r26422 | r26423 | |
| 102 | 102 | netlist_ttl_input_t m_feedback; |
| 103 | 103 | netlist_ttl_output_t m_Q; |
| 104 | 104 | |
| 105 | | netlist_param_t m_freq; |
| 105 | netlist_param_double_t m_freq; |
| 106 | 106 | |
| 107 | 107 | netlist_time m_inc; |
| 108 | 108 | netlist_time m_last_step; |
| r26422 | r26423 | |
| 206 | 206 | { |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | | netlist_param_t m_R; |
| 209 | netlist_param_double_t m_R; |
| 210 | 210 | |
| 211 | 211 | protected: |
| 212 | 212 | void start() |
| r26422 | r26423 | |
| 233 | 233 | { |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | | netlist_param_t m_C; |
| 236 | netlist_param_double_t m_C; |
| 237 | 237 | |
| 238 | 238 | protected: |
| 239 | 239 | void start() |
| r26422 | r26423 | |
| 266 | 266 | { |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | | netlist_param_t m_Vt; |
| 270 | | netlist_param_t m_Is; |
| 271 | | netlist_param_t m_Rmin; |
| 269 | netlist_param_double_t m_Vt; |
| 270 | netlist_param_double_t m_Is; |
| 271 | netlist_param_double_t m_Rmin; |
| 272 | 272 | |
| 273 | 273 | double m_VtInv; |
| 274 | 274 | double m_Vcrit; |
trunk/src/emu/netlist/nl_base.c
| r26422 | r26423 | |
| 326 | 326 | register_link_internal(*this, in, out, aState); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | | ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &name, netlist_param_t ¶m, double initialVal) |
| 329 | template <class C, class T> |
| 330 | ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, C ¶m, const T initialVal) |
| 330 | 331 | { |
| 331 | | param.set_netdev(dev); |
| 332 | | param.initial(initialVal); |
| 333 | | m_setup->register_object(*this, *this, name, param, netlist_terminal_t::STATE_NONEX); |
| 332 | param.set_netdev(dev); |
| 333 | param.initial(initialVal); |
| 334 | m_setup->register_object(*this, *this, sname, param, netlist_terminal_t::STATE_NONEX); |
| 334 | 335 | } |
| 335 | 336 | |
| 336 | | ATTR_COLD void netlist_device_t::register_param(const pstring &name, netlist_param_t ¶m, double initialVal) |
| 337 | | { |
| 338 | | register_param(*this,name, param, initialVal); |
| 339 | | } |
| 337 | template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_double_t ¶m, const double initialVal); |
| 338 | template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_int_t ¶m, const int initialVal); |
| 339 | template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_logic_t ¶m, const int initialVal); |
| 340 | 340 | |
| 341 | |
| 341 | 342 | // ---------------------------------------------------------------------------------------- |
| 342 | 343 | // net_net_t |
| 343 | 344 | // ---------------------------------------------------------------------------------------- |
trunk/src/emu/netlist/nl_base.h
| r26422 | r26423 | |
| 714 | 714 | virtual void update() { } |
| 715 | 715 | virtual void start() { } |
| 716 | 716 | |
| 717 | | ATTR_COLD void register_param(const pstring &sname, netlist_param_t ¶m, const double initialVal = 0.0); |
| 718 | | ATTR_COLD void register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_t ¶m, const double initialVal = 0.0); |
| 717 | template <class C, class T> |
| 718 | ATTR_COLD void register_param(const pstring &sname, C ¶m, const T initialVal) |
| 719 | { |
| 720 | register_param(*this, sname, param, initialVal); |
| 721 | } |
| 719 | 722 | |
| 723 | template <class C, class T> |
| 724 | ATTR_COLD void register_param(netlist_core_device_t &dev, const pstring &sname, C ¶m, const T initialVal); |
| 725 | |
| 720 | 726 | netlist_setup_t *m_setup; |
| 721 | 727 | bool m_variable_input_count; |
| 722 | 728 | |
| r26422 | r26423 | |
| 726 | 732 | class netlist_param_t : public netlist_object_t |
| 727 | 733 | { |
| 728 | 734 | public: |
| 729 | | netlist_param_t() |
| 735 | |
| 736 | enum param_type_t { |
| 737 | STRING, |
| 738 | DOUBLE, |
| 739 | INTEGER, |
| 740 | LOGIC |
| 741 | }; |
| 742 | |
| 743 | netlist_param_t(const param_type_t atype) |
| 730 | 744 | : netlist_object_t(PARAM, ANALOG) |
| 731 | | , m_param(0.0) |
| 745 | , m_param_type(atype) |
| 732 | 746 | , m_netdev(NULL) |
| 733 | 747 | { } |
| 734 | 748 | |
| 735 | | ATTR_HOT inline void setTo(const double param) { m_param = param; m_netdev->update_param(); } |
| 736 | | ATTR_HOT inline void setTo(const int param) { m_param = param; m_netdev->update_param(); } |
| 737 | | ATTR_COLD inline void initial(const double val) { m_param = val; } |
| 738 | | ATTR_COLD inline void initial(const int val) { m_param = val; } |
| 739 | 749 | |
| 740 | | ATTR_HOT inline const double Value() const { return m_param; } |
| 741 | | ATTR_HOT inline const int ValueInt() const { return (int) m_param; } |
| 742 | | |
| 750 | ATTR_HOT inline const param_type_t param_type() const { return m_param_type; } |
| 743 | 751 | ATTR_HOT inline netlist_core_device_t &netdev() const { return *m_netdev; } |
| 744 | 752 | ATTR_COLD void set_netdev(netlist_core_device_t &dev) { m_netdev = &dev; } |
| 745 | 753 | |
| 746 | 754 | private: |
| 747 | | |
| 748 | | double m_param; |
| 755 | const param_type_t m_param_type; |
| 749 | 756 | netlist_core_device_t *m_netdev; |
| 750 | 757 | }; |
| 751 | 758 | |
| 759 | class netlist_param_double_t : public netlist_param_t |
| 760 | { |
| 761 | public: |
| 762 | netlist_param_double_t() |
| 763 | : netlist_param_t(DOUBLE) |
| 764 | , m_param(0.0) |
| 765 | { } |
| 752 | 766 | |
| 767 | ATTR_HOT inline void setTo(const double param) { m_param = param; netdev().update_param(); } |
| 768 | ATTR_COLD inline void initial(const double val) { m_param = val; } |
| 769 | ATTR_HOT inline const double Value() const { return m_param; } |
| 770 | |
| 771 | private: |
| 772 | double m_param; |
| 773 | }; |
| 774 | |
| 775 | class netlist_param_int_t : public netlist_param_t |
| 776 | { |
| 777 | public: |
| 778 | netlist_param_int_t() |
| 779 | : netlist_param_t(INTEGER) |
| 780 | , m_param(0) |
| 781 | { } |
| 782 | |
| 783 | ATTR_HOT inline void setTo(const int param) { m_param = param; netdev().update_param(); } |
| 784 | ATTR_COLD inline void initial(const int val) { m_param = val; } |
| 785 | |
| 786 | ATTR_HOT inline const int Value() const { return m_param; } |
| 787 | |
| 788 | private: |
| 789 | int m_param; |
| 790 | }; |
| 791 | |
| 792 | class netlist_param_logic_t : public netlist_param_int_t |
| 793 | { |
| 794 | public: |
| 795 | netlist_param_logic_t() |
| 796 | : netlist_param_int_t() |
| 797 | { } |
| 798 | }; |
| 799 | |
| 753 | 800 | // ---------------------------------------------------------------------------------------- |
| 754 | 801 | // netlist_base_t |
| 755 | 802 | // ---------------------------------------------------------------------------------------- |
trunk/src/emu/netlist/nl_setup.c
| r26422 | r26423 | |
| 167 | 167 | const pstring val = m_params_temp.find(temp); |
| 168 | 168 | if (val != "") |
| 169 | 169 | { |
| 170 | | //printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr()); |
| 171 | | double vald = 0; |
| 172 | | if (sscanf(val.cstr(), "%lf", &vald) != 1) |
| 173 | | fatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr()); |
| 174 | | param.initial(vald); |
| 170 | switch (param.param_type()) |
| 171 | { |
| 172 | case netlist_param_t::DOUBLE: |
| 173 | { |
| 174 | //printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr()); |
| 175 | double vald = 0; |
| 176 | if (sscanf(val.cstr(), "%lf", &vald) != 1) |
| 177 | fatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr()); |
| 178 | dynamic_cast<netlist_param_double_t &>(param).initial(vald); |
| 179 | } |
| 180 | break; |
| 181 | case netlist_param_t::INTEGER: |
| 182 | case netlist_param_t::LOGIC: |
| 183 | { |
| 184 | //printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr()); |
| 185 | int vald = 0; |
| 186 | if (sscanf(val.cstr(), "%d", &vald) != 1) |
| 187 | fatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr()); |
| 188 | dynamic_cast<netlist_param_int_t &>(param).initial(vald); |
| 189 | } |
| 190 | break; |
| 191 | default: |
| 192 | fatalerror("Parameter is not supported %s : %s\n", temp.cstr(), val.cstr()); |
| 193 | } |
| 175 | 194 | } |
| 176 | 195 | if (!(m_params.add(temp, ¶m, false)==TMERR_NONE)) |
| 177 | 196 | fatalerror("Error adding parameter %s to parameter list\n", name.cstr()); |