From 47c3ba0bf1eb153cd5c267f7e0ae2388a51924e9 Mon Sep 17 00:00:00 2001 From: smf- Date: Mon, 11 Feb 2013 12:23:01 +0000 Subject: [PATCH] removed runtime ioport tagmap lookup when using PORT_CONDITION with PORT_BIT, used by gmgalax for example [smf] --- src/emu/ioport.c | 20 ++++++++++++++++++-- src/emu/ioport.h | 9 ++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/emu/ioport.c b/src/emu/ioport.c index 5a2b487f9a9..5c7ffee6071 100644 --- a/src/emu/ioport.c +++ b/src/emu/ioport.c @@ -1522,14 +1522,14 @@ astring natural_keyboard::dump() // eval - evaluate condition //------------------------------------------------- -bool ioport_condition::eval(device_t &device) const +bool ioport_condition::eval() const { // always condition is always true if (m_condition == ALWAYS) return true; // otherwise, read the referenced port and switch off the condition type - ioport_value condvalue = device.ioport(m_tag)->read(); + ioport_value condvalue = m_port->read(); switch (m_condition) { case ALWAYS: return true; @@ -1544,6 +1544,17 @@ bool ioport_condition::eval(device_t &device) const } +//------------------------------------------------- +// initialize - create the live state +//------------------------------------------------- + +void ioport_condition::initialize(device_t &device) +{ + if (m_tag != NULL) + m_port = device.ioport(m_tag); +} + + //************************************************************************** // I/O PORT SETTING @@ -2257,6 +2268,11 @@ void ioport_field::init_live_state(analog_field *analog) // allocate live state m_live = global_alloc(ioport_field_live(*this, analog)); + + m_condition.initialize(device()); + + for (ioport_setting *setting = first_setting(); setting != NULL; setting = setting->next()) + setting->condition().initialize(setting->device()); } diff --git a/src/emu/ioport.h b/src/emu/ioport.h index c9af4c6b0ea..d00d85cbcea 100644 --- a/src/emu/ioport.h +++ b/src/emu/ioport.h @@ -917,7 +917,7 @@ public: // operators 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); } - bool eval(device_t &device) const; + bool eval() const; bool none() const { return (m_condition == ALWAYS); } // configuration @@ -930,10 +930,13 @@ public: m_value = value; } + void initialize(device_t &device); + private: // internal state condition_t m_condition; // condition to use const char * m_tag; // tag of port whose condition is to be tested + ioport_port * m_port; // reference to the port to be tested ioport_value m_mask; // mask to apply to the port ioport_value m_value; // value to compare against }; @@ -961,7 +964,7 @@ public: const char *name() const { return m_name; } // helpers - bool enabled() { return m_condition.eval(device()); } + bool enabled() { return m_condition.eval(); } private: // internal state @@ -1084,7 +1087,7 @@ public: bool is_digital_joystick() const { return (m_type > IPT_DIGITAL_JOYSTICK_FIRST && m_type < IPT_DIGITAL_JOYSTICK_LAST); } // additional operations - bool enabled() const { return m_condition.eval(device()); } + bool enabled() const { return m_condition.eval(); } const char *setting_name() const; bool has_previous_setting() const; void select_previous_setting();