Previous 15994 Revisions Next

r2288 Sunday 6th April, 2008 at 01:02:02 UTC by Nathan Woods
More device cleanups
[src/mess]device.c image.c image.h
[src/mess/drivers]dgn_beta.c
[src/mess/osd/winui]softwarepicker.c
[src/mess/tools/messtest]testmess.c

src/mess/tools/messtest/testmess.c
r2287r2288
668668   const char *filename;
669669   const char *format;
670670   char buf[128];
671   const struct IODevice *dev;
671   image_device_info info;
672672   const char *file_extensions;
673673   astring *filepath;
674674   int success;
r2287r2288
690690         device_typename(device_type), device_slot);
691691      return;
692692   }
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;
695695
696696   /* is an image format specified? */
697697   format = current_command->u.image_args.format;
698698   if (format != NULL)
699699   {
700      const struct IODevice *dev = mess_device_from_core_device(image);
701
700702      if (current_command->command_type != MESSTEST_COMMAND_IMAGE_CREATE)
701703      {
702704         state = STATE_ABORTED;
src/mess/image.c
r2287r2288
356356
357357
358358
359/*-------------------------------------------------
360    image_device_compute_hash - compute a hash,
361   using this device's partial hash if appropriate
362-------------------------------------------------*/
363
364void 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
359384/****************************************************************************
360385    IMAGE LOADING
361386****************************************************************************/
src/mess/image.h
r2287r2288
8585   DEVINFO_FCT_IMAGE_CREATE,                           /* R/O: device_create_handler */
8686   DEVINFO_FCT_IMAGE_UNLOAD,                           /* R/O: device_unload_handler */
8787   DEVINFO_FCT_DISPLAY,                              /* R/O: device_display_func */
88   DEVINFO_FCT_IMAGE_PARTIAL_HASH,                        /* R/O: device_image_partialhash_func */
8889   DEVINFO_FCT_IMAGE_LAST = DEVINFO_FCT_FIRST + 0x0fff
8990};
9091
r2287r2288
120121/* checks to see if a particular devices uses a certain file extension */
121122int image_device_uses_file_extension(const device_config *device, const char *file_extension);
122123
124/* compute a hash, using this device's partial hash if appropriate */
125void image_device_compute_hash(char *dest, const device_config *device,
126   const void *data, size_t length, unsigned int functions);
123127
124128
129
125130/****************************************************************************
126131  Device loading and unloading functions
127132
src/mess/device.c
r2287r2288
277277      case DEVINFO_FCT_IMAGE_CREATE:         info->f   = mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_CREATE); break;
278278      case DEVINFO_FCT_IMAGE_UNLOAD:         info->f = mess_device_get_info_fct(&mess_device->io_device.devclass, MESS_DEVINFO_PTR_UNLOAD); break;
279279      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;
280281
281282      /* --- the following bits of info are returned as NULL-terminated strings --- */
282283      case DEVINFO_STR_NAME:               info->s = "Legacy MESS Device";               break;
src/mess/osd/winui/softwarepicker.c
r2287r2288
263263static void ComputeFileHash(software_picker_info *pPickerInfo,
264264   file_info *pFileInfo, const unsigned char *pBuffer, unsigned int nLength)
265265{
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;
270268
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);
274271
275   nFunctions = hashfile_functions_used(pPickerInfo->pHashFile, type);
272   // determine which functions to use
273   functions = hashfile_functions_used(pPickerInfo->pHashFile, info.type);
276274
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);
285277}
286278
287279
r2287r2288
395387   // have already been calculated
396388   if ((pPickerInfo->pHashFile != NULL) && (pFileInfo->device != NULL))
397389   {
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;
400392      if (type < IO_COUNT)
401393           nHashFunctionsUsed = hashfile_functions_used(pPickerInfo->pHashFile, type);
402394      nCalculatedHashes = hash_data_used_functions(pFileInfo->szHash);
src/mess/drivers/dgn_beta.c
r2287r2288
279279INPUT_PORTS_END
280280
281281
282//static const char *dgnbeta_floppy_getname(const struct IODevice *dev, int id, char *buf, size_t bufsize)
283//{
284//  /* Dragon people like their floppy drives zero counted */
285//  snprintf(buf, bufsize, "Floppy #%d", id);
286//  return buf;
287//}
288
289282static void dgnbeta_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
290283{
291284   /* floppy */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team