10 print"{r}torquemada 1541{R}"
20 print"this program will mobilize your disk"
30 print"head to its maximum extents using the"
40 print"fdc bump and seek jobs and an alignment"
50 print"master disk you insert. this may help"
55 print"cure sticky heads or alignment errors."
60 print
70 print"{r}warning!!!{R} this program should not be"
80 print"used on functional drives, as it may"
90 print"put them --out-- of alignment! you use"
100 print"this program at your own risk!!!"
110 print
120 print"copyright 2002 cameron kaiser":print"this is at your own risk-ware"
130 input"press return";w$
140 input"{q}device number";dv:ifdv<8ordv>11thenprint"bad device -- bye":end
150 print"checking for device":open15,dv,15:close15:ifst=0goto170
160 print"{r}device"dv"does not appear to exist":end
170 print"checking device signature":open15,dv,15,"ui":input#15,en,em$:close15
180 ifen<>73thenprint"{r}unexpected response code"en"from drive":end
190 dt$=right$(em$,4):ifdt$="1541"goto250
200 ifdt$="1571"goto230
210 a$="not a 1541 or 1571!":b$="this may not work!":gosub5000:ifexthenend
220 goto250
230 a$="this is a 1571!":b$="1571 drives rarely go out of alignment!":gosub5000
240 ifexthenend
250 print"{q}drive and firmware seem operational"
260 print"insert {r}write-protected{R} alignment"
270 print"master into device"dv:poke198,.
280 input"press return when ready";a$
290 open15,dv,15:print#15,"m-r"chr$(0)chr$(28):get#15,a$:a=asc(a$+chr$(0))
300 close15:a=aand16:ifa=0goto320
310 a$="sensor error!":b$="no disk or not write protected!":gosub5000
311 ifexthenend
320 rem *** main loop starts here ***
321 open15,dv,15,"m-w"+chr$(106)+chr$(0)+chr$(1)+chr$(193):input#15,en:close15
322 ifen<>0thenprint"{r}error"en"when changing revcnt":print"check drive ram":end
325 open15,dv,15,"i0":input#15,en,em$,et,es:close15
330 ifen<>0goto342
340 a$="valid track 18 read!":b$="bam seems to be readable now!":gosub5000
341 ifex=1thenprint"{q}resetting ... ";:open15,dv,15,"u:":close15:print"bye":end
342 open15,dv,15,"m-w"+chr$(106)+chr$(0)+chr$(1)+chr$(0):input#15,en:close15
344 ifen<>0thenprint"{r}error"en"when changing revcnt":print"check drive ram":end
345 print"{q}hold space to cancel drive operation"
349 print"{r}doing bump'n'seek ...{]}";
350 open15,dv,15:fory=1to4:printy;
360 t=35:s=0:j=176:gosub5500:ife<>1thenprint"{r}fdc error"e"on seek track 35"
370 t=1:s=0:j=192:gosub5500:ife<>1thenprint"{r}fdc error"e"on bump"
380 t=1:s=0:j=176:gosub5500:ife<>1thenprint"{r}fdc error"e"on seek track 1"
390 ifpeek(198)<>0thenprint:y=999
400 next:close15:print:ify>998thena$="user cancelled!":gosub5000:ifex=1goto341
410 goto320
4999 end
5000 ex=0:print"{r}warning!!!{R} "a$:ifb$<>""thenprintb$:b$=""
5010 poke198,.:input"continue anyway (y/n)";a$:a$=left$(a$,1):ifa$<>"y"thenex=1
5020 return
5500 cy=0
5510 print#15,"m-w"chr$(6)chr$(0)chr$(2)chr$(t)chr$(s)
5520 print#15,"m-w"chr$(0)chr$(0)chr$(1)chr$(j)
5530 cy=cy+1:print#15,"m-r"chr$(0)chr$(0):get#15,a$:e=asc(a$+chr$(0))
5540 ifcy>500thenprint"{r}timeout on fdc job":return
5550 ife>127goto5530
5560 return