
 1000  *SAVE S.FORMAT.UNIDISK
 1010  *--------------------------------
 1020  UNIDISK.SLOT .EQ 5
 1030   
 1040  RWTS         .EQ $3D9
 1050   
 1060  PC.DISPATCH  .EQ UNIDISK.SLOT*$100+$C000
 1070   
 1080  HOME         .EQ $FC58
 1090  COUT         .EQ $FDED
 1100  *--------------------------------
 1110         .OR $803
 1120  *      .TF FORMAT.UNIDISK
 1130   
 1140  FORMAT CLC
 1150         LDA UNIDISK.SLOT*$100+$C0FF
 1160         ADC #3
 1170         STA PC.CALL
 1180         JSR PC.DISPATCH   format the disk
 1190  PC.CALL .EQ *-2
 1200         .DA #3
 1210         .DA PC.PARMS
 1220         BCS ERROR
 1230         LDA #2
 1240         STA DRIVE         do drive 2 first
 1250   
 1260  DO.CATALOG
 1270         JSR CLEAR.BUFFER
 1280         LDA #$11
 1290         STA TRACK
 1300         STA MY.BUFFER+1   link pointer
 1310         LDY #$1F
 1320  .1     STY SECTOR
 1330         DEY
 1340         BNE .2
 1350         STY MY.BUFFER+1   mark end of catalog
 1360  .2     STY MY.BUFFER+2   link pointer
 1370         JSR CALL.RWTS
 1380         LDY SECTOR
 1390         DEY
 1400         BNE .1            and go back for more
 1410         STY SECTOR
 1420   
 1430  DO.VTOC
 1440         JSR CLEAR.BUFFER
 1450         LDX #0
 1460  .1     LDY VTOC.INDEXES,X
 1470         LDA VTOC.VALUES,X
 1480         STA MY.BUFFER,Y   set VTOC header info
 1490         INX
 1500         CPX #ENTRY.COUNT
 1510         BCC .1
 1520         LDA DRIVE         use drive # for volume
 1530         STA MY.BUFFER+6
 1540         LDA #$FF
 1550         INY
 1560  .2     INY               skip a track in bitmap
 1570         INY
 1580         INY
 1590         INY
 1600  .3     STA MY.BUFFER,Y   mark free
 1610         INY
 1620         BEQ .4            leave if done
 1630         CPY #$7C          track $11?
 1640         BEQ .2            yes, skip it
 1650         BNE .3            no, go on
 1660  .4     JSR CALL.RWTS     
 1670         DEC DRIVE         now go back and
 1680         BNE DO.CATALOG    do drive one
 1690   
 1700  DO.BOOT.SECTOR
 1710         INC DRIVE         that was drive one,
 1720         JSR CLEAR.BUFFER  so write a boot sector
 1730         STA TRACK         A = 0
 1740         STA SECTOR
 1750         LDY #BOOT.SIZE
 1760  .1     LDA BOOT.IMAGE,Y  install the image
 1770         STA MY.BUFFER,Y
 1780         DEY
 1790         BPL .1            fall into CALL.RWTS
 1800  *--------------------------------
 1810  CALL.RWTS
 1820         LDA /IOB
 1830         LDY #IOB
 1840         JSR RWTS
 1850         BCS ERROR
 1860         RTS
 1870  ERROR  BRK
 1880  *--------------------------------
 1890  CLEAR.BUFFER
 1900         LDY #0
 1910         TYA
 1920  .1     STA MY.BUFFER,Y
 1930         INY
 1940         BNE .1
 1950         RTS
 1960  *--------------------------------
 1970  PC.PARMS .DA #1     one parm
 1980           .DA #1     unit one
 1990  *--------------------------------
 2000  IOB    .DA #1
 2010  SLOT   .DA #UNIDISK.SLOT*$10
 2020  DRIVE  .BS 1
 2030  VOL    .DA #0
 2040  TRACK  .BS 1
 2050  SECTOR .BS 1
 2060  DCT    .DA $B7FB
 2070  BUFFER .DA MY.BUFFER
 2080         .BS 1
 2090         .DA #0
 2100  COMAND .DA #2       write
 2110  RETURN .BS 1
 2120  P.VOL  .BS 1
 2130  P.SLOT .BS 1
 2140  P.DRIV .BS 1
 2150  *--------------------------------
 2160  VTOC.INDEXES .HS 00.01.02.03.27.30.31.34.35.36.37
 2170  ENTRY.COUNT .EQ *-VTOC.INDEXES
 2180  VTOC.VALUES  .HS 04.11.1F.03.7A.11.01.32.20.00.01
 2190  *--------------------------------
 2200  BOOT.IMAGE
 2210         .PH $800
 2220  BOOT   .HS 01
 2230         JSR HOME
 2240         LDY #0
 2250  .1     LDA MESSAGE,Y
 2260         BEQ .2
 2270         JSR COUT          print message
 2280         INY
 2290         BNE .1
 2300  .2     BEQ .2            and hang...
 2310   
 2320  MESSAGE
 2330         .HS 8D8D8D
 2340         .AS -/Sorry, can't boot DOS here yet./
 2350         .HS 8D8700
 2360         .EP
 2370  BOOT.SIZE .EQ *-BOOT.IMAGE
 2380  *--------------------------------
 2390  MY.BUFFER
 2400         .LIF

