home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 123 / 123.d81 / hex calc.basic (.txt) < prev    next >
Encoding:
Commodore BASIC  |  1994-01-01  |  8.7 KB  |  460 lines

  1. 10 poke56,56:poke52,56:clr
  2. 12 poke53281,0:poke53280,0:print"[147]":ti$="000000":gosub60000
  3. 14 ifti$<"000005"then14
  4. 20 tp$="[145]                    [176][192][192][192][174][176][192][192][192][174][176][192][192][192][174][176][192][192][192][174]"
  5. 30 bt$="[145]                    [173][192][192][192][189][173][192][192][192][189][173][192][192][192][189][173][192][192][192][189]"
  6. 100 dv=peek(186):ifdv<8thendv=8
  7. 200 rem  sys57812"calc font",dv,0:poke780,0:poke781,0:poke782,56:sys65493
  8. 220 print"[147]"chr$(142)
  9. 230 poke53281,0:poke646,0:poke53272,25:poke788,52
  10. 232 gosub5000
  11. 240 dim k%(27),vm(19,4)
  12. 250 gosub 3600:rem initialize k%
  13. 260 rem calculator
  14. 270 rem md=-1 for decimal
  15. 280 rem md= 1 for hexadecimal
  16. 290 rem ee=1 means input evaluated
  17. 300 rem ee=0 means evaluation needed
  18. 310 rem ee=-1 means eval done after unary operator
  19. 320 rem k0% holds keypress to turn off
  20. 330 rem k1% holds keypress to turn on
  21. 340 rem k2% holds 2nd key to turn off
  22. 350 rem k3% holds old operator key
  23. 360 rem note: -1 means skip turning on/off
  24. 370 op=0:rem null operator
  25. 380 md=-1:ba=10:t1=0:t2=0:tm=0:la=2:ee=1:er=0
  26. 390 k0%=-1:k1%=-1:k2%=-1:k3%=-1
  27. 400 poke214,0:print:printtab(24)"";
  28. 410 a$="":get a$:if a$="" then 410
  29. 412 xq=pos(1):poke781,24:sys59903:poke214,0:print:printtab(xq)"";
  30. 420 if er then 1990
  31. 430 if a$<"0" or a$>"9"then 560
  32. 440 if ee then gosub 3210:ee=0
  33. 450 if la>=9 then 410
  34. 460 if md>0 and la>=5 then 410
  35. 470 la=la+1
  36. 480 t$(la)=a$
  37. 490 t2=0
  38. 500 print a$;
  39. 510 k0%=k1%
  40. 520 k1%=asc(a$)-48
  41. 530 k2%=-1
  42. 540 goto 2240
  43. 550 rem check hex digits
  44. 560 if a$<"a" or a$>"f" then 690
  45. 570 if md<0 then 410
  46. 580 if ee then gosub 3210:ee=0
  47. 590 if la>=5 then 410
  48. 600 la=la+1
  49. 610 t$(la)=a$
  50. 620 t2=0
  51. 630 print a$;
  52. 640 k0%=k1%
  53. 650 k1%=asc(a$)-55
  54. 660 k2%=-1
  55. 670 goto 2240
  56. 680 rem evaluate addition
  57. 690 if a$<>"+" then 780
  58. 700 if ee<=0 then gosub 2470
  59. 710 op=1
  60. 720 k0%=k1%
  61. 730 k1%=19
  62. 740 k2%=k3%
  63. 750 k3%=k1%
  64. 760 goto 2240
  65. 770 rem evaluate subtraction
  66. 780 if a$<>"-" then 870
  67. 790 if ee<=0 then gosub 2470
  68. 800 op=2
  69. 810 k0%=k1%
  70. 820 k1%=18
  71. 830 k2%=k3%
  72. 840 k3%=k1%
  73. 850 goto 2240
  74. 860 rem evaluate multiplication
  75. 870 if a$<>"*" then 960
  76. 880 if ee<=0 then gosub 2470
  77. 890 op=3
  78. 900 k0%=k1%
  79. 910 k1%=16
  80. 920 k2%=k3%
  81. 930 k3%=k1%
  82. 940 goto 2240
  83. 950 rem evaluate division
  84. 960 if a$<>"/" then 1050
  85. 970 if ee<=0 then gosub 2470
  86. 980 op=4
  87. 990 k0%=k1%
  88. 1000 k1%=17
  89. 1010 k2%=k3%
  90. 1020 k3%=k1%
  91. 1030 goto 2240
  92. 1040 rem evaluate result
  93. 1050 if a$<>"=" then 1150
  94. 1060 if ee<=0 then gosub 2470
  95. 1070 op=0
  96. 1080 t2=tm
  97. 1090 k0%=k1%
  98. 1100 k1%=20
  99. 1110 k2%=k3%
  100. 1120 k3%=k1%
  101. 1130 goto 2240
  102. 1140 rem evaluate complement
  103. 1150 if a$<>"@" then 1290
  104. 1160 if ee=0 then gosub 3290:ee=-1
  105. 1170 if er then 1240
  106. 1180 t0=-t1
  107. 1190 if ee>0 then t0=-tm
  108. 1200 gosub 3210
  109. 1210 gosub 2810
  110. 1220 if ee<=0 then t1=t0
  111. 1230 if ee>0 then tm=t0
  112. 1240 k0%=k1%
  113. 1250 k1%=22
  114. 1260 k2%=-1
  115. 1270 goto 2240
  116. 1280 rem evaluate base conversion
  117. 1290 if a$<>"_" then 1530
  118. 1300 if ee=0 then gosub 3290:ee=-1
  119. 1310 if er then 1480
  120. 1320 md=-md
  121. 1330 t0=t1
  122. 1340 if ee>0 then t0=tm
  123. 1350 if md>0 then 1410
  124. 1360 ba=10
  125. 1370 poke 1100,4
  126. 1380 poke 1101,5
  127. 1390 poke 1102,3
  128. 1400 goto 1450
  129. 1410 ba=16
  130. 1420 poke 1100,8
  131. 1430 poke 1101,5
  132. 1440 poke 1102,24
  133. 1450 gosub 3210
  134. 1460 gosub 2810:rem display t0
  135. 1470 if ee>0 then tm=t0:t2=t0
  136. 1480 k0%=k1%
  137. 1490 k1%=23
  138. 1500 k2%=-1
  139. 1510 goto 2240
  140. 1520 rem evaluate delete
  141. 1530 if a$<>chr$(20) then 1620
  142. 1540 if ee or la<=0 then 410
  143. 1550 la=la-1
  144. 1560 print"[157] [157]";
  145. 1570 k0%=k1%
  146. 1580 k1%=-1:rem turn off only
  147. 1590 k2%=-1
  148. 1600 goto 2240
  149. 1610 rem evaluate and
  150. 1620 if a$<>"&" then 1710
  151. 1630 if ee<=0 then gosub 2470
  152. 1640 op=5
  153. 1650 k0%=k1%
  154. 1660 k1%=24
  155. 1670 k2%=k3%
  156. 1680 k3%=k1%
  157. 1690 goto 2240
  158. 1700 rem evaluate or
  159. 1710 if a$<>"%" then 1800
  160. 1720 if ee<=0 then gosub 2470
  161. 1730 op=6
  162. 1740 k0%=k1%
  163. 1750 k1%=25
  164. 1760 k2%=k3%
  165. 1770 k3%=k1%
  166. 1780 goto 2240
  167. 1790 rem evaluate not
  168. 1800 if a$<>"#" then 1990
  169. 1810 if ee=0 then gosub 3290:ee=-1
  170. 1820 if er then 1940
  171. 1830 rem normalize argument
  172. 1840 if ee>0 then 1880
  173. 1850 if t1>32767 then t1=t1-65536
  174. 1860 t0=not t1
  175. 1870 goto 1900
  176. 1880 if tm>32767 then tm=tm-65536
  177. 1890 t0=not tm
  178. 1900 gosub 3210
  179. 1910 gosub 2810
  180. 1920 if ee<=0 then t1=t0
  181. 1930 if ee>0 then tm=t0
  182. 1940 k0%=k1%
  183. 1950 k1%=26
  184. 1960 k2%=-1
  185. 1970 goto 2240
  186. 1980 rem evaluate clear
  187. 1990 if a$<>chr$(147) then 2130
  188. 2000 t2=0
  189. 2010 tm=0
  190. 2020 gosub 2790
  191. 2030 ee=1
  192. 2040 op=0
  193. 2050 er=0
  194. 2060 em=0:gosub 3540:rem erase message
  195. 2070 k0%=k1%
  196. 2080 k1%=21
  197. 2090 k2%=k3%
  198. 2100 k3%=k1%
  199. 2110 goto 2240
  200. 2120 rem evaluate off
  201. 2130 if a$<>"q" then 410
  202. 2132 xq=pos(1)
  203. 2140 em=4:gosub 3540:rem display prompt
  204. 2150 a$="":get a$:if a$="" then 2150
  205. 2160 if a$="y" then 2190
  206. 2170 poke781,24:sys59903:rem erase prompt
  207. 2172 poke214,0:print:printtab(xq)"";
  208. 2180 goto 410
  209. 2190 poke788,49:goto40000
  210. 2230 rem light up keys
  211. 2240 if k0%<0 then 2310
  212. 2250 ad=1034+k%(k0%)
  213. 2260 poke ad,peek(ad) or 128
  214. 2270 ad=ad+1
  215. 2280 poke ad,peek(ad) or 128
  216. 2290 ad=ad+1
  217. 2300 poke ad,peek(ad) or 128
  218. 2310 if k1%<0 then 2380
  219. 2320 ad=1034+k%(k1%)
  220. 2330 poke ad,peek(ad) and 127
  221. 2340 ad=ad+1
  222. 2350 poke ad,peek(ad) and 127
  223. 2360 ad=ad+1
  224. 2370 poke ad,peek(ad) and 127
  225. 2380 if k2%<0 then 410
  226. 2390 ad=1034+k%(k2%)
  227. 2400 poke ad,peek(ad) or 128
  228. 2410 ad=ad+1
  229. 2420 poke ad,peek(ad) or 128
  230. 2430 ad=ad+1
  231. 2440 poke ad,peek(ad) or 128
  232. 2450 goto 410
  233. 2460 rem evaluate prev operation
  234. 2470 if ee=0 then gosub 3290
  235. 2480 ee=1
  236. 2490 if er then return
  237. 2500 on op+1 goto 2510, 2560, 2590, 2620, 2650, 2690, 2740
  238. 2510 rem null operator
  239. 2520 tm=t2+t1
  240. 2530 t1=0
  241. 2540 return
  242. 2550 rem addition
  243. 2560 tm=tm+t1
  244. 2570 goto 2790
  245. 2580 rem subtraction
  246. 2590 tm=tm-t1
  247. 2600 goto 2790
  248. 2610 rem multiplication
  249. 2620 tm=tm*t1
  250. 2630 goto 2790
  251. 2640 rem division
  252. 2650 if t1=0 then em=3:goto 3470
  253. 2660 tm=tm/t1
  254. 2670 goto 2790
  255. 2680 rem logical and
  256. 2690 if t1>32767 then t1=t1-65536
  257. 2700 if tm>32767 then tm=tm-65536
  258. 2710 tm=tm and t1
  259. 2720 goto 2790
  260. 2730 rem logical or
  261. 2740 if t1>32767 then t1=t1-65536
  262. 2750 if tm>32767 then tm=tm-65536
  263. 2760 tm=tm or t1
  264. 2770 goto 2790
  265. 2780 rem display result
  266. 2790 t1=0:t0=tm
  267. 2800 gosub 3210
  268. 2810 if md>0 then 2890
  269. 2820 rem display decimal
  270. 2830 if em>0 then em=0:gosub 3540
  271. 2840 t0$=str$(t0)
  272. 2850 la=la+len(t0$)
  273. 2860 print t0$;
  274. 2870 return
  275. 2880 rem hex conversion
  276. 2890 if t0<-32768 then 3100
  277. 2900 if t0> 65535 then 3100
  278. 2910 n=sgn(t0)*int(abs(t0))
  279. 2920 t0=n
  280. 2930 m=-16:rem leading space
  281. 2940 if n>=0 then 2970
  282. 2950 m= 15:rem leading f
  283. 2960 n=n+65536
  284. 2970 gosub 3160
  285. 2980 m=int(n/4096)
  286. 2990 gosub 3160
  287. 3000 n=n-4096*m
  288. 3010 m=int(n/256)
  289. 3020 gosub 3160
  290. 3030 n=n-256*m
  291. 3040 m=int(n/16)
  292. 3050 gosub 3160
  293. 3060 m=n-16*m
  294. 3070 gosub 3160
  295. 3080 return
  296. 3090 rem hex overflow
  297. 3100 print "overflow";
  298. 3110 la=la+8
  299. 3120 em=2
  300. 3130 gosub 3540:rem display message
  301. 3140 return
  302. 3150 rem display hex digit
  303. 3160 if m<10 then hx$=chr$(48+m)
  304. 3170 if m>=10 then hx$=chr$(55+m)
  305. 3180 print hx$;
  306. 3190 la=la+1
  307. 3200 return
  308. 3210 rem erase input
  309. 3220 if la=0 then return
  310. 3230 for i=1 to la
  311. 3240 print "[157] [157]";
  312. 3250 next i
  313. 3260 la=0
  314. 3270 return
  315. 3280 rem evaluate input string
  316. 3290 if la=0 then return
  317. 3300 t1=0
  318. 3310 for i=1 to la
  319. 3320 aa$=t$(i)
  320. 3330 if aa$<"0" or aa$>"9" then 3370
  321. 3340 t1=t1*ba
  322. 3350 t1=t1+asc(aa$)-48
  323. 3360 goto 3400
  324. 3370 if aa$<"a" or aa$>"f" then 3400
  325. 3380 t1=t1*ba
  326. 3390 t1=t1+asc(aa$)-55
  327. 3400 next i
  328. 3410 if md<0 then return
  329. 3420 rem check sign bit
  330. 3430 if t1>65535 then t1=t1-1048576
  331. 3440 if t1>-32769 then return
  332. 3450 em=1
  333. 3460 rem input error
  334. 3470 gosub 3210
  335. 3480 print "error";
  336. 3490 la=5
  337. 3500 gosub 3540:rem display message
  338. 3510 er=1
  339. 3520 return
  340. 3530 rem display error message
  341. 3540 am=2003
  342. 3550 for i=0 to 19
  343. 3560 am=am+1
  344. 3570 poke am,vm(i,em)
  345. 3580 next
  346. 3590 return
  347. 3600 rem initialize array of key posns
  348. 3610 k%( 0)=891
  349. 3620 k%( 1)=771
  350. 3630 k%( 2)=776
  351. 3640 k%( 3)=781
  352. 3650 k%( 4)=651
  353. 3660 k%( 5)=656
  354. 3670 k%( 6)=661
  355. 3680 k%( 7)=531
  356. 3690 k%( 8)=536
  357. 3700 k%( 9)=541
  358. 3710 k%(10)=411
  359. 3720 k%(11)=416
  360. 3730 k%(12)=421
  361. 3740 k%(13)=291
  362. 3750 k%(14)=296
  363. 3760 k%(15)=301
  364. 3770 k%(16)=546
  365. 3780 k%(17)=426
  366. 3790 k%(18)=666
  367. 3800 k%(19)=786
  368. 3810 k%(20)=906
  369. 3820 k%(21)=306
  370. 3830 k%(22)=896
  371. 3840 k%(23)=901
  372. 3850 k%(24)=171
  373. 3860 k%(25)=176
  374. 3870 k%(26)=181
  375. 3880 k%(27)=186
  376. 3890 rem initialize error message array
  377. 3900 for j=0 to 4
  378. 3910 for i=0 to 19
  379. 3920 read vm(i,j)
  380. 3940 next
  381. 3950 next
  382. 3960 return
  383. 3970 data 160,160,160,160,160
  384. 3980 data 160,160,160,160,160
  385. 3990 data 160,160,160,160,160
  386. 4000 data 160,160,160,160,160
  387. 4010 data 62, 9,12,12, 5
  388. 4020 data  7, 1,12,32,14
  389. 4030 data  5, 7,32,14,21
  390. 4040 data 13, 2, 5,18,60
  391. 4050 data 62,62,20,15,15
  392. 4060 data 32,12, 1,18, 7
  393. 4070 data  5,32, 6,15,18
  394. 4080 data 32, 8, 5,24,60
  395. 4090 data 62,62,62, 4, 9
  396. 4100 data 22, 9, 4, 5,32
  397. 4110 data  2,25,32,26, 5
  398. 4120 data 18,15,60,60,60
  399. 4130 data 17,21, 9,20,63
  400. 4140 data 32, 1,18, 5,32
  401. 4150 data 25,15,21,32,19
  402. 4160 data 21,18, 5,63,32
  403. 5000 print""tab(20)"[176][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][174]"
  404. 5002 printtab(20)"[145][221][159]               [146]dec[221]"
  405. 5004 printtab(20)"[145][173][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][189]"
  406. 5006 printtp$
  407. 5008 printtab(20)"[145][221]and[146][221][221]o r[146][221][221]not[146][221][221]off[146][221]"
  408. 5010 printtab(20)"[145][173][192]&[192][189][173][192]%[192][189][173][192]#[192][189][173][192]q[192][189]"
  409. 5012 printtp$
  410. 5014 printtab(20)"[145][221] d [146][221][221] e [146][221][221] f [146][221][221]clr[146][221]"
  411. 5016 printbt$
  412. 5018 printtp$
  413. 5020 printtab(20)"[145][221] a [146][221][221] b [146][221][221] c [146][221][221][149] / [146][221]"
  414. 5022 printbt$
  415. 5024 printtp$
  416. 5026 printtab(20)"[145][221][154] 7 [146][221][221][154] 8 [146][221][221][154] 9 [146][221][221][149] * [146][221]"
  417. 5028 printbt$
  418. 5030 printtp$
  419. 5032 printtab(20)"[145][221][154] 4 [146][221][221][154] 5 [146][221][221][154] 6 [146][221][221][149] - [146][221]"
  420. 5034 printbt$
  421. 5036 printtp$
  422. 5038 printtab(20)"[145][221][154] 1 [146][221][221][154] 2 [146][221][221][154] 3 [146][221][221][149] + [146][221]"
  423. 5040 printbt$
  424. 5042 printtp$
  425. 5044 printtab(20)"[145][221][154] 0 [146][221][221]sgn[146][221][221]cnv[146][221][221][149] = [146][221]"
  426. 5046 printtab(20)"[145][173][192][192][192][189][173][192]@[192][189][173][192]_[192][189][173][192][192][192][189]"
  427. 5050 fori=217to242:pokei,peek(i)or128:next
  428. 5060 print"[129]  l o a d s t a r
  429. 5070 [153]"  p r e s e n t s
  430. 6000 print"[159] john m. campbell's "
  431. 6001 print"                    "
  432. 6002 print"   [174]  [176] [176][192][192][174] [174]   [176]  "
  433. 6004 print"   [221]  [221] [221]    [173][174] [176][189]  "
  434. 6006 print"   [171][192][192][179] [171][192][179]   [171][192][179]   "
  435. 6008 print"   [221]  [221] [221]    [176][189] [173][174]  "
  436. 6010 print"   [189]  [173] [173][192][192][189] [189]   [173]  "
  437. 6011 print"                    "
  438. 6012 print" [176][192][192][174] [176][192][192][174] [174]   [176][192][192][174] "
  439. 6014 print" [221]  [189] [221]  [221] [221]   [221]  [189] "
  440. 6016 print" [221]    [171][192][192][179] [221]   [221]    "
  441. 6018 print" [221]  [174] [221]  [221] [221]   [221]  [174] "
  442. 6020 print" [173][192][192][189] [189]  [173] [173][192][192][189][173][192][192][189] "
  443. 6090 return
  444. 10000 open15,8,15,"s0:hex calc.bas":close15:save"hex calc.bas",8:end
  445. 40000 a$="hello connect":fori=8to9:close2:open2,i,2:close2:ifstthen40020
  446. 40010 close15:open15,i,15,"r0:"+a$+"="+a$:input#15,er:close15:ifer=63then40030
  447. 40020 next:print"[147]":poke2048,0:poke44,8:poke53272,23:poke186,8:end
  448. 40030 poke646,peek(53281):print"[147]load"chr$(34)a$chr$(34)","i
  449. 40040 print"run":poke44,8:poke2048,0:poke631,13:poke632,13:poke198,2:end
  450. 60000 print"[147]":z$=" [152]                                      ":poke214,10:print
  451. 60010 print" [155][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184][184]":fori=0to8:printz$:next
  452. 60020 print" [151][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][185][152]"
  453. 60030 z$(0)="[200] [197] [216]   [195] [193] [204] [195] [213] [204] [193] [212] [207] [210]":z$(1)="by [202]ohn [205]. [195]ampbell
  454. 60040 z$(2)[178]"(len) 1994 by (NULL)oftdisk, right$nc."[170][199](13)
  455. 60050 z$(3)[178]"(NULL)his program is the copyrighted work
  456. 60060 z$(4)="of [211][207][198][212][196][201][211][203] [208][213][194][204][201][211][200][201][206][199].  [201]t is not"
  457. 60070 z$(5)="shareware or in the public domain."
  458. 60090 poke214,12:print
  459. 60100 fori=0to5:printtab(20-(len(z$(i))/2))""z$(i):next:return
  460.