src/mess/uimess.c
| r2132 | r2133 | |
| 25 | 25 | { |
| 26 | 26 | static int ui_toggle_key = 0; |
| 27 | 27 | |
| 28 | | int id, toggled = 0; |
| 28 | int toggled = 0; |
| 29 | 29 | const struct IODevice *dev; |
| 30 | 30 | |
| 31 | 31 | /* traditional MESS interface */ |
| r2132 | r2133 | |
| 82 | 82 | { |
| 83 | 83 | if (dev->display != NULL) |
| 84 | 84 | { |
| 85 | | for (id = 0; id < device_count(dev->type); id++) |
| 86 | | { |
| 87 | | mess_image *img = image_from_devtype_and_index(dev->type, id); |
| 88 | | dev->display(img); |
| 89 | | } |
| 85 | mess_image *img = image_from_device(dev); |
| 86 | dev->display(img); |
| 90 | 87 | } |
| 91 | 88 | } |
| 92 | 89 | } |
| r2132 | r2133 | |
| 103 | 100 | { |
| 104 | 101 | char *dst = buf; |
| 105 | 102 | const struct IODevice *dev; |
| 106 | | int id; |
| 107 | 103 | |
| 108 | 104 | dst += sprintf(dst, "%s\n\n", Machine->gamedrv->description); |
| 109 | 105 | |
| r2132 | r2133 | |
| 115 | 111 | |
| 116 | 112 | for (dev = mess_device_first_from_machine(Machine); dev != NULL; dev = mess_device_next(dev)) |
| 117 | 113 | { |
| 118 | | for (id = 0; id < dev->count; id++) |
| 114 | mess_image *img = image_from_device(dev); |
| 115 | const char *name = image_filename(img); |
| 116 | if( name ) |
| 119 | 117 | { |
| 120 | | mess_image *img = image_from_device_and_index(dev, id); |
| 121 | | const char *name = image_filename(img); |
| 122 | | if( name ) |
| 123 | | { |
| 124 | | const char *base_filename; |
| 125 | | const char *info; |
| 126 | | char *base_filename_noextension; |
| 118 | const char *base_filename; |
| 119 | const char *info; |
| 120 | char *base_filename_noextension; |
| 127 | 121 | |
| 128 | | base_filename = image_basename(img); |
| 129 | | base_filename_noextension = strip_extension(base_filename); |
| 122 | base_filename = image_basename(img); |
| 123 | base_filename_noextension = strip_extension(base_filename); |
| 130 | 124 | |
| 131 | | /* display device type and filename */ |
| 132 | | dst += sprintf(dst,"%s: %s\n", image_typename_id(img), base_filename); |
| 125 | /* display device type and filename */ |
| 126 | dst += sprintf(dst,"%s: %s\n", image_typename_id(img), base_filename); |
| 133 | 127 | |
| 134 | | /* display long filename, if present and doesn't correspond to name */ |
| 135 | | info = image_longname(img); |
| 136 | | if (info && (!base_filename_noextension || mame_stricmp(info, base_filename_noextension))) |
| 137 | | dst += sprintf(dst,"%s\n", info); |
| 128 | /* display long filename, if present and doesn't correspond to name */ |
| 129 | info = image_longname(img); |
| 130 | if (info && (!base_filename_noextension || mame_stricmp(info, base_filename_noextension))) |
| 131 | dst += sprintf(dst,"%s\n", info); |
| 138 | 132 | |
| 139 | | /* display manufacturer, if available */ |
| 140 | | info = image_manufacturer(img); |
| 141 | | if (info) |
| 142 | | { |
| 143 | | dst += sprintf(dst,"%s", info); |
| 144 | | info = stripspace(image_year(img)); |
| 145 | | if (info && *info) |
| 146 | | dst += sprintf(dst,", %s", info); |
| 147 | | dst += sprintf(dst,"\n"); |
| 148 | | } |
| 149 | | |
| 150 | | /* display playable information, if available */ |
| 151 | | info = image_playable(img); |
| 152 | | if (info) |
| 153 | | dst += sprintf(dst,"%s\n", info); |
| 154 | | |
| 155 | | if (base_filename_noextension) |
| 156 | | free(base_filename_noextension); |
| 157 | | } |
| 158 | | else |
| 133 | /* display manufacturer, if available */ |
| 134 | info = image_manufacturer(img); |
| 135 | if (info) |
| 159 | 136 | { |
| 160 | | dst += sprintf(dst,"%s: ---\n", image_typename_id(img)); |
| 137 | dst += sprintf(dst,"%s", info); |
| 138 | info = stripspace(image_year(img)); |
| 139 | if (info && *info) |
| 140 | dst += sprintf(dst,", %s", info); |
| 141 | dst += sprintf(dst,"\n"); |
| 161 | 142 | } |
| 143 | |
| 144 | /* display playable information, if available */ |
| 145 | info = image_playable(img); |
| 146 | if (info) |
| 147 | dst += sprintf(dst,"%s\n", info); |
| 148 | |
| 149 | if (base_filename_noextension) |
| 150 | free(base_filename_noextension); |
| 162 | 151 | } |
| 152 | else |
| 153 | { |
| 154 | dst += sprintf(dst,"%s: ---\n", image_typename_id(img)); |
| 155 | } |
| 163 | 156 | } |
| 164 | 157 | return dst - buf; |
| 165 | 158 | } |
src/mess/image.c
| r2132 | r2133 | |
| 109 | 109 | int image_init(running_machine *machine) |
| 110 | 110 | { |
| 111 | 111 | int err; |
| 112 | | int count, indx, j; |
| 112 | int count, indx; |
| 113 | 113 | UINT32 mask, dev_mask = 0; |
| 114 | 114 | const struct IODevice *dev; |
| 115 | 115 | |
| r2132 | r2133 | |
| 121 | 121 | count = 0; |
| 122 | 122 | for (dev = mess_device_first_from_machine(machine); dev != NULL; dev = mess_device_next(dev)) |
| 123 | 123 | { |
| 124 | | /* check to see if this device type is used multiple times */ |
| 125 | | mask = 1 << dev->type; |
| 126 | | if (dev_mask & mask) |
| 127 | | multiple_dev_mask |= mask; |
| 128 | | else |
| 129 | | dev_mask |= mask; |
| 124 | /* weird check only relevant on the first device */ |
| 125 | if (dev->index_in_device == 0) |
| 126 | { |
| 127 | /* check to see if this device type is used multiple times */ |
| 128 | mask = 1 << dev->type; |
| 129 | if (dev_mask & mask) |
| 130 | multiple_dev_mask |= mask; |
| 131 | else |
| 132 | dev_mask |= mask; |
| 133 | } |
| 130 | 134 | |
| 131 | 135 | /* increment the count */ |
| 132 | | count += dev->count; |
| 136 | count++; |
| 133 | 137 | } |
| 134 | 138 | |
| 135 | 139 | /* allocate the array */ |
| r2132 | r2133 | |
| 143 | 147 | indx = 0; |
| 144 | 148 | for (dev = mess_device_first_from_machine(machine); dev != NULL; dev = mess_device_next(dev)) |
| 145 | 149 | { |
| 146 | | for (j = 0; j < dev->count; j++) |
| 147 | | { |
| 148 | | images[indx + j].mempool = pool_alloc(memory_error); |
| 150 | images[indx].mempool = pool_alloc(memory_error); |
| 149 | 151 | |
| 150 | | /* setup the device */ |
| 151 | | tagpool_init(&images[indx + j].tagpool); |
| 152 | | images[indx + j].dev = dev; |
| 152 | /* setup the device */ |
| 153 | tagpool_init(&images[indx].tagpool); |
| 154 | images[indx].dev = dev; |
| 153 | 155 | |
| 154 | | if (dev->init != NULL) |
| 155 | | { |
| 156 | | err = dev->init(&images[indx + j]); |
| 157 | | if (err != INIT_PASS) |
| 158 | | return err; |
| 159 | | } |
| 160 | | |
| 156 | if (dev->init != NULL) |
| 157 | { |
| 158 | err = dev->init(&images[indx]); |
| 159 | if (err != INIT_PASS) |
| 160 | return err; |
| 161 | 161 | } |
| 162 | | indx += dev->count; |
| 162 | indx++; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | add_exit_callback(machine, image_exit); |
| r2132 | r2133 | |
| 174 | 174 | |
| 175 | 175 | static void image_exit(running_machine *machine) |
| 176 | 176 | { |
| 177 | | int j, indx; |
| 177 | int indx; |
| 178 | 178 | mess_image *image; |
| 179 | 179 | const struct IODevice *dev; |
| 180 | 180 | |
| r2132 | r2133 | |
| 186 | 186 | |
| 187 | 187 | for (dev = mess_device_first_from_machine(machine); dev != NULL; dev = mess_device_next(dev)) |
| 188 | 188 | { |
| 189 | | for (j = 0; j < dev->count; j++) |
| 190 | | { |
| 191 | | /* identify the image */ |
| 192 | | image = &images[indx + j]; |
| 189 | /* identify the image */ |
| 190 | image = &images[indx]; |
| 193 | 191 | |
| 194 | | /* call the exit handler if appropriate */ |
| 195 | | if (dev->exit != NULL) |
| 196 | | dev->exit(image); |
| 192 | /* call the exit handler if appropriate */ |
| 193 | if (dev->exit != NULL) |
| 194 | dev->exit(image); |
| 197 | 195 | |
| 198 | | /* free the tagpool */ |
| 199 | | tagpool_exit(&images[indx + j].tagpool); |
| 196 | /* free the tagpool */ |
| 197 | tagpool_exit(&images[indx].tagpool); |
| 200 | 198 | |
| 201 | | /* free the working directory */ |
| 202 | | if (image->working_directory != NULL) |
| 203 | | { |
| 204 | | free(image->working_directory); |
| 205 | | image->working_directory = NULL; |
| 206 | | } |
| 207 | | |
| 208 | | /* free the memory pool */ |
| 209 | | pool_free(image->mempool); |
| 210 | | image->mempool = NULL; |
| 199 | /* free the working directory */ |
| 200 | if (image->working_directory != NULL) |
| 201 | { |
| 202 | free(image->working_directory); |
| 203 | image->working_directory = NULL; |
| 211 | 204 | } |
| 212 | | indx += dev->count; |
| 205 | |
| 206 | /* free the memory pool */ |
| 207 | pool_free(image->mempool); |
| 208 | image->mempool = NULL; |
| 209 | indx++; |
| 213 | 210 | } |
| 214 | 211 | } |
| 215 | 212 | |
| r2132 | r2133 | |
| 746 | 743 | |
| 747 | 744 | void image_unload_all(int ispreload) |
| 748 | 745 | { |
| 749 | | int id; |
| 750 | 746 | const struct IODevice *dev; |
| 751 | 747 | mess_image *image; |
| 752 | 748 | |
| r2132 | r2133 | |
| 761 | 757 | { |
| 762 | 758 | if (dev->load_at_init == ispreload) |
| 763 | 759 | { |
| 764 | | /* all instances */ |
| 765 | | for (id = 0; id < dev->count; id++) |
| 766 | | { |
| 767 | | image = image_from_device_and_index(dev, id); |
| 760 | image = image_from_device(dev); |
| 768 | 761 | |
| 769 | | /* unload this image */ |
| 770 | | image_unload_internal(image, TRUE); |
| 771 | | } |
| 762 | /* unload this image */ |
| 763 | image_unload_internal(image, TRUE); |
| 772 | 764 | } |
| 773 | 765 | } |
| 774 | 766 | } |
| r2132 | r2133 | |
| 1002 | 994 | |
| 1003 | 995 | int image_slotexists(mess_image *img) |
| 1004 | 996 | { |
| 1005 | | return image_index_in_device(img) < image_device(img)->count; |
| 997 | return TRUE; |
| 1006 | 998 | } |
| 1007 | 999 | |
| 1008 | 1000 | |
| r2132 | r2133 | |
| 1594 | 1586 | type/id. |
| 1595 | 1587 | ****************************************************************************/ |
| 1596 | 1588 | |
| 1597 | | mess_image *image_from_device_and_index(const struct IODevice *device, int id) |
| 1589 | mess_image *image_from_device(const struct IODevice *device) |
| 1598 | 1590 | { |
| 1599 | 1591 | int indx; |
| 1600 | 1592 | mess_image *image = NULL; |
| 1601 | 1593 | const struct IODevice *dev; |
| 1602 | 1594 | |
| 1603 | | assert(id < device->count); |
| 1604 | 1595 | assert(images); |
| 1605 | 1596 | |
| 1606 | 1597 | indx = 0; |
| r2132 | r2133 | |
| 1608 | 1599 | { |
| 1609 | 1600 | if (device == dev) |
| 1610 | 1601 | { |
| 1611 | | image = &images[indx + id]; |
| 1602 | image = &images[indx]; |
| 1612 | 1603 | break; |
| 1613 | 1604 | } |
| 1614 | | indx += dev->count; |
| 1605 | indx++; |
| 1615 | 1606 | } |
| 1616 | 1607 | |
| 1617 | 1608 | assert(image != NULL); |
| r2132 | r2133 | |
| 1625 | 1616 | int indx; |
| 1626 | 1617 | mess_image *image = NULL; |
| 1627 | 1618 | const struct IODevice *dev; |
| 1619 | int device_index; |
| 1628 | 1620 | |
| 1629 | 1621 | indx = 0; |
| 1622 | device_index = 0; |
| 1630 | 1623 | for (dev = mess_device_first_from_machine(Machine); dev != NULL; dev = mess_device_next(dev)) |
| 1631 | 1624 | { |
| 1632 | | if (dev->tag && !strcmp(dev->tag, devtag)) |
| 1625 | if (dev->tag && !strcmp(dev->tag, devtag) && (device_index++ == id)) |
| 1633 | 1626 | { |
| 1634 | | image = &images[indx + id]; |
| 1627 | image = &images[indx]; |
| 1635 | 1628 | break; |
| 1636 | 1629 | } |
| 1637 | | indx += dev->count; |
| 1630 | indx++; |
| 1638 | 1631 | } |
| 1639 | 1632 | |
| 1640 | | assert(image); |
| 1633 | assert(image != NULL); |
| 1641 | 1634 | return image; |
| 1642 | 1635 | } |
| 1643 | 1636 | |
| r2132 | r2133 | |
| 1648 | 1641 | int indx; |
| 1649 | 1642 | mess_image *image = NULL; |
| 1650 | 1643 | const struct IODevice *dev; |
| 1644 | int device_index; |
| 1651 | 1645 | |
| 1652 | 1646 | assert((multiple_dev_mask & (1 << type)) == 0); |
| 1653 | 1647 | assert(id < device_count(type)); |
| 1654 | 1648 | |
| 1655 | 1649 | indx = 0; |
| 1650 | device_index = 0; |
| 1656 | 1651 | for (dev = mess_device_first_from_machine(Machine); dev != NULL; dev = mess_device_next(dev)) |
| 1657 | 1652 | { |
| 1658 | | if (type == dev->type) |
| 1653 | if ((type == dev->type) && (device_index++ == id)) |
| 1659 | 1654 | { |
| 1660 | | image = &images[indx + id]; |
| 1655 | image = &images[indx]; |
| 1661 | 1656 | break; |
| 1662 | 1657 | } |
| 1663 | | indx += dev->count; |
| 1658 | indx++; |
| 1664 | 1659 | } |
| 1665 | 1660 | |
| 1666 | 1661 | assert(image); |
| r2132 | r2133 | |
| 1678 | 1673 | |
| 1679 | 1674 | int image_index_in_device(mess_image *img) |
| 1680 | 1675 | { |
| 1681 | | int indx; |
| 1682 | | |
| 1683 | 1676 | assert(img); |
| 1684 | | indx = img - image_from_device_and_index(img->dev, 0); |
| 1685 | | |
| 1686 | | assert(indx >= 0); |
| 1687 | | assert(indx < img->dev->count); |
| 1688 | | return indx; |
| 1677 | return img->dev->index_in_device; |
| 1689 | 1678 | } |
src/mess/device.c
| r2132 | r2133 | |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | name = device_uiname(dev->type); |
| 183 | | if (dev->count > 1) |
| 183 | if (dev->multiple) |
| 184 | 184 | { |
| 185 | 185 | /* for the average user counting starts at #1 ;-) */ |
| 186 | 186 | snprintf(buf, bufsize, "%s #%d", name, id + 1); |
| r2132 | r2133 | |
| 293 | 293 | int count_override, int *position) |
| 294 | 294 | { |
| 295 | 295 | mess_device_class mess_devclass; |
| 296 | | const char *tag; |
| 296 | const char *mess_tag; |
| 297 | const char *mame_tag; |
| 297 | 298 | const char *info_string; |
| 298 | 299 | char dynamic_tag[32]; |
| 299 | 300 | device_config *device; |
| 300 | 301 | mess_device_config *mess_device; |
| 301 | 302 | const char *file_extensions; |
| 302 | | int j; |
| 303 | int i, j, count; |
| 303 | 304 | size_t string_buffer_pos = 0; |
| 304 | 305 | int createimage_optcount; |
| 305 | 306 | |
| r2132 | r2133 | |
| 307 | 308 | mess_devclass.get_info = handler; |
| 308 | 309 | mess_devclass.gamedrv = gamedrv; |
| 309 | 310 | |
| 310 | | /* determine the tag */ |
| 311 | | tag = mess_device_get_info_string(&mess_devclass, MESS_DEVINFO_STR_DEV_TAG); |
| 312 | | if (tag == NULL) |
| 313 | | { |
| 314 | | /* create a default tag */ |
| 315 | | snprintf(dynamic_tag, ARRAY_LENGTH(dynamic_tag), "mess_device_%d", *position); |
| 316 | | tag = dynamic_tag; |
| 317 | | } |
| 318 | | |
| 319 | | /* create a bonafide MAME device */ |
| 320 | | device = device_list_add(listheadptr, MESS_DEVICE, tag); |
| 321 | | mess_device = (mess_device_config *) device->inline_config; |
| 311 | /* determine device count */ |
| 312 | count = mess_device_get_info_int(&mess_devclass, MESS_DEVINFO_INT_COUNT); |
| 322 | 313 | |
| 323 | | /* convert file extensions from comma delimited to null delimited */ |
| 324 | | file_extensions = mess_device_get_info_string(&mess_devclass, MESS_DEVINFO_STR_FILE_EXTENSIONS); |
| 325 | | if (file_extensions != NULL) |
| 314 | /* create one MAME device for each of these */ |
| 315 | for (i = 0; i < count; i++) |
| 326 | 316 | { |
| 327 | | const char *file_extensions_copy = &mess_device->string_buffer[string_buffer_pos]; |
| 328 | | |
| 329 | | /* copy the file extensions over to the buffer */ |
| 330 | | for (j = 0; file_extensions[j] != '\0'; j++) |
| 317 | /* determine the tag */ |
| 318 | mess_tag = mess_device_get_info_string(&mess_devclass, MESS_DEVINFO_STR_DEV_TAG); |
| 319 | if (mess_tag != NULL) |
| 331 | 320 | { |
| 332 | | string_buffer_putc(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, |
| 333 | | (file_extensions[j] != ',') ? file_extensions[j] : '\0'); |
| 321 | snprintf(dynamic_tag, ARRAY_LENGTH(dynamic_tag), "%s_%d", mess_tag, i); |
| 322 | mame_tag = dynamic_tag; |
| 334 | 323 | } |
| 335 | | string_buffer_putc(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, '\0'); |
| 336 | | string_buffer_putc(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, '\0'); |
| 324 | else |
| 325 | { |
| 326 | /* create a default tag */ |
| 327 | snprintf(dynamic_tag, ARRAY_LENGTH(dynamic_tag), "mess_device_%d", *position); |
| 328 | mame_tag = dynamic_tag; |
| 329 | } |
| 330 | |
| 331 | /* create a bonafide MAME device */ |
| 332 | device = device_list_add(listheadptr, MESS_DEVICE, mame_tag); |
| 333 | mess_device = (mess_device_config *) device->inline_config; |
| 337 | 334 | |
| 338 | | file_extensions = file_extensions_copy; |
| 339 | | } |
| 335 | /* convert file extensions from comma delimited to null delimited */ |
| 336 | file_extensions = mess_device_get_info_string(&mess_devclass, MESS_DEVINFO_STR_FILE_EXTENSIONS); |
| 337 | if (file_extensions != NULL) |
| 338 | { |
| 339 | const char *file_extensions_copy = &mess_device->string_buffer[string_buffer_pos]; |
| 340 | 340 | |
| 341 | | /* populate the legacy MESS device */ |
| 342 | | mess_device->io_device.tag = device->tag; |
| 343 | | mess_device->io_device.devconfig = device; |
| 344 | | mess_device->io_device.devclass = mess_devclass; |
| 345 | | mess_device->io_device.type = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_TYPE); |
| 346 | | mess_device->io_device.count = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_COUNT); |
| 347 | | mess_device->io_device.position = *position; |
| 348 | | mess_device->io_device.file_extensions = file_extensions; |
| 341 | /* copy the file extensions over to the buffer */ |
| 342 | for (j = 0; file_extensions[j] != '\0'; j++) |
| 343 | { |
| 344 | string_buffer_putc(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, |
| 345 | (file_extensions[j] != ',') ? file_extensions[j] : '\0'); |
| 346 | } |
| 347 | string_buffer_putc(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, '\0'); |
| 348 | string_buffer_putc(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, '\0'); |
| 349 | 349 | |
| 350 | | mess_device->io_device.readable = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_READABLE) ? 1 : 0; |
| 351 | | mess_device->io_device.writeable = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_WRITEABLE) ? 1 : 0; |
| 352 | | mess_device->io_device.creatable = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_CREATABLE) ? 1 : 0; |
| 353 | | mess_device->io_device.reset_on_load = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_RESET_ON_LOAD) ? 1 : 0; |
| 354 | | mess_device->io_device.must_be_loaded = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_MUST_BE_LOADED) ? 1 : 0; |
| 355 | | mess_device->io_device.load_at_init = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_LOAD_AT_INIT) ? 1 : 0; |
| 350 | file_extensions = file_extensions_copy; |
| 351 | } |
| 356 | 352 | |
| 357 | | mess_device->io_device.init = (device_init_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_INIT); |
| 358 | | mess_device->io_device.exit = (device_exit_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_EXIT); |
| 359 | | mess_device->io_device.load = (device_load_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_LOAD); |
| 360 | | mess_device->io_device.create = (device_create_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_CREATE); |
| 361 | | mess_device->io_device.unload = (device_unload_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_UNLOAD); |
| 362 | | mess_device->io_device.imgverify = (device_verify_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_VERIFY); |
| 363 | | mess_device->io_device.partialhash = (device_partialhash_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_PARTIAL_HASH); |
| 364 | | mess_device->io_device.getdispositions = (device_getdispositions_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_GET_DISPOSITIONS); |
| 353 | /* populate the legacy MESS device */ |
| 354 | mess_device->io_device.tag = mess_tag; |
| 355 | mess_device->io_device.devconfig = device; |
| 356 | mess_device->io_device.devclass = mess_devclass; |
| 357 | mess_device->io_device.type = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_TYPE); |
| 358 | mess_device->io_device.position = *position; |
| 359 | mess_device->io_device.index_in_device = i; |
| 360 | mess_device->io_device.file_extensions = file_extensions; |
| 365 | 361 | |
| 366 | | mess_device->io_device.display = (device_display_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_DISPLAY); |
| 367 | | mess_device->io_device.name = default_device_name; |
| 362 | mess_device->io_device.readable = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_READABLE) ? 1 : 0; |
| 363 | mess_device->io_device.writeable = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_WRITEABLE) ? 1 : 0; |
| 364 | mess_device->io_device.creatable = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_CREATABLE) ? 1 : 0; |
| 365 | mess_device->io_device.reset_on_load = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_RESET_ON_LOAD) ? 1 : 0; |
| 366 | mess_device->io_device.must_be_loaded = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_MUST_BE_LOADED) ? 1 : 0; |
| 367 | mess_device->io_device.load_at_init = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_LOAD_AT_INIT) ? 1 : 0; |
| 368 | 368 | |
| 369 | | mess_device->io_device.createimage_optguide = (const struct OptionGuide *) mess_device_get_info_ptr(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_CREATE_OPTGUIDE); |
| 369 | mess_device->io_device.init = (device_init_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_INIT); |
| 370 | mess_device->io_device.exit = (device_exit_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_EXIT); |
| 371 | mess_device->io_device.load = (device_load_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_LOAD); |
| 372 | mess_device->io_device.create = (device_create_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_CREATE); |
| 373 | mess_device->io_device.unload = (device_unload_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_UNLOAD); |
| 374 | mess_device->io_device.imgverify = (device_verify_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_VERIFY); |
| 375 | mess_device->io_device.partialhash = (device_partialhash_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_PARTIAL_HASH); |
| 376 | mess_device->io_device.getdispositions = (device_getdispositions_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_GET_DISPOSITIONS); |
| 370 | 377 | |
| 371 | | createimage_optcount = (int) mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_CREATE_OPTCOUNT); |
| 372 | | if (createimage_optcount > 0) |
| 373 | | { |
| 374 | | if (createimage_optcount > MESS_DEVINFO_CREATE_OPTMAX) |
| 375 | | fatalerror("MESS_DEVINFO_INT_CREATE_OPTCOUNT: Too many options"); |
| 378 | mess_device->io_device.display = (device_display_handler) mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_DISPLAY); |
| 379 | mess_device->io_device.name = default_device_name; |
| 376 | 380 | |
| 377 | | /* set up each option in the list */ |
| 378 | | for (j = 0; j < createimage_optcount; j++) |
| 381 | mess_device->io_device.createimage_optguide = (const struct OptionGuide *) mess_device_get_info_ptr(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_CREATE_OPTGUIDE); |
| 382 | |
| 383 | createimage_optcount = (int) mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_CREATE_OPTCOUNT); |
| 384 | if (createimage_optcount > 0) |
| 379 | 385 | { |
| 380 | | info_string = mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_CREATE_OPTNAME + j); |
| 381 | | mess_device->createimage_options[j].name = string_buffer_putstr(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, info_string); |
| 386 | if (createimage_optcount > MESS_DEVINFO_CREATE_OPTMAX) |
| 387 | fatalerror("MESS_DEVINFO_INT_CREATE_OPTCOUNT: Too many options"); |
| 382 | 388 | |
| 383 | | info_string = mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_CREATE_OPTDESC + j); |
| 384 | | mess_device->createimage_options[j].description = string_buffer_putstr(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, info_string); |
| 385 | | |
| 386 | | info_string = mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_CREATE_OPTEXTS + j); |
| 387 | | mess_device->createimage_options[j].extensions = string_buffer_putstr(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, info_string); |
| 388 | | |
| 389 | | mess_device->createimage_options[j].optspec = mess_device_get_info_ptr(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_CREATE_OPTSPEC + j); |
| 389 | /* set up each option in the list */ |
| 390 | for (j = 0; j < createimage_optcount; j++) |
| 391 | { |
| 392 | info_string = mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_CREATE_OPTNAME + j); |
| 393 | mess_device->createimage_options[j].name = string_buffer_putstr(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, info_string); |
| 394 | |
| 395 | info_string = mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_CREATE_OPTDESC + j); |
| 396 | mess_device->createimage_options[j].description = string_buffer_putstr(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, info_string); |
| 397 | |
| 398 | info_string = mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_CREATE_OPTEXTS + j); |
| 399 | mess_device->createimage_options[j].extensions = string_buffer_putstr(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, info_string); |
| 400 | |
| 401 | mess_device->createimage_options[j].optspec = mess_device_get_info_ptr(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_CREATE_OPTSPEC + j); |
| 402 | } |
| 403 | |
| 404 | /* terminate the list */ |
| 405 | memset(&mess_device->createimage_options[createimage_optcount], 0, sizeof(mess_device->createimage_options[createimage_optcount])); |
| 390 | 406 | } |
| 391 | 407 | |
| 392 | | /* terminate the list */ |
| 393 | | memset(&mess_device->createimage_options[createimage_optcount], 0, sizeof(mess_device->createimage_options[createimage_optcount])); |
| 394 | | } |
| 408 | (*position)++; |
| 395 | 409 | |
| 396 | | *position += mess_device->io_device.count; |
| 410 | /* overriding the count? */ |
| 411 | //if (count_override != 0) |
| 412 | // mess_device->io_device.count = count_override; |
| 397 | 413 | |
| 398 | | /* overriding the count? */ |
| 399 | | if (count_override != 0) |
| 400 | | mess_device->io_device.count = count_override; |
| 414 | /* any problems? */ |
| 415 | assert((mess_device->io_device.type >= 0) && (mess_device->io_device.type < IO_COUNT)); |
| 401 | 416 | |
| 402 | | /* any problems? */ |
| 403 | | assert((mess_device->io_device.type >= 0) && (mess_device->io_device.type < IO_COUNT)); |
| 404 | | assert ((mess_device->io_device.count >= 0) && (mess_device->io_device.count <= MAX_DEV_INSTANCES)); |
| 405 | | |
| 406 | | /* fill in defaults */ |
| 407 | | if (!mess_device->io_device.getdispositions) |
| 408 | | mess_device->io_device.getdispositions = default_device_getdispositions; |
| 417 | /* fill in defaults */ |
| 418 | if (!mess_device->io_device.getdispositions) |
| 419 | mess_device->io_device.getdispositions = default_device_getdispositions; |
| 420 | } |
| 409 | 421 | } |
| 410 | 422 | |
| 411 | 423 | |
| r2132 | r2133 | |
| 498 | 510 | |
| 499 | 511 | int device_count_tag_from_machine(const running_machine *machine, const char *tag) |
| 500 | 512 | { |
| 501 | | const device_config *device = device_list_find_by_tag(machine->config->devicelist, MESS_DEVICE, tag); |
| 502 | | const struct IODevice *iodev = mess_device_from_core_device(device); |
| 503 | | return (iodev != NULL) ? iodev->count : 0; |
| 513 | int count = 0; |
| 514 | const device_config *device; |
| 515 | |
| 516 | for (device = device_list_first(machine->config->devicelist, MESS_DEVICE); device != NULL; device = device_list_next(device, MESS_DEVICE)) |
| 517 | { |
| 518 | const struct IODevice *iodev = mess_device_from_core_device(device); |
| 519 | if (!strcmp(tag, iodev->tag)) |
| 520 | { |
| 521 | count++; |
| 522 | } |
| 523 | } |
| 524 | return count; |
| 504 | 525 | } |
| 505 | 526 | |
| 506 | 527 | |
| r2132 | r2133 | |
| 526 | 547 | /* this function is deprecated */ |
| 527 | 548 | int device_count(iodevice_t type) |
| 528 | 549 | { |
| 529 | | const struct IODevice *iodev = device_find_from_machine(Machine, type); |
| 530 | | return (iodev != NULL) ? iodev->count : 0; |
| 550 | int count = 0; |
| 551 | const device_config *device; |
| 552 | |
| 553 | for (device = device_list_first(Machine->config->devicelist, MESS_DEVICE); device != NULL; device = device_list_next(device, MESS_DEVICE)) |
| 554 | { |
| 555 | const struct IODevice *iodev = mess_device_from_core_device(device); |
| 556 | if (iodev->type == type) |
| 557 | { |
| 558 | count++; |
| 559 | } |
| 560 | } |
| 561 | return count; |
| 531 | 562 | } |
| 532 | 563 | |
| 533 | 564 | |
src/mess/osd/windows/menu.c
| r2132 | r2133 | |
| 1347 | 1347 | // then set up the actual devices |
| 1348 | 1348 | for (dev = mess_device_first_from_machine(machine); dev != NULL; dev = mess_device_next(dev)) |
| 1349 | 1349 | { |
| 1350 | | for (i = 0; i < dev->count; i++) |
| 1351 | | { |
| 1352 | | img = image_from_device_and_index(dev, i); |
| 1350 | img = image_from_device(dev); |
| 1353 | 1351 | |
| 1354 | | new_item = ID_DEVICE_0 + (image_absolute_index(img) * DEVOPTION_MAX); |
| 1355 | | flags_for_exists = MF_STRING; |
| 1352 | new_item = ID_DEVICE_0 + (image_absolute_index(img) * DEVOPTION_MAX); |
| 1353 | flags_for_exists = MF_STRING; |
| 1356 | 1354 | |
| 1357 | | if (!image_exists(img)) |
| 1358 | | flags_for_exists |= MF_GRAYED; |
| 1355 | if (!image_exists(img)) |
| 1356 | flags_for_exists |= MF_GRAYED; |
| 1359 | 1357 | |
| 1360 | | flags_for_writing = flags_for_exists; |
| 1361 | | if (!image_is_writable(img)) |
| 1362 | | flags_for_writing |= MF_GRAYED; |
| 1358 | flags_for_writing = flags_for_exists; |
| 1359 | if (!image_is_writable(img)) |
| 1360 | flags_for_writing |= MF_GRAYED; |
| 1363 | 1361 | |
| 1364 | | sub_menu = CreateMenu(); |
| 1365 | | append_menu_uistring(sub_menu, MF_STRING, new_item + DEVOPTION_OPEN, UI_mount); |
| 1362 | sub_menu = CreateMenu(); |
| 1363 | append_menu_uistring(sub_menu, MF_STRING, new_item + DEVOPTION_OPEN, UI_mount); |
| 1366 | 1364 | |
| 1367 | | if (dev->creatable) |
| 1368 | | append_menu_uistring(sub_menu, MF_STRING, new_item + DEVOPTION_CREATE, UI_create); |
| 1365 | if (dev->creatable) |
| 1366 | append_menu_uistring(sub_menu, MF_STRING, new_item + DEVOPTION_CREATE, UI_create); |
| 1369 | 1367 | |
| 1370 | | append_menu_uistring(sub_menu, flags_for_exists, new_item + DEVOPTION_CLOSE, UI_unmount); |
| 1368 | append_menu_uistring(sub_menu, flags_for_exists, new_item + DEVOPTION_CLOSE, UI_unmount); |
| 1371 | 1369 | |
| 1372 | 1370 | #if HAS_WAVE |
| 1373 | | if ((dev->type == IO_CASSETTE) && !strcmp(dev->file_extensions, "wav")) |
| 1374 | | { |
| 1375 | | cassette_state state; |
| 1376 | | state = image_exists(img) ? (cassette_get_state(img) & CASSETTE_MASK_UISTATE) : CASSETTE_STOPPED; |
| 1377 | | append_menu_uistring(sub_menu, MF_SEPARATOR, 0, -1); |
| 1378 | | append_menu_uistring(sub_menu, flags_for_exists | ((state == CASSETTE_STOPPED) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_STOPPAUSE, UI_pauseorstop); |
| 1379 | | append_menu_uistring(sub_menu, flags_for_exists | ((state == CASSETTE_PLAY) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_PLAY, UI_play); |
| 1380 | | append_menu_uistring(sub_menu, flags_for_writing | ((state == CASSETTE_RECORD) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_RECORD, UI_record); |
| 1371 | if ((dev->type == IO_CASSETTE) && !strcmp(dev->file_extensions, "wav")) |
| 1372 | { |
| 1373 | cassette_state state; |
| 1374 | state = image_exists(img) ? (cassette_get_state(img) & CASSETTE_MASK_UISTATE) : CASSETTE_STOPPED; |
| 1375 | append_menu_uistring(sub_menu, MF_SEPARATOR, 0, -1); |
| 1376 | append_menu_uistring(sub_menu, flags_for_exists | ((state == CASSETTE_STOPPED) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_STOPPAUSE, UI_pauseorstop); |
| 1377 | append_menu_uistring(sub_menu, flags_for_exists | ((state == CASSETTE_PLAY) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_PLAY, UI_play); |
| 1378 | append_menu_uistring(sub_menu, flags_for_writing | ((state == CASSETTE_RECORD) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_RECORD, UI_record); |
| 1381 | 1379 | #if USE_TAPEDLG |
| 1382 | | append_menu_uistring(sub_menu, flags_for_exists, new_item + DEVOPTION_CASSETTE_DIALOG, UI_tapecontrol); |
| 1380 | append_menu_uistring(sub_menu, flags_for_exists, new_item + DEVOPTION_CASSETTE_DIALOG, UI_tapecontrol); |
| 1383 | 1381 | #else |
| 1384 | | append_menu_uistring(sub_menu, flags_for_exists, new_item + DEVOPTION_CASSETTE_REWIND, UI_rewind); |
| 1385 | | append_menu_uistring(sub_menu, flags_for_exists, new_item + DEVOPTION_CASSETTE_FASTFORWARD, UI_fastforward); |
| 1382 | append_menu_uistring(sub_menu, flags_for_exists, new_item + DEVOPTION_CASSETTE_REWIND, UI_rewind); |
| 1383 | append_menu_uistring(sub_menu, flags_for_exists, new_item + DEVOPTION_CASSETTE_FASTFORWARD, UI_fastforward); |
| 1386 | 1384 | #endif |
| 1387 | | } |
| 1385 | } |
| 1388 | 1386 | #endif /* HAS_WAVE */ |
| 1389 | | s = image_exists(img) ? image_filename(img) : ui_getstring(UI_emptyslot); |
| 1390 | | flags = MF_POPUP; |
| 1387 | s = image_exists(img) ? image_filename(img) : ui_getstring(UI_emptyslot); |
| 1388 | flags = MF_POPUP; |
| 1391 | 1389 | |
| 1392 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s: %s", image_typename_id(img), s); |
| 1393 | | append_menu_utf8(device_menu, flags, (UINT_PTR) sub_menu, buf); |
| 1394 | | } |
| 1390 | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s: %s", image_typename_id(img), s); |
| 1391 | append_menu_utf8(device_menu, flags, (UINT_PTR) sub_menu, buf); |
| 1395 | 1392 | } |
| 1396 | 1393 | } |
| 1397 | 1394 | |
src/mess/osd/winui/messui.c
| r2132 | r2133 | |
| 378 | 378 | machine_config *config; |
| 379 | 379 | const device_config *dev; |
| 380 | 380 | const struct IODevice *iodev; |
| 381 | | int i, nPos; |
| 381 | int nPos; |
| 382 | 382 | char szMessage[256]; |
| 383 | 383 | LPCSTR pszSoftware; |
| 384 | 384 | BOOL bResult = FALSE; |
| r2132 | r2133 | |
| 396 | 396 | // confirm any mandatory devices are loaded |
| 397 | 397 | if (iodev->must_be_loaded) |
| 398 | 398 | { |
| 399 | | for (i = 0; i < iodev->count; i++) |
| 399 | pszSoftware = GetSelectedSoftware(drvindex, &iodev->devclass, iodev->index_in_device); |
| 400 | if (!pszSoftware || !*pszSoftware) |
| 400 | 401 | { |
| 401 | | pszSoftware = GetSelectedSoftware(drvindex, &iodev->devclass, i); |
| 402 | | if (!pszSoftware || !*pszSoftware) |
| 403 | | { |
| 404 | | snprintf(szMessage, sizeof(szMessage) / sizeof(szMessage[0]), |
| 405 | | "System '%s' requires that device %s must have an image to load\n", |
| 406 | | drivers[drvindex]->description, |
| 407 | | device_typename(iodev->type)); |
| 408 | | goto done; |
| 409 | | } |
| 402 | snprintf(szMessage, sizeof(szMessage) / sizeof(szMessage[0]), |
| 403 | "System '%s' requires that device %s must have an image to load\n", |
| 404 | drivers[drvindex]->description, |
| 405 | device_typename(iodev->type)); |
| 406 | goto done; |
| 410 | 407 | } |
| 411 | 408 | } |
| 412 | 409 | |
| 413 | | nPos += iodev->count; |
| 410 | nPos++; |
| 414 | 411 | } |
| 415 | 412 | bResult = TRUE; |
| 416 | 413 | |
| r2132 | r2133 | |
| 448 | 445 | const device_config *dev; |
| 449 | 446 | const struct IODevice *iodev = NULL; |
| 450 | 447 | const char *s; |
| 451 | | int i; |
| 452 | 448 | |
| 453 | 449 | // allocate the machine config |
| 454 | 450 | config = machine_config_alloc_with_mess_devices(drivers[drvindex]); |
| r2132 | r2133 | |
| 469 | 465 | if (nID < 0) |
| 470 | 466 | { |
| 471 | 467 | // special case; first try to find existing image |
| 472 | | for (i = 0; i < iodev->count; i++) |
| 468 | s = GetSelectedSoftware(drvindex, &iodev->devclass, iodev->index_in_device); |
| 469 | if (s && !mame_stricmp(s, pszFilename)) |
| 473 | 470 | { |
| 474 | | s = GetSelectedSoftware(drvindex, &iodev->devclass, i); |
| 475 | | if (s && !mame_stricmp(s, pszFilename)) |
| 476 | | { |
| 477 | | nID = i; |
| 478 | | break; |
| 479 | | } |
| 471 | nID = iodev->index_in_device; |
| 480 | 472 | } |
| 481 | 473 | } |
| 482 | 474 | |
| 483 | 475 | if (nID < 0) |
| 484 | 476 | { |
| 485 | 477 | // still not found? locate an empty slot |
| 486 | | for (i = 0; i < iodev->count; i++) |
| 478 | s = GetSelectedSoftware(drvindex, &iodev->devclass, iodev->index_in_device); |
| 479 | if (!s || !*s || !mame_stricmp(s, pszFilename)) |
| 487 | 480 | { |
| 488 | | s = GetSelectedSoftware(drvindex, &iodev->devclass, i); |
| 489 | | if (!s || !*s || !mame_stricmp(s, pszFilename)) |
| 490 | | { |
| 491 | | nID = i; |
| 492 | | break; |
| 493 | | } |
| 481 | nID = iodev->index_in_device; |
| 494 | 482 | } |
| 495 | 483 | } |
| 496 | 484 | |
| r2132 | r2133 | |
| 506 | 494 | |
| 507 | 495 | static void MessRemoveImage(int drvindex, mess_device_class devclass, LPCSTR pszFilename) |
| 508 | 496 | { |
| 509 | | int i, nPos; |
| 497 | int nPos; |
| 510 | 498 | machine_config *config; |
| 511 | 499 | const device_config *dev; |
| 512 | 500 | const struct IODevice *iodev = NULL; |
| r2132 | r2133 | |
| 523 | 511 | |
| 524 | 512 | if (iodev->devclass.get_info == devclass.get_info) |
| 525 | 513 | break; |
| 526 | | nPos += iodev->count; |
| 514 | nPos++; |
| 527 | 515 | } |
| 528 | 516 | |
| 529 | 517 | if (iodev != NULL) |
| 530 | 518 | { |
| 531 | | for (i = 0; i < iodev->count; i++) |
| 519 | if (!mame_stricmp(pszFilename, GetSelectedSoftware(drvindex, &iodev->devclass, iodev->index_in_device))) |
| 532 | 520 | { |
| 533 | | if (!mame_stricmp(pszFilename, GetSelectedSoftware(drvindex, &iodev->devclass, i))) |
| 534 | | { |
| 535 | | MessSpecifyImage(drvindex, &devclass, i, NULL); |
| 536 | | break; |
| 537 | | } |
| 521 | MessSpecifyImage(drvindex, &devclass, iodev->index_in_device, NULL); |
| 538 | 522 | } |
| 539 | 523 | } |
| 540 | 524 | |
| r2132 | r2133 | |
| 558 | 542 | static void MessRefreshPicker(int drvindex) |
| 559 | 543 | { |
| 560 | 544 | HWND hwndSoftware; |
| 561 | | int i, id; |
| 545 | int i; |
| 562 | 546 | LVFINDINFO lvfi; |
| 563 | 547 | machine_config *config; |
| 564 | 548 | const device_config *dev; |
| r2132 | r2133 | |
| 580 | 564 | { |
| 581 | 565 | iodev = mess_device_from_core_device(dev); |
| 582 | 566 | |
| 583 | | for (id = 0; id < iodev->count; id++) |
| 567 | pszSoftware = GetSelectedSoftware(drvindex, &iodev->devclass, iodev->index_in_device); |
| 568 | if (pszSoftware && *pszSoftware) |
| 584 | 569 | { |
| 585 | | pszSoftware = GetSelectedSoftware(drvindex, &iodev->devclass, id); |
| 586 | | if (pszSoftware && *pszSoftware) |
| 570 | i = SoftwarePicker_LookupIndex(hwndSoftware, pszSoftware); |
| 571 | if (i < 0) |
| 587 | 572 | { |
| 573 | SoftwarePicker_AddFile(hwndSoftware, pszSoftware); |
| 588 | 574 | i = SoftwarePicker_LookupIndex(hwndSoftware, pszSoftware); |
| 589 | | if (i < 0) |
| 590 | | { |
| 591 | | SoftwarePicker_AddFile(hwndSoftware, pszSoftware); |
| 592 | | i = SoftwarePicker_LookupIndex(hwndSoftware, pszSoftware); |
| 593 | | } |
| 594 | | if (i >= 0) |
| 595 | | { |
| 596 | | memset(&lvfi, 0, sizeof(lvfi)); |
| 597 | | lvfi.flags = LVFI_PARAM; |
| 598 | | lvfi.lParam = i; |
| 599 | | i = ListView_FindItem(hwndSoftware, -1, &lvfi); |
| 600 | | ListView_SetItemState(hwndSoftware, i, LVIS_SELECTED, LVIS_SELECTED); |
| 601 | | } |
| 602 | 575 | } |
| 576 | if (i >= 0) |
| 577 | { |
| 578 | memset(&lvfi, 0, sizeof(lvfi)); |
| 579 | lvfi.flags = LVFI_PARAM; |
| 580 | lvfi.lParam = i; |
| 581 | i = ListView_FindItem(hwndSoftware, -1, &lvfi); |
| 582 | ListView_SetItemState(hwndSoftware, i, LVIS_SELECTED, LVIS_SELECTED); |
| 583 | } |
| 603 | 584 | } |
| 604 | 585 | } |
| 605 | 586 | |
src/mess/osd/winui/devview.c
| r2132 | r2133 | |
| 39 | 39 | struct DevViewEntry |
| 40 | 40 | { |
| 41 | 41 | const struct IODevice *dev; |
| 42 | | int id; |
| 43 | 42 | HWND hwndStatic; |
| 44 | 43 | HWND hwndEdit; |
| 45 | 44 | HWND hwndBrowseButton; |
| r2132 | r2133 | |
| 126 | 125 | hwndDevView, |
| 127 | 126 | pDevViewInfo->nGame, |
| 128 | 127 | pDevViewInfo->pEntries[i].dev, |
| 129 | | pDevViewInfo->pEntries[i].id, |
| 128 | pDevViewInfo->pEntries[i].dev->index_in_device, |
| 130 | 129 | szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0])); |
| 131 | 130 | |
| 132 | 131 | if (!pszSelection) |
| r2132 | r2133 | |
| 151 | 150 | pDevViewInfo->pCallbacks->pfnSetSelectedSoftware(hwndDevView, |
| 152 | 151 | pDevViewInfo->nGame, |
| 153 | 152 | pDevViewInfo->pEntries[nChangedEntry].dev, |
| 154 | | pDevViewInfo->pEntries[nChangedEntry].id, |
| 153 | pDevViewInfo->pEntries[nChangedEntry].dev->index_in_device, |
| 155 | 154 | pszFilename); |
| 156 | 155 | } |
| 157 | 156 | } |
| r2132 | r2133 | |
| 190 | 189 | const device_config *dev; |
| 191 | 190 | const struct IODevice *iodev; |
| 192 | 191 | struct DevViewEntry *pEnt; |
| 193 | | int i, id; |
| 192 | int i; |
| 194 | 193 | int y, nHeight, nDevCount; |
| 195 | 194 | int nStaticPos, nStaticWidth, nEditPos, nEditWidth, nButtonPos, nButtonWidth; |
| 196 | 195 | HDC hDc; |
| r2132 | r2133 | |
| 217 | 216 | for (dev = device_list_first(pDevViewInfo->config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE)) |
| 218 | 217 | { |
| 219 | 218 | iodev = mess_device_from_core_device(dev); |
| 220 | | nDevCount += iodev->count; |
| 219 | nDevCount += 1; |
| 221 | 220 | } |
| 222 | 221 | |
| 223 | 222 | if (nDevCount > 0) |
| r2132 | r2133 | |
| 230 | 229 | { |
| 231 | 230 | iodev = mess_device_from_core_device(dev); |
| 232 | 231 | |
| 233 | | for (id = 0; id < iodev->count; id++) |
| 234 | | { |
| 235 | | utf8_s = iodev->name(iodev, id, buf, sizeof(buf) / sizeof(buf[0])); |
| 236 | | s = tstring_from_utf8(utf8_s); |
| 237 | | ppszDevices[i] = alloca((_tcslen(s) + 1) * sizeof(TCHAR)); |
| 238 | | _tcscpy(ppszDevices[i], s); |
| 239 | | free(s); |
| 240 | | i++; |
| 241 | | } |
| 232 | utf8_s = iodev->name(iodev, iodev->index_in_device, buf, sizeof(buf) / sizeof(buf[0])); |
| 233 | s = tstring_from_utf8(utf8_s); |
| 234 | ppszDevices[i] = alloca((_tcslen(s) + 1) * sizeof(TCHAR)); |
| 235 | _tcscpy(ppszDevices[i], s); |
| 236 | free(s); |
| 237 | i++; |
| 242 | 238 | } |
| 243 | 239 | |
| 244 | 240 | // Calculate the requisite size for the device column |
| r2132 | r2133 | |
| 270 | 266 | { |
| 271 | 267 | iodev = mess_device_from_core_device(dev); |
| 272 | 268 | |
| 273 | | for (id = 0; id < iodev->count; id++) |
| 274 | | { |
| 275 | | pEnt->dev = iodev; |
| 276 | | pEnt->id = id; |
| 269 | pEnt->dev = iodev; |
| 277 | 270 | |
| 278 | | pEnt->hwndStatic = win_create_window_ex_utf8(0, "STATIC", iodev->name(iodev, id, buf, sizeof(buf) / sizeof(buf[0])), |
| 279 | | WS_VISIBLE | WS_CHILD, nStaticPos, y, nStaticWidth, nHeight, |
| 280 | | hwndDevView, NULL, NULL, NULL); |
| 271 | pEnt->hwndStatic = win_create_window_ex_utf8(0, "STATIC", iodev->name(iodev, iodev->index_in_device, buf, sizeof(buf) / sizeof(buf[0])), |
| 272 | WS_VISIBLE | WS_CHILD, nStaticPos, y, nStaticWidth, nHeight, |
| 273 | hwndDevView, NULL, NULL, NULL); |
| 281 | 274 | |
| 282 | | pEnt->hwndEdit = win_create_window_ex_utf8(0, "EDIT", "", |
| 283 | | WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, nEditPos, y, nEditWidth, nHeight, |
| 284 | | hwndDevView, NULL, NULL, NULL); |
| 275 | pEnt->hwndEdit = win_create_window_ex_utf8(0, "EDIT", "", |
| 276 | WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, nEditPos, y, nEditWidth, nHeight, |
| 277 | hwndDevView, NULL, NULL, NULL); |
| 285 | 278 | |
| 286 | | pEnt->hwndBrowseButton = win_create_window_ex_utf8(0, "BUTTON", "...", |
| 287 | | WS_VISIBLE | WS_CHILD, nButtonPos, y, nButtonWidth, nHeight, |
| 288 | | hwndDevView, NULL, NULL, NULL); |
| 279 | pEnt->hwndBrowseButton = win_create_window_ex_utf8(0, "BUTTON", "...", |
| 280 | WS_VISIBLE | WS_CHILD, nButtonPos, y, nButtonWidth, nHeight, |
| 281 | hwndDevView, NULL, NULL, NULL); |
| 289 | 282 | |
| 290 | | if (pEnt->hwndStatic) |
| 291 | | { |
| 292 | | SendMessage(pEnt->hwndStatic, WM_SETFONT, (WPARAM) pDevViewInfo->hFont, TRUE); |
| 293 | | } |
| 294 | | if (pEnt->hwndEdit) |
| 295 | | { |
| 296 | | SendMessage(pEnt->hwndEdit, WM_SETFONT, (WPARAM) pDevViewInfo->hFont, TRUE); |
| 297 | | l = (LONG_PTR) DevView_EditWndProc; |
| 298 | | l = SetWindowLongPtr(pEnt->hwndEdit, GWLP_WNDPROC, l); |
| 299 | | pEnt->pfnEditWndProc = (WNDPROC) l; |
| 300 | | SetWindowLongPtr(pEnt->hwndEdit, GWLP_USERDATA, (LONG_PTR) pEnt); |
| 301 | | } |
| 302 | | if (pEnt->hwndBrowseButton) |
| 303 | | { |
| 304 | | SetWindowLongPtr(pEnt->hwndBrowseButton, GWLP_USERDATA, (LONG_PTR) pEnt); |
| 305 | | } |
| 306 | | |
| 307 | | y += nHeight; |
| 308 | | pEnt++; |
| 283 | if (pEnt->hwndStatic) |
| 284 | { |
| 285 | SendMessage(pEnt->hwndStatic, WM_SETFONT, (WPARAM) pDevViewInfo->hFont, TRUE); |
| 309 | 286 | } |
| 287 | if (pEnt->hwndEdit) |
| 288 | { |
| 289 | SendMessage(pEnt->hwndEdit, WM_SETFONT, (WPARAM) pDevViewInfo->hFont, TRUE); |
| 290 | l = (LONG_PTR) DevView_EditWndProc; |
| 291 | l = SetWindowLongPtr(pEnt->hwndEdit, GWLP_WNDPROC, l); |
| 292 | pEnt->pfnEditWndProc = (WNDPROC) l; |
| 293 | SetWindowLongPtr(pEnt->hwndEdit, GWLP_USERDATA, (LONG_PTR) pEnt); |
| 294 | } |
| 295 | if (pEnt->hwndBrowseButton) |
| 296 | { |
| 297 | SetWindowLongPtr(pEnt->hwndBrowseButton, GWLP_USERDATA, (LONG_PTR) pEnt); |
| 298 | } |
| 299 | |
| 300 | y += nHeight; |
| 301 | pEnt++; |
| 310 | 302 | } |
| 311 | 303 | } |
| 312 | 304 | |