home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol142 / blakjack.bas < prev    next >
Encoding:
BASIC Source File  |  1984-04-29  |  11.2 KB  |  370 lines

  1. 10 '         *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*
  2. 20 '         *+                                             +*
  3. 30 '         *+  Graphics Games for the Osborne I Computer  +*
  4. 40 '         *+      Courtesy of Kelly Smith, CP/M-Net      +* 
  5. 50 '         *+              (805) 527-9321                 +*
  6. 60 '         *+                   and                       +*
  7. 70 '         *+       Wizard of OsZ, (213) 341-9399         +*
  8. 80 '         *+                                             +*
  9. 90 '         *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*
  10. 100 '
  11. 110 ' Wizard of OsZ, P.O. Box 964, Chatsworth, CA 91311 (213) 341-9399
  12. 120 '
  13. 130 ' ---------------- Osborne I Terminal Commands -------------------
  14. 140 '
  15. 150 '
  16. 160 E$=CHR$(27): '                Escape Character
  17. 170 CLS$=CHR$(26): '              Clear Screen
  18. 180 DC$=E$+"=": '                 Direct Cursor Addressing
  19. 190 GY$=E$+"g": '                 Graphics On
  20. 200 GN$=E$+"G": '                 Graphics Off
  21. 210 HO$=E$+CHR$(1): '             Cursor Home
  22. 220 EP$=E$+"T": '                Erase to End of Line
  23. 230 DY$=E$+")": '                DIM Display On
  24. 240 DN$=E$+"(": '                DIM Display Off
  25. 250 UY$=E$+"l": '                Start Underlining
  26. 260 UN$=E$+"m": '                End Underlining
  27. 270 'NOTE: The Osborne I uses the following scheme for direct cursor addressing:
  28. 280 '      Location= (CHR$(Line number+32));(CHR$(Column number+32))
  29. 290 PRINT CLS$
  30. 300 PRINT"          The Wizard of OsZ - 'Black-Jack'"
  31. 310 PRINT
  32. 320 PRINT:PRINT"Do you require instructions (Y or N) ?";
  33. 330 A$=INKEY$:IF LEN(A$)=0 THEN GOTO 330 ' get keyboard input
  34. 340 IF A$="N" OR A$="n" THEN PRINT CLS$:GOTO 430
  35. 350 PRINT CLS$;UY$;"  The Wizard of OsZ Casino house limit is $10,000   ";UN$;:PRINT
  36. 360 PRINT:PRINT "Your choices to the question HIT are as follows:":PRINT
  37. 370 PRINT "0 <-- NO HIT";DY$;" on this hand";DN$
  38. 380 PRINT "1 <-- HIT";DY$;" on this hand";DN$
  39. 390 PRINT "2 <-- DOUBLE BET";DY$;" after seeing cards 1 and 2 and HIT";DN$
  40. 400 PRINT "3 <-- SPLIT";DY$;" the hand, for two pairs";DN$
  41. 410 PRINT:PRINT "To stop the game, enter a ";UY$;"0";UN$;" for your wager.":PRINT
  42. 420 DIM W[10]
  43. 430 K=K1=W1=C2=0
  44. 440 NB$=STRING$(6,127)
  45. 450 MD$=STRING$(1,127)+STRING$(4,32)+STRING$(1,127)
  46. 460 DIM Q[52]:DIM D[52]
  47. 470 PRINT:PRINT TAB(15);"Press any key to begin play...";
  48. 480 IF INKEY$="" THEN RS=RS+1:GOTO 480
  49. 490 RANDOMIZE RS
  50. 500 PRINT CLS$
  51. 510 FOR I=1 TO N/2
  52. 520    X=INT(RND*100):IF X>51 THEN GOTO 520
  53. 530 NEXT I
  54. 540 FOR A=1 TO 52
  55. 550   D[A]=0
  56. 560 NEXT A
  57. 570 FOR A=0 TO 39 STEP 13
  58. 580   FOR C=1 TO 13
  59. 590     Q[A+C]=C
  60. 600   NEXT C
  61. 610 NEXT A
  62. 620 PRINT 
  63. 630 K=K+1
  64. 640 FOR P=1 TO 5
  65. 650   E[P]=0
  66. 660   V[P]=0
  67. 670   T[P]=0
  68. 680 NEXT P
  69. 690 V[3]=1
  70. 700 ' ask for wager entry, clearing any overflow digits from screen
  71. 710 PRINT DC$+CHR$(53)+CHR$(32);"Enter your wager";EP$
  72. 720 PRINT DC$+CHR$(53)+CHR$(48); ' reposition for new wager entry                  
  73. 730 P=1
  74. 740 INPUT W2
  75. 750 PRINT
  76. 760 W[2]=W2
  77. 770 IF W2<=0 THEN GOTO 3490
  78. 780 IF W2<=10000 THEN GOTO 840
  79. 790 FOR I = 1 TO 50
  80. 800    PRINT DC$+CHR$(1)+CHR$(34);"That's too much...the casino limit is $10,000!";
  81. 810    FOR X=1 TO 20:NEXT X:PRINT DC$+CHR$(1)+CHR$(32);EP$
  82. 820 NEXT I
  83. 830 GOTO 710
  84. 840 PRINT DC$+CHR$(1)+CHR$(33);
  85. 850 FOR TPT=1 TO 20
  86. 860   PRINT DC$+CHR$(TPT+32)+CHR$(32);EP$
  87. 870 NEXT TPT
  88. 880 PRINT DC$+CHR$(1)+CHR$(33);"Dealers hand";DC$+CHR$(12)+CHR$(33);"Your hand"
  89. 890 CLM=3
  90. 900 LN=2
  91. 910 PRINT HO$; ' home cursor
  92. 920 FOR HH=1 TO 9:PRINT EP$+CHR$(10);:NEXT HH ' sanitize screen
  93. 930 PRINT EP$
  94. 940 GOSUB 2180 : ' deal the cards
  95. 950 GOSUB 3530:PRINT DY$; ' begin half intensity
  96. 960 FOR TPT=1 TO 3 ' dealers card down (and dirty!)
  97. 970   PRINT DC$+CHR$(LN+TPT)+CHR$(CLM+33);"****":NEXT TPT
  98. 980 PRINT DN$ ' end half intensity
  99. 990 IF E[1]=0 THEN GOTO 1010
  100. 1000 V[4]=1
  101. 1010 V[5]=1
  102. 1020 GOSUB 2180 : ' deal the cards
  103. 1030 M=X
  104. 1040 P=2
  105. 1050 LN=10
  106. 1060 CLM=3
  107. 1070 GOSUB 2180 : ' deal the cards
  108. 1080 G=X
  109. 1090 ' next card up
  110. 1100 GOSUB 2180 : ' deal the cards
  111. 1110 IF V[2]>0 THEN GOTO 1540
  112. 1120 S=X
  113. 1130 IF V[3]<>1 THEN GOTO 1540
  114. 1140 IF T[P]<>21 THEN GOTO 1260
  115. 1150 FOR I=1 TO 50 ' flash opponent blackjack win and ring bell
  116. 1160    PRINT DC$+CHR$(15)+CHR$(32);"         >>>BLACKJACK<<<";CHR$(7);
  117. 1170    FOR X=1 TO 20:NEXT X:PRINT DC$+CHR$(15)+CHR$(41);EP$
  118. 1180 NEXT I
  119. 1190 PRINT DC$+CHR$(8)+CHR$(32);"My hole card was ",
  120. 1200 X=M
  121. 1210 CLM=10
  122. 1220 LN=2
  123. 1230 GOSUB 2550 : ' print card
  124. 1240 W1=W1+W2*2
  125. 1250 GOTO 3130
  126. 1260 IF V[4]=0 THEN GOTO 1450
  127. 1270 PRINT DC$+CHR$(7)+CHR$(32);"Do you want to buy insurance (Y for YES, N for NO)";EP$
  128. 1280 PRINT "If YES and I have BLACKJACK, you ";UY$;"win $";W2;UN$
  129. 1290 PRINT "If not, you ";UY$;"lose $";W2/2;UN$;" to the Wizard of OsZ Casino";EP$
  130. 1300 INPUT X$
  131. 1310 PRINT 
  132. 1320 IF LEFT$(X$,1)="N" OR LEFT$(X$,1)="n" THEN GOTO 1400
  133. 1330 IF T[1]<>21 THEN GOTO 1400
  134. 1340 W1=W1+W2
  135. 1350 FOR I=1 TO 50 ' flash "you win on insurance"
  136. 1360    PRINT DC$+CHR$(1)+CHR$(32);"   You win $";W2;" on your insurance bet";
  137. 1370    FOR X=1 TO 20:NEXT X:PRINT DC$+CHR$(1)+CHR$(32);EP$
  138. 1380 NEXT I
  139. 1390 GOTO 1450
  140. 1400 W1=W1-W2/2
  141. 1410 FOR I=1 TO 50 ' flash "You lost on insurance"
  142. 1420    PRINT DC$+CHR$(1)+CHR$(32);"   You lost $";W2/2;" on your insurance bet";
  143. 1430    FOR X=1 TO 20:NEXT X:PRINT DC$+CHR$(1)+CHR$(32);EP$
  144. 1440 NEXT I
  145. 1450 IF T[1]<>21 THEN GOTO 1540
  146. 1460 FOR I=1 TO 50 ' flash dealer blackjack win and ring bell
  147. 1470    PRINT DC$+CHR$(7)+CHR$(32);"         >>>BLACKJACK<<<";CHR$(7);
  148. 1480    FOR X=1 TO 20:NEXT X:PRINT DC$+CHR$(7)+CHR$(41);EP$
  149. 1490 NEXT I
  150. 1500 X=M
  151. 1510 LN=2:CLM=10
  152. 1520 GOSUB 2550 : ' print card
  153. 1530 GOTO 3110
  154. 1540 IF T[P]<=21 THEN GOTO 1650
  155. 1550 IF E[P]>0 THEN GOTO 1630
  156. 1560 PRINT DC$+CHR$(16)+CHR$(32);"You busted!  ";
  157. 1570 PRINT "Your total was";T[P];EP$;
  158. 1580 FOR I=1 TO 500:NEXT I ' delay for readability
  159. 1590 IF V[2]=1 THEN GOTO 1950
  160. 1600 CLM=9
  161. 1610 LN=2
  162. 1620 GOTO 2890 : ' dealer plays
  163. 1630 E[P]=E[P]-1
  164. 1640 T[P]=T[P]-10
  165. 1650 IF V[1]=2 THEN GOTO 1570
  166. 1660 V[3]=V[3]+1
  167. 1670 FOR I=1 TO 10:PRINT DC$+CHR$(15)+CHR$(32);EP$
  168. 1680 FOR X=1 TO 10:NEXT X ' flash hit request on screen
  169. 1690    PRINT CHR$(7);DC$+CHR$(15)+CHR$(32);"Hit";
  170. 1700 FOR X=1 TO 10:NEXT X
  171. 1710 NEXT I
  172. 1720 INPUT X:V[1]=X
  173. 1730 IF V[1]<>3 THEN GOTO 2090
  174. 1740 IF V[2]>0 THEN GOTO 2070
  175. 1750 IF V[3]<>2 THEN GOTO 2070
  176. 1760 IF Q[G]=Q[S] THEN GOTO 1790
  177. 1770 PRINT "Now really, does that look like a PAIR?";EP$
  178. 1780 GOTO 1670
  179. 1790 V[2]=1
  180. 1800 IF Q[G]<>1 THEN GOTO 1820
  181. 1810 V[1]=2
  182. 1820 P=3
  183. 1830 PRINT DC$+CHR$(21)+CHR$(32);"Playing ";UY$;"HAND ONE";UN$;" now";EP$
  184. 1840 ' 1st card
  185. 1850 CLM=3
  186. 1860 W[3]=W2
  187. 1870 X=G
  188. 1880 GOSUB 1900
  189. 1890 GOTO 1090 : ' next card
  190. 1900 GOSUB 2460
  191. 1910 GOSUB 2550 : ' print card
  192. 1920 V[3]=1
  193. 1930 T[P]=C
  194. 1940 RETURN 
  195. 1950 P=2
  196. 1960 V[2]=2
  197. 1970 PRINT DC$+CHR$(21)+CHR$(32);"Playing ";UY$;"HAND TWO";UN$;" now"
  198. 1980 PRINT DC$+CHR$(42)+CHR$(32); ' boogie back to last hand position and...
  199. 1990 FOR HH=1 TO 5:PRINT EP$+CHR$(10);:NEXT HH ' clear last hand delt
  200. 2000 X=S
  201. 2010 LN=10
  202. 2020 CLM=3
  203. 2030 GOSUB 1900
  204. 2040 IF Q[G]=1 THEN GOTO 2060
  205. 2050 V[1]=0
  206. 2060 GOTO 1090 : ' next card
  207. 2070 PRINT "No splits now, try again..."
  208. 2080 GOTO 1670
  209. 2090 IF V[1]<>2 THEN GOTO 2140
  210. 2100 IF V[3]=2 THEN GOTO 2130
  211. 2110 PRINT "Too late to double!";EP$
  212. 2120 GOTO 1670
  213. 2130 W[P]=2*W[P]
  214. 2140 IF V[1]>0 THEN GOTO 1090 : ' next card
  215. 2150 CLM=10
  216. 2160 LN=10
  217. 2170 GOTO 1570
  218. 2180 ' subroutine to deal the cards
  219. 2190 GOSUB 2290
  220. 2200 T[P]=T[P]+C
  221. 2210 IF V[5]=0 THEN GOTO 2270
  222. 2220 V[5]=0
  223. 2230 IF P<>2 THEN RETURN 
  224. 2240 PRINT DC$+CHR$(16)+CHR$(32);
  225. 2250 PRINT USING "'Your total is  ',D3.0,'  '",T[P];EP$
  226. 2260 RETURN 
  227. 2270 GOSUB 2550 : ' print a card
  228. 2280 RETURN 
  229. 2290 N=INT(RND*100):IF N>14 THEN GOTO 2290
  230. 2300 FOR A=1 TO N
  231. 2310    X=INT(RND*100):IF X>52 THEN 2310
  232. 2320   IF X=0 THEN GOTO 2310
  233. 2330 NEXT A
  234. 2340 IF D[X]=0 THEN GOTO 2440
  235. 2350 R=R+1
  236. 2360 IF R<50 THEN GOTO 2290
  237. 2370 FOR A=1 TO 52
  238. 2380   IF D[A]=K THEN GOTO 2400
  239. 2390   D[A]=0
  240. 2400 NEXT A
  241. 2410 R=0
  242. 2420 PRINT DC$+CHR$(8)+CHR$(32);"I reshuffled the deck...";EP$
  243. 2430 GOTO 2290
  244. 2440 R=0
  245. 2450 D[X]=K
  246. 2460 IF Q[X]<>1 THEN GOTO 2500
  247. 2470 C=11 ' be sure that ace counts as 11
  248. 2480 E[P]=E[P]+1
  249. 2490 RETURN 
  250. 2500 IF Q[X]>10 THEN GOTO 2530
  251. 2510 C=Q[X]
  252. 2520 RETURN 
  253. 2530 C=10
  254. 2540 RETURN 
  255. 2550 ' subroutine to print a card
  256. 2560 GOSUB 2590
  257. 2570 GOSUB 2730 : ' print suit
  258. 2580 RETURN 
  259. 2590 IF Q[X]<>1 THEN GOTO 2620
  260. 2600 NMB$="A" ' ace
  261. 2610 RETURN 
  262. 2620 IF Q[X]>10 THEN GOTO 2650
  263. 2630 X$=STR$(Q[X]):NMB$=MID$(X$,2,2)
  264. 2640 RETURN 
  265. 2650 IF Q[X]>11 THEN GOTO 2680
  266. 2660 NMB$="J" ' jack
  267. 2670 RETURN 
  268. 2680 IF Q[X]>12 THEN GOTO 2710
  269. 2690 NMB$="Q" ' queen
  270. 2700 RETURN 
  271. 2710 NMB$="K" ' king
  272. 2720 RETURN 
  273. 2730 ' subroutine to print suit
  274. 2740 IF X>39 THEN GOTO 2800
  275. 2750 IF X>26 THEN GOTO 2830
  276. 2760 IF X>13 THEN GOTO 2860
  277. 2770 SUT$="S" ' spade
  278. 2780 GOSUB 3610 : ' print cards
  279. 2790 RETURN 
  280. 2800 SUT$="C" ' club
  281. 2810 GOSUB 3610 : ' print cards
  282. 2820 RETURN 
  283. 2830 SUT$="H" ' heart
  284. 2840 GOSUB 3610 : ' print cards
  285. 2850 RETURN 
  286. 2860 SUT$="D" ' diamond
  287. 2870 GOSUB 3610 : ' print cards
  288. 2880 RETURN 
  289. 2890 ' subroutine for dealer play
  290. 2900 P=2
  291. 2910 PRINT DC$+CHR$(7)+CHR$(32);
  292. 2920 X=M
  293. 2930 LN=2
  294. 2940 CLM=10
  295. 2950 GOSUB 2550 : ' print card
  296. 2960 IF T[2]<22 THEN GOTO 2990
  297. 2970 IF V[2]=0 THEN GOTO 3110
  298. 2980 IF T[3]>21 THEN GOTO 3110
  299. 2990 P=1
  300. 3000 IF T[1]<17 THEN GOTO 3180
  301. 3010 IF T[1]>17 THEN GOTO 3030
  302. 3020 IF E[1]>0 THEN GOTO 3180
  303. 3030 IF T[1]>21 THEN GOTO 3210
  304. 3040 P=2
  305. 3050 IF T[P]>21 THEN GOTO 3110
  306. 3060 IF T[1]>21 THEN GOTO 3090
  307. 3070 IF T[1]>T[P] THEN GOTO 3110
  308. 3080 IF T[1]=T[P] THEN GOTO 3120
  309. 3090 W1=W1+W[P]
  310. 3100 GOTO 3120
  311. 3110 W1=W1-W[P]
  312. 3120 IF V[2]>0 THEN GOTO 3150
  313. 3130 GOSUB 3270
  314. 3140 GOTO 630
  315. 3150 P=3
  316. 3160 V[2]=0
  317. 3170 GOTO 3050
  318. 3180 PRINT DC$+CHR$(6)+CHR$(32);"I Draw..."
  319. 3190 GOSUB 2180 : ' deal
  320. 3200 GOTO 2990
  321. 3210 IF E[1]=0 THEN GOTO 3250
  322. 3220 E[1]=E[1]-1
  323. 3230 T[1]=T[1]-10
  324. 3240 GOTO 2990
  325. 3250 PRINT DC$+CHR$(7)+CHR$(32);"I busted!";EP$;
  326. 3260 GOTO 3040
  327. 3270 PRINT DC$+CHR$(8)+CHR$(32);"My total was ";T[1];EP$
  328. 3280 PRINT EP$ ' flush next entry on comment line
  329. 3290 IF W1<0 THEN GOTO 3370
  330. 3300 IF W1=0 THEN GOTO 3430
  331. 3310 FOR I=1 TO 10 ' slowly flash current financial status
  332. 3320    FOR X=1 TO 50:NEXT X:PRINT DC$+CHR$(21)+CHR$(60);EP$
  333. 3330    PRINT DC$+CHR$(21)+CHR$(60);"You're ";UY$;"ahead $";W1;UN$;EP$
  334. 3340    FOR X=1 TO 50:NEXT X:PRINT DC$+CHR$(21)+CHR$(60);EP$
  335. 3350 NEXT I
  336. 3360 RETURN 
  337. 3370 FOR I=1 TO 10 ' slowly flash current financial status
  338. 3380    FOR X=1 TO 50:NEXT X:PRINT DC$+CHR$(21)+CHR$(60);EP$
  339. 3390    PRINT DC$+CHR$(21)+CHR$(60);"You're "UY$;"behind $";-W1;UN$;EP$
  340. 3400    FOR X=1 TO 50:NEXT X:PRINT DC$+CHR$(21)+CHR$(60);EP$
  341. 3410 NEXT I
  342. 3420 RETURN 
  343. 3430 FOR I=1 TO 10 ' slowly flash current financial status
  344. 3440    FOR X=1 TO 50:NEXT X:PRINT DC$+CHR$(21)+CHR$(60);EP$
  345. 3450    PRINT DC$+CHR$(21)+CHR$(60);"You're ";UY$;"EVEN!";UN$;EP$
  346. 3460    FOR X=1 TO 50:NEXT X:PRINT DC$+CHR$(21)+CHR$(60);EP$
  347. 3470 NEXT I
  348. 3480 RETURN 
  349. 3490 PRINT CLS$:INPUT"Do you really want to quit (Y or N)";X$
  350. 3500 IF LEFT$(X$,1)="N" OR LEFT$(X$,1)="n" THEN GOTO 500
  351. 3510 PRINT CLS$
  352. 3520 SYSTEM
  353. 3530 ' print blank card
  354. 3540 CLM=CLM+7
  355. 3550 PRINT DC$+CHR$(LN)+CHR$(32+CLM);NB$
  356. 3560 PRINT DC$+CHR$(LN+1)+CHR$(32+CLM);MD$
  357. 3570 PRINT DC$+CHR$(LN+2)+CHR$(32+CLM);MD$
  358. 3580 PRINT DC$+CHR$(LN+3)+CHR$(32+CLM);MD$
  359. 3590 PRINT DC$+CHR$(LN+4)+CHR$(32+CLM);NB$
  360. 3600 RETURN 
  361. 3610 ' print cards
  362. 3620 GOSUB 3530
  363. 3630 PRINT DY$
  364. 3640 PRINT DC$+CHR$(LN+1)+CHR$(CLM+33);NMB$;SUT$
  365. 3650 PRINT DC$+CHR$(LN+3)+CHR$(CLM+32+(4-LEN(NMB$)));NMB$;SUT$
  366. 3660 PRINT DC$+CHR$(16)+CHR$(32);
  367. 3670 PRINT DN$;
  368. 3680 IF P=2 THEN PRINT "Your total is ";T[P];EP$
  369. 3690 RETURN
  370.