mirror of
https://github.com/holub/mame
synced 2025-06-07 13:23:50 +03:00
view: Save their state
This commit is contained in:
parent
4a27ad89e9
commit
cf472744a2
@ -522,6 +522,7 @@ bool device_t::findit(validity_checker *valid) const
|
||||
return allfound;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// resolve_pre_map - find objects that may be used
|
||||
// in memory maps
|
||||
@ -534,6 +535,7 @@ void device_t::resolve_pre_map()
|
||||
m_string_buffer.reserve(1024);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// resolve - find objects
|
||||
//-------------------------------------------------
|
||||
@ -549,6 +551,16 @@ void device_t::resolve_post_map()
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// view_register - register a view for future state saving
|
||||
//-------------------------------------------------
|
||||
|
||||
void device_t::view_register(memory_view *view)
|
||||
{
|
||||
m_viewlist.push_back(view);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// start - start a device
|
||||
//-------------------------------------------------
|
||||
@ -599,6 +611,11 @@ void device_t::start()
|
||||
save_item(NAME(m_unscaled_clock));
|
||||
save_item(NAME(m_clock_scale));
|
||||
|
||||
// have the views register their state
|
||||
logerror("Registering %d views\n", int(m_viewlist.size()));
|
||||
for(memory_view *view : m_viewlist)
|
||||
view->register_state();
|
||||
|
||||
// we're now officially started
|
||||
m_started = true;
|
||||
}
|
||||
|
@ -644,6 +644,7 @@ public:
|
||||
// misc
|
||||
template <typename Format, typename... Params> void popmessage(Format &&fmt, Params &&... args) const;
|
||||
template <typename Format, typename... Params> void logerror(Format &&fmt, Params &&... args) const;
|
||||
void view_register(memory_view *view);
|
||||
|
||||
protected:
|
||||
// miscellaneous helpers
|
||||
@ -836,6 +837,7 @@ private:
|
||||
finder_base * m_auto_finder_list; // list of objects to auto-find
|
||||
mutable std::vector<rom_entry> m_rom_entries;
|
||||
std::list<devcb_base *> m_callbacks;
|
||||
std::vector<memory_view *> m_viewlist; // list of views
|
||||
|
||||
// string formatting buffer for logerror
|
||||
mutable util::ovectorstream m_string_buffer;
|
||||
|
@ -445,7 +445,6 @@ memory_bank *memory_manager::bank_find(std::string name)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// ADDRESS SPACE CONFIG
|
||||
//**************************************************************************
|
||||
|
@ -1811,6 +1811,7 @@ class memory_view
|
||||
friend class memory_view_entry;
|
||||
friend class address_map_entry;
|
||||
friend class address_map;
|
||||
friend class device_t;
|
||||
|
||||
DISABLE_COPYING(memory_view);
|
||||
|
||||
@ -1868,6 +1869,7 @@ private:
|
||||
std::pair<handler_entry *, handler_entry *> make_handlers(address_space &space, offs_t addrstart, offs_t addrend);
|
||||
void make_subdispatch(std::string context);
|
||||
int id_to_slot(int id) const;
|
||||
void register_state();
|
||||
};
|
||||
|
||||
|
||||
@ -1918,10 +1920,9 @@ private:
|
||||
running_machine & m_machine; // reference to the machine
|
||||
|
||||
std::vector<std::unique_ptr<void, stdlib_deleter>> m_datablocks; // list of memory blocks to free on exit
|
||||
std::unordered_map<std::string, std::unique_ptr<memory_bank>> m_banklist; // data gathered for each bank
|
||||
std::unordered_map<std::string, std::unique_ptr<memory_share>> m_sharelist; // map for share lookups
|
||||
std::unordered_map<std::string, std::unique_ptr<memory_region>> m_regionlist; // list of memory regions
|
||||
|
||||
std::unordered_map<std::string, std::unique_ptr<memory_bank>> m_banklist; // map of banks
|
||||
std::unordered_map<std::string, std::unique_ptr<memory_share>> m_sharelist; // map of shares
|
||||
std::unordered_map<std::string, std::unique_ptr<memory_region>> m_regionlist; // map of memory regions
|
||||
|
||||
// Allocate the address spaces
|
||||
void allocate(device_memory_interface &memory);
|
||||
|
@ -608,6 +608,14 @@ std::string memory_view::memory_view_entry::key() const
|
||||
|
||||
memory_view::memory_view(device_t &device, std::string name) : m_device(device), m_name(name), m_config(nullptr), m_addrstart(0), m_addrend(0), m_space(nullptr), m_handler_read(nullptr), m_handler_write(nullptr), m_cur_id(-1), m_cur_slot(-1)
|
||||
{
|
||||
device.view_register(this);
|
||||
}
|
||||
|
||||
void memory_view::register_state()
|
||||
{
|
||||
m_device.machine().save().save_item(&m_device, "view", m_name.c_str(), 0, NAME(m_cur_slot));
|
||||
m_device.machine().save().save_item(&m_device, "view", m_name.c_str(), 0, NAME(m_cur_id));
|
||||
m_device.machine().save().register_postload(save_prepost_delegate(NAME([this]() { m_select_a(m_cur_id); })));
|
||||
}
|
||||
|
||||
void memory_view::disable()
|
||||
|
Loading…
Reference in New Issue
Block a user