From ff1db593b74a6924ddaf1d6038a0761a11c8bfc3 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Thu, 5 May 2011 07:02:28 +0000 Subject: [PATCH] Attach gamedrv's input ports to the driver_device, so that there's no longer anything special about how they are processed. Removed logic that handled the game inputs as a special case. --- src/emu/info.c | 1 - src/emu/inptport.c | 11 +---------- src/emu/inptport.h | 2 +- src/emu/machine.c | 13 ++++++++++++- src/emu/machine.h | 1 + src/emu/validity.c | 8 -------- 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/emu/info.c b/src/emu/info.c index 5ef5f542476..d3529dfc2aa 100644 --- a/src/emu/info.c +++ b/src/emu/info.c @@ -248,7 +248,6 @@ void info_xml_creator::output_one() // allocate input ports machine_config &config = m_drivlist.config(); ioport_list portlist; - input_port_list_init(portlist, driver.ipt, NULL, 0, FALSE, NULL); for (device_t *device = config.devicelist().first(); device != NULL; device = device->next()) if (device->input_ports() != NULL) input_port_list_init(portlist, device->input_ports(), NULL, 0, FALSE, device); diff --git a/src/emu/inptport.c b/src/emu/inptport.c index 7d9e9078b31..ff27742bb7b 100644 --- a/src/emu/inptport.c +++ b/src/emu/inptport.c @@ -973,7 +973,7 @@ static WRITE_LINE_DEVICE_HANDLER( changed_write_line_device ) system -------------------------------------------------*/ -time_t input_port_init(running_machine &machine, const input_port_token *tokens, const device_list &devicelist) +time_t input_port_init(running_machine &machine, const device_list &devicelist) { //input_port_private *portdata; char errorbuf[1024]; @@ -991,22 +991,13 @@ time_t input_port_init(running_machine &machine, const input_port_token *tokens, init_port_types(machine); /* if we have a token list, proceed */ - if (tokens != NULL) - { - input_port_list_init(machine.m_portlist, tokens, errorbuf, sizeof(errorbuf), TRUE, NULL); - if (errorbuf[0] != 0) - mame_printf_error("Input port errors:\n%s", errorbuf); - } - for (device_t *device = devicelist.first(); device != NULL; device = device->next()) - { if (device->input_ports() != NULL) { input_port_list_init(machine.m_portlist, device->input_ports(), errorbuf, sizeof(errorbuf), TRUE, device); if (errorbuf[0] != 0) mame_printf_error("Input port errors:\n%s", errorbuf); } - } init_port_state(machine); /* register callbacks for when we load configurations */ diff --git a/src/emu/inptport.h b/src/emu/inptport.h index d7baddb1895..238d10e3af2 100644 --- a/src/emu/inptport.h +++ b/src/emu/inptport.h @@ -1085,7 +1085,7 @@ struct _inp_header /* ----- core system management ----- */ /* initialize the input ports, processing the given token list */ -time_t input_port_init(running_machine &machine, const input_port_token *tokens, const device_list &devicelist); +time_t input_port_init(running_machine &machine, const device_list &devicelist); diff --git a/src/emu/machine.c b/src/emu/machine.c index 05c62d01e8b..81a392cb05d 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -279,7 +279,7 @@ void running_machine::start() // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags - time_t newbase = input_port_init(*this, m_system.ipt, devicelist()); + time_t newbase = input_port_init(*this, devicelist()); if (newbase != 0) m_base_time = newbase; @@ -1140,6 +1140,17 @@ const rom_entry *driver_device::device_rom_region() const } +//------------------------------------------------- +// device_input_ports - return a pointer to the +// game's input ports +//------------------------------------------------- + +const input_port_token *driver_device::device_input_ports() const +{ + return m_system->ipt; +} + + //------------------------------------------------- // device_start - device override which calls // the various helpers diff --git a/src/emu/machine.h b/src/emu/machine.h index cbad4048c77..abdd6e0ffa7 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -576,6 +576,7 @@ protected: // device-level overrides virtual const rom_entry *device_rom_region() const; + virtual const input_port_token *device_input_ports() const; virtual void device_start(); virtual void device_reset(); diff --git a/src/emu/validity.c b/src/emu/validity.c index 5af753c818f..a263a59ef14 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -957,14 +957,7 @@ static bool validate_inputs(driver_enumerator &drivlist, int_map &defstr_map, io return FALSE; /* allocate the input ports */ - input_port_list_init(portlist, driver.ipt, errorbuf, sizeof(errorbuf), FALSE, NULL); - if (errorbuf[0] != 0) - { - mame_printf_error("%s: %s has input port errors:\n%s\n", driver.source_file, driver.name, errorbuf); - error = true; - } for (device_t *cfg = config.devicelist().first(); cfg != NULL; cfg = cfg->next()) - { if (cfg->input_ports() != NULL) { input_port_list_init(portlist, cfg->input_ports(), errorbuf, sizeof(errorbuf), FALSE, cfg); @@ -974,7 +967,6 @@ static bool validate_inputs(driver_enumerator &drivlist, int_map &defstr_map, io error = true; } } - } /* check for duplicate tags */ for (port = portlist.first(); port != NULL; port = port->next())