Changes between Initial Version and Version 1 of Develop/FileFormats/Atari


Ignore:
Timestamp:
Oct 8, 2016, 1:36:40 PM (8 years ago)
Author:
pulkomandy
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Develop/FileFormats/Atari

    v1 v1  
     1This is a copy of the document "ST Picture Formats" : [http://www.umich.edu/~archive/atari/Graphics/picfmts.doc picfmts.doc]
     2
     3We use it as a reference for implementing NEOchrome images support.
     4
     5The original document is enclosed in tags to prevent wiki formatting, but otherwise unmodified.
     6
     7{{{
     8                           ST Picture Formats
     9                           ------------------
     10                               Edited by:
     11
     12                              David Baggett
     13                         5640 Vantage Point Road
     14                         Columbia, MD  21044 USA
     15                             (301)  596-4779   
     16                          (usenet: dmb@TIS.COM)
     17
     18                   (Please report errors or additions.)
     19
     20        Copyright (C) 1988, 1989, 1990, 1991 by David M. Baggett
     21
     22
     23    Non-profit redistribution of this document is permitted, provided
     24    the document is not modified in any way.
     25
     26    Reproduction of this document in whole or in part for  commercial
     27    purposes is expressly forbidden without the prior written consent
     28    of David M. Baggett.
     29
     30    The  information  presented here is not guaranteed to be correct.
     31    The editor and contributors will in no event be liable for direct,
     32    indirect, incidental, or consequential damages resulting from the
     33    use of the information in this document.
     34
     35    This document is the product of many hours of volunteer work by a
     36    large number of people. Please respect this -- do not violate the
     37    distribution policy.
     38
     39
     40                              CONTRIBUTORS
     41 
     42    Steve Belczyk  Phil Blanchfield  Jason Blochowiak  John Brochu**
     43       David Brooks  Daniel Deimert  Neil Forsyth   Stefan Hoehn 
     44        Gerfried Klein   Ken MacLeod  Jim McCabe  Darek Mihocka   
     45         David Mumper   George Nassas   George Seto  Joe Smith 
     46              Greg Wageman   Roland Waldi*  Gerry Wheeler
     47
     48
     49                                Contents
     50                                --------
     51
     52        NEOchrome                               *.NEO
     53        NEOchrome Animation                     *.ANI
     54        DEGAS                                   *.PI?   ? = 1, 2, 3
     55        DEGAS Elite                             *.PI?   ? = 1, 2, 3
     56        DEGAS Elite (Compressed)                *.PC?   ? = 1, 2, 3
     57        Tiny                                    *.TN?   ? = 1, 2, 3, Y
     58        Spectrum 512                            *.SPU
     59        Spectrum 512 (Compressed)               *.SPC
     60        Art Director                            *.ART
     61        C.O.L.R. Object Editor Mural            *.MUR
     62        Doodle                                  *.DOO
     63        Animatic Film                           *.FLM
     64        GEM Bit Image                           *.IMG
     65        STAD                                    *.PAC
     66        Imagic Film/Picture                     *.IC?   ? = 1, 2, 3
     67        IFF                                     *.IFF
     68        MacPaint                                *.MAC
     69        PackBits Compression Algorithm
     70 
     71
     72                        Introductory Information
     73                        ------------------------
     74word    = 2 bytes
     75long    = 4 bytes
     76palette = Hardware color palette, stored as 16 words.  First word is
     77          color register zero (background), last word is color register
     78          15.  Each word has the form:
     79
     80          Bit:  (MSB) 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 (LSB)
     81                      -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
     82                       0  0  0  0  0 R2 R1 R0  0 G2 G1 G0  0 B2 B1 B0
     83
     84          R2 = MSB of red intensity
     85          R0 = LSB of red intensity
     86
     87          G2 = MSB of green intensity
     88          G0 = LSB of green intensity
     89
     90          B2 = MSB of blue intensity
     91          B0 = LSB of blue intensity
     92
     93          Intensity ranges from 0 (color not present) to 7 (highest
     94          intensity).
     95
     96          Example: { red = 7, green = 3, blue = 5 } -> 0735 (hex)
     97
     98          Caveat:  It is wise to mask off the upper four bits of each
     99                   palette entry, since a few programs store special
     100                   information there (most notably Art Studio).
     101
     102
     103                             The Formats
     104                             -----------
     105
     106<NEOchrome>     *.NEO
     107 
     1081 word          flag byte [always 0]
     1091 word          resolution [0 = low res, 1 = medium res, 2 = high res]
     11016 words        palette
     11112 bytes        filename [usually "        .   "]
     1121 word          color animation limits.  High bit (bit 15) set if color
     113                animation data is valid.  Low byte contains color animation
     114                limits (4 most significant bits are left/lower limit,
     115                4 least significant bits are right/upper limit).
     1161 word          color animation speed and direction.  High bit (bit 15) set
     117                if animation is on.  Low order byte is # vblanks per step.
     118                If negative, scroll is left (decreasing).  Number of vblanks
     119                between cycles is |x| - 1
     1201 word          # of color steps (as defined in previous word) to display
     121                picture before going to the next.  (For use in slide shows)
     1221 word          image X offset [unused, always 0]
     1231 word          image Y offset [unused, always 0]
     1241 word          image width [unused, always 320]
     1251 word          image height [unused, always 200]
     12633 words        reserved for future expansion
     12716000 words     picture data (screen memory)
     128-----------
     12932128 bytes     total
     130 
     131
     132<NEOchrome Animation>        *.ANI
     133
     134NOTE:      To get this feature on versions 0.9 and later select the Grabber
     135        icon and click both mouse buttons in the eye of the second R in the
     136        word GRABBER.
     137           Interestingly enough, some versions of NEO only require you
     138        to press the right button, not both.  Hmmm...
     139
     1401 long          magic number BABEEBEA (hex) (seems to be ignored)
     1411 word          width of image in bytes (always divisible by 8)
     1421 word          height of image in scan lines
     1431 word          size of image in bytes + 10 (!)
     1441 word          x coordinate of image (must be divisible by 16) - 1
     1451 word          y coordinate of image - 1
     1461 word          number of frames
     1471 word          animation speed (# vblanks to delay between frames)
     1481 long          reserved; should be zero
     149--------
     15022 bytes        total for header
     151
     152? words         image data (words of screen memory) for each frame, in
     153                order
     154
     155
     156<DEGAS>         *.PI1 (low resolution)
     157                *.PI2 (medium resolution)
     158                *.PI3 (high resolution)
     159
     1601 word          resolution (0 = low res, 1 = medium res, 2 = high res)
     161                Other bits may be used in the future; use a simple bit
     162                test rather than checking for specific word values.
     16316 words        palette
     16416000 words     picture data (screen memory)
     165-----------
     16632034 bytes     total
     167
     168
     169<DEGAS Elite>   *.PI1 (low resolution)
     170                *.PI2 (medium resolution)
     171                *.PI3 (high resolution)
     172
     1731 word          resolution (0 = low res, 1 = medium res, 2 = high res)
     174                Other bits may be used in the future; use a simple bit
     175                test rather than checking for specific word values.
     17616 words        palette
     17716000 words     picture data (screen memory)
     1784 words         left color animtion limit table (starting color numbers)
     1794 words         right color animation limit table (ending color numbers)
     1804 words         animation channel direction flag (0 = left, 1 = off, 2 = right)
     1814 words         128 - animation channel delay in 1/60's of a second. [0 - 128]
     182                (I.e., subtract word from 128 to get 1/60th's of a second.)
     183-----------
     18432066 bytes     total
     185
     186
     187<DEGAS Elite (Compressed)>      *.PC1 (low resolution)
     188                                *.PC2 (medium resolution)
     189                                *.PC3 (high resolution)
     190 
     1911 word          resolution (same as Degas, but high order bit is set;
     192                i.e., hex 8000 = low res, hex 8001 = medium res,
     193                hex 8002 = high res).  Other bits may be used in the
     194                future; use a simple bit test rather than checking
     195                for specific word values.
     19616 words        palette
     197< 32000 bytes   control/data bytes
     1984 words         left color animation limit table (starting color numbers)
     1994 words         right color animation limit table (ending color numbers)
     2004 words         animation channel direction flag [0 = left, 1 = off, 2 = right]
     2014 words         128 - animation channel delay in 1/60's of a second. [0 - 128]
     202                (I.e., subtract word from 128 to get 1/60th's of a second.)
     203-----------
     204< 32066 bytes   total
     205 
     206Compression Scheme:
     207 
     208   PackBits compression is used (see below).  Each scan line is compressed
     209separately; i.e., all data for a given scan line appears before any data
     210for the next scan line.  The scan lines are specified from top to bottom
     211(i.e., 0 is first).  For each scan line, all the data for a given bit plane
     212appears before any data for the next higher order bit plane.  Note this is
     213identical to the IFF 'BODY' image data.
     214   To clarify:  The first data in the file will be the data for the lowest
     215order bit plane of scan line zero, followed by the data for the next higher
     216order bit plane of scan line zero, etc., until all bit planes have been
     217specified for scan line zero.  The next data in the file will be the data
     218for the lowest order bit plane of scan line one, followed by the data for
     219the next higher order bit plane of scan line one, etc., until all bit planes
     220have been specified for all scan lines.
     221 
     222Caveats:
     223 
     224   DEGAS Elite's picture loading routine places some restrictions on
     225compressed DEGAS files:
     226 
     227        o Elite uses a 40-byte buffer to store data being decompressed.
     228 
     229        o Whenever a control command is encountered, bytes are stuffed
     230        in this buffer.
     231 
     232        o The buffer is only emptied when there are EXACTLY 40
     233        characters in it.
     234 
     235The important conclusion here is that
     236 
     237        No control command may cause the buffer to have more than 40
     238        bytes in it.  In other words, all control commands must end on
     239        or before the 40-byte boundary.
     240 
     241Any picture violating the last condition will cause Elite to get a bus
     242error when the picture is loaded.
     243 
     244
     245<Tiny>  *.TNY (any resolution)
     246        *.TN1 (low resolution)
     247        *.TN2 (medium resolution)
     248        *.TN3 (high resolution)
     249
     250   Several people have reported sightings of mutated Tiny pictures that
     251do not follow the standard format, so let's be careful out there.  What
     252is described here is the format that David Mumper's original
     253TNYSTUFF.PRG produces.
     254
     2551 byte          resolution (same as NEO, but +3 indicates rotation
     256                information also follows)
     257
     258If resolution > 2 {
     2591 byte          left and right color animation limits.  High 4 bits
     260                hold left (start) limit; low 4 bits hold right (end)
     261                limit
     2621 byte          direction and speed of color animation (negative value
     263                indicates left, positive indicates right, absolute value
     264                is delay in 1/60's of a second.
     2651 word          color rotation duration (number of iterations)
     266}
     267
     26816 words        palette
     2691 word          number of control bytes
     2701 word          number of data words
     2713-10667 bytes   control bytes
     2721-16000 words   data words
     273-------------
     27442-32044 bytes  total
     275
     276Control byte meanings:
     277
     278        For a given control byte, x:
     279
     280        x < 0   Absolute value specifies the number of unique words to
     281                take from the data section (from 1 to 127)
     282        x = 0   1 word is taken from the control section which specifies
     283                the number of times to repeat the next data word (from
     284                128 to 32767)
     285        x = 1   1 word is taken from the control section which specifies
     286                the number of unique words to be taken from the data
     287                section (from 128 - 32767)
     288        x > 1   Specifies the number of times to repeat the next word
     289                taken from the data section (from 2 to 127)
     290
     291Format of expanded data:
     292
     293   The expanded data is not simply screen memory bitmap data; instead, the
     294data is divided into four sets of vertical columns.  (This results in
     295better compression.)  A column consists of one specific word taken
     296from each scan line, going from top to bottom.  For example, column 1
     297consists of word 1 on scanline 1 followed by word 1 on scanline 2, etc.,
     298followed by word 1 on scanline 200.
     299   The columns appear in the following order:
     300
     301   1st set contains columns 1, 5,  9, 13, ..., 69, 73, 77 in order
     302   2nd set contains columns 2, 6, 10, 14, ..., 70, 74, 78 in order
     303   3rd set contains columns 3, 7, 11, 15, ..., 71, 75, 79 in order
     304   4th set contains columns 4, 8, 12, 16, ..., 72, 76, 80 in order
     305
     306Note that Tiny partitions the screen this way regardless of resolution; i.e.,
     307these aren't bitplanes.  For example, medium resoltion only has two bitplanes,
     308but Tiny still divides medium resolution pictures into four parts.
     309
     310
     311<Spectrum 512>  *.SPU
     312
     31380 words        first scan line of picture (unused) -- should be zeroes
     31415920 words     picture data (screen memory) for scan lines 1 through 199
     3159552 words      3 palettes for each scan line (the top scan line is
     316                not included because Spectrum 512 can't display it)
     317-----------
     31851104 bytes     total
     319
     320Note that the Spectrum 512 mode's three palette changes per scan
     321line allow more colors on the screen than normally possible, but a
     322tremendous amount of CPU time is required to maintain the image.
     323
     324The Spectrum format specifies a palette of 48 colors for each scan line.
     325To decode a Spectrum picture, one must be know which of these 48 colors
     326are in effect for a given horizontal pixel position.
     327
     328Given an x-coordinate (from 0 to 319) and a color index (from 0 to 15),
     329the following C function will return the proper index into the Spectrum
     330palette (from 0 to 47):
     331
     332/*
     333 *  Given an x-coordinate and a color index, returns the corresponding
     334 *  Spectrum palette index.
     335 *
     336 *  by Steve Belczyk; placed in the public domain December, 1990.
     337 */
     338int
     339FindIndex(x, c)
     340        int x, c;
     341{
     342        int x1;
     343
     344        x1 = 10 * c;
     345
     346        if (1 & c)              /* If c is odd */
     347                x1 = x1 - 5;
     348        else                    /* If c is even */
     349                x1 = x1 + 1;
     350
     351        if (x >= x1 && x < x1 + 160)
     352                c = c + 16;
     353        else if (x >= x1 + 160)
     354                c = c + 32;
     355
     356        return c;
     357}
     358
     359
     360<Spectrum 512 (Compressed)>        *.SPC
     361 
     3621 word          flag word [$5350 or "SP"]
     3631 word          reserved for future use [always 0]
     3641 long          length of data bit map
     3651 long          length of color bit map
     366<= 32092 bytes  compressed data bit map
     367<= 17910 bytes  compressed color bit map
     368--------------
     369<= 50014 bytes   total
     370 
     371Data compression:
     372 
     373   Compression is via a modified run length encoding (RLE) scheme,
     374similar to DEGAS compressed and Tiny.  The data map is stored as a
     375sequence of records.  Each record consists of a header byte followed by
     376one or more data bytes.  The meaning of the header byte is as follows:
     377 
     378        For a given header byte, x:
     379 
     380           0 <= x <= 127   Use the next x + 1 bytes literally (no repetition)
     381        -128 <= x <=  -1   Use the next byte -x + 2 times
     382 
     383The data appears in the following order:
     384 
     385        1. Picture data, bit plane 0, scan lines 1 - 199
     386        2. Picture data, bit plane 1, scan lines 1 - 199
     387        3. Picture data, bit plane 2, scan lines 1 - 199
     388        4. Picture data, bit plane 3, scan lines 1 - 199
     389 
     390Decompression of data ends when 31840 data bytes have been used.
     391 
     392Color map compression:
     393 
     394   Each 16-word palette is compressed separately.  There are three
     395palettes for each scan line (597 total).  The color map is stored as a
     396sequence of records.  Each record starts with a 1-word bit vector which
     397specifies which of the 16 palette entries are included in the data
     398following the bit vector (1 = included, 0 = not included).  If a palette
     399entry is not included, it is assumed to be zero (black).  The least
     400significant bit of the bit vector refers to palette entry zero, while the
     401most significant bit refers to palette entry 15.  Bit 15 must be zero,
     402since Spectrum 512 does not use palette entry 15.  Bit 0 should also be
     403zero, since Spectrum 512 always makes the background color black.
     404   The words specifying the values for the palette entries indicated in
     405the bit vector follow the bit vector itself, in order (0 - 15).
     406
     407
     408<Art Director>  *.ART (low resolution only)
     409
     41016000 words     picture data (screen memory)
     41116 words        palette
     41215 * 16 words   15 more palettes for animation
     413-------------
     41432512 bytes     total
     415
     416
     417<C.O.L.R. Object Editor Mural>        *.MUR (low resolution only)
     418
     41916000 words     picture data (screen memory)
     420                (palettes are stored in separate files)
     421-----------
     42232000 bytes     total
     423
     424
     425<Doodle>        *.DOO (high resolution only)
     426
     42716000 words     picture data (screen memory)
     428-----------
     42932000 bytes     total
     430
     431
     432<Animatic Film> *.FLM (low resolution only)
     433
     4341 word          number of frames
     43516 words        palette
     4361 word          speed (0 - 99; value is 99 - # vblanks to delay between frames)
     4371 word          direction (0 = forwards, 1 = backwards)
     4381 word          end action (what to do after the last frame)
     439                0 = pause, then repeat from beginning
     440                1 = immediately repeat from beginning
     441                2 = reverse (change direction)
     4421 word          width of film in pixels
     4431 word          height of film in pixels
     4441 word          Animatic version number (major)
     4451 word          Animatic version number (minor)
     4461 long          magic number 27182818 (hex)
     4473 longs         reserved for expansion (should be all zeros)
     448--------
     44932 words        total for header
     450
     451? words         image data (words of screen memory) for each frame, in order
     452
     453
     454<GEM Bit Image> *.IMG
     455 
     4561 word          version number of image file [1]
     4571 word          length of header in words [usually 8]
     4581 word          number of color planes [1 for monochrome]
     4591 word          pattern length in bytes [1-8, usually 2 for screen images]
     4601 word          pixel width in microns (1/1000 mm, 25400 microns per inch)
     4611 word          pixel height in microns
     4621 word          line width in pixels
     4631 word          number of lines
     464-------
     465? words         header length defined in 2nd word of header
     466 
     467? bytes         data
     468 
     469NOTES:  If the image is a color image (planes > 1), the planes are stored
     470separately starting with plane 0.  There is, however, no standard way of
     471storing the color palette.  Some programs may save the palette in separate
     472files, some may extend the header.  For this reason, you should never
     473assume the header is 8 words long, always get the header length from the
     4742nd word of the header.  Also, the line width in the 7th word is the number
     475of pixels in a line.  Since the data is encoded in byte-wide packets, the
     476actual unpacked line width is always a multiple of 8, and may be 1-7 pixels
     477longer than the length specified in the header.
     478
     479For each byte x in the data section,
     480 
     481        x = 0           Pattern/scanline run.
     482                        Read the next byte, n (unsigned).
     483 
     484                        If n > 0 then:
     485                                Read a number of bytes equal to the "pattern
     486                                length" word in the header.  Repeat this
     487                                pattern n times.
     488 
     489                        If n = 0 then:
     490                                Scanline run.  Data for the next scanline
     491                                is to be used multiple times.  Read the
     492                                following record:
     493 
     494                                1 byte          flag byte [$FF]
     495                                1 byte          number of times to use
     496                                                next scanline data
     497 
     498                                The data for the next scanline follows,
     499                                compressed normally.
     500 
     501        x = 80 (hex)    Uncompressed bit string.  The next byte
     502                        determines the number of bytes to use
     503                        literally.  The literal data bytes follow.
     504 
     505        otherwise       Solid run.  The value of x determines
     506                        what to draw.  The high bit specifies whether
     507                        the pixels are set or cleared.  A 1 indicates
     508                        a byte-run using $FF, a 0 indicates a byte-run
     509                        using $00.  The low 7 bits, taken as an unsigned
     510                        quantity, specify the length of the run in bytes.
     511 
     512
     513<STAD>          *.PAC (high resolution only)
     514
     5154 bytes         "pM86" (vertically packed) or "pM85" (horizontally packed)
     5161 byte          id byte
     5171 byte          pack byte (most frequently occuring byte in bitmap)
     5181 byte          "special" byte
     519-------
     5207 bytes         total for header
     521
     522? bytes         data
     523
     524The data is encoded as follows.  For each byte x in the data section:
     525
     526        x = id byte             Read one more byte, n.  Use pack byte
     527                                n + 1 times.
     528        x = "special" byte      Read two more bytes, d, and n (in order).
     529                                Use byte d n times.
     530        otherwise               Use byte x literally.
     531
     532
     533<Imagic Film/Picture>           *.IC1 (low resolution)
     534                                *.IC2 (medium resolution)
     535                                *.IC3 (high resolution)
     536
     5374 bytes         "IMDC"
     5381 word          resolution (0 = low res, 1 = medium res, 2 = high res)
     53916 words        palette
     5401 word          date (GEMDOS format)
     5411 word          time (GEMDOS format)
     5428 bytes         name of base picture file (for delta compression), or zeroes
     5431 word          length of data (?)
     5441 long          registration number
     5458 bytes         reserved
     5461 byte          compressed? (0 = no, 1 = yes)
     547
     548If compressed {
     5491 byte          delta-compressed? (-1 = no, > -1 = yes)
     5501 byte          ?
     5511 byte          escape byte
     552}
     553-------
     55465 bytes        total for header (68 bytes if compressed)
     555
     556? bytes         data
     557
     558   Compressed data may be either stand-alone or delta-compressed (relative
     559to the base picture named in the header).  Delta compression involves
     560storing only how the picture differs from the base picture (i.e., only
     561portions of the screen that have changed are stored).  This is used to
     562to encode animated sequences efficiently.
     563
     564Compressed data, stand-alone:
     565
     566For each byte x in the data section:
     567
     568        x = escape byte         Read one more byte, n.  (n is unsigned).
     569
     570                                If n >= 2, use the next byte n times.
     571                                If n = 1, keep reading bytes until a
     572                                byte k not equal to 1 is encountered.
     573                                Then read the next byte d.
     574                                If the number of 1 bytes encountered is o,
     575                                use d (256 * o + k) times.  I.e.,
     576
     577                                if (n == 1) {
     578                                        o = 0;
     579                                        while (n == 1) {
     580                                                o++;
     581                                                n = next byte;
     582                                        }
     583
     584                                        k = n;
     585                                        d = next byte;
     586
     587                                        Use d (256 * o + k) times.
     588                                }
     589                                else {
     590                                        d = next byte;
     591                                        Use d (n) times.
     592                                }
     593
     594        x != escape byte        Use x literally.
     595
     596Compressed data, delta compressed:
     597
     598For each byte x in the data section:
     599
     600        x = escape byte         Read one more byte, n.  (n is unsigned).
     601
     602                                If n >= 3, use the next byte n times.
     603                                If n = 1, do the same as for n = 1 in
     604                                stand-alone compression (above).
     605                                If n = 2, then set n = next byte.
     606                                        If n = 0, end of picture.
     607                                        If n >= 2, take n bytes from base
     608                                        picture.
     609                                        If n = 1, do the same as for n = 1
     610                                        in stand-alone compression (above),
     611                                        but take (256 * o + k) bytes from
     612                                        base picture.
     613
     614        x != escape byte        Use x literally.
     615
     616
     617<IFF Format>    *.IFF
     618 
     6194 bytes         "FORM" (FORM chunk ID)
     6201 long          length of file that follows
     6214 bytes         "ILBM" (InterLeaved BitMap file ID)
     622
     6234 bytes         "BMHD" (BitMap HeaDer chunk ID)
     6241 long          length of chunk [20]
     62520 bytes        1 word = image width in pixels
     626                1 word = image height in lines
     627                1 word = image x-offset [usually 0]
     628                1 word = image y-offset [usually 0]
     629                1 byte = # bitplanes
     630                1 byte = mask (0=no, 1=impl., 2=transparent, 3=lasso)
     631                1 byte = compressed [1] or uncompressed [0]
     632                1 byte = unused [0]
     633                1 word = transparent color (for mask=2)
     634                1 byte = x-aspect [5=640x200, 10=320x200/640x400, 20=320x400]
     635                1 byte = y-aspect [11]
     636                1 word = page width (usually the same as image width)
     637                1 word = page height (usually the same as image height)
     638
     6394 bytes         "CMAP" (ColorMAP chunk ID)
     6401 long          length of chunk [3*n where n is the # colors]
     6413n bytes        3 bytes per RGB color.  Each color value is a byte
     642                and the actual color value is left-justified in the
     643                byte such that the most significant bit of the value
     644                is the MSB of the byte.  (ie. a color value of 15 ($0F)
     645                is stored as $F0)  The bytes are stored in R,G,B order.
     646
     6474 bytes         "CRNG" (Color RaNGe chunk ID)
     6481 long          length of chunk [8]
     6498 bytes         1 word = reserved [0]
     650                1 word = animation speed (16384 = 60 steps per second)
     651                1 word = active [1] or inactive [0]
     652                1 byte = left/lower color animation limit
     653                1 byte = right/upper color animation limit
     654
     6554 bytes         "CAMG" (Commodore AMiGa viewport mode chunk ID)
     6561 long          length of chunk [4]
     6571 long          viewport mode bits (bit 11 = HAM, bit 3 = interlaced)
     658
     6594 bytes         "BODY" (BODY chunk ID)
     6601 long          length of chunk [# bytes of image data that follow]
     661? bytes         actual image data
     662 
     663NOTES: Some of these chunks may not be present in every IFF file, and may
     664not be in this order.  You should always look for the ID bytes to find a
     665certain chunk.  All chunk IDs are followed by a long value that tells the
     666size of the chunk.  This is the number of bytes that FOLLOW the 4 ID bytes
     667and size longword.  The exception to this is the FORM chunk.  The size
     668longword that follows the FORM ID is the size of the remainder of the file.
     669The FORM chunk must always be the first chunk in an IFF file.
     670
     671The R,G,B ranges of AMIGA and ST are different (AMIGA 0...15, ST 0...7),
     672as is the maximum number of bitplanes (AMIGA: 5, ST: 4).
     673
     674Format of body data
     675 
     676An expanded picture is simply a bitmap.  The packing method is PackBits
     677(see below), and is identical to MacPaint and DEGAS Elite compressed.
     678 
     679The (decompressed) body data appears in the following order:
     680 
     681        line 1 plane 0 ... line 1 plane 1 ... ... line 1 plane m
     682        [line 1 mask (if appropriate)]
     683        line 2 plane 0 ... line 2 plane 1 ... ... line 2 plane m
     684        [line 2 mask (if appropriate)]
     685        ...
     686        line x plane 0 ... line x plane 1 ... ... line x plane m
     687        [line x mask (if appropriate)]
     688 
     689The FORM chunk identifies the type of data:
     690 
     691        "ILBM" = interleaved bit map
     692        "8SVX" = 8-bit sample voice
     693        "SMUS" = simple music score
     694        "FTXT" = formatted text (Amiga)
     695 
     696
     697<MacPaint>      *.MAC
     698 
     6991 long          version number [0=ignore header, 2=header valid]
     70038 * 8 bytes    8x8 brush/fill patterns.  Each byte is a pattern row,
     701                and the bytes map the pattern rows top to bottom.  The
     702                patterns are stored in the order they appear at the bottom
     703                of the MacPaint screen top to bottom, left to right.
     704204 bytes       unused
     705-------------
     706512 bytes       total for header
     707
     708< 51200 bytes   compressed bitmap data
     709-------------
     710< 51712 bytes   total
     711 
     712NOTE:  The version number is actually a flag to MacPaint to indicate if
     713the brush/fill patterns are present in the file.  If the version is 0,
     714the default patterns are used.  Therefore you can simply save a MacPaint
     715file by writing a blank header (512 $00 bytes), followed by the packed
     716image data.
     717
     718Bitmap compression:
     719 
     720   The bitmap data is for a 576 pixel by 720 pixel monochrome image.
     721The packing method is PackBits (see below).  There are 72 bytes per
     722scan line.  Each bit represents one pixel; 0 = white, 1 = black.
     723 
     724
     725<PackBits Compression Algorithm>
     726
     727The following packing algorithm originated on the Mac, was adopted by
     728Electronic Arts/Commodore for use in the IFF standard, and then by Tom
     729Hudson for use in DEGAS Elite.  The algorithm is currently used in
     730MacPaint, IFF, and DEGAS Elite compressed file formats.  Each scan line
     731is packed separately, and packing never extends beyond a scan line.
     732
     733For a given control byte 'n':
     734    0 <= n <= 127   : use the next n + 1 bytes literally (no repetition).
     735 -127 <= n <= -1    : use the next byte -n + 1 times.
     736         n = -128   : no operation, not used.
     737
     738-------------------------------------------------------------------------
     739
     740* Roland Waldi contributed extensive information on the following formats:
     741
     742        GEM, IMG, Doodle, STAD, Imagic Film/Picture, Art Director, IFF
     743
     744** John Brochu, ST picture formats guru, provided sage advice and many
     745   corrections to the following formats:
     746
     747        NeoChrome, DEGAS Elite Compressed, Spectrum 512 Compressed,
     748        GEM Bit Image, IFF, MacPaint
     749
     750Version of Wed Dec 19 11:20:55 EST 1990
     751Cosmetic changes Tue Jan 29 00:17:51 EST 1991
     752}}}