Enabled filtering in best matches and also in "noswitch" aka MAME like start or software (no whatsnew)

Note that it is possible to mount wrong region image manually,for example with cart parameter and
that prints warning
This commit is contained in:
Miodrag Milanovic 2011-12-22 15:15:51 +00:00
parent 40bb0ceaf3
commit 0b03356800
5 changed files with 65 additions and 46 deletions

View File

@ -197,33 +197,35 @@ int cli_frontend::execute(int argc, char **argv)
for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
{
const char *mount = software_part_get_feature(swpart, "automount");
if (mount==NULL || strcmp(mount,"no")!=0) {
// loop trough all parts
// search for a device with the right interface
const device_image_interface *image = NULL;
for (bool gotone = config.devicelist().first(image); gotone; gotone = image->next(image))
{
const char *interface = image->image_interface();
if (interface != NULL)
if (is_software_compatible(swpart, swlist)) {
if (mount==NULL || strcmp(mount,"no")!=0) {
// loop trough all parts
// search for a device with the right interface
const device_image_interface *image = NULL;
for (bool gotone = config.devicelist().first(image); gotone; gotone = image->next(image))
{
if (!strcmp(interface, swpart->interface_))
const char *interface = image->image_interface();
if (interface != NULL)
{
const char *option = m_options.value(image->brief_instance_name());
// mount only if not already mounted
if (strlen(option)==0) {
astring val;
val.printf("%s:%s:%s",swlist->list_name,m_options.software_name(),swpart->name);
// call this in order to set slot devices according to mounting
m_options.parse_slot_devices(argc, argv, option_errors, image->instance_name(), val.cstr());
if (!strcmp(interface, swpart->interface_))
{
const char *option = m_options.value(image->brief_instance_name());
// mount only if not already mounted
if (strlen(option)==0) {
astring val;
val.printf("%s:%s:%s",swlist->list_name,m_options.software_name(),swpart->name);
// call this in order to set slot devices according to mounting
m_options.parse_slot_devices(argc, argv, option_errors, image->instance_name(), val.cstr());
}
break;
}
break;
}
}
}
found = TRUE;
}
}
software_list_close(list);
found = TRUE;
break;
}

View File

@ -1211,7 +1211,7 @@ static int softlist_penalty_compare(const char *source, const char *target)
software_list_find_approx_matches
-------------------------------------------------*/
void software_list_find_approx_matches(software_list *swlist, const char *name, int matches, software_info **list, const char* interface)
void software_list_find_approx_matches(software_list_config *swlistcfg, software_list *swlist, const char *name, int matches, software_info **list, const char* interface)
{
#undef rand
@ -1238,7 +1238,7 @@ void software_list_find_approx_matches(software_list *swlist, const char *name,
software_info *candidate = swinfo;
software_part *part = software_find_part(swinfo, NULL, NULL);
if (interface==NULL || !strcmp(interface, part->interface_))
if ((interface==NULL || !strcmp(interface, part->interface_)) && (is_software_compatible(part, swlistcfg)))
{
/* pick the best match between driver name and description */
@ -1442,7 +1442,7 @@ void software_display_matches(const device_list &devlist,emu_options &options, c
software_list_parse(list, list->error_proc, NULL);
// get the top 5 approximate matches for the selected device interface (i.e. only carts for cartslot, etc.)
software_list_find_approx_matches(list, name, ARRAY_LENGTH(matches), matches, interface);
software_list_find_approx_matches(swlist, list, name, ARRAY_LENGTH(matches), matches, interface);
if (matches[0] != 0)
{
@ -1677,6 +1677,17 @@ bool load_software_part(emu_options &options, device_image_interface *image, con
*full_sw_name = auto_alloc_array( image->device().machine(), char, strlen(swlist_name) + strlen(software_info_ptr->shortname) + strlen(software_part_ptr->name) + 3 );
sprintf( *full_sw_name, "%s:%s:%s", swlist_name, software_info_ptr->shortname, software_part_ptr->name );
for (device_t *swlists = image->device().machine().devicelist().first(SOFTWARE_LIST); swlists != NULL; swlists = swlists->typenext())
{
software_list_config *swlist = (software_list_config *)downcast<const legacy_device_base *>(swlists)->inline_config();
if (strcmp(swlist->list_name,swlist_name)==0) {
if (!is_software_compatible(software_part_ptr, swlist)) {
mame_printf_warning("WARNING! the set %s might not work on this system due to missing filter(s) '%s'\n",software_info_ptr->shortname,swlist->filter);
}
break;
}
}
{
const char *requirement = software_part_get_feature(software_part_ptr, "requirement");
if (requirement!=NULL) {
@ -1776,6 +1787,26 @@ const char *software_part_get_feature(software_part *part, const char *feature_n
return retVal;
}
/*-------------------------------------------------
is_software_compatible
-------------------------------------------------*/
bool is_software_compatible(software_part *swpart, software_list_config *swlist)
{
const char *compatibility = software_part_get_feature(swpart, "compatibility");
const char *filter = swlist->filter;
if ((compatibility==NULL) || (filter==NULL)) return TRUE;
astring comp = astring(compatibility,",");
char *filt = core_strdup(filter);
char *token = strtok(filt,",");
while (token!= NULL)
{
if (comp.find(0,astring(token,","))!=-1) return TRUE;
token = strtok (NULL, ",");
}
return FALSE;
}
/***************************************************************************
DEVICE INTERFACE
***************************************************************************/

View File

@ -97,6 +97,14 @@ struct _software_list
int list_entries;
};
typedef struct _software_list_config software_list_config;
struct _software_list_config
{
char *list_name;
UINT32 list_type;
const char *filter;
};
/* Handling a software list */
software_list *software_list_open(emu_options &options, const char *listname, int is_preload, void (*error_proc)(const char *message));
void software_list_close(software_list *swlist);
@ -119,6 +127,8 @@ void software_display_matches(const device_list &devlist, emu_options &options,c
const char *software_get_default_slot(const device_list &devlist, emu_options &options, const device_image_interface *image, const char* default_card_slot);
void validate_softlists(emu_options &options);
bool is_software_compatible(software_part *swpart, software_list_config *swlist);
/*********************************************************************
Driver software list configuration
@ -130,14 +140,6 @@ DECLARE_LEGACY_DEVICE(SOFTWARE_LIST, software_list);
#define SOFTWARE_SUPPORTED_PARTIAL 1
#define SOFTWARE_SUPPORTED_NO 2
typedef struct _software_list_config software_list_config;
struct _software_list_config
{
char *list_name;
UINT32 list_type;
const char *filter;
};
#define SOFTWARE_LIST_ORIGINAL_SYSTEM 0
#define SOFTWARE_LIST_COMPATIBLE_SYSTEM 1

View File

@ -126,20 +126,6 @@ int ui_menu_software_list::compare_entries(const ui_menu_software_entry_info *e1
return result;
}
bool ui_menu_software_list::if_compatible(const char *compatibility, const char *filter)
{
if ((compatibility==NULL) || (filter==NULL)) return TRUE;
astring comp = astring(compatibility,",");
char *filt = core_strdup(filter);
char *token = strtok(filt,",");
while (token!= NULL)
{
if (comp.find(0,astring(token,","))!=-1) return TRUE;
token = strtok (NULL, ",");
}
return FALSE;
}
/* populate a specific list */
ui_menu_software_entry_info *ui_menu_software_list::append_software_entry(software_info *swinfo, device_image_interface* image)
@ -152,8 +138,7 @@ ui_menu_software_entry_info *ui_menu_software_list::append_software_entry(softwa
// check if at least one of the parts has the correct interface and add a menu entry only in this case
for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
{
const char *compatibility = software_part_get_feature(swpart, "compatibility");
if ((strcmp(interface, swpart->interface_) == 0) && if_compatible(compatibility, swlist->filter))
if ((strcmp(interface, swpart->interface_) == 0) && is_software_compatible(swpart, swlist))
{
entry_updated = TRUE;
// allocate a new entry

View File

@ -55,7 +55,6 @@ private:
int compare_entries(const ui_menu_software_entry_info *e1, const ui_menu_software_entry_info *e2, bool shortname);
ui_menu_software_entry_info *append_software_entry(software_info *swinfo, device_image_interface* image);
bool swinfo_has_multiple_parts(software_info *swinfo, const char *interface);
bool if_compatible(const char *compatibility, const char *filter);
};
class ui_menu_software : public ui_menu {