Diamond Dave

Type
Game
Category
Maze action game
Author
Stephen Stout
Published in
Antic, August 1987 (Vol. 6, No. 4), Game of the Month
Year
1987
Language
Atari BASIC
Requirements
32K RAM, Atari BASIC, joystick in port 1
A mine of red brick-textured rock rows with black passages, five pale glowing diamonds, a green prairie-dog sprite, and the robot entering at the top below a LEVEL 1 banner with five robot icons

About the program

The story behind Diamond Dave is pure 1987 satire. Mr. Dave has lost his diamonds to Mrs. Marcos, corporate raider "Boesky Investment Insiders" is circling, and his last hope is an abandoned mine in the Arizona desert, used for underground nuclear tests in the 1950s. Humans can't work there, so Dave buys five ex-car-factory robots and you drive them. Radio control won't work through all that radiation, so each robot trails a power-and-control cable behind it. The cable lets you yank the robot back to the surface in an instant. That's useful, because giant mutant prairie dogs are racing through the tunnels.

Stephen Stout was 18 and lived in Fort Walton Beach, Florida. Antic said he showed "disturbing signs" of being another wild game designer in the tradition of J. D. Casten. The game ran as the August 1987 Game of the Month and needs 32K.

Typing it in

Line 620 is a 56-character machine-language memory-move routine written as a string full of inverse control characters. Antic printed a second listing to create that line as a LINES.LST file, which you then ENTER over the main program. The disk listing here already contains it. The string is called MOVX$ here (MOVE$ as published), so the listing runs on Atari BASIC and on the Altirra BASIC replacement ROM that many emulators use, which has a MOVE command of its own. Lines 430–440 (the prairie dog shapes) and 770 (the mine template) also have inverse and control characters. {inv}…{/inv} means type with the Atari key on, {CTRL-E} means hold CTRL and press E, {CTRL-,} is CTRL-comma, and {BACK S}/{INS CHAR} are typed as ESC then the key. Line 100 has also been corrected: as published, its bottom-edge test read Y=IY>22 instead of Y+IY>22.

How to play

Press the joystick button at the title screen. Each robot enters at the top of the mine. Push the joystick to drive it through any open passage, and it leaves a blue cable behind. Collect the five glowing diamonds on the screen to go down to the next level. The prairie dogs (green and red player-missile sprites) run left and right along the passages. If one touches your robot or its cable, the robot is destroyed. Press the button to pull the robot straight back to the top. Its cable disappears, but the diamonds you've collected stay collected. Each level has one more prairie dog than the last. Survive level 11, where there's a prairie dog in every passage, and you win. You have five robots in all.

How it works

  • Strings as player-missile memory. Line 590 is the clever bit. It DIMs a dummy string just long enough that the next strings (BUF$, MI$, P0$, P1$) start exactly on a 2K boundary, which player-missile graphics needs. Line 950 then points PMBASE (54279) at them, so a prairie dog is created just by assigning its shape into P0$ or P1$ at the right row.
  • Collision detection is done in hardware. Lines 50–60 PEEK the player-to-playfield collision registers (53252, 53253), and POKE 53278,0 (HITCLR) clears them.
  • A screen in a string. The mine layout is 460 bytes (23 rows of 20 characters in GRAPHICS 1). It is kept in S1$/S2$ and copied to screen memory with the machine-language move in one call. Pulling a robot out is simply "copy S2$ back to the screen", which wipes the cable.
  • Glowing diamonds. Lines 630–640 poke a 16-byte routine into page 6 and install it as a vertical-blank interrupt. Every 1/60 of a second it adds 1 to colour register 709, the colour the diamond characters use, so they shimmer through every hue.
  • Custom characters. Lines 690–750 redefine the robot, the solid rock and the diamond in a RAM character set at page 144.

Variations to try

  • Give Dave more robots: change LIVES=5 in line 920 (and the five ! marks printed beside it).
  • Speed up the prairie dogs by changing X1=X1+1:X2=X2-1 in line 20 to steps of 2.

Changes from the published listing

Line As published Now Why
100 … OR Y=IY>22 THEN 20 … OR Y+IY>22 THEN 20 A typing slip: Y=IY>22 is never true, so the bottom-edge check did nothing.
180, 250, 320, 390, 490, 620 MOVE$ MOVX$ Altirra BASIC (used by many emulators) has a MOVE command, so it rejected line 620 (DIM MOVE$(56)). The same-length name keeps memory use identical; behaviour on Atari BASIC is unchanged.

Listing

