src/mess/image.c
| r2224 | r2225 | |
| 1641 | 1641 | { |
| 1642 | 1642 | return Machine->images_data->slots[absolute_index].dev; |
| 1643 | 1643 | } |
| 1644 | | |
| 1645 | | |
| 1646 | | |
| 1647 | | /**************************************************************************** |
| 1648 | | Deprecated functions |
| 1649 | | |
| 1650 | | The usage of these functions is to be phased out. The first group because |
| 1651 | | they reflect the outdated fixed relationship between devices and their |
| 1652 | | type/id. |
| 1653 | | ****************************************************************************/ |
| 1654 | | |
| 1655 | | const device_config *image_from_device(const struct IODevice *device) |
| 1656 | | { |
| 1657 | | return device->devconfig; |
| 1658 | | } |
| 1659 | | |
| 1660 | | |
| 1661 | | |
| 1662 | | const device_config *image_from_devtag_and_index(const char *devtag, int id) |
| 1663 | | { |
| 1664 | | const device_config *image = NULL; |
| 1665 | | const device_config *dev; |
| 1666 | | const struct IODevice *iodev; |
| 1667 | | |
| 1668 | | for (dev = image_device_first(Machine->config); dev != NULL; dev = image_device_next(dev)) |
| 1669 | | { |
| 1670 | | iodev = mess_device_from_core_device(dev); |
| 1671 | | if ((iodev != NULL) && (iodev->tag != NULL) && !strcmp(iodev->tag, devtag) && (iodev->index_in_device == id)) |
| 1672 | | { |
| 1673 | | image = dev; |
| 1674 | | break; |
| 1675 | | } |
| 1676 | | } |
| 1677 | | |
| 1678 | | assert(image != NULL); |
| 1679 | | return image; |
| 1680 | | } |
| 1681 | | |
| 1682 | | |
| 1683 | | |
| 1684 | | const device_config *image_from_devtype_and_index(iodevice_t type, int id) |
| 1685 | | { |
| 1686 | | const device_config *image = NULL; |
| 1687 | | const device_config *dev; |
| 1688 | | const struct IODevice *iodev; |
| 1689 | | |
| 1690 | | assert((Machine->images_data->multiple_dev_mask & (1 << type)) == 0); |
| 1691 | | assert(id < device_count(Machine, type)); |
| 1692 | | |
| 1693 | | for (dev = image_device_first(Machine->config); dev != NULL; dev = image_device_next(dev)) |
| 1694 | | { |
| 1695 | | iodev = mess_device_from_core_device(dev); |
| 1696 | | if ((iodev != NULL) && (type == iodev->type) && (iodev->index_in_device == id)) |
| 1697 | | { |
| 1698 | | image = dev; |
| 1699 | | break; |
| 1700 | | } |
| 1701 | | } |
| 1702 | | |
| 1703 | | assert(image); |
| 1704 | | return image; |
| 1705 | | } |
| 1706 | | |
| 1707 | | |
| 1708 | | |
| 1709 | | iodevice_t image_devtype(const device_config *image) |
| 1710 | | { |
| 1711 | | const struct IODevice *iodev = mess_device_from_core_device(image); |
| 1712 | | assert(iodev != NULL); |
| 1713 | | return iodev->type; |
| 1714 | | } |
| 1715 | | |
| 1716 | | |
| 1717 | | |
| 1718 | | int image_index_in_device(const device_config *image) |
| 1719 | | { |
| 1720 | | const struct IODevice *iodev = mess_device_from_core_device(image); |
| 1721 | | assert(iodev != NULL); |
| 1722 | | return iodev->index_in_device; |
| 1723 | | } |
src/mess/image.h
| r2224 | r2225 | |
| 14 | 14 | #include "fileio.h" |
| 15 | 15 | #include "utils.h" |
| 16 | 16 | #include "opresolv.h" |
| 17 | | #include "device.h" |
| 18 | 17 | #include "osdmess.h" |
| 19 | 18 | |
| 20 | 19 | |
| 21 | 20 | |
| 22 | 21 | /*************************************************************************** |
| 23 | | CONSTANTS |
| 22 | TYPE DEFINITIONS |
| 24 | 23 | ***************************************************************************/ |
| 25 | 24 | |
| 26 | 25 | typedef enum |
| r2224 | r2225 | |
| 189 | 188 | |
| 190 | 189 | |
| 191 | 190 | /**************************************************************************** |
| 192 | | Deprecated functions |
| 193 | | |
| 194 | | The usage of these functions is to be phased out. The first group because |
| 195 | | they reflect the outdated fixed relationship between devices and their |
| 196 | | type/id. |
| 197 | | ****************************************************************************/ |
| 198 | | |
| 199 | | int image_index_in_device(const device_config *img); |
| 200 | | const device_config *image_from_device(const struct IODevice *dev); |
| 201 | | const device_config *image_from_devtag_and_index(const char *devtag, int id); |
| 202 | | |
| 203 | | /* deprecated; as there can be multiple devices of a certain type */ |
| 204 | | iodevice_t image_devtype(const device_config *img); |
| 205 | | const device_config *image_from_devtype_and_index(iodevice_t type, int id); |
| 206 | | |
| 207 | | |
| 208 | | |
| 209 | | |
| 210 | | /**************************************************************************** |
| 211 | 191 | Macros for declaring device callbacks |
| 212 | 192 | ****************************************************************************/ |
| 213 | 193 | |
src/mess/device.c
| r2224 | r2225 | |
| 8 | 8 | |
| 9 | 9 | #include <stddef.h> |
| 10 | 10 | |
| 11 | #include "driver.h" |
| 11 | 12 | #include "device.h" |
| 13 | #include "deprecat.h" |
| 12 | 14 | #include "mslegacy.h" |
| 13 | | #include "driver.h" |
| 14 | 15 | #include "pool.h" |
| 15 | 16 | #include "tagpool.h" |
| 16 | 17 | |
| r2224 | r2225 | |
| 623 | 624 | |
| 624 | 625 | /************************************* |
| 625 | 626 | * |
| 627 | * Deprecated device access functions |
| 628 | * |
| 629 | *************************************/ |
| 630 | |
| 631 | int image_index_in_device(const device_config *image) |
| 632 | { |
| 633 | const struct IODevice *iodev = mess_device_from_core_device(image); |
| 634 | assert(iodev != NULL); |
| 635 | return iodev->index_in_device; |
| 636 | } |
| 637 | |
| 638 | |
| 639 | |
| 640 | const device_config *image_from_device(const struct IODevice *device) |
| 641 | { |
| 642 | return device->devconfig; |
| 643 | } |
| 644 | |
| 645 | |
| 646 | |
| 647 | const device_config *image_from_devtag_and_index(const char *devtag, int id) |
| 648 | { |
| 649 | const device_config *image = NULL; |
| 650 | const device_config *dev; |
| 651 | const struct IODevice *iodev; |
| 652 | |
| 653 | for (dev = device_list_first(Machine->config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE)) |
| 654 | { |
| 655 | iodev = mess_device_from_core_device(dev); |
| 656 | if ((iodev->tag != NULL) && !strcmp(iodev->tag, devtag) && (iodev->index_in_device == id)) |
| 657 | { |
| 658 | image = dev; |
| 659 | break; |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | assert(image != NULL); |
| 664 | return image; |
| 665 | } |
| 666 | |
| 667 | |
| 668 | |
| 669 | iodevice_t image_devtype(const device_config *image) |
| 670 | { |
| 671 | const struct IODevice *iodev = mess_device_from_core_device(image); |
| 672 | assert(iodev != NULL); |
| 673 | return iodev->type; |
| 674 | } |
| 675 | |
| 676 | |
| 677 | |
| 678 | const device_config *image_from_devtype_and_index(iodevice_t type, int id) |
| 679 | { |
| 680 | const device_config *image = NULL; |
| 681 | const device_config *dev; |
| 682 | const struct IODevice *iodev; |
| 683 | |
| 684 | assert((Machine->images_data->multiple_dev_mask & (1 << type)) == 0); |
| 685 | assert(id < device_count(Machine, type)); |
| 686 | |
| 687 | for (dev = device_list_first(Machine->config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE)) |
| 688 | { |
| 689 | iodev = mess_device_from_core_device(dev); |
| 690 | if ((type == iodev->type) && (iodev->index_in_device == id)) |
| 691 | { |
| 692 | image = dev; |
| 693 | break; |
| 694 | } |
| 695 | } |
| 696 | |
| 697 | assert(image); |
| 698 | return image; |
| 699 | } |
| 700 | |
| 701 | |
| 702 | |
| 703 | /************************************* |
| 704 | * |
| 626 | 705 | * Diagnostics |
| 627 | 706 | * |
| 628 | 707 | *************************************/ |
src/mess/device.h
| r2224 | r2225 | |
| 295 | 295 | void *image_alloctag(const device_config *device, const char *tag, size_t size); |
| 296 | 296 | void *image_lookuptag(const device_config *device, const char *tag); |
| 297 | 297 | |
| 298 | /* deprecated device access functions */ |
| 299 | int image_index_in_device(const device_config *device); |
| 300 | const device_config *image_from_device(const struct IODevice *iodev); |
| 301 | const device_config *image_from_devtag_and_index(const char *devtag, int id); |
| 302 | |
| 303 | /* deprecated device access functions that assume one device of any given type */ |
| 304 | iodevice_t image_devtype(const device_config *device); |
| 305 | const device_config *image_from_devtype_and_index(iodevice_t type, int id); |
| 306 | |
| 298 | 307 | /* diagnostics */ |
| 299 | 308 | int device_valididtychecks(void); |
| 300 | 309 | |