TIP: Click on subject to list as thread! ANSI
echo: z3_pascal
to: All
from: Adam Whitehead
date: 1996-03-17 18:18:30
subject: Best TextMode Fading Unit!

Hi,

Here's a little Text Mode Fading unit that I have found to be EXTREMELY
good and I use it in all of my programs to make them look a bit more
professional ;)

It is written in PASCAL but is honestly a hell of a lot better than ANY
fading routines I have seen in Assembler.

-cut-

{ In Procedures FADEIN & FADEOUT, the (X) is the delay between   screen
darkenings. }

 Unit Fade;
 Interface

   Uses Crt;

   Const
     PelAddrRgR  = $3C7;
     PelAddrRgW  = $3C8;
     PelDataReg  = $3C9;

   Type
     RGB = Record
             R,
             G,
             B : Byte;
           End;
   Color = Array [0..63] Of RGB;

   Var
     Col : Color;


   Procedure GetCol(C : Byte; Var R, G, B : Byte);
   Procedure SetCol(C, R, G, B : Byte);
   Procedure SetInten(B : Byte);
   Procedure FadeIn (X:Integer);
   Procedure FadeOut (X:Integer);

 Implementation



Procedure GetCol(C : Byte; Var R, G, B : Byte);
Begin
  Port[PelAddrRgR] := C;
  R := Port[PelDataReg];
  G := Port[PelDataReg];
  B := Port[PelDataReg];
End;

Procedure SetCol(C, R, G, B : Byte);
Begin
  Port[PelAddrRgW] := C;
  Port[PelDataReg] := R;
  Port[PelDataReg] := G;
  Port[PelDataReg] := B;
End;

Procedure SetInten(b : Byte);
 Var
   I : Integer;
   FR, FG, FB : Byte;
 Begin
   For I:=0 To 63 Do
   Begin
     FR:=Col[I].R*B Div 63;
     FG:=Col[I].G*B Div 63;
     FB:=Col[I].B*B Div 63;
     SetCol(I, FR, FG, FB);
   End;
 End;

Procedure FadeIn (X:Integer);
Var
  Y:Integer;           (* Y is the LCV *)
Begin
  For Y:=0 To 63 Do
    Begin
      SetInten(Y);
      Delay(X);
    End;
End;

Procedure FadeOut (X:Integer);
Var
  Y:Integer;    (* Y is the LCV *)
Begin
  For Y:=0 To 63 Do
    GetCol(Y, Col[Y].R, Col[Y].G, Col[Y].B);
  For Y:=63 DownTo 0 Do
    Begin
      SetInten(Y);
      Delay(X);
    End;
End;
End.

[-end-]

I think we can all work out how to use this.. only the FadeIn(X) and
FadeOut(X) procedures are required to do a fade. 10 is a good delay to
start with....

Cheerz
Adam Whitehead

--- Ezycom V1.20g0 03fa002d
* Origin: Shady's BBS (3:850/106)
SEEN-BY: 633/267 270
@PATH: 850/106 100 800/1 711/808 50/99 635/544 727 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.