Twenty-one against the computer dealer on a 1K ZX80. Your cards are listed on the left and the dealer’s on the right, with the totals underneath; the dealer’s total is hidden until it plays. Press NEWLINE for another card, or SPACE and NEWLINE to stand, and the dealer then draws to 17 and the program prints WIN or LOSE.
You can hold at most five cards, and aces always count 11. NEWLINE plays again; SPACE and NEWLINE exits. The listing in SYNTAX explains each line after a semicolon; those notes are left out of the file. As printed, line 670 shows the dealer’s first card (only its total is masked). The March 1982 Program Improvements column gives Clifford Efaw’s changes for the 8K ROM, including 670 PRINT P(Z),CHR$ (15).
Published in Syntax January 1982 (4K/1K Blackjack).
Source Code
10 DIM P(5)
20 DIM C(5)
30 DIM D(10)
40 LET Q=0
50 LET U=0
60 LET V=1
70 FOR J=3 TO 5
80 LET C(J)=0
90 LET P(J)=0
100 NEXT J
110 GO SUB 360
120 GO SUB 500
130 GO SUB 550
140 GO SUB 500
150 GO SUB 550
160 GO TO 200
170 INPUT A$
180 IF NOT A$="" THEN GO TO 230
190 GO SUB 500
200 IF S>21 THEN GO TO 300
210 IF S=21 THEN GO TO 230
220 GO TO 170
230 LET V=0
240 GO SUB 600
250 GO TO 270
260 GO SUB 550
270 IF T<17 THEN GO TO 260
280 IF T>21 THEN GO TO 340
290 IF T<S THEN GO TO 340
300 PRINT "LOSE"
310 INPUT A$
320 IF NOT A$="" THEN STOP
330 GO TO 40
340 PRINT "WIN"
350 GO TO 310
360 FOR J=1 TO 10
370 LET X=RND(52)
380 FOR W=1 TO 10
390 IF X=D(W) THEN GO TO 370
400 NEXT W
410 GO TO 430
420 LET X=X-13
430 IF X>13 THEN GO TO 420
440 IF X>10 THEN LET X=10
450 IF X=1 THEN LET X=11
460 LET D(J)=X
470 NEXT J
480 LET K=0
490 RETURN
500 LET K=K+1
510 LET Q=Q+1
520 LET P(Q)=D(K)
530 GO SUB 600
540 RETURN
550 LET K=K+1
560 LET U=U+1
570 LET C(U)=D(K)
580 GO SUB 600
590 RETURN
600 CLS
610 LET S=0
620 LET T=0
630 FOR Z=1 TO 5
640 IF V=Z THEN GO TO 670
650 PRINT P(Z),C(Z)
660 GO TO 680
670 PRINT P(Z),C(Z)
680 PRINT
690 LET S=S+P(Z)
700 LET T=T+C(Z)
710 NEXT Z
720 IF V=1 THEN GO TO 750
730 PRINT S,T
740 GO TO 760
750 PRINT S,CHR$(15)
760 PRINT
770 RETURNNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.


