home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / GAMETP.ZIP / VGAKERN.INT < prev    next >
Encoding:
Text File  |  1992-10-29  |  25.6 KB  |  758 lines

  1. Unit VgaKern;
  2.  
  3. { VgaKern version 3.5b Copyright (C) 1992 Scott D. Ramsay }
  4.  
  5. {   This unit is specifically for Mode 13h (320x200x256).  It is a    }
  6. { lot faster than using the BGI drivers (VGA256.BGI).  Majority of    }
  7. { the code is written using BASM.  This will work on 286 machines or  }
  8. { higher. "I don't know about the P5 chip though." ;)                 }
  9. {   This is the raw unit of the lib.  Most of the basic low level     }
  10. { routines are here.                                                  }
  11. {   VGAKERN.TPU can be used freely in commerical and non-commerical   }
  12. { programs.  As long as you don't give yourself credit for writing    }
  13. { this portion of the code.  When distributing it (free only), please }
  14. { include all files and samples so others may enjoy using the code.   }
  15. { Enjoy.                                                              }
  16.  
  17. { Please bear with my comments.  I'm not a tech-writer.  You're more }
  18. { than welcome to modify the comments in this file for people to     }
  19. { understand.                                                        }
  20.  
  21. Interface
  22.  
  23. const
  24.   VidSet     : boolean = true;       { When set to FALSE, OPENMODE() does  }
  25.                                      { clear the vga screen to black       }
  26.                                      {  e.g.  ah=$93 instead of ah=$13     }
  27.                                      { See dos ref. for the set of HI-bit  }
  28.   MaxPages   = 8;                    { Maxium virtual pages allowed        }
  29.   WinMinX    : word = 0;             { WinMin% sets the boundry for CLINE  }
  30.   WinMinY    : word = 0;             {  This is the only function that     }
  31.   WinMaxX    : word = 319;           {  does any clipping. (Clipping slows }
  32.   WinMaxY    : word = 199;           {  slows functions)                   }
  33.  
  34. type
  35.  
  36. { RGBType/RGBlist handles the color palette }
  37.  
  38.   RGBType    = record
  39.                  red,green,blue : byte;
  40.                end;
  41.   RGBlist    = array[0..255] of RGBType;
  42.  
  43. { Same as then record declared in TVISION's OBJECTS unit }
  44.   PtrRec     = record
  45.                  ofs,seg : word;
  46.                end;
  47. var
  48.   PrevMode,                                      { previous }
  49.   crpg          : byte;                          { current active page  }
  50.   scnseg,scnofs : word;                          { current page address }
  51.   pages         : array[1..MaxPages] of pointer; { page pointers }
  52.   thdmat        : set of byte;                   { set for mattevsp }
  53.   vspcnt,                                        { vsp last load count }
  54.   maxpage       : word;                          { pages used }
  55.   zdc           : RGBlist;                       { all black palette }
  56.  
  57. { See Implementation section for description of functions }
  58.  
  59. function LoadVSP(fn:string;var buff):integer;
  60. procedure MatteVsp(var from,too);
  61. procedure VSinc;
  62. procedure SetDefaultColors;
  63. procedure Switch(var a,b:integer);
  64. procedure Parse(var x,y:integer);
  65. function BuffSize(width,height:integer):word;
  66. function ImageSize(var image):word;
  67. procedure ImageDims(var image;var width,height:integer);
  68. procedure SetPtr(var i:PtrRec;var buff);
  69. function pt(x,y:integer):word;
  70. procedure OpenMode(npages:byte);
  71. function Point(x,y:integer;pg:byte):byte;
  72. procedure Pset(x,y:integer;n:byte);
  73. procedure fPcopy(var from,too);
  74. procedure Pcopy(from,too:byte);
  75. procedure FastMatte(x1,y1,x2,y2:integer;var from,too);
  76. procedure SwapMatte(x1,y1,x2,y2:integer;from,too:byte);
  77. procedure Matte(x1,y1,x2,y2:integer;from,too:byte);
  78. procedure Line(x1,y1,x2,y2:integer;n:byte);
  79. procedure Bar(x1,y1,x2,y2:integer;n:byte);
  80. procedure Rectangle(x1,y1,x2,y2:integer;n:byte);
  81. procedure Circle(x1,y1,r:integer;n:byte);
  82. procedure Ellipse(xc,yc,a0,b0:integer;c:byte);
  83. procedure fBitDraw(x,y:word;var buff);
  84. procedure Cls(n:byte);
  85. procedure CloseMode;
  86. procedure FastGet(x1,y1,x2,y2:integer;var image);
  87. procedure GetPic(x1,y1,x2,y2:integer;var image);
  88. procedure FastPut(x1,y1:integer;var image);
  89. procedure PutPic(x1,y1:integer;var image;rmw:byte);
  90. procedure SetPageActive(page:byte);
  91. procedure GetColor(num:byte;var red,green,blue:byte);
  92. procedure SetColor(num,red,green,blue:byte);
  93. procedure fSetColors(var colors);
  94. procedure fGetColors(var colors);
  95. procedure FadeIn(steps:word;var color1,color2);
  96. procedure FadeOut(steps:word;var color1,color2);
  97. function LoadColors(filename:string;var colors;count:integer):integer;
  98. function SaveColors(filename:string;var colors;count:integer):integer;
  99. procedure Paint(x,y:integer;n:byte);
  100. procedure CopyTo(x1,y1,x2,y2,x,y:integer;from,too:byte);
  101. procedure BitDraw(x,y:integer;var image,matte);
  102. procedure BitErase(x,y:integer;page:byte;var matte);
  103. procedure DispLayer(x,y:integer;var pic,mat,virt;plv:byte);
  104. procedure EraseLayer(x,y:integer;bkpage:byte;var mat,virt;plv:byte);
  105. procedure DispVirt(x,y:integer;var mat,virt;plv:byte);
  106. procedure EraseVirt(x,y:integer;var mat,virt;plv:byte);
  107. procedure CopyVirt(x,y:integer;var mat,v1,v2;plv:byte);
  108. procedure DispSprite(x,y:integer;var pic,mat,virt;plv:byte);
  109. procedure EraseSprite(x,y:integer;var mat,v2;bkpage,plv:byte);
  110. function AnalyzeScreen:byte;
  111. procedure MemWrite(var source,dest;size:word;var off:longint);
  112. procedure MemRead(var source,dest;size:word;var off:longint);
  113. procedure FastWPut(x1,y1:integer;var image);
  114. procedure FastWMatte(x1,y1,x2,y2:integer;var from,too);
  115.  
  116. Implementation
  117.  
  118. (***********************************************************************)
  119. function LoadVSP(fn:string;var buff):integer;
  120.  
  121.   Loads a VSP (Vga SPrite) file.  The procedure automatically
  122.   allocates memory for the images onto the heap space
  123.  
  124.   fn:string     The VSP file name
  125.   buff          The location to place the sprites
  126.                 NOTE: buff must be of type POINTER
  127.                 or an array of pointers
  128.                 e.g.
  129.                    var
  130.                      sprite_1 : pointer;
  131.                      sprite_2 : array[1..sprites_in_file] of pointer;
  132.  
  133.    The format of a sprite file:
  134.  
  135. {       BYTE            SIZE   DESCRIPTION
  136.         0..1            word   width of sprite
  137.         2..3            word   height of sprite
  138.     4..(width*height+4) byte   pixel information
  139.          n              word   width of next sprite
  140.          n+2            word   height of next sprite
  141.                    .
  142.                    .
  143.                    .
  144.  }
  145.    example:
  146.  
  147.       const
  148.         sprites_in_file = 10;
  149.       var
  150.         list_sprite : array[1..sprites_in_file] of pointer;
  151.         a_sprite    : pointer;
  152.       begin
  153.         loadvsp('sprite01.vsp',list_sprite);
  154.         loadvsp('sprite02.vsp',a_sprite);
  155.         fastput(10,10,list_sprite[2]^);
  156.         fastput(100,100,a_sprite^);
  157.       end;
  158.  
  159. (***********************************************************************)
  160. procedure MatteVsp(var from,too);
  161.  
  162.   Creates a VSP matte,  the matte is used for identifying
  163.   transparent color in sprites using the set THDMAT for
  164.   the transparent colors.  The "too" sprite memory must
  165.   be allocated or a static array large enough to fit the
  166.   entire sprite.
  167.  
  168.           e.g
  169.             var
  170.               sprite1 : pointer;               { <- need to allocate }
  171.               sprite2 : array[1..260] of byte; { <- ready to use }
  172.  
  173.             getmem(sprite,BuffSize(16,16)); { allocate mem for 16x16 sprite }
  174.  
  175.  
  176.  
  177.     example:
  178.  
  179.        const
  180.          sprite_size = 1000;
  181.  
  182.        var
  183.          sprite,sprite_matte : pointer;
  184.          sprites             : array[0..1] of pointer;
  185.          mattesprite         : array[1..sprite_size] of byte;
  186.        begin
  187.            .
  188.            .
  189.            .
  190.          THDMAT := [0,4,5]; { Transparent colors for mattevsp are now 0,4,5 }
  191.          MatteVsp(sprite^,sprite_matte^);
  192.          MatteVsp(sprite[0]^,sprite[1]^);
  193.          THDMAT := [0];     { 0 is the only transparent color }
  194.          MatteVsp(sprite[0]^,mattesprite);
  195.  
  196.      }
  197.  
  198.  
  199. (***********************************************************************)
  200. procedure VSinc;
  201.  
  202.    Waits for VBI "Vertical Blanking Interval"
  203.  
  204. (***********************************************************************)
  205. procedure SetDefaultColors;
  206.  
  207.    Sets to the default palette.  Colors 0..15 are the default EGA colors
  208.    where 16..255 are different intensities of those colors
  209.  
  210.  
  211. (***********************************************************************)
  212. procedure Switch(var a,b:integer);
  213.  
  214.    Switches the values of A and B.  Quickly!
  215.  
  216.      a := a xor b;
  217.      b := a xor b;
  218.      a := a xor b;            { do the math, it works! }
  219.  
  220. (***********************************************************************)
  221. procedure Parse(var x,y:integer);
  222.  
  223.    Clips the values of X and Y to be in the range 0..319, 0..199
  224.      if x<0 then x := 0
  225.      else
  226.        if x>319
  227.          then x := 319;
  228.      if y<0 then y := 0
  229.        else
  230.          if y>199
  231.            then y := 199;
  232.  
  233. (***********************************************************************)
  234. function BuffSize(width,height:integer):word;
  235.  
  236.      Returns the bytes required to store a sprite of size
  237.        width, height.
  238.  
  239. (***********************************************************************)
  240. function ImageSize(var image):word;
  241.  
  242.     Returns the amount of memory the sprite uses. (in bytes)
  243.  
  244. (***********************************************************************)
  245. procedure ImageDims(var image;var width,height:integer);
  246.  
  247.    Returns the width and height of a sprite
  248.  
  249. (***********************************************************************)
  250. procedure SetPtr(var i:PtrRec;var buff);
  251.  
  252.    Sets the Segment and offset of buff to the i:PTRREC
  253. (***********************************************************************)
  254. function pt(x,y:integer):word;
  255.  
  256.    Calcuates the screen offset of x,y.
  257.  
  258.      example:
  259.  
  260.        const
  261.          x = 160;
  262.          y = 100;
  263.  
  264.          .
  265.          .
  266.          .
  267.        begin
  268.          mem[$A000:pt(x,y)] := 1; { Places a pixel of color 1 at (x,y) }
  269.        end;
  270.  
  271.  
  272. (***********************************************************************)
  273. procedure OpenMode(npages:byte);
  274.  
  275.    Sets to mode 13h, Initalizes variables,  Allocates virtual pages,
  276.    and sets default palette.  (The first call you should do before
  277.    using the other functions.
  278.  
  279.    npages:byte;   { The number of pages to allocate }
  280.  
  281.    example:
  282.  
  283.        openmode(3);  { allocates 2 virtual pages to the heap }
  284.                      { page 1 is always $A000:0              }
  285.  
  286.        You must copy pages 2..n to page 1 to view.  The visual
  287.        page is always page 1.
  288.  
  289. (***********************************************************************)
  290. function Point(x,y:integer;pg:byte):byte;
  291.  
  292.   Returns the pixel value at (X,Y) on page (PG)
  293.  
  294. (***********************************************************************)
  295. procedure Pset(x,y:integer;n:byte);
  296.  
  297.   Sets a pixel value on the current page of (N) at (X,Y)
  298.  
  299. (***********************************************************************)
  300. procedure fPcopy(var from,too);
  301.  
  302.   Copies a page to another page, Fast.
  303.  
  304.    example:
  305.  
  306.      fPcopy(pages[1]^,pages[2]^); { copies the contents of page 1 to page 2 }
  307.  
  308.    The untyped parameters allows for user created virtual pages.  Such
  309.    at EMS memory.  e.g.    fPcopy(pages[2]^,mem[EMSsegment,0]);
  310.  
  311.  
  312. (***********************************************************************)
  313. procedure Pcopy(from,too:byte);
  314.  
  315.   Copies a page to another page.
  316.  
  317.      Pcopy(2,4);  { Copies the contents of page 1 to page 4 }
  318.  
  319. (***********************************************************************)
  320. procedure FastMatte(x1,y1,x2,y2:integer;var from,too);
  321.  
  322.   Copies a rectanglar region (x1,y1,x2,y2) at FROM to TOO.
  323.  
  324.     example:
  325.  
  326.        FastMatte(10,10,100,100,pages[1]^,pages[2]^);
  327.  
  328. (***********************************************************************)
  329. procedure SwapMatte(x1,y1,x2,y2:integer;page1,page2:byte);
  330.  
  331.    Switches a rectanglar region (x1,y1,x2,y2). Not blinding fast.
  332.  
  333.      example:
  334.  
  335.         SwapMatte(0,0,319,199,4,2); { exchanges contents of page 4, page 2
  336.  
  337. (***********************************************************************)
  338. procedure Matte(x1,y1,x2,y2:integer;from,too:byte);
  339.  
  340.   Same a FastMatte.  Slower.
  341.  
  342.     example:
  343.  
  344.        Matte(100,100,120,145,1,2);
  345.  
  346. (***********************************************************************)
  347. procedure Line(x1,y1,x2,y2:integer;n:byte);
  348.  
  349.   Draws a line on the current page.  Alot faster than BGI drivers.
  350.  
  351. (***********************************************************************)
  352. procedure Bar(x1,y1,x2,y2:integer;n:byte);
  353.  
  354.   Draws a filled rectangle on the current page
  355.  
  356. (***********************************************************************)
  357. procedure Rectangle(x1,y1,x2,y2:integer;n:byte);
  358.  
  359.   Draws a rectangle on the current page
  360.  
  361. (***********************************************************************)
  362. procedure Circle(x1,y1,r:integer;n:byte);
  363.  
  364.   Draws a circle with a radius of R and color N on the current page
  365.  
  366. (***********************************************************************)
  367. procedure Ellipse(xc,yc,a0,b0:integer;c:byte);
  368.  
  369.   Draws an ellipse with horiz radius of a0 and vertical radius of b0
  370.  
  371. (***********************************************************************)
  372. procedure fBitDraw(x,y:word;var buff);
  373.  
  374.   Draws a sprite on the current page with color 0 being transparent. Fast.
  375.  
  376. (***********************************************************************)
  377. procedure Cls(n:byte);
  378.  
  379.   Clear the current page to color (N)
  380.  
  381. (***********************************************************************)
  382. procedure CloseMode;
  383.  
  384.   Deallocates virtual pages and restores the display mode.
  385.  
  386. (***********************************************************************)
  387. procedure FastGet(x1,y1,x2,y2:integer;var image);
  388.  
  389.   Gets a sprite from the current page at the region (x1,y1,x2,y2) faster
  390.   than GetPic.
  391.  
  392.    example:
  393.  
  394.      var
  395.        sprite : pointer;
  396.        .
  397.        .
  398.        .
  399.      FastGet(10,10,24,26,sprite^);
  400.  
  401. (***********************************************************************)
  402. procedure GetPic(x1,y1,x2,y2:integer;var image);
  403.  
  404.   Same as FastGet.
  405.  
  406. (***********************************************************************)
  407. procedure FastPut(x1,y1:integer;var image);
  408.  
  409.   Puts a sprite onto the current page. Fast.  With no transparency.
  410.  
  411.      example:
  412.  
  413.         var
  414.           sprite : array[0..100] of byte;
  415.           listsprite : array[0..2] of pointer;
  416.           .
  417.           .
  418.           .
  419.         FastPut(10,10,sprite);
  420.         FastPut(20,20,listsprite[2]^);
  421.  
  422. (***********************************************************************)
  423. procedure PutPic(x1,y1:integer;var image;rmw:byte);
  424.  
  425.   Puts a sprite onto the current page.
  426.     values of RMW
  427.       0  = MOV
  428.       1  = XOR
  429.       2  = OR
  430.       3  = AND
  431.       4  = NOT
  432.     The above values are the same as XORput,NormPut ... defined in
  433.     the unit GRAPH.TPU
  434.  
  435. (***********************************************************************)
  436. procedure SetPageActive(page:byte);
  437.  
  438.   Changes the active page specified by (PAGE).  Updates the values
  439.   of SCNSEG, SCNOFS.
  440.  
  441.     example:
  442.  
  443.         SetPageActive(1);  { SCNSEG = $A000, SCNOFS = 0 }
  444.  
  445.   User defined pages can be set by modifing SCNSEG and SCNOFS directly.
  446.      e.g.
  447.           var
  448.              ascreen : pointer;
  449.  
  450.              .
  451.              .
  452.              .
  453.           getmem(ascreen,64000);  { screen size = 64000 bytes }
  454.           SCNSEG := seg(ascreen^);
  455.           SCNOFS := ofs(ascreen^);
  456.           line(0,0,319,199,4);     { draws a line on ascreen }
  457.  
  458. (***********************************************************************)
  459. procedure GetColor(num:byte;var red,green,blue:byte);
  460.  
  461.   Returns the red, green, blue values of color (num)
  462.  
  463. (***********************************************************************)
  464. procedure SetColor(num,red,green,blue:byte);
  465.  
  466.   Sets the red, green, blue values of color (num)
  467.  
  468. (***********************************************************************)
  469. procedure fSetColors(var colors);
  470.  
  471.   Sets the entire palette. (With out flicker)
  472.  
  473.   colors is usually variable of type RGBlist
  474.  
  475. (***********************************************************************)
  476. procedure fGetColors(var colors);
  477.  
  478.   Gets the current color palette.
  479.  
  480. (***********************************************************************)
  481. procedure FadeIn(steps:word;var color1,color2);
  482.  
  483.   Fades in the current palette from color1 to color2 in (STEPS) steps.
  484.  
  485.   example:
  486.  
  487.       var
  488.         MyPalette : RGBlist;
  489.           .
  490.           .
  491.           .
  492.  
  493.       LoadColors('colors.pal',MyPalette,256);
  494.       FSetColors(zdc);   { black out the palette.  ZDC defined in unit }
  495.       FadeIn(70,zdc,MyPalette);
  496.  
  497. (***********************************************************************)
  498. procedure FadeOut(steps:word;var color1,color2);
  499.  
  500.   Fades out the current palette from color2 to color1 in (STEPS) steps.
  501.  
  502.   example:
  503.  
  504.       var
  505.         MyPalette : RGBlist;
  506.           .
  507.           .
  508.           .
  509.  
  510.       LoadColors('colors.pal',MyPalette,256);
  511.       FSetColors(MyPalette);
  512.  
  513.           .
  514.           .
  515.           .
  516.  
  517.       FadeOut(70,zdc,MyPalette);   { Fades the screen to black }
  518.  
  519. (***********************************************************************)
  520. function LoadColors(filename:string;var colors;count:integer):integer;
  521.  
  522.    Loads a list of RGBtypes.
  523.      filename:string  The palette file.
  524.      colors           Location to store the palette
  525.      count            Number of colors to read
  526.  
  527.    example:
  528.  
  529.      LoadColors('colors.pal',MyPalette,256);
  530.      FSetColors(MyPalette);
  531.  
  532. (***********************************************************************)
  533. function SaveColors(filename:string;var colors;count:integer):integer;
  534.  
  535.    Saves a list of RGBtypes.
  536.      filename:string  The palette file.
  537.      colors           palette to save
  538.      count            Number of colors to save
  539.  
  540.    example:
  541.  
  542.      SaveColor('black.pal',zdc,256);
  543.  
  544. (***********************************************************************)
  545. procedure Paint(x,y:integer;n:byte);
  546.  
  547.   Does a flood fill at (x,y) with color n.  Changes only
  548.   the surrounding region at the color (x,y).  Slow, my own
  549.   coding, but it works.
  550.  
  551. (***********************************************************************)
  552. procedure CopyTo(x1,y1,x2,y2,x,y:integer;from,too:byte);
  553.  
  554.   Copies a rectangular region (x1,y1,x2,y2) to (x,y) (top,left corner)
  555.  
  556.   from,too indicates page number.
  557.  
  558.   Does check for overlapping regions if FROM and TOO are the same page.
  559.   (I hate checking code.  Slows things down. Write the program to
  560.    avoid overlapping.  "Just my 2cents" sorry.)
  561.  
  562. (***********************************************************************)
  563. procedure BitDraw(x,y:integer;var image,matte);
  564.  
  565.   Puts a sprite, on the screen transparent areas are specified
  566.   by the matte sprite.  Usefull for images that change transparency.
  567.   (The imgage doesn't change, only the matte);
  568.  
  569.   The how BitDraw works:
  570.      Checks the each pixel in "matte". If the pixel value in
  571.     matte is non-zero, then the corresponding pixel in "image"
  572.     is drawn onto the current page.
  573.  
  574.   NOTE: the image and matte sprites should be the same size.
  575.  
  576.   See also:  MatteVsp, DispLayer
  577.  
  578. (***********************************************************************)
  579. procedure BitErase(x,y:integer;page:byte;var matte);
  580.  
  581.   Erases the region on the current page by the region on (page) at X,Y.
  582.  
  583.   example:
  584.  
  585.       SetActivePage(1);
  586.       BitDraw(x,y,ball_sprite^,ball_matte^);
  587.       BitErase(x,y,2,ball_matte^);
  588.  
  589.       { page 2 can be the background, BitErase erases only the
  590.         areas affected by the BitDraw }
  591.  
  592. (***********************************************************************)
  593. procedure DispLayer(x,y:integer;var pic,mat,virt;plv:byte);
  594.  
  595.    Displays a Sprite (pic) and its matte (mat) on the current page.
  596.     Based on the sprites level.  (plv) is the sprite layer number. (virt)
  597.     virtual page which keeps track of "DispLayer" sprites on screen.
  598.  
  599.    Think of the display having 256 layers.  Layer 0 is furthest back and
  600.     layer 255 is the top layer.  For example, a sprite "Displayer" with
  601.     plv=4 will only overwrite sprites that have been written with a plv
  602.     value less than 4.  Sprites greater than 4 will be unaffected.
  603.  
  604.    The how DispLayer works:
  605.       Functions the same as BitDraw, except that it also checks the
  606.       screen location on the "virt" page.  If that pixel value is less
  607.       than the "plv" value, then the pixel is drawn.
  608.  
  609.    Use the "DispLayer" function with DispVirt to update the virtual page.
  610.  
  611.    See sample programs for use of this.  (I can't explain it very well, huh)
  612.  
  613.    example:
  614.                                       
  615.      DispLayer(x,y,sprite^,sprite_matte^,pages[2]^,4);
  616.                                       { Draws the sprite at layer 4 }
  617.                                       
  618.      DispVirt(x,y,sprite_matte^,pages[2]^,plv);
  619.                                       { Updates the virtual page }
  620.  
  621.    See Also:
  622.        BitDraw, BitErase, EraseLayer
  623.  
  624. (***********************************************************************)
  625. procedure EraseLayer(x,y:integer;bkpage:byte;var mat,virt;plv:byte);
  626.  
  627.    Erases a Sprite on the current page.
  628.  
  629.    x,y    : coordinates to place the sprite
  630.    bkpage : the background page to write to the current screen.
  631.    mat    : the sprite matte
  632.    plv    : sprite value
  633.  
  634.    Functionally the same as BitErase.  Except that the pixel value
  635.     at (virt) must less than equal to (plv)
  636.  
  637. (***********************************************************************)
  638. procedure DispVirt(x,y:integer;var mat,virt;plv:byte);
  639.  
  640.    Updates the (virt) "virtual" page.
  641.  
  642.    See EraseLayer, BitDraw, BitErase, DispLayer
  643.  
  644. (***********************************************************************)
  645. procedure EraseVirt(x,y:integer;var mat,virt;plv:byte);
  646.  
  647.    Erases the (virt) "virtual" page.
  648.  
  649.    See EraseLayer, BitDraw, BitErase, DispLayer
  650.  
  651. (***********************************************************************)
  652. procedure CopyVirt(x,y:integer;var mat,v1,v2;plv:byte);
  653.  
  654.   Copies the (plv) on page (v1) to (v2).
  655.  
  656.   Example:
  657.  
  658.      CopyVirt(x,y,sprite_mat^,pages[2]^,pages[3]^,4);
  659.  
  660. (***********************************************************************)
  661. procedure DispSprite(x,y:integer;var pic,mat,virt;plv:byte);
  662.  
  663.     Calls DispLayer(x,y,pic,mat,virt,plv); and
  664.     Calls DispVirt(x,y,mat,virt,plv);
  665.  
  666. (***********************************************************************)
  667. procedure EraseSprite(x,y:integer;var mat,v2;bkpage,plv:byte);
  668.  
  669.     Calls EraseVirt(x,y,mat,virt,plv); and
  670.     Calls EraseLayer(x,y,bkpage,mat,virt,plv);
  671.  
  672. (***********************************************************************)
  673. function AnalyzeScreen:byte;
  674.  
  675.    Returns the color number that is most used on the screen.
  676.  
  677.    Used by SavePTR in unit IMAGING.TPU
  678.  
  679. (***********************************************************************)
  680. procedure MemWrite(var source,dest;size:word;var off:longint);
  681.  
  682.    Copies a block of memory from "source" to "dest" of size "size".
  683.  
  684.    off: is the starting offset of "dest".  and
  685.      returns (off+size).  The next byte(s) to be read.
  686.  
  687.  
  688. (***********************************************************************)
  689. procedure MemRead(var source,dest;size:word;var off:longint);
  690.  
  691.    Same as MemWrite.  Except  "off" specifies the starting
  692.      offset of "source"
  693.  
  694. (***********************************************************************)
  695. procedure FastWPut(x1,y1:integer;var image);
  696.  
  697.    Same as FastPut.  But moves WORDS, instead of BYTES.
  698.     note: Make sure the width of the sprite is an even value.
  699.  
  700. (***********************************************************************)
  701. procedure FastWMatte(x1,y1,x2,y2:integer;var from,too);
  702.  
  703.    Same as FastMatte.  But moves WORDS instead of BYTES.
  704.    note: Make sure that (x2-x1)+1 is an even value.
  705.  
  706. (***********************************************************************)
  707.  
  708.  
  709.   As you will notice.   Some functions are similar. Such as:
  710.  
  711.       PUTPIC, FASTPUT, FASTWPUT
  712.       MATTE, FASTMATTE, FASTWMATTE
  713.  
  714.   This unit is a result of alot of revisions.  Notice it is version 3.5b
  715.   eventhough this is it first public release.
  716.  
  717.   I just kept the older versions of the functions in for my own
  718.    compatiblity.  "Lucky for Turbo's Smart Linking.  ;)"
  719.  
  720.  
  721. If you have any problems, e-mail at:
  722.  
  723.     ramsays@express.digex.com
  724.  
  725.   Sorry, I don't have permanent snail-mail address yet.  I just moved
  726.    to the Washington DC area.
  727.  
  728.   The TPU units can be used with in your programs.  With out giving
  729.    me credit.  If you want the source code, more samples or swap-talk,
  730.    just e-mail me.  I'll give sample use-code for free.  Actual TPU-source
  731.    code prices can be discussed.
  732.  
  733.   Also,  I have completed the following programs.
  734.  
  735.      GEOMAKER        Makes tile-maps quickly.
  736.      VSPMAKER        Makes the VSP files.
  737.      BKMAKER         A drawing program that can read
  738.                       VEW files (my own raw format)
  739.                       PTR files (my own compressed format)
  740.                       GIF files
  741.                       PCX files
  742.  
  743.   The three above programs are specifically designed for the 320x200x256
  744.   (game development).  I'll upload them when I think they are ready
  745.   to go. (Bout a week)
  746.  
  747.   (Artwork samples done by me.  Freeware.  Knock your-self out.
  748.    Plug.  Highly recommended.  For game programmers, try to get
  749.    Animator Pro by Autodesk.  This is an excellent program for
  750.    imaging, sprites and so forth. Very similar to the Animator,
  751.    but has better graphic features.  The 3D models are created
  752.    with 3D studio by Autodesk then ported to Animator Pro, then
  753.    scaled down/converted to my VSP files.  If you can blow a
  754.    few thousand bucks, buy the 3D studio.  You can do some amazing
  755.    3D animations. I can't afford it, I use it at work.)
  756.  
  757.  
  758.    Scott D. Ramsay