home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1991 January
/
1991-01.d64
/
diskid
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
4KB
|
109 lines
10 rem diskid (version 2: 1541/1571/1581 disk drives)
20 rem this program rewrites the disk id block. use with care.
30 print"[147]program diskid":print
40 input"which disk drive # (8/9/10/11)";u
50 print:print"select drive type":print"(1) 1541":print"(2) 1571"
60 :print"(3) 1581":print
70 :input"which drive type (1/2/3)";mode
80 :if mode<1 or mode>3 then goto 50
90 if mode=1 then d$="1541":dtrk=18:s0=1:dside=0
100 if mode=2 then d$="1571":dtrk=18:s0=1:dside=128
110 if mode=3 then d$="1581":dtrk=40:s0=3
120 print
130 print"put the backup corrupted disk in drive."
140 print"this programs rewrites the disk id block"
150 print:print"be careful that correct disk is in drive"
160 print
170 input"new disk name";n$
180 s$="":for i=1 to 18:s$=s$+chr$(160):next
190 na$=left$(n$+s$,18)
200 input"new disk id (2 chars)";i$
210 id$=left$(i$+s$,2)
220 t=dtrk:s=0 :rem (NULL) track.
230 open15,u,15,"i0":input#15,a,b$,c,d:print a;b$;c;d
240 if d$<>"1571" then goto 280
250 :print#15,"u0>m1":rem set 1571 to 1571 mode.
260 :input#15,a,b$,c,d:if a=0 then goto 280
270 ::printa;b$;c;d:print"not a 1571 drive":close15:stop
280 if d$<>"1541" and d$<>"1571" then goto 330
290 :rem now overwrite disk dos version already read into drive,
300 :rem at location (in 1541/1571) $0101.
310 :rem a zero in $0101 turns off dos compatibility checks.
320 :print#15,"m-w";chr$(01);chr$(01);chr$(01);chr$(0)
330 rem now start writing the disk (NULL) block.
340 rem first 2 bytes of disk (NULL) block give (NULL) starting address.
350 open5,u,5,"#"
360 print#15,"u1";5;0;t;s
370 print#15,"b-p";5;0
380 print#5,chr$(dtrk);chr$(s0); :rem location of first (NULL) block
390 if d$="1581" then goto 610
400 rem ..........................
410 rem 1541/1571 (NULL) section starts here
420 :print#5,"a";:rem disk format version
430 :print#5,chr$(dside);:rem 2-sided flag: $00 for 1541, $80 for 1571
440 :for ib=4 to 143:print#5,chr$(0);:next ib: rem dummy bam block entries
450 :print#5,na$;:rem disk name:18 bytes, trailing chr$(160)
460 :print#5,id$;:rem disk id: 2 bytes
470 :print#5,chr$(160);
480 :print#5,"2";: rem dos version
490 :print#5,"a";: rem disk format type
500 :for ib=167 to 170:print#5,chr$(160);:next ib
510 :for ib=171 to 255:print#5,chr$(0);: next ib:rem 1541=dummy,1571=bam
520 :print#15,"u2";5;0;t;s:rem write this block
530 :input#15,a,b$,c,d:printa;b$;c;d
540 :if a=0 or a=73 then goto 1060 : rem exit 1541/1571 section
550 ::print:print"problem writing to disk. please check"
560 ::print"that correct disk is in drive";u;"[146]"
570 ::print"that the disk is write-enabled"
580 ::print"and that the drive is a ";d$;"[146]."
590 ::close5:close15:stop
600 rem................................
610 rem 1581 (NULL) section starts here
620 :print#5,"d";:rem disk version #
630 :print#5,chr$(0);
640 :print#5,na$; :rem disk name
650 :print#5,id$; :rem disk id
660 :print#5,chr$(160);
670 :print#5,"3"; :rem dos version
680 :print#5,"d"; :rem disk version
690 :print#5,left$(s$,2);
700 :for i=29 to 255:print#5,chr$(0);:next
710 :print#15,"b-[215]";5;0;t;s:rem write this block
720 :input#15,a,b$,c,d:printa;b$;c;d
730 :if a=0 or a=73 then goto 780
740 :print:print"problem writing to disk. please check"
750 :print"that correct disk is in drive";u
760 :print"and that the disk is write-enabled."
770 :close5:close15:stop
780 :rem now write second block (sector 1)
790 :s=1
800 :print#15,"u1";5;0;t;s:rem read in what's already in first bam block
810 :print#15,"b-p";5;0:rem reset pointer
820 :print#5,chr$(40);chr$(2); :rem t/s of next bam block
830 :print#5,"d"; :rem version #
840 :print#5,chr$(255-asc("d"));:rem compliment version #
850 :print#5,id$;: rem disk id
860 :print#5,chr$(192); :rem i/o byte
870 :for i=7 to 15:print#5,chr$(0);:next
880 :print#15,"b-[215]";5;0;t;s:rem write this sector
890 :input#15,a,b$,c,d:if a=0 then goto 910
900 ::print"problem writing sector 1":print a;b$;c;d:close5:close15:stop
910 :rem now sector #2
920 :s=2
930 :print#15,"u1";5;0;t;s:rem read in what's already in first bam block
940 :print#15,"b-p";5;0:rem reset pointer
950 :print#5,chr$(0);chr$(255);
960 :print#5,"d"; :rem version #
970 :print#5,chr$(255-asc("d")); :rem compliment version #
980 :print#5,id$;: rem disk id
990 :print#5,chr$(192); :rem i/o byte
1000 :for i=7 to 15:print#5,chr$(0);:next
1010 :print#15,"b-[215]";5;0;t;s:rem write this sector
1020 :input#15,a,b$,c,d:if a=0 then goto 1060
1030 ::print"problem writing sector 2":print a;b$;c;d:close5:close15:stop
1040 :rem end of 1581-specific (NULL)
1050 rem ........................
1060 close5
1070 print#15,"i0":close15
1080 end