src/mess/devices/cartslot.c
| r7236 | r7237 | |
| 392 | 392 | pcb_type = identify_pcb(device); |
| 393 | 393 | if (pcb_type != NULL) |
| 394 | 394 | { |
| 395 | | //devlist->append(TAG_PCB, global_alloc(running_device(&device->baseconfig(), pcb_type->devtype, TAG_PCB, 0))); |
| 395 | const device_config *cfg = new device_config(&device->baseconfig(), pcb_type->devtype, TAG_PCB, 0); |
| 396 | running_device *dev = devlist->append(device->subtag(tempstring,TAG_PCB), new running_device(*machine, *cfg)); |
| 397 | |
| 398 | const machine_config_token *tokens = (const machine_config_token *)dev->get_config_ptr(DEVINFO_PTR_MACHINE_CONFIG); |
| 399 | machine_config *config; |
| 400 | const device_config *config_dev; |
| 401 | running_device *new_dev = NULL; |
| 402 | if (tokens != NULL) |
| 403 | { |
| 404 | config = machine_config_alloc(tokens); |
| 405 | for (config_dev = config->devicelist.first(); config_dev != NULL; config_dev = config_dev->next) |
| 406 | { |
| 407 | device_config *new_cfg = new device_config(cfg, config_dev->type, config_dev->tag, config_dev->clock); |
| 408 | new_cfg->static_config = config_dev->static_config; |
| 409 | memcpy( |
| 410 | new_cfg->inline_config, |
| 411 | config_dev->inline_config, |
| 412 | new_cfg->get_config_int(DEVINFO_INT_INLINE_CONFIG_BYTES)); |
| 413 | new_dev = devlist->append(dev->subtag(tempstring,config_dev->tag), new running_device(*machine, *new_cfg)); |
| 414 | new_dev->owner = dev; |
| 415 | } |
| 416 | machine_config_free(config); |
| 417 | } |
| 418 | |
| 396 | 419 | } |
| 397 | 420 | } |
| 398 | 421 | |
src/mess/mess.c
| r7236 | r7237 | |
| 39 | 39 | { |
| 40 | 40 | const char *image_name; |
| 41 | 41 | running_device *image; |
| 42 | | running_device *dev; |
| 43 | 42 | image_device_info info; |
| 44 | 43 | device_get_image_devices_func get_image_devices; |
| 45 | 44 | device_list *devlist; |
| r7236 | r7237 | |
| 57 | 56 | { |
| 58 | 57 | if (is_image_device(image)) |
| 59 | 58 | { |
| 59 | /* get the device info */ |
| 60 | info = image_device_getinfo(machine->config, image); |
| 60 | 61 | |
| 61 | | /* get the device info */ |
| 62 | | info = image_device_getinfo(machine->config, image); |
| 62 | /* is an image specified for this image */ |
| 63 | image_name = mess_get_device_option(&info); |
| 63 | 64 | |
| 64 | | /* is an image specified for this image */ |
| 65 | | image_name = mess_get_device_option(&info); |
| 66 | | |
| 67 | | if ((image_name != NULL) && (image_name[0] != '\0')) |
| 68 | | { |
| 69 | | } |
| 70 | | else |
| 71 | | { |
| 72 | | /* no image... must this device be loaded? */ |
| 73 | | if (info.must_be_loaded) |
| 65 | if ((image_name != NULL) && (image_name[0] != '\0')) |
| 74 | 66 | { |
| 75 | | /* unload all images */ |
| 76 | | image_unload_all(machine); |
| 77 | | |
| 78 | | fatalerror_exitcode(machine, MAMERR_DEVICE, "Driver requires that device \"%s\" must have an image to load\n", info.instance_name); |
| 79 | 67 | } |
| 80 | | } |
| 81 | | |
| 82 | | /* get image-specific hardware */ |
| 83 | | get_image_devices = (device_get_image_devices_func) image->get_config_fct(DEVINFO_FCT_GET_IMAGE_DEVICES); |
| 84 | | if (get_image_devices != NULL) |
| 85 | | (*get_image_devices)(image, devlist); |
| 86 | | } |
| 87 | | } |
| 88 | | |
| 89 | | /* ensure that any added devices have a machine */ |
| 90 | | for (dev = machine->devicelist.first(); dev != NULL; dev = dev->next) |
| 91 | | { |
| 92 | | if (dev->machine == NULL) |
| 93 | | { |
| 94 | | const machine_config_token *tokens; |
| 95 | | machine_config *config; |
| 96 | | const device_config *config_dev; |
| 97 | | running_device *new_dev = NULL; |
| 98 | | astring tempstring; |
| 99 | | |
| 100 | | dev->machine = machine; |
| 101 | | |
| 102 | | tokens = (const machine_config_token *)dev->get_config_ptr(DEVINFO_PTR_MACHINE_CONFIG); |
| 103 | | if (tokens != NULL) |
| 68 | else |
| 104 | 69 | { |
| 105 | | config = machine_config_alloc(tokens); |
| 106 | | for (config_dev = config->devicelist.first(); config_dev != NULL; config_dev = config_dev->next) |
| 107 | | { |
| 108 | | new_dev = devlist->append(config_dev->tag, global_alloc(running_device(*machine, *config_dev))); |
| 70 | /* no image... must this device be loaded? */ |
| 71 | if (info.must_be_loaded) |
| 72 | { |
| 73 | fatalerror_exitcode(machine, MAMERR_DEVICE, "Driver requires that device \"%s\" must have an image to load\n", info.instance_name); |
| 109 | 74 | } |
| 110 | | machine_config_free(config); |
| 111 | 75 | } |
| 112 | | } |
| 76 | |
| 77 | /* get image-specific hardware */ |
| 78 | get_image_devices = (device_get_image_devices_func) image->get_config_fct(DEVINFO_FCT_GET_IMAGE_DEVICES); |
| 79 | if (get_image_devices != NULL) |
| 80 | (*get_image_devices)(image, machine, devlist); |
| 81 | } |
| 113 | 82 | } |
| 114 | 83 | } |
| 115 | 84 | |
src/mess/image.h
| r7236 | r7237 | |
| 36 | 36 | typedef void (*device_display_func)(running_device *image); |
| 37 | 37 | typedef void (*device_image_partialhash_func)(char *, const unsigned char *, unsigned long, unsigned int); |
| 38 | 38 | typedef const char *(*device_get_name_func)(running_device *device, char *buffer, size_t buffer_length); |
| 39 | | typedef void (*device_get_image_devices_func)(running_device *device, device_list *devlist); |
| 39 | typedef void (*device_get_image_devices_func)(running_device *device, running_machine *machine, device_list *devlist); |
| 40 | 40 | |
| 41 | 41 | typedef enum |
| 42 | 42 | { |
| r7236 | r7237 | |
| 338 | 338 | #define DEVICE_IMAGE_UNLOAD(name) void DEVICE_IMAGE_UNLOAD_NAME(name)(running_device *image) |
| 339 | 339 | |
| 340 | 340 | #define DEVICE_GET_IMAGE_DEVICES_NAME(name) device_get_image_devices_##name |
| 341 | | #define DEVICE_GET_IMAGE_DEVICES(name) void DEVICE_GET_IMAGE_DEVICES_NAME(name)(running_device *device, device_list *devlist) |
| 341 | #define DEVICE_GET_IMAGE_DEVICES(name) void DEVICE_GET_IMAGE_DEVICES_NAME(name)(running_device *device, running_machine *machine, device_list *devlist) |
| 342 | 342 | |
| 343 | 343 | #endif /* __IMAGE_H__ */ |