[comp.sys.m6809] GF9 Graphics/Animation File

jimomura@lsuc.UUCP (12/05/87)

/* GF9 revision 87/12/05
 * Public Domain

Changes since last distribution:

     Completely remapped to use *only* 16 bit word
and 32 bit long word data types.  Also based on
128 byte main header.  Slightly re-ordered.

     Header Length variable included.

     The Color Cycling speed is now expressed in the
same grades as the display duration.

     Color Cycling speed also indicates cycling
direction.

     A second set of Color Cycling registers has
 been allocated.
 
 ************************************************

TITLE: Proposal for Graphics File Format Standard
For OS-9 / Color Computer Users

     I've been waiting for a while now for some sort of standard
to arise, but nothing has happened.  As such, this is what I'm
going to use for now.  If something better comes along, I state
right now that I intend to abandon this format.  But I'll
only do so if there is an alternative which looks to be better
than this.  I don't like the idea of wasting my efforts, but
I believe more strongly in establishing standards which are
useful in the industry generally.  So if I drop this without
"a fight" that's why.

Proposed Name :

     I've arbitrarily called it 'GF9' for Graphics Format 9.
Files need not use this as an extension, but it wouldn't hurt
if you did.

The Header Format:

     The normal header is 128 bytes which are, for the most, to be
thought of as 64 "words" (16 bit), some of which are combined into
32 bit "long words".  Byte order is Motorola.  The most significant
byte if first, followed by the next most significant byte, and so
on.  These 64 words make up the header.  There is no "tail" or
trailing information defined at this time.

Offset in Bytes:

0x00 - 1    Header Length.  Currently only 128 byte headers
            are used, so 0x00 == 0 and 0x01 == 0x80

0x02 - 5    File length.  This is the number of bytes of
            actual picture data, not including the header.  If
            the file is 5000 bytes of picture data and 64 bytes
            of header, the total file will be 5064 bytes.

            0 Length Files

            A frame file which is delta'd and having no data
            changes from the previous frame may be stored as
            a header with 0 data. This may occasionally prove
            useful.  With the variability of display duration,
            it is not likely to be *very* useful.  However,
            it might be valuable during development and
            also for special usage of the color pallette.

       For the sake of portability with other computers
       the file length is specified as a "long" to be used
       as an unsigned integer value.  I don't feel that this
       format will be a truly *universal* format because such
       universality is very inefficent, but there might be some
       value in using this file format with some relatively
       similar machines.  Where it looks like an undue amount
       of time might be wasted in catering to other machines,
       I'll opt to support the CoCo3 and other users will
       be best advised to consider using the basic concepts
       of this format design, but not to worry about compati-
       bility.  In particular, using the 16 bit and 32 bit
       data sizes exclusively should make it possible for the
       programmer to do a mass conversion of byte order, with
       some later word-order rearranging where necessary
       on Intel byte order machines.  This wastes data on
       the CoCo3, but isn't unreasonable.  However, the
       Motorola byte order is maintained to save the CoCo3
       users the time needed for the conversion.

0x06 - 7    Screen mode class.

            0  Old Color Computer
            1  CoCo3 Alphanumerics
            2  CoCo3  Graphics modes

0x08 - 9    The 2nd byte is a submode.

            For mode 0 they are:

            0  Alphanumerics
            1  Inverted Alphanumerics
            2  SemiGraphics - 4
            3  64 * 64 Color Graphics
            4  128 * 64 Graphics
            5  128 * 64 Color Graphics
            6  128 * 96 Graphics
            7  128 * 96 Color Graphics
            8  128 * 192 Graphics
            9  128 * 192 Color Graphics
            0x0a  128 * 256 Graphics

            For mode 1 they are:

            0  32 char.
            1  40 char.
            2  80 char.

            For mode 2 they are:

            0  160 * 16
            1  256 * 2
            3  256 * 4
            4  256 * 16
            5  320 * 4
            6  320 * 16
            7  512 * 2
            8  512 * 4
            9  640 * 2
            0x0a  640 * 4

0x0a - b    Compression style:  Up to 255 forms of compression
            may be defined.

       0 is uncompressed.

       1 is run length encoding.  Run length encoding
       will work as follows:

       The picture file will consist of a series of variable
       length "packets" in the form

       [key value] [data bytes].

       The Key Value is a single byte.  If the high bit is
       set, then the following byte is repeated the number
       of times specified by the unsigned value of the rest
       of the byte.  I.e. if the byte is 10010000 binary,
       then the first bit specifies that the "packet" is
       compressed and the next byte is to be repeated
       0010000 (16) times.  The key value 10000000 is a
       special case where the next byte repeated 128 times.
       
       If the Key Value high bit is unset, then the rest of
       the byte specifies the number of bytes are to be
       considered "literal".  I.e., if the byte is 01000000,
       then the next 64 bytes are not compressed, and the
       next byte after the last "literal" byte is the next
       Key Value byte.

       2 is delta compression.
       
            Delta compression really isn't compression on its
       own at all.  Each byte in a frame is subtracted from the
       corresponding byte in the previous frame and the difference
       is stored.  A delta frame is useful because the delta file
       can be compressed by other means with a separate compression
       utility.  If you want to show animation, the uncompressed file
       requires less alteration than a compressed deltafile for display.
       Furthermore, with a multi-tasking OS, it is conceivable that
       one might have uncompression of files occuring as a background
       task separate from the display function, so there may be some
       value in this separation of functions.

       3 is delta and run length encoding combined.  In storing
       the file, the original frame is "delta"d from the previous
       frame, and then the result is run length encoded using
       the method described in compression #1.

0x0c - d  Display Duration in 1/64 sec. increments.  The
          16 bit value is treated as an unsigned integer.  Although
          it is formally a 1/64 sec., it should be presumed that
          due to the multi-tasking nature of the OS, some delay
          may occur between frames.  As such, specific frame synch
          might require "something more".  Display based on 1/60
          sec. tickrates would not be considered "wrong".  Maximum
          duration is 1024 seconds, or a bit over 17 minutes.

          0 Duration Files

          Duration 0 is a special case.  A 0 duration file is
          not intended to be displayed at all.  Such files are
          used for holding sprite definitions, or even programming
          code to define sprite movement or other special features.

     NOTE:  For more info on 0 Duration files, see below.

0x0e - 0x15  Color Cycling Set 1

     0x0e = first register (0 - 15)
     0x10 = last register (0 - 15)
     0x12 = recursions (0 = infinite)
     0x14 = speed in 1/64 sec. High bit indicates direction
            of cycle.  If clear, then registers are INC'd.
            If set, then registers are DEC'd.  By INC'ing,
            I mean that if FFB0 is the lowest addressed
            register in the set, the value in FFB0 is moved to
            FFB1 and so forth until the highest register
            is hit.  The value is then sent to the lowest
            register in the set.

0x16 - 0x1d  Color Cycling Set 2

    0x16 = first register (0 - 15)
    0x18 = last register (0 - 15)
    0x1a = recursions (0 = infinite)
    0x1c = speed in 1/64 sec.  High bit indicates direction
           of cycle.  (see above)

0x1e - 0x3f  Undefined

0x40    Color Pallette 0 (address FFB0)
0x42    Color Pallette 1 (address FFB1)
0x44    Color Pallette 2 (address FFB2)
0x46    Color Pallette 3 (address FFB3)
0x48    Color Pallette 4 (address FFB4)
0x4a    Color Pallette 5 (address FFB5)
0x4c    Color Pallette 6 (etc.)
0x4e
0x50
0x52
0x54
0x56
0x58
0x5a
0x5c
0x5e    Color Pallette 15 (address FFBF)

0x60 - 0x7f are reserved for further Color Pallettes
            for compatibility with other graphic displays.

Picture Data

     The bytes of the file follow as a straight memory dump
if there is no defined compression.  There are no special
delimiter characters in the uncompressed formats.  File length
should *always* be provided, even in uncompressed files.

Miscellaneous

     The reason for the "undefined" words is for such
things as sprite definition, object motion and such.
It'll be useful for the future.

Duration 0 File Headers:

     The contents of these files are defined by *internal*
headers which start *after* the 128th byte.

     It is expected that the first bytes of the extended definition
will be used for additional color registers for later computers
able to display more than 16 colors.

     A number of special files may be contained inside a single
0 Duration file.  For example, if you have 16 bit images of a
girl walking, you may call them 'judy.1' to 'judy.16'.  Each
would be contained in a Sprite Definition File by its name
in the form

[Sprite Definition File Header][Sprite definition data]

and all the files may be concatenated into one 0 duration file.

     Similarly, Program Files can be intermixed with Sprite
Definition Files.  By default, unless another program file
is currently being executed, the first program file will be
executed immediately.

     Program files are in a form as follows:

[Program File Header][Program File data]
*/
-- 
Jim Omura, 2A King George's Drive, Toronto, (416) 652-3880
ihnp4!utzoo!lsuc!jimomura
Byte Information eXchange: jimomura