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

  1. Uses Crt;
  2. Var Stars:Array[0..500] of Record
  3.                               x,y,Plane:Integer;
  4.                             End;
  5.   st_no:Word;
  6.  
  7. Procedure PutPixel(x,y,col:word);assembler;
  8. {sets pixel (x/y) to color col (Mode 13h)}
  9. asm
  10.   mov ax,0a000h                 {load segment}
  11.   mov es,ax
  12.   mov ax,320                    {Offset = Y*320 + X}
  13.   mul y
  14.   add ax,x
  15.   mov di,ax                     {load offset}
  16.   mov al,byte ptr col           {load color}
  17.   mov es:[di],al                {and set pixel}
  18. End;
  19.  
  20. Begin
  21.   Randomize;                    {initialize random numbers}
  22.   asm mov ax,13h; int 10h End;  {set Mode 13h}
  23.   Repeat                        {executed once per display}
  24.     For St_no:=0 to 500 do Begin{calculate new position for each star}
  25.       With stars[st_no] do Begin
  26.         PutPixel(x,y,0);        {clear old pixel}
  27.         Dec(x,Plane shr 5 + 1); {continue moving}
  28.         if x <= 0 Then Begin    {left ?}
  29.           x:=319;               {then reinitialize}
  30.           y:=Random(200);
  31.           Plane:=Random(256);
  32.         End;
  33.         PutPixel(x,y,Plane shr 4 + 16);  {set new pixel}
  34.       End;
  35.     End;
  36.   Until KeyPressed;             {run until key pressed}
  37.   TextMode(3);
  38. End.
  39.