src/emu/clifront.c
| r12655 | r12656 | |
| 734 | 734 | // verifyroms - verify the ROM sets of one or |
| 735 | 735 | // more games |
| 736 | 736 | //------------------------------------------------- |
| 737 | extern int m_device_count; |
| 738 | extern const device_type *s_devices_sorted[]; |
| 737 | 739 | |
| 738 | 740 | void cli_frontend::verifyroms(const char *gamename) |
| 739 | 741 | { |
| r12655 | r12656 | |
| 748 | 750 | |
| 749 | 751 | // iterate over drivers |
| 750 | 752 | media_auditor auditor(drivlist); |
| 753 | UINT8* device_used = global_alloc_array_clear(UINT8, m_device_count); |
| 751 | 754 | while (drivlist.next()) |
| 752 | 755 | { |
| 753 | 756 | // audit the ROMs in this set |
| r12655 | r12656 | |
| 755 | 758 | |
| 756 | 759 | // output the summary of the audit |
| 757 | 760 | astring summary_string; |
| 758 | | auditor.summarize(&summary_string); |
| 761 | auditor.summarize(drivlist.driver().name,&summary_string); |
| 759 | 762 | mame_printf_info("%s", summary_string.cstr()); |
| 763 | for (const rom_source *source = rom_first_source(drivlist.config()); source != NULL; source = rom_next_source(*source)) |
| 764 | { |
| 765 | for(int i=0;i<m_device_count;i++) { |
| 766 | if (source->type() == *s_devices_sorted[i]) device_used[i] = 1; |
| 767 | } |
| 768 | } |
| 760 | 769 | |
| 761 | 770 | // if not found, count that and leave it at that |
| 762 | 771 | if (summary == media_auditor::NOTFOUND) |
| r12655 | r12656 | |
| 794 | 803 | } |
| 795 | 804 | } |
| 796 | 805 | } |
| 806 | |
| 807 | drivlist.reset(); |
| 808 | drivlist.next(); |
| 809 | machine_config &config = drivlist.config(); |
| 810 | device_t *owner = config.devicelist().first(); |
| 811 | // check if all are listed, note that empty one is included |
| 812 | bool display_all = driver_list::total() == (drivlist.count()+1); |
| 813 | for(int i=0;i<m_device_count;i++) { |
| 814 | if (display_all || (device_used[i]!=0)) { |
| 815 | device_type type = *s_devices_sorted[i]; |
| 816 | device_t *dev = (*type)(config, "dummy", owner, 0); |
| 817 | dev->config_complete(); |
| 818 | |
| 819 | // audit the ROMs in this set |
| 820 | media_auditor::summary summary = auditor.audit_device(dev, AUDIT_VALIDATE_FAST); |
| 797 | 821 | |
| 822 | // output the summary of the audit |
| 823 | astring summary_string; |
| 824 | auditor.summarize(dev->shortname(),&summary_string); |
| 825 | mame_printf_info("%s", summary_string.cstr()); |
| 826 | |
| 827 | // if not found, count that and leave it at that |
| 828 | if (summary == media_auditor::NOTFOUND) |
| 829 | notfound++; |
| 830 | |
| 831 | // else display information about what we discovered |
| 832 | else |
| 833 | { |
| 834 | mame_printf_info("romset %s ", dev->shortname()); |
| 835 | |
| 836 | // switch off of the result |
| 837 | switch (summary) |
| 838 | { |
| 839 | case media_auditor::INCORRECT: |
| 840 | mame_printf_info("is bad\n"); |
| 841 | incorrect++; |
| 842 | break; |
| 843 | |
| 844 | case media_auditor::CORRECT: |
| 845 | mame_printf_info("is good\n"); |
| 846 | correct++; |
| 847 | break; |
| 848 | |
| 849 | case media_auditor::BEST_AVAILABLE: |
| 850 | mame_printf_info("is best available\n"); |
| 851 | correct++; |
| 852 | break; |
| 853 | |
| 854 | default: |
| 855 | break; |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | global_free(dev); |
| 860 | } |
| 861 | } |
| 862 | |
| 863 | global_free(device_used); |
| 864 | |
| 798 | 865 | // clear out any cached files |
| 799 | 866 | zip_file_cache_clear(); |
| 800 | 867 | |
| r12655 | r12656 | |
| 842 | 909 | |
| 843 | 910 | // output the summary of the audit |
| 844 | 911 | astring summary_string; |
| 845 | | auditor.summarize(&summary_string); |
| 912 | auditor.summarize(drivlist.driver().name,&summary_string); |
| 846 | 913 | mame_printf_info("%s", summary_string.cstr()); |
| 847 | 914 | |
| 848 | 915 | // if not found, print a message and set the flag |
src/emu/audit.c
| r12655 | r12656 | |
| 83 | 83 | int required = 0; |
| 84 | 84 | int sharedFound = 0; |
| 85 | 85 | int sharedRequired = 0; |
| 86 | | for (const rom_source *source = rom_first_source(m_enumerator.config()); source != NULL; source = rom_next_source(*source)) |
| 86 | //for (const rom_source *source = rom_first_source(m_enumerator.config()); source != NULL; source = rom_next_source(*source)) |
| 87 | const rom_source *source = rom_first_source(m_enumerator.config()); |
| 87 | 88 | { |
| 88 | 89 | // determine the search path for this source and iterate through the regions |
| 89 | 90 | m_searchpath = source->searchpath(); |
| r12655 | r12656 | |
| 148 | 149 | } |
| 149 | 150 | |
| 150 | 151 | // return a summary |
| 151 | | return summarize(); |
| 152 | return summarize(m_enumerator.driver().name); |
| 152 | 153 | } |
| 153 | 154 | |
| 154 | 155 | |
| 155 | 156 | //------------------------------------------------- |
| 157 | // audit_device - audit the device |
| 158 | //------------------------------------------------- |
| 159 | |
| 160 | media_auditor::summary media_auditor::audit_device(device_t *device, const char *validation) |
| 161 | { |
| 162 | // start fresh |
| 163 | m_record_list.reset(); |
| 164 | |
| 165 | // store validation for later |
| 166 | m_validation = validation; |
| 167 | |
| 168 | // iterate over ROM sources and regions |
| 169 | int found = 0; |
| 170 | int required = 0; |
| 171 | // determine the search path for this source and iterate through the regions |
| 172 | m_searchpath = device->shortname(); |
| 173 | |
| 174 | // now iterate over regions and ROMs within |
| 175 | for (const rom_entry *region = rom_first_region(*device); region != NULL; region = rom_next_region(region)) |
| 176 | { |
| 177 | for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) |
| 178 | { |
| 179 | hash_collection hashes(ROM_GETHASHDATA(rom)); |
| 180 | |
| 181 | // count the number of files with hashes |
| 182 | if (!hashes.flag(hash_collection::FLAG_NO_DUMP) && !ROM_ISOPTIONAL(rom)) |
| 183 | { |
| 184 | required++; |
| 185 | } |
| 186 | |
| 187 | // audit a file |
| 188 | audit_record *record = NULL; |
| 189 | if (ROMREGION_ISROMDATA(region)) |
| 190 | record = audit_one_rom(rom); |
| 191 | |
| 192 | // audit a disk |
| 193 | else if (ROMREGION_ISDISKDATA(region)) |
| 194 | record = audit_one_disk(rom); |
| 195 | |
| 196 | // count the number of files that are found. |
| 197 | if (record != NULL && (record->status() == audit_record::STATUS_GOOD || (record->status() == audit_record::STATUS_FOUND_INVALID && also_used_by_parent(record->actual_hashes(), record->actual_length()) < 0))) |
| 198 | { |
| 199 | found++; |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | // return a summary |
| 205 | return summarize(device->shortname()); |
| 206 | } |
| 207 | |
| 208 | |
| 209 | //------------------------------------------------- |
| 156 | 210 | // audit_samples - validate the samples for the |
| 157 | 211 | // currently-enumerated driver |
| 158 | 212 | //------------------------------------------------- |
| r12655 | r12656 | |
| 207 | 261 | return NOTFOUND; |
| 208 | 262 | |
| 209 | 263 | // return a summary |
| 210 | | return summarize(); |
| 264 | return summarize(m_enumerator.driver().name); |
| 211 | 265 | } |
| 212 | 266 | |
| 213 | 267 | |
| r12655 | r12656 | |
| 216 | 270 | // string format |
| 217 | 271 | //------------------------------------------------- |
| 218 | 272 | |
| 219 | | media_auditor::summary media_auditor::summarize(astring *string) |
| 273 | media_auditor::summary media_auditor::summarize(const char *name, astring *string) |
| 220 | 274 | { |
| 221 | 275 | // loop over records |
| 222 | 276 | summary overall_status = CORRECT; |
| r12655 | r12656 | |
| 231 | 285 | // output the game name, file name, and length (if applicable) |
| 232 | 286 | if (string != NULL) |
| 233 | 287 | { |
| 234 | | string->catprintf("%-12s: %s", m_enumerator.driver().name, record->name()); |
| 288 | string->catprintf("%-12s: %s", name, record->name()); |
| 235 | 289 | if (record->expected_length() > 0) |
| 236 | 290 | string->catprintf(" (%d bytes)", record->expected_length()); |
| 237 | 291 | string->catprintf(" - "); |