From d5aa280c102c59b62497b029dc9f8aa835d15906 Mon Sep 17 00:00:00 2001 From: AJR Date: Thu, 28 Apr 2016 17:29:27 -0400 Subject: [PATCH] Move system name lookup into frontend (nw) --- src/emu/emuopts.cpp | 14 -------------- src/emu/emuopts.h | 1 - src/emu/hashfile.cpp | 2 +- src/frontend/mame/clifront.cpp | 8 ++++---- src/frontend/mame/mame.cpp | 2 +- src/frontend/mame/mameopts.cpp | 23 ++++++++++++++++++----- src/frontend/mame/mameopts.h | 1 + src/frontend/mame/ui/menu.cpp | 2 +- 8 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp index e7a7d74db2b..85bf2c0415e 100644 --- a/src/emu/emuopts.cpp +++ b/src/emu/emuopts.cpp @@ -10,7 +10,6 @@ #include "emu.h" #include "emuopts.h" -#include "drivenum.h" //************************************************************************** // CORE EMULATOR OPTIONS @@ -225,19 +224,6 @@ emu_options::emu_options() } - -//------------------------------------------------- -// system - return a pointer to the specified -// system driver, or nullptr if no match -//------------------------------------------------- - -const game_driver *emu_options::system() const -{ - int index = driver_list::find(core_filename_extract_base(system_name(), true).c_str()); - return (index != -1) ? &driver_list::driver(index) : nullptr; -} - - std::string emu_options::main_value(const char *name) const { std::string buffer = value(name); diff --git a/src/emu/emuopts.h b/src/emu/emuopts.h index a47b1381dbb..d4d4731997c 100644 --- a/src/emu/emuopts.h +++ b/src/emu/emuopts.h @@ -200,7 +200,6 @@ public: // core options const char *system_name() const { return value(OPTION_SYSTEMNAME); } const char *software_name() const { return value(OPTION_SOFTWARENAME); } - const game_driver *system() const; // core configuration options bool read_config() const { return bool_value(OPTION_READCONFIG); } diff --git a/src/emu/hashfile.cpp b/src/emu/hashfile.cpp index ca668e1dfae..d37d6cbe21b 100644 --- a/src/emu/hashfile.cpp +++ b/src/emu/hashfile.cpp @@ -568,7 +568,7 @@ bool hashfile_extrainfo(device_image_interface &image, std::string &result) /* now read the hash file */ image.crc(); extra_info = nullptr; - int drv = driver_list::find(*image.device().mconfig().options().system()); + int drv = driver_list::find(image.device().mconfig().gamedrv()); int compat, open = drv; bool hashfound; do diff --git a/src/frontend/mame/clifront.cpp b/src/frontend/mame/clifront.cpp index e169479f383..bbe64537aa2 100644 --- a/src/frontend/mame/clifront.cpp +++ b/src/frontend/mame/clifront.cpp @@ -191,7 +191,7 @@ int cli_frontend::execute(int argc, char **argv) if (*(m_options.software_name()) != 0) { - const game_driver *system = m_options.system(); + const game_driver *system = mame_options::system(m_options); if (system == nullptr && *(m_options.system_name()) != 0) throw emu_fatalerror(EMU_ERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name()); @@ -256,7 +256,7 @@ int cli_frontend::execute(int argc, char **argv) if (!mame_options::parse_command_line(m_options,argc, argv, option_errors)) { // if we failed, check for no command and a system name first; in that case error on the name - if (*(m_options.command()) == 0 && m_options.system() == nullptr && *(m_options.system_name()) != 0) + if (*(m_options.command()) == 0 && mame_options::system(m_options) == nullptr && *(m_options.system_name()) != 0) throw emu_fatalerror(EMU_ERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name()); // otherwise, error on the options @@ -286,7 +286,7 @@ int cli_frontend::execute(int argc, char **argv) osd_printf_error("Error in command line:\n%s\n", strtrimspace(option_errors).c_str()); // if we can't find it, give an appropriate error - const game_driver *system = m_options.system(); + const game_driver *system = mame_options::system(m_options); if (system == nullptr && *(m_options.system_name()) != 0) throw emu_fatalerror(EMU_ERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name()); @@ -305,7 +305,7 @@ int cli_frontend::execute(int argc, char **argv) // if a game was specified, wasn't a wildcard, and our error indicates this was the // reason for failure, offer some suggestions - if (m_result == EMU_ERR_NO_SUCH_GAME && *(m_options.system_name()) != 0 && strchr(m_options.system_name(), '*') == nullptr && m_options.system() == nullptr) + if (m_result == EMU_ERR_NO_SUCH_GAME && *(m_options.system_name()) != 0 && strchr(m_options.system_name(), '*') == nullptr && mame_options::system(m_options) == nullptr) { // get the top 16 approximate matches driver_enumerator drivlist(m_options); diff --git a/src/frontend/mame/mame.cpp b/src/frontend/mame/mame.cpp index afc6820b273..99d8d6699b0 100644 --- a/src/frontend/mame/mame.cpp +++ b/src/frontend/mame/mame.cpp @@ -187,7 +187,7 @@ int mame_machine_manager::execute() m_new_driver_pending = nullptr; // if no driver, use the internal empty driver - const game_driver *system = m_options.system(); + const game_driver *system = mame_options::system(m_options); if (system == nullptr) { system = &GAME_NAME(___empty); diff --git a/src/frontend/mame/mameopts.cpp b/src/frontend/mame/mameopts.cpp index 9d894709d58..273ba6dbbc7 100644 --- a/src/frontend/mame/mameopts.cpp +++ b/src/frontend/mame/mameopts.cpp @@ -26,7 +26,7 @@ int mame_options::m_device_options = 0; bool mame_options::add_slot_options(emu_options &options, const software_part *swpart) { // look up the system configured by name; if no match, do nothing - const game_driver *cursystem = options.system(); + const game_driver *cursystem = system(options); if (cursystem == nullptr) return false; @@ -78,7 +78,7 @@ bool mame_options::add_slot_options(emu_options &options, const software_part *s void mame_options::update_slot_options(emu_options &options, const software_part *swpart) { // look up the system configured by name; if no match, do nothing - const game_driver *cursystem = options.system(); + const game_driver *cursystem = system(options); if (cursystem == nullptr) return; machine_config config(*cursystem, options); @@ -121,7 +121,7 @@ void mame_options::update_slot_options(emu_options &options, const software_part void mame_options::add_device_options(emu_options &options) { // look up the system configured by name; if no match, do nothing - const game_driver *cursystem = options.system(); + const game_driver *cursystem = system(options); if (cursystem == nullptr) return; machine_config config(*cursystem, options); @@ -249,7 +249,7 @@ void mame_options::parse_standard_inis(emu_options &options, std::string &error_ parse_one_ini(options,"debug", OPTION_PRIORITY_DEBUG_INI, &error_string); // if we have a valid system driver, parse system-specific INI files - const game_driver *cursystem = (driver == nullptr) ? options.system() : driver; + const game_driver *cursystem = (driver == nullptr) ? system(options) : driver; if (cursystem == nullptr) return; @@ -314,6 +314,19 @@ void mame_options::parse_standard_inis(emu_options &options, std::string &error_ options.update_cached_options(); } + +//------------------------------------------------- +// system - return a pointer to the specified +// system driver, or nullptr if no match +//------------------------------------------------- + +const game_driver *mame_options::system(const emu_options &options) +{ + int index = driver_list::find(core_filename_extract_base(options.system_name(), true).c_str()); + return (index != -1) ? &driver_list::driver(index) : nullptr; +} + + //------------------------------------------------- // set_system_name - set a new system name //------------------------------------------------- @@ -342,7 +355,7 @@ void mame_options::set_system_name(emu_options &options, const char *name) } // get the new system - const game_driver *cursystem = options.system(); + const game_driver *cursystem = system(options); if (cursystem == nullptr) return; diff --git a/src/frontend/mame/mameopts.h b/src/frontend/mame/mameopts.h index 50b1ae5b776..962048826b2 100644 --- a/src/frontend/mame/mameopts.h +++ b/src/frontend/mame/mameopts.h @@ -60,6 +60,7 @@ public: // FIXME: Couriersud: This should be in image_device_exit static void remove_device_options(emu_options &options); + static const game_driver *system(const emu_options &options); static void set_system_name(emu_options &options, const char *name); static bool add_slot_options(emu_options &options, const software_part *swpart = nullptr); private: diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp index af7213d172f..c2d329db905 100644 --- a/src/frontend/mame/ui/menu.cpp +++ b/src/frontend/mame/ui/menu.cpp @@ -2627,7 +2627,7 @@ void ui_menu::draw_palette_menu() float gutter_width = lr_arrow_width * 1.3f; int itemnum, linenum; - if (ui().options().use_background_image() && machine().options().system() == nullptr && bgrnd_bitmap->valid()) + if (ui().options().use_background_image() && &machine().system() == &GAME_NAME(___empty) && bgrnd_bitmap->valid()) container->add_quad(0.0f, 0.0f, 1.0f, 1.0f, rgb_t::white, bgrnd_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // compute the width and height of the full menu