1 0x0118f2c2 rename("tempfile", $outputFileName);
2 0x071b5cb4 "If the output file name extension is .mif, then the text mif file will be generated.\n" .
3 0x07dc90ac die "usage: buildCrcStringTable.pl [-t tabFileName.ext] outputFileName.ext [stringFile...]\n" .
4 0x07f0308b hex("0xF12F560E"), hex("0xF5EE4BB9"), hex("0xF8AD6D60"), hex("0xFC6C70D7"), hex("0xE22B20D2"), hex("0xE6EA3D65"), hex("0xEBA91BBC"), hex("0xEF68060B"),
5 0x0aca0e33 print "\t\tchunk \"DATA\"\n";
6 0x0bb7b42a $offset{$_} = $offset;
7 0x0fd8c2d7 use integer;
9 0x13eb8375 print "}\n";
10 0x1493d7f3 "-t : generate tab delimited output file as well\n" .
11 0x17c11891 hex("0x4C11DB70"), hex("0x48D0C6C7"), hex("0x4593E01E"), hex("0x4152FDA9"), hex("0x5F15ADAC"), hex("0x5BD4B01B"), hex("0x569796C2"), hex("0x52568B75"),
12 0x1c1a605d $outputFileName = shift;
13 0x2136581d hex("0x6A1936C8"), hex("0x6ED82B7F"), hex("0x639B0DA6"), hex("0x675A1011"), hex("0x791D4014"), hex("0x7DDC5DA3"), hex("0x709F7B7A"), hex("0x745E66CD"),
14 0x2146eb87 hex("0x4F040D56"), hex("0x4BC510E1"), hex("0x46863638"), hex("0x42472B8F"), hex("0x5C007B8A"), hex("0x58C1663D"), hex("0x558240E4"), hex("0x51435D53"),
15 0x21d0e687 hex("0x89B8FD09"), hex("0x8D79E0BE"), hex("0x803AC667"), hex("0x84FBDBD0"), hex("0x9ABC8BD5"), hex("0x9E7D9662"), hex("0x933EB0BB"), hex("0x97FFAD0C"),
16 0x22304a3e open(OUTPUT, ">" . $tabFileName) || die "could not open $tabFileName\n";
17 0x25bb1ec0 system("miff -i tempfile -o $outputFileName");
18 0x292b6c6d hex("0xD727BBB6"), hex("0xD3E6A601"), hex("0xDEA580D8"), hex("0xDA649D6F"), hex("0xC423CD6A"), hex("0xC0E2D0DD"), hex("0xCDA1F604"), hex("0xC960EBB3"),
19 0x2e71c624 "Otherwise, the binary IFF data will be written.\n" if (@ARGV < 1 || $ARGV[0] =~ /^[\/-][h\?]$/);
21 0x314ae407 my $offset = 0;
22 0x3531c729 hex("0xC6BCF05F"), hex("0xC27DEDE8"), hex("0xCF3ECB31"), hex("0xCBFFD686"), hex("0xD5B88683"), hex("0xD1799B34"), hex("0xDC3ABDED"), hex("0xD8FBA05A"),
23 0x353a3f3b print "\t\tchunk \"CRCT\"\n";
24 0x3afc35be hex("0xD4326D90"), hex("0xD0F37027"), hex("0xDDB056FE"), hex("0xD9714B49"), hex("0xC7361B4C"), hex("0xC3F706FB"), hex("0xCEB42022"), hex("0xCA753D95"),
25 0x3fdfeaa7 my $tab = 0;
26 0x408cef82 hex("0x690CE0EE"), hex("0x6DCDFD59"), hex("0x608EDB80"), hex("0x644FC637"), hex("0x7A089632"), hex("0x7EC98B85"), hex("0x738AAD5C"), hex("0x774BB0EB"),
27 0x40df4fb5 print $outputFileName, "\n";
28 0x41db48cb hex("0xE3A1CBC1"), hex("0xE760D676"), hex("0xEA23F0AF"), hex("0xEEE2ED18"), hex("0xF0A5BD1D"), hex("0xF464A0AA"), hex("0xF9278673"), hex("0xFDE69BC4"),
29 0x436b3ac7 hex("0x3793A651"), hex("0x3352BBE6"), hex("0x3E119D3F"), hex("0x3AD08088"), hex("0x2497D08D"), hex("0x2056CD3A"), hex("0x2D15EBE3"), hex("0x29D4F654"),
30 0x43cf6b39 my $crc = $crc_init;
31 0x469e46a4 if ($_ ne "")
32 0x4a7d0856 select $old;
33 0x4c8775c1 foreach (split(//, $string))
34 0x52952b9d my $tabFileName = "";
35 0x53af7596 if ($outputFileName eq "-t")
36 0x562fa059 my $old = select(OUTPUT);
38 0x59912d48 print "\t\t\tcstring \"", $crc{$_}, "\" /* ", $_, " */\n";
39 0x5d22447d print "\t\t{\n";
40 0x5d332fca return $crc ^ $crc_init;
41 0x5e3bf14a hex("0x2608EDB8"), hex("0x22C9F00F"), hex("0x2F8AD6D6"), hex("0x2B4BCB61"), hex("0x350C9B64"), hex("0x31CD86D3"), hex("0x3C8EA00A"), hex("0x384FBDBD"),
43 0x5ffe9b68 hex("0x5D8A9099"), hex("0x594B8D2E"), hex("0x5408ABF7"), hex("0x50C9B640"), hex("0x4E8EE645"), hex("0x4A4FFBF2"), hex("0x470CDD2B"), hex("0x43CDC09C"),
45 0x615db20a hex("0x8AAD2B2F"), hex("0x8E6C3698"), hex("0x832F1041"), hex("0x87EE0DF6"), hex("0x99A95DF3"), hex("0x9D684044"), hex("0x902B669D"), hex("0x94EA7B2A"),
46 0x6182410b $crc = $crctable[(($crc>>24) ^ ord($_)) & 255] ^ ($crc << 8);
47 0x631bcba2 my @crctable =
48 0x659055d5 $crc{$crc} = $_;
49 0x67e21e2a hex("0xBE2B5B58"), hex("0xBAEA46EF"), hex("0xB7A96036"), hex("0xB3687D81"), hex("0xAD2F2D84"), hex("0xA9EE3033"), hex("0xA4AD16EA"), hex("0xA06C0B5D"),
50 0x6b352a7a my $crc = sprintf("0x%08x", crc($_));
52 0x6eb9730f hex("0x34867077"), hex("0x30476DC0"), hex("0x3D044B19"), hex("0x39C556AE"), hex("0x278206AB"), hex("0x23431B1C"), hex("0x2E003DC5"), hex("0x2AC12072"),
53 0x75347d61 use warnings;
56 0x790992c4 print "\t}\n";
57 0x79cd85e9 $tabFileName = shift;
59 0x7abbcaa1 hex("0xE0B41DE7"), hex("0xE4750050"), hex("0xE9362689"), hex("0xEDF73B3E"), hex("0xF3B06B3B"), hex("0xF771768C"), hex("0xFA325055"), hex("0xFEF34DE2"),
60 0x7ba81dd0 hex("0x119B4BE9"), hex("0x155A565E"), hex("0x18197087"), hex("0x1CD86D30"), hex("0x029F3D35"), hex("0x065E2082"), hex("0x0B1D065B"), hex("0x0FDC1BEC"),
61 0x7d3cdff0 print "\t\t\tuint32 ", $_, "\n";
62 0x80554433 $offset += length($crc{$_}) + 1;
63 0x83c46933 hex("0x128E9DCF"), hex("0x164F8078"), hex("0x1B0CA6A1"), hex("0x1FCDBB16"), hex("0x018AEB13"), hex("0x054BF6A4"), hex("0x0808D07D"), hex("0x0CC9CDCA"),
64 0x846889a5 print "form \"CSTB\"\n";
65 0x87964fea hex("0x9823B6E0"), hex("0x9CE2AB57"), hex("0x91A18D8E"), hex("0x95609039"), hex("0x8B27C03C"), hex("0x8FE6DD8B"), hex("0x82A5FB52"), hex("0x8664E6E5"),
66 0x8a58ef79 hex("0xACA5C697"), hex("0xA864DB20"), hex("0xA527FDF9"), hex("0xA1E6E04E"), hex("0xBFA1B04B"), hex("0xBB60ADFC"), hex("0xB6238B25"), hex("0xB2E29692"),
67 0x8c562960 print OUTPUT $_, "\t", $crc{$_}, "\n";
68 0x8ed2220e my %offset;
69 0x906ee7fe my $string = $_[0];
70 0x91a3a541 return 0 if ($string eq "");
72 0x95ee3e7e close(OUTPUT);
73 0x965657b6 print "\tform \"0000\"\n";
74 0x97bdd926 # =====================================================================
76 0xa105cfec print "{\n";
77 0xa12b46be hex("0x251D3B9E"), hex("0x21DC2629"), hex("0x2C9F00F0"), hex("0x285E1D47"), hex("0x36194D42"), hex("0x32D850F5"), hex("0x3F9B762C"), hex("0x3B5A6B9B"),
78 0xa88572a5 hex("0x7B827D21"), hex("0x7F436096"), hex("0x7200464F"), hex("0x76C15BF8"), hex("0x68860BFD"), hex("0x6C47164A"), hex("0x61043093"), hex("0x65C52D24"),
79 0xa952a8f4 #!/usr/bin/perl
80 0xae4468e9 if ($outputFileName =~ /\.mif/)
81 0xb372444e use strict;
83 0xbb1713e8 print "\n";
84 0xbe0a0d57 hex("0xAFB010B1"), hex("0xAB710D06"), hex("0xA6322BDF"), hex("0xA2F33668"), hex("0xBCB4666D"), hex("0xB8757BDA"), hex("0xB5365D03"), hex("0xB1F740B4")
85 0xbe468f4e close(OUTPUT);
86 0xc0d385a8 my $outputFileName = shift;
87 0xc1b8bc35 hex("0x0315D626"), hex("0x07D4CB91"), hex("0x0A97ED48"), hex("0x0E56F0FF"), hex("0x1011A0FA"), hex("0x14D0BD4D"), hex("0x19939B94"), hex("0x1D528623"),
88 0xc98d4cbe print "\t\t\tint32 ", $offset{$_}, "\n";
89 0xc9c069c8 print "\t\tchunk \"STRT\"\n";
90 0xcbe7de5d print "\t{\n";
92 0xd1451685 my $crc_init = hex("0xffffffff");
94 0xd4bfd092 hex("0x5E9F46BF"), hex("0x5A5E5B08"), hex("0x571D7DD1"), hex("0x53DC6066"), hex("0x4D9B3063"), hex("0x495A2DD4"), hex("0x44190B0D"), hex("0x40D816BA"),
96 0xd6d1b47a open(OUTPUT, "> tempfile") || die "could not open tempfile\n";
97 0xd83528b7 hex("0xBD3E8D7E"), hex("0xB9FF90C9"), hex("0xB4BCB610"), hex("0xB07DABA7"), hex("0xAE3AFBA2"), hex("0xAAFBE615"), hex("0xA7B8C0CC"), hex("0xA379DD7B"),
98 0xdadc70b2 hex("0xC5A92679"), hex("0xC1683BCE"), hex("0xCC2B1D17"), hex("0xC8EA00A0"), hex("0xD6AD50A5"), hex("0xD26C4D12"), hex("0xDF2F6BCB"), hex("0xDBEE767C"),
99 0xddbdb518 hex("0x9B3660C6"), hex("0x9FF77D71"), hex("0x92B45BA8"), hex("0x9675461F"), hex("0x8832161A"), hex("0x8CF30BAD"), hex("0x81B02D74"), hex("0x857130C3"),
100 0xe0a8d6f6 hex("0x00000000"), hex("0x04C11DB7"), hex("0x09823B6E"), hex("0x0D4326D9"), hex("0x130476DC"), hex("0x17C56B6B"), hex("0x1A864DB2"), hex("0x1E475005"),
101 0xe0c9adbe foreach (sort keys %crc)
102 0xe6d3ade9 print "\t\t\tint32 ", scalar(keys(%crc)), "\n";
103 0xed464c3e foreach (sort keys %crc)
104 0xed59325d print "\t\tchunk \"STNG\"\n";
105 0xefcc08e4 print "\t\t}\n";
107 0xf486f7af unlink("tempfile");
108 0xf66d531d die "crc string clash for $crc:\n\t$crc{$crc}\n\t$_\n" if (defined($crc{$crc}) && $_ ne $crc{$crc});
109 0xfac0da72 hex("0xF23A8028"), hex("0xF6FB9D9F"), hex("0xFBB8BB46"), hex("0xFF79A6F1"), hex("0xE13EF6F4"), hex("0xE5FFEB43"), hex("0xE8BCCD9A"), hex("0xEC7DD02D"),
110 0xfd617b31 hex("0x7897AB07"), hex("0x7C56B6B0"), hex("0x71159069"), hex("0x75D48DDE"), hex("0x6B93DDDB"), hex("0x6F52C06C"), hex("0x6211E6B5"), hex("0x66D0FB02"),