home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / KMAGV2.ZIP / FADEEXAM.PAS < prev    next >
Pascal/Delphi Source File  |  1995-10-23  |  6KB  |  166 lines

  1. {FADEEXAM.PAS / EXAMPLE FOR FADE SCREEN}
  2. {WRITING BY THE KING IN 10/22/95       }
  3. Uses Crt;
  4. Type
  5.     RGB = Record                           {A Record Of Red,Green,Blue}
  6.         R,G,B:Byte;
  7.     End;
  8.     PalType = Array[0..255] Of RGB;        {256 Color Of Red Green Blue}
  9. Var
  10.     Pal : PalType;                         {Palette For Start}
  11.     Pal1 : PalType;                        {Palette For The Picture}
  12.  
  13. {-------------------------------------------------------}
  14. {Get Red Green And Blue From a Color                    }
  15. {-------------------------------------------------------}
  16.  
  17. Procedure GetColor(Col:Byte;Var R,G,B:Byte);Assembler;
  18. ASM
  19.     Mov Dx,3c7H                  {Set To GET COLOR}
  20.     Mov Al,Col
  21.     Out Dx,Al
  22.     Inc Dx                       {Dx = 3c8H}
  23.     Inc Dx                       {Dx = 3c9H}
  24.     Les Di,R                     {Es:Di = R}
  25.     In Al,Dx                     {Get Red Value}
  26.     Mov [Es:Di],Al               {R = Red Value}
  27.     In Al,Dx                     {Get Green Value}
  28.     Les Di,G                     {Es:Di = G}
  29.     Mov [Es:Di],Al               {G = Green Value}
  30.     In Al,Dx                     {Get Blue Value}
  31.     Les Di,B                     {Es:Di = B}
  32.     Mov [Es:Di],Al               {B = Blue Value}
  33. END;
  34.  
  35. {-------------------------------------------------------}
  36. {Set Red Green And Blue To a Color                      }
  37. {-------------------------------------------------------}
  38.  
  39. Procedure SetColor(Col:Byte;R,G,B:Byte);Assembler;
  40. Asm
  41.     Mov Dx,3c8h                  {SET TO SET COLOR}
  42.     Mov Al,Col
  43.     Out Dx,Al
  44.     Inc Dx                       {DX = 3c9h}
  45.     Mov Al,R                     {Senting Red Value}
  46.     Out Dx,Al
  47.     Mov Al,G                     {Senting Green Value}
  48.     Out Dx,Al
  49.     Mov Al,B                     {Senting Blue Value}
  50.     Out Dx,Al
  51. End;
  52. {------------------------------------------------}
  53. {Set Mode To Mode 13H , 320x200x256 Colors..     }
  54. {------------------------------------------------}
  55.  
  56. Procedure SetMode;Assembler;
  57. Asm
  58.        Mov Ah,00h  {Function 00,13 Interrupt 10h / SET MODE}
  59.     Mov Al,13h
  60.     Int 10h     {SETING TO MODE 13H}
  61. End;
  62. {------------------------------------------------}
  63. {Plot a single pixel on the screen .             }
  64. {------------------------------------------------}
  65. Procedure PutPixel(X,Y:Integer;Col:Byte);Assembler;
  66. Asm
  67.     Mov Ax,0a000h     {Ax = SEGMENT OF THE SCREEN}
  68.     Mov Es,Ax         {Es = SEGMENT OF THE SCREEN}
  69.     Mov Ax,320        {Ax = MAX VERTICAL LINE}
  70.     Mul Y             {Ax = AX * Y = HORIZONTAL LINE}
  71.     Add Ax,X          {Ax = VERTICAL LINE + HORIZONTAL LINE = OFFSET}
  72.     Mov Di,Ax         {DI = OFFSET}
  73.     Mov Al,Col        {AL = COLOR}
  74.     StoSb             {[0A000h:OFFSET] = COLOR}
  75. End;
  76. {------------------------------------------------}
  77. {Set Mode To Mode 3H , 80x25x16 Colors..         }
  78. {------------------------------------------------}
  79. Procedure SetTextMode;Assembler;
  80. Asm
  81.     Mov Ah,00h {Function 00,3 Interrupt 10h / SET MODE}
  82.     Mov Al,3h
  83.     Int 10h    {SET MODE TO MODE 3 / TEXT MODE}
  84. End;
  85. {---------------------------------------------------}
  86. { Make a BLACK Palette                              }
  87. {---------------------------------------------------}
  88. Procedure ZeroPal(Var Pal:PalType);
  89. Begin
  90.     FillChar(Pal,SizeOf(Pal),0);
  91. End;
  92. {---------------------------------------------------}
  93. { Show The Palette                                  }
  94. {---------------------------------------------------}
  95. Procedure ShowPal(Var Pal:PalType);
  96. Var T:Byte;
  97. Begin
  98.     For T:=0 To 255 Do
  99.         SetColor(T,Pal[T].R,Pal[T].G,Pal[T].B);
  100. End;
  101. {---------------------------------------------------}
  102. { Get The Use Palette From The Screen               }
  103. {---------------------------------------------------}
  104.  
  105. Procedure GetPal(Var Pal:PalType);
  106. Var T:Byte;
  107. Begin
  108.     For T:=0 To 255 Do
  109.         GetColor(T,Pal[T].R,Pal[T].G,Pal[T].B);
  110. End;
  111. {---------------------------------------------------}
  112. { Fill The Screen With Random Dots.                 }
  113. {---------------------------------------------------}
  114.  
  115. Procedure FillPoints;
  116. Var
  117.     T:Word;
  118. Begin
  119.     For T:=1 To 65535 Do
  120.     Begin
  121.         PutPixel(Random(319),Random(199),Random(255));
  122.     End;
  123. End;
  124. {---------------------------------------------------}
  125. { Fade To The Screen From Palette To Palette.       }
  126. {---------------------------------------------------}
  127. Procedure FadeTo(Pal,ToPal:PalType);
  128. Var
  129.     T,T1:Byte;
  130. Begin
  131.     For T1:=1 To 63 Do
  132.     Begin
  133.         For T:=1 To 255 Do
  134.         Begin
  135.             If Pal[T].R > ToPal[T].R Then
  136.                 Dec(Pal[T].R);
  137.             If Pal[T].R < ToPal[T].R Then
  138.                 Inc(Pal[T].R);
  139.             If Pal[T].G > ToPal[T].G Then
  140.                 Dec(Pal[T].G);
  141.             If Pal[T].G < ToPal[T].G Then
  142.                 Inc(Pal[T].G);
  143.             If Pal[T].B > ToPal[T].B Then
  144.                 Dec(Pal[T].B);
  145.             If Pal[T].B < ToPal[T].B Then
  146.                 Inc(Pal[T].B);
  147.         End;
  148.         ShowPal(Pal);
  149.         Delay(20);   {Can Be Change To What Speed You Want}
  150.     End;
  151. End;
  152. Begin
  153.                             {MAIN PROGRAM}
  154.  
  155.     SetMode;               {Set To 320X200X256 Mode}
  156.     GetPal(Pal);           {Get Palette To Pal}
  157.     ZeroPal(Pal1);         {Make Pal1 Black Palette}
  158.     ShowPal(Pal1);         {Show The Black Palette That On Pal1}
  159.     FillPoints;            {Fill The Screen With Points}
  160.     FadeTo(Pal1,Pal);      {Fade From Black Screen To Pal}
  161.     Repeat
  162.     Until(Keypressed);     {Wait For KeyPressed}
  163.     FadeTo(Pal,Pal1);      {Fade From Pal To Black Screen}
  164.     SetTextMode;           {Set To Text Mode Screen}
  165.     Writeln('Thanks For Watching My Example.');
  166. End. {End Program}