{$m 8000,0,8000}
uses pstuff21;
var
 piece:array[0..10] of graftype;
 CH:CHAR;

procedure drawboard;
var
 lines:array[1..20] of string;
 i,ii,III:integer;
 CH:CHAR;
begin
 lines[ 1]:='!------------------------?';
 lines[ 2]:='|........................|';
 lines[ 3]:='|.!---?.!--?.!--?.--=--..|';
 lines[ 4]:='|.|...|.|..|.|..|...|....|';
 lines[ 5]:='|.<---/.|..|.<-=/...|....|';
 lines[ 6]:='|.|.....\--/.|.|....|.S..|';
 lines[ 7]:='|........................|';
 lines[ 8]:='|........................|';
 lines[ 9]:='|......S........S........|';
 lines[10]:='|..........!?............|';
 lines[11]:='|..........\/............|';
 lines[12]:='|......|........|........|';
 lines[13]:='|......\--------/........|';
 lines[14]:='|........................|';
 lines[15]:='\------------------------/';
 lines[16]:='|........................|';
 lines[17]:='\------------------------/';
 lines[18]:='|........................|';
 lines[19]:='\------------------------/';

 for i:=1 to 19 do
  for ii:=1 to length(lines[i]) do
   putscreen(doubleBACKG,ii*8-8,i*7,piece[pos(lines[i][ii],'!-.?</=S|\')]);
              {PUT EACH PIECE ON THE BACKGROUND SCREEN}

 III:=0;
 CHANGESPRITE(1,PIECE[2],NULL_GRAPH);   {CHANGE SPRITE 1 TO A HORIZ. LINE}
 CHANGESPRITE(2,PIECE[2],NULL_GRAPH);   {CHANGE SPRITE 2 TO THE SAME THING}
 APPEAR(DOUBLEBACKG);                   {SHOW THE BOARD}
 REPEAT
  SCANCODE:=0;
  IF KEYBUFFER THEN CH:=KEYHIT;  {IF A KEY WAS HIT, THEN READ THAT KEY}
  IF SCANCODE=72 THEN      {IF UP ARROW WAS HIT}
   DEC(III,SCREENLINELENGTH*2)  {SUBTRACT ONE SCREEN LINE}
  ELSE IF SCANCODE=80 THEN {IF DOWN ARROW WAS HIT}
   INC(III,SCREENLINELENGTH*2); {ADD ONE SCREEN LINE}
  IF NOT(LCD_OK) THEN         {IF THIS IS NOT ON A PORTFOLIO}
  BEGIN
   MOVESPRITE(0,III DIV SCREENLINELENGTH,1);  {MOVE SPRITE 1 TO WHERE TOP OF
                                               SCREEN IS}
   MOVESPRITE(0,III DIV SCREENLINELENGTH+64,2);{MOVE SPRITE 2 TO WHERE BOTTOM
                                                OF SCREEN IS}
  END;
  SLIDESCREEN(III);    {SLIDE THE SCREEN TO THE POSITION OF III}
  III:=LCDPOSITION;    {ASSIGN THE POSITION RETURNED BY SLIDESCREEN TO III}
  UPDATESPRITES(TRUE);       {REDRAW SPRITES AND SHOW THEM ON SCREEN}

 UNTIL SCANCODE=1;     {QUIT IF ESC KEY IS HIT}
 LOCATELCD(0);         {MOVE SCREEN BACK TO TOP OF SCREEN}
end;

var i:word;
begin
 for i:=0 to screenlength do
  doublebackg[i]:=0;    {CLEAR BACKGROUND SCREEN}
 doubleLOGIC:=doubleBACKG;   {COPY BACKGROUND SCREEN TO LOGICAL SCREEN}
 LOCATELCD(0);               {MOVE SCREEN TO TOP}
 VIDEOMODE(4);               {SET GRAPHICS MODE}

 (*DEFINE SHAPES*)

 PIECE[0]:=NULL_GRAPH;  {ASSIGN A BLANK CHARACTER TO THIS ONE}

 piece[1,1]:=convert('........');
 piece[1,2]:=convert('........');
 piece[1,3]:=convert('.....XXX');
 piece[1,4]:=convert('....X...');
 piece[1,5]:=convert('...X..XX');
 piece[1,6]:=convert('...X.X..');
 piece[1,7]:=convert('...X.X..');

 piece[2,1]:=convert('........');
 piece[2,2]:=convert('........');
 piece[2,3]:=convert('XXXXXXXX');
 piece[2,4]:=convert('........');
 piece[2,5]:=convert('XXXXXXXX');
 piece[2,6]:=convert('........');
 piece[2,7]:=convert('........');

 piece[3,1]:=convert('........');
 piece[3,2]:=convert('........');
 piece[3,3]:=convert('........');
 piece[3,4]:=convert('...XX...');
 piece[3,5]:=convert('........');
 piece[3,6]:=convert('........');
 piece[3,7]:=convert('........');

 piece[4,1]:=convert('........');
 piece[4,2]:=convert('........');
 piece[4,3]:=convert('XXXX....');
 piece[4,4]:=convert('....X...');
 piece[4,5]:=convert('XXX..X..');
 piece[4,6]:=convert('...X.X..');
 piece[4,7]:=convert('...X.X..');

 piece[5,1]:=convert('...X.X..');
 piece[5,2]:=convert('...X.X..');
 piece[5,3]:=convert('...X.XXX');
 piece[5,4]:=convert('...X....');
 piece[5,5]:=convert('...X.XXX');
 piece[5,6]:=convert('...X.X..');
 piece[5,7]:=convert('...X.X..');

 piece[6,1]:=convert('...X.X..');
 piece[6,2]:=convert('...X.X..');
 piece[6,3]:=convert('XXX..X..');
 piece[6,4]:=convert('....X...');
 piece[6,5]:=convert('XXXX....');
 piece[6,6]:=convert('........');
 piece[6,7]:=convert('........');

 piece[7,1]:=convert('........');
 piece[7,2]:=convert('........');
 piece[7,3]:=convert('XXXXXXXX');
 piece[7,4]:=convert('........');
 piece[7,5]:=convert('XXXX.XXX');
 piece[7,6]:=convert('...X.X..');
 piece[7,7]:=convert('...X.X..');

 piece[8,1]:=convert('..XXXX..');
 piece[8,2]:=convert('.X....X.');
 piece[8,3]:=convert('X......X');
 piece[8,4]:=convert('X......X');
 piece[8,5]:=convert('X......X');
 piece[8,6]:=convert('.X....X.');
 piece[8,7]:=convert('..XXXX..');

 piece[9,1]:=convert('...X.X..');
 piece[9,2]:=convert('...X.X..');
 piece[9,3]:=convert('...X.X..');
 piece[9,4]:=convert('...X.X..');
 piece[9,5]:=convert('...X.X..');
 piece[9,6]:=convert('...X.X..');
 piece[9,7]:=convert('...X.X..');

 piece[10,1]:=convert('...X.X..');
 piece[10,2]:=convert('...X.X..');
 piece[10,3]:=convert('...X..XX');
 piece[10,4]:=convert('....X...');
 piece[10,5]:=convert('.....XXX');
 piece[10,6]:=convert('........');
 piece[10,7]:=convert('........');

 DRAWBOARD;
 VIDEOMODE(3);   {SET TO TEXT MODE}
end.