src/mess/tools/messtest/testmess.c
| r2287 | r2288 | |
| 668 | 668 | const char *filename; |
| 669 | 669 | const char *format; |
| 670 | 670 | char buf[128]; |
| 671 | | const struct IODevice *dev; |
| 671 | image_device_info info; |
| 672 | 672 | const char *file_extensions; |
| 673 | 673 | astring *filepath; |
| 674 | 674 | int success; |
| r2287 | r2288 | |
| 690 | 690 | device_typename(device_type), device_slot); |
| 691 | 691 | return; |
| 692 | 692 | } |
| 693 | | dev = mess_device_from_core_device(image); |
| 694 | | file_extensions = dev->file_extensions; |
| 693 | info = image_device_getinfo(image); |
| 694 | file_extensions = info.file_extensions; |
| 695 | 695 | |
| 696 | 696 | /* is an image format specified? */ |
| 697 | 697 | format = current_command->u.image_args.format; |
| 698 | 698 | if (format != NULL) |
| 699 | 699 | { |
| 700 | const struct IODevice *dev = mess_device_from_core_device(image); |
| 701 | |
| 700 | 702 | if (current_command->command_type != MESSTEST_COMMAND_IMAGE_CREATE) |
| 701 | 703 | { |
| 702 | 704 | state = STATE_ABORTED; |
src/mess/image.c
| r2287 | r2288 | |
| 356 | 356 | |
| 357 | 357 | |
| 358 | 358 | |
| 359 | /*------------------------------------------------- |
| 360 | image_device_compute_hash - compute a hash, |
| 361 | using this device's partial hash if appropriate |
| 362 | -------------------------------------------------*/ |
| 363 | |
| 364 | void image_device_compute_hash(char *dest, const device_config *device, |
| 365 | const void *data, size_t length, unsigned int functions) |
| 366 | { |
| 367 | deviceinfo info; |
| 368 | device_image_partialhash_func partialhash; |
| 369 | |
| 370 | /* retrieve the partial hash func */ |
| 371 | info.f = 0; |
| 372 | (*device->type)(device, DEVINFO_FCT_IMAGE_PARTIAL_HASH, &info); |
| 373 | partialhash = (device_image_partialhash_func) info.f; |
| 374 | |
| 375 | /* compute the hash */ |
| 376 | if (partialhash != NULL) |
| 377 | partialhash(dest, data, length, functions); |
| 378 | else |
| 379 | hash_compute(dest, data, length, functions); |
| 380 | } |
| 381 | |
| 382 | |
| 383 | |
| 359 | 384 | /**************************************************************************** |
| 360 | 385 | IMAGE LOADING |
| 361 | 386 | ****************************************************************************/ |
src/mess/image.h
| r2287 | r2288 | |
| 85 | 85 | DEVINFO_FCT_IMAGE_CREATE, /* R/O: device_create_handler */ |
| 86 | 86 | DEVINFO_FCT_IMAGE_UNLOAD, /* R/O: device_unload_handler */ |
| 87 | 87 | DEVINFO_FCT_DISPLAY, /* R/O: device_display_func */ |
| 88 | DEVINFO_FCT_IMAGE_PARTIAL_HASH, /* R/O: device_image_partialhash_func */ |
| 88 | 89 | DEVINFO_FCT_IMAGE_LAST = DEVINFO_FCT_FIRST + 0x0fff |
| 89 | 90 | }; |
| 90 | 91 | |
| r2287 | r2288 | |
| 120 | 121 | /* checks to see if a particular devices uses a certain file extension */ |
| 121 | 122 | int image_device_uses_file_extension(const device_config *device, const char *file_extension); |
| 122 | 123 | |
| 124 | /* compute a hash, using this device's partial hash if appropriate */ |
| 125 | void image_device_compute_hash(char *dest, const device_config *device, |
| 126 | const void *data, size_t length, unsigned int functions); |
| 123 | 127 | |
| 124 | 128 | |
| 129 | |
| 125 | 130 | /**************************************************************************** |
| 126 | 131 | Device loading and unloading functions |
| 127 | 132 | |
src/mess/device.c
| r2287 | r2288 | |
| 277 | 277 | case DEVINFO_FCT_IMAGE_CREATE: info->f = mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_CREATE); break; |
| 278 | 278 | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_UNLOAD); break; |
| 279 | 279 | case DEVINFO_FCT_DISPLAY: info->f = mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_DISPLAY); break; |
| 280 | case DEVINFO_FCT_IMAGE_PARTIAL_HASH: info->f = mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_PARTIAL_HASH); break; |
| 280 | 281 | |
| 281 | 282 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 282 | 283 | case DEVINFO_STR_NAME: info->s = "Legacy MESS Device"; break; |
src/mess/osd/winui/softwarepicker.c
| r2287 | r2288 | |
| 263 | 263 | static void ComputeFileHash(software_picker_info *pPickerInfo, |
| 264 | 264 | file_info *pFileInfo, const unsigned char *pBuffer, unsigned int nLength) |
| 265 | 265 | { |
| 266 | | unsigned int nFunctions; |
| 267 | | const struct IODevice *iodev; |
| 268 | | iodevice_t type; |
| 269 | | device_image_partialhash_func partialhash; |
| 266 | image_device_info info; |
| 267 | unsigned int functions; |
| 270 | 268 | |
| 271 | | iodev = mess_device_from_core_device(pFileInfo->device); |
| 272 | | type = iodev->type; |
| 273 | | partialhash = iodev->partialhash; |
| 269 | // get the device info |
| 270 | info = image_device_getinfo(pFileInfo->device); |
| 274 | 271 | |
| 275 | | nFunctions = hashfile_functions_used(pPickerInfo->pHashFile, type); |
| 272 | // determine which functions to use |
| 273 | functions = hashfile_functions_used(pPickerInfo->pHashFile, info.type); |
| 276 | 274 | |
| 277 | | if (partialhash) |
| 278 | | { |
| 279 | | partialhash(pFileInfo->szHash, pBuffer, nLength, nFunctions); |
| 280 | | } |
| 281 | | else |
| 282 | | { |
| 283 | | hash_compute(pFileInfo->szHash, pBuffer, nLength, nFunctions); |
| 284 | | } |
| 275 | // compute the hash |
| 276 | image_device_compute_hash(pFileInfo->szHash, pFileInfo->device, pBuffer, nLength, functions); |
| 285 | 277 | } |
| 286 | 278 | |
| 287 | 279 | |
| r2287 | r2288 | |
| 395 | 387 | // have already been calculated |
| 396 | 388 | if ((pPickerInfo->pHashFile != NULL) && (pFileInfo->device != NULL)) |
| 397 | 389 | { |
| 398 | | const struct IODevice *iodev = mess_device_from_core_device(pFileInfo->device); |
| 399 | | type = iodev->type; |
| 390 | image_device_info info = image_device_getinfo(pFileInfo->device); |
| 391 | type = info.type; |
| 400 | 392 | if (type < IO_COUNT) |
| 401 | 393 | nHashFunctionsUsed = hashfile_functions_used(pPickerInfo->pHashFile, type); |
| 402 | 394 | nCalculatedHashes = hash_data_used_functions(pFileInfo->szHash); |