home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1985 Fall
/
rerun-1985-fall.d64
/
calculator
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
4KB
|
118 lines
100 print "[147]":poke53282,0:poke53265,107:poke646,1
110 print "personal calculator[146]"
120 printtab(9);"to set screen colors"
130 printtab(9);"hit f1 for blue"
140 printtab(13);"f3 for white"
150 printtab(13);"f5 for grey"
160 printtab(13);"f7 for red"
170 for j=0to4
180 for i=1353 to 1372
190 pokei+j*40,peek(i+j*40)and63or64
200 next:next:poke53265,91
210 get a$:if a$=""then210
220 rem f1 option
230 if a$="[133]"then 310
240 rem f3 option
250 if a$="[134]"then 320
260 rem f5 option
270 if a$=chr$(135) then 330
280 rem f7 option
290 if peek(197)=3andpeek(653)=0then 340
300 goto210
310 poke53281,6:poke53280,14:poke646,14:goto350
320 poke53281,1:poke53280,6:poke646,6:goto350
330 poke53281,15:poke53280,11:poke646,11:goto350
340 poke53281,2:poke53280,10:poke646,10:
350 poke53265,27
360 print"[147] hit f1 to add a+b "
370 printtab(8);"f1' to subtract a-b "
380 printtab(8);"f2 to multiply a*b "
390 printtab(8);"f3 to divide a/b "
400 printtab(8);"f3' to get log "
410 printtab(8);"f4 to get sine (degrees) "
420 printtab(8);"f5 to get tangent (degrees) "
430 printtab(8);"f5' to get hex from decimal "
440 printtab(8);"f6 to get decimal from hex "
450 printtab(8);"f7 to get binary from decimal"
460 printtab(8);"f7' to get decimal from binary"
470 printtab(8);"f8 to quit "
480 x$=""
490 get a$:ifa$=""then490
500 rem f1 response
510 ifpeek(197)=4andpeek(653)=0thengosub1080:printa;" + ";b;" = ";a+b:goto1050
520 rem f1' response
530 ifpeek(197)=4andpeek(653)=2thengosub1080:printa;" - ";b;" = ";a-b:goto1050
540 rem f2 response
550 ifpeek(197)=4andpeek(653)=1thengosub1080:printa;" x ";b;" = ";a*b:goto1050
560 rem f3 response
570 ifpeek(197)=5andpeek(653)=0thengosub1080:printa;" / ";b;" = ";a/b:goto1050
580 rem f3' response
590 ifpeek(197)<>5orpeek(653)<>2thengoto640
600 gosub1100:c=log(a):d=log(a)/log(10)
610 print"log(10) of ";a;" = "d
620 print"log(e) of ";a;" = "c:goto1050
630 rem f4 response
640 ifpeek(197)<>5orpeek(653)<>1thengoto660
650 x$="in degrees":gosub1100:print"sine ";a;" = "sin(a*(NULL)/180):goto1050
660 ifpeek(197)<>6orpeek(653)<>0thengoto690
670 x$="in degrees":gosub1100:print"tangent ";a;" = "tan(a*(NULL)/180):goto1050
680 rem f5' response
690 ifpeek(197)<>6orpeek(653)<>2thengoto750
700 x$="(65535 max)":gosub1100:b=int(a/16^3):c=int((a-b*16^3)/256)
710 d=int((a-b*16^3-c*256)/16):e=int(a-b*16^3-c*256-d*16)
720 print"hex of";a;;" is $";
730 f=b:gosub1110:f=c:gosub1110:f=d:gosub1110:f=e:gosub1110:goto1050
740 rem f6 response
750 ifpeek(197)<>6orpeek(653)<>1thengoto850
760 print"[147]input hex number with leading zeros ($ffff max)":input a$
770 if left$(a$,1)="$"then a$=mid$(a$,2,8)
780 b$=left$(a$,1):c$=mid$(a$,2,1):d$=mid$(a$,3,1):e$=right$(a$,1):g=0:z=0
790 f$=b$:f=16^3:gosub1190:z=g*f
800 f$=c$:f=16^2:gosub1190:z=g*f+z
810 f$=d$:f=16:gosub1190:z=g*f+z
820 f$=e$:f=1:gosub1190:z=g*f+z
830 print"the decimal value of $";a$;" is ";z:goto1050
840 rem f7 response
850 ifpeek(197)<>3orpeek(653)<>0thengoto960
860 x$="(255 max)":gosub1100
870 b=int(a/128):c=int((a-b*128)/64):d=int((a-b*128-c*64)/32)
880 e=int((a-b*128-c*64-d*32)/16):f=int((a-b*128-c*64-d*32-e*16)/8)
890 g=int((a-b*128-c*64-d*32-e*16-f*8)/4)
900 h=int((a-b*128-c*64-d*32-e*16-f*8-g*4)/2)
910 i=int(a-b*128-c*64-d*32-e*16-f*8-g*4-h*2)
920 b$="%"+chr$(b+48)+chr$(c+48)+chr$(d+48)+chr$(e+48)+chr$(f+48)+chr$(g+48)
930 b$=b$+chr$(h+48)+chr$(i+48):print"the binary value of";a;"is ";b$
940 goto1050
950 rem f7' response
960 ifpeek(197)<>3orpeek(653)<>2thengoto1030
970 print"[147]enter binary number (%11111111) max":input a$
980 if left$(a$,1)="%"then a$=mid$(a$,2,8)
990 q$=a$:x=0:for i=7to0step-1:b=val(left$(a$,1))
1000 x=x+b*2^i:a$=mid$(a$,2):next
1010 print"the decimal value of %";q$;" is ";x:goto1050
1020 rem f8 response
1030 ifpeek(197)=3andpeek(653)=1thenprint"[147]bye":end
1040 goto510
1050 print"hit any key to continue"
1060 get a$:if a$=""then 1060
1070 goto360
1080 print"[147]input a":input a
1090 print"input b":inputb:return
1100 print"[147]input a ";x$ :input a:return
1110 if f<10 then f$=chr$(f+48)
1120 if f=10 then f$="a"
1130 if f=11 then f$="b"
1140 if f=12 then f$="c"
1150 if f=13 then f$="d"
1160 if f=14 then f$="e"
1170 if f=15 then f$="f"
1180 print f$;:return
1190 if val(f$)<10 then g=val(f$)
1200 if f$="a" then g=10
1210 if f$="b" then g=11
1220 if f$="c" then g=12
1230 if f$="d" then g=13
1240 if f$="e" then g=14
1250 if f$="f" then g=15
1260 return