{$s-;$a+;$d-;$e-;$g+:$v-;$b-;$i-;$r-}
{$i img20.pas}
{$i pas\clavier.pas}
{$m 4000,0,35000}
type
position=record
         x,y:word;
end;

type
spr=record
   pos:position;
   larg,haut,
   pagex,pagey:word;
   page:byte;
   statu:boolean;
end;

type
anim=record
   count:word;
end;


var
sprite       :array [1..10] of spr;
count,
countb,
ani          :array [1..10] of anim;
nbspr        :word;
holdvecadres :pointer;
number,vites :byte;

procedure lightani(x,y:word;numero,speed:byte);
var
contani:word;
begin
inc(ani[numero].count,speed);
if ani[numero].count>150 then ani[numero].count:=0;
contani:=ani[numero].count;
if contani>0 then if contani<50 then
 movsqr(sprite[1].pagex,
          sprite[1].pagey,
          x,y+4,
          sprite[1].larg,
          sprite[1].haut,
          sprite[1].page,9);

if contani>50 then if contani<100 then
 movsqr(sprite[2].pagex,
          sprite[2].pagey,
          x,y,
          sprite[2].larg,
          sprite[2].haut,
          sprite[2].page,9);

if contani>100 then if contani<150 then
 movsqr(sprite[3].pagex,
          sprite[3].pagey,
          x,y+1,
          sprite[3].larg,
          sprite[3].haut,
          sprite[3].page,9);

end;

procedure ecran;
begin
if statu then
  begin
   copypage(adres[9],
            adres[5],
            32000);
  end;
statu:=not statu;
end;

procedure initvar;
begin
{scrolling}
 lpal('ptab1.img');
 loadimg('ptab2.img',1);
 loadimg('ptab1.img',2);
 saveems(1,1);
 saveems(2,2);
 prepscroll;
 loadimg('ptab1.img',9);
 actupos:=1;
 adres[4]:=adrescroll;
 adres[7]:=adrescroll+4000;
 adres[5]:=$a000;
 rendems(1,7);
 rendems(2,4);
 scrolimage[0]:=100;
 scrolimage[1]:=1;
 scrolimage[2]:=2;
 scrolimage[3]:=100;
 num:=2;

{sprites}
  nbspr:=1;
 number:=0;
loadisc('pspr.img',1);

{sprites 1}
 inc(number);
 sprite[number].pos.y:=0;
 sprite[number].pos.x:=0;
 sprite[number].page:=1;
 sprite[number].pagex:=154;
 sprite[number].pagey:=5;
 sprite[number].larg:=9;
 sprite[number].haut:=30;
 sprite[number].statu:=true;

{sprites 2}
 inc(number);
 sprite[number].pos.y:=0;
 sprite[number].pos.x:=0;
 sprite[number].page:=1;
 sprite[number].pagex:=180;
 sprite[number].pagey:=2;
 sprite[number].larg:=9;
 sprite[number].haut:=34;
 sprite[number].statu:=true;

{sprites 3}
 inc(number);
 sprite[number].pos.y:=0;
 sprite[number].pos.x:=0;
 sprite[number].page:=1;
 sprite[number].pagex:=203;
 sprite[number].pagey:=3;
 sprite[number].larg:=9;
 sprite[number].haut:=33;
 sprite[number].statu:=true;

{affichage}
 statu:=true;
end;

begin
 mode(19);
 instalnewkeyb;
 clearkbd;
 initvar;

  repeat
   {lightani(50,50-actupos,1,1);
   }ecran;
   if keypress(80) then scrollup;
   if keypress(72) then scrolldown;
  until keypress(1);

 delallems(2);
 holdkey;
 textmode(co80);
end.
