modernized configuration_manager (nw)

This commit is contained in:
Miodrag Milanovic 2016-01-10 15:17:18 +01:00
parent 2a2a4a3c6e
commit 3e5ad46410
19 changed files with 159 additions and 186 deletions

View File

@ -321,7 +321,7 @@ void laserdisc_device::device_start()
init_audio(); init_audio();
// register callbacks // 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 // 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 // we only care about game files
if (config_type != CONFIG_TYPE_GAME) if (cfg_type != config_type::CONFIG_TYPE_GAME)
return; return;
// might not have any data // might not have any data
@ -1178,10 +1178,10 @@ void laserdisc_device::config_load(int config_type, xml_data_node *parentnode)
// file // 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 // we only care about game files
if (config_type != CONFIG_TYPE_GAME) if (cfg_type != config_type::CONFIG_TYPE_GAME)
return; return;
// create a node // create a node

View File

@ -284,8 +284,8 @@ private:
void read_track_data(); void read_track_data();
static void *read_async_static(void *param, int threadid); static void *read_async_static(void *param, int threadid);
void process_track_data(); void process_track_data();
void config_load(int config_type, xml_data_node *parentnode); void config_load(config_type cfg_type, xml_data_node *parentnode);
void config_save(int config_type, xml_data_node *parentnode); void config_save(config_type cfg_type, xml_data_node *parentnode);
// configuration // configuration
laserdisc_get_disc_delegate m_getdisc_callback; laserdisc_get_disc_delegate m_getdisc_callback;

View File

@ -40,7 +40,7 @@ bookkeeping_manager::bookkeeping_manager(running_machine &machine)
machine.save().save_item(NAME(m_dispensed_tickets)); machine.save().save_item(NAME(m_dispensed_tickets));
// register for configuration // 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 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; xml_data_node *coinnode, *ticketnode;
/* on init, reset the counters */ /* 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)); memset(m_coin_count, 0, sizeof(m_coin_count));
m_dispensed_tickets = 0; m_dispensed_tickets = 0;
} }
/* only care about game-specific data */ /* only care about game-specific data */
if (config_type != CONFIG_TYPE_GAME) if (cfg_type != config_type::CONFIG_TYPE_GAME)
return; return;
/* might not have any data */ /* might not have any data */
@ -120,12 +120,12 @@ void bookkeeping_manager::config_load(int config_type, xml_data_node *parentnode
and tickets 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; int i;
/* only care about game-specific data */ /* only care about game-specific data */
if (config_type != CONFIG_TYPE_GAME) if (cfg_type != config_type::CONFIG_TYPE_GAME)
return; return;
/* iterate over coin counters */ /* iterate over coin counters */

View File

@ -29,6 +29,8 @@
// ======================> bookkeeping_manager // ======================> bookkeeping_manager
enum class config_type;
class bookkeeping_manager class bookkeeping_manager
{ {
public: public:
@ -61,8 +63,8 @@ public:
// getters // getters
running_machine &machine() const { return m_machine; } running_machine &machine() const { return m_machine; }
private: private:
void config_load(int config_type, xml_data_node *parentnode); void config_load(config_type cfg_type, xml_data_node *parentnode);
void config_save(int config_type, xml_data_node *parentnode); void config_save(config_type cfg_type, xml_data_node *parentnode);
// internal state // internal state
running_machine & m_machine; // reference to our machine running_machine & m_machine; // reference to our machine

View File

@ -13,59 +13,22 @@
#include "config.h" #include "config.h"
#include "xmlfile.h" #include "xmlfile.h"
#define DEBUG_CONFIG 0 #define DEBUG_CONFIG 0
//**************************************************************************
// CONFIGURATION MANAGER
//**************************************************************************
//-------------------------------------------------
// configuration_manager - constructor
//-------------------------------------------------
/*************************************************************************** configuration_manager::configuration_manager(running_machine &machine)
TYPE DEFINITIONS : m_machine(machine)
***************************************************************************/
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)
{
typelist = nullptr;
} }
/************************************* /*************************************
* *
* Register to be involved in config * 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_element element;
config_type **ptype; element.name = nodename;
element.load = load;
element.save = save;
/* allocate a new type */ m_typelist.push_back(element);
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;
} }
@ -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(); const char *controller = machine().options().ctrlr();
config_type *type;
int loaded = 0; int loaded = 0;
/* loop over all registrants and call their init function */ /* loop over all registrants and call their init function */
for (type = typelist; type; type = type->next) for (auto type : m_typelist)
type->load(CONFIG_TYPE_INIT, nullptr); type.load(config_type::CONFIG_TYPE_INIT, nullptr);
/* now load the controller file */ /* now load the controller file */
if (controller[0] != 0) if (controller[0] != 0)
{ {
/* open the config file */ /* 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"); file_error filerr = file.open(controller, ".cfg");
if (filerr != FILERR_NONE) if (filerr != FILERR_NONE)
throw emu_fatalerror("Could not load controller file %s.cfg", controller); throw emu_fatalerror("Could not load controller file %s.cfg", controller);
/* load the XML */ /* 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); throw emu_fatalerror("Could not load controller file %s.cfg", controller);
} }
/* next load the defaults file */ /* 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"); file_error filerr = file.open("default.cfg");
if (filerr == FILERR_NONE) 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 */ /* finally, load the game-specific file */
filerr = file.open(machine.basename(), ".cfg"); filerr = file.open(machine().basename(), ".cfg");
if (filerr == FILERR_NONE) 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 */ /* loop over all registrants and call their final function */
for (type = typelist; type; type = type->next) for (auto type : m_typelist)
type->load(CONFIG_TYPE_FINAL, nullptr); 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 */ /* 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. */ /* 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 */ /* loop over all registrants and call their init function */
for (type = typelist; type; type = type->next) for (auto type : m_typelist)
type->save(CONFIG_TYPE_INIT, nullptr); type.save(config_type::CONFIG_TYPE_INIT, nullptr);
/* save the defaults file */ /* 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"); file_error filerr = file.open("default.cfg");
if (filerr == FILERR_NONE) 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 */ /* finally, save the game-specific file */
filerr = file.open(machine.basename(), ".cfg"); filerr = file.open(machine().basename(), ".cfg");
if (filerr == FILERR_NONE) 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 */ /* loop over all registrants and call their final function */
for (type = typelist; type; type = type->next) for (auto type : m_typelist)
type->save(CONFIG_TYPE_FINAL, nullptr); 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; xml_data_node *root, *confignode, *systemnode;
config_type *type;
const char *srcfile; const char *srcfile;
int version, count; int version, count;
@ -199,13 +151,13 @@ static int config_load_xml(running_machine &machine, emu_file &file, int which_t
goto error; goto error;
/* strip off all the path crap from the source filename */ /* strip off all the path crap from the source filename */
srcfile = strrchr(machine.system().source_file, '/'); srcfile = strrchr(machine().system().source_file, '/');
if (!srcfile) if (!srcfile)
srcfile = strrchr(machine.system().source_file, '\\'); srcfile = strrchr(machine().system().source_file, '\\');
if (!srcfile) if (!srcfile)
srcfile = strrchr(machine.system().source_file, ':'); srcfile = strrchr(machine().system().source_file, ':');
if (!srcfile) if (!srcfile)
srcfile = machine.system().source_file; srcfile = machine().system().source_file;
else else
srcfile++; 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 */ /* based on the file type, determine whether we have a match */
switch (which_type) switch (which_type)
{ {
case CONFIG_TYPE_GAME: case config_type::CONFIG_TYPE_GAME:
/* only match on the specific game name */ /* only match on the specific game name */
if (strcmp(name, machine.system().name) != 0) if (strcmp(name, machine().system().name) != 0)
continue; continue;
break; break;
case CONFIG_TYPE_DEFAULT: case config_type::CONFIG_TYPE_DEFAULT:
/* only match on default */ /* only match on default */
if (strcmp(name, "default") != 0) if (strcmp(name, "default") != 0)
continue; continue;
break; break;
case CONFIG_TYPE_CONTROLLER: case config_type::CONFIG_TYPE_CONTROLLER:
{ {
int clone_of; int clone_of;
/* match on: default, game name, source file name, parent name, grandparent name */ /* match on: default, game name, source file name, parent name, grandparent name */
if (strcmp(name, "default") != 0 && if (strcmp(name, "default") != 0 &&
strcmp(name, machine.system().name) != 0 && strcmp(name, machine().system().name) != 0 &&
strcmp(name, srcfile) != 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)) (clone_of == -1 || ((clone_of = driver_list::clone(clone_of)) == -1) || strcmp(name, driver_list::driver(clone_of).name) != 0))
continue; continue;
break; break;
} }
default:
break;
} }
/* log that we are processing this entry */ /* 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); osd_printf_debug("Entry: %s -- processing\n", name);
/* loop over all registrants and call their load function */ /* loop over all registrants and call their load function */
for (type = typelist; type; type = type->next) for (auto type : m_typelist)
type->load(which_type, xml_get_sibling(systemnode->child, type->name)); type.load(which_type, xml_get_sibling(systemnode->child, type.name.c_str()));
count++; 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 *root = xml_file_create();
xml_data_node *confignode, *systemnode; xml_data_node *confignode, *systemnode;
config_type *type;
/* if we don't have a root, bail */ /* if we don't have a root, bail */
if (!root) 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); systemnode = xml_add_child(confignode, "system", nullptr);
if (!systemnode) if (!systemnode)
goto error; 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 */ /* create the input node and write it out */
/* loop over all registrants and call their save function */ /* 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) if (!curnode)
goto error; goto error;
type->save(which_type, curnode); type.save(which_type, curnode);
/* if nothing was added, just nuke the node */ /* if nothing was added, just nuke the node */
if (!curnode->value && !curnode->child) if (!curnode->value && !curnode->child)

View File

@ -14,8 +14,6 @@
#include "xmlfile.h" #include "xmlfile.h"
/************************************* /*************************************
* *
* Constants * Constants
@ -24,7 +22,7 @@
#define CONFIG_VERSION 10 #define CONFIG_VERSION 10
enum enum class config_type
{ {
CONFIG_TYPE_INIT = 0, /* opportunity to initialize things first */ CONFIG_TYPE_INIT = 0, /* opportunity to initialize things first */
CONFIG_TYPE_CONTROLLER, /* loading from controller file */ CONFIG_TYPE_CONTROLLER, /* loading from controller file */
@ -33,27 +31,42 @@ enum
CONFIG_TYPE_FINAL /* opportunity to finish initialization */ CONFIG_TYPE_FINAL /* opportunity to finish initialization */
}; };
/************************************* /*************************************
* *
* Type definitions * Type definitions
* *
*************************************/ *************************************/
typedef delegate<void (int, xml_data_node *)> config_saveload_delegate; typedef delegate<void (config_type, xml_data_node *)> config_saveload_delegate;
// ======================> configuration_manager
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
* Function prototypes configuration_manager(running_machine &machine);
*
*************************************/
void config_init(running_machine &machine); void config_register(const char* nodename, config_saveload_delegate load, config_saveload_delegate save);
void config_register(running_machine &machine, const char *nodename, config_saveload_delegate load, config_saveload_delegate save); int load_settings();
int config_load_settings(running_machine &machine); void save_settings();
void config_save_settings(running_machine &machine);
// 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__ */ #endif /* __CONFIG_H__ */

