program stars;

uses crush13h;

var a,x,y:integer;

procedure blur_f(from,too:word);
var x,y,aaa,ccc,ccc2,counter:integer;
    cccc: array [1..9] of integer;
begin
     for x:=1 to 318 do for y:=1 to 198 do
         begin
          cccc[1]:=mem[from:(x)+(y+1)*320];
          cccc[2]:=mem[from:(x+1)+(y)*320];
          cccc[3]:=mem[from:(x)+(y)*320];
          cccc[4]:=mem[from:(x-1)+(y)*320];
          cccc[5]:=mem[from:(x)+(y-1)*320];

               ccc2:=(((cccc[1]+cccc[2]+cccc[4]+cccc[5]) div 4) + cccc[3]) div 2;
               mem[too:x+y*320]:=ccc2;

         end;
end;

procedure blur(from,too:word);
var x,y,aaa,ccc,ccc2,counter:integer;
    cccc: array [1..9] of integer;
begin
     for x:=1 to 318 do for y:=1 to 198 do
         begin
          cccc[1]:=mem[from:(x+1)+(y+1)*320];
          cccc[2]:=mem[from:(x)+(y+1)*320];
          cccc[3]:=mem[from:(x-1)+(y+1)*320];
          cccc[4]:=mem[from:(x+1)+(y)*320];
          cccc[5]:=mem[from:(x)+(y)*320];
          cccc[6]:=mem[from:(x-1)+(y)*320];
          cccc[7]:=mem[from:(x+1)+(y-1)*320];
          cccc[8]:=mem[from:(x)+(y-1)*320];
          cccc[9]:=mem[from:(x-1)+(y-1)*320];

          ccc2:=cccc[1];
          counter:=0;
          for aaa:=1 to 9 do if cccc[aaa]<>ccc2 then counter:=1;

          ccc:=0;
          if counter=1
           then
             begin
                  counter:=0;
                  for aaa:=1 to 9 do
                   begin
                           counter:=counter+1;
                           ccc:=ccc+cccc[aaa];
                   end;
                  mem[too:x+y*320]:=trunc(ccc div counter);
             end
           else mem[too:x+y*320]:=ccc2;
         end;
end;

begin

     video_mode ( $13);
     initvirt;
     cls (0,vp[1]);

     randomize;

     for a:=0 to 255 do setcolor (a,a div 4, a div 4, a div 4);

     for a:=0 to 1000 do
     begin
          x:=random (320);
          y:=random (200);
          putpixel (x,y,random(256),vp[1]);
     end;



     move (mem[vp[1]:0],mem[vga:0],64000);


     readln;

     closevirt;
     video_mode ( 03);

end.