trunk/src/emu/machine/netlist.c
| r26689 | r26690 | |
| 49 | 49 | #include "netlist/nl_base.h" |
| 50 | 50 | #include "netlist/nl_setup.h" |
| 51 | 51 | #include "netlist/devices/net_lib.h" |
| 52 | #include "debugger.h" |
| 52 | 53 | |
| 53 | 54 | //#define LOG_DEV_CALLS(x) printf x |
| 54 | 55 | #define LOG_DEV_CALLS(x) do { } while (0) |
| r26689 | r26690 | |
| 178 | 179 | |
| 179 | 180 | ATTR_COLD void netlist_mame_device::save_state() |
| 180 | 181 | { |
| 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 | for (pstate_entry_t::list_t::entry_t *p = m_netlist->save_list().first(); p != NULL; p = m_netlist->save_list().next(p)) |
| 182 | 183 | { |
| 183 | | netlist_setup_t::save_entry_t *s = p->object(); |
| 184 | pstate_entry_t *s = p->object(); |
| 184 | 185 | NL_VERBOSE_OUT(("saving state for %s\n", s->m_name.cstr())); |
| 185 | 186 | switch (s->m_dt) |
| 186 | 187 | { |
| 187 | 188 | case DT_DOUBLE: |
| 188 | | save_pointer((double *) s->m_ptr, s->m_name, 1); |
| 189 | save_pointer((double *) s->m_ptr, s->m_name, s->m_count); |
| 189 | 190 | break; |
| 190 | 191 | case DT_INT64: |
| 191 | | save_pointer((INT64 *) s->m_ptr, s->m_name, 1); |
| 192 | save_pointer((INT64 *) s->m_ptr, s->m_name, s->m_count); |
| 192 | 193 | break; |
| 193 | 194 | case DT_INT8: |
| 194 | | save_pointer((INT8 *) s->m_ptr, s->m_name, 1); |
| 195 | save_pointer((INT8 *) s->m_ptr, s->m_name, s->m_count); |
| 195 | 196 | break; |
| 196 | 197 | case DT_INT: |
| 197 | | save_pointer((int *) s->m_ptr, s->m_name, 1); |
| 198 | save_pointer((int *) s->m_ptr, s->m_name, s->m_count); |
| 198 | 199 | break; |
| 199 | 200 | case DT_BOOLEAN: |
| 200 | | save_pointer((bool *) s->m_ptr, s->m_name, 1); |
| 201 | save_pointer((bool *) s->m_ptr, s->m_name, s->m_count); |
| 201 | 202 | break; |
| 202 | | #if 0 |
| 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; |
| 211 | | #endif |
| 212 | 203 | case NOT_SUPPORTED: |
| 213 | 204 | default: |
| 214 | 205 | m_netlist->xfatalerror("found unsupported save element %s\n", s->m_name.cstr()); |
| r26689 | r26690 | |
| 225 | 216 | save_pointer(qtemp[i].m_name, "queue_name", sizeof(qtemp[i].m_name), i); |
| 226 | 217 | |
| 227 | 218 | } |
| 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 |
| 235 | 219 | } |
| 236 | 220 | |
| 237 | 221 | ATTR_COLD UINT64 netlist_mame_device::execute_clocks_to_cycles(UINT64 clocks) const |
| r26689 | r26690 | |
| 246 | 230 | |
| 247 | 231 | ATTR_HOT void netlist_mame_device::execute_run() |
| 248 | 232 | { |
| 249 | | //bool check_debugger = ((device_t::machine().debug_flags & DEBUG_FLAG_ENABLED) != 0); |
| 233 | bool check_debugger = ((device_t::machine().debug_flags & DEBUG_FLAG_ENABLED) != 0); |
| 250 | 234 | |
| 251 | 235 | // debugging |
| 252 | 236 | //m_ppc = m_pc; // copy PC to previous PC |
| 253 | | //if (check_debugger) |
| 254 | | // debugger_instruction_hook(this, 0); //m_pc); |
| 237 | if (check_debugger) |
| 238 | debugger_instruction_hook(this, 0); //m_pc); |
| 255 | 239 | |
| 256 | 240 | m_netlist->process_queue(m_icount); |
| 257 | 241 | } |
trunk/src/emu/netlist/nl_base.c
| r26689 | r26690 | |
| 39 | 39 | return m_name; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | | ATTR_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 | | |
| 59 | 42 | // ---------------------------------------------------------------------------------------- |
| 60 | 43 | // netlist_owned_object_t |
| 61 | 44 | // ---------------------------------------------------------------------------------------- |
trunk/src/emu/netlist/pstate.h
| r0 | r26690 | |
| 1 | /* |
| 2 | * pstate.h |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | #ifndef PSTATE_H_ |
| 7 | #define PSTATE_H_ |
| 8 | |
| 9 | #include "nl_config.h" |
| 10 | #include "nl_time.h" |
| 11 | #include "nl_lists.h" |
| 12 | #include "pstring.h" |
| 13 | |
| 14 | // ---------------------------------------------------------------------------------------- |
| 15 | // state saving ... |
| 16 | // ---------------------------------------------------------------------------------------- |
| 17 | |
| 18 | #define PSTATE_INTERFACE(manager, module) \ |
| 19 | template<class C> ATTR_COLD void save(C &state, const pstring &stname) \ |
| 20 | { \ |
| 21 | dynamic_cast<pstate_manager_t &>(manager).save_manager(state, module + "." + stname); \ |
| 22 | } |
| 23 | |
| 24 | enum netlist_data_type_e { |
| 25 | NOT_SUPPORTED, |
| 26 | DT_DOUBLE, |
| 27 | DT_INT64, |
| 28 | DT_INT8, |
| 29 | DT_INT, |
| 30 | DT_BOOLEAN |
| 31 | }; |
| 32 | |
| 33 | template<typename _ItemType> struct nl_datatype { static const netlist_data_type_e type = netlist_data_type_e(NOT_SUPPORTED); }; |
| 34 | //template<typename _ItemType> struct type_checker<_ItemType*> { static const bool is_atom = false; static const bool is_pointer = true; }; |
| 35 | |
| 36 | #define NETLIST_SAVE_TYPE(TYPE, TYPEDESC) template<> struct nl_datatype<TYPE>{ static const netlist_data_type_e type = netlist_data_type_e(TYPEDESC); } |
| 37 | |
| 38 | NETLIST_SAVE_TYPE(double, DT_DOUBLE); |
| 39 | NETLIST_SAVE_TYPE(INT8, DT_INT8); |
| 40 | NETLIST_SAVE_TYPE(UINT8, DT_INT8); |
| 41 | NETLIST_SAVE_TYPE(INT64, DT_INT64); |
| 42 | NETLIST_SAVE_TYPE(UINT64, DT_INT64); |
| 43 | NETLIST_SAVE_TYPE(bool, DT_BOOLEAN); |
| 44 | NETLIST_SAVE_TYPE(UINT32, DT_INT); |
| 45 | NETLIST_SAVE_TYPE(INT32, DT_INT); |
| 46 | |
| 47 | struct pstate_entry_t |
| 48 | { |
| 49 | typedef netlist_list_t<pstate_entry_t *> list_t; |
| 50 | |
| 51 | pstate_entry_t(const pstring &stname, const netlist_data_type_e dt, const int size, const int count, void *ptr) : |
| 52 | m_name(stname), m_dt(dt), m_size(size), m_count(count), m_ptr(ptr) { } |
| 53 | pstring m_name; |
| 54 | netlist_data_type_e m_dt; |
| 55 | int m_size; |
| 56 | int m_count; |
| 57 | void *m_ptr; |
| 58 | }; |
| 59 | |
| 60 | class pstate_manager_t |
| 61 | { |
| 62 | public: |
| 63 | |
| 64 | ATTR_COLD ~pstate_manager_t(); |
| 65 | |
| 66 | template<class C> ATTR_COLD void save_manager(C &state, const pstring &stname) |
| 67 | { |
| 68 | save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), 1, &state); |
| 69 | } |
| 70 | |
| 71 | template<class C> ATTR_COLD void save_manager(C *state, const pstring &stname, const int count) |
| 72 | { |
| 73 | save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), count, state); |
| 74 | } |
| 75 | |
| 76 | template<class C, std::size_t N> ATTR_COLD void save_manager(C (&state)[N], const pstring &stname) |
| 77 | { |
| 78 | save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), N, &(state[0])); |
| 79 | } |
| 80 | |
| 81 | inline const pstate_entry_t::list_t &save_list() const { return m_save; } |
| 82 | |
| 83 | protected: |
| 84 | ATTR_COLD void save_state_ptr(const pstring &stname, const netlist_data_type_e, const int size, const int count, void *ptr); |
| 85 | |
| 86 | private: |
| 87 | pstate_entry_t::list_t m_save; |
| 88 | }; |
| 89 | |
| 90 | template<> ATTR_COLD inline void pstate_manager_t::save_manager(netlist_time &nlt, const pstring &stname) |
| 91 | { |
| 92 | save_state_ptr(stname, DT_INT64, sizeof(netlist_time::INTERNALTYPE), 1, nlt.get_internaltype_ptr()); |
| 93 | } |
| 94 | |
| 95 | |
| 96 | |
| 97 | #endif /* PSTATE_H_ */ |
trunk/src/emu/netlist/nl_base.h
| r26689 | r26690 | |
| 155 | 155 | #include "nl_lists.h" |
| 156 | 156 | #include "nl_time.h" |
| 157 | 157 | #include "pstring.h" |
| 158 | #include "pstate.h" |
| 158 | 159 | |
| 159 | 160 | // ---------------------------------------------------------------------------------------- |
| 160 | 161 | // Type definitions |
| r26689 | r26690 | |
| 247 | 248 | class NETLIB_NAME(mainclock); |
| 248 | 249 | |
| 249 | 250 | // ---------------------------------------------------------------------------------------- |
| 250 | | // state saving ... |
| 251 | | // ---------------------------------------------------------------------------------------- |
| 252 | | |
| 253 | | enum netlist_data_type_e { |
| 254 | | NOT_SUPPORTED, |
| 255 | | DT_DOUBLE, |
| 256 | | DT_INT64, |
| 257 | | DT_INT8, |
| 258 | | DT_INT, |
| 259 | | DT_BOOLEAN |
| 260 | | }; |
| 261 | | |
| 262 | | template<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 | | |
| 267 | | NETLIST_SAVE_TYPE(double, DT_DOUBLE); |
| 268 | | NETLIST_SAVE_TYPE(INT8, DT_INT8); |
| 269 | | NETLIST_SAVE_TYPE(UINT8, DT_INT8); |
| 270 | | NETLIST_SAVE_TYPE(INT64, DT_INT64); |
| 271 | | NETLIST_SAVE_TYPE(UINT64, DT_INT64); |
| 272 | | NETLIST_SAVE_TYPE(bool, DT_BOOLEAN); |
| 273 | | NETLIST_SAVE_TYPE(UINT32, DT_INT); |
| 274 | | NETLIST_SAVE_TYPE(INT32, DT_INT); |
| 275 | | |
| 276 | | // ---------------------------------------------------------------------------------------- |
| 277 | 251 | // netlist_object_t |
| 278 | 252 | // ---------------------------------------------------------------------------------------- |
| 279 | 253 | |
| r26689 | r26690 | |
| 313 | 287 | |
| 314 | 288 | ATTR_COLD const pstring &name() const; |
| 315 | 289 | |
| 316 | | ATTR_COLD void save_state_ptr(const pstring &stname, const netlist_data_type_e, const int size, void *ptr); |
| 290 | PSTATE_INTERFACE(*m_netlist, name()) |
| 291 | |
| 292 | #if 0 |
| 317 | 293 | template<class C> ATTR_COLD void save(C &state, const pstring &stname) |
| 318 | 294 | { |
| 319 | 295 | save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), &state); |
| 320 | 296 | } |
| 297 | #endif |
| 321 | 298 | |
| 322 | 299 | ATTR_HOT inline const type_t type() const { return m_objtype; } |
| 323 | 300 | ATTR_HOT inline const family_t family() const { return m_family; } |
| r26689 | r26690 | |
| 330 | 307 | |
| 331 | 308 | protected: |
| 332 | 309 | |
| 310 | #if 0 |
| 311 | // pstate_interface virtual |
| 312 | ATTR_COLD virtual void save_state_ptr(const pstring &stname, const netlist_data_type_e, const int size, const int count, void *ptr); |
| 313 | #endif |
| 314 | |
| 333 | 315 | // must call parent save_register ! |
| 334 | 316 | ATTR_COLD virtual void save_register() { }; |
| 335 | 317 | |
| r26689 | r26690 | |
| 340 | 322 | netlist_base_t * RESTRICT m_netlist; |
| 341 | 323 | }; |
| 342 | 324 | |
| 343 | | template<> 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 | | |
| 348 | 325 | // ---------------------------------------------------------------------------------------- |
| 349 | 326 | // netlist_owned_object_t |
| 350 | 327 | // ---------------------------------------------------------------------------------------- |
| r26689 | r26690 | |
| 983 | 960 | |
| 984 | 961 | typedef tagmap_t<netlist_device_t *, 393> tagmap_devices_t; |
| 985 | 962 | |
| 986 | | class netlist_base_t : public netlist_object_t |
| 963 | class netlist_base_t : public netlist_object_t, public pstate_manager_t |
| 987 | 964 | { |
| 988 | 965 | NETLIST_PREVENT_COPYING(netlist_base_t) |
| 989 | 966 | public: |
trunk/src/emu/netlist/nl_setup.h
| r26689 | r26690 | |
| 135 | 135 | |
| 136 | 136 | void print_stats(); |
| 137 | 137 | |
| 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 | | |
| 160 | 138 | protected: |
| 161 | 139 | |
| 162 | 140 | private: |
trunk/src/emu/netlist/pstate.c
| r0 | r26690 | |
| 1 | /* |
| 2 | * pstate.c |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | #include "pstate.h" |
| 7 | |
| 8 | ATTR_COLD pstate_manager_t::~pstate_manager_t() |
| 9 | { |
| 10 | m_save.reset_and_free(); |
| 11 | } |
| 12 | |
| 13 | |
| 14 | |
| 15 | ATTR_COLD void pstate_manager_t::save_state_ptr(const pstring &stname, const netlist_data_type_e dt, const int size, const int count, void *ptr) |
| 16 | { |
| 17 | pstring fullname = stname; |
| 18 | ATTR_UNUSED pstring ts[] = { |
| 19 | "NOT_SUPPORTED", |
| 20 | "DT_DOUBLE", |
| 21 | "DT_INT64", |
| 22 | "DT_INT8", |
| 23 | "DT_INT", |
| 24 | "DT_BOOLEAN" |
| 25 | }; |
| 26 | |
| 27 | NL_VERBOSE_OUT(("SAVE: <%s> %s(%d) %p\n", fullname.cstr(), ts[dt].cstr(), size, ptr)); |
| 28 | pstate_entry_t *p = new pstate_entry_t(stname, dt, size, count, ptr); |
| 29 | m_save.add(p); |
| 30 | } |