Previous 15994 Revisions Next

r3046 Saturday 16th August, 2008 at 14:23:52 UTC by Nathan Woods
Made IODevice an opaque structure
[src/mess]device.c device.h
[src/mess/devices]appldriv.c cassette.c idedrive.c mflopimg.c
[src/mess/osd/winui]softwarepicker.c

src/mess/device.c
r3045r3046
2929    TYPE DEFINITIONS
3030***************************************************************************/
3131
32struct IODevice
33{
34   mess_device_class devclass;
35   const device_config *devconfig;
36
37   /* the basics */
38   const char *tag;
39   iodevice_t type;
40   int position;
41   int index_in_device;
42
43   /* open dispositions */
44   unsigned int readable : 1;
45   unsigned int writeable : 1;
46   unsigned int creatable : 1;
47
48   /* miscellaneous flags */
49   unsigned int reset_on_load : 1;
50   unsigned int load_at_init : 1;
51   unsigned int multiple : 1;
52};
53
54
55
3256/* this is placed in the inline_config of the MAME device structure */
3357typedef struct _mess_device_config mess_device_config;
3458struct _mess_device_config
r3045r3046
479503
480504
481505
506const mess_device_class *mess_devclass_from_core_device(const device_config *device)
507{
508   const struct IODevice *iodev = mess_device_from_core_device(device);
509   return (iodev != NULL) ? &iodev->devclass : NULL;
510}
511
512
513
482514int device_count_tag_from_machine(const running_machine *machine, const char *tag)
483515{
484516   int count = 0;
src/mess/device.h
r3045r3046
188188   const char *optspec;
189189};
190190
191struct IODevice
192{
193   mess_device_class devclass;
194   const device_config *devconfig;
195
196   /* the basics */
197   const char *tag;
198   iodevice_t type;
199   int position;
200   int index_in_device;
201
202   /* open dispositions */
203   unsigned int readable : 1;
204   unsigned int writeable : 1;
205   unsigned int creatable : 1;
206
207   /* miscellaneous flags */
208   unsigned int reset_on_load : 1;
209   unsigned int load_at_init : 1;
210   unsigned int multiple : 1;
211};
212
213191/* interoperability with MAME devices */
214192DEVICE_GET_INFO(mess_device);
215193struct _machine_config *machine_config_alloc_with_mess_devices(const game_driver *gamedrv);
216194const struct IODevice *mess_device_from_core_device(const device_config *device);
195const mess_device_class *mess_devclass_from_core_device(const device_config *device);
217196
218197/* device naming */
219198const char *device_uiname(iodevice_t devtype);
src/mess/devices/cassette.c
r3045r3046
4141
4242
4343
44static cassette_state get_default_state(const struct IODevice *dev)
44static cassette_state get_default_state(const device_config *dev)
4545{
46   assert(dev->type == IO_CASSETTE);
47   return (cassette_state) (int) mess_device_get_info_int(&dev->devclass, MESS_DEVINFO_INT_CASSETTE_DEFAULT_STATE);
46   return (cassette_state) (int) mess_device_get_info_int(mess_devclass_from_core_device(dev), MESS_DEVINFO_INT_CASSETTE_DEFAULT_STATE);
4847}
4948
5049
r3045r3046
231230
232231static DEVICE_START( cassette )
233232{
234   const struct IODevice *dev;
235
236233   image_alloctag(device, CASSETTE_TAG, sizeof(struct mess_cassetteimg));
237234
238235   /* set to default state */
239   dev = mess_device_from_core_device(device);
240   get_cassimg(device)->state = get_default_state(dev);
236   get_cassimg(device)->state = get_default_state(device);
241237}
242238
243239
r3045r3046
247243   casserr_t err;
248244   int cassette_flags;
249245   struct mess_cassetteimg *tag;
250   const struct IODevice *dev;
246   const mess_device_class *devclass;
251247   const struct CassetteFormat **formats;
252248   const struct CassetteOptions *create_opts;
253249   const char *extension;
r3045r3046
256252   tag = get_cassimg(image);
257253
258254   /* figure out the cassette format */
259   dev = mess_device_from_core_device(image);
260   formats = mess_device_get_info_ptr(&dev->devclass, MESS_DEVINFO_PTR_CASSETTE_FORMATS);
255   devclass = mess_devclass_from_core_device(image);
256   formats = mess_device_get_info_ptr(devclass, MESS_DEVINFO_PTR_CASSETTE_FORMATS);
261257
262258   if (image_has_been_created(image))
263259   {
264260      /* creating an image */
265      create_opts = (const struct CassetteOptions *) mess_device_get_info_ptr(&dev->devclass, MESS_DEVINFO_PTR_CASSETTE_OPTIONS);
261      create_opts = (const struct CassetteOptions *) mess_device_get_info_ptr(devclass, MESS_DEVINFO_PTR_CASSETTE_OPTIONS);
266262      err = cassette_create((void *) image, &mess_ioprocs, &wavfile_format, create_opts, CASSETTE_FLAG_READWRITE|CASSETTE_FLAG_SAVEONEXIT, &tag->cassette);
267263      if (err)
268264         goto error;
r3045r3046
288284   }
289285
290286   /* set to default state, but only change the UI state */
291   cassette_change_state(image, get_default_state(dev), CASSETTE_MASK_UISTATE);
287   cassette_change_state(image, get_default_state(image), CASSETTE_MASK_UISTATE);
292288
293289   /* reset the position */
294290   tag->position = 0.0;
src/mess/devices/idedrive.c
r3045r3046
2222   device_image_load_func *parent_load,
2323   device_image_unload_func *parent_unload)
2424{
25   const mess_device_class *devclass = &mess_device_from_core_device(image)->devclass;
25   const mess_device_class *devclass = mess_devclass_from_core_device(image);
2626   mess_device_class parent_devclass;
2727
2828   *which_bus = image_index_in_device(image);
src/mess/devices/mflopimg.c
r3045r3046
269269{
270270   floperr_t err;
271271   mess_flopimg *flopimg;
272   const struct IODevice *dev;
272   const mess_device_class *devclass;
273273   const struct FloppyFormat *floppy_options;
274274   int floppy_flags, i;
275275   const char *extension;
r3045r3046
279279   flopimg = get_flopimg(image);
280280
281281   /* figure out the floppy options */
282   dev = mess_device_from_core_device(image);
283   floppy_options = mess_device_get_info_ptr(&dev->devclass, MESS_DEVINFO_PTR_FLOPPY_OPTIONS);
282   devclass = mess_devclass_from_core_device(image);
283   floppy_options = mess_device_get_info_ptr(devclass, MESS_DEVINFO_PTR_FLOPPY_OPTIONS);
284284
285285   if (image_has_been_created(image))
286286   {
r3045r3046
308308      apply double steps. Setting the track count of the drive to the
309309      medium track count will then lead to unreachable tracks.
310310   */
311   keep_geometry = (int)mess_device_get_info_int(&mess_device_from_core_device(image)->devclass, MESS_DEVINFO_INT_KEEP_DRIVE_GEOMETRY);
311   keep_geometry = (int)mess_device_get_info_int(mess_devclass_from_core_device(image), MESS_DEVINFO_INT_KEEP_DRIVE_GEOMETRY);
312312
313313   if (!keep_geometry
314314            && floppy_callbacks(flopimg->floppy)->get_heads_per_disk
src/mess/devices/appldriv.c
r3045r3046
172172   struct apple525_disk *disk;
173173   int spinfract_divisor;
174174   int spinfract_dividend;
175   const struct IODevice *dev;
175   const mess_device_class *devclass;
176176
177177   disk = (struct apple525_disk *) image_lookuptag(img, APPLE525TAG);
178   dev = mess_device_from_core_device(img);
179   spinfract_dividend = (int) mess_device_get_info_int(&dev->devclass, MESS_DEVINFO_INT_APPLE525_SPINFRACT_DIVIDEND);
180   spinfract_divisor = (int) mess_device_get_info_int(&dev->devclass, MESS_DEVINFO_INT_APPLE525_SPINFRACT_DIVISOR);
178   devclass = mess_devclass_from_core_device(img);
179   spinfract_dividend = (int) mess_device_get_info_int(devclass, MESS_DEVINFO_INT_APPLE525_SPINFRACT_DIVIDEND);
180   spinfract_divisor = (int) mess_device_get_info_int(devclass, MESS_DEVINFO_INT_APPLE525_SPINFRACT_DIVISOR);
181181
182182   /* no image initialized for that drive ? */
183183   if (!image_exists(img))
src/mess/osd/winui/softwarepicker.c
r3045r3046
639639   BOOL bSuccess;
640640   int nCount;
641641   BOOL bDone = FALSE;
642   iodevice_t type;
642   image_device_info info;
643643
644644   pPickerInfo = GetSoftwarePickerInfo(hwndPicker);
645645
r3045r3046
688688      pFileInfo = pPickerInfo->file_index[pPickerInfo->current_position];
689689      if (!pFileInfo->hash_realized)
690690      {
691         type = mess_device_from_core_device(pFileInfo->device)->type;
692         if (hashfile_functions_used(pPickerInfo->config->hashfile, type))
691         info = image_device_getinfo(pPickerInfo->config->mconfig, pFileInfo->device);
692         if (hashfile_functions_used(pPickerInfo->config->hashfile, info.type))
693693         {
694694            // only calculate the hash if it is appropriate for this device
695695            if (!SoftwarePicker_CalculateHash(hwndPicker, pPickerInfo->current_position))

Previous 15994 Revisions Next


© 1998-2018 The MESS Team