home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / formats / atari / spec / atari.txt
Text File  |  1994-06-01  |  49KB  |  1,203 lines

  1.  
  2.                            ST Picture Formats
  3.                            ------------------
  4.                                Edited by:
  5.  
  6.                               David Baggett
  7.  
  8.                                 Internet:
  9.                              dmb@ai.mit.edu
  10.  
  11.                    (Please report errors or additions.)
  12.  
  13.             Copyright (C) 1988 -- 1993  by David M. Baggett
  14.  
  15.  
  16.     Non-profit redistribution of this document is permitted, provided
  17.     the document is not modified in any way.
  18.  
  19.     Reproduction of this document in whole or in part for  commercial
  20.     purposes is expressly forbidden without the prior written consent
  21.     of David M. Baggett.
  22.  
  23.     The  information  presented here is not guaranteed to be correct.
  24.     The editor and contributors will in no event be liable for direct,
  25.     indirect, incidental, or consequential damages resulting from the 
  26.     use of the information in this document.
  27.  
  28.     This document is the product of many hours of volunteer work by a
  29.     large number of people. Please respect this -- do not violate the
  30.     distribution policy.
  31.  
  32.  
  33.                               CONTRIBUTORS
  34.   
  35.              Steve Belczyk  Phil Blanchfield  Marcel Boom
  36.     Jason Blochowiak  John Brochu**  David Brooks  Daniel Deimert
  37.     Neil Forsyth  Stefan Hoehn  Gerfried Klein  G. "Maddog" Knauss
  38.         Ken MacLeod  Shamus McBride  Jim McCabe  Lars Michael
  39.         Darek Mihocka  David Mumper  George Nassas  Jim Omura
  40.                  George Seto  Joe Smith  Greg Wageman
  41.                      Roland Waldi*  Gerry Wheeler
  42.  
  43.  
  44.                                 Contents 
  45.                                 --------
  46.  
  47.         NEOchrome                               *.NEO
  48.         NEOchrome Animation                     *.ANI
  49.         DEGAS                                   *.PI?   ? = 1, 2, 3
  50.         DEGAS Elite                             *.PI?   ? = 1, 2, 3
  51.         DEGAS Elite (Compressed)                *.PC?   ? = 1, 2, 3
  52.         Tiny                                    *.TN?   ? = 1, 2, 3, Y
  53.         Spectrum 512                            *.SPU
  54.         Spectrum 512 (Compressed)               *.SPC
  55.         Spectrum 512 (Smooshed)                 *.SPS
  56.         Art Director                            *.ART
  57.         C.O.L.R. Object Editor Mural            *.MUR
  58.         Doodle                                  *.DOO
  59.         Cyber Paint Sequence                    *.SEQ
  60.         Animatic Film                           *.FLM
  61.         Animaster Sprite Bank                   *.ASB
  62.         STOS                                    *.MBK
  63.         GEM Bit Image                           *.IMG
  64.         GEM Metafile (vector graphics)          *.GEM
  65.         STAD                                    *.PAC
  66.         Imagic Film/Picture                     *.IC?   ? = 1, 2, 3
  67.         IFF                                     *.IFF
  68.         RGB Intermediate Format                 *.RGB
  69.         ComputerEyes Raw Data Format            *.CE?   ? = 1, 2
  70.         MacPaint                                *.MAC
  71.         PackBits Compression Algorithm
  72.  
  73.  
  74.                         Introductory Information
  75.                         ------------------------
  76. word    = 2 bytes
  77. long    = 4 bytes
  78. palette = Hardware color palette, stored as 16 words.  First word is
  79.           color register zero (background), last word is color register
  80.           15.  Each word has the form:
  81.  
  82.           Bit:  (MSB) 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 (LSB)
  83.                       -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  84.                        0  0  0  0  0 R2 R1 R0  0 G2 G1 G0  0 B2 B1 B0
  85.  
  86.           R2 = MSB of red intensity
  87.           R0 = LSB of red intensity
  88.  
  89.           G2 = MSB of green intensity
  90.           G0 = LSB of green intensity
  91.  
  92.           B2 = MSB of blue intensity
  93.           B0 = LSB of blue intensity
  94.  
  95.           Intensity ranges from 0 (color not present) to 7 (highest
  96.           intensity).
  97.  
  98.           Example: { red = 7, green = 3, blue = 5 } -> 0735 (hex)
  99.  
  100.           Caveat:  It is wise to mask off the upper four bits of each
  101.                    palette entry, since a few programs store special
  102.                    information there (most notably Art Studio).
  103.  
  104.  
  105.                              The Formats
  106.                              -----------
  107.  
  108. <NEOchrome>     *.NEO
  109.  
  110. 1 word          flag byte [always 0]
  111. 1 word          resolution [0 = low res, 1 = medium res, 2 = high res]
  112. 16 words        palette
  113. 12 bytes        filename [usually "        .   "]
  114. 1 word          color animation limits.  High bit (bit 15) set if color
  115.                 animation data is valid.  Low byte contains color animation
  116.                 limits (4 most significant bits are left/lower limit,
  117.                 4 least significant bits are right/upper limit).
  118. 1 word          color animation speed and direction.  High bit (bit 15) set
  119.                 if animation is on.  Low order byte is # vblanks per step.
  120.                 If negative, scroll is left (decreasing).  Number of vblanks
  121.                 between cycles is |x| - 1
  122. 1 word          # of color steps (as defined in previous word) to display
  123.                 picture before going to the next.  (For use in slide shows)
  124. 1 word          image X offset [unused, always 0]
  125. 1 word          image Y offset [unused, always 0]
  126. 1 word          image width [unused, always 320]
  127. 1 word          image height [unused, always 200]
  128. 33 words        reserved for future expansion
  129. 16000 words     picture data (screen memory)
  130. -----------
  131. 32128 bytes     total
  132.  
  133.  
  134. <NEOchrome Animation>        *.ANI
  135.  
  136. NOTE:      To get this feature on versions 0.9 and later select the Grabber
  137.         icon and click both mouse buttons in the eye of the second R in the
  138.         word GRABBER.
  139.            Interestingly enough, some versions of NEO only require you
  140.         to press the right button, not both.  Hmmm...
  141.  
  142. 1 long          magic number BABEEBEA (hex) (seems to be ignored)
  143. 1 word          width of image in bytes (always divisible by 8)
  144. 1 word          height of image in scan lines
  145. 1 word          size of image in bytes + 10 (!)
  146. 1 word          x coordinate of image (must be divisible by 16) - 1
  147. 1 word          y coordinate of image - 1
  148. 1 word          number of frames
  149. 1 word          animation speed (# vblanks to delay between frames)
  150. 1 long          reserved; should be zero
  151. --------
  152. 22 bytes        total for header
  153.  
  154. ? words         image data (words of screen memory) for each frame, in 
  155.                 order
  156.  
  157.  
  158. <DEGAS>         *.PI1 (low resolution)
  159.                 *.PI2 (medium resolution)
  160.                 *.PI3 (high resolution)
  161.  
  162. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  163.                 Other bits may be used in the future; use a simple bit
  164.                 test rather than checking for specific word values.
  165. 16 words        palette
  166. 16000 words     picture data (screen memory)
  167. -----------
  168. 32034 bytes     total
  169.  
  170.  
  171. <DEGAS Elite>   *.PI1 (low resolution)
  172.                 *.PI2 (medium resolution)
  173.                 *.PI3 (high resolution)
  174.  
  175. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  176.                 Other bits may be used in the future; use a simple bit
  177.                 test rather than checking for specific word values.
  178. 16 words        palette
  179. 16000 words     picture data (screen memory)
  180. 4 words         left color animtion limit table (starting color numbers)
  181. 4 words         right color animation limit table (ending color numbers)
  182. 4 words         animation channel direction flag (0 = left, 1 = off, 2 = right)
  183. 4 words         128 - animation channel delay in 1/60's of a second. [0 - 128]
  184.                 (I.e., subtract word from 128 to get 1/60th's of a second.)
  185. -----------
  186. 32066 bytes     total
  187.  
  188.  
  189. <DEGAS Elite (Compressed)>      *.PC1 (low resolution)
  190.                                 *.PC2 (medium resolution)
  191.                                 *.PC3 (high resolution)
  192.  
  193. 1 word          resolution (same as Degas, but high order bit is set;
  194.                 i.e., hex 8000 = low res, hex 8001 = medium res,
  195.                 hex 8002 = high res).  Other bits may be used in the
  196.                 future; use a simple bit test rather than checking
  197.                 for specific word values.
  198. 16 words        palette
  199. < 32000 bytes   control/data bytes
  200. 4 words         left color animation limit table (starting color numbers)
  201. 4 words         right color animation limit table (ending color numbers)
  202. 4 words         animation channel direction flag [0 = left, 1 = off, 2 = right]
  203. 4 words         128 - animation channel delay in 1/60's of a second. [0 - 128]
  204.                 (I.e., subtract word from 128 to get 1/60th's of a second.)
  205. -----------
  206. < 32066 bytes   total
  207.  
  208. Compression Scheme:
  209.  
  210.    PackBits compression is used (see below).  Each scan line is compressed
  211. separately; i.e., all data for a given scan line appears before any data
  212. for the next scan line.  The scan lines are specified from top to bottom
  213. (i.e., 0 is first).  For each scan line, all the data for a given bit plane
  214. appears before any data for the next higher order bit plane.  Note that this
  215. is identical to the IFF 'BODY' image data.
  216.    To clarify:  The first data in the file will be the data for the lowest
  217. order bit plane of scan line zero, followed by the data for the next higher
  218. order bit plane of scan line zero, etc., until all bit planes have been
  219. specified for scan line zero.  The next data in the file will be the data
  220. for the lowest order bit plane of scan line one, followed by the data for
  221. the next higher order bit plane of scan line one, etc., until all bit planes
  222. have been specified for all scan lines.
  223.  
  224. Caveats:
  225.  
  226.    DEGAS Elite's picture loading routine places some restrictions on
  227. compressed DEGAS files:
  228.  
  229.         o Elite uses a 40-byte buffer to store data being decompressed.
  230.  
  231.         o Whenever a control command is encountered, bytes are stuffed
  232.         in this buffer.
  233.  
  234.         o The buffer is only emptied when there are EXACTLY 40
  235.         characters in it.
  236.  
  237. The important conclusion here is that
  238.  
  239.         No control command may cause the buffer to have more than 40
  240.         bytes in it.  In other words, all control commands must end on
  241.         or before the 40-byte boundary.
  242.  
  243. Any picture violating the last condition will cause Elite to get a bus
  244. error when the picture is loaded.
  245.  
  246.  
  247. <Tiny>  *.TNY (any resolution)
  248.         *.TN1 (low resolution)
  249.         *.TN2 (medium resolution)
  250.         *.TN3 (high resolution)
  251.  
  252.    Several people have reported sightings of mutated Tiny pictures that
  253. do not follow the standard format, so let's be careful out there.  What
  254. is described here is the format that David Mumper's original
  255. TNYSTUFF.PRG produces.
  256.  
  257. 1 byte          resolution (same as NEO, but +3 indicates rotation
  258.                 information also follows)
  259.  
  260. If resolution > 2 {
  261. 1 byte          left and right color animation limits.  High 4 bits
  262.                 hold left (start) limit; low 4 bits hold right (end) limit
  263. 1 byte          direction and speed of color animation (negative value
  264.                 indicates left, positive indicates right, absolute value
  265.                 is delay in 1/60's of a second.
  266. 1 word          color rotation duration (number of iterations)
  267. }
  268.  
  269. 16 words        palette
  270. 1 word          number of control bytes
  271. 1 word          number of data words
  272. 3-10667 bytes   control bytes
  273. 1-16000 words   data words
  274. -------------
  275. 42-32044 bytes  total
  276.  
  277. Control byte meanings:
  278.  
  279.         For a given control byte, x:
  280.  
  281.         x < 0   Absolute value specifies the number of unique words to
  282.                 take from the data section (from 1 to 127)
  283.         x = 0   1 word is taken from the control section which specifies
  284.                 the number of times to repeat the next data word (from
  285.                 128 to 32767)
  286.         x = 1   1 word is taken from the control section which specifies
  287.                 the number of unique words to be taken from the data
  288.                 section (from 128 - 32767)
  289.         x > 1   Specifies the number of times to repeat the next word
  290.                 taken from the data section (from 2 to 127)
  291.  
  292. Format of expanded data:
  293.  
  294.    The expanded data is not simply screen memory bitmap data; instead, the 
  295. data is divided into four sets of vertical columns.  (This results in
  296. better compression.)  A column consists of one specific word taken
  297. from each scan line, going from top to bottom.  For example, column 1 
  298. consists of word 1 on scanline 1 followed by word 1 on scanline 2, etc., 
  299. followed by word 1 on scanline 200.
  300.    The columns appear in the following order:
  301.  
  302.    1st set contains columns 1, 5,  9, 13, ..., 69, 73, 77 in order
  303.    2nd set contains columns 2, 6, 10, 14, ..., 70, 74, 78 in order
  304.    3rd set contains columns 3, 7, 11, 15, ..., 71, 75, 79 in order
  305.    4th set contains columns 4, 8, 12, 16, ..., 72, 76, 80 in order
  306.  
  307. Note that Tiny partitions the screen this way regardless of resolution; i.e., 
  308. these aren't bitplanes.  For example, medium resoltion only has two bitplanes, 
  309. but Tiny still divides medium resolution pictures into four parts.
  310.  
  311.  
  312. <Spectrum 512>  *.SPU
  313.  
  314. 80 words        first scan line of picture (unused) -- should be zeroes
  315. 15920 words     picture data (screen memory) for scan lines 1 through 199
  316. 9552 words      3 palettes for each scan line (the top scan line is
  317.                 not included because Spectrum 512 can't display it)
  318. -----------
  319. 51104 bytes     total
  320.  
  321. Note that the Spectrum 512 mode's three palette changes per scan
  322. line allow more colors on the screen than normally possible, but a
  323. tremendous amount of CPU time is required to maintain the image.
  324.  
  325. The Spectrum format specifies a palette of 48 colors for each scan line.
  326. To decode a Spectrum picture, one must be know which of these 48 colors
  327. are in effect for a given horizontal pixel position.
  328.  
  329. Given an x-coordinate (from 0 to 319) and a color index (from 0 to 15),
  330. the following C function will return the proper index into the Spectrum
  331. palette (from 0 to 47):
  332.  
  333. /*
  334.  *  Given an x-coordinate and a color index, returns the corresponding
  335.  *  Spectrum palette index.
  336.  *
  337.  *  by Steve Belczyk; placed in the public domain December, 1990.
  338.  */
  339. int 
  340. FindIndex(x, c)
  341.         int x, c;
  342. {
  343.         int x1;
  344.  
  345.         x1 = 10 * c;
  346.  
  347.         if (1 & c)              /* If c is odd */
  348.                 x1 = x1 - 5;
  349.         else                    /* If c is even */
  350.                 x1 = x1 + 1;
  351.  
  352.         if (x >= x1 && x < x1 + 160) 
  353.                 c = c + 16;
  354.         else if (x >= x1 + 160) 
  355.                 c = c + 32;
  356.  
  357.         return c;
  358. }
  359.  
  360.  
  361. <Spectrum 512 (Compressed)>        *.SPC
  362.  
  363. 1 word          flag word [$5350 or "SP"]
  364. 1 word          reserved for future use [always 0]
  365. 1 long          length of data bit map
  366. 1 long          length of color bit map
  367. <= 32092 bytes  compressed data bit map
  368. <= 17910 bytes  compressed color bit map
  369. --------------
  370. <= 50014 bytes  total
  371.  
  372. Data compression:
  373.  
  374.    Compression is via a modified run length encoding (RLE) scheme,
  375. similar to DEGAS compressed and Tiny.  The data map is stored as a
  376. sequence of records.  Each record consists of a header byte followed by
  377. one or more data bytes.  The meaning of the header byte is as follows:
  378.  
  379.         For a given header byte, x:
  380.  
  381.            0 <= x <= 127   Use the next x + 1 bytes literally (no repetition)
  382.         -128 <= x <=  -1   Use the next byte -x + 2 times
  383.  
  384. The data appears in the following order:
  385.  
  386.         1. Picture data, bit plane 0, scan lines 1 - 199
  387.         2. Picture data, bit plane 1, scan lines 1 - 199
  388.         3. Picture data, bit plane 2, scan lines 1 - 199
  389.         4. Picture data, bit plane 3, scan lines 1 - 199
  390.  
  391. Decompression of data ends when 31840 data bytes have been used.
  392.  
  393. Color map compression:
  394.  
  395.    Each 16-word palette is compressed separately.  There are three
  396. palettes for each scan line (597 total).  The color map is stored as a
  397. sequence of records.  Each record starts with a 1-word bit vector which
  398. specifies which of the 16 palette entries are included in the data
  399. following the bit vector (1 = included, 0 = not included).  If a palette
  400. entry is not included, it is assumed to be zero (black).  The least
  401. significant bit of the bit vector refers to palette entry zero, while the
  402. most significant bit refers to palette entry 15.  Bit 15 must be zero,
  403. since Spectrum 512 does not use palette entry 15.  Bit 0 should also be
  404. zero, since Spectrum 512 always makes the background color black.
  405.    The words specifying the values for the palette entries indicated in
  406. the bit vector follow the bit vector itself, in order (0 - 15).
  407.  
  408. NOTE:   Regarding Spectrum pictures, Shamus McBride reports the following:
  409.  
  410.         "... [The Picture Formats List] says bit 15 of the color map vector
  411.         must be zero. I've encountered quite a few files where [bit 15] is 
  412.         set (with no associated palette entry)..."
  413.  
  414.  
  415. <Spectrum 512 (Smooshed)>          *.SPS
  416.  
  417.    This format compresses Spectrum 512 pictures better than the standard
  418. method.  There are at least two programs that support this format, SPSLIDEX
  419. and ANISPEC, although the two seem to differ slightly in their interpretation
  420. of the format.
  421.    One point of interest: Shamus McBride deciphered this format without an ST!
  422.  
  423. 1 word          5350 (hex) ("SP")
  424. 1 word          0 (reserved for future use)
  425. 1 long          length of data bit map
  426. 1 long          length of color bit map
  427. <= ? bytes      compressed data bit map
  428. <= ? bytes      compressed color bit map
  429. ----------
  430. < ?  bytes      total
  431.  
  432. Data compression:
  433.  
  434.    Compression is via a modified run length encoding (RLE) scheme,
  435. similar to that used in Spectrum Compressed (*.SPC) pictures.
  436.  
  437. The data map is stored as a sequence of records.  Each record consists of a
  438. header byte followed by one or more data bytes.  The meaning of the header
  439. byte is as follows:
  440.  
  441.         For a given header byte, x (unsigned):
  442.  
  443.           0 <= x <= 127    Use the next byte x + 3 times
  444.         128 <= x <= 255    Use the next x - 128 + 1 bytes literally
  445.                            (no repetition)
  446.  
  447. There are two kinds of *.SPS files.
  448.  
  449. The data may appear in the same order as *.SPC files (SPSLIDEX format?):
  450.  
  451.         1. Picture data, bit plane 0, scan lines 1 - 199
  452.         2. Picture data, bit plane 1, scan lines 1 - 199
  453.         3. Picture data, bit plane 2, scan lines 1 - 199
  454.         4. Picture data, bit plane 3, scan lines 1 - 199
  455.  
  456. The second variant (ANISPEC format?) encodes the data as byte wide vertical
  457. strips:
  458.  
  459.         Picture data, bit plane 0, scan line   1, columns   0 -   7.
  460.         Picture data, bit plane 0, scan line   2, columns   0 -   7.
  461.         Picture data, bit plane 0, scan line   3, columns   0 -   7.
  462.         . . .
  463.         Picture data, bit plane 0, scan line 199, columns   0 -   7.
  464.         Picture data, bit plane 0, scan line   1, columns   8 -  15.
  465.         Picture data, bit plane 0, scan line   2, columns   8 -  15.
  466.         . . .
  467.         Picture data, bit plane 0, scan line 199, columns 312 - 319.
  468.         Picture data, bit plane 1, scan line   1, columns   0 -   7.
  469.         . . .
  470.         Picture data, bit plane 3, scan line 198, columns 312 - 319
  471.         Picture data, bit plane 3, scan line 199, columns 312 - 319.
  472.  
  473. A for loop to process that data would look like
  474.  
  475.         for (plane = 0; plane < 4; plane++)
  476.             for (x = 0; x < 320; x += 8)
  477.                 for (y = 1; y < 200; y++)
  478.                     for (x1 = 0; x1 < 8; x1++)
  479.                         image[y, x + x1] = ...
  480.  
  481. Color map compression:
  482.  
  483.    Color map compression is similar to *.SPC color map compression, but
  484. the map is compressed as a string of bits, rather than words.  There are
  485. 597 records (one for each palette). Each record is composed of a 14-bit
  486. header followed by a number of 9-bit palette entries.  The 14-bit header
  487. specifies which palette entries follow (1 = included, 0 = not included).
  488. The most significant bit of the header refers to palette entry 1, while
  489. the least significant bit refers to palette 14.  Palette entries 0 and 15
  490. are forced to black (zero).  Each palette entry is encoded as "rrrgggbbb".
  491.  
  492. The format of the palette is described above in the section on uncompressed
  493. Spectrum pictures (*.SPU).
  494.  
  495.  
  496. <Art Director>  *.ART (low resolution only)
  497.  
  498. 16000 words     picture data (screen memory)
  499. 16 words        palette
  500. 15 * 16 words   15 more palettes for animation
  501. -------------
  502. 32512 bytes     total
  503.  
  504.  
  505. <C.O.L.R. Object Editor Mural>        *.MUR (low resolution only)
  506.  
  507. 16000 words     picture data (screen memory)
  508.                 (palettes are stored in separate files)
  509. -----------
  510. 32000 bytes     total
  511.  
  512.  
  513. <Doodle>        *.DOO (high resolution only)
  514.  
  515. 16000 words     picture data (screen memory)
  516. -----------
  517. 32000 bytes     total
  518.  
  519.  
  520. <Cyber Paint Sequence>  *.SEQ (low resolution only)
  521.  
  522.    This format, while fairly complex, yields excellent compression of animated
  523. images while offering reasonably fast decompression times.
  524.  
  525. 1 word          magic number [$FEDB or $FEDC]
  526. 1 word          version number
  527. 1 long          number of frames
  528. 1 word          speed (high byte is vblanks per frame)
  529. 118 bytes       reserved
  530. ---------
  531. 128 bytes       total for .SEQ header
  532.  
  533. for each frame {
  534. 1 long          offset to data for this frame, in bytes [basically useless]
  535. }
  536.  
  537. for each frame {
  538. 1 word          type (ignored?)
  539. 1 word          resolution [always 0]
  540. 16 words        palette
  541. 12 bytes        filename [usually "        .   "]
  542. 1 word          color animation limits [not used]
  543. 1 word          color animation speed and direction [not used]
  544. 1 word          number of color steps [not used]
  545. 1 word          x offset for this frame [0 - 319]
  546. 1 word          y offset for this frame [0 - 199]
  547. 1 word          width of this frame, in pixels (may be 0, see below)
  548. 1 word          height of this frame, in pixels (may be 0, see below)
  549. 1 byte          operation [0 = copy, 1 = exclusive or]
  550. 1 byte          storage method [0 = uncompressed, 1 = compressed]
  551. 1 long          length of data in bytes (if the data is compressed, this
  552.                 will be the size of the compressed data BEFORE decompression)
  553. 60 bytes        reserved                
  554. --------
  555. 128 bytes       total for frame header
  556.  
  557. ? bytes         data
  558. }
  559.  
  560.    Frames are "delta-compressed," meaning that only the changes from one
  561. frame to the next are stored.  On the ST, .SEQ files are always full-screen
  562. low resolution animations, so the sequence resulting from expanding all the
  563. data will be n 320 by 200 pixel low resolution screens, where n is given in
  564. the .SEQ header.
  565.   
  566.    Since only the changes from frame to frame are stored, image data for a
  567. frame will rarely be 320x200 (except for the very first frame, which will 
  568. always be a full screen).  Instead what is stored is the smallest rectangular
  569. region on the screen that contains all the changes from the previous frame to
  570. the current frame.  The x offset and y offset in the frame header determine
  571. where the upper left corner of the "change box" lies, and the width and height
  572. specify the box's size.
  573.  
  574.    Additionally, each "change box" is stored in one of five ways.  For each
  575.    of these, the screen is assumed to have the full-screen image from the last
  576.    frame on it.
  577.    
  578.    o uncompressed copy:  The data for this frame is uncompressed image data,
  579.      and is simply copied onto the screen at position (x, y) specified
  580.      in the frame header.
  581.  
  582.    o uncompressed eor:  The data for this frame is exclusive or'ed with the
  583.      screen at position (x, y).
  584.  
  585.    o compressed copy:  The data for this frame must be decompressed (see 
  586.      below), and then copied onto the screen at position (x, y) specified
  587.      in the frame header.
  588.  
  589.    o compressed eor:  The data for this frame must be decompressed (see 
  590.      below), and then exclusive or'ed with the screen RAM at position (x, y).
  591.  
  592.    o null frame:  The width and/or height of this frame is 0, so this
  593.      frame is the same as the previous frame.
  594.    
  595.    Of the 5 methods above, the one that results in the smallest amount
  596.    of data being stored for a particular is used for that frame.
  597.   
  598. Compression Scheme:
  599.  
  600.    Compression is similar to that employed by Tiny, but is not quite as
  601. space-efficient.
  602.  
  603. Control word meanings:
  604.  
  605.         For a given control word, x:
  606.  
  607.         x < 0   Absolute value specifies the number of unique words to
  608.                 take from the data section (from 1 to 32767).
  609.         x > 0   Specifies the number of times to repeat the next word
  610.                 taken from the data section (from 1 to 32767).
  611.  
  612.         Note that a control word of 0 is possible but meaningless.
  613.  
  614. Format of expanded data:
  615.  
  616.    The expanded data is not simply screen memory bitmap data; instead the four
  617. bitplanes are separated, and the data within each bitplane is presented
  618. vertically instead of horizontally.  (This results in better compression.)
  619.  
  620.    To clarify, data for a full screen would appear in the following order:
  621.    
  622.    bitplane 0, word 0, scanline 0
  623.    bitplane 0, word 0, scanline 1
  624.    ...
  625.    bitplane 0, word 0, scanline 199
  626.    bitplane 0, word 1, scanline 0
  627.    bitplane 0, word 1, scanline 1
  628.    ...
  629.    bitplane 0, word 1, scanline 199
  630.    ... 
  631.    bitplane 0, word 79, scanline 199
  632.    bitplane 1, word 0, scanline 0
  633.    ... 
  634.    bitplane 3, word 79, scanline 199
  635.  
  636. Note however, that the data does not usually refer to an entire screen, but
  637. rather to the smaller "change box," whose size is given in the frame header.
  638.  
  639.  
  640. <Animatic Film> *.FLM (low resolution only)
  641.  
  642. 1 word          number of frames
  643. 16 words        palette
  644. 1 word          speed (0 - 99; value is 99 - # vblanks to delay between frames)
  645. 1 word          direction (0 = forwards, 1 = backwards)
  646. 1 word          end action (what to do after the last frame)
  647.                 0 = pause, then repeat from beginning
  648.                 1 = immediately repeat from beginning
  649.                 2 = reverse (change direction)
  650. 1 word          width of film in pixels
  651. 1 word          height of film in pixels
  652. 1 word          Animatic version number (major) [< 2]
  653. 1 word          Animatic version number (minor)
  654. 1 long          magic number 27182818 (hex)
  655. 3 longs         reserved for expansion (should be all zeros)
  656. --------
  657. 32 words        total for header
  658.  
  659. ? words         image data (words of screen memory) for each frame, in order
  660.  
  661.  
  662. <Animaster Sprite Bank> *.ASB (low resolution only)
  663.  
  664. 1 word          number of frames - 1
  665. 1 word          ?
  666. 1 byte          maximum width, in pixels
  667. 1 byte          maximum height, in pixels
  668. 16 words        palette
  669. --------
  670. 38 bytes        total for header
  671.  
  672. For each frame {
  673. 1 word          width of this frame (in pixels) - 1
  674. 1 word          height of this frame (in pixels) - 1
  675. 1 word          ? 
  676. ? words         image data (words of screen memory)
  677. }
  678.  
  679.  
  680. <STOS>  *.MBK
  681.  
  682. 9 words         ?
  683. 1 long          $19861987 (magic number?)
  684. 1 long          offset from this long to header for low resolution 
  685.                 parameter block (if past end of file, no low res frames)
  686. 1 long          offset from this long to header for med resolution 
  687.                 parameter block (if past end of file, no med res frames)
  688. 1 long          offset from this long to header for high resolution 
  689.                 parameter block (if past end of file, no high res frames)
  690. 1 word          number of low resolution frames
  691. 1 word          number of medium resolution frames
  692. 1 word          number of high resolution frames
  693.  
  694. For each frame {
  695. 1 long          offset to data (probably only used internally by STOS)
  696. 1 byte          width in words (multiply by 16 to get width in pixels)
  697. 1 byte          height in pixels
  698. 1 byte          X hotspot location
  699. 1 byte          Y hotspot location
  700. }
  701.  
  702. (The format implies other stuff could be here.)
  703.  
  704. 1 long          ["PALT" $50414C54]
  705. 16 words        palette
  706.  
  707. ?               words of data for each frame, in the order mentioned in the
  708.                 header.  Monoplanar mask data follows image data for each frame.
  709. ----------
  710. ? words         total
  711.  
  712.    The frames often seem to be in semi-random order, not necessarily in 
  713. the order they are to be animated. 
  714.  
  715.  
  716. <GEM Bit Image> *.IMG
  717.  
  718. 1 word          version number of image file [1]
  719. 1 word          length of header in words [usually 8]
  720. 1 word          number of color planes [1 for monochrome]
  721. 1 word          pattern length in bytes [1-8, usually 2 for screen images]
  722. 1 word          pixel width in microns (1/1000 mm, 25400 microns per inch)
  723. 1 word          pixel height in microns
  724. 1 word          line width in pixels
  725. 1 word          number of lines
  726. -------
  727. ? words         header length defined in 2nd word of header
  728.  
  729. ? bytes         data
  730.  
  731. NOTES:  If the image is a color image (planes > 1), the planes are stored
  732. separately starting with plane 0.  There is, however, no standard way of
  733. storing the color palette.  Some programs may save the palette in separate
  734. files, some may extend the header.  For this reason, you should never
  735. assume the header is 8 words long, always get the header length from the
  736. 2nd word of the header.  Also, the line width in the 7th word is the number
  737. of pixels in a line.  Since the data is encoded in byte-wide packets, the
  738. actual unpacked line width is always a multiple of 8, and may be 1-7 pixels
  739. longer than the length specified in the header.
  740.  
  741. For each byte x in the data section,
  742.  
  743.         x = 0           Pattern/scanline run.
  744.                         Read the next byte, n (unsigned).
  745.  
  746.                         If n > 0 then:
  747.                                 Read a number of bytes equal to the "pattern
  748.                                 length" word in the header.  Repeat this
  749.                                 pattern n times.
  750.  
  751.                         If n = 0 then:
  752.                                 Scanline run.  Data for the next scanline
  753.                                 is to be used multiple times.  Read the
  754.                                 following record:
  755.  
  756.                                 1 byte          flag byte [$FF]
  757.                                 1 byte          number of times to use
  758.                                                 next scanline data
  759.  
  760.                                 The data for the next scanline follows,
  761.                                 compressed normally.
  762.  
  763.         x = 80 (hex)    Uncompressed bit string.  The next byte
  764.                         determines the number of bytes to use
  765.                         literally.  The literal data bytes follow.
  766.  
  767.         otherwise       Solid run.  The value of x determines
  768.                         what to draw.  The high bit specifies whether
  769.                         the pixels are set or cleared.  A 1 indicates
  770.                         a byte-run using $FF, a 0 indicates a byte-run
  771.                         using $00.  The low 7 bits, taken as an unsigned
  772.                         quantity, specify the length of the run in bytes.
  773.  
  774.  
  775. <GEM Metafile>  *.GEM
  776.  
  777. Marcel Boom <mboom@mswe.dnet.ms.philips.nl> recently sent me this
  778. format description.  I have reproduced it here, largely unchanged.
  779.  
  780. The file consists out of a header and the data records. The header has
  781. the following format:
  782.  
  783. word mf_header:         should be -1, which indicates a metafile
  784. word mf_hlength:        The length of the header part (usually 24 words)
  785. word mf_version:        Version number (usually 101)
  786. word mf_ndcrcfl:        0: NDC coordinates, 2: Raster coordinates
  787. word mf_extends1:       Optional, minimal used x coordinate
  788. word mf_extends2:       Optional, minimal used y coordinate
  789. word mf_extends3:       Optional, maximal used x coordinate
  790. word mf_extends4:       Optional, maximal used y coordinate
  791. word mf_width:          Optional, page width in 0.1 mm
  792. word mf_height:         Optional, page height in 0.1 mm
  793. word mf_coords1:        Optional, coordinate system param 1
  794. word mf_coords2:        Optional, coordinate system param 2
  795. word mf_coords3:        Optional, coordinate system param 3
  796. word mf_coords4:        Optional, coordinate system param 4
  797. word mf_imgflag:        0: No images, 1 contains bit images
  798. word mf_reserved1:      reserved.
  799. .
  800. .
  801. word mf_reserved9:      reserved.
  802.  
  803. After the header follows the data records of the following format:
  804.  
  805. word 0:                 VDI command number
  806. word 1:                 n: Number of parameters for ptsin array
  807. word 2:                 m: Number of parameters for intin array
  808. word 3:                 Subopcode
  809. word 4 to 4+n:          ptsin array
  810. word 4+n to 4+n+m:      intin array
  811.  
  812. A VDI command number of -1 signals the end of file.
  813.  
  814. VDI command numbers:
  815.    5:   Escape functions:
  816.         Subopcode:
  817.                 1:      Inquire addressable character cells
  818.                 2:      Exit alpha mode
  819.                 3:      Enter alpha mode
  820.                 20:     Form advance
  821.                 21:     Output window
  822.                 22:     Clear display list
  823.                 23:     Output bit image file
  824.                 98:     Update metafile extents
  825.                 99:     Write metafile item
  826.                 100:    Change GEM VDI filename
  827.     6:  Polyline
  828.     7:  Polymarker
  829.     8:  Text
  830.     9:  Filled area
  831.     11: GDP:
  832.         subopcode:
  833.                 1:      Bar
  834.                 2:      Arc
  835.                 3:      Pie
  836.                 4:      Circle
  837.                 5:      Ellipse
  838.                 6:      Elliptical arc
  839.                 7:      Elliptical Pie
  840.                 8:      Rounded rectangle
  841.                 9:      Filled rounded rectangle
  842.                 10:     Jutified graphic text
  843.     12: Set character height, absolute mode
  844.     13: Set character baseline vector
  845.     14: Set color representation
  846.     15: Set polyline linetype
  847.     16: Set polyline line width
  848.     17: Set polyline color index
  849.     18: Set polymarker type
  850.     19: Set polymarker height
  851.     20: Set polymarker color index
  852.     21: Set text face
  853.     22: Set graphic text color index
  854.     23: Set fill interior style
  855.     24: Set fill style index
  856.     25: Set fill color index
  857.     26: Inquire color representation    
  858.     32: Set writing mode
  859.     35: Inquire current polyline attributes
  860.     36: Inquire current polymarker attributes
  861.     37: Inquire current fill area attributes
  862.     38: Inquire current graphic text attributes
  863.     39: Set graphic text allignment
  864.     102: Extended inquire function
  865.     103: Countour fill
  866.     104: Set fill perimeter visibility
  867.     106: Set graphic text special effects
  868.     107: Set character cell height, points mode
  869.     108: Set polyline end styles
  870.     112: Set user defines fill pattern
  871.     113: Set user defined line style pattern
  872.     114: Fill rectangle
  873.     117: Inquire character cell width
  874.     129: Set clipping rectangle
  875.     131: Inquire current face information
  876.  
  877. The meaning of the arrays can be found in the several GEM programming books. 
  878.  
  879. NOTE: The word qualifier is not the Motorola word, but the Intel word,
  880. so high and low byte are swapped!
  881.  
  882.  
  883. <STAD>          *.PAC (high resolution only)
  884.  
  885. 4 bytes         "pM86" (vertically packed) or "pM85" (horizontally packed)
  886. 1 byte          id byte
  887. 1 byte          pack byte (most frequently occuring byte in bitmap)
  888. 1 byte          "special" byte
  889. -------
  890. 7 bytes         total for header
  891.  
  892. ? bytes         data
  893.  
  894. The data is encoded as follows.  For each byte x in the data section:
  895.  
  896.         x = id byte             Read one more byte, n.  Use pack byte 
  897.                                 n + 1 times.
  898.         x = "special" byte      Read two more bytes, d, and n (in order).
  899.                                 Use byte d n times.
  900.         otherwise               Use byte x literally.
  901.  
  902.  
  903. <Imagic Film/Picture>           *.IC1 (low resolution)
  904.                                 *.IC2 (medium resolution)
  905.                                 *.IC3 (high resolution)
  906.  
  907. 4 bytes         "IMDC"
  908. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  909. 16 words        palette
  910. 1 word          date (GEMDOS format)
  911. 1 word          time (GEMDOS format)
  912. 8 bytes         name of base picture file (for delta compression), or zeroes
  913. 1 word          length of data (?)
  914. 1 long          registration number
  915. 8 bytes         reserved
  916. 1 byte          compressed? (0 = no, 1 = yes)
  917.  
  918. If compressed {
  919. 1 byte          delta-compressed? (-1 = no, > -1 = yes)
  920. 1 byte          ?
  921. 1 byte          escape byte
  922. }
  923. -------
  924. 65 bytes        total for header (68 bytes if compressed)
  925.  
  926. ? bytes         data
  927.  
  928.    Compressed data may be either stand-alone or delta-compressed (relative
  929. to the base picture named in the header).  Delta compression involves
  930. storing only how the picture differs from the base picture (i.e., only
  931. portions of the screen that have changed are stored).  This is used to
  932. to encode animated sequences efficiently.
  933.  
  934. Compressed data, stand-alone:
  935.  
  936. For each byte x in the data section:
  937.  
  938.         x = escape byte         Read one more byte, n.  (n is unsigned).
  939.  
  940.                                 If n >= 2, use the next byte n times.
  941.                                 If n = 1, keep reading bytes until a
  942.                                 byte k not equal to 1 is encountered.
  943.                                 Then read the next byte d.
  944.                                 If the number of 1 bytes encountered is o,
  945.                                 use d (256 * o + k) times.  I.e.,
  946.  
  947.                                 if (n == 1) {
  948.                                         o = 0;
  949.                                         while (n == 1) {
  950.                                                 o++;
  951.                                                 n = next byte;
  952.                                         }
  953.  
  954.                                         k = n;
  955.                                         d = next byte;
  956.  
  957.                                         Use d (256 * o + k) times.
  958.                                 }
  959.                                 else {
  960.                                         d = next byte;
  961.                                         Use d (n) times.
  962.                                 }
  963.  
  964.         x != escape byte        Use x literally.
  965.  
  966. Compressed data, delta compressed:
  967.  
  968. For each byte x in the data section:
  969.  
  970.         x = escape byte         Read one more byte, n.  (n is unsigned).
  971.  
  972.                                 If n >= 3, use the next byte n times.
  973.                                 If n = 1, do the same as for n = 1 in
  974.                                 stand-alone compression (above).
  975.                                 If n = 2, then set n = next byte.
  976.                                         If n = 0, end of picture.
  977.                                         If n >= 2, take n bytes from base
  978.                                         picture.
  979.                                         If n = 1, do the same as for n = 1
  980.                                         in stand-alone compression (above),
  981.                                         but take (256 * o + k) bytes from 
  982.                                         base picture.
  983.  
  984.         x != escape byte        Use x literally.
  985.  
  986.  
  987. <IFF Format>    *.IFF
  988.  
  989. 4 bytes         "FORM" (FORM chunk ID)
  990. 1 long          length of file that follows
  991. 4 bytes         "ILBM" (InterLeaved BitMap file ID)
  992.  
  993. 4 bytes         "BMHD" (BitMap HeaDer chunk ID)
  994. 1 long          length of chunk [20]
  995. 20 bytes        1 word = image width in pixels
  996.                 1 word = image height in lines
  997.                 1 word = image x-offset [usually 0]
  998.                 1 word = image y-offset [usually 0]
  999.                 1 byte = # bitplanes
  1000.                 1 byte = mask (0=no, 1=impl., 2=transparent, 3=lasso)
  1001.                 1 byte = compressed [1] or uncompressed [0]
  1002.                 1 byte = unused [0]
  1003.                 1 word = transparent color (for mask=2)
  1004.                 1 byte = x-aspect [5=640x200, 10=320x200/640x400, 20=320x400]
  1005.                 1 byte = y-aspect [11]
  1006.                 1 word = page width (usually the same as image width)
  1007.                 1 word = page height (usually the same as image height)
  1008.  
  1009. 4 bytes         "CMAP" (ColorMAP chunk ID)
  1010. 1 long          length of chunk [3*n where n is the # colors]
  1011. 3n bytes        3 bytes per RGB color.  Each color value is a byte
  1012.                 and the actual color value is left-justified in the
  1013.                 byte such that the most significant bit of the value
  1014.                 is the MSB of the byte.  (ie. a color value of 15 ($0F)
  1015.                 is stored as $F0)  The bytes are stored in R,G,B order.
  1016.  
  1017. 4 bytes         "CRNG" (Color RaNGe chunk ID)
  1018. 1 long          length of chunk [8]
  1019. 8 bytes         1 word = reserved [0]
  1020.                 1 word = animation speed (16384 = 60 steps per second)
  1021.                 1 word = active [1] or inactive [0]
  1022.                 1 byte = left/lower color animation limit
  1023.                 1 byte = right/upper color animation limit
  1024.  
  1025. 4 bytes         "CAMG" (Commodore AMiGa viewport mode chunk ID)
  1026. 1 long          length of chunk [4]
  1027. 1 long          viewport mode bits (bit 11 = HAM, bit 3 = interlaced)
  1028.  
  1029. 4 bytes         "BODY" (BODY chunk ID)
  1030. 1 long          length of chunk [# bytes of image data that follow]
  1031. ? bytes         actual image data
  1032.  
  1033. NOTES: Some of these chunks may not be present in every IFF file, and may
  1034. not be in this order.  You should always look for the ID bytes to find a
  1035. certain chunk.  All chunk IDs are followed by a long value that tells the
  1036. size of the chunk (note that "ILBM" is not a chunk ID).  This is the number of
  1037. bytes that FOLLOW the 4 ID bytes and size longword.  The exception to this is
  1038. the FORM chunk.  The size longword that follows the FORM ID is the size of the
  1039. remainder of the file.  The FORM chunk must always be the first chunk in an
  1040. IFF file.
  1041.  
  1042. The R,G,B ranges of AMIGA and ST are different (AMIGA 0...15, ST 0...7),
  1043. as is the maximum number of bitplanes (AMIGA: 5, ST: 4).
  1044.  
  1045. Format of body data
  1046.  
  1047. An expanded picture is simply a bitmap.  The packing method is PackBits
  1048. (see below), and is identical to MacPaint and DEGAS Elite compressed.
  1049.  
  1050. The (decompressed) body data appears in the following order:
  1051.  
  1052.         line 1 plane 0 ... line 1 plane 1 ... ... line 1 plane m
  1053.         [line 1 mask (if appropriate)]
  1054.         line 2 plane 0 ... line 2 plane 1 ... ... line 2 plane m
  1055.         [line 2 mask (if appropriate)]
  1056.         ...
  1057.         line x plane 0 ... line x plane 1 ... ... line x plane m
  1058.         [line x mask (if appropriate)]
  1059.  
  1060. The FORM chunk identifies the type of data:
  1061.  
  1062.         "ILBM" = interleaved bit map
  1063.         "8SVX" = 8-bit sample voice
  1064.         "SMUS" = simple music score
  1065.         "FTXT" = formatted text (Amiga)
  1066.  
  1067.  
  1068. <MacPaint>      *.MAC
  1069.  
  1070. 1 long          version number [0=ignore header, 2=header valid]
  1071. 38 * 8 bytes    8x8 brush/fill patterns.  Each byte is a pattern row,
  1072.                 and the bytes map the pattern rows top to bottom.  The
  1073.                 patterns are stored in the order they appear at the bottom
  1074.                 of the MacPaint screen top to bottom, left to right.
  1075. 204 bytes       unused
  1076. -------------
  1077. 512 bytes       total for header
  1078.  
  1079. < 51200 bytes   compressed bitmap data
  1080. -------------
  1081. < 51712 bytes   total
  1082.  
  1083. NOTE:  The version number is actually a flag to MacPaint to indicate if
  1084. the brush/fill patterns are present in the file.  If the version is 0,
  1085. the default patterns are used.  Therefore you can simply save a MacPaint
  1086. file by writing a blank header (512 $00 bytes), followed by the packed
  1087. image data.
  1088.  
  1089. Bitmap compression:
  1090.  
  1091.    The bitmap data is for a 576 pixel by 720 pixel monochrome image.
  1092. The packing method is PackBits (see below).  There are 72 bytes per
  1093. scan line.  Each bit represents one pixel; 0 = white, 1 = black.
  1094.  
  1095.  
  1096. <RGB Intermediate Format>       *.RGB (low resolution only)
  1097.  
  1098.    This format was invented by Lars Michael to facilitate conversions between
  1099. standard ST picture formats and higher resolution formats like GIF and IFF.
  1100. It supports 12 bits of color resolution by keeping the red, green and blue
  1101. components in separate bit planes.
  1102.  
  1103. 1 word          resolution (ignored)
  1104. 16 word         palette (ignored)
  1105. 16000 words     red plane (screen memory)
  1106. 1 word          resolution (ignored)
  1107. 16 word         palette (ignored)
  1108. 16000 words     green plane (screen memory)
  1109. 1 word          resolution (ignored)
  1110. 16 word         palette (ignored)
  1111. 16000 words     blue plane (screen memory)
  1112. ------------
  1113. 96102 bytes     total
  1114.  
  1115. The format was derived by concatenating three DEGAS .PI1 files together -- 
  1116. one for each color gun.  The RGB value for a pixel is constructed by looking
  1117. at the appropriate pixel in the red plane, green plane, and blue plane.  The
  1118. bitplanes are in standard ST low resolution screen RAM format, but where pixel
  1119. values in screen RAM refer to palette entries (0 through 15), pixel values
  1120. here correspond to absolute R, G, and B values.  The red, green, and blue
  1121. components for each pixel range from 0 to 15 (4 bits), yielding a total of
  1122. 12 bits of color information per pixel.  Not coincidentally, this is exactly
  1123. the format of ST palette entries (although on ST's without the extended 
  1124. palette only the lower 3 bits of each color component are used).
  1125.  
  1126. You can view a single bit plane on a standard ST by splitting the .RGB file
  1127. into its three DEGAS .PI1 components and setting the palette to successively
  1128. brighter shades of gray.
  1129.  
  1130.  
  1131. <ComputerEyes Raw Data Format>  *.CE1 (low resolution)
  1132.                                 *.CE2 (medium resolution)
  1133.                                 
  1134. 1 long          [$45594553 or "EYES"]
  1135. 1 word          resolution [0 = low res, 1 = medium res]
  1136. 8 words         ?
  1137. If resolution = 0 {
  1138. 64000 bytes     red plane, 320 x 200, 1 pixel per byte
  1139. 64000 bytes     green plane, 320 x 200, 1 pixel per byte
  1140. 64000 bytes     blue plane, 320 x 200, 1 pixel per byte
  1141. ------------
  1142. 192022 bytes    total
  1143. else If resolution = 1 {
  1144. 128000 words    640 x 200, 1 pixel per word
  1145. ------------
  1146. 256022 bytes    total
  1147. }
  1148.  
  1149.    This is almost two formats in one:
  1150.    
  1151.         Low resolution:
  1152.  
  1153.            The planes are arranged vertically, instead of horizontally.
  1154.         The first byte is the red component of pixel (0,0), the second is (0,1),
  1155.         and the third (0,2).  The 201st corresponds to (1,0), etc.  The 64001st
  1156.         byte is the green component of (0,0).
  1157.            Only the low six bits of each byte are used.
  1158.  
  1159.         Medium resolution:
  1160.  
  1161.            The picture is arranged vertically, instead of horizontally.
  1162.         The first word is pixel (0,0), the second is (0,1), and the third
  1163.         (0,2).  The 200th is (1,0) etc.
  1164.            Each word is divided up into the RGB values for the corresponding
  1165.         pixel, as follows:
  1166.  
  1167.           Bit:  (MSB) 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 (LSB)
  1168.                       -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  1169.                        0 B4 B3 B2 B1 B0 G4 G3 G2 G1 G0 R4 R3 R2 R1 R0
  1170.  
  1171.         Bit 15 is not used.
  1172.  
  1173.  
  1174. <PackBits Compression Algorithm>
  1175.  
  1176. The following packing algorithm originated on the Mac, was adopted by
  1177. Electronic Arts/Commodore for use in the IFF standard, and then by Tom
  1178. Hudson for use in DEGAS Elite.  The algorithm is currently used in
  1179. MacPaint, IFF, and DEGAS Elite compressed file formats.  Each scan line
  1180. is packed separately, and packing never extends beyond a scan line.
  1181.  
  1182. For a given control byte 'n':
  1183.     0 <= n <= 127   : use the next n + 1 bytes literally (no repetition).
  1184.  -127 <= n <= -1    : use the next byte -n + 1 times.
  1185.          n = -128   : no operation, not used.
  1186.  
  1187. -------------------------------------------------------------------------
  1188.  
  1189. * Roland Waldi contributed extensive information on the following formats:
  1190.  
  1191.         GEM, IMG, Doodle, STAD, Imagic Film/Picture, Art Director, IFF
  1192.  
  1193. ** John Brochu, ST picture formats guru, provided sage advice and many
  1194.    corrections to the following formats:
  1195.  
  1196.         NeoChrome, DEGAS Elite Compressed, Spectrum 512 Compressed,
  1197.         GEM Bit Image, IFF, MacPaint
  1198.  
  1199. Version of...........Wed Mar 31 12:17:26 EST 1993
  1200. (Last change: GEM format decription added)
  1201.  
  1202.