program bitkoding;

uses crush13h,crt;

var x,y:integer;
    count1,add1:integer;
    count2,add2:integer;
    c:char;

begin
     video_mode ( $13);
     initvirt;
     inittables;
     loadpcx ('..\skyscape\cloud2.pcx',vp[1]);


     cls (0,vp[2]);
     cls (0,vga);


     for y:=1 to 201 do
     begin
          for x:=1 to 321 do
              begin
                   if (x*y mod 2) = 0 then putpixel (x-1,y-1,10,vp[2]);
                   if (x*y mod 2) <> 0 then putpixel (x-1,y-1,20,vp[2]);
              end;
     end;



     count1:=0;
     add1:=10;

     count2:=0;
     add2:=2;

     repeat
     count1:=count1+add1;
     if count1>1799 then count1:=count1-1259;

     count2:=count2+add2;
     if count2>1799 then count2:=count2-1259;

     for y:=-50 to 50 do
         begin
              for x:=-80 to 80 do
                  begin
                       mem[vga:320*round(100-y)+round(160+x)]:=
                       mem[vp[1]:320*round(100-y)+round(160+x)]+
                       mem[vp[2]:320*round(100-(Y*Cosines^[count1]-X*Sines^[count1])*cosines^[count1])+
                         round(160+(X*Cosines^[count1]+Y*Sines^[count1])*cosines^[count1])];
                  end;
         end;

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


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

     cleartables;
     closevirt;
     video_mode ( 03);
end.