home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1987 May / 1987-05.d64 / mlx (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  4KB  |  105 lines

  1. 10 rem version 1.1: lines 830,950 modified, lines 485-487 added
  2. 100 poke 56,50:clr:dim in$,i,j,a,b,a$,b$,a(7),n$
  3. 110 c4=48:c6=16:c7=7:z2=2:z4=254:z5=255:z6=256:z7=127
  4. 120 fa=peek(45)+z6*peek(46):bs=peek(55)+z6*peek(56):h$="0123456789abcdef"
  5. 130 r$=chr$(13):l$="[157]":s$=" ":d$=chr$(20):z$=chr$(0):t$=""
  6. 140 sd=54272:for i=sd to sd+23:poke i,0:next:poke sd+24,15:poke 788,52
  7. 150 print"[147]"chr$(142)chr$(8):poke 53280,15:poke 53281,15
  8. 160 print t$"   [164][164][164][164][164][164][164][164]  "spc(28)"  [146] mlx ii   "spc(28)"            "
  9. 170 print"   compute!'s machine language editor"
  10. 180 print"[144]starting address[151]";:gosub300:sa=ad:gosub1040:if f then180
  11. 190 print"[144]  ending address[151]";:gosub300:ea=ad:gosub1030:if f then190
  12. 200 input"[144]clear workspace [y/n][151]";a$:if left$(a$,1)<>"y"then220
  13. 210 print"working...";:fori=bs to bs+ea-sa+7:poke i,0:next:print"done"
  14. 220 printtab(10)"[144] mlx command menu [151]":print t$"e[146]nter data"
  15. 230 print t$"d[146]isplay data":print t$"l[146]oad file"
  16. 240 print t$"s[146]ave file":print t$"q[146]uit[144]"
  17. 250 get a$:if a$=n$ then250
  18. 260 a=0:for i=1 to 5:if a$=mid$("edlsq",i,1)then a=i:i=5
  19. 270 next:on a goto420,610,690,700,280:gosub1060:goto250
  20. 280 print" quit ":input"[151]are you sure [y/n]";a$:if left$(a$,1)<>"y"then220
  21. 290 poke sd+24,0:end
  22. 300 in$=n$:ad=0:inputin$:iflen(in$)<>4thenreturn
  23. 310 b$=in$:gosub320:ad=a:b$=mid$(in$,3):gosub320:ad=ad*256+a:return
  24. 320 a=0:for j=1 to 2:a$=mid$(b$,j,1):b=asc(a$)-c4+(a$>"@")*c7:a=a*c6+b
  25. 330 if b<0 or b>15 then ad=0:a=-1:j=2
  26. 340 next:return
  27. 350 b=int(a/c6):print mid$(h$,b+1,1);:b=a-b*c6:print mid$(h$,b+1,1);:return
  28. 360 a=int(ad/z6):gosub350:a=ad-a*z6:gosub350:print":";
  29. 370 ck=int(ad/z6):ck=ad-z4*ck+z5*(ck>z7):goto390
  30. 380 ck=ck*z2+z5*(ck>z7)+a
  31. 390 ck=ck+z5*(ck>z5):return
  32. 400 print"starting at[151]";:gosub300:if in$<>n$ then gosub1030:if f then400
  33. 410 return
  34. 420 print" enter data ":gosub400:if in$=n$ then220
  35. 430 open3,3:print
  36. 440 poke198,0:gosub360:if f then print in$:print"[145]";
  37. 450 for i=0 to 24 step 3:b$=s$:for j=1 to 2:if f then b$=mid$(in$,i+j,1)
  38. 460 print""b$l$;:if i<24then print"[146]";
  39. 470 get a$:if a$=n$ then470
  40. 480 if(a$>"/"anda$<":")or(a$>"@"anda$<"g")then540
  41. 485 a=-(a$="m")-2*(a$=",")-3*(a$=".")-4*(a$="/")-5*(a$="j")-6*(a$="k")
  42. 486 a=a-7*(a$="l")-8*(a$=":")-9*(a$="u")-10*(a$="i")-11*(a$="o")-12*(a$="p")
  43. 487 a=a-13*(a$=s$):if a then a$=mid$("abcd123e456f0",a,1):goto 540
  44. 490 if a$=r$ and((i=0)and(j=1)or f)then print b$;:j=2:next:i=24:goto550
  45. 500 if a$="" then print b$:j=2:next:i=24:next:f=0:goto440
  46. 510 if(a$="")andf thenprint b$l$;:goto540
  47. 520 if a$<>l$ and a$<>d$ or((i=0)and(j=1))then gosub1060:goto470
  48. 530 a$=l$+s$+l$:print b$l$;:j=2-j:if j then print l$;:i=i-3
  49. 540 print a$;:next j:print s$;
  50. 550 next i:print:print"[145]";:input#3,in$:if in$=n$ then close3:goto220
  51. 560 for i=1 to 25 step3:b$=mid$(in$,i):gosub320:if i<25 then gosub380:a(i/3)=a
  52. 570 next:if a<>ck then gosub1060:print"[144] error: reenter line [151]":f=1:goto440
  53. 580 gosub1080:b=bs+ad-sa:for i=0 to 7:poke b+i,a(i):next
  54. 590 ad=ad+8:if ad>ea then close3:print"** end of entry **[144]":goto700
  55. 600 f=0:goto440
  56. 610 print"[147] display data ":gosub400:if in$=n$ then220
  57. 620 print"press: space[146] to pause, return[146] to break[151]"
  58. 630 gosub360:b=bs+ad-sa:fori=bto b+7:a=peek(i):gosub350:gosub380:print s$;
  59. 640 next:print"";:a=ck:gosub350:print
  60. 650 f=1:ad=ad+8:if ad>ea thenprint"** end of data **":goto220
  61. 660 get a$:if a$=r$ then gosub1080:goto220
  62. 670 if a$=s$ then f=f+1:gosub1080
  63. 680 onfgoto630,660,630
  64. 690 print" load data ":op=1:goto710
  65. 700 print" save file ":op=0
  66. 710 in$=n$:input"filename[151]";in$:if in$=n$ then220
  67. 720 f=0:print"[144]t[146]ape or d[146]isk: [151]";
  68. 730 get a$:if a$="t"then print"t":goto880
  69. 740 if a$<>"d"then730
  70. 750 print"d":open15,8,15,"i0:":b=ea-sa:in$="0:"+in$:if op then810
  71. 760 open 1,8,8,in$+",p,w":gosub860:if a then220
  72. 770 ah=int(sa/256):al=sa-(ah*256):print#1,chr$(al);chr$(ah);
  73. 780 for i=0 to b:print#1,chr$(peek(bs+i));:if st then800
  74. 790 next:close1:close15:goto940
  75. 800 gosub1060:print"[144]error during save:[151]":gosub860:goto220
  76. 810 open 1,8,8,in$+",p,r":gosub860:if a then220
  77. 820 get#1,a$,b$:ad=asc(a$+z$)+256*asc(b$+z$):if ad<>sa then f=1:goto850
  78. 830 for i=0 to b:get#1,a$:poke bs+i,asc(a$+z$):if(i<>b)and st then f=2:ad=i:i=b
  79. 840 next:if st<>64 then f=3
  80. 850 close1:close15:on abs(f>0)+1 goto960,970
  81. 860 input#15,a,a$:if a then close1:close15:gosub1060:print"error: "a$
  82. 870 return
  83. 880 poke183,peek(fa+2):poke187,peek(fa+3):poke188,peek(fa+4):ifop=0then920
  84. 890 sys 63466:if(peek(783)and1)then gosub1060:print" file not found ":goto690
  85. 900 ad=peek(829)+256*peek(830):if ad<>sa then f=1:goto970
  86. 910 a=peek(831)+256*peek(832)-1:f=f-2*(a<ea)-3*(a>ea):ad=a-ad:goto930
  87. 920 a=sa:b=ea+1:gosub1010:poke780,3:sys 63338
  88. 930 a=bs:b=bs+(ea-sa)+1:gosub1010:on op goto950:sys 63591
  89. 940 gosub1080:print"** save completed **":goto220
  90. 950 poke147,0:sys 63562:if st>0 then970
  91. 960 gosub1080:print"** load completed **":goto220
  92. 970 gosub1060:print"[144]error during load:[151]":on f gosub980,990,1000:goto220
  93. 980 print"incorrect starting address (";:gosub360:print")":return
  94. 990 print"load ended at ";:ad=sa+ad:gosub360:print d$:return
  95. 1000 print"truncated at ending address":return
  96. 1010 ah=int(a/256):al=a-(ah*256):poke193,al:poke194,ah
  97. 1020 ah=int(b/256):al=b-(ah*256):poke174,al:poke175,ah:return
  98. 1030 if ad<sa or ad>ea then1050
  99. 1040 if(ad>511 and ad<40960)or(ad>49151 and ad<53248)then gosub1080:f=0:return
  100. 1050 gosub1060:print" invalid address [144]":f=1:return
  101. 1060 poke sd+5,31:poke sd+6,208:poke sd,240:poke sd+1,4:poke sd+4,33
  102. 1070 for s=1 to 100:next:goto1090
  103. 1080 poke sd+5,8:poke sd+6,240:poke sd,0:poke sd+1,90:poke sd+4,17
  104. 1090 for s=1 to 100:next:poke sd+4,0:poke sd,0:poke sd+1,0:return
  105.