Previous 199869 Revisions Next

r40091 Friday 31st July, 2015 at 21:21:22 UTC by Wilbert Pol
reduce tagmap lookups (nw)
[src/emu]ioport.c ioport.h machine.c render.c render.h rendlay.c rendlay.h

trunk/src/emu/ioport.c
r248602r248603
19171917
19181918   // coin impulse option
19191919   int effective_impulse = m_impulse;
1920   int impulse_option_val = machine().options().coin_impulse();
1921   if (impulse_option_val != 0)
1920   if (m_impulse_option_val != 0)
19221921   {
1923      if (impulse_option_val < 0)
1922      if (m_impulse_option_val < 0)
19241923         effective_impulse = 0;
19251924      else if ((m_type >= IPT_COIN1 && m_type <= IPT_COIN12) || m_impulse != 0)
1926         effective_impulse = impulse_option_val;
1925         effective_impulse = m_impulse_option_val;
19271926   }
19281927
19291928   // if this is a switch-down event, handle impulse and toggle
r248602r248603
21372136
21382137   for (ioport_setting *setting = first_setting(); setting != NULL; setting = setting->next())
21392138      setting->condition().initialize(setting->device());
2139
2140   m_impulse_option_val = machine().options().coin_impulse();
21402141}
21412142
21422143
r248602r248603
29022903   ioport_field *mouse_field = NULL;
29032904   if (mouse_button && mouse_target != NULL)
29042905   {
2905      const char *tag = NULL;
2906      ioport_port *port = NULL;
29062907      ioport_value mask;
29072908      float x, y;
2908      if (mouse_target->map_point_input(mouse_target_x, mouse_target_y, tag, mask, x, y))
2909      if (mouse_target->map_point_input(mouse_target_x, mouse_target_y, port, mask, x, y))
29092910      {
2910         ioport_port *port = machine().root_device().ioport(tag);
29112911         if (port != NULL)
29122912            mouse_field = port->field(mask);
29132913      }
trunk/src/emu/ioport.h
r248602r248603
11171117   void *                      m_read_param;       // parameter for read callback routine
11181118   ioport_field_write_delegate m_write;            // write callback routine
11191119   void *                      m_write_param;      // parameter for write callback routine
1120   int                         m_impulse_option_val; // impulse setting from options
11201121
11211122   // data relevant to digital control types
11221123   bool                        m_digital_value;    // externally set value
trunk/src/emu/machine.c
r248602r248603
275275   if ((debug_flags & DEBUG_FLAG_ENABLED) != 0)
276276      debugger_init(*this);
277277
278   m_render->resolve_tags();
279
278280   // call the game driver's init function
279281   // this is where decryption is done and memory maps are altered
280282   // so this location in the init order is important
trunk/src/emu/render.c
r248602r248603
13941394
13951395bool render_target::map_point_container(INT32 target_x, INT32 target_y, render_container &container, float &container_x, float &container_y)
13961396{
1397   const char *input_tag;
1397   ioport_port *input_port;
13981398   ioport_value input_mask;
1399   return map_point_internal(target_x, target_y, &container, container_x, container_y, input_tag, input_mask);
1399   return map_point_internal(target_x, target_y, &container, container_x, container_y, input_port, input_mask);
14001400}
14011401
14021402
r248602r248603
14061406//  container, if possible
14071407//-------------------------------------------------
14081408
1409bool render_target::map_point_input(INT32 target_x, INT32 target_y, const char *&input_tag, ioport_value &input_mask, float &input_x, float &input_y)
1409bool render_target::map_point_input(INT32 target_x, INT32 target_y, ioport_port *&input_port, ioport_value &input_mask, float &input_x, float &input_y)
14101410{
1411   return map_point_internal(target_x, target_y, NULL, input_x, input_y, input_tag, input_mask);
1411   return map_point_internal(target_x, target_y, NULL, input_x, input_y, input_port, input_mask);;
14121412}
14131413
14141414
r248602r248603
14671467
14681468
14691469//-------------------------------------------------
1470//  resolve_tags - resolve tag lookups
1471//-------------------------------------------------
1472
1473void render_target::resolve_tags()
1474{
1475   for (layout_file *file = m_filelist.first(); file != NULL; file = file->next())
1476   {
1477      for (layout_view *view = file->first_view(); view != NULL; view = view->next())
1478      {
1479         view->resolve_tags();
1480      }
1481   }
1482}
1483
1484
1485//-------------------------------------------------
14701486//  update_layer_config - recompute after a layer
14711487//  config change
14721488//-------------------------------------------------
r248602r248603
18611877//  mapping points
18621878//-------------------------------------------------
18631879
1864bool render_target::map_point_internal(INT32 target_x, INT32 target_y, render_container *container, float &mapped_x, float &mapped_y, const char *&mapped_input_tag, ioport_value &mapped_input_mask)
1880bool render_target::map_point_internal(INT32 target_x, INT32 target_y, render_container *container, float &mapped_x, float &mapped_y, ioport_port *&mapped_input_port, ioport_value &mapped_input_mask)
18651881{
18661882   // compute the visible width/height
18671883   INT32 viswidth, visheight;
r248602r248603
18751891   // default to point not mapped
18761892   mapped_x = -1.0;
18771893   mapped_y = -1.0;
1878   mapped_input_tag = NULL;
1894   mapped_input_port = NULL;
18791895   mapped_input_mask = 0;
18801896
18811897   // convert target coordinates to float
r248602r248603
19261942               // point successfully mapped
19271943               mapped_x = (target_fx - item->bounds().x0) / (item->bounds().x1 - item->bounds().x0);
19281944               mapped_y = (target_fy - item->bounds().y0) / (item->bounds().y1 - item->bounds().y0);
1929               mapped_input_tag = item->input_tag_and_mask(mapped_input_mask);
1945               mapped_input_port = item->input_tag_and_mask(mapped_input_mask);
19301946               return true;
19311947            }
19321948         }
r248602r248603
25892605
25902606
25912607//-------------------------------------------------
2608//  resolve_tags - resolve tag lookups
2609//-------------------------------------------------
2610
2611void render_manager::resolve_tags()
2612{
2613   for (render_target *target = m_targetlist.first(); target != NULL; target = target->next())
2614   {
2615      target->resolve_tags();
2616   }
2617}
2618
2619
2620//-------------------------------------------------
25922621//  container_alloc - allocate a new container
25932622//-------------------------------------------------
25942623
trunk/src/emu/render.h
r248602r248603
651651
652652   // hit testing
653653   bool map_point_container(INT32 target_x, INT32 target_y, render_container &container, float &container_x, float &container_y);
654   bool map_point_input(INT32 target_x, INT32 target_y, const char *&input_tag, ioport_value &input_mask, float &input_x, float &input_y);
654   bool map_point_input(INT32 target_x, INT32 target_y, ioport_port *&input_port, ioport_value &input_mask, float &input_x, float &input_y);
655655
656656   // reference tracking
657657   void invalidate_all(void *refptr);
r248602r248603
661661   void debug_free(render_container &container);
662662   void debug_top(render_container &container);
663663
664   // resolve tag lookups
665   void resolve_tags();
666
664667private:
665668   // internal helpers
666669   void update_layer_config();
r248602r248603
668671   bool load_layout_file(const char *dirname, const char *filename);
669672   void add_container_primitives(render_primitive_list &list, const object_transform &xform, render_container &container, int blendmode);
670673   void add_element_primitives(render_primitive_list &list, const object_transform &xform, layout_element &element, int state, int blendmode);
671   bool map_point_internal(INT32 target_x, INT32 target_y, render_container *container, float &mapped_x, float &mapped_y, const char *&mapped_input_tag, ioport_value &mapped_input_mask);
674   bool map_point_internal(INT32 target_x, INT32 target_y, render_container *container, float &mapped_x, float &mapped_y, ioport_port *&mapped_input_port, ioport_value &mapped_input_mask);
672675
673676   // config callbacks
674677   void config_load(xml_data_node &targetnode);
r248602r248603
760763   // reference tracking
761764   void invalidate_all(void *refptr);
762765
766   // resolve tag lookups
767   void resolve_tags();
768
763769private:
764770   // containers
765771   render_container *container_alloc(screen_device *screen = NULL);
trunk/src/emu/rendlay.c
r248602r248603
23042304}
23052305
23062306
2307//-----------------------------
2308//  resolve_tags - resolve tags
2309//-----------------------------
23072310
2311void layout_view::resolve_tags()
2312{
2313   for (item_layer layer = ITEM_LAYER_FIRST; layer < ITEM_LAYER_MAX; layer++)
2314   {
2315      for (item *curitem = first_item(layer); curitem != NULL; curitem = curitem->next())
2316      {
2317         curitem->resolve_tags();
2318      }
2319   }
2320}
2321
2322
2323
23082324//**************************************************************************
23092325//  LAYOUT VIEW ITEM
23102326//**************************************************************************
r248602r248603
23162332layout_view::item::item(running_machine &machine, xml_data_node &itemnode, simple_list<layout_element> &elemlist)
23172333   : m_next(NULL),
23182334      m_element(NULL),
2335      m_input_port(NULL),
23192336      m_input_mask(0),
23202337      m_screen(NULL),
23212338      m_orientation(ROT0)
r248602r248603
23652382      if (m_element == NULL)
23662383         throw emu_fatalerror("Layout item of type %s require an element tag", itemnode.name);
23672384   }
2385
2386   if (has_input())
2387   {
2388      m_input_port = m_element->machine().root_device().ioport(m_input_tag.c_str());
2389   }
23682390}
23692391
23702392
r248602r248603
23872409   return (m_screen != NULL) ? &m_screen->container() : NULL;
23882410}
23892411
2412
23902413//-------------------------------------------------
23912414//  state - fetch state based on configured source
23922415//-------------------------------------------------
r248602r248603
24042427   // if configured to an input, fetch the input value
24052428   else if (m_input_tag[0] != 0)
24062429   {
2407      ioport_port *port = m_element->machine().root_device().ioport(m_input_tag.c_str());
2408      if (port != NULL)
2430      if (m_input_port != NULL)
24092431      {
2410         ioport_field *field = port->field(m_input_mask);
2432         ioport_field *field = m_input_port->field(m_input_mask);
24112433         if (field != NULL)
2412            state = ((port->read() ^ field->defvalue()) & m_input_mask) ? 1 : 0;
2434            state = ((m_input_port->read() ^ field->defvalue()) & m_input_mask) ? 1 : 0;
24132435      }
24142436   }
24152437   return state;
24162438}
24172439
24182440
2441//---------------------------------------------
2442//  resolve_tags - resolve tags, if any are set
2443//---------------------------------------------
24192444
2445
2446void layout_view::item::resolve_tags()
2447{
2448   if (has_input())
2449   {
2450      m_input_port = m_element->machine().root_device().ioport(m_input_tag.c_str());
2451   }
2452}
2453
2454
2455
24202456//**************************************************************************
24212457//  LAYOUT FILE
24222458//**************************************************************************
trunk/src/emu/rendlay.h
r248602r248603
208208      int orientation() const { return m_orientation; }
209209      render_container *screen_container(running_machine &machine) const;
210210      bool has_input() const { return !m_input_tag.empty(); }
211      const char *input_tag_and_mask(ioport_value &mask) const { mask = m_input_mask; return m_input_tag.c_str(); }
211      ioport_port *input_tag_and_mask(ioport_value &mask) const { mask = m_input_mask; return m_input_port; };
212212
213213      // fetch state based on configured source
214214      int state() const;
215215
216      // resolve tags, if any
217      void resolve_tags();
218
216219   private:
217220      // internal state
218221      item *              m_next;             // link to next item
219222      layout_element *    m_element;          // pointer to the associated element (non-screens only)
220223      std::string         m_output_name;      // name of this item
221224      std::string         m_input_tag;        // input tag of this item
225      ioport_port *       m_input_port;       // input port of this item
222226      ioport_value        m_input_mask;       // input mask of this item
223227      screen_device *     m_screen;           // pointer to screen
224228      int                 m_orientation;      // orientation of this item
r248602r248603
245249   // operations
246250   void recompute(render_layer_config layerconfig);
247251
252   // resolve tags, if any
253   void resolve_tags();
254
248255private:
249256   // internal state
250257   layout_view *       m_next;             // pointer to next layout in the list


Previous 199869 Revisions Next


© 1997-2024 The MAME Team