home *** CD-ROM | disk | FTP | other *** search
/ PC Underground / UNDERGROUND.ISO / graphic / fade.pas < prev    next >
Pascal/Delphi Source File  |  1995-07-28  |  2KB  |  63 lines

  1. Unit fade;
  2. {used to fade a picture (part) that has just been displayed into a new one}
  3.  
  4. Interface
  5. Uses ModeXLib;
  6.  
  7. Var Colors:Word;                {Number of colors per single frame}
  8.  
  9. Procedure fade_ResetPic(y,Height:Word);
  10. Procedure Fade1(Pic:Pointer;Pal:Array of Byte; Start,y,Height:Word);
  11.  
  12.  
  13. Implementation
  14. Var i,j:Word;                   {temporary counter}
  15.     Destination_Pal:Array[0..768] of Byte;  {temporary destination palette}
  16.  
  17. Procedure fade_set(Source:Pointer;Start,y,Height:Word);external;
  18. {"mixes" source with VGA-Ram}
  19. {use source beginning at Start line and VGA-Ram beginning at y line at height of Height}
  20. Procedure fade_ResetPic(y,Height:Word);external;
  21. {prepares faded picture for another fade}
  22. {reduction of "Colors^2" to "Colors" colors}
  23. {here again y=line in VGA-Ram, Height=Height of area to be edited}
  24.  
  25. {$l fade}
  26.  
  27.  
  28. Procedure fade_CopyPal;
  29. {multiply palette on Colors^2 (multiply non-homogenous Block 0)}
  30. Begin
  31.   For i:=1 to Colors do
  32.     Move(Palette[0],Palette[i*3*Colors],Colors*3);
  33.  
  34. End;
  35.  
  36. Procedure fade_spread(Var Pal:Array of Byte);
  37. {spread palette to Colors^2 (multiply each color separately)}
  38. {the homogenous blocks are formed here from the colors 0..Colors-1}
  39. Begin
  40.   For i:= 0 to Colors-1 do      {edit each color separately}
  41.     For j:=0 to Colors -1 do    {write Colors once each time}
  42.       Move(Pal[i*3],Pal[(i+1)*3*Colors+j*3],3);
  43. End;
  44.  
  45. Procedure Fade1(Pic:Pointer;Pal:Array of Byte; Start,y,Height:Word);
  46. {Fades from current visible picture to Pic (with Palette Pal). During 
  47. this process, in the "Start" row, the program begins copying "Height" 
  48. rows to the y-coordinate y of the current picture.}
  49. Begin
  50.   WaitRetrace;                  {synchronization}
  51.   fade_CopyPal;                 {multiply block in current palette}
  52.   SetPal;                       {reset this palette}
  53.   Move(Palette,Destination_Pal,768);   {keep original palette parts}
  54.   Move(pal,Destination_Pal,Colors*3);  {load destination palette}
  55.   fade_spread(Destination_pal);      {spread destination palette blocks}
  56.   fade_set(pic,start,y,height);  {mix in new picture}
  57.   fade_to(Destination_pal,1);          {and fade}
  58. End;
  59.  
  60. Begin
  61.   Colors:=15;                   {only default value !}
  62. End.
  63.