Added validity check to ensure that ports referenced by a condition

actually exist. Fixed a case where this was violated.
This commit is contained in:
Aaron Giles 2008-08-19 05:12:45 +00:00
parent 35ee8d5279
commit 719eca9c82
2 changed files with 42 additions and 8 deletions

View File

@ -1327,6 +1327,7 @@ static int validate_inputs(int drivnum, const machine_config *config, const inpu
for (port = *portlistptr; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
{
const input_setting_config *setting;
int strindex = 0;
/* verify analog inputs */
@ -1381,6 +1382,39 @@ static int validate_inputs(int drivnum, const machine_config *config, const inpu
/* look up the string and print an error if default strings are not used */
strindex = get_defstr_index(field->name, driver, &error);
}
/* verify conditions on the field */
if (field->condition.tag != NULL)
{
/* find a matching port */
for (scanport = *portlistptr; scanport != NULL; scanport = scanport->next)
if (scanport->tag != NULL && strcmp(field->condition.tag, scanport->tag) == 0)
break;
/* if none, error */
if (scanport == NULL)
{
mame_printf_error("%s: %s has a condition referencing non-existent input port tag \"%s\"\n", driver->source_file, driver->name, field->condition.tag);
error = TRUE;
}
}
/* verify conditions on the settings */
for (setting = field->settinglist; setting != NULL; setting = setting->next)
if (setting->condition.tag != NULL)
{
/* find a matching port */
for (scanport = *portlistptr; scanport != NULL; scanport = scanport->next)
if (scanport->tag != NULL && strcmp(setting->condition.tag, scanport->tag) == 0)
break;
/* if none, error */
if (scanport == NULL)
{
mame_printf_error("%s: %s has a condition referencing non-existent input port tag \"%s\"\n", driver->source_file, driver->name, setting->condition.tag);
error = TRUE;
}
}
}
#ifdef MESS

View File

@ -397,14 +397,14 @@ static INPUT_PORTS_START( asterock )
PORT_DIPSETTING ( 0x00, DEF_STR( Normal ) )
PORT_DIPSETTING ( 0x20, "Special" )
PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:7,8")
PORT_DIPSETTING ( 0xc0, DEF_STR( 2C_1C ) ) PORT_CONDITION("DSW",0x20,PORTCOND_EQUALS,0x00)
PORT_DIPSETTING ( 0x80, DEF_STR( 1C_1C ) ) PORT_CONDITION("DSW",0x20,PORTCOND_EQUALS,0x00)
PORT_DIPSETTING ( 0x40, DEF_STR( 1C_2C ) ) PORT_CONDITION("DSW",0x20,PORTCOND_EQUALS,0x00)
// PORT_DIPSETTING ( 0x00, DEF_STR( 1C_1C ) ) PORT_CONDITION("DSW",0x20,PORTCOND_EQUALS,0x00)
PORT_DIPSETTING ( 0xc0, "Coin A 2/1 Coin B 2/1 Coin C 1/1" ) PORT_CONDITION("DSW",0x20,PORTCOND_NOTEQUALS,0x00)
PORT_DIPSETTING ( 0x80, "Coin A 1/1 Coin B 1/1 Coin C 1/2" ) PORT_CONDITION("DSW",0x20,PORTCOND_NOTEQUALS,0x00)
PORT_DIPSETTING ( 0x40, "Coin A 1/2 Coin B 1/2 Coin C 1/4" ) PORT_CONDITION("DSW",0x20,PORTCOND_NOTEQUALS,0x00)
// PORT_DIPSETTING ( 0x00, "Coin A 1/1 Coin B 1/1 Coin C 1/2" ) PORT_CONDITION("DSW",0x20,PORTCOND_NOTEQUALS,0x00)
PORT_DIPSETTING ( 0xc0, DEF_STR( 2C_1C ) ) PORT_CONDITION("DSW1",0x20,PORTCOND_EQUALS,0x00)
PORT_DIPSETTING ( 0x80, DEF_STR( 1C_1C ) ) PORT_CONDITION("DSW1",0x20,PORTCOND_EQUALS,0x00)
PORT_DIPSETTING ( 0x40, DEF_STR( 1C_2C ) ) PORT_CONDITION("DSW1",0x20,PORTCOND_EQUALS,0x00)
// PORT_DIPSETTING ( 0x00, DEF_STR( 1C_1C ) ) PORT_CONDITION("DSW1",0x20,PORTCOND_EQUALS,0x00)
PORT_DIPSETTING ( 0xc0, "Coin A 2/1 Coin B 2/1 Coin C 1/1" ) PORT_CONDITION("DSW1",0x20,PORTCOND_NOTEQUALS,0x00)
PORT_DIPSETTING ( 0x80, "Coin A 1/1 Coin B 1/1 Coin C 1/2" ) PORT_CONDITION("DSW1",0x20,PORTCOND_NOTEQUALS,0x00)
PORT_DIPSETTING ( 0x40, "Coin A 1/2 Coin B 1/2 Coin C 1/4" ) PORT_CONDITION("DSW1",0x20,PORTCOND_NOTEQUALS,0x00)
// PORT_DIPSETTING ( 0x00, "Coin A 1/1 Coin B 1/1 Coin C 1/2" ) PORT_CONDITION("DSW1",0x20,PORTCOND_NOTEQUALS,0x00)
INPUT_PORTS_END