Dale’s Atari 800 Games › Stan Ockers
Munchers
By Stan Ockers, in the ACE newsletter of October 1981.
Play MunchersStan’s write-up
O.K., let’s get those player missile graphics routines out of page six and leave that area for other important functions. Easily enough said, but doing it is another matter. The problem is that it is difficult to find an area of memory guaranteed to be free for all memory sizes, disk users, cassette users etc. About the only area you can be certain about is just that page six.
The answer to the problem is to make the routines relocatable. That means they will run fine no matter where they’re located. I’ve re-written the routines this way using as absolute locations some bytes at the end of page six. I’ve also added some useful new routines and consolidated the beginning portions of all routines.
Where did I put the routines? Well, after considering a number of alternatives I decided to pack all the routines into a string U$. Using U=ADR(U$), you can determine the address where the string begins. The starting point of various routines can be stated relative to this point. I’m assuming that once dimensioned, the address of U$ doesn’t change while the program runs, (I’m not absolutely sure of this yet).
The consolidations previously mentioned requires that the calling procedure be a little different. Here is a list of routines and how to call them: :
U=ADR(U$) 1) CLEAR PLAYER X AREA Call by A=USR(U,X,R1) where R1=U+41 2) LOAD PLAYER X WITH DATA AT ADDR. Call by A=USR(U,X,ADDR,R2) where R2=U+50 and ADDR is the location of 1st byte of player image (data ends with a zero) 3) MOVE PLYR X ACCORDING TO JOYSTICK 0 Call by A=USR(U,X,R3) where R3=U+111 4) MOVE PLYR X ACCORDING TO JOYSTICK 2 Call by A=USR(U,X,R4) where R4=U+105 5) GO IN DIRECTION GIVEN Call by A=USR(U,X,DIR,R5) where R5=U+100 and DIR is the direction as from a joystick. 6) PLAYER X CONTINUES IN THE SAME DIRECTION Call by A=USR(U,X,R6) where R6=U+117 7) TURN AROUND ( EXACT OPPOSITE DIRECTION ) Call by A=USR(U,X,R7) where R7=U+72 8) CHANGE DIRECTION ACCORDING TO TABLE This could be useful to change direction always clockwise, for example. The next direction is picked up from a table you place in page six. Table 1 shows how these locations are set up for clockwise change, Call by A=USR(U,X,R8) where R8=U+89 There are a couple of bounce direction changes. One for walls at the sides of the screen and one for a top or bottom limit, 9) BOUNCE OFF SIDES Call by A=USR(U,X,R9) where R9=U+81 10) BOUNCE OFF TOP OR BOTTOM Call by A=USR(U,X,R10) where R10=U+77 It is often necessary to correlate graphic mode screen-locations with the location of a player missile object. Two routines are used and the code has to be changed depending on the graphics mode used. 11) DETERMINE HORIZ. LOCATION Call by X=USR(U,X,R11) where R11=U+218 12) DETERMINE VERT. LOCATION Call by Y=USR(U,X,R12) where R12=U+234 The variables X and Y will actually contain the positions after these calls and can be used in LOC.(X,Y,Z) for example. The code that has to be changed is in lines 85 and 90 where sets of three 74’s in a row occur. These are shifts, each 74 representing a division by two. Table 2 tells how many 74’s to replace by 234’s (no operations or NOP’s ) for each graphic mode, 13) LOCATE PLAYR X ON TOP OF PLAYER Y Call by A=USR(U,X,Y,R13) where R13=U+250 14) INITIALIZE PLAYER MISSILE GRAPHICS Call by A=USR(R14) where R14=U+265 This saves you all the trouble of initializing the pointers to player areas etc. PM area start is set 2K below RAMTOP, O.K. for graphics modes 4 and lower (probably 5 also). For GR. 6 change the 8 in line 92 to a 12,(3K), Change it to a 20, (5K), for GR. 7. The starting page for PM area is saved in 1789, Set up the graphics mode you will use before calling this routine. You still must initialize horizontal and vertical coordinates and colors of the players and fill the appropriate areas with player data (routine 2). Also, the ‘speed’ for movement routines must be set for each player. These are numbers representing the number of times through the routine +1 ( minimum of 2) and are stored in locations 1749 through 1753. A complete description of locations used in page six is given in table 3.
The program listing shows how some of these routines are used in a game I call ‘Munchers’.
—Stan Ockers

