home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1985 September / Ahoy_Magazine_85-09_1985_Double_L.d64 / auto-gen (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  2KB  |  100 lines

  1. 900 print"[147]":poke53280,6:poke53281,1
  2. 1000 printspc(15)"auto-gen"
  3. 1010 printspc(13)"sep   1, 1984"
  4. 1020 printspc(13)"david a jones"
  5. 1030 rem creates disk file of data statements containing image of memory
  6. 1040 :
  7. 1050 fl=0        : rem first memory location to be saved
  8. 1060 ll=0        : rem last memory location to be saved
  9. 1070 ln=1000     : rem output program line number
  10. 1080 lb=0        : rem low byte of 16 bit number
  11. 1090 hb=0        : rem high byte of 16 bit number
  12. 1100 hh=0        : rem temp store for hexideciaml conversion
  13. 1110 mm=0        : rem decimal value of number converted from string
  14. 1120 nd=10       : rem number of data items per line
  15. 1130 nl=2049     : rem pointer to start of next basic line
  16. 1140 x=0         : rem outer loop counter
  17. 1150 y=0         : rem inner loop counter
  18. 1160 z=0         : rem data item counter
  19. 1170 c$=","      : rem comma
  20. 1180 d$=chr$(131): rem basic token for "data"
  21. 1190 s$=" "      : rem space
  22. 1200 fi$=""      : rem output file name
  23. 1210 nn$=""      : rem number string input
  24. 1220 x$=""       : rem 4 character string representing 1 memory location
  25. 1230 :
  26. 1240 :     rem main program
  27. 1250 :
  28. 1260 print:input"first memory location";nn$
  29. 1270 mm=val(nn$)
  30. 1280 if left$(nn$,1)="$" then gosub 1830
  31. 1290 fl=mm
  32. 1300 print:input"last memory location";nn$
  33. 1310 mm=val(nn$)
  34. 1320 if left$(nn$,1)="$" then gosub 1830
  35. 1330 ll=mm
  36. 1340 print:input"starting line number";ln
  37. 1350 print:input"number of data items per line";nd
  38. 1360 print:input"output filename";fi$
  39. 1370 :
  40. 1380 open 15,8,15
  41. 1390 open 8,8,8,"0:"+fi$+",p,w"
  42. 1400 gosub 1920
  43. 1410 :
  44. 1420 print#8,chr$(1);chr$(8);: rem program load location
  45. 1430 :
  46. 1440 :     rem main loop
  47. 1450 :
  48. 1460 for x=fl to ll step nd
  49. 1470 nl=nl+2+2+1+4*nd+1
  50. 1480 lb=nl-256*(int(nl/256)): hb=int(nl/256)
  51. 1490 print#8,chr$(lb);chr$(hb);: rem next basic line
  52. 1500 lb=ln-256*(int(ln/256)): hb=int(ln/256)
  53. 1510 print#8,chr$(lb);chr$(hb);: rem next line number
  54. 1520 print ln;: rem show user what's happening
  55. 1530 print#8,d$;: rem data token
  56. 1540 :
  57. 1550 for y=x to x+nd-1: rem 0 to 9 = 10 items
  58. 1560 x$=right$("    "+str$(peek(y)),3)
  59. 1570 :
  60. 1580 for i=1 to 3
  61. 1590 print#8,chr$(asc(mid$(x$,i,1)));
  62. 1600 next i
  63. 1610 :
  64. 1620 z=z+1
  65. 1630 if z<nd then print#8,c$;
  66. 1640 next y
  67. 1650 :
  68. 1660 print#8,chr$(0);: rem end of line terminator
  69. 1670 ln=ln+10
  70. 1680 z=0
  71. 1690 gosub 1920
  72. 1700 next x
  73. 1710 :
  74. 1720 :     rem add end of program terminator
  75. 1730 :
  76. 1740 print#8,chr$(0);chr$(0);
  77. 1750 close 8
  78. 1760 gosub 1920
  79. 1770 close 15
  80. 1780 print:print"complete"
  81. 1790 end
  82. 1800 :
  83. 1810 :     rem hex to decimal
  84. 1820 :
  85. 1830 mm=0: hh=0
  86. 1840 for x=2 to len(nn$)
  87. 1850 hh=asc(mid$(nn$,(x),1))-48
  88. 1860 mm=16*mm+hh+7*(hh>9)
  89. 1870 next
  90. 1880 return
  91. 1890 :
  92. 1900 :     rem disk i/0 error
  93. 1910 :
  94. 1920 input#15,en$,em$,et$,es$: en=val(en$)
  95. 1930 if en=0 then 1970
  96. 1940 print"disk i/o error ";
  97. 1950 print en$,em$,et$,es$
  98. 1960 close 8: close 15: stop
  99. 1970 return
  100.