View File

@ -129,8 +129,8 @@ static const rgb_t crosshair_colors[] =
***************************************************************************/ ***************************************************************************/
static void crosshair_exit(running_machine &machine); static void crosshair_exit(running_machine &machine);
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);
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);
static void animate(running_machine &machine, screen_device &device, bool vblank_state); 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 */ /* register callbacks for when we load/save configurations */
if (global.usage) 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 */ /* register the animation callback */
if (machine.first_screen() != nullptr) if (machine.first_screen() != nullptr)
@ -412,7 +412,7 @@ void crosshair_set_screen(running_machine &machine, int player, screen_device *s
configuration file 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 */ /* 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; int auto_time;
/* we only care about game files */ /* we only care about game files */
if (config_type != CONFIG_TYPE_GAME) if (cfg_type != config_type::CONFIG_TYPE_GAME)
return; return;
/* might not have any data */ /* might not have any data */
@ -471,7 +471,7 @@ static void crosshair_load(running_machine &machine, int config_type, xml_data_n
configuration file 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 */ /* 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; int player;
/* we only care about game files */ /* we only care about game files */
if (config_type != CONFIG_TYPE_GAME) if (cfg_type != config_type::CONFIG_TYPE_GAME)
return; return;
for (player = 0; player < MAX_PLAYERS; player++) for (player = 0; player < MAX_PLAYERS; player++)

View File

@ -63,13 +63,13 @@ struct io_procs image_ioprocs =
configuration items 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; xml_data_node *node;
const char *dev_instance; const char *dev_instance;
const char *working_directory; 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")) 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 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; xml_data_node *node;
const char *dev_instance; const char *dev_instance;
/* only care about game-specific data */ /* 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()); image_interface_iterator iter(machine.root_device());
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) 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) void image_init(running_machine &machine)
{ {
image_device_init(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));
} }

View File

@ -2535,7 +2535,7 @@ time_t ioport_manager::initialize()
m_natkeyboard.initialize(); m_natkeyboard.initialize();
// register callbacks for when we load configurations // 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 // calculate "has..." values
{ {
@ -2958,10 +2958,10 @@ INT32 ioport_manager::frame_interpolate(INT32 oldval, INT32 newval)
// data from the XML nodes // 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 // 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; m_safe_to_read = true;
frame_update(); frame_update();
@ -2972,7 +2972,7 @@ void ioport_manager::load_config(int config_type, xml_data_node *parentnode)
return; return;
// iterate over all the remap nodes for controller configs only // 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); load_remap_table(parentnode);
// iterate over all the port nodes // 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 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); load_default_config(portnode, type, player, newseq);
else else
load_game_config(portnode, type, player, newseq); 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 // after applying the controller config, push that back into the backup, since that is
// what we will diff against // 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_type_entry *entry = m_typelist.first(); entry != nullptr; entry = entry->next())
for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype) for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype)
entry->defseq(seqtype) = entry->seq(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 // 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 no parentnode, ignore
if (parentnode == nullptr) if (parentnode == nullptr)
return; return;
// default ports save differently // default ports save differently
if (config_type == CONFIG_TYPE_DEFAULT) if (cfg_type == config_type::CONFIG_TYPE_DEFAULT)
save_default_inputs(parentnode); save_default_inputs(parentnode);
else else
save_game_inputs(parentnode); save_game_inputs(parentnode);

View File

@ -1353,6 +1353,8 @@ struct ioport_port_live
}; };
enum class config_type;
// ======================> ioport_manager // ======================> ioport_manager
// private input port state // private input port state
@ -1411,12 +1413,12 @@ private:
input_seq_type token_to_seq_type(const char *string); input_seq_type token_to_seq_type(const char *string);
void update_defaults(); 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); 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_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); 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); 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); bool save_this_input_field_type(ioport_type type);
void save_default_inputs(xml_data_node *parentnode); void save_default_inputs(xml_data_node *parentnode);

View File

@ -216,7 +216,7 @@ TIMER_CALLBACK_MEMBER(running_machine::autoboot_callback)
void running_machine::start() void running_machine::start()
{ {
// initialize basic can't-fail systems here // 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); m_input = std::make_unique<input_manager>(*this);
output_init(*this); output_init(*this);
m_render = std::make_unique<render_manager>(*this); m_render = std::make_unique<render_manager>(*this);
@ -334,7 +334,7 @@ int running_machine::run(bool firstrun)
start(); start();
// load the configuration settings and NVRAM // load the configuration settings and NVRAM
config_load_settings(*this); m_configuration->load_settings();
// disallow save state registrations starting here. // disallow save state registrations starting here.
// Don't do it earlier, config load can create network // 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 // save the NVRAM and configuration
sound().ui_mute(true); sound().ui_mute(true);
nvram_save(); nvram_save();
config_save_settings(*this); m_configuration->save_settings();
} }
catch (emu_fatalerror &fatal) catch (emu_fatalerror &fatal)
{ {

View File

@ -87,7 +87,9 @@ class tilemap_manager;
class debug_view_manager; class debug_view_manager;
class network_manager; class network_manager;
class bookkeeping_manager; class bookkeeping_manager;
class configuration_manager;
class osd_interface; class osd_interface;
enum class config_type;
struct romload_private; struct romload_private;
struct ui_input_private; struct ui_input_private;
@ -166,6 +168,7 @@ public:
video_manager &video() const { assert(m_video != nullptr); return *m_video; } video_manager &video() const { assert(m_video != nullptr); return *m_video; }
network_manager &network() const { assert(m_network != nullptr); return *m_network; } network_manager &network() const { assert(m_network != nullptr); return *m_network; }
bookkeeping_manager &bookkeeping() const { assert(m_network != nullptr); return *m_bookkeeping; } 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; } ui_manager &ui() const { assert(m_ui != nullptr); return *m_ui; }
tilemap_manager &tilemap() const { assert(m_tilemap != nullptr); return *m_tilemap; } 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; } debug_view_manager &debug_view() const { assert(m_debug_view != nullptr); return *m_debug_view; }
@ -217,7 +220,7 @@ public:
// watchdog control // watchdog control
void watchdog_reset(); void watchdog_reset();
void watchdog_enable(bool enable = true); 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 // misc
void popmessage(const char *format, ...) const; 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<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<network_manager> m_network; // internal data from network.c
std::unique_ptr<bookkeeping_manager> m_bookkeeping;// internal data from bookkeeping.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 // system state
machine_phase m_current_phase; // current execution phase machine_phase m_current_phase; // current execution phase

View File

@ -24,7 +24,7 @@
network_manager::network_manager(running_machine &machine) network_manager::network_manager(running_machine &machine)
: m_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 // 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; 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")) 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 // 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; xml_data_node *node;
/* only care about game-specific data */ /* 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()); network_interface_iterator iter(machine().root_device());
for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next()) for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next())

View File

@ -23,8 +23,8 @@ public:
// getters // getters
running_machine &machine() const { return m_machine; } running_machine &machine() const { return m_machine; }
private: private:
void config_load(int config_type, xml_data_node *parentnode); void config_load(config_type cfg_type, xml_data_node *parentnode);
void config_save(int config_type, xml_data_node *parentnode); void config_save(config_type cfg_type, xml_data_node *parentnode);
// internal state // internal state
running_machine & m_machine; // reference to our machine running_machine & m_machine; // reference to our machine

View File

@ -2403,7 +2403,7 @@ render_manager::render_manager(running_machine &machine)
m_ui_container(global_alloc(render_container(*this))) m_ui_container(global_alloc(render_container(*this)))
{ {
// register callbacks // 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 // create one container per screen
screen_device_iterator iter(machine.root_device()); screen_device_iterator iter(machine.root_device());
@ -2650,10 +2650,10 @@ void render_manager::container_free(render_container *container)
// configuration file // 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 // we only care about game files
if (config_type != CONFIG_TYPE_GAME) if (cfg_type != config_type::CONFIG_TYPE_GAME)
return; return;
// might not have any data // might not have any data
@ -2709,10 +2709,10 @@ void render_manager::config_load(int config_type, xml_data_node *parentnode)
// file // 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 // we only care about game files
if (config_type != CONFIG_TYPE_GAME) if (cfg_type != config_type::CONFIG_TYPE_GAME)
return; return;
// write out the interface target // write out the interface target

View File

@ -1057,8 +1057,8 @@ private:
void container_free(render_container *container); void container_free(render_container *container);
// config callbacks // config callbacks
void config_load(int config_type, xml_data_node *parentnode); void config_load(config_type cfg_type, xml_data_node *parentnode);
void config_save(int config_type, xml_data_node *parentnode); void config_save(config_type cfg_type, xml_data_node *parentnode);
// internal state // internal state
running_machine & m_machine; // reference back to the machine running_machine & m_machine; // reference back to the machine

View File

@ -838,7 +838,7 @@ sound_manager::sound_manager(running_machine &machine)
m_wavfile = wav_open(wavfile, machine.sample_rate(), 2); m_wavfile = wav_open(wavfile, machine.sample_rate(), 2);
// register callbacks // 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_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_RESUME, machine_notify_delegate(FUNC(sound_manager::resume), this));
machine.add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(sound_manager::reset), 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 // 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 // we only care about game files
if (config_type != CONFIG_TYPE_GAME) if (cfg_type != config_type::CONFIG_TYPE_GAME)
return; return;
// might not have any data // might not have any data
@ -997,10 +997,10 @@ void sound_manager::config_load(int config_type, xml_data_node *parentnode)
// file // 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 // we only care about game files
if (config_type != CONFIG_TYPE_GAME) if (cfg_type != config_type::CONFIG_TYPE_GAME)
return; return;
// iterate over mixer channels // iterate over mixer channels

View File

@ -222,8 +222,8 @@ private:
void reset(); void reset();
void pause(); void pause();
void resume(); void resume();
void config_load(int config_type, xml_data_node *parentnode); void config_load(config_type cfg_type, xml_data_node *parentnode);
void config_save(int config_type, xml_data_node *parentnode); void config_save(config_type cfg_type, xml_data_node *parentnode);
void update(void *ptr = nullptr, INT32 param = 0); void update(void *ptr = nullptr, INT32 param = 0);

View File

@ -77,10 +77,10 @@ static MainWindow* mainQtWindow = NULL;
std::vector<WindowQtConfig*> xmlConfigurations; 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 // We only care about game files
if (config_type != CONFIG_TYPE_GAME) if (cfg_type != config_type::CONFIG_TYPE_GAME)
return; return;
// Might not have any data // 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 // We only write to game configurations
if (config_type != CONFIG_TYPE_GAME) if (cfg_type != config_type::CONFIG_TYPE_GAME)
return; return;
for (int i = 0; i < xmlConfigurations.size(); i++) for (int i = 0; i < xmlConfigurations.size(); i++)
@ -268,8 +268,7 @@ void debug_qt::init_debugger(running_machine &machine)
m_machine = &machine; m_machine = &machine;
// Setup the configuration XML saving and loading // Setup the configuration XML saving and loading
config_register(machine, machine.configuration().config_register("debugger",
"debugger",
config_saveload_delegate(FUNC(xml_configuration_load), &machine), config_saveload_delegate(FUNC(xml_configuration_load), &machine),
config_saveload_delegate(FUNC(xml_configuration_save), &machine)); config_saveload_delegate(FUNC(xml_configuration_save), &machine));
} }