summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-10-25 05:06:08 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-10-25 05:06:08 +0000
commitc96cde525f2a163313939bb10bf36ed0f792343b (patch)
treed8265599ac66691c2d16afafc89f24f0e668b07c
parent731077c991f07646c0a32535f70f26b9f54c53ce (diff)
From: Dirk Best <startaq@gmail.com>
Date: Sun, Oct 11, 2009 at 00:38 Subject: patch for devcb.c To: submit@mamedev.org Hello, attached is a patch for devcb.c which allows devices to directly call child devices. An example would be a device with its own CPU and a child device that calls DEVCB_CPU_INPUT_LINE. Without the patch, this would have only worked with tags like DEVCB_CPU_INPUT_LINE("parent:device_cpu", 0). With the patch, its enough to write DEVCB_CPU_INPUT_LINE("device_cpu", 0). Dirk
-rw-r--r--src/emu/devcb.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/emu/devcb.c b/src/emu/devcb.c
index a9594a46e31..90350a94290 100644
--- a/src/emu/devcb.c
+++ b/src/emu/devcb.c
@@ -52,7 +52,12 @@ void devcb_resolve_read_line(devcb_resolved_read_line *resolved, const devcb_rea
else if (config->type >= DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM) && config->type < DEVCB_TYPE_MEMORY(ADDRESS_SPACES) && config->readspace != NULL)
{
FPTR space = (FPTR)config->type - (FPTR)DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM);
- const device_config *cpu = cputag_get_cpu(device->machine, config->tag);
+ const device_config *cpu;
+
+ if (device->owner != NULL)
+ cpu = device_find_child_by_tag(device->owner, config->tag);
+ else
+ cpu = cputag_get_cpu(device->machine, config->tag);
if (cpu == NULL)
fatalerror("devcb_resolve_read_line: unable to find CPU '%s' (requested by %s '%s')", config->tag, device_get_name(device), device->tag);
@@ -67,7 +72,14 @@ void devcb_resolve_read_line(devcb_resolved_read_line *resolved, const devcb_rea
/* device handlers */
else if ((config->type == DEVCB_TYPE_DEVICE || config->type == DEVCB_TYPE_SELF) && (config->readline != NULL || config->readdevice != NULL))
{
- resolved->target = (config->type == DEVCB_TYPE_SELF) ? device : devtag_get_device(device->machine, config->tag);
+ /* locate the device */
+ if (config->type == DEVCB_TYPE_SELF)
+ resolved->target = device;
+ else if (device->owner != NULL)
+ resolved->target = device_find_child_by_tag(device->owner, config->tag);
+ else
+ resolved->target = devtag_get_device(device->machine, config->tag);
+
if (resolved->target == NULL)
fatalerror("devcb_resolve_read_line: unable to find device '%s' (requested by %s '%s')", config->tag, device_get_name(device), device->tag);
@@ -114,7 +126,12 @@ void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_w
if (config->type >= DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM) && config->type < DEVCB_TYPE_MEMORY(ADDRESS_SPACES) && config->writespace != NULL)
{
FPTR space = (FPTR)config->type - (FPTR)DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM);
- const device_config *cpu = cputag_get_cpu(device->machine, config->tag);
+ const device_config *cpu;
+
+ if (device->owner != NULL)
+ cpu = device_find_child_by_tag(device->owner, config->tag);
+ else
+ cpu = cputag_get_cpu(device->machine, config->tag);
if (cpu == NULL)
fatalerror("devcb_resolve_write_line: unable to find CPU '%s' (requested by %s '%s')", config->tag, device_get_name(device), device->tag);
@@ -130,7 +147,12 @@ void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_w
else if (config->type >= DEVCB_TYPE_CPU_LINE(0) && config->type < DEVCB_TYPE_CPU_LINE(MAX_INPUT_LINES))
{
FPTR line = (FPTR)config->type - (FPTR)DEVCB_TYPE_CPU_LINE(0);
- const device_config *cpu = cputag_get_cpu(device->machine, config->tag);
+ const device_config *cpu;
+
+ if (device->owner != NULL)
+ cpu = device_find_child_by_tag(device->owner, config->tag);
+ else
+ cpu = cputag_get_cpu(device->machine, config->tag);
if (cpu == NULL)
fatalerror("devcb_resolve_write_line: unable to find CPU '%s' (requested by %s '%s')", config->tag, device_get_name(device), device->tag);
@@ -143,7 +165,14 @@ void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_w
/* device handlers */
else if ((config->type == DEVCB_TYPE_DEVICE || config->type == DEVCB_TYPE_SELF) && (config->writeline != NULL || config->writedevice != NULL))
{
- resolved->target = (config->type == DEVCB_TYPE_SELF) ? device : devtag_get_device(device->machine, config->tag);
+ /* locate the device */
+ if (config->type == DEVCB_TYPE_SELF)
+ resolved->target = device;
+ else if (device->owner != NULL)
+ resolved->target = device_find_child_by_tag(device->owner, config->tag);
+ else
+ resolved->target = devtag_get_device(device->machine, config->tag);
+
if (resolved->target == NULL)
fatalerror("devcb_resolve_write_line: unable to find device '%s' (requested by %s '%s')", config->tag, device_get_name(device), device->tag);