program blob_slide;

uses crush13h,crt;

var blob:pointer;
    c: char;
    x,y: integer;
    d:real;
{
Procedure GetImage(x1,y1,x2,y2:Word;Var Img:Pointer;Where:Word);
Var Dx,Dy:Word;
    A,B:Word;
    Segm,Offs:Word;
Begin
     Dx:=Abs(x2-x1)+1;
     Dy:=Abs(y2-y1)+1;
     GetMem(Img,Dx*Dy+4);
     Segm:=Seg(Img^);
     Offs:=Ofs(Img^);
     Move(Dx,Mem[Segm:Offs],2);
     Move(Dy,Mem[Segm:Offs+2],2);
     Offs:=Offs+4;
     For A:=y1 to y2 Do
     For B:=x1 to x2 Do
     Begin
          Mem[Segm:Offs]:=GetPixel(B,A,Where);
          Inc(Offs);
     End;
End;

Procedure KillImage(Var Img:Pointer);
Var Dx,Dy:Word;
    Segm,Offs:Word;
Begin
     Segm:=Seg(Img^);
     Offs:=Ofs(Img^);
     Move(Mem[Segm:Offs],Dx,2);
     Move(Mem[Segm:Offs+2],Dy,2);
     FreeMem(Img,Dx*Dy+4);
End;
}
Procedure PutImage_bob(X,Y,C:Integer;Var Img:Pointer;Where:Word);
const minx=0;
      maxx=319;
      miny=0;
      maxy=199;
Var Dx,Dy:Word;
    A,B:integer;
    Segm,Offs:Word;
    c1,c2,c3:integer;
Begin
     Segm:=Seg(Img^);
     Offs:=Ofs(Img^);
     Move(Mem[Segm:Offs],Dx,2);
     Move(Mem[Segm:Offs+2],Dy,2);
     Offs:=Offs+4;
     for a:=y to y+dy-1 do
     Begin
          for b:=x to x+dx-1 do
          Begin

               if Mem[Segm:Offs]<>c then
               if b>minx then if b<maxx then if a>miny then if a<maxy then
                  begin
                       c1:=getpixel(B,A,where);
                       c2:=mem[segm:offs];
                       c3:=c2+c1;

                       if c3>255 then c3:=255;
                       if c3<0 then c3:=0;
                       if c2<>c then PutPixel(B,A,c3,Where);
                  end;
               Inc(Offs);
          End;
     End;
End;

begin
     video_mode ( $13);
     initvirt;

     loadpcx ('pcx01.pcx',vp[2]);

     getimage (1,4,11,6,blob,vp[2]);

     cls (0,vp[1]);

     y:=-12;
     x:=100;
     repeat

     y:=y+1;
     if y>199 then y:=0;

     d:=random(5);
     d:=d-2;
     x:=round(x+d);
     if x>319 then x:=x-319;
     if x<0 then x:=x+319;

     putimage(x,y,252,blob,vp[1]);
     waitvbl;

     move (mem[vp[1]:0],mem[vga:0],64000);
     if keypressed=true then c:=readkey;
     until c=#27;

     killimage (blob);
     closevirt;
     video_mode ( 03);
end.

{commets: hum... if i get a normal way to put those blob pixels down which
im to lazy to do then the x and y boundaries bug will go obselete.
hum... there must be a better way ti make blobs. you dont understand this...
i call the effects diferent names from what they really are... im trying
to pull off 2d-metaballs lookalike... maybe with a bob... but that would go
erratic... i dunno... fukit... im not inspired to code today...
}