home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / be.zip / be.ini < prev    next >
Text File  |  1999-11-16  |  52KB  |  2,053 lines

  1. //
  2. // Binary Editor configuration file
  3. //
  4. // This default initialisation file has definitions to aid in the decoding and
  5. // display of a variety of file formats. This file may be extended to allow
  6. // decoding of other file formats too.
  7. //
  8. // It is admitted that the field names used to describe the various fields
  9. // may or may not match up that given in the official documentation.
  10. // In fact, some of the below might be downright wrong.
  11. // Trademarks owned by their respective companies.
  12. //
  13.  
  14. /*...ssources:0:*/
  15. // All of the information in this file derived from non-confidential sources
  16. // usually source code, books, magazine articles, specs., WWW, etc..
  17. // References to source material are given, in case I've made mistakes.
  18.  
  19. // "EoGFF" is short for Encyclopedia of Graphics File Formats, by James D
  20. // Murray and William vanRyper, published by O'Reilly & Associates.
  21.  
  22. // "GBM source" is short for the source for the Generalised Bitmap Module,
  23. // written by myself. This source is included on the CD-ROM with EoGFF.
  24. // http://www.interalpha.net/customer/nyangau/ gives a link to this.
  25. /*...e*/
  26.  
  27. /*...sutils:0:*/
  28. map bool { "TRUE" 1 "FALSE" 0 }
  29.  
  30. def BYTE  { n8  hex "byte"  } def BYTES  { 2048 n8  hex "bytes"  }
  31. def WORD  { n16 hex "word"  } def WORDS  { 2048 n16 hex "words"  }
  32. def DWORD { n32 hex "dword" } def DWORDS { 2048 n32 hex "dwords" }
  33.  
  34. def DBLINE union { 8 n8  hex "bytes"  buf 8  asc "chars"  }
  35. def DWLINE union { 4 n16 hex "words"  buf 8  asc "chars"  }
  36. def DDLINE union { 4 n32 hex "dwords" buf 16 asc "chars " }
  37. def DB { 4096 DBLINE open open open "lines" }
  38. def DW { 4096 DWLINE open open open "lines" }
  39. def DD { 4096 DDLINE open open open "lines" }
  40.  
  41. unsigned dec // be explicit about defaults
  42. /*...e*/
  43. /*...sendianness:0:*/
  44. // Some file formats, such as TIFF and XWD can have data stored within them
  45. // in either endianness. By default BE will decode them assuming they have the
  46. // same endianness as the environment where BE is running. This can be
  47. // overridden by forcing BE to decode one way or the other using the BE_FORCE
  48. // or LE_FORCE preprocessor symbols. Invoke BE as 'be -DBE_FORCE ...' etc..
  49.  
  50. $ifdef BE
  51.   $define BE_DECODE
  52. $endif
  53.  
  54. $ifdef BE_FORCE
  55.   $undef  BE_DECODE
  56.   $define BE_DECODE
  57. $endif
  58.  
  59. $ifdef LE_FORCE
  60.   $undef  BE_DECODE
  61. $endif
  62. /*...e*/
  63.  
  64. /*...sBITMAP_FILES:0:*/
  65. // Mainly headers and palettes only
  66.  
  67. /*...sBMP_FILE    \45\ OS\47\2 and Windows bitmap:0:*/
  68. // Decode the headers and palettes, but not the bitmap bits
  69. // Ref: OS/2 Toolkit pmbitmap.h and related files.
  70. // Ref: GBM source.
  71.  
  72. le
  73.  
  74. map BFT_ // bitmap file type
  75.     {
  76.     "BFT_ICON"         'CI'
  77.     "BFT_BMAP"         'MB'
  78.     "BFT_POINTER"      'TP'
  79.     "BFT_COLORICON"    'IC'
  80.     "BFT_COLORPOINTER" 'PC'
  81.     "BFT_BITMAPARRAY"  'AB'
  82.     }
  83.  
  84. map BCA_ // ulCompression
  85.     {
  86.     "BCA_UNCOMP"    0
  87.     "BCA_RLE8"      1
  88.     "BCA_RLE4"      2
  89.     "BCA_HUFFMAN1D" 3
  90.     "BCA_RLE24"     4
  91.     }
  92.  
  93. map BRU_ // units
  94.     {
  95.     "BRU_METRIC" 0
  96.     }
  97.  
  98. map BRA_ // algorithm
  99.     {
  100.     "BRA_BOTTOMUP" 0
  101.     }
  102.  
  103. map BRH_ // halftoning alg
  104.     {
  105.     "BRH_NOTHALFTONED"   0
  106.     "BRH_ERRORDIFFUSION" 1
  107.     "BRH_PANDA"          2
  108.     "BRH_SUPERCIRCLE"    3
  109.     }
  110.  
  111. def RGB
  112.     {
  113.     n8 hex "bBlue"
  114.     n8 hex "bGreen"
  115.     n8 hex "bRed"
  116.     }
  117.  
  118. def RGB2
  119.     {
  120.     n8 hex "bBlue"
  121.     n8 hex "bGreen"
  122.     n8 hex "bRed"
  123.     n8 hex "fcOptions"
  124.     }
  125.  
  126. def BMP_PALETTE_11
  127.     {
  128.     0x100 RGB "argbColor"
  129.     }
  130.  
  131. def BMP_INFO_HEADER_11
  132.     {
  133.     n32 ptr BMP_PALETTE_11 "cbFix"
  134.     n16                    "cx"
  135.     n16                    "cy"
  136.     n16                    "cPlanes"
  137.     n16                    "cBitCount"
  138.     }
  139.  
  140. def BMP_PALETTE_20
  141.     {
  142.     0x100 RGB2 "argbColor"
  143.     }
  144.  
  145. def BMP_INFO_HEADER_20
  146.     {
  147.     n32 ptr BMP_PALETTE_20 rel "cbFix"
  148.     n32                        "cx"
  149.     n32                        "cy"
  150.     n16                        "cPlanes"
  151.     n16                        "cBitCount"
  152.     n32 map BCA_               "ulCompression"
  153.     n32                        "cbImage"
  154.     n32                        "cxResolution"
  155.     n32                        "cyResolution"
  156.     n32                        "cclrUsed"
  157.     n32                        "cclrImportant"
  158.     n16 map BRU_               "usUnits"
  159.     n16                        "usReserved"
  160.     n16 map BRA_               "usRecording"
  161.     n16 map BRH_               "usRendering"
  162.     n32                        "cSize1"
  163.     n32                        "cSize2"
  164.     n32                        "ulColorEncoding"
  165.     n32 hex                    "ulIdentifier"
  166.     }
  167.  
  168. def BMP_INFO_HEADER
  169.     {
  170.     n32                                       "cbFix"
  171.     at 0 BMP_INFO_HEADER_11 valid "cbFix==12" "1.1 header"
  172.     at 0 BMP_INFO_HEADER_20 valid "cbFix>12"  "2.0 header"
  173.     }
  174.  
  175. def BMP_FILE_HEADER
  176.     {
  177.     n16 map BFT_ valid "usType==BFT_BMAP" "usType"
  178.     n32                                   "cbSize"
  179.     n16 signed                            "xHotspot"
  180.     n16 signed                            "yHotspot"
  181.     n32 hex                               "offBits"
  182.     BMP_INFO_HEADER                       "bmp"
  183.     }
  184.  
  185. def BMP_ARRAY_FILE_HEADER
  186.     {
  187.     n16 map BFT_ valid "usType==BFT_BITMAPARRAY" "usType"
  188.     n32                                          "cbSize"
  189.     n32 hex ptr BMP_ARRAY_FILE_HEADER            "offNext"
  190.     n16                                          "cxDisplay"
  191.     n16                                          "cyDisplay"
  192.     BMP_FILE_HEADER                              "bfh"
  193.     }
  194.  
  195. def BMP_FILE union
  196.     {
  197.     n16 map BFT_                                          "usType"
  198.     BMP_FILE_HEADER       valid "usType==BFT_BMAP"        "bitmap"
  199.     BMP_ARRAY_FILE_HEADER valid "usType==BFT_BITMAPARRAY" "bitmaparray"
  200.     }
  201. /*...e*/
  202. /*...sCUT_FILE    \45\ Media Cybernetics\44\ HALO Image File Format:0:*/
  203. // Ref: EoGFF
  204.  
  205. le
  206.  
  207. def CUT_FILE
  208.     {
  209.     n16                         "Width"
  210.     n16                         "Height"
  211.     n16 hex valid "Reserved==0" "Reserved"
  212.     buf 100 hex                 "Data starts here ..."
  213.     }
  214. /*...e*/
  215. /*...sGIF_FILE    \45\ Compu\36\erve GIF bitmap:0:*/
  216. // Decode headers and block structures
  217. // Ref: ftp://ftp.ncsa.uiuc.edu/misc/file.formats/graphics.formats/gif87a.doc
  218. // Ref: ftp://ftp.ncsa.uiuc.edu/misc/file.formats/graphics.formats/gif89a.doc
  219. // Ref: GBM source.
  220.  
  221. le
  222.  
  223. def GIF_RGB
  224.     {
  225.     n8 hex "red"
  226.     n8 hex "green"
  227.     n8 hex "blue"
  228.     }
  229.  
  230. def GIF_CHUNK
  231.     {
  232.     union
  233.       {
  234.       n8 ptr GIF_CHUNK add 1 rel      valid "size!=0" "size"
  235.       n8 ptr GIF_BLOCK add 1 rel null valid "size==0" "block"
  236.       }
  237.     16 buf 16 hex                                     "data"
  238.     }
  239.  
  240. // A number of LCT palette entries, followed by a GIF_CHUNK
  241. def GIF_LCT1 {   2 GIF_RGB "palette" GIF_CHUNK "chunk" }
  242. def GIF_LCT2 {   4 GIF_RGB "palette" GIF_CHUNK "chunk" }
  243. def GIF_LCT3 {   8 GIF_RGB "palette" GIF_CHUNK "chunk" }
  244. def GIF_LCT4 {  16 GIF_RGB "palette" GIF_CHUNK "chunk" }
  245. def GIF_LCT5 {  32 GIF_RGB "palette" GIF_CHUNK "chunk" }
  246. def GIF_LCT6 {  64 GIF_RGB "palette" GIF_CHUNK "chunk" }
  247. def GIF_LCT7 { 128 GIF_RGB "palette" GIF_CHUNK "chunk" }
  248. def GIF_LCT8 { 256 GIF_RGB "palette" GIF_CHUNK "chunk" }
  249.  
  250. def GIF_EXTENSION
  251.     {
  252.     n8 hex valid "introducer==0x21" "introducer"
  253.     n8 hex                          "graphic_control_label"
  254.     GIF_CHUNK                       "first_chunk"
  255.     }
  256.  
  257. def GIF_IMAGE_DESC
  258.     {
  259.     n8 hex valid "introducer==0x2c" "introducer"
  260.     n16                             "xpos"
  261.     n16                             "ypos"
  262.     n16                             "width"
  263.     n16                             "height"
  264.     union
  265.       {
  266.       n8 bits 7:7 map bool          "got_lct"
  267.       n8 bits 6:6 map bool          "ilace"
  268.       n8 bits 2:0 dec               "bpp_minus_one"
  269.       }
  270.     n8                              "min_LZW_code_size_minus_one"
  271.     union
  272.       {
  273.       GIF_CHUNK valid "!got_lct"                 "if no lct"
  274.       GIF_LCT1 valid "got_lct&&bpp_minus_one==0" "if 1bpp lct"
  275.       GIF_LCT2 valid "got_lct&&bpp_minus_one==1" "if 2bpp lct"
  276.       GIF_LCT3 valid "got_lct&&bpp_minus_one==2" "if 3bpp lct"
  277.       GIF_LCT4 valid "got_lct&&bpp_minus_one==3" "if 4bpp lct"
  278.       GIF_LCT5 valid "got_lct&&bpp_minus_one==4" "if 5bpp lct"
  279.       GIF_LCT6 valid "got_lct&&bpp_minus_one==5" "if 6bpp lct"
  280.       GIF_LCT7 valid "got_lct&&bpp_minus_one==6" "if 7bpp lct"
  281.       GIF_LCT8 valid "got_lct&&bpp_minus_one==7" "if 8bpp lct"
  282.       }
  283.     }
  284.  
  285. def GIF_TERM
  286.     {
  287.     n8 hex valid "introducer==0x3b" "introducer"
  288.     }
  289.  
  290. def GIF_BLOCK union
  291.     {
  292.     n8 hex                                  "introducer"
  293.     GIF_EXTENSION  valid "introducer==0x21" "extension"
  294.     GIF_IMAGE_DESC valid "introducer==0x2c" "image_desc"
  295.     GIF_TERM       valid "introducer==0x3b" "term"
  296.     }
  297.  
  298. // A number of GCT palette entries, followed by a GIF_BLOCK
  299. def GIF_GCT1 {   2 GIF_RGB "palette" GIF_BLOCK "block" }
  300. def GIF_GCT2 {   4 GIF_RGB "palette" GIF_BLOCK "block" }
  301. def GIF_GCT3 {   8 GIF_RGB "palette" GIF_BLOCK "block" }
  302. def GIF_GCT4 {  16 GIF_RGB "palette" GIF_BLOCK "block" }
  303. def GIF_GCT5 {  32 GIF_RGB "palette" GIF_BLOCK "block" }
  304. def GIF_GCT6 {  64 GIF_RGB "palette" GIF_BLOCK "block" }
  305. def GIF_GCT7 { 128 GIF_RGB "palette" GIF_BLOCK "block" }
  306. def GIF_GCT8 { 256 GIF_RGB "palette" GIF_BLOCK "block" }
  307.  
  308. // signature and screen descriptor
  309.  
  310. def GIF_FILE
  311.     {
  312.     buf 6 asc                          "signiture (GIFxxx)"
  313.     n16                                "xscreen"
  314.     n16                                "yscreen"
  315.     union
  316.       {
  317.       n8 bits 7:7 map bool             "got_gct"
  318.       n8 bits 2:0 dec                  "bpp_minus_one"
  319.       }
  320.     n8                                 "bg_index"
  321.     n8 hex                             "?"
  322.     union
  323.       {
  324.       GIF_BLOCK valid "!got_gct"                 "if no gct"
  325.       GIF_GCT1 valid "got_gct&&bpp_minus_one==0" "if 1bpp gct"
  326.       GIF_GCT2 valid "got_gct&&bpp_minus_one==1" "if 2bpp gct"
  327.       GIF_GCT3 valid "got_gct&&bpp_minus_one==2" "if 3bpp gct"
  328.       GIF_GCT4 valid "got_gct&&bpp_minus_one==3" "if 4bpp gct"
  329.       GIF_GCT5 valid "got_gct&&bpp_minus_one==4" "if 5bpp gct"
  330.       GIF_GCT6 valid "got_gct&&bpp_minus_one==5" "if 6bpp gct"
  331.       GIF_GCT7 valid "got_gct&&bpp_minus_one==6" "if 7bpp gct"
  332.       GIF_GCT8 valid "got_gct&&bpp_minus_one==7" "if 8bpp gct"
  333.       }
  334.     }
  335. /*...e*/
  336. /*...sILBM_FILE   \45\ IFF Interleaved bitmap:0:*/
  337. // Decode chunk structure
  338. // Ref: http://www.ea.com/
  339. // Ref: EA IFF 85 spec.
  340. // Ref: GBM source.
  341.  
  342. be
  343.  
  344. map ILBM_COMP_TYPE
  345.     {
  346.     "none" 0
  347.     "rle"  1
  348.     }
  349.  
  350. map ILBM_MASKING
  351.     {
  352.     "none"        0
  353.     "mask"        1
  354.     "transparent" 2
  355.     }
  356.  
  357. def ILBM_BMHD_DATA
  358.     {
  359.     n16                   "width"
  360.     n16                   "height"
  361.     n16                   "xpos"
  362.     n16                   "ypos"
  363.     n8                    "bitsperpixel"
  364.     n8 map ILBM_MASKING   "masking"
  365.     n8 map ILBM_COMP_TYPE "compression"
  366.     n8 hex                "unused"
  367.     n16                   "transcol"
  368.     n8                    "xaspect"
  369.     n8                    "yaspect"
  370.     n16                   "xscreen"
  371.     n16                   "yscreen"
  372.     }
  373.  
  374. map ILBM_CAMG_VALUE
  375.     {
  376.     "lace"    0x00000004 : .
  377.     "ehb"    0x00000080 : .
  378.     "ham"    0x00000800 : .
  379.     "hires"    0x00008000 : .
  380.     }
  381.  
  382. def ILBM_RGB
  383.     {
  384.     n8 hex "red"
  385.     n8 hex "green"
  386.     n8 hex "blue"
  387.     }
  388.  
  389. def ILBM_SHAM_PAL
  390.     {
  391.     16 ILBM_RGB "0rgb's"
  392.     }
  393.  
  394. def ILBM_SHAM_DATA
  395.     {
  396.     n16 valid "sham_version==0" "sham_version"
  397.     200 ILBM_SHAM_PAL           "sham_palettes"
  398.     }
  399.  
  400. // note that chunk next pointer may require size rounding up by one
  401.  
  402. def ILBM_CHUNK
  403.     {
  404.     n32 asc                                        "name"
  405.     n32 ptr ILBM_CHUNK add 4 rel align 2           "size"
  406.     union
  407.       {
  408.       ILBM_BMHD_DATA          valid "name=='BMHD'" "bmhd"
  409.       n32 map ILBM_CAMG_VALUE valid "name=='CAMG'" "camg"
  410.       0x100 ILBM_RGB          valid "name=='CMAP'" "cmap"
  411.       ILBM_SHAM_DATA          valid "name=='SHAM'" "sham"
  412.       buf 100 hex                         suppress "raw data"
  413.       }
  414.     }
  415.  
  416. def ILBM_FILE
  417.     {
  418.     buf 4 asc  "form"
  419.     n32        "length"
  420.     buf 4 asc  "ilbm"
  421.     ILBM_CHUNK "first_chunk"
  422.     }
  423. /*...e*/
  424. /*...sJFIF_FILE   \45\ JFIF JPEG bitmap:0:*/
  425. // Ref: ftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz
  426.  
  427. be
  428.  
  429. map JFIF_EXTCODE
  430.     {
  431.     "JPEG_THUMBNAIL"                       0x10
  432.     "1_BYTE_PIXELS_PLUS_PALETTE_THUMBNAIL" 0x11
  433.     "3_BYTE_RGB_PIXELS_THUMBNAIL"          0x13
  434.     }
  435.  
  436. def JFIF_EXT
  437.     {
  438.     n16 hex valid "APP0==0xffe0" "APP0"
  439.     n16 hex ptr JFIF_MARKER rel  "Length"
  440.     buf 5 asc                    "Identifier (=JFXX)"
  441.     n8 map JFIF_EXTCODE          "ExtensionCode"
  442.     buf 100 hex                  "Data ..."
  443.     }
  444.  
  445. def JFIF_COPYRIGHT
  446.     {
  447.     n16 hex valid "APP0==0xfffe" "APP0"
  448.     n16 hex ptr JFIF_MARKER rel  "Length"
  449.     buf 100 asc                  "Copyright ..."
  450.     }
  451.  
  452. def JFIF_MARKER
  453.     {
  454.     buf 2 hex                                "APP0"
  455.     n16 hex ptr JFIF_MARKER rel              "Length"
  456.     buf 100 hex                              "Data ..."
  457.     at 0 JFIF_EXT       valid "APP0==0xffe0" "ext"
  458.     at 0 JFIF_COPYRIGHT valid "APP0==0xfffe" "copyright"
  459.     }
  460.  
  461. def JFIF_FILE
  462.     {
  463.     n16 hex valid "SOI==0xffd8"  "SOI"
  464.     n16 hex valid "APP0==0xffe0" "APP0"
  465.     n16 ptr JFIF_MARKER rel      "Length"
  466.     buf 5 asc                    "Identifier (=JFIF)"
  467.     buf 2 hex                    "Version"
  468.     n8                           "Units"
  469.     n16                          "Xdensity"
  470.     n16                          "Ydensity"
  471.     n8 dec                       "XThumbnail"
  472.     n8 dec                       "YThumbnail"
  473.     buf 100 hex                  "Thumbnail ..." // discouraged
  474.     }
  475. /*...e*/
  476. /*...sKPS_FILE    \45\ IBM KIPS bitmap:0:*/
  477. // Just decode the header
  478. // Ref: GBM source.
  479.  
  480. def KPS_FILE
  481.     {
  482.     buf 8 asc  "signiture (=DFIMAG00)"
  483.     n16        "height"
  484.     n16        "width"
  485.     buf 20 hex "unknown"
  486.     }
  487. /*...e*/
  488. /*...sMSP_FILE    \45\ Microsoft Paint:0:*/
  489. // Ref: EoGFF
  490.  
  491. le
  492.  
  493. def MSP_FILE
  494.     {
  495.     n16 hex   "Key1"
  496.     n16 hex   "Key2"
  497.     n16       "Width"
  498.     n16       "Height"
  499.     n16       "XARBitmap"
  500.     n16       "YARBitmap"
  501.     n16       "XARPrinter"
  502.     n16       "YARPrinter"
  503.     n16       "PrinterWidth "
  504.     n16       "PrinterHeight"
  505.     n16       "XAspectCorr"
  506.     n16       "YAspectCorr"
  507.     n16       "Checksum"
  508.     buf 6 hex "Padding"
  509.     }
  510. /*...e*/
  511. /*...sNEO_FILE    \45\ Atari ST\44\ NEOchrome:0:*/
  512. // Ref: EoGFF
  513.  
  514. be
  515.  
  516. map NEO_RES
  517.     {
  518.     "LOW"    0
  519.     "MEDIUM" 1
  520.     "HIGH"   2
  521.     }
  522.  
  523. def NEO_FILE
  524.     {
  525.     n16 valid "Flag==0"     "Flag"
  526.     n16 map NEO_RES         "Resolution"
  527.     16 n16 hex              "Palette"
  528.     buf 12 asc              "FileName"
  529.     n16 hex                 "Limits"
  530.     n16                     "Speed"
  531.     n16                     "NumberOfSteps"
  532.     n16 valid "XOffset==0"  "XOffset"
  533.     n16 valid "YOffset==0"  "YOffset"
  534.     n16 valid "Width==320"  "Width"
  535.     n16 valid "Height==200" "Height"
  536.     buf 33 hex              "Reserved (always 0)"
  537.     200 buf 320/2 hex       "Data"        // 16000 bytes ???
  538.     }
  539. /*...e*/
  540. /*...sPAL_FILE    \45\ Media Cybernetics\44\ HALO Image Palette Format:0:*/
  541. // Ref: EoGFF
  542.  
  543. le
  544.  
  545. map PAL_SUBTYPE
  546.     {
  547.     "GENERIC"           0
  548.     "HARDWARE_SPECIFIC" 1
  549.     }
  550.  
  551. def PAL_FILE
  552.     {
  553.     n16 asc valid "FileId=='AH'"  "FileId"
  554.     n16                           "Version"
  555.     n16                           "Size (not including header)"
  556.     n8 hex valid "FileType==0x0a" "FileType"
  557.     n8 map PAL_SUBTYPE            "SubType"
  558.     n16                           "BoardId"
  559.     n16                           "MaxIndex"
  560.     n16                           "MaxRed"
  561.     n16                           "MaxGreen"
  562.     n16                           "MaxBlue"
  563.     buf 20 asc                    "PaletteId (=Dr. Halo)"
  564.     buf 100 hex                   "Palette data starts here..."
  565.     }
  566. /*...e*/
  567. /*...sPCX_FILE    \45\ ZSoft PCX bitmap file:0:*/
  568. // Decode header with small inline 4bpp palette
  569. // Don't decode compressed bitmap bits or trailer with 8bpp palette
  570. // Ref: GBM source.
  571.  
  572. le
  573.  
  574. map PCXENC_
  575.     {
  576.     "PCXENC_RLE" 1
  577.     }
  578.  
  579. def PCX_RGB
  580.     {
  581.     n8 hex "red"
  582.     n8 hex "green"
  583.     n8 hex "blue"
  584.     }
  585.  
  586. def PCX_FILE
  587.     {
  588.     n8 hex valid "magic==0x0a"       "magic"
  589.     n8 valid "version<5&&version!=4" "version"
  590.     n8 map PCXENC_                   "compression"
  591.     n8                               "bpppp"
  592.     n16                              "x1"
  593.     n16                              "y1"
  594.     n16                              "x2"
  595.     n16                              "y2"
  596.  
  597.     at 16
  598.     16 PCX_RGB                       "4bpp_palette"
  599.  
  600.     at 65
  601.     n8                               "planes"
  602.     n16                              "bytes_per_line"
  603.     n8                               "colour_or_bw"
  604.  
  605.     at 0
  606.     8 buf 16 hex                     "header as hex"
  607.     }
  608. /*...e*/
  609. /*...sPNG_FILE    \45\ Portable Network Graphics bitmap:0:*/
  610. // preliminary - untested on any file
  611. // Ref: http://www.boutell.com/boutell/png/
  612.  
  613. be
  614.  
  615. map PNG_COLOR_TYPE
  616.     {
  617.     "GRAYSCALE"           0
  618.     "RGB"                 2
  619.     "PALETTE_INDEX"       3
  620.     "GRAYSCALE_AND_ALPHA" 4
  621.     "RGB_AND_ALPHA"       6
  622.     }
  623.  
  624. map PNG_COMP_METHOD
  625.     {
  626.     "DEFLATED_32K" 0
  627.     }
  628.  
  629. map PNG_FILT_METHOD
  630.     {
  631.     "ADAPTIVE_FILTERING_WITH_5_BASIC_FILTER_TYPES" 0
  632.     }
  633.  
  634. map PNG_ILACE_METHOD
  635.     {
  636.     "NONE"  0
  637.     "ADAM7" 1
  638.     }
  639.  
  640. def PNG_CHUNK_DATA_IHDR
  641.     {
  642.     n32                     "Width"
  643.     n32                     "Height"
  644.     n8                      "BitDepth"
  645.     n8 map PNG_COLOR_TYPE   "ColorType"
  646.     n8 map PNG_COMP_METHOD  "CompressionMethod"
  647.     n8 map PNG_FILT_METHOD  "FilterMethod"
  648.     n8 map PNG_ILACE_METHOD "InterlaceMethod"
  649.     }
  650.  
  651. def PNG_RGB
  652.     {
  653.     n8 hex "Red"
  654.     n8 hex "Green"
  655.     n8 hex "Blue "
  656.     }
  657.  
  658. def PNG_CHUNK_DATA_PLTE
  659.     {
  660.     0x100 PNG_RGB "Palette"
  661.     }
  662.  
  663. def PNG_CHUNK_DATA_IDAT
  664.     {
  665.     buf 100 hex "ImageData ..."
  666.     }
  667.  
  668. def PNG_CHUNK_DATA_IEND
  669.     {
  670.     // empty
  671.     }
  672.  
  673. def PNG_CHUNK_DATA_bKGD
  674.     {
  675.     union
  676.       {
  677.       n8    "PaletteIndex (if PALETTE_INDEX)"
  678.       n16   "Gray         (if GRAYSCALE or GRAYSCALE_AND_ALPHA)"
  679.       struct
  680.         {
  681.         n16 "Red          (if RGB or RGB_AND_ALPHA)"
  682.         n16 "Green        (if RGB or RGB_AND_ALPHA)"
  683.         n16 "Blue         (if RGB or RGB_AND_ALPHA)"
  684.         }
  685.       }
  686.     }
  687.  
  688. def PNG_CHUNK_DATA_cHRM
  689.     {
  690.     n32 "WhitePointX"
  691.     n32 "WhitePointY"
  692.     n32 "RedX"
  693.     n32 "RedY"
  694.     n32 "GreenX"
  695.     n32 "GreenY"
  696.     n32 "BlueX"
  697.     n32 "BlueY"
  698.     }
  699.  
  700. def PNG_CHUNK_DATA_gAMA
  701.     {
  702.     n32 "ImageGamma"
  703.     }
  704.  
  705. def PNG_CHUNK_DATA_hIST
  706.     {
  707.     0x100 n16 "Frequencys"
  708.     }
  709.  
  710. map PNG_UNIT
  711.     {
  712.     "UNKNOWN" 0
  713.     "METRE"   1
  714.     }
  715.  
  716. def PNG_CHUNK_DATA_pHYs
  717.     {
  718.     n32             "PixelsPerUnitX"
  719.     n32             "PixelsPerUnitY"
  720.     n8 map PNG_UNIT "UnitSpecifier"
  721.     }
  722.  
  723. def PNG_CHUNK_DATA_sBIT
  724.     {
  725.     union
  726.       {
  727.       n8   "Significant (if GRAYSCALE)"
  728.       3 n8 "Significant (if RGB or PALETTE_INDEX)"
  729.       struct
  730.         {
  731.         n8 "SignificantGrey  (if GRAYSCALE_AND_ALPHA)"
  732.         n8 "SignificantAlpha (if GRAYSCALE_AND_ALPHA)"
  733.         }
  734.       struct
  735.         {
  736.         n8 "SignificantRed   (if RGB_AND_ALPHA)"
  737.         n8 "SignificantGreen (if RGB_AND_ALPHA)"
  738.         n8 "SignificantBlue  (if RGB_AND_ALPHA)"
  739.         n8 "SignificantAlpha (if RGB_AND_ALPHA)"
  740.         }
  741.       }
  742.     }
  743.  
  744. def PNG_CHUNK_DATA_tEXt
  745.     {
  746.     buf 100 asc "KeywordThenNullThenText"
  747.     }
  748.  
  749. def PNG_CHUNK_DATA_tIME
  750.     {
  751.     n16 "Year"
  752.     n8  "Month  (1-12)"
  753.     n8  "Day    (1-31)"
  754.     n8  "Hour   (0-23)"
  755.     n8  "Minute (0-59)"
  756.     n8  "Second (0-60)" // 60 for leap second
  757.     }
  758.  
  759. def PNG_CHUNK_DATA_tRNS
  760.     {
  761.     union
  762.       {
  763.       n16      "Transparency (if GRAYSCALE)"
  764.       struct
  765.         {
  766.         n16    "TransparencyRed   (if RGB)"
  767.         n16    "TransparencyGreen (if RGB)"
  768.         n16    "TransparencyBlue  (if RGB)"
  769.         }
  770.       0x100 n8 "Transparencies (if PALETTE_INDEX)"
  771.       }
  772.     }
  773.  
  774. def PNG_CHUNK_DATA_zTXt
  775.     {
  776.     buf 80 asc zterm "KeywordThenNull"
  777.         // compresion method and compressed data follow
  778.     }
  779.  
  780. def PNG_CHUNK
  781.     {
  782.     union
  783.       {
  784.       n32 ptr PNG_CHUNK_END add 8  rel null suppress "Length"
  785.       n32 ptr PNG_CHUNK     add 12 rel null suppress "Length"
  786.         // display length field twice, so it can be followed to find
  787.         // the CRC at the end of the chunk, or the next chunk
  788.       }
  789.     n32 asc                                          "ChunkType"
  790.     union
  791.       {
  792.       buf 100 hex                           suppress "raw_data"
  793.       PNG_CHUNK_DATA_IHDR  valid "ChunkType=='IHDR'" "IHDR"
  794.       PNG_CHUNK_DATA_PLTE  valid "ChunkType=='PLTR'" "PLTE"
  795.       PNG_CHUNK_DATA_IDAT  valid "ChunkType=='IDAT'" "IDAT"
  796.       PNG_CHUNK_DATA_IEND  valid "ChunkType=='IEND'" "IEND"
  797.       PNG_CHUNK_DATA_bKGD  valid "ChunkType=='bKGD'" "bKGD"
  798.       PNG_CHUNK_DATA_cHRM  valid "ChunkType=='cHRM'" "cHRM"
  799.       PNG_CHUNK_DATA_gAMA  valid "ChunkType=='gAMA'" "gAMA"
  800.       PNG_CHUNK_DATA_hIST  valid "ChunkType=='hIST'" "hIST"
  801.       PNG_CHUNK_DATA_pHYs  valid "ChunkType=='pHYs'" "pHYs"
  802.       PNG_CHUNK_DATA_sBIT  valid "ChunkType=='sBIT'" "sBIT"
  803.       PNG_CHUNK_DATA_tEXt  valid "ChunkType=='tEXt'" "tEXt"
  804.       PNG_CHUNK_DATA_tIME  valid "ChunkType=='tIME'" "tIME"
  805.       PNG_CHUNK_DATA_tRNS  valid "ChunkType=='tRNS'" "tRNS"
  806.       PNG_CHUNK_DATA_zTXt  valid "ChunkType=='zTXt'" "zTXt"
  807.       }
  808.     }
  809.  
  810. def PNG_CHUNK_END
  811.     {
  812.     n32 hex "CRC"
  813.     }
  814.  
  815. def PNG_FILE
  816.     {
  817.     buf 8 hex "Signature (=@89504e470d0a1a0a)"
  818.     PNG_CHUNK "FirstChunk"
  819.     }
  820. /*...e*/
  821. /*...sPSEG_FILE   \45\ IBM Page Segment:0:*/
  822. // I don't know very much about the internal structure of these.
  823. // Here is enough to allow loading and saving of 1bpp PSEG files.
  824. // Ref: GBM source.
  825.  
  826. be
  827.  
  828. def PSEG_COMMENT
  829.     {
  830.     buf 100 ebc "text"
  831.     }
  832.  
  833. def PSEG_BEGIN_PAGE
  834.     {
  835.     buf 100 ebc "segment (often is filename)"
  836.     }
  837.  
  838. def PSEG_BEGIN_IMG_BLOCK
  839.     {
  840.     buf 100 ebc "image (often is filename)"
  841.     }
  842.  
  843. map PSEG_ORIENTATION
  844.     {
  845.     "90degrees" 0x2d
  846.     }
  847.  
  848. def PSEG_IMG_OUTPUT_CTL
  849.     {
  850.     buf 6 hex               "?"
  851.     buf 2 hex               "?"
  852.     n8 map PSEG_ORIENTATION "orientation"
  853.     buf 1 hex               "?"
  854.     buf 8 hex               "?"
  855.     n16                     "x_scale"
  856.     n16                     "y_scale"
  857.     buf 2 hex               "reserved"
  858.     }
  859.  
  860. def PSEG_INPUT_IMG_DESC
  861.     {
  862.     buf 2                   "?"
  863.     n16 hex                 "0 or 0x0960"
  864.     n16 hex                 "0 or 0x0960"
  865.     buf 8 hex               "?"
  866.     n16 hex                 "0 or 0x0960"
  867.     n16 hex                 "0 or 0x0960"
  868.     n16                     "bytes_per_line"
  869.     n16                     "lines"
  870.     buf 4 hex               "?"
  871.         n8 map PSEG_ORIENTATION "orientation"
  872.     buf 1 hex               "?"
  873.     n16                     "x_cell"
  874.     n16                     "y_cell"
  875.     buf 4 hex               "? (=0001ffff)"
  876.     }
  877.  
  878. def PSEG_RASTER_DATA
  879.     {
  880.     buf 100 hex "data"
  881.     }
  882.  
  883. def PSEG_IMG_CELL_POSN
  884.     {
  885.     n16 "x_cell_pos"
  886.     n16 "y_cell_pos"
  887.     n16 "x_cell_size"
  888.     n16 "y_cell_size"
  889.     n16 "x_fill_size"
  890.     n16 "y_fill_size"
  891.     }
  892.  
  893. def PSEG_END_IMG_BLOCK
  894.     {
  895.     buf 100 ebc "image (often is filename)"
  896.     }
  897.  
  898. def PSEG_END_PAGE
  899.     {
  900.     buf 100 ebc "segment (often is filename)"
  901.     }
  902.  
  903. def PSEG_RECORD
  904.     {
  905.     n8 hex                    valid "start==0x5a" "start"
  906.     n16 ptr PSEG_RECORD rel                       "data_size"
  907.     n24 hex                                       "type"
  908.     buf 3 hex                                     "?"
  909.     union
  910.       {
  911.       PSEG_COMMENT         valid "type==0xdeeeee" "comment"
  912.       PSEG_BEGIN_PAGE      valid "type==0xd3a85f" "begin_page"
  913.       PSEG_BEGIN_IMG_BLOCK valid "type==0xd3a87b" "begin_image_block"
  914.       PSEG_IMG_OUTPUT_CTL  valid "type==0xd3a77b" "image_output_ctl"
  915.       PSEG_INPUT_IMG_DESC  valid "type==0xd3a67b" "input_img_desc"
  916.       PSEG_RASTER_DATA     valid "type==0xd3ee7b" "raster_data"
  917.       PSEG_IMG_CELL_POSN   valid "type==0xd3ac7b" "img_cell_posn"
  918.       PSEG_END_IMG_BLOCK   valid "type==0xd3a97b" "img_block"
  919.       PSEG_END_PAGE        valid "type==0xd3a95f" "end_page"
  920.       buf 100 hex                                 "as raw data"
  921.       }
  922.     }
  923.  
  924. def PSEG_FILE
  925.     {
  926.     PSEG_RECORD "first_record"
  927.     }
  928. /*...e*/
  929. /*...sRAS_FILE    \45\ Sun Raster file:0:*/
  930. // Ref: EoGFF
  931. // Ref: /usr/include/rasterfile.h on SunOS etc.
  932.  
  933. be
  934.  
  935. map RAS_TYPE
  936.     {
  937.     "OLD"          0x0000    // uncompressed
  938.     "STANDARD"     0x0001    // uncompressed
  939.     "BYTE_ENCODED" 0x0002    // a form of RLE
  940.     "RGB"          0x0003
  941.     "TIFF"         0x0004    // file originally converted from TIFF
  942.     "IFF"          0x0005    // file originally converted from IFF
  943.     "EXPERIMENTAL" 0xffff    // does not comply with Sun Raster format
  944.     }
  945.  
  946. map RAS_CTYPE
  947.     {
  948.     "NO_COLOR_MAP"  0x0000
  949.     "RGB_COLOR_MAP" 0x0001
  950.     "RAW_COLOR_MAP" 0x0002
  951.     }
  952.  
  953. def RAS_FILE
  954.     {
  955.     n32 hex valid "MagicNumber==0x59a66a95" "MagicNumber"
  956.     n32                                     "Width"
  957.     n32                                     "Height"
  958.     n32                                     "Depth"
  959.     n32                                     "Length (in bytes)"
  960.                         // if 0 use Width*Height*Depth
  961.     n32 map RAS_TYPE                        "Type"
  962.     n32 map RAS_CTYPE                       "ColorMapType"
  963.     n32                                     "ColorMapLength (in bytes)"
  964.     }
  965. /*...e*/
  966. /*...sRLE_FILE    \45\ Utah Raster Toolkit bitmap:0:*/
  967. // Ref: EoGFF
  968. // Ref: ftp://cs.uath.edu
  969. // Ref: ftp://weedeater.math.yale.edu
  970. // Ref: ftp://freebie.engin.umich.edu
  971.  
  972. le
  973.  
  974. def RLE_FILE
  975.     {
  976.     n16    "Magic"
  977.     n16    "Xpos"
  978.     n16    "Ypos"
  979.     n16    "Xsize"
  980.     n16    "Ysize"
  981.     n8 hex "Flags"
  982.     n8     "Ncolors"
  983.     n8     "Pixelbits"
  984.     n8     "Ncmap"
  985.     n8     "Cmaplen"
  986.     n8     "Redbg"
  987.     n8     "Greenbg"
  988.     n8     "Bluebg"
  989.         // palette, comment area and bitmap follow
  990.     }
  991. /*...e*/
  992. /*...sSGI_FILE    \45\ Silicon Graphics bitmap:0:*/
  993. // Ref: EoGFF
  994. // Ref: http://ftp.sgi.com/graphics/SGIIMAGESPEC
  995. // Ref: http://reality.sgi.com/grafica/sgiimage.html
  996.  
  997. be
  998.  
  999. map SGI_STORAGE
  1000.     {
  1001.     "VERBATIM" 0    // uncompressed
  1002.     "RLE"      1
  1003.     }
  1004.  
  1005. map SGI_DIMENSION
  1006.     {
  1007.     "SINGLE_CHANNEL_1_SCAN" 1
  1008.     "SINGLE_CHANNEL_DIM_XY" 2
  1009.     "MULTI_CHANNEL"         3
  1010.     }
  1011.  
  1012. map SGI_COLORMAP
  1013.     {
  1014.     "NORMAL"   0    // most common
  1015.     "DITHERED" 1    // obsolete, pixels bytes are BBGGGRRR
  1016.     "SCREEN"   2    // index into color map
  1017.     "COLORMAP" 3    // colour map
  1018.     }
  1019.  
  1020. def SGI_FILE
  1021.     {
  1022.     n16        valid "Magic==474" "Magic"
  1023.     n8 map SGI_STORAGE            "Storage"
  1024.     n8 dec valid "Bpc==1||Bpc==2" "Bpc"
  1025.     n16 map SGI_DIMENSION valid "Dimension==1||Dimension==2||Dimension==3"
  1026.                                   "Dimension"
  1027.     n16                           "XSize"
  1028.     n16                           "YSize"
  1029.     n16 valid "ZSize==1||ZSize==3||ZSize==4"
  1030.                                   "ZSize"
  1031.     n32                           "PixMin"
  1032.     n32                           "PixMax"
  1033.     buf 4 hex                     "Unused (all zeroes)"
  1034.     buf 80 asc zterm              "ImageName"
  1035.     n32 map SGI_COLORMAP          "ColorMap"
  1036.     buf 404 hex                   "Unused (all zeroes)"
  1037.     union
  1038.       {
  1039.       buf 100 hex                 "Data begins ..."
  1040.       100 n32                     "ScanOffsets YSize*ZSize"
  1041.       }
  1042.     }
  1043. /*...e*/
  1044. /*...sSPRITE_FILE \45\ RiscOS Sprite bitmap:0:*/
  1045. // Display headers and data (rather crudely).
  1046. // Ref: RiscOS / Archimedes owners book.
  1047. // Ref: http://www.pcug.org.au/~markwart/canbug/files/sprite.html
  1048.  
  1049. le
  1050.  
  1051. map SPRITE_MODE
  1052.     {
  1053.     "640x256x1bpp"                    0
  1054.     "320x256x2bpp"                    1
  1055.     "160x256x4bpp"                    2
  1056.     "Text only"                    3
  1057.     "320x256x1bpp"                    4
  1058.     "160x256x2bpp"                    5
  1059.     "160x256x2bpp"                    6
  1060.     "Teletext"                    7
  1061.     "640x256x2bpp"                    8
  1062.     "320x256x4bpp"                    9
  1063.     "160x256x8bpp"                    10
  1064.     "640x250x2bpp"                    11
  1065.     "640x256x4bpp"                    12
  1066.     "320x256x8bpp"                    13
  1067.     "640x250x4bpp"                    14
  1068.     "640x256x8bpp"                    15
  1069.     "1056x250x4bpp"                    16
  1070.     "1056x256x4bpp"                    17
  1071.     "640x512x1bpp multisync-monitor"        18
  1072.     "640x512x2bpp multisync-monitor"        19
  1073.     "640x512x4bpp multisync-monitor"        20
  1074.     "640x512x8bpp multisync-monitor"        21
  1075.     "1152x896x1bpp 61.2Hz-hires-monitor"        23
  1076.     "1056x256x8bpp"                    24
  1077.     "640x480x1bpp multisync-or-60Hz-VGA-monitor"    25
  1078.     "640x480x2bpp multisync-or-60Hz-VGA-monitor"    26
  1079.     "640x480x4bpp multisync-or-60Hz-VGA-monitor"    27
  1080.     "640x480x8bpp multisync-or-60Hz-VGA-monitor"    28
  1081.     }
  1082.  
  1083. // 2 RGB values match if not flashing
  1084.  
  1085. def SPRITE_PAL
  1086.     {
  1087.     n8 hex "?"
  1088.     n8 hex "red"
  1089.     n8 hex "green"
  1090.     n8 hex "blue"
  1091.     n8 hex "?"
  1092.     n8 hex "red"
  1093.     n8 hex "green"
  1094.     n8 hex "blue "
  1095.     }
  1096.  
  1097. // List the first few bytes of data
  1098. // Give it laid out at several widths
  1099. // Remember, nibbles can be swapped
  1100.  
  1101. def SPRITE_DATA
  1102.     {
  1103.     at 0 50 buf  4 hex "data (1 dword  per line)"
  1104.     at 0 50 buf  8 hex "data (2 dwords per line)"
  1105.     at 0 50 buf 12 hex "data (3 dwords per line)"
  1106.     at 0 50 buf 16 hex "data (4 dwords per line)"
  1107.     at 0 50 buf 20 hex "data (5 dwords per line)"
  1108.     at 0 50 buf 24 hex "data (6 dwords per line)"
  1109.     at 0 50 buf 28 hex "data (7 dwords per line)"
  1110.     at 0 50 buf 32 hex "data (8 dwords per line)"
  1111.     }
  1112.  
  1113. def SPRITE_HDR
  1114.     {
  1115.     n32 hex ptr SPRITE_HDR rel         "next_sprite"
  1116.     buf 12 asc                         "name"
  1117.     n32                                "width_in_dwords-1"
  1118.     n32                                "scan_lines-1"
  1119.     n32                                "first_bit"
  1120.     n32                                "last_bit"
  1121.     n32 hex ptr SPRITE_DATA add -. rel "offset_image"
  1122.     n32 hex ptr SPRITE_DATA add -. rel "offset_mask"
  1123.     n32 map SPRITE_MODE                "mode"
  1124.     0x40 SPRITE_PAL                    "palette"
  1125.     }
  1126.  
  1127. def SPRITE_FILE
  1128.     {
  1129.     n32                           "num_sprites "
  1130.     n32 hex ptr SPRITE_HDR add -. "first_sprite"
  1131.     }
  1132. /*...e*/
  1133. /*...sTGA_FILE    \45\ Targa\47\Vista bitmap:0:*/
  1134. // Just decode the header.
  1135. // Ref: EoGFF
  1136. // Ref: GBM source.
  1137. // Ref: http://www.truevision.com/
  1138.  
  1139. le
  1140.  
  1141. map TGA_
  1142.     {
  1143.     "TGA_NO_IMAGE"    0
  1144.     "TGA_UNCOMP_CM"   1
  1145.     "TGA_UNCOMP_RGB"  2
  1146.     "TGA_UNCOMP_BW"   3
  1147.     "TGA_RL_CM"       9
  1148.     "TGA_RL_RGB"     10
  1149.     "TGA_RL_BW"      11
  1150.     "TGA_COMP_CM"    32
  1151.     "TGA_COMP_CM_4"  33
  1152.     }
  1153.  
  1154. map IDB_
  1155.     {
  1156.     "IDB_ORIGIN"  0x20 : .
  1157.     "IDB_NON_INT" 0x00 : 0xc0
  1158.     "IDB_2_WAY"   0x40 : 0xc0
  1159.     "IDB_4_WAY"   0x80 : 0xc0
  1160.     }
  1161.  
  1162. def TGA_HEADER
  1163.     {
  1164.     n8          "n_chars_in_id"
  1165.     n8          "color_map_present"
  1166.     n8 map TGA_ "image_type"
  1167.     n16         "color_map_start"
  1168.     n16         "color_map_length"
  1169.     n8          "color_map_entry_bits"
  1170.     n16         "x_origin"
  1171.     n16         "y_origin"
  1172.     n16         "width"
  1173.     n16         "height"
  1174.     n8          "bpp"
  1175.     n8 map IDB_ "image_descriptor"
  1176.     }
  1177.  
  1178. def TGA_FILE
  1179.     {
  1180.     n8 ptr TGA_HEADER null "n_chars_in_id"
  1181.     buf 255 asc            "id"
  1182.     }
  1183. /*...e*/
  1184. /*...sTIFF_FILE   \45\ Aldus\47\Microsoft TIFF:0:*/
  1185. // Ref: ftp://sgi.com/graphics/tiff/TIFF6.ps.Z
  1186. // Ref: GBM source.
  1187.  
  1188. // This section makes heavy use of the BE 'valid' keyword to ensure that the
  1189. // correct data decode of tags (tag D_ type and inline/non-inline) takes place.
  1190.  
  1191. $ifdef BE_DECODE
  1192. be
  1193. $else
  1194. le
  1195. $endif
  1196.  
  1197. map TIFF_T
  1198.     {
  1199.     "T_NEWSUBFILETYPE"        254
  1200.     "T_SUBFILETYPE"           255
  1201.     "T_IMAGEWIDTH"            256
  1202.     "T_IMAGELENGTH"           257
  1203.     "T_BITSPERSAMPLE"         258
  1204.     "T_COMPRESSION"           259
  1205.     "T_PHOTOMETRIC"           262
  1206.     "T_THRESHOLDING"          263
  1207.     "T_CELLWIDTH"             264
  1208.     "T_CELLLENGTH"            265
  1209.     "T_FILLORDER"             266
  1210.     "T_DOCNAME"               269
  1211.     "T_DESCRIPTION"           270
  1212.     "T_MAKE"                  271
  1213.     "T_MODEL"                 272
  1214.     "T_STRIPOFFSETS"          273
  1215.     "T_ORIENTATION"           274
  1216.     "T_SAMPLESPERPIXEL"       277
  1217.     "T_ROWSPERSTRIP"          278
  1218.     "T_STRIPBYTECOUNTS"       279
  1219.     "T_MINSAMPLEVALUE"        280
  1220.     "T_MAXSAMPLEVALUE"        281
  1221.     "T_XRESOLUTION"           282
  1222.     "T_YRESOLUTION"           283
  1223.     "T_PLANARCONFIG"          284
  1224.     "T_PAGENAME"              285
  1225.     "T_XPOSITION"             286
  1226.     "T_YPOSITION"             287
  1227.     "T_FREEOFFSETS"           288
  1228.     "T_FREEBYTECOUNTS"        289
  1229.     "T_GRAYRESPONSEUNIT"      290
  1230.     "T_GRAYRESPONSECURVE"     291
  1231.     "T_GROUP3OPTIONS"         292
  1232.     "T_GROUP4OPTIONS"         293
  1233.     "T_RESOLUTIONUNIT"        296
  1234.     "T_PAGENUMBER"            297
  1235.     "T_COLORRESPONSECURVES"   301
  1236.     "T_SOFTWARE"              305
  1237.     "T_DATETIME"              306
  1238.     "T_ARTIST"                315
  1239.     "T_HOSTCOMPUTER"          316
  1240.     "T_PREDICTOR"             317
  1241.     "T_WHITEPOINT"            318
  1242.     "T_PRIMARYCHROMA"         319
  1243.     "T_COLORMAP"              320
  1244.     "T_HALFTONEHINTS"         321
  1245.     "T_TILEWIDTH"             322
  1246.     "T_TILELENGTH"            323
  1247.     "T_TILEOFFSETS"           324
  1248.     "T_TILEBYTECOUNTS"        325
  1249.     "T_INKSET"                332
  1250.     "T_INKNAMES"              333
  1251.     "T_NUMBEROFINKS"          334
  1252.     "T_DOTRANGE"              336
  1253.     "T_TARGETPRINTER"         337
  1254.     "T_EXTRASAMPLES"          338
  1255.     "T_SAMPLEFORMAT"          339
  1256.     "T_SMINSAMPLEVALUE"       340
  1257.     "T_SMAXSAMPLEVALUE"       341
  1258.     "T_TRANSFERRANGE"         342
  1259.     "T_JPEGPROC"              512
  1260.     "T_JPEGINTERCHANGEFMT"    513
  1261.     "T_JPEGINTERCHANGEFMTLEN" 514
  1262.     "T_JPEGRESTARTINTERVAL"   515
  1263.     "T_JPEGLOSSLESSPRED"      517
  1264.     "T_JPEGPOINTTRANSFORMS"   518
  1265.     "T_JPEGOTABLES"           519
  1266.     "T_JPEGDCTABLES"          520
  1267.     "T_JPEGACTABLES"          521
  1268.     "T_COEFFICIENTS"          529
  1269.     "T_SUBSAMPLING"           530
  1270.     "T_REFERENCEBLACKWHITE"   532
  1271.     }
  1272.  
  1273. map TIFF_D
  1274.     {
  1275.     "D_BYTE"       1
  1276.     "D_ASCII"      2
  1277.     "D_SHORT"      3
  1278.     "D_LONG"       4
  1279.     "D_RATIONAL"   5
  1280.     "D_SBYTE"      6
  1281.     "D_UNDEFINED"  7
  1282.     "D_SSHORT"     8
  1283.     "D_SLONG"      9
  1284.     "D_SRATIONAL" 10
  1285.     "D_FLOAT"     11
  1286.     "D_DOUBLE"    12
  1287.     }
  1288.  
  1289. def TIFF_RATIONAL
  1290.     {
  1291.     n32 unsigned "numerator"
  1292.     n32 unsigned "denominator"
  1293.     }
  1294.  
  1295. def TIFF_SRATIONAL
  1296.     {
  1297.     n32 signed "numerator"
  1298.     n32 signed "denominator"
  1299.     }
  1300.  
  1301. def TIFF_TAG_ASCII_NI { buf 100 asc "ascii" }
  1302.  
  1303. def TIFF_TAG_ASCII
  1304.     {
  1305.     n32 dec width 3 "length"
  1306.     union
  1307.       {
  1308.       buf 4 asc                     valid "length<=4" "inline"
  1309.       n32 hex ptr TIFF_TAG_ASCII_NI valid "length>4"  "non-inline"
  1310.       }
  1311.     }
  1312.  
  1313. def TIFF_TAG_BYTE_NI { 100 n8 unsigned open "bytes" }
  1314.  
  1315. def TIFF_TAG_BYTE
  1316.     {
  1317.     n32 dec width 3 "length"
  1318.     union
  1319.       {
  1320.       4 n8 unsigned open           valid "length<=4" "inline"
  1321.       n32 hex ptr TIFF_TAG_BYTE_NI valid "length>4"  "non_inline"
  1322.       }
  1323.     }
  1324.  
  1325. def TIFF_TAG_SBYTE_NI { 100 n8 signed open "bytes" }
  1326.  
  1327. def TIFF_TAG_SBYTE
  1328.     {
  1329.     n32 dec width 3 "length"
  1330.     union
  1331.       {
  1332.       4 n8 signed open              valid "length<=4" "inline"
  1333.       n32 hex ptr TIFF_TAG_SBYTE_NI valid "length>4"  "non_inline"
  1334.       }
  1335.     }
  1336.  
  1337. def TIFF_TAG_SHORT_NI { 100 n16 unsigned open "shorts" }
  1338.  
  1339. def TIFF_TAG_SHORT
  1340.     {
  1341.     n32 dec width 3 "length"
  1342.     union
  1343.       {
  1344.       2 n16 unsigned open           valid "length<=2" "inline"
  1345.       n32 hex ptr TIFF_TAG_SHORT_NI valid "length>2"  "non_inline"
  1346.       }
  1347.     }
  1348.  
  1349. def TIFF_TAG_SSHORT_NI { 100 n16 signed open "sshorts" }
  1350.  
  1351. def TIFF_TAG_SSHORT
  1352.     {
  1353.     n32 dec width 3 "length"
  1354.     union
  1355.       {
  1356.       2 n16 signed open              valid "length<=2" "inline"
  1357.       n32 hex ptr TIFF_TAG_SSHORT_NI valid "length>2"  "non_inline"
  1358.       }
  1359.     }
  1360.  
  1361. def TIFF_TAG_LONG_NI { 100 n32 unsigned open "longs" }
  1362.  
  1363. def TIFF_TAG_LONG
  1364.     {
  1365.     n32 dec width 3 "length"
  1366.     union
  1367.       {
  1368.       n32 unsigned                 valid "length<=1" "inline"
  1369.       n32 hex ptr TIFF_TAG_LONG_NI valid "length>1"  "non_inline"
  1370.       }
  1371.     }
  1372.  
  1373. def TIFF_TAG_SLONG_NI { 100 n32 signed open "slongs" }
  1374.  
  1375. def TIFF_TAG_SLONG
  1376.     {
  1377.     n32 dec width 3 "length"
  1378.     union
  1379.       {
  1380.       n32 signed                    valid "length<=1" "inline"
  1381.       n32 hex ptr TIFF_TAG_SLONG_NI valid "length>1"  "non_inline"
  1382.       }
  1383.     }
  1384.  
  1385. def TIFF_TAG_FLOAT_NI { 100 buf 4 hex open "floats" }
  1386.  
  1387. def TIFF_TAG_FLOAT
  1388.     {
  1389.     n32 dec width 3 "length"
  1390.     union
  1391.       {
  1392.       buf 4 hex                     valid "length<=1" "inline"
  1393.       n32 hex ptr TIFF_TAG_FLOAT_NI valid "length>1"  "non_inline"
  1394.       }
  1395.     }
  1396.  
  1397. def TIFF_TAG_RATIONAL_NI { 100 TIFF_RATIONAL open open "rationals" }
  1398.  
  1399. def TIFF_TAG_RATIONAL
  1400.     {
  1401.     n32 dec width 3 "length"
  1402.     n32 hex ptr TIFF_TAG_RATIONAL "non_inline"
  1403.     }
  1404.  
  1405. def TIFF_TAG_SRATIONAL_NI { 100 TIFF_SRATIONAL open open "srationals" }
  1406.  
  1407. def TIFF_TAG_SRATIONAL
  1408.     {
  1409.     n32 dec width 3 "length"
  1410.     n32 hex ptr TIFF_TAG_SRATIONAL "non_inline"
  1411.     }
  1412.  
  1413. def TIFF_TAG_DOUBLE_NI { 100 buf 8 hex open "doubles" }
  1414.  
  1415. def TIFF_TAG_DOUBLE
  1416.     {
  1417.     n32 dec width 3 "length"
  1418.     n32 hex ptr TIFF_TAG_DOUBLE "non_inline"
  1419.     }
  1420.  
  1421. def TIFF_TAG
  1422.     {
  1423.     n16 map TIFF_T width 23 "type"
  1424.     n16 map TIFF_D width 11 "dtype"
  1425.     union
  1426.       {
  1427.       TIFF_TAG_ASCII     valid "dtype==map TIFF_D \"D_ASCII\""     "ascii"
  1428.       TIFF_TAG_BYTE      valid "dtype==map TIFF_D \"D_BYTE\""      "bytes"
  1429.       TIFF_TAG_SBYTE     valid "dtype==map TIFF_D \"D_SBYTE\""     "sbytes"
  1430.       TIFF_TAG_SHORT     valid "dtype==map TIFF_D \"D_SHORT\""     "shorts"
  1431.       TIFF_TAG_SSHORT    valid "dtype==map TIFF_D \"D_SSHORT\""    "sshorts"
  1432.       TIFF_TAG_LONG      valid "dtype==map TIFF_D \"D_LONG\""      "longs"
  1433.       TIFF_TAG_SLONG     valid "dtype==map TIFF_D \"D_SLONG\""     "slongs"
  1434.       TIFF_TAG_FLOAT     valid "dtype==map TIFF_D \"D_FLOAT\""     "floats"
  1435.       TIFF_TAG_RATIONAL  valid "dtype==map TIFF_D \"D_RATIONAL\""  "rationals"
  1436.       TIFF_TAG_SRATIONAL valid "dtype==map TIFF_D \"D_SRATIONAL\"" "srationals"
  1437.       TIFF_TAG_DOUBLE    valid "dtype==map TIFF_D \"D_DOUBLE\""    "doubles"
  1438.       n32 ptr TIFF_TAG_ASCII_NI valid "dtype<1||dtype>12"          "other"
  1439.         // Note: saying map TIFF_D "D_xyz" is equivelent to, but much
  1440.         // faster than saying D_xyz on its own, as BE only has to scan
  1441.         // the TIFF_D map for a match, not all possible identifiers.
  1442.       }
  1443.     }
  1444.  
  1445. def TIFF_NEXT_IFD
  1446.     {
  1447.     n32 ptr TIFF_IFD "offset_ifd"
  1448.     at 12
  1449.     }
  1450.  
  1451. def TIFF_IFD
  1452.     {
  1453.     n16 ptr TIFF_NEXT_IFD mul add 2 rel "n_tags"
  1454.     100 TIFF_TAG                        "tags"
  1455.     }
  1456.  
  1457. def TIFF_FILE
  1458.     {
  1459.     n16 asc valid "byte_order=='II'||byte_order=='MM'" "byte_order"
  1460.     n16 dec valid "version_number==42"                 "version_number"
  1461.     n32 ptr TIFF_IFD                                   "offset_ifd"
  1462.     }
  1463. /*...e*/
  1464. /*...sVID_FILE    \45\ IBM M\45\Motion bitmap:0:*/
  1465. // Ref: GBM source.
  1466.  
  1467. le
  1468.  
  1469. def VID_FILE
  1470.     {
  1471.     buf 6 asc "signiture (=YUV12C)"
  1472.     buf 2 hex "padding"
  1473.     n16       "xpos"
  1474.     n16       "ypos"
  1475.     n16       "xsize"
  1476.     n16       "ysize"
  1477.     }
  1478. /*...e*/
  1479. /*...sYCC_FILE    \45\ Kodak YCC printer bitmap:0:*/
  1480. // as used by XL7700 printer
  1481. // Ref: EoGFF
  1482.  
  1483. be
  1484.  
  1485. def YCC_FILE
  1486.     {
  1487.     n32 valid "Magic==5965600"   "Magic"
  1488.     n32 ptr YCC_FILE2 add -. rel "HSize"
  1489.     }
  1490.  
  1491. def YCC_FILE2
  1492.     {
  1493.     n32                              "HSize"
  1494.     n32                              "FSize"
  1495.     buf 16 asc                       "FName"
  1496.     n32 valid "FType==7"             "FType"
  1497.     buf 8 hex                        "Unused"
  1498.     n32                              "XSize"
  1499.     n32                              "YSize"
  1500.     buf 12 hex                       "Unused"
  1501.     n32 valid "Planes==1||Planes==3" "Planes"
  1502.     buf 8 hex                        "Unused"
  1503.     buf 100 hex                      "Data ..."
  1504.     }
  1505. /*...e*/
  1506. /*...sXWD10_FILE  \45\ X10 Window Dump:0:*/
  1507. be
  1508.  
  1509. map XWD10_FORMAT
  1510.     {
  1511.     "XY_FORMAT" 0    // single plane
  1512.     "Z_FORMAT"  1    // multiple planes
  1513.     }
  1514.  
  1515. def XWD10_CMAP
  1516.     {
  1517.     n16 hex "EntryNumber"
  1518.     n16 hex "Red"
  1519.     n16 hex "Green"
  1520.     n16 hex "Blue"
  1521.     }
  1522.  
  1523. def XWD10_CMAPS
  1524.     {
  1525.     256 XWD10_CMAP "ColorMap"
  1526.     }
  1527.  
  1528. def XWD10_FILE
  1529.     {
  1530.     n32 ptr XWD_CMAPS valid "WindowNumColors!=0"
  1531.                                "HeaderSize"
  1532.     n32 valid "FileVersion==6" "FileVersion"
  1533.     n32                        "DisplayType"
  1534.     n32 valid "DisplayPlanes==1||DisplayPlanes==3"
  1535.                                "DisplayPlanes"
  1536.     n32 map XWD10_FORMAT       "PixmapFormat"
  1537.     n32                        "PixmapWidth"
  1538.     n32                        "PixmapHeight"
  1539.     n16                        "WindowWidth"
  1540.     n16                        "WindowHeight"
  1541.     n16 signed                 "WindowX"
  1542.     n16 signed                 "WindowY"
  1543.     n16                        "WindowBorderWidth"
  1544.     n16                        "WindowNumColors"
  1545.  
  1546.     buf 500 asc zterm          "WindowName ..."
  1547.         // This field is not known to exist in an X10 XWD.
  1548.         // I've put it in here as the HeaderSize field above gives
  1549.         // provision for its existance.
  1550.     }
  1551. /*...e*/
  1552. /*...sXWD11_FILE  \45\ X11 Window Dump:0:*/
  1553. // Ref: EoGFF
  1554. // Ref: ftp://ftp.x.org/
  1555. // Ref: X11 headers, see file below
  1556. /*...v\47\usr\47\X11\47\include\47\X11\47\XWDFile\46\h:0:*/
  1557.  
  1558. be
  1559.  
  1560. map XWD11_FORMAT
  1561.     {
  1562.     "XY_BITMAP" 0
  1563.     "XY_PIXMAP" 1
  1564.     "Z_PIXMAP"  2
  1565.     }
  1566.  
  1567. map XWD11_BYTEORD
  1568.     {
  1569.     "LS_BYTE_FIRST" 0
  1570.     "MS_BYTE_FIRST" 1
  1571.     }
  1572.  
  1573. map XWD11_BITORD
  1574.     {
  1575.     "LS_BIT_FIRST" 0
  1576.     "MS_BIT_FIRST" 1
  1577.     }
  1578.  
  1579. map XWD11_VISUAL
  1580.     {
  1581.     "FIXED"      0 : 1
  1582.     "DYNAMIC"    1 : 1
  1583.     "GRAY_SCALE" 0 : ~1
  1584.     "COLOR"      2 : ~1
  1585.     "TRUE_COLOR" 4 : ~1
  1586.     }
  1587.  
  1588. def XWD11_CMAP
  1589.     {
  1590.     n32 hex "EntryNumber"
  1591.     n16 hex "Red"
  1592.     n16 hex "Green"
  1593.     n16 hex "Blue"
  1594.     n8  hex "Flags"
  1595.     n8  hex "Padding"
  1596.     }
  1597.  
  1598. def XWD11_CMAPS
  1599.     {
  1600.     256 XWD11_CMAP "ColorMap"
  1601.     }
  1602.  
  1603. def XWD11_FILE
  1604.     {
  1605.     n32 ptr XWD11_CMAPS valid "ColorMapEntries!=0"
  1606.                                "HeaderSize"
  1607.     n32 valid "FileVersion==7" "FileVersion"
  1608.     n32 map XWD11_FORMAT       "PixmapFormat"
  1609.     n32                        "PixmapDepth"
  1610.     n32                        "PixmapWidth"
  1611.     n32                        "PixmapHeight"
  1612.     n32                        "XOffset"
  1613.     n32 map XWD11_BYTEORD      "ByteOrder"
  1614.     n32 valid "BitmapUnit==8||BitmapUnit==16||BitmapUnit==32"
  1615.                                "BitmapUnit"
  1616.     n32 map XWD11_BITORD       "BitmapBitOrder"
  1617.     n32 valid "BitmapPad==8||BitmapPad==16||BitmapPad==32"
  1618.                                "BitmapPad"
  1619.     n32                        "BitsPerPixel"
  1620.     n32                        "BytesPerLine"
  1621.     n32 map XWD11_VISUAL       "VisualClass"
  1622.     n32 hex                    "RedMask"
  1623.     n32 hex                    "GreenMask"
  1624.     n32 hex                    "BlueMask"
  1625.     n32                        "BitsPerRgb"
  1626.     n32                        "NumberOfColors"
  1627.     n32                        "ColorMapEntries"
  1628.     n32                        "WindowWidth"
  1629.     n32                        "WindowHeight"
  1630.     n32 signed                 "WindowX"
  1631.     n32 signed                 "WindowY"
  1632.     n32                        "WindowBorderWidth"
  1633.     buf 500 asc zterm          "WindowName ..."
  1634.     }
  1635.  
  1636. // Just temporary stuff for some investigation I'm doing...
  1637.  
  1638. def XWD11_PIXEL32
  1639.     {
  1640.     n24 le hex suppress "pixel"
  1641.     expr "pixel!=0" dec "nz"
  1642.     }
  1643.  
  1644. def XWD11_PIXELS32
  1645.     {
  1646.     200 XWD11_PIXEL32 "pixels" 
  1647.     at 3216
  1648.     }
  1649. /*...e*/
  1650.  
  1651. def BITMAP_FILES union
  1652.     {
  1653.     BMP_FILE    "Windows or OS/2 bitmap             .bmp .dib"
  1654.     CUT_FILE    "Dr.Halo bitmap                          .cut"
  1655.     GIF_FILE    "Compu$erve GIF bitmap                   .gif"
  1656.     ILBM_FILE   "Amiga ILBM bitmap                  .lbm .iff"
  1657.     JFIF_FILE   "JFIF JPEG bitmap             .jpg .jpeg .jpg"
  1658.     KPS_FILE    "IBM KIPS bitmap                    .kps .kpl"
  1659.     MSP_FILE    "Microsoft Paint bitmap                  .msp"
  1660.     NEO_FILE    "Atari ST, NEOchrome bitmap              .neo"
  1661.     PAL_FILE    "Dr.Halo palette                         .pal"
  1662.     PCX_FILE    "ZSoft PCX bitmap                   .pcx .pcc"
  1663.     PNG_FILE    "Portable Network Graphics bitmap        .png"
  1664.     PSEG_FILE   "IBM Page Segment        .pse .pseg .pseg3820"
  1665.     RAS_FILE    "Sun Raster file                         .ras"
  1666.     RLE_FILE    "Utah Raster Toolkit bitmap              .rle"
  1667.     SGI_FILE    "Silicon Graphics bitmap  .sgi .bw .rgb .rgba"
  1668.     SPRITE_FILE "RiscOS Sprite bitmap            .spr .sprite"
  1669.     TGA_FILE    "Targa/Vista bitmap                 .tga .vst"
  1670. $ifdef BE_DECODE
  1671.     TIFF_FILE   "Aldus/Microsoft TIFF (BE)         .tiff .tif"
  1672. $else
  1673.     TIFF_FILE   "Aldus/Microsoft TIFF (LE)         .tiff .tif"
  1674. $endif
  1675.     VID_FILE    "IBM M-Motion bitmap                     .vid"
  1676.     YCC_FILE    "Kodak YCC printer bitmap                .ycc"
  1677.     XWD10_FILE  "X Windows 10 window dump                .xwd"
  1678.     XWD11_FILE  "X Windows 11 window dump                .xwd"
  1679.     }
  1680. /*...e*/
  1681. /*...sANIMATION_FILES:0:*/
  1682. // Mainly headers and palettes only
  1683.  
  1684. /*...sANI_FILE \45\ Atari ST\44\ NEOchrome Animation Format:0:*/
  1685. // Ref: EoGFF
  1686. // Ref: http://www.wotsit.demon.co.uk/graphics.htm#atari
  1687.  
  1688. be
  1689.  
  1690. def ANI_FILE
  1691.     {
  1692.     n32 hex valid "MagicNumber==0xbabeebea" "MagicNumber"
  1693.     n16                                     "Width (in bytes)"
  1694.     n16                                     "Height (in scan lines)"
  1695.     n16                                     "Size (in bytes + 10)"
  1696.     n16                                     "XCoord-1"
  1697.     n16                                     "YCoord-1"
  1698.     n16                                     "NumberOfFrames"
  1699.     n16                                     "Speed"
  1700.     n32 hex valid "Reserved==0"             "Reserved"
  1701.     }
  1702. /*...e*/
  1703. /*...sFLM_FILE \45\ Atari ST\44\ Animatic Film Format:0:*/
  1704. // A sequence of low resolution 16 colour images
  1705. // Ref: EoGFF
  1706. // Ref: http://www.wotsit.demon.co.uk/graphics.htm#atari
  1707.  
  1708. be
  1709.  
  1710. map FLM_PLAYDIR
  1711.     {
  1712.     "FORWARDS"  0
  1713.     "BACKWARDS" 1
  1714.     }
  1715.  
  1716. map FLM_ENDACTION
  1717.     {
  1718.     "PAUSE_AND_REPEAT" 0
  1719.     "REPEAT"           1
  1720.     "REPEAT_BACKWARDS" 3
  1721.     }
  1722.  
  1723. def FLM_FILE
  1724.     {
  1725.     n16                                     "NumberOfFrames"
  1726.     16 n16 hex                              "Palette"
  1727.     n16 valid "FilmSpeed<=99"               "FilmSpeed"
  1728.     n16 map FLM_PLAYDIR                     "PlayDirection"
  1729.     n16 map FLM_ENDACTION                   "EndAction"
  1730.     n16                                     "FrameWidth"
  1731.     n16                                     "FrameHeight"
  1732.     n16                                     "MajorVersionNumber"
  1733.     n16                                     "MinorVersionNumber"
  1734.     n32 hex valid "MagicNumber==0x27182818" "MagicNumber"
  1735.     buf 12 hex                              "Unused (all zeros)"
  1736.     buf 100 hex                             "Data starts here ..."
  1737.     }
  1738. /*...e*/
  1739. /*...sSEQ_FILE \45\ Atari ST\44\ Cyber Paint Sequence Format:0:*/
  1740. // Ref: EoGFF
  1741.  
  1742. be
  1743.  
  1744. def SEQ_FILE
  1745.     {
  1746.     n16 hex               "MagicNumber"
  1747.     n16                   "VersionNumber"
  1748.     n32                   "NumberOfFrames"
  1749.     n16                   "DisplayRate"
  1750.     buf 118 hex           "Reserved (all zeroes)"
  1751.     100 n32 ptr SEQ_FRAME "FrameOffsets"
  1752.     }
  1753.  
  1754. map SEQ_OP
  1755.     {
  1756.     "COPY" 0
  1757.     "XOR"  1
  1758.     }
  1759.  
  1760. map SEQ_COMP
  1761.     {
  1762.     "UNCOMPRESSED" 0
  1763.     "COMPRESSED"   1
  1764.     }
  1765.  
  1766. def SEQ_FRAME
  1767.     {
  1768.     n16                     "Type"
  1769.     n16                     "Resolution"
  1770.     16 n16 hex              "Palette"
  1771.     buf 16 asc              "FileName"
  1772.     n16                     "Limits"
  1773.     n16                     "Speed"
  1774.     n16                     "NumberOfSteps"
  1775.     n16 valid "XOffset<320" "XOffset"
  1776.     n16 valid "YOffset<200" "YOffset"
  1777.     n16                     "FrameWidth"
  1778.     n16                     "FrameHeight"
  1779.     n8 map SEQ_OP           "Operation"
  1780.     n8 map SEQ_COMP         "Compression"
  1781.     n32                     "DataSize"
  1782.     buf 60 hex              "Unused (all zeroes)"
  1783.     }
  1784. /*...e*/
  1785.  
  1786. def ANIMATION_FILES union
  1787.     {
  1788.     ANI_FILE "Atari ST, NEOchrome Animation Format   .ani"
  1789.     FLM_FILE "Atari ST, Animatic File Format         .flm"
  1790.     SEQ_FILE "Atari ST, Cyber Paint Sequence Format  .seq"
  1791.     }
  1792. /*...e*/
  1793. /*...sMISC_FILES:0:*/
  1794. /*...sRES_FILE  \45\ IBM OS\47\2 Resource file:0:*/
  1795. // Assumes types and names are not ASCII strings.
  1796. // Ref: OS/2 programmers manual.
  1797.  
  1798. le
  1799.  
  1800. map RES_TYPE
  1801.     {
  1802.     "RT_POINTER"       1
  1803.     "RT_BITMAP"        2
  1804.     "RT_MENU"          3
  1805.     "RT_DIALOG"        4
  1806.     "RT_STRING"        5
  1807.     "RT_FONTDIR"       6
  1808.     "RT_FONT"          7
  1809.     "RT_ACCELTABLE"    8
  1810.     "RT_RCDATA"        9
  1811.     "RT_DLGINCLUDE"   11
  1812.     "RT_FKALONG"      17
  1813.     "RT_HELPTABLE"    18
  1814.     "RT_HELPSUBTABLE" 19
  1815.     }
  1816.  
  1817. map RES_MEM_FLAGS
  1818.     {
  1819.     "NSCODE"    0x0000 : 0x0007
  1820.     "NSDATA"    0x0001 : 0x0007
  1821.     "NSITER"    0x0008 : .
  1822.     "NSMOVE"    0x0010 : .
  1823.     "NSPURE"    0x0020 : .
  1824.     "NSPRELOAD" 0x0040 : .
  1825.     "NSEXRD"    0x0080 : .
  1826.     "NSRELOC"   0x0100 : .
  1827.     "NSCONFORM" 0x0200 : .
  1828.     "NSDPL0"    0x0400 : .
  1829.     "NSDPL1"    0x0800 : .
  1830.     "NSDISCARD" 0x1000 : .
  1831.     "NS32BIT"   0x2000 : .
  1832.     "NSHUGE"    0x4000 : .
  1833.     }
  1834.  
  1835. def RES_FILE
  1836.     {
  1837.     n8 hex                                      "(=0xff)"
  1838.     n16 map RES_TYPE                            "resource_type"
  1839.     n8 hex                                      "(=0xff)"
  1840.     n16                                         "name"
  1841.     n16 map RES_MEM_FLAGS                       "memory_flags"
  1842.     n32 ptr RES_FILE add 4 rel                  "data_size"
  1843.     union
  1844.       {
  1845.       buf 100 hex                               "data..."
  1846.       BMP_FILE valid "resource_type==RT_BITMAP" "data..."
  1847.       }
  1848.     }
  1849. /*...e*/
  1850. /*...sRIFF_FILE \45\ Microsoft RIFF chunked file:0:*/
  1851. // Ref: EoGFF
  1852.  
  1853. le
  1854.  
  1855. def RIFF_SUBCHUNK
  1856.     {
  1857.     buf 4 asc                                        "SubChunkId"
  1858.     n32 hex ptr RIFF_SUBCHUNK add 4 rel align 2      "SubChunkSize"
  1859.     buf 100 hex                                      "SubChunk Data ... "
  1860.         // certain sub chunks have a fixed layout
  1861.         // eg: WAVE, which is followed by 2 subchunks
  1862.         // However, I can't embed a subchunk in a subchunk
  1863.         // so the following BE initialisation file hack is needed!
  1864.     at 4 n8 ptr RIFF_SUBCHUNK mult 0 rel    suppress "??? first nested"
  1865.     }
  1866.  
  1867. def RIFF_CHUNK
  1868.     {
  1869.     buf 4 asc                                "ChunkId"
  1870.     n32 hex ptr RIFF_CHUNK add 4 rel align 2 "ChunkSize"
  1871.     union
  1872.       {
  1873.       buf 100 hex                            "ChunkData ..."
  1874.       RIFF_SUBCHUNK                          "ChunkData (first subchunk)"
  1875.       }
  1876.     }
  1877.  
  1878. def RIFF_FILE
  1879.     {
  1880.     RIFF_CHUNK "WholeFileChunk"
  1881.     }
  1882. /*...e*/
  1883. /*...sTEX_FILE  \45\ Andys Raytracer and Modular Rendeder 3D texture format:0:*/
  1884. // 3D Texture block file, as understood by Andys CSG Raytracer,
  1885. // and the Modular Renderer C++ class library, written by the BE author.
  1886. // Ref: http://www.interalpha.net/nyangau/
  1887.  
  1888. le
  1889.  
  1890. def TEX_FILE
  1891.     {
  1892.     n32 hex valid "magic==0x1a584554" "magic"
  1893.     n32 dec                           "w"
  1894.     n32 dec                           "h"
  1895.     n32 dec                           "d"
  1896.     n32 dec                           "bpv"
  1897.     buf 100 hex                       "data..."
  1898.     }
  1899. /*...e*/
  1900. /*...sZIP_FILE  \45\ ZIP compressed archive format:0:*/
  1901. // Ref: Documentation that comes with Info-ZIP Zip etc..
  1902.  
  1903. // zero or more zipped-files
  1904. //   where each zipped-file is a ZIP_LOCAL_FILE_HEADER followed by its data
  1905. // followed by zero or more ZIP_FILE_HEADERs
  1906. // followed by ZIP_CENTRAL
  1907.  
  1908. le
  1909.  
  1910. // Operating system
  1911.  
  1912. map ZIP_OS
  1913.     {
  1914.     "MS-DOS and OS/2 (FAT FS)" 0
  1915.     "Amiga"                    1
  1916.     "VMS"                      2
  1917.     "*nix"                     3
  1918.     "VM/CMS"                   4
  1919.     "Atari ST"                 5
  1920.     "OS/2 (HPFS FS)"           6
  1921.     "Macintosh"                7
  1922.     "Z-System"                 8
  1923.     "CP/M"                     9
  1924.     }
  1925.  
  1926. // Compression method
  1927.  
  1928. map ZIP_COMP
  1929.     {
  1930.     "Stored"                                         0
  1931.     "Shrunk (dynamic LZW)"                           1
  1932.     "Reduced with compression factor 1"              2
  1933.     "Reduced with compression factor 2"              3 
  1934.     "Reduced with compression factor 3"              4
  1935.     "Reduced with compression factor 4"              5
  1936.     "Imploded (sliding dict.+shannon fano)"          6
  1937.     "Tokenized"                                      7
  1938.     "Imploded (sliding dict.+dyn huff+shannon fano)" 8
  1939.     }
  1940.  
  1941. // header to each zipped-file in the zip-archive
  1942.  
  1943. def ZIP_LOCAL_FILE_HEADER
  1944.     {
  1945.     // Will be followed by more ZIP_LOCAL_FILE_HEADERs,
  1946.     // or after all of these, there will be ZIP_FILE_HEADERs.
  1947.     expr "30+compressed_size+filename_length+extra_field_length"
  1948.          hex ptr ZIP_LOCAL_FILE_HEADER rel suppress "next"
  1949.     expr "30+compressed_size+filename_length+extra_field_length"
  1950.          hex ptr ZIP_FILE_HEADER rel suppress "next"
  1951.  
  1952.     n32 hex valid "signature==0x04034b50"
  1953.                               "signature"
  1954.     n8 dec           suppress "version_needed_to_extract_level"
  1955.     n8 map ZIP_OS    suppress "version_needed_to_extract_OS"
  1956.     n16 hex          suppress "general_purpose_bit_flag"
  1957.     n16 map ZIP_COMP suppress "compression_method"
  1958.     n16 dec          suppress "last_mod_file_time"
  1959.     n16 dec          suppress "last_mod_file_date"
  1960.     n32 hex          suppress "crc_32"
  1961.     n32 dec width 8           "compressed_size"
  1962.     n32 dec width 8           "uncompressed_size"
  1963.     n16 dec width 2           "filename_length"
  1964.     n16 dec width 3           "extra_field_length"
  1965.     // 30 bytes upto here ...
  1966.     buf 100 asc               "filename_and_extra_field ..."
  1967.     }
  1968.  
  1969. // header to each entry in the central directory
  1970.  
  1971. def ZIP_FILE_HEADER
  1972.     {
  1973.     // Will be followed by more ZIP_FILE_HEADERs,
  1974.     // or after all of these, there will be a ZIP_CENTRAL.
  1975.     expr "46+filename_length+extra_field_length"
  1976.          hex ptr ZIP_FILE_HEADER rel suppress "next"
  1977.     expr "46+filename_length+extra_field_length"
  1978.          hex ptr ZIP_CENTRAL rel suppress "next"
  1979.  
  1980.     n32 hex valid "signature==0x02014b50"
  1981.                            "signature"
  1982.     n8 dec        suppress "version_made_by_level"
  1983.     n8 map ZIP_OS suppress "version_made_by_OS"
  1984.     n8 dec        suppress "version_needed_to_extract_level"
  1985.     n8 map ZIP_OS suppress "version_needed_to_extract_OS"
  1986.     n16 hex       suppress "general_purpose_bit_flag"
  1987.     n16 dec       suppress "compression_method"
  1988.     n16 dec       suppress "last_mod_file_time"
  1989.     n16 dec       suppress "last_mod_file_date"
  1990.     n32 hex       suppress "crc_32"
  1991.     n32 dec width 8        "compressed_size"
  1992.     n32 dec width 8        "uncompressed_size"
  1993.     n16 dec width 2        "filename_length"
  1994.     n16 dec width 3        "extra_field_length"
  1995.     n16 dec width 3        "file_comment_length"
  1996.     n16 dec                "disk_number_start"
  1997.     n16 hex       suppress "internal_file_attributes"
  1998.     n32 hex       suppress "external_file_attributes"
  1999.     n32 dec       suppress "relative_offset_of_local_header"
  2000.     // 46 bytes upto here ...
  2001.     buf 100 asc            "filename_and_extra_field_and_comment ..."
  2002.     }
  2003.  
  2004. // central directory
  2005.  
  2006. def ZIP_CENTRAL
  2007.     {
  2008.     n32 hex valid "signature==0x06054b50"
  2009.                 "signature"
  2010.     n16 dec     "number_of_this_disk"
  2011.     n16 dec     "number_of_disk_with_start_of_central_directory"
  2012.     n16 dec     "total_number_of_entries_in_the_central_dir_on_this_disk"
  2013.     n16 dec     "total_number_of_entries_in_the_central_dir"
  2014.     n32 dec     "size_of_the_central_directory"
  2015.     n32 dec     "offset_of_start_of_central_directory_wrt_start_disk_num"
  2016.     n16 dec     "zipfile_comment_length"
  2017.     buf 100 asc "zipfile_comment ..."
  2018.     }
  2019.  
  2020. // In theory, the above structures could occur in various orders.
  2021. // The signature can be used to see what you've got.
  2022. // So the following definition helps a little.
  2023.  
  2024. def ZIP_BLOCK union
  2025.     {
  2026.     n32 hex                                             "signature"
  2027.     ZIP_LOCAL_FILE_HEADER valid "signature==0x04034b50" "local_file_header"
  2028.     ZIP_FILE_HEADER       valid "signature==0x02014b50" "file_header"
  2029.     ZIP_CENTRAL           valid "signature==0x06054b50" "central_directory"
  2030.     }
  2031.  
  2032. def ZIP_FILE
  2033.     {
  2034.     ZIP_BLOCK "first_zip_block"
  2035.     }
  2036. /*...e*/
  2037.  
  2038. def MISC_FILES union
  2039.     {
  2040.     RES_FILE  "IBM OS/2 Resource file            .res"
  2041.     RIFF_FILE "Microsoft RIFF chunked file  .avi .wav"
  2042.     TEX_FILE  "RT and MR 3D texture format       .tex"
  2043.     ZIP_FILE  "ZIP compressed archive file       .zip"
  2044.     }
  2045. /*...e*/
  2046.  
  2047. def main union
  2048.     {
  2049.     BITMAP_FILES    "Bitmap file formats"
  2050.     ANIMATION_FILES "Animation file formats"
  2051.     MISC_FILES      "Files in other categories"
  2052.     }
  2053.