I'm sorry, but you've pushed me to the point of insanity!! I pre-owned an Atari 1040STFM that used GFA Basic 3.0. I do not destroy anything.. to the point where I keep everything, including emails. To follow was my first major attempt at Tetris on the Atari STFM using GFA Basic. The full source is supplied, so if you have GFA Basic and an Atari ST, go right and play the game
REM
REM T E T R I S
REM
REM Original idea from IBM PC, re-programmed using GFA-BASIC v3 and Compiler
REM
REM Programmed by
REM Paul S J Millard
REM
res=XBIOS(4)
IF res<>0 THEN
ALERT 1," Low resolution only",0,"Sorry",dummy%
END
ENDIF
' Define variables and playing area
'
OPTION BASE 0
DIM m(12,21) !Playing zone for shapes to form
DIM stat(7) !Statistics index
select=FALSE !Either shape is display or not
now=0 !Holds current shape number. (1-7)
next=0 !Selects the nest random shape
rot=1 !Which rotation state shape is in
min=0 !Minimum that x can be before stopping
max=0 !maximum that x can be before stopping
loopx=0 !Used for loops
loopy=0 !Also used for loops
y=1 !Height of shape within matrix
x=1 !Position of shape within matrix
dot=8
lines=0 !Number of lines formed, part of score
score=0 !Actual score
k$="" !Present key pressed
loop=0 !Used with FOR and NEXT commands
DIM scores(19),name$(19) !Define score and name table
IF EXIST("A:\TETRIS.RES")=TRUE THEN
GOSUB load_scores
ELSE
FOR y=0 TO 19
scores(y)=0
LET name$(y)="......................"
NEXT y
ENDIF
'
DO
GOSUB title
~INP(2)
GOSUB asklevel
score=0
lines=0
ARRAYFILL stat(),0
GOSUB gamescreen
GOSUB start
GOSUB score
~INP(2)
LOOP
> PROCEDURE title
CLS
VSETCOLOR 0,0,0,0
VSETCOLOR 1,7,7,7
VSETCOLOR 2,2,0,7
PRINT AT(1,1);CHR$(27);"b";CHR$(RAND(14)+1);
RESTORE titledata
FOR loop=1 TO 5
READ line$
FOR loopx=1 TO LEN(line$)
IF VAL(MID$(line$,loopx,1))=1 THEN
LOCATE 8+loopx,2+loop
PRINT "#";
ELSE
LOCATE 8+loopx,2+loop
PRINT " "
ENDIF
NEXT loopx
line$=""
NEXT loop
PRINT CHR$(27)+"b"+CHR$(15);
LOCATE 20-31/2,10
PRINT "Game origination from IBM PC800"
LOCATE 20-27/2,13
PRINT "Reprogrammed by P.J.Millard"
LOCATE 20-18/2,16
PRINT "For the ATARI STFM"
LOCATE 20-32/2,19
PRINT "Coded in GFA Advanced BASIC 3.7e"
BOX 1,1,319,199
titledata:
DATA "111 111 111 111 111 111"
DATA " 1 1 1 1 1 1 1 "
DATA " 1 111 1 111 1 111"
DATA " 1 1 1 11 1 1"
DATA " 1 111 1 1 1 111 111"
RETURN
> PROCEDURE asklevel
CLS
REPEAT
BOX 1,1,319,199
LOCATE 3,12
PRINT "Please enter level (0-9)?";
REPEAT
k$=INKEY$
UNTIL k$<>""
lev=VAL(k$)
DEFTEXT 14,4,0,12
TEXT 220,96,STR$(lev)
UNTIL lev>=0 AND lev<=9
PAUSE 60
RETURN
> PROCEDURE gamescreen
ERASE m()
DIM m(12,21)
SETCOLOR 1,0,7,7
SETCOLOR 2,0,7,0
SETCOLOR 3,7,7,7
SETCOLOR 4,7,0,7
SETCOLOR 5,7,3,0
SETCOLOR 6,7,0,0
SETCOLOR 7,0,0,4
CLS
FOR loop=0 TO 11
m(loop,21)=1
NEXT loop
FOR loop=1 TO 21
m(0,loop)=1
m(11,loop)=1
NEXT loop
FOR loop=1 TO 21
LOCATE 31,loop
PRINT CHR$(27)+"b"+CHR$(7);"#";
LOCATE 20,loop
PRINT "#";
NEXT loop
sel=FALSE
y=2
x=14
rotate=1
FOR now=1 TO 7
shape(1,0)
y=y+3
NEXT now
PRINT CHR$(27);"c";CHR$(0);
LOCATE 20,21
PRINT "############"
BOX 1,1,319,199
LOCATE 21,1
PRINT " ";
PRINT AT(4,9);CHR$(27);"b";CHR$(15);"Select:"
LOCATE 29,23
PRINT "Statistics:";
LOCATE 1,15
PRINT AT(2,15);" 1:SELECT"
PRINT AT(2,16);" 6:SPEED UP"
PRINT AT(2,17);" 7:LEFT "
PRINT AT(2,18);" 8:ROTATE"
PRINT AT(2,19);" 9:RIGHT"
PRINT AT(2,20);" SPACE:DROP"
PRINT AT(2,21);" Q:QUIT"
GOSUB printscore
GOSUB printlines
GOSUB printlevel
DEFTEXT 10,16,0,10
TEXT 20,185,"TETRIS"
FOR loopx=21 TO 30
FOR loopy=1 TO 20
PRINT AT(loopx,loopy);CHR$(27);"b";CHR$(dot);".";
NEXT loopy
NEXT loopx
RETURN
> PROCEDURE printlevel
level=lev+INT(score/1000)
PRINT AT(2,2);CHR$(27);"b";CHR$(15);;CHR$(27);"c";CHR$(0);"Current level:";level
RETURN
> PROCEDURE printscore
PRINT AT(2,4);CHR$(27);"b";CHR$(15);;CHR$(27);"b";CHR$(15);"Your score:";score;
RETURN
> PROCEDURE printlines
PRINT AT(2,6);CHR$(27);"b";CHR$(15);;CHR$(27);"b";CHR$(15);"No. of lines:";lines;
RETURN
> PROCEDURE statistic
FOR loop=1 TO 7
PRINT AT(38,-1+(loop*3));CHR$(27);"c";CHR$(0);stat(loop);
NEXT loop
RETURN
> PROCEDURE start
score=0
nm$=""
lines=0
sel=0
next=INT(RAND(7))+1
now=INT(RAND(7))+1
INC stat(now)
GOSUB statistic
go:
x=5
y=2
rotate=1
GOSUB shape(1,0)
GOSUB check
IF colide=TRUE THEN
finished=TRUE
ENDIF
REPEAT
INC delay
IF delay>(910-level*100) THEN
droplabel:
GOSUB move
delay=0
IF colide=TRUE THEN
line
score=score+y
GOSUB printlevel
GOSUB printlines
GOSUB printscore
tempsel=sel
sel=0
select
sel=tempsel
tempsel=0
now=next
next=INT(RAND(7))+1
INC stat(now)
GOSUB statistic
GOSUB select
GOTO go
ENDIF
ENDIF
k$=UPPER$(INKEY$)
IF k$="7" THEN
GOSUB left
ENDIF
IF k$="8" THEN
GOSUB rotate
ENDIF
IF k$="9" THEN
GOSUB right
ENDIF
IF k$=" " THEN
GOSUB drop
GOTO droplabel
ENDIF
IF k$="1" THEN
IF sel=TRUE THEN
sel=FALSE
select
GOTO endsel
ENDIF
IF sel=FALSE THEN
sel=TRUE
select
ENDIF
endsel:
ENDIF
IF k$="6" THEN
INC lev
IF lev>9 THEN
lev=9
ENDIF
GOSUB printlevel
ENDIF
UNTIL k$="Q" OR finished=TRUE
FOR loop=15 DOWNTO 1
SOUND 1,loop,12-loop/2,8,2
SOUND 3,loop,1+loop/2,2,2
NEXT loop
finished=FALSE
RETURN
> PROCEDURE shape(c,set)
PRINT AT(1,1);CHR$(27);"c";CHR$(0);
IF now=1 THEN
IF c=1 THEN
col=1
ELSE
col=0
ENDIF
' ##
' *#
IF rotate=1 OR rotate=3 THEN
IF set=1 THEN
m(x-1,y-1)=col
m(x,y-1)=col
m(x,y)=col
m(x+1,y)=col
ENDIF
j=0
IF c>0 THEN
PRINT AT(20+x-1,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y-1);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x+1,y);" ";
ELSE
PRINT AT(20+x-1,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y-1);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x+1,y);".";
ENDIF
ENDIF
' #
' *#
' #
IF rotate=2 OR rotate=4 THEN
IF set=1 THEN
m(x+1,y-1)=col
m(x+1,y)=col
m(x,y)=col
m(x,y+1)=col
ENDIF
j=1
IF c>0 THEN
PRINT AT(20+x+1,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x+1,y);" ";
PRINT AT(20+x,y+1);" ";
ELSE
PRINT AT(20+x+1,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x+1,y);".";
PRINT AT(20+x,y+1);".";
ENDIF
ENDIF
ENDIF
IF now=2 THEN
IF c=1 THEN
col=2
ELSE
col=0
ENDIF
' ##
' #*
IF rotate=1 OR rotate=3 THEN
IF set=1 THEN
m(x-1,y)=col
m(x,y)=col
m(x,y-1)=col
m(x+1,y-1)=col
ENDIF
j=0
IF c>0 THEN
PRINT AT(20+x-1,y);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x,y-1);" ";
PRINT AT(20+x+1,y-1);" ";
ELSE
PRINT AT(20+x-1,y);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x,y-1);".";
PRINT AT(20+x+1,y-1);".";
ENDIF
ENDIF
' #
' *#
' #
IF rotate=2 OR rotate=4 THEN
IF set=1 THEN
m(x,y-1)=col
m(x,y)=col
m(x+1,y)=col
m(x+1,y+1)=col
ENDIF
j=1
IF c>0 THEN
PRINT AT(20+x,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x+1,y);" ";
PRINT AT(20+x+1,y+1);" ";
ELSE
PRINT AT(20+x,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x+1,y);".";
PRINT AT(20+x+1,y+1);".";
ENDIF
ENDIF
ENDIF
IF now=3
IF c=1 THEN
col=3
ELSE
col=0
ENDIF
' #
' #*#
IF rotate=1 THEN
IF set=1 THEN
m(x-1,y-1)=col
m(x-1,y)=col
m(x,y)=col
m(x+1,y)=col
ENDIF
j=0
IF c>0 THEN
PRINT AT(20+x-1,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x-1,y);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x+1,y);" ";
ELSE
PRINT AT(20+x-1,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x-1,y);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x+1,y);".";
ENDIF
ENDIF
' ##
' *
' #
IF rotate=2 THEN
IF set=1 THEN
m(x+1,y-1)=col
m(x,y-1)=col
m(x,y)=col
m(x,y+1)=col
ENDIF
j=1
IF c>0 THEN
PRINT AT(20+x+1,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y-1);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x,y+1);" ";
ELSE
PRINT AT(20+x+1,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y-1);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x,y+1);".";
ENDIF
ENDIF
' #*#
' #
IF rotate=3 THEN
IF set=1 THEN
m(x-1,y)=col
m(x,y)=col
m(x+1,y)=col
m(x+1,y+1)=col
ENDIF
j=1
IF c>0 THEN
PRINT AT(20+x-1,y);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x+1,y);" ";
PRINT AT(20+x+1,y+1);" ";
ELSE
PRINT AT(20+x-1,y);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x+1,y);".";
PRINT AT(20+x+1,y+1);".";
ENDIF
ENDIF
' #
' *
' ##
IF rotate=4 THEN
IF set=1 THEN
m(x,y-1)=col
m(x,y)=col
m(x,y+1)=col
m(x-1,y+1)=col
ENDIF
j=1
IF c>0 THEN
PRINT AT(20+x,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x,y+1);" ";
PRINT AT(20+x-1,y+1);" ";
ELSE
PRINT AT(20+x,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x,y+1);".";
PRINT AT(20+x-1,y+1);".";
ENDIF
ENDIF
ENDIF
IF now=4 THEN
IF c=1 THEN
col=4
ELSE
col=0
ENDIF
' #*#
' #
IF rotate=1 THEN
IF set=1 THEN
m(x-1,y)=col
m(x,y)=col
m(x+1,y)=col
m(x-1,y+1)=col
ENDIF
j=1
IF c>0 THEN
PRINT AT(20+x-1,y);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x+1,y);" ";
PRINT AT(20+x-1,y+1);" ";
ELSE
PRINT AT(20+x-1,y);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x+1,y);".";
PRINT AT(20+x-1,y+1);".";
ENDIF
ENDIF
' ##
' *
' #
IF rotate=2 THEN
IF set=1 THEN
m(x-1,y-1)=col
m(x,y-1)=col
m(x,y)=col
m(x,y+1)=col
ENDIF
j=1
IF c>0 THEN
PRINT AT(20+x-1,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y-1);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x,y+1);" ";
ELSE
PRINT AT(20+x-1,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y-1);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x,y+1);".";
ENDIF
ENDIF
' #
' #*#
IF rotate=3 THEN
IF set=1 THEN
m(x+1,y-1)=col
m(x-1,y)=col
m(x,y)=col
m(x+1,y)=col
ENDIF
j=0
IF c>0 THEN
PRINT AT(20+x+1,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x-1,y);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x+1,y);" ";
ELSE
PRINT AT(20+x+1,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x-1,y);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x+1,y);".";
ENDIF
ENDIF
' #
' *
' ##
IF rotate=4 THEN
IF set=1 THEN
m(x,y-1)=col
m(x,y)=col
m(x,y+1)=col
m(x+1,y+1)=col
ENDIF
j=1
IF c>0 THEN
PRINT AT(20+x,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x,y+1);" ";
PRINT AT(20+x+1,y+1);" ";
ELSE
PRINT AT(20+x,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x,y+1);".";
PRINT AT(20+x+1,y+1);".";
ENDIF
ENDIF
ENDIF
IF now=5 THEN
IF c=1 THEN
col=5
ELSE
col=0
ENDIF
' #*#
' #
IF rotate=1 THEN
IF set=1 THEN
m(x-1,y)=col
m(x,y)=col
m(x+1,y)=col
m(x,y+1)=col
ENDIF
j=1
IF c>0 THEN
PRINT AT(20+x-1,y);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x+1,y);" ";
PRINT AT(20+x,y+1);" ";
ELSE
PRINT AT(20+x-1,y);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x+1,y);".";
PRINT AT(20+x,y+1);".";
ENDIF
ENDIF
' #
' #*
' #
IF rotate=2 THEN
IF set=1 THEN
m(x,y-1)=col
m(x,y)=col
m(x-1,y)=col
m(x,y+1)=col
ENDIF
j=1
IF c>0 THEN
PRINT AT(20+x,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x-1,y);" ";
PRINT AT(20+x,y+1);" ";
ELSE
PRINT AT(20+x,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x-1,y);".";
PRINT AT(20+x,y+1);".";
ENDIF
ENDIF
' #
' #*#
IF rotate=3 THEN
IF set=1 THEN
m(x-1,y)=col
m(x,y)=col
m(x+1,y)=col
m(x,y-1)=col
ENDIF
j=0
IF c>0 THEN
PRINT AT(20+x,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x-1,y);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x+1,y);" ";
ELSE
PRINT AT(20+x,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x-1,y);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x+1,y);".";
ENDIF
ENDIF
' #
' *#
' #
IF rotate=4 THEN
IF set=1 THEN
m(x,y-1)=col
m(x,y)=col
m(x+1,y)=col
m(x,y+1)=col
ENDIF
j=1
IF c>0 THEN
PRINT AT(20+x,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x+1,y);" ";
PRINT AT(20+x,y+1);" ";
ELSE
PRINT AT(20+x,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x+1,y);".";
PRINT AT(20+x,y+1);".";
ENDIF
ENDIF
ENDIF
IF now=6 THEN
IF c=1 THEN
col=6
ELSE
col=0
ENDIF
' #*##
IF rotate=1 OR rotate=3 THEN
IF set=1 THEN
m(x-1,y)=col
m(x,y)=col
m(x+1,y)=col
m(x+2,y)=col
ENDIF
j=0
IF c>0 THEN
PRINT AT(20+x-1,y);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x+1,y);" ";
PRINT AT(20+x+2,y);" ";
ELSE
PRINT AT(20+x-1,y);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x+1,y);".";
PRINT AT(20+x+2,y);".";
ENDIF
ENDIF
' #
' *
' #
' #
IF rotate=2 OR rotate=4 THEN
IF set=1 THEN
m(x,y-1)=col
m(x,y)=col
m(x,y+1)=col
m(x,y+2)=col
ENDIF
j=2
IF c>0 THEN
PRINT AT(20+x,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x,y+1);" ";
PRINT AT(20+x,y+2);" ";
ELSE
PRINT AT(20+x,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x,y+1);".";
PRINT AT(20+x,y+2);".";
ENDIF
ENDIF
ENDIF
IF now=7 THEN
IF c=1 THEN
col=7
ELSE
col=0
ENDIF
' ##
' *#
IF rotate=1 OR rotate=2 OR rotate=3 OR rotate=4 THEN
IF set=1 THEN
m(x,y-1)=col
m(x+1,y-1)=col
m(x,y)=col
m(x+1,y)=col
ENDIF
j=0
IF c>0 THEN
PRINT AT(20+x,y-1);CHR$(27);"c";CHR$(col);" ";
PRINT AT(20+x+1,y-1);" ";
PRINT AT(20+x,y);" ";
PRINT AT(20+x+1,y);" ";
ELSE
PRINT AT(20+x,y-1);CHR$(27);"b";CHR$(dot);".";
PRINT AT(20+x+1,y-1);".";
PRINT AT(20+x,y);".";
PRINT AT(20+x+1,y);".";
ENDIF
ENDIF
ENDIF
RETURN
> PROCEDURE check
colide=FALSE
IF now=1 THEN
IF rotate=1 OR rotate=3 THEN
' ##
' *#
IF m(x-1,y-1)>0 OR m(x,y-1)>0 OR m(x,y)>0 OR m(x+1,y)>0 THEN
colide=TRUE
ENDIF
ENDIF
IF rotate=2 OR rotate=4 THEN
' #
' *#
' #
IF m(x+1,y-1)>0 OR m(x,y)>0 OR m(x+1,y)>0 OR m(x,y+1)>0 THEN
colide=TRUE
ENDIF
ENDIF
ENDIF
IF now=2 THEN
IF rotate=1 OR rotate=3 THEN
' ##
' #*
IF m(x-1,y)>0 OR m(x,y)>0 OR m(x,y-1)>0 OR m(x+1,y-1)>0 THEN
colide=TRUE
ENDIF
ENDIF
IF rotate=2 OR rotate=4 THEN
' #
' *#
' #
IF m(x,y-1)>0 OR m(x,y)>0 OR m(x+1,y)>0 OR m(x+1,y+1)>0 THEN
colide=TRUE
ENDIF
ENDIF
ENDIF
IF now=3 THEN
IF rotate=1 THEN
' #
' #*#
IF m(x-1,y-1)>0 OR m(x-1,y)>0 OR m(x,y)>0 OR m(x+1,y)>0 THEN
colide=TRUE
ENDIF
ENDIF
IF rotate=2 THEN
' ##
' *
' #
IF m(x,y-1)>0 OR m(x+1,y-1)>0 OR m(x,y)>0 OR m(x,y+1)>0 THEN
colide=TRUE
ENDIF
ENDIF
IF rotate=3 THEN
' #*#
' #
IF m(x-1,y)>0 OR m(x,y)>0 OR m(x+1,y)>0 OR m(x+1,y+1)>0 THEN
colide=TRUE
ENDIF
ENDIF
IF rotate=4 THEN
' #
' *
' ##
IF m(x,y-1)>0 OR m(x,y)>0 OR m(x-1,y+1)>0 OR m(x,y+1)>0 THEN
colide=TRUE
ENDIF
ENDIF
ENDIF
IF now=4 THEN
IF rotate=1 THEN
' #*#
' #
IF m(x-1,y)>0 OR m(x,y)>0 OR m(x+1,y)>0 OR m(x-1,y+1)>0 THEN
colide=TRUE
ENDIF
ENDIF
IF rotate=2 THEN
' ##
' *
' #
IF m(x-1,y-1)>0 OR m(x,y-1)>0 OR m(x,y)>0 OR m(x,y+1)>0 THEN
colide=TRUE
ENDIF
ENDIF
IF rotate=3 THEN
' #
' #*#
IF m(x-1,y)>0 OR m(x,y)>0 OR m(x+1,y-1)>0 OR m(x+1,y)>0 THEN
colide=TRUE
ENDIF
ENDIF
IF rotate=4 THEN
' #
' *
' ##
IF m(x,y-1)>0 OR m(x,y)>0 OR m(x,y+1)>0 OR m(x+1,y+1)>0 THEN
colide=TRUE
ENDIF
ENDIF
ENDIF
IF now=5 THEN
IF rotate=1 THEN
' #*#
' #
IF m(x-1,y)>0 OR m(x,y)>0 OR m(x+1,y)>0 OR m(x,y+1)>0 THEN
colide=TRUE
ENDIF
ENDIF
IF rotate=2 THEN
' #
' #*
' #
IF m(x-1,y)>0 OR m(x,y-1)>0 OR m(x,y)>0 OR m(x,y+1)>0 THEN
colide=TRUE
ENDIF
ENDIF
IF rotate=3 THEN
' #
' #*#
IF m(x,y-1)>0 OR m(x-1,y)>0 OR m(x,y)>0 OR m(x+1,y)>0 THEN
colide=TRUE
ENDIF
ENDIF
IF rotate=4 THEN
' #
' *#
' #
IF m(x,y-1)>0 OR m(x,y)>0 OR m(x+1,y)>0 OR m(x,y+1)>0 THEN
colide=TRUE
ENDIF
ENDIF
ENDIF
IF now=6 THEN
IF rotate=1 OR rotate=3 THEN
' #*##
IF m(x-1,y)>0 OR m(x,y)>0 OR m(x+1,y)>0 OR m(x+2,y)>0 THEN
colide=TRUE
ENDIF
ENDIF
IF rotate=2 OR rotate=4 THEN
' #
' *
' #
' #
IF m(x,y-1)>0 OR m(x,y)>0 OR m(x,y+1)>0 OR m(x,y+2)>0 THEN
colide=TRUE
ENDIF
ENDIF
ENDIF
IF now=7 THEN
IF rotate=1 OR rotate=2 OR rotate=3 OR rotate=4 THEN
' ##
' *#
IF m(x,y-1)>0 OR m(x+1,y-1)>0 OR m(x,y)>0 OR m(x+1,y)>0 THEN
colide=TRUE
ENDIF
ENDIF
ENDIF
RETURN
> PROCEDURE select
tempx=x
tempy=y
temprot=rotate
tempnow=now
now=next
IF sel=TRUE THEN
x=-13
y=12
rotate=1
shape(1,0)
x=tempx
y=tempy
rotate=temprot
now=tempnow
ENDIF
IF sel=FALSE THEN
PRINT AT(5,11);CHR$(27);"c";CHR$(0);" ";
PRINT AT(5,12);" ";
PRINT AT(5,13);" ";
PRINT AT(5,14);" ";
ENDIF
RETURN
> PROCEDURE move
INC y
check
IF colide=TRUE THEN
DEC y
shape(1,1)
ELSE
DEC y
shape(0,0)
INC y
shape(1,0)
ENDIF
RETURN
> PROCEDURE rotate
INC rotate
IF rotate>4 THEN
rotate=1
ENDIF
GOSUB check
IF colide=TRUE THEN
DEC rotate
IF rotate<1 THEN
rotate=4
ENDIF
ELSE
DEC rotate
IF rotate<1 THEN
rotate=4
ENDIF
shape(0,0)
INC rotate
IF rotate>4 THEN
rotate=1
ENDIF
shape(1,0)
ENDIF
RETURN
> PROCEDURE left
DEC x
check
IF colide=TRUE THEN
INC x
ELSE
INC x
shape(0,0)
DEC x
shape(1,0)
ENDIF
RETURN
> PROCEDURE right
INC x
check
IF colide=TRUE THEN
DEC x
ELSE
DEC x
shape(0,0)
INC x
shape(1,0)
ENDIF
RETURN
> PROCEDURE drop
shape(0,0)
REPEAT
INC y
check
UNTIL colide=TRUE
DEC y
shape(1,0)
FOR loop=1 TO 12 STEP 2
SOUND 1,15-loop,loop,6,1
NEXT loop
SOUND 1,0,0,0,0
RETURN
> PROCEDURE line
l=0
yes=FALSE
ly=(y+j)
count=0
REPEAT
REPEAT
count=0
FOR lx=1 TO 10
IF m(lx,ly)>0 THEN
INC count
ENDIF
NEXT lx
IF count=10 THEN
PRINT AT(21,ly-l);CHR$(27);"b";CHR$(dot);CHR$(27);"c";CHR$(0);"..........";
INC l
INC lines
yes=TRUE
FOR loopy=ly DOWNTO 3
FOR lx=1 TO 10
m(lx,loopy)=m(lx,loopy-1)
NEXT lx
NEXT loopy
ENDIF
UNTIL count<10
DEC ly
UNTIL count=0
IF yes=TRUE
ly=(y+j)
FOR loop=1 TO l
FOR loop2=1 TO 12 STEP 3
SOUND 1,15-loop2,loop2,6,1
NEXT loop2
NEXT loop
SOUND 1,0,0,0,0
FOR loopy=ly DOWNTO 3
FOR lx=1 TO 10
LOCATE 20+lx,loopy
IF m(lx,loopy)>0 THEN
PRINT CHR$(27);"c";CHR$(m(lx,loopy));" ";
ELSE
PRINT CHR$(27);"c";CHR$(0);CHR$(27);"b";CHR$(dot);".";
ENDIF
NEXT lx
NEXT loopy
LOCATE 1,1
PRINT CHR$(27);"c";CHR$(0);
ENDIF
RETURN
> PROCEDURE score
label=1000
PRINT CHR$(27);"c";CHR$(0);
CLS
IF score<scores(19) THEN
GOTO endscore
ELSE
CLS
BOX 1,1,319,199
DEFTEXT 14,8,0,9
TEXT 10,20,"You obtained a high score"
LOCATE 2,12
PRINT "Enter name:";
REPEAT
a$=INKEY$
IF a$=CHR$(8) AND LEN(nm$)>0 THEN
nm$=LEFT$(nm$,LEN(nm$)-1)
a$=""
ENDIF
IF a$>CHR$(31) THEN
IF a$<>CHR$(8) THEN
nm$=nm$+a$
ENDIF
ENDIF
LOCATE 13,12
PRINT CHR$(27);"b";CHR$(15);CHR$(27);"c";CHR$(0);nm$;CHR$(27);"c";CHR$(6);" ";CHR$(27);"c";CHR$(0);" ";
UNTIL a$=CHR$(13) OR LEN(nm$)=22
CLS
y=0
REPEAT
IF score>scores(y) THEN
label=y
INSERT scores(y)=score
INSERT name$(y)=nm$
y=19
ENDIF
y=y+1
UNTIL y>19
GOSUB save_scores
ENDIF
endscore:
CLS
DEFTEXT 14,8,0,10
TEXT 50,15,"Top twenty scores"
DEFTEXT 0,0,0,0
FOR y=0 TO 19
LOCATE 5,y+4
PRINT CHR$(27);"b";CHR$(15);CHR$(27);"c";CHR$(0);USING "##",y+1;
LOCATE 8,y+4
IF y=label THEN
PRINT CHR$(27);"b";CHR$(4);name$(y);
ELSE
PRINT CHR$(27);"b";CHR$(11);name$(y);
ENDIF
LOCATE 30,y+4
PRINT CHR$(27);"b";CHR$(6);scores(y);
NEXT y
PRINT CHR$(27);"c";CHR$(0);
BOX 1,1,319,199
RETURN
> PROCEDURE load_scores
OPEN "I",#1,"A:\TETRIS.RES"
FOR loop=0 TO 19
INPUT #1,name$(loop)
INPUT #1,scores(loop)
NEXT loop
CLOSE #1
RETURN
> PROCEDURE save_scores
IF EXIST("A:\TETRIS.RES")=TRUE THEN
KILL "A:\TETRIS.RES"
ENDIF
OPEN "O",#1,"A:\TETRIS.RES"
FOR loop=0 TO 19
PRINT #1,name$(loop)
PRINT #1,scores(loop)
NEXT loop
CLOSE #1
RETURN
Paul.