program pcxdist2;

uses crush13h,crt;


var c:char;
    x,y:integer;
    count,add:integer;
    a:integer;
    c1:byte;

procedure putball2 (x,y,c:integer;from,where:word);
var b:integer;
begin
     for b:=-2 to 2 do putpixel (x+b,y-5,c,where);
     for b:=-3 to 3 do putpixel (x+b,y-4,c,where);
     for b:=-4 to 4 do putpixel (x+b,y-3,c,where);
     for b:=-5 to 5 do putpixel (x+b,y-2,c,where);
     for b:=-5 to 5 do putpixel (x+b,y-1,c,where);
     for b:=-5 to 5 do putpixel (x+b,y,c,where);
     for b:=-5 to 5 do putpixel (x+b,y+1,c,where);
     for b:=-5 to 5 do putpixel (x+b,y+2,c,where);
     for b:=-4 to 4 do putpixel (x+b,y+3,c,where);
     for b:=-3 to 3 do putpixel (x+b,y+4,c,where);
     for b:=-2 to 2 do putpixel (x+b,y+5,c,where);
end;

procedure putball3 (x,y,c:integer;from,where:word);
var b:integer;
begin
     for b:=-1 to 1 do putpixel (x+b,y-2,c,where);
     for b:=-2 to 2 do putpixel (x+b,y-1,c,where);
     for b:=-2 to 2 do putpixel (x+b,y,c,where);
     for b:=-2 to 2 do putpixel (x+b,y+1,c,where);
     for b:=-1 to 1 do putpixel (x+b,y+2,c,where);
end;

begin
     video_mode ( $13);
     initvirt;
     inittables;

     loadpcx ('..\skyscape\cloud2.pcx',vp[2]);
     cls (0,vp[1]);

     count:=0;
     add:=1;

     randomize;

     repeat

     count:=count+add;
     if count>1799 then count:=count-1259;

     x:=random (320);
     y:=random (200);

     c1:=mem[vp[2]:x+320*y];

     putball3 (x,y,c1,vp[2],vp[1]);

     if (count mod 2) = 0 then move (mem[vp[1]:0],mem[vga:0],64000);
     waitvbl;
     swapcolors_p (0,255);
     {if (count mod 2) <> 0 then  move (mem[vp[2]:0],mem[vga:0],64000);}


     if keypressed=true then c:=readkey;
     until c=#27;

     cleartables;
     closevirt;
     video_mode ( 03);
end.