From 772082e0b88a348c6f68a83f1295dc42325fbbbe Mon Sep 17 00:00:00 2001 From: Couriersud Date: Wed, 20 Aug 2008 21:15:01 +0000 Subject: [PATCH] devintrf.c: add devtag_get_device(machine, type, tag) to retrieve the device_config for (type, tag) * This is needed, if you need to read a device or device status outside a AM_DEVREAD context. --- src/emu/devintrf.c | 20 ++++++++++++++++++++ src/emu/devintrf.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index d684c1fed8d..b8fdd88b223 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -590,6 +590,26 @@ void *devtag_get_token(running_machine *machine, device_type type, const char *t } +/*------------------------------------------------- + devtag_get_device - return the device associated + with a tag +-------------------------------------------------*/ + +const device_config *devtag_get_device(running_machine *machine, device_type type, const char *tag) +{ + const device_config *device; + + assert(machine != NULL); + assert(type != NULL); + assert(tag != NULL); + + device = device_list_find_by_tag(machine->config->devicelist, type, tag); + if (device == NULL) + fatalerror("devtag_get_device failed to find device: type=%s tag=%s\n", devtype_name(type), tag); + return device; +} + + /*------------------------------------------------- devtag_get_static_config - return a pointer to the static configuration for a device based on diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index 53f150b2c95..0331b666d0f 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -254,6 +254,9 @@ void devtag_reset(running_machine *machine, device_type type, const char *tag); /* ----- device information getters ----- */ +/* return the device associated with a tag */ +const device_config *devtag_get_device(running_machine *machine, device_type type, const char *tag); + /* return the token associated with an allocated device */ void *devtag_get_token(running_machine *machine, device_type type, const char *tag);