summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emu/emuopts.cpp94
1 files changed, 50 insertions, 44 deletions
diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp
index 2da58c5e177..38bcee35467 100644
--- a/src/emu/emuopts.cpp
+++ b/src/emu/emuopts.cpp
@@ -544,9 +544,10 @@ void emu_options::set_system_name(const char *name)
{
// remember the original system name
std::string old_system_name(system_name());
+ bool new_system = old_system_name.compare(name)!=0;
// if the system name changed, fix up the device options
- if (old_system_name.compare(name)!=0)
+ if (new_system)
{
// first set the new name
std::string error;
@@ -555,55 +556,60 @@ void emu_options::set_system_name(const char *name)
// remove any existing device options
remove_device_options();
- const game_driver *cursystem = system();
- if (cursystem == nullptr)
- return;
+ }
- if (software_name())
+ // get the new system
+ const game_driver *cursystem = system();
+ if (cursystem == nullptr)
+ return;
+
+ 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
+ if (new_system)
{
- 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);
+ 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());
- }
+ int num;
+ do {
+ num = options_count();
+ update_slot_options(swpart);
+ } while(num != options_count());
+ }
+ else if (new_system)
+ {
+ // add the options afresh
+ while (add_slot_options()) { }
+ add_device_options();
+ int num;
+ do {
+ num = options_count();
+ update_slot_options();
+ } while(num != options_count());
}
}