A.N.A.L.O.G. ISSUE 50 / JANUARY 1987 / PAGE 28
Krazy Katerpillars is a fast-action arcade-type game. Your job is to clear the screen of the swarming katerpillars before they do you in. Though you start out in the screen center, in a zone clear of the bugs, you’re surrounded—above and below. Katerpillars begin to move across the screen, advancing on you. Shoot as many as possible, while trying to outmaneuver the rest. Be careful. If you miss your target, your missile cycles to the screen bottom and forms a deadly spike that heads straight toward you.
Listing 1 is the BASIC data used to create both cassette and disk versions of Krazy Katerpillars. Those readers who are interested in how the game works may obtain the assembly listing on either the magazine disk version or the ANALOG Computing Atari Users’ Group on Delphi.
Disk users should refer to the M/L Editor article on page 10 for typing instructions.
If you have a cassette system, type in Listing 1, then add the lines shown in Listing 2. Type RUN and press RETURN. The program will begin checking the data statements, printing the line numbers as it goes. It will alert you to any problems. Fix any incorrect lines and rerun the program until all errors are eliminated.
When all your data lines are correct, the computer will beep twice and prompt you to READY CASSETTE AND PRESS RETURN. Now, insert a blank cassette in your recorder, press the RECORD and PLAY buttons simultaneously, and hit RETURN. The message WRITING FILE will appear, and the program will create a machine language boot tape version of Krazy Katerpillars, printing each data line number as it goes. When the READY prompt appears, the game is recorded and ready to play. CSAVE the BASIC program onto a separate tape before continuing.
To play the game, rewind the tape created with the BASIC program to the beginning. Turn your computer off and remove all cartridges. Press the PLAY button on your recorder and turn on your computer, while holding down the START key. If you have an XL or XE series computer, you must hold the START and OPTION keys when you turn on the power. The computer will beep once. Hit the RETURN key, and Krazy Katerpillars will load and run automatically.
When the title screen appears, use the SELECT key to choose a starting level, 1-9, then press START to begin playing.
In Krazy Katerpillars, you have four lives. The number remaining is shown in the upper right corner, under your level. Contact with any creature or a spike will take one life. A level is completed when all the Katerpillars have been destroyed. The larvae going off the screen’s bottom will cycle back to the top and reappear.
Any of your missiles that reach the top of the screen are reset to the bottom and become spikes. Remember, contact with a spike is deadly. Spikes can be useful, though, for killing Katerpillars—the tip is deadly to them.
When over, the game may be restarted at the original starting level by pressing the fire button. To pick a new level, press START. The title screen will appear, with the level selector.
Go with the flow of bugs from left to right. Try to shoot and maneuver your way up above the top layer. Then destroy the Katerpillars, using the spikes. On higher levels, you have to do this; it’s impossible to shoot them all on the first run-through.
1000 DATA 255,255,0,32,181,39,76,181,32,112,112,112,112,112,71,33,3613 1010 DATA 32,112,7,112,112,112,6,112,1 12,6,112,112,112,112,112,112,4045 1020 DATA 112,6,48,6,65,3,32,0,0,0,0,0 ,0,0,43,114,4348 1030 DATA 161,58,121,0,0,0,0,0,0,0,0,0 ,0,0,0,43,2358 1040 DATA 97,180,37,114,176,41,108,172 ,33,114,179,0,0,0,0,0,8728 1050 DATA 0,0,0,0,0,0,0,0,226,249,0,0, 0,0,0,0,5574 1060 DATA 0,0,0,0,0,0,0,0,228,225,246, 233,228,0,232,245,1228 1070 DATA 230,230,0,0,0,0,0,0,0,0,0,24 3,229,236,229,227,8024 1080 DATA 244,0,236,229,246,229,236,0, 0,0,0,0,0,0,0,240,1044 1090 DATA 242,229,243,243,0,243,244,22 5,242,244,0,0,0,0,0,0,3075 1100 DATA 0,0,0,0,112,112,112,70,0,48, 134,197,40,48,133,133,3309 1110 DATA 133,133,133,133,133,133,133, 133,65,158,32,216,169,72,141,196,9463 1120 DATA 2,169,40,141,197,2,169,120,1 41,198,2,169,104,141,199,2,6926 1130 DATA 169,0,141,200,2,169,3,141,48 ,2,169,32,141,49,2,162,2531 1140 DATA 31,169,0,149,176,202,16,251, 162,0,138,157,0,6,202,208,7619 1150 DATA 250,169,40,133,194,169,48,13 3,195,32,230,37,162,8,169,0,5576 1160 DATA 157,0,210,202,16,250,32,101, 228,160,115,162,38,169,7,32,5705 1170 DATA 92,228,162,1,142,11,6,173,19 8,2,72,162,1,189,196,2,4579 1180 DATA 157,197,2,202,16,247,104,141 ,196,2,169,15,141,24,6,173,4813 1190 DATA 31,208,41,1,240,52,173,24,6, 208,244,173,31,208,41,2,5535 1200 DATA 208,18,238,11,6,169,170,141, 7,210,169,121,141,6,210,169,8809 1210 DATA 10,141,8,6,173,11,6,201,10,1 44,5,169,1,141,11,6,9992 1220 DATA 9,208,162,97,157,33,32,76,17 ,33,206,11,6,174,11,6,9990 1230 DATA 142,10,6,142,12,6,169,224,13 3,198,169,40,133,200,169,0,7629 1240 DATA 133,197,133,199,162,1,160,0, 177,197,145,199,136,208,249,230,4539 1250 DATA 198,230,200,202,16,240,162,3 9,189,101,39,157,0,40,202,16,5152 1260 DATA 247,169,28,141,196,2,169,136 ,141,197,2,169,204,141,198,2,8673 1270 DATA 169,42,141,199,2,169,0,141,2 00,2,169,158,141,48,2,169,5708 1280 DATA 32,141,49,2,169,103,141,0,2, 169,37,141,1,2,169,192,3654 1290 DATA 141,14,212,169,40,141,244,2, 169,3,141,29,208,169,62,141,7247 1300 DATA 47,2,169,40,141,7,212,169,16 ,141,111,2,162,0,142,8,2764 1310 DATA 208,142,12,208,169,44,133,17 7,169,43,133,191,32,163,37,162,7677 1320 DATA 39,189,141,39,157,0,48,202,1 6,247,162,0,142,16,6,142,3881 1330 DATA 17,6,142,18,6,32,217,36,162, 4,142,23,6,32,0,36,8324 1340 DATA 162,1,142,0,6,142,30,208,32, 117,36,32,225,34,32,217,4277 1350 DATA 36,32,105,36,32,225,34,32,82 ,38,173,9,6,240,3,32,1037 1360 DATA 0,36,173,13,6,240,3,76,71,34 ,76,34,34,169,0,141,1389 1370 DATA 0,6,141,13,6,160,17,185,46,3 9,145,176,136,16,248,169,7373 1380 DATA 32,141,4,210,169,34,141,7,6, 173,7,6,208,251,32,163,5877 1390 DATA 37,206,23,6,173,23,6,240,23, 32,37,37,32,230,37,32,978 1400 DATA 250,37,32,203,37,169,1,141,3 0,208,141,0,6,76,34,34,1063 1410 DATA 162,8,189,92,39,157,25,48,20 2,16,247,32,230,37,169,10,5501 1420 DATA 141,15,6,32,44,38,169,10,141 ,15,6,230,195,32,44,38,1944 1430 DATA 198,195,173,31,208,41,1,208, 10,173,31,208,41,1,240,249,8406 1440 DATA 76,181,32,173,132,2,240,16,1 73,24,6,208,229,32,117,36,5261 1450 DATA 169,10,141,24,6,76,172,34,17 4,12,6,142,10,6,142,11,96 1460 DATA 6,32,230,37,76,249,33,162,3, 189,8,208,240,6,238,13,7252 1470 DATA 6,76,251,35,202,16,242,162,3 ,189,0,208,240,3,32,208,8000 1480 DATA 35,202,16,245,162,1,142,30,2 08,162,3,173,27,6,61,252,5980 1490 DATA 35,240,3,32,110,35,202,16,24 2,173,4,6,240,6,206,4,4826 1500 DATA 6,76,251,35,169,4,141,4,6,17 3,132,2,240,3,76,251,6017 1510 DATA 35,162,3,173,27,6,61,252,35, 208,15,189,252,35,13,27,4405 1520 DATA 6,141,27,6,32,74,35,76,251,3 5,202,16,230,76,251,35,6772 1530 DATA 169,166,141,1,210,169,15,141 ,5,6,165,178,24,105,3,157,4150 1540 DATA 4,208,149,181,56,165,176,233 ,5,149,185,169,65,157,28,6,6654 1550 DATA 32,110,35,96,181,185,133,190 ,222,28,6,240,53,189,32,6,5892 1560 DATA 208,14,160,2,189,252,35,73,2 55,49,190,145,190,136,16,244,703 1570 DATA 56,165,190,233,3,133,190,149 ,185,201,50,144,13,160,2,177,8017 1580 DATA 190,29,252,35,145,190,136,16 ,246,96,169,255,149,185,157,32,1156 1590 DATA 6,96,160,0,169,0,133,190,189 ,252,35,73,255,49,190,145,217 1600 DATA 190,136,208,244,169,0,157,28 ,6,157,32,6,189,252,35,77,5620 1610 DATA 27,6,141,27,6,96,32,172,35,1 81,185,133,190,181,181,133,9989 1620 DATA 189,142,3,6,32,159,36,169,0, 145,192,200,145,192,169,32,8426 1630 DATA 141,21,6,169,168,141,3,210,1 69,11,141,6,6,174,3,6,1803 1640 DATA 96,96,3,12,48,192,248,24,173 ,10,6,105,1,141,10,6,521 1650 DATA 216,169,0,141,0,6,141,9,6,23 8,11,6,173,11,6,201,2199 1660 DATA 16,144,5,169,14,141,11,6,174 ,11,6,189,89,36,141,14,1706 1670 DATA 6,169,168,141,7,210,169,200, 141,6,210,169,80,141,8,6,6057 1680 DATA 32,163,37,32,37,37,32,217,36 ,32,250,37,32,203,37,169,4999 1690 DATA 150,141,24,6,173,24,6,208,25 1,169,1,141,0,6,96,0,2109 1700 DATA 30,25,20,25,17,10,15,12,10,1 0,7,6,5,5,4,174,5604 1710 DATA 14,6,160,255,136,208,253,202 ,208,248,96,162,2,142,25,6,8388 1720 DATA 160,255,230,195,177,194,170, 198,195,160,0,142,26,6,177,194,9923 1730 DATA 170,173,26,6,145,194,200,208 ,242,230,195,206,25,6,208,233,3653 1740 DATA 198,195,198,195,96,56,165,18 9,233,48,74,74,170,169,0,141,8296 1750 DATA 1,6,56,165,190,233,48,41,240 ,74,141,2,6,10,10,46,1182 1760 DATA 1,6,24,109,2,6,133,192,173,1 ,6,105,0,133,193,24,2828 1770 DATA 169,40,101,192,133,192,169,4 8,101,193,133,193,138,168,96,248,2646 1780 DATA 24,162,2,189,16,6,125,19,6,1 57,16,6,202,16,244,216,5871 1790 DATA 162,2,169,0,157,19,6,202,16, 250,162,6,160,0,185,16,4629 1800 DATA 6,32,14,37,232,232,200,192,3 ,208,243,162,17,173,10,6,7161 1810 DATA 32,14,37,96,141,22,6,41,15,9 ,16,157,1,48,173,22,9489 1820 DATA 6,74,74,74,74,9,16,157,0,48, 96,169,45,133,180,169,5699 1830 DATA 38,133,179,162,3,169,0,157,0 ,208,202,208,250,169,26,141,664 1840 DATA 193,2,141,194,2,141,195,2,16 2,2,160,13,185,32,39,145,4625 1850 DATA 179,136,16,248,230,180,202,1 6,241,174,23,6,202,240,9,189,492 1860 DATA 99,37,157,0,208,202,208,247, 96,0,176,183,190,72,138,72,9884 1870 DATA 152,72,166,196,189,141,37,18 8,152,37,141,10,212,141,22,208,8799 1880 DATA 140,23,208,230,196,224,11,20 8,4,162,0,134,196,104,168,104,9127 1890 DATA 170,104,64,134,198,24,86,126 ,182,70,42,6,102,14,14,26,760 1900 DATA 60,28,136,202,122,70,28,60,1 68,169,0,133,190,162,5,169,7253 1910 DATA 0,168,145,190,136,208,251,23 0,191,202,208,246,169,43,133,191,5795 1920 DATA 162,3,169,0,157,32,6,157,28, 6,141,27,6,202,16,244,4107 1930 DATA 96,169,128,133,176,169,100,1 41,0,208,133,178,169,14,141,192,261 1940 DATA 2,160,13,185,32,39,145,176,1 36,16,248,96,162,1,169,0,5777 1950 DATA 168,145,194,136,208,251,230, 195,202,16,246,169,48,133,195,96,2909 1960 DATA 32,35,38,230,195,32,35,38,19 8,195,24,165,194,105,160,133,9308 1970 DATA 194,165,195,105,0,133,195,16 0,160,169,0,145,194,136,208,251,3374 1980 DATA 169,40,133,194,169,48,133,19 5,96,174,11,6,189,66,38,141,6032 1990 DATA 15,6,172,10,210,32,56,38,206 ,15,6,16,245,96,162,4,3796 2000 DATA 138,145,194,136,202,208,249, 96,0,6,10,15,25,16,10,20,9692 2010 DATA 22,25,25,27,30,30,35,35,162, 1,160,0,177,194,208,15,4725 2020 DATA 136,208,249,230,195,202,16,2 44,162,1,142,9,6,208,5,162,7285 2030 DATA 0,142,9,6,169,48,133,195,96, 216,174,24,6,240,3,206,7994 2040 DATA 24,6,174,5,6,240,11,189,64,3 9,141,0,210,206,5,6,3979 2050 DATA 208,5,169,0,141,1,210,174,6, 6,240,11,189,80,39,141,5652 2060 DATA 2,210,206,6,6,208,5,169,0,14 1,3,210,173,7,6,240,6029 2070 DATA 9,74,141,5,210,206,7,6,208,5 ,169,0,141,5,210,174,6671 2080 DATA 8,6,240,5,206,8,6,208,5,169, 0,141,7,210,173,0,4677 2090 DATA 6,208,3,76,98,228,173,4,208, 240,6,238,13,6,76,205,7793 2100 DATA 38,166,178,164,176,173,120,2 ,74,176,2,136,136,74,176,2,5990 2110 DATA 200,200,74,176,2,202,202,74, 176,2,232,232,224,50,144,11,9752 2120 DATA 224,208,144,2,162,50,134,178 ,142,0,208,192,90,144,6,192,8890 2130 DATA 185,176,2,132,176,160,13,185 ,32,39,145,176,136,16,248,169,9413 2140 DATA 0,133,77,76,205,38,0,0,8,8,8 ,28,28,62,62,62,7924 2150 DATA 62,62,0,0,8,16,74,34,72,68,1 6,133,16,4,162,20,9376 2160 DATA 69,18,72,18,8,16,230,240,250 ,255,230,200,180,170,150,130,4999 2170 DATA 100,75,65,50,45,40,120,100,9 0,80,75,70,50,40,30,20,175 2180 DATA 10,5,167,161,173,165,0,175,1 82,165,178,0,0,0,0,0,1846 2190 DATA 0,0,0,0,12,51,86,90,86,51,12 ,0,204,51,149,165,3535 2200 DATA 149,51,204,0,204,51,86,90,86 ,51,204,0,192,48,148,165,7267 2210 DATA 148,48,192,115,99,111,114,10 1,0,0,0,0,0,0,0,0,6257 2220 DATA 108,118,108,0,0,0,0,0,0,0,0, 0,0,0,0,0,2888 2230 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,25 5,0,255,9880 2240 DATA 37,224,2,225,2,0,32,0,0,0,0, 0,0,0,0,0,3865
10 REM *** KRAZY KATERPILLARS *** 20 REM CASSETTE MAKER PROGRAM 40 DIM DAT(16):LINE=990:RESTORE 10000:TRAP 120:? "CHECKING DATA" 50 LINE=LINE+10:? "LINE :"; LINE : FOR X=1 TO 16:READ DAT:IF DAT<0 OR DAT>25 5 THEN 220 60 DAT(X)=DAT:NEKT X:DATLIN=PEEK(183)+ PEEK(843)*256:IF DATLIN<>LINE THEN ? " LINE ";LINE;" MISSING !":END 70 TOTAL=LINE:FOR X=1 TO 16 80 IF PASS=0 THEN PUT #1,DAT(X):NEXT X :READ CHKSUM:GOTO 50 90 TOTAL=TOTAL+DAT(X)*X:IF TOTAL>9999 THEN TOTAL=TOTAL−10000 100 NEXT X:READ CHKSUM:IF TOTAL=CHKSUM THEN 50 110 GOTO 220 120 IF PEEK(195)<>6 THEN 220 130 IF PASS=0 THEN 200 160 FOR X=1 TO 128:PUT #1,0:NEXT X:CLO SE #1:END 200 ? "READY CASSETTE AND PRESS RETURN ";:OPEN #1,8,128,"C:":RESTORE 230:FOR X=1 TO 40:READ N:PUT #1,N:NEXT X 210 ? :? "WRITING FILE":PASS=2:LINE=99 0:RESTORE 1000:TRAP 120:GOTO 50 220 ? "BAD DATA: LINE ";LINE:END 230 DATA 0,16,210,31,249,31,169,0,234, 234,234,169,60,141,2,211,169,0,141,231 ,2,133,14,169,86,141,232,2 240 DATA 133,15,169,0,133,10,169,32,13
;KRAZY KATERPILLARS ;DAVID HUFF ; ; ;RUN ADDRESS: $2000 ; ; .OPT NOEJECT .TAB 12,17,28 ; ;SYSTEM EQUATES ; HPOSP0 = $D000 HPOSM0 = $D004 SIZEP0 = $D008 SIZEM = $D00C M0PF = $D000 P0PF = $D004 M0PL = $D008 PMBASE = $D407 HITCLR = $D01E GRACTL = $D01D SDMCTL = $022F GPRIOR = $026F SDLSTL = $0230 VDSLST = $0200 CHBAS = $02F4 STICK0 = $0278 STRIG0 = $0284 PCOLR0 = $02C0 COLOR0 = $02C4 ATRACT = $4D COLPF0 = $D016 AUDCTL = $D208 AUDF1 = $D200 AUDC1 = $D201 AUDF2 = $D202 AUDC2 = $D203 AUDF3 = $D204 AUDC3 = $D205 AUDF4 = $D206 AUDC4 = $D207 RANDOM = $D20A XITVBV = $E462 SETVBV = $E45C SIOINV = $E465 NMIEN = $D40E WSYNC = $D40A CONSOL = $D01F ; ;PROGRAM REGISTERS ; *= $B0 ; VP0LO *= *+1 ;Y POS. PLAYER0 VP0HI *= *+1 SHP0 *= *+1 ;X POS. PLAYER0 VP1LO *= *+1 ;Y POS. PLAYER1 VP1HI *= *+1 SHM0 *= *+4 ;X POS. MISSILES VPMLO *= *+4 ;Y POS. MISSILES HPOSM *= *+1 ;X POS. COLLISION VPM0LO *= *+1 ;Y POS. COLLISION VPM0HI *= *+1 COLLO *= *+1 ;COLLISION ADDR COLHI *= *+1 DMLO *= *+1 ;START SCREEN MEM DMHI *= *+1 DLCNT *= *+1 ;DLI COUNTER OLDSET *= *+2 ;ADDR ROM CHSET NEWSET *= *+2 ;ADDR NEW CHSET ; *= $0600 ; STOP *= *+1 ;PLAYER MOVEMENT? TEMPHI *= *+1 ;TEMPS LOX8 *= *+1 SAVEX *= *+1 TRGCNT *= *+1 ;READ TRIGGER? M0SND *= *+1 ;SOUNDS HITSND *= *+1 P0SND *= *+1 LVLSND *= *+1 LVLFLG *= *+1 ;NEW LEVEL? LEVEL *= *+1 ;BCD LEVEL # LEVHEX *= *+1 ;HEX LEVEL # LEVORG *= *+1 ;ORIGINAL LEVEL P0DEAD *= *+1 ;PLAYER DEAD? SPEED *= *+1 ;BUGS SPEED BUGCNT *= *+1 ;# OF BUGS SCORE *= *+3 ;SCORE SCOADD *= *+3 ;ADD TO SCORE DIGIT *= *+1 ;FOR DISPLAY LIVES *= *+1 ;LIVES TIMER *= *+1 ;DELAY TIMER CPYCNT *= *+1 ;PAGES TO MOVE CPYTMP *= *+1 ;TEMP MSTAT *= *+1 ;WHICH MISSILES OUT MSTOP *= *+4 ;DISTANCE TO GO SPKFLG *= *+4 ;SPIKE ON? ; PMB = $2800 ;PMBASE ADDRESS CHBASE = PMB ;CHARACTER SET BASE SCOMEM = $3000 ;SCORE LINE DMEM = SCOMEM+40 ;DISPLAY MEMORY ; ; *= $2000 ; JMP START ; ; ;DISPLAY LIST FOR TITLE ; DLTITL .BYTE $70,$70,$70,$70,$70 .BYTE $47 .WORD TITLE .BYTE $70,7,$70,$70,$70,6,$70,$70,6 .BYTE $70,$70,$70,$70,$70,$70,$70,6,$30,6 .BYTE $41 .WORD DLTITL ; ; ;TITLE MEMORY ; TITLE .BYTE 0,0,0,0,0,0,0,43,114,161,58,121 *= *+12 .BYTE 43,97,180,37,114,176,41 .BYTE 108,172,33,114,179 *= *+13 .BYTE 226,249 *= *+14 .BYTE 228,225,246,233,228,0,232,245,230,230 *= *+9 .BYTE 243,229,236,229,227,244,0 .BYTE 236,229,246,229,236 *= *+8 .BYTE 240,242,229,243,243,0 .BYTE 243,244,225,242,244 *= *+10 ; ; ;GAME DISPLAY LIST ; DLIST .BYTE $70,$70,$70 .BYTE $46 .WORD SCOMEM .BYTE $86,$C5 .WORD DMEM .BYTE $85,$85,$85,$85,$85,$85,$85,$85,$85,$85 .BYTE $41 .WORD DLIST ; ; START CLD LDA #72 ;TITLE COLORS STA COLOR0 LDA #40 STA COLOR0+1 LDA #120 STA COLOR0+2 LDA #104 STA COLOR0+3 LDA #0 ;BACKGND STA COLOR0+4 ; LDA #DLTITL&$FF ;SHOW TITLE STA SDLSTL LDA #DLTITL/256 STA SDLSTL+1 ; LDX #31 ;CLEAR PAGE0 REGISTERS LDA #0 CLRP0 STA $B0,X DEX BPL CLRP0 ; LDX #0 ;CLEAR PAGE6 TXA CLRP6 STA $0600,X DEX BNE CLRP6 ; LDA #DMEM&$FF ;SET POINTER TO STA DMLO ;SCREEN MEMORY LDA #DMEM/256 STA DMHI JSR CLRSM ;CLEAR PLAYFIELD ; LDX #8 ;INITIALIZE SOUNDS LDA #0 NOSND STA AUDF1,X DEX BPL NOSND JSR SIOINV ; LDY #VBLANK&$FF ;START VBI LDX #VBLANK/256 LDA #7 JSR SETVBV ; LDX #1 ;SET LEVEL STX LEVHEX ; ; ;ROTATE TITLE COLORS ; ROTCOL LDA COLOR0+2 ;GET COLOR2 PHA ;SAVE IT LDX #1 COLR LDA COLOR0,X ;GET COLOR STA COLOR0+1,X ;MOVE IT DEX ;NEXT COLOR BPL COLR PLA ;GET COLOR2 STA COLOR0 ;TO COLOR0 ; LDA #15 ;DELAY STA TIMER TM LDA CONSOL AND #1 ;CHECK START BEQ BEGIN ;PRESSED, BEGIN GAME LDA TIMER ;TIME UP? BNE TM ;NO ; LDA CONSOL AND #2 ;CHECK SELECT BNE SHOLEV ;NOT PRESSED INC LEVHEX ;PRESSED LDA #$AA ;BEEP STA AUDC4 LDA #121 STA AUDF4 LDA #10 ;DURATION STA LVLSND SHOLEV LDA LEVHEX ;GET LEVEL CMP #10 ;TO BIG? BCC OKLEV ;NO LDA #1 ;YES,RESET STA LEVHEX OKLEV ORA #$D0 ;COLOR3 LDX #97 STA TITLE,X ;DISPLAY IT JMP ROTCOL ;TITLE ROUTINE ; BEGIN DEC LEVHEX ;WANT (0-9) LDX LEVHEX ;START LEVEL STX LEVEL STX LEVORG ;KEEP ORIGINAL LEVEL ; ; ;REDEFINE CHARACTERS ; LDA #$E0 ;ADDR ROM CHSET STA OLDSET+1 LDA #CHBASE/256 ;NEW CHBASE STA NEWSET+1 LDA #0 ;LOW BYTES STA OLDSET STA NEWSET ; LDX #1 ;DO 2 PAGES OF CHSET CH1 LDY #0 CH2 LDA (OLDSET),Y ;GET ROM STA (NEWSET),Y ;PUT IN RAM DEY BNE CH2 INC OLDSET+1 ;DO NEXT PAGE INC NEWSET+1 DEX BPL CH1 ; NEWCH LDX #39 ;REDEFINE CHARACTERS NEW1 LDA CHR1,X ;GET CHAR DATA STA CHBASE,X ;MOVE IT DEX BPL NEW1 ; ;GAME COLORS ; LDA #28 ;SCORE NUMBERS STA COLOR0 LDA #136 ;SCORE LETTERS STA COLOR0+1 LDA #204 ;BUGS LEGS STA COLOR0+2 LDA #42 ;MISSILES STA COLOR0+3 LDA #0 ;BACKGND STA COLOR0+4 ; LDA #DLIST&$FF ;GAME DISPLA ON STA SDLSTL LDA #DLIST/256 STA SDLSTL+1 ; LDA #DLI&$FF ;SET DLI VECTOR STA VDSLST LDA #DLI/256 STA VDSLST+1 ; LDA #$C0 ;ENABLE DLI STA NMIEN ; LDA #CHBASE/256 ;SWITCH CHAR BASE STA CHBAS ; LDA #3 ;ENABLE P/M STA GRACTL LDA #62 ;SINGLE LINE RES. STA SDMCTL LDA #PMB/256 ;HI BYTE PMBASE STA PMBASE LDA #16 ;FIFTH PLAYER ENABLE STA GPRIOR LDX #0 ;NORMAL SIZE STX SIZEP0 STX SIZEM LDA #PMB/256+4 ;PLAYER0 BASE STA VP0HI LDA #PMB/256+3 ;MISSILE BASE STA VPM0HI JSR CLRPM ;CLEAR P/M AREA ; RESET LDX #39 ;DISPLAY SCORE LINE SCRLN LDA SCOLN,X STA SCOMEM,X DEX BPL SCRLN ; LDX #0 ;SCORE = 0 STX SCORE STX SCORE+1 STX SCORE+2 JSR DISPSCO ;PUT ON SCORE ; LDX #4 ;4 LIVES STX LIVES JSR NEWLVL ;GET FIRST LEVEL ; LDX #1 ;ENABLE MOVEMENT STX STOP STX HITCLR ;CLEAR COLLISIONS ; ; ; ;MAIN LOOP ; PLAY JSR COPY ;MOVE BUGS JSR MFIRE ;MOVE MISSILES JSR DISPSCO ;SHOW SCORE JSR DELAY ;SLOW IT DOWN JSR MFIRE ;MOVE AGAIN JSR CKLEV ;CHECK LEVEL LDA LVLFLG ;COMPLETE? BEQ CHKP0 ;NO JSR NEWLVL ;YES,DO NEXT LEVEL ; CHKP0 LDA P0DEAD ;PLAYER DEAD BEQ ALIVE ;NO JMP KILLP0 ;YES,EXPLOSION ; ALIVE JMP PLAY ;CONTINUE GAME ; ; ;PLAYER KILLED ; KILLP0 LDA #0 ;NO MOTION STA STOP STA P0DEAD ;RESET FLAG ; LDY #17 ;SHOW EXPLOSION EXP LDA EXPLODE,Y ;DATA STA (VP0LO),Y ;SHOW IT DEY BPL EXP ; LDA #32 ;TURN ON SOUND STA AUDF3 LDA #34 STA P0SND DLY LDA P0SND ;WAIT BNE DLY ; JSR CLRPM ;CLEAR P/M AREA ; DEC LIVES ;LOSE A LIFE LDA LIVES ;ANY LEFT? BEQ DEAD ;NO JSR DISPLIV ;YES,SHOW THEM JSR CLRSM ;CLEAR SCREEN JSR SETUP ;SETUP LEVEL JSR STARTP0 ;RESTART LDA #1 STA HITCLR ;CLEAR COLLISION STA STOP ;ALLOW MOVEMENT JMP PLAY ;TO MAIN LOOP ; ; ; ; GAME OVER ROUTINE ; DEAD LDX #8 DD1 LDA MESSAGE,X ;GAME OVER STA SCOMEM+25,X ;SHOW IT DEX BPL DD1 ; JSR CLRSM ;CLEAR SCREEN LDA #10 STA BUGCNT ;10 BUGS JSR SET1 ;SHOW THEM LDA #10 STA BUGCNT ;10 BUGS INC DMHI ;NEXT PAGE JSR SET1 ;SHOW THEM DEC DMHI ;RESTORE ; WAIT LDA CONSOL AND #1 ;START? BNE WT1 ;NO WT2 LDA CONSOL ;YES AND #1 ;RELEASED? BEQ WT2 ;NO JMP START ;YES, DO TITLE ; WT1 LDA STRIG0 ;PRESSED? BEQ RESTART ;YES LDA TIMER ;TIME UP? BNE WAIT ;NO JSR COPY ;MOVE BUGS LDA #10 ;RELOAD TIMER STA TIMER JMP WAIT ;KEEP CHECKING ; RESTART LDX LEVORG ;ORIGINAL LEV STX LEVEL ;RESET STX LEVHEX JSR CLRSM ;CLEAR SCREEN JMP RESET ;RESTART ; ; ; ; ;SUBROUTINES ; ; ;MISSILE ROUTINES ; MFIRE LDX #3 ;DO 4 MISSILES CKP0 LDA M0PL,X ;PLAYER HIT? BEQ NOMHIT ;NO INC P0DEAD ;YES,SET FLAG JMP FMEXIT ;DONE NOMHIT DEX ;NEXT MISSILE BPL CKP0 ; LDX #3 ;DO 4 MISSILES CKM LDA M0PF,X ;BUG HIT? BEQ NOHIT ;NO JSR KILLBUG ;YES, DESTROY IT NOHIT DEX ;NEXT MISSILE BPL CKM ; LDX #1 ;CLEAR COLLISIONS STX HITCLR ; LDX #3 ;MOVE MISSILES IF OUT FIREM LDA MSTAT ;MISSILE STATUS AND MDATA,X ;IS IT OUT? BEQ NOMOVE ;NO JSR MOVEM ;YES, MOVE IT NOMOVE DEX ;NEXT ONE BPL FIREM ; TRIG LDA TRGCNT ;CHECK TRIG? BEQ CKTRIG ;YES DEC TRGCNT ;NO JMP FMEXIT ;DONE ; CKTRIG LDA #4 ;RESET IT STA TRGCNT LDA STRIG0 ;PRESSED? BEQ LAUNCH ;YES, TRY TO FIRE JMP FMEXIT ;NO ; LAUNCH LDX #3 NEXTM LDA MSTAT ;ANY AVAILABLE? AND MDATA,X ;CHECK BITS BNE MOUT ;NO,ALREADY OUT LDA MDATA,X ;YES ORA MSTAT ;UPDATE MSTAT STA MSTAT ;TO SHOW IT'S OUT JSR STARTM ;START IT JMP FMEXIT ;CAN ONLY FIRE 1 MOUT DEX ;TRY NEXT ONE BPL NEXTM JMP FMEXIT ; STARTM LDA #$A6 ;MISSILE SOUND STA AUDC1 LDA #15 STA M0SND ; LDA SHP0 ;GET PLAYERS X POS. CLC ADC #3 ;OFFSET STA HPOSM0,X STA SHM0,X ;SAVE MISSILE POS. ; SEC LDA VP0LO ;PLAYERS VERT .POS SBC #5 ;OFFSET STA VPMLO,X ;SAVE IT ; LDA #65 ;MOVE IT 65 TIMES STA MSTOP,X ; JSR MOVEM ;MOVE IT RTS ; MOVEM LDA VPMLO,X ;GET Y STA VPM0LO ;SAVE IT ; DEC MSTOP,X ;DONE? BEQ CLEARM ;YES, CLEAR IT ; LDA SPKFLG,X ;SPIKE? BNE SPIKE ;YES LDY #2 ;NO,ERASE OLD POS. CLRM LDA MDATA,X ;GET BITS EOR #$FF ;MAKE MASK AND (VPM0LO),Y ;ZERO BITS STA (VPM0LO),Y ;MISSILE OFF DEY BPL CLRM ; SPIKE SEC LDA VPM0LO ;OLD Y SBC #3 ;MOVE UP 3 STA VPM0LO STA VPMLO,X ;SAVE NEW Y CMP #50 ;TOP LIMIT BCC SPKON ;YES,SPIKE ON LDY #2 ;NO LOADM LDA (VPM0LO),Y ORA MDATA,X ;GET MISSILE BITS STA (VPM0LO),Y ;MISSILE ON DEY BPL LOADM RTS ; SPKON LDA #255 ;SPIKE ON STA VPMLO,X ;MISSILE TO BOTTOM STA SPKFLG,X ;SET FLAG RTS ; CLEARM LDY #0 ;ERASE A MISSILE LDA #0 STA VPM0LO CLM LDA MDATA,X ;GET MISSILE BITS EOR #$FF ;MAKE MASK AND (VPM0LO),Y ;ZERO BITS STA (VPM0LO),Y ;TURN IT OFF DEY ;DO ALL OF MISSILE BNE CLM ; LDA #0 ;RESET STA MSTOP,X STA SPKFLG,X ; LDA MDATA,X ;MISSILE BITS EOR MSTAT ;MISSILE NOT OUT STA MSTAT ;UPDATE MSTAT RTS ; ; KILLBUG JSR CLEARM ;HIT A BUG LDA VPMLO,X ;GET Y POS. STA VPM0LO LDA SHM0,X ;GET X POS STA HPOSM ; STX SAVEX ;SAVE MISSILE # JSR FIND ;GET MEMORY LOCATION ; LDA #0 ;ERASE THE BUG STA (COLLO),Y ;FIRST PART INY STA (COLLO),Y ;SECOND PART ; LDA #$20 ;UP SCORE STA SCOADD+2 ; LDA #$A8 ;SOUND ON STA AUDC2 LDA #11 STA HITSND LDX SAVEX ;RECOVER MISSILE # RTS ; FMEXIT RTS TO MAIN LOOP ; MDATA .BYTE 3,12,48,192 ; ; ; ;SHOW NEXT LEVEL ; NEWLVL SED ;BCD ADDITION CLC LDA LEVEL ;BCD LEVEL ADC #1 STA LEVEL CLD ; LDA #0 STA STOP ;STOP MOVEMENT STA LVLFLG ;RESET FLAG ; INC LEVHEX ;HEX LEVEL LDA LEVHEX CMP #16 ;TOO BIG? BCC LEVOK ;NO LDA #14 ;YES STA LEVHEX LEVOK LDX LEVHEX ;INDEX LDA LEVSPEED,X ;GET LEVEL SPEED STA SPEED ;FOR COPY ROUTINE ; LDA #$A8 ;NEW LEVEL SOUND STA AUDC4 LDA #200 STA AUDF4 LDA #80 ;SOUND DURATION STA LVLSND ; JSR CLRPM ;CLEAR P/M JSR DISPLIV ;SHOW LIVES JSR DISPSCO ;SHOW SCORE JSR SETUP ;NEXT LEVEL JSR STARTP0 ;START PLAYER ; LDA #150 ;DELAY BETWEEN LEVELS STA TIMER DLEV1 LDA TIMER BNE DLEV1 LDA #1 STA STOP ;ALLOW MOVEMENT RTS ; LEVSPEED .BYTE 0,30,25,20,25,17,10,15 .BYTE 12,10,10,7,6,5,5,4 ; ; ; DELAY LDX SPEED ;SLOW IT DOWN DE1 LDY #255 DE2 DEY BNE DE2 DEX BNE DE1 RTS ; ; ; ;MOVE THE BUGS ; COPY LDX #2 ;DO 2 PAGES STX CPYCNT ; LDY #$FF INC DMHI LDA (DMLO),Y ;GET LAST BYTE TAX ;SAVE IT DEC DMHI ;RESTORE ; CPY1 LDY #0 ;SET TO FIRST BYTE CPY2 STX CPYTMP LDA (DMLO),Y ;GET BYTE TAX ;STORE LDA CPYTMP ;GET PREVIOUS BYTE STA (DMLO),Y ;MOVE IT INY ;NEXT BYTE BNE CPY2 ; INC DMHI ;NEXT PAGE DEC CPYCNT ;DONE? BNE CPY1 ;NO ; DEC DMHI ;YES,RESTORE DEC DMHI RTS ; ; ; ;CALCULATE SCREEN MEMORY ADDRESS ;FROM P/M COORDINATES ; FIND SEC LDA HPOSM ;X POS SBC #48 ;OFFSET LSR A ;/2 LSR A ;/4 TAX ;X COORD ; LDA #0 ;CLEAR STA TEMPHI ; SEC ;Y=Y/16*40 BYTES/LINE LDA VPM0LO ;Y POS SBC #48 ;OFFSET AND #$F0 ;Y/16*16 LSR A ;SHIFT RIGHT (*8) STA LOX8 ;SAVE *8 ; ASL A ;*16 ASL A ;*32 ROL TEMPHI ;SHIFT CARRY ; CLC ;ADD *8+*32=*40 ADC LOX8 STA COLLO ;*40 LO LDA TEMPHI ADC #0 STA COLHI ;*40 HI ; CLC ;GET FINAL COLLISION ADDR LDA #DMEM&$FF ;SCREEN MEM ADC COLLO ;ADD POSITION STA COLLO ;COLLISION ADDR LO LDA #DMEM/256 ADC COLHI STA COLHI ;COLLISION ADDR HI ; TXA ;GET X TAY ;Y=INDEX FOR X POS RTS ; ; ; ;SCORE AND LEVEL DISPLAY ; DISPSCO SED ;BCD ADDITION CLC LDX #2 ;DO 3 BYTES TOTAL LDA SCORE,X ;GET OLD SCORE ADC SCOADD,X ;ADD TO SCORE STA SCORE,X ;SAVE SCORE DEX BPL TOTAL CLD ; LDX #2 ;CLEAR SCOADD LDA #0 ZERO STA SCOADD,X DEX BPL ZERO ; LDX #6 ;POSITION 6 LDY #0 SCODP LDA SCORE,Y ;GET BYTE JSR DISP ;DISPLAY IT INX ;NEXT POSITION INX INY ;NEXT BYTE CPY #3 ;DO 3 BYTES BNE SCODP ; DISPLVL LDX #17 ;POSITION 17 LDA LEVEL ;LEVEL JSR DISP ;DISPLAY IT ; RTS ; ; DISP STA DIGIT ;BCD # TO SHOW AND #$0F ;LOWER NIBBLE ORA #$10 ;COLOR0 ; STA SCOMEM+1,X ;DISLPAY IT LDA DIGIT ;GET BCD # LSR A ;GET HIGH NIBBLE LSR A LSR A LSR A ORA #$10 ;COLOR0 STA SCOMEM,X ;DISPLAY IT RTS ; ; ; ;DISPLAY REMAINING LIVES ; DISPLIV LDA #PMB/256+5 ;PLAYER 1 Y POS. STA VP1HI LDA #38 STA VP1LO ; LDX #3 ;REMOVE ALL LDA #0 ;FROM SCREEN LD1 STA HPOSP0,X DEX BNE LD1 ; LDA #26 ;COLORS STA PCOLR0+1 STA PCOLR0+2 STA PCOLR0+3 ; LDX #2 ;DO 3 PLAYERS LD2 LDY #13 LD3 LDA P0DATA,Y ;SHAPE DATA STA (VP1LO),Y ;SHOW IT DEY BPL LD3 INC VP1HI ;NEXT PLAYER DEX BPL LD2 ; LDX LIVES DEX ;SHOW ONE LESS BEQ LD5 ;NONE TO SHOW LD4 LDA TABX,X ;POSITIONS STA HPOSP0,X ;SHOW PLAYERS DEX BNE LD4 LD5 RTS ; TABX .BYTE 0,176,183,190 ; ; ; ;DISPLAY LIST INTERRUPT ; DLI PHA ;SAVE X,Y,A TXA PHA TYA PHA ; LDX DLCNT ;WHICH LINE LDA BODYCLR,X ;COLOR0 LDY SPOTCLR,X ;COLOR1 STA WSYNC ;WAIT FOR SYNC STA COLPF0 ;CHANGE HARDWARE REG STY COLPF0+1 INC DLCNT ;NEXT LINE CPX #11 ;LAST ONE? BNE DLIEND ;NO LDX #0 ;YES STX DLCNT ;RESET TO TOP ; DLIEND PLA ;RESTORE X,Y,A TAY PLA TAX PLA RTI ; BODYCLR .BYTE 134,198,24,86,126,182,70,42,6,102,14 ; SPOTCLR .BYTE 14,26,60,28,136,202,122,70,28,60,168 ; ; ; ; ;CLEAR P/M MEMORY ; CLRPM LDA #0 ;MISSILE BASE STA VPM0LO ; LDX #5 ;DO 5 PAGES UP LDA #0 TAY CPM STA (VPM0LO),Y ;CLEAR IT DEY BNE CPM INC VPM0HI ;NEXT PAGE DEX BNE CPM ; LDA #PMB/256+3 ;RESET STA VPM0HI ; LDX #3 ;UPDATE TO SHOW LDA #0 ;ALL MISSILES OFF OFF STA SPKFLG,X STA MSTOP,X STA MSTAT DEX BPL OFF ; RTS ; ; ; ;START PLAYER ; STARTP0 LDA #128 ;Y START POS. STA VP0LO LDA #100 ;X STA HPOSP0 STA SHP0 ; LDA #14 STA PCOLR0 ;COLOR P0 ; LDY #13 DISP0 LDA P0DATA,Y ;SHAPE DATA STA (VP0LO),Y ;SHOW IT DEY BPL DISP0 ; RTS ; ; ; ;CLEAR SCREEN MEMORY ; CLRSM LDX #1 ;2 PAGES LDA #0 TAY CSM STA (DMLO),Y ;CLEAR IT DEY BNE CSM INC DMHI ;NEXT PAGE DEX BPL CSM ; LDA #DMEM/256 ;RESTORE STA DMHI ; RTS ; ; ; ;PLAYFIELD SETUP ; SETUP JSR RNDPF ;PUT ON BUGS INC DMHI ;NEXT PAGE OF MEMORY JSR RNDPF ;MORE BUGS DEC DMHI ;RESTORE ; CLC LDA DMLO ;FIND ADDR ADC #160 ;SCREEN CENTER STA DMLO LDA DMHI ADC #0 STA DMHI ; LDY #160 ;CLEAR 4 LINES LDA #0 ;IN SCREEN CENTER CP0S STA (DMLO),Y ;FOR START DEY BNE CP0S ; LDA #DMEM&$FF ;RESTORE STA DMLO LDA #DMEM/256 STA DMHI RTS ; ; RNDPF LDX LEVHEX ;INDEX LDA BUGLEV,X ;# TO DISPLAY STA BUGCNT ; SET1 LDY RANDOM ;POSITION JSR BUG ;SHOW THEM DEC BUGCNT ;ANY MORE? BPL SET1 ;YES RTS ;NO ; BUG LDX #4 ;CHARACTERS 1-4 SBUG TXA STA (DMLO),Y ;SHOW BUGS DEY DEX BNE SBUG ; RTS ; BUGLEV .BYTE 0,6,10,15,25,16,10 .BYTE 20,22,25,25,27,30,30,35,35 ; ; ; ;CHECK IF LEVEL COMPLETE ; CKLEV LDX #1 ;2 PAGES LDY #0 CKL1 LDA (DMLO),Y ;GET MEMORY BNE NOTDONE ; IF<>0 NOT DONE DEY ;CHECK NEXT BNE CKL1 INC DMHI ;NEXT PAGE DEX BPL CKL1 ; LDX #1 ;ALL ZERO,LEVEL DONE STX LVLFLG ;SET FLAG BNE LVLDONE ; NOTDONE LDX #0 ;NOT DONE STX LVLFLG LVLDONE LDA #DMEM/256 ;RESET STA DMHI ; RTS ; ; ; ; ; ; VBLANK ROUTINE ; ; VBLANK CLD ; LDX TIMER ;COUNT DOWN TIMER BEQ SOUND1 DEC TIMER ; SOUND1 LDX M0SND ;MISSILE SOUND ON? BEQ NOSND1 ;NO LDA M0SND1,X ;YES, NEXT FREQ STA AUDF1 DEC M0SND BNE SOUND2 NOSND1 LDA #0 ;OFF STA AUDC1 ; SOUND2 LDX HITSND ;BUG HIT SND ON? BEQ NOSND2 ;NO LDA HITSND2,X ;YES, NEXT FREQ STA AUDF2 DEC HITSND BNE SOUND3 NOSND2 LDA #0 ;OFF STA AUDC2 ; SOUND3 LDA P0SND ;BLOW UP SND ON? BEQ NOSND3 ;NO LSR A ;YES,/2 STA AUDC3 DEC P0SND BNE SOUND4 NOSND3 LDA #0 ;OFF STA AUDC3 ; SOUND4 LDX LVLSND ;SOUND 4 ON? BEQ NOSND4 ;NO DEC LVLSND ;YES BNE STOPVB NOSND4 LDA #$00 ;OFF STA AUDC4 ; STOPVB LDA STOP ;CONTINUE? BNE COLCK ;YES EXIT JMP XITVBV ;NO ; COLCK LDA P0PF ;PLAYER HIT? BEQ MOVE ;NO INC P0DEAD ;YES,SET FLAG JMP EXIT ; MOVE LDX SHP0 ;PLAYER X POS LDY VP0LO ;Y POS ; LDA STICK0 LSR A ;CHECK D0 BCS NOTUP ;SET,NO MOTION DEY ;NOT SET,MOVE UP 2 DEY ; NOTUP LSR A ;CHECK D1 BCS NOTDOWN ;NO INY ;MOVE DOWN 2 INY ; NOTDOWN LSR A ;CHECK D2 BCS NOTLEFT ;NO DEX ;MOVE 2 LEFT DEX ; NOTLEFT LSR A ;CHECK D3 BCS NOTRT ;NO INX ;MOVE 2 RIGHT INX ; NOTRT CPX #50 ;LEFT LIMIT BCC BADX ;TOO FAR CPX #208 ;RIGHT LIMIT BCC GOODX ;OK? YES LDX #50 ;NO,RESET TO LEFT GOODX STX SHP0 ;NEW X POS STX HPOSP0 ; BADX CPY #90 ;UPPER LIMIT BCC BADY ;TOO FAR? YES CPY #185 ;LOWER LIMIT BCS BADY ;TOO FAR? YES STY VP0LO ;OK, SAVE IT ; BADY LDY #13 ;READ IN PLAYER LP1 LDA P0DATA,Y ;AT VP0LO STA (VP0LO),Y DEY BPL LP1 ; LDA #0 ;STOP ATTRACT STA ATRACT JMP EXIT ;ALL DONE ; ; ; ;DATA TABLES ; P0DATA .BYTE 0,0,8,8,8,28,28,62,62,62,62,62,0,0 ; EXPLODE .BYTE 8,16,74,34,72,68,16,133,16 .BYTE 4,162,20,69,18,72,18,8,16 ; M0SND1 .BYTE 230,240,250,255,230,200,180,170,150,130 .BYTE 100,75,65,50,45,40 ; HITSND2 .BYTE 120,100,90,80,75,70,50,40,30,20,10,5 ; MESSAGE .BYTE 167,161,173,165,0,175,182,165,178 ; CHR1 .BYTE 0,0,0,0,0,0,0,0 .BYTE 0,12,51,86,90,86,51,12 .BYTE 0,204,51,149,165,149,51,204 .BYTE 0,204,51,86,90,86,51,204 .BYTE 0,192,48,148,165,148,48,192 ; SCOLN .BYTE $73,$63,$6F,$72,$65,0,0,0,0,0,0,0,0 .BYTE $6C,$76,$6C,0,0,0 *= *+21 ; .END