home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1994 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1994.iso
/
compsrcs
/
games
/
vmsnet
/
tetris
/
part02
< prev
next >
Wrap
Internet Message Format
|
1992-07-01
|
29KB
Path: uunet!caen!kuhub.cc.ukans.edu!nrlvx1.nrl.navy.mil!koffley
Newsgroups: vmsnet.sources.games
Subject: TETRIS_VMS.02_OF_05
Message-ID: <1992Jul2.123900.743@nrlvx1.nrl.navy.mil>
From: koffley@nrlvx1.nrl.navy.mil
Date: 2 Jul 92 12:39:00 -0400
Organization: NRL SPACE SYSTEMS DIVISION
Lines: 1113
-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
XX rotright:=chr(rotrightint);
XX writeln(rotright);
XX writeln('press key to move shape to bottom: ');
XX waitkey(speedint,chan);
XX while (speedint=rightint) or`20
XX (speedint=leftint) or`20
XX (speedint=rotleftint) or
XX (speedint=rotrightint) do
XX waitkey(speedint,chan);
XX speed:=chr(speedint);
XX writeln(speed);
XX writeln('press key to quit game: ');
XX waitkey(quitint,chan);
XX while (quitint=rightint) or`20
XX (quitint=leftint) or`20
XX (quitint=rotleftint) or
XX (quitint=rotrightint) or
XX (quitint=speedint) do
XX waitkey(quitint,chan);
XX quitkey:=chr(quitint);
XX writeln(quitkey);
XX writeln('press key to redraw screen');
XX waitkey(redrawint,chan);
XX while (redrawint=rightint) or
XX (redrawint=leftint) or
XX (redrawint=rotrightint) or
XX (redrawint=rotleftint) or
XX (redrawint=quitint) do
XX waitkey(redrawint,chan);
XX redraw:=chr(redrawint);
XX writeln(redraw);
XX writeln;
XX writeln;
XX writeln;
XX writeln(' Press any key to continue ');
XX waitkey(null,chan);
XXend; `7BKEYDEFINE`7D
XX`7B*******************************************************************`7D
XX
XX
XX
XX`7B***********************************************************************`
V7D
XXprocedure Shapestuff(shape,position,y,x:integer; var screen:screenarray;
XX n:integer);
XXbegin
XX screen`5By,x`5D:=n;
XX if shape = 1 then
XX begin
XX screen`5By,x+1`5D:=n;
XX screen`5By+1,x`5D:=n;
XX screen`5By+1,x+1`5D:=n;
XX end
XX else
XX if shape = 2 then
XX begin
XX if position = 1 then
XX begin
XX screen`5By-1,x`5D:=n;
XX screen`5By+1,x`5D:=n;
XX screen`5By+1,x+1`5D:=n;
XX end
XX else
XX if position = 2 then
XX begin
XX screen`5By,x+1`5D:=n;
XX screen`5By,x-1`5D:=n;
XX screen`5By+1,x-1`5D:=n;
XX end
XX else
XX if position = 3 then
XX begin
XX screen`5By+1,x`5D:=n;
XX screen`5By-1,x`5D:=n;
XX screen`5By-1,x-1`5D:=n;
XX end
XX else
XX if position = 4 then
XX begin
XX screen`5By,x-1`5D:=n;
XX screen`5By,x+1`5D:=n;
XX screen`5By-1,x+1`5D:=n;
XX end;
XX end
XX else
XX if shape = 3 then
XX begin
XX if position = 1 then
XX begin
XX screen`5By-1,x`5D:=n;
XX screen`5By+1,x`5D:=n;
XX screen`5By+1,x-1`5D:=n;
XX end
XX else
XX if position = 2 then
XX begin
XX screen`5By,x+1`5D:=n;
XX screen`5By,x-1`5D:=n;
XX screen`5By-1,x-1`5D:=n;
XX end
XX else
XX if position = 3 then
XX begin
XX screen`5By-1,x`5D:=n;
XX screen`5By+1,x`5D:=n;
XX screen`5By-1,x+1`5D:=n;
XX end
XX else
XX if position = 4 then
XX begin
XX screen`5By,x-1`5D:=n;
XX screen`5By,x+1`5D:=n;
XX screen`5By+1,x+1`5D:=n;
XX end;
XX end
XX else
XX if shape = 4 then
XX begin
XX if position = 1 then
XX begin
XX screen`5By-1,x`5D:=n;
XX screen`5By+1,x`5D:=n;
XX screen`5By,x+1`5D:=n;
XX end
XX else
XX if position = 2 then
XX begin
XX screen`5By+1,x`5D:=n;
XX screen`5By,x-1`5D:=n;
XX screen`5By,x+1`5D:=n;
XX end
XX else
XX if position = 3 then
XX begin
XX screen`5By-1,x`5D:=n;
XX screen`5By+1,x`5D:=n;
XX screen`5By,x-1`5D:=n;
XX end
XX else
XX if position = 4 then
XX begin
XX screen`5By-1,x`5D:=n;
XX screen`5By,x-1`5D:=n;
XX screen`5By,x+1`5D:=n;
XX end;
XX end
XX else
XX if shape = 5 then
XX begin
XX if (position = 1) or (position = 3) then
XX begin
XX screen`5By+1,x`5D:=n;
XX screen`5By,x+1`5D:=n;
XX screen`5By-1,x+1`5D:=n;
XX end
XX else
XX if (position = 2) or (position = 4) then
XX begin
XX screen`5By,x-1`5D:=n;
XX screen`5By+1,x`5D:=n;
XX screen`5By+1,x+1`5D:=n;
XX end;
XX end
XX else
XX if shape = 6 then
XX begin
XX if (position = 1) or (position = 3) then
XX begin
XX screen`5By-1,x`5D:=n;
XX screen`5By,x+1`5D:=n;
XX screen`5By+1,x+1`5D:=n;
XX end
XX else
XX if (position = 2) or (position = 4) then
XX begin
XX screen`5By,x+1`5D:=n;
XX screen`5By+1,x`5D:=n;
XX screen`5By+1,x-1`5D:=n;
XX end;
XX end
XX else
XX if shape = 7 then
XX begin
XX if (position = 1) or (position = 3) then
XX begin
XX screen`5By-1,x`5D:=n;
XX screen`5By+1,x`5D:=n;
XX screen`5By+2,x`5D:=n;
XX end
XX else
XX if (position = 2) or (position = 4) then
XX begin
XX screen`5By,x-2`5D:=n;
XX screen`5By,x-1`5D:=n;
XX screen`5By,x+1`5D:=n;
XX end;
XX end;
XXend;
XX`7B************************************************************************
V****`7D
XX
XX
XX`7B***********************************************************************`
V7D
XXprocedure Check(shape,position,y,x:integer; var change:boolean);
XX
XXbegin
XX change:=true;
XX if shape = 2 then
XX begin
XX if position = 1 then
XX begin
XX if screen`5By-1,x`5D=1 then change:= false
XX else
XX if screen`5By+1,x`5D=1 then change:= false
XX else
XX if screen`5By+1,x+1`5D=1 then change:= false;
XX end
XX else
XX if position = 2 then
XX begin
XX if screen`5By,x+1`5D=1 then change:= false else
XX if screen`5By,x-1`5D=1 then change:= false else
XX if screen`5By+1,x-1`5D=1 then change:= false;
XX end
XX else
XX if position = 3 then
XX begin
XX if screen`5By+1,x`5D=1 then change:= false else
XX if screen`5By-1,x`5D=1 then change:= false else
XX if screen`5By-1,x-1`5D=1 then change:= false;
XX end
XX else
XX if position = 4 then
XX begin
XX if screen`5By,x-1`5D=1 then change:= false else
XX if screen`5By,x+1`5D=1 then change:= false else
XX if screen`5By-1,x+1`5D=1 then change:= false;
XX end;
XX end
XX else
XX if shape = 3 then
XX begin
XX if position = 1 then
XX begin
XX if screen`5By-1,x`5D=1 then change:= false else
XX if screen`5By+1,x`5D=1 then change:= false else
XX if screen`5By+1,x-1`5D=1 then change:= false;
XX end
XX else
XX if position = 2 then
XX begin
XX if screen`5By,x+1`5D=1 then change:= false else
XX if screen`5By,x-1`5D=1 then change:= false else
XX if screen`5By-1,x-1`5D=1 then change:= false;
XX end
XX else
XX if position = 3 then
XX begin
XX if screen`5By-1,x`5D=1 then change:= false else
XX if screen`5By+1,x`5D=1 then change:= false else
XX if screen`5By-1,x+1`5D=1 then change:= false;
XX end
XX else
XX if position = 4 then
XX begin
XX if screen`5By,x-1`5D=1 then change:= false else
XX if screen`5By,x+1`5D=1 then change:= false else
XX if screen`5By+1,x+1`5D=1 then change:= false;
XX end;
XX end
XX else
XX if shape = 4 then
XX begin
XX if position = 1 then
XX begin
XX if screen`5By-1,x`5D=1 then change:= false else
XX if screen`5By+1,x`5D=1 then change:= false else
XX if screen`5By,x+1`5D=1 then change:= false;
XX end
XX else
XX if position = 2 then
XX begin
XX if screen`5By+1,x`5D=1 then change:= false else
XX if screen`5By,x-1`5D=1 then change:= false else
XX if screen`5By,x+1`5D=1 then change:= false;
XX end
XX else
XX if position = 3 then
XX begin
XX if screen`5By-1,x`5D=1 then change:= false else
XX if screen`5By+1,x`5D=1 then change:= false else
XX if screen`5By,x-1`5D=1 then change:= false;
XX end
XX else
XX if position = 4 then
XX begin
XX if screen`5By-1,x`5D=1 then change:= false else
XX if screen`5By,x-1`5D=1 then change:= false else
XX if screen`5By,x+1`5D=1 then change:= false;
XX end;
XX end
XX else
XX if shape = 5 then
XX begin
XX if (position = 1) or (position = 3) then
XX begin
XX if screen`5By+1,x`5D=1 then change:= false else
XX if screen`5By,x+1`5D=1 then change:= false else
XX if screen`5By-1,x+1`5D=1 then change:= false;
XX end
XX else
XX if (position = 2) or (position = 4) then
XX begin
XX if screen`5By,x-1`5D=1 then change:= false else
XX if screen`5By+1,x`5D=1 then change:= false else
XX if screen`5By+1,x+1`5D=1 then change:= false;
XX end;
XX end
XX else
XX if shape = 6 then
XX begin
XX if (position = 1) or (position = 3) then
XX begin
XX if screen`5By-1,x`5D=1 then change:= false else
XX if screen`5By,x+1`5D=1 then change:= false else
XX if screen`5By+1,x+1`5D=1 then change:= false;
XX end
XX else
XX if (position = 2) or (position = 4) then
XX begin
XX if screen`5By,x+1`5D=1 then change:= false else
XX if screen`5By+1,x`5D=1 then change:= false else
XX if screen`5By+1,x-1`5D=1 then change:= false;
XX end;
XX end
XX else
XX if shape = 7 then
XX begin
XX if (position = 1) or (position = 3) then
XX begin
XX if screen`5By-1,x`5D=1 then change:= false else
XX if screen`5By+1,x`5D=1 then change:= false else
XX if screen`5By+2,x`5D=1 then change:= false;
XX end
XX else
XX if (position = 2) or (position = 4) then
XX begin
XX if screen`5By,x-2`5D=1 then change:= false else
XX if screen`5By,x-1`5D=1 then change:= false else
XX if screen`5By,x+1`5D=1 then change:= false;
XX end;
XX end;
XXend;
XX`7B************************************************************************
V****`7D
XX
XX
XX`7B************************************************************************
V****`7D
XXprocedure Create(var shape,position,y,x:integer);
XX
XXvar
XX shapenum:integer;
XX
XXbegin
XX shapenum:=random(1,23);
XX if shapenum < 4 then shape:=1
XX else
XX if shapenum < 7 then shape:=2
XX else
XX if shapenum < 11 then shape:=3
XX else
XX if shapenum < 14 then shape:=4
XX else
XX if shapenum < 17 then shape:=5
XX else
XX if shapenum < 20 then shape:=6
XX else`20
XX if shapenum < 23 then shape:=7
XX else
XX shape:=8;
XX position:=1;
XX y:=2;
XX x:=5;
XXend;
XX`7B************************************************************************
V**`7D
XX
XX
XX`7B***********************************************`7D
XXprocedure PrintLines(screen:screenarray; b:integer);
XX
XXvar
XX a,
XX c:integer;
XX noline:boolean;
XX
XXbegin
XX a:=b;
XX repeat
XX noline:=true;
XX for c:=1 to 10 do
XX begin
XX if screen`5Ba,c`5D = 1 then noline:=false;
XX intochar(xchrhigh,xchrlow,ychrhigh,ychrlow,c+30,a);
XX if screen`5Ba,c`5D = 1 then
XX writeln(chr(27),'`5B',ychrhigh,ychrlow,';',xchrhigh,xchrlow,'H#');
XX if screen`5Ba,c`5D = 0 then
XX writeln(chr(27),'`5B',ychrhigh,ychrlow,';',xchrhigh,xchrlow,'H ');
XX end;
XX a:=a-1;
XX until (noline) or (a = 1);
XXend;
XX`7B************************************************`7D
XX`7B******************************************************`7D
XXprocedure LineDelete(var screen:screenarray; b:integer; var score:integer;
XX level:integer; var lines:integer);
XX
XXvar
XX a,
XX c:integer;
XX
XXbegin
XX for a:= b downto 2 do
XX for c:=1 to 10 do
XX screen`5Ba,c`5D:=screen`5Ba-1,c`5D;
XX printlines(screen,b);
XX if not(flag) then
XX score:=score+(150*level)
XX else
XX score:=score+(100*level);
XX lines:=lines+1;
XX writeln(chr(27),'`5B14;7H',((5*level)-lines):2);
XX writeln(chr(27),'`5B10;7H',score:1);
XXend;
XX`7B***************************************************`7D
XX`7B************************************************************************
V****`7D
XXprocedure LineStuff(var screen:screenarray; var lines:integer;
XX level:integer; var score:integer);
XX
XXvar
XX A,
XX B:integer;
XX line,
XX nothing:boolean;
XX linenum:integer;
XX bounty:integer;
XX
XXbegin
XX linenum:=lines;
XX b:=22;
XX bounty:=0;
XX repeat
XX line:=true;
XX for a:=1 to 10 do
XX if screen`5Bb,a`5D=0 then line:=false;
XX nothing:=true;
XX for a:=1 to 10 do
XX if screen`5Bb,a`5D=1 then nothing:=false;
XX if line then
XX begin
XX LineDelete(screen,b,score,level,lines);
XX b:=b+1;
XX end;
XX b:=b-1;
XX until (nothing = true) or (b = 0);
XX linenum:=lines-linenum;
XX if linenum > 1 then bounty:=((linenum-1) * 200 * level);
XX score:=score+bounty;
XX writeln(chr(27),'`5B10;7H',score:1);
XXend;
XX`7B**********************************************************************`7
VD
XX
XX
XX`7B**********************************************************************`7
VD
XXprocedure bonus(var score:integer; screen:screenarray; level:integer);
XX
XXvar
XX a,
XX b:integer;
XX noline:boolean;
XX
XX
XXbegin
XX a:=22;
XX b:=1;
XX repeat
XX noline:=true;
XX for b:=1 to 10 do
XX if screen`5Ba,b`5D = 1 then noline:=false;
XX a:=a-1;
XX until (a = 0) or (noline = true);
XX
XX if noline then
XX score:=score+(100*a*level);
XXend;
XX`7B******************************************************************`7D
XX
XX`7B*************************************`7D
XXprocedure Printshape(screen:screenarray; y,x:integer);
XX
XXvar
XX a,
XX b,
XX i,
XX j:integer;
XX stuff:packed array`5B1..10`5D of char;
XX
XXbegin
XX if flag2 = TRUE then
XX begin
XX waitx(factor);
XX end;
XX for a:= y-2 to y+3 do
XX begin
XX if (a < 23) and (a > 1) then
XX begin
XX intochar(xchrhigh,xchrlow,ychrhigh,ychrlow,31,a); `20
XX for b:=1 to 10 do
XX begin
XX if screen`5Ba,b`5D = 1 then stuff`5Bb`5D:='#'
XX else
XX if screen`5Ba,b`5D = 2 then stuff`5Bb`5D:='@'
XX else
XX stuff`5Bb`5D:=' ';`20
XX end;
XX writeln(chr(27),'`5B',ychrhigh,ychrlow,';31H',stuff)
XX end;
XX end;
XXend;
XX`7B*************************************`7D
XX
XX`7B**********************************************************************`7
VD
XXprocedure printnext(shape:integer);
XX
XXbegin
XX writeln(chr(27),'`5B07;50H ');
XX writeln(chr(27),'`5B08;50H ');
XX if shape = 1 then
XX begin
XX writeln(chr(27),'`5B05;50H@@');
XX writeln(chr(27),'`5B06;50H@@');
XX end
XX else
XX if shape = 2 then
XX begin
XX writeln(chr(27),'`5B05;50H@ ');
XX writeln(chr(27),'`5B06;50H@ ');
XX writeln(chr(27),'`5B07;50H@@');
XX end
XX else
XX if shape = 3 then
XX begin
XX writeln(chr(27),'`5B05;50H @');
XX writeln(chr(27),'`5B06;50H @');
XX writeln(chr(27),'`5B07;50H@@');
XX end
XX else
XX if shape = 4 then
XX begin
XX writeln(chr(27),'`5B05;50H@ ');
XX writeln(chr(27),'`5B06;50H@@');
XX writeln(chr(27),'`5B07;50H@ ');
XX end
XX else
XX if shape = 5 then
XX begin
XX writeln(chr(27),'`5B05;50H @');
XX writeln(chr(27),'`5B06;50H@@');
XX writeln(chr(27),'`5B07;50H@ ');
XX end
XX else
XX if shape = 6 then
XX begin
XX writeln(chr(27),'`5B05;50H@ ');
XX writeln(chr(27),'`5B06;50H@@');
XX writeln(chr(27),'`5B07;50H @');
XX end
XX else
XX if shape = 7 then
XX begin
XX writeln(chr(27),'`5B05;50H@ ');
XX writeln(chr(27),'`5B06;50H@ ');
XX writeln(chr(27),'`5B07;50H@ ');
XX writeln(chr(27),'`5B08;50H@ ');
XX end;
XXend;
XX`7B**********************************************************************`7
VD
XX
XX
XX`7B**********************************************************************`7
VD
XVprocedure Rotation(var screen:screenarray; shape:integer; var position:inte
Vger
XX;
XX rotint:integer; var y,x:integer);
XX
XXvar
XX newposition:integer;
XX ax:integer;
XX change:boolean;
XX
XXbegin
XX if shape = 7 then
XX begin
XX ax:=x;
XX if x = 10 then ax:=9;
XX if x = 1 then ax:=3;
XX if x = 2 then ax:=3;
XX end
XX else
XX if x =1 then ax:=2
XX else
XX if x =10 then ax:=9
XX else
XX ax:=x;
XX
XX
XX if rotint = -1 then
XX begin
XX if position = 1 then newposition:=4
XX else
XX newposition:=position -1;
XX end
XX else
XX if rotint = 1 then
XX begin
XX if position = 4 then newposition:=1
XX else
XX newposition:=position +1;
XX end;
XX
XX
XX check(shape,newposition,y,ax,change);
XX if change = true then
XX begin
XX shapestuff(shape,position,y,x,screen,0);
XX position:=newposition;
XX x:=ax;
XX shapestuff(shape,position,y,x,screen,2);
XX printshape(screen,y,x);
XX end;
XXend;
XV`7B************************************************************************
V*****
XX`7D
XX
XX
XV`7B************************************************************************
V*****
XX`7D
XXprocedure Movement(var screen:screenarray; shape,position:integer;
XX var y,x:integer; d:integer);
XX
XX
XXvar
XX move:boolean;
XX a,
XX b:integer;
XXbegin
XX move:=true;
XX if d = 1 then
XX begin
XX for a:= x+2 downto x-2 do
XX for b:=y+2 downto y-1 do
XX if (a >1) and (a<11) and (b > 1) and (b < 23) then
XX begin
XX if (a = 10) and (screen`5Bb,a`5D = 2) then move:=false;
XX if (screen`5Bb,a`5D = 1) and (screen`5Bb,a-1`5D = 2) then move:=f
Valse;
XX end;`20
XX end
XX else
XX if d = -1 then
XX begin
XX for a:=x-3 to x+1 do
XX for b:=y-1 to y+2 do
XX if (a >0) and (a<9) and (b>1) and (b<23) then
XX begin
XX if (a = 1) and (screen`5Bb,a`5D = 2) then move:=false;
XX if (screen`5Bb,a`5D = 1) and (screen`5Bb,a+1`5D = 2) then move:=f
Valse;
XX end;
XX end;`20
XX if move = true then
XX begin
XX shapestuff(shape,position,y,x,screen,0);
XX x:=x+d;
XX shapestuff(shape,position,y,x,screen,2);
XX printshape(screen,y,x);
XX end;
XXend;
XX`7B************************************************************************
V`7D
XV`7B************************************************************************
V*****
XX`7D
XVprocedure Down(var screen:screenarray; shape,position:integer; var y,x:inte
Vger
XX;
XX var fast:boolean);
XX
XX
XXvar
XX move:boolean;
XX a,
XX b:integer;
XX
XXbegin
XX move:=true;
XX for b:=y+3 downto y-1 do
XX for a:= x+2 downto x-2 do
XX if (a >0) and (a<11) and (b > 1) and (b < 23) then
XX begin
XX if (b = 22) and (screen`5Bb,a`5D = 2) then move:=false;
XX if (screen`5Bb,a`5D = 1) and (screen`5Bb-1,a`5D = 2) then move:=fal
Vse;
XX end;`20
XX if move = true then
XX begin
XX if fast = true then
XX begin
XX y:=y+1;
XX shapestuff(shape,position,y-1,x,screen,0);
XX printshape(screen,y,x);
XX shapestuff(shape,position,y,x,screen,2);
XX repeat
XX move:=true;
XX for b:=y+3 downto y-1 do
XX for a:= x+2 downto x-2 do
XX if (a >0) and (a<11) and (b > 1) and (b < 23) then
XX begin
XX if (b = 22) and (screen`5Bb,a`5D = 2) then move:=false;
XX if (screen`5Bb,a`5D = 1) and (screen`5Bb-1,a`5D = 2 ) then mo
Vve:=false;
XX end;
XX if move = true then
XX begin
XX y:=y+1;
XX shapestuff(shape,position,y-1,x,screen,0);
XX shapestuff(shape,position,y,x,screen,2);
XX end;
XX until move=false;
XX printshape(screen,y,x);
XX end
XX else
XX begin
XX y:=y+1;
XX screen`5By-1,x`5D:=0;
XX screen`5By,x`5D:=2;
XX shapestuff(shape,position,y-1,x,screen,0);
XX shapestuff(shape,position,y,x,screen,2);
XX printshape(screen,y,x);
XX end;
XX end;
XX fast:=false;
XXend;
XX`7B************************************************************************
V`7D
XX
XXprocedure printall(screen:screenarray; score,lines,level:integer);
XX
XX
XXvar
XX a,
XX b:integer;
XX g,
XX h,
XX xchrhigh,
XX xchrlow,
XX ychrhigh,
XX ychrlow:char;
XX stuff:packed array`5B1..10`5D of char;
XX
XXbegin
XX `20
XX cls;
XX for I:=1 to 22 do
XX begin
XX intochar(g,h,ychrhigh,ychrlow,1,I);
XX writeln(chr(27),'`5B',ychrhigh,ychrlow,';30H`7C `7C');
XX end;
XX writeln(chr(27),'`5B23;30H------------');
XX if flag then writeln(chr(27),'`5B03;49HNEXT');
XX writeln(chr(27),'`5B10;1HSCORE:',score:1);
XX writeln(chr(27),'`5B12;1HLEVEL:',level:1);
XX writeln(chr(27),'`5B14;1HLINES:',((5*level)-lines):2);
XX for a:=1 to 22 do
XX begin
XX intochar(xchrhigh,xchrlow,ychrhigh,ychrlow,31,a);
XX for b:=1 to 10 do
XX begin
XX if screen`5Ba,b`5D = 1 then stuff`5Bb`5D:='#'
XX else
XX stuff`5Bb`5D:=' ';
XX end;
XX writeln(chr(27),'`5B',ychrhigh,ychrlow,';31H',stuff);
XX end;
XXend;
XV`7B************************************************************************
V*****
XX*`7D
XX
XV`7B************************************************************************
V*****
XX*`7D
XXprocedure editshape(key:integer; var nshape:integer);
XX
XX
XXbegin
XX nshape:=key-48;
XX printnext(nshape);
XXend;
XV`7B************************************************************************
V*****
XX*`7D
XX`7B***********************************************`7D
XXprocedure getyearday(inp:datestr; var year,day:integer);
XX
XXvar
XX digit1,
XX digit2,
XX digit3,
XX digit4:integer;
XX offset:integer;
XX
XXbegin
XX offset:= ord('1') + 1;
XX digit1:= ord(inp`5B8`5D) - offset;
XX digit2:= ord(inp`5B9`5D) - offset;
XX digit3:= ord(inp`5B10`5D) - offset;
XX digit4:= ord(inp`5B11`5D) - offset;
XX year:= digit4 + (10*digit3) + (100*digit2) + (1000*digit1);
XX digit1:= ord(inp`5B1`5D) - offset;
XX digit2:= ord(inp`5B2`5D) - offset;
XX day:= digit2 + (10*digit1);
XXend;
XX`7B************************************************`7D
XX
XX`7B**********************************************`7D
XXprocedure getmonth(inp:datestr; var month:integer);
XX
XXbegin
XX `20
XX if (inp`5B4`5D = 'J') and (inp`5B5`5D = 'A') then month:=1
XX else
XX if (inp`5B4`5D = 'F') then month:=2
XX else
XX if (inp`5B4`5D = 'M') and (inp`5B6`5D = 'R') then month:=3
XX else
XX if (inp`5B4`5D = 'A') and (inp`5B5`5D = 'P') then month:=4
XX else
XX if (inp`5B4`5D = 'M') and (inp`5B6`5D = 'Y') then month:=5
XX else
XX if (inp`5B4`5D = 'J') and (inp`5B6`5D = 'N') then month:=7
XX else
XX if (inp`5B4`5D = 'J') then month:=6
XX else
XX if (inp`5B4`5D = 'A') and (inp`5B5`5D = 'U') then month:=8
XX else
XX if (inp`5B4`5D = 'S') then month:=9
XX else
XX if (inp`5B4`5D = 'O') then month:=10
XX else
XX if (inp`5B4`5D = 'N') then month:=11
XX else
XX if (inp`5B4`5D = 'D') then month:=12;
XXend;
XX
XV`7B************************************************************************
V*****
XX*`7D
XV`7B************************************************************************
V*****
XX*`7D
XXfunction older(one,two:datestr):boolean;
XX
XX
XXvar
XX oneyear,
XX twoyear,
XX onemonth,
XX twomonth,
XX oneday,
XX twoday:integer;
XX
XXbegin
XX getyearday(one,oneyear,oneday);
XX getyearday(two,twoyear,twoday);
XX getmonth(one,onemonth);
XX getmonth(two,twomonth);
XX if oneyear < twoyear then older:=true
XX else
XX if onemonth < twomonth then older:=true
XX else
XX if oneday < twoday then older:=true
XX else
XX older:=false;
XXend;
XV`7B************************************************************************
V*****
XX*`7D
XV`7B************************************************************************
V*****
XX*`7D
XX
XX
XV`7B************************************************************************
V*****
XX*`7D
XV`7B************************************************************************
V*****
XX*`7D
XXProcedure MainGame(left,right,rotleft,rotright,speed,quitkey,redraw:char;
XX level:integer; cheat:boolean);
XX
XXvar
XX oldest:integer;
XX saved,
XX saving:saverec;
XX count:integer;
XX quit:boolean;
XX a,b:integer;
XX height:integer;
XX choice:char;
XX nx,
XX ny,
XX nshape,
XX nposition:integer;
XX fast:boolean;
XX gotin:boolean;
XX
XXbegin
XX
XXrandomise;
XXif restored = false then
XXbegin
XX for a:=1 to 22 do
XX for b:=1 to 10 do
XX screen`5Ba,b`5D:=0;
XX score:=0;
XX position:=1;
XX create(shape,position,y,x);
XX lines:=0;
XX shapestuff(shape,position,y,x,screen,2);
XXend;
XXcreate(nshape,nposition,ny,nx);
XXcount:=0;
XXfast:=false;
XXquit:=false;
XXott:=false;
XXcls;
XX
XXprintshape(screen,y,x);
XXprintall(screen,score,lines,level);
XXif restored then`20
XX writeln(chr(27),'`5B10;49HPress any key to continue game')
XXelse
XX writeln(chr(27),'`5B10;49HPress any key to play game');
XXwaitkey(key,chan);
XXwriteln(chr(27),'`5B10;49H ');
XXrestored:=false;
XXif flag then printnext(nshape);
XXrepeat
XX readkey(key,chan);
XX choice:=chr(key);
XX if choice = left then Movement(screen,shape,position,y,x,-1)
XX else
XX if choice = right then movement(screen,shape,position,y,x,1)
XX else
XX if choice = rotleft then Rotation(screen,shape,position,-1,y,x)
XX else
XX if choice = rotright then Rotation(screen,shape,position,1,y,x)
XX else
XX if choice = speed then fast:=true
XX else
XX if (choice in `5B'1'..'7'`5D) and (cheat = true) then editshape(key,nsha
Vpe)
XX else
XX if choice = redraw then
XX begin
XX printall(screen,score,lines,level);
XX if flag then printnext(nshape);
XX end
XX else
XX if choice = quitkey then ott:=true
XX else
XX if choice = '!' then`20
XX begin
XX cls;
XX writeln('%DCL-I-SPAWN, Type eoj to return to Shapes');
XX spawn;
XX printall(screen,score,lines,level);
XX if flag then printnext(nshape);
XX writeln(chr(27),'`5B10;49HPress any key to continue Shapes');
XX waitkey(key,chan);
XX writeln(chr(27),'`5B10;49H ');
XX end
XX else
XX if choice = '@' then
XX begin
XX cls;
XX Writeln( 'Save game option');
XX usernum(userid);
XX if (userid = 'CADP02 ') or
XX (userid = 'CADP03 ') then`20
XX begin`20
XX write('Enter username, MAX 8 letters, RETURN for default: ');
XX userid:=' ';
XX readln(userid);
XX if userid`5B1`5D = ' ' then usernum(userid);
XX end;
XX saving.num:=score;
XX saving.level:=level;
XX saving.outp:=screen;
XX saving.lines:=lines;
XX saving.x:=x;
XX saving.y:=y;
XX saving.shape:=shape;
XX saving.position:=position;
XX saving.user:=userid;
XX DATE(saving.current);
XX open(Save,Savefile,history:=readonly);
XX reset(save);
XX del:=false;
XX for I:=1 to 100 do
XX begin
XX read(save,peeps`5BI`5D);
XX if (del = true) and (peeps`5BI`5D.user = saving.user) then
XX peeps`5BI`5D.user:='UNUSED ';
XX if (del = false) and (peeps`5BI`5D.user = 'UNUSED ') then
XX begin
XX peeps`5BI`5D:=saving;
XX del:=true;
XX end;
XX if (del = false) and (peeps`5BI`5D.user = saving.user) then
XX begin
XX del:=true;
XX peeps`5BI`5D:=saving;
XX end;
XX end;
XX if del = false then
XX begin
XX reset(save);
XX read(save,peeps`5B1`5D);
XX oldest:=1;
XX for I:=2 to 100 do
XX begin
XX read(save,peeps`5BI`5D);
XX if older(peeps`5BI-1`5D.current,peeps`5BI`5D.current) = false the
Vn`20
XX oldest:=I;
XX end;
XX peeps`5Boldest`5D:=saving;
XX end;
XX close(save);
XX open(Save,Savefile,history:=old);
XX rewrite(save);
XX for I:=1 to 100 do
XX write(save,peeps`5BI`5D);
XX close(save);
XX ott:=true;
XX del:=false;
XX writeln('Game saved.');
XX writeln('Press any key for main menu.');
XX waitkey(key,chan);
XX end;
XX if count = 3 then
XX begin
XX height:=y;
XX Down(screen,shape,position,y,x,fast);
XX if height = y then
XX begin
XX for a:=1 to 10 do
XX if screen`5B1,a`5D=2 then ott:=true;
XX shapestuff(shape,position,y,x,screen,1);
XX printshape(screen,y,x);
XX linestuff(screen,lines,level,score);
XX shape:=Nshape;
XX position:=Nposition;
XX y:=Ny;
XX x:=Nx;
XX create(nshape,nposition,ny,nx);
XX if flag then printnext(nshape);
XX shapestuff(shape,position,y,x,screen,2);
XX if lines >= 5*level then
XX begin
XX level:=level+1;
XX bonus(score,screen,level);
XX lines:=0;
XX printall(screen,score,lines,level);
XX if flag then printnext(nshape);
XX end;
XX end;
XX count:=0;
XX end;
XX count:=count+1;
XXuntil OTT = true;
+-+-+-+-+-+-+-+- END OF PART 2 +-+-+-+-+-+-+-+-
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
< Joe Koffley KOFFLEY@NRLVAX.NRL.NAVY.MIL >
< Naval Research Laboratory KOFFLEY@SMOVAX.NRL.NAVY.MIL >
< Space Systems Division AT&T : 202-767-0894 >
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/