diff options
Diffstat (limited to 'src/emu/machine/netlist.c')
-rw-r--r-- | src/emu/machine/netlist.c | 114 |
1 files changed, 99 insertions, 15 deletions
diff --git a/src/emu/machine/netlist.c b/src/emu/machine/netlist.c index 5e5b5e67d7f..e7bebcfdee4 100644 --- a/src/emu/machine/netlist.c +++ b/src/emu/machine/netlist.c @@ -50,7 +50,8 @@ #include "netlist/nl_setup.h" #include "netlist/devices/net_lib.h" -#define LOG_DEV_CALLS(x) do { } while (0); +//#define LOG_DEV_CALLS(x) printf x +#define LOG_DEV_CALLS(x) do { } while (0) // ---------------------------------------------------------------------------------------- // netlist_mame_device @@ -61,6 +62,7 @@ const device_type NETLIST = &device_creator<netlist_mame_device>; netlist_mame_device::netlist_mame_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, NETLIST, "netlist", tag, owner, clock, "netlist_mame", __FILE__), device_execute_interface(mconfig, *this), + //device_state_interface(mconfig, *this), m_device_start_list(100), m_netlist(NULL), m_setup(NULL), @@ -86,11 +88,13 @@ void netlist_mame_device::device_start() LOG_DEV_CALLS(("device_start\n")); m_netlist = global_alloc_clear(netlist_mame_t(*this)); - m_netlist->set_clock_freq(this->clock()); - m_setup = global_alloc_clear(netlist_setup_t(*m_netlist)); + m_netlist->init_object(*m_netlist, "netlist"); + m_setup->init(); + + m_netlist->set_clock_freq(this->clock()); - // register additional devices + // register additional devices m_setup->factory().register_device<nld_analog_callback>( "NETDEV_CALLBACK", "nld_analog_callback"); @@ -107,7 +111,6 @@ void netlist_mame_device::device_start() m_netlist->xfatalerror("required elements not found\n"); save_state(); - /* TODO: we have to save the round robin queue as well */ // set our instruction counter m_icountptr = &m_icount; @@ -130,31 +133,113 @@ void netlist_mame_device::device_stop() m_netlist = NULL; } -void netlist_mame_device::device_post_load() +ATTR_COLD void netlist_mame_device::device_post_load() { + LOG_DEV_CALLS(("device_post_load\n")); + m_netlist->queue().clear(); + NL_VERBOSE_OUT(("current time %f qsize %d\n", m_netlist->time().as_double(), qsize)); + for (int i = 0; i < qsize; i++ ) + { + netlist_net_t *n = m_netlist->find_net(qtemp[i].m_name); + NL_VERBOSE_OUT(("Got %s ==> %p\n", qtemp[i].m_name, n)); + NL_VERBOSE_OUT(("schedule time %f (%f)\n", n->time().as_double(), qtemp[i].m_time.as_double())); + m_netlist->queue().push(netlist_base_t::queue_t::entry_t(qtemp[i].m_time, *n)); + } +} + +ATTR_COLD void netlist_mame_device::device_pre_save() +{ + LOG_DEV_CALLS(("device_pre_save\n")); + + qsize = m_netlist->queue().count(); + NL_VERBOSE_OUT(("current time %f qsize %d\n", m_netlist->time().as_double(), qsize)); + for (int i = 0; i < qsize; i++ ) + { + qtemp[i].m_time = m_netlist->queue().listptr()[i].time(); + const char *p = m_netlist->queue().listptr()[i].object().name().cstr(); + int n = MIN(63, strlen(p)); + strncpy(qtemp[i].m_name, p, n); + qtemp[i].m_name[n] = 0; + } +#if 0 + + netlist_time *nlt = (netlist_time *) ; + netlist_base_t::queue_t::entry_t *p = m_netlist->queue().listptr()[i]; + netlist_time *nlt = (netlist_time *) p->time_ptr(); + save_pointer(nlt->get_internaltype_ptr(), "queue", 1, i); +#endif } void netlist_mame_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { } -void netlist_mame_device::save_state() + + +ATTR_COLD void netlist_mame_device::save_state() { + for (netlist_setup_t::save_entry_list_t::entry_t *p = setup().m_save.first(); p != NULL; p = setup().m_save.next(p)) + { + netlist_setup_t::save_entry_t *s = p->object(); + NL_VERBOSE_OUT(("saving state for %s\n", s->m_name.cstr())); + switch (s->m_dt) + { + case DT_DOUBLE: + save_pointer((double *) s->m_ptr, s->m_name, 1); + break; + case DT_INT64: + save_pointer((INT64 *) s->m_ptr, s->m_name, 1); + break; + case DT_INT8: + save_pointer((INT8 *) s->m_ptr, s->m_name, 1); + break; + case DT_INT: + save_pointer((int *) s->m_ptr, s->m_name, 1); + break; + case DT_BOOLEAN: + save_pointer((bool *) s->m_ptr, s->m_name, 1); + break; #if 0 - for (netlist_setup_t::tagmap_output_t::entry_t *entry = m_setup->m_outputs.first(); entry != NULL; entry = m_setup->m_outputs.next(entry)) - { - save_item(*entry->object()->Q_ptr(), entry->tag().cstr(), 0); - save_item(*entry->object()->new_Q_ptr(), entry->tag().cstr(), 1); - } + case DT_NLTIME: + { + netlist_time *nlt = (netlist_time *) s->m_ptr; + //save_pointer((netlist_time::INTERNALTYPE *) s->m_ptr, s->m_name, 1); + //save_pointer(nlt->get_internaltype_ptr(), s->m_name, 1); + save_item(*nlt->get_internaltype_ptr(), s->m_name.cstr()); + } + break; +#endif + case NOT_SUPPORTED: + default: + m_netlist->xfatalerror("found unsupported save element %s\n", s->m_name.cstr()); + break; + } + } + + // handle the queue + + save_item(NAME(qsize)); + for (int i = 0; i < m_netlist->queue().capacity(); i++ ) + { + save_pointer(qtemp[i].m_time.get_internaltype_ptr(), "queue_time", 1, i); + save_pointer(qtemp[i].m_name, "queue_name", sizeof(qtemp[i].m_name), i); + + } +#if 0 + + netlist_time *nlt = (netlist_time *) ; + netlist_base_t::queue_t::entry_t *p = m_netlist->queue().listptr()[i]; + netlist_time *nlt = (netlist_time *) p->time_ptr(); + save_pointer(nlt->get_internaltype_ptr(), "queue", 1, i); #endif } -UINT64 netlist_mame_device::execute_clocks_to_cycles(UINT64 clocks) const +ATTR_COLD UINT64 netlist_mame_device::execute_clocks_to_cycles(UINT64 clocks) const { return clocks; } -UINT64 netlist_mame_device::execute_cycles_to_clocks(UINT64 cycles) const +ATTR_COLD UINT64 netlist_mame_device::execute_cycles_to_clocks(UINT64 cycles) const { return cycles; } @@ -169,5 +254,4 @@ ATTR_HOT void netlist_mame_device::execute_run() // debugger_instruction_hook(this, 0); //m_pc); m_netlist->process_queue(m_icount); - } |