Bomb Blaster

An Atari 8-bit game
Designed by William Kendrick (age 5)
Programmed by Bill Kendrick (papa)

July 2012


A few days back, my 5½ year old son William cut up some paper, drew symbols on them, flipped them over, made a logo, and said "do you want to play 'Bomb Blaster'?" The rules didn't make much sense, and was it basically a game of chance.

However I decided it'd be fun to whip up a computer game based on it, for his amusement. So after dinner the other night, I pondered some rules, fired up an Atari character set editor I had written for myself in BASIC in 1990, and did my best to reproduce his game's symbols.

Then, over the course of that evening, while ignoring a huge pile of laundry, and interrupted to help tend our infant son, I came up with an Atari version of my son's game, written in TurboBASIC XL:

Requirements

How to Play

Download

Code Breakdown

I used "detokenize.pl" to convert the TurboBASIC XL code to an ATASCII listing. (I should have used BASIC's "LIST "D:FILENAME.LST"" command, since I had to manually put back some TBXL-specific code that was missing).

Then I created a little HTML script to convert ATASCII text into HTML, using Unicode characters to represent some of the Atari graphical characters. And here's the code:

HTML ATASCII Viewer by Bill Kendrick, 2012-2013
Options:
Columns: 38 | 40 | Unlimited
Style: Unicode | Images | Images (2x) | Compute! listings

0 REM SAVE "D:BOMBBLST.TBS":RUN 
5 DIM COVERED(9),PIECES(9)
10 GRAPHICS 18
15 POKE 712,10:POKE 708,0:POKE 709,200
20 CH=PEEK(106)-16
30 OPEN #1,4,0,"D:BOMBBLST.FNT"
40 BGET #1,CH*256,1024
50 POKE 756,CH
60 ? #6;" ;; BOMB BLASTER ;;"
70 ? #6;"  BY BILL KENDRICK"
80 ? #6;"AND WILLIAM KENDRICK"
90 ? #6
100 ? #6;"{3 SPACES}{D}{E}{3 SPACES}*+{4 SPACES}[\"
110 ? #6;"{3 SPACES}{F}{G}{3 SPACES},-{4 SPACES}]^"
120 POKE 710,INT(RND(0)*15)+64
130 IF STRIG(0)=1 AND PEEK(53279)<>6 THE
N 120
140 IF STRIG(0)=0 THEN 140
200 ? #6;"{CLEAR}{4 SPACES}BOMB BLASTER"
205 ? #6
206 POKE 712,10
207 FOR A=1 TO 3
210 ? #6;"{5 SPACES}#==#==#==#"
220 ? #6;"{5 SPACES}:??:??:??:"
230 ? #6;"{5 SPACES}:??:??:??:"
235 NEXT A
240 ? #6;"{5 SPACES}#==#==#==#"
250 X=1:Y=1:UNCOVERED=0:MONEY=0:HAPPY=0
260 FOR A=0 TO 8:COVERED(A)=1:PIECES(A)=
-1:NEXT A
270 GOSUB 1000
280 POSITION 0,2:? #6;"{D}{E}"
285 POSITION 0,3:? #6;"{F}{G}"
300 POSITION (X*3)+5,(Y*3)+2
305 ? #6;"{C}{DOWN}{DOWN}{C}"
310 POSITION (X*3)+5,(Y*3)+5
315 ? #6;"{C}{DOWN}{DOWN}{C}"
320 FOR Z=3 TO 4:POSITION (X*3)+5,(Y*3)+
Z:? #6;"{Z}":POSITION (X*3)+8,(Y*3)+Z:? #6
;"{Z}":NEXT Z
350 S=STICK(0):F=STRIG(0)
355 POKE 710,INT(RND(0)*15)+64
360 IF S<>7 AND S<>11 AND S<>13 AND S<>1
4 AND F=1 THEN 350
400 POSITION (X*3)+5,(Y*3)+2
405 ? #6;"#==#"
410 POSITION (X*3)+5,(Y*3)+5
415 ? #6;"#==#"
420 FOR Z=3 TO 4:POSITION (X*3)+5,(Y*3)+
Z:? #6;":":POSITION (X*3)+8,(Y*3)+Z:? #6
;":":NEXT Z
500 IF S=7 THEN IF X<2 THEN X=X+1
510 IF S=11 THEN IF X>0 THEN X=X-1
520 IF S=13 THEN IF Y<2 THEN Y=Y+1
530 IF S=14 THEN IF Y>0 THEN Y=Y-1
535 IF STICK(0)<>15 THEN 535
540 IF S<>15 THEN FOR Z=15 TO 0 STEP -1:
SOUND 0,100,10,Z:NEXT Z:GOTO 300
550 IF F=1 THEN 300
600 IF COVERED(Y*3+X)=0 THEN FOR Z=15 TO
 0 STEP -:SOUND 0,200,12,Z:NEXT Z:GOTO 3
00
610 COVERED(Y*3+X)=0
620 P=PIECES(Y*3+X)
630 POSITION (X*3)+6,(Y*3)+3:? #6;CHR$(P
);CHR$(P+1)
640 POSITION (X*3)+6,(Y*3)+4:? #6;CHR$(P
+2);CHR$(P+3)
650 UNCOVERED=UNCOVERED+1
700 IF P=ASC("{D}") THEN GOSUB 2000
710 IF P=ASC("*") AND HAPPY=0 THEN GOSUB
 3000
