home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 210 / 210.d81 / tw.game (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  16KB  |  403 lines

  1. 100 rem trail west game
  2. 110 rem and window magic routines
  3. 120 rem trail west copyright 1987
  4. 130 rem window magic copyright 1986
  5. 140 rem by richard f. daley
  6. 150 rem
  7. 160 rem may be copied for personal use only
  8. 170 rem any form of sale or distribution
  9. 180 rem without permission is forbidden.
  10. 190 rem
  11. 200 poke 53280,13: poke 53281,11: sys 14848: a=rnd(rnd(-ti))
  12. 210 rem
  13. 220 rem *** initialization segment ***
  14. 230 rem
  15. 240 print "[147]";chr$(142);chr$(8): gosub 3930
  16. 250 dim bd%(10,13),cc(5),sh%(5,4),nm$(5),pn$(4),s(5),sp%(5),as%(5)
  17. 260 dim xb%(4,5),yb%(4,5),pc%(10,13),bc%(8)
  18. 270 for i=1 to 5
  19. 280 for j=1 to 4: sh%(i,j)=0: xb%(j,i)=-1: yb%(j,i)=-1: next j
  20. 290 ts(i)=0: sp%(i)=100: as%(i)=0: cc(i)=6000: next i
  21. 300 nm$(1)="[150]apache courier ltd": nm$(2)="[156]buffalo freight"
  22. 310 nm$(3)="[152]canyon shipping co": nm$(4)="[154]denver stage inc"
  23. 320 nm$(5)="[153]eldorado express": (NULL)
  24. 330 ex$(1)="[150]aph": ex$(2)="[156]buf": ex$(3)="[152]cny": ex$(4)="[154]dnv": ex$(5)="[153]eld"
  25. 340 tk$="[146].[146]+[158][146][218][150]a[156]b[152]c[154]d[153]e": sp=0
  26. 350 cd$=""
  27. 360 jy$="[158][213][195][195][195][201][157][157][157][157][157][194][194][157][157][157][157][157][202][195][195][195][203]"
  28. 370 bj$="[158]     [157][157][157][157][157]  [157][157][157][157][157]     "
  29. 380 bl$="                                 ": bl$=bl$+bl$
  30. 390 for i=1 to 9: for j=1 to 12: pc%(i,j)=0
  31. 400 if int(rnd(1)*20)+1<>10 then bd%(i,j)=1: goto 420
  32. 410 bd%(i,j)=3
  33. 420 next j,i: (NULL)(4,5,5,23): (NULL)(1,15,0,32,20,20)
  34. 430 t$="[150]plug a joystick into port 2, then press"
  35. 440 t$=t$+chr$(13)+"fire[146] to continue."
  36. 450 (NULL)(1,t$)
  37. 460 jv=peek(56320): fb=(jv and 16): if fb then 460
  38. 470 (NULL)(3)
  39. 480 (NULL)(13,9,4,20): (NULL)(1,14,0,32,20,20)
  40. 490 t$="[159]how many players are there (2-4)?": (NULL)(1,t$): pl=2
  41. 500 print left$(cd$,16);tab(26);pl
  42. 510 for i3=1 to 50: next i3
  43. 520 jv=peek(56320): fb=(jv and 16): jy=15-(15 and jv)
  44. 530 if fb=0 then 590
  45. 540 if jy=1 then pl=pl+1
  46. 550 if jy=2 then pl=pl-1
  47. 560 if pl<2 then pl=4
  48. 570 if pl>4 then pl=2
  49. 580 goto 500
  50. 590 print "[147][158]"
  51. 600 get a$: if a$<>"" then 600
  52. 610 for i=1 to pl: print
  53. 620 print "player";i;: input "what is your name    [157][157][157][157]";pn$(i)
  54. 630 next i: print "now i[146] will decide who will go first..."
  55. 640 ma=80-(pl=3)
  56. 650 for i3=1 to 100: j3=j3+1: next i3
  57. 660 i=int(pl*rnd(1)+1): print pn$(i);" is the first player to move."
  58. 670 for i3=1 to 500: j3=j3+1: next i3
  59. 680 mv=0: (NULL): print "[147]": gosub 2190
  60. 690 ps=3000
  61. 700 p=i: goto 790
  62. 710 rem
  63. 720 rem *** main game loop ***
  64. 730 rem
  65. 740 mv=mv+1: if mv=ma then 3780
  66. 750 p=p+1: if p=pl+1 then p=1
  67. 760 rem
  68. 770 rem *** select playing pieces ***
  69. 780 rem
  70. 790 for i3=1 to 5
  71. 800 if yb%(p,i3)>0 then if xb%(p,i3)>0 then 880
  72. 810 y%=9*rnd(1)+1: x%=12*rnd(1)+1
  73. 820 if pc%(y%,x%)=1 then 810
  74. 830 for i1=i3-1 to 0 step-1
  75. 840 if y%=yb%(p,i1) then if x%=xb%(p,i1) then i1=0: next i1: goto 810
  76. 850 next i1
  77. 860 if bd%(y%,x%)>1 then 810
  78. 870 pc%(y%,x%)=1: yb%(p,i3)=y%: xb%(p,i3)=x%
  79. 880 next i3
  80. 890 rem
  81. 900 rem *** get player move ***
  82. 910 rem
  83. 920 for i3=1 to 5: mv%(i3)=0: next i3: ap=0
  84. 930 print left$(cd$,24);"";pn$(p);", your move.         ": jy=1
  85. 940 t$=chr$(13)+"[159]":for i=1 to 5
  86. 950 t$=t$+str$(yb%(p,i))+" "+chr$(64+xb%(p,i))+chr$(13)+chr$(13)
  87. 960 next i: t$=t$+" stk"+chr$(13)+chr$(13)+" cal"
  88. 970 if ap=1 then t$=t$+chr$(13)+chr$(13)+" pas"
  89. 980 (NULL)(4,31,(17+2*ap),8): (NULL)(0,1,42,32,5,5)
  90. 990 (NULL)(1,t$)
  91. 1000 print left$(cd$,6+2*(jy-1));tab(32);jy$
  92. 1010 jv=peek(56320): fb=(jv and 16): jv=15-(jv and 15)
  93. 1020 if fb=0 then 1140
  94. 1030 if jv=1 or jv=2 then 1050
  95. 1040 goto 1010
  96. 1050 print left$(cd$,6+2*(jy-1));tab(32);bj$
  97. 1060 if jv=1 then jy=jy-1
  98. 1070 if jv=2 then jy=jy+1
  99. 1080 if jy<1 then jy=7+ap
  100. 1090 if jy>(7+ap) then jy=1
  101. 1100 goto 1000
  102. 1110 rem
  103. 1120 rem *** perform selected move ***
  104. 1130 rem
  105. 1140 (NULL)(3)
  106. 1150 if jy=6 then gosub 3100: goto 930
  107. 1160 if jy=7 then 3300
  108. 1170 if ap=1 then if jy=8 then 3510
  109. 1180 r=yb%(p,jy): c=xb%(p,jy)
  110. 1190 a1=bd%(r-1,c): a2=bd%(r+1,c): a3=bd%(r,c+1): a4=bd%(r,c-1)
  111. 1200 for i1=1 to 5: if as%(i1)=0 then i1=5: next i1: goto 1310
  112. 1210 next i1
  113. 1220 if a1>3 or a2>3 or a3>3 or a4>3 then 1310
  114. 1230 if a1=2 then if a2<4 then if a3<4 then if a4<4 then 3430
  115. 1240 if a2=2 then if a1<4 then if a3<4 then if a4<4 then 3430
  116. 1250 if a3=2 then if a1<4 then if a2<4 then if a4<4 then 3430
  117. 1260 if a4=2 then if a1<4 then if a2<4 then if a3<4 then 3430
  118. 1270 if a1=3 then if a2<4 then if a3<4 then if a4<4 then 3430
  119. 1280 if a2=3 then if a1<4 then if a3<4 then if a4<4 then 3430
  120. 1290 if a3=3 then if a1<4 then if a2<4 then if a4<4 then 3430
  121. 1300 if a4=3 then if a1<4 then if a2<4 then if a3<4 then 3430
  122. 1310 yb%(p,jy)=-1: xb%(p,jy)=-1
  123. 1320 if a1>1 then 1340
  124. 1330 if a2<=1 then if a3<=1 then if a4<=1 then bd%(r,c)=2: goto 1690
  125. 1340 if a1=<3 then 1380
  126. 1350 if a2>3 then if a2<>a1 then gosub 2340
  127. 1360 if a3>3 then if a3<>a1 then gosub 2340
  128. 1370 if a4>3 then if a4<>a1 then gosub 2340
  129. 1380 if a2>3 then if a3>3 then if a3<>a2 then gosub 2340
  130. 1390 if a2>3 then if a4>3 then if a4<>a2 then gosub 2340
  131. 1400 if a3>3 then if a4>3 then if a4<>a3 then gosub 2340
  132. 1410 if a1<4 then if a2<4 then if a3<4 then if a4<4 then 1490
  133. 1420 if bd%(r,c)>3 then 1690
  134. 1430 if a1>3 then i=a1-3
  135. 1440 if a2>3 then i=a2-3
  136. 1450 if a3>3 then i=a3-3
  137. 1460 if a4>3 then i=a4-3
  138. 1470 bd%(r,c)=i+3
  139. 1480 as%(i)=as%(i)+1: sp%(i)=sp%(i)+100: goto 1540
  140. 1490 for i=1 to 5: if as%(i)=0 then 1510
  141. 1500 next i: if bd%(r,c)<3 then bd%(r,c)=2: gosub 2190: goto 1730
  142. 1510 t$="a new shipping company has been formed! "
  143. 1520 t$=t$+"it's name is "+chr$(13)+"   "+nm$(i)
  144. 1530 sh%(i,p)=sh%(i,p)+5: as%(i)=1: hs=1
  145. 1540 if a1=3 then sp%(i)=sp%(i)+500
  146. 1550 if a2=3 then sp%(i)=sp%(i)+500
  147. 1560 if a3=3 then sp%(i)=sp%(i)+500
  148. 1570 if a4=3 then sp%(i)=sp%(i)+500
  149. 1580 if a1=2 then sp%(i)=sp%(i)+100: as%(i)=as%(i)+1: bd%(r-1,c)=i+3
  150. 1590 if a2=2 then sp%(i)=sp%(i)+100: as%(i)=as%(i)+1: bd%(r+1,c)=i+3
  151. 1600 if a3=2 then sp%(i)=sp%(i)+100: as%(i)=as%(i)+1: bd%(r,c+1)=i+3
  152. 1610 if a4=2 then sp%(i)=sp%(i)+100: as%(i)=as%(i)+1: bd%(r,c-1)=i+3
  153. 1620 if sp%(i)>=ps then t1=i: gosub 2970
  154. 1630 bd%(r,c)=i+3: as%(i)=as%(i)+1: gosub 2190: (NULL)
  155. 1640 if hs=1 then hs=0: gosub 3710
  156. 1650 if sp=0 then 1730
  157. 1660 print left$(cd$,23);tab(4);"[153]press fire[146] to continue.": sp=0
  158. 1670 jv=peek(56320): fb=(jv and 16): if fb then 1670
  159. 1680 (NULL)(3): goto 1730
  160. 1690 gosub 2190
  161. 1700 rem
  162. 1710 rem *** check for stock buys ***
  163. 1720 rem
  164. 1730 for i=1 to 5: cc(p)=cc(p)+int(.05*sh%(i,p)*sp%(i)): next i
  165. 1740 t=0: for i=0 to 5: t=t+as%(i): next i
  166. 1750 if t=0 then 740
  167. 1760 t$="[159]purch"+chr$(13): for i=1 to 5
  168. 1770 t$=t$+" "+ex$(i)+chr$(13)+chr$(13)
  169. 1780 next i: t$=t$+" [155]stk"+chr$(13)+chr$(13)+" end"
  170. 1790 (NULL)(4,31,18,8): (NULL)(1,13,0,32,5,5)
  171. 1800 (NULL)(1,t$): jy=1
  172. 1810 print left$(cd$,7+2*(jy-1));tab(32);jy$
  173. 1820 jv=peek(56320): fb=(jv and 16): jv=15-(jv and 15)
  174. 1830 if fb=0 then 1920
  175. 1840 if jv=1 or jv=2 then 1860
  176. 1850 goto 1820
  177. 1860 print left$(cd$,7+2*(jy-1));tab(32);bj$
  178. 1870 if jv=1 then jy=jy-1
  179. 1880 if jv=2 then jy=jy+1
  180. 1890 if jy<1 then jy=7
  181. 1900 if jy>7 then jy=1
  182. 1910 goto 1810
  183. 1920 if jy=6 then gosub 3100: goto 1810
  184. 1930 if jy=7 then: (NULL)(3): goto 740
  185. 1940 if as%(jy)=0 then: (NULL)(3): goto 1760
  186. 1950 t$="[155]how many shares of "+nm$(jy)
  187. 1960 mx=int(cc(p)/sp%(jy)): t1$=str$(mx): t1$=right$(t1$,len(t1$)-1)
  188. 1970 t$=t$+"[155] to buy? (max ="+t1$+")"+chr$(13)
  189. 1980 t$=t$+"your cash $"+str$(cc(p))+chr$(13)+"?[154]"
  190. 1990 (NULL)(16,6,7,22): (NULL)(1,5,0,32,1,1)
  191. 2000 (NULL)(1,t$)
  192. 2010 ct=0
  193. 2020 print left$(cd$,22);tab(8);ct;"[157]   "
  194. 2030 jv=peek(56320): fb=(jv and 16): jv=15-(jv and 15)
  195. 2040 if fb=0 then 2120
  196. 2050 if jv=1 or jv=2 then 2070
  197. 2060 goto 2030
  198. 2070 if jv=1 then ct=ct+1
  199. 2080 if jv=2 then ct=ct-1
  200. 2090 if ct<0 then ct=mx
  201. 2100 if ct>mx then ct=0
  202. 2110 goto 2020
  203. 2120 sh%(jy,p)=sh%(jy,p)+ct: cc(p)=cc(p)-(ct*sp%(jy))
  204. 2130 (NULL)(3)
  205. 2140 jv=peek(56320): fb=(jv and 16): if fb=0 then 2140
  206. 2150 goto 1810
  207. 2160 rem
  208. 2170 rem *** screen update routine ***
  209. 2180 rem
  210. 2190 if wn=3 then 2250
  211. 2200 print "[147][155]";tab(15);"trail west"
  212. 2210 (NULL)(3,3,14,29): (NULL)(1,14,0,32,5,5): wn=3
  213. 2220 t$="      map of the west "+chr$(13)
  214. 2230 t$=t$+"