home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1994 May / 1994-05b.d64 / exponents (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  12KB  |  316 lines

  1. 5 rem copyright 1994 -compute publications intl ltd - all rights reserved
  2. 10 rem by robert quinn
  3. 20 gosub2760
  4. 30 getb$:js=peek(p6)andpeek(p7)andp8
  5. 40 pokevm+p(px),peek(vm+p(px))-n8:pokevm+p(px)-1,n2:pokevm+p(px)+1,n2
  6. 50 :
  7. 60 r=(js=30)+abs(js=29):ifr<>k0thenpx=px+r:px=px+(px=11)*ka-(px=k0)*ka
  8. 70 ifjs>kfandjs<28thenifpx<>k4andpx<>k6thengosub190
  9. 80 ifb$>"0"thenifb$<"7"thennc=val(b$)
  10. 90 ifb$="q"thennc=7
  11. 100 ifb$="w"thennc=8
  12. 110 ifb$="e"thennc=9
  13. 120 ifb$="t"thennc=10
  14. 130 if(js=kf)or(b$=b1$)thennc=px
  15. 140 ifnc>k0thenpx=nc
  16. 150 pokevm+p(px),peek(vm+p(px))+n8:pokevm+p(px)-k1,k0:pokevm+p(px)+k1,k0
  17. 160 ifnc>k0then220
  18. 170 ifb$>b1$thenifb$<>chr$(95)thengosub2940
  19. 180 forr=1to44:next:goto30
  20. 190 ifpx<k4thenpx=px+k6:return
  21. 200 ifpx>k6andpx<kathenpx=px-k6:return
  22. 210 px=px+(px=ka)*k5-(px=k5)*k5:return
  23. 220 forr=720+vmtor+39:poker,n2:next:poke829,11:sys828:poke53280,12:xf=k0
  24. 230 ifnc<>k1andnc<>k4thensys879
  25. 240 onncgosub270,1010,1010,270,1960,2330,830,1750,1750,1960
  26. 250 ifnc<>k1andnc<>k4andnc<>k6thensys879
  27. 260 nc=k0:poke53280,14:poke198,k0:goto30
  28. 270 bn=int(rnd(1)*ka)+n4:cn=int(rnd(k1)*ka)+n4:ifnc=k4thencn=int(rnd(k1)*9)+49
  29. 280 ifbn=peek(907)orcn=peek(908)then270
  30. 290 poke907,bn:poke908,cn:sys879
  31. 300 bn$=chr$(bn):sys856,ka,22:printkf$rn$bn$b1$b1$r1$;"="r1$;
  32. 310 ifnc=k6then360
  33. 320 printrf$r1$"power ";:ifnc=k4thenprint"-";
  34. 330 printchr$(cn)" of "bn$;:ifnc=k4then360
  35. 340 ifcn=51thenprintr1$r2$"[cube]";
  36. 350 ifcn=50thenprintr1$r2$"[square]";
  37. 360 sys856,ka,21:printrn$b1$;:ifnc=k4thenprint"-";
  38. 370 printchr$(cn);:ifnc=k1ornc=6thenprintb1$;
  39. 380 ifnc=6then440
  40. 390 printr2$r2$rf$;:forr=1to2222:next:ifnc=k4thenprint"-";
  41. 400 printchr$(cn);" is the exponent"
  42. 410 forr=1to2222:next:print"base "bn$;
  43. 420 forr=1to2222:next:ifcn=n4thenbn=49
  44. 430 forr=856tor+23:poker+vm,0:poker+vn,11:poker+40+vm,0:poker+40+vn,11:next
  45. 440 dx=17:sys856,16,22:printrn$;
  46. 450 ifnc=k4thendx=21:print"1 / ";:ifbn=n4thensys856,9,19:printm5$;
  47. 460 sys856,dx-k1,22:printchr$(bn);:ifcn<50then530
  48. 470 sys856,14,24:print"=";:ifnc=k4thenifbn<>49thenprintspc(k1)"1 / ";
  49. 480 rw=bn-n4:ry=rw
  50. 490 forr=1tocn-49:forrm=1to555:next:sys856,dx,22:print"x"bn$;:dx=dx+k2
  51. 500 ifbn=49thenb$=" 1 ":goto520
  52. 510 gosub780
  53. 520 sys856,kf+nc+(nc=6)*5,24:printb$;:next
  54. 530 ifnc=6thenreturn
  55. 540 aa$=chr$(cn):cc$="x a x b  ":bb$=aa$:ifnc=k4then640
  56. 550 ifcn=n4thenb$=" 1 ":cc$="x 1 x 1  ":bb$=chr$(160)
  57. 560 ifcn=49thenb$=bn$+b1$:bb$=chr$(160)
  58. 570 rw=len(b$):ry=int((kd-rw)/k2)
  59. 580 sys856,k1+ry,16:print"("bn$"ab) = "bn$" a b  ="b$cc$;
  60. 590 sys856,k1+ry,kf:printb1$b1$b3$aa$;b3$aa$b1$aa$b1$aa$b3$b3$;
  61. 600 forr=k2torw:printb1$;:next:printbb$b3$bb$b1$;
  62. 610 forr=601+rytor+38-ry:ifpeek(r+vm)<n8then630
  63. 620 poker+vm-40,160:poker+vm+80,160:poker+vn-40,kf:poker+vn+80,kf:rm=r+k1
  64. 630 next:pokerm+vm-41,160:pokerm+vm+79,160:pokerm+vn-41,kf:poker+vn+79,kf
  65. 640 ry=k1:r=int(rnd(k1)*ka):rx=cn-n4:bb$=chr$(r+n4):ifnc=k1then670
  66. 650 aa$="-"+aa$:rx=-rx
  67. 660 ifr>k0thenry=int(rnd(k1)*k2):ifry=k0thenry=-k1:bb$="-"+bb$:r=-r
  68. 670 rw=rx*r:sys856,4,kd:printm1$;
  69. 680 getb$:js=peek(p6)andpeek(p7)andp8:ifb$<>b1$andjs<>kfthen680
  70. 690 sys893:poke880,0:sys879:poke880,n2:printrn$;
  71. 700 forrx=k0tok3:sys856,k7,kd+rx:forr=k1to9:printb3$;:next:printb1$;:next
  72. 710 sys856,k7,14:printb1$chr$(97)b1$aa$chr$(99)bb$b3$aa$" x "bb$;
  73. 720 printb3$left$(b1$,abs(rw<k0))rwchr$(157)b1$;
  74. 730 sys856,k7,kf:printb1$chr$(98)bn$left$(b3$,k1-(nc=k4))chr$(100);
  75. 740 printleft$(b3$,k1-(ry<k0))"= "bn$b3$b3$left$(b3$,abs(nc=k4)-(ry<k0));
  76. 750 r=abs(abs(rw)>9):ry=abs(rw<k0)
  77. 760 print"= "bn$b1$b1$;:printleft$(b3$,r+ry);
  78. 770 forr=1to99:next:return
  79. 780 rw=rw*ry:aa$=str$(rw)
  80. 790 rm=len(aa$)-1:rx=int(rm/3):wx=rm-rx*k3:b$=b1$
  81. 800 ifwx>k0thenb$=b$+mid$(aa$,2,wx)+b1$
  82. 810 ifrx>k0thenforrm=k0torx-k1:b$=b$+mid$(aa$,wx+k2+rm*k3,k3)+b1$:next
  83. 820 return
  84. 830 bn=int(rnd(k1)*ka)+n4:bn$=chr$(bn):cn=int(rnd(1)*ka)+n4:rm=0:xb$="":aa$=bn$
  85. 840 sys856,9,22:printkf$rn$b1$chr$(cn)
  86. 850 sys856,9,23:printrn$bn$b1$r1$"="r1$"?"
  87. 860 gosub980:ifcn=n4thenbn$="1":aa$=bn$
  88. 870 getb$:js=peek(p6)andpeek(p7)andp8
  89. 880 ifrm>k0thenifb$=chr$(kd)or(js>kfandjs<p8)then920
  90. 890 ifb$<>b1$andjs<>kfthen870
  91. 900 aa$=aa$+xb$:sys856,14,23:printaa$"?";:xb$="x"+bn$
  92. 910 rm=rm+k1:printrn$;:ifrm<>12thengosub970:getb$:goto870
  93. 920 ifrm=cn-n4thensys856,14,23:printkb$aa$chr$(64);
  94. 930 printkf$rn$;:ifcn>49thenforr=2tocn-n4:bn$=bn$+xb$:next
  95. 940 rm=k0:gosub970:sys856,9,20:printchr$(bn)b1$r1$"="r1$bn$;
  96. 950 poke769+vn,kf:poke770+vn,kf:poke770+vm,cn+n8:return
  97. 960 :
  98. 970 sys879:ifrm=k0thenreturn
  99. 980 sys856,4,kf:printm1$
  100. 990 ifrm>k0thensys856,k2,17:print"or press return/push joystick to quit";
  101. 1000 return
  102. 1010 xc=24:xd=43:xf=k0:ifnc=k3thenxc=47:xd=45:xf=k1
  103. 1020 wf=k0:bn=int(rnd(k1)*9)+k1:bn$=mid$(str$(bn),2)
  104. 1030 forr=k0tok1
  105. 1040 sys856,k5,r+20:printkf$rn$b1$b3$r2$r2$b1$r2$r2$b1$b3$r2$;
  106. 1050 printkb$chr$(96)chr$(96)kf$r2$b3$b3$:next
  107. 1060 poke845+vm,bn+176:poke858+vm,bn+176:poke853+vm,xc+n8
  108. 1070 forr=1to2:xb$="":rf=n4:bb$=bn$:pa=k1:pb=806:ifr=k2thenpa=21:pb=819
  109. 1080 sys856,k2,13:ifnc=k2thenprint"multiply";
  110. 1090 ifnc=k3thenprint"divid";
  111. 1100 print"ing powers of the same base":sys856,0,kf:printm1$;
  112. 1110 getb$:js=peek(p6)andpeek(p7)andp8
  113. 1120 ifrf>n4thenifb$=chr$(kd)or(js>kfandjs<p8)then1190
  114. 1130 ifb$<>b1$andjs<>kfthen1110
  115. 1140 bb$=bb$+xb$:rf=rf+k1:pokepb+vm,rf+n8:sys856,pa,24:printbb$;
  116. 1150 sys879:sys856,0,kf:printm1$rn$"again?"
  117. 1160 sys856,k1,17:print"or press return/push joystick to quit";
  118. 1170 ifrf=57then1190
  119. 1180 xb$="x"+bn$:getb$:goto1110
  120. 1190 sys879:ifr=k1thenaa=rf-n4:aa$=bb$
  121. 1200 ifr=k2thencc=rf-n4:cc$=bb$
  122. 1210 next:poke979+vm,xc:poke979+vn,1:poke868+vm,bn+176:poke829+vm,63
  123. 1220 rl=k0:rd=n4:forr=960to999:rf=peek(r+vm):rk=peek(r+vn)andkf
  124. 1230 cx=k0:poker+vn,1:poker+vm,191:ifrf<n4orrk=11then1340
  125. 1240 rl=r:rd=rd+k1:poker-42+vn,11:poker-42+vm,k0:poker-41+vn,11:poker-41+vm,k0
  126. 1250 ifwf=k0thenifrf=49andaa=0thencx=k1
  127. 1260 ifwf=k1thenifrf=49andcc=k0thencx=k1
  128. 1270 ifwf<>k2then1300
  129. 1280 ifr<979andaa=k0thencx=k1
  130. 1290 ifr>979thencx=-(aa=k0):ifcc=k0thencx=cx+k1
  131. 1300 poker-40+vn,k1:poker-40+vm,rd-cx
  132. 1310 ifxf=0thenifaa>0andrd>57thenpoker-40+vm,49:poker-39+vn,1:poker-39+vm,rd-ka
  133. 1320 ifnot(xf=k1andr>979)then1340
  134. 1330 poker-39+(cc=k0)+vn,k1:poker-39+(cc=k0)+vm,rd-cx:ifcc<>0thenpoker-40+vm,45
  135. 1340 ifwf=k3then1400
  136. 1350 ifrf=k0thenifrd>n4thenph=r-41:gosub1570
  137. 1360 ifxf=k1andr+rl=997thengosub1570:goto1380
  138. 1370 ifxf=k1andwf=k3thenph=rl-41
  139. 1380 ifwf<k2andr=979thenrd=n4
  140. 1390 ifrf<>k0thenforrm=1to222:next
  141. 1400 poker+vn,rk:poker+vm,rf:next:ifwf=k3then1450
  142. 1410 forrm=1to666:next:sys856,20,24:printkf$cc$kb$"@@";:forrm=1to111:next
  143. 1420 forr=k1to18-len(aa$):poke211,r:printkb$"@"kf$aa$;
  144. 1430 forrm=1to111:next:next:tn=k1:wf=k2:ifxf=k1thenpoke979+vm,47:gosub1680
  145. 1440 goto1220
  146. 1450 ifxf=0thenba=aa+cc
  147. 1460 ifxf=1thenba=aa-cc
  148. 1470 ry=ba:gosub2590
  149. 1480 forr=ph-920to36:sys856,r,23:printkb$chr$(64)chr$(5)ve$;
  150. 1490 forrm=1to111:next:next:forr=k0tok3:sys856,37,23-r:printkb$"@@";
  151. 1500 sys856,37,22-r:printchr$(5)ve$;:forrm=1to111:next:next
  152. 1510 forr=k1tok4:poke211,37-r:printkf$rn$ve$kb$rf$chr$(64);
  153. 1520 forrm=1to111:next:next
  154. 1530 poke790+vn,kf:poke790+vm,xd+n8:poke792+vn,kf:poke792+vm,189
  155. 1540 forrm=1to444:next:poke211,29:printchr$(17)kf$rn$ve$b1$;
  156. 1550 forrm=1to2222:next:b$="":sys856,29,19:printrf$kb$"@@@@@@";:return
  157. 1560 :
  158. 1570 ifwf=k2thenwf=k3:ph=r-41:return
  159. 1580 tn=k1:ifwf=k0thenba=aa:rx=908
  160. 1590 ifwf=k1thenba=cc:rx=910
  161. 1600 ifwf=k1andba>k5thentn=-k1:rx=912
  162. 1610 pokeph+vn+1,11:pokeph+vm+1,0:pokeph+vn,11:pokeph+vm,0:ph=ph-40
  163. 1620 forry=phtorxsteptn:pokery+vn,11:pokery+vm,k0
  164. 1630 pokery+tn+vn,k1:pokery+tn+vm,ba+n4:forrm=1to55:next:next
  165. 1640 sys856,29,22:printrf$kb$"@@@@@@";
  166. 1650 pokerx+tn+vm-120,ba+176:pokerx+tn+vn-120,kf
  167. 1660 ifwf<k2thenwf=k1:rd=n4
  168. 1670 return
  169. 1680 ck=980:forr=962+vmto978+vmstepk2:dx=peek(r):ifdx<>peek(ck+vm)then1740
  170. 1690 forrm=1to222:next:pokeck+vn,k1:pokeck+vm,dx+n8
  171. 1700 forrm=1to999:next:pokeck+vm,0:forrm=1to222:next
  172. 1710 pokeck+vn,11:pokeck+vm,49:forrm=1to222:next
  173. 1720 poker-vm+vn,k1:poker,dx+n8:forrm=1to999:next:poker,k0:forrm=1to222:next
  174. 1730 poker-vm+vn,11:poker,49:forrm=1to222:next:ck=ck+k2
  175. 1740 next:return
  176. 1750 rl=0:zg=1:rd=829:xc=24:xd=43:ifnc=9thenxc=47:xd=45:xf=k1
  177. 1760 wf=k0:bn=int(rnd(k1)*9)+k1:bn$=mid$(str$(bn),k2)
  178. 1770 forr=k0tok1:sys856,k5,r+20:printkf$rn$;
  179. 1780 printb1$b3$r2$r2$b1$r2$r2$b1$b3$r2$;
  180. 1790