home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1994 May
/
1994-05b.d64
/
exponents
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
12KB
|
316 lines
5 rem copyright 1994 -compute publications intl ltd - all rights reserved
10 rem by robert quinn
20 gosub2760
30 getb$:js=peek(p6)andpeek(p7)andp8
40 pokevm+p(px),peek(vm+p(px))-n8:pokevm+p(px)-1,n2:pokevm+p(px)+1,n2
50 :
60 r=(js=30)+abs(js=29):ifr<>k0thenpx=px+r:px=px+(px=11)*ka-(px=k0)*ka
70 ifjs>kfandjs<28thenifpx<>k4andpx<>k6thengosub190
80 ifb$>"0"thenifb$<"7"thennc=val(b$)
90 ifb$="q"thennc=7
100 ifb$="w"thennc=8
110 ifb$="e"thennc=9
120 ifb$="t"thennc=10
130 if(js=kf)or(b$=b1$)thennc=px
140 ifnc>k0thenpx=nc
150 pokevm+p(px),peek(vm+p(px))+n8:pokevm+p(px)-k1,k0:pokevm+p(px)+k1,k0
160 ifnc>k0then220
170 ifb$>b1$thenifb$<>chr$(95)thengosub2940
180 forr=1to44:next:goto30
190 ifpx<k4thenpx=px+k6:return
200 ifpx>k6andpx<kathenpx=px-k6:return
210 px=px+(px=ka)*k5-(px=k5)*k5:return
220 forr=720+vmtor+39:poker,n2:next:poke829,11:sys828:poke53280,12:xf=k0
230 ifnc<>k1andnc<>k4thensys879
240 onncgosub270,1010,1010,270,1960,2330,830,1750,1750,1960
250 ifnc<>k1andnc<>k4andnc<>k6thensys879
260 nc=k0:poke53280,14:poke198,k0:goto30
270 bn=int(rnd(1)*ka)+n4:cn=int(rnd(k1)*ka)+n4:ifnc=k4thencn=int(rnd(k1)*9)+49
280 ifbn=peek(907)orcn=peek(908)then270
290 poke907,bn:poke908,cn:sys879
300 bn$=chr$(bn):sys856,ka,22:printkf$rn$bn$b1$b1$r1$;"="r1$;
310 ifnc=k6then360
320 printrf$r1$"power ";:ifnc=k4thenprint"-";
330 printchr$(cn)" of "bn$;:ifnc=k4then360
340 ifcn=51thenprintr1$r2$"[cube]";
350 ifcn=50thenprintr1$r2$"[square]";
360 sys856,ka,21:printrn$b1$;:ifnc=k4thenprint"-";
370 printchr$(cn);:ifnc=k1ornc=6thenprintb1$;
380 ifnc=6then440
390 printr2$r2$rf$;:forr=1to2222:next:ifnc=k4thenprint"-";
400 printchr$(cn);" is the exponent"
410 forr=1to2222:next:print"base "bn$;
420 forr=1to2222:next:ifcn=n4thenbn=49
430 forr=856tor+23:poker+vm,0:poker+vn,11:poker+40+vm,0:poker+40+vn,11:next
440 dx=17:sys856,16,22:printrn$;
450 ifnc=k4thendx=21:print"1 / ";:ifbn=n4thensys856,9,19:printm5$;
460 sys856,dx-k1,22:printchr$(bn);:ifcn<50then530
470 sys856,14,24:print"=";:ifnc=k4thenifbn<>49thenprintspc(k1)"1 / ";
480 rw=bn-n4:ry=rw
490 forr=1tocn-49:forrm=1to555:next:sys856,dx,22:print"x"bn$;:dx=dx+k2
500 ifbn=49thenb$=" 1 ":goto520
510 gosub780
520 sys856,kf+nc+(nc=6)*5,24:printb$;:next
530 ifnc=6thenreturn
540 aa$=chr$(cn):cc$="x a x b ":bb$=aa$:ifnc=k4then640
550 ifcn=n4thenb$=" 1 ":cc$="x 1 x 1 ":bb$=chr$(160)
560 ifcn=49thenb$=bn$+b1$:bb$=chr$(160)
570 rw=len(b$):ry=int((kd-rw)/k2)
580 sys856,k1+ry,16:print"("bn$"ab) = "bn$" a b ="b$cc$;
590 sys856,k1+ry,kf:printb1$b1$b3$aa$;b3$aa$b1$aa$b1$aa$b3$b3$;
600 forr=k2torw:printb1$;:next:printbb$b3$bb$b1$;
610 forr=601+rytor+38-ry:ifpeek(r+vm)<n8then630
620 poker+vm-40,160:poker+vm+80,160:poker+vn-40,kf:poker+vn+80,kf:rm=r+k1
630 next:pokerm+vm-41,160:pokerm+vm+79,160:pokerm+vn-41,kf:poker+vn+79,kf
640 ry=k1:r=int(rnd(k1)*ka):rx=cn-n4:bb$=chr$(r+n4):ifnc=k1then670
650 aa$="-"+aa$:rx=-rx
660 ifr>k0thenry=int(rnd(k1)*k2):ifry=k0thenry=-k1:bb$="-"+bb$:r=-r
670 rw=rx*r:sys856,4,kd:printm1$;
680 getb$:js=peek(p6)andpeek(p7)andp8:ifb$<>b1$andjs<>kfthen680
690 sys893:poke880,0:sys879:poke880,n2:printrn$;
700 forrx=k0tok3:sys856,k7,kd+rx:forr=k1to9:printb3$;:next:printb1$;:next
710 sys856,k7,14:printb1$chr$(97)b1$aa$chr$(99)bb$b3$aa$" x "bb$;
720 printb3$left$(b1$,abs(rw<k0))rwchr$(157)b1$;
730 sys856,k7,kf:printb1$chr$(98)bn$left$(b3$,k1-(nc=k4))chr$(100);
740 printleft$(b3$,k1-(ry<k0))"= "bn$b3$b3$left$(b3$,abs(nc=k4)-(ry<k0));
750 r=abs(abs(rw)>9):ry=abs(rw<k0)
760 print"= "bn$b1$b1$;:printleft$(b3$,r+ry);
770 forr=1to99:next:return
780 rw=rw*ry:aa$=str$(rw)
790 rm=len(aa$)-1:rx=int(rm/3):wx=rm-rx*k3:b$=b1$
800 ifwx>k0thenb$=b$+mid$(aa$,2,wx)+b1$
810 ifrx>k0thenforrm=k0torx-k1:b$=b$+mid$(aa$,wx+k2+rm*k3,k3)+b1$:next
820 return
830 bn=int(rnd(k1)*ka)+n4:bn$=chr$(bn):cn=int(rnd(1)*ka)+n4:rm=0:xb$="":aa$=bn$
840 sys856,9,22:printkf$rn$b1$chr$(cn)
850 sys856,9,23:printrn$bn$b1$r1$"="r1$"?"
860 gosub980:ifcn=n4thenbn$="1":aa$=bn$
870 getb$:js=peek(p6)andpeek(p7)andp8
880 ifrm>k0thenifb$=chr$(kd)or(js>kfandjs<p8)then920
890 ifb$<>b1$andjs<>kfthen870
900 aa$=aa$+xb$:sys856,14,23:printaa$"?";:xb$="x"+bn$
910 rm=rm+k1:printrn$;:ifrm<>12thengosub970:getb$:goto870
920 ifrm=cn-n4thensys856,14,23:printkb$aa$chr$(64);
930 printkf$rn$;:ifcn>49thenforr=2tocn-n4:bn$=bn$+xb$:next
940 rm=k0:gosub970:sys856,9,20:printchr$(bn)b1$r1$"="r1$bn$;
950 poke769+vn,kf:poke770+vn,kf:poke770+vm,cn+n8:return
960 :
970 sys879:ifrm=k0thenreturn
980 sys856,4,kf:printm1$
990 ifrm>k0thensys856,k2,17:print"or press return/push joystick to quit";
1000 return
1010 xc=24:xd=43:xf=k0:ifnc=k3thenxc=47:xd=45:xf=k1
1020 wf=k0:bn=int(rnd(k1)*9)+k1:bn$=mid$(str$(bn),2)
1030 forr=k0tok1
1040 sys856,k5,r+20:printkf$rn$b1$b3$r2$r2$b1$r2$r2$b1$b3$r2$;
1050 printkb$chr$(96)chr$(96)kf$r2$b3$b3$:next
1060 poke845+vm,bn+176:poke858+vm,bn+176:poke853+vm,xc+n8
1070 forr=1to2:xb$="":rf=n4:bb$=bn$:pa=k1:pb=806:ifr=k2thenpa=21:pb=819
1080 sys856,k2,13:ifnc=k2thenprint"multiply";
1090 ifnc=k3thenprint"divid";
1100 print"ing powers of the same base":sys856,0,kf:printm1$;
1110 getb$:js=peek(p6)andpeek(p7)andp8
1120 ifrf>n4thenifb$=chr$(kd)or(js>kfandjs<p8)then1190
1130 ifb$<>b1$andjs<>kfthen1110
1140 bb$=bb$+xb$:rf=rf+k1:pokepb+vm,rf+n8:sys856,pa,24:printbb$;
1150 sys879:sys856,0,kf:printm1$rn$"again?"
1160 sys856,k1,17:print"or press return/push joystick to quit";
1170 ifrf=57then1190
1180 xb$="x"+bn$:getb$:goto1110
1190 sys879:ifr=k1thenaa=rf-n4:aa$=bb$
1200 ifr=k2thencc=rf-n4:cc$=bb$
1210 next:poke979+vm,xc:poke979+vn,1:poke868+vm,bn+176:poke829+vm,63
1220 rl=k0:rd=n4:forr=960to999:rf=peek(r+vm):rk=peek(r+vn)andkf
1230 cx=k0:poker+vn,1:poker+vm,191:ifrf<n4orrk=11then1340
1240 rl=r:rd=rd+k1:poker-42+vn,11:poker-42+vm,k0:poker-41+vn,11:poker-41+vm,k0
1250 ifwf=k0thenifrf=49andaa=0thencx=k1
1260 ifwf=k1thenifrf=49andcc=k0thencx=k1
1270 ifwf<>k2then1300
1280 ifr<979andaa=k0thencx=k1
1290 ifr>979thencx=-(aa=k0):ifcc=k0thencx=cx+k1
1300 poker-40+vn,k1:poker-40+vm,rd-cx
1310 ifxf=0thenifaa>0andrd>57thenpoker-40+vm,49:poker-39+vn,1:poker-39+vm,rd-ka
1320 ifnot(xf=k1andr>979)then1340
1330 poker-39+(cc=k0)+vn,k1:poker-39+(cc=k0)+vm,rd-cx:ifcc<>0thenpoker-40+vm,45
1340 ifwf=k3then1400
1350 ifrf=k0thenifrd>n4thenph=r-41:gosub1570
1360 ifxf=k1andr+rl=997thengosub1570:goto1380
1370 ifxf=k1andwf=k3thenph=rl-41
1380 ifwf<k2andr=979thenrd=n4
1390 ifrf<>k0thenforrm=1to222:next
1400 poker+vn,rk:poker+vm,rf:next:ifwf=k3then1450
1410 forrm=1to666:next:sys856,20,24:printkf$cc$kb$"@@";:forrm=1to111:next
1420 forr=k1to18-len(aa$):poke211,r:printkb$"@"kf$aa$;
1430 forrm=1to111:next:next:tn=k1:wf=k2:ifxf=k1thenpoke979+vm,47:gosub1680
1440 goto1220
1450 ifxf=0thenba=aa+cc
1460 ifxf=1thenba=aa-cc
1470 ry=ba:gosub2590
1480 forr=ph-920to36:sys856,r,23:printkb$chr$(64)chr$(5)ve$;
1490 forrm=1to111:next:next:forr=k0tok3:sys856,37,23-r:printkb$"@@";
1500 sys856,37,22-r:printchr$(5)ve$;:forrm=1to111:next:next
1510 forr=k1tok4:poke211,37-r:printkf$rn$ve$kb$rf$chr$(64);
1520 forrm=1to111:next:next
1530 poke790+vn,kf:poke790+vm,xd+n8:poke792+vn,kf:poke792+vm,189
1540 forrm=1to444:next:poke211,29:printchr$(17)kf$rn$ve$b1$;
1550 forrm=1to2222:next:b$="":sys856,29,19:printrf$kb$"@@@@@@";:return
1560 :
1570 ifwf=k2thenwf=k3:ph=r-41:return
1580 tn=k1:ifwf=k0thenba=aa:rx=908
1590 ifwf=k1thenba=cc:rx=910
1600 ifwf=k1andba>k5thentn=-k1:rx=912
1610 pokeph+vn+1,11:pokeph+vm+1,0:pokeph+vn,11:pokeph+vm,0:ph=ph-40
1620 forry=phtorxsteptn:pokery+vn,11:pokery+vm,k0
1630 pokery+tn+vn,k1:pokery+tn+vm,ba+n4:forrm=1to55:next:next
1640 sys856,29,22:printrf$kb$"@@@@@@";
1650 pokerx+tn+vm-120,ba+176:pokerx+tn+vn-120,kf
1660 ifwf<k2thenwf=k1:rd=n4
1670 return
1680 ck=980:forr=962+vmto978+vmstepk2:dx=peek(r):ifdx<>peek(ck+vm)then1740
1690 forrm=1to222:next:pokeck+vn,k1:pokeck+vm,dx+n8
1700 forrm=1to999:next:pokeck+vm,0:forrm=1to222:next
1710 pokeck+vn,11:pokeck+vm,49:forrm=1to222:next
1720 poker-vm+vn,k1:poker,dx+n8:forrm=1to999:next:poker,k0:forrm=1to222:next
1730 poker-vm+vn,11:poker,49:forrm=1to222:next:ck=ck+k2
1740 next:return
1750 rl=0:zg=1:rd=829:xc=24:xd=43:ifnc=9thenxc=47:xd=45:xf=k1
1760 wf=k0:bn=int(rnd(k1)*9)+k1:bn$=mid$(str$(bn),k2)
1770 forr=k0tok1:sys856,k5,r+20:printkf$rn$;
1780 printb1$b3$r2$r2$b1$r2$r2$b1$b3$r2$;
1790