
“Brick Buster” is a game in which the player earns points by knocking out as many of the bricks in the playing area as possible. On-screen scoring and a high score memory are provided for competitive playing. The active part of the game is written in machine code for fast action. The rest of the game is in Basic for ease of programming.
Using the machine code loader program in Figure 1 (or your own program, if you prefer), enter the machine code from the second column in Figure 2 into the first REM statement. Check the address on the screen after each entry to make sure that it corresponds to Figure 2. After the machine code is entered, be very careful not to alter the REM statement in any way. Save it now in case of a crash later.
Figure 1. Machine code loader.
1 REM 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
10 LET L=16514
20 LET L$="4082"
30 SCROLL
40 PRINT L$;" ";
50 INPUT A$
60 IF A$="S" THEN STOP
70 PRINT A$
80 IF A$="" THEN GOTO 30
90 POKE L,16*CODE A$+CODE A$(2)-476
100 LET L=L+1
110 LET A$=A$(3 TO )
120 LET B=4
130 LET A=CODE L$(B)+1
140 IF A>43 THEN GOTO 200
150 LET L$=L$( TO B-1)+CHR$ A
160 FOR F=B-1 TO 2
170 LET L$=L$+"0"
180 NEXT F
190 GOTO 80
200 LET B=B-1
210 GOTO 130
Figure 2. Machine code listing.
4082 111016 LD DE,1610 ; Initialize paddle position.
4085 010516 LD BC,1605 ; Initialize ball position.
4088 78 START: LD A,B ; Has ball hit back wall?
4089 FE02 CP 02 ;
408B 2007 JR NZ,MISS ; No. Go check for a miss.
408D 3E04 LD A,04 ; Yes. Change vertical direction.
408F 32AC40 LD (BINST),A ;
4092 1803 JR LWALL ; Go check left wall.
4094 FE18 MISS: CP 18 ; Did ball get past paddle?
4096 C8 RET Z ; Yes. Return to Basic.
4097 79 LWALL: LD A,C ; No. Has ball reached left wall?
4098 FE02 CP 02 ;
409A 2007 JR NZ,RWALL ; No. Go check right wall.
409C 3E0C LD A,0C ; Yes. Change horizontal direction.
409E 32AD40 LD (CINST),A ;
40A1 1809 JR BINST ; Go change ball direction.
40A3 FE1F RWALL: CP 1F ; Has ball reached right wall?
40A5 2005 JR NZ,BINST ;
40A7 3E0D LD A,0D ; Yes. Change horizontal direction.
40A9 32AD40 LD (CINST),A ;
40AC 05 BINST: DEC B ; No. Change position of ball.
40AD 0D CINST: DEC C ; (B: vertical; C: horizontal).
40AE CD5541 CALL ADDR ; Find new address of ball.
40B1 7E LD A,(HL) ; Is there a brick in new ball position?
40B2 FE08 CP 08 ;
40B4 2016 JR NZ,SUBS ; No. Go move ball.
40B6 CD6A41 CALL SCORE ; Yes. Go increment score.
40B9 3AAC40 LD A,(BINST) ; Make ball bounce off brick in
40BC FE05 CP 05 ; opposite vertical direction.
40BE 2007 JR NZ,BOUNCE ;
40C0 3E04 LD A,04 ;
40C2 32AC40 LD (BINST),A ;
40C5 1805 JR SUBS ;
40C7 3E05 BOUNCE: LD A,05 ;
40C9 32AC40 LD (BINST),A ;
40CC 3680 SUBS: LD (HL),80 ; Print ball in new position.
40CE CDE040 CALL PADDLE ; Move paddle.
40D1 CD8241 CALL DELAY ; Delay.
40D4 CDE040 CALL PADDLE ; Move paddle.
40D7 CD8241 CALL DELAY ; Delay.
40DA 3600 LD (HL),00 ; Print blank in old ball position.
40DC 18AA JR START ; Go back to start.
40DE 00 NOP ;
40DF 00 NOP ;
40E0 E5 PADDLE: PUSH HL ; Save ball position.
40E1 C5 PUSH BC ;
40E2 42 LD B,D ; Get paddle position.
40E3 4B LD C,E ;
40E4 DB04 IN A,04 ; Find what key is pressed.
40E6 FE3B CP 3B ; Move right?
40E8 2008 JR NZ,MVLF ; No. Go check for move left.
40EA 79 LD A,C ; Yes. Is paddle at right end?
40EB FE1D CP 1D ;
40ED 280D JR Z,PRPADL ; Yes. Go print paddle.
40EF 0C INC C ; No. Move paddle position to right.
40F0 180A JR PRPADL ; Go print new paddle.
40F2 FE2F MVLF: CP 2F ; Move left?
40F4 2006 JR NZ,PRPADL ; No. Go print paddle.
40F6 79 LD A,C ; Yes. Is paddle at left end?
40F7 FE01 CP 01 ;
40F9 2801 JR Z,PRPADL ; Yes. Go print new paddle.
40FB 0D DEC C ; No. Move paddle position to left.
40FC CD5541 PRPADL: CALL ADDR ; Find paddle address.
40FF 3600 LD (HL),00 ; Print paddle.
4101 23 INC HL ;
4102 3603 LD (HL),03 ;
4104 23 INC HL ;
4105 3603 LD (HL),03 ;
4107 23 INC HL ;
4108 3600 LD (HL),00 ;
410A 05 DEC B ; Check if ball hit paddle.
410B CD5541 CALL ADDR ;
410E 3AAD40 LD A,(CINST) ;
4111 FE0C CP 0C ;
4113 200F JR NZ,MIDPAD ;
4115 7E LD A,(HL) ; Check left end of paddle.
4116 FE80 CP 80 ;
4118 200A JR NZ,MIDPAD ;
411A 3E0D LD A,0D ;
411C 32AD40 LD (CINST),A ;
411F 3E05 LD A,05 ;
4121 32AC40 LD (BINST),A ;
4124 0602 MIDPAD: LD B,02 ;
4126 23 TWICE: INC HL ; Check center sections of paddle
4127 7E LD A,(HL) ; for hit.
4128 FE80 CP 80 ;
412A 200C JR NZ,CONT ;
412C 3E05 LD A,05 ;
412E 32AC40 LD (BINST),A ;
4131 D9 EXX ; If ball hits center of paddle,
4132 C1 POP BC ; project ball one extra position
4133 0614 LD B,14 ; vertically to make sure all bricks
4135 C5 PUSH BC ; can be hit.
4136 D9 EXX ;
4137 00 NOP ;
4138 10EC CONT: DJNZ TWICE ;
413A 23 INC HL ;
413B 3AAD40 LD A,(CINST) ;
413E FE0D CP 0D ;
4140 200F JR NZ,ENDPAD ;
4142 7E LD A,(HL) ; Check right end of paddle.
4143 FE80 CP 80 ;
4145 200A JR NZ,ENDPAD ;
4147 3E0C LD A,0C ;
4149 32AD40 LD (CINST),A ;
414C 3E05 LD A,05 ;
414E 32AC40 LD (BINST),A ;
4151 59 ENDPAD: LD E,C ;
4152 C1 POP BC ; Get ball position.
4153 E1 POP HL ;
4154 C9 RET ;
4155 D5 ADDR: PUSH DE ; Save paddle position.
4156 C5 PUSH BC ; Save ball position.
4157 2A0C40 LD HL,D-FILE ; Get display address.
415A C5 PUSH BC ;
415B 0600 LD B,00 ;
415D 09 ADD HL,BC ; Find horizontal position.
415E C1 POP BC ;
415F 112100 LD DE,0021 ;
4162 1003 TEST: DJNZ AGAIN ;
4164 C1 POP BC ; Get ball position.
4165 D1 POP DE ; Get paddle position.
4166 C9 RET ;
4167 19 AGAIN: ADD HL,DE ; Find vertical position.
4168 18F8 JR TEST ;
416A E5 SCORE: PUSH HL ; Save ball address.
416B 2A0C40 LD HL,D-FILE ; Get display address.
416E 23 INC HL ; Find tens position in score.
416F 23 INC HL ;
4170 23 INC HL ;
4171 23 INC HL ;
4172 7E CHECK: LD A,(HL) ; Add 10 to score.
4173 3C INC A ;
4174 FE26 CP 26 ;
4176 2803 JR Z,CARRY ;
4178 77 LD (HL),A ;
4179 1805 JR ENDSCR ;
417B 361C CARRY: LD (HL),1C ;
417D 2B DEC HL ;
417E 18F2 JR CHECK ;
4180 E1 ENDSCR: POP HL ; Get ball address.
4181 C9 RET ;
4182 C5 DELAY: PUSH BC ; Save ball position.
4183 010002 LD BC,0200 ; Load delay.
4186 0B CNTDWN: DEC BC ;
4187 78 LD A,B ;
4188 B1 OR C ;
4189 20FB JR NZ,CNTDWN ; Continue with delay.
418B C1 POP BC ; Get ball position.
418C C9 RET ;
Next, enter the Basic part of the game. Enter the lines in Figure 3 over the first program. Be sure to leave the REM statement alone. Make sure you enter the Basic just as in Figure 3. The line notes will help.
After the Basic part of the game is entered, you are all set to play. Again to be safe, SAVE the whole program now by typing RUN 500. When you LOAD the program to play again, it will start running by itself. After it is LOADed, the computer will ask you to enter the speed of play. Five or greater is suggested for the beginner. After you enter the speed, the playing field is drawn. You have 5 balls per game. You serve the ball by pressing S. The paddle is controlled by the 5 and 8 keys. Each brick is worth 10 points. At the end of the game, if you have the highest score so far, you get to enter your name which will stay in memory until your score is beaten or the program is stopped.

