src/mess/climess.c
| r7758 | r7759 | |
| 113 | 113 | info_listsoftware - output the list of |
| 114 | 114 | software supported by a given game or set of |
| 115 | 115 | games |
| 116 | | TODO: Avoid outputting lists more than once. |
| 117 | | TODO: Add DTD. |
| 118 | 116 | TODO: Add all information read from the source files |
| 117 | Possible improvement: use a sorted list for |
| 118 | identifying duplicate lists. |
| 119 | 119 | -------------------------------------------------*/ |
| 120 | 120 | |
| 121 | 121 | int info_listsoftware(core_options *options, const char *gamename) |
| 122 | 122 | { |
| 123 | 123 | FILE *out = stdout; |
| 124 | int nr_lists = 0; |
| 125 | char ** lists = NULL; |
| 126 | int list_idx = 0; |
| 124 | 127 | |
| 128 | /* First determine the maximum number of lists we might encounter */ |
| 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] && *swlist->list_name[i] ) |
| 145 | nr_lists++; |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | /* free the machine config */ |
| 151 | machine_config_free( config ); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | lists = global_alloc_array( char *, nr_lists ); |
| 156 | |
| 125 | 157 | fprintf( out, |
| 126 | 158 | "<?xml version=\"1.0\"?>\n" |
| 159 | "<!ELEMENT softwarelists (softwarelist*)\n" |
| 160 | "\t<!ELEMENT softwarelist (software+)>\n" |
| 161 | "\t\t<!ATTLIST softwarelist name CDATA #REQUIRED>\n" |
| 162 | "\t\t<!ATTLIST softwarelist description CDATA #IMPLIED>\n" |
| 163 | "\t\t<!ELEMENT software (description, year?, publisher, part*)>\n" |
| 164 | "\t\t\t<!ATTLIST software name CDATA #REQUIRED>\n" |
| 165 | "\t\t\t<!ATTLIST software cloneof CDATA #IMPLIED>\n" |
| 166 | "\t\t\t<!ATTLIST software supported (yes|partial|no) \"yes\">\n" |
| 167 | "\t\t\t<!ELEMENT description (#PCDATA)>\n" |
| 168 | "\t\t\t<!ELEMENT year (#PCDATA)>\n" |
| 169 | "\t\t\t<!ELEMENT publisher (#PCDATA)>\n" |
| 170 | "\t\t\t<!ELEMENT part (dataarea*)>\n" |
| 171 | "\t\t\t\t<!ATTLIST part name CDATA #REQUIRED>\n" |
| 172 | "\t\t\t\t<!ATTLIST part interface CDATA #REQUIRED>\n" |
| 173 | "\t\t\t\t<!ATTLIST part feature CDATA #IMPLIED>\n" |
| 174 | "\t\t\t\t<!ELEMENT dataarea (rom*)>\n" |
| 175 | "\t\t\t\t\t<!ATTLIST dataarea name CDATA #REQUIRED>\n" |
| 176 | "\t\t\t\t\t<!ATTLIST dataarea size CDATA #REQUIRED>\n" |
| 177 | "\t\t\t\t\t<!ATTLIST dataarea databits (8|16|32|64) \"8\">\n" |
| 178 | "\t\t\t\t\t<!ATTLIST dataarea endian (big|little) \"little\">\n" |
| 179 | "\t\t\t\t\t<!ELEMENT rom EMPTY>\n" |
| 180 | "\t\t\t\t\t\t<!ATTLIST rom name CDATA #IMPLIED>\n" |
| 181 | "\t\t\t\t\t\t<!ATTLIST rom size CDATA #REQUIRED>\n" |
| 182 | "\t\t\t\t\t\t<!ATTLIST rom crc CDATA #IMPLIED>\n" |
| 183 | "\t\t\t\t\t\t<!ATTLIST rom md5 CDATA #IMPLIED>\n" |
| 184 | "\t\t\t\t\t\t<!ATTLIST rom sha1 CDATA #IMPLIED>\n" |
| 185 | "\t\t\t\t\t\t<!ATTLIST rom offset CDATA #IMPLIED>\n" |
| 186 | "\t\t\t\t\t\t<!ATTLIST rom status (baddump|nodump|good) \"good\">\n" |
| 187 | "\t\t\t\t\t\t<!ATTLIST rom loadflag (load16_byte|load16_word|load16_word_swap|load32_byte|load32_word|load32_word_swap|load32_dword|load64_word|load64_word_swap|reload) #IMPLIED>\n" |
| 127 | 188 | "<softwarelists>\n" |
| 128 | 189 | ); |
| 129 | 190 | |
| r7758 | r7759 | |
| 144 | 205 | { |
| 145 | 206 | if ( swlist->list_name[i] && *swlist->list_name[i] ) |
| 146 | 207 | { |
| 147 | | fprintf(out, "\t<softwarelist name=\"%s\">\n", swlist->list_name[i] ); |
| 148 | | |
| 149 | 208 | software_list *list = software_list_open( options, swlist->list_name[i], FALSE, NULL ); |
| 150 | 209 | |
| 151 | 210 | if ( list ) |
| 152 | 211 | { |
| 153 | | for ( software_info *swinfo = software_list_first( list ); swinfo != NULL; swinfo = software_list_next( list ) ) |
| 212 | /* Verify if we have encountered this list before */ |
| 213 | bool seen_before = false; |
| 214 | for ( int l = 0; l < list_idx && !seen_before; l++ ) |
| 154 | 215 | { |
| 155 | | fprintf( out, "\t\t<software name=\"%s\"", swinfo->shortname ); |
| 156 | | if ( swinfo->supported == SOFTWARE_SUPPORTED_PARTIAL ) |
| 157 | | fprintf( out, " supported=\"partial\"" ); |
| 158 | | if ( swinfo->supported == SOFTWARE_SUPPORTED_NO ) |
| 159 | | fprintf( out, " supported=\"no\"" ); |
| 160 | | fprintf( out, ">\n" ); |
| 161 | | fprintf( out, "\t\t\t<description>%s</description>\n", xml_normalize_string(swinfo->longname) ); |
| 162 | | fprintf( out, "\t\t\t<year>%s</year>\n", xml_normalize_string( swinfo->year ) ); |
| 163 | | fprintf( out, "\t\t\t<publisher>%s</publisher>\n", xml_normalize_string( swinfo->publisher ) ); |
| 216 | if ( ! strcmp( swlist->list_name[i], lists[l] ) ) |
| 217 | { |
| 218 | seen_before = true; |
| 219 | } |
| 220 | } |
| 164 | 221 | |
| 165 | | for ( software_part *part = software_find_part( swinfo, NULL, NULL ); part != NULL; part = software_part_next( part ) ) |
| 222 | if ( ! seen_before ) |
| 223 | { |
| 224 | lists[list_idx] = core_strdup( swlist->list_name[i] ); |
| 225 | list_idx++; |
| 226 | |
| 227 | fprintf(out, "\t<softwarelist name=\"%s\">\n", swlist->list_name[i] ); |
| 228 | |
| 229 | for ( software_info *swinfo = software_list_first( list ); swinfo != NULL; swinfo = software_list_next( list ) ) |
| 166 | 230 | { |
| 167 | | fprintf( out, "\t\t\t<part name=\"%s\"", part->name ); |
| 168 | | if ( part->interface_ ) |
| 169 | | fprintf( out, " interface=\"%s\"", part->interface_ ); |
| 170 | | if ( part->feature ) |
| 171 | | fprintf( out, " features=\"%s\"", part->feature ); |
| 172 | | fprintf( out, ">\n"); |
| 231 | fprintf( out, "\t\t<software name=\"%s\"", swinfo->shortname ); |
| 232 | if ( swinfo->supported == SOFTWARE_SUPPORTED_PARTIAL ) |
| 233 | fprintf( out, " supported=\"partial\"" ); |
| 234 | if ( swinfo->supported == SOFTWARE_SUPPORTED_NO ) |
| 235 | fprintf( out, " supported=\"no\"" ); |
| 236 | fprintf( out, ">\n" ); |
| 237 | fprintf( out, "\t\t\t<description>%s</description>\n", xml_normalize_string(swinfo->longname) ); |
| 238 | fprintf( out, "\t\t\t<year>%s</year>\n", xml_normalize_string( swinfo->year ) ); |
| 239 | fprintf( out, "\t\t\t<publisher>%s</publisher>\n", xml_normalize_string( swinfo->publisher ) ); |
| 173 | 240 | |
| 174 | | /* TODO: display rom region information */ |
| 175 | | for ( const rom_entry *region = part->romdata; region; region = rom_next_region( region ) ) |
| 241 | for ( software_part *part = software_find_part( swinfo, NULL, NULL ); part != NULL; part = software_part_next( part ) ) |
| 176 | 242 | { |
| 177 | | fprintf( out, "\t\t\t\t<dataarea name=\"%s\" size=\"%x\">\n", ROMREGION_GETTAG(region), ROMREGION_GETLENGTH(region) ); |
| 243 | fprintf( out, "\t\t\t<part name=\"%s\"", part->name ); |
| 244 | if ( part->interface_ ) |
| 245 | fprintf( out, " interface=\"%s\"", part->interface_ ); |
| 246 | if ( part->feature ) |
| 247 | fprintf( out, " features=\"%s\"", part->feature ); |
| 248 | fprintf( out, ">\n"); |
| 178 | 249 | |
| 179 | | for ( const rom_entry *rom = rom_first_file( region ); rom; rom = rom_next_file( rom ) ) |
| 250 | /* TODO: display rom region information */ |
| 251 | for ( const rom_entry *region = part->romdata; region; region = rom_next_region( region ) ) |
| 180 | 252 | { |
| 181 | | if ( ROMENTRY_ISFILE(rom) ) |
| 253 | fprintf( out, "\t\t\t\t<dataarea name=\"%s\" size=\"%x\">\n", ROMREGION_GETTAG(region), ROMREGION_GETLENGTH(region) ); |
| 254 | |
| 255 | for ( const rom_entry *rom = rom_first_file( region ); rom; rom = rom_next_file( rom ) ) |
| 182 | 256 | { |
| 183 | | fprintf( out, "\t\t\t\t\t<rom name=\"%s\" size=\"%d\"", ROM_GETNAME(rom), ROM_GETLENGTH(rom) ); |
| 184 | | |
| 185 | | /* dump checksum information only if there is a known dump */ |
| 186 | | if (!hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) |
| 257 | if ( ROMENTRY_ISFILE(rom) ) |
| 187 | 258 | { |
| 188 | | char checksum[HASH_BUF_SIZE]; |
| 189 | | int hashtype; |
| 259 | fprintf( out, "\t\t\t\t\t<rom name=\"%s\" size=\"%d\"", ROM_GETNAME(rom), ROM_GETLENGTH(rom) ); |
| 190 | 260 | |
| 191 | | /* iterate over hash function types and print out their values */ |
| 192 | | for (hashtype = 0; hashtype < HASH_NUM_FUNCTIONS; hashtype++) |
| 193 | | if (hash_data_extract_printable_checksum(ROM_GETHASHDATA(rom), 1 << hashtype, checksum)) |
| 194 | | fprintf(out, " %s=\"%s\"", hash_function_name(1 << hashtype), checksum); |
| 195 | | } |
| 261 | /* dump checksum information only if there is a known dump */ |
| 262 | if (!hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) |
| 263 | { |
| 264 | char checksum[HASH_BUF_SIZE]; |
| 265 | int hashtype; |
| 196 | 266 | |
| 197 | | fprintf( out, " offset=\"%x\"", ROM_GETOFFSET(rom) ); |
| 267 | /* iterate over hash function types and print out their values */ |
| 268 | for (hashtype = 0; hashtype < HASH_NUM_FUNCTIONS; hashtype++) |
| 269 | if (hash_data_extract_printable_checksum(ROM_GETHASHDATA(rom), 1 << hashtype, checksum)) |
| 270 | fprintf(out, " %s=\"%s\"", hash_function_name(1 << hashtype), checksum); |
| 271 | } |
| 198 | 272 | |
| 199 | | if ( hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP) ) |
| 200 | | fprintf( out, " status=\"baddump\"" ); |
| 201 | | if ( hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP) ) |
| 202 | | fprintf( out, " status=\"nodump\"" ); |
| 273 | fprintf( out, " offset=\"%x\"", ROM_GETOFFSET(rom) ); |
| 203 | 274 | |
| 204 | | fprintf( out, "/>\n" ); |
| 275 | if ( hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP) ) |
| 276 | fprintf( out, " status=\"baddump\"" ); |
| 277 | if ( hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP) ) |
| 278 | fprintf( out, " status=\"nodump\"" ); |
| 279 | |
| 280 | fprintf( out, "/>\n" ); |
| 281 | } |
| 205 | 282 | } |
| 283 | |
| 284 | fprintf( out, "\t\t\t\t</datearea>\n" ); |
| 206 | 285 | } |
| 207 | 286 | |
| 208 | | fprintf( out, "\t\t\t\t</datearea>\n" ); |
| 287 | fprintf( out, "\t\t\t</part>\n" ); |
| 209 | 288 | } |
| 210 | 289 | |
| 211 | | fprintf( out, "\t\t\t</part>\n" ); |
| 290 | fprintf( out, "\t\t</software>\n" ); |
| 212 | 291 | } |
| 213 | 292 | |
| 214 | | fprintf( out, "\t\t</software>\n" ); |
| 293 | fprintf(out, "\t</softwarelist>\n" ); |
| 215 | 294 | } |
| 216 | 295 | |
| 217 | 296 | software_list_close( list ); |
| 218 | 297 | } |
| 219 | | |
| 220 | | fprintf(out, "\t</softwarelist>\n" ); |
| 221 | 298 | } |
| 222 | 299 | } |
| 223 | 300 | } |
| r7758 | r7759 | |
| 229 | 306 | |
| 230 | 307 | fprintf( out, "</softwarelists>\n" ); |
| 231 | 308 | |
| 309 | global_free( lists ); |
| 310 | |
| 232 | 311 | return MAMERR_NONE; |
| 233 | 312 | } |
| 234 | 313 | |