trunk/src/emu/diserial.c
| r243552 | r243553 | |
| 50 | 50 | { |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | | void device_serial_interface::register_save_state(save_manager &save, const char *module, const char *tag) |
| 53 | void device_serial_interface::register_save_state(save_manager &save, device_t *device) |
| 54 | 54 | { |
| 55 | | save.save_item(module, tag, 0, NAME(m_df_start_bit_count)); |
| 56 | | save.save_item(module, tag, 0, NAME(m_df_word_length)); |
| 57 | | save.save_item(module, tag, 0, NAME(m_df_parity)); |
| 58 | | save.save_item(module, tag, 0, NAME(m_df_stop_bit_count)); |
| 59 | | save.save_item(module, tag, 0, NAME(m_rcv_register_data)); |
| 60 | | save.save_item(module, tag, 0, NAME(m_rcv_flags)); |
| 61 | | save.save_item(module, tag, 0, NAME(m_rcv_bit_count_received)); |
| 62 | | save.save_item(module, tag, 0, NAME(m_rcv_bit_count)); |
| 63 | | save.save_item(module, tag, 0, NAME(m_rcv_byte_received)); |
| 64 | | save.save_item(module, tag, 0, NAME(m_rcv_framing_error)); |
| 65 | | save.save_item(module, tag, 0, NAME(m_rcv_parity_error)); |
| 66 | | save.save_item(module, tag, 0, NAME(m_tra_register_data)); |
| 67 | | save.save_item(module, tag, 0, NAME(m_tra_flags)); |
| 68 | | save.save_item(module, tag, 0, NAME(m_tra_bit_count_transmitted)); |
| 69 | | save.save_item(module, tag, 0, NAME(m_tra_bit_count)); |
| 70 | | save.save_item(module, tag, 0, NAME(m_rcv_rate)); |
| 71 | | save.save_item(module, tag, 0, NAME(m_tra_rate)); |
| 72 | | save.save_item(module, tag, 0, NAME(m_rcv_line)); |
| 73 | | save.save_item(module, tag, 0, NAME(m_tra_clock_state)); |
| 74 | | save.save_item(module, tag, 0, NAME(m_rcv_clock_state)); |
| 55 | const char *module = device->name(); |
| 56 | const char *tag = device->tag(); |
| 57 | save.save_item(device, module, tag, 0, NAME(m_df_start_bit_count)); |
| 58 | save.save_item(device, module, tag, 0, NAME(m_df_word_length)); |
| 59 | save.save_item(device, module, tag, 0, NAME(m_df_parity)); |
| 60 | save.save_item(device, module, tag, 0, NAME(m_df_stop_bit_count)); |
| 61 | save.save_item(device, module, tag, 0, NAME(m_rcv_register_data)); |
| 62 | save.save_item(device, module, tag, 0, NAME(m_rcv_flags)); |
| 63 | save.save_item(device, module, tag, 0, NAME(m_rcv_bit_count_received)); |
| 64 | save.save_item(device, module, tag, 0, NAME(m_rcv_bit_count)); |
| 65 | save.save_item(device, module, tag, 0, NAME(m_rcv_byte_received)); |
| 66 | save.save_item(device, module, tag, 0, NAME(m_rcv_framing_error)); |
| 67 | save.save_item(device, module, tag, 0, NAME(m_rcv_parity_error)); |
| 68 | save.save_item(device, module, tag, 0, NAME(m_tra_register_data)); |
| 69 | save.save_item(device, module, tag, 0, NAME(m_tra_flags)); |
| 70 | save.save_item(device, module, tag, 0, NAME(m_tra_bit_count_transmitted)); |
| 71 | save.save_item(device, module, tag, 0, NAME(m_tra_bit_count)); |
| 72 | save.save_item(device, module, tag, 0, NAME(m_rcv_rate)); |
| 73 | save.save_item(device, module, tag, 0, NAME(m_tra_rate)); |
| 74 | save.save_item(device, module, tag, 0, NAME(m_rcv_line)); |
| 75 | save.save_item(device, module, tag, 0, NAME(m_tra_clock_state)); |
| 76 | save.save_item(device, module, tag, 0, NAME(m_rcv_clock_state)); |
| 75 | 77 | } |
| 76 | 78 | |
| 77 | 79 | void device_serial_interface::interface_pre_start() |
trunk/src/emu/save.h
| r243552 | r243553 | |
| 51 | 51 | // use this as above, but also to declare that dynamic_array<TYPE> is safe as well |
| 52 | 52 | #define ALLOW_SAVE_TYPE_AND_ARRAY(TYPE) \ |
| 53 | 53 | ALLOW_SAVE_TYPE(TYPE); \ |
| 54 | | template<> inline void save_manager::save_item(const char *module, const char *tag, int index, dynamic_array<TYPE> &value, const char *name) { save_memory(module, tag, index, name, &value[0], sizeof(TYPE), value.count()); } |
| 54 | template<> inline void save_manager::save_item(device_t *device, const char *module, const char *tag, int index, dynamic_array<TYPE> &value, const char *name) { save_memory(device, module, tag, index, name, &value[0], sizeof(TYPE), value.count()); } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | // register items with explicit tags |
| 58 | 58 | #define state_save_register_item(_mach, _mod, _tag, _index, _val) \ |
| 59 | | (_mach).save().save_item(_mod, _tag, _index, _val, #_val) |
| 59 | (_mach).save().save_item(NULL, _mod, _tag, _index, _val, #_val) |
| 60 | 60 | |
| 61 | 61 | #define state_save_register_item_pointer(_mach, _mod, _tag, _index, _val, _count) \ |
| 62 | | (_mach).save().save_pointer(_mod, _tag, _index, _val, #_val, _count) |
| 62 | (_mach).save().save_pointer(NULL, _mod, _tag, _index, _val, #_val, _count) |
| 63 | 63 | |
| 64 | 64 | #define state_save_register_item_array(_mach, _mod, _tag, _index, _val) \ |
| 65 | | (_mach).save().save_item(_mod, _tag, _index, _val, #_val) |
| 65 | (_mach).save().save_item(NULL, _mod, _tag, _index, _val, #_val) |
| 66 | 66 | |
| 67 | 67 | #define state_save_register_item_2d_array(_mach, _mod, _tag, _index, _val) \ |
| 68 | | (_mach).save().save_item(_mod, _tag, _index, _val, #_val) |
| 68 | (_mach).save().save_item(NULL, _mod, _tag, _index, _val, #_val) |
| 69 | 69 | |
| 70 | 70 | #define state_save_register_item_bitmap(_mach, _mod, _tag, _index, _val) \ |
| 71 | | (_mach).save().save_item(_mod, _tag, _index, *(_val), #_val) |
| 71 | (_mach).save().save_item(NULL, _mod, _tag, _index, *(_val), #_val) |
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | |
| r243552 | r243553 | |
| 76 | 76 | // TYPE DEFINITIONS |
| 77 | 77 | //************************************************************************** |
| 78 | 78 | |
| 79 | class state_entry |
| 80 | { |
| 81 | public: |
| 82 | // construction/destruction |
| 83 | state_entry(void *data, const char *name, device_t *device, const char *module, const char *tag, int index, UINT8 size, UINT32 count); |
| 84 | |
| 85 | // getters |
| 86 | state_entry *next() const { return m_next; } |
| 87 | |
| 88 | // helpers |
| 89 | void flip_data(); |
| 90 | |
| 91 | // state |
| 92 | state_entry * m_next; // pointer to next entry |
| 93 | void * m_data; // pointer to the memory to save/restore |
| 94 | astring m_name; // full name |
| 95 | device_t * m_device; // associated device, NULL if none |
| 96 | astring m_module; // module name |
| 97 | astring m_tag; // tag name |
| 98 | int m_index; // index |
| 99 | UINT8 m_typesize; // size of the raw data type |
| 100 | UINT32 m_typecount; // number of items |
| 101 | UINT32 m_offset; // offset within the final structure |
| 102 | }; |
| 103 | |
| 79 | 104 | class save_manager |
| 80 | 105 | { |
| 81 | 106 | // type_checker is a set of templates to identify valid save types |
| r243552 | r243553 | |
| 104 | 129 | void dispatch_postload(); |
| 105 | 130 | |
| 106 | 131 | // generic memory registration |
| 107 | | void save_memory(const char *module, const char *tag, UINT32 index, const char *name, void *val, UINT32 valsize, UINT32 valcount = 1); |
| 132 | void save_memory(device_t *device, const char *module, const char *tag, UINT32 index, const char *name, void *val, UINT32 valsize, UINT32 valcount = 1); |
| 108 | 133 | |
| 109 | 134 | // templatized wrapper for general objects |
| 110 | 135 | template<typename _ItemType> |
| 111 | | void save_item(const char *module, const char *tag, int index, _ItemType &value, const char *valname) |
| 136 | void save_item(device_t *device, const char *module, const char *tag, int index, _ItemType &value, const char *valname) |
| 112 | 137 | { |
| 113 | 138 | if (type_checker<_ItemType>::is_pointer) throw emu_fatalerror("Called save_item on a pointer with no count!"); |
| 114 | 139 | if (!type_checker<_ItemType>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!"); |
| 115 | | save_memory(module, tag, index, valname, &value, sizeof(value)); |
| 140 | save_memory(device, module, tag, index, valname, &value, sizeof(value)); |
| 116 | 141 | } |
| 117 | 142 | |
| 118 | 143 | // templatized wrapper for 1-dimensional arrays |
| 119 | 144 | template<typename _ItemType, std::size_t N> |
| 120 | | void save_item(const char *module, const char *tag, int index, _ItemType (&value)[N], const char *valname) |
| 145 | void save_item(device_t *device, const char *module, const char *tag, int index, _ItemType (&value)[N], const char *valname) |
| 121 | 146 | { |
| 122 | 147 | if (!type_checker<_ItemType>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!"); |
| 123 | | save_memory(module, tag, index, valname, &value[0], sizeof(value[0]), N); |
| 148 | save_memory(device, module, tag, index, valname, &value[0], sizeof(value[0]), N); |
| 124 | 149 | } |
| 125 | 150 | |
| 126 | 151 | // templatized wrapper for 2-dimensional arrays |
| 127 | 152 | template<typename _ItemType, std::size_t M, std::size_t N> |
| 128 | | void save_item(const char *module, const char *tag, int index, _ItemType (&value)[M][N], const char *valname) |
| 153 | void save_item(device_t *device, const char *module, const char *tag, int index, _ItemType (&value)[M][N], const char *valname) |
| 129 | 154 | { |
| 130 | 155 | if (!type_checker<_ItemType>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!"); |
| 131 | | save_memory(module, tag, index, valname, &value[0][0], sizeof(value[0][0]), M * N); |
| 156 | save_memory(device, module, tag, index, valname, &value[0][0], sizeof(value[0][0]), M * N); |
| 132 | 157 | } |
| 133 | 158 | |
| 134 | 159 | // templatized wrapper for pointers |
| 135 | 160 | template<typename _ItemType> |
| 136 | | void save_pointer(const char *module, const char *tag, int index, _ItemType *value, const char *valname, UINT32 count) |
| 161 | void save_pointer(device_t *device, const char *module, const char *tag, int index, _ItemType *value, const char *valname, UINT32 count) |
| 137 | 162 | { |
| 138 | 163 | if (!type_checker<_ItemType>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!"); |
| 139 | | save_memory(module, tag, index, valname, value, sizeof(*value), count); |
| 164 | save_memory(device, module, tag, index, valname, value, sizeof(*value), count); |
| 140 | 165 | } |
| 141 | 166 | |
| 142 | 167 | // global memory registration |
| 143 | 168 | template<typename _ItemType> |
| 144 | | void save_item(_ItemType &value, const char *valname, int index = 0) { save_item("global", NULL, index, value, valname); } |
| 169 | void save_item(_ItemType &value, const char *valname, int index = 0) { save_item(NULL, "global", NULL, index, value, valname); } |
| 145 | 170 | template<typename _ItemType> |
| 146 | | void save_pointer(_ItemType *value, const char *valname, UINT32 count, int index = 0) { save_pointer("global", NULL, index, value, valname, count); } |
| 171 | void save_pointer(_ItemType *value, const char *valname, UINT32 count, int index = 0) { save_pointer(NULL, "global", NULL, index, value, valname, count); } |
| 147 | 172 | |
| 148 | 173 | // file processing |
| 149 | 174 | static save_error check_file(running_machine &machine, emu_file &file, const char *gamename, void (CLIB_DECL *errormsg)(const char *fmt, ...)); |
| r243552 | r243553 | |
| 171 | 196 | save_prepost_delegate m_func; // delegate |
| 172 | 197 | }; |
| 173 | 198 | |
| 174 | | class state_entry |
| 175 | | { |
| 176 | | public: |
| 177 | | // construction/destruction |
| 178 | | state_entry(void *data, const char *name, UINT8 size, UINT32 count); |
| 179 | | |
| 180 | | // getters |
| 181 | | state_entry *next() const { return m_next; } |
| 182 | | |
| 183 | | // helpers |
| 184 | | void flip_data(); |
| 185 | | |
| 186 | | // state |
| 187 | | state_entry * m_next; // pointer to next entry |
| 188 | | void * m_data; // pointer to the memory to save/restore |
| 189 | | astring m_name; // full name |
| 190 | | UINT8 m_typesize; // size of the raw data type |
| 191 | | UINT32 m_typecount; // number of items |
| 192 | | UINT32 m_offset; // offset within the final structure |
| 193 | | }; |
| 194 | | |
| 195 | 199 | // internal state |
| 196 | 200 | running_machine & m_machine; // reference to our machine |
| 197 | 201 | bool m_reg_allowed; // are registrations allowed? |
| r243552 | r243553 | |
| 232 | 236 | //------------------------------------------------- |
| 233 | 237 | |
| 234 | 238 | template<> |
| 235 | | inline void save_manager::save_item(const char *module, const char *tag, int index, bitmap_ind8 &value, const char *name) |
| 239 | inline void save_manager::save_item(device_t *device, const char *module, const char *tag, int index, bitmap_ind8 &value, const char *name) |
| 236 | 240 | { |
| 237 | | save_memory(module, tag, index, name, &value.pix(0), value.bpp() / 8, value.rowpixels() * value.height()); |
| 241 | save_memory(device, module, tag, index, name, &value.pix(0), value.bpp() / 8, value.rowpixels() * value.height()); |
| 238 | 242 | } |
| 239 | 243 | |
| 240 | 244 | template<> |
| 241 | | inline void save_manager::save_item(const char *module, const char *tag, int index, bitmap_ind16 &value, const char *name) |
| 245 | inline void save_manager::save_item(device_t *device, const char *module, const char *tag, int index, bitmap_ind16 &value, const char *name) |
| 242 | 246 | { |
| 243 | | save_memory(module, tag, index, name, &value.pix(0), value.bpp() / 8, value.rowpixels() * value.height()); |
| 247 | save_memory(device, module, tag, index, name, &value.pix(0), value.bpp() / 8, value.rowpixels() * value.height()); |
| 244 | 248 | } |
| 245 | 249 | |
| 246 | 250 | template<> |
| 247 | | inline void save_manager::save_item(const char *module, const char *tag, int index, bitmap_ind32 &value, const char *name) |
| 251 | inline void save_manager::save_item(device_t *device, const char *module, const char *tag, int index, bitmap_ind32 &value, const char *name) |
| 248 | 252 | { |
| 249 | | save_memory(module, tag, index, name, &value.pix(0), value.bpp() / 8, value.rowpixels() * value.height()); |
| 253 | save_memory(device, module, tag, index, name, &value.pix(0), value.bpp() / 8, value.rowpixels() * value.height()); |
| 250 | 254 | } |
| 251 | 255 | |
| 252 | 256 | template<> |
| 253 | | inline void save_manager::save_item(const char *module, const char *tag, int index, bitmap_rgb32 &value, const char *name) |
| 257 | inline void save_manager::save_item(device_t *device, const char *module, const char *tag, int index, bitmap_rgb32 &value, const char *name) |
| 254 | 258 | { |
| 255 | | save_memory(module, tag, index, name, &value.pix(0), value.bpp() / 8, value.rowpixels() * value.height()); |
| 259 | save_memory(device, module, tag, index, name, &value.pix(0), value.bpp() / 8, value.rowpixels() * value.height()); |
| 256 | 260 | } |
| 257 | 261 | |
| 258 | 262 | |
| r243552 | r243553 | |
| 261 | 265 | //------------------------------------------------- |
| 262 | 266 | |
| 263 | 267 | template<> |
| 264 | | inline void save_manager::save_item(const char *module, const char *tag, int index, attotime &value, const char *name) |
| 268 | inline void save_manager::save_item(device_t *device, const char *module, const char *tag, int index, attotime &value, const char *name) |
| 265 | 269 | { |
| 266 | 270 | astring tempstr(name, ".attoseconds"); |
| 267 | | save_memory(module, tag, index, tempstr, &value.attoseconds, sizeof(value.attoseconds)); |
| 271 | save_memory(device, module, tag, index, tempstr, &value.attoseconds, sizeof(value.attoseconds)); |
| 268 | 272 | tempstr.cpy(name).cat(".seconds"); |
| 269 | | save_memory(module, tag, index, tempstr, &value.seconds, sizeof(value.seconds)); |
| 273 | save_memory(device, module, tag, index, tempstr, &value.seconds, sizeof(value.seconds)); |
| 270 | 274 | } |
| 271 | 275 | |
| 272 | 276 | |
trunk/src/emu/tilemap.c
| r243552 | r243553 | |
| 407 | 407 | |
| 408 | 408 | // save relevant state |
| 409 | 409 | int instance = manager.alloc_instance(); |
| 410 | | machine().save().save_item("tilemap", NULL, instance, NAME(m_enable)); |
| 411 | | machine().save().save_item("tilemap", NULL, instance, NAME(m_attributes)); |
| 412 | | machine().save().save_item("tilemap", NULL, instance, NAME(m_palette_offset)); |
| 413 | | machine().save().save_item("tilemap", NULL, instance, NAME(m_scrollrows)); |
| 414 | | machine().save().save_item("tilemap", NULL, instance, NAME(m_scrollcols)); |
| 415 | | machine().save().save_item("tilemap", NULL, instance, NAME(m_rowscroll)); |
| 416 | | machine().save().save_item("tilemap", NULL, instance, NAME(m_colscroll)); |
| 417 | | machine().save().save_item("tilemap", NULL, instance, NAME(m_dx)); |
| 418 | | machine().save().save_item("tilemap", NULL, instance, NAME(m_dx_flipped)); |
| 419 | | machine().save().save_item("tilemap", NULL, instance, NAME(m_dy)); |
| 420 | | machine().save().save_item("tilemap", NULL, instance, NAME(m_dy_flipped)); |
| 410 | machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_enable)); |
| 411 | machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_attributes)); |
| 412 | machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_palette_offset)); |
| 413 | machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_scrollrows)); |
| 414 | machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_scrollcols)); |
| 415 | machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_rowscroll)); |
| 416 | machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_colscroll)); |
| 417 | machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_dx)); |
| 418 | machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_dx_flipped)); |
| 419 | machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_dy)); |
| 420 | machine().save().save_item(m_device, "tilemap", NULL, instance, NAME(m_dy_flipped)); |
| 421 | 421 | |
| 422 | 422 | // reset everything after a load |
| 423 | 423 | machine().save().register_postload(save_prepost_delegate(FUNC(tilemap_t::postload), this)); |