diff options
author | npwoods <npwoods@alumni.carnegiemellon.edu> | 2017-05-05 02:17:49 -0400 |
---|---|---|
committer | Vas Crabb <cuavas@users.noreply.github.com> | 2017-05-05 16:17:49 +1000 |
commit | 536990e77b49ccc50ef275bfbf1018cc29c16154 (patch) | |
tree | 86e160cca07995479cd87506732c178b3728e58a /src/osd | |
parent | cce3369cdeec54494c6d4dc4a781cbba64d027bd (diff) |
Overhaul to how MAME handles options (#2260)
This is an overhaul to how MAME handles options to provide a better foundation for what MAME is already doing in practice. Previously, core_options was designed to provide an input/output facility for reading options from the command line and INI files. However, the current needs (image/slot/get_default_card_software calculus and MewUI) go way beyond that.
Broadly, this PR makes the following changes:
* core_options now has an extensibility mechanism, so one can register options that behave dramatically differently
* With that foundation, emu_options now encapsulates all of the funky image/slot/get_default_card_software calculus that were previously handled by static methods in mameopts.cpp. Changes to emu_options should not automatically cascade in such a way so that it stays in a consistent state
* emu_options no longer provides direct access to the slot_options/image_options maps; there are simpler API functions that control these capabilities
* Many core_options functions that expose internal data structures (e.g. - priority) that were only really needed because of previous (now obsolete) techniques have been removed.
* core_options is now exception based (rather than dumping text to an std::string). The burden is on the caller to catch these, and discern between warnings and errors as needed.
Obviously this is a risky change; that's why this is being submitted at the start of the dev cycle.
Diffstat (limited to 'src/osd')
-rw-r--r-- | src/osd/modules/lib/osdobj_common.h | 2 | ||||
-rw-r--r-- | src/osd/modules/render/drawbgfx.cpp | 1 | ||||
-rw-r--r-- | src/osd/sdl/sdlmain.cpp | 10 | ||||
-rw-r--r-- | src/osd/windows/winmain.cpp | 15 |
4 files changed, 11 insertions, 17 deletions
diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h index df8096840cf..2c2f750fdbe 100644 --- a/src/osd/modules/lib/osdobj_common.h +++ b/src/osd/modules/lib/osdobj_common.h @@ -270,7 +270,7 @@ private: // FIXME: should be elsewhere osd_module *select_module_options(const core_options &opts, const std::string &opt_name) { - std::string opt_val = opts.value(opt_name.c_str()); + std::string opt_val = opts.exists(opt_name) ? opts.value(opt_name.c_str()) : ""; if (opt_val.compare("auto")==0) opt_val = ""; else if (!m_mod_man.type_has_name(opt_name.c_str(), opt_val.c_str())) diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp index 2fb0d0b3a1e..31ddc58c145 100644 --- a/src/osd/modules/render/drawbgfx.cpp +++ b/src/osd/modules/render/drawbgfx.cpp @@ -85,7 +85,6 @@ renderer_bgfx::renderer_bgfx(std::shared_ptr<osd_window> w) , m_avi_writer(nullptr) , m_avi_target(nullptr) { - m_options = downcast<osd_options &>(assert_window()->machine().options()); } //============================================================ diff --git a/src/osd/sdl/sdlmain.cpp b/src/osd/sdl/sdlmain.cpp index 31f65e2ba66..10e57ec5766 100644 --- a/src/osd/sdl/sdlmain.cpp +++ b/src/osd/sdl/sdlmain.cpp @@ -408,14 +408,12 @@ void sdl_osd_interface::init(running_machine &machine) // determine if we are benchmarking, and adjust options appropriately int bench = options().bench(); - std::string error_string; if (bench > 0) { - options().set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM, error_string); - options().set_value(OSDOPTION_SOUND, "none", OPTION_PRIORITY_MAXIMUM, error_string); - options().set_value(OSDOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM, error_string); - options().set_value(OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM, error_string); - assert(error_string.c_str()[0] == 0); + options().set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM); + options().set_value(OSDOPTION_SOUND, "none", OPTION_PRIORITY_MAXIMUM); + options().set_value(OSDOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM); + options().set_value(OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM); } // Some driver options - must be before audio init! diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp index efec6700849..805a769d1b8 100644 --- a/src/osd/windows/winmain.cpp +++ b/src/osd/windows/winmain.cpp @@ -515,23 +515,20 @@ void windows_osd_interface::init(running_machine &machine) // determine if we are benchmarking, and adjust options appropriately int bench = options.bench(); - std::string error_string; if (bench > 0) { - options.set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM, error_string); - options.set_value(OSDOPTION_SOUND, "none", OPTION_PRIORITY_MAXIMUM, error_string); - options.set_value(OSDOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM, error_string); - options.set_value(OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM, error_string); - assert(error_string.empty()); + options.set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM); + options.set_value(OSDOPTION_SOUND, "none", OPTION_PRIORITY_MAXIMUM); + options.set_value(OSDOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM); + options.set_value(OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM); } // determine if we are profiling, and adjust options appropriately int profile = options.profile(); if (profile > 0) { - options.set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM, error_string); - options.set_value(OSDOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM, error_string); - assert(error_string.empty()); + options.set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM); + options.set_value(OSDOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM); } // thread priority |