trunk/src/emu/diimage.c
| r18440 | r18441 | |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | /*------------------------------------------------- |
| 741 | dump_wrong_and_correct_checksums - dump an |
| 742 | error message containing the wrong and the |
| 743 | correct checksums for a given software item |
| 744 | -------------------------------------------------*/ |
| 745 | |
| 746 | static void dump_wrong_and_correct_checksums(const hash_collection &hashes, const hash_collection &acthashes) |
| 747 | { |
| 748 | astring tempstr; |
| 749 | mame_printf_error(" EXPECTED: %s\n", hashes.macro_string(tempstr)); |
| 750 | mame_printf_error(" FOUND: %s\n", acthashes.macro_string(tempstr)); |
| 751 | } |
| 752 | |
| 753 | /*------------------------------------------------- |
| 754 | verify_length_and_hash - verify the length |
| 755 | and hash signatures of a file |
| 756 | -------------------------------------------------*/ |
| 757 | |
| 758 | static int verify_length_and_hash(emu_file *file, const char *name, UINT32 explength, const hash_collection &hashes) |
| 759 | { |
| 760 | int retVal = 0; |
| 761 | if (file==NULL) return 0; |
| 762 | |
| 763 | /* verify length */ |
| 764 | UINT32 actlength = file->size(); |
| 765 | if (explength != actlength) |
| 766 | { |
| 767 | mame_printf_error("%s WRONG LENGTH (expected: %d found: %d)\n", name, explength, actlength); |
| 768 | retVal++; |
| 769 | } |
| 770 | |
| 771 | /* If there is no good dump known, write it */ |
| 772 | astring tempstr; |
| 773 | hash_collection &acthashes = file->hashes(hashes.hash_types(tempstr)); |
| 774 | if (hashes.flag(hash_collection::FLAG_NO_DUMP)) |
| 775 | { |
| 776 | mame_printf_error("%s NO GOOD DUMP KNOWN\n", name); |
| 777 | } |
| 778 | /* verify checksums */ |
| 779 | else if (hashes != acthashes) |
| 780 | { |
| 781 | /* otherwise, it's just bad */ |
| 782 | mame_printf_error("%s WRONG CHECKSUMS:\n", name); |
| 783 | dump_wrong_and_correct_checksums(hashes, acthashes); |
| 784 | retVal++; |
| 785 | } |
| 786 | /* If it matches, but it is actually a bad dump, write it */ |
| 787 | else if (hashes.flag(hash_collection::FLAG_BAD_DUMP)) |
| 788 | { |
| 789 | mame_printf_error("%s NEEDS REDUMP\n",name); |
| 790 | } |
| 791 | return retVal; |
| 792 | } |
| 793 | |
| 794 | /*------------------------------------------------- |
| 741 | 795 | load_software - software image loading |
| 742 | 796 | -------------------------------------------------*/ |
| 743 | 797 | bool device_image_interface::load_software(char *swlist, char *swname, rom_entry *start) |
| r18440 | r18441 | |
| 746 | 800 | const rom_entry *region; |
| 747 | 801 | astring regiontag; |
| 748 | 802 | bool retVal = FALSE; |
| 803 | int warningcount = 0; |
| 749 | 804 | for (region = start; region != NULL; region = rom_next_region(region)) |
| 750 | 805 | { |
| 751 | 806 | /* loop until we hit the end of this region */ |
| r18440 | r18441 | |
| 831 | 886 | if ((m_mame_file == NULL) && (tag5.cstr() != NULL)) |
| 832 | 887 | filerr = common_process_file(device().machine().options(), tag5.cstr(), has_crc, crc, romp, &m_mame_file); |
| 833 | 888 | |
| 889 | warningcount += verify_length_and_hash(m_mame_file,ROM_GETNAME(romp),ROM_GETLENGTH(romp),hash_collection(ROM_GETHASHDATA(romp))); |
| 890 | |
| 834 | 891 | if (filerr == FILERR_NONE) |
| 835 | 892 | { |
| 836 | 893 | m_file = *m_mame_file; |
| r18440 | r18441 | |
| 842 | 899 | romp++; /* something else; skip */ |
| 843 | 900 | } |
| 844 | 901 | } |
| 902 | if (warningcount > 0) |
| 903 | { |
| 904 | mame_printf_error("WARNING: the software item might not run correctly.\n"); |
| 905 | } |
| 845 | 906 | return retVal; |
| 846 | 907 | } |
| 847 | 908 | |