int config_load_settings(running_machine *machine) { const char *controller = options_get_string(mame_options(), OPTION_CTRLR); file_error filerr; config_type *type; mame_file *file; int loaded = 0; astring *fname; /* loop over all registrants and call their init function */ for (type = typelist; type; type = type->next) (*type->load)(CONFIG_TYPE_INIT, NULL); /* now load the controller file */ if (controller[0] != 0) { /* open the config file */ fname = astring_assemble_2(astring_alloc(), controller, ".cfg"); filerr = mame_fopen(SEARCHPATH_CTRLR, astring_c(fname), OPEN_FLAG_READ, &file); astring_free(fname); if (filerr != FILERR_NONE) fatalerror("Could not load controller file %s.cfg", controller); /* load the XML */ if (!config_load_xml(machine, file, CONFIG_TYPE_CONTROLLER)) fatalerror("Could not load controller file %s.cfg", controller); mame_fclose(file); } /* next load the defaults file */ filerr = mame_fopen(SEARCHPATH_CONFIG, "default.cfg", OPEN_FLAG_READ, &file); if (filerr == FILERR_NONE) { config_load_xml(machine, file, CONFIG_TYPE_DEFAULT); mame_fclose(file); } /* finally, load the game-specific file */ fname = astring_assemble_2(astring_alloc(), machine->basename, ".cfg"); filerr = mame_fopen(SEARCHPATH_CONFIG, astring_c(fname), OPEN_FLAG_READ, &file); astring_free(fname); if (filerr == FILERR_NONE) { loaded = config_load_xml(machine, file, CONFIG_TYPE_GAME); mame_fclose(file); } /* loop over all registrants and call their final function */ for (type = typelist; type; type = type->next) (*type->load)(CONFIG_TYPE_FINAL, NULL); /* 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. */ return loaded; }
int config_load_settings(running_machine &machine) { const char *controller = machine.options().ctrlr(); config_type *type; int loaded = 0; /* loop over all registrants and call their init function */ for (type = typelist; type; type = type->next) type->load(CONFIG_TYPE_INIT, NULL); /* now load the controller file */ if (controller[0] != 0) { /* open the config file */ 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)) 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); file_error filerr = file.open("default.cfg"); if (filerr == FILERR_NONE) config_load_xml(machine, file, CONFIG_TYPE_DEFAULT); /* finally, load the game-specific file */ filerr = file.open(machine.basename(), ".cfg"); if (filerr == FILERR_NONE) loaded = config_load_xml(machine, file, CONFIG_TYPE_GAME); /* loop over all registrants and call their final function */ for (type = typelist; type; type = type->next) type->load(CONFIG_TYPE_FINAL, NULL); /* 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. */ return loaded; }