trunk/src/emu/ioport.c
| r248602 | r248603 | |
| 1917 | 1917 | |
| 1918 | 1918 | // coin impulse option |
| 1919 | 1919 | 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) |
| 1922 | 1921 | { |
| 1923 | | if (impulse_option_val < 0) |
| 1922 | if (m_impulse_option_val < 0) |
| 1924 | 1923 | effective_impulse = 0; |
| 1925 | 1924 | 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; |
| 1927 | 1926 | } |
| 1928 | 1927 | |
| 1929 | 1928 | // if this is a switch-down event, handle impulse and toggle |
| r248602 | r248603 | |
| 2137 | 2136 | |
| 2138 | 2137 | for (ioport_setting *setting = first_setting(); setting != NULL; setting = setting->next()) |
| 2139 | 2138 | setting->condition().initialize(setting->device()); |
| 2139 | |
| 2140 | m_impulse_option_val = machine().options().coin_impulse(); |
| 2140 | 2141 | } |
| 2141 | 2142 | |
| 2142 | 2143 | |
| r248602 | r248603 | |
| 2902 | 2903 | ioport_field *mouse_field = NULL; |
| 2903 | 2904 | if (mouse_button && mouse_target != NULL) |
| 2904 | 2905 | { |
| 2905 | | const char *tag = NULL; |
| 2906 | ioport_port *port = NULL; |
| 2906 | 2907 | ioport_value mask; |
| 2907 | 2908 | 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)) |
| 2909 | 2910 | { |
| 2910 | | ioport_port *port = machine().root_device().ioport(tag); |
| 2911 | 2911 | if (port != NULL) |
| 2912 | 2912 | mouse_field = port->field(mask); |
| 2913 | 2913 | } |
trunk/src/emu/render.c
| r248602 | r248603 | |
| 1394 | 1394 | |
| 1395 | 1395 | bool render_target::map_point_container(INT32 target_x, INT32 target_y, render_container &container, float &container_x, float &container_y) |
| 1396 | 1396 | { |
| 1397 | | const char *input_tag; |
| 1397 | ioport_port *input_port; |
| 1398 | 1398 | 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); |
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | 1402 | |
| r248602 | r248603 | |
| 1406 | 1406 | // container, if possible |
| 1407 | 1407 | //------------------------------------------------- |
| 1408 | 1408 | |
| 1409 | | 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) |
| 1409 | 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) |
| 1410 | 1410 | { |
| 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);; |
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | 1414 | |
| r248602 | r248603 | |
| 1467 | 1467 | |
| 1468 | 1468 | |
| 1469 | 1469 | //------------------------------------------------- |
| 1470 | // resolve_tags - resolve tag lookups |
| 1471 | //------------------------------------------------- |
| 1472 | |
| 1473 | void 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 | //------------------------------------------------- |
| 1470 | 1486 | // update_layer_config - recompute after a layer |
| 1471 | 1487 | // config change |
| 1472 | 1488 | //------------------------------------------------- |
| r248602 | r248603 | |
| 1861 | 1877 | // mapping points |
| 1862 | 1878 | //------------------------------------------------- |
| 1863 | 1879 | |
| 1864 | | 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) |
| 1880 | 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) |
| 1865 | 1881 | { |
| 1866 | 1882 | // compute the visible width/height |
| 1867 | 1883 | INT32 viswidth, visheight; |
| r248602 | r248603 | |
| 1875 | 1891 | // default to point not mapped |
| 1876 | 1892 | mapped_x = -1.0; |
| 1877 | 1893 | mapped_y = -1.0; |
| 1878 | | mapped_input_tag = NULL; |
| 1894 | mapped_input_port = NULL; |
| 1879 | 1895 | mapped_input_mask = 0; |
| 1880 | 1896 | |
| 1881 | 1897 | // convert target coordinates to float |
| r248602 | r248603 | |
| 1926 | 1942 | // point successfully mapped |
| 1927 | 1943 | mapped_x = (target_fx - item->bounds().x0) / (item->bounds().x1 - item->bounds().x0); |
| 1928 | 1944 | 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); |
| 1930 | 1946 | return true; |
| 1931 | 1947 | } |
| 1932 | 1948 | } |
| r248602 | r248603 | |
| 2589 | 2605 | |
| 2590 | 2606 | |
| 2591 | 2607 | //------------------------------------------------- |
| 2608 | // resolve_tags - resolve tag lookups |
| 2609 | //------------------------------------------------- |
| 2610 | |
| 2611 | void 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 | //------------------------------------------------- |
| 2592 | 2621 | // container_alloc - allocate a new container |
| 2593 | 2622 | //------------------------------------------------- |
| 2594 | 2623 | |
trunk/src/emu/render.h
| r248602 | r248603 | |
| 651 | 651 | |
| 652 | 652 | // hit testing |
| 653 | 653 | 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); |
| 655 | 655 | |
| 656 | 656 | // reference tracking |
| 657 | 657 | void invalidate_all(void *refptr); |
| r248602 | r248603 | |
| 661 | 661 | void debug_free(render_container &container); |
| 662 | 662 | void debug_top(render_container &container); |
| 663 | 663 | |
| 664 | // resolve tag lookups |
| 665 | void resolve_tags(); |
| 666 | |
| 664 | 667 | private: |
| 665 | 668 | // internal helpers |
| 666 | 669 | void update_layer_config(); |
| r248602 | r248603 | |
| 668 | 671 | bool load_layout_file(const char *dirname, const char *filename); |
| 669 | 672 | void add_container_primitives(render_primitive_list &list, const object_transform &xform, render_container &container, int blendmode); |
| 670 | 673 | 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); |
| 672 | 675 | |
| 673 | 676 | // config callbacks |
| 674 | 677 | void config_load(xml_data_node &targetnode); |
| r248602 | r248603 | |
| 760 | 763 | // reference tracking |
| 761 | 764 | void invalidate_all(void *refptr); |
| 762 | 765 | |
| 766 | // resolve tag lookups |
| 767 | void resolve_tags(); |
| 768 | |
| 763 | 769 | private: |
| 764 | 770 | // containers |
| 765 | 771 | render_container *container_alloc(screen_device *screen = NULL); |
trunk/src/emu/rendlay.c
| r248602 | r248603 | |
| 2304 | 2304 | } |
| 2305 | 2305 | |
| 2306 | 2306 | |
| 2307 | //----------------------------- |
| 2308 | // resolve_tags - resolve tags |
| 2309 | //----------------------------- |
| 2307 | 2310 | |
| 2311 | void 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 | |
| 2308 | 2324 | //************************************************************************** |
| 2309 | 2325 | // LAYOUT VIEW ITEM |
| 2310 | 2326 | //************************************************************************** |
| r248602 | r248603 | |
| 2316 | 2332 | layout_view::item::item(running_machine &machine, xml_data_node &itemnode, simple_list<layout_element> &elemlist) |
| 2317 | 2333 | : m_next(NULL), |
| 2318 | 2334 | m_element(NULL), |
| 2335 | m_input_port(NULL), |
| 2319 | 2336 | m_input_mask(0), |
| 2320 | 2337 | m_screen(NULL), |
| 2321 | 2338 | m_orientation(ROT0) |
| r248602 | r248603 | |
| 2365 | 2382 | if (m_element == NULL) |
| 2366 | 2383 | throw emu_fatalerror("Layout item of type %s require an element tag", itemnode.name); |
| 2367 | 2384 | } |
| 2385 | |
| 2386 | if (has_input()) |
| 2387 | { |
| 2388 | m_input_port = m_element->machine().root_device().ioport(m_input_tag.c_str()); |
| 2389 | } |
| 2368 | 2390 | } |
| 2369 | 2391 | |
| 2370 | 2392 | |
| r248602 | r248603 | |
| 2387 | 2409 | return (m_screen != NULL) ? &m_screen->container() : NULL; |
| 2388 | 2410 | } |
| 2389 | 2411 | |
| 2412 | |
| 2390 | 2413 | //------------------------------------------------- |
| 2391 | 2414 | // state - fetch state based on configured source |
| 2392 | 2415 | //------------------------------------------------- |
| r248602 | r248603 | |
| 2404 | 2427 | // if configured to an input, fetch the input value |
| 2405 | 2428 | else if (m_input_tag[0] != 0) |
| 2406 | 2429 | { |
| 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) |
| 2409 | 2431 | { |
| 2410 | | ioport_field *field = port->field(m_input_mask); |
| 2432 | ioport_field *field = m_input_port->field(m_input_mask); |
| 2411 | 2433 | 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; |
| 2413 | 2435 | } |
| 2414 | 2436 | } |
| 2415 | 2437 | return state; |
| 2416 | 2438 | } |
| 2417 | 2439 | |
| 2418 | 2440 | |
| 2441 | //--------------------------------------------- |
| 2442 | // resolve_tags - resolve tags, if any are set |
| 2443 | //--------------------------------------------- |
| 2419 | 2444 | |
| 2445 | |
| 2446 | void 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 | |
| 2420 | 2456 | //************************************************************************** |
| 2421 | 2457 | // LAYOUT FILE |
| 2422 | 2458 | //************************************************************************** |
trunk/src/emu/rendlay.h
| r248602 | r248603 | |
| 208 | 208 | int orientation() const { return m_orientation; } |
| 209 | 209 | render_container *screen_container(running_machine &machine) const; |
| 210 | 210 | 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; }; |
| 212 | 212 | |
| 213 | 213 | // fetch state based on configured source |
| 214 | 214 | int state() const; |
| 215 | 215 | |
| 216 | // resolve tags, if any |
| 217 | void resolve_tags(); |
| 218 | |
| 216 | 219 | private: |
| 217 | 220 | // internal state |
| 218 | 221 | item * m_next; // link to next item |
| 219 | 222 | layout_element * m_element; // pointer to the associated element (non-screens only) |
| 220 | 223 | std::string m_output_name; // name of this item |
| 221 | 224 | std::string m_input_tag; // input tag of this item |
| 225 | ioport_port * m_input_port; // input port of this item |
| 222 | 226 | ioport_value m_input_mask; // input mask of this item |
| 223 | 227 | screen_device * m_screen; // pointer to screen |
| 224 | 228 | int m_orientation; // orientation of this item |
| r248602 | r248603 | |
| 245 | 249 | // operations |
| 246 | 250 | void recompute(render_layer_config layerconfig); |
| 247 | 251 | |
| 252 | // resolve tags, if any |
| 253 | void resolve_tags(); |
| 254 | |
| 248 | 255 | private: |
| 249 | 256 | // internal state |
| 250 | 257 | layout_view * m_next; // pointer to next layout in the list |