720 IF P=ASC("[") THEN GOSUB 5000
800 IF UNCOVERED=9 THEN GOSUB 10000:GOTO
 200
990 POKE 710,INT(RND(0)*15)+64
999 GOTO 300
1000 FOR A=1 TO 5
1010 XX=INT(RND(0)*3):YY=INT(RND(0)*3)
1015 SOUND 0,50+YY*20+XX*10,10,8
1020 IF PIECES(YY*3+XX)<>-1 THEN 1010
1030 PIECES(YY*3+XX)=ASC("{D}"):REM MONEY
1040 NEXT A
1100 FOR A=1 TO 3
1110 XX=INT(RND(0)*3):YY=INT(RND(0)*3)
1115 SOUND 0,50+YY*20+XX*10,10,8
1120 IF PIECES(YY*3+XX)<>-1 THEN 1110
1130 PIECES(YY*3+XX)=ASC("*"):REM BAD
1140 NEXT A
1150 SOUND 0,0,0,0
1200 FOR A=0 TO 8
1210 IF PIECES(A)=-1 THEN PIECES(A)=ASC(
"["):REM GOOD
1220 NEXT A
1299 RETURN 
2000 MONEY=MONEY+1:FOR A=1 TO 3:FOR Z=15
 TO 0 STEP -1:SOUND 0,10,10,Z:NEXT Z:NEX