The program
The listing, “MUNCHERS by Stan Ockers”, is on pages 8, 9 of the issue. The game page runs it line by line in an emulated Atari 800, just as typed in.
Where this copy came from: Typed-in copy from Atarimania (Munchers.zip), proofread against the October 1981 issue in ACE Volume 1 (pages 106-108). The program matched; the copy came from a later reprint with a different header and the first two lines renumbered, which are restored as Stan printed them.
Show the listing
1 REM ********************** 2 REM *** MUNCHERS *** 3 REM *** BY S. OCKERS *** 4 REM *** 9-81 *** 5 REM ********************** 6 REM 8 POKE 752,1:? CHR$(125):OPEN #2,4,0,"K:":? :? :? ,"INSTRUCTIONS?":GET #2,A:IF A<>89 THEN 38 10 GOSUB 2000:GOTO 38 18 REM ** CHOMPING SOUND SUBROUTINE ** 20 SOUND 0,150,12,12:FOR DELAY=1 TO 10:NEXT DELAY:SOUND 0,0,0,0:RETURN 36 REM ** LOAD PM GRAPHICS SUBROUTINES ** 38 ? CHR$(125):? :? :? ,"INITIALIZING" 40 DIM U$(326):FOR I=1 TO 326:READ A:U$(I)=CHR$(A):NEXT I 50 DATA 104,133,207,198,207,240,23,104,104,170,189,233,6,133,203,189,238,6,133,204,198,207,240,6,104,133,206 55 DATA 104,133,205,104,141,255,6,104,141,254,6,108,254,6,160,0,152,145,203,200,16,251,96,188,243,6,162,0,161 60 DATA 205,201,0,240,11,145,203,230,205,208,2,230,206,200,208,239,96,169,255,208,6,169,3,208,2,169,12,93,218,6 65 DATA 24,144,25,165,208,41,15,168,185,218,6,24,144,14,165,205,24,144,9,173,1,211,24,144,3,173,0,211,157,218,6 70 DATA 189,213,6,133,209,198,209,208,1,96,189,218,6,133,207,70,207,176,26,188,243,6,192,1,240,19,208,1,200,177 75 DATA 203,240,6,136,145,203,200,208,245,136,145,203,222,243,6,70,207,176,29,188,243,6,200,192,126,176,21 80 DATA 177,203,208,247,136,177,203,240,6,200,145,203,136,208,245,200,145,203,254,243,6,70,207,176,3,222,248 85 DATA 6,70,207,176,3,254,248,6,189,248,6,157,0,208,24,144,160,189,248,6,56,233,44,74,74,74,133,212,169 90 DATA 0,133,213,96,189,243,6,56,233,12,74,74,74,133,212,169,0,133,213,96,164,205,185,248,6,157,248,6,185 91 DATA 243,6,157,243,6,96,104,165,106,56,233,8,141,253,6,141,7,212,170,232,142,242,6,232,142,238,6,142,239 92 DATA 6,232,142,240,6,142,241,6,169,0,141,233,6,141,235,6,169,128,141,234,6,141,236,6,141,237,6,169,46,141 93 DATA 47,2,169,3,141,29,208,96 94 REM ** DRAW PLAYING FIELD ** 95 GRAPHICS 18:POSITION 0,11:? #6;"____________________";:FOR I=1 TO 10:POSITION 0,I:? #6;"!" 96 POSITION 19,I:? #6;"!":NEXT I 98 REM ** INITIALIZE PM GRAPHICS ** 99 REM ** SET UP ROUTINE USR LOCATIONS ** 100 U=ADR(U$):A=USR(U+265):START=PEEK(1789)*256:R3=U+111:R6=U+117:R9=U+81:R10=U+77 108 REM ** LOAD PLYR DATA INTO MEMORY ** 110 FOR I=START TO START+43:READ A:POKE I,A:NEXT I 120 DATA 102,36,126,219,255,66,60,102,0,36,126,219,231,126,36,36,102,0,129,90,126,90,36,24,24,102,0,24,60,90 130 DATA 255,129,255,66,195,0,102,36,60,66,255,219,126,0 138 REM ** INITIALIZE PLYR POSITIONS AND COLORS ** 140 FOR I=0 TO 3:X=70+30*I:POKE 53248+I,X:POKE 1784+I,X:POKE 1779+I,50:POKE 704+I,73+32*I:NEXT I:SETCOLOR 4,9,2 148 REM ** CLEAR AND LOAD PLYRS INTO PM AREAS ** 150 FOR X=0 TO 3:A=USR(U,X,U+41):A=USR(U,X,START+9*X,U+50):NEXT X:POKE 77,0 158 REM ** INITIALIZE SPEEDS ** 160 FOR I=0 TO 3:POKE 1749+I,4+2*I:NEXT I 168 REM ** RESET COLL. REG. - INIT. COUNTERS ** 170 POKE 53278,0:TIME=30:FAST=10:SCORE=0:HIT=0:POSITION 0,0:? #6;"CHOMPS SCORE " 180 REM ** START PLYRS IN CERTAIN DIRECTIONS ** 190 A=USR(U,1,5,U+100):A=USR(U,2,9,U+100):A=USR(U,3,5,U+100) 198 REM ** MAIN LOOP STARTS HERE ** 200 FOR X=1 TO 3:A=USR(U,X,R6):P=PEEK(1779+X):IF P>103 OR P<18 THEN A=USR(U,X,R10) 210 P=PEEK(1784+X):IF P>194 OR P<55 THEN A=USR(U,X,R9) 225 IF PEEK(53260)>0 THEN HIT=HIT+1:POKE 53278,0:GOSUB 20:POSITION 7,0:? #6;HIT 227 IF HIT>29 THEN 300 230 NEXT X:SCORE=SCORE+1:IF SCORE>999 THEN 500 232 P=PEEK(1784):IF P>194 OR P<55 THEN 400 235 P=PEEK(1779):IF P>103 OR P<18 THEN 400 240 A=USR(U,0,R3):TIME=TIME-1:IF TIME=0 THEN TIME=10:POSITION 17,0:? #6;SCORE:FAST=FAST-1 250 IF FAST=0 THEN FAST=10:FOR X=0 TO 3:P=PEEK(1749+X):POKE 1749+X,P+1:NEXT X 260 GOTO 200 300 FOR I=10 TO 100 STEP 5:POSITION 2,8:? #6;" ":SOUND 0,50+I,10,12 310 FOR D=1 TO 5:NEXT D:POSITION 2,8:? #6;"YOU'VE HAD IT !":FOR D=1 TO 5:NEXT D:NEXT I 320 SOUND 0,0,0,0:GOTO 430 400 FOR I=1 TO 9:POSITION 10,8:? #6;" ":POKE 704,63:SOUND 0,20+RND(0)*20,8,12 410 FOR D=1 TO 10:NEXT D:POSITION 10,8:? #6;"FRIED!!":POKE 704,200:SOUND 0,0,0,0:FOR D=1 TO 10:NEXT D 420 NEXT I:A=USR(U,0,START+36,U+50):POKE 704,6 430 POSITION 2,10:? #6;"PRESS TRIGGER" 440 IF STRIG(0)=1 THEN 440 450 POSITION 2,8:? #6;" ":POSITION 2,10:? #6;" ":GOTO 140 500 ? #6;CHR$(125):POSITION 1,4:? #6;"CONGRATULATIONS !!!":POSITION 4,6:? #6;"YOU'VE MASTERED" 510 POSITION 6,8:? #6;"THE MUNCHERS":POSITION 2,10:? #6;"PRESS TRIGGER" 540 IF STRIG(0)=1 THEN 540 550 CLR :POKE 53277,0:RUN 2000 ? :? :? "Stay away from the MUNCHERS! If you":? "get too close they will chomp you." 2010 ? "30 chomps and you've had it. Also":? "stay away from the border. It's" 2030 ? "electrified and you will fry if you":? "hit it! The longer you last, the" 2040 ? "higher the score. Reach 1000 and":? "you've mastered the munchers. One" 2050 ? "problem though... the longer you":? "last, the faster everybody moves.":? :? 2060 ? "You're the squat dog earred guy.":? "Move by using a joystick in PLYR1" 2065 ? "position. Press trigger to start." 2070 IF STRIG(0)=1 THEN 2070 2080 RETURN