summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2011-06-27 12:37:56 +0000
committer Miodrag Milanovic <mmicko@gmail.com>2011-06-27 12:37:56 +0000
commitba15f08a16c45adbe685ecc60a75823d8910059b (patch)
tree7329ad498dca310fda03b4af60c44537ad0fd7a9
parentd052177a6057780204f0d5fef08e3ef1af78ec04 (diff)
Added support for multi level slot devices [Miodrag Milanovic]
Now it is possible to attach slot device to other slot device, also containing multiple image devices under it.
-rw-r--r--src/emu/emuopts.c78
-rw-r--r--src/emu/emuopts.h3
-rw-r--r--src/emu/mconfig.c2
-rw-r--r--src/lib/util/options.c9
-rw-r--r--src/lib/util/options.h1
5 files changed, 65 insertions, 28 deletions
diff --git a/src/emu/emuopts.c b/src/emu/emuopts.c
index 66d4154cfcb..4e2be89fcd0 100644
--- a/src/emu/emuopts.c
+++ b/src/emu/emuopts.c
@@ -210,68 +210,86 @@ emu_options::emu_options()
//-------------------------------------------------
-// add_device_options - add all of the device
+// add_slot_options - add all of the slot
// options for the configured system
//-------------------------------------------------
-void emu_options::add_device_options()
+bool emu_options::add_slot_options(bool isfirst)
{
- // remove any existing device options
- remove_device_options();
-
// look up the system configured by name; if no match, do nothing
const game_driver *cursystem = system();
if (cursystem == NULL)
- return;
-
- // create the configuration
- machine_config config(*cursystem, *this);
+ return false;
// iterate through all slot devices
options_entry entry[2] = { { 0 }, { 0 } };
bool first = true;
const device_slot_interface *slot = NULL;
+ // create the configuration
+ machine_config config(*cursystem, *this);
+ bool added = false;
for (bool gotone = config.devicelist().first(slot); gotone; gotone = slot->next(slot))
{
// first device? add the header as to be pretty
- if (first)
+ if (first && isfirst)
{
- first = false;
entry[0].name = NULL;
entry[0].description = "SLOT DEVICES";
entry[0].flags = OPTION_HEADER | OPTION_FLAG_DEVICE;
entry[0].defvalue = NULL;
add_entries(entry);
}
+ first = false;
// retrieve info about the device instance
astring option_name;
option_name.printf("%s;%s", slot->device().tag(), slot->device().tag());
- // add the option
- entry[0].name = option_name;
- entry[0].description = NULL;
- entry[0].flags = OPTION_STRING | OPTION_FLAG_DEVICE;
- entry[0].defvalue = (slot->get_slot_interfaces() != NULL) ? slot->get_default_card() : NULL;
- add_entries(entry, true);
+ if (!exists(slot->device().tag())) {
+
+ // add the option
+ entry[0].name = slot->device().tag();
+ entry[0].description = NULL;
+ entry[0].flags = OPTION_STRING | OPTION_FLAG_DEVICE;
+ entry[0].defvalue = (slot->get_slot_interfaces() != NULL) ? slot->get_default_card() : NULL;
+ add_entries(entry, true);
+
+ added = true;
+ }
}
+ return added;
+}
+//-------------------------------------------------
+// add_device_options - add all of the device
+// options for the configured system
+//-------------------------------------------------
+
+void emu_options::add_device_options(bool isfirst)
+{
+ // look up the system configured by name; if no match, do nothing
+ const game_driver *cursystem = system();
+ if (cursystem == NULL)
+ return;
+
+ // iterate through all slot devices
+ options_entry entry[2] = { { 0 }, { 0 } };
+ bool first = true;
// iterate through all image devices
const device_image_interface *image = NULL;
- machine_config slot_config(*cursystem, *this);
- first = true;
- for (bool gotone = slot_config.devicelist().first(image); gotone; gotone = image->next(image))
+ machine_config config(*cursystem, *this);
+ for (bool gotone = config.devicelist().first(image); gotone; gotone = image->next(image))
{
// first device? add the header as to be pretty
- if (first)
+ if (first && isfirst)
{
- first = false;
entry[0].name = NULL;
entry[0].description = "IMAGE DEVICES";
entry[0].flags = OPTION_HEADER | OPTION_FLAG_DEVICE;
entry[0].defvalue = NULL;
add_entries(entry);
}
+ first = false;
// retrieve info about the device instance
astring option_name;
@@ -323,8 +341,15 @@ bool emu_options::parse_command_line(int argc, char *argv[], astring &error_stri
// if the system name changed, fix up the device options
if (old_system_name != system_name())
{
- add_device_options();
-
+ // remove any existing device options
+ remove_device_options();
+ add_device_options(true);
+ bool isfirst = true;
+ while (add_slot_options(isfirst)) {
+ result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
+ add_device_options(false);
+ isfirst = false;
+ }
// if we failed the first time, try parsing again with the new options in place
if (!result)
result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
@@ -423,9 +448,10 @@ void emu_options::set_system_name(const char *name)
astring error;
set_value(OPTION_SYSTEMNAME, name, OPTION_PRIORITY_CMDLINE, error);
assert(!error);
-
+ // remove any existing device options
+ remove_device_options();
// then add the options
- add_device_options();
+ add_device_options(true);
}
}
diff --git a/src/emu/emuopts.h b/src/emu/emuopts.h
index 41e9ebf72c7..962dcf512e9 100644
--- a/src/emu/emuopts.h
+++ b/src/emu/emuopts.h
@@ -349,7 +349,8 @@ public:
private:
// device-specific option handling
- void add_device_options();
+ void add_device_options(bool isfirst);
+ bool add_slot_options(bool isfirst);
void remove_device_options();
// INI parsing helper
diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c
index 38a180c2867..8ae9b221608 100644
--- a/src/emu/mconfig.c
+++ b/src/emu/mconfig.c
@@ -76,7 +76,7 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
{
device_t &owner = slot->device();
const char *selval = options.value(owner.tag());
- if (options.seqid(owner.tag()) == 0)
+ if (!options.exists(owner.tag()))
selval = slot->get_default_card();
if (selval != NULL)
diff --git a/src/lib/util/options.c b/src/lib/util/options.c
index 01022a1665d..ac7897fb6d3 100644
--- a/src/lib/util/options.c
+++ b/src/lib/util/options.c
@@ -556,6 +556,15 @@ UINT32 core_options::seqid(const char *name) const
return (curentry != NULL) ? curentry->seqid() : 0;
}
+//-------------------------------------------------
+// exists - return if option exists in list
+//-------------------------------------------------
+
+bool core_options::exists(const char *name) const
+{
+ entry *curentry = m_entrymap.find(name);
+ return (curentry != NULL);
+}
//-------------------------------------------------
// set_value - set the raw option value
diff --git a/src/lib/util/options.h b/src/lib/util/options.h
index 4ef8a6b1170..03aa293bebf 100644
--- a/src/lib/util/options.h
+++ b/src/lib/util/options.h
@@ -175,6 +175,7 @@ public:
int int_value(const char *name) const { return atoi(value(name)); }
float float_value(const char *name) const { return atof(value(name)); }
UINT32 seqid(const char *name) const;
+ bool exists(const char *name) const;
// setting
void set_command(const char *command);