From 96c6dd334432aa2ed8efd5f46ab60eb072b30c7c Mon Sep 17 00:00:00 2001 From: AJR Date: Sat, 26 Mar 2016 01:17:01 -0400 Subject: [PATCH] Allow software selected from UI to install slot defaults Prevent clang warning about unused variable in BGFX target_manager (nw) --- src/emu/emuopts.cpp | 61 ++++++++++++++++--- src/emu/mame.cpp | 33 +--------- src/osd/modules/render/bgfx/targetmanager.cpp | 1 + 3 files changed, 54 insertions(+), 41 deletions(-) diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp index 35a8fae6333..2da58c5e177 100644 --- a/src/emu/emuopts.cpp +++ b/src/emu/emuopts.cpp @@ -376,6 +376,9 @@ void emu_options::remove_device_options() remove_entry(*curentry); } + // take also care of ramsize options + set_default_value(OPTION_RAMSIZE, ""); + // reset counters m_slot_options = 0; m_device_options = 0; @@ -550,17 +553,57 @@ void emu_options::set_system_name(const char *name) set_value(OPTION_SYSTEMNAME, name, OPTION_PRIORITY_CMDLINE, error); assert(error.empty()); - // remove any existing device options and then add them afresh + // remove any existing device options remove_device_options(); - while (add_slot_options()) { } + const game_driver *cursystem = system(); + if (cursystem == nullptr) + return; - // then add the options - add_device_options(); - int num; - do { - num = options_count(); - update_slot_options(); - } while(num != options_count()); + if (software_name()) + { + std::string sw_load(software_name()); + std::string sw_list, sw_name, sw_part, sw_instance, option_errors, error_string; + int left = sw_load.find_first_of(':'); + int middle = sw_load.find_first_of(':', left + 1); + int right = sw_load.find_last_of(':'); + + sw_list = sw_load.substr(0, left - 1); + sw_name = sw_load.substr(left + 1, middle - left - 1); + sw_part = sw_load.substr(middle + 1, right - middle - 1); + sw_instance = sw_load.substr(right + 1); + sw_load.assign(sw_load.substr(0, right)); + + // look up the software part + machine_config config(*cursystem, *this); + software_list_device *swlist = software_list_device::find_by_name(config, sw_list.c_str()); + software_info *swinfo = swlist->find(sw_name.c_str()); + software_part *swpart = swinfo->find_part(sw_part.c_str()); + + // then add the options + while (add_slot_options(swpart)) { } + add_device_options(); + + set_value(OPTION_SOFTWARENAME, sw_name.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + if (exists(sw_instance.c_str())) + set_value(sw_instance.c_str(), sw_load.c_str(), OPTION_PRIORITY_SUBCMD, error_string); + + int num; + do { + num = options_count(); + update_slot_options(swpart); + } while(num != options_count()); + } + else + { + // add the options afresh + while (add_slot_options()) { } + add_device_options(); + int num; + do { + num = options_count(); + update_slot_options(); + } while(num != options_count()); + } } } diff --git a/src/emu/mame.cpp b/src/emu/mame.cpp index 9232ee9443f..9e872c7a96f 100644 --- a/src/emu/mame.cpp +++ b/src/emu/mame.cpp @@ -251,40 +251,9 @@ int machine_manager::execute() // check the state of the machine if (m_new_driver_pending) { - std::string old_system_name(m_options.system_name()); - bool new_system = (old_system_name.compare(m_new_driver_pending->name)!=0); - // first: if we scheduled a new system, remove device options of the old system - // notice that, if we relaunch the same system, there is no effect on the emulation - if (new_system) - m_options.remove_device_options(); - // second: set up new system name (and the related device options) + // set up new system name and adjust device options accordingly m_options.set_system_name(m_new_driver_pending->name); - // third: if we scheduled a new system, take also care of ramsize options - if (new_system) - { - std::string error_string; - m_options.set_value(OPTION_RAMSIZE, "", OPTION_PRIORITY_CMDLINE, error_string); - } firstrun = true; - if (m_options.software_name()) - { - std::string sw_load(m_options.software_name()); - std::string sw_list, sw_name, sw_part, sw_instance, option_errors, error_string; - int left = sw_load.find_first_of(':'); - int middle = sw_load.find_first_of(':', left + 1); - int right = sw_load.find_last_of(':'); - - sw_list = sw_load.substr(0, left - 1); - sw_name = sw_load.substr(left + 1, middle - left - 1); - sw_part = sw_load.substr(middle + 1, right - middle - 1); - sw_instance = sw_load.substr(right + 1); - sw_load.assign(sw_load.substr(0, right)); - - char arg[] = "mame"; - char *argv = &arg[0]; - m_options.set_value(OPTION_SOFTWARENAME, sw_name.c_str(), OPTION_PRIORITY_CMDLINE, error_string); - m_options.parse_slot_devices(1, &argv, option_errors, sw_instance.c_str(), sw_load.c_str()); - } } else { diff --git a/src/osd/modules/render/bgfx/targetmanager.cpp b/src/osd/modules/render/bgfx/targetmanager.cpp index 7702d0700b4..9820f237a48 100644 --- a/src/osd/modules/render/bgfx/targetmanager.cpp +++ b/src/osd/modules/render/bgfx/targetmanager.cpp @@ -26,6 +26,7 @@ target_manager::target_manager(osd_options& options, texture_manager& textures) , m_options(options) , m_screen_count(0) { + (void)m_options; // prevent carping about unused variable } target_manager::~target_manager()