summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend
diff options
context:
space:
mode:
author npwoods <npwoods@alumni.carnegiemellon.edu>2017-04-15 16:32:12 -0400
committer Olivier Galibert <galibert@pobox.com>2017-04-15 22:32:12 +0200
commit02ea4fd43cb42ffdbba6f87a93c03b697c426269 (patch)
treef04a48f239f0686fe711fbda5dc7e69a97d2b281 /src/frontend
parentc4b2aa746602b5896400bef928cf76c5d5c72e83 (diff)
Fixes issues specifying image/slot options fron INI files (reported by Robbbert) (#2231)
This fix really doesn't go far enough. I added hooks so that options specified at the command line can also be responded to when parsed from INI files, but in the long run much of the logic that is currently in mame_options should go into emu_options so that when an option is specified, all of the wacko logic around slot/image specification "just works" because it is encapsulated within emu_options. We have a release 11 days away; I want to be in stabilization mode.
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/mame/mameopts.cpp33
-rw-r--r--src/frontend/mame/mameopts.h1
2 files changed, 16 insertions, 18 deletions
diff --git a/src/frontend/mame/mameopts.cpp b/src/frontend/mame/mameopts.cpp
index 8a55f13194c..f610fbdf8ac 100644
--- a/src/frontend/mame/mameopts.cpp
+++ b/src/frontend/mame/mameopts.cpp
@@ -57,13 +57,20 @@ bool mame_options::add_slot_options(emu_options &options, value_specifier_func v
// add the option
options.add_entry(name, nullptr, OPTION_STRING | OPTION_FLAG_DEVICE, slot.default_option(), true);
+ options.slot_options()[name] = slot_option();
// allow opportunity to specify this value
if (value_specifier)
{
std::string value = value_specifier(name);
if (value != value_specifier_invalid_value())
- options.slot_options()[name] = parse_slot_option(std::move(value));
+ {
+ const device_slot_option *option = slot.option(value.c_str());
+ if (option)
+ {
+ options.slot_options()[name] = emu_options::parse_slot_option(std::move(value), option->selectable());
+ }
+ }
}
}
}
@@ -179,6 +186,7 @@ void mame_options::add_device_options(emu_options &options, value_specifier_func
// add the option
std::string option_name = get_full_option_name(image);
options.add_entry(option_name.c_str(), nullptr, OPTION_STRING | OPTION_FLAG_DEVICE, nullptr, true);
+ options.image_options()[image.instance_name()] = "";
// allow opportunity to specify this value
if (value_specifier)
@@ -299,6 +307,13 @@ bool mame_options::reevaluate_slot_options(emu_options &options)
if (options.slot_options()[name].default_card_software() != default_card_software)
{
options.slot_options()[name].set_default_card_software(std::move(default_card_software));
+
+ // the value of this slot option has changed. we may need to change is_selectable(); this
+ // should really be encapsulated within emu_options
+ const device_slot_option *option = slot.option(options.slot_options()[name].value().c_str());
+ if (option)
+ options.slot_options()[name].set_is_selectable(option->selectable());
+
result = true;
}
}
@@ -688,19 +703,3 @@ bool mame_options::parse_one_ini(emu_options &options, const char *basename, int
return result;
}
-
-//-------------------------------------------------
-// parse_slot_option - parses a slot option (the
-// ',bios=XYZ' syntax)
-//-------------------------------------------------
-
-slot_option mame_options::parse_slot_option(std::string &&text)
-{
- slot_option result;
- const char *bios_arg = ",bios=";
-
- size_t pos = text.find(bios_arg);
- return pos != std::string::npos
- ? slot_option(text.substr(0, pos), text.substr(pos + strlen(bios_arg)))
- : slot_option(std::move(text));
-}
diff --git a/src/frontend/mame/mameopts.h b/src/frontend/mame/mameopts.h
index 8d045817e63..3c543e65c66 100644
--- a/src/frontend/mame/mameopts.h
+++ b/src/frontend/mame/mameopts.h
@@ -72,7 +72,6 @@ private:
static void update_slot_options(emu_options &options, const software_part *swpart = nullptr);
static void parse_slot_devices(emu_options &options, value_specifier_func value_specifier);
static std::string get_full_option_name(const device_image_interface &image);
- static slot_option parse_slot_option(std::string &&text);
static std::string get_default_card_software(device_slot_interface &slot, const emu_options &options);
// INI parsing helper