Worm Squirm
- Type
- Game
- Category
- Snake-style action game
- Author
- John Gunther
- Published in
- Antic, December 1983 (Vol. 2, No. 9), In the Public Domain
- Year
- 1983
- Language
- Atari BASIC
- Requirements
- 16K RAM, Atari BASIC, joystick in port 1
About the program
"Today, you're going to take your worm out for a squirm around the block." John Gunther's Worm Squirm is a snake game. The worm grows with every bug it eats, and it dies if it hits a wall, its own tail, or turns back on its own neck. Survive long enough and you reach a "higher level of existence" where small castles appear. You have to attack them before they harden into stone obstacles, and they grow darker as a warning.
Gunther also meant it as a lesson. He wrote that you would be amazed to find "not a single line of machine language in the program", and that BASIC "is not necessarily a slow language".
Typing it in
The only special characters are the inverse-video words in the instructions (lines 4020–4026), the inverse NAME in line 8055 and one inverse ! in line 10105. {inv}…{/inv} means press the Atari key before and after. Lower-case and inverse words in the GRAPHICS 1 text come out in different colours. The worm and bug shapes are in the DATA lines. Each record gives a character number and eight bytes for each of the two character sets.
How to play
Type a difficulty from 1 (hardest) to 10 and press RETURN. The article says you can enter any higher number for an easier game, which is useful for small children. The game waits until you move the joystick. Steer the worm to the 19 red bugs (10 points each). Now and then a green bug appears for a short time and is worth 50. The longer the worm gets, the harder it is to keep the tail out of the way. At the end, enter your name if you've made the top five.
How it works
The article explains the speed tricks:
- One fast test. Line 115 does
IF NOT PEEK(PPOS) THEN 150. If the square ahead is empty (zero), every other collision test is skipped. Moves are made by POKEing screen memory directly. - Hot code first. The main loop and the most-used subroutines sit at the top of the program, because BASIC searches for line numbers from the start.
- Variable GOSUBs.
GOSUB RA(line 150) calls a different routine depending on the level: 20 places a green bug, 30 removes it, and 3000 handles the castles. - Two character sets. Animation (the worm's body changing, the bugs quivering) comes from flipping location 756 between
SETandSET+2, two copies of the font with different shapes (lines 115, 170, 2010 and 2055). - The worm's body positions are kept in the array
L(), so the tail square can be erased exactlySZmoves later.
Gunther suggested the high-score routine (lines 8050–8610, with the strings set up in 4000–4004) as something to reuse in your own games.
Listing
5 REM ...WORM SQUIRM...
7 REM ...by John Gunther...
9 REM ANTIC MAGAZINE
10 GOTO 4000
20 R1=SCREEN+INT(480*RND(0)):IF PEEK(R1)=0 THEN POKE R1,GBUG:EXT=LT+SZ:RA=30:RETURN
21 GOTO 20
30 POKE R1,0:RA=20:EXT=LT+15:RETURN
100 IF STICK(0)=15 THEN 100
105 FOR V=0 TO DIF:NEXT V:ST=STICK(0):DX=(ST=7)-(ST=11):DY=(ST=13)-(ST=14):IF ST=15 OR DX+DY=0 THEN 115
110 XD=DX:YD=DY:TS=ST
115 POKE 756,SET:TX=PX+XD:TY=PY+YD:PPOS=SCREEN+TX+20*TY:IF NOT PEEK(PPOS) THEN 150
135 SEE=PEEK(PPOS):IF SEE=RBUG THEN 2000
140 IF SEE=GBUG THEN 2005
145 IF SEE<=BOD THEN 1000
148 IF SEE=CASTLE THEN FIX=15:RA=3000:EXT=LT+15
150 LT=LT+1:IF LT>EXT THEN GOSUB RA
155 L(LT)=PX+20*PY:POKE SCREEN+L(LT),BOD
160 IF LT>SZ THEN POKE SCREEN+L(LT-SZ),0
165 POKE PPOS,CHR(TS):PX=TX:PY=TY
170 POKE 756,SET+2:GOTO 105
200 GRAPHICS 1+16:POKE 756,CHSET/256:GOSUB 9000
240 XD=0:YD=0:RBUG=193:BOD=70:EXT=20:GBUG=75
260 SETCOLOR 1,12,4:LT=0
270 FIX=15:B=7:FOR I=0 TO 19:POKE SCREEN+I,B
280 POKE SCREEN+460+I,B:NEXT I
290 FOR I=1 TO 23:POKE SCREEN+I*20,B:POKE SCREEN+19+I*20,B:NEXT I
300 POSITION 0,0:? #6;"SCORE:";SC:POSITION 11,0:? #6;"SIZE:";SZ:POSITION 1,23:? #6;"HI.SCORE:";HS
390 FOR I=0 TO 18
395 R=SCREEN+INT(480*RND(0)):IF PEEK(R)=0 THEN POKE R,RBUG:NEXT I:GOTO 410
400 GOTO 395
410 PX=10:PY=11:POKE SCREEN+PX+20*PY,CHR(14)
430 DX=1:DY=1:GOTO 100
1000 POKE PPOS,CHR(TS)+192:POKE SCREEN+PX+20*PY,BOD+128:FOR FF=0 TO 1000:NEXT FF
1005 IF SC>HS THEN HS=SC
1010 GOTO 8050
2000 A1=218:A2=224:A3=RBUG:SC=SC+10:GOTO 2010
2005 RA=20:SC=SC+50:A1=90:A2=96:A3=GBUG
2010 FOR I=A1 TO A2 STEP 0.2:POKE 756,SET:POKE PPOS,A3
2050 SOUND 0,2*(I-A1),12,14
2055 POKE PPOS,I:POKE 756,SET+2:NEXT I
2070 SZ=SZ+1:SOUND 0,0,0,0
2080 POSITION 6,0:? #6;SC:POSITION 16,0:? #6;SZ:GOTO 150
3000 BRICK=INT(RND(0)*22)
3010 BRICK=SCREEN+25+BRICK*20:IF NOT PEEK(BRICK) THEN FIX=15:POKE BRICK,CASTLE:RA=3050
3020 RETURN
3050 IF FIX=0 THEN FIX=15:POKE BRICK,B:RA=3000:EXT=LT+20:RETURN
3060 FIX=FIX-0.2:SETCOLOR 2,9,FIX:RETURN
4000 DIM SK(6),NAME$(75),SCORER$(10):SZ=10:RA=20:CHROM=57344
4002 NAME$=" ":REM 66 SPACES
4003 DIM BLANK$(12):BLANK$=" ":REM 12 SPACES
4004 FOR N=0 TO 6:SK(N)=0:NEXT N
4006 DIM CHR(15),L(500):CHR(14)=2:CHR(13)=3:CHR(11)=4:CHR(7)=5:CASTLE=136
4008 SET=(PEEK(106)-4):CHSET=SET*256:POKE 106,PEEK(106)-5
4010 GRAPHICS 1:GOSUB 9000
4020 POSITION 2,3:? #6;" YOU {inv}are{/inv} A worm AS YOU eat YOU GET LONGER AND {inv}LONGER{/inv} SCORING MORE POINTS"
4025 POSITION 2,8:? #6;" but..."
4026 POSITION 1,10:? #6;"YOUR {inv}existence is{/inv} terminated{inv} if{/inv} {inv}you..{/inv}RUN INTO YOUR BODY, TURN BACK ON YOUR- SELF"
4027 POSITION 1,15:? #6;"OR RUN INTO A WALL"
5000 FOR M=0 TO 511:CAROM=CHROM+M:POKE CHSET+M,PEEK(CAROM):POKE CHSET+512+M,PEEK(CAROM):POKE 709,M/3:NEXT M
5002 READ A:IF A<0 THEN GOSUB 10000:GOTO 200
5003 FOR J=0 TO 7:READ B:POKE CHSET+A*8+J,B:NEXT J
5004 READ A
5006 FOR J=0 TO 7:READ B:POKE CHSET+A*8+J+512,B:NEXT J
5010 GOTO 5002
5020 DATA 1,195,36,24,60,90,153,24,36
5022 DATA 1,60,36,24,60,90,153,24,36
5024 DATA 2,5,2,6,60,102,231,165,231
5026 DATA 2,160,64,96,60,102,231,165,231
5028 DATA 3,231,165,231,102,60,6,2,5
5030 DATA 3,231,165,231,102,60,96,64,160
5032 DATA 4,135,109,191,16,16,31,13,7
5034 DATA 4,7,13,31,16,16,191,109,135
5036 DATA 5,225,182,253,8,8,248,176,224
5038 DATA 5,224,176,248,8,8,253,182,225
5040 DATA 6,126,255,255,255,255,255,255,126
5042 DATA 6,126,255,255,231,231,255,255,126
5044 DATA 7,255,255,255,255,255,255,255,255
5046 DATA 7,255,255,255,255,255,255,255,255
5048 DATA 11,153,165,102,24,231,36,102,153
5050 DATA 11,153,189,126,24,255,60,126,153
5052 DATA 8,14,142,200,235,235,191,229,231
5054 DATA 8,56,184,200,235,235,191,253,255
5200 DATA -1
8050 GRAPHICS 0:SETCOLOR 1,0,0:SETCOLOR 4,8,0:SETCOLOR 2,0,7:IF SC<SK(5) THEN 8600
8055 ? " PLEASE ENTER YOUR {inv}NAME{/inv}";:INPUT SCORER$
8060 LN=LEN(SCORER$):IF LN<10 THEN SCORER$(LN+1)=BLANK$(1,10-LN)
8100 FOR N=1 TO 5:IF SC>=SK(N) THEN 8400
8150 NEXT N
8200 GOTO 8600
8400 M1=51:M2=60
8500 FOR N1=5 TO N STEP -1:SK(N1+1)=SK(N1)
8510 NAME$(M1+10,M2+10)=NAME$(M1,M2)
8515 M1=M1-10:M2=M2-10
8520 NEXT N1:SK(N)=SC:NAME$(M1+10,M2+10)=NAME$(M1,M2):NAME$(M1,M2)=SCORER$
8600 ? ,"HIGH SCORERS":? :? :? ,"PLAYER SCORE":?
8610 M3=1:M4=10:FOR SS=1 TO 5:? ,NAME$(M3,M4),SK(SS):M3=M3+10:M4=M4+10:? :NEXT SS
8615 GOSUB 10000:SC=0:SZ=10:RA=20:GOTO 200
9000 SCREEN=PEEK(88)+256*PEEK(89):RETURN
10000 TRAP 10000:? "DIFFICULTY (1-10 1=HARD)";:INPUT DIF:DIF=DIF*2:TRAP 10100:RETURN
10100 POSITION 2,14:? #6;"CONGRATULATIONS":POSITION 1,15:? #6;"YOU HAVE COMPLETED"
10105 POSITION 3,16:? #6;"THIS LEVEL !{inv}!{/inv}":FOR T=0 TO 1000:NEXT T:RA=3000:TRAP 10100:GOTO 200
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: WORMSQRM.BAS.
Credits
- Program listing: Worm Squirm — program listing (Antic, December 1983 (Vol. 2, No. 9), In the Public Domain) — John Gunther
- Picture: The start of a game: nineteen red bugs wait inside the walls. (Captured from a copy with the difficulty prompt answered in the program.) — John Gunther (program); screenshot by the site
- Antic, December 1983 - Vol. 2 No. 9: scan of the printed magazine, In the Public Domain: Worm Squirm, by John Gunther — Internet Archive, 1983
- Antic disk, December 1983 - Vol. 2 No. 9: WORMSQRM.BAS (detokenized listing) — John Gunther, 1983
