program radialblur;

uses crush13h,crt;

var x,y,count,counter: integer;
    c: char;
    cccc: array [1..9] of integer;
    ccc,aaa:integer;

begin
     video_mode ( $13);
     initvirt;

     randomize;
     c:=' ';
     for x:=0 to 255 do setcolor (x ,x div 4, x div 4, x div 4);

     loadpcx('tunel.pcx',vp[2]);
     cls (0,vp[1]);

     count:=0;

     repeat
           count:=count+1;
           if count>319 then count:=0;

           line(count,10,319-count,190,4,vp[1]);
           line(319-count,10,count,190,4,vp[1]);

            for x:=0 to 320 do for y:=0 to 200 do
         begin
          cccc[1]:=mem[vp[1]:(x+1)+(y+1)*320];
          cccc[2]:=mem[vp[1]:(x)+(y+1)*320];
          cccc[3]:=mem[vp[1]:(x-1)+(y+1)*320];
          cccc[4]:=mem[vp[1]:(x+1)+(y)*320];
          cccc[5]:=mem[vp[1]:(x)+(y)*320];
          cccc[6]:=mem[vp[1]:(x-1)+(y)*320];
          cccc[7]:=mem[vp[1]:(x+1)+(y-1)*320];
          cccc[8]:=mem[vp[1]:(x)+(y-1)*320];
          cccc[9]:=mem[vp[1]:(x-1)+(y-1)*320];
          ccc:=0;
          counter:=0;
          for aaa:=1 to 9 do
              begin
                   {if cccc[aaa]<>0 then
                      begin}
                           counter:=counter+1;
                           ccc:=ccc+cccc[aaa];
                     { end;  }
              end;
          counter:=counter+1;
          ccc:=ccc+mem[vp[2]:x+y*320];
          if mem[vp[1]:x+y*320]<>0 then mem[vga:x+y*320]:=round(ccc div counter)-1;
      end;

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

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

     closevirt;
     video_mode ( 03);
end.