program pcxdistortion;

uses crush13h,crt;

var c:char;
    a,b:word;

begin
     video_mode ( $13);
     initvirt;

     cls (0,vga);
     cls (0,vp[1]);
     cls (0,vp[2]);
     loadpcx ('..\..\..\neopaint\pcx\cloud.pcx',vp[2]);

     repeat

     for a:=0 to 199 do
         begin
              if (a mod 2 = 0) then for b:=0 to 319 do
                 begin
                 mem[vp[1]:a*320+b]:=mem[vp[2]:a*320+b]+5;
                 if mem[vp[1]:a*320+b]>255 then mem[vp[1]:a*320+b]:=0;
                 end;
              if (a mod 2 <> 0) then for b:=0 to 319 do
                 begin
                 {mem[vp[1]:a*320+b]:=mem[vp[2]:a*320+b]-1;
                 if mem[vp[1]:a*320+b]<0 then mem[vp[1]:a*320+b]:=255;}
                 mem[vp[1]:a*320+b]:=random(256);
                 end;
         end;

     if keypressed=true then c:=readkey;

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

     until c=#27;

     closevirt;
     video_mode ( 03);
end.