home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1991 January / 1991-01.d64 / lincata (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  3KB  |  90 lines

  1. 10 rem        lincata             260390
  2. 20 print"[147] program lincata":print
  3. 30 print"catalogs t/s addresses from blocks":print"on disk":print
  4. 40 input"which disk drive # (8/9/10/11)";u
  5. 50 print"which type of drive and corrupted disk:"
  6. 60 print" (1)  1541":print" (2)  1571":print" (3)  1581":print
  7. 70 input"1/2/3";dt
  8. 80 if dt<1 or dt>3 then goto50 
  9. 90 dim ssiz(80):rem ssiz(t) is the actual number of valid sectors on track t
  10. 100 rem    ssiz is the maximum number of sectors on any track.
  11. 110 if dt<>1 then goto170 
  12. 120 :d$="1541":tsiz=35:ssiz=20
  13. 130 :for t=1  to 17:ssiz(t)=20:nextt
  14. 140 :for t=18 to 24:ssiz(t)=18:nextt
  15. 150 :for t=25 to 30:ssiz(t)=17:nextt
  16. 160 :for t=31 to 35:ssiz(t)=16:nextt
  17. 170 if dt<>2 then goto270 
  18. 180 :d$="1571":tsiz=70:ssiz=20
  19. 190 :for t0=0 to 35 step 35
  20. 200 ::for t=1+t0 to 17+t0:ssiz(t)=20:nextt
  21. 210 ::for t=18+t0 to 24+t0:ssiz(t)=18:nextt
  22. 220 ::for t=25+t0 to 30+t0:ssiz(t)=17:nextt
  23. 230 ::for t=31+t0 to 35+t0:ssiz(t)=16:nextt
  24. 240 :next t0
  25. 250 :rem now make sure drive is in 1571 mode.
  26. 260 :open1,8,15,"u0>m1":close1
  27. 270 if dt<>3 then goto300 
  28. 280 :d$="1581":tsiz=80:ssiz=39
  29. 290 :for t=1 to 80:ssiz(t)=39:next t
  30. 300 print:print"use drive # ";u;"[146], assuming type ";d$;"[146] ."
  31. 310 print "max range of tracks:  1 to";tsiz
  32. 320 print "max range of sectors: 0 to";ssiz
  33. 330 dim t%(tsiz,ssiz),s%(tsiz,ssiz),status%(tsiz,ssiz)
  34. 340 print
  35. 350 print"put copy of the corrupted disk in drive"
  36. 360 print"make sure the disk is write-protected[146]"
  37. 370 input "press return[146] when disk is ready: ok ";z$
  38. 380 open15,u,15
  39. 390 open5,u,5,"#"
  40. 400 ns=0
  41. 410 for t=1 to tsiz:print"track";t;": forward link track/sectors"
  42. 420 :for s=0 to ssiz(t)
  43. 430 ::print#15,"u1";5;0;t;s
  44. 440 ::get#5,a$:get#5,b$
  45. 450 ::t2=asc(a$+chr$(0)):s2=asc(b$+chr$(0))
  46. 460 ::t%(t,s)=t2:s%(t,s)=s2
  47. 470 ::ift2>0andt2<=tsizands2>=0ands2<=ssiz(t)thenstatus%(t2,s2)=status%(t2,s2)+1
  48. 480 ::print"t/s";s;":";t2;s2;"[146]"
  49. 490 ::if t=t2 and s=s2 then print"warning: sector link points to itself."
  50. 500 ::ns=ns+1
  51. 510 :next s
  52. 520 next t
  53. 530 close5:close15
  54. 540 print:print"   status map, showing number of times  ";
  55. 550 print"that each block is referenced:"
  56. 560 for t=1to tsiz:print"track";t:for s=0to ssiz(t):printstatus%(t,s);
  57. 570 next s:print:next t
  58. 580 print"total";ns;"sectors, including directory."
  59. 590 ::::::::::::::::::::::::::::
  60. 600 rem now write to disk
  61. 610 input"push return[146] if work disk is in drive";z$
  62. 620 open15,u,15,"i0":close15
  63. 630 open2,u,2,"t/s arrays,s,r":open15,u,15:input#15,a,b$,c,d
  64. 640 if a=62 then close2:goto690: rem file not found, so ok, and open for write
  65. 650 :print" 't/s arrays[146]' file already exists."
  66. 660 :input"o.k. to delete old version (y/n)";z$
  67. 670 :if z$<>"y" then print"abort program":close2:close15:end
  68. 680 :close2:print#15,"s0:t/s arrays":input#15,a,b$,c,d:print a;b$;c;d
  69. 690 open2,u,2,"t/s arrays,s,w"
  70. 700 input#15,a,b$,c,d:print a;b$;c;d
  71. 710 ifa<>0then print"problem opening 't/s arrats' file: aborting":close15:stop
  72. 720 print"writing to t/s arrays[146] file."
  73. 730 print"please be patient......"
  74. 740 rem: file "t/s arrays" format:
  75. 750 rem  4 bytes giving drive type (1541,1571 or 1581
  76. 760 rem  2 bytes giving number of tracks and max number of sectors on any track
  77. 770 rem  tsiz bytes giving the number of valid sectors in each of tsiz tracks
  78. 780 rem  tsiz*ssiz(t) pairs of bytes, giving the track/sector forward reference
  79. 790 print#2,d$;:rem disk type
  80. 800 print#2,chr$(tsiz);chr$(ssiz);
  81. 810 for t=1 to tsiz:print#2,chr$(ssiz(t));:next:rem array of #sectors/track
  82. 820 for t=1 to tsiz:for s=0 to ssiz(t)
  83. 830 :print#2,chr$(t%(t,s));chr$(s%(t,s));
  84. 840 next:next
  85. 850 rem :note that only ssiz(t) sector values have been written for each track.
  86. 860 print#2,chr$(255);chr$(255)
  87. 870 rem flag bytes for end of data
  88. 880 close2
  89. 890 end
  90.