10
20
30
40
50 :
60 DIM X% 31,data% 255:Y%=X%DIV256:*DISK
70 ON ERROR REPORT:PRINT " at line ";ERL:OSCLI"FX180,"+STR$(PAGE/256):END
80 *FX180,64
90 INPUT"Drive: "drive%
100 INPUT"Tracks: (80) "tracks%:IF tracks%=0:tracks%=80
110 INPUT"Sides: (2) "sides%:IF sides%=0:sides%=2
120 INPUT"Start sector: (1) "A$:IF A$="":sec0%=1 ELSE sec0%=VALA$
130 sectors%=10
140 FOR track%=0 TO tracks%-1
150 FOR side%=0 TO sides%-1
160 :
170 this%=track%:IF this%>79:this%=this%-80:drive%=drive% OR 2
180 PRINT CHR$13;"Format ";drive%;":";this%;":";side%;SPC3;CHR$8;CHR$8;CHR$8;
190 FOR sector%=0 TO 9
200 data%!(sector%*4+0)=this%
210 data%?(sector%*4+1)=side%+track%DIV80
220 data%?(sector%*4+2)=sec0%+(sector%+this%*7)MOD10+side%*sectors%
230 data%?(sector%*4+3)=1
240 IF track%=0:IF side%=0:IF sector%<2:data%?(sector%*4+2)=sector%
250 NEXT sector%
260 X%?0=drive% OR side%*2
270 X%!1=data%
280 X%!5=&6305
290 X%?7=this%
300 X%!8=&10002A10
310 A%=127:REPEAT:CALL&FFF1:UNTIL X%?12<>&10
320 IF X%?12:PRINT TAB(18);"error &";~X%?12
330 :
340 FOR A%=0 TO 255 STEP 4:data%!A%=0:NEXT A%
350 FOR sector%=0 TO sectors%-1
360 sec%=sec0%+sector%+side%*sectors%
370 IF this%=0:IF side%=0:IF sector%<2:sec%=sector%
380 PRINT CHR$13;"Link ";drive%;":";this%;":";side%;":";sec%;
390 link0%=track%:link1%=sec%+side%*sectors%+1
400 IF sector%=sectors%-1:IF side%=sides%-1:link0%=track%+1:link1%=sec0%:IF track%=tracks%-1:link0%=0:link1%=0:
410 IF sector%=sectors%-1:IF track%=0:IF side%=0:link0%=0:link1%=0:
420 data%?0=link0%
430 data%?1=link1%
440 :
450 X%?0=drive% OR side%*2
460 X%!1=data%
470 X%!5=&4B03
480 X%?7=this%
490 X%?8=sec%
500 X%!9=&21
510 A%=127:REPEAT:CALL&FFF1:UNTIL X%?10<>&10
520 IF X%?10:PRINT TAB(18);"error &";~X%?10
530 NEXT sector%
540 :
550 NEXT side%
560 NEXT track%
570 :
580 PRINT CHR$13;"Initialise SIR ";CHR$8;CHR$8;
590 FOR A%=0 TO 255 STEP 4:data%!A%=0:NEXT A%
600 data%!&1D=&0101
610 data%?&1F=tracks%-1
620 data%?&20=sectors%
630 data%?&21=(sectors%*tracks%*sides%-sectors%) DIV 256
640 data%?&22=(sectors%*tracks%*sides%-sectors%) AND 255
650 data%!&23=&730101
660 data%?&26=tracks%-1
670 data%?&27=sectors%
680 :
690 X%?0=drive%
700 X%!1=data%
710 X%!5=&03004B03
720 X%!9=&21
730 A%=127:REPEAT:CALL&FFF1:UNTIL X%?10<>&10
740 IF X%?10:PRINT TAB(18);"error &";~X%?10
750 PRINT
760 :
770 OSCLI"FX180,"+STR$(PAGE/256):END