Previous 15994 Revisions Next

r2194 Tuesday 1st April, 2008 at 11:01:39 UTC by Nathan Woods
Created calls for enumerating/counting devices with images
[src/mess]climess.c image.c image.h infomess.c
[src/mess/osd/winui]devview.c messui.c msuiutil.c softwarepicker.c

src/mess/climess.c
r2193r2194
7070
7171         driver_name = drivers[i]->name;
7272
73         for (dev = device_list_first(config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
73         for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev))
7474         {
7575            iodev = mess_device_from_core_device(dev);
7676
src/mess/image.c
r2193r2194
9595
9696
9797/***************************************************************************
98    IMAGE SYSTEM INITIALIZATION
98    CORE IMPLEMENTATION
9999***************************************************************************/
100100
101101/*-------------------------------------------------
r2193r2194
255255
256256
257257/****************************************************************************
258    IMAGE DEVICE ENUMERATION
259****************************************************************************/
260
261/*-------------------------------------------------
262    is_image_device - determines if a particular
263   device supports images or not
264-------------------------------------------------*/
265
266static int is_image_device(const device_config *device)
267{
268   return (device->type == MESS_DEVICE)
269      || (device_get_info_fct(device, DEVINFO_FCT_IMAGE_LOAD) != NULL)
270      || (device_get_info_fct(device, DEVINFO_FCT_IMAGE_CREATE) != NULL)
271      || (device_get_info_fct(device, DEVINFO_FCT_IMAGE_UNLOAD) != NULL);
272}
273
274
275
276/*-------------------------------------------------
277    image_device_first - return the first device in
278   the list that supports images
279-------------------------------------------------*/
280
281const device_config *image_device_first(const machine_config *config)
282{
283   const device_config *device = device_list_first(config->devicelist, DEVICE_TYPE_WILDCARD);
284   while((device != NULL) && !is_image_device(device))
285   {
286      device = device_list_next(device, DEVICE_TYPE_WILDCARD);
287   }
288   return device;   
289}
290
291
292
293/*-------------------------------------------------
294    image_device_next - return the next device in
295   the list that supports images
296-------------------------------------------------*/
297
298const device_config *image_device_next(const device_config *prevdevice)
299{
300   const device_config *device = device_list_next(prevdevice, DEVICE_TYPE_WILDCARD);
301   while((device != NULL) && !is_image_device(device))
302   {
303      device = device_list_next(device, DEVICE_TYPE_WILDCARD);
304   }
305   return device;   
306}
307
308
309
310/*-------------------------------------------------
311    image_device_count - counts the number of
312   devices that support images
313-------------------------------------------------*/
314
315int image_device_count(const machine_config *config)
316{
317   int count = 0;
318   const device_config *device;
319   for (device = image_device_first(config); device != NULL; device = image_device_next(device))
320   {
321      count++;
322   }
323   return count;
324}
325
326
327
328/****************************************************************************
258329    IMAGE LOADING
259330****************************************************************************/
260331
src/mess/infomess.c
r2193r2194
3333   const char *name;
3434   const char *shortname;
3535
36   for (dev = device_list_first(config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
36   for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev))
3737   {
3838      iodev = mess_device_from_core_device(dev);
3939
src/mess/image.h
r2193r2194
4343enum
4444{
4545   /* --- the following bits of info are returned as pointers to functions --- */
46   DEVINFO_FCT_IMAGE_FIRST      = DEVINFO_FCT_FIRST + 0x7000,
46   DEVINFO_FCT_IMAGE_FIRST = DEVINFO_FCT_FIRST + 0x7000,
4747   DEVINFO_FCT_IMAGE_LOAD,                              /* R/O: device_load_handler */
4848   DEVINFO_FCT_IMAGE_CREATE,                           /* R/O: device_create_handler */
4949   DEVINFO_FCT_IMAGE_UNLOAD,                           /* R/O: device_unload_handler */
50   DEVINFO_FCT_IMAGE_LAST      = DEVINFO_FCT_FIRST + 0x0fff
50   DEVINFO_FCT_IMAGE_LAST = DEVINFO_FCT_FIRST + 0x0fff
5151};
5252
5353
5454
5555
56/****************************************************************************
57  A const device_config pointer represents one device entry; this could be an instance
58  of a floppy drive or a printer.  The defining property is that either at
59  startup or at runtime, it can become associated with a file on the hosting
60  machine (for the examples above, a disk image or printer output file
61  repsectively).  In fact, const device_config might be better renamed mess_device.
56/***************************************************************************
57    FUNCTION PROTOTYPES
58***************************************************************************/
6259
63  MESS drivers declare what device types each system had and how many.  For
64  each of these, a const device_config is allocated.  Devices can have init functions
65  that allow the devices to set up any relevant internal data structures.
66  It is recommended that devices use the tag allocation system described
67  below.
60/* ----- core implementation ----- */
6861
69  There are also various other accessors for other information about a
70  device, from whether it is mounted or not, or information stored in a CRC
71  file.
72****************************************************************************/
73
74/* not to be called by anything other than core */
62/* core initialization */
7563int image_init(running_machine *machine);
7664
7765
66/* ----- image device enumeration ----- */
7867
68/* return the first device in the list that supports images */
69const device_config *image_device_first(const machine_config *config);
70
71/* return the next device in the list that supports images */
72const device_config *image_device_next(const device_config *prevdevice);
73
74/* counts the number of devices that support images */
75int image_device_count(const machine_config *config);
76
77
78
7979/****************************************************************************
8080  Device loading and unloading functions
8181
src/mess/osd/winui/messui.c
r2193r2194
389389   config = machine_config_alloc_with_mess_devices(drivers[drvindex]);
390390
391391   nPos = 0;
392   for (dev = device_list_first(config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
392   for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev))
393393   {
394394      iodev = mess_device_from_core_device(dev);
395395
r2193r2194
449449   // allocate the machine config
450450   config = machine_config_alloc_with_mess_devices(drivers[drvindex]);
451451
452   for (dev = device_list_first(config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
452   for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev))
453453   {
454454      iodev = mess_device_from_core_device(dev);
455455
r2193r2194
505505      config = machine_config_alloc_with_mess_devices(drivers[drvindex]);
506506
507507      nPos = 0;
508      for (dev = device_list_first(config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
508      for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev))
509509      {
510510         iodev = mess_device_from_core_device(dev);
511511
r2193r2194
560560   // be problematic
561561   ListView_SetItemState(hwndSoftware, -1, 0, LVIS_SELECTED);
562562
563   for (dev = device_list_first(config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
563   for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev))
564564   {
565565      iodev = mess_device_from_core_device(dev);
566566
r2193r2194
754754      num_extensions++;
755755    }
756756
757   for (dev = device_list_first(config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
757   for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev))
758758   {
759759      iodev = mess_device_from_core_device(dev);
760760
src/mess/osd/winui/devview.c
r2193r2194
212212   pDevViewInfo->config = machine_config_alloc_with_mess_devices(drivers[nGame]);
213213
214214   // count total amount of devices
215   nDevCount = 0;
216   for (dev = device_list_first(pDevViewInfo->config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
217   {
218      iodev = mess_device_from_core_device(dev);
219      nDevCount += 1;
220   }
215   nDevCount = image_device_count(pDevViewInfo->config);
221216
222217   if (nDevCount > 0)
223218   {
r2193r2194
225220      ppszDevices = (LPTSTR *) alloca(nDevCount * sizeof(*ppszDevices));
226221      i = 0;
227222
228      for (dev = device_list_first(pDevViewInfo->config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
223      for (dev = image_device_first(pDevViewInfo->config); dev != NULL; dev = image_device_next(dev))
229224      {
230225         iodev = mess_device_from_core_device(dev);
231226
r2193r2194
262257      DevView_GetColumns(hwndDevView, &nStaticPos, &nStaticWidth,
263258         &nEditPos, &nEditWidth, &nButtonPos, &nButtonWidth);
264259
265      for (dev = device_list_first(pDevViewInfo->config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
260      for (dev = image_device_first(pDevViewInfo->config); dev != NULL; dev = image_device_next(dev))
266261      {
267262         iodev = mess_device_from_core_device(dev);
268263
src/mess/osd/winui/msuiutil.c
r2193r2194
4747   // allocate the machine config
4848   config = machine_config_alloc_with_mess_devices(gamedrv);
4949
50   for (device = device_list_first(config->devicelist, MESS_DEVICE); device != NULL; device = device_list_next(device, MESS_DEVICE))
50   for (device = image_device_first(config); device != NULL; device = image_device_next(device))
5151   {
5252      const struct IODevice *iodev = mess_device_from_core_device(device);
5353      if (iodev->type == type)
src/mess/osd/winui/softwarepicker.c
r2193r2194
429429      // skip the initial '.' in the file extension
430430      pszExtension++;
431431
432      for (device = device_list_first(pPickerInfo->pConfig->devicelist, MESS_DEVICE); device != NULL; device = device_list_next(device, MESS_DEVICE))
432      for (device = image_device_first(pPickerInfo->pConfig); device != NULL; device = image_device_next(device))
433433      {
434434         const struct IODevice *iodev = mess_device_from_core_device(device);
435435

Previous 15994 Revisions Next


© 1998-2018 The MESS Team