From d77d9fdb64935a0f1680960d664bcf0608346ca5 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Mon, 24 Mar 2008 01:33:12 +0000 Subject: [PATCH] Added validity check to ensure input port tags don't have duplicates. Fixed several drivers where there were duplicates. --- src/emu/validity.c | 28 ++++++++++++++++++++++++---- src/mame/drivers/hyperspt.c | 2 +- src/mame/drivers/metro.c | 2 +- src/mame/drivers/system16.c | 2 +- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/emu/validity.c b/src/emu/validity.c index 660798f3cc8..d18c2ea8c8d 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -1016,6 +1016,8 @@ static int validate_inputs(int drivnum, const machine_config *config, input_port const char *flipscreen = input_port_string_from_index(INPUT_STRING_Flip_Screen); const input_port_entry *inp, *last_dipname_entry = NULL; const game_driver *driver = drivers[drivnum]; + const char *tag[MAX_INPUT_PORTS] = { 0 }; + int portnum = 0; int empty_string_found = FALSE; int last_strindex = 0; quark_entry *entry; @@ -1043,6 +1045,24 @@ static int validate_inputs(int drivnum, const machine_config *config, input_port for (inp = *memory; inp->type != IPT_END; inp++) { int strindex = 0; + + /* check for duplicate tags */ + if (inp->type == IPT_PORT) + { + if (inp->start.tag != NULL && portnum < ARRAY_LENGTH(tag)) + { + int scanport; + + for (scanport = 0; scanport < portnum - 1; scanport++) + if (strcmp(inp->start.tag, tag[scanport]) == 0) + { + mame_printf_error("%s: %s has a duplicate input port tag \"%s\"\n", driver->source_file, driver->name, inp->start.tag); + error = TRUE; + } + tag[portnum++] = inp->start.tag; + } + continue; + } if (port_type_is_analog(inp->type)) { @@ -1148,7 +1168,7 @@ static int validate_inputs(int drivnum, const machine_config *config, input_port } /* clear the DIP switch tracking when we hit the first non-DIP entry */ - if (last_dipname_entry && inp->type != IPT_DIPSWITCH_SETTING) + if (last_dipname_entry != NULL && inp->type != IPT_DIPSWITCH_SETTING) last_dipname_entry = NULL; /* look for invalid (0) types which should be mapped to IPT_OTHER */ @@ -1159,7 +1179,7 @@ static int validate_inputs(int drivnum, const machine_config *config, input_port } /* if this entry doesn't have a name, we don't care about the rest of this stuff */ - if (!inp->name || inp->name == IP_NAME_DEFAULT) + if (inp->name == NULL || inp->name == IP_NAME_DEFAULT) { /* not allowed for dipswitches */ if (inp->type == IPT_DIPSWITCH_NAME || inp->type == IPT_DIPSWITCH_SETTING) @@ -1172,7 +1192,7 @@ static int validate_inputs(int drivnum, const machine_config *config, input_port } /* check for empty string */ - if (!inp->name[0] && !empty_string_found) + if (inp->name[0] == 0 && !empty_string_found) { mame_printf_error("%s: %s has an input with an empty string\n", driver->source_file, driver->name); error = TRUE; @@ -1180,7 +1200,7 @@ static int validate_inputs(int drivnum, const machine_config *config, input_port } /* check for trailing spaces */ - if (inp->name[0] && inp->name[strlen(inp->name) - 1] == ' ') + if (inp->name[0] != 0 && inp->name[strlen(inp->name) - 1] == ' ') { mame_printf_error("%s: %s input '%s' has trailing spaces\n", driver->source_file, driver->name, inp->name); error = TRUE; diff --git a/src/mame/drivers/hyperspt.c b/src/mame/drivers/hyperspt.c index 6b2e89a8064..7f3ce38006d 100644 --- a/src/mame/drivers/hyperspt.c +++ b/src/mame/drivers/hyperspt.c @@ -362,7 +362,7 @@ static INPUT_PORTS_START( roadf ) /* 0x00 disables Coin 2. It still accepts coins and makes the sound, but it doesn't give you any credit */ - PORT_START_TAG("IN1") + PORT_START_TAG("DSW1") PORT_DIPNAME( 0x01, 0x00, DEF_STR( Allow_Continue ) ) PORT_DIPSETTING( 0x01, DEF_STR( No ) ) PORT_DIPSETTING( 0x00, DEF_STR( Yes ) ) diff --git a/src/mame/drivers/metro.c b/src/mame/drivers/metro.c index b733ef69258..aa38204c4c3 100644 --- a/src/mame/drivers/metro.c +++ b/src/mame/drivers/metro.c @@ -2328,7 +2328,7 @@ INPUT_PORTS_END ***************************************************************************/ static INPUT_PORTS_START( batlbubl ) - PORT_START_TAG("IN0") + PORT_START_TAG("IN1") JOY_LSB(1, BUTTON1, UNKNOWN, UNKNOWN, UNKNOWN) JOY_MSB(2, BUTTON1, UNKNOWN, UNKNOWN, UNKNOWN) diff --git a/src/mame/drivers/system16.c b/src/mame/drivers/system16.c index c4f082e317c..50efaf2453e 100644 --- a/src/mame/drivers/system16.c +++ b/src/mame/drivers/system16.c @@ -1093,7 +1093,7 @@ static INPUT_PORTS_START( fpoint ) PORT_START_TAG("IN1") PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_START_TAG("IN2") + PORT_START_TAG("IN3") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_COCKTAIL PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL