home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / TGBACKUP.ZIP / FADER.PAS next >
Pascal/Delphi Source File  |  1996-09-07  |  2KB  |  91 lines

  1. { In Procdures FADEIN & FADEOUT, the (X) is the delay between
  2.   screen darkenings. }
  3.  
  4.  Unit Fader;
  5.  Interface
  6.  
  7.    Uses Crt;
  8.  
  9.    Const
  10.      PelAddrRgR  = $3C7;
  11.      PelAddrRgW  = $3C8;
  12.      PelDataReg  = $3C9;
  13.  
  14.    Type
  15.      RGB = Record
  16.              R,
  17.              G,
  18.              B : Byte;
  19.            End;
  20.    Color = Array [0..63] Of RGB;
  21.  
  22.    Var
  23.      Col : Color;
  24.  
  25.  
  26.    Procedure GetCol(C : Byte; Var R, G, B : Byte);
  27.    Procedure SetCol(C, R, G, B : Byte);
  28.    Procedure SetInten(B : Byte);
  29.    Procedure FadeIn (X:Integer);
  30.    Procedure FadeOut (X:Integer);
  31.  
  32.  Implementation
  33.  
  34.  
  35.  
  36. Procedure GetCol(C : Byte; Var R, G, B : Byte);
  37. Begin
  38.   Port[PelAddrRgR] := C;
  39.   R := Port[PelDataReg];
  40.   G := Port[PelDataReg];
  41.   B := Port[PelDataReg];
  42. End;
  43.    
  44. Procedure SetCol(C, R, G, B : Byte);
  45. Begin
  46.   Port[PelAddrRgW] := C;
  47.   Port[PelDataReg] := R;
  48.   Port[PelDataReg] := G;
  49.   Port[PelDataReg] := B;
  50. End;
  51.  
  52. Procedure SetInten(b : Byte);
  53.  Var
  54.    I : Integer;
  55.    FR, FG, FB : Byte;
  56.  Begin
  57.    For I:=0 To 63 Do
  58.    Begin
  59.      FR:=Col[I].R*B Div 63;
  60.      FG:=Col[I].G*B Div 63;
  61.      FB:=Col[I].B*B Div 63;
  62.      SetCol(I, FR, FG, FB);
  63.    End;
  64.  End;
  65.  
  66. Procedure FadeIn (X:Integer);
  67.  Var
  68.    Y:Integer;           (* Y is the LCV *)
  69.  Begin
  70.    For Y:=0 To 63 Do
  71.      Begin
  72.        SetInten(Y);
  73.        Delay(X);
  74.      End;
  75.  End;
  76.  
  77. Procedure FadeOut (X:Integer);
  78.  Var
  79.    Y:Integer;    (* Y is the LCV *)
  80.  Begin
  81.    For Y:=0 To 63 Do
  82.      GetCol(Y, Col[Y].R, Col[Y].G, Col[Y].B);
  83.    For Y:=63 DownTo 0 Do
  84.      Begin
  85.        SetInten(Y);
  86.        Delay(X);
  87.      End;
  88.  End;
  89. End.
  90.  
  91.