src/mess/device.c
| r3047 | r3048 | |
| 29 | 29 | TYPE DEFINITIONS |
| 30 | 30 | ***************************************************************************/ |
| 31 | 31 | |
| 32 | | struct IODevice |
| 32 | typedef struct _legacy_mess_device legacy_mess_device; |
| 33 | struct _legacy_mess_device |
| 33 | 34 | { |
| 34 | 35 | mess_device_class devclass; |
| 35 | 36 | const device_config *devconfig; |
| r3047 | r3048 | |
| 57 | 58 | typedef struct _mess_device_config mess_device_config; |
| 58 | 59 | struct _mess_device_config |
| 59 | 60 | { |
| 60 | | struct IODevice io_device; |
| 61 | legacy_mess_device io_device; |
| 61 | 62 | char string_buffer[1024]; |
| 62 | 63 | }; |
| 63 | 64 | |
| r3047 | r3048 | |
| 111 | 112 | FUNCTION PROTOTYPES |
| 112 | 113 | ***************************************************************************/ |
| 113 | 114 | |
| 114 | | static const struct IODevice *mess_device_from_core_device(const device_config *device); |
| 115 | static const legacy_mess_device *mess_device_from_core_device(const device_config *device); |
| 115 | 116 | |
| 116 | 117 | |
| 117 | 118 | |
| r3047 | r3048 | |
| 226 | 227 | static DEVICE_GET_NAME(mess_device) |
| 227 | 228 | { |
| 228 | 229 | const char *name; |
| 229 | | const struct IODevice *iodev = mess_device_from_core_device(device); |
| 230 | const legacy_mess_device *iodev = mess_device_from_core_device(device); |
| 230 | 231 | int id = iodev->index_in_device; |
| 231 | 232 | |
| 232 | 233 | /* use the cool new device string technique */ |
| 233 | 234 | name = mess_device_get_info_string(&iodev->devclass, MESS_DEVINFO_STR_DESCRIPTION + id); |
| 234 | | if (name) |
| 235 | if (name != NULL) |
| 235 | 236 | { |
| 236 | 237 | snprintf(buffer, buffer_length, "%s", name); |
| 237 | 238 | return buffer; |
| r3047 | r3048 | |
| 503 | 504 | * |
| 504 | 505 | *************************************/ |
| 505 | 506 | |
| 506 | | static const struct IODevice *mess_device_from_core_device(const device_config *device) |
| 507 | static const legacy_mess_device *mess_device_from_core_device(const device_config *device) |
| 507 | 508 | { |
| 508 | 509 | const mess_device_config *mess_device = (device != NULL) ? (const mess_device_config *) device->inline_config : NULL; |
| 509 | 510 | return (mess_device != NULL) ? &mess_device->io_device : NULL; |
| r3047 | r3048 | |
| 513 | 514 | |
| 514 | 515 | const mess_device_class *mess_devclass_from_core_device(const device_config *device) |
| 515 | 516 | { |
| 516 | | const struct IODevice *iodev = mess_device_from_core_device(device); |
| 517 | const legacy_mess_device *iodev = mess_device_from_core_device(device); |
| 517 | 518 | return (iodev != NULL) ? &iodev->devclass : NULL; |
| 518 | 519 | } |
| 519 | 520 | |
| r3047 | r3048 | |
| 526 | 527 | |
| 527 | 528 | for (device = device_list_first(machine->config->devicelist, MESS_DEVICE); device != NULL; device = device_list_next(device, MESS_DEVICE)) |
| 528 | 529 | { |
| 529 | | const struct IODevice *iodev = mess_device_from_core_device(device); |
| 530 | const legacy_mess_device *iodev = mess_device_from_core_device(device); |
| 530 | 531 | if (!strcmp(tag, iodev->tag)) |
| 531 | 532 | { |
| 532 | 533 | count++; |
| r3047 | r3048 | |
| 538 | 539 | |
| 539 | 540 | |
| 540 | 541 | /* this function is deprecated */ |
| 541 | | const struct IODevice *device_find_from_machine(const running_machine *machine, iodevice_t type) |
| 542 | int device_find_from_machine(const running_machine *machine, iodevice_t type) |
| 542 | 543 | { |
| 543 | 544 | const device_config *device; |
| 544 | 545 | |
| 545 | 546 | for (device = device_list_first(machine->config->devicelist, MESS_DEVICE); device != NULL; device = device_list_next(device, MESS_DEVICE)) |
| 546 | 547 | { |
| 547 | | const struct IODevice *iodev = mess_device_from_core_device(device); |
| 548 | const legacy_mess_device *iodev = mess_device_from_core_device(device); |
| 548 | 549 | if (iodev->type == type) |
| 549 | | { |
| 550 | | return iodev; |
| 551 | | } |
| 550 | return TRUE; |
| 552 | 551 | } |
| 553 | | return NULL; |
| 552 | return FALSE; |
| 554 | 553 | } |
| 555 | 554 | |
| 556 | 555 | |
| r3047 | r3048 | |
| 563 | 562 | |
| 564 | 563 | for (device = device_list_first(machine->config->devicelist, MESS_DEVICE); device != NULL; device = device_list_next(device, MESS_DEVICE)) |
| 565 | 564 | { |
| 566 | | const struct IODevice *iodev = mess_device_from_core_device(device); |
| 565 | const legacy_mess_device *iodev = mess_device_from_core_device(device); |
| 567 | 566 | if (iodev->type == type) |
| 568 | 567 | { |
| 569 | 568 | count++; |
| r3047 | r3048 | |
| 615 | 614 | |
| 616 | 615 | int image_index_in_device(const device_config *image) |
| 617 | 616 | { |
| 618 | | const struct IODevice *iodev = mess_device_from_core_device(image); |
| 617 | const legacy_mess_device *iodev = mess_device_from_core_device(image); |
| 619 | 618 | assert(iodev != NULL); |
| 620 | 619 | return iodev->index_in_device; |
| 621 | 620 | } |
| r3047 | r3048 | |
| 626 | 625 | { |
| 627 | 626 | const device_config *image = NULL; |
| 628 | 627 | const device_config *dev; |
| 629 | | const struct IODevice *iodev; |
| 628 | const legacy_mess_device *iodev; |
| 630 | 629 | |
| 631 | 630 | for (dev = device_list_first(machine->config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE)) |
| 632 | 631 | { |
| r3047 | r3048 | |
| 646 | 645 | |
| 647 | 646 | iodevice_t image_devtype(const device_config *image) |
| 648 | 647 | { |
| 649 | | const struct IODevice *iodev = mess_device_from_core_device(image); |
| 648 | const legacy_mess_device *iodev = mess_device_from_core_device(image); |
| 650 | 649 | assert(iodev != NULL); |
| 651 | 650 | return iodev->type; |
| 652 | 651 | } |
| r3047 | r3048 | |
| 657 | 656 | { |
| 658 | 657 | const device_config *image = NULL; |
| 659 | 658 | const device_config *dev; |
| 660 | | const struct IODevice *iodev; |
| 659 | const legacy_mess_device *iodev; |
| 661 | 660 | |
| 662 | 661 | for (dev = device_list_first(Machine->config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE)) |
| 663 | 662 | { |