const software_part *device_image_interface::find_software_item(const std::string &identifier, bool restrict_to_interface, software_list_device **dev) const { // split full software name into software list name and short software name std::string list_name, software_name, part_name; if (!software_name_parse(identifier, &list_name, &software_name, &part_name)) return nullptr; // determine interface const char *interface = restrict_to_interface ? image_interface() : nullptr; // find the software list if explicitly specified for (software_list_device &swlistdev : software_list_device_iterator(device().mconfig().root_device())) { if (list_name.empty() || (list_name == swlistdev.list_name())) { const software_info *info = swlistdev.find(software_name); if (info != nullptr) { const software_part *part = info->find_part(part_name, interface); if (part != nullptr) { if (dev != nullptr) *dev = &swlistdev; return part; } } } if (software_name == swlistdev.list_name()) { // ad hoc handling for the case path = swlist_name:swinfo_name (e.g. // gameboy:sml) which is not handled properly by software_name_split // since the function cannot distinguish between this and the case // path = swinfo_name:swpart_name const software_info *info = swlistdev.find(part_name); if (info != nullptr) { const software_part *part = info->find_part("", interface); if (part != nullptr) { if (dev != nullptr) *dev = &swlistdev; return part; } } } } // if explicitly specified and not found, just error here if (dev != nullptr) *dev = nullptr; return nullptr; }
image_manager::image_manager(running_machine &machine) : m_machine(machine) { // make sure that any required devices have been allocated for (device_image_interface &image : image_interface_iterator(machine.root_device())) { // ignore things not user loadable if (!image.user_loadable()) continue; // is an image specified for this image const char *image_name_ptr = machine.options().value(image.instance_name()); if ((image_name_ptr != nullptr) && (image_name_ptr[0] != '\0')) { image_init_result result = image_init_result::FAIL; std::string image_name(image_name_ptr); // mark init state image.set_init_phase(); // try as a softlist if (software_name_parse(image_name)) result = image.load_software(image_name); // failing that, try as an image if (result != image_init_result::PASS) result = image.load(image_name); // failing that, try creating it (if appropriate) if (result != image_init_result::PASS && image.support_command_line_image_creation()) result = image.create(image_name); // did the image load fail? if (result != image_init_result::PASS) { // retrieve image error message std::string image_err = std::string(image.error()); // unload all images unload_all(); fatalerror_exitcode(machine, EMU_ERR_DEVICE, "Device %s load (%s) failed: %s", image.device().name(), image_name.c_str(), image_err.c_str()); } } } machine.configuration().config_register("image_directories", config_saveload_delegate(FUNC(image_manager::config_load), this), config_saveload_delegate(FUNC(image_manager::config_save), this)); }