Scurry

David Bohlke

In Scurry you are presented with a series of tasks to be accomplished within a limited amount of time, with obstacles to be avoided. The tasks consist of X shaped targets that appear on the screen for a brief period of time. You must use the joystick to move the cursor over the target before it disappears. The obstacles are blocks on the screen.

You receive 10 points for each target you reach, and lose 2 points for each obstacle you hit. Your cursor is continuously moving, so the game is not easy. As your score increases, the cursor moves faster and more obstacles appear.

Scurry was written to demonstrate several of the special abilities of the Atari computer, including the use of joysticks and Player-Missile graphics.

The main feature of this demonstration game is the machine language routine stored in Y$ in line numbers 90 to 97. Objects in P/M graphics can be moved horizontally on the screen with animation speed by using the appropriate POKE addresses. However, there is no such provision for the up and down movement of the graphic images to any vertical location. It is necessary to reposition the entire image, one byte at a time, in the P/M graphics list. If you do this using Basic POKEs the speed of the graphics will be unacceptably slow.

One way to speed up this vertical movement is to reposition the image using a machine language routine. The following code will accomplish this task:

162,20 LDX,20
20 is the number of bytes to be moved.
LOOP LDA, Source address
189,0,0 STA, DESTINATION address
This will be the vertical location in the Player 0 list (and the screen) that the image will be displayed.
157,0,0 STA, DESTINATION address
This will be the vertical location in the Player 0 list (and the screen) that the image will be displayed.
202 DEX
decrement counter
208,247 BNE, LOOP
Move another byte, for a count of twenty in this example
104 PLA
96 RTS

Line number 95 of the listing sets UY as the machine language addresses for the USR function. In line number 97, the source address for the image (POKE m+5, MB+1) is set at the beginning of the Player 0 list. The decimal 250 effectively moves this address six bytes below the Player 0 image. Since a total of 20 bytes are moved, these extra blank bytes before and after the image will erase the previously set image if the vertical change is restricted to plus or minus five bytes. Hence, it is not necessary at each move to clear the entire Player 0 list.

The POKE M+8,MB+2 instruction in line 97 will place the MSB destination byte in the routine. Since PY=M+7, the LSB byte can be set each time you want to move the image. Now, the only commands needed for vertical movement are POKE PY,SV: Z=USR(UY) where SV is the vertical placement in the Player 0 list.

If you have several images to move, it will be necessary to POKE changes for both the source and destination addresses in the routine. Or, perhaps it would be better to set up a different machine language routine for each image. Although this machine code may not be appropriate every time you need to use Player/ Missile graphics; hopefully you will find some benefit from the description.

Scurry was not designed as a game to give you 'endless' pleasure until 4 a.m. each morning even though it is fun for a change of pace from time to time. But it will be worthwhile if it helps you to piece together some of the concepts in Player/ Missile graphics.


Line description
5-97 initialization:
10 Y$(15) holds the machine language routine
D(15) holds directions for STICK commands:
11-13 colors:
20 MB is 12 pages down from the top of memory
PB is the beginning of Player/ Missile graphics list:
25 reset color attract mode, turn off cursor:
30-40 initialize P/M graphics:
50-52 put cursor image at bottom of Player 0 area in P/M graphics list:
54-56 size and color of Player 0:
90-97 put machine language routine into Y$:
100-270 pre-game initialization:
100 P stores points accumulated PK is the increment of 100:
110 counter SH,SV are the cursor horizontal and vertical positions:
120-122 prints:
150 position target:
160-162 directions for STICK function:
200-270 T is time, D is direction
X,Y are speed increments for the cursor:
300-500 main game loop:
300 check for collision of cursor and graphics blocs:
310 if collision then decrement points, pick new RND direction, print score:
320 decrease time:
330-390 check STICK for cursor direction:
400 adjust P/M cursor's vertical position:
410 plot P/M cursor's horizontal position:
420-430 check for hit on target:
440 increment points for hit:
460 plot new target:
480 check if point increment is over 100 multiple:
490 increase speed:
492 reset rime, increment multiple of 100 counter:
700-790 set new target:
800-820 prompt for next game:

