home *** CD-ROM | disk | FTP | other *** search
/ World of Graphics / WOGRAPH.BIN / 570.UNCRUNCH.H < prev    next >
Text File  |  1993-03-21  |  6KB  |  140 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.          unsigned char far *screenaddr = (char 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 have been used also.
  50.  
  51.      UnCrunch remembers the original horizontal (X) starting position when
  52.      it goes down to the next line.  This permits a block to be displayed
  53.      correctly anywhere on the screen.  ie:
  54.  
  55.        +-------------------------------------------------+
  56.        |                                                 |
  57.        |                                                 | <- Pretend this
  58.        |                                                 |    is the video
  59.        |           ┌─────────────────────┐               |    display.
  60.        |           │█████████████████████│               |
  61.        |           │█████████████████████│               |
  62.        |           │██ ImageData block ██│               |
  63.        |           │█████████████████████│               |
  64.        |           │█████████████████████│               |
  65.        |           │█████████████████████│               |
  66.        |           └─────────────────────┘               |
  67.        |                                                 |
  68.        |                                                 |
  69.        |                                                 |
  70.        +-------------------------------------------------+
  71.  
  72.  
  73.      The ImageData block could just as well have been display in the
  74.      upper-left corner of the screen with:
  75.  
  76.        uncrunch (IMAGEDATA,screenaddr,sizeof(IMAGEDATA));
  77.  
  78.      Notice the array address offset has been removed, since we want the
  79.      upper-left corner and SCREENADDR points directly at that position.
  80.  
  81.      To display the block in the lower-right corner you would use:
  82.        uncrunch (IMAGEDATA,screenaddr+40*2+(15*160)-162,sizeof(IMAGEDATA));
  83.  
  84.      The block is 40 characters wide by 10 lines deep.  Therefore to display
  85.      such a large block, we must display the block at X=40, Y=15.
  86.  
  87.    ---------------------------------------------------------------------
  88.  
  89.    There are two implementations of the UnCrunch routine.  One is for
  90.    near code referencing and the other for far code referencing.  Use
  91.    whichever is appropriate for your compiler configuration.  Please note,
  92.    it would be bad to use the wrong one...
  93.  
  94.      The file UNCRUN_N.OBJ contains the near code model.
  95.      The file UNCRUN_F.OBJ contains the far code model.
  96.  
  97.    Configure your machine to link in the appropriate file.  This is compiler
  98.    dependant.  In TurboC for instance, you include the filename in the
  99.    project file list.
  100.  
  101.    ---------------------------------------------------------------------
  102.  
  103.    The routines do not alter any CPU registers or return any result value.
  104.    They have been tested successfully with Turbo C v2.0 and MicroSoft C v5.1,
  105.    but are not guaranteed to work with all compilers.
  106.  
  107.    The stack setup expected by the routines is:
  108.  
  109.    NEAR CODE MODEL:
  110.      SP:      <retaddr>   Return address
  111.      SP+02:   <offset>    32-bit pointer to source data.
  112.      SP+04:   <segment>
  113.      SP+06:   <offset>    32-bit pointer to destination address.
  114.      SP+08:   <segment>
  115.      SP+0A:   <length>    Length (in bytes) of uncrunch data block.
  116.  
  117.    FAR CODE MODEL:
  118.      SP:      <retofs>    Return address (32-bit, CS:IP);
  119.      SP+02:   <retseg>
  120.      SP+04:   <offset>    32-bit pointer to source data.
  121.      SP+06:   <segment>
  122.      SP+08:   <offset>    32-bit pointer to destination address.
  123.      SP+0A:   <segment>
  124.      SP+0C:   <length>    Length (in bytes) of uncrunch data block.
  125.  
  126.    Note finally that the routines do not clean up the stack after
  127.    finishing (standard C calling convention).  It is up to the
  128.    caller to remove the data parameters from the stack.
  129. */
  130.  
  131. extern int uncrunch ();
  132.  
  133. /*
  134.    If your compiler can handle function prototypes and type void,
  135.    you may prefer using the following header line.  It allows the
  136.    compiler to perform better type checking.
  137.  
  138. extern void uncrunch (char far *sourceptr, char far *destptr, int length);
  139. */
  140.