10 PRINT:PRINT:PRINT:PRINT:PRINT:PRINT
20 DIM C(52),V$(10)
30 PRINT "DO YOU WANT INSTRUCTIONS"
40 INPUT "(Type 0 for NO, 1 for YES)";I
50 IF I<>0 THEN 2130
60 C=0
70 FOR K=0 TO 3
80 FOR J=1 TO 10
90 C(J+10*K)=J
100 NEXT J:NEXT K
110 FOR J=41 TO 52:C(J)=10:NEXT J
120 V$(1)=" A"
130 V$(2)=" 2"
140 V$(3)=" 3"
150 V$(4)=" 4"
160 V$(5)=" 5"
170 V$(6)=" 6"
180 V$(7)=" 7"
190 V$(8)=" 8"
200 V$(9)=" 9"
210 V$(10)="10"
220 L=40
230 IF L<40 THEN 320
240 FOR J=1 TO 52
250 Z=C(J)
260 R=INT(RND(J)*52+1)
270 C(J)=C(R)
280 C(R)=Z
290 NEXT J
300 L=1
310 PRINT "NEW DECK":PRINT
320 T=0
330 T1=0
340 S=0
350 S1=0
360 INPUT"BET AMOUNT = $",B
370 IF B=0 THEN 240
380 IF B=999 THEN END
390 IF B>500 THEN 360
400 IF B<1 THEN 360
410 IF B<> INT(B) THEN 360
420 GOSUB 1870
430 GOSUB 2020
440 PRINT "    ";V$(C(L-1))
450 GOSUB 1870 
460 GOSUB 2020
470 H=C(L-1)
480 IF C(L-3)=1 THEN 1760
490 IF T=21 THEN 1630
500 IF T1=21 THEN 1710
510 INPUT D$
520 IF LEFT$(D$,1)="G" THEN 1340
530 IF LEFT$(D$,1)="D" THEN 1310
540 IF LEFT$(D$,1)="H" THEN 1220
550 IF LEFT$(D$,1)="S" THEN 580
560 PRINT"    RETYPE: ";
570 GOTO 510
580 IF C(L-2)<>C(L-4) THEN 560
590 PRINT"FIRST HAND"
600 B1=B
610 PRINT V$(C(L-2))
620 X=C(L-2)
630 T1=X
640 GOSUB 1870
650 IF X<>1 THEN 680
660 T1=T1+10
670 GOTO 870
680 INPUT D1$
690 IF LEFT$(D1$,1)="G" THEN 870
700 IF LEFT$(D1$,1)="D" THEN 840
710 IF LEFT$(D1$,1)="H" THEN 730
720 PRINT"    RETYPE: ";:GOTO 680
730 GOSUB 1870
740 IF T1>0 THEN 800
750 X1=0
760 C=C-B1
770 B1=0
780 PRINT"BUST"
790 GOTO 890
800 INPUT D1$
810 IF LEFT$(D1$,1)="G" THEN 870
820 IF LEFT$(D1$,1)="H" THEN 730
830 PRINT"    RETYPE: ";:GOTO 800
840 B1=2*B
850 GOSUB 1870
860 IF T1=0 THEN 750
870 PRINT:PRINT T1
880 X1=T1
890 PRINT"SECOND HAND"
900 B2=B
910 PRINT V$(X)
920 T1=X
930 GOSUB 1870
940 IF X<>1 THEN 970
950 T1=T1+10
960 GOTO 1180
970 INPUT D1$
980 IF LEFT$(D1$,1)="G"THEN 1180
990 IF LEFT$(D1$,1)="D" THEN 1160
1000 IF LEFT$(D1$,1)="H" THEN 1020
1010 PRINT "    RETYPE: ";:GOTO 970
1020 GOSUB 1870
1030 IF T1>0 THEN 1110
1040 X2=0
1050 C=C-B2
1060 B2=0
1070 PRINT"BUST";
1080 IF X1>0 THEN 1350
1090 PRINT "    ";V$(H)
1100 GOTO 1450
1110 INPUT D1$
1120 IF LEFT$(D1$,1)="G" THEN 1180
1130 IF LEFT$(D1$,1)="H"THEN 1020
1140 PRINT "    RETYPE: ";:GOTO 1110
1150 B2=2*B
1160 GOSUB 1870
1170 IF T1=0 THEN 1040
1180 PRINT:PRINT T1
1190 B=B1+B2
1200 X2=T1
1210 GOTO 1350
1220 GOSUB 1870
1230 IF T1>0 THEN 1270
1240 PRINT"BUST";
1250 PRINT"    ";V$(H)
1260 GOTO 1500
1270 INPUT D$
1280 IF LEFT$(D$,1)="G" THEN 1340
1290 IF LEFT$(D$,1)="H" THEN 1220
1300 PRINT "    RETYPE: ";:GOTO 1270
1310 B=2*B
1320 GOSUB 1870
1330 IF T1=0 THEN 1240
1340 PRINT:PRINT T1;
1350 PRINT"      ";V$(H);
1360 GOTO 1390
1370 GOSUB 2020
1380 PRINT"  ";V$(C(L-1));
1390 IF T<17 THEN 1370
1400 IF T>21 THEN 1430
1410 PRINT":";T
1420 GOTO 1470
1430 PRINT": BUST"
1440 C=C+B
1450 PRINT"YOU HAVE $";C
1460 GOTO 230
1470 IF LEFT$(D$,1)="S" THEN 1520
1480 IF T1>T THEN 1440
1490 IF T1=T THEN 1450
1500 B=-B
1510 GOTO 1440
1520 IF T>X1 THEN 1610
1530 IF T=X1 THEN 1550
1540 C=C+B1
1550 IF T>X2 THEN 1590
1560 IF T=X2 THEN 1450
1570 C=C+B2
1580 GOTO 1450
1590 C=C-B2
1600 GOTO 1450
1610 C=C-B1
1620 GOTO 1550
1630 IF T1=21 THEN 1680
1640 C=C-B
1650 PRINT"    ";V$(H);
1660 PRINT"  BLACKJACK"
1670 GOTO 1450
1680 PRINT"BLACKJACK"
1690 PRINT "    ";
1700 GOTO 1650
1710 PRINT"BLACKJACK"
1720 PRINT"        ";V$(H);
1730 PRINT
1740 C=C+1.5*B
1750 GOTO 1450
1760 INPUT"      INSURANCE ";I$
1770 IF LEFT$(I$,1)="Y" THEN 1800
1780 PRINT "    ";
1790 GOTO 490
1800 IF T=21 THEN 1830
1810 C=C-.5*B
1820 GOTO 1780
1830 PRINT "        10";
1840 IF T1<>21 THEN 1660
1850 C=C+B
1860 GOTO 1660
1870 IF T1>10 THEN 1910
1880 IF C(L)<>1 THEN 1910
1890 T1=T1+10
1900 S1=1
1910 T1=T1+C(L)
1920 PRINT V$(C(L));"  ";
1930 L=L+1
1940 IF T1<=21 THEN 2010
1950 IF S1=0 THEN 1990
1960 T1=T1-10
1970 S1=0
1980 GOTO 2010
1990 T1=0
2000 PRINT
2010 RETURN
2020 IF T>10 THEN 2060
2030 IF C(L)<>1 THEN 2060
2040 T=T+10
2050 S=1
2060 T=T+C(L)
2070 L=L+1
2080 IF T<=21 THEN 2120
2090 IF S=0 THEN 2120
2100 T=T-10
2110 S=0
2120 RETURN
2130 PRINT:PRINT:PRINT
2140 PRINT"THIS BLACKJACK PROGRAM ENABLES THE OPERATOR TO PLAY HEAD-"
2150 PRINT"TO-HEAD WITH THE COMPUTER, SIMULATING THE EXACT RULES AS"
2160 PRINT"THOSE ON THE LAS VAGES STRIP.  THE CARDS ARE DEALT FROM ONE"
2170 PRINT"52-CARD DECK UNTIL A HAND STARTS WITH LESS THAN 12 CARDS"
2180 PRINT"REMAINING IN WHICH CASE IT RESHUFFLES.  THE DEALER MUST HIT"
2190 PRINT"THROUGH A TOTAL OF 16 AND STAND ON ALL TOTALS OF 17 AND ABOVE."
2200 INPUT"TYPE <RETURN> TO GO ON";W9
2210 PRINT:PRINT"THE INSURANCE BET IS OFFERED AT HALF THE PLAYER'S BET WHEN"
2220 PRINT"THE DEALER'S UP-CARD IS AN ACE."
2230 PRINT"YOU MAY DOUBLE-DOWN ON ANY TWO CARDS, AND RECEIVE ONE MORE"
2240 PRINT"CARD WHILE THE ORIGINAL BET IS DOUBLED."
2250 PRINT"YOU MAY SPLIT ANY HAND BUT RESPLITTING IS NOT ALLOWED."
2260 PRINT"ALSO, ONLY ONE CARD IS DEALT ON EACH OF A PAIR OF ACES."
2270 PRINT"YOUR CARDS APPEAR IN THE FAR LEFT COLUMN; THE DEALER'S ON THE"
2280 PRINT"FAR RIGHT.  "
2290 PRINT" THE COMMANDS ARE AS FOLLOWS:"
2300 PRINT"      HIT (DRAW ANOTHER CARD)"
2310 PRINT"      GOOD (STAND ON CURRENT TOTAL)"
2320 PRINT"      DOUBLE (DOUBLE YOUR BET AND DRAW ONE CARD)"
2330 PRINT"      SPLIT (FORM TWO HANDS FROM A PAIR WITH THE ORIGINAL"
2340 PRINT"             BET ON EACH HAND)"
2350 PRINT:PRINT"COMMANDS MAY BE TYPED IN AS THE FIRST LETTER"
2360 PRINT "TO EXIT PROGRAM ENTER 999 AS A BET":PRINT"GOOD LUCK":PRINT
2370 GOTO 60
DS MAY BE TYPED IN AS THE FIRST LETTER