src/mess/device.c
| r3045 | r3046 | |
| 29 | 29 | TYPE DEFINITIONS |
| 30 | 30 | ***************************************************************************/ |
| 31 | 31 | |
| 32 | struct 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 | |
| 32 | 56 | /* this is placed in the inline_config of the MAME device structure */ |
| 33 | 57 | typedef struct _mess_device_config mess_device_config; |
| 34 | 58 | struct _mess_device_config |
| r3045 | r3046 | |
| 479 | 503 | |
| 480 | 504 | |
| 481 | 505 | |
| 506 | const 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 | |
| 482 | 514 | int device_count_tag_from_machine(const running_machine *machine, const char *tag) |
| 483 | 515 | { |
| 484 | 516 | int count = 0; |
src/mess/device.h
| r3045 | r3046 | |
| 188 | 188 | const char *optspec; |
| 189 | 189 | }; |
| 190 | 190 | |
| 191 | | struct 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 | | |
| 213 | 191 | /* interoperability with MAME devices */ |
| 214 | 192 | DEVICE_GET_INFO(mess_device); |
| 215 | 193 | struct _machine_config *machine_config_alloc_with_mess_devices(const game_driver *gamedrv); |
| 216 | 194 | const struct IODevice *mess_device_from_core_device(const device_config *device); |
| 195 | const mess_device_class *mess_devclass_from_core_device(const device_config *device); |
| 217 | 196 | |
| 218 | 197 | /* device naming */ |
| 219 | 198 | const char *device_uiname(iodevice_t devtype); |
src/mess/devices/cassette.c
| r3045 | r3046 | |
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | |
| 44 | | static cassette_state get_default_state(const struct IODevice *dev) |
| 44 | static cassette_state get_default_state(const device_config *dev) |
| 45 | 45 | { |
| 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); |
| 48 | 47 | } |
| 49 | 48 | |
| 50 | 49 | |
| r3045 | r3046 | |
| 231 | 230 | |
| 232 | 231 | static DEVICE_START( cassette ) |
| 233 | 232 | { |
| 234 | | const struct IODevice *dev; |
| 235 | | |
| 236 | 233 | image_alloctag(device, CASSETTE_TAG, sizeof(struct mess_cassetteimg)); |
| 237 | 234 | |
| 238 | 235 | /* 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); |
| 241 | 237 | } |
| 242 | 238 | |
| 243 | 239 | |
| r3045 | r3046 | |
| 247 | 243 | casserr_t err; |
| 248 | 244 | int cassette_flags; |
| 249 | 245 | struct mess_cassetteimg *tag; |
| 250 | | const struct IODevice *dev; |
| 246 | const mess_device_class *devclass; |
| 251 | 247 | const struct CassetteFormat **formats; |
| 252 | 248 | const struct CassetteOptions *create_opts; |
| 253 | 249 | const char *extension; |
| r3045 | r3046 | |
| 256 | 252 | tag = get_cassimg(image); |
| 257 | 253 | |
| 258 | 254 | /* 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); |
| 261 | 257 | |
| 262 | 258 | if (image_has_been_created(image)) |
| 263 | 259 | { |
| 264 | 260 | /* 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); |
| 266 | 262 | err = cassette_create((void *) image, &mess_ioprocs, &wavfile_format, create_opts, CASSETTE_FLAG_READWRITE|CASSETTE_FLAG_SAVEONEXIT, &tag->cassette); |
| 267 | 263 | if (err) |
| 268 | 264 | goto error; |
| r3045 | r3046 | |
| 288 | 284 | } |
| 289 | 285 | |
| 290 | 286 | /* 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); |
| 292 | 288 | |
| 293 | 289 | /* reset the position */ |
| 294 | 290 | tag->position = 0.0; |
src/mess/devices/mflopimg.c
| r3045 | r3046 | |
| 269 | 269 | { |
| 270 | 270 | floperr_t err; |
| 271 | 271 | mess_flopimg *flopimg; |
| 272 | | const struct IODevice *dev; |
| 272 | const mess_device_class *devclass; |
| 273 | 273 | const struct FloppyFormat *floppy_options; |
| 274 | 274 | int floppy_flags, i; |
| 275 | 275 | const char *extension; |
| r3045 | r3046 | |
| 279 | 279 | flopimg = get_flopimg(image); |
| 280 | 280 | |
| 281 | 281 | /* 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); |
| 284 | 284 | |
| 285 | 285 | if (image_has_been_created(image)) |
| 286 | 286 | { |
| r3045 | r3046 | |
| 308 | 308 | apply double steps. Setting the track count of the drive to the |
| 309 | 309 | medium track count will then lead to unreachable tracks. |
| 310 | 310 | */ |
| 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); |
| 312 | 312 | |
| 313 | 313 | if (!keep_geometry |
| 314 | 314 | && floppy_callbacks(flopimg->floppy)->get_heads_per_disk |
src/mess/devices/appldriv.c
| r3045 | r3046 | |
| 172 | 172 | struct apple525_disk *disk; |
| 173 | 173 | int spinfract_divisor; |
| 174 | 174 | int spinfract_dividend; |
| 175 | | const struct IODevice *dev; |
| 175 | const mess_device_class *devclass; |
| 176 | 176 | |
| 177 | 177 | 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); |
| 181 | 181 | |
| 182 | 182 | /* no image initialized for that drive ? */ |
| 183 | 183 | if (!image_exists(img)) |
src/mess/osd/winui/softwarepicker.c
| r3045 | r3046 | |
| 639 | 639 | BOOL bSuccess; |
| 640 | 640 | int nCount; |
| 641 | 641 | BOOL bDone = FALSE; |
| 642 | | iodevice_t type; |
| 642 | image_device_info info; |
| 643 | 643 | |
| 644 | 644 | pPickerInfo = GetSoftwarePickerInfo(hwndPicker); |
| 645 | 645 | |
| r3045 | r3046 | |
| 688 | 688 | pFileInfo = pPickerInfo->file_index[pPickerInfo->current_position]; |
| 689 | 689 | if (!pFileInfo->hash_realized) |
| 690 | 690 | { |
| 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)) |
| 693 | 693 | { |
| 694 | 694 | // only calculate the hash if it is appropriate for this device |
| 695 | 695 | if (!SoftwarePicker_CalculateHash(hwndPicker, pPickerInfo->current_position)) |