src/mess/image.c
| r2271 | r2272 | |
| 272 | 272 | ****************************************************************************/ |
| 273 | 273 | |
| 274 | 274 | /*------------------------------------------------- |
| 275 | image_device_getinfo - returns info on a device; |
| 276 | can be called by front end code |
| 277 | -------------------------------------------------*/ |
| 278 | |
| 279 | image_device_info image_device_getinfo(const device_config *device) |
| 280 | { |
| 281 | const struct IODevice *iodev; |
| 282 | const char *s; |
| 283 | image_device_info info; |
| 284 | int i; |
| 285 | |
| 286 | memset(&info, 0, sizeof(info)); |
| 287 | |
| 288 | iodev = mess_device_from_core_device(device); |
| 289 | if (iodev != NULL) |
| 290 | { |
| 291 | /* retrieve type */ |
| 292 | info.type = iodev->type; |
| 293 | |
| 294 | /* retrieve flags */ |
| 295 | info.readable = iodev->readable; |
| 296 | info.writeable = iodev->writeable; |
| 297 | info.creatable = iodev->creatable; |
| 298 | info.must_be_loaded = iodev->must_be_loaded; |
| 299 | info.uses_partial_hash = iodev->partialhash != NULL; |
| 300 | |
| 301 | /* retrieve name */ |
| 302 | s = (*iodev->name)(iodev, iodev->index_in_device, info.name, ARRAY_LENGTH(info.name)); |
| 303 | if (s != info.name) |
| 304 | snprintf(info.name, ARRAY_LENGTH(info.name), "%s", s); |
| 305 | |
| 306 | /* retrieve file extensions */ |
| 307 | for(i = 0; iodev->file_extensions[i] != '\0'; i += strlen(&iodev->file_extensions[i]) + 1) |
| 308 | ; |
| 309 | memcpy(info.file_extensions, iodev->file_extensions, i * sizeof(info.file_extensions[0])); |
| 310 | |
| 311 | /* retrieve instance name */ |
| 312 | s = device_instancename(&iodev->devclass, iodev->index_in_device); |
| 313 | snprintf(info.instance_name, ARRAY_LENGTH(info.instance_name), "%s", s); |
| 314 | |
| 315 | /* retrieve brief instance name */ |
| 316 | s = device_briefinstancename(&iodev->devclass, iodev->index_in_device); |
| 317 | snprintf(info.brief_instance_name, ARRAY_LENGTH(info.brief_instance_name), "%s", s); |
| 318 | } |
| 319 | |
| 320 | return info; |
| 321 | } |
| 322 | |
| 323 | |
| 324 | |
| 325 | /*------------------------------------------------- |
| 275 | 326 | image_device_uses_file_extension - checks to |
| 276 | 327 | see if a particular devices uses a certain |
| 277 | 328 | file extension |
src/mess/image.h
| r2271 | r2272 | |
| 57 | 57 | IMAGE_ERROR_UNSPECIFIED |
| 58 | 58 | } image_error_t; |
| 59 | 59 | |
| 60 | typedef struct _image_device_info image_device_info; |
| 61 | struct _image_device_info |
| 62 | { |
| 63 | iodevice_t type : 8; |
| 64 | unsigned int readable : 1; |
| 65 | unsigned int writeable : 1; |
| 66 | unsigned int creatable : 1; |
| 67 | unsigned int must_be_loaded : 1; |
| 68 | unsigned int uses_partial_hash : 1; |
| 69 | char name[62]; |
| 70 | char file_extensions[32]; |
| 71 | char instance_name[32]; |
| 72 | char brief_instance_name[16]; |
| 73 | }; |
| 74 | |
| 60 | 75 | struct _images_private; |
| 61 | 76 | typedef struct _images_private images_private; |
| 62 | 77 | |
| r2271 | r2272 | |
| 99 | 114 | |
| 100 | 115 | /* ----- analysis ----- */ |
| 101 | 116 | |
| 117 | /* returns info on a device - can be called by front end code */ |
| 118 | image_device_info image_device_getinfo(const device_config *device); |
| 119 | |
| 102 | 120 | /* checks to see if a particular devices uses a certain file extension */ |
| 103 | 121 | int image_device_uses_file_extension(const device_config *device, const char *file_extension); |
| 104 | 122 | |
src/mess/osd/winui/messui.c
| r2271 | r2272 | |
| 377 | 377 | { |
| 378 | 378 | machine_config *config; |
| 379 | 379 | const device_config *dev; |
| 380 | | const struct IODevice *iodev; |
| 381 | 380 | int nPos; |
| 382 | 381 | char szMessage[256]; |
| 383 | 382 | LPCSTR pszSoftware; |
| r2271 | r2272 | |
| 391 | 390 | nPos = 0; |
| 392 | 391 | for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev)) |
| 393 | 392 | { |
| 394 | | iodev = mess_device_from_core_device(dev); |
| 393 | image_device_info info = image_device_getinfo(dev); |
| 395 | 394 | |
| 396 | 395 | // confirm any mandatory devices are loaded |
| 397 | | if (iodev->must_be_loaded) |
| 396 | if (info.must_be_loaded) |
| 398 | 397 | { |
| 399 | 398 | pszSoftware = GetSelectedSoftware(drvindex, dev); |
| 400 | 399 | if (!pszSoftware || !*pszSoftware) |
| r2271 | r2272 | |
| 402 | 401 | snprintf(szMessage, sizeof(szMessage) / sizeof(szMessage[0]), |
| 403 | 402 | "System '%s' requires that device %s must have an image to load\n", |
| 404 | 403 | drivers[drvindex]->description, |
| 405 | | device_typename(iodev->type)); |
| 404 | device_typename(info.type)); |
| 406 | 405 | goto done; |
| 407 | 406 | } |
| 408 | 407 | } |
| r2271 | r2272 | |
| 523 | 522 | LVFINDINFO lvfi; |
| 524 | 523 | machine_config *config; |
| 525 | 524 | const device_config *dev; |
| 526 | | const struct IODevice *iodev; |
| 527 | 525 | LPCSTR pszSoftware; |
| 528 | 526 | |
| 529 | 527 | hwndSoftware = GetDlgItem(GetMainWindow(), IDC_SWLIST); |
| r2271 | r2272 | |
| 539 | 537 | |
| 540 | 538 | for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev)) |
| 541 | 539 | { |
| 542 | | iodev = mess_device_from_core_device(dev); |
| 543 | | |
| 544 | 540 | pszSoftware = GetSelectedSoftware(drvindex, dev); |
| 545 | 541 | if (pszSoftware && *pszSoftware) |
| 546 | 542 | { |
| r2271 | r2272 | |
| 606 | 602 | |
| 607 | 603 | typedef struct |
| 608 | 604 | { |
| 609 | | const struct IODevice *dev; |
| 605 | const device_config *dev; |
| 610 | 606 | const char *ext; |
| 611 | 607 | } mess_image_type; |
| 612 | 608 | |
| r2271 | r2272 | |
| 652 | 648 | if (!imagetypes[i].dev) |
| 653 | 649 | typname = "Compressed images"; |
| 654 | 650 | else |
| 655 | | typname = lookupdevice(imagetypes[i].dev->type)->dlgname; |
| 651 | typname = lookupdevice(image_device_getinfo(imagetypes[i].dev).type)->dlgname; |
| 656 | 652 | |
| 657 | 653 | strcpy(s, typname); |
| 658 | 654 | s += strlen(s); |
| r2271 | r2272 | |
| 736 | 732 | /* special case; all non-printer devices */ |
| 737 | 733 | for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev)) |
| 738 | 734 | { |
| 739 | | const struct IODevice *iodev = mess_device_from_core_device(dev); |
| 735 | image_device_info info = image_device_getinfo(dev); |
| 740 | 736 | |
| 741 | | if (iodev->type != IO_PRINTER) |
| 737 | if (info.type != IO_PRINTER) |
| 742 | 738 | SetupImageTypes(config, &types[num_extensions], count - num_extensions, FALSE, dev); |
| 743 | 739 | } |
| 744 | 740 | |
| 745 | 741 | } |
| 746 | 742 | else |
| 747 | 743 | { |
| 748 | | const struct IODevice *iodev = mess_device_from_core_device(dev); |
| 749 | | const char *ext = iodev->file_extensions; |
| 744 | image_device_info info = image_device_getinfo(dev); |
| 745 | const char *ext = info.file_extensions; |
| 750 | 746 | |
| 751 | 747 | if (ext != NULL) |
| 752 | 748 | { |
| r2271 | r2272 | |
| 754 | 750 | { |
| 755 | 751 | if (num_extensions < count) |
| 756 | 752 | { |
| 757 | | types[num_extensions].dev = iodev; |
| 753 | types[num_extensions].dev = dev; |
| 758 | 754 | types[num_extensions].ext = ext; |
| 759 | 755 | num_extensions++; |
| 760 | 756 | } |
| r2271 | r2272 | |
| 913 | 909 | nIcon = GetMessIcon(drvindex, nType); |
| 914 | 910 | if (!nIcon) |
| 915 | 911 | { |
| 916 | | if (nType < 0) |
| 912 | if (nType == 0) |
| 917 | 913 | nType = IO_BAD; |
| 918 | 914 | switch(nType) |
| 919 | 915 | { |
src/mess/osd/winui/devview.c
| r2271 | r2272 | |
| 193 | 193 | LPTSTR *ppszDevices; |
| 194 | 194 | LPTSTR s; |
| 195 | 195 | SIZE sz; |
| 196 | | char buf[128]; |
| 197 | 196 | LONG_PTR l; |
| 198 | | const char* utf8_s; |
| 199 | 197 | |
| 200 | 198 | pDevViewInfo = GetDevViewInfo(hwndDevView); |
| 201 | 199 | |
| r2271 | r2272 | |
| 219 | 217 | |
| 220 | 218 | for (dev = image_device_first(pDevViewInfo->config); dev != NULL; dev = image_device_next(dev)) |
| 221 | 219 | { |
| 222 | | const struct IODevice *iodev = mess_device_from_core_device(dev); |
| 220 | image_device_info info = image_device_getinfo(dev); |
| 223 | 221 | |
| 224 | | utf8_s = iodev->name(iodev, iodev->index_in_device, buf, sizeof(buf) / sizeof(buf[0])); |
| 225 | | s = tstring_from_utf8(utf8_s); |
| 222 | s = tstring_from_utf8(info.name); |
| 226 | 223 | ppszDevices[i] = alloca((_tcslen(s) + 1) * sizeof(TCHAR)); |
| 227 | 224 | _tcscpy(ppszDevices[i], s); |
| 228 | 225 | free(s); |
| r2271 | r2272 | |
| 256 | 253 | |
| 257 | 254 | for (dev = image_device_first(pDevViewInfo->config); dev != NULL; dev = image_device_next(dev)) |
| 258 | 255 | { |
| 259 | | const struct IODevice *iodev = mess_device_from_core_device(dev); |
| 256 | image_device_info info = image_device_getinfo(dev); |
| 260 | 257 | |
| 261 | 258 | pEnt->dev = dev; |
| 262 | 259 | |
| 263 | | pEnt->hwndStatic = win_create_window_ex_utf8(0, "STATIC", iodev->name(iodev, iodev->index_in_device, buf, sizeof(buf) / sizeof(buf[0])), |
| 260 | pEnt->hwndStatic = win_create_window_ex_utf8(0, "STATIC", info.name, |
| 264 | 261 | WS_VISIBLE | WS_CHILD, nStaticPos, y, nStaticWidth, nHeight, |
| 265 | 262 | hwndDevView, NULL, NULL, NULL); |
| 266 | 263 | |
src/mess/osd/winui/optionsms.c
| r2271 | r2272 | |
| 142 | 142 | |
| 143 | 143 | void SetSelectedSoftware(int driver_index, const device_config *dev, const char *software) |
| 144 | 144 | { |
| 145 | | const struct IODevice *iodev = mess_device_from_core_device(dev); |
| 146 | | const char *opt_name = device_instancename(&iodev->devclass, iodev->index_in_device); |
| 145 | image_device_info info = image_device_getinfo(dev); |
| 146 | const char *opt_name = info.instance_name; |
| 147 | 147 | core_options *o; |
| 148 | 148 | |
| 149 | 149 | if (LOG_SOFTWARE) |
| r2271 | r2272 | |
| 160 | 160 | |
| 161 | 161 | const char *GetSelectedSoftware(int driver_index, const device_config *dev) |
| 162 | 162 | { |
| 163 | | const struct IODevice *iodev = mess_device_from_core_device(dev); |
| 164 | | const char *opt_name = device_instancename(&iodev->devclass, iodev->index_in_device); |
| 163 | image_device_info info = image_device_getinfo(dev); |
| 164 | const char *opt_name = info.instance_name; |
| 165 | 165 | const char *software; |
| 166 | 166 | core_options *o; |
| 167 | 167 | |