{$m 8000,0,8000}
uses pstuff21;
var i:word;
    ball,ballmask:graftype;
    ballx,bally,angle:integer;
    change:boolean;
begin
 for i:=0 to onescreensize-1 do        {USE NORMAL 240x64 GRAPHICS}
  doublelogic[i]:=convert('X.X.X.X.');

 LOADLETTERS('ALPHA.DAT');
 LOGICRITE(3,5,'DEMO NO. 3  BY ROB QUEZADA',TRUE);
 ball[1]:=convert('........');
 ball[2]:=convert('...XX...');
 ball[3]:=convert('..X..X..');
 ball[4]:=convert('.X....X.');
 ball[5]:=convert('..X..X..');
 ball[6]:=convert('...XX...');
 ball[7]:=convert('........');

 ballmask[1]:=convert('..XXXX..');
 ballmask[2]:=convert('.XXXXXX.');
 ballmask[3]:=convert('XXXXXXXX');
 ballmask[4]:=convert('XXXXXXXX');
 ballmask[5]:=convert('XXXXXXXX');
 ballmask[6]:=convert('.XXXXXX.');
 ballmask[7]:=convert('..XXXX..');

 changesprite(1,ball,ballmask); {DEFINE SPRITES}
 CHANGESPRITE(2,BALL,BALLMASK);
 angle:=0;
 videomode(4);
 doublebackg:=doublelogic;{COPY LOGIC SCREEN TO BACKGROUND SCREEN}
 appear(doublelogic);
 change:=false;
 sprite[1].slow:=true;    {MAKE SPRITE CLEAN ITSELF UP WHEN MOVING}
 sprite[2].slow:=false;   {DON'T MAKE IT CLEAN UP TO SHOW USER}
 ballx:=50;bally:=20;
 repeat
  case angle of
   0:begin dec(ballx);dec(bally);end;
   1:begin dec(ballx);inc(bally);end;
   2:begin inc(ballx);dec(bally);end;
   3:begin inc(ballx);inc(bally);end;
  end;
  if bally<8 then begin bally:=8;change:=true;end;
  if bally>57 then begin bally:=57;change:=true;end;
  if ballx<8 then begin ballx:=8;change:=true;end;
  if ballx>232 then begin ballx:=232;change:=true;end;

  if change then
  begin
   if bally=8 then inc(angle);
   if bally=57 then dec(angle);
   if ballx=8 then inc(angle,2);
   if ballx=232 then dec(angle,2);
   change:=false;
  end;
  movesprite(ballx,bally,1);       {SET SPRITE 1 POSITION}
  MOVESPRITE(240-BALLX,64-BALLY,2);{SET SPRITE 2 POSITION}
  updatesprites(true);             {UPDATE SPRITES AND SHOW THEM}
 until keybuffer;                  {KEEP ON GOING UNTIL A KEY IS HIT}
 i:=ord(keyhit);                   {READ THAT KEY IN BUFFER}
 videomode(3);                     {ENTER TEXT MODE}
end.
