Listing of file='WORM' on disk='vmedia/games_vol_3.wvd.zip'
# Sector 296, program filename = 'WORM'
0000 DEFFN'0"\ACT";HEX(22);"WORM";HEX(22);":\85<S>T()";HEX(22);"WORM";HEX(22);
":\A0\D20C);";HEX(22);"WORM saved on disk.";HEX(22);";\CD70);";HEX(0D)
0010 REM %* Worm Farm Game *#* Written by RAS *#* Created 17-Feb-82 *
: REM Original Idea taken from UNIX game of same name
0020 REM % *---------------- Mods --------------------*
0030 REM \A0\A0\CE\EF\AE \D7\E8\E5\EE\A0\A0\A0\A0 \D7\E8\EF \CE\EF\F4\E1\F4
\E9\EF\EE
0040 REM [001] 17/02/82 RAS Written
0050 REM [002] 18/02/82 RAS Best so far code added
0060 REM [003] 23/02/82 RAS Name changed to "WORM"
0070 REM [004] 23/02/82 RAS Speedup as game progress.
0080 REM [005] 08/03/82 RAS Program protect (against illicit hackers)
0090 REM [006] 05/03/86 MPB Unprotected. Direction keys added. To GAMES
1000 REM %Best player so far
: REM *MUST* be line 1000
: REM *MUST* be in this format
: DATA 000202," "
3010 DIM C(2),D$1,F,F(2),F$(1560)2,H,H(2),L,L1,T,U,U$1,U1,U1$2,U2$1,U9$80,W$(1
560)2
3020 REM C() = Current position of cursor
3030 REM D$ = Direction entered
3040 REM F = Value of food
3050 REM F() = Position of food on screen
3060 REM F$() = Unused screen positions (for creating food)
3070 REM H = Position of head of worm in W$()
3080 REM H() = Next position of worm head
3090 REM L = Current (actual) length of worm
3100 REM T = Position of tail of worm in W$()
3110 REM L1 = Length that worm is supposed to be
: REM differs from L only after eating food
3120 REM U vars = Temps
3130 REM W$() = Each element is a segment of worm
: REM packed as PACK(##)W$(s)FROM row, column
4000 REM %..... Image Statements .....
4010 % \C2\E1\E3\EB\E7\F2\EF\F5\EE\E4
4020 % You are a farmer of a rather unusual sort. Your farm prod
uces
4030 % worms. Understandably there is not much competition in this a
rea,
4040 % however worm farmers are a proud lot and this keeps the standards h
igh.
4050 % The International Annual Worm Farmers Convention is coming up soon
and
4060 % one of the star attractions is the Mister Wormy-Verse competition.
The
4070 % winning entry is the world's l o n g e s t worm. You have ent
ered
4080 % this competition. Your task now is to grow your worm.
4090 % \C9\EE\F3\F4\F2\F5\E3\F4\E9\EF\EE\F3
4100 % The worm appears as an '@' (the head) followed by a strin
g of
4110 % 'ooooooo's (the body). Its movement is directed by the following k
eys:
4120 % 8 - up, 2 - down, 4 - left, 6 right. Periodically a digit will app
ear.
4130 % This is the worm's food. When the worm runs through (eats) the d
igit
4140 % he grows by the size of the digit. However if he tries to eat the
wall
4150 % or himself he dies (and is pickled for display).
4160 % Press RETURN to Continue
4180 % Your worm is ##### segments long
5000 REM %..... Start up .....
5010 REM %Instructions
: PRINT HEX(0306);TAB(28);HEX(020400020E);" * W O R M F A R M * ";HEX(02
0402000F)
: PRINT
: PRINTUSING 4010
: PRINT
: PRINTUSING 4020
: PRINTUSING 4030
: PRINTUSING 4040
: PRINTUSING 4050
: PRINTUSING 4060
: PRINTUSING 4070
: PRINTUSING 4080
: PRINT
: PRINTUSING 4090
: PRINT
: PRINTUSING 4100
: PRINTUSING 4110
: PRINTUSING 4120
: PRINTUSING 4130
: PRINTUSING 4140
: PRINTUSING 4150
: PRINT
: PRINT
: PRINT HEX(020404000E);
: PRINTUSING 4160
: PRINT HEX(020402000F);
5020 KEYIN U$,5020,5020
: IF U$=HEX(1F)OR U$=HEX(81)THEN LOAD RUN "Games"
: IF U$<>HEX(0D)THEN 5020
5030 REM %Initialise Screen
: PRINT AT(9,20);BOX(-5,-40);AT(2,0,);HEX(020400020E);
: SELECT PRINT 705(255)
: PRINT AT(2,0);
: GOSUB 9010
: PRINT AT(2,79);
: GOSUB 9010
: U9$=ALL(CF)
: PRINT HEX(0202020E);AT(2,0);U9$
: U9$=ALL(FC)
: PRINT AT(23,0);U9$
: PRINT HEX(020402000F0202000F);
: SELECT PRINT 005(80)
5040 REM %Initialise Game
: U9$="Initialising ..."
: PRINT HEX(020404000E);AT(12,40-LEN(U9$)/2);U9$;HEX(020402000F);
: W$()=ALL(00)
: FOR U=1TO 20
: FOR U1=1TO 78
: PACK(##)F$((U-1)*78+U1)FROMU,U1
: NEXT U1,U
: D$="6"
: H=0
: T=1
: L=0
: L1=5
: H(1)=5
: H(2)=15
: GOSUB 9020
: MAT C=CON
: PRINT AT(12,3,70);AT(3,1);
5050 REM %Create a new piece of food
: UNPACK(##)F$(RND(1)*(1560-L)+1)TO F()
: MAT H=F
: F=INT(RND(1)*9+1)
: CONVERT FTO U$,(#)
: GOSUB 9100
5060 REM %Enter Direction
: U=20*(1-L1/1560)
: U1=255*(1-L1/1560)
5070 KEYIN U$,5080,5080
: $BREAKU1
: U=U-1
: IF U>0THEN 5070
: GOTO 5090
5080 KEYIN U2$,5080,5080
: IF U$=HEX(1F)OR U$=HEX(81)THEN LOAD T"GAMES"
: $TRAN(U$,HEX(344D345D32453255365C364C38563846))R
: IF POS("2468"=U$)=0THEN 5070
: D$=U$
5090 GOSUB 9040
: PACK(##)U1$FROMH()
: MAT SEARCHW$(),=STR(U1$)TO U9$STEP 2
: IF STR(U9$,3,2)<>HEX(0000)OR H(1)<1OR H(1)>20OR H(2)<1OR H(2)>78THEN 5100
: IF H(1)<>F(1)OR H(2)<>F(2)THEN 5060
: L1=L1+F
: GOTO 5050
5100 REM %End of Game
: SELECT PRINT 005(80)
: FOR U=7TO 16
: PRINT AT(U,1,78);
: NEXT U
: RESTORE LINE1000
: U9$=HEX(0000)
: PRINTUSING TO U9$,"Your worm is ###### segments long";L;
: PRINT AT(8,41-LEN(U9$)/2);STR(U9$,3,LEN(U9$)-2)
5110 U9$="The winner of the Wormy-Verse competition so far was grown by"
: PRINT AT(10,40-LEN(U9$)/2);U9$
: READ U,U9$
: U9$=U9$&". That entry is ##### segments long."
: F$()=HEX(0000)
: PRINTUSING TO F$(),U9$,U;
: PRINT AT(11,41-LEN(F$())/2);STR(F$(),3,LEN(F$())-2)
: IF L<=UTHEN 5140
5120 U9$="You are the new progressive winner. Please enter your name below."
: PRINT AT(14,40-LEN(U9$)/2);U9$
: U9$=" "
: PRINT AT(15,24);
: LINPUT -STR(U9$,,30)
: PRINT HEX(06);
: $OPEN #0
: LIMITS T"WORM",U,U1,U1
5130 U=U+1
: DATA LOAD BA T(U)F$()
: MAT SEARCHF$(),=HEX(00FF1000)TO U1$
: IF U1$=HEX(0000)THEN 5130
: U1=VAL(U1$,2)
: U1=POS(STR(F$(),U1)=HEX(97))+U1
: CONVERT LTO STR(F$(),U1,6),(######)
: STR(F$(),U1+8,30)=U9$
: DATA SAVE BA T(U)F$()
: $CLOSE#0
: LOAD T"WORM"BEG 5030
5140 U9$="Press RETURN to Continue"
: PRINT AT(14,10,60);AT(15,10,60);AT(14,40-LEN(U9$)/2);U9$
: GOTO 5020
9000 REM %..... Subroutines .....
9010 REM %Print side of box
: PRINT " ";
: FOR U=3TO 22
: PRINT HEX(080A20);
: NEXT U
: RETURN
9020 REM %Add a worm segment
: H=MOD(H,1560)+1
: PACK(##)W$(H)FROMH()
: MAT SEARCHF$(),=STR(W$(H))TO U1$STEP 2
: U1=VAL(U1$,2)
: IF U1=0THEN RETURN
: IF U1=3119THEN 9030
: STR(F$(),U1)=STR(F$(),U1+2)
9030 F$(1560)=ALL(00)
: L=L+1
: RETURN
9040 REM %Move worm
: IF L<L1THEN 9050
: REM Tail
: UNPACK(##)W$(T)TO H()
: U$=" "
: GOSUB 9100
: L=L-1
: F$(1560-L)=W$(T)
: W$(T)=ALL(00)
: T=MOD(T,1560)+1
9050 REM Head
: UNPACK(##)W$(H)TO H()
: U$="o"
: GOSUB 9100
: ON POS("2468"=D$)GOSUB 9060,9070,9080,9090
: GOSUB 9020
: U$="@"
: GOSUB 9100
: RETURN
9060 REM Down
: H(1)=H(1)+1
: RETURN
9070 REM Left
: H(2)=H(2)-1
: RETURN
9080 REM Right
: H(2)=H(2)+1
: RETURN
9090 REM Up
: H(1)=H(1)-1
: RETURN
9100 REM %Print a character
: ON SGN(C(1)-H(1))+2GOTO 9110,9130,9120
: END
9110 U9$=ALL(0A)
: $GIO/005(A000)STR(U9$,,H(1)-C(1))
: GOTO 9130
9120 U9$=ALL(0C)
: $GIO/005(A000)STR(U9$,,C(1)-H(1))
9130 ON SGN(C(2)-H(2))+2GOTO 9140,9160,9150
: END
9140 U9$=ALL(09)
: $GIO/005(A000)STR(U9$,,H(2)-C(2))
: GOTO 9160
9150 U9$=ALL(08)
: $GIO/005(A000)STR(U9$,,C(2)-H(2))
9160 $GIO/005(A000)U$
: C(1)=H(1)
: C(2)=H(2)+1
: RETURN