diff options
-rw-r--r-- | src/devices/machine/laserdsc.cpp | 10 | ||||
-rw-r--r-- | src/devices/machine/laserdsc.h | 4 | ||||
-rw-r--r-- | src/emu/bookkeeping.cpp | 12 | ||||
-rw-r--r-- | src/emu/bookkeeping.h | 6 | ||||
-rw-r--r-- | src/emu/config.cpp | 159 | ||||
-rw-r--r-- | src/emu/config.h | 47 | ||||
-rw-r--r-- | src/emu/crsshair.cpp | 14 | ||||
-rw-r--r-- | src/emu/image.cpp | 10 | ||||
-rw-r--r-- | src/emu/ioport.cpp | 16 | ||||
-rw-r--r-- | src/emu/ioport.h | 6 | ||||
-rw-r--r-- | src/emu/machine.cpp | 6 | ||||
-rw-r--r-- | src/emu/machine.h | 6 | ||||
-rw-r--r-- | src/emu/network.cpp | 10 | ||||
-rw-r--r-- | src/emu/network.h | 4 | ||||
-rw-r--r-- | src/emu/render.cpp | 10 | ||||
-rw-r--r-- | src/emu/render.h | 4 | ||||
-rw-r--r-- | src/emu/sound.cpp | 10 | ||||
-rw-r--r-- | src/emu/sound.h | 4 | ||||
-rw-r--r-- | src/osd/modules/debugger/debugqt.cpp | 11 |
19 files changed, 161 insertions, 188 deletions
diff --git a/src/devices/machine/laserdsc.cpp b/src/devices/machine/laserdsc.cpp index 7dbae408ba7..861565bafe5 100644 --- a/src/devices/machine/laserdsc.cpp +++ b/src/devices/machine/laserdsc.cpp @@ -321,7 +321,7 @@ void laserdisc_device::device_start() init_audio(); // register callbacks - config_register(machine(), "laserdisc", config_saveload_delegate(FUNC(laserdisc_device::config_load), this), config_saveload_delegate(FUNC(laserdisc_device::config_save), this)); + machine().configuration().config_register("laserdisc", config_saveload_delegate(FUNC(laserdisc_device::config_load), this), config_saveload_delegate(FUNC(laserdisc_device::config_save), this)); } @@ -1142,10 +1142,10 @@ void laserdisc_device::process_track_data() // configuration file //------------------------------------------------- -void laserdisc_device::config_load(int config_type, xml_data_node *parentnode) +void laserdisc_device::config_load(config_type cfg_type, xml_data_node *parentnode) { // we only care about game files - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) return; // might not have any data @@ -1178,10 +1178,10 @@ void laserdisc_device::config_load(int config_type, xml_data_node *parentnode) // file //------------------------------------------------- -void laserdisc_device::config_save(int config_type, xml_data_node *parentnode) +void laserdisc_device::config_save(config_type cfg_type, xml_data_node *parentnode) { // we only care about game files - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) return; // create a node diff --git a/src/devices/machine/laserdsc.h b/src/devices/machine/laserdsc.h index 0980bbb9f13..c550a9f61aa 100644 --- a/src/devices/machine/laserdsc.h +++ b/src/devices/machine/laserdsc.h @@ -284,8 +284,8 @@ private: void read_track_data(); static void *read_async_static(void *param, int threadid); void process_track_data(); - void config_load(int config_type, xml_data_node *parentnode); - void config_save(int config_type, xml_data_node *parentnode); + void config_load(config_type cfg_type, xml_data_node *parentnode); + void config_save(config_type cfg_type, xml_data_node *parentnode); // configuration laserdisc_get_disc_delegate m_getdisc_callback; diff --git a/src/emu/bookkeeping.cpp b/src/emu/bookkeeping.cpp index 86f3fc2415c..753d9c8e270 100644 --- a/src/emu/bookkeeping.cpp +++ b/src/emu/bookkeeping.cpp @@ -40,7 +40,7 @@ bookkeeping_manager::bookkeeping_manager(running_machine &machine) machine.save().save_item(NAME(m_dispensed_tickets)); // register for configuration - config_register(machine, "counters", config_saveload_delegate(FUNC(bookkeeping_manager::config_load), this), config_saveload_delegate(FUNC(bookkeeping_manager::config_save), this)); + machine.configuration().config_register("counters", config_saveload_delegate(FUNC(bookkeeping_manager::config_load), this), config_saveload_delegate(FUNC(bookkeeping_manager::config_save), this)); } @@ -81,19 +81,19 @@ void bookkeeping_manager::increment_dispensed_tickets(int delta) and tickets -------------------------------------------------*/ -void bookkeeping_manager::config_load(int config_type, xml_data_node *parentnode) +void bookkeeping_manager::config_load(config_type cfg_type, xml_data_node *parentnode) { xml_data_node *coinnode, *ticketnode; /* on init, reset the counters */ - if (config_type == CONFIG_TYPE_INIT) + if (cfg_type == config_type::CONFIG_TYPE_INIT) { memset(m_coin_count, 0, sizeof(m_coin_count)); m_dispensed_tickets = 0; } /* only care about game-specific data */ - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) return; /* might not have any data */ @@ -120,12 +120,12 @@ void bookkeeping_manager::config_load(int config_type, xml_data_node *parentnode and tickets -------------------------------------------------*/ -void bookkeeping_manager::config_save(int config_type, xml_data_node *parentnode) +void bookkeeping_manager::config_save(config_type cfg_type, xml_data_node *parentnode) { int i; /* only care about game-specific data */ - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) return; /* iterate over coin counters */ diff --git a/src/emu/bookkeeping.h b/src/emu/bookkeeping.h index 668b9375d37..26b5699c6ae 100644 --- a/src/emu/bookkeeping.h +++ b/src/emu/bookkeeping.h @@ -29,6 +29,8 @@ // ======================> bookkeeping_manager +enum class config_type; + class bookkeeping_manager { public: @@ -61,8 +63,8 @@ public: // getters running_machine &machine() const { return m_machine; } private: - void config_load(int config_type, xml_data_node *parentnode); - void config_save(int config_type, xml_data_node *parentnode); + void config_load(config_type cfg_type, xml_data_node *parentnode); + void config_save(config_type cfg_type, xml_data_node *parentnode); // internal state running_machine & m_machine; // reference to our machine diff --git a/src/emu/config.cpp b/src/emu/config.cpp index 65dbea7ce38..691012a4a41 100644 --- a/src/emu/config.cpp +++ b/src/emu/config.cpp @@ -13,59 +13,22 @@ #include "config.h" #include "xmlfile.h" - #define DEBUG_CONFIG 0 +//************************************************************************** +// CONFIGURATION MANAGER +//************************************************************************** +//------------------------------------------------- +// configuration_manager - constructor +//------------------------------------------------- -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -struct config_type -{ - config_type * next; /* next in line */ - const char * name; /* node name */ - config_saveload_delegate load; /* load callback */ - config_saveload_delegate save; /* save callback */ -}; - - - -/*************************************************************************** - GLOBAL VARIABLES -***************************************************************************/ - -static config_type *typelist; - - - -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -static int config_load_xml(running_machine &machine, emu_file &file, int type); -static int config_save_xml(running_machine &machine, emu_file &file, int type); - - - -/*************************************************************************** - CORE IMPLEMENTATION -***************************************************************************/ - -/************************************* - * - * Reset the configuration callbacks - * - *************************************/ -void config_init(running_machine &machine) +configuration_manager::configuration_manager(running_machine &machine) + : m_machine(machine) { - typelist = nullptr; } - - /************************************* * * Register to be involved in config @@ -73,21 +36,14 @@ void config_init(running_machine &machine) * *************************************/ -void config_register(running_machine &machine, const char *nodename, config_saveload_delegate load, config_saveload_delegate save) +void configuration_manager::config_register(const char* nodename, config_saveload_delegate load, config_saveload_delegate save) { - config_type *newtype; - config_type **ptype; - - /* allocate a new type */ - newtype = auto_alloc(machine, config_type); - newtype->next = nullptr; - newtype->name = nodename; - newtype->load = load; - newtype->save = save; - - /* add us to the end */ - for (ptype = &typelist; *ptype; ptype = &(*ptype)->next) { } - *ptype = newtype; + config_element element; + element.name = nodename; + element.load = load; + element.save = save; + + m_typelist.push_back(element); } @@ -98,45 +54,44 @@ void config_register(running_machine &machine, const char *nodename, config_save * *************************************/ -int config_load_settings(running_machine &machine) +int configuration_manager::load_settings() { - const char *controller = machine.options().ctrlr(); - config_type *type; + const char *controller = machine().options().ctrlr(); int loaded = 0; /* loop over all registrants and call their init function */ - for (type = typelist; type; type = type->next) - type->load(CONFIG_TYPE_INIT, nullptr); + for (auto type : m_typelist) + type.load(config_type::CONFIG_TYPE_INIT, nullptr); /* now load the controller file */ if (controller[0] != 0) { /* open the config file */ - emu_file file(machine.options().ctrlr_path(), OPEN_FLAG_READ); + emu_file file(machine().options().ctrlr_path(), OPEN_FLAG_READ); file_error filerr = file.open(controller, ".cfg"); if (filerr != FILERR_NONE) throw emu_fatalerror("Could not load controller file %s.cfg", controller); /* load the XML */ - if (!config_load_xml(machine, file, CONFIG_TYPE_CONTROLLER)) + if (!load_xml(file, config_type::CONFIG_TYPE_CONTROLLER)) throw emu_fatalerror("Could not load controller file %s.cfg", controller); } /* next load the defaults file */ - emu_file file(machine.options().cfg_directory(), OPEN_FLAG_READ); + emu_file file(machine().options().cfg_directory(), OPEN_FLAG_READ); file_error filerr = file.open("default.cfg"); if (filerr == FILERR_NONE) - config_load_xml(machine, file, CONFIG_TYPE_DEFAULT); + load_xml(file, config_type::CONFIG_TYPE_DEFAULT); /* finally, load the game-specific file */ - filerr = file.open(machine.basename(), ".cfg"); + filerr = file.open(machine().basename(), ".cfg"); if (filerr == FILERR_NONE) - loaded = config_load_xml(machine, file, CONFIG_TYPE_GAME); + loaded = load_xml(file, config_type::CONFIG_TYPE_GAME); /* loop over all registrants and call their final function */ - for (type = typelist; type; type = type->next) - type->load(CONFIG_TYPE_FINAL, nullptr); + for (auto type : m_typelist) + type.load(config_type::CONFIG_TYPE_FINAL, nullptr); /* if we didn't find a saved config, return 0 so the main core knows that it */ /* is the first time the game is run and it should diplay the disclaimer. */ @@ -144,28 +99,26 @@ int config_load_settings(running_machine &machine) } -void config_save_settings(running_machine &machine) +void configuration_manager::save_settings() { - config_type *type; - /* loop over all registrants and call their init function */ - for (type = typelist; type; type = type->next) - type->save(CONFIG_TYPE_INIT, nullptr); + for (auto type : m_typelist) + type.save(config_type::CONFIG_TYPE_INIT, nullptr); /* save the defaults file */ - emu_file file(machine.options().cfg_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); + emu_file file(machine().options().cfg_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); file_error filerr = file.open("default.cfg"); if (filerr == FILERR_NONE) - config_save_xml(machine, file, CONFIG_TYPE_DEFAULT); + save_xml(file, config_type::CONFIG_TYPE_DEFAULT); /* finally, save the game-specific file */ - filerr = file.open(machine.basename(), ".cfg"); + filerr = file.open(machine().basename(), ".cfg"); if (filerr == FILERR_NONE) - config_save_xml(machine, file, CONFIG_TYPE_GAME); + save_xml(file, config_type::CONFIG_TYPE_GAME); /* loop over all registrants and call their final function */ - for (type = typelist; type; type = type->next) - type->save(CONFIG_TYPE_FINAL, nullptr); + for (auto type : m_typelist) + type.save(config_type::CONFIG_TYPE_FINAL, nullptr); } @@ -176,10 +129,9 @@ void config_save_settings(running_machine &machine) * *************************************/ -static int config_load_xml(running_machine &machine, emu_file &file, int which_type) +int configuration_manager::load_xml(emu_file &file, config_type which_type) { xml_data_node *root, *confignode, *systemnode; - config_type *type; const char *srcfile; int version, count; @@ -199,13 +151,13 @@ static int config_load_xml(running_machine &machine, emu_file &file, int which_t goto error; /* strip off all the path crap from the source filename */ - srcfile = strrchr(machine.system().source_file, '/'); + srcfile = strrchr(machine().system().source_file, '/'); if (!srcfile) - srcfile = strrchr(machine.system().source_file, '\\'); + srcfile = strrchr(machine().system().source_file, '\\'); if (!srcfile) - srcfile = strrchr(machine.system().source_file, ':'); + srcfile = strrchr(machine().system().source_file, ':'); if (!srcfile) - srcfile = machine.system().source_file; + srcfile = machine().system().source_file; else srcfile++; @@ -219,30 +171,32 @@ static int config_load_xml(running_machine &machine, emu_file &file, int which_t /* based on the file type, determine whether we have a match */ switch (which_type) { - case CONFIG_TYPE_GAME: + case config_type::CONFIG_TYPE_GAME: /* only match on the specific game name */ - if (strcmp(name, machine.system().name) != 0) + if (strcmp(name, machine().system().name) != 0) continue; break; - case CONFIG_TYPE_DEFAULT: + case config_type::CONFIG_TYPE_DEFAULT: /* only match on default */ if (strcmp(name, "default") != 0) continue; break; - case CONFIG_TYPE_CONTROLLER: + case config_type::CONFIG_TYPE_CONTROLLER: { int clone_of; /* match on: default, game name, source file name, parent name, grandparent name */ if (strcmp(name, "default") != 0 && - strcmp(name, machine.system().name) != 0 && + strcmp(name, machine().system().name) != 0 && strcmp(name, srcfile) != 0 && - ((clone_of = driver_list::clone(machine.system())) == -1 || strcmp(name, driver_list::driver(clone_of).name) != 0) && + ((clone_of = driver_list::clone(machine().system())) == -1 || strcmp(name, driver_list::driver(clone_of).name) != 0) && (clone_of == -1 || ((clone_of = driver_list::clone(clone_of)) == -1) || strcmp(name, driver_list::driver(clone_of).name) != 0)) continue; break; } + default: + break; } /* log that we are processing this entry */ @@ -250,8 +204,8 @@ static int config_load_xml(running_machine &machine, emu_file &file, int which_t osd_printf_debug("Entry: %s -- processing\n", name); /* loop over all registrants and call their load function */ - for (type = typelist; type; type = type->next) - type->load(which_type, xml_get_sibling(systemnode->child, type->name)); + for (auto type : m_typelist) + type.load(which_type, xml_get_sibling(systemnode->child, type.name.c_str())); count++; } @@ -277,11 +231,10 @@ error: * *************************************/ -static int config_save_xml(running_machine &machine, emu_file &file, int which_type) +int configuration_manager::save_xml(emu_file &file, config_type which_type) { xml_data_node *root = xml_file_create(); xml_data_node *confignode, *systemnode; - config_type *type; /* if we don't have a root, bail */ if (!root) @@ -297,16 +250,16 @@ static int config_save_xml(running_machine &machine, emu_file &file, int which_t systemnode = xml_add_child(confignode, "system", nullptr); if (!systemnode) goto error; - xml_set_attribute(systemnode, "name", (which_type == CONFIG_TYPE_DEFAULT) ? "default" : machine.system().name); + xml_set_attribute(systemnode, "name", (which_type == config_type::CONFIG_TYPE_DEFAULT) ? "default" : machine().system().name); /* create the input node and write it out */ /* loop over all registrants and call their save function */ - for (type = typelist; type; type = type->next) + for (auto type : m_typelist) { - xml_data_node *curnode = xml_add_child(systemnode, type->name, nullptr); + xml_data_node *curnode = xml_add_child(systemnode, type.name.c_str(), nullptr); if (!curnode) goto error; - type->save(which_type, curnode); + type.save(which_type, curnode); /* if nothing was added, just nuke the node */ if (!curnode->value && !curnode->child) diff --git a/src/emu/config.h b/src/emu/config.h index da3d7dc3bae..6875fba899e 100644 --- a/src/emu/config.h +++ b/src/emu/config.h @@ -14,8 +14,6 @@ #include "xmlfile.h" - - /************************************* * * Constants @@ -24,7 +22,7 @@ #define CONFIG_VERSION 10 -enum +enum class config_type { CONFIG_TYPE_INIT = 0, /* opportunity to initialize things first */ CONFIG_TYPE_CONTROLLER, /* loading from controller file */ @@ -33,27 +31,42 @@ enum CONFIG_TYPE_FINAL /* opportunity to finish initialization */ }; - - /************************************* * * Type definitions * *************************************/ -typedef delegate<void (int, xml_data_node *)> config_saveload_delegate; - - +typedef delegate<void (config_type, xml_data_node *)> config_saveload_delegate; -/************************************* - * - * Function prototypes - * - *************************************/ +// ======================> configuration_manager -void config_init(running_machine &machine); -void config_register(running_machine &machine, const char *nodename, config_saveload_delegate load, config_saveload_delegate save); -int config_load_settings(running_machine &machine); -void config_save_settings(running_machine &machine); +class configuration_manager +{ + struct config_element + { + std::string name; /* node name */ + config_saveload_delegate load; /* load callback */ + config_saveload_delegate save; /* save callback */ + }; + +public: + // construction/destruction + configuration_manager(running_machine &machine); + + void config_register(const char* nodename, config_saveload_delegate load, config_saveload_delegate save); + int load_settings(); + void save_settings(); + + // getters + running_machine &machine() const { return m_machine; } +private: + int load_xml(emu_file &file, config_type which_type); + int save_xml(emu_file &file, config_type which_type); + + // internal state + running_machine & m_machine; // reference to our machine + std::vector<config_element> m_typelist; +}; #endif /* __CONFIG_H__ */ diff --git a/src/emu/crsshair.cpp b/src/emu/crsshair.cpp index 88cfb8dac02..64c288763d3 100644 --- a/src/emu/crsshair.cpp +++ b/src/emu/crsshair.cpp @@ -129,8 +129,8 @@ static const rgb_t crosshair_colors[] = ***************************************************************************/ static void crosshair_exit(running_machine &machine); -static void crosshair_load(running_machine &machine, int config_type, xml_data_node *parentnode); -static void crosshair_save(running_machine &machine, int config_type, xml_data_node *parentnode); +static void crosshair_load(running_machine &machine, config_type cfg_type, xml_data_node *parentnode); +static void crosshair_save(running_machine &machine, config_type cfg_type, xml_data_node *parentnode); static void animate(running_machine &machine, screen_device &device, bool vblank_state); @@ -240,7 +240,7 @@ void crosshair_init(running_machine &machine) /* register callbacks for when we load/save configurations */ if (global.usage) - config_register(machine, "crosshairs", config_saveload_delegate(FUNC(crosshair_load), &machine), config_saveload_delegate(FUNC(crosshair_save), &machine)); + machine.configuration().config_register("crosshairs", config_saveload_delegate(FUNC(crosshair_load), &machine), config_saveload_delegate(FUNC(crosshair_save), &machine)); /* register the animation callback */ if (machine.first_screen() != nullptr) @@ -412,7 +412,7 @@ void crosshair_set_screen(running_machine &machine, int player, screen_device *s configuration file -------------------------------------------------*/ -static void crosshair_load(running_machine &machine, int config_type, xml_data_node *parentnode) +static void crosshair_load(running_machine &machine, config_type cfg_type, xml_data_node *parentnode) { /* Note: crosshair_load() is only registered if croshairs are used */ @@ -420,7 +420,7 @@ static void crosshair_load(running_machine &machine, int config_type, xml_data_n int auto_time; /* we only care about game files */ - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) return; /* might not have any data */ @@ -471,7 +471,7 @@ static void crosshair_load(running_machine &machine, int config_type, xml_data_n configuration file -------------------------------------------------*/ -static void crosshair_save(running_machine &machine, int config_type, xml_data_node *parentnode) +static void crosshair_save(running_machine &machine, config_type cfg_type, xml_data_node *parentnode) { /* Note: crosshair_save() is only registered if crosshairs are used */ @@ -479,7 +479,7 @@ static void crosshair_save(running_machine &machine, int config_type, xml_data_n int player; /* we only care about game files */ - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) return; for (player = 0; player < MAX_PLAYERS; player++) diff --git a/src/emu/image.cpp b/src/emu/image.cpp index ab7f7406854..6dcddfa0536 100644 --- a/src/emu/image.cpp +++ b/src/emu/image.cpp @@ -63,13 +63,13 @@ struct io_procs image_ioprocs = configuration items -------------------------------------------------*/ -static void image_dirs_load(running_machine &machine, int config_type, xml_data_node *parentnode) +static void image_dirs_load(running_machine &machine, config_type cfg_type, xml_data_node *parentnode) { xml_data_node *node; const char *dev_instance; const char *working_directory; - if ((config_type == CONFIG_TYPE_GAME) && (parentnode != nullptr)) + if ((cfg_type == config_type::CONFIG_TYPE_GAME) && (parentnode != nullptr)) { for (node = xml_get_sibling(parentnode->child, "device"); node; node = xml_get_sibling(node->next, "device")) { @@ -98,13 +98,13 @@ static void image_dirs_load(running_machine &machine, int config_type, xml_data_ directories to the configuration file -------------------------------------------------*/ -static void image_dirs_save(running_machine &machine, int config_type, xml_data_node *parentnode) +static void image_dirs_save(running_machine &machine, config_type cfg_type, xml_data_node *parentnode) { xml_data_node *node; const char *dev_instance; /* only care about game-specific data */ - if (config_type == CONFIG_TYPE_GAME) + if (cfg_type == config_type::CONFIG_TYPE_GAME) { image_interface_iterator iter(machine.root_device()); for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) @@ -298,7 +298,7 @@ void image_postdevice_init(running_machine &machine) void image_init(running_machine &machine) { image_device_init(machine); - config_register(machine, "image_directories", config_saveload_delegate(FUNC(image_dirs_load), &machine), config_saveload_delegate(FUNC(image_dirs_save), &machine)); + machine.configuration().config_register("image_directories", config_saveload_delegate(FUNC(image_dirs_load), &machine), config_saveload_delegate(FUNC(image_dirs_save), &machine)); } diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index af099545f48..7ae15931eba 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -2535,7 +2535,7 @@ time_t ioport_manager::initialize() m_natkeyboard.initialize(); // register callbacks for when we load configurations - config_register(machine(), "input", config_saveload_delegate(FUNC(ioport_manager::load_config), this), config_saveload_delegate(FUNC(ioport_manager::save_config), this)); + machine().configuration().config_register("input", config_saveload_delegate(FUNC(ioport_manager::load_config), this), config_saveload_delegate(FUNC(ioport_manager::save_config), this)); // calculate "has..." values { @@ -2958,10 +2958,10 @@ INT32 ioport_manager::frame_interpolate(INT32 oldval, INT32 newval) // data from the XML nodes //------------------------------------------------- -void ioport_manager::load_config(int config_type, xml_data_node *parentnode) +void ioport_manager::load_config(config_type cfg_type, xml_data_node *parentnode) { // in the completion phase, we finish the initialization with the final ports - if (config_type == CONFIG_TYPE_FINAL) + if (cfg_type == config_type::CONFIG_TYPE_FINAL) { m_safe_to_read = true; frame_update(); @@ -2972,7 +2972,7 @@ void ioport_manager::load_config(int config_type, xml_data_node *parentnode) return; // iterate over all the remap nodes for controller configs only - if (config_type == CONFIG_TYPE_CONTROLLER) + if (cfg_type == config_type::CONFIG_TYPE_CONTROLLER) load_remap_table(parentnode); // iterate over all the port nodes @@ -3002,7 +3002,7 @@ void ioport_manager::load_config(int config_type, xml_data_node *parentnode) } // if we're loading default ports, apply to the defaults - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) load_default_config(portnode, type, player, newseq); else load_game_config(portnode, type, player, newseq); @@ -3010,7 +3010,7 @@ void ioport_manager::load_config(int config_type, xml_data_node *parentnode) // after applying the controller config, push that back into the backup, since that is // what we will diff against - if (config_type == CONFIG_TYPE_CONTROLLER) + if (cfg_type == config_type::CONFIG_TYPE_CONTROLLER) for (input_type_entry *entry = m_typelist.first(); entry != nullptr; entry = entry->next()) for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype) entry->defseq(seqtype) = entry->seq(seqtype); @@ -3149,14 +3149,14 @@ bool ioport_manager::load_game_config(xml_data_node *portnode, int type, int pla // port configuration //------------------------------------------------- -void ioport_manager::save_config(int config_type, xml_data_node *parentnode) +void ioport_manager::save_config(config_type cfg_type, xml_data_node *parentnode) { // if no parentnode, ignore if (parentnode == nullptr) return; // default ports save differently - if (config_type == CONFIG_TYPE_DEFAULT) + if (cfg_type == config_type::CONFIG_TYPE_DEFAULT) save_default_inputs(parentnode); else save_game_inputs(parentnode); diff --git a/src/emu/ioport.h b/src/emu/ioport.h index ddb653b5926..17a33545661 100644 --- a/src/emu/ioport.h +++ b/src/emu/ioport.h @@ -1353,6 +1353,8 @@ struct ioport_port_live }; +enum class config_type; + // ======================> ioport_manager // private input port state @@ -1411,12 +1413,12 @@ private: input_seq_type token_to_seq_type(const char *string); void update_defaults(); - void load_config(int config_type, xml_data_node *parentnode); + void load_config(config_type cfg_type, xml_data_node *parentnode); void load_remap_table(xml_data_node *parentnode); bool load_default_config(xml_data_node *portnode, int type, int player, const input_seq *newseq); bool load_game_config(xml_data_node *portnode, int type, int player, const input_seq *newseq); - void save_config(int config_type, xml_data_node *parentnode); + void save_config(config_type cfg_type, xml_data_node *parentnode); void save_sequence(xml_data_node *parentnode, input_seq_type type, ioport_type porttype, const input_seq &seq); bool save_this_input_field_type(ioport_type type); void save_default_inputs(xml_data_node *parentnode); diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 4445cf96dff..a48aa0811c6 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -216,7 +216,7 @@ TIMER_CALLBACK_MEMBER(running_machine::autoboot_callback) void running_machine::start() { // initialize basic can't-fail systems here - config_init(*this); + m_configuration = std::make_unique<configuration_manager>(*this); m_input = std::make_unique<input_manager>(*this); output_init(*this); m_render = std::make_unique<render_manager>(*this); @@ -334,7 +334,7 @@ int running_machine::run(bool firstrun) start(); // load the configuration settings and NVRAM - config_load_settings(*this); + m_configuration->load_settings(); // disallow save state registrations starting here. // Don't do it earlier, config load can create network @@ -389,7 +389,7 @@ int running_machine::run(bool firstrun) // save the NVRAM and configuration sound().ui_mute(true); nvram_save(); - config_save_settings(*this); + m_configuration->save_settings(); } catch (emu_fatalerror &fatal) { diff --git a/src/emu/machine.h b/src/emu/machine.h index 1b5e5ad6369..6c2a08c4c15 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -87,7 +87,9 @@ class tilemap_manager; class debug_view_manager; class network_manager; class bookkeeping_manager; +class configuration_manager; class osd_interface; +enum class config_type; struct romload_private; struct ui_input_private; @@ -166,6 +168,7 @@ public: video_manager &video() const { assert(m_video != nullptr); return *m_video; } network_manager &network() const { assert(m_network != nullptr); return *m_network; } bookkeeping_manager &bookkeeping() const { assert(m_network != nullptr); return *m_bookkeeping; } + configuration_manager &configuration() const { assert(m_configuration != nullptr); return *m_configuration; } ui_manager &ui() const { assert(m_ui != nullptr); return *m_ui; } tilemap_manager &tilemap() const { assert(m_tilemap != nullptr); return *m_tilemap; } debug_view_manager &debug_view() const { assert(m_debug_view != nullptr); return *m_debug_view; } @@ -217,7 +220,7 @@ public: // watchdog control void watchdog_reset(); void watchdog_enable(bool enable = true); - INT32 get_vblank_watchdog_counter() { return m_watchdog_counter; } + INT32 get_vblank_watchdog_counter() const { return m_watchdog_counter; } // misc void popmessage(const char *format, ...) const; @@ -283,6 +286,7 @@ private: std::unique_ptr<debug_view_manager> m_debug_view; // internal data from debugvw.c std::unique_ptr<network_manager> m_network; // internal data from network.c std::unique_ptr<bookkeeping_manager> m_bookkeeping;// internal data from bookkeeping.c + std::unique_ptr<configuration_manager> m_configuration; // internal data from config.c // system state machine_phase m_current_phase; // current execution phase diff --git a/src/emu/network.cpp b/src/emu/network.cpp index 8d48690e5b4..0f5db2fd703 100644 --- a/src/emu/network.cpp +++ b/src/emu/network.cpp @@ -24,7 +24,7 @@ network_manager::network_manager(running_machine &machine) : m_machine(machine) { - config_register(machine, "network", config_saveload_delegate(FUNC(network_manager::config_load), this), config_saveload_delegate(FUNC(network_manager::config_save), this)); + machine.configuration().config_register("network", config_saveload_delegate(FUNC(network_manager::config_load), this), config_saveload_delegate(FUNC(network_manager::config_save), this)); } //------------------------------------------------- @@ -32,10 +32,10 @@ network_manager::network_manager(running_machine &machine) // configuration file //------------------------------------------------- -void network_manager::config_load(int config_type, xml_data_node *parentnode) +void network_manager::config_load(config_type cfg_type, xml_data_node *parentnode) { xml_data_node *node; - if ((config_type == CONFIG_TYPE_GAME) && (parentnode != nullptr)) + if ((cfg_type == config_type::CONFIG_TYPE_GAME) && (parentnode != nullptr)) { for (node = xml_get_sibling(parentnode->child, "device"); node; node = xml_get_sibling(node->next, "device")) { @@ -69,12 +69,12 @@ void network_manager::config_load(int config_type, xml_data_node *parentnode) // file //------------------------------------------------- -void network_manager::config_save(int config_type, xml_data_node *parentnode) +void network_manager::config_save(config_type cfg_type, xml_data_node *parentnode) { xml_data_node *node; /* only care about game-specific data */ - if (config_type == CONFIG_TYPE_GAME) + if (cfg_type == config_type::CONFIG_TYPE_GAME) { network_interface_iterator iter(machine().root_device()); for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next()) diff --git a/src/emu/network.h b/src/emu/network.h index ab082922129..41ed328c37d 100644 --- a/src/emu/network.h +++ b/src/emu/network.h @@ -23,8 +23,8 @@ public: // getters running_machine &machine() const { return m_machine; } private: - void config_load(int config_type, xml_data_node *parentnode); - void config_save(int config_type, xml_data_node *parentnode); + void config_load(config_type cfg_type, xml_data_node *parentnode); + void config_save(config_type cfg_type, xml_data_node *parentnode); // internal state running_machine & m_machine; // reference to our machine diff --git a/src/emu/render.cpp b/src/emu/render.cpp index 2fe0a20d880..baa5aa8db1b 100644 --- a/src/emu/render.cpp +++ b/src/emu/render.cpp @@ -2403,7 +2403,7 @@ render_manager::render_manager(running_machine &machine) m_ui_container(global_alloc(render_container(*this))) { // register callbacks - config_register(machine, "video", config_saveload_delegate(FUNC(render_manager::config_load), this), config_saveload_delegate(FUNC(render_manager::config_save), this)); + machine.configuration().config_register("video", config_saveload_delegate(FUNC(render_manager::config_load), this), config_saveload_delegate(FUNC(render_manager::config_save), this)); // create one container per screen screen_device_iterator iter(machine.root_device()); @@ -2650,10 +2650,10 @@ void render_manager::container_free(render_container *container) // configuration file //------------------------------------------------- -void render_manager::config_load(int config_type, xml_data_node *parentnode) +void render_manager::config_load(config_type cfg_type, xml_data_node *parentnode) { // we only care about game files - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) return; // might not have any data @@ -2709,10 +2709,10 @@ void render_manager::config_load(int config_type, xml_data_node *parentnode) // file //------------------------------------------------- -void render_manager::config_save(int config_type, xml_data_node *parentnode) +void render_manager::config_save(config_type cfg_type, xml_data_node *parentnode) { // we only care about game files - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) return; // write out the interface target diff --git a/src/emu/render.h b/src/emu/render.h index a369cd6b40e..df8896b712b 100644 --- a/src/emu/render.h +++ b/src/emu/render.h @@ -1057,8 +1057,8 @@ private: void container_free(render_container *container); // config callbacks - void config_load(int config_type, xml_data_node *parentnode); - void config_save(int config_type, xml_data_node *parentnode); + void config_load(config_type cfg_type, xml_data_node *parentnode); + void config_save(config_type cfg_type, xml_data_node *parentnode); // internal state running_machine & m_machine; // reference back to the machine diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp index 89db24f85ca..1b007a303ea 100644 --- a/src/emu/sound.cpp +++ b/src/emu/sound.cpp @@ -838,7 +838,7 @@ sound_manager::sound_manager(running_machine &machine) m_wavfile = wav_open(wavfile, machine.sample_rate(), 2); // register callbacks - config_register(machine, "mixer", config_saveload_delegate(FUNC(sound_manager::config_load), this), config_saveload_delegate(FUNC(sound_manager::config_save), this)); + machine.configuration().config_register("mixer", config_saveload_delegate(FUNC(sound_manager::config_load), this), config_saveload_delegate(FUNC(sound_manager::config_save), this)); machine.add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(sound_manager::pause), this)); machine.add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(sound_manager::resume), this)); machine.add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(sound_manager::reset), this)); @@ -967,10 +967,10 @@ void sound_manager::resume() // configuration file //------------------------------------------------- -void sound_manager::config_load(int config_type, xml_data_node *parentnode) +void sound_manager::config_load(config_type cfg_type, xml_data_node *parentnode) { // we only care about game files - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) return; // might not have any data @@ -997,10 +997,10 @@ void sound_manager::config_load(int config_type, xml_data_node *parentnode) // file //------------------------------------------------- -void sound_manager::config_save(int config_type, xml_data_node *parentnode) +void sound_manager::config_save(config_type cfg_type, xml_data_node *parentnode) { // we only care about game files - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) return; // iterate over mixer channels diff --git a/src/emu/sound.h b/src/emu/sound.h index 50c94486eb3..9480388ac5b 100644 --- a/src/emu/sound.h +++ b/src/emu/sound.h @@ -222,8 +222,8 @@ private: void reset(); void pause(); void resume(); - void config_load(int config_type, xml_data_node *parentnode); - void config_save(int config_type, xml_data_node *parentnode); + void config_load(config_type cfg_type, xml_data_node *parentnode); + void config_save(config_type cfg_type, xml_data_node *parentnode); void update(void *ptr = nullptr, INT32 param = 0); diff --git a/src/osd/modules/debugger/debugqt.cpp b/src/osd/modules/debugger/debugqt.cpp index 195cf38ae89..e553585f729 100644 --- a/src/osd/modules/debugger/debugqt.cpp +++ b/src/osd/modules/debugger/debugqt.cpp @@ -77,10 +77,10 @@ static MainWindow* mainQtWindow = NULL; std::vector<WindowQtConfig*> xmlConfigurations; -static void xml_configuration_load(running_machine &machine, int config_type, xml_data_node *parentnode) +static void xml_configuration_load(running_machine &machine, config_type cfg_type, xml_data_node *parentnode) { // We only care about game files - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) return; // Might not have any data @@ -112,10 +112,10 @@ static void xml_configuration_load(running_machine &machine, int config_type, xm } -static void xml_configuration_save(running_machine &machine, int config_type, xml_data_node *parentnode) +static void xml_configuration_save(running_machine &machine, config_type cfg_type, xml_data_node *parentnode) { // We only write to game configurations - if (config_type != CONFIG_TYPE_GAME) + if (cfg_type != config_type::CONFIG_TYPE_GAME) return; for (int i = 0; i < xmlConfigurations.size(); i++) @@ -268,8 +268,7 @@ void debug_qt::init_debugger(running_machine &machine) m_machine = &machine; // Setup the configuration XML saving and loading - config_register(machine, - "debugger", + machine.configuration().config_register("debugger", config_saveload_delegate(FUNC(xml_configuration_load), &machine), config_saveload_delegate(FUNC(xml_configuration_save), &machine)); } |