home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1985 Fall / rerun-1985-fall.d64 / calculator (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  4KB  |  118 lines

  1. 100 print "[147]":poke53282,0:poke53265,107:poke646,1
  2. 110 print "personal calculator[146]"
  3. 120 printtab(9);"to set screen colors"
  4. 130 printtab(9);"hit f1 for blue"
  5. 140 printtab(13);"f3 for white"
  6. 150 printtab(13);"f5 for grey"
  7. 160 printtab(13);"f7 for red"
  8. 170 for j=0to4
  9. 180 for i=1353 to 1372
  10. 190 pokei+j*40,peek(i+j*40)and63or64
  11. 200 next:next:poke53265,91
  12. 210 get a$:if a$=""then210
  13. 220 rem f1 option
  14. 230 if a$="[133]"then 310
  15. 240 rem f3 option
  16. 250 if a$="[134]"then 320
  17. 260 rem f5 option
  18. 270 if a$=chr$(135) then 330
  19. 280 rem f7 option
  20. 290 if peek(197)=3andpeek(653)=0then 340
  21. 300 goto210
  22. 310 poke53281,6:poke53280,14:poke646,14:goto350
  23. 320 poke53281,1:poke53280,6:poke646,6:goto350
  24. 330 poke53281,15:poke53280,11:poke646,11:goto350
  25. 340 poke53281,2:poke53280,10:poke646,10:
  26. 350 poke53265,27
  27. 360 print"[147]    hit f1  to add a+b                "
  28. 370 printtab(8);"f1' to subtract a-b           "
  29. 380 printtab(8);"f2  to multiply a*b           "
  30. 390 printtab(8);"f3  to divide a/b             "
  31. 400 printtab(8);"f3' to get log                "
  32. 410 printtab(8);"f4  to get sine (degrees)     "
  33. 420 printtab(8);"f5  to get tangent (degrees)  "
  34. 430 printtab(8);"f5' to get hex from decimal   "
  35. 440 printtab(8);"f6  to get decimal from hex   "
  36. 450 printtab(8);"f7  to get binary from decimal"
  37. 460 printtab(8);"f7' to get decimal from binary"
  38. 470 printtab(8);"f8  to quit                   "
  39. 480 x$=""
  40. 490 get a$:ifa$=""then490
  41. 500 rem f1 response
  42. 510 ifpeek(197)=4andpeek(653)=0thengosub1080:printa;" + ";b;" = ";a+b:goto1050
  43. 520 rem f1' response
  44. 530 ifpeek(197)=4andpeek(653)=2thengosub1080:printa;" - ";b;" = ";a-b:goto1050
  45. 540 rem f2 response
  46. 550 ifpeek(197)=4andpeek(653)=1thengosub1080:printa;" x ";b;" = ";a*b:goto1050
  47. 560 rem f3 response
  48. 570 ifpeek(197)=5andpeek(653)=0thengosub1080:printa;" / ";b;" = ";a/b:goto1050
  49. 580 rem f3' response
  50. 590 ifpeek(197)<>5orpeek(653)<>2thengoto640
  51. 600 gosub1100:c=log(a):d=log(a)/log(10)
  52. 610 print"log(10) of ";a;" = "d
  53. 620 print"log(e) of ";a;" = "c:goto1050
  54. 630 rem f4 response
  55. 640 ifpeek(197)<>5orpeek(653)<>1thengoto660
  56. 650 x$="in degrees":gosub1100:print"sine ";a;" = "sin(a*(NULL)/180):goto1050
  57. 660 ifpeek(197)<>6orpeek(653)<>0thengoto690
  58. 670 x$="in degrees":gosub1100:print"tangent ";a;" = "tan(a*(NULL)/180):goto1050
  59. 680 rem f5' response
  60. 690 ifpeek(197)<>6orpeek(653)<>2thengoto750
  61. 700 x$="(65535 max)":gosub1100:b=int(a/16^3):c=int((a-b*16^3)/256)
  62. 710 d=int((a-b*16^3-c*256)/16):e=int(a-b*16^3-c*256-d*16)
  63. 720 print"hex of";a;;" is $";
  64. 730 f=b:gosub1110:f=c:gosub1110:f=d:gosub1110:f=e:gosub1110:goto1050
  65. 740 rem f6 response
  66. 750 ifpeek(197)<>6orpeek(653)<>1thengoto850
  67. 760 print"[147]input hex number with leading zeros     ($ffff max)":input a$
  68. 770 if left$(a$,1)="$"then a$=mid$(a$,2,8)
  69. 780 b$=left$(a$,1):c$=mid$(a$,2,1):d$=mid$(a$,3,1):e$=right$(a$,1):g=0:z=0
  70. 790 f$=b$:f=16^3:gosub1190:z=g*f
  71. 800 f$=c$:f=16^2:gosub1190:z=g*f+z
  72. 810 f$=d$:f=16:gosub1190:z=g*f+z
  73. 820 f$=e$:f=1:gosub1190:z=g*f+z
  74. 830 print"the decimal value of $";a$;" is ";z:goto1050
  75. 840 rem f7 response
  76. 850 ifpeek(197)<>3orpeek(653)<>0thengoto960
  77. 860 x$="(255 max)":gosub1100
  78. 870 b=int(a/128):c=int((a-b*128)/64):d=int((a-b*128-c*64)/32)
  79. 880 e=int((a-b*128-c*64-d*32)/16):f=int((a-b*128-c*64-d*32-e*16)/8)
  80. 890 g=int((a-b*128-c*64-d*32-e*16-f*8)/4)
  81. 900 h=int((a-b*128-c*64-d*32-e*16-f*8-g*4)/2)
  82. 910 i=int(a-b*128-c*64-d*32-e*16-f*8-g*4-h*2)
  83. 920 b$="%"+chr$(b+48)+chr$(c+48)+chr$(d+48)+chr$(e+48)+chr$(f+48)+chr$(g+48)
  84. 930 b$=b$+chr$(h+48)+chr$(i+48):print"the binary value of";a;"is ";b$
  85. 940 goto1050
  86. 950 rem f7' response
  87. 960 ifpeek(197)<>3orpeek(653)<>2thengoto1030
  88. 970 print"[147]enter binary number (%11111111) max":input a$
  89. 980 if left$(a$,1)="%"then a$=mid$(a$,2,8)
  90. 990 q$=a$:x=0:for i=7to0step-1:b=val(left$(a$,1))
  91. 1000 x=x+b*2^i:a$=mid$(a$,2):next
  92. 1010 print"the decimal value of %";q$;" is ";x:goto1050
  93. 1020 rem f8 response
  94. 1030 ifpeek(197)=3andpeek(653)=1thenprint"[147]bye":end
  95. 1040 goto510
  96. 1050 print"hit any key to continue"
  97. 1060 get a$:if a$=""then 1060
  98. 1070 goto360
  99. 1080 print"[147]input a":input a
  100. 1090 print"input b":inputb:return
  101. 1100 print"[147]input a ";x$ :input a:return
  102. 1110 if f<10 then f$=chr$(f+48)
  103. 1120 if f=10 then f$="a"
  104. 1130 if f=11 then f$="b"
  105. 1140 if f=12 then f$="c"
  106. 1150 if f=13 then f$="d"
  107. 1160 if f=14 then f$="e"
  108. 1170 if f=15 then f$="f"
  109. 1180 print f$;:return
  110. 1190 if val(f$)<10 then g=val(f$)
  111. 1200 if f$="a" then g=10
  112. 1210 if f$="b" then g=11
  113. 1220 if f$="c" then g=12
  114. 1230 if f$="d" then g=13
  115. 1240 if f$="e" then g=14
  116. 1250 if f$="f" then g=15
  117. 1260 return
  118.