T A
2010 POSITION 0,4:? #6;MONEY
2099 RETURN 
3000 MONEY=0
3010 FOR A=0 TO 8
3020 IF COVERED(A)=0 AND PIECES(A)=ASC("
{D}") THEN GOSUB 4000
3030 NEXT A
3040 POSITION 0,4:? #6;" "
3050 RETURN 
4000 YY=INT(A/3):XX=A MOD 3
4010 POSITION (XX*3)+6,(YY*3)+3:? #6;";;
"
4020 POSITION (XX*3)+6,(YY*3)+4:? #6;";;
"
4030 RETURN 
5000 HAPPY=1
5010 POSITION 18,2:? #6;"[\";
5020 POSITION 18,3:? #6;"]^";
5030 RETURN 
10000 POSITION 1,1:? #6;"G A M E ;; O V 
E R"
10005 IF STRIG(0)=0 THEN 10005
10010 POKE 710,INT(RND(0)*15)+64
10011 IF MONEY=5:Z=Z-1:ELSE:Z=Z+1:ENDIF
10015 IF Z<0 THEN Z=250
10016 SOUND 0,Z,10,8
10017 SOUND 1,Z+2,10,6
10018 IF MONEY=5 THEN POKE 712,Z
10019 IF Z>250 THEN Z=0
10020 IF STRIG(0)=1 AND PEEK(53279)<>6 T
HEN 10010
10030 IF STRIG(0)=0 OR PEEK(53279)=6 THE
N 10030
10040 SOUND 0,0,0,0:SOUND 1,0,0,0
10099 RETURN 

Set-Up, Title and Main Loop

  • 10-50 — Switch to large, colored text mode (10). Set some colors (15). Find a spot for a character set (20), load it (30-40), and switch to it (50).
  • 20-110 — Draw the title and credits.
  • 120 — Randomly flash one of the color palette spots red.
  • 130 — Wait until user presses FIRE or START
  • 140 — Wait until user releases FIRE (so they don't accidentally pick a cell)
  • 200-240 — Draw the game screen, including a 3x3 grid of "??" cells
  • 250 — Reset game: selection starts in the middle (1,1), no cells are uncovered, you have no money, and you don't have the good-guy bomb
  • 260 — Clear the cells; all cells are covered, nothing in the cells yet
  • 270 — Jump to subroutine at line 1000, which randomly fills the cells with objects
  • 280-285 — Draw a big dollar sign on the left side
  • 300-320 ‐ Highlight the cell the cursor is at
  • 350 — Capture state of the joystick and Fire button
  • 355 — Randomly flash one of the color palette spots red.
  • 360 — If joystick is not being moved, and Fire not being pressed, go back to 350
  • 400-420 — Unhighlight the cell the cursor is/was at
  • 500-530 — If the joystick was moved, move the cursor that direction
  • 535 — If the joystick is still being moved, wait until the user lets go (only move one cell at a time)
  • 540 — Play a sound effect, if the cursor was being moved. Then go bac to 300 and wait.
  • 600 — They pressed fire. If the cell was already uncovered, play a complaint sound effect, and go back to 300 and wait.
  • 610-650 — Uncover the cell (610), figure out what piece is there (620), draw the shape of the piece (630-640), and keep track of how may cells we've uncovered.
  • 700-720 — Do something, depending on what piece was uncovered.
  • 800 — If all 9 cells were uncovered, go to the Game Over subroutine, at line 10000. Then go back to 200 to start a new game.
  • 990 — Randomly flash one of the color palette spots red.
  • 999 — Go back to 300 and wait.

Subroutines

  • 1000: Randomly pick pieces
    • 1000-1040 — For the five money pieces (1000), pick a spot on the grid (1010), play a little sound while we 'think' (1015), and if the spot is taken, try again (1020), otherwise set the cell to a money piece (1030)
    • 1100-1140 — For the three bad-guy pirate bombs (1100), pick a spot on the grid (1110), play a little sound while we 'think' (1115), and if the spot is taken, try again (1120), otherwise set the cell to a bad-guy piece (1130)
    • 1150 — Stop playing sounds
    • 1200-1220 — There should be one clear ("-1") spot on the board. Place the good-guy bomb there.
  • 2000: Uncovered money piece
    • 2000 — Add money and play a 'ding!' sound three times
    • 2010 — Show how much money has been collected, under the big dollar sign on the left
  • 3000: Uncovered bad-guy pirate bomb
    • 3000 — Wipe out money!
    • 3010-3030 — Search all uncovered cells for money. When one is found, jump to subroutine at line 4000 to replace it with an explosion image.
    • 3040 — Erase the number underneath the big dollar sign on the left
  • 4000: Replace a money piece with an explosion (sub-subroutine!)
    • 4000 — Based on the cell number (0-8 for the 9 spots), determine the (x,y) position on the 3x3 grid.
    • 4010-4020 — Draw an explosion
  • 5000: Uncovered good-guy bomb
    • 5000 — Note that we have the good-guy bomb.
    • 5010-5020 — Draw the good-guy bomb on the right.
  • 10000: Game-over
    • 10000 — Write "Game Over" at the top.
    • 10005 — If user is still pressing Fire, wait until they release (so we don't dismiss the game-over screen immediately!)
    • 10010 — Randomly flash one of the color palette spots red.
    • 10011 — If you have all 5 money, the sound effect will go up in celebration; otherwise, it will go down.
    • 10015 — Avoid having sound pitch (and color) go negative.
    • 10016-10017 — Play a sound effect (with a little reverb effect, using two channels)
    • 10018 — If you have all 5 money, flash the background rainbow colors, in celebration!
    • 10019 — Avoid having sound pitch (and color) go above ~255.
    • 10020 — Keep doing all this until user press Fire or Start.
    • 10030 — Then wait until they let go of Fire or Start...
    • 10040 — End sound effects.

Note: Only a few TurboBASIC XL commands were used:

  • "BGET" command on line 40 to quickly load the font from disk into memory.
  • " MOD " operator on line 4000 to convert a cell position (0-8) into a grid X-position on the screen.
  • "IF {...}:{true}:ELSE:{false}:ENDIF" block on line 10011.

Font:

Here's a screenshot of the font:

Here are the characters I redefined:

#a + shape, for the grid
$%
&'
money
*+
,-
bad-guy pirate bomb
:a | shape, for the grid
;an explosion
=a – shape, for the grid
[\
]^
good-guy bomb

Note that in "GRAPHICS 2" mode on the Atari, only the first 64 characters of the character set are available. The second 64 appear as the first 64, but using a different color from the palette. Inverse-video is not supported, either. The high bit causes another pair of colors to be used. (e.g., the various colors of the character "!" can be made with: "!", Ctrl+A, Inverse-"!", and Inverse-Ctrl+A.)

So, for example, the Ctrl+D character (┫) in "P=ASC("┫")" is checking for a green-colored "$" character (part of the "$%&'" sequence used to make the large (2x2) dollar-sign symbol). The inverse-video ";" is the red-flashing one.


Back to New Breed Software. E-mail me.