Scurry

5 REM SCURRY by David Bohlke
10 DIM Y$(15),D(15)
11 GRAPHICS 3
12 SETCOLOR 2,14,2:SETCOLOR 4,14,2
13 SETCOLOR 0,8,6:SETCOLOR 1,11,8
20 MB=PEEK(106)-12:POKE 54279,MB:PB=256*MB
25 POKE 77,0:POKE 752,1
26 POKE 656,1:POKE 657,16:PRINT " SCURRY "
30 POKE 559,46:REM DOUBLE LINE GR.
32 POKE 53277,3:REM ENABLE GRAPHICS
34 POKE 623,8:REM PLYR PRIORITY
40 FOR I=PB+500 TO PB+800:POKE I,0:NEXT I:REM ZERO GR. AREA
50 RESTORE 52:FOR I=PB+512 TO PB+516:READ A:POKE I,A:NEXT I
51 REM PUT PL0 AT BOTTOM OF PL0 AREA
52 DATA 14,17,21,17,14
54 POKE 53256,0:REM SIZE OF PL0
56 POKE 704,0:REM COLOR OF PL0
90 M=ADR(Y$):RESTORE 92:FOR I=1 TO 13:READ A:POKE M+I,A:NEXT I
91 REM MACHINE LANG. ROUTINE
92 DATA 162,20,189,250,0,157,0,0,202,208,247,104,96
95 UY=M+1:REM POKE PY,SV:Z=USR(UY)
96 REM SOURCE,DESTINATION OF ROUTINE
97 POKE M+5,MB+1:POKE M+8,MB+2:PY=M+7
100 P=0:PK=0
110 SH=125:SV=60
120 POKE 656,3:POKE 657,1:PRINT "SCORE ";
122 POKE 656,3:POKE 657,30:PRINT "TIME";
150 GOSUB 700
160 RESTORE 162:FOR I=5 TO 15:READ A:D(I)=A:NEXT I
162 DATA 2,1,2,0,3,4,4,0,3,1,0
200 T=500
210 D=INT(RND(0)*4)+1
270 X=3:Y=3
299 REM MAIN PLAY LOOP
300 C=PEEK(53252):POKE 53278,0
310 IF C=2 OR C=1 THEN P=P-2:SOUND 0,50*C,10,14:D=INT(RND(0)*4)+1:POKE 657,7:PRINT P;" ";
320 T=T-1:POKE 656,3:POKE 657,35:PRINT INT(T);" ";:IF T<1 THEN 800
330 S=STICK(0):IF S=15 THEN 350
340 D=D(S)
350 GOTO D*10+350
360 SV=SV-Y:IF SV<10 THEN SV=10:D=3
362 GOTO 400
370 SH=SH+X:IF SH>200 THEN SH=200:D=4
372 GOTO 400
380 SV=SV+Y:IF SV>90 THEN SV=90:D=1
382 GOTO 400
390 SH=SH-X:IF SH<50 THEN SH=50:D=2
400 POKE PY,SV:Z=USR(UY)
405 SOUND 0,0,0,0
410 POKE 53248,SH
420 C=PEEK(53260)
430 IF C<>2 THEN 300
440 P=P+10:POKE 656,3:POKE 657,7:PRINT P;" ";
450 SOUND 1,222,6,12:SOUND 2,100,2,14
460 GOSUB 700
462 POKE 53278,0
464 SOUND 1,0,0,0:SOUND 2,0,0,0
480 IF INT(P/100)200 AND RND(0)<0.8 THEN 790
782 COLOR C:PLOT RND(0)*39,RND(0)*19
790 RETURN
800 PRINT :PRINT "Press START for next game ?";
810 IF PEEK(53279)=6 THEN 11
820 SOUND 0,RND(0)*200,10,2:GOTO 810

David Bohlke, Lynn Drive, Coggon, IA 52218.

Table of Contents
Previous Section: Monster Combat
Next Section: Collision