Previous 15994 Revisions Next

r7701 Sunday 4th April, 2010 at 14:56:19 UTC by Wilbert Pol
Allow MESS to do addtional software checking for -romident.
Added -listsoftware command.
[src/emu]clifront.c clifront.h
[src/mess]climess.c climess.h

src/emu/clifront.c
r7700r7701
5757static int info_romident(core_options *options, const char *gamename);
5858
5959/* utilities */
60static void romident(const char *filename, romident_status *status);
61static void identify_file(const char *name, romident_status *status);
62static void identify_data(const char *name, const UINT8 *data, int length, romident_status *status);
63static void match_roms(const char *hash, int length, int *found);
60static void romident(core_options *options, const char *filename, romident_status *status);
61static void identify_file(core_options *options, const char *name, romident_status *status);
62static void identify_data(core_options *options, const char *name, const UINT8 *data, int length, romident_status *status);
63static void match_roms(core_options *options, const char *hash, int length, int *found);
6464
6565
6666
r7700r7701
9797   { "listdevices;ld",           "0",        OPTION_COMMAND,    "list available devices" },
9898#ifdef MESS
9999   { "listmedia;lm",             "0",        OPTION_COMMAND,    "list available media for the system" },
100   { "listsoftware",             "0",        OPTION_COMMAND,    "list known software for the system" },
100101#endif
101102
102103   { NULL }
r7700r7701
274275      { CLIOPTION_VERIFYSAMPLES,   info_verifysamples },
275276#ifdef MESS
276277      { CLIOPTION_LISTMEDIA,      info_listmedia },
278      { CLIOPTION_LISTSOFTWARE,   info_listsoftware },
277279#endif
278280      { CLIOPTION_ROMIDENT,      info_romident }
279281   };
r7700r7701
876878      return MAMERR_FATALERROR;
877879
878880   /* do the identification */
879   romident(gamename, &status);
881   romident(options, gamename, &status);
880882
881883   /* clear out any cached files */
882884   zip_file_cache_clear();
r7700r7701
902904    romident - identify files
903905-------------------------------------------------*/
904906
905static void romident(const char *filename, romident_status *status)
907static void romident(core_options *options, const char *filename, romident_status *status)
906908{
907909   osd_directory *directory;
908910
r7700r7701
920922         if (entry->type == ENTTYPE_FILE)
921923         {
922924            astring curfile(filename, PATH_SEPARATOR, entry->name);
923            identify_file(curfile, status);
925            identify_file(options, curfile, status);
924926         }
925927      osd_closedir(directory);
926928   }
r7700r7701
945947                  /* decompress data into RAM and identify it */
946948                  ziperr = zip_file_decompress(zip, data, entry->uncompressed_length);
947949                  if (ziperr == ZIPERR_NONE)
948                     identify_data(entry->filename, data, entry->uncompressed_length, status);
950                     identify_data(options, entry->filename, data, entry->uncompressed_length, status);
949951                  global_free(data);
950952               }
951953            }
r7700r7701
957959
958960   /* otherwise, identify as a raw file */
959961   else
960      identify_file(filename, status);
962      identify_file(options, filename, status);
961963}
962964
963965
r7700r7701
967969    files
968970-------------------------------------------------*/
969971
970static void identify_file(const char *name, romident_status *status)
972static void identify_file(core_options *options, const char *name, romident_status *status)
971973{
972974   file_error filerr;
973975   osd_file *file;
r7700r7701
985987         /* read file data into RAM and identify it */
986988         filerr = osd_read(file, data, 0, length, &bytes);
987989         if (filerr == FILERR_NONE)
988            identify_data(name, data, bytes, status);
990            identify_data(options, name, data, bytes, status);
989991         global_free(data);
990992      }
991993      osd_close(file);
r7700r7701
9991001    fusemap into raw data first
10001002-------------------------------------------------*/
10011003
1002static void identify_data(const char *name, const UINT8 *data, int length, romident_status *status)
1004static void identify_data(core_options *options, const char *name, const UINT8 *data, int length, romident_status *status)
10031005{
10041006   char hash[HASH_BUF_SIZE];
10051007   UINT8 *tempjed = NULL;
r7700r7701
10311033   mame_printf_info("%-20s", basename.cstr());
10321034
10331035   /* see if we can find a match in the ROMs */
1034   match_roms(hash, length, &found);
1036   match_roms(options, hash, length, &found);
10351037
10361038   /* if we didn't find it, try to guess what it might be */
10371039   if (found == 0)
r7700r7701
10621064    match_roms - scan for a matching ROM by hash
10631065-------------------------------------------------*/
10641066
1065static void match_roms(const char *hash, int length, int *found)
1067static void match_roms(core_options *options, const char *hash, int length, int *found)
10661068{
10671069   int drvindex;
10681070
r7700r7701
10901092
10911093      machine_config_free(config);
10921094   }
1095
1096#ifdef MESS
1097   mess_match_roms( options, hash, length, found );
1098#endif
10931099}
src/emu/clifront.h
r7700r7701
3939#define CLIOPTION_VERIFYSAMPLES         "verifysamples"
4040#define CLIOPTION_ROMIDENT            "romident"
4141#define CLIOPTION_LISTMEDIA            "listmedia"      // needed by MESS
42#define CLIOPTION_LISTSOFTWARE         "listsoftware"
4243
4344
4445
src/mess/climess.c
r7700r7701
1010#include "climess.h"
1111#include "output.h"
1212#include "hash.h"
13#include "xmlfile.h"
1314
1415
1516/*-------------------------------------------------
r7700r7701
109110
110111
111112/*-------------------------------------------------
113    info_listsoftware - output the list of
114    software supported by a given game or set of
115    games
116   TODO: Avoid outputting lists more than once.
117   TODO: Add DTD.
118-------------------------------------------------*/
119
120int info_listsoftware(core_options *options, const char *gamename)
121{
122   FILE *out = stdout;
123
124   fprintf( out,
125         "<?xml version=\"1.0\"?>\n"
126         "<softwarelists>\n"
127   );
128
129   for ( int drvindex = 0; drivers[drvindex] != NULL; drvindex++ )
130   {
131      if ( mame_strwildcmp( gamename, drivers[drvindex]->name ) == 0 )
132      {
133         /* allocate the machine config */
134         machine_config *config = machine_config_alloc( drivers[drvindex]->machine_config );
135
136         for (const device_config *dev = config->devicelist.first(); dev != NULL; dev = dev->next)
137         {
138            if ( ! strcmp( dev->tag(), __SOFTWARE_LIST_TAG ) )
139            {
140               software_list_config *swlist = (software_list_config *)dev->inline_config;
141
142               for ( int i = 0; i < DEVINFO_STR_SWLIST_MAX - DEVINFO_STR_SWLIST_0; i++ )
143               {
144                  if ( swlist->list_name[i] )
145                  {
146                     fprintf(out, "\t<softwarelist name=\"%s\">\n", swlist->list_name[i] );
147
148                     software_list *list = software_list_open( options, swlist->list_name[i], FALSE, NULL );
149
150                     for ( software_info *swinfo = software_list_first( list ); swinfo != NULL; swinfo = software_list_next( list ) )
151                     {
152                        fprintf( out, "\t\t<software name=\"%s\"", swinfo->shortname );
153                        if ( swinfo->supported == SOFTWARE_SUPPORTED_PARTIAL )
154                           fprintf( out, " supported=\"partial\"" );
155                        if ( swinfo->supported == SOFTWARE_SUPPORTED_NO )
156                           fprintf( out, " supported=\"no\"" );
157                        fprintf( out, ">\n" );
158                        fprintf( out, "\t\t\t<description>%s</description>\n", xml_normalize_string(swinfo->longname) );
159                        fprintf( out, "\t\t\t<year>%s</year>\n", xml_normalize_string( swinfo->year ) );
160                        fprintf( out, "\t\t\t<publisher>%s</publisher>\n", xml_normalize_string( swinfo->publisher ) );
161
162                        for ( software_part *part = software_find_part( swinfo, NULL, NULL ); part != NULL; part = software_part_next( part ) )
163                        {
164                           fprintf( out, "\t\t\t<part name=\"%s\"", part->name );
165                           if ( part->interface )
166                              fprintf( out, " interface=\"%s\"", part->interface );
167                           if ( part->feature )
168                              fprintf( out, " features=\"%s\"", part->feature );
169                           fprintf( out, ">\n");
170
171                           /* TODO: display rom region information */
172                           for ( const rom_entry *region = part->romdata; region; region = rom_next_region( region ) )
173                           {
174                              fprintf( out, "\t\t\t\t<dataarea name=\"%s\" size=\"%x\">\n", ROMREGION_GETTAG(region), ROMREGION_GETLENGTH(region) );
175
176                              for ( const rom_entry *rom = rom_first_file( region ); rom; rom = rom_next_file( rom ) )
177                              {
178                                 if ( ROMENTRY_ISFILE(rom) )
179                                 {
180                                    fprintf( out, "\t\t\t\t\t<rom name=\"%s\" size=\"%d\"", ROM_GETNAME(rom), ROM_GETLENGTH(rom) );
181
182                                    /* dump checksum information only if there is a known dump */
183                                    if (!hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP))
184                                    {
185                                       char checksum[HASH_BUF_SIZE];
186                                       int hashtype;
187
188                                       /* iterate over hash function types and print out their values */
189                                       for (hashtype = 0; hashtype < HASH_NUM_FUNCTIONS; hashtype++)
190                                          if (hash_data_extract_printable_checksum(ROM_GETHASHDATA(rom), 1 << hashtype, checksum))
191                                             fprintf(out, " %s=\"%s\"", hash_function_name(1 << hashtype), checksum);
192                                    }
193
194                                    fprintf( out, " offset=\"%x\" />\n", ROM_GETOFFSET(rom) );
195                                 }
196                              }
197
198                              fprintf( out, "\t\t\t\t</datearea>\n" );
199                           }
200
201                           fprintf( out, "\t\t\t</part>\n" );
202                        }
203
204                        fprintf( out, "\t\t</software>\n" );
205                     }
206
207                     software_list_close( list );
208
209                     fprintf(out, "\t</softwarelist>\n" );
210                  }
211               }
212            }
213         }
214
215         machine_config_free( config );
216      }
217   }
218
219   fprintf( out, "</softwarelists>\n" );
220
221   return MAMERR_NONE;
222}
223
224
225/*-------------------------------------------------
112226    match_roms - scan for a matching software ROM by hash
113227-------------------------------------------------*/
114void mess_match_roms(const char *hash, int length, int *found)
228void mess_match_roms(core_options *options, const char *hash, int length, int *found)
115229{
116   int listnum;
230   int drvindex;
117231
118   for ( listnum = 0; software_lists[listnum] != NULL; listnum++ )
232   /* iterate over drivers */
233   for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
119234   {
120      const software_list *swlist = software_lists[listnum];
121      int j;
235      machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config);
122236
123      for ( j = 0; swlist->entries[j].name != NULL; j++ )
237      for (const device_config *dev = config->devicelist.first(); dev != NULL; dev = dev->next)
124238      {
125         const software_entry *sw = &swlist->entries[j];
126         const rom_entry *region, *rom;
239         if ( ! strcmp( dev->tag(), __SOFTWARE_LIST_TAG ) )
240         {
241            software_list_config *swlist = (software_list_config *)dev->inline_config;
127242
128         for (region = &sw->rom_info[0]; region; region = rom_next_region(region))
129         {
130            for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
243            for ( int i = 0; i < DEVINFO_STR_SWLIST_MAX - DEVINFO_STR_SWLIST_0; i++ )
131244            {
132               if (hash_data_is_equal(hash, ROM_GETHASHDATA(rom), 0))
245               if ( swlist->list_name[i] )
133246               {
134                  int baddump = hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP);
247                  software_list *list = software_list_open( options, swlist->list_name[i], FALSE, NULL );
135248
136                  /* output information about the match */
137                  if (*found != 0)
138                     mame_printf_info("                    ");
139                  mame_printf_info("= %s%-20s  %-10s %s [%s]\n", baddump ? "(BAD) " : "", ROM_GETNAME(rom), sw->name, sw->fullname, swlist->name);
140                  (*found)++;
249                  for ( software_info *swinfo = software_list_first( list ); swinfo != NULL; swinfo = software_list_next( list ) )
250                  {
251                     for ( software_part *part = software_find_part( swinfo, NULL, NULL ); part != NULL; part = software_part_next( part ) )
252                     {
253                        for ( const rom_entry *region = part->romdata; region; region = rom_next_region(region) )
254                        {
255                           for ( const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom) )
256                           {
257                              if ( hash_data_is_equal(hash, ROM_GETHASHDATA(rom), 0) )
258                              {
259                                 int baddump = hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP);
260
261                                 /* output information about the match */
262                                 if (*found != 0)
263                                    mame_printf_info("                    ");
264                                 mame_printf_info("= %s%-20s  %s:%s %s\n", baddump ? "(BAD) " : "", ROM_GETNAME(rom), swlist->list_name[i], swinfo->shortname, swinfo->longname);
265                                 (*found)++;
266                              }
267                           }
268                        }
269                     }
270                  }
271
272                  software_list_close( list );
141273               }
142274            }
143275         }
144276      }
277
278      machine_config_free(config);
145279   }
146280}
147281
148
src/mess/climess.h
r7700r7701
1818
1919void mess_display_help(void);
2020int info_listmedia(core_options *opts, const char *gamename);
21void mess_match_roms(const char *hash, int length, int *found);
21void mess_match_roms(core_options *options, const char *hash, int length, int *found);
22int info_listsoftware(core_options *opts, const char *gamename);
2223
2324
2425#endif   /* __CLIMESS_H__ */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team