Uses Crt;
Var Stars:Array[0..500] of Record
                              x,y,Plane:Integer;
                            End;
  st_no:Word;

Procedure PutPixel(x,y,col:word);assembler;
{sets pixel (x/y) to color col (Mode 13h)}
asm
  mov ax,0a000h                 {load segment}
  mov es,ax
  mov ax,320                    {Offset = Y*320 + X}
  mul y
  add ax,x
  mov di,ax                     {load offset}
  mov al,byte ptr col           {load color}
  mov es:[di],al                {and set pixel}
End;

Begin
  Randomize;                    {initialize random numbers}
  asm mov ax,13h; int 10h End;  {set Mode 13h}
  Repeat                        {executed once per display}
    For St_no:=0 to 500 do Begin{calculate new position for each star}
      With stars[st_no] do Begin
        PutPixel(x,y,0);        {clear old pixel}
        Dec(x,Plane shr 5 + 1); {continue moving}
        if x <= 0 Then Begin    {left ?}
          x:=319;               {then reinitialize}
          y:=Random(200);
          Plane:=Random(256);
        End;
        PutPixel(x,y,Plane shr 4 + 16);  {set new pixel}
      End;
    End;
  Until KeyPressed;             {run until key pressed}
  TextMode(3);
End.
