Previous 15994 Revisions Next

r12024 Wednesday 22nd June, 2011 at 12:55:04 UTC by Miodrag Milanović
Fixed PORT_CONDITION to look relative to device (no whatsnew)
[src/emu]inptport.c inptport.h uimenu.c validity.c

src/emu/uimenu.c
r12023r12024
18681868         const char *name = input_field_name(field);
18691869
18701870         /* add if we match the group and we have a valid name */
1871         if (name != NULL && input_condition_true(machine, &field->condition) &&
1871         if (name != NULL && input_condition_true(machine, &field->condition, port->owner()) &&
18721872            (field->category == 0 || input_category_active(machine, field->category)) &&
18731873            ((field->type == IPT_OTHER && field->name != NULL) || input_type_group(machine, field->type, field->player) != IPG_INVALID))
18741874         {
r12023r12024
22162216   /* loop over input ports and set up the current values */
22172217   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
22182218      for (field = port->fieldlist().first(); field != NULL; field = field->next())
2219         if (field->type == type && input_condition_true(machine, &field->condition))
2219         if (field->type == type && input_condition_true(machine, &field->condition, port->owner()))
22202220         {
22212221            UINT32 flags = 0;
22222222
r12023r12024
24702470   /* loop over input ports and add the items */
24712471   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
24722472      for (field = port->fieldlist().first(); field != NULL; field = field->next())
2473         if (input_type_is_analog(field->type) && input_condition_true(machine, &field->condition))
2473         if (input_type_is_analog(field->type) && input_condition_true(machine, &field->condition, port->owner()))
24742474         {
24752475            input_field_user_settings settings;
24762476            int use_autocenter = FALSE;
src/emu/inptport.c
r12023r12024
11151115
11161116   /* scan the list of settings looking for a match on the current value */
11171117   for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
1118      if (input_condition_true(field->machine(), &setting->condition))
1118      if (input_condition_true(field->machine(), &setting->condition, field->port().owner()))
11191119         if (setting->value == field->state->value)
11201120            return setting->name;
11211121
r12023r12024
11371137
11381138   /* scan the list of settings looking for a match on the current value */
11391139   for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
1140      if (input_condition_true(field->machine(), &setting->condition))
1140      if (input_condition_true(field->machine(), &setting->condition, field->port().owner()))
11411141         return (setting->value != field->state->value);
11421142
11431143   return FALSE;
r12023r12024
11611161   /* scan the list of settings looking for a match on the current value */
11621162   prevsetting = NULL;
11631163   for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
1164      if (input_condition_true(field->machine(), &setting->condition))
1164      if (input_condition_true(field->machine(), &setting->condition, field->port().owner()))
11651165      {
11661166         if (setting->value == field->state->value)
11671167         {
r12023r12024
11761176   if (!found_match)
11771177   {
11781178      for (prevsetting = field->settinglist().first(); prevsetting != NULL; prevsetting = prevsetting->next())
1179         if (input_condition_true(field->machine(), &prevsetting->condition))
1179         if (input_condition_true(field->machine(), &prevsetting->condition, field->port().owner()))
11801180            break;
11811181   }
11821182
r12023r12024
12011201
12021202   /* scan the list of settings looking for a match on the current value */
12031203   for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
1204      if (input_condition_true(field->machine(), &setting->condition))
1204      if (input_condition_true(field->machine(), &setting->condition, field->port().owner()))
12051205      {
12061206         if (found)
12071207            return TRUE;
r12023r12024
12291229   /* scan the list of settings looking for a match on the current value */
12301230   nextsetting = NULL;
12311231   for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
1232      if (input_condition_true(field->machine(), &setting->condition))
1232      if (input_condition_true(field->machine(), &setting->condition, field->port().owner()))
12331233         if (setting->value == field->state->value)
12341234            break;
12351235
12361236   /* if we found one, scan forward for the next valid one */
12371237   if (setting != NULL)
12381238      for (nextsetting = setting->next(); nextsetting != NULL; nextsetting = nextsetting->next())
1239         if (input_condition_true(field->machine(), &nextsetting->condition))
1239         if (input_condition_true(field->machine(), &nextsetting->condition, field->port().owner()))
12401240            break;
12411241
12421242   /* if we hit the end, search from the beginning */
12431243   if (nextsetting == NULL)
12441244      for (nextsetting = field->settinglist().first(); nextsetting != NULL; nextsetting = nextsetting->next())
1245         if (input_condition_true(field->machine(), &nextsetting->condition))
1245         if (input_condition_true(field->machine(), &nextsetting->condition, field->port().owner()))
12461246            break;
12471247
12481248   /* update the value to the previous one */
r12023r12024
14301430
14311431   /* update read values */
14321432   for (device_field = port->state->readdevicelist; device_field != NULL; device_field = device_field->next)
1433      if (input_condition_true(port->machine(), &device_field->field->condition))
1433      if (input_condition_true(port->machine(), &device_field->field->condition, port->owner()))
14341434      {
14351435         /* replace the bits with bits from the device */
14361436         input_port_value newval = device_field->field->read(*device_field->field, device_field->field->read_param);
r12023r12024
14521452
14531453   /* merge in analog portions */
14541454   for (analog = port->state->analoglist; analog != NULL; analog = analog->next)
1455      if (input_condition_true(port->machine(), &analog->field->condition))
1455      if (input_condition_true(port->machine(), &analog->field->condition, port->owner()))
14561456      {
14571457         /* start with the raw value */
14581458         INT32 value = analog->accum;
r12023r12024
15411541   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
15421542      for (field = port->first_field(); field != NULL; field = field->next())
15431543         if (field->player == player && field->crossaxis != CROSSHAIR_AXIS_NONE)
1544            if (input_condition_true(machine, &field->condition))
1544            if (input_condition_true(machine, &field->condition, port->owner()))
15451545            {
15461546               analog_field_state *analog = field->state->analog;
15471547               INT32 rawvalue = apply_analog_settings(analog->accum, analog) & (analog->field->mask >> analog->shift);
r12023r12024
16171617
16181618         /* first compute the default value for the entire port */
16191619         for (field = port->first_field(); field != NULL; field = field->next())
1620            if (input_condition_true(machine, &field->condition))
1620            if (input_condition_true(machine, &field->condition, port->owner()))
16211621               port->state->defvalue = (port->state->defvalue & ~field->mask) | (field->state->value & field->mask);
16221622      }
16231623   }
r12023r12024
16721672   COMBINE_DATA(&port->state->outputvalue);
16731673
16741674   for (device_field = port->state->writedevicelist; device_field; device_field = device_field->next)
1675      if (device_field->field->type == IPT_OUTPUT && input_condition_true(port->machine(), &device_field->field->condition))
1675      if (device_field->field->type == IPT_OUTPUT && input_condition_true(port->machine(), &device_field->field->condition, port->owner()))
16761676      {
16771677         input_port_value newval = ( (port->state->outputvalue ^ device_field->field->defvalue ) & device_field->field->mask) >> device_field->shift;
16781678
r12023r12024
17241724    if the given condition attached is true
17251725-------------------------------------------------*/
17261726
1727int input_condition_true(running_machine &machine, const input_condition *condition)
1727int input_condition_true(running_machine &machine, const input_condition *condition,device_t &owner)
17281728{
17291729   input_port_value condvalue;
17301730
r12023r12024
17331733      return TRUE;
17341734
17351735   /* otherwise, read the referenced port */
1736   condvalue = input_port_read(machine, condition->tag);
1736   astring conditiontag;
1737   owner.subtag(conditiontag, condition->tag);
1738   condvalue = input_port_read(machine, conditiontag.cstr());
17371739
17381740   /* based on the condition encoded, determine truth */
17391741   switch (condition->condition)
r12023r12024
24552457
24562458      /* now loop back and modify based on the inputs */
24572459      for (field = port->first_field(); field != NULL; field = field->next())
2458         if (input_condition_true(port->machine(), &field->condition))
2460         if (input_condition_true(port->machine(), &field->condition, port->owner()))
24592461         {
24602462            /* accumulate VBLANK bits */
24612463            if (field->type == IPT_VBLANK)
r12023r12024
24802482      /* call device line write handlers */
24812483      newvalue = input_port_read_direct(port);
24822484      for (device_field = port->state->writedevicelist; device_field; device_field = device_field->next)
2483         if (device_field->field->type != IPT_OUTPUT && input_condition_true(port->machine(), &device_field->field->condition))
2485         if (device_field->field->type != IPT_OUTPUT && input_condition_true(port->machine(), &device_field->field->condition, port->owner()))
24842486         {
24852487            input_port_value newval = (newvalue & device_field->field->mask) >> device_field->shift;
24862488
src/emu/inptport.h
r12023r12024
12421242/* ----- misc helper functions ----- */
12431243
12441244/* return the TRUE if the given condition attached is true */
1245int input_condition_true(running_machine &machine, const input_condition *condition);
1245int input_condition_true(running_machine &machine, const input_condition *condition,device_t &owner);
12461246
12471247/* convert an input_port_token to a default string */
12481248const char *input_port_string_from_token(const char *token);
src/emu/validity.c
r12023r12024
10381038         if (field->condition.tag != NULL)
10391039         {
10401040            /* find a matching port */
1041            for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next())
1042               if (strcmp(field->condition.tag, scanport->tag()) == 0)
1041            for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next()) {
1042               astring porttag;
1043               port->owner().subtag(porttag, field->condition.tag);
1044               if (strcmp(porttag.cstr(), scanport->tag()) == 0)
10431045                  break;
1044
1046            }
10451047            /* if none, error */
10461048            if (scanport == NULL)
10471049            {
r12023r12024
10551057            if (setting->condition.tag != NULL)
10561058            {
10571059               /* find a matching port */
1058               for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next())
1059                  if (strcmp(setting->condition.tag, scanport->tag()) == 0)
1060               for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next()) {
1061                  astring porttag;
1062                  port->owner().subtag(porttag, setting->condition.tag);                 
1063                  if (strcmp(porttag.cstr(), scanport->tag()) == 0)
10601064                     break;
1061
1065               }
10621066               /* if none, error */
10631067               if (scanport == NULL)
10641068               {

Previous 15994 Revisions Next


© 1998-2018 The MESS Team