summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine
diff options
context:
space:
mode:
author Couriersud <couriersud@users.noreply.github.com>2013-12-20 15:54:48 +0000
committer Couriersud <couriersud@users.noreply.github.com>2013-12-20 15:54:48 +0000
commitf46847e487f4ea9eda52c6e3189deabaf0f3e34e (patch)
tree819ce92808aff399eb4b905660ab03baebc7e82b /src/emu/machine
parent5eb4f5530b1544324fd7e209d036d67991abd195 (diff)
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.
Diffstat (limited to 'src/emu/machine')
-rw-r--r--src/emu/machine/netlist.c114
-rw-r--r--src/emu/machine/netlist.h12
2 files changed, 111 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);
-
}
diff --git a/src/emu/machine/netlist.h b/src/emu/machine/netlist.h
index 9389838beab..1ad5588bb00 100644
--- a/src/emu/machine/netlist.h
+++ b/src/emu/machine/netlist.h
@@ -122,6 +122,7 @@ private:
class netlist_mame_device : public device_t,
public device_execute_interface
+ //public device_state_interface
//, public device_memory_interface
{
public:
@@ -158,6 +159,7 @@ protected:
virtual void device_stop();
virtual void device_reset();
virtual void device_post_load();
+ virtual void device_pre_save();
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const;
virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const;
@@ -168,6 +170,16 @@ protected:
netlist_setup_t *m_setup;
+// more save state ... needs to go somewhere else
+
+ struct qentry {
+ netlist_time m_time;
+ char m_name[64];
+ };
+
+ qentry qtemp[1024];
+ int qsize;
+
private:
void save_state();