Previous 15994 Revisions Next

r5849 Tuesday 22nd September, 2009 at 14:22:46 UTC by Miodrag Milanović
Some deprecated functions removed from device.h and device.c
[src/mess]device.c device.h
[src/mess/devices]flopdrv.c
[src/mess/tools/messtest]testmess.c

src/mess/tools/messtest/testmess.c
r5848r5849
712712      /* no device_type was specified; use the new preferred mechanism */
713713      device = devtag_get_device(machine, ident->tag);
714714   }
715   else if (ident->tag != NULL)
716   {
717      /* perform a legacy lookup by tag */
718      device = image_from_devtag_and_index(machine, ident->tag, ident->slot);
719   }
720715   else
721716   {
722717      /* perform a legacy lookup by device type */
src/mess/device.c
r5848r5849
520520   return (mess_device != NULL) ? &mess_device->io_device : NULL;
521521}
522522
523
524
525const mess_device_class *mess_devclass_from_core_device(const device_config *device)
526{
527   const legacy_mess_device *iodev = mess_device_from_core_device(device);
528   return (iodev != NULL) ? &iodev->devclass : NULL;
529}
530
531
532
533int device_count_tag_from_machine(const running_machine *machine, const char *tag)
534{
535   int count = 0;
536   const device_config *device;
537
538   for (device = device_list_first(machine->config->devicelist, MESS_DEVICE); device != NULL; device = device_list_next(device, MESS_DEVICE))
539   {
540      const legacy_mess_device *iodev = mess_device_from_core_device(device);
541      if (!strcmp(tag, iodev->tag))
542      {
543         count++;
544      }
545   }
546   return count;
547}
548
549
550
551/* this function is deprecated */
552int device_find_from_machine(const running_machine *machine, iodevice_t type)
553{
554   const device_config *device;
555
556   for (device = device_list_first(machine->config->devicelist, MESS_DEVICE); device != NULL; device = device_list_next(device, MESS_DEVICE))
557   {
558      const legacy_mess_device *iodev = mess_device_from_core_device(device);
559      if (iodev->type == type)
560         return TRUE;
561   }
562   return FALSE;
563}
564
565
566
567/* this function is deprecated */
568int device_count(running_machine *machine, iodevice_t type)
569{
570   int count = 0;
571   const device_config *device;
572
573   for (device = device_list_first(machine->config->devicelist, MESS_DEVICE); device != NULL; device = device_list_next(device, MESS_DEVICE))
574   {
575      const legacy_mess_device *iodev = mess_device_from_core_device(device);
576      if (iodev->type == type)
577      {
578         count++;
579      }
580   }
581   return count;
582}
583
584
585
586523/*************************************
587524 *
588 *   Tag management
589 *
590 *************************************/
591
592static mess_device_token *get_token(const device_config *device)
593{
594   assert(device->type == MESS_DEVICE);
595   return (mess_device_token *) device->token;
596}
597
598
599
600void *image_alloctag(const device_config *device, const char *tag, size_t size)
601{
602   void *ptr = tagpool_alloc(&get_token(device)->tagpool, tag, size);
603   if (ptr == NULL)
604   {
605      fatalerror("Out of memory");
606   }
607   return ptr;
608}
609
610
611
612void *image_lookuptag(const device_config *device, const char *tag)
613{
614   return tagpool_lookup(&get_token(device)->tagpool, tag);
615}
616
617
618
619/*************************************
620 *
621525 *   Deprecated device access functions
622526 *
623527 *************************************/
r5848r5849
630534}
631535
632536
633
634const device_config *image_from_devtag_and_index(running_machine *machine, const char *devtag, int id)
635{
636   const device_config *image = NULL;
637   const device_config *dev;
638   const legacy_mess_device *iodev;
639
640   for (dev = device_list_first(machine->config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
641   {
642      iodev = mess_device_from_core_device(dev);
643      if ((iodev->tag != NULL) && !strcmp(iodev->tag, devtag) && (iodev->index_in_device == id))
644      {
645         image = dev;
646         break;
647      }
648   }
649
650   assert(image != NULL);
651   return image;
652}
653
654
655
656iodevice_t image_devtype(const device_config *image)
657{
658   const legacy_mess_device *iodev = mess_device_from_core_device(image);
659   assert(iodev != NULL);
660   return iodev->type;
661}
662
663
664
665537const device_config *image_from_devtype_and_index(running_machine *machine, iodevice_t type, int id)
666538{
667539   const device_config *image = NULL;
src/mess/device.h
r5848r5849
182182/* interoperability with MAME devices */
183183DEVICE_GET_INFO(mess_device);
184184struct _machine_config *machine_config_alloc_with_mess_devices(const game_driver *gamedrv);
185const mess_device_class *mess_devclass_from_core_device(const device_config *device);
186185
187186/* device naming */
188187const char *device_typename(iodevice_t type);
r5848r5849
192191/* device allocation */
193192void mess_devices_setup(running_machine *machine, machine_config *config, const game_driver *gamedrv);
194193
195/* device lookup */
196int device_count_tag_from_machine(const running_machine *machine, const char *tag);
197
198/* deprecated: device lookup; both of these function assume only one of each type of device */
199int device_find_from_machine(const running_machine *machine, iodevice_t type);
200int device_count(running_machine *machine, iodevice_t type);
201
202/* deprecated tag management functions; only works on legacy devices */
203void *image_alloctag(const device_config *device, const char *tag, size_t size);
204void *image_lookuptag(const device_config *device, const char *tag);
205
206194/* deprecated device access functions */
207195int image_index_in_device(const device_config *device);
208const device_config *image_from_devtag_and_index(running_machine *machine, const char *devtag, int id);
209196
210197/* deprecated device access functions that assume one device of any given type */
211iodevice_t image_devtype(const device_config *device);
212198const device_config *image_from_devtype_and_index(running_machine *machine, iodevice_t type, int id);
213199
214200/* diagnostics */
src/mess/devices/flopdrv.c
r5848r5849
221221void floppy_drive_init(const device_config *img)
222222{   
223223   floppy_drive *pDrive = get_safe_token( img );
224//   assert(image_slotexists(img));
225224
226//   pDrive = image_alloctag(img, FLOPDRVTAG, sizeof(floppy_drive));
227
228225   /* initialise flags */
229226   pDrive->flags = 0;
230227   pDrive->index_pulse_callback = NULL;
r5848r5849
730727{
731728   floperr_t err;
732729   floppy_drive *flopimg;
733   const mess_device_class *devclass;
734730   const struct FloppyFormat *floppy_options;
735731   int floppy_flags, i;
736732   const char *extension;
r5848r5849
739735   flopimg = get_safe_token( image );
740736
741737   /* figure out the floppy options */
742   devclass = mess_devclass_from_core_device(image);
743738   floppy_options = ((floppy_config*)image->static_config)->formats;
744739
745740   if (image_has_been_created(image))

Previous 15994 Revisions Next


© 1998-2018 The MESS Team