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

  1. 10 rem  diskid    (version 2: 1541/1571/1581 disk drives)
  2. 20 rem this program rewrites the disk id block.  use with care.
  3. 30 print"[147]program diskid":print
  4. 40 input"which disk drive  # (8/9/10/11)";u
  5. 50 print:print"select drive type":print"(1)    1541":print"(2)    1571"
  6. 60 :print"(3)    1581":print
  7. 70 :input"which drive type  (1/2/3)";mode
  8. 80 :if mode<1 or mode>3 then goto 50
  9. 90 if mode=1 then d$="1541":dtrk=18:s0=1:dside=0
  10. 100 if mode=2 then d$="1571":dtrk=18:s0=1:dside=128
  11. 110 if mode=3 then d$="1581":dtrk=40:s0=3
  12. 120 print
  13. 130 print"put the backup corrupted disk in drive."
  14. 140 print"this programs rewrites the disk id block"
  15. 150 print:print"be careful that correct disk is in drive"
  16. 160 print
  17. 170 input"new disk name";n$
  18. 180 s$="":for i=1 to 18:s$=s$+chr$(160):next
  19. 190 na$=left$(n$+s$,18)
  20. 200 input"new disk id (2 chars)";i$
  21. 210 id$=left$(i$+s$,2)
  22. 220 t=dtrk:s=0  :rem (NULL) track.
  23. 230 open15,u,15,"i0":input#15,a,b$,c,d:print a;b$;c;d
  24. 240 if d$<>"1571" then goto 280
  25. 250 :print#15,"u0>m1":rem set 1571 to 1571 mode.
  26. 260 :input#15,a,b$,c,d:if a=0 then goto 280
  27. 270 ::printa;b$;c;d:print"not a 1571 drive":close15:stop
  28. 280 if d$<>"1541" and d$<>"1571" then goto 330
  29. 290 :rem now overwrite disk dos version already read into drive,
  30. 300 :rem at location (in 1541/1571) $0101.
  31. 310 :rem a zero in $0101 turns off dos compatibility checks.
  32. 320 :print#15,"m-w";chr$(01);chr$(01);chr$(01);chr$(0)
  33. 330 rem    now start writing the disk (NULL) block.
  34. 340 rem    first 2 bytes of disk (NULL) block give (NULL) starting address.
  35. 350 open5,u,5,"#"
  36. 360 print#15,"u1";5;0;t;s
  37. 370 print#15,"b-p";5;0
  38. 380 print#5,chr$(dtrk);chr$(s0);     :rem location of first (NULL) block
  39. 390 if d$="1581" then goto 610
  40. 400 rem ..........................
  41. 410 rem 1541/1571 (NULL) section starts here
  42. 420 :print#5,"a";:rem disk format version
  43. 430 :print#5,chr$(dside);:rem 2-sided flag: $00 for 1541, $80 for 1571
  44. 440 :for ib=4 to 143:print#5,chr$(0);:next ib: rem dummy bam block entries
  45. 450 :print#5,na$;:rem disk name:18 bytes, trailing chr$(160)
  46. 460 :print#5,id$;:rem disk id:   2 bytes
  47. 470 :print#5,chr$(160);
  48. 480 :print#5,"2";: rem dos version
  49. 490 :print#5,"a";: rem disk format type
  50. 500 :for ib=167 to 170:print#5,chr$(160);:next ib
  51. 510 :for ib=171 to 255:print#5,chr$(0);:  next ib:rem 1541=dummy,1571=bam
  52. 520 :print#15,"u2";5;0;t;s:rem write this block
  53. 530 :input#15,a,b$,c,d:printa;b$;c;d
  54. 540 :if a=0 or a=73 then goto 1060 : rem exit 1541/1571 section
  55. 550 ::print:print"problem writing to disk. please check"
  56. 560 ::print"that correct disk is in drive";u;"[146]"
  57. 570 ::print"that the disk is write-enabled"
  58. 580 ::print"and that the drive is a ";d$;"[146]."
  59. 590 ::close5:close15:stop
  60. 600 rem................................
  61. 610 rem 1581 (NULL) section starts here
  62. 620 :print#5,"d";:rem disk version #
  63. 630 :print#5,chr$(0);
  64. 640 :print#5,na$;      :rem disk name
  65. 650 :print#5,id$;      :rem disk id
  66. 660 :print#5,chr$(160);
  67. 670 :print#5,"3";      :rem dos version
  68. 680 :print#5,"d";      :rem disk version
  69. 690 :print#5,left$(s$,2);
  70. 700 :for i=29 to 255:print#5,chr$(0);:next
  71. 710 :print#15,"b-[215]";5;0;t;s:rem write this block
  72. 720 :input#15,a,b$,c,d:printa;b$;c;d
  73. 730 :if a=0 or a=73  then goto 780
  74. 740 :print:print"problem writing to disk. please check"
  75. 750 :print"that correct disk is in drive";u
  76. 760 :print"and that the disk is write-enabled."
  77. 770 :close5:close15:stop
  78. 780 :rem now write second block (sector 1)
  79. 790 :s=1
  80. 800 :print#15,"u1";5;0;t;s:rem read in what's already in first bam block
  81. 810 :print#15,"b-p";5;0:rem reset pointer
  82. 820 :print#5,chr$(40);chr$(2);                       :rem t/s of next bam block
  83. 830 :print#5,"d";      :rem version #
  84. 840 :print#5,chr$(255-asc("d"));:rem compliment version #
  85. 850 :print#5,id$;:        rem disk id
  86. 860 :print#5,chr$(192);  :rem i/o byte
  87. 870 :for i=7 to 15:print#5,chr$(0);:next
  88. 880 :print#15,"b-[215]";5;0;t;s:rem write this sector
  89. 890 :input#15,a,b$,c,d:if a=0 then goto 910
  90. 900 ::print"problem writing sector 1":print a;b$;c;d:close5:close15:stop
  91. 910 :rem now sector #2
  92. 920 :s=2
  93. 930 :print#15,"u1";5;0;t;s:rem read in what's already in first bam block
  94. 940 :print#15,"b-p";5;0:rem reset pointer
  95. 950 :print#5,chr$(0);chr$(255);
  96. 960 :print#5,"d";      :rem version #
  97. 970 :print#5,chr$(255-asc("d"));                      :rem compliment version #
  98. 980 :print#5,id$;:        rem disk id
  99. 990 :print#5,chr$(192);  :rem i/o byte
  100. 1000 :for i=7 to 15:print#5,chr$(0);:next
  101. 1010 :print#15,"b-[215]";5;0;t;s:rem write this sector
  102. 1020 :input#15,a,b$,c,d:if a=0 then goto 1060
  103. 1030 ::print"problem writing sector 2":print a;b$;c;d:close5:close15:stop
  104. 1040 :rem end of 1581-specific (NULL)
  105. 1050 rem ........................
  106. 1060 close5
  107. 1070 print#15,"i0":close15
  108. 1080 end
  109.