2 REM DIAMOND DAVE
4 REM BY STEPHEN STOUT
6 REM (c)1987, ANTIC PUBLISHING
10 GOTO 570
20 POKE 53248,X1:POKE 53249,X2:X1=X1+1:X2=X2-1
30 IF X1>210 THEN X1=32
40 IF X2<32 THEN X2=210
50 IF PEEK(53252)<>0 AND PEEK(53252)<>2 THEN 210
60 IF PEEK(53253)<>0 AND PEEK(53253)<>2 THEN 210
70 POKE 77,0:ST=STICK(0):IX=(ST=7)-(ST=11):IY=(ST=13)-(ST=14)
80 IF STRIG(0)=0 THEN 180
90 IF IX=0 AND IY=0 THEN 20
100 IF X+IX<0 OR X+IX>19 OR Y+IY<1 OR Y+IY>22 THEN 20
110 LOCATE X+IX,Y+IY,Z:IF Z<>32 AND Z<>163 AND Z<>5 THEN 20
120 POSITION X,Y:? #6;"{inv}#{/inv}":X=X+IX:Y=Y+IY:POSITION X,Y:? #6;"!":SOUND 0,0,0,15:SOUND 0,0,0,0
130 IF Z<>5 THEN 20
140 DMN=DMN+1:POSITION 0+DMN-1,0:? #6;"%":D=X+1+(Y-1)*20:S2$(D,D)="{CTRL-,}"
150 FOR I=250 TO 10 STEP -10:SOUND 0,I,10,8:NEXT I:SOUND 0,0,0,0
160 IF DMN=5 THEN FOR I=1 TO 300:NEXT I:GOTO 270
170 GOTO 20
180 ML=USR(ADR(MOVX$),ADR(S2$),PEEK(88)+PEEK(89)*256+20,460)
190 POKE 53278,0:X=9:Y=1
200 FOR I=10 TO 250 STEP 10:SOUND 0,I,10,8:NEXT I:SOUND 0,0,0,0:GOTO 20
210 LIVES=LIVES-1:POSITION 19-LIVES,0:? #6;" "
220 X=9:Y=1
230 FOR I=15 TO 0 STEP -1:SOUND 0,0,0,I:FOR D=1 TO 15:NEXT D:POKE 710,PEEK(20):NEXT I:POKE 710,148
240 IF LIVES=0 THEN 480
250 ML=USR(ADR(MOVX$),ADR(S2$),PEEK(88)+PEEK(89)*256+20,460):POKE 53278,0
260 GOTO 20
270 IF LEVEL=11 THEN 480
280 POKE 53248,0:POKE 53249,0:POKE 559,0
290 LEVEL=LEVEL+1:POSITION 13,0:? #6;CHR$(ASC(STR$(LEVEL))+128):POSITION 0,0:? #6;"     "
300 IF LEVEL=10 THEN POSITION 12,0:? #6;"{inv}10{/inv}"
310 IF LEVEL=11 THEN POSITION 12,0:? #6;"{inv}11{/inv}"
320 ML=USR(ADR(MOVX$),ADR(S1$),PEEK(88)+PEEK(89)*256+20,460)
330 FOR Y=3 TO 21:X=INT(RND(0)*8)+1:POSITION X,Y:? #6;" "
340 X=INT(RND(0)*8)+11:POSITION X,Y:? #6;" ":NEXT Y
350 FOR I=1 TO 5
360 X=INT(RND(0)*18)+1:Y=INT(RND(0)*20)+2:LOCATE X,Y,D:IF D<>32 THEN 360
370 POSITION X,Y:? #6;"{CTRL-E}"
380 NEXT I
390 ML=USR(ADR(MOVX$),PEEK(88)+PEEK(89)*256+20,ADR(S2$),460)
400 X1=32:X2=210
410 D=INT(RND(0)*11)+1:IF ROW(D)<>0 THEN 410
420 ROW(D)=1
430 IF INT(LEVEL/2)*2<>LEVEL THEN P0$(PY(D))="<{BACK S}{inv}[{/inv}{INS CHAR}{inv}WC{/inv}j<":GOTO 450
440 P1$(PY(D))="<{BACK S}{inv}[{/inv}{INS CHAR}{inv}=[{/inv}f<"
450 X=9:Y=1:POKE 53278,0:DMN=0
460 POKE 559,58
470 GOTO 20
480 FOR I=10 TO 250 STEP 1:SOUND 0,I,10,8:NEXT I:SOUND 0,0,0,0:POKE 53248,0:POKE 53249,0
490 ML=USR(ADR(MOVX$),ADR(S2$),PEEK(88)+PEEK(89)*256+20,460)
500 POSITION 3,9:? #6;"{inv}##############{/inv}"
510 IF LIVES=0 THEN POSITION 3,10:? #6;"{inv}#{/inv}  YOU LOST  {inv}#{/inv}":GOTO 530
520 IF LEVEL=11 THEN POSITION 3,10:? #6;"{inv}#{/inv}  YOU  WON  {inv}#{/inv}"
530 POSITION 3,11:? #6;"{inv}#{/inv}            {inv}#{/inv}":POSITION 3,12:? #6;"{inv}#{/inv}HIT  TRIGGER{inv}#{/inv}"
540 POSITION 3,13:? #6;"{inv}##############{/inv}"
550 POKE 77,0:IF STRIG(0)=1 THEN 550
560 RUN
570 GRAPHICS 0:POKE 559,0:POKE 16,64:POKE 53774,64
580 FOR I=53248 TO 53255:POKE I,0:NEXT I:FOR I=704 TO 707:POKE I,0:NEXT I
590 CLR :DIM FIL1$(1),FIL2$((INT(ADR(FIL1$)/2048)+1)*2048-ADR(FIL1$)-1)
600 DIM BUF$(768),MI$(256),P0$(256),P1$(256)
610 BUF$(1)=CHR$(0):BUF$(768)=CHR$(0):BUF$(2)=BUF$:MI$=BUF$:P0$=BUF$:P1$=BUF$
620 DIM MOVX$(56):MOVX$="hh{inv}{CTRL-E}{/inv}{CTRL-B}h{inv}{CTRL-E}{/inv}{CTRL-A}h{inv}{CTRL-E}{/inv}{CTRL-D}h{inv}{CTRL-E}{/inv}{CTRL-C}h{inv}{CTRL-E}{/inv}{CTRL-F}h{inv}{CTRL-E}{/inv}{CTRL-E}{inv} {/inv}{CTRL-,}{inv}p{/inv}{CTRL-P}{inv}1{/inv}{CTRL-A}{inv}{CTRL-Q}{/inv}{CTRL-C}{inv}f{/inv}{CTRL-A}{inv}P{/inv}{CTRL-B}{inv}f{/inv}{CTRL-B}{inv}f{/inv}{CTRL-C}{inv}P{/inv}{CTRL-B}{inv}f{/inv}{CTRL-D}{inv}F{/inv}{CTRL-E}{inv}%{/inv}{CTRL-E}{inv}I{/inv}{INS CHAR}{inv}PhF{/inv}{CTRL-F}{inv}%{/inv}{CTRL-F}{inv}I{/inv}{INS CHAR}{inv}P{CTRL-.}{/inv}{CTRL-.}"
630 RESTORE 640:FOR I=0 TO 15:READ D:POKE 1664+I,D:NEXT I
640 DATA 104,162,6,160,138,169,7,76,92,228,238,197,2,76,98,228
650 CHSET=144*256
660 ML=USR(ADR(MOVX$),57344,CHSET,1024)
670 RESTORE 710
680 GOTO 700
690 FOR I=0 TO 7:READ D:POKE CHSET+A*8+I,D:NEXT I
700 READ A:IF A<>-1 THEN GOTO 690
710 DATA 1,56,124,130,146,254,40,68,130
720 DATA 3,255,255,255,255,255,255,255,255
730 DATA 4,223,255,251,127,255,254,223,251
740 DATA 5,146,84,0,124,254,124,56,16
750 DATA -1
760 DIM S1$(460),S2$(460)
770 TRAP 780:S1$(LEN(S1$)+1)="{inv}DDDDDDDDDDDDDDDDDDDD{/inv}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}{CTRL-,}":GOTO 770
780 S1$(10,10)="{CTRL-A}":S2$=S1$
790 DIM ROW(11):FOR I=0 TO 11:ROW(I)=0:NEXT I
800 DIM PY(11):PY(0)=0:PY(1)=49:FOR I=2 TO 11:PY(I)=PY(I-1)+16:NEXT I
810 GRAPHICS 1+16:POKE 559,0:POKE 16,64:POKE 53774,64
820 POKE 708,8:POKE 709,196
830 POSITION 3,0:? #6;"{inv}antic  magazine{/inv}":POSITION 6,1:? #6;"{inv}presents{/inv}"
840 D=PEEK(560)+PEEK(561)*256+4:POKE D+6,7:POKE D+8,7
850 POSITION 4,5:? #6;"DIAMOND DAVE":POSITION 2,7:? #6;"{inv}BY STEPHEN STOUT{/inv}"
860 POSITION 2,20:? #6;"TRIGGER TO BEGIN"
870 POKE 559,34
880 POKE 77,0:IF STRIG(0)=0 THEN 900
890 GOTO 880
900 GRAPHICS 1+16:POKE 559,0:POKE 16,64:POKE 53774,64
910 LEVEL=0:POSITION 6,0:? #6;"{inv}LEVEL: 1{/inv}"
920 LIVES=5:POSITION 15,0:? #6;"!!!!!"
930 POKE 756,144:POKE 708,8:POKE 711,36:ML=USR(1664)
940 POKE 704,196:POKE 705,68
950 POKE 54279,ADR(BUF$)/256
960 POKE 53277,3
970 POKE 623,0
980 POKE 53256,0:POKE 53257,0
990 GOTO 270

Download

The original program from the Antic disk, to LOAD or ENTER instead of typing it: DIMNDAVE.BAS.

Credits