mirror of
https://github.com/holub/mame
synced 2025-04-30 11:50:30 +03:00
Software list entries can now supply slot option defaults
This feature is enabled when executing 'mame driver software'. After the specified software is found in the software list and attached to an appropriate image device, the software part's feature list is examined for any feature whose name is that of a slot device with _default appended. The feature's value field becomes the slot's default option, which overrides any driver-specified default and can be overridden by user-specified options. No software lists have been updated to use this feature at the moment.
This commit is contained in:
parent
dc7cc9a7eb
commit
d3eecba525
@ -148,7 +148,7 @@ int cli_frontend::execute(int argc, char **argv)
|
|||||||
strprintf(val, "%s:%s:%s", swlistdev->list_name(), m_options.software_name(), swpart->name());
|
strprintf(val, "%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());
|
m_options.parse_slot_devices(argc, argv, option_errors, image->instance_name(), val.c_str(), swpart);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
#include "emuopts.h"
|
#include "emuopts.h"
|
||||||
#include "drivenum.h"
|
#include "drivenum.h"
|
||||||
|
#include "softlist.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@ -205,6 +206,8 @@ 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);
|
||||||
}
|
}
|
||||||
@ -215,18 +218,17 @@ emu_options::emu_options()
|
|||||||
// options for the configured system
|
// options for the configured system
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
bool emu_options::add_slot_options(bool isfirstpass)
|
bool emu_options::add_slot_options(const software_part *swpart)
|
||||||
{
|
{
|
||||||
// look up the system configured by name; if no match, do nothing
|
// look up the system configured by name; if no match, do nothing
|
||||||
const game_driver *cursystem = system();
|
const game_driver *cursystem = system();
|
||||||
if (cursystem == nullptr)
|
if (cursystem == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// create the configuration
|
||||||
machine_config config(*cursystem, *this);
|
machine_config config(*cursystem, *this);
|
||||||
|
|
||||||
// iterate through all slot devices
|
// iterate through all slot devices
|
||||||
bool first = true;
|
|
||||||
|
|
||||||
// create the configuration
|
|
||||||
int starting_count = options_count();
|
int starting_count = options_count();
|
||||||
slot_interface_iterator iter(config.root_device());
|
slot_interface_iterator iter(config.root_device());
|
||||||
for (const device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next())
|
for (const device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next())
|
||||||
@ -236,9 +238,8 @@ bool emu_options::add_slot_options(bool isfirstpass)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// first device? add the header as to be pretty
|
// first device? add the header as to be pretty
|
||||||
if (isfirstpass && first)
|
if (m_slot_options++ == 0)
|
||||||
add_entry(nullptr, "SLOT DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
|
add_entry(nullptr, "SLOT DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
|
||||||
first = false;
|
|
||||||
|
|
||||||
// retrieve info about the device instance
|
// retrieve info about the device instance
|
||||||
const char *name = slot->device().tag() + 1;
|
const char *name = slot->device().tag() + 1;
|
||||||
@ -255,6 +256,15 @@ bool emu_options::add_slot_options(bool isfirstpass)
|
|||||||
}
|
}
|
||||||
add_entry(name, nullptr, flags, defvalue, true);
|
add_entry(name, nullptr, flags, defvalue, 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)
|
||||||
|
set_default_value(name, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (options_count() != starting_count);
|
return (options_count() != starting_count);
|
||||||
}
|
}
|
||||||
@ -265,7 +275,7 @@ bool emu_options::add_slot_options(bool isfirstpass)
|
|||||||
// depending of image mounted
|
// depending of image mounted
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void emu_options::update_slot_options()
|
void emu_options::update_slot_options(const software_part *swpart)
|
||||||
{
|
{
|
||||||
// look up the system configured by name; if no match, do nothing
|
// look up the system configured by name; if no match, do nothing
|
||||||
const game_driver *cursystem = system();
|
const game_driver *cursystem = system();
|
||||||
@ -290,8 +300,8 @@ void emu_options::update_slot_options()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (add_slot_options(false)) { }
|
while (add_slot_options(swpart)) { }
|
||||||
add_device_options(false);
|
add_device_options();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -300,7 +310,7 @@ void emu_options::update_slot_options()
|
|||||||
// options for the configured system
|
// options for the configured system
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void emu_options::add_device_options(bool isfirstpass)
|
void emu_options::add_device_options()
|
||||||
{
|
{
|
||||||
// look up the system configured by name; if no match, do nothing
|
// look up the system configured by name; if no match, do nothing
|
||||||
const game_driver *cursystem = system();
|
const game_driver *cursystem = system();
|
||||||
@ -309,14 +319,12 @@ void emu_options::add_device_options(bool isfirstpass)
|
|||||||
machine_config config(*cursystem, *this);
|
machine_config config(*cursystem, *this);
|
||||||
|
|
||||||
// iterate through all image devices
|
// iterate through all image devices
|
||||||
bool first = true;
|
|
||||||
image_interface_iterator iter(config.root_device());
|
image_interface_iterator iter(config.root_device());
|
||||||
for (const device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
|
for (const device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
|
||||||
{
|
{
|
||||||
// first device? add the header as to be pretty
|
// first device? add the header as to be pretty
|
||||||
if (first && isfirstpass)
|
if (m_device_options++ == 0)
|
||||||
add_entry(nullptr, "IMAGE DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
|
add_entry(nullptr, "IMAGE DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
|
||||||
first = false;
|
|
||||||
|
|
||||||
// retrieve info about the device instance
|
// retrieve info about the device instance
|
||||||
std::string option_name;
|
std::string option_name;
|
||||||
@ -348,6 +356,10 @@ void emu_options::remove_device_options()
|
|||||||
if ((curentry->flags() & OPTION_FLAG_DEVICE) != 0)
|
if ((curentry->flags() & OPTION_FLAG_DEVICE) != 0)
|
||||||
remove_entry(*curentry);
|
remove_entry(*curentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset counters
|
||||||
|
m_slot_options = 0;
|
||||||
|
m_device_options = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -356,7 +368,7 @@ void emu_options::remove_device_options()
|
|||||||
// and update slot and image devices
|
// 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)
|
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
|
// an initial parse to capture the initial set of values
|
||||||
bool result;
|
bool result;
|
||||||
@ -364,15 +376,13 @@ bool emu_options::parse_slot_devices(int argc, char *argv[], std::string &error_
|
|||||||
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
||||||
|
|
||||||
// keep adding slot options until we stop seeing new stuff
|
// keep adding slot options until we stop seeing new stuff
|
||||||
bool isfirstpass = true;
|
m_slot_options = 0;
|
||||||
while (add_slot_options(isfirstpass))
|
while (add_slot_options(swpart))
|
||||||
{
|
|
||||||
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
||||||
isfirstpass = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add device options and reparse
|
// add device options and reparse
|
||||||
add_device_options(true);
|
m_device_options = 0;
|
||||||
|
add_device_options();
|
||||||
if (name != nullptr && exists(name))
|
if (name != nullptr && exists(name))
|
||||||
set_value(name, value, OPTION_PRIORITY_CMDLINE, error_string);
|
set_value(name, value, OPTION_PRIORITY_CMDLINE, error_string);
|
||||||
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
||||||
@ -380,7 +390,7 @@ bool emu_options::parse_slot_devices(int argc, char *argv[], std::string &error_
|
|||||||
int num;
|
int num;
|
||||||
do {
|
do {
|
||||||
num = options_count();
|
num = options_count();
|
||||||
update_slot_options();
|
update_slot_options(swpart);
|
||||||
result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
||||||
} while (num != options_count());
|
} while (num != options_count());
|
||||||
|
|
||||||
@ -399,7 +409,7 @@ bool emu_options::parse_command_line(int argc, char *argv[], std::string &error_
|
|||||||
{
|
{
|
||||||
// parse as normal
|
// parse as normal
|
||||||
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
|
||||||
bool result = parse_slot_devices(argc, argv, error_string, nullptr, nullptr);
|
bool result = parse_slot_devices(argc, argv, error_string);
|
||||||
update_cached_options();
|
update_cached_options();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -523,11 +533,10 @@ void emu_options::set_system_name(const char *name)
|
|||||||
|
|
||||||
// remove any existing device options and then add them afresh
|
// remove any existing device options and then add them afresh
|
||||||
remove_device_options();
|
remove_device_options();
|
||||||
if (add_slot_options(true))
|
while (add_slot_options()) { }
|
||||||
while (add_slot_options(false)) { }
|
|
||||||
|
|
||||||
// then add the options
|
// then add the options
|
||||||
add_device_options(true);
|
add_device_options();
|
||||||
int num;
|
int num;
|
||||||
do {
|
do {
|
||||||
num = options_count();
|
num = options_count();
|
||||||
|
@ -197,6 +197,7 @@ enum
|
|||||||
|
|
||||||
// forward references
|
// forward references
|
||||||
struct game_driver;
|
struct game_driver;
|
||||||
|
class software_part;
|
||||||
|
|
||||||
|
|
||||||
class emu_options : public core_options
|
class emu_options : public core_options
|
||||||
@ -210,7 +211,7 @@ public:
|
|||||||
// parsing wrappers
|
// parsing wrappers
|
||||||
bool parse_command_line(int argc, char *argv[], std::string &error_string);
|
bool parse_command_line(int argc, char *argv[], std::string &error_string);
|
||||||
void parse_standard_inis(std::string &error_string);
|
void parse_standard_inis(std::string &error_string);
|
||||||
bool parse_slot_devices(int argc, char *argv[], std::string &error_string, const char *name, const char *value);
|
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); }
|
||||||
@ -370,12 +371,12 @@ public:
|
|||||||
|
|
||||||
std::string main_value(const char *option) const;
|
std::string main_value(const char *option) const;
|
||||||
std::string sub_value(const char *name, const char *subname) const;
|
std::string sub_value(const char *name, const char *subname) const;
|
||||||
bool add_slot_options(bool isfirst);
|
bool add_slot_options(const software_part *swpart = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// device-specific option handling
|
// device-specific option handling
|
||||||
void add_device_options(bool isfirst);
|
void add_device_options();
|
||||||
void update_slot_options();
|
void update_slot_options(const software_part *swpart = nullptr);
|
||||||
|
|
||||||
// INI parsing helper
|
// INI parsing helper
|
||||||
bool parse_one_ini(const char *basename, int priority, std::string *error_string = nullptr);
|
bool parse_one_ini(const char *basename, int priority, std::string *error_string = nullptr);
|
||||||
@ -390,6 +391,8 @@ 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,7 +189,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(false);
|
machine().options().add_slot_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