From a6876a99800c4a2440259c3c45a45c97963c19e0 Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Fri, 25 Feb 2011 09:01:47 +0000 Subject: [PATCH] Added overloaded input_port_read() for reading device owned input ports. [Curt Coder] --- src/emu/inptport.c | 15 +++++++++++++++ src/emu/inptport.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/emu/inptport.c b/src/emu/inptport.c index 3ccbc1695e0..53b66434e6f 100644 --- a/src/emu/inptport.c +++ b/src/emu/inptport.c @@ -1582,6 +1582,21 @@ input_port_value input_port_read(running_machine *machine, const char *tag) } +/*------------------------------------------------- + input_port_read - return the value of + an device input port specified by tag +-------------------------------------------------*/ + +input_port_value input_port_read(running_machine *machine, device_t *device, const char *tag) +{ + astring tempstring; + const input_port_config *port = machine->port(device->baseconfig().subtag(tempstring, tag)); + if (port == NULL) + fatalerror("Unable to locate input port '%s'", tag); + return input_port_read_direct(port); +} + + /*------------------------------------------------- input_port_read_safe - return the value of an input port specified by tag, or a default diff --git a/src/emu/inptport.h b/src/emu/inptport.h index bd2159fa7de..01b04cfcca6 100644 --- a/src/emu/inptport.h +++ b/src/emu/inptport.h @@ -1137,6 +1137,9 @@ input_port_value input_port_read_direct(const input_port_config *port); /* return the value of an input port specified by tag */ input_port_value input_port_read(running_machine *machine, const char *tag); +/* return the value of an input port specified by tag */ +input_port_value input_port_read(running_machine *machine, device_t *device, const char *tag); + /* return the value of an input port specified by tag, or a default value if the port does not exist */ input_port_value input_port_read_safe(running_machine *machine, const char *tag, input_port_value defvalue);