home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1994 November / 1994-11b.d64 / find-a-word (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  14KB  |  376 lines

  1. 10 rem: copyright 1994 compute publications intl ltd - all rights reserved
  2. 20 clr:tp$="123456789012345":tp$=tp$+tp$:rl=30
  3. 30 l=peek(46)*256+peek(45)+2:hb=peek(l+2):lb=peek(l+1):tp=hb*256+lb
  4. 40 bc=53280:sc=53281:cc=646:sb=53265:vp=781:hp=782:pl=65520:sd=54272:dv=8
  5. 50 gosub2580
  6. 60 dimm$(20,20),w$(20),lx(20),ly(20),tw(20),h1(12),h2(12),l1(12),l2(12),lw(20)
  7. 70 dimcv(6),cd$(6),ch$(6),pw$(11),pt$(11),dp$(9),pr$(9)
  8. 80 nu$=" 1 2 3 4 5 6 7 8 91011121314151617181920"
  9. 90 pr$(0)="4":pr$(1)="27,64":pr$(2)="27,69":pr$(3)="27,77":pr$(4)="27,87,1"
  10. 100 pr$(5)="12"
  11. 110 sz=20:forr=1to8:readxd(r),yd(r):next:forr=828to912:readd:poker,d:next
  12. 120 forr=1to12:readh1(r):readl1(r):readh2(r):readl2(r):next
  13. 130 forr=0to34:readd:poke679+r,d:next
  14. 140 forr=0to6:readcv(r):cd$(r)=chr$(cv(r)):next:forr=0to6:readch$(r):next
  15. 150 poke826,24:poke827,96:fort=1to2000:next
  16. 160 :
  17. 170 print"[147]":pokesc,15:co=6:v=9:mg=2:wd=34:ht=5:gosub2540
  18. 180 pokevp,11:pokehp,4:syspl
  19. 190 print"[144]do you need playing instructions":print:printtab(17)"(y/n)[144]"
  20. 200 getd$:ifd$="n"then370
  21. 210 ifd$<>"y"then200
  22. 220 print"[147]":pokevp,1:pokehp,9:syspl:print"[162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162]"
  23. 230 printtab(9)" playing instructions ":printtab(9)"[162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][162][144]"
  24. 240 print" you begin by selecting the number of"
  25. 250 print" words & the actual words to be used"
  26. 260 print" the computer then places the words in"
  27. 270 print" a numbered matrix for screen play"
  28. 280 print" all words will be straight lines; up"
  29. 290 print" down, forward, backward, & diagonally"
  30. 300 print" when prompted with row [144] and column[144]"
  31. 310 print" enter the row and column number of"
  32. 320 print" the first letter of each word found"
  33. 330 print" to win you must find all words in the"
  34. 340 print" allotted time you select"
  35. 350 printtab(14)"good luck!!!":printtab(7)"[144]press any key to continue"
  36. 360 getd$:ifd$=""then360
  37. 370 print"[147]":pokesc,15:co=6:v=1:mg=1:wd=36:ht=21:gosub2540
  38. 380 print""tab(17)"[144]select":printtab(8)"desired number of words"
  39. 390 printtab(7)"minimum 10 -/- maximum 20"
  40. 400 print"[144]10 to 15 makes for the best play"
  41. 410 co=2:v=8:mg=17:wd=4:ht=1:gosub2540:pokecc,0
  42. 420 v=9:h=19:le=2:m=0:cl=0:gosub2670:wt=val(tp$)
  43. 430 ifwt<10orwt>20thenpokevp,9:pokehp,19:syspl:print"  ":goto420
  44. 440 printtab(10)"you have selected"wt:
  45. 450 printtab(9)"is this correct? (y/n)"
  46. 460 print:printtab(7)"[144]for an interesting game and"
  47. 470 printtab(9)"an additional challenge":
  48. 480 printtab(5)"enter numbers instead of words"
  49. 490 getd$:ifd$="n"then370
  50. 500 ifd$<>"y"then490
  51. 510 print"[147]":co=6:v=2:mg=5:wd=28:ht=3:gosub2540
  52. 520 print"":printtab(9)"[144]please enter words now"
  53. 530 printtab(8)"minimum length 5[144] letters"
  54. 540 printtab(8)"[144]maximum length 15[144] letters"
  55. 550 poke198,0:co=2:v=7:mg=10:wd=18:ht=1:gosub2540:fori=1towt:w$(i)=""
  56. 560 pokecc,0:pokevp,8:pokehp,11:syspl:print"                  "
  57. 570 v=8:h=12:le=15:m=1:cl=0:gosub2670:iflen(tp$)<5then560
  58. 580 w$(i)=tp$:forj=0toi-1:ifw$(i)=w$(j)thenw$(i)="":goto560
  59. 590 next:x=10:ifi=>10thenx=9
  60. 600 ifwt>10then620
  61. 610 pokevp,10+i:pokehp,x:syspl:printi"[157]. "w$(i):goto650
  62. 620 ifi>10then640
  63. 630 pokevp,10+i:pokehp,x-9:syspl:printi"[157]. "w$(i):goto650
  64. 640 pokevp,i:pokehp,10+x:syspl:printi"[157]. "w$(i)
  65. 650 next:pokevp,22:pokehp,8:syspl:print"[144]is this correct? (y/n)[144]"
  66. 660 getd$:ifd$="n"then510
  67. 670 ifd$<>"y"then660
  68. 680 :
  69. 690 print"[147]":pokesc,15:co=6:v=9:mg=2:wd=34:ht=5:gosub2540
  70. 700 pokevp,11:pokehp,4:syspl
  71. 710 print"[144]do you wish to print the matrix?":print:printtab(17)"(y/n)":pr=0
  72. 720 getd$:ifd$="y"thenpr=1:ta$="00:00":goto750
  73. 730 ifd$<>"n"then720
  74. 740 gosub2270
  75. 750 print"[147]":pokesc,14:co=1:v=10:mg=1:wd=36:ht=3:gosub2540
  76. 760 pokevp,12:pokehp,2:syspl:print"building matrix...one moment please."
  77. 770 fori=1to1500:next:pokesb,peek(sb)and239
  78. 780 print"[147]":co=0:v=2:mg=2:wd=20:ht=20:gosub2540
  79. 790 pokevp,0:pokehp,3:syspl:print"         11111111112"
  80. 800 print"   12345678901234567890":print""
  81. 810 fori=1to39step2:printmid$(nu$,i,2):next:print
  82. 820 gosub2820:gp=wt
  83. 830 gp=int(gp/2):ifgp=0then900
  84. 840 f=0
  85. 850 form=1to(wt-gp):iflen(w$(m))>=len(w$(m+gp))then870
  86. 860 sw$=w$(m):w$(m)=w$(m+gp):w$(m+gp)=sw$:f=1
  87. 870 next:iffthen840
  88. 880 goto830
  89. 890 :
  90. 900 fori=1tosz:forj=1tosz:m$(i,j)=" ":next:next:forr=1towt:lw(r)=0:next
  91. 910 fori=1towt:d=int(8*rnd(1))+1:le=len(w$(i))
  92. 920 hz=int(sz*rnd(1))+1:vt=int(sz*rnd(1))+1
  93. 930 ifhz+le*xd(d)<0orhz+le*xd(d)>szorvt+le*yd(d)<0orvt+le*yd(d)>szthen920
  94. 940 forx=0tole-1:t$=mid$(w$(i),x+1,1)
  95. 950 ifm$(hz+x*xd(d),vt+x*yd(d))<>" "andt$<>m$(hz+x*xd(d),vt+x*yd(d))then920
  96. 960 next:forx=0tole-1
  97. 970 m$(hz+x*xd(d),vt+x*yd(d))=mid$(w$(i),x+1,1):next
  98. 980 lx(i)=hz:ly(i)=vt:tw(i)=d
  99. 990 pokevp,2+i:pokehp,24:syspl:printw$(i):next
  100. 1000 fori=1to20:forj=1to20
  101. 1010 ifm$(i,j)=" "thenm$(i,j)=mid$(w$(wt*rnd(1)+1),5*rnd(1)+1,1)
  102. 1020 pokevp,i+2:pokehp,j+2:syspl:printm$(i,j):next:next:pokesc,15:pokecc,0
  103. 1030 :
  104. 1040 ifprthen1570
  105. 1050 ifsp=1thengosub2820
  106. 1060 pokesb,peek(sb)or16
  107. 1070 gosub2860:po=0:ti$="000000":ge=0:sys828
  108. 1080 sys848:ifti$=>gt$then1360
  109. 1090 gosub2850:print"row    [157][157][157][157][157][157]":v=1:h=32:le=2:m=0:cl=1:gosub2670
  110. 1100 r=val(tp$):ifr=99then1390
  111. 1110 ifr<1orr>20then1080
  112. 1120 gosub2860
  113. 1130 sys848:ifti$=>gt$then1360
  114. 1140 gosub2850:print"col    [157][157][157][157][157][157]":gosub2670
  115. 1150 c=val(tp$):ifc<1orc>20then1130
  116. 1160 gosub2860
  117. 1170 sys848:ifti$=>gt$then1360
  118. 1180 cg=0:forj=1towt:ifr=lx(j)thenifc=ly(j)thencg=1:xf=j:lw(j)=1:sys848
  119. 1190 next:ifcg=1thengosub2800:goto1220
  120. 1200 gosub2850:print"wrong":sys848:fork=1to500:sys848:next
  121. 1210 gosub2860:goto1080
  122. 1220 forj=0tolen(w$(xf))-1:xc=(3+lx(xf)+j*xd(tw(xf))):yc=(2+ly(xf)+j*yd(tw(xf)))
  123. 1230 pokevp,xc-1:pokehp,yc:syspl:print""m$(xc-3,yc-2)"[144]":next
  124. 1240 pokevp,2+xf:pokehp,24:syspl:print""w$(xf)"[144]"
  125. 1250 wc=wc+1:ifwc=wtthen1270
  126. 1260 goto1080
  127. 1270 ifge<>0then1360
  128. 1280 fort=1to1000:next:print"[147]":pokesc,14:pokecc,1
  129. 1290 co=1:v=7:mg=2:wd=34:ht=9:gosub2540
  130. 1300 pokevp,9:pokehp,4:syspl:print"congratulations you're a winner!"
  131. 1310 pokesd+5,85:pokesd+6,85:pokesd+12,85:pokesd+13,85:pokesd+24,15
  132. 1320 pokesd+4,33:pokesd+11,17:forx=1to12:pokesd,l1(x):pokesd+1,h1(x)
  133. 1330 pokesd+7,l2(x):pokesd+8,h2(x):ifh1(x)=50thenfort=1to200:next
  134. 1340 ifx=6thenfort=1to1000:next
  135. 1350 fort=1to200:next:next:ford=0to24:pokesd+d,0:next:goto1470
  136. 1360 gosub2850:print"time's up[144]"
  137. 1370 forj=sdtosd+23::pokej,0:next:pokesd+24,15:pokesd,169:pokesd+6,240
  138. 1380 pokesd+1,6:pokesd+4,17:ford=0to1499:next:pokesd+4,16
  139. 1390 fori=1towt
  140. 1400 forj=0tolen(w$(i))-1:xc=(3+lx(i)+j*xd(tw(i))):yc=(2+ly(i)+j*yd(tw(i)))
  141. 1410 iflw(i)=0thenpokevp,xc-1:pokehp,yc:syspl:print""m$(xc-3,yc-2)
  142. 1420 next:next
  143. 1430 pokevp,24:pokehp,0:syspl:print"       [144]press any key to continue       ";
  144. 1440 poke198,0:wait198,1:poke198,0:print"[147]":pokesc,14:pokecc,1
  145. 1450 co=1:v=8:mg=2:wd=34:ht=7:gosub2540
  146. 1460 pokevp,9:pokehp,5:syspl:print"sorry...better luck next time!
  147. 1470 [151]vp,11:[151]hp,5:[158]pl:[153]"would you like to play again?"
  148. 1480 [153][163]17)"(y/n)"
  149. 1490 [161]d$:[139]d$[178]"n"[167][158]64738
  150. 1500 [139]d$[178]"y"[167]wc[178]0:[137]1520
  151. 1510 [137]1490
  152. 1520 [153]:[153][163]10)"use the same words?":[153][163]17)"(y/n)
  153. 1530 getd$:ifd$="y"then740
  154. 1540 ifd$="n"then370
  155. 1550 goto1530
  156. 1560 :
  157. 1570 gosub2880
  158. 1580 print"[147]":pokesc,14:pokecc,1:pokesb,peek(sb)or16:pr=0
  159. 1590 co=1:v=6:mg=5:wd=28:ht=13:gosub2540:
  160. 1600 pokesc,14:pokevp,8:pokehp,14:syspl:print"do you want:"
  161. 1610 printtab(7)"1. use generic printer?"
  162. 1620 printtab(7)"2. print normal width?"
  163. 1630 printtab(7)"3. print expanded width?"
  164. 1640 printtab(7)"4. modify printer driver?"
  165. 1650 printtab(7)"5. return to beginning?":poke198,0
  166. 1660 getd$:ifd$<"1"ord$>"5"then1660
  167. 1670 pf=val(d$):onpfgoto1830,1680,1680,2910,170
  168. 1680 open15,8,15,"i0:":close15:gosub3440:ifflthen1580
  169. 1690 sys57812"wpd.*",8,1:poke780,0:poke781,1:poke782,8:sys65493
  170. 1700 gosub3460:ifflthen1580
  171. 1710 ife1<>62then1760
  172. 1720 print"[147]":sys826:v=8:mg=4:wd=30:ht=7:gosub2540
  173. 1730 pokevp,10:pokehp,6:syspl:print"no printer driver was found"
  174. 174