Previous 15994 Revisions Next

r2227 Thursday 3rd April, 2008 at 00:45:15 UTC by Nathan Woods
More cleanups
[src/mess]device.c image.c

src/mess/image.c
r2226r2227
7474
7575struct _images_private
7676{
77   UINT32 multiple_dev_mask;
7877   int slot_count;
7978   image_slot_data slots[1];
8079};
r2226r2227
114113void image_init(running_machine *machine)
115114{
116115   int count, indx;
117   UINT32 mask, dev_mask = 0, multiple_dev_mask = 0;
118116   const device_config *dev;
119   const struct IODevice *iodev;
120117   size_t private_size;
121118   image_slot_data *slot;
122119
r2226r2227
125122   assert(DEVINFO_FCT_IMAGE_LAST < DEVINFO_FCT_DEVICE_SPECIFIC);
126123
127124   /* first count all images, and identify multiply defined devices */
128   count = 0;
129   for (dev = image_device_first(machine->config); dev != NULL; dev = image_device_next(dev))
130   {
131      /* weird check only relevant on the first legacy MESS device */
132      iodev = mess_device_from_core_device(dev);
133      if ((iodev != NULL) && (iodev->index_in_device == 0))
134      {
135         /* check to see if this device type is used multiple times */
136         mask = 1 << iodev->type;
137         if (dev_mask & mask)
138            multiple_dev_mask |= mask;
139         else
140            dev_mask |= mask;
141      }
125   count = image_device_count(machine->config);
142126
143      /* increment the count */
144      count++;
145   }
146
147127   /* allocate the private structure */
148128   private_size = sizeof(*machine->images_data) + ((count - 1)
149129      * sizeof(machine->images_data->slots[0]));
r2226r2227
151131   memset(machine->images_data, '\0', private_size);
152132
153133   /* some setup */
154   machine->images_data->multiple_dev_mask = multiple_dev_mask;
155134   machine->images_data->slot_count = count;
156135
157136   /* initialize the devices */
src/mess/device.c
r2226r2227
681681   const device_config *dev;
682682   const struct IODevice *iodev;
683683
684   assert((Machine->images_data->multiple_dev_mask & (1 << type)) == 0);
685684   assert(id < device_count(Machine, type));
686685
687686   for (dev = device_list_first(Machine->config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
r2226r2227
689688      iodev = mess_device_from_core_device(dev);
690689      if ((type == iodev->type) && (iodev->index_in_device == id))
691690      {
691         /* if 'image' is not null, that means that there are multiple devices of this iodevice_t type */
692         assert(image == NULL);
693
692694         image = dev;
693695         break;
694696      }
695697   }
696698
697   assert(image);
699   /* by calling this function, the caller assumes that there will be a matching device */
700   assert(image != NULL);
698701   return image;
699702}
700703

Previous 15994 Revisions Next


© 1998-2018 The MESS Team