Bounce
- Type
- Game
- Category
- Breakout-style bat and ball game
- Author
- Robert "Rassilon" Patton
- Published in
- Antic, January 1988 (Vol. 6, No. 9), Game of the Month ("Rassilon's Triple-Header")
- Year
- 1988
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, any memory size, Atari BASIC, joystick in port 1
About the program
Breakout was one of Atari's classic arcade games. Robert "Rassilon" Patton recreated it in Atari BASIC as the third game of his January 1988 Triple-Header (with Rollout and Pegboard). Unlike the original, Bounce uses a joystick instead of a paddle. You get 25 balls to knock out a six-row wall of bricks, and the angle the ball comes off your bat depends on where it hits. The best trick, Patton said, is to get the ball behind the wall. It then bounces between the bricks and the top of the screen, clearing them for you, and with practice you can clear the whole wall with one ball.
Typing it in
It's 42 lines and nearly all plain text. The only special characters are in the messages: {CLEAR} (ESC, then SHIFT-CLEAR), {TAB} (ESC, then TAB), {LEFT} (ESC, then CTRL-+) and the inverse words, which are typed with the Atari key on and off. Most numbers in the program are written as variables, such as N0, N1 and N39, defined in lines 290–300. Type them exactly, because a mistyped N39 is just a new variable worth 0.
How to play
Press the button to serve. Move the bat with the stick, left and right. Holding the button while you move makes the bat go twice as fast as the ball (line 110). But since the button also serves, Patton noted that this can send the next ball off before you're ready, which is one reason you get 25 of them. Scoring isn't done in the main loop, to keep it fast. Press SELECT whenever you want to see your score, which is counted from the bricks you've removed. When you clear the wall, or run out of balls, press the button to play again.
How it works
This program is a lesson in squeezing speed out of Atari BASIC, and the article lists the tricks:
- Constants in variables. Atari BASIC stores every number in a program line as a 6-byte floating-point constant, and converts it each time the line runs. Looking up a variable is quicker. Lines 290–300 define
N0toN732, and the main loop (lines 30–130) uses nothing else. - Hot code first. The main loop starts at line 30. Atari BASIC searches for line numbers from the start of the program, so GOTOs to low lines are found quickest.
- Shadow registers. The stick and button are read with
PEEK(632)andPEEK(644), the operating system's copies ofSTICK(0)andSTRIG(0). - The screen is the collision map. In GRAPHICS 5 (80×40, four colours) the ball is a single pixel.
LOCATE(line 60) reads the colour of the pixel the ball is about to enter. Anything that isn't background bounces it back. If the ball reaches the bottom row on a pixel of colour 3, that's the bat. The new sideways speed is the distance from the bat's centre,DBC=BC-PC, so hitting with the edge sends the ball off at a steep angle. - Random serves. Line 160 reads POKEY's random-number register at 53770 to choose where the ball starts, and line 180 uses it again to pick a direction.
- Scoring (lines 230–250) scans the brick area with LOCATE and subtracts one point from 240 for each brick still standing. So the score is the number of bricks gone, and 240 means you've won.
Variations to try
- Change the number of balls:
B=N26in line 320 gives 25. - Add more rows of bricks by raising the 3 in
FOR K=N1 TO N3in line 270. Each colour adds two rows. You'll need to adjust the 240 maximum in the scoring routine too.
Listing
5 REM BOUNCE
10 REM BY ROBERT PATTON
15 REM (c)1987, ANTIC PUBLISHING
20 GOSUB 280:GOSUB 270:GOSUB 140
30 S=PEEK(N632):T=PEEK(N644):IF BR<>N39 THEN COLOR N0:PLOT BC,BR
40 BC=BC+DBC:IF BC<N20 OR BC>N59 THEN DBC=DBC*-N1:BC=BC+DBC
50 BR=BR+DBR:IF BR<N0 THEN DBR=DBR*-N1:BR=BR+DBR
60 LOCATE BC,BR,L:IF L<>N0 THEN DBR=DBR*-N1
70 IF BR=N39 AND L=N3 THEN DBC=BC-PC
80 IF BR=N39 AND L<>N3 THEN GOSUB 140
90 IF BR<>N39 THEN COLOR N1:PLOT BC,BR
100 IF S=N7 THEN PC=PC+N1*(PC<N57):COLOR N3:PLOT PC+N2,N39:COLOR N0:PLOT PC-N3*(PC>N22),N39
110 IF T=0 THEN T=1:GOTO 100
120 IF S=N11 THEN PC=PC-N1*(PC>N22):COLOR N3:PLOT PC-N2,N39:COLOR N0:PLOT PC+N3*(PC<N57),N39
130 GOTO 30
140 B=B-N1:BR=FR:POKE 77,0:IF B=N0 THEN 330
150 GOSUB 400
160 BC=PEEK(53770):IF BC>59 OR BC<20 THEN 160
170 DBR=N1:DBC=N1
180 IF PEEK(53770)<N128 THEN DBC=DBC*-N1
190 COLOR N1:PLOT BC,BR
200 IF PEEK(53279)=N5 THEN GOSUB 230
210 IF STRIG(0)<>N0 THEN 200
220 RETURN
230 GOSUB 400:SC=N240:FOR R=FR-N6 TO FR-N1:FOR C=N20 TO N59
240 LOCATE C,R,L:IF L<>N0 THEN SC=SC-N1:SOUND 0,SC,10,2:SOUND 1,SC+1,10,2
250 NEXT C:NEXT R:? SC;"{LEFT}{LEFT}{LEFT}";:IF SC=N240 THEN 350
260 SOUND 0,0,0,0:SOUND 1,0,0,0:RETURN
270 FOR K=N1 TO N3:FOR FR=FR TO FR+N1:COLOR K:PLOT N20,FR:DRAWTO N59,FR:NEXT FR:NEXT K:RETURN
280 GRAPHICS 5:POKE 752,1
290 N0=0:N1=1:N2=2:N3=3:N4=4:N5=5:N6=6:N7=7:N8=8:N9=9:N10=10:N11=11:N12=12:N13=13:N14=14:N15=15:N16=16:N17=17
300 N20=20:N22=22:N26=26:N39=39:N50=50:N57=57:N59=59:N128=128:N240=240:N632=632:N644=644:N732=732
310 COLOR N3:FOR C=N16 TO 19:PLOT C,N0:DRAWTO C,N39:NEXT C:FOR C=60 TO 62:PLOT C,N0:DRAWTO C,N39:NEXT C
320 FR=N2:B=N26:COLOR N3:PC=N39:FOR X=(-N2) TO N2:PLOT PC+X,N39:NEXT X:RETURN
330 ? "{CLEAR}":? :? "{TAB}{TAB}{inv} GAME OVER {/inv}":GOSUB 380:? "{TAB} Your Score was ";:GOSUB 230:? :IF SC=N240 THEN 350
340 GOTO 360
350 ? "{CLEAR}":? :? "{TAB}{TAB}{inv} YOU WON!! {/inv}":? :GOSUB 380
360 IF PEEK(N644)<>0 THEN 360
370 RUN
380 ? "{TAB} PRESS FIRE TO PLAY AGAIN":RETURN
400 ? "{CLEAR} {inv} BOUNCE by Rassilon (c) 1987 {/inv}":? "{TAB} Press FIRE to SERVE BALL ";26-B
410 ? "{TAB}Press {inv}SELECT{/inv} to CALC SCORE = ";:RETURN
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: BOUNCE.BAS.
Credits
- Program listing: Bounce — program listing (Antic, January 1988 (Vol. 6, No. 9), Game of the Month ("Rassilon's Triple-Header")) — Robert "Rassilon" Patton
- Picture: The first ball has just been served towards the six-row wall. — Robert "Rassilon" Patton (program); screenshot by the site
- Antic, January 1988 - Vol. 6 No. 9 — article: games by Robert "Rassilon" Patton — Robert "Rassilon" Patton, 1988
- Antic Software Archive — January 1988 - Vol. 6 No. 9 disk: BOUNCE.BAS — AtariMagazines.com (Kevin Savetz), 1988
