home *** CD-ROM | disk | FTP | other *** search
/ The New Aladdin Col 287 Atari ST / The_New_Aladdin_Col_287_Disk-A.ST / REF.TXT < prev    next >
Encoding:
Text File  |  1985-11-20  |  4.9 KB  |  1 lines

  1.     During the development stage of      THE NEW ALADDIN, we investigated        several graphic compression routines    that were available for the Atari ST    computer.  While in certain cases one   routine would work better than others,  we found that in the long run           TINYSTUF, a freeware program written    by David Mumper of Sussex, Wisconsin,   produced the smallest files.  We had    the program to compress our graphic     files, but we could not find the        source code that would allow our        programs to expand the compressed       files into full screen displays.                                                   Armed with a brief and, as I later   found out, error-filled description of  the compressed file and a file dump,    I set out to develop a "C" subroutine   to decompress TINY graphics files.                                                 First let me describe the com-       pressed file.  It is divided into       three sections.  The first section      contains color information and the      number of bytes in the other two        sections.  The second section contains  control information which I will dis-   cuss later, and the third, the data     bytes for the picture.                                                             The first byte on the file tells     you the resolution and whether ro-      tation information follows.  The        values 0, 1, and 2 represent low,       medium, and high resolution respec-     tively, with 3 being added to indicate  rotation.                                                                          Next come the optional four bytes    of rotation information.  The first     byte contains the start color in the    high order four bits, while the end     color is in the lower four.  The        second byte gives the direction and     speed for the rotation.  The value      indicates the number of vertical        blanks between each color shift.  If    the value is positive, the shift is to  the right, while negative indicates a   left shift of the colors.  The next     two bytes form an integer to indicate   the number of rotations to be made.        The color palette comes next and     consists of 16 integers of two bytes    each.  This is followed by another      two-byte integer that tells the number  of control bytes for the file.          Finally, there's another two-byte       integer that tells how many two-byte    pairs of graphic data are contained on  the disk.                                                                          The control bytes tell us how to     format the data bytes.  Their meaning   is as follows:                                                                     <0 -- 1 to 127 unique words (2                bytes) are taken from the               data section.                                                              0 -- the next two bytes in the               control section tell how many           times to repeat the next data           word.                                                                      1 -- the next two bytes in the               control section tell how many           unique words are taken from             the data section.                                                         >1 -- repeat the next data word 2             to 127 times.                                                             Now let's discuss how to use the     routine in your "C" program.  First we  need to define some global variables.   These are:                                                                         long *screen_memory;                    int rez;                                int rotate [4];                         int palette_array [16];                                                         Allocate screen memory, which must   be aligned on a 256-byte boundry with   the instruction:                                                                   screen_memory = (long *)((Malloc             (32256L) + 255) & 0xffffff00);                                             Then call the routine with:                                                     uncompress_graphic ("filename.ext",          screen_memory, &rez, rotate,            palette);                                                                  The source code for the routine can  be found on Aladdin disk "A" as         DECOMP.C.  TNYSTUFF and TINYVIEW, a     slideshow program, can be found on      many bulletin boards or through user    groups.                                                                            I wrote this routine in my early     stages of learning "C" and the          Atari ST.  I am sure this isn't the     most efficient way to attack this       problem, but it works.  If you have a   better routine, let us hear about it    and we'll share it with our readers.                                            (Bo Davis is a systems analyst, the     ST developer for THE NEW ALADDIN,       and a Certified Data Processor.)