src/mess/image.c
| r2318 | r2319 | |
| 375 | 375 | |
| 376 | 376 | |
| 377 | 377 | /*------------------------------------------------- |
| 378 | get_device_file_extensions - retrieves the file |
| 379 | extensions used by a device |
| 380 | -------------------------------------------------*/ |
| 381 | |
| 382 | static void get_device_file_extensions(const device_config *device, char *buffer, size_t buffer_len) |
| 383 | { |
| 384 | const char *file_extensions; |
| 385 | char *s; |
| 386 | |
| 387 | /* be pedantic - we need room for a string list */ |
| 388 | assert(buffer_len > 0); |
| 389 | buffer_len--; |
| 390 | |
| 391 | /* copy the string */ |
| 392 | file_extensions = device_get_info_string_offline(device, DEVINFO_STR_IMAGE_FILE_EXTENSIONS); |
| 393 | snprintf(buffer, buffer_len, "%s", (file_extensions != NULL) ? file_extensions : ""); |
| 394 | |
| 395 | /* convert the comma delimited list to a NUL delimited list */ |
| 396 | s = buffer; |
| 397 | while((s = strchr(s, ',')) != NULL) |
| 398 | *(s++) = '\0'; |
| 399 | } |
| 400 | |
| 401 | |
| 402 | |
| 403 | /*------------------------------------------------- |
| 378 | 404 | image_device_getinfo - returns info on a device; |
| 379 | 405 | can be called by front end code |
| 380 | 406 | -------------------------------------------------*/ |
| r2318 | r2319 | |
| 384 | 410 | const struct IODevice *iodev; |
| 385 | 411 | const char *s; |
| 386 | 412 | image_device_info info; |
| 387 | | int i; |
| 388 | 413 | |
| 389 | 414 | memset(&info, 0, sizeof(info)); |
| 390 | 415 | |
| r2318 | r2319 | |
| 400 | 425 | /* retrieve name */ |
| 401 | 426 | get_device_name(device, info.name, ARRAY_LENGTH(info.name)); |
| 402 | 427 | |
| 428 | /* retrieve file extensions */ |
| 429 | get_device_file_extensions(device, info.file_extensions, ARRAY_LENGTH(info.file_extensions)); |
| 430 | |
| 403 | 431 | iodev = mess_device_from_core_device(device); |
| 404 | 432 | if (iodev != NULL) |
| 405 | 433 | { |
| 406 | | /* retrieve file extensions */ |
| 407 | | for(i = 0; iodev->file_extensions[i] != '\0'; i += strlen(&iodev->file_extensions[i]) + 1) |
| 408 | | ; |
| 409 | | memcpy(info.file_extensions, iodev->file_extensions, i * sizeof(info.file_extensions[0])); |
| 410 | | |
| 411 | 434 | /* retrieve instance name */ |
| 412 | 435 | s = device_instancename(&iodev->devclass, iodev->index_in_device); |
| 413 | 436 | snprintf(info.instance_name, ARRAY_LENGTH(info.instance_name), "%s", s); |
| r2318 | r2319 | |
| 431 | 454 | int image_device_uses_file_extension(const device_config *device, const char *file_extension) |
| 432 | 455 | { |
| 433 | 456 | int result = FALSE; |
| 434 | | const struct IODevice *iodev; |
| 457 | const char *s; |
| 458 | char file_extension_list[256]; |
| 435 | 459 | |
| 436 | 460 | /* skip initial period, if present */ |
| 437 | 461 | if (file_extension[0] == '.') |
| 438 | 462 | file_extension++; |
| 439 | 463 | |
| 440 | | iodev = mess_device_from_core_device(device); |
| 441 | | if (iodev != NULL) |
| 464 | /* retrieve file extension list */ |
| 465 | get_device_file_extensions(device, file_extension_list, ARRAY_LENGTH(file_extension_list)); |
| 466 | |
| 467 | /* find the extensions */ |
| 468 | s = file_extension_list; |
| 469 | while(!result && (*s != '\0')) |
| 442 | 470 | { |
| 443 | | const char *s = iodev->file_extensions; |
| 444 | | while(!result && (*s != '\0')) |
| 471 | if (!mame_stricmp(s, file_extension)) |
| 445 | 472 | { |
| 446 | | if (!mame_stricmp(s, file_extension)) |
| 447 | | { |
| 448 | | result = TRUE; |
| 449 | | break; |
| 450 | | } |
| 451 | | s += strlen(s) + 1; |
| 473 | result = TRUE; |
| 474 | break; |
| 452 | 475 | } |
| 476 | s += strlen(s) + 1; |
| 453 | 477 | } |
| 454 | 478 | return result; |
| 455 | 479 | } |
src/mess/device.c
| r2318 | r2319 | |
| 276 | 276 | case DEVINFO_INT_IMAGE_READABLE: info->i = mess_device->io_device.readable; break; |
| 277 | 277 | case DEVINFO_INT_IMAGE_WRITEABLE: info->i = mess_device->io_device.writeable; break; |
| 278 | 278 | case DEVINFO_INT_IMAGE_CREATABLE: info->i = mess_device->io_device.creatable; break; |
| 279 | case DEVINFO_INT_IMAGE_TYPE: info->i = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_TYPE); break; |
| 279 | 280 | case DEVINFO_INT_IMAGE_MUST_BE_LOADED: info->i = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_MUST_BE_LOADED); break; |
| 280 | 281 | |
| 281 | 282 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| r2318 | r2319 | |
| 296 | 297 | case DEVINFO_STR_VERSION: info->s = "1.0"; break; |
| 297 | 298 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; |
| 298 | 299 | case DEVINFO_STR_CREDITS: info->s = "Copyright the MESS Team"; break; |
| 300 | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: info->s = mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_FILE_EXTENSIONS); break; |
| 299 | 301 | } |
| 300 | 302 | } |
| 301 | 303 | |
| r2318 | r2319 | |
| 357 | 359 | char dynamic_tag[32]; |
| 358 | 360 | device_config *device; |
| 359 | 361 | mess_device_config *mess_device; |
| 360 | | const char *file_extensions; |
| 361 | 362 | int i, j, count; |
| 362 | 363 | size_t string_buffer_pos = 0; |
| 363 | 364 | int createimage_optcount; |
| r2318 | r2319 | |
| 398 | 399 | info_string = mess_tag; |
| 399 | 400 | mess_tag = string_buffer_putstr(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, info_string); |
| 400 | 401 | |
| 401 | | /* convert file extensions from comma delimited to null delimited */ |
| 402 | | file_extensions = mess_device_get_info_string(&mess_devclass, MESS_DEVINFO_STR_FILE_EXTENSIONS); |
| 403 | | if (file_extensions != NULL) |
| 404 | | { |
| 405 | | const char *file_extensions_copy = &mess_device->string_buffer[string_buffer_pos]; |
| 406 | | |
| 407 | | /* copy the file extensions over to the buffer */ |
| 408 | | for (j = 0; file_extensions[j] != '\0'; j++) |
| 409 | | { |
| 410 | | string_buffer_putc(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, |
| 411 | | (file_extensions[j] != ',') ? file_extensions[j] : '\0'); |
| 412 | | } |
| 413 | | string_buffer_putc(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, '\0'); |
| 414 | | string_buffer_putc(mess_device->string_buffer, ARRAY_LENGTH(mess_device->string_buffer), &string_buffer_pos, '\0'); |
| 415 | | |
| 416 | | file_extensions = file_extensions_copy; |
| 417 | | } |
| 418 | | |
| 419 | 402 | /* populate the legacy MESS device */ |
| 420 | 403 | mess_device->io_device.tag = mess_tag; |
| 421 | 404 | mess_device->io_device.devconfig = device; |
| r2318 | r2319 | |
| 423 | 406 | mess_device->io_device.type = mess_device_get_info_int(&mess_device->io_device.devclass, MESS_DEVINFO_INT_TYPE); |
| 424 | 407 | mess_device->io_device.position = *position; |
| 425 | 408 | mess_device->io_device.index_in_device = i; |
| 426 | | mess_device->io_device.file_extensions = file_extensions; |
| 427 | 409 | |
| 428 | 410 | 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; |
| 429 | 411 | 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; |
src/mess/osd/windows/menu.c
| r2318 | r2319 | |
| 1353 | 1353 | // then set up the actual devices |
| 1354 | 1354 | for (img = image_device_first(machine->config); img != NULL; img = image_device_next(img)) |
| 1355 | 1355 | { |
| 1356 | | const struct IODevice *dev = mess_device_from_core_device(img); |
| 1356 | image_device_info info = image_device_getinfo(img); |
| 1357 | 1357 | |
| 1358 | 1358 | new_item = ID_DEVICE_0 + (image_absolute_index(img) * DEVOPTION_MAX); |
| 1359 | 1359 | flags_for_exists = MF_STRING; |
| r2318 | r2319 | |
| 1368 | 1368 | sub_menu = CreateMenu(); |
| 1369 | 1369 | append_menu_uistring(sub_menu, MF_STRING, new_item + DEVOPTION_OPEN, UI_mount); |
| 1370 | 1370 | |
| 1371 | | if (dev->creatable) |
| 1371 | if (info.creatable) |
| 1372 | 1372 | append_menu_uistring(sub_menu, MF_STRING, new_item + DEVOPTION_CREATE, UI_create); |
| 1373 | 1373 | |
| 1374 | 1374 | append_menu_uistring(sub_menu, flags_for_exists, new_item + DEVOPTION_CLOSE, UI_unmount); |
| 1375 | 1375 | |
| 1376 | 1376 | #if HAS_WAVE |
| 1377 | | if ((dev->type == IO_CASSETTE) && !strcmp(dev->file_extensions, "wav")) |
| 1377 | if ((info.type == IO_CASSETTE) && !strcmp(info.file_extensions, "wav")) |
| 1378 | 1378 | { |
| 1379 | 1379 | cassette_state state; |
| 1380 | 1380 | state = image_exists(img) ? (cassette_get_state(img) & CASSETTE_MASK_UISTATE) : CASSETTE_STOPPED; |
src/mess/osd/winui/messui.c
| r2318 | r2319 | |
| 36 | 36 | |
| 37 | 37 | #define LOG_SOFTWARE 0 |
| 38 | 38 | |
| 39 | | #ifdef UNUSED_FUNCTION |
| 40 | | static int requested_device_type(char *tchar); |
| 41 | | #endif |
| 42 | | |
| 43 | 39 | static void SoftwarePicker_OnHeaderContextMenu(POINT pt, int nColumn); |
| 44 | 40 | |
| 45 | 41 | static LPCSTR SoftwareTabView_GetTabShortName(int tab); |
| r2318 | r2319 | |
| 86 | 82 | |
| 87 | 83 | struct deviceentry |
| 88 | 84 | { |
| 89 | | int dev_type; |
| 85 | iodevice_t dev_type; |
| 90 | 86 | const char *icon_name; |
| 91 | 87 | const char *dlgname; |
| 92 | 88 | }; |
| r2318 | r2319 | |
| 172 | 168 | |
| 173 | 169 | |
| 174 | 170 | |
| 175 | | static void AssertValidDevice(int d) |
| 171 | static const struct deviceentry *lookupdevice(iodevice_t d) |
| 176 | 172 | { |
| 177 | | assert((sizeof(s_devices) / sizeof(s_devices[0])) == IO_COUNT); |
| 178 | | assert(((d >= 0) && (d < IO_COUNT)) || (d == IO_UNKNOWN) || (d == IO_BAD) || (d == IO_ZIP)); |
| 179 | | } |
| 180 | | |
| 181 | | |
| 182 | | |
| 183 | | static const struct deviceentry *lookupdevice(int d) |
| 184 | | { |
| 185 | | assert(d >= 0); |
| 186 | | assert(d < IO_COUNT); |
| 187 | | AssertValidDevice(d); |
| 188 | | return &s_devices[d]; |
| 189 | | } |
| 190 | | |
| 191 | | |
| 192 | | |
| 193 | | // ------------------------------------------------------------------------ |
| 194 | | #ifdef UNUSED_FUNCTION |
| 195 | | static int requested_device_type(char *tchar) |
| 196 | | { |
| 197 | | int device = -1; |
| 198 | 173 | int i; |
| 199 | | |
| 200 | | logerror("Requested device is %s\n", tchar); |
| 201 | | |
| 202 | | if (*tchar == '-') |
| 174 | for (i = 0; i < ARRAY_LENGTH(s_devices); i++) |
| 203 | 175 | { |
| 204 | | tchar++; |
| 205 | | |
| 206 | | for (i = 1; i < IO_COUNT; i++) |
| 207 | | { |
| 208 | | if (!mame_stricmp(tchar, device_typename(i)) || !mame_stricmp(tchar, device_brieftypename(i))) |
| 209 | | { |
| 210 | | device = i; |
| 211 | | break; |
| 212 | | } |
| 213 | | } |
| 176 | if (s_devices[i].dev_type == d) |
| 177 | return &s_devices[i]; |
| 214 | 178 | } |
| 215 | | |
| 216 | | return device; |
| 179 | return NULL; |
| 217 | 180 | } |
| 218 | | #endif |
| 219 | 181 | |
| 220 | 182 | |
| 183 | |
| 221 | 184 | // ------------------------------------------------------------------------ |
| 222 | 185 | // UI |
| 223 | 186 | // ------------------------------------------------------------------------ |
| r2318 | r2319 | |
| 895 | 858 | |
| 896 | 859 | static int SoftwarePicker_GetItemImage(HWND hwndPicker, int nItem) |
| 897 | 860 | { |
| 898 | | int nType; |
| 861 | iodevice_t nType; |
| 899 | 862 | int nIcon; |
| 900 | 863 | int drvindex; |
| 901 | 864 | const char *icon_name; |