home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1991 January
/
1991-01.d64
/
lincatc
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
3KB
|
74 lines
10 rem lincatc 260390
20 print"[147]program lincatc":print
30 dim f$(400),t(400),s(400),nb(400)
40 input "which disk drive number (8/9/10/11)";u
50 open15,u,15
60 print"put the work disk with the filelist[146] data into drive #";u;"."
70 input"ok to proceed (y/n)";z$
80 if z$<>"y" then close15:stop
90 open1,u,2,"filelist,s,r"
100 input#15,a,b$,c,d:print a;b$;c;d
110 if a<>0 then print"'filelist' not found. abort.":close1:close15:stop
120 d$="":for i=1 to 4:get#1,e$:d$=d$+e$:next i
130 print"filelist[146] drive type ";d$;"[146]"
140 if d$="1541" or d$="1571" then dtrk=18:dsct=1: goto170
150 if d$="1581" then dtrk=40:dsct=3 :goto170
160 print"drive type not recognised. aborting.":close1:close15:stop
170 print"directory track is";dtrk
180 print"starting sector is";dsct
190 nf=0
200 print"filename,track,sector,size:"
210 input#1,a$,b,c,d
220 print a$;b;c;d
230 nf=nf+1
240 f$(nf)=a$:t(nf)=b:s(nf)=c:nb(nf)=d
250 rem set file name, track & sector start, block size.
260 if a$<>"end" goto210
270 nf=nf-1
280 close1
290 print"found ";nf;"directory file entries."
300 rem now write the directory out to the directory track
310 print:print"change disk[146]: put corrupted disk in drive"
320 input"ok to proceed (y/n)";z$
330 if z$<>"y" then close15:stop
340 print"about to overwrite the entire directory":print"track #";dtrk;"."
350 input"shall i continue (y/n)";z$
360 if z$<>"y" then close15:stop
370 print#15,"i0":rem init drive:nb must have disk header and id already set
380 if d$="1571" then print#15,"u0>m1":rem make sure in 1571 mode, if need be.
390 t1=dtrk:s1=dsct:rem starting track,sector for the directory rewrite
400 sp$=chr$(160):fori=1to11:sp$=sp$+chr$(160):next i
410 z$=chr$(0)
420 for i=1 to nf step 8
430 :open4,u,4,"#"
440 :print#15,"b-p";4;0 :rem set pointer in 1541/1571/1581 buffer area
450 :if (i+7)<nf then print#4,chr$(t1);chr$(s1+1); :rem normal dir. block
460 :if (i+7)>=nf then print#4,chr$(0);chr$(255); :rem last directory block
470 :print "t/s: ";i;t1;s1+1;"[146]"
480 :rem link to next sector
490 :for k=0 to 7
500 : ff=i+k:if ff>nf then for l=1to(8-k)*32-2:print#4,z$;:nextl:goto620
510 : print#4,chr$(130);:rem assume type pgm file
520 : print#4,chr$(t(ff));chr$(s(ff));
530 : fi$=left$(f$(ff),4)+sp$
540 : print#4,fi$;
550 : for z=1to9:print#4,z$;:next z
560 : b2=int(nb(ff)/256):b1=nb(ff)-256*b2
570 : print#4,chr$(b1);chr$(b2);
580 : if k<7 then print#4,z$;z$;
590 : print ff;t(ff);s(ff);"<";fi$;">"
600 : print b1;b2
610 : next k
620 :print#15,"u2";4;0;t1;s1
630 :input#15,a,b$,c,d:if a=0 then goto670
640 : print: printa;b$;c;d:print"problem writing to disk. please check"
650 : print"correct disk is in drive, write enabled"
660 : print"aborting program.":close4:close15:stop
670 :s1=s1+1:rem set for next sector
680 :close4
690 next i
700 close15
710 print:print"directory written. end of lincatc."
720 print"now check directory, identify files and"
730 print"rename where necessary."