bool device_image_interface::load_software_part(const std::string &identifier, const software_part *&swpart, std::string *list_name) { // if no match has been found, we suggest similar shortnames software_list_device *swlist; swpart = find_software_item(identifier, true, &swlist); if (swpart == nullptr) { software_list_device::display_matches(device().machine().config(), image_interface(), identifier); return false; } // I'm not sure what m_init_phase is all about; but for now I'm preserving this behavior if (is_reset_on_load()) set_init_phase(); // Load the software part const char *swname = swpart->info().shortname().c_str(); const rom_entry *start_entry = swpart->romdata().data(); const software_list_loader &loader = get_software_list_loader(); bool result = loader.load_software(*this, *swlist, swname, start_entry); #ifdef UNUSED_VARIABLE // Tell the world which part we actually loaded std::string full_sw_name = string_format("%s:%s:%s", swlist.list_name(), swpart->info().shortname(), swpart->name()); #endif // check compatibility switch (swlist->is_compatible(*swpart)) { case SOFTWARE_IS_COMPATIBLE: break; case SOFTWARE_IS_INCOMPATIBLE: swlist->popmessage("WARNING! the set %s might not work on this system due to incompatible filter(s) '%s'\n", swpart->info().shortname(), swlist->filter()); break; case SOFTWARE_NOT_COMPATIBLE: swlist->popmessage("WARNING! the set %s might not work on this system due to missing filter(s) '%s'\n", swpart->info().shortname(), swlist->filter()); break; } // check requirements and load those images const char *requirement = swpart->feature("requirement"); if (requirement != nullptr) { const software_part *req_swpart = find_software_item(requirement, false); if (req_swpart != nullptr) { device_image_interface *req_image = software_list_device::find_mountable_image(device().mconfig(), *req_swpart); if (req_image != nullptr) { req_image->set_init_phase(); req_image->load(requirement); } } } if (list_name != nullptr) *list_name = swlist->list_name(); return result; }
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; }
bool device_image_interface::load_software_part(const char *path, software_part *&swpart) { // if no match has been found, we suggest similar shortnames swpart = find_software_item(path, true); if (swpart == NULL) { software_list_device::display_matches(device().machine().config(), image_interface(), path); return false; } // Load the software part bool result = call_softlist_load(swpart->info().list(), swpart->info().shortname(), swpart->romdata()); // Tell the world which part we actually loaded astring full_sw_name; full_sw_name.printf("%s:%s:%s", swpart->info().list().list_name(), swpart->info().shortname(), swpart->name()); // check compatibility if (!swpart->is_compatible(swpart->info().list())) osd_printf_warning("WARNING! the set %s might not work on this system due to missing filter(s) '%s'\n", swpart->info().shortname(), swpart->info().list().filter()); // check requirements and load those images const char *requirement = swpart->feature("requirement"); if (requirement != NULL) { software_part *req_swpart = find_software_item(requirement, false); if (req_swpart != NULL) { image_interface_iterator imgiter(device().machine().root_device()); for (device_image_interface *req_image = imgiter.first(); req_image != NULL; req_image = imgiter.next()) { const char *interface = req_image->image_interface(); if (interface != NULL) { if (req_swpart->matches_interface(interface)) { const char *option = device().mconfig().options().value(req_image->brief_instance_name()); // mount only if not already mounted if (strlen(option) == 0 && !req_image->filename()) { req_image->set_init_phase(); req_image->load(requirement); } break; } } } } } return result; }
bool device_image_interface::load_software_part(const char *path, const software_part *&swpart) { // if no match has been found, we suggest similar shortnames swpart = find_software_item(path, true); if (swpart == nullptr) { software_list_device::display_matches(device().machine().config(), image_interface(), path); return false; } // Load the software part software_list_device &swlist = swpart->info().list(); bool result = call_softlist_load(swlist, swpart->info().shortname().c_str(), swpart->romdata()); // Tell the world which part we actually loaded std::string full_sw_name = string_format("%s:%s:%s", swlist.list_name(), swpart->info().shortname(), swpart->name()); // check compatibility switch (swpart->is_compatible(swlist)) { case SOFTWARE_IS_COMPATIBLE: break; case SOFTWARE_IS_INCOMPATIBLE: swlist.popmessage("WARNING! the set %s might not work on this system due to incompatible filter(s) '%s'\n", swpart->info().shortname(), swlist.filter()); break; case SOFTWARE_NOT_COMPATIBLE: swlist.popmessage("WARNING! the set %s might not work on this system due to missing filter(s) '%s'\n", swpart->info().shortname(), swlist.filter()); break; } // check requirements and load those images const char *requirement = swpart->feature("requirement"); if (requirement != nullptr) { const software_part *req_swpart = find_software_item(requirement, false); if (req_swpart != nullptr) { device_image_interface *req_image = req_swpart->find_mountable_image(device().mconfig()); if (req_image != nullptr) { req_image->set_init_phase(); req_image->load(requirement); } } } return result; }
software_part *device_image_interface::find_software_item(const char *path, bool restrict_to_interface) const { // split full software name into software list name and short software name std::string swlist_name, swinfo_name, swpart_name; software_name_split(path, swlist_name, swinfo_name, swpart_name); // determine interface const char *interface = nullptr; if (restrict_to_interface) interface = image_interface(); // find the software list if explicitly specified software_list_device_iterator deviter(device().mconfig().root_device()); for (software_list_device *swlistdev = deviter.first(); swlistdev != nullptr; swlistdev = deviter.next()) { if (swlist_name.compare(swlistdev->list_name())==0 || !(swlist_name.length() > 0)) { software_info *info = swlistdev->find(swinfo_name.c_str()); if (info != nullptr) { software_part *part = info->find_part(swpart_name.c_str(), interface); if (part != nullptr) return part; } } if (swinfo_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 software_info *info = swlistdev->find(swpart_name.c_str()); if (info != nullptr) { software_part *part = info->find_part(nullptr, interface); if (part != nullptr) return part; } } } // if explicitly specified and not found, just error here return nullptr; }
software_part *device_image_interface::find_software_item(const char *path, bool restrict_to_interface) { // // Note: old code would explicitly load swlist_name if it was specified, rather than // searching the devices. // // Also if not found, old code would attempt to open <drivername>.xml and even // <swinfo_name>.xml. Hopefully removing this won't break anything. // // split full software name into software list name and short software name astring swlist_name, swinfo_name, swpart_name; software_name_split(path, swlist_name, swinfo_name, swpart_name); bool explicit_name = (swlist_name.len() > 0); // determine interface const char *interface = NULL; if (restrict_to_interface) interface = image_interface(); // find the software list if explicitly specified software_list_device_iterator deviter(device().mconfig().root_device()); for (software_list_device *swlistdev = deviter.first(); swlistdev != NULL; swlistdev = deviter.next()) if (!explicit_name || swlist_name == swlistdev->list_name()) { software_info *info = swlistdev->find(swinfo_name); if (info != NULL) { software_part *part = info->find_part(swpart_name, interface); if (part != NULL) return part; } } // if explicitly specified and not found, just error here return NULL; }