mirror of
https://github.com/holub/mame
synced 2025-10-06 09:00:04 +03:00
Created mame_options as 1st step towards creating core independent of MAME implementation (nw)
This commit is contained in:
parent
e5690695e1
commit
682bc90764
@ -159,7 +159,7 @@ cli_frontend::cli_frontend(emu_options &options, osd_interface &osd)
|
|||||||
cli_frontend::~cli_frontend()
|
cli_frontend::~cli_frontend()
|
||||||
{
|
{
|
||||||
// nuke any device options since they will leak memory
|
// nuke any device options since they will leak memory
|
||||||
m_options.remove_device_options();
|
mame_options::remove_device_options(m_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
@ -177,9 +177,9 @@ int cli_frontend::execute(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
// first parse options to be able to get software from it
|
// first parse options to be able to get software from it
|
||||||
std::string option_errors;
|
std::string option_errors;
|
||||||
m_options.parse_command_line(argc, argv, option_errors);
|
mame_options::parse_command_line(m_options,argc, argv, option_errors);
|
||||||
|
|
||||||
m_options.parse_standard_inis(option_errors);
|
mame_options::parse_standard_inis(m_options,option_errors);
|
||||||
|
|
||||||
load_translation(m_options);
|
load_translation(m_options);
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ int cli_frontend::execute(int argc, char **argv)
|
|||||||
std::string val = string_format("%s:%s:%s", swlistdev.list_name(), m_options.software_name(), swpart.name());
|
std::string val = string_format("%s:%s:%s", swlistdev.list_name(), m_options.software_name(), swpart.name());
|
||||||
|
|
||||||
// call this in order to set slot devices according to mounting
|
// call this in order to set slot devices according to mounting
|
||||||
m_options.parse_slot_devices(argc, argv, option_errors, image.instance_name(), val.c_str(), &swpart);
|
mame_options::parse_slot_devices(m_options, argc, argv, option_errors, image.instance_name(), val.c_str(), &swpart);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,7 +249,7 @@ int cli_frontend::execute(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parse the command line, adding any system-specific options
|
// parse the command line, adding any system-specific options
|
||||||
if (!m_options.parse_command_line(argc, argv, option_errors))
|
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 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 && m_options.system() == nullptr && *(m_options.system_name()) != 0)
|
||||||
@ -276,7 +276,7 @@ int cli_frontend::execute(int argc, char **argv)
|
|||||||
if (m_options.read_config())
|
if (m_options.read_config())
|
||||||
{
|
{
|
||||||
m_options.revert(OPTION_PRIORITY_INI);
|
m_options.revert(OPTION_PRIORITY_INI);
|
||||||
m_options.parse_standard_inis(option_errors);
|
mame_options::parse_standard_inis(m_options,option_errors);
|
||||||
}
|
}
|
||||||
if (!option_errors.empty())
|
if (!option_errors.empty())
|
||||||
osd_printf_error("Error in command line:\n%s\n", strtrimspace(option_errors).c_str());
|
osd_printf_error("Error in command line:\n%s\n", strtrimspace(option_errors).c_str());
|
||||||
@ -1670,7 +1670,7 @@ void cli_frontend::execute_commands(const char *exename)
|
|||||||
|
|
||||||
// other commands need the INIs parsed
|
// other commands need the INIs parsed
|
||||||
std::string option_errors;
|
std::string option_errors;
|
||||||
m_options.parse_standard_inis(option_errors);
|
mame_options::parse_standard_inis(m_options,option_errors);
|
||||||
if (!option_errors.empty())
|
if (!option_errors.empty())
|
||||||
osd_printf_error("%s\n", option_errors.c_str());
|
osd_printf_error("%s\n", option_errors.c_str());
|
||||||
|
|
||||||
|
@ -225,309 +225,11 @@ emu_options::emu_options()
|
|||||||
, m_joystick_contradictory(false)
|
, m_joystick_contradictory(false)
|
||||||
, m_sleep(true)
|
, m_sleep(true)
|
||||||
, m_refresh_speed(false)
|
, m_refresh_speed(false)
|
||||||
, m_slot_options(0)
|
|
||||||
, m_device_options(0)
|
|
||||||
{
|
{
|
||||||
add_entries(emu_options::s_option_entries);
|
add_entries(emu_options::s_option_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// add_slot_options - add all of the slot
|
|
||||||
// options for the configured system
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
bool emu_options::add_slot_options(const software_part *swpart)
|
|
||||||
{
|
|
||||||
// look up the system configured by name; if no match, do nothing
|
|
||||||
const game_driver *cursystem = system();
|
|
||||||
if (cursystem == nullptr)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// create the configuration
|
|
||||||
machine_config config(*cursystem, *this);
|
|
||||||
|
|
||||||
// iterate through all slot devices
|
|
||||||
int starting_count = options_count();
|
|
||||||
for (const device_slot_interface &slot : slot_interface_iterator(config.root_device()))
|
|
||||||
{
|
|
||||||
// skip fixed slots
|
|
||||||
if (slot.fixed())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// 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
|
|
||||||
add_entry(name, nullptr, OPTION_STRING | OPTION_FLAG_DEVICE, slot.default_option(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// allow software lists to supply their own defaults
|
|
||||||
if (swpart != nullptr)
|
|
||||||
{
|
|
||||||
std::string featurename = std::string(name).append("_default");
|
|
||||||
const char *value = swpart->feature(featurename.c_str());
|
|
||||||
if (value != nullptr && (*value == '\0' || slot.option(value) != nullptr))
|
|
||||||
{
|
|
||||||
// set priority above INIs but below actual command line
|
|
||||||
std::string error;
|
|
||||||
set_value(name, value, OPTION_PRIORITY_SUBCMD, error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (options_count() != starting_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// update_slot_options - update slot values
|
|
||||||
// depending of image mounted
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
void emu_options::update_slot_options(const software_part *swpart)
|
|
||||||
{
|
|
||||||
// look up the system configured by name; if no match, do nothing
|
|
||||||
const game_driver *cursystem = system();
|
|
||||||
if (cursystem == nullptr)
|
|
||||||
return;
|
|
||||||
machine_config config(*cursystem, *this);
|
|
||||||
|
|
||||||
// iterate through all slot devices
|
|
||||||
for (device_slot_interface &slot : slot_interface_iterator(config.root_device()))
|
|
||||||
{
|
|
||||||
// retrieve info about the device instance
|
|
||||||
const char *name = slot.device().tag() + 1;
|
|
||||||
if (exists(name) && !slot.option_list().empty())
|
|
||||||
{
|
|
||||||
std::string defvalue = slot.get_default_card_software();
|
|
||||||
if (defvalue.empty())
|
|
||||||
{
|
|
||||||
// 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)) { }
|
|
||||||
add_device_options();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// add_device_options - add all of the device
|
|
||||||
// options for the configured system
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
void emu_options::add_device_options()
|
|
||||||
{
|
|
||||||
// look up the system configured by name; if no match, do nothing
|
|
||||||
const game_driver *cursystem = system();
|
|
||||||
if (cursystem == nullptr)
|
|
||||||
return;
|
|
||||||
machine_config config(*cursystem, *this);
|
|
||||||
|
|
||||||
// iterate through all image devices
|
|
||||||
for (const device_image_interface &image : image_interface_iterator(config.root_device()))
|
|
||||||
{
|
|
||||||
if (!image.user_loadable())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// retrieve info about the device instance
|
|
||||||
std::ostringstream option_name;
|
|
||||||
util::stream_format(option_name, "%s;%s", image.instance_name(), image.brief_instance_name());
|
|
||||||
if (strcmp(image.device_typename(image.image_type()), image.instance_name()) == 0)
|
|
||||||
util::stream_format(option_name, ";%s1;%s1", image.instance_name(), image.brief_instance_name());
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// remove_device_options - remove device options
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
void emu_options::remove_device_options()
|
|
||||||
{
|
|
||||||
// iterate through options and remove interesting ones
|
|
||||||
entry *nextentry;
|
|
||||||
for (entry *curentry = first(); curentry != nullptr; curentry = nextentry)
|
|
||||||
{
|
|
||||||
// pre-fetch the next entry in case we delete this one
|
|
||||||
nextentry = curentry->next();
|
|
||||||
|
|
||||||
// if this is a device option, nuke it
|
|
||||||
if ((curentry->flags() & OPTION_FLAG_DEVICE) != 0)
|
|
||||||
remove_entry(*curentry);
|
|
||||||
}
|
|
||||||
|
|
||||||
// take also care of ramsize options
|
|
||||||
set_default_value(OPTION_RAMSIZE, "");
|
|
||||||
|
|
||||||
// reset counters
|
|
||||||
m_slot_options = 0;
|
|
||||||
m_device_options = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// parse_slot_devices - parse the command line
|
|
||||||
// and update slot and image devices
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
bool emu_options::parse_slot_devices(int argc, char *argv[], std::string &error_string, const char *name, const char *value, const software_part *swpart)
|
|
||||||
{
|
|
||||||
// an initial parse to capture the initial set of values
|
|
||||||
bool result;
|
|
||||||
|
|
||||||
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
|
||||||
|
|
||||||
// keep adding slot options until we stop seeing new stuff
|
|
||||||
while (add_slot_options(swpart))
|
|
||||||
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
|
||||||
|
|
||||||
// add device options and reparse
|
|
||||||
add_device_options();
|
|
||||||
if (name != nullptr && exists(name))
|
|
||||||
set_value(name, value, OPTION_PRIORITY_SUBCMD, error_string);
|
|
||||||
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
|
||||||
|
|
||||||
int num;
|
|
||||||
do {
|
|
||||||
num = options_count();
|
|
||||||
update_slot_options(swpart);
|
|
||||||
result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
|
||||||
} while (num != options_count());
|
|
||||||
|
|
||||||
update_cached_options();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// parse_command_line - parse the command line
|
|
||||||
// and update the devices
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
bool emu_options::parse_command_line(int argc, char *argv[], std::string &error_string)
|
|
||||||
{
|
|
||||||
// parse as normal
|
|
||||||
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
|
||||||
bool result = parse_slot_devices(argc, argv, error_string);
|
|
||||||
update_cached_options();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// parse_standard_inis - parse the standard set
|
|
||||||
// of INI files
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
void emu_options::parse_standard_inis(std::string &error_string, const game_driver *driver)
|
|
||||||
{
|
|
||||||
// start with an empty string
|
|
||||||
error_string.clear();
|
|
||||||
|
|
||||||
// parse the INI file defined by the platform (e.g., "mame.ini")
|
|
||||||
// we do this twice so that the first file can change the INI path
|
|
||||||
parse_one_ini(emulator_info::get_configname(), OPTION_PRIORITY_MAME_INI);
|
|
||||||
parse_one_ini(emulator_info::get_configname(), OPTION_PRIORITY_MAME_INI, &error_string);
|
|
||||||
|
|
||||||
// debug mode: parse "debug.ini" as well
|
|
||||||
if (debug())
|
|
||||||
parse_one_ini("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) ? system() : driver;
|
|
||||||
if (cursystem == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// parse "vertical.ini" or "horizont.ini"
|
|
||||||
if (cursystem->flags & ORIENTATION_SWAP_XY)
|
|
||||||
parse_one_ini("vertical", OPTION_PRIORITY_ORIENTATION_INI, &error_string);
|
|
||||||
else
|
|
||||||
parse_one_ini("horizont", OPTION_PRIORITY_ORIENTATION_INI, &error_string);
|
|
||||||
|
|
||||||
if (cursystem->flags & MACHINE_TYPE_ARCADE)
|
|
||||||
parse_one_ini("arcade", OPTION_PRIORITY_SYSTYPE_INI, &error_string);
|
|
||||||
else if (cursystem->flags & MACHINE_TYPE_CONSOLE)
|
|
||||||
parse_one_ini("console", OPTION_PRIORITY_SYSTYPE_INI, &error_string);
|
|
||||||
else if (cursystem->flags & MACHINE_TYPE_COMPUTER)
|
|
||||||
parse_one_ini("computer", OPTION_PRIORITY_SYSTYPE_INI, &error_string);
|
|
||||||
else if (cursystem->flags & MACHINE_TYPE_OTHER)
|
|
||||||
parse_one_ini("othersys", OPTION_PRIORITY_SYSTYPE_INI, &error_string);
|
|
||||||
|
|
||||||
machine_config config(*cursystem, *this);
|
|
||||||
for (const screen_device &device : screen_device_iterator(config.root_device()))
|
|
||||||
{
|
|
||||||
// parse "raster.ini" for raster games
|
|
||||||
if (device.screen_type() == SCREEN_TYPE_RASTER)
|
|
||||||
{
|
|
||||||
parse_one_ini("raster", OPTION_PRIORITY_SCREEN_INI, &error_string);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// parse "vector.ini" for vector games
|
|
||||||
if (device.screen_type() == SCREEN_TYPE_VECTOR)
|
|
||||||
{
|
|
||||||
parse_one_ini("vector", OPTION_PRIORITY_SCREEN_INI, &error_string);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// parse "lcd.ini" for lcd games
|
|
||||||
if (device.screen_type() == SCREEN_TYPE_LCD)
|
|
||||||
{
|
|
||||||
parse_one_ini("lcd", OPTION_PRIORITY_SCREEN_INI, &error_string);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// next parse "source/<sourcefile>.ini"; if that doesn't exist, try <sourcefile>.ini
|
|
||||||
std::string sourcename = core_filename_extract_base(cursystem->source_file, true).insert(0, "source" PATH_SEPARATOR);
|
|
||||||
if (!parse_one_ini(sourcename.c_str(), OPTION_PRIORITY_SOURCE_INI, &error_string))
|
|
||||||
{
|
|
||||||
sourcename = core_filename_extract_base(cursystem->source_file, true);
|
|
||||||
parse_one_ini(sourcename.c_str(), OPTION_PRIORITY_SOURCE_INI, &error_string);
|
|
||||||
}
|
|
||||||
|
|
||||||
// then parse the grandparent, parent, and system-specific INIs
|
|
||||||
int parent = driver_list::clone(*cursystem);
|
|
||||||
int gparent = (parent != -1) ? driver_list::clone(parent) : -1;
|
|
||||||
if (gparent != -1)
|
|
||||||
parse_one_ini(driver_list::driver(gparent).name, OPTION_PRIORITY_GPARENT_INI, &error_string);
|
|
||||||
if (parent != -1)
|
|
||||||
parse_one_ini(driver_list::driver(parent).name, OPTION_PRIORITY_PARENT_INI, &error_string);
|
|
||||||
parse_one_ini(cursystem->name, OPTION_PRIORITY_DRIVER_INI, &error_string);
|
|
||||||
|
|
||||||
// Re-evaluate slot options after loading ini files
|
|
||||||
update_slot_options();
|
|
||||||
|
|
||||||
update_cached_options();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// system - return a pointer to the specified
|
// system - return a pointer to the specified
|
||||||
@ -541,117 +243,6 @@ const game_driver *emu_options::system() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// set_system_name - set a new system name
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
void emu_options::set_system_name(const char *name)
|
|
||||||
{
|
|
||||||
// remember the original system name
|
|
||||||
std::string old_system_name(system_name());
|
|
||||||
bool new_system = old_system_name.compare(name)!=0;
|
|
||||||
|
|
||||||
// if the system name changed, fix up the device options
|
|
||||||
if (new_system)
|
|
||||||
{
|
|
||||||
// first set the new name
|
|
||||||
std::string error;
|
|
||||||
set_value(OPTION_SYSTEMNAME, name, OPTION_PRIORITY_CMDLINE, error);
|
|
||||||
assert(error.empty());
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
if (cursystem == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (*software_name() != 0)
|
|
||||||
{
|
|
||||||
std::string sw_load(software_name());
|
|
||||||
std::string sw_list, sw_name, sw_part, sw_instance, error_string;
|
|
||||||
int left = sw_load.find_first_of(':');
|
|
||||||
int middle = sw_load.find_first_of(':', left + 1);
|
|
||||||
int right = sw_load.find_last_of(':');
|
|
||||||
|
|
||||||
sw_list = sw_load.substr(0, left - 1);
|
|
||||||
sw_name = sw_load.substr(left + 1, middle - left - 1);
|
|
||||||
sw_part = sw_load.substr(middle + 1, right - middle - 1);
|
|
||||||
sw_instance = sw_load.substr(right + 1);
|
|
||||||
sw_load.assign(sw_load.substr(0, right));
|
|
||||||
|
|
||||||
// look up the software part
|
|
||||||
machine_config config(*cursystem, *this);
|
|
||||||
software_list_device *swlist = software_list_device::find_by_name(config, sw_list.c_str());
|
|
||||||
software_info *swinfo = swlist != nullptr ? swlist->find(sw_name.c_str()) : nullptr;
|
|
||||||
software_part *swpart = swinfo != nullptr ? swinfo->find_part(sw_part.c_str()) : nullptr;
|
|
||||||
|
|
||||||
// then add the options
|
|
||||||
if (new_system)
|
|
||||||
{
|
|
||||||
while (add_slot_options(swpart)) { }
|
|
||||||
add_device_options();
|
|
||||||
}
|
|
||||||
|
|
||||||
set_value(OPTION_SOFTWARENAME, sw_name.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
|
|
||||||
if (exists(sw_instance.c_str()))
|
|
||||||
set_value(sw_instance.c_str(), sw_load.c_str(), OPTION_PRIORITY_SUBCMD, error_string);
|
|
||||||
|
|
||||||
int num;
|
|
||||||
do {
|
|
||||||
num = options_count();
|
|
||||||
update_slot_options(swpart);
|
|
||||||
} while(num != options_count());
|
|
||||||
}
|
|
||||||
else if (new_system)
|
|
||||||
{
|
|
||||||
// add the options afresh
|
|
||||||
while (add_slot_options()) { }
|
|
||||||
add_device_options();
|
|
||||||
int num;
|
|
||||||
do {
|
|
||||||
num = options_count();
|
|
||||||
update_slot_options();
|
|
||||||
} while(num != options_count());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// parse_one_ini - parse a single INI file
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
bool emu_options::parse_one_ini(const char *basename, int priority, std::string *error_string)
|
|
||||||
{
|
|
||||||
// don't parse if it has been disabled
|
|
||||||
if (!read_config())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// open the file; if we fail, that's ok
|
|
||||||
emu_file file(ini_path(), OPEN_FLAG_READ);
|
|
||||||
osd_file::error filerr = file.open(basename, ".ini");
|
|
||||||
if (filerr != osd_file::error::NONE)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// parse the file
|
|
||||||
osd_printf_verbose("Parsing %s.ini\n", basename);
|
|
||||||
std::string error;
|
|
||||||
bool result = parse_ini_file((util::core_file&)file, priority, OPTION_PRIORITY_DRIVER_INI, error);
|
|
||||||
|
|
||||||
// append errors if requested
|
|
||||||
if (!error.empty() && error_string)
|
|
||||||
error_string->append(string_format("While parsing %s:\n%s\n", file.fullpath(), error));
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string emu_options::main_value(const char *name) const
|
std::string emu_options::main_value(const char *name) const
|
||||||
{
|
{
|
||||||
std::string buffer = value(name);
|
std::string buffer = value(name);
|
||||||
@ -692,3 +283,416 @@ void emu_options::update_cached_options()
|
|||||||
m_sleep = bool_value(OPTION_SLEEP);
|
m_sleep = bool_value(OPTION_SLEEP);
|
||||||
m_refresh_speed = bool_value(OPTION_REFRESHSPEED);
|
m_refresh_speed = bool_value(OPTION_REFRESHSPEED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int mame_options::m_slot_options = 0;
|
||||||
|
int mame_options::m_device_options = 0;
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// add_slot_options - add all of the slot
|
||||||
|
// options for the configured system
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
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();
|
||||||
|
if (cursystem == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// create the configuration
|
||||||
|
machine_config config(*cursystem, options);
|
||||||
|
|
||||||
|
// iterate through all slot devices
|
||||||
|
int starting_count = options.options_count();
|
||||||
|
for (const device_slot_interface &slot : slot_interface_iterator(config.root_device()))
|
||||||
|
{
|
||||||
|
// skip fixed slots
|
||||||
|
if (slot.fixed())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// retrieve info about the device instance
|
||||||
|
const char *name = slot.device().tag() + 1;
|
||||||
|
if (!options.exists(name))
|
||||||
|
{
|
||||||
|
// first device? add the header as to be pretty
|
||||||
|
if (m_slot_options++ == 0)
|
||||||
|
options.add_entry(nullptr, "SLOT DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
|
||||||
|
|
||||||
|
// add the option
|
||||||
|
options.add_entry(name, nullptr, OPTION_STRING | OPTION_FLAG_DEVICE, slot.default_option(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// allow software lists to supply their own defaults
|
||||||
|
if (swpart != nullptr)
|
||||||
|
{
|
||||||
|
std::string featurename = std::string(name).append("_default");
|
||||||
|
const char *value = swpart->feature(featurename.c_str());
|
||||||
|
if (value != nullptr && (*value == '\0' || slot.option(value) != nullptr))
|
||||||
|
{
|
||||||
|
// set priority above INIs but below actual command line
|
||||||
|
std::string error;
|
||||||
|
options.set_value(name, value, OPTION_PRIORITY_SUBCMD, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (options.options_count() != starting_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// update_slot_options - update slot values
|
||||||
|
// depending of image mounted
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
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();
|
||||||
|
if (cursystem == nullptr)
|
||||||
|
return;
|
||||||
|
machine_config config(*cursystem, options);
|
||||||
|
|
||||||
|
// iterate through all slot devices
|
||||||
|
for (device_slot_interface &slot : slot_interface_iterator(config.root_device()))
|
||||||
|
{
|
||||||
|
// retrieve info about the device instance
|
||||||
|
const char *name = slot.device().tag() + 1;
|
||||||
|
if (options.exists(name) && !slot.option_list().empty())
|
||||||
|
{
|
||||||
|
std::string defvalue = slot.get_default_card_software();
|
||||||
|
if (defvalue.empty())
|
||||||
|
{
|
||||||
|
// keep any non-default setting
|
||||||
|
if (options.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
|
||||||
|
options.set_default_value(name, defvalue.c_str());
|
||||||
|
const device_slot_option *option = slot.option(defvalue.c_str());
|
||||||
|
options.set_flag(name, ~OPTION_FLAG_INTERNAL, (option != nullptr && !option->selectable()) ? OPTION_FLAG_INTERNAL : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (add_slot_options(options,swpart)) {}
|
||||||
|
add_device_options(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// add_device_options - add all of the device
|
||||||
|
// options for the configured system
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
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();
|
||||||
|
if (cursystem == nullptr)
|
||||||
|
return;
|
||||||
|
machine_config config(*cursystem, options);
|
||||||
|
|
||||||
|
// iterate through all image devices
|
||||||
|
for (const device_image_interface &image : image_interface_iterator(config.root_device()))
|
||||||
|
{
|
||||||
|
if (!image.user_loadable())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// retrieve info about the device instance
|
||||||
|
std::ostringstream option_name;
|
||||||
|
util::stream_format(option_name, "%s;%s", image.instance_name(), image.brief_instance_name());
|
||||||
|
if (strcmp(image.device_typename(image.image_type()), image.instance_name()) == 0)
|
||||||
|
util::stream_format(option_name, ";%s1;%s1", image.instance_name(), image.brief_instance_name());
|
||||||
|
|
||||||
|
// add the option
|
||||||
|
if (!options.exists(image.instance_name()))
|
||||||
|
{
|
||||||
|
// first device? add the header as to be pretty
|
||||||
|
if (m_device_options++ == 0)
|
||||||
|
options.add_entry(nullptr, "IMAGE DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
|
||||||
|
|
||||||
|
// add the option
|
||||||
|
options.add_entry(option_name.str().c_str(), nullptr, OPTION_STRING | OPTION_FLAG_DEVICE, nullptr, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// remove_device_options - remove device options
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
void mame_options::remove_device_options(emu_options &options)
|
||||||
|
{
|
||||||
|
// iterate through options and remove interesting ones
|
||||||
|
core_options::entry *nextentry;
|
||||||
|
for (auto *curentry = options.first(); curentry != nullptr; curentry = nextentry)
|
||||||
|
{
|
||||||
|
// pre-fetch the next entry in case we delete this one
|
||||||
|
nextentry = curentry->next();
|
||||||
|
|
||||||
|
// if this is a device option, nuke it
|
||||||
|
if ((curentry->flags() & OPTION_FLAG_DEVICE) != 0)
|
||||||
|
options.remove_entry(*curentry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// take also care of ramsize options
|
||||||
|
options.set_default_value(OPTION_RAMSIZE, "");
|
||||||
|
|
||||||
|
// reset counters
|
||||||
|
m_slot_options = 0;
|
||||||
|
m_device_options = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// parse_slot_devices - parse the command line
|
||||||
|
// and update slot and image devices
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
bool mame_options::parse_slot_devices(emu_options &options, int argc, char *argv[], std::string &error_string, const char *name, const char *value, const software_part *swpart)
|
||||||
|
{
|
||||||
|
// an initial parse to capture the initial set of values
|
||||||
|
bool result;
|
||||||
|
|
||||||
|
options.parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
||||||
|
|
||||||
|
// keep adding slot options until we stop seeing new stuff
|
||||||
|
while (add_slot_options(options,swpart))
|
||||||
|
options.parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
||||||
|
|
||||||
|
// add device options and reparse
|
||||||
|
add_device_options(options);
|
||||||
|
if (name != nullptr && options.exists(name))
|
||||||
|
options.set_value(name, value, OPTION_PRIORITY_SUBCMD, error_string);
|
||||||
|
options.parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
||||||
|
|
||||||
|
int num;
|
||||||
|
do {
|
||||||
|
num = options.options_count();
|
||||||
|
update_slot_options(options,swpart);
|
||||||
|
result = options.parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
||||||
|
} while (num != options.options_count());
|
||||||
|
|
||||||
|
options.update_cached_options();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// parse_command_line - parse the command line
|
||||||
|
// and update the devices
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
bool mame_options::parse_command_line(emu_options &options, int argc, char *argv[], std::string &error_string)
|
||||||
|
{
|
||||||
|
// parse as normal
|
||||||
|
options.parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
||||||
|
bool result = parse_slot_devices(options,argc, argv, error_string);
|
||||||
|
options.update_cached_options();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// parse_standard_inis - parse the standard set
|
||||||
|
// of INI files
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
void mame_options::parse_standard_inis(emu_options &options, std::string &error_string, const game_driver *driver)
|
||||||
|
{
|
||||||
|
// start with an empty string
|
||||||
|
error_string.clear();
|
||||||
|
|
||||||
|
// parse the INI file defined by the platform (e.g., "mame.ini")
|
||||||
|
// we do this twice so that the first file can change the INI path
|
||||||
|
parse_one_ini(options,emulator_info::get_configname(), OPTION_PRIORITY_MAME_INI);
|
||||||
|
parse_one_ini(options,emulator_info::get_configname(), OPTION_PRIORITY_MAME_INI, &error_string);
|
||||||
|
|
||||||
|
// debug mode: parse "debug.ini" as well
|
||||||
|
if (options.debug())
|
||||||
|
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;
|
||||||
|
if (cursystem == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// parse "vertical.ini" or "horizont.ini"
|
||||||
|
if (cursystem->flags & ORIENTATION_SWAP_XY)
|
||||||
|
parse_one_ini(options,"vertical", OPTION_PRIORITY_ORIENTATION_INI, &error_string);
|
||||||
|
else
|
||||||
|
parse_one_ini(options,"horizont", OPTION_PRIORITY_ORIENTATION_INI, &error_string);
|
||||||
|
|
||||||
|
if (cursystem->flags & MACHINE_TYPE_ARCADE)
|
||||||
|
parse_one_ini(options,"arcade", OPTION_PRIORITY_SYSTYPE_INI, &error_string);
|
||||||
|
else if (cursystem->flags & MACHINE_TYPE_CONSOLE)
|
||||||
|
parse_one_ini(options,"console", OPTION_PRIORITY_SYSTYPE_INI, &error_string);
|
||||||
|
else if (cursystem->flags & MACHINE_TYPE_COMPUTER)
|
||||||
|
parse_one_ini(options,"computer", OPTION_PRIORITY_SYSTYPE_INI, &error_string);
|
||||||
|
else if (cursystem->flags & MACHINE_TYPE_OTHER)
|
||||||
|
parse_one_ini(options,"othersys", OPTION_PRIORITY_SYSTYPE_INI, &error_string);
|
||||||
|
|
||||||
|
machine_config config(*cursystem, options);
|
||||||
|
for (const screen_device &device : screen_device_iterator(config.root_device()))
|
||||||
|
{
|
||||||
|
// parse "raster.ini" for raster games
|
||||||
|
if (device.screen_type() == SCREEN_TYPE_RASTER)
|
||||||
|
{
|
||||||
|
parse_one_ini(options,"raster", OPTION_PRIORITY_SCREEN_INI, &error_string);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// parse "vector.ini" for vector games
|
||||||
|
if (device.screen_type() == SCREEN_TYPE_VECTOR)
|
||||||
|
{
|
||||||
|
parse_one_ini(options,"vector", OPTION_PRIORITY_SCREEN_INI, &error_string);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// parse "lcd.ini" for lcd games
|
||||||
|
if (device.screen_type() == SCREEN_TYPE_LCD)
|
||||||
|
{
|
||||||
|
parse_one_ini(options,"lcd", OPTION_PRIORITY_SCREEN_INI, &error_string);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// next parse "source/<sourcefile>.ini"; if that doesn't exist, try <sourcefile>.ini
|
||||||
|
std::string sourcename = core_filename_extract_base(cursystem->source_file, true).insert(0, "source" PATH_SEPARATOR);
|
||||||
|
if (!parse_one_ini(options,sourcename.c_str(), OPTION_PRIORITY_SOURCE_INI, &error_string))
|
||||||
|
{
|
||||||
|
sourcename = core_filename_extract_base(cursystem->source_file, true);
|
||||||
|
parse_one_ini(options,sourcename.c_str(), OPTION_PRIORITY_SOURCE_INI, &error_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
// then parse the grandparent, parent, and system-specific INIs
|
||||||
|
int parent = driver_list::clone(*cursystem);
|
||||||
|
int gparent = (parent != -1) ? driver_list::clone(parent) : -1;
|
||||||
|
if (gparent != -1)
|
||||||
|
parse_one_ini(options,driver_list::driver(gparent).name, OPTION_PRIORITY_GPARENT_INI, &error_string);
|
||||||
|
if (parent != -1)
|
||||||
|
parse_one_ini(options,driver_list::driver(parent).name, OPTION_PRIORITY_PARENT_INI, &error_string);
|
||||||
|
parse_one_ini(options,cursystem->name, OPTION_PRIORITY_DRIVER_INI, &error_string);
|
||||||
|
|
||||||
|
// Re-evaluate slot options after loading ini files
|
||||||
|
update_slot_options(options);
|
||||||
|
|
||||||
|
options.update_cached_options();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// set_system_name - set a new system name
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
void mame_options::set_system_name(emu_options &options, const char *name)
|
||||||
|
{
|
||||||
|
// remember the original system name
|
||||||
|
std::string old_system_name(options.system_name());
|
||||||
|
bool new_system = old_system_name.compare(name) != 0;
|
||||||
|
|
||||||
|
// if the system name changed, fix up the device options
|
||||||
|
if (new_system)
|
||||||
|
{
|
||||||
|
// first set the new name
|
||||||
|
std::string error;
|
||||||
|
options.set_value(OPTION_SYSTEMNAME, name, OPTION_PRIORITY_CMDLINE, error);
|
||||||
|
assert(error.empty());
|
||||||
|
|
||||||
|
// remove any existing device options
|
||||||
|
remove_device_options(options);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// revert device options set for the old software
|
||||||
|
options.revert(OPTION_PRIORITY_SUBCMD, OPTION_PRIORITY_SUBCMD);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the new system
|
||||||
|
const game_driver *cursystem = options.system();
|
||||||
|
if (cursystem == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (*options.software_name() != 0)
|
||||||
|
{
|
||||||
|
std::string sw_load(options.software_name());
|
||||||
|
std::string sw_list, sw_name, sw_part, sw_instance, error_string;
|
||||||
|
int left = sw_load.find_first_of(':');
|
||||||
|
int middle = sw_load.find_first_of(':', left + 1);
|
||||||
|
int right = sw_load.find_last_of(':');
|
||||||
|
|
||||||
|
sw_list = sw_load.substr(0, left - 1);
|
||||||
|
sw_name = sw_load.substr(left + 1, middle - left - 1);
|
||||||
|
sw_part = sw_load.substr(middle + 1, right - middle - 1);
|
||||||
|
sw_instance = sw_load.substr(right + 1);
|
||||||
|
sw_load.assign(sw_load.substr(0, right));
|
||||||
|
|
||||||
|
// look up the software part
|
||||||
|
machine_config config(*cursystem, options);
|
||||||
|
software_list_device *swlist = software_list_device::find_by_name(config, sw_list.c_str());
|
||||||
|
software_info *swinfo = swlist != nullptr ? swlist->find(sw_name.c_str()) : nullptr;
|
||||||
|
software_part *swpart = swinfo != nullptr ? swinfo->find_part(sw_part.c_str()) : nullptr;
|
||||||
|
|
||||||
|
// then add the options
|
||||||
|
if (new_system)
|
||||||
|
{
|
||||||
|
while (add_slot_options(options,swpart)) {}
|
||||||
|
add_device_options(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
options.set_value(OPTION_SOFTWARENAME, sw_name.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
|
||||||
|
if (options.exists(sw_instance.c_str()))
|
||||||
|
options.set_value(sw_instance.c_str(), sw_load.c_str(), OPTION_PRIORITY_SUBCMD, error_string);
|
||||||
|
|
||||||
|
int num;
|
||||||
|
do {
|
||||||
|
num = options.options_count();
|
||||||
|
update_slot_options(options,swpart);
|
||||||
|
} while (num != options.options_count());
|
||||||
|
}
|
||||||
|
else if (new_system)
|
||||||
|
{
|
||||||
|
// add the options afresh
|
||||||
|
while (add_slot_options(options)) {}
|
||||||
|
add_device_options(options);
|
||||||
|
int num;
|
||||||
|
do {
|
||||||
|
num = options.options_count();
|
||||||
|
update_slot_options(options);
|
||||||
|
} while (num != options.options_count());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// parse_one_ini - parse a single INI file
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
bool mame_options::parse_one_ini(emu_options &options, const char *basename, int priority, std::string *error_string)
|
||||||
|
{
|
||||||
|
// don't parse if it has been disabled
|
||||||
|
if (!options.read_config())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// open the file; if we fail, that's ok
|
||||||
|
emu_file file(options.ini_path(), OPEN_FLAG_READ);
|
||||||
|
osd_file::error filerr = file.open(basename, ".ini");
|
||||||
|
if (filerr != osd_file::error::NONE)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// parse the file
|
||||||
|
osd_printf_verbose("Parsing %s.ini\n", basename);
|
||||||
|
std::string error;
|
||||||
|
bool result = options.parse_ini_file((util::core_file&)file, priority, OPTION_PRIORITY_DRIVER_INI, error);
|
||||||
|
|
||||||
|
// append errors if requested
|
||||||
|
if (!error.empty() && error_string)
|
||||||
|
error_string->append(string_format("While parsing %s:\n%s\n", file.fullpath(), error));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -218,25 +218,43 @@ enum
|
|||||||
struct game_driver;
|
struct game_driver;
|
||||||
class software_part;
|
class software_part;
|
||||||
|
|
||||||
|
class mame_options
|
||||||
class emu_options : public core_options
|
|
||||||
{
|
{
|
||||||
static const UINT32 OPTION_FLAG_DEVICE = 0x80000000;
|
static const UINT32 OPTION_FLAG_DEVICE = 0x80000000;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// parsing wrappers
|
||||||
|
static bool parse_command_line(emu_options &options, int argc, char *argv[], std::string &error_string);
|
||||||
|
static void parse_standard_inis(emu_options &options, std::string &error_string, const game_driver *driver = nullptr);
|
||||||
|
static bool parse_slot_devices(emu_options &options, int argc, char *argv[], std::string &error_string, const char *name = nullptr, const char *value = nullptr, const software_part *swpart = nullptr);
|
||||||
|
// FIXME: Couriersud: This should be in image_device_exit
|
||||||
|
static void remove_device_options(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:
|
||||||
|
// device-specific option handling
|
||||||
|
static void add_device_options(emu_options &options);
|
||||||
|
static void update_slot_options(emu_options &options, const software_part *swpart = nullptr);
|
||||||
|
|
||||||
|
// INI parsing helper
|
||||||
|
static bool parse_one_ini(emu_options &options, const char *basename, int priority, std::string *error_string = nullptr);
|
||||||
|
|
||||||
|
static int m_slot_options;
|
||||||
|
static int m_device_options;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class emu_options : public core_options
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
// construction/destruction
|
// construction/destruction
|
||||||
emu_options();
|
emu_options();
|
||||||
|
|
||||||
// parsing wrappers
|
|
||||||
bool parse_command_line(int argc, char *argv[], std::string &error_string);
|
|
||||||
void parse_standard_inis(std::string &error_string, const game_driver *driver = nullptr);
|
|
||||||
bool parse_slot_devices(int argc, char *argv[], std::string &error_string, const char *name = nullptr, const char *value = nullptr, const software_part *swpart = nullptr);
|
|
||||||
|
|
||||||
// core options
|
// core options
|
||||||
const char *system_name() const { return value(OPTION_SYSTEMNAME); }
|
const char *system_name() const { return value(OPTION_SYSTEMNAME); }
|
||||||
const char *software_name() const { return value(OPTION_SOFTWARENAME); }
|
const char *software_name() const { return value(OPTION_SOFTWARENAME); }
|
||||||
const game_driver *system() const;
|
const game_driver *system() const;
|
||||||
void set_system_name(const char *name);
|
|
||||||
|
|
||||||
// core configuration options
|
// core configuration options
|
||||||
bool read_config() const { return bool_value(OPTION_READCONFIG); }
|
bool read_config() const { return bool_value(OPTION_READCONFIG); }
|
||||||
@ -406,25 +424,12 @@ public:
|
|||||||
|
|
||||||
const char *language() const { return value(OPTION_LANGUAGE); }
|
const char *language() const { return value(OPTION_LANGUAGE); }
|
||||||
|
|
||||||
// FIXME: Couriersud: This should be in image_device_exit
|
|
||||||
void remove_device_options();
|
|
||||||
|
|
||||||
std::string main_value(const char *option) const;
|
|
||||||
std::string sub_value(const char *name, const char *subname) const;
|
|
||||||
bool add_slot_options(const software_part *swpart = nullptr);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
// device-specific option handling
|
|
||||||
void add_device_options();
|
|
||||||
void update_slot_options(const software_part *swpart = nullptr);
|
|
||||||
|
|
||||||
// INI parsing helper
|
|
||||||
bool parse_one_ini(const char *basename, int priority, std::string *error_string = nullptr);
|
|
||||||
|
|
||||||
// cache frequently used options in members
|
// cache frequently used options in members
|
||||||
void update_cached_options();
|
void update_cached_options();
|
||||||
|
|
||||||
|
std::string main_value(const char *option) const;
|
||||||
|
std::string sub_value(const char *name, const char *subname) const;
|
||||||
|
private:
|
||||||
static const options_entry s_option_entries[];
|
static const options_entry s_option_entries[];
|
||||||
|
|
||||||
// cached options
|
// cached options
|
||||||
@ -432,8 +437,6 @@ private:
|
|||||||
bool m_joystick_contradictory;
|
bool m_joystick_contradictory;
|
||||||
bool m_sleep;
|
bool m_sleep;
|
||||||
bool m_refresh_speed;
|
bool m_refresh_speed;
|
||||||
int m_slot_options;
|
|
||||||
int m_device_options;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ info_xml_creator::info_xml_creator(driver_enumerator &drivlist)
|
|||||||
m_drivlist(drivlist),
|
m_drivlist(drivlist),
|
||||||
m_lookup_options(m_drivlist.options())
|
m_lookup_options(m_drivlist.options())
|
||||||
{
|
{
|
||||||
m_lookup_options.remove_device_options();
|
mame_options::remove_device_options(m_lookup_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ int machine_manager::execute()
|
|||||||
{
|
{
|
||||||
m_options.revert(OPTION_PRIORITY_INI);
|
m_options.revert(OPTION_PRIORITY_INI);
|
||||||
std::string errors;
|
std::string errors;
|
||||||
m_options.parse_standard_inis(errors);
|
mame_options::parse_standard_inis(m_options,errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise, perform validity checks before anything else
|
// otherwise, perform validity checks before anything else
|
||||||
@ -286,12 +286,12 @@ int machine_manager::execute()
|
|||||||
if (m_new_driver_pending)
|
if (m_new_driver_pending)
|
||||||
{
|
{
|
||||||
// set up new system name and adjust device options accordingly
|
// set up new system name and adjust device options accordingly
|
||||||
m_options.set_system_name(m_new_driver_pending->name);
|
mame_options::set_system_name(m_options,m_new_driver_pending->name);
|
||||||
firstrun = true;
|
firstrun = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (machine.exit_pending()) m_options.set_system_name("");
|
if (machine.exit_pending()) mame_options::set_system_name(m_options,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (machine.exit_pending() && (!started_empty || (system == &GAME_NAME(___empty))))
|
if (machine.exit_pending() && (!started_empty || (system == &GAME_NAME(___empty))))
|
||||||
|
@ -693,7 +693,7 @@ ui_menu_machine_configure::ui_menu_machine_configure(running_machine &machine, r
|
|||||||
{
|
{
|
||||||
// parse the INI file
|
// parse the INI file
|
||||||
std::string error;
|
std::string error;
|
||||||
m_opts.parse_standard_inis(error, m_drv);
|
mame_options::parse_standard_inis(m_opts,error, m_drv);
|
||||||
setup_bios();
|
setup_bios();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ void ui_menu_slot_devices::handle()
|
|||||||
{
|
{
|
||||||
if ((FPTR)menu_event->itemref == 1 && menu_event->iptkey == IPT_UI_SELECT)
|
if ((FPTR)menu_event->itemref == 1 && menu_event->iptkey == IPT_UI_SELECT)
|
||||||
{
|
{
|
||||||
machine().options().add_slot_options();
|
mame_options::add_slot_options(machine().options());
|
||||||
machine().schedule_hard_reset();
|
machine().schedule_hard_reset();
|
||||||
}
|
}
|
||||||
else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||||
|
Loading…
Reference in New Issue
Block a user