From 080a944190ed581fcc9a847bc7cfd7fedaa58351 Mon Sep 17 00:00:00 2001 From: Nigel Barnes Date: Wed, 15 Feb 2017 11:15:28 +0000 Subject: [PATCH] allow softlist software parts to use different interfaces: - imgcntrl: don't assume first software part, find part with correct interface - swlist: check all software parts for matching interface when populating list of software lists - softlist_dev: check all software parts when finding approx matches --- src/emu/softlist_dev.cpp | 38 ++++++++++++++++--------------- src/frontend/mame/ui/imgcntrl.cpp | 2 +- src/frontend/mame/ui/swlist.cpp | 16 +++++++++---- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/emu/softlist_dev.cpp b/src/emu/softlist_dev.cpp index 87e236194ac..db3aeb28e9d 100644 --- a/src/emu/softlist_dev.cpp +++ b/src/emu/softlist_dev.cpp @@ -145,29 +145,31 @@ void software_list_device::find_approx_matches(const std::string &name, int matc // iterate over our info (will cause a parse if needed) for (const software_info &swinfo : get_info()) { - const software_part &part = swinfo.parts().front(); - if ((interface == nullptr || part.matches_interface(interface)) && is_compatible(part) == SOFTWARE_IS_COMPATIBLE) + for (const software_part &swpart : swinfo.parts()) { - // pick the best match between driver name and description - int longpenalty = driver_list::penalty_compare(name.c_str(), swinfo.longname().c_str()); - int shortpenalty = driver_list::penalty_compare(name.c_str(), swinfo.shortname().c_str()); - int curpenalty = std::min(longpenalty, shortpenalty); - - // insert into the sorted table of matches - for (int matchnum = matches - 1; matchnum >= 0; matchnum--) + if ((interface == nullptr || swpart.matches_interface(interface)) && is_compatible(swpart) == SOFTWARE_IS_COMPATIBLE) { - // stop if we're worse than the current entry - if (curpenalty >= penalty[matchnum]) - break; + // pick the best match between driver name and description + int longpenalty = driver_list::penalty_compare(name.c_str(), swinfo.longname().c_str()); + int shortpenalty = driver_list::penalty_compare(name.c_str(), swinfo.shortname().c_str()); + int curpenalty = std::min(longpenalty, shortpenalty); - // as long as this isn't the last entry, bump this one down - if (matchnum < matches - 1) + // insert into the sorted table of matches + for (int matchnum = matches - 1; matchnum >= 0; matchnum--) { - penalty[matchnum + 1] = penalty[matchnum]; - list[matchnum + 1] = list[matchnum]; + // stop if we're worse than the current entry + if (curpenalty >= penalty[matchnum]) + break; + + // as long as this isn't the last entry, bump this one down + if (matchnum < matches - 1) + { + penalty[matchnum + 1] = penalty[matchnum]; + list[matchnum + 1] = list[matchnum]; + } + list[matchnum] = &swinfo; + penalty[matchnum] = curpenalty; } - list[matchnum] = &swinfo; - penalty[matchnum] = curpenalty; } } } diff --git a/src/frontend/mame/ui/imgcntrl.cpp b/src/frontend/mame/ui/imgcntrl.cpp index 793466f7d57..1c25db2cac4 100644 --- a/src/frontend/mame/ui/imgcntrl.cpp +++ b/src/frontend/mame/ui/imgcntrl.cpp @@ -223,7 +223,7 @@ void menu_control_device_image::handle() } else { - m_swp = &m_swi->parts().front(); + m_swp = m_swi->find_part("", m_image.image_interface()); load_software_part(); } break; diff --git a/src/frontend/mame/ui/swlist.cpp b/src/frontend/mame/ui/swlist.cpp index c327980376f..04c4feadad1 100644 --- a/src/frontend/mame/ui/swlist.cpp +++ b/src/frontend/mame/ui/swlist.cpp @@ -354,8 +354,12 @@ void menu_software::populate(float &customtop, float &custombottom) { bool found = false; for (const software_info &swinfo : swlistdev.get_info()) - if (swinfo.parts().front().matches_interface(m_interface)) - found = true; + for (const software_part &swpart : swinfo.parts()) + if (swpart.matches_interface(m_interface)) + { + found = true; + break; + } if (found) item_append(swlistdev.description(), "", 0, (void *)&swlistdev); } @@ -367,8 +371,12 @@ void menu_software::populate(float &customtop, float &custombottom) { bool found = false; for (const software_info &swinfo : swlistdev.get_info()) - if (swinfo.parts().front().matches_interface(m_interface)) - found = true; + for (const software_part &swpart : swinfo.parts()) + if (swpart.matches_interface(m_interface)) + { + found = true; + break; + } if (found) { if (!have_compatible)