program alias;

uses crt,crush13h;

var a:integer;
    c:char;
    counter,add:integer;

procedure blur_f(from,too:word);
var x,y,aaa,ccc,ccc2:integer;
    shit,shit2:boolean;
    cccc: array [1..5] 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[5]:=mem[from:(x)+(y)*320];
          cccc[4]:=mem[from:(x-1)+(y)*320];
          cccc[3]:=mem[from:(x)+(y-1)*320];

          ccc:=cccc[1];
          shit:=false;
          shit2:=false;
          for aaa:=2 to 5 do
              begin
               if cccc[a]<>ccc then shit:=true;
              end;

          if shit=true then

           begin
            for aaa:=2 to 4 do if cccc[a]<>ccc then shit2:=true;
            if shit2=true
                 then ccc2:=(cccc[1]+cccc[2]+cccc[3]+cccc[4]) div 4
                 else ccc2:=ccc;
            if cccc[5]=ccc2
                 then ccc:=ccc2
                 else ccc:=(ccc2+cccc[5]) div 2;
           end;

          mem[too:x+y*320]:=ccc;
         end;
end;

begin
     video_mode ( $13);
     initvirt;

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

     cls (1,vp[1]);
     cls (1,vp[2]);

     counter:=0;
     add:=2;

     repeat
      setcolor (0,40,0,40);

      counter:=counter+add;
      if counter>200 then add:=-2;
      if counter<0 then add:=2;

      cls (1,vp[1]);
      cls (1,vp[2]);

      for a:=0 to 20 do line (a*10+counter,20+counter,200-counter,a*10,150,vp[2]);

      blur_f (vp[2],vp[1]);
{      move (mem[vp[2]:0],mem[vp[1]:0],64000);}
      move (mem[vp[1]:0],mem[vga:0],64000);

      setcolor (0,0,40,0);
      waitvbl;

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

     closevirt;
     video_mode ( 03);
end.