From 39788873b0b99c85bb6d8c6b5da9ead619b38411 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Sun, 18 Jan 2015 16:28:09 +0100 Subject: [PATCH] save: factor-out presave/postload dispatchers Signed-off-by: Luca Bruno --- src/emu/save.c | 28 ++++++++++++++++++++++++---- src/emu/save.h | 4 ++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/emu/save.c b/src/emu/save.c index d7d8ba57ab5..98c23caf4a0 100644 --- a/src/emu/save.c +++ b/src/emu/save.c @@ -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()) diff --git a/src/emu/save.h b/src/emu/save.h index 8fc537e1289..7e00daf3fd1 100644 --- a/src/emu/save.h +++ b/src/emu/save.h @@ -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);