mirror of
https://github.com/holub/mame
synced 2025-04-20 23:42:22 +03:00
reduce tagmap lookups (nw)
This commit is contained in:
parent
79c45ea383
commit
4936d59546
@ -1917,13 +1917,12 @@ void ioport_field::frame_update(ioport_value &result, bool mouse_down)
|
||||
|
||||
// coin impulse option
|
||||
int effective_impulse = m_impulse;
|
||||
int impulse_option_val = machine().options().coin_impulse();
|
||||
if (impulse_option_val != 0)
|
||||
if (m_impulse_option_val != 0)
|
||||
{
|
||||
if (impulse_option_val < 0)
|
||||
if (m_impulse_option_val < 0)
|
||||
effective_impulse = 0;
|
||||
else if ((m_type >= IPT_COIN1 && m_type <= IPT_COIN12) || m_impulse != 0)
|
||||
effective_impulse = impulse_option_val;
|
||||
effective_impulse = m_impulse_option_val;
|
||||
}
|
||||
|
||||
// if this is a switch-down event, handle impulse and toggle
|
||||
@ -2137,6 +2136,8 @@ void ioport_field::init_live_state(analog_field *analog)
|
||||
|
||||
for (ioport_setting *setting = first_setting(); setting != NULL; setting = setting->next())
|
||||
setting->condition().initialize(setting->device());
|
||||
|
||||
m_impulse_option_val = machine().options().coin_impulse();
|
||||
}
|
||||
|
||||
|
||||
@ -2902,12 +2903,11 @@ g_profiler.start(PROFILER_INPUT);
|
||||
ioport_field *mouse_field = NULL;
|
||||
if (mouse_button && mouse_target != NULL)
|
||||
{
|
||||
const char *tag = NULL;
|
||||
ioport_port *port = NULL;
|
||||
ioport_value mask;
|
||||
float x, y;
|
||||
if (mouse_target->map_point_input(mouse_target_x, mouse_target_y, tag, mask, x, y))
|
||||
if (mouse_target->map_point_input(mouse_target_x, mouse_target_y, port, mask, x, y))
|
||||
{
|
||||
ioport_port *port = machine().root_device().ioport(tag);
|
||||
if (port != NULL)
|
||||
mouse_field = port->field(mask);
|
||||
}
|
||||
|
@ -1117,6 +1117,7 @@ private:
|
||||
void * m_read_param; // parameter for read callback routine
|
||||
ioport_field_write_delegate m_write; // write callback routine
|
||||
void * m_write_param; // parameter for write callback routine
|
||||
int m_impulse_option_val; // impulse setting from options
|
||||
|
||||
// data relevant to digital control types
|
||||
bool m_digital_value; // externally set value
|
||||
|
@ -275,6 +275,8 @@ void running_machine::start()
|
||||
if ((debug_flags & DEBUG_FLAG_ENABLED) != 0)
|
||||
debugger_init(*this);
|
||||
|
||||
m_render->resolve_tags();
|
||||
|
||||
// call the game driver's init function
|
||||
// this is where decryption is done and memory maps are altered
|
||||
// so this location in the init order is important
|
||||
|
@ -1394,9 +1394,9 @@ render_primitive_list &render_target::get_primitives()
|
||||
|
||||
bool render_target::map_point_container(INT32 target_x, INT32 target_y, render_container &container, float &container_x, float &container_y)
|
||||
{
|
||||
const char *input_tag;
|
||||
ioport_port *input_port;
|
||||
ioport_value input_mask;
|
||||
return map_point_internal(target_x, target_y, &container, container_x, container_y, input_tag, input_mask);
|
||||
return map_point_internal(target_x, target_y, &container, container_x, container_y, input_port, input_mask);
|
||||
}
|
||||
|
||||
|
||||
@ -1406,9 +1406,9 @@ bool render_target::map_point_container(INT32 target_x, INT32 target_y, render_c
|
||||
// container, if possible
|
||||
//-------------------------------------------------
|
||||
|
||||
bool 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)
|
||||
bool 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)
|
||||
{
|
||||
return map_point_internal(target_x, target_y, NULL, input_x, input_y, input_tag, input_mask);
|
||||
return map_point_internal(target_x, target_y, NULL, input_x, input_y, input_port, input_mask);;
|
||||
}
|
||||
|
||||
|
||||
@ -1466,6 +1466,22 @@ void render_target::debug_top(render_container &container)
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// resolve_tags - resolve tag lookups
|
||||
//-------------------------------------------------
|
||||
|
||||
void render_target::resolve_tags()
|
||||
{
|
||||
for (layout_file *file = m_filelist.first(); file != NULL; file = file->next())
|
||||
{
|
||||
for (layout_view *view = file->first_view(); view != NULL; view = view->next())
|
||||
{
|
||||
view->resolve_tags();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// update_layer_config - recompute after a layer
|
||||
// config change
|
||||
@ -1861,7 +1877,7 @@ void render_target::add_element_primitives(render_primitive_list &list, const ob
|
||||
// mapping points
|
||||
//-------------------------------------------------
|
||||
|
||||
bool 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)
|
||||
bool 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)
|
||||
{
|
||||
// compute the visible width/height
|
||||
INT32 viswidth, visheight;
|
||||
@ -1875,7 +1891,7 @@ bool render_target::map_point_internal(INT32 target_x, INT32 target_y, render_co
|
||||
// default to point not mapped
|
||||
mapped_x = -1.0;
|
||||
mapped_y = -1.0;
|
||||
mapped_input_tag = NULL;
|
||||
mapped_input_port = NULL;
|
||||
mapped_input_mask = 0;
|
||||
|
||||
// convert target coordinates to float
|
||||
@ -1926,7 +1942,7 @@ bool render_target::map_point_internal(INT32 target_x, INT32 target_y, render_co
|
||||
// point successfully mapped
|
||||
mapped_x = (target_fx - item->bounds().x0) / (item->bounds().x1 - item->bounds().x0);
|
||||
mapped_y = (target_fy - item->bounds().y0) / (item->bounds().y1 - item->bounds().y0);
|
||||
mapped_input_tag = item->input_tag_and_mask(mapped_input_mask);
|
||||
mapped_input_port = item->input_tag_and_mask(mapped_input_mask);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -2588,6 +2604,19 @@ void render_manager::invalidate_all(void *refptr)
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// resolve_tags - resolve tag lookups
|
||||
//-------------------------------------------------
|
||||
|
||||
void render_manager::resolve_tags()
|
||||
{
|
||||
for (render_target *target = m_targetlist.first(); target != NULL; target = target->next())
|
||||
{
|
||||
target->resolve_tags();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// container_alloc - allocate a new container
|
||||
//-------------------------------------------------
|
||||
|
@ -651,7 +651,7 @@ public:
|
||||
|
||||
// hit testing
|
||||
bool map_point_container(INT32 target_x, INT32 target_y, render_container &container, float &container_x, float &container_y);
|
||||
bool map_point_input(INT32 target_x, INT32 target_y, const char *&input_tag, ioport_value &input_mask, float &input_x, float &input_y);
|
||||
bool map_point_input(INT32 target_x, INT32 target_y, ioport_port *&input_port, ioport_value &input_mask, float &input_x, float &input_y);
|
||||
|
||||
// reference tracking
|
||||
void invalidate_all(void *refptr);
|
||||
@ -661,6 +661,9 @@ public:
|
||||
void debug_free(render_container &container);
|
||||
void debug_top(render_container &container);
|
||||
|
||||
// resolve tag lookups
|
||||
void resolve_tags();
|
||||
|
||||
private:
|
||||
// internal helpers
|
||||
void update_layer_config();
|
||||
@ -668,7 +671,7 @@ private:
|
||||
bool load_layout_file(const char *dirname, const char *filename);
|
||||
void add_container_primitives(render_primitive_list &list, const object_transform &xform, render_container &container, int blendmode);
|
||||
void add_element_primitives(render_primitive_list &list, const object_transform &xform, layout_element &element, int state, int blendmode);
|
||||
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);
|
||||
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);
|
||||
|
||||
// config callbacks
|
||||
void config_load(xml_data_node &targetnode);
|
||||
@ -760,6 +763,9 @@ public:
|
||||
// reference tracking
|
||||
void invalidate_all(void *refptr);
|
||||
|
||||
// resolve tag lookups
|
||||
void resolve_tags();
|
||||
|
||||
private:
|
||||
// containers
|
||||
render_container *container_alloc(screen_device *screen = NULL);
|
||||
|
@ -2304,6 +2304,22 @@ void layout_view::recompute(render_layer_config layerconfig)
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------
|
||||
// resolve_tags - resolve tags
|
||||
//-----------------------------
|
||||
|
||||
void layout_view::resolve_tags()
|
||||
{
|
||||
for (item_layer layer = ITEM_LAYER_FIRST; layer < ITEM_LAYER_MAX; layer++)
|
||||
{
|
||||
for (item *curitem = first_item(layer); curitem != NULL; curitem = curitem->next())
|
||||
{
|
||||
curitem->resolve_tags();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LAYOUT VIEW ITEM
|
||||
@ -2316,6 +2332,7 @@ void layout_view::recompute(render_layer_config layerconfig)
|
||||
layout_view::item::item(running_machine &machine, xml_data_node &itemnode, simple_list<layout_element> &elemlist)
|
||||
: m_next(NULL),
|
||||
m_element(NULL),
|
||||
m_input_port(NULL),
|
||||
m_input_mask(0),
|
||||
m_screen(NULL),
|
||||
m_orientation(ROT0)
|
||||
@ -2365,6 +2382,11 @@ layout_view::item::item(running_machine &machine, xml_data_node &itemnode, simpl
|
||||
if (m_element == NULL)
|
||||
throw emu_fatalerror("Layout item of type %s require an element tag", itemnode.name);
|
||||
}
|
||||
|
||||
if (has_input())
|
||||
{
|
||||
m_input_port = m_element->machine().root_device().ioport(m_input_tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2387,6 +2409,7 @@ render_container *layout_view::item::screen_container(running_machine &machine)
|
||||
return (m_screen != NULL) ? &m_screen->container() : NULL;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// state - fetch state based on configured source
|
||||
//-------------------------------------------------
|
||||
@ -2404,18 +2427,31 @@ int layout_view::item::state() const
|
||||
// if configured to an input, fetch the input value
|
||||
else if (m_input_tag[0] != 0)
|
||||
{
|
||||
ioport_port *port = m_element->machine().root_device().ioport(m_input_tag.c_str());
|
||||
if (port != NULL)
|
||||
if (m_input_port != NULL)
|
||||
{
|
||||
ioport_field *field = port->field(m_input_mask);
|
||||
ioport_field *field = m_input_port->field(m_input_mask);
|
||||
if (field != NULL)
|
||||
state = ((port->read() ^ field->defvalue()) & m_input_mask) ? 1 : 0;
|
||||
state = ((m_input_port->read() ^ field->defvalue()) & m_input_mask) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------
|
||||
// resolve_tags - resolve tags, if any are set
|
||||
//---------------------------------------------
|
||||
|
||||
|
||||
void layout_view::item::resolve_tags()
|
||||
{
|
||||
if (has_input())
|
||||
{
|
||||
m_input_port = m_element->machine().root_device().ioport(m_input_tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LAYOUT FILE
|
||||
|
@ -208,17 +208,21 @@ public:
|
||||
int orientation() const { return m_orientation; }
|
||||
render_container *screen_container(running_machine &machine) const;
|
||||
bool has_input() const { return !m_input_tag.empty(); }
|
||||
const char *input_tag_and_mask(ioport_value &mask) const { mask = m_input_mask; return m_input_tag.c_str(); }
|
||||
ioport_port *input_tag_and_mask(ioport_value &mask) const { mask = m_input_mask; return m_input_port; };
|
||||
|
||||
// fetch state based on configured source
|
||||
int state() const;
|
||||
|
||||
// resolve tags, if any
|
||||
void resolve_tags();
|
||||
|
||||
private:
|
||||
// internal state
|
||||
item * m_next; // link to next item
|
||||
layout_element * m_element; // pointer to the associated element (non-screens only)
|
||||
std::string m_output_name; // name of this item
|
||||
std::string m_input_tag; // input tag of this item
|
||||
ioport_port * m_input_port; // input port of this item
|
||||
ioport_value m_input_mask; // input mask of this item
|
||||
screen_device * m_screen; // pointer to screen
|
||||
int m_orientation; // orientation of this item
|
||||
@ -245,6 +249,9 @@ public:
|
||||
// operations
|
||||
void recompute(render_layer_config layerconfig);
|
||||
|
||||
// resolve tags, if any
|
||||
void resolve_tags();
|
||||
|
||||
private:
|
||||
// internal state
|
||||
layout_view * m_next; // pointer to next layout in the list
|
||||
|
Loading…
Reference in New Issue
Block a user