mirror of
https://github.com/holub/mame
synced 2025-04-23 17:00:53 +03:00
Merge pull request #842 from ajrhacker/sysmame
Move system name lookup into frontend (nw)
This commit is contained in:
commit
7220b6e316
@ -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);
|
||||
|
@ -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); }
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user