home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1991 January
/
1991-01.d64
/
lincata
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
3KB
|
90 lines
10 rem lincata 260390
20 print"[147] program lincata":print
30 print"catalogs t/s addresses from blocks":print"on disk":print
40 input"which disk drive # (8/9/10/11)";u
50 print"which type of drive and corrupted disk:"
60 print" (1) 1541":print" (2) 1571":print" (3) 1581":print
70 input"1/2/3";dt
80 if dt<1 or dt>3 then goto50
90 dim ssiz(80):rem ssiz(t) is the actual number of valid sectors on track t
100 rem ssiz is the maximum number of sectors on any track.
110 if dt<>1 then goto170
120 :d$="1541":tsiz=35:ssiz=20
130 :for t=1 to 17:ssiz(t)=20:nextt
140 :for t=18 to 24:ssiz(t)=18:nextt
150 :for t=25 to 30:ssiz(t)=17:nextt
160 :for t=31 to 35:ssiz(t)=16:nextt
170 if dt<>2 then goto270
180 :d$="1571":tsiz=70:ssiz=20
190 :for t0=0 to 35 step 35
200 ::for t=1+t0 to 17+t0:ssiz(t)=20:nextt
210 ::for t=18+t0 to 24+t0:ssiz(t)=18:nextt
220 ::for t=25+t0 to 30+t0:ssiz(t)=17:nextt
230 ::for t=31+t0 to 35+t0:ssiz(t)=16:nextt
240 :next t0
250 :rem now make sure drive is in 1571 mode.
260 :open1,8,15,"u0>m1":close1
270 if dt<>3 then goto300
280 :d$="1581":tsiz=80:ssiz=39
290 :for t=1 to 80:ssiz(t)=39:next t
300 print:print"use drive # ";u;"[146], assuming type ";d$;"[146] ."
310 print "max range of tracks: 1 to";tsiz
320 print "max range of sectors: 0 to";ssiz
330 dim t%(tsiz,ssiz),s%(tsiz,ssiz),status%(tsiz,ssiz)
340 print
350 print"put copy of the corrupted disk in drive"
360 print"make sure the disk is write-protected[146]"
370 input "press return[146] when disk is ready: ok ";z$
380 open15,u,15
390 open5,u,5,"#"
400 ns=0
410 for t=1 to tsiz:print"track";t;": forward link track/sectors"
420 :for s=0 to ssiz(t)
430 ::print#15,"u1";5;0;t;s
440 ::get#5,a$:get#5,b$
450 ::t2=asc(a$+chr$(0)):s2=asc(b$+chr$(0))
460 ::t%(t,s)=t2:s%(t,s)=s2
470 ::ift2>0andt2<=tsizands2>=0ands2<=ssiz(t)thenstatus%(t2,s2)=status%(t2,s2)+1
480 ::print"t/s";s;":";t2;s2;"[146]"
490 ::if t=t2 and s=s2 then print"warning: sector link points to itself."
500 ::ns=ns+1
510 :next s
520 next t
530 close5:close15
540 print:print" status map, showing number of times ";
550 print"that each block is referenced:"
560 for t=1to tsiz:print"track";t:for s=0to ssiz(t):printstatus%(t,s);
570 next s:print:next t
580 print"total";ns;"sectors, including directory."
590 ::::::::::::::::::::::::::::
600 rem now write to disk
610 input"push return[146] if work disk is in drive";z$
620 open15,u,15,"i0":close15
630 open2,u,2,"t/s arrays,s,r":open15,u,15:input#15,a,b$,c,d
640 if a=62 then close2:goto690: rem file not found, so ok, and open for write
650 :print" 't/s arrays[146]' file already exists."
660 :input"o.k. to delete old version (y/n)";z$
670 :if z$<>"y" then print"abort program":close2:close15:end
680 :close2:print#15,"s0:t/s arrays":input#15,a,b$,c,d:print a;b$;c;d
690 open2,u,2,"t/s arrays,s,w"
700 input#15,a,b$,c,d:print a;b$;c;d
710 ifa<>0then print"problem opening 't/s arrats' file: aborting":close15:stop
720 print"writing to t/s arrays[146] file."
730 print"please be patient......"
740 rem: file "t/s arrays" format:
750 rem 4 bytes giving drive type (1541,1571 or 1581
760 rem 2 bytes giving number of tracks and max number of sectors on any track
770 rem tsiz bytes giving the number of valid sectors in each of tsiz tracks
780 rem tsiz*ssiz(t) pairs of bytes, giving the track/sector forward reference
790 print#2,d$;:rem disk type
800 print#2,chr$(tsiz);chr$(ssiz);
810 for t=1 to tsiz:print#2,chr$(ssiz(t));:next:rem array of #sectors/track
820 for t=1 to tsiz:for s=0 to ssiz(t)
830 :print#2,chr$(t%(t,s));chr$(s%(t,s));
840 next:next
850 rem :note that only ssiz(t) sector values have been written for each track.
860 print#2,chr$(255);chr$(255)
870 rem flag bytes for end of data
880 close2
890 end