Line notes:
70: 3, zero (4), 6 (26), 4. (graphics characters underlined in the original)
90: 8, 5.
120: A (32).
190: Space (32).
280: In inverse: PRESS “P” TO PLAY AGAIN.
Figure 3. The Basic program.
5 LET DISP=PEEK (16396)+PEEK (16397)*256
10 LET BEST=0
15 CLS
20 PRINT "ENTER SPEED 1 TO 9 (1=FASTEST)"
25 PRINT AT 3,6;"<=5....8=> S=SERVE"
30 INPUT I
40 IF I<1 OR I>9 THEN GOTO 30
50 POKE 16773,I
60 CLS
70 PRINT "[graphic 3][graphic 0 x4][graphic 6 x26][graphic 4]"
80 FOR F=1 TO 20
90 PRINT AT F,0;"[graphic 8]";TAB 31;"[graphic 5]"
100 NEXT F
110 FOR F=1 TO 7
120 PRINT AT F,1;"[graphic A x32]"
130 NEXT F
140 FOR F=5 TO 25 STEP 5
150 POKE 16556,5
160 POKE 16518,F
170 IF INKEY$<>"S" THEN GOTO 170
180 RAND USR 16514
190 PRINT AT 21,0;" "
200 NEXT F
210 PRINT AT 0,11;"GAME OVER"
220 LET SCORE=0
230 FOR R=1 TO 4
240 LET SCORE=SCORE+(PEEK (DISP+R+1)-28)*10**(4-R)
250 NEXT R
260 IF SCORE>BEST THEN GOSUB 400
270 PRINT AT 10,1;"BEST SCORE IS ";BEST;" BY ";Z$
280 PRINT AT 12,4;"[inverse PRESS ""P"" TO PLAY AGAIN]";AT 12,4;"PRESS ""P"" TO PLAY AGAIN"
290 IF INKEY$="P" THEN GOTO 15
300 GOTO 280
400 CLS
410 LET BEST=SCORE
420 PRINT AT 2,2;"YOU NOW HAVE THE BEST SCORE"
430 PRINT AT 4,1;"ENTER YOUR NAME (1-9 LETTERS)"
440 INPUT Z$
450 RETURN
500 SAVE "BRICKBUSTE[inverse R]"
510 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.