Mole Attack
- Type
- Education
- Category
- Typing practice game (whack-a-mole)
- Author
- Masahiro Mori
- Published in
- Antic, October 1984 (Vol. 3, No. 6)
- Year
- 1984
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, Atari BASIC, keyboard
About the program
"The moles are attacking! Get ready to type!" Mole Attack is a keyboard version of whack-a-mole for "one-finger wizards": young beginners learning where the letters are. Five holes each get a random letter. A mole pops up beside one of them, and you hit it with a hammer by pressing that letter before it ducks back down. The article suggested commercial programs such as Type Attack and MasterType for more advanced drills.
Masahiro Mori was 14, attending Morrison Christian Academy in Taiwan, and was one of Antic's youngest regular contributors. He was especially interested in player/missile graphics and redefined character sets. His Three Color Demo and Colors From Taiwan also appeared in Antic.
Typing it in
Many lines use {inv}…{/inv} (press the Atari key before and after). In REMs these are just headings. In the GRAPHICS 1 and 2 screens, inverse and lower-case text prints in other colours, and the inverse ! in line 160 is the mole itself. {CTRL-,} is CTRL with comma, and {CTRL-V}/{CTRL-B} (line 1050) are CTRL with V and B. {BELL} is ESC then CTRL-2. The punctuation characters !, ", #, $ and % are redefined into the mole, the hammer, the hole and other scenery, so type them exactly. The magazine printed TYPO codes.
How to play
After the title and a short cartoon that introduces the mole, the hammer and the hole, the program plays a snatch of "Oh! Susanna". Then:
- Type a level from 1 (hardest) to 10 (easiest) and press RETURN.
- Type the game length in seconds (the article suggests 20 to start).
- Five random letters appear. Type each of them in turn. The program is learning your keys.
Now whack the moles. Each hit scores a point. When time is up you get a report and can enter your name for "today's hi-score". Press the space bar to play again.
How it works
- Learning the key codes. While you type the five letters (lines 550–690), the program records the raw keyboard code from location 764 for each one. During the game it just
PEEKs location 764 and compares it with those five numbers. That's much faster thanGET, and it never has to wait for a key. - Timing. The game clock comes from the three-byte jiffy counter in locations 18–20, divided by 60 (lines 1090–1110).
- Level. The level sets how many times the program checks the keyboard (
LV*10, line 170) before the mole disappears. - The opening cartoon (lines 1140–1170) reveals each line of text from the middle outwards. Lines 1500–1510 disable the BREAK key through location 16.
Listing
5 REM MOLE ATTACK
6 REM BY MASHAHIRO MORI
7 REM ANTIC MAGAZINE
8 POKE 756,224
10 GOSUB 900
20 GRAPHICS 18:GOSUB 1500:POKE 756,S/256:GOSUB 1120:REM {inv}SET SCREEN{/inv}
30 FOR A=0 TO 19:POKE SCR+A+20*1,4:POKE SCR+A+20*10,4:NEXT A
40 FOR A=1 TO 10:POKE SCR+20*A,4:POKE SCR+19+20*A,4:NEXT A:GOSUB 430:GOSUB 1080
50 ML=INT(RND(1)*6):IF ML<1 OR TT=ML THEN 50
60 POSITION 7,4:? #6;"#":POSITION 12,4:? #6;"#":POSITION 4,8:? #6;"#"
65 POSITION 10,8:? #6;"#":POSITION 15,8:? #6;"#"
70 POSITION 7,2:? #6;"%":POSITION 12,2:? #6;"%":POSITION 4,6:? #6;"%"
75 POSITION 10,6:? #6;"%":POSITION 15,6:? #6;"%"
80 TT=ML:POSITION 0,0:? #6;"time:";TIMEG:POSITION 10,0:? #6;"score:";SC:GOSUB 1100
90 IF TIMEG>=SEC THEN 360
100 IF ML=1 THEN A=7:B=3:GOTO 160
110 IF ML=2 THEN A=12:B=3:GOTO 160
120 IF ML=3 THEN A=4:B=7:GOTO 160
130 IF ML=4 THEN A=10:B=7:GOTO 160
140 IF ML=5 THEN A=15:B=7:GOTO 160
150 GOTO 170
160 POSITION A,B:? #6;"{inv}!{/inv}"
165 GOSUB 1500
170 FOR PA=1 TO LV*10:I=PEEK(764)
180 IF I=V1 THEN A=7:B=2:GOTO 240
190 IF I=V2 THEN A=12:B=2:GOTO 240
200 IF I=V3 THEN A=4:B=6:GOTO 240
210 IF I=V4 THEN A=10:B=6:GOTO 240
220 IF I=V5 THEN A=15:B=6:GOTO 240
230 GOSUB 1100:POSITION 0,0:? #6;"time:";TIMEG:NEXT PA
240 POSITION A,B:? #6;CHR$(34):POKE 764,255:GOSUB 260:POSITION 7,3:? #6;A$:POSITION 4,7:? #6;A$
250 GOTO 50
260 REM {inv}CHECKING IF HIT{/inv}
270 IF ML=1 AND I=V1 THEN A=7:B=3:GOTO 330
280 IF ML=2 AND I=V2 THEN A=12:B=3:GOTO 330
290 IF ML=3 AND I=V3 THEN A=4:B=7:GOTO 330
300 IF ML=4 AND I=V4 THEN A=10:B=7:GOTO 330
310 IF ML=5 AND I=V5 THEN A=15:B=7:GOTO 330
320 RETURN
330 POSITION A,B-1:? #6;"{CTRL-,}":POSITION A,B:? #6;CHR$(162):FOR Q=15 TO 0 STEP -1:SOUND 0,243,10,Q:SOUND 1,21,10,Q
340 NEXT Q:SC=SC+1:GOSUB 720:RETURN
350 FOR PA=1 TO W:NEXT PA:RETURN
360 REM {inv}GAME OVER{/inv}
370 RESTORE 1420:POSITION 5,1:? #6;"game over":GOSUB 400
375 POSITION 4,5:? #6;"press {inv}space{/inv}"
380 IF PEEK(764)=33 THEN GOSUB 1250:GOTO 20
390 POSITION 4,1:? #6;A$:POSITION 4,1:? #6;" {inv}game over{/inv}":GOTO 380
400 TRAP 410:READ AA:FOR P=1 TO 3:FOR I=15 TO 0 STEP -1:SOUND 0,AA,10,I:NEXT I:GOSUB 720:NEXT P:GOTO 400
410 FOR I=15 TO 0 STEP -1:SOUND 0,121,10,I:W=50:GOSUB 350:NEXT I:GOSUB 720
420 L=LV:SE=SEC:RETURN
430 OPEN #1,4,0,"K:":REM {inv}NEW KEYS{/inv}
440 GOSUB 490:K1=A:GOSUB 490:K2=A:IF K2=K1 THEN 440
450 GOSUB 490:K3=A:IF K3=K2 OR K3=K1 THEN 450
460 GOSUB 490:K4=A:IF K4=K3 OR K4=K2 OR K4=K1 THEN 460
470 GOSUB 490:K5=A:IF K5=K4 OR K5=K3 OR K5=K2 OR K5=K1 THEN 470
480 GOTO 520
490 A=INT(RND(0)*26):A=A+97:RETURN
500 POSITION 6,4:? #6;CHR$(K1):POSITION 11,4:? #6;CHR$(K2)
510 POSITION 3,8:? #6;CHR$(K3):POSITION 9,8:? #6;CHR$(K4):POSITION 14,8:? #6;CHR$(K5):RETURN
520 POSITION 4,3:? #6;"please press":POSITION 4,4:? #6;"------------"
540 POSITION 5,6:? #6;CHR$(K1);" ";CHR$(K2);" ";CHR$(K3);" ";CHR$(K4);" ";CHR$(K5)
545 GOSUB 1500
550 GOSUB 750:V1=I:GET #1,K:IF K=K1-32 THEN 570
560 GOSUB 740:GOTO 550
570 GOSUB 730:POSITION 5,6:? #6;CHR$(K1-32)
580 GOSUB 750:V2=I:GET #1,K:IF K=K2-32 THEN 600
590 GOSUB 740:GOTO 580
600 GOSUB 730:POSITION 7,6:? #6;CHR$(K2-32)
610 GOSUB 750:V3=I:GET #1,K:IF K=K3-32 THEN 630
620 GOSUB 740:GOTO 610
630 GOSUB 730:POSITION 9,6:? #6;CHR$(K3-32)
640 GOSUB 750:V4=I:GET #1,K:IF K=K4-32 THEN 660
650 GOSUB 740:GOTO 640
660 GOSUB 730:POSITION 11,6:? #6;CHR$(K4-32)
670 GOSUB 750:V5=I:GET #1,K:IF K=K5-32 THEN 690
680 GOSUB 740:GOTO 670
690 GOSUB 730:POSITION 13,6:? #6;CHR$(K5-32)
700 POSITION 5,9:? #6;"THANK YOU":FOR PA=2 TO 6:POSITION 4,PA:? #6;A$:NEXT PA
710 W=300:GOSUB 350:POSITION 5,9:? #6;A$:CLOSE #1:GOTO 500
720 SOUND 0,0,0,0:SOUND 1,0,0,0:RETURN
730 FOR PA=15 TO 0 STEP -1:SOUND 0,121,10,PA:NEXT PA:GOSUB 720:POKE 764,255:RETURN
740 FOR Q=15 TO 0 STEP -1:SOUND 0,200,10,Q:SOUND 1,255,10,Q:NEXT Q:GOSUB 720:RETURN
750 I=PEEK(764):IF I=255 THEN 750
760 RETURN
770 REM {inv} REDEFINE CHARACTERS {/inv}
780 S=(PEEK(106)+1)*256
790 FOR M=0 TO 1023:POKE 755,KK:POKE S+M,PEEK(57344+M):IF K1<6 THEN 820
800 IF KK=2 THEN KK=3:K1=0:NEXT M:GOTO 830
810 IF KK=3 THEN KK=2:K1=0:NEXT M:GOTO 830
820 K1=K1+1:NEXT M
830 AA=0:RESTORE 1390
840 AA=AA+8:IF AA>40 THEN 1140
850 FOR I=0 TO 7:READ V:POKE AA+S+I,V:NEXT I:GOTO 840
890 REM {inv}PRESENTATION{/inv}
900 DIM NAME$(20),H$(15),A$(12):A$=" ":POKE 106,PEEK(106)-5
905 GRAPHICS 0:POKE 709,2:POKE 710,12
910 NW=1:POKE 752,1:FOR U=1 TO 21:FOR PA=0 TO 2:POKE 53279,0:NEXT PA
920 POSITION 12,U:? "M.MORI":POSITION 12,U-1:? A$
930 POSITION 19,22-U:? "PRESENTS":POSITION 19,22-U+1:? A$
940 IF U=11 THEN W=250:GOSUB 350
950 NEXT U:POSITION 12,21:? A$:POSITION 19,1:? A$
960 FOR U=1 TO 22:FOR PA=0 TO 2:POKE 53279,0:NEXT PA:POSITION 14,U:? "MOLE ATTACK":POSITION 14,U-1:? A$
970 IF U=11 THEN W=250:GOSUB 350
980 NEXT U:X=1
1050 W=200:GOSUB 350:V=10:H$=" {inv}{CTRL-V}MOLE ATTACK{CTRL-B}{/inv}"
1060 L=LEN(H$):T=18-L/2:FOR A=1 TO L:FOR B=22 TO V STEP -1
1065 POSITION T+A,B:PRINT H$(A,A);:POSITION T+A,B+1:? " ";:NEXT B:NEXT A:V=V+2:IF V>12 THEN KK=2:K1=0:GOTO 780
1070 H$="{inv}{CTRL-V}INITIALIZING{CTRL-B}{/inv} ":GOTO 1060
1080 REM {inv}START TIME{/inv}
1090 TIME1=INT(((PEEK(18)*65536)+(PEEK(19)*256)+PEEK(20))/60):RETURN
1100 REM {inv}ELAPSED TIME{/inv}
1110 NOW=INT(((PEEK(18)*65536)+(PEEK(19)*256)+PEEK(20))/60):TIMEG=NOW-TIME1:RETURN
1120 SCR=PEEK(88)+256*PEEK(89):RETURN
1130 REM {inv}CARTOON{/inv}
1140 DIM AA$(40):GRAPHICS 18:POKE 756,S/256:POKE 710,132
1150 READ AA,AA$:IF AA=-1 THEN 1220
1160 AB=LEN(AA$):IF AB/2<>INT(AB/2) THEN AA$(AB+1)=" ":AB=AB+1
1170 FOR AC=1 TO AB/2:POSITION 10-AC,AA:? #6;AA$(1,AC);AA$(AB-AC+1):W=30:GOSUB 350:NEXT AC:GOTO 1150
1220 READ MUSIC:IF MUSIC=-1 THEN 1250
1230 W=10:GOSUB 350
1240 FOR VOL=15 TO 0 STEP -1:SOUND 0,MUSIC,10,VOL:SOUND 1,MUSIC+1,10,VOL:NEXT VOL:GOTO 1220
1250 GRAPHICS 17:POKE 87,0:POSITION 0,3:? "level":? " {inv}1{/inv}:HARD {inv}10{/inv}:EASY":? "{inv}=>{/inv}";
1251 GOSUB 1500:TRAP 1252:INPUT LV:GOTO 1255
1252 ? "{BELL}";:GOTO 1250
1255 IF (LV<>INT(LV)) OR ((LV<1) OR (LV>10)) THEN ? "{BELL}";:GOTO 1250
1260 GOSUB 1280
1270 GRAPHICS 17:POKE 87,0:POSITION 0,3:TRAP 1274:? "seconds:":? " TO COMPLETE ":? " {inv}=>{/inv}";
1271 GOSUB 1500:INPUT SEC
1272 IF SEC>=0 THEN 1279
1274 ? "{BELL}":GOTO 1270
1279 GOSUB 1280:GOTO 1300
1280 FOR Q=15 TO 0 STEP -1:SOUND 0,121,10,Q:W=20:GOSUB 350:NEXT Q:RETURN
1290 REM {inv}HI-SCORE INPUT{/inv}
1300 GRAPHICS 17:POKE 87,0
1310 IF NW=1 THEN NW=0:RETURN
1320 IF SC>HSC THEN HSC=SC:? "name:";:GOSUB 1500:INPUT NAME$:HLV=L:HSEC=SE
1330 GRAPHICS 17:POKE 756,S/256:POSITION 2,2:? #6;"TODAY'S HI-SCORE":POSITION 2,3:? #6;"{inv}----------------{/inv}"
1340 FOR I=0 TO 22:POSITION 0,I:? #6;"$":POSITION 19,I:? #6;"$":NEXT I
1350 FOR I=0 TO 19:POSITION I,0:? #6;"$":POSITION I,22:? #6;"$":NEXT I
1360 POSITION 4,5:? #6;"hi-score=";HSC:POSITION 4,7:? #6;"level=";HLV:POSITION 4,9:? #6;"seconds=";HSEC
1370 POSITION 4,11:? #6;"by=";NAME$
1380 W=1500:GOSUB 350:SC=0:TIMEG=0:TIME1=0:RETURN
1390 DATA 126,195,129,165,129,165,153,195,248,112,255,112,248,112,248,0,0,120,134,129,129,97,30,0
1400 DATA 255,255,255,255,255,255,255,255,248,112,255,112,248,0,0,0
1405 DATA 0,MOLE ATTACK,1,-------------,2,{inv}!{/inv} {inv}={/inv} MOLE,4, " {inv}={/inv} HAMMER,6,# {inv}={/inv} HOLE,8,{inv}C{/inv}H{inv}a{/inv}r{inv}A{/inv}C{inv}t{/inv}e{inv}R{/inv}S,10,by M.MORI,-1,A
1410 DATA 121,108,96,81,81,72,81,96,121,108,96,96,108,121,108,121,108,121,108,121,121,121,-1
1420 DATA 121,96,81,96,121
1500 DSBL=PEEK(16)-128:IF DSBL<0 THEN RETURN
1510 POKE 16,DSBL:POKE 53774,DSBL:RETURN
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: MOLE.BAS.
Credits
- Program listing: Mole Attack — program listing (Antic, October 1984 (Vol. 3, No. 6)) — Masahiro Mori
- Picture: Choosing the level after the opening cartoon and the snatch of "Oh! Susanna". — Masahiro Mori (program); screenshot by the site
- Antic, October 1984 (Vol. 3 No. 6): Mole Attack, by Masahiro Mori (atarimagazines.com) — Masahiro Mori, 1984
- Antic disk, October 1984 - Vol. 3 No. 6: MOLE.BAS (detokenized listing) — AtariMagazines.com (Kevin Savetz), 1984
