eedump_apparam.pl 1.6 KB

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