save: factor-out presave/postload dispatchers

Signed-off-by: Luca Bruno <lucab@debian.org>
This commit is contained in:
Luca Bruno 2015-01-18 16:28:09 +01:00
parent c95ed9c31d
commit 39788873b0
2 changed files with 28 additions and 4 deletions

View File

@ -213,6 +213,17 @@ save_error save_manager::check_file(running_machine &machine, emu_file &file, co
return validate_header(header, gamename, sig, errormsg, "");
}
//-------------------------------------------------
// dispatch_postload - invoke all registered
// postload callbacks for updates
//-------------------------------------------------
void save_manager::dispatch_postload()
{
for (state_callback *func = m_postload_list.first(); func != NULL; func = func->next())
func->m_func();
}
//-------------------------------------------------
// read_file - read the data from a file
@ -253,12 +264,22 @@ save_error save_manager::read_file(emu_file &file)
}
// call the post-load functions
for (state_callback *func = m_postload_list.first(); func != NULL; func = func->next())
func->m_func();
dispatch_postload();
return STATERR_NONE;
}
//-------------------------------------------------
// dispatch_presave - invoke all registered
// presave callbacks for updates
//-------------------------------------------------
void save_manager::dispatch_presave()
{
for (state_callback *func = m_presave_list.first(); func != NULL; func = func->next())
func->m_func();
}
//-------------------------------------------------
// write_file - writes the data to a file
@ -287,8 +308,7 @@ save_error save_manager::write_file(emu_file &file)
file.compress(FCOMPRESS_MEDIUM);
// call the pre-save functions
for (state_callback *func = m_presave_list.first(); func != NULL; func = func->next())
func->m_func();
dispatch_presave();
// then write all the data
for (state_entry *entry = m_entry_list.first(); entry != NULL; entry = entry->next())

View File

@ -99,6 +99,10 @@ public:
void register_presave(save_prepost_delegate func);
void register_postload(save_prepost_delegate func);
// callback dispatching
void dispatch_presave();
void dispatch_postload();
// generic memory registration
void save_memory(const char *module, const char *tag, UINT32 index, const char *name, void *val, UINT32 valsize, UINT32 valcount = 1);