Previous 15994 Revisions Next

r13404 Monday 28th November, 2011 at 11:58:11 UTC by Miodrag Milanović
Added validate lists option and removed on startup softlist validation (no whatsnew)
Highly improve startup time for drivers with big softlists
[src/emu]clifront.c clifront.h softlist.c softlist.h

src/emu/clifront.c
r13403r13404
6363   { NULL,                            NULL,       OPTION_HEADER,     "CORE COMMANDS" },
6464   { CLICOMMAND_HELP ";h;?",           "0",       OPTION_COMMAND,    "show help message" },
6565   { CLICOMMAND_VALIDATE ";valid",     "0",       OPTION_COMMAND,    "perform driver validation on all game drivers" },
66   { CLICOMMAND_VALIDATE_LISTS ";vl",  "0",       OPTION_COMMAND,    "perform driver validation on all softlists" },
6667
6768   /* configuration commands */
6869   { NULL,                            NULL,       OPTION_HEADER,     "CONFIGURATION COMMANDS" },
r13403r13404
13121313      return;
13131314   }
13141315
1316   if (strcmp(m_options.command(), CLICOMMAND_VALIDATE_LISTS) == 0)
1317   {
1318      validate_softlists(m_options);
1319      return;
1320   }
1321
13151322   // other commands need the INIs parsed
13161323   astring option_errors;
13171324   m_options.parse_standard_inis(option_errors);
src/emu/clifront.h
r13403r13404
5252// core commands
5353#define CLICOMMAND_HELP               "help"
5454#define CLICOMMAND_VALIDATE            "validate"
55#define CLICOMMAND_VALIDATE_LISTS      "validatelists"
5556
5657// configuration commands
5758#define CLICOMMAND_CREATECONFIG         "createconfig"
src/emu/softlist.c
r13403r13404
16661666{
16671667}
16681668
1669static DEVICE_VALIDITY_CHECK( software_list )
1669void validate_softlists(emu_options &options)
16701670{
1671   software_list_config *swlist = (software_list_config *)downcast<const legacy_device_base *>(device)->inline_config();
1672   int error = FALSE;
1673   softlist_map names;
1674   softlist_map descriptions;
1671   driver_enumerator drivlist(options);
1672   // first determine the maximum number of lists we might encounter
1673   int list_count = 0;
1674   while (drivlist.next())
1675      for (const device_t *dev = drivlist.config().devicelist().first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
1676      {
1677         software_list_config *swlist = (software_list_config *)downcast<const legacy_device_base *>(dev)->inline_config();
16751678
1676   enum { NAME_LEN_PARENT = 8, NAME_LEN_CLONE = 16 };
1679         for (int listnum = 0; listnum < DEVINFO_STR_SWLIST_MAX - DEVINFO_STR_SWLIST_0; listnum++)
1680            if (swlist->list_name[listnum] && *swlist->list_name[listnum] && swlist->list_type == SOFTWARE_LIST_ORIGINAL_SYSTEM)
1681               list_count++;
1682      }
16771683
1678   for (int i = 0; i < DEVINFO_STR_SWLIST_MAX - DEVINFO_STR_SWLIST_0; i++)
1684   // allocate a list
1685   astring *lists = global_alloc_array(astring, list_count);
1686   bool error = FALSE;
1687   if (list_count)
16791688   {
1680      if (swlist->list_name[i])
1689      drivlist.reset();
1690      list_count = 0;
1691      while (drivlist.next())
1692      for (const device_t *dev = drivlist.config().devicelist().first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
16811693      {
1682         software_list *list = software_list_open(options, swlist->list_name[i], FALSE, NULL);
1694         software_list_config *swlist = (software_list_config *)downcast<const legacy_device_base *>(dev)->inline_config();
1695         softlist_map names;
1696         softlist_map descriptions;
16831697
1684         /* if no .xml list is found, then return (this happens e.g. if you moved/renamed the xml list) */
1685         if (list == NULL)
1686            return FALSE;
1698         enum { NAME_LEN_PARENT = 8, NAME_LEN_CLONE = 16 };
16871699
1688         for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
1700         for (int i = 0; i < DEVINFO_STR_SWLIST_MAX - DEVINFO_STR_SWLIST_0; i++)
16891701         {
1690            const char *s;
1691            int is_clone = 0;
1702            if (swlist->list_name[i])
1703            {
1704               software_list *list = software_list_open(options, swlist->list_name[i], FALSE, NULL);
1705               if ( list )
1706               {
1707                  /* Verify if we have encountered this list before */
1708                  bool seen_before = false;
1709                  for (int seen_index = 0; seen_index < list_count && !seen_before; seen_index++)
1710                     if (lists[seen_index] == swlist->list_name[i])
1711                        seen_before = true;
16921712
1693            /* First, check if the xml got corrupted: */
1713                  if (!seen_before)
1714                  {
1715                     lists[list_count++] = swlist->list_name[i];
1716                     mame_printf_error("Validating : %s\n",swlist->list_name[i]);
1717                     for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
1718                     {
1719                        const char *s;
1720                        int is_clone = 0;
16941721
1695            /* Did we lost any description? */
1696            if (swinfo->longname == NULL)
1697            {
1698               mame_printf_error("%s: %s has no description\n", swlist->list_name[i], swinfo->shortname);
1699               return TRUE;
1700            }
1722                        /* First, check if the xml got corrupted: */
17011723
1702            /* Did we lost any year? */
1703            if (swinfo->year == NULL)
1704            {
1705               mame_printf_error("%s: %s has no year\n", swlist->list_name[i], swinfo->shortname);
1706               return TRUE;
1707            }
1724                        /* Did we lost any description? */
1725                        if (swinfo->longname == NULL)
1726                        {
1727                           mame_printf_error("%s: %s has no description\n", swlist->list_name[i], swinfo->shortname);
1728                           error = TRUE; break;
1729                        }
17081730
1709            /* Did we lost any publisher? */
1710            if (swinfo->publisher == NULL)
1711            {
1712               mame_printf_error("%s: %s has no publisher\n", swlist->list_name[i], swinfo->shortname);
1713               return TRUE;
1714            }
1731                        /* Did we lost any year? */
1732                        if (swinfo->year == NULL)
1733                        {
1734                           mame_printf_error("%s: %s has no year\n", swlist->list_name[i], swinfo->shortname);
1735                           error = TRUE; break;
1736                        }
17151737
1716            /* Second, since the xml is fine, run additional checks: */
1738                        /* Did we lost any publisher? */
1739                        if (swinfo->publisher == NULL)
1740                        {
1741                           mame_printf_error("%s: %s has no publisher\n", swlist->list_name[i], swinfo->shortname);
1742                           error = TRUE; break;
1743                        }
17171744
1718            /* check for duplicate names */
1719            if (names.add(swinfo->shortname, swinfo, FALSE) == TMERR_DUPLICATE)
1720            {
1721               software_info *match = names.find(swinfo->shortname);
1722               mame_printf_error("%s: %s is a duplicate name (%s)\n", swlist->list_name[i], swinfo->shortname, match->shortname);
1723               error = TRUE;
1724            }
1745                        /* Second, since the xml is fine, run additional checks: */
17251746
1726            /* check for duplicate descriptions */
1727            if (descriptions.add(swinfo->longname, swinfo, FALSE) == TMERR_DUPLICATE)
1728            {
1729               software_info *match = names.find(swinfo->shortname);
1730               mame_printf_error("%s: %s is a duplicate description (%s)\n", swlist->list_name[i], swinfo->longname, match->longname);
1731               error = TRUE;
1732            }
1747                        /* check for duplicate names */
1748                        if (names.add(swinfo->shortname, swinfo, FALSE) == TMERR_DUPLICATE)
1749                        {
1750                           software_info *match = names.find(swinfo->shortname);
1751                           mame_printf_error("%s: %s is a duplicate name (%s)\n", swlist->list_name[i], swinfo->shortname, match->shortname);
1752                           error = TRUE;
1753                        }
17331754
1734            if (swinfo->parentname != NULL)
1735            {
1736               is_clone = 1;
1755                        /* check for duplicate descriptions */
1756                        if (descriptions.add(swinfo->longname, swinfo, FALSE) == TMERR_DUPLICATE)
1757                        {
1758                           software_info *match = names.find(swinfo->shortname);
1759                           mame_printf_error("%s: %s is a duplicate description (%s)\n", swlist->list_name[i], swinfo->longname, match->longname);
1760                           error = TRUE;
1761                        }
17371762
1738               if (strcmp(swinfo->parentname, swinfo->shortname) == 0)
1739               {
1740                  mame_printf_error("%s: %s is set as a clone of itself\n", swlist->list_name[i], swinfo->shortname);
1741                  error = TRUE;
1742                  break;
1743               }
1763                        if (swinfo->parentname != NULL)
1764                        {
1765                           is_clone = 1;
17441766
1745               /* make sure the parent exists */
1746               software_info *swinfo2 = software_list_find(list, swinfo->parentname, NULL );
1767                           if (strcmp(swinfo->parentname, swinfo->shortname) == 0)
1768                           {
1769                              mame_printf_error("%s: %s is set as a clone of itself\n", swlist->list_name[i], swinfo->shortname);
1770                              error = TRUE;
1771                              break;
1772                           }
17471773
1748               if (!swinfo2)
1749               {
1750                  mame_printf_error("%s: parent '%s' software for '%s' not found\n", swlist->list_name[i], swinfo->parentname, swinfo->shortname);
1751                  error = TRUE;
1752               }
1753               else
1754               {
1755                  if (swinfo2->parentname != NULL)
1756                  {
1757                     mame_printf_error("%s: %s is a clone of a clone\n", swlist->list_name[i], swinfo->shortname);
1758                     error = TRUE;
1759                  }
1760               }
1761            }
1774                           /* make sure the parent exists */
1775                           software_info *swinfo2 = software_list_find(list, swinfo->parentname, NULL );
17621776
1763            /* make sure the driver name is 8 chars or less */
1764            if ((is_clone && strlen(swinfo->shortname) > NAME_LEN_CLONE) || ((!is_clone) && strlen(swinfo->shortname) > NAME_LEN_PARENT))
1765            {
1766               mame_printf_error("%s: %s %s driver name must be %d characters or less\n", swlist->list_name[i], swinfo->shortname,
1767                             is_clone ? "clone" : "parent", is_clone ? NAME_LEN_CLONE : NAME_LEN_PARENT);
1768               error = TRUE;
1769            }
1777                           if (!swinfo2)
1778                           {
1779                              mame_printf_error("%s: parent '%s' software for '%s' not found\n", swlist->list_name[i], swinfo->parentname, swinfo->shortname);
1780                              error = TRUE;
1781                           }
1782                           else
1783                           {
1784                              if (swinfo2->parentname != NULL)
1785                              {
1786                                 mame_printf_error("%s: %s is a clone of a clone\n", swlist->list_name[i], swinfo->shortname);
1787                                 error = TRUE;
1788                              }
1789                           }
1790                        }
17701791
1771            /* make sure the year is only digits, '?' or '+' */
1772            for (s = swinfo->year; *s; s++)
1773               if (!isdigit((UINT8)*s) && *s != '?' && *s != '+')
1774               {
1775                  mame_printf_error("%s: %s has an invalid year '%s'\n", swlist->list_name[i], swinfo->shortname, swinfo->year);
1776                  error = TRUE;
1777                  break;
1778               }
1792                        /* make sure the driver name is 8 chars or less */
1793                        if ((is_clone && strlen(swinfo->shortname) > NAME_LEN_CLONE) || ((!is_clone) && strlen(swinfo->shortname) > NAME_LEN_PARENT))
1794                        {
1795                           mame_printf_error("%s: %s %s driver name must be %d characters or less\n", swlist->list_name[i], swinfo->shortname,
1796                                         is_clone ? "clone" : "parent", is_clone ? NAME_LEN_CLONE : NAME_LEN_PARENT);
1797                           error = TRUE;
1798                        }
17791799
1780            for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
1781            {
1782               if (swpart->interface_ == NULL)
1783               {
1784                  mame_printf_error("%s: %s has a part (%s) without interface\n", swlist->list_name[i], swinfo->shortname, swpart->name);
1785                  error = TRUE;
1786               }
1800                        /* make sure the year is only digits, '?' or '+' */
1801                        for (s = swinfo->year; *s; s++)
1802                           if (!isdigit((UINT8)*s) && *s != '?' && *s != '+')
1803                           {
1804                              mame_printf_error("%s: %s has an invalid year '%s'\n", swlist->list_name[i], swinfo->shortname, swinfo->year);
1805                              error = TRUE;
1806                              break;
1807                           }
17871808
1788               if (software_find_romdata(swpart, NULL) == NULL)
1789               {
1790                  mame_printf_error("%s: %s has a part (%s) with no data\n", swlist->list_name[i], swinfo->shortname, swpart->name);
1791                  error = TRUE;
1792               }
1809                        for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
1810                        {
1811                           if (swpart->interface_ == NULL)
1812                           {
1813                              mame_printf_error("%s: %s has a part (%s) without interface\n", swlist->list_name[i], swinfo->shortname, swpart->name);
1814                              error = TRUE;
1815                           }
17931816
1794               for (struct rom_entry *swdata = software_find_romdata(swpart, NULL); swdata != NULL;  swdata = software_romdata_next(swdata))
1795               {
1796                  struct rom_entry *data = swdata;
1817                           if (software_find_romdata(swpart, NULL) == NULL)
1818                           {
1819                              mame_printf_error("%s: %s has a part (%s) with no data\n", swlist->list_name[i], swinfo->shortname, swpart->name);
1820                              error = TRUE;
1821                           }
17971822
1798                  if (data->_name && data->_hashdata)
1799                  {
1800                     const char *str;
1823                           for (struct rom_entry *swdata = software_find_romdata(swpart, NULL); swdata != NULL;  swdata = software_romdata_next(swdata))
1824                           {
1825                              struct rom_entry *data = swdata;
18011826
1802                     /* make sure it's all lowercase */
1803                     for (str = data->_name; *str; str++)
1804                        if (tolower((UINT8)*str) != *str)
1805                        {
1806                           mame_printf_error("%s: %s has upper case ROM name %s\n", swlist->list_name[i], swinfo->shortname, data->_name);
1807                           error = TRUE;
1808                           break;
1827                              if (data->_name && data->_hashdata)
1828                              {
1829                                 const char *str;
1830
1831                                 /* make sure it's all lowercase */
1832                                 for (str = data->_name; *str; str++)
1833                                    if (tolower((UINT8)*str) != *str)
1834                                    {
1835                                       mame_printf_error("%s: %s has upper case ROM name %s\n", swlist->list_name[i], swinfo->shortname, data->_name);
1836                                       error = TRUE;
1837                                       break;
1838                                    }
1839
1840                                 /* make sure the hash is valid */
1841                                 hash_collection hashes;
1842                                 if (!hashes.from_internal_string(data->_hashdata))
1843                                 {
1844                                    mame_printf_error("%s: %s has rom '%s' with an invalid hash string '%s'\n", swlist->list_name[i], swinfo->shortname, data->_name, data->_hashdata);
1845                                    error = TRUE;
1846                                 }
1847                              }
1848                           }
18091849                        }
1810
1811                     /* make sure the hash is valid */
1812                     hash_collection hashes;
1813                     if (!hashes.from_internal_string(data->_hashdata))
1814                     {
1815                        mame_printf_error("%s: %s has rom '%s' with an invalid hash string '%s'\n", swlist->list_name[i], swinfo->shortname, data->_name, data->_hashdata);
1816                        error = TRUE;
18171850                     }
18181851                  }
1819               }
1852                  software_list_close(list);
1853               }               
18201854            }
18211855         }
1822
1823         software_list_close(list);
18241856      }
18251857   }
1826   return error;
1858   if (error)
1859      throw emu_fatalerror(MAMERR_FAILED_VALIDITY, "Validity checks failed");
18271860}
18281861
18291862DEVICE_GET_INFO( software_list )
r13403r13404
18371870      /* --- the following bits of info are returned as pointers to data or functions --- */
18381871      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME( software_list );   break;
18391872      case DEVINFO_FCT_STOP:                     /* Nothing */                              break;
1840      case DEVINFO_FCT_VALIDITY_CHECK:            info->p = (void*)DEVICE_VALIDITY_CHECK_NAME( software_list ); break;
18411873
18421874      /* --- the following bits of info are returned as NULL-terminated strings --- */
18431875      case DEVINFO_STR_NAME:                     strcpy(info->s, "Software lists");               break;
src/emu/softlist.h
r13403r13404
118118
119119const char *software_get_default_slot(const device_list &devlist, emu_options &options, const device_image_interface *image, const char* default_card_slot);
120120
121void validate_softlists(emu_options &options);
121122/*********************************************************************
122123
123124    Driver software list configuration

Previous 15994 Revisions Next


© 1998-2018 The MESS Team