home *** CD-ROM | disk | FTP | other *** search
/ The Commodore Format PowerPacks 30 / Commodore_Format_PowerPacks_The_30_19xx_Future_GB.d64 / blackjack (.txt) next >
Commodore BASIC  |  2022-10-26  |  8KB  |  407 lines

  1. 1 goto910
  2. 5 rem ** blackjack from the public domain with chages made for the c64 by
  3. 6 rem ** ken jirele and fred layberger, omaha nebraska
  4. 10 rem **general input routine **
  5. 15 :
  6. 30 :
  7. 35 rem +++ input section +++
  8. 40 pokeuo,0:ur$="":ui$=""
  9. 42 iful=0thenul=80
  10. 45 pokeuc,0
  11. 50 getui$:ifui$=""then50
  12. 55 ifui$=chr$(13)andlen(ur$)>=1thenpokeuc,1:print" [157]";:goto120
  13. 60 ifui$=chr$(20)then105
  14. 62 if len(ur$)=>ulthen50
  15. 65 gosub120:rem check for valid character
  16. 70 ur$=ur$+ui$
  17. 75 printui$;
  18. 80 goto50
  19. 102 rem ++ check delete ++
  20. 105 iflen(ur$)<1then50
  21. 110 ur$=left$(ur$,len(ur$)-1)
  22. 115 print"[157]  [157][157]";:goto50
  23. 120 rem ++ check for valid characters ++
  24. 125 iflen(us$)=0then150
  25. 130 forus=1tolen(us$)
  26. 135 ifui$=mid$(us$,us,1)thenreturn
  27. 140 next
  28. 145 ui$="":return
  29. 150 rem ** standard input **
  30. 152 ifasc(ui$)=46thenreturn
  31. 155 ifui$=chr$(32)thenreturn
  32. 160 ifasc(ui$)<48orasc(ui$)>57then170
  33. 165 return
  34. 170 ifasc(ui$)<65orasc(ui$)>90then180
  35. 175 return
  36. 180 ifasc(ui$)<193orasc(ui$)>218thenui$="":return
  37. 185 ifpeek(ut)=ul%thenui$=chr$(asc(ui$)-128):return
  38. 187 return
  39. 190 ui$="":return
  40. 216 goto300
  41. 217 uz=0:us$=uj$:ug$=uk$:up=uj:ul=uk:ifpeek(50003)=0thenpoke53281,6:poke53280,14
  42. 220 print"[147]";:pokeut,uv%:foruq=ubto(u2%*256+u1%+u3%-3)
  43. 225 pokeuq,uq%(uq-ub):next
  44. 230 pokeu1,u1%
  45. 232 pokeu2,u2%
  46. 233 pokeu4,u4%
  47. 234 pokeu3,u3%-1
  48. 235 goto35
  49. 300 rem ** menu **
  50. 301 :
  51. 302 print"[147][144]":pokeut,uu%:ifpeek(50003)=0thenpoke53281,15:poke53280,0
  52. 303 :
  53. 305 print"                menu"
  54. 310 print" --------------------------------------"
  55. 315 print"       1.   begin blackjack"
  56. 320 print"       2.   instructions"
  57. 335 print"       3.   quit"
  58. 340 print" --------------------------------------"
  59. 345 print"       press a number key (1-3) ";
  60. 350 ul=1:us$="123":gosub35:rem input routine
  61. 352 us$=""
  62. 355 onval(ur$)gosub1000,400,396
  63. 360 goto300
  64. 395 rem ** re-enable stop key and end **
  65. 396 clr:end
  66. 400 rem ** student instructions **
  67. 405 print"[147]":pokeut,ul%:ifpeek(50003)=0thenpoke53281,15:poke53280,0
  68. 410 up=0:ug$="[211]tudent [201]nst":gosub850
  69. 413 print"    [212]his game simulates the game of
  70. 415 [153]"    blackjack.":[153]"    (NULL)ou must get up to 21 in less"
  71. 420 [153]"    than 5 cards. (NULL)ou can bet on"
  72. 422 [153]"    your hand. right$f you lose, your bet"
  73. 425 [153]"    is deducted from your total":[153]"    earnings."
  74. 426 [141]835:[141]850
  75. 427 [153]"    (NULL)ou may decide if you want"
  76. 430 [153]"    another card each time.  right$f you"
  77. 431 [153]"    want to double your bet when you"
  78. 433 [153]"    are in the middle of a hand, the"
  79. 435 [153]"    computer will give you another "
  80. 436 [153]"    card and double your bet."
  81. 437 [141]835:[141]850
  82. 438 [153]"    (NULL)o double betwait:  type  d <return>"
  83. 440 [153]"    left$ouse limit on each betwait:":[153][163]26)"$25,000.00"
  84. 485 [141]835
  85. 490 [139]uz[178]1[167][158]up%:[137]217
  86. 499 [142]
  87. 835 [143] ** space bar press **
  88. 840 [151]uo,0:[153][200](ud$,24);"press space bar to continuewait"
  89. 844 [161]ui$:[139]ui$[179][177]" "[167]844
  90. 846 [142]
  91. 850 [143] ** page design routine **
  92. 852 up[178]up[170]1
  93. 853 [139][194](ut)[178]ul%[167]855
  94. 854 ut$[178]" blackjack":ug$[178]"blackjack":[137]857
  95. 855 ut$[178]" peek(NULL)atnlen(NULL)mid$atnlen(NULL)"
  96. 857 [153]"load"[200](ut$[170]up$,21);[201](up$[170]ug$[170][196](up),18)
  97. 860 [153]" --------------------------------------"
  98. 864 [139]uh[179][177]0[167]870
  99. 865 [153][200](ud$,24);[200](up$,6);"to exit game press  qwait ."
  100. 870 uh[178]0:[153]"":[142]
  101. 875 [143] ** please wait remark **
  102. 880 [153][200](ud$,24);"           one moment please...     "
  103. 885 [142]
  104. 900 [143] ** set up variables **
  105. 901 ux$[178]"h":[134]uq%(1000):ub[178]32768:u1[178]196:u2[178]197:u3[178]198:u4[178]216:uc[178]167:uu[178]1024
  106. 902 ut[178]59468:uu%[178]12:ul%[178]14:up%[178]1146:um[178]32768:uo[178]158:[151] 50003,0
  107. 903 [139][194](50003)[178]0[167]ub[178]1024:u1[178]209:u2[178]210:u3[178]211:u4[178]214:uc[178]204:uu[178]2048
  108. 904 [139][194](50003)[178]0[167]ut[178]53272:uu%[178]21:ul%[178]23:up%[178]2139:um[178]1024:uo[178]198
  109. 905 ud$[178]""
  110. 906 up$[178]"                                       "
  111. 908 [142]
  112. 910 [143] ** set variables **
  113. 911 [134]c(52),p(10),d(10)
  114. 912 [134]s$(52),c$(52)
  115. 920 [141]900
  116. 980 [137]300:[143] menu
  117. 1000 [139]uz[178]1[167][158]up%:[158]up%:uz[178]0:[143] ** program starts here **
  118. 1001 [153]"load";:[140]:[139][194](50003)[178]0[167][151]53281,15:[151]53280,5
  119. 1070 s9$[178]"atn(NULL)(NULL)(NULL)"
  120. 1080 c8$[178]"23456789tjqka"
  121. 1090 c9$[178]" 2 3 4 5 6 7 8 91010101011"
  122. 1100 er$[178]"":[129]i[178]1[164]13:er$[178]er$[170]"   ":[130]
  123. 1110 [129]i[178]1[164]13:er$[178]er$[170]"cmdcmdcmd":[130]
  124. 1115 er$[178]er$[170]"   "
  125. 1120 dn$[178]""
  126. 1130 [143]
  127. 1170 [141]2260
  128. 1180 t[178]0
  129. 1190 j8[178]j
  130. 1200 [139]a9[179]4[167]1220
  131. 1210 [141]835:[141]2260
  132. 1220 [139]j[179]42[167]1240
  133. 1230 [141]835:[141]2260
  134. 1240 [153]dn$;er$"place your bet.      cmdcmdcmdcmdcmd";
  135. 1250 us$[178]"012345678910q":ul[178]5:[141]35:[139]ur$[178]"q"[167]2160
  136. 1260 b1[178][197](ur$):k$[178]b$
  137. 1270 [139]b1[178]0[167]1240
  138. 1280 [139]b1[177]0[167]1310
  139. 1290 [141]835:[141]2260
  140. 1300 b1[178][171]b1
  141. 1310 [139]b1[177][178]1[167]1340
  142. 1320 [153]er$"the minimum bet is $1"
  143. 1330 [137]1190
  144. 1340 [139]b1[179][178]25000[167]1380
  145. 1350 [139]m1[178]1[167]2950
  146. 1360 [153]er$:[153]er$:[153]er$"the limit per bet is $25,000."
  147. 1370 [137]1240
  148. 1380 p[178]0:d[178]0:p9[178]0:d9[178]0
  149. 1390 v[178]0
  150. 1400 h[178]0
  151. 1410 [141]850
  152. 1420 m1[178]1
  153. 1430 [141]2530
  154. 1440 [141]2650
  155. 1450 [141]3700
  156. 1460 j1[178]j
  157. 1470 m1[178]2
  158. 1480 [141]2530
  159. 1490 [141]2650
  160. 1500 [141]2860
  161. 1510 [139]p[178]21[167]1570
  162. 1520 [139]d[179]21[167]1650
  163. 1530 m1[178]1
  164. 1540 [141]2860
  165. 1550 [153]dn$""er$"dealer has a blackjack"
  166. 1560 [137]2060
  167. 1570 m1[178]1
  168. 1580 [141]2860
  169. 1590 [139]d[179]21[167]1620
  170. 1600 [153]dn$""er$"we both have blackjack"
  171. 1610 [137]2000
  172. 1620 [153]dn$""er$"you have a blackjack"
  173. 1630 b1[178]1.5[172]b1
  174. 1640 [137]2020
  175. 1650 [139]p[179]22[167]1710
  176. 1660 [153]dn$""er$"you have busted"
  177. 1665 [129]q[178]1[164]400:[130]q
  178. 1670 m1[178]1
  179. 1680 [141]2860
  180. 1690 m1[178]2
  181. 1700 [137]2060
  182. 1710 [139]v[178]0[167]1730
  183. 1720 [137]1870
  184. 1730 [153]dn$;er$"do want another card? ";
  185. 1760 us$[178]"yndq":ul[178]1:[141]35:a$[178]ur$
  186. 1765 [139]a$[178]"q"[167]2160
  187. 1770 [139]a$[178]"y"[167]1830
  188. 1780 [139]a$[178]"d"[167]1810
  189. 1800 [137]1870
  190. 1810 b1[178]2[172]b1
  191. 1820 v[178]1
  192. 1830 k$[178]b$
  193. 1840 m1[178]m1[170]1
  194. 1850 [141]2530
  195. 1860 [137]1650
  196. 1870 m1[178]1
  197. 1880 [141]2860
  198. 1890 m1[178]2
  199. 1900 [139]d[177]16[167]1950
  200. 1910 m1[178]m1[170]1
  201. 1920 [141]2650
  202. 1930 [141]2860
  203. 1940 [137]1900
  204. 1950 [139]d[179][178]21[167]1980
  205. 1960 [153]dn$""er$"dealer has broke--you win!":[141]3950
  206. 1970 [137]2030
  207. 1980 [139]d[179]p[167]2020
  208. 1990 [139]d[177]p[167]2060
  209. 2000 [153]dn$""er$"you pushed the dealer"
  210. 2010 [137]2080
  211. 2020 [153]dn$""er$"you win!":[141]3950
  212. 2030 t[178]t[170]b1
  213. 2040 [137]2080
  214. 2060 [153]dn$""er$"you loose!":[141]3900
  215. 2070 t[178]t[171]b1
  216. 2080 [139]t[177]0[167]2120
  217. 2090 [139]t[179]0[167]2140
  218. 2100 [153]"   you are even  "
  219. 2110 [137]1190
  220. 2120 [153]"   you are ahead $";t;
  221. 2130 [137]1190
  222. 2140 [153]"   you are down $";[171]t;
  223. 2150 [137]1190
  224. 2160 [141]850
  225. 2170 [139]t[178]0[167]2210
  226. 2180 [139]t[179]0[167]2230
  227. 2190 [153]dn$"     you have won  $";t;"cmd."
  228. 2200 [137]2250
  229. 2210 [153]dn$"            you broke even."
  230. 2220 [137]2250
  231. 2230 [153]dn$"       you lost  $";[171]t;"cmd."
  232. 2250 [141]835:[142]
  233. 2260 [143] *** shuffling routine
  234. 2270 [153]"load"dn$;er$"      i'm shuffling the cards."
  235. 2280 [129]i[178]1[164]4
  236. 2290 [129]j[178]1[164]13
  237. 2300 w1[178]13[172](i[171]1)[170]j
  238. 2305 [153][163]18)"on   cmdcmdcmd";65[171]i[172]13[171]j
  239. 2310 s$(w1)[178][202](s9$,i,1)
  240. 2320 c$(w1)[178][202](c8$,j,1)
  241. 2330 c(w1)[178][197]([202](c9$,2[172]j[171]1,2))
  242. 2340 [130]j
  243. 2350 [130]i
  244. 2360 [129]i[178]1[164]52
  245. 2365 [153][163]18)"on   cmdcmdcmd";i;"  "
  246. 2370 j[178]52[172][187](1)[170]1
  247. 2380 tt$[178]s$(i)
  248. 2390 s$(i)[178]s$(j)
  249. 2400 s$(j)[178]tt$
  250. 2410 tt$[178]c$(i)
  251. 2420 c$(i)[178]c$(j)
  252. 2430 c$(j)[178]tt$
  253. 2440 tt[178]c(i)
  254. 2450 c(i)[178]c(j)
  255. 2460 c(j)[178]tt
  256. 2470 [130]i
  257. 2480 a9[178]0
  258. 2490 j[178]0
  259. 2500 j1[178]2
  260. 2510 j8[178]0
  261. 2514 [141]850
  262. 2520 [142]
  263. 2530 j[178]j[170]1
  264. 2540 p(m1)[178]j
  265. 2550 [139]c(j)[179]11[167]2580
  266. 2560 p9[178]p9[170]1
  267. 2570 a9[178]a9[170]1
  268. 2580 p[178]p[170]c(j)
  269. 2590 [139]p[179]22[167]2630
  270. 2600 [139]p9[178]0[167]2630
  271. 2610 p[178]p[171]10
  272. 2620 p9[178]p9[171]1
  273. 2630 [153]dn$""
  274. 2640 [137]2890
  275. 2650 j[178]j[170]1
  276. 2660 d(m1)[178]j
  277. 2670 [139]c(j)[179]11[167]2700
  278. 2680 d9[178]d9[170]1
  279. 2690 a9[178]a9[170]1
  280. 2700 d[178]d[170]c(j)
  281. 2710 [139]d[179]22[167]2750
  282. 2720 [139]d9[178]0[167]2750
  283. 2730 d[178]d[171]10
  284. 2740 d9[178]d9[171]1
  285. 2750 [142]
  286. 2760 [129]i[178]1[164]52
  287. 2770 p(i)[178]0
  288. 2780 d(i)[178]0
  289. 2790 [130]i
  290. 2800 [142]
  291. 2810 [129]i[178]1[164]52
  292. 2820 [153]c$(i)[170]s$(i);
  293. 2830 [130]i
  294. 2840 [153]
  295. 2850 [142]
  296. 2860 p5[178]0
  297. 2870 [153]""
  298. 2880 [137]2900
  299. 2890 p5[178]1
  300. 2900 [129]l[178]1[164]8
  301. 2910 [139]m1[178]1[167]2950
  302. 2920 [129]i5[178]1[164]m1[171]1
  303. 2930 [153]"";
  304. 2940 [130]i5
  305. 2950 [139]p5[178]1[167]2980
  306. 2960 i[178]d(m1)
  307. 2970 [137]2990
  308. 2980 i[178]p(m1)
  309. 2990 [151]646,2
  310. 2995 [139]s$(i)[178]"atn"[176]s$(i)[178]"(NULL)"[167][151]646,0:[141]3800
  311. 2996 [139]s$(i)[178]"(NULL)"[176]s$(i)[178]"(NULL)"[167][151]646,2:[141]3850
  312. 3000 r[178]c(i)
  313. 3010 [139]l[177]1[167]3030
  314. 3020 [153]qq$;:[137]3660
  315. 3030 [139]l[177]2[167]3100
  316. 3040 [143]
  317. 3050 [139]c$(i)[178]"t"[167]3080
  318. 3060 [153]rr$;[201](c$(i),1);"    ";rr$;
  319. 3070 [137]3660
  320. 3080 [153]rr$;"10";"   ";rr$;
  321. 3090 [137]3660
  322. 3100 [139]l[177]3[167]3170
  323. 3110 [139]c(i)[179]11[167]3130
  324. 3120 [137]3590
  325. 3130 [139]c(i)[177]2[167]3150
  326. 3140 [137]3590
  327. 3150 [139]c(i)[177]3[167]3630
  328. 3160 [137]3610
  329. 3170 [139]l[177]4[167]3320
  330. 3180 [139]c(i)[179]11[167]3200
  331. 3190 [137]3610
  332. 3200 [139]c(i)[179]9[167]3220
  333. 3210 [137]3650
  334. 3220 [139]c(i)[177]3[167]3240
  335. 3230 [137]3610
  336. 3240 [139]c(i)[177]4[167]3260
  337. 3250 [137]3590
  338. 3260 [139]c(i)[177]5[167]3280
  339. 3270 [137]3610
  340. 3280 [139]c(i)[177]6[167]3300
  341. 3290 [137]3630
  342. 3300 [139]c(i)[177]7[167]3630
  343. 3310 [137]3610
  344. 3320 [139]l[177]5[167]3420
  345. 3330 [139]c(i)[179]11[167]3350
  346. 3340 [137]3590
  347. 3350 [139]c(i)[179]10[167]3370
  348. 3360 [137]3650
  349. 3370 [139]c(i)[179]6[167]3390
  350. 3380 [137]3630
  351. 3390 [139]c(i)[179]4[167]3410
  352. 3400 [137]3590
  353. 3410 [137]3610
  354. 3420 [139]l[177]6[167]3510
  355. 3430 [139]c(i)[179]11[167]3450
  356. 3440 [137]3590
  357. 3450 [139]c(i)[179]7[167]3470
  358. 3460 [137]3630
  359. 3470 [139]c(i)[178]4[167]3500
  360. 3480 [139]c(i)[178]5[167]3500
  361. 3490 [137]3590
  362. 3500 [137]3630
  363. 3510 [139]l[177]7[167]3580
  364. 3520 [153]rr$"  ";
  365. 3530 [139]c$(i)[178]"t"[167]3560
  366. 3540 [153]"  "[201](c$(i),1);rr$;
  367. 3550 [137]3660
  368. 3560 [153]" 10";rr$;
  369. 3570 [137]3660
  370. 3580 [153]ss$;:[137]3660
  371. 3590 [153]rr$"     "rr$;
  372. 3600 [137]3660
  373. 3610 [153]rr$"  ";s$(i);"  ";rr$;
  374. 3620 [137]3660
  375. 3630 [153]rr$" ";s$(i);" ";s$(i);" ";rr$;
  376. 3640 [137]3660
  377. 3650 [153]rr$" ";s$(i);s$(i);s$(i);" ";rr$;
  378. 3660 [153]
  379. 3670 [130]l
  380. 3680 [153]"":[153]
  381. 3690 [142]
  382. 3700 [153]""[170]qq$
  383. 3710 [153]rr$[166]5)rr$
  384. 3720 [153]rr$[170]"step  waitfn "[170]rr$
  385. 3730 [153]rr$[170]" wait   waitstep"[170]rr$
  386. 3740 [153]rr$[170]" wait   (NULL)wait"[170]rr$
  387. 3750 [153]rr$[170]"(NULL)  wait  "[170]rr$
  388. 3760 [153]rr$[166]5)rr$
  389. 3770 [153]ss$
  390. 3780 [142]
  391. 3800 qq$[178]"print#(NULL)lenlenlenlenlenright$stop"
  392. 3810 rr$[178]"print#peekstop"
  393. 3820 ss$[178]"print#mid$ascascascascasc(NULL)stop"
  394. 3830 [142]
  395. 3850 qq$[178]"print#(NULL)lenlenlenlenlenright$"
  396. 3860 rr$[178]"print#peek"
  397. 3870 ss$[178]"print#mid$ascascascascasc(NULL)"
  398. 3880 [142]
  399. 3900 [143] ** buzzer
  400. 3905 [151]54296,15:[151]54277,45:[151]54278,165
  401. 3910 [151]54276,33:[151]54273,6:[151]54272,5
  402. 3915 [129]tt[178]1[164]200:[130]:[151]54276,32:[151]54273,0:[151]54273,0:[151]54272,0:[142]
  403. 3950 [143] ** bell sound
  404. 3955 [151]54296,15:[151]54277,0:[151]54278,247
  405. 3960 [151]54276,17:[151]54273,40:[151]54272,0
  406. 3965 [129]tt[178]1[164]200:[130]:[151]54276,16:[151]54273,0:[151]54273,0:[151]54272,0:[142]
  407.