Previous 199869 Revisions Next

r20935 Monday 11th February, 2013 at 12:23:01 UTC by smf
removed runtime ioport tagmap lookup when using PORT_CONDITION with PORT_BIT, used by gmgalax for example [smf]
[src/emu]ioport.c ioport.h

trunk/src/emu/ioport.c
r20934r20935
15221522//  eval - evaluate condition
15231523//-------------------------------------------------
15241524
1525bool ioport_condition::eval(device_t &device) const
1525bool ioport_condition::eval() const
15261526{
15271527   // always condition is always true
15281528   if (m_condition == ALWAYS)
15291529      return true;
15301530
15311531   // otherwise, read the referenced port and switch off the condition type
1532   ioport_value condvalue = device.ioport(m_tag)->read();
1532   ioport_value condvalue = m_port->read();
15331533   switch (m_condition)
15341534   {
15351535      case ALWAYS:            return true;
r20934r20935
15441544}
15451545
15461546
1547//-------------------------------------------------
1548//  initialize - create the live state
1549//-------------------------------------------------
15471550
1551void ioport_condition::initialize(device_t &device)
1552{
1553   if (m_tag != NULL)
1554      m_port = device.ioport(m_tag);
1555}
1556
1557
1558
15481559//**************************************************************************
15491560//  I/O PORT SETTING
15501561//**************************************************************************
r20934r20935
22572268
22582269   // allocate live state
22592270   m_live = global_alloc(ioport_field_live(*this, analog));
2271
2272   m_condition.initialize(device());
2273
2274   for (ioport_setting *setting = first_setting(); setting != NULL; setting = setting->next())
2275      setting->condition().initialize(setting->device());
22602276}
22612277
22622278
trunk/src/emu/ioport.h
r20934r20935
917917
918918   // operators
919919   bool operator==(const ioport_condition &rhs) const { return (m_mask == rhs.m_mask && m_value == rhs.m_value && m_condition == rhs.m_condition && strcmp(m_tag, rhs.m_tag) == 0); }
920   bool eval(device_t &device) const;
920   bool eval() const;
921921   bool none() const { return (m_condition == ALWAYS); }
922922
923923   // configuration
r20934r20935
930930      m_value = value;
931931   }
932932
933   void initialize(device_t &device);
934
933935private:
934936   // internal state
935937   condition_t     m_condition;    // condition to use
936938   const char *    m_tag;          // tag of port whose condition is to be tested
939   ioport_port *   m_port;         // reference to the port to be tested
937940   ioport_value    m_mask;         // mask to apply to the port
938941   ioport_value    m_value;        // value to compare against
939942};
r20934r20935
961964   const char *name() const { return m_name; }
962965
963966   // helpers
964   bool enabled() { return m_condition.eval(device()); }
967   bool enabled() { return m_condition.eval(); }
965968
966969private:
967970   // internal state
r20934r20935
10841087   bool is_digital_joystick() const { return (m_type > IPT_DIGITAL_JOYSTICK_FIRST && m_type < IPT_DIGITAL_JOYSTICK_LAST); }
10851088
10861089   // additional operations
1087   bool enabled() const { return m_condition.eval(device()); }
1090   bool enabled() const { return m_condition.eval(); }
10881091   const char *setting_name() const;
10891092   bool has_previous_setting() const;
10901093   void select_previous_setting();

Previous 199869 Revisions Next


© 1997-2024 The MAME Team