home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI04.ARJ / ictari.04 / MISC / PIC_FMTS / PIC.TXT
Text File  |  1992-10-02  |  45KB  |  1,101 lines

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