Previous 199869 Revisions Next

r26668 Friday 20th December, 2013 at 15:54:48 UTC by Couriersud
Netlist and Pong:
- Added save-state support.
- Fixed a compile issue with MSVC

The state saving is now 80% generic. This still needs some polishing, but works.
[src/emu/machine]netlist.c netlist.h
[src/emu/netlist]nl_base.c nl_base.h nl_lists.h nl_setup.c nl_setup.h nl_time.h
[src/emu/netlist/devices]net_lib.c nld_7483.c nld_7490.c nld_7493.c nld_9316.c nld_legacy.c nld_log.c nld_ne555.c nld_signal.h nld_solver.c nld_solver.h nld_twoterm.c nld_twoterm.h
[src/emu/video]fixfreq.c
[src/mame/drivers]pong.c

trunk/src/emu/machine/netlist.c
r26667r26668
5050#include "netlist/nl_setup.h"
5151#include "netlist/devices/net_lib.h"
5252
53#define LOG_DEV_CALLS(x)   do { } while (0);
53//#define LOG_DEV_CALLS(x)   printf x
54#define LOG_DEV_CALLS(x)   do { } while (0)
5455
5556// ----------------------------------------------------------------------------------------
5657// netlist_mame_device
r26667r26668
6162netlist_mame_device::netlist_mame_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
6263   : device_t(mconfig, NETLIST, "netlist", tag, owner, clock, "netlist_mame", __FILE__),
6364      device_execute_interface(mconfig, *this),
65        //device_state_interface(mconfig, *this),
6466      m_device_start_list(100),
6567      m_netlist(NULL),
6668      m_setup(NULL),
r26667r26668
8688    LOG_DEV_CALLS(("device_start\n"));
8789
8890   m_netlist = global_alloc_clear(netlist_mame_t(*this));
89   m_netlist->set_clock_freq(this->clock());
90
9191   m_setup = global_alloc_clear(netlist_setup_t(*m_netlist));
92    m_netlist->init_object(*m_netlist, "netlist");
93    m_setup->init();
9294
93   // register additional devices
95    m_netlist->set_clock_freq(this->clock());
9496
97    // register additional devices
98
9599   m_setup->factory().register_device<nld_analog_callback>( "NETDEV_CALLBACK", "nld_analog_callback");
96100
97101   m_setup_func(*m_setup);
r26667r26668
107111        m_netlist->xfatalerror("required elements not found\n");
108112
109113   save_state();
110   /* TODO: we have to save the round robin queue as well */
111114
112115   // set our instruction counter
113116   m_icountptr = &m_icount;
r26667r26668
130133   m_netlist = NULL;
131134}
132135
133void netlist_mame_device::device_post_load()
136ATTR_COLD void netlist_mame_device::device_post_load()
134137{
138    LOG_DEV_CALLS(("device_post_load\n"));
139    m_netlist->queue().clear();
140    NL_VERBOSE_OUT(("current time %f qsize %d\n", m_netlist->time().as_double(), qsize));
141    for (int i = 0; i < qsize; i++ )
142    {
143        netlist_net_t *n = m_netlist->find_net(qtemp[i].m_name);
144        NL_VERBOSE_OUT(("Got %s ==> %p\n", qtemp[i].m_name, n));
145        NL_VERBOSE_OUT(("schedule time %f (%f)\n", n->time().as_double(), qtemp[i].m_time.as_double()));
146        m_netlist->queue().push(netlist_base_t::queue_t::entry_t(qtemp[i].m_time, *n));
147    }
135148}
136149
150ATTR_COLD void netlist_mame_device::device_pre_save()
151{
152    LOG_DEV_CALLS(("device_pre_save\n"));
153
154    qsize = m_netlist->queue().count();
155    NL_VERBOSE_OUT(("current time %f qsize %d\n", m_netlist->time().as_double(), qsize));
156    for (int i = 0; i < qsize; i++ )
157    {
158        qtemp[i].m_time =  m_netlist->queue().listptr()[i].time();
159        const char *p = m_netlist->queue().listptr()[i].object().name().cstr();
160        int n = MIN(63, strlen(p));
161        strncpy(qtemp[i].m_name, p, n);
162        qtemp[i].m_name[n] = 0;
163    }
164#if 0
165
166    netlist_time *nlt = (netlist_time *) ;
167    netlist_base_t::queue_t::entry_t *p = m_netlist->queue().listptr()[i];
168    netlist_time *nlt = (netlist_time *) p->time_ptr();
169    save_pointer(nlt->get_internaltype_ptr(), "queue", 1, i);
170#endif
171}
172
137173void netlist_mame_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
138174{
139175}
140176
141void netlist_mame_device::save_state()
177
178
179ATTR_COLD void netlist_mame_device::save_state()
142180{
181    for (netlist_setup_t::save_entry_list_t::entry_t *p = setup().m_save.first(); p != NULL; p = setup().m_save.next(p))
182    {
183        netlist_setup_t::save_entry_t *s = p->object();
184        NL_VERBOSE_OUT(("saving state for %s\n", s->m_name.cstr()));
185        switch (s->m_dt)
186        {
187            case DT_DOUBLE:
188                save_pointer((double *) s->m_ptr, s->m_name, 1);
189                break;
190            case DT_INT64:
191                save_pointer((INT64 *) s->m_ptr, s->m_name, 1);
192                break;
193            case DT_INT8:
194                save_pointer((INT8 *) s->m_ptr, s->m_name, 1);
195                break;
196            case DT_INT:
197                save_pointer((int *) s->m_ptr, s->m_name, 1);
198                break;
199            case DT_BOOLEAN:
200                save_pointer((bool *) s->m_ptr, s->m_name, 1);
201                break;
143202#if 0
144   for (netlist_setup_t::tagmap_output_t::entry_t *entry = m_setup->m_outputs.first(); entry != NULL; entry = m_setup->m_outputs.next(entry))
145   {
146      save_item(*entry->object()->Q_ptr(), entry->tag().cstr(), 0);
147      save_item(*entry->object()->new_Q_ptr(), entry->tag().cstr(), 1);
148   }
203            case DT_NLTIME:
204                {
205                    netlist_time *nlt = (netlist_time *) s->m_ptr;
206                    //save_pointer((netlist_time::INTERNALTYPE *) s->m_ptr, s->m_name, 1);
207                    //save_pointer(nlt->get_internaltype_ptr(), s->m_name, 1);
208                    save_item(*nlt->get_internaltype_ptr(), s->m_name.cstr());
209                }
210                break;
149211#endif
212            case NOT_SUPPORTED:
213            default:
214                m_netlist->xfatalerror("found unsupported save element %s\n", s->m_name.cstr());
215                break;
216        }
217    }
218
219    // handle the queue
220
221    save_item(NAME(qsize));
222    for (int i = 0; i < m_netlist->queue().capacity(); i++ )
223    {
224        save_pointer(qtemp[i].m_time.get_internaltype_ptr(), "queue_time", 1, i);
225        save_pointer(qtemp[i].m_name, "queue_name", sizeof(qtemp[i].m_name), i);
226
227    }
228#if 0
229
230    netlist_time *nlt = (netlist_time *) ;
231    netlist_base_t::queue_t::entry_t *p = m_netlist->queue().listptr()[i];
232    netlist_time *nlt = (netlist_time *) p->time_ptr();
233    save_pointer(nlt->get_internaltype_ptr(), "queue", 1, i);
234#endif
150235}
151236
152UINT64 netlist_mame_device::execute_clocks_to_cycles(UINT64 clocks) const
237ATTR_COLD UINT64 netlist_mame_device::execute_clocks_to_cycles(UINT64 clocks) const
153238{
154239   return clocks;
155240}
156241
157UINT64 netlist_mame_device::execute_cycles_to_clocks(UINT64 cycles) const
242ATTR_COLD UINT64 netlist_mame_device::execute_cycles_to_clocks(UINT64 cycles) const
158243{
159244   return cycles;
160245}
r26667r26668
169254   //  debugger_instruction_hook(this, 0); //m_pc);
170255
171256   m_netlist->process_queue(m_icount);
172
173257}
trunk/src/emu/machine/netlist.h
r26667r26668
122122
123123class netlist_mame_device : public device_t,
124124                      public device_execute_interface
125                          //public device_state_interface
125126                      //, public device_memory_interface
126127{
127128public:
r26667r26668
158159   virtual void device_stop();
159160   virtual void device_reset();
160161   virtual void device_post_load();
162    virtual void device_pre_save();
161163   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
162164   virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const;
163165   virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const;
r26667r26668
168170
169171   netlist_setup_t *m_setup;
170172
173// more save state ... needs to go somewhere else
174
175   struct qentry {
176        netlist_time m_time;
177       char m_name[64];
178   };
179
180   qentry qtemp[1024];
181   int qsize;
182
171183private:
172184
173185   void save_state();
trunk/src/emu/netlist/nl_base.h
r26667r26668
247247class NETLIB_NAME(mainclock);
248248
249249// ----------------------------------------------------------------------------------------
250// state saving ...
251// ----------------------------------------------------------------------------------------
252
253enum netlist_data_type_e {
254    NOT_SUPPORTED,
255    DT_DOUBLE,
256    DT_INT64,
257    DT_INT8,
258    DT_INT,
259    DT_BOOLEAN
260};
261
262template<typename _ItemType> struct nl_datatype { static const netlist_data_type_e type = netlist_data_type_e(NOT_SUPPORTED); };
263//template<typename _ItemType> struct type_checker<_ItemType*> { static const bool is_atom = false; static const bool is_pointer = true; };
264
265#define NETLIST_SAVE_TYPE(TYPE, TYPEDESC) template<> struct nl_datatype<TYPE>{ static const netlist_data_type_e type = netlist_data_type_e(TYPEDESC); }
266
267NETLIST_SAVE_TYPE(double, DT_DOUBLE);
268NETLIST_SAVE_TYPE(INT8, DT_INT8);
269NETLIST_SAVE_TYPE(UINT8, DT_INT8);
270NETLIST_SAVE_TYPE(INT64, DT_INT64);
271NETLIST_SAVE_TYPE(UINT64, DT_INT64);
272NETLIST_SAVE_TYPE(bool, DT_BOOLEAN);
273NETLIST_SAVE_TYPE(UINT32, DT_INT);
274NETLIST_SAVE_TYPE(INT32, DT_INT);
275
276// ----------------------------------------------------------------------------------------
250277// netlist_object_t
251278// ----------------------------------------------------------------------------------------
252279
r26667r26668
261288      PARAM    = 3,
262289      NET      = 4,
263290        DEVICE   = 5,
291        NETLIST   = 6,
264292   };
265293    enum family_t {
266294        // Terminal families
r26667r26668
285313
286314    ATTR_COLD const pstring &name() const;
287315
316    ATTR_COLD void save_state_ptr(const pstring &stname, const netlist_data_type_e, const int size, void *ptr);
317    template<class C> ATTR_COLD void save(C &state, const pstring &stname)
318    {
319        save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), &state);
320    }
321
288322   ATTR_HOT inline const type_t type() const { return m_objtype; }
289323    ATTR_HOT inline const family_t family() const { return m_family; }
290324
r26667r26668
294328    ATTR_HOT inline netlist_base_t & RESTRICT netlist() { return *m_netlist; }
295329    ATTR_HOT inline const netlist_base_t & RESTRICT netlist() const { return *m_netlist; }
296330
331protected:
332
333    // must call parent save_register !
334    ATTR_COLD virtual void save_register() { };
335
297336private:
298337    pstring m_name;
299338   const type_t m_objtype;
r26667r26668
301340    netlist_base_t * RESTRICT m_netlist;
302341};
303342
343template<> ATTR_COLD inline void netlist_object_t::save(netlist_time &state, const pstring &stname)
344{
345    save_state_ptr(stname, DT_INT64, sizeof(netlist_time::INTERNALTYPE), state.get_internaltype_ptr());
346}
347
304348// ----------------------------------------------------------------------------------------
305349// netlist_owned_object_t
306350// ----------------------------------------------------------------------------------------
r26667r26668
338382        STATE_NONEX = 256
339383    };
340384
385
341386   ATTR_COLD netlist_core_terminal_t(const type_t atype, const family_t afamily);
342387
343388   ATTR_COLD void init_object(netlist_core_device_t &dev, const pstring &aname, const state_e astate);
r26667r26668
357402
358403    netlist_core_terminal_t *m_update_list_next;
359404
405protected:
406    ATTR_COLD virtual void save_register() { save(NAME(m_state)); netlist_owned_object_t::save_register(); }
407
360408private:
361409    netlist_net_t * RESTRICT m_net;
362410    state_e m_state;
363411};
364412
413NETLIST_SAVE_TYPE(netlist_core_terminal_t::state_e, DT_INT);
414
415
365416class netlist_terminal_t : public netlist_core_terminal_t
366417{
367418    NETLIST_PREVENT_COPYING(netlist_terminal_t)
r26667r26668
394445
395446
396447    netlist_terminal_t *m_otherterm;
448
449protected:
450    ATTR_COLD virtual void save_register()
451    {
452        save(NAME(m_Idr));
453        save(NAME(m_go));
454        save(NAME(m_gt));
455        netlist_core_terminal_t::save_register();
456    }
457
397458};
398459
399460
r26667r26668
502563    };
503564
504565    ATTR_COLD netlist_net_t(const type_t atype, const family_t afamily);
566    ATTR_COLD void init_object(netlist_base_t &nl, const pstring &aname);
505567
506568    ATTR_COLD void register_con(netlist_core_terminal_t &terminal);
507569    ATTR_COLD void merge_net(netlist_net_t *othernet);
r26667r26668
568630
569631    UINT32 m_num_cons;
570632
633protected:
634    ATTR_COLD virtual void save_register()
635    {
636        save(NAME(m_last.Analog));
637        save(NAME(m_cur.Analog));
638        save(NAME(m_new.Analog));
639        save(NAME(m_last.Q));
640        save(NAME(m_cur.Q));
641        save(NAME(m_new.Q));
642        save(NAME(m_time));
643        save(NAME(m_active));
644        save(NAME(m_in_queue));
645        netlist_object_t::save_register();
646    }
647
571648private:
572649    ATTR_HOT void update_dev(const netlist_core_terminal_t *inp, const UINT32 mask) const;
573650
r26667r26668
688765    ATTR_COLD inline void initial(const double val) { m_param = val; }
689766    ATTR_HOT inline const double Value() const        { return m_param;   }
690767
768protected:
769    ATTR_COLD virtual void save_register()
770    {
771        save(NAME(m_param));
772        netlist_param_t::save_register();
773    }
774
691775private:
692776    double m_param;
693777};
r26667r26668
703787
704788    ATTR_HOT inline const int Value() const     { return m_param;     }
705789
790protected:
791    ATTR_COLD virtual void save_register()
792    {
793        save(NAME(m_param));
794        netlist_param_t::save_register();
795    }
796
706797private:
707798    int m_param;
708799};
r26667r26668
832923protected:
833924
834925   ATTR_HOT virtual void update() { }
835   ATTR_HOT virtual void start() { }
926   ATTR_COLD virtual void start() { }
836927
837928private:
838929};
r26667r26668
892983
893984typedef tagmap_t<netlist_device_t *, 393> tagmap_devices_t;
894985
895class netlist_base_t
986class netlist_base_t : public netlist_object_t
896987{
897988    NETLIST_PREVENT_COPYING(netlist_base_t)
898989public:
r26667r26668
9201011    ATTR_COLD void set_solver_dev(NETLIB_NAME(solver) *dev);
9211012    ATTR_COLD void set_setup(netlist_setup_t *asetup) { m_setup = asetup;  }
9221013
1014    ATTR_COLD netlist_net_t *find_net(const pstring &name);
1015
9231016    ATTR_COLD void set_clock_freq(UINT64 clockfreq);
9241017
9251018    ATTR_COLD netlist_setup_t &setup() { return *m_setup; }
r26667r26668
9281021   ATTR_COLD void xfatalerror(const char *format, ...) const;
9291022
9301023    tagmap_devices_t m_devices;
1024    netlist_net_t::list_t m_nets;
9311025
9321026protected:
9331027
9341028   // any derived netlist must override this ...
9351029   virtual void vfatalerror(const char *format, va_list ap) const = 0;
1030
1031protected:
1032    ATTR_COLD virtual void save_register()
1033    {
1034        //queue_t                     m_queue;
1035        save(NAME(m_time_ps));
1036        save(NAME(m_rem));
1037        save(NAME(m_div));
1038        netlist_object_t::save_register();
1039    }
1040
9361041#if (NL_KEEP_STATISTICS)
9371042   // performance
9381043   int m_perf_out_processed;
r26667r26668
9781083protected:
9791084   ATTR_COLD void start()
9801085   {
981      m_I.init_object(*this, "I", netlist_terminal_t::STATE_INP_ACTIVE);
982
983      m_Q.init_object(*this, "Q");
1086       register_input("I", m_I, netlist_terminal_t::STATE_INP_ACTIVE);
1087       register_output("Q", m_Q);
9841088      m_Q.initial(1);
9851089   }
9861090
r26667r26668
10201124protected:
10211125   ATTR_COLD void start()
10221126   {
1023      m_I.init_object(*this, "I", netlist_terminal_t::STATE_INP_ACTIVE);
1024      m_Q.init_object(*this, "Q");
1127        register_input("I", m_I, netlist_terminal_t::STATE_INP_ACTIVE);
1128        register_output("Q", m_Q);
10251129      m_Q.initial(0);
10261130   }
10271131
trunk/src/emu/netlist/nl_setup.c
r26667r26668
3333    , m_proxy_cnt(0)
3434{
3535    netlist.set_setup(this);
36}
37
38void netlist_setup_t::init()
39{
3640    m_factory.initialize();
3741    NETLIST_NAME(base)(*this);
3842}
r26667r26668
4549   m_params.reset();
4650   m_terminals.reset();
4751   m_params_temp.reset();
52   m_save.reset_and_free();
4853
4954   netlist().set_setup(NULL);
5055
r26667r26668
132137        case netlist_terminal_t::DEVICE:
133138            return "DEVICE";
134139            break;
140        case netlist_terminal_t::NETLIST:
141            return "NETLIST";
142            break;
135143    }
136144    // FIXME: noreturn
137145    netlist().xfatalerror("Unknown object type %d\n", in.type());
r26667r26668
161169            break;
162170        case netlist_terminal_t::PARAM:
163171            {
164
165172                netlist_param_t &param = dynamic_cast<netlist_param_t &>(obj);
166                pstring temp = param.netdev().name() + "." + name;
167                const pstring val = m_params_temp.find(temp);
173                const pstring val = m_params_temp.find(name);
168174                if (val != "")
169175                {
170176                    switch (param.param_type())
r26667r26668
174180                            NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", temp.cstr(), val->cstr()));
175181                            double vald = 0;
176182                            if (sscanf(val.cstr(), "%lf", &vald) != 1)
177                                netlist().xfatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr());
183                                netlist().xfatalerror("Invalid number conversion %s : %s\n", name.cstr(), val.cstr());
178184                            dynamic_cast<netlist_param_double_t &>(param).initial(vald);
179185                        }
180186                        break;
181187                        case netlist_param_t::INTEGER:
182188                        case netlist_param_t::LOGIC:
183189                        {
184                            NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", temp.cstr(), val->cstr()));
190                            NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", name.cstr(), val->cstr()));
185191                            int vald = 0;
186192                            if (sscanf(val.cstr(), "%d", &vald) != 1)
187                                netlist().xfatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr());
193                                netlist().xfatalerror("Invalid number conversion %s : %s\n", name.cstr(), val.cstr());
188194                            dynamic_cast<netlist_param_int_t &>(param).initial(vald);
189195                        }
190196                        break;
r26667r26668
213219                        }
214220                        break;
215221                        default:
216                            netlist().xfatalerror("Parameter is not supported %s : %s\n", temp.cstr(), val.cstr());
222                            netlist().xfatalerror("Parameter is not supported %s : %s\n", name.cstr(), val.cstr());
217223                    }
218224                }
219                if (!(m_params.add(temp, &param, false)==TMERR_NONE))
225                if (!(m_params.add(name, &param, false)==TMERR_NONE))
220226                    netlist().xfatalerror("Error adding parameter %s to parameter list\n", name.cstr());
221227            }
222228            break;
223229        case netlist_terminal_t::DEVICE:
230            netlist().xfatalerror("Device registration not yet supported - \n", name.cstr());
224231            break;
232        case netlist_terminal_t::NETLIST:
233            netlist().xfatalerror("Netlist registration not yet supported - \n", name.cstr());
234            break;
225235    }
226236}
227237
r26667r26668
462472        NL_VERBOSE_OUT(("adding net ...\n"));
463473        netlist_net_t *anet =  new netlist_net_t(netlist_object_t::NET, netlist_object_t::ANALOG);
464474        t1.set_net(*anet);
465        m_netlist.solver()->m_nets.add(anet);
475        //m_netlist.solver()->m_nets.add(anet);
466476        // FIXME: Nets should have a unique name
467        t1.net().init_object(netlist(),"some net");
477        t1.net().init_object(netlist(),"net." + t1.name() );
468478        t1.net().register_con(t2);
469479        t1.net().register_con(t1);
470480    }
r26667r26668
533543            //VERBOSE_OUT(("%s %d\n", out->netdev()->name(), *out->Q_ptr()));
534544    }
535545
546#if 0
547    NL_VERBOSE_OUT(("deleting empty nets ...\n"));
548
549    // delete empty nets ...
550    for (netlist_net_t::list_t::entry_t *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn))
551    {
552        if (pn->object()->m_head == NULL)
553        {
554            NL_VERBOSE_OUT(("Deleting net ...\n"));
555            netlist_net_t *to_delete = pn->object();
556            netlist().m_nets.remove(to_delete);
557            if (!to_delete->isRailNet())
558                delete to_delete;
559            pn--;
560        }
561    }
562#endif
536563    if (m_netlist.solver() != NULL)
537564        m_netlist.solver()->post_start();
538565
r26667r26668
578605        netlist_device_t *dev = entry->object();
579606        dev->init(netlist(), entry->tag().cstr());
580607    }
608
581609}
582610
583611void netlist_setup_t::parse(const char *buf)
trunk/src/emu/netlist/nl_time.h
r26667r26668
5050    ATTR_HOT inline const INTERNALTYPE as_raw() const { return m_time; }
5151    ATTR_HOT inline const double as_double() const { return (double) m_time / (double) RESOLUTION; }
5252
53    // for save states ....
54    ATTR_HOT inline INTERNALTYPE *get_internaltype_ptr() { return &m_time; }
55
5356    ATTR_HOT static inline const netlist_time from_nsec(const int ns) { return netlist_time((UINT64) ns * (RESOLUTION / U64(1000000000))); }
5457    ATTR_HOT static inline const netlist_time from_usec(const int us) { return netlist_time((UINT64) us * (RESOLUTION / U64(1000000))); }
5558    ATTR_HOT static inline const netlist_time from_msec(const int ms) { return netlist_time((UINT64) ms * (RESOLUTION / U64(1000))); }
trunk/src/emu/netlist/nl_lists.h
r26667r26668
113113   ATTR_HOT inline bool empty() const { return (m_ptr < m_list); }
114114   ATTR_HOT inline void reset() { m_ptr = m_list - 1; }
115115
116   ATTR_COLD void reset_and_free()
117   {
118        for (entry_t *i = m_list; i <= m_ptr; i++)
119        {
120            delete i->object();
121        }
122        reset();
123   }
124
116125    //ATTR_HOT inline entry_t *item(int i) const { return &m_list[i]; }
117126   ATTR_HOT inline _ListClass& operator[](const int & index) { return m_list[index].m_obj; }
118127    ATTR_HOT inline const _ListClass& operator[](const int & index) const { return m_list[index].m_obj; }
r26667r26668
142151      inline entry_t(const _Time atime, _Element &elem) : m_time(atime), m_object(&elem) {}
143152      ATTR_HOT inline const _Time &time() const { return m_time; }
144153      ATTR_HOT inline _Element & object() const { return *m_object; }
154
155      ATTR_HOT inline const _Time *time_ptr() const { return &m_time; }
156        ATTR_HOT inline _Element *object_ptr() const { return m_object; }
145157   private:
146158      _Time m_time;
147159      _Element *m_object;
r26667r26668
153165      clear();
154166   }
155167
168    ATTR_HOT inline int capacity() const { return _Size; }
156169   ATTR_HOT inline bool is_empty() const { return (m_end == &m_list[0]); }
157170   ATTR_HOT inline bool is_not_empty() const { return (m_end > &m_list[0]); }
158171
r26667r26668
193206      m_end = &m_list[0];
194207   }
195208
209   // save state support
210
211   ATTR_COLD entry_t *listptr() { return &m_list[0]; }
212   ATTR_COLD int count() const { return m_end - m_list; }
213
196214#if (NL_KEEP_STATISTICS)
197215   // profiling
198216   INT32   m_prof_start;
trunk/src/emu/netlist/nl_setup.h
r26667r26668
102102   netlist_setup_t(netlist_base_t &netlist);
103103   ~netlist_setup_t();
104104
105   void init();
106
105107   netlist_base_t &netlist() { return m_netlist; }
106108    const netlist_base_t &netlist() const { return m_netlist; }
107109   netlist_factory &factory() { return m_factory; }
r26667r26668
133135
134136   void print_stats();
135137
138   /* save state */
139
140   struct save_entry_t
141   {
142       save_entry_t(const pstring &stname, const netlist_data_type_e dt, const int size, void *ptr) :
143           m_name(stname), m_dt(dt), m_size(size), m_ptr(ptr) { }
144       pstring m_name;
145       netlist_data_type_e m_dt;
146       int m_size;
147       void *m_ptr;
148   };
149
150   typedef netlist_list_t<save_entry_t *> save_entry_list_t;
151
152   void save_state_ptr(const pstring &stname, const netlist_data_type_e dt, const int size, void *ptr)
153   {
154       save_entry_t *p = new save_entry_t(stname, dt, size, ptr);
155       m_save.add(p);
156   }
157
158   save_entry_list_t m_save;
159
136160protected:
137161
138162private:
trunk/src/emu/netlist/devices/net_lib.c
r26667r26668
118118    register_output("e", m_e);
119119    register_output("f", m_f);
120120    register_output("g", m_g);
121
122    save(NAME(m_state));
121123}
122124
123125NETLIB_UPDATE(nic7448_sub)
r26667r26668
225227
226228    m_Q.initial(0);
227229    m_QQ.initial(1);
230
231    save(NAME(m_Q1));
232    save(NAME(m_Q2));
233    save(NAME(m_F));
228234}
229235
230236NETLIB_START(nic74107A)
trunk/src/emu/netlist/devices/nld_solver.h
r26667r26668
7474
7575        ~NETLIB_NAME(solver)();
7676
77        netlist_net_t::list_t m_nets;
78
7977        ATTR_HOT inline void schedule();
8078
8179        ATTR_COLD void post_start();
trunk/src/emu/netlist/devices/nld_signal.h
r26667r26668
4343         register_input(sIN[i], m_i[i], netlist_input_t::STATE_INP_ACTIVE);
4444      }
4545      m_Q.initial(1);
46      save(NAME(m_active));
4647   }
4748
4849#if (USE_DEACTIVE_DEVICE)
r26667r26668
6970public:
7071   netlist_ttl_input_t m_i[_numdev];
7172   netlist_ttl_output_t m_Q;
72   INT8 m_active;
73   INT32 m_active;
7374};
7475
7576
r26667r26668
9293      {
9394         register_input(sIN[i], m_i[i]);
9495      }
96        save(NAME(m_active));
9597   }
9698
9799   #if (USE_DEACTIVE_DEVICE)
r26667r26668
142144public:
143145   netlist_ttl_input_t m_i[_numdev];
144146   netlist_ttl_output_t m_Q;
145   INT8 m_active;
147   INT32 m_active;
146148};
147149
148150#if 1
r26667r26668
165167      {
166168         register_input(sIN[i], m_i[i], netlist_input_t::STATE_INP_ACTIVE);
167169      }
170        save(NAME(m_active));
168171   }
169172
170173   #if (USE_DEACTIVE_DEVICE)
r26667r26668
214217public:
215218   netlist_ttl_input_t m_i[2];
216219   netlist_ttl_output_t m_Q;
217   INT8 m_active;
220   INT32 m_active;
218221
219222};
220223#endif
trunk/src/emu/netlist/devices/nld_legacy.c
r26667r26668
2121    }
2222    register_param("POS", m_POS, 0);
2323    register_output("Q", m_Q);
24
25    save(NAME(m_position));
26
2427}
2528
2629NETLIB_UPDATE(nicMultiSwitch)
r26667r26668
116119    register_param("VS", m_VS, 5.0);
117120    register_param("VL", m_VL, 0.0 *5.0);
118121
119    m_THRESHOLD_OUT.init_object(*this, "THRESHOLD");
122    m_THRESHOLD_OUT.init_object(*this, name() + "THRESHOLD");
120123    register_link_internal(m_THRESHOLD, m_THRESHOLD_OUT, netlist_input_t::STATE_INP_ACTIVE);
121124
122125    m_Q.initial(5.0 * 0.4);
123126    m_last = false;
127
128    save(NAME(m_last));
129
124130}
125131
126132inline double NETLIB_NAME(nicNE555N_MSTABLE)::nicNE555N_cv()
trunk/src/emu/netlist/devices/nld_7483.c
r26667r26668
2424    register_output("SC", m_SC);
2525    register_output("SD", m_SD);
2626    register_output("C4", m_C4);
27
28    save(NAME(m_lastr));
2729}
2830
2931NETLIB_UPDATE(7483)
trunk/src/emu/netlist/devices/nld_log.c
r26667r26668
66#include "nld_log.h"
77#include "sound/wavwrite.h"
88
9//FIXME: what to do with save states?
10
911NETLIB_START(log)
1012{
1113    register_input("I", m_I);
trunk/src/emu/netlist/devices/nld_twoterm.c
r26667r26668
124124    register_param("model", m_model, "");
125125
126126    m_Vd = 0.7;
127
128    save(NAME(m_Vd));
129
127130}
128131
129132
r26667r26668
197200    setup().connect(m_RB.m_N, m_RC.m_N);
198201    setup().connect(m_RB.m_P, m_BV);
199202    setup().connect(m_RB.m_N, m_EV);
203
204    save(NAME(m_state_on));
200205}
201206
202207NETLIB_UPDATE(Q)
r26667r26668
256261    register_terminal("OP", m_OP);
257262    register_terminal("ON", m_ON);
258263
259    m_OP1.init_object(*this, "OP1", netlist_core_terminal_t::STATE_INP_ACTIVE);
260    m_ON1.init_object(*this, "ON1", netlist_core_terminal_t::STATE_INP_ACTIVE);
264    m_OP1.init_object(*this, name() + ".OP1", netlist_core_terminal_t::STATE_INP_ACTIVE);
265    m_ON1.init_object(*this, name() + ".ON1", netlist_core_terminal_t::STATE_INP_ACTIVE);
261266
262267    const double m_mult = m_G.Value() * Gfac; // 1.0 ==> 1V ==> 1A
263268    m_IP.set(GI);
trunk/src/emu/netlist/devices/nld_ne555.c
r26667r26668
4848    setup().connect(m_RDIS.m_N, m_R3.m_N);
4949
5050    m_last_out = false;
51
52    save(NAME(m_last_out));
5153}
5254
5355NETLIB_UPDATE(NE555)
trunk/src/emu/netlist/devices/nld_9316.c
r26667r26668
4848    register_output("QD", m_QD);
4949    register_output("RC", m_RC);
5050
51    save(NAME(m_cnt));
52    save(NAME(m_loadq));
53    save(NAME(m_ent));
5154}
5255
5356NETLIB_UPDATE(9316_sub)
trunk/src/emu/netlist/devices/nld_7490.c
r26667r26668
1919    register_output("QB", m_Q[1]);
2020    register_output("QC", m_Q[2]);
2121    register_output("QD", m_Q[3]);
22
23    save(NAME(m_cnt));
24
2225}
2326
2427NETLIB_UPDATE(7490)
trunk/src/emu/netlist/devices/nld_twoterm.h
r26667r26668
219219        }
220220        else
221221        {
222            //m_Vd = m_Vd + log((nVd - m_Vd) * m_VtInv + 1.0) * m_Vt;
222#if defined(_MSC_VER) && _MSC_VER < 1200
223            m_Vd = m_Vd + log((nVd - m_Vd) * m_VtInv + 1.0) * m_Vt;
224#else
223225            m_Vd = m_Vd + log1p((nVd - m_Vd) * m_VtInv) * m_Vt;
224
226#endif
225227            const double eVDVt = exp(m_Vd * m_VtInv);
226228            Id = m_Is * (eVDVt - 1.0);
227229
r26667r26668
348350    double m_gB; // base conductance / switch on
349351    double m_gC; // collector conductance / switch on
350352    double m_V; // internal voltage source
351    int m_state_on;
353    UINT8 m_state_on;
352354
353355private:
354356};
trunk/src/emu/netlist/devices/nld_7493.c
r26667r26668
2828
2929NETLIB_START(7493ff)
3030{
31    m_reset = 0;
32
3133    register_input("CLK", m_I, netlist_input_t::STATE_INP_HL);
3234    register_output("Q", m_Q);
35
36    save(NAME(m_reset));
3337}
3438
3539NETLIB_UPDATE(7493ff)
trunk/src/emu/netlist/devices/nld_solver.c
r26667r26668
187187static void process_net(net_groups_t groups, int &cur_group, netlist_net_t *net)
188188{
189189    /* add the net */
190    if (net->m_head == NULL)
191        return;
190192    groups[cur_group].add(net);
191193    for (netlist_core_terminal_t *p = net->m_head; p != NULL; p = p->m_update_list_next)
192194    {
r26667r26668
216218    register_param("ACCURACY", m_accuracy, 1e-3);
217219    register_param("CONVERG", m_convergence, 0.3);
218220
219    register_link_internal(m_fb_sync, m_Q_sync, netlist_input_t::STATE_INP_ACTIVE);
220    register_link_internal(m_fb_step, m_Q_step, netlist_input_t::STATE_INP_ACTIVE);
221    // internal staff
222
223    register_input("FB_sync", m_fb_sync, netlist_input_t::STATE_INP_ACTIVE);
224    register_input("FB_step", m_fb_step, netlist_input_t::STATE_INP_ACTIVE);
225
226    setup().connect(m_fb_sync, m_Q_sync);
227    setup().connect(m_fb_step, m_Q_step);
228
221229    m_last_step = netlist_time::zero;
222230
231    save(NAME(m_last_step));
232
223233}
224234
225235NETLIB_UPDATE_PARAM(solver)
r26667r26668
237247        e = en;
238248    }
239249
240    netlist_net_t::list_t::entry_t *p = m_nets.first();
241    while (p != NULL)
242    {
243        netlist_net_t::list_t::entry_t *pn = m_nets.next(p);
244        delete p->object();
245        p = pn;
246    }
247250}
248251
249252NETLIB_FUNC_VOID(solver, post_start, ())
r26667r26668
251254    netlist_net_t::list_t groups[100];
252255    int cur_group = -1;
253256
254    NL_VERBOSE_OUT(("post start solver ...\n"));
255
256    // delete empty nets ...
257    for (netlist_net_t::list_t::entry_t *pn = m_nets.first(); pn != NULL; pn = m_nets.next(pn))
258    {
259        if (pn->object()->m_head == NULL)
260        {
261            NL_VERBOSE_OUT(("Deleting net ...\n"));
262            netlist_net_t *to_delete = pn->object();
263            m_nets.remove(to_delete);
264            delete to_delete;
265            pn--;
266        }
267    }
268
269257    SOLVER_VERBOSE_OUT(("Scanning net groups ...\n"));
270258    // determine net groups
271    for (netlist_net_t::list_t::entry_t *pn = m_nets.first(); pn != NULL; pn = m_nets.next(pn))
259    for (netlist_net_t::list_t::entry_t *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn))
272260    {
273261        if (!already_processed(groups, cur_group, pn->object()))
274262        {
trunk/src/emu/netlist/nl_base.c
r26667r26668
2929{
3030    m_netlist = &nl;
3131    m_name = aname;
32    save_register();
3233}
3334
3435ATTR_COLD const pstring &netlist_object_t::name() const
r26667r26668
3839    return m_name;
3940}
4041
42ATTR_COLD void netlist_object_t::save_state_ptr(const pstring &stname, const netlist_data_type_e dt, const int size, void *ptr)
43{
44    pstring fullname = name() + "." + stname;
45    // do nothing for now;
46    ATTR_UNUSED  pstring ts[] = {
47            "NOT_SUPPORTED",
48            "DT_DOUBLE",
49            "DT_INT64",
50            "DT_INT8",
51            "DT_INT",
52            "DT_BOOLEAN"
53    };
54
55    NL_VERBOSE_OUT(("SAVE: <%s> %s(%d) %p\n", fullname.cstr(), ts[dt].cstr(), size, ptr));
56    netlist().setup().save_state_ptr(fullname, dt, size, ptr);
57}
58
4159// ----------------------------------------------------------------------------------------
4260// netlist_owned_object_t
4361// ----------------------------------------------------------------------------------------
r26667r26668
6179// ----------------------------------------------------------------------------------------
6280
6381netlist_base_t::netlist_base_t()
64    :   m_time_ps(netlist_time::zero),
82    :   netlist_object_t(NETLIST, GENERIC),
83        m_time_ps(netlist_time::zero),
6584        m_rem(0),
6685        m_div(NETLIST_DIV),
6786        m_mainclock(NULL),
r26667r26668
82101netlist_base_t::~netlist_base_t()
83102{
84103    tagmap_free_entries<tagmap_devices_t>(m_devices);
104
105    netlist_net_t::list_t::entry_t *p = m_nets.first();
106    while (p != NULL)
107    {
108        netlist_net_t::list_t::entry_t *pn = m_nets.next(p);
109        if (!p->object()->isRailNet())
110            delete p->object();
111        p = pn;
112    }
113
114    m_nets.reset();
85115    pstring::resetmem();
86116}
87117
118ATTR_COLD netlist_net_t *netlist_base_t::find_net(const pstring &name)
119{
120    for (netlist_net_t::list_t::entry_t *p = m_nets.first(); p != NULL; p = m_nets.next(p))
121    {
122        if (p->object()->name() == name)
123            return p->object();
124    }
125    return NULL;
126}
127
88128ATTR_COLD void netlist_base_t::set_mainclock_dev(NETLIB_NAME(mainclock) *dev)
89129{
90130    m_mainclock = dev;
r26667r26668
339379    setup().register_object(*this, *this, name, inp, type);
340380}
341381
382//FIXME: Get rid of this
342383static void init_term(netlist_core_device_t &dev, netlist_core_terminal_t &term, netlist_input_t::state_e aState)
343384{
344385    if (!term.isInitalized())
r26667r26668
346387        switch (term.type())
347388        {
348389            case netlist_terminal_t::OUTPUT:
349                dynamic_cast<netlist_output_t &>(term).init_object(dev, "internal output");
390                dynamic_cast<netlist_output_t &>(term).init_object(dev, dev.name() + ".INTOUT");
350391                break;
351392            case netlist_terminal_t::INPUT:
352                dynamic_cast<netlist_input_t &>(term).init_object(dev, "internal input", aState);
393                dynamic_cast<netlist_input_t &>(term).init_object(dev, dev.name() + ".INTINP", aState);
353394                break;
354395            case netlist_terminal_t::TERMINAL:
355                dynamic_cast<netlist_terminal_t &>(term).init_object(dev, "internal terminal", aState);
396                dynamic_cast<netlist_terminal_t &>(term).init_object(dev, dev.name() + ".INTTERM", aState);
356397                break;
357398            default:
358399                dev.netlist().xfatalerror("Unknown terminal type");
r26667r26668
362403}
363404
364405// FIXME: Revise internal links ...
406//FIXME: Get rid of this
365407ATTR_COLD void netlist_device_t::register_link_internal(netlist_core_device_t &dev, netlist_input_t &in, netlist_output_t &out, const netlist_input_t::state_e aState)
366408{
367409    init_term(dev, in, aState);
r26667r26668
377419template <class C, class T>
378420ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, C &param, const T initialVal)
379421{
380    param.init_object(dev, sname);
422    pstring fullname = dev.name() + "." + sname;
423    param.init_object(dev, fullname);
381424    param.initial(initialVal);
382    setup().register_object(*this, *this, sname, param, netlist_terminal_t::STATE_NONEX);
425    //FIXME: pass fullname from above
426    setup().register_object(*this, *this, fullname, param, netlist_terminal_t::STATE_NONEX);
383427}
384428
385429template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_double_t &param, const double initialVal);
r26667r26668
405449{
406450};
407451
452ATTR_COLD void netlist_net_t::init_object(netlist_base_t &nl, const pstring &aname)
453{
454    netlist_object_t::init_object(nl, aname);
455    nl.m_nets.add(this);
456}
457
408458ATTR_COLD void netlist_net_t::register_railterminal(netlist_output_t &mr)
409459{
410460    assert(m_railterminal == NULL);
r26667r26668
551601ATTR_COLD void netlist_output_t::init_object(netlist_core_device_t &dev, const pstring &aname)
552602{
553603    netlist_core_terminal_t::init_object(dev, aname, STATE_OUT);
554    net().init_object(dev.netlist(), aname);
604    net().init_object(dev.netlist(), aname + ".net");
555605    net().register_railterminal(*this);
556606}
557607
trunk/src/emu/video/fixfreq.c
r26667r26668
113113   m_bitmap[1] = NULL;
114114   //m_vblank_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vga_device::vblank_timer_cb),this));
115115   recompute_parameters(false);
116
117    save_item(NAME(m_vid));
118    save_item(NAME(m_last_x));
119    save_item(NAME(m_last_y));
120    save_item(NAME(m_last_time));
121    save_item(NAME(m_line_time));
122    save_item(NAME(m_last_hsync_time));
123    save_item(NAME(m_last_vsync_time));
124    save_item(NAME(m_refresh));
125    save_item(NAME(m_clock_period));
126    //save_item(NAME(m_bitmap[0]));
127    //save_item(NAME(m_bitmap[1]));
128    save_item(NAME(m_cur_bm));
129
130    /* sync separator */
131    save_item(NAME(m_vint));
132    save_item(NAME(m_int_trig));
133    save_item(NAME(m_mult));
134
135    save_item(NAME(m_sig_vsync));
136    save_item(NAME(m_sig_composite));
137    save_item(NAME(m_sig_field));
138
139
140
116141}
117142
118143void fixedfreq_device::device_reset()
r26667r26668
122147   m_last_hsync_time = attotime::zero;
123148   m_last_vsync_time = attotime::zero;
124149   m_vint = 0;
150
125151}
126152
127153
trunk/src/mame/drivers/pong.c
r26667r26668
982982ROM_END
983983
984984
985GAME( 1972, pong,  0, pong, pong, driver_device,  0, ROT0, "Atari", "Pong (Rev E)", 0 )
986GAME( 1972, pongf,  0, pongf, pong, driver_device,  0, ROT0, "Atari", "Pong (Rev E), no subcycles", 0 )
985GAME( 1972, pong,  0, pong, pong, driver_device,  0, ROT0, "Atari", "Pong (Rev E)", GAME_SUPPORTS_SAVE )
986GAME( 1972, pongf,  0, pongf, pong, driver_device,  0, ROT0, "Atari", "Pong (Rev E), no subcycles", GAME_SUPPORTS_SAVE )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team