home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / open / tdraw320.lzh / UNCRUNCH.H < prev    next >
Text File  |  1989-04-04  |  6KB  |  134 lines

  1. /*
  2.    C prototype for accessing TheDraw Video Screen UnCrunch routine.
  3.  
  4.    This is the flash display routine used to display crunched TheDraw image
  5.    files.  It uses a custom protocol for reproducing an image with any
  6.    possible color combinations.  The control codes below #32 are reserved
  7.    for this function.  See file UNCRUNCH.ASM for description of protocol.
  8.  
  9.    Example call:
  10.  
  11.      uncrunch (source_data,target_area,length);
  12.  
  13.        source_data should be a 32 bit address.
  14.        target_area should be a 32 bit address.
  15.        length should be an integer;
  16.  
  17.    NOTE:
  18.      The UnCrunch routines require usage of a LARGE data model using
  19.      32 bit pointers.  Use of a small data model will cause extremely
  20.      erroneous results, is guaranteed to overwrite the wrong places
  21.      and do all other manner of nasty things.  Please be aware of this.
  22.  
  23.    ---------------------------------------------------------------------
  24.    Program example:
  25.  
  26.      Assume we have an ImageData file (saved to IMAGE.H) of a 40 character
  27.      by 10 line block.  Also the following defintions.  ie:
  28.  
  29.        #include <stdio.h>
  30.        #include "uncrunch.h"
  31.        #include "image.h"
  32.  
  33.        main ()
  34.        {
  35.          void far *screenaddr = (void far *) 0xB8000000;
  36.  
  37.          uncrunch (ImageData,screenaddr+34*2+(5*160)-162,sizeof(ImageData));
  38.        }
  39.  
  40.      SCREENADDR is a pointer mapped to the same location as the physical
  41.      video addresses.   The rather messy array offset tells UnCrunch where
  42.      to start displaying the ImageData block.
  43.  
  44.      The 34*2 indicates the horizontal position number 34 with the 5*160
  45.      indicating line number 5.
  46.  
  47.      Note the use of the SIZEOF operator.  This tells the compiler to figure
  48.      out how large the ImageData array is.  The array length value listed at
  49.      the top of the image data (in IMAGE.h) could just as well been used
  50.      instead.
  51.  
  52.      UnCrunch remembers the horizontal (X) starting position when it goes
  53.      down to the next line.  This allows you to display the ImageData block
  54.      correctly at any position on the screen.   ie:
  55.  
  56.        +-------------------------------------------------+
  57.        |                                                 |
  58.        |                                                 | <- Pretend this
  59.        |                                                 |    is the video
  60.        |           ┌─────────────────────┐               |    display.
  61.        |           │█████████████████████│               |
  62.        |           │█████████████████████│               |
  63.        |           │██ ImageData block ██│               |
  64.        |           │█████████████████████│               |
  65.        |           │█████████████████████│               |
  66.        |           │█████████████████████│               |
  67.        |           └─────────────────────┘               |
  68.        |                                                 |
  69.        |                                                 |
  70.        |                                                 |
  71.        +-------------------------------------------------+
  72.  
  73.  
  74.      The ImageData block could just as well have been display in the
  75.      upper-left corner of the screen with:
  76.  
  77.        uncrunch (ImageData,screenaddr,sizeof(ImageData));
  78.  
  79.      Notice the array address offset has been removed, since we want the
  80.      upper-left corner and SCREENADDR points directly at that position.
  81.  
  82.      To display the block in the lower-right corner you would use:
  83.        uncrunch (ImageData,screenaddr+40*2+(15*160)-162,sizeof(ImageData));
  84.  
  85.      The block is 40 characters wide by 10 lines deep.  Therefore to display
  86.      such a large block, we must display the block at X=40, Y=15.
  87.  
  88.    ---------------------------------------------------------------------
  89.  
  90.    There are two implementations of the UnCrunch routine.  One is for
  91.    near code referencing and the other for far code referencing.  Use
  92.    whichever is appropriate for your compiler configuration.  Please note,
  93.    it would be bad to use the wrong code implementation...
  94.  
  95.      The file UNCRUN_N.OBJ contains the near code model.
  96.      The file UNCRUN_F.OBJ contains the far code model.
  97.  
  98.    Configure your machine to link in the appropriate file.  This is compiler
  99.    dependant.  In TurboC for instance, you include the filename in the
  100.    project file list.
  101.  
  102.    ---------------------------------------------------------------------
  103.  
  104.    The routines do not alter any CPU registers and do not return any result
  105.    value.  These routines have been tested successfully with Turbo C v2.0
  106.    and Microsoft C v5.1, but are not guaranteed to work with all compilers.
  107.  
  108.    The stack setup expected by the routines is:
  109.  
  110.    NEAR CODE MODEL:
  111.      SP:      <retaddr>   Return address
  112.      SP+02:   <offset>    32-bit pointer to source data.
  113.      SP+04:   <segment>
  114.      SP+06:   <offset>    32-bit pointer to destination address.
  115.      SP+08:   <segment>
  116.      SP+0A:   <length>    Length (in bytes) of uncrunch data block.
  117.  
  118.    FAR CODE MODEL:
  119.      SP:      <retofs>    Return address (32-bit, CS:IP);
  120.      SP+02:   <retseg>
  121.      SP+04:   <offset>    32-bit pointer to source data.
  122.      SP+06:   <segment>
  123.      SP+08:   <offset>    32-bit pointer to destination address.
  124.      SP+0A:   <segment>
  125.      SP+0C:   <length>    Length (in bytes) of uncrunch data block.
  126.  
  127.    Note finally that the routines to not clean up the stack after
  128.    finishing (as according to standard C practice).  It is up to the
  129.    caller to remove the data parameters from the stack.
  130. */
  131.  
  132. extern int uncrunch ();
  133.  
  134.