From 5596c512fc7f049a22b5faef0a8146686f90e332 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 11 Feb 2012 16:15:39 +0000 Subject: [PATCH] Sync core fixes from MESS done by OG (nw) --- src/emu/dislot.c | 3 +++ src/emu/mconfig.c | 27 +++++++++++++++++++++++++++ src/emu/mconfig.h | 4 ++-- src/emu/validity.c | 2 +- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/emu/dislot.c b/src/emu/dislot.c index 29a9a10efc5..95cfedaa046 100644 --- a/src/emu/dislot.c +++ b/src/emu/dislot.c @@ -10,6 +10,9 @@ device_slot_interface::device_slot_interface(const machine_config &mconfig, device_t &device) : device_interface(device) { + m_default_card = 0; + m_input_defaults = 0; + m_slot_interfaces = 0; } device_slot_interface::~device_slot_interface() diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c index 60b9fc72be7..bd2d236b5c7 100644 --- a/src/emu/mconfig.c +++ b/src/emu/mconfig.c @@ -141,6 +141,33 @@ screen_device *machine_config::first_screen() const device_t *machine_config::device_add(device_t *owner, const char *tag, device_type type, UINT32 clock) { + const char *orig_tag = tag; + + // if the device path is absolute, start from the root + if (tag[0] == ':') + { + tag++; + owner = m_root_device; + } + + // go down the path until we're done with it + while (strchr(tag, ':')) + { + const char *next = strchr(tag, ':'); + assert(next != tag); + astring part(tag, next-tag); + device_t *curdevice; + for (curdevice = owner->m_subdevice_list.first(); curdevice != NULL; curdevice = curdevice->next()) + if (part == curdevice->m_basetag) + break; + if (!curdevice) + throw emu_fatalerror("Could not find %s when looking up path for device %s\n", + part.cstr(), orig_tag); + owner = curdevice; + tag = next+1; + } + assert(tag[0]); + // if there's an owner, let the owner do the work if (owner != NULL) return owner->add_subdevice(type, tag, clock); diff --git a/src/emu/mconfig.h b/src/emu/mconfig.h index 73f7770cf92..b225bd5ea4d 100644 --- a/src/emu/mconfig.h +++ b/src/emu/mconfig.h @@ -51,8 +51,8 @@ // CONSTANTS //************************************************************************** -// by convention, tags should all lowercase and between 2-15 characters -#define MIN_TAG_LENGTH 2 +// by convention, tags should all lowercase and between 1-15 characters +#define MIN_TAG_LENGTH 1 #define MAX_TAG_LENGTH 15 diff --git a/src/emu/validity.c b/src/emu/validity.c index 270cd04fb9b..843f6b08acd 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -1139,7 +1139,7 @@ void validity_checker::validate_slots() { // iterate over interfaces const slot_interface *intf = slot->get_slot_interfaces(); - for (int j = 0; intf[j].name != NULL; j++) + for (int j = 0; intf && intf[j].name != NULL; j++) { // instantiate the device device_t *dev = (*intf[j].devtype)(*m_current_config, "dummy", &m_current_config->root_device(), 0);