Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | #!/usr/bin/perl |
2 | |||
3 | |||
4 | $file = $ARGV[0]; |
||
5 | |||
6 | |||
7 | open(IN,$file) || die print "Failed to open file: $file : $!"; |
||
8 | |||
9 | read(IN,$buffer,1); |
||
10 | read(IN,$buffer2,1); |
||
11 | if (ord($buffer2) != 0x41 && ord($buffer) != 0x50) { |
||
12 | print "bad header ". $buffer ." ".$buffer2. "\n"; |
||
13 | exit; |
||
14 | } |
||
15 | read(IN,$buffer,1); |
||
16 | if (ord($buffer) != 5) { |
||
17 | print "bad version"; |
||
18 | exit; |
||
19 | } |
||
20 | |||
21 | # spare |
||
22 | read(IN,$buffer,1); |
||
23 | |||
24 | $a = 0; |
||
25 | |||
26 | while (read(IN,$buffer,1)) { |
||
27 | $pos = (tell(IN) - 1); |
||
28 | |||
29 | if (ord($buffer) == 0xff) { |
||
30 | printf("end sentinel at %u\n", $pos); |
||
31 | last; |
||
32 | } |
||
33 | |||
34 | read(IN,$buffer2,1); |
||
35 | read(IN,$buffer3,1); |
||
36 | |||
37 | if (ord($buffer3) == 0) { #none |
||
38 | $size = 0; |
||
39 | $type = "NONE"; |
||
40 | } elsif (ord($buffer3) == 1) { #int8 |
||
41 | $size = 1; |
||
42 | $type = "INT8"; |
||
43 | } elsif (ord($buffer3) == 2) { #int16 |
||
44 | $size = 2; |
||
45 | $type = "INT16"; |
||
46 | } elsif (ord($buffer3) == 3) { #int32 |
||
47 | $size = 4; |
||
48 | $type = "INT32"; |
||
49 | } elsif (ord($buffer3) == 4) { #float |
||
50 | $size = 4; |
||
51 | $type = "FLOAT"; |
||
52 | } elsif (ord($buffer3) == 5) { #vector 3 |
||
53 | $size = 3*4; |
||
54 | $type = "VECTOR3F"; |
||
55 | } elsif (ord($buffer3) == 6) { #vector6 |
||
56 | $size = 6*4; |
||
57 | $type = "VECTOR6F"; |
||
58 | } elsif (ord($buffer3) == 7) { #matrix |
||
59 | $size = 3*3*4; |
||
60 | $type = "MATRIX6F"; |
||
61 | } elsif (ord($buffer3) == 8) { #group |
||
62 | $size = 0; |
||
63 | $type = "GROUP"; |
||
64 | } else { |
||
65 | print "Unknown type\n"; |
||
66 | $size = 0; |
||
67 | } |
||
68 | |||
69 | printf("%04x: type %u ($type) key %u group_element %u size %d\n ", $pos, ord($buffer3),ord($buffer),ord($buffer2), $size); |
||
70 | |||
71 | for ($i = 0; $i < ($size); $i++) { |
||
72 | read(IN,$buffer,1); |
||
73 | printf(" %02x", ord($buffer)); |
||
74 | } |
||
75 | print "\n"; |
||
76 | } |
||
77 | |||
78 | close IN; |