From ee12b7d2f74834cb9ca9dd8d6de7ba9d8c1f30e1 Mon Sep 17 00:00:00 2001 From: AJR Date: Mon, 4 Apr 2016 23:46:44 -0400 Subject: Revert software-installed slot/image options when changing software - Remove emu.h's stealth include of emuopts.h through mconfig.h; reduce dependency on emuopts.h in other headers and source files. - MCFG_CPU_FORCE_NO_DRC is now a CPU configuration parameter rather than a global one; it still works to override the -drc option setting. --- src/emu/emuopts.cpp | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'src/emu/emuopts.cpp') diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp index dfca2bde492..d480f94a284 100644 --- a/src/emu/emuopts.cpp +++ b/src/emu/emuopts.cpp @@ -255,24 +255,16 @@ bool emu_options::add_slot_options(const software_part *swpart) if (slot->fixed()) continue; - // first device? add the header as to be pretty - if (m_slot_options++ == 0) - add_entry(nullptr, "SLOT DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE); - // retrieve info about the device instance const char *name = slot->device().tag() + 1; if (!exists(name)) { + // first device? add the header as to be pretty + if (m_slot_options++ == 0) + add_entry(nullptr, "SLOT DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE); + // add the option - UINT32 flags = OPTION_STRING | OPTION_FLAG_DEVICE; - const char *defvalue = slot->default_option(); - if (defvalue != nullptr) - { - const device_slot_option *option = slot->option(defvalue); - if (option != nullptr && !option->selectable()) - flags |= OPTION_FLAG_INTERNAL; - } - add_entry(name, nullptr, flags, defvalue, true); + add_entry(name, nullptr, OPTION_STRING | OPTION_FLAG_DEVICE, slot->default_option(), true); } // allow software lists to supply their own defaults @@ -314,12 +306,21 @@ void emu_options::update_slot_options(const software_part *swpart) if (exists(name) && !slot->option_list().empty()) { std::string defvalue = slot->get_default_card_software(); - if (defvalue.length() > 0) + if (defvalue.empty()) { - set_default_value(name, defvalue.c_str()); - const device_slot_option *option = slot->option(defvalue.c_str()); - set_flag(name, ~OPTION_FLAG_INTERNAL, (option != nullptr && !option->selectable()) ? OPTION_FLAG_INTERNAL : 0); + // keep any non-default setting + if (priority(name) > OPTION_PRIORITY_DEFAULT) + continue; + + // reinstate the actual default value as configured + if (slot->default_option() != nullptr) + defvalue.assign(slot->default_option()); } + + // set the value and hide the option if not selectable + set_default_value(name, defvalue.c_str()); + const device_slot_option *option = slot->option(defvalue.c_str()); + set_flag(name, ~OPTION_FLAG_INTERNAL, (option != nullptr && !option->selectable()) ? OPTION_FLAG_INTERNAL : 0); } } while (add_slot_options(swpart)) { } @@ -344,10 +345,6 @@ void emu_options::add_device_options() image_interface_iterator iter(config.root_device()); for (const device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { - // first device? add the header as to be pretty - if (m_device_options++ == 0) - add_entry(nullptr, "IMAGE DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE); - // retrieve info about the device instance std::ostringstream option_name; util::stream_format(option_name, "%s;%s", image->instance_name(), image->brief_instance_name()); @@ -356,7 +353,14 @@ void emu_options::add_device_options() // add the option if (!exists(image->instance_name())) + { + // first device? add the header as to be pretty + if (m_device_options++ == 0) + add_entry(nullptr, "IMAGE DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE); + + // add the option add_entry(option_name.str().c_str(), nullptr, OPTION_STRING | OPTION_FLAG_DEVICE, nullptr, true); + } } } @@ -401,12 +405,10 @@ bool emu_options::parse_slot_devices(int argc, char *argv[], std::string &error_ core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string); // keep adding slot options until we stop seeing new stuff - m_slot_options = 0; while (add_slot_options(swpart)) core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string); // add device options and reparse - m_device_options = 0; add_device_options(); if (name != nullptr && exists(name)) set_value(name, value, OPTION_PRIORITY_SUBCMD, error_string); @@ -560,6 +562,11 @@ void emu_options::set_system_name(const char *name) // remove any existing device options remove_device_options(); } + else + { + // revert device options set for the old software + revert(OPTION_PRIORITY_SUBCMD, OPTION_PRIORITY_SUBCMD); + } // get the new system const game_driver *cursystem = system(); -- cgit v1.2.3-70-g09d2