src/mess/image.c
| r2193 | r2194 | |
| 95 | 95 | |
| 96 | 96 | |
| 97 | 97 | /*************************************************************************** |
| 98 | | IMAGE SYSTEM INITIALIZATION |
| 98 | CORE IMPLEMENTATION |
| 99 | 99 | ***************************************************************************/ |
| 100 | 100 | |
| 101 | 101 | /*------------------------------------------------- |
| r2193 | r2194 | |
| 255 | 255 | |
| 256 | 256 | |
| 257 | 257 | /**************************************************************************** |
| 258 | IMAGE DEVICE ENUMERATION |
| 259 | ****************************************************************************/ |
| 260 | |
| 261 | /*------------------------------------------------- |
| 262 | is_image_device - determines if a particular |
| 263 | device supports images or not |
| 264 | -------------------------------------------------*/ |
| 265 | |
| 266 | static 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 | |
| 281 | const 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 | |
| 298 | const 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 | |
| 315 | int 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 | /**************************************************************************** |
| 258 | 329 | IMAGE LOADING |
| 259 | 330 | ****************************************************************************/ |
| 260 | 331 | |
src/mess/image.h
| r2193 | r2194 | |
| 43 | 43 | enum |
| 44 | 44 | { |
| 45 | 45 | /* --- 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, |
| 47 | 47 | DEVINFO_FCT_IMAGE_LOAD, /* R/O: device_load_handler */ |
| 48 | 48 | DEVINFO_FCT_IMAGE_CREATE, /* R/O: device_create_handler */ |
| 49 | 49 | 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 |
| 51 | 51 | }; |
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | |
| 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 | ***************************************************************************/ |
| 62 | 59 | |
| 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 ----- */ |
| 68 | 61 | |
| 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 */ |
| 75 | 63 | int image_init(running_machine *machine); |
| 76 | 64 | |
| 77 | 65 | |
| 66 | /* ----- image device enumeration ----- */ |
| 78 | 67 | |
| 68 | /* return the first device in the list that supports images */ |
| 69 | const device_config *image_device_first(const machine_config *config); |
| 70 | |
| 71 | /* return the next device in the list that supports images */ |
| 72 | const device_config *image_device_next(const device_config *prevdevice); |
| 73 | |
| 74 | /* counts the number of devices that support images */ |
| 75 | int image_device_count(const machine_config *config); |
| 76 | |
| 77 | |
| 78 | |
| 79 | 79 | /**************************************************************************** |
| 80 | 80 | Device loading and unloading functions |
| 81 | 81 | |
src/mess/osd/winui/messui.c
| r2193 | r2194 | |
| 389 | 389 | config = machine_config_alloc_with_mess_devices(drivers[drvindex]); |
| 390 | 390 | |
| 391 | 391 | 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)) |
| 393 | 393 | { |
| 394 | 394 | iodev = mess_device_from_core_device(dev); |
| 395 | 395 | |
| r2193 | r2194 | |
| 449 | 449 | // allocate the machine config |
| 450 | 450 | config = machine_config_alloc_with_mess_devices(drivers[drvindex]); |
| 451 | 451 | |
| 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)) |
| 453 | 453 | { |
| 454 | 454 | iodev = mess_device_from_core_device(dev); |
| 455 | 455 | |
| r2193 | r2194 | |
| 505 | 505 | config = machine_config_alloc_with_mess_devices(drivers[drvindex]); |
| 506 | 506 | |
| 507 | 507 | 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)) |
| 509 | 509 | { |
| 510 | 510 | iodev = mess_device_from_core_device(dev); |
| 511 | 511 | |
| r2193 | r2194 | |
| 560 | 560 | // be problematic |
| 561 | 561 | ListView_SetItemState(hwndSoftware, -1, 0, LVIS_SELECTED); |
| 562 | 562 | |
| 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)) |
| 564 | 564 | { |
| 565 | 565 | iodev = mess_device_from_core_device(dev); |
| 566 | 566 | |
| r2193 | r2194 | |
| 754 | 754 | num_extensions++; |
| 755 | 755 | } |
| 756 | 756 | |
| 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)) |
| 758 | 758 | { |
| 759 | 759 | iodev = mess_device_from_core_device(dev); |
| 760 | 760 | |
src/mess/osd/winui/devview.c
| r2193 | r2194 | |
| 212 | 212 | pDevViewInfo->config = machine_config_alloc_with_mess_devices(drivers[nGame]); |
| 213 | 213 | |
| 214 | 214 | // 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); |
| 221 | 216 | |
| 222 | 217 | if (nDevCount > 0) |
| 223 | 218 | { |
| r2193 | r2194 | |
| 225 | 220 | ppszDevices = (LPTSTR *) alloca(nDevCount * sizeof(*ppszDevices)); |
| 226 | 221 | i = 0; |
| 227 | 222 | |
| 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)) |
| 229 | 224 | { |
| 230 | 225 | iodev = mess_device_from_core_device(dev); |
| 231 | 226 | |
| r2193 | r2194 | |
| 262 | 257 | DevView_GetColumns(hwndDevView, &nStaticPos, &nStaticWidth, |
| 263 | 258 | &nEditPos, &nEditWidth, &nButtonPos, &nButtonWidth); |
| 264 | 259 | |
| 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)) |
| 266 | 261 | { |
| 267 | 262 | iodev = mess_device_from_core_device(dev); |
| 268 | 263 | |