Previous 199869 Revisions Next

r18441 Thursday 11th October, 2012 at 10:18:59 UTC by Miodrag Milanović
verify softlist items that are not CHDs or roms and display warnings/errors (no whatsnew)
[src/emu]diimage.c

trunk/src/emu/diimage.c
r18440r18441
738738}
739739
740740/*-------------------------------------------------
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
746static 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
758static 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/*-------------------------------------------------
741795    load_software - software image loading
742796-------------------------------------------------*/
743797bool device_image_interface::load_software(char *swlist, char *swname, rom_entry *start)
r18440r18441
746800   const rom_entry *region;
747801   astring regiontag;
748802   bool retVal = FALSE;
803   int warningcount = 0;
749804   for (region = start; region != NULL; region = rom_next_region(region))
750805   {
751806      /* loop until we hit the end of this region */
r18440r18441
831886            if ((m_mame_file == NULL) && (tag5.cstr() != NULL))
832887               filerr = common_process_file(device().machine().options(), tag5.cstr(), has_crc, crc, romp, &m_mame_file);
833888
889            warningcount += verify_length_and_hash(m_mame_file,ROM_GETNAME(romp),ROM_GETLENGTH(romp),hash_collection(ROM_GETHASHDATA(romp)));
890
834891            if (filerr == FILERR_NONE)
835892            {
836893               m_file = *m_mame_file;
r18440r18441
842899         romp++;   /* something else; skip */
843900      }
844901   }
902   if (warningcount > 0)
903   {
904      mame_printf_error("WARNING: the software item might not run correctly.\n");
905   }
845906   return retVal;
846907}
847908

Previous 199869 Revisions Next


© 1997-2024 The MAME Team