
 1000  *      .LIST OFF
 1010  *---------------------------------
 1020  *      DOS 3.3 DISASSEMBLY     $BEAF-BFFF
 1030  *      BOB SANDER-CEDERLOF        3-26-81
 1040  *---------------------------------
 1050  RETRY.COUNT         .EQ $578
 1060  *---------------------------------
 1070  PHASE.OFF           .EQ $C080
 1080  PHASE.ON            .EQ $C081
 1090  MOTOR.OFF           .EQ $C088
 1100  MOTOR.ON            .EQ $C089
 1110  ENABLE.DRIVE.1      .EQ $C08A
 1120  ENABLE.DRIVE.2      .EQ $C08B
 1130  Q6L                 .EQ $C08C
 1140  Q6H                 .EQ $C08D
 1150  Q7L                 .EQ $C08E
 1160  Q7H                 .EQ $C08F
 1170  *---------------------------------
 1180  SECTOR     .EQ $2D
 1190  CONST.AA   .EQ $3E
 1200  FMT.SECTOR .EQ $3F
 1210  VOLUME     .EQ $41
 1220  TRACK.CNTR .EQ $44
 1230  SYNC.CNT   .EQ $45
 1240  IOB.PNTR   .EQ $48,49
 1250  *---------------------------------
 1260  WRITE.SECTOR        .EQ $B82A
 1270  READ.SECTOR         .EQ $B8DC
 1280  READ.ADDRESS        .EQ $B944
 1290  RWTS.BUFFER         .EQ $BB00
 1300  WRITE.ADDRESS       .EQ $BC56
 1310  SEEK.TRACK          .EQ $BE5A
 1320  SETUP.TRACK         .EQ $BE95
 1330  *---------------------------------
 1340  ERR.CANT.FORMAT     .EQ $08
 1350  *---------------------------------
 1360         .OR $BEAF
 1370         .TA $800
 1380  *---------------------------------
 1390  FORMAT LDY #3       POINT AT VOLUME NUMBER
 1400         LDA (IOB.PNTR),Y
 1410         STA VOLUME
 1420         LDA #$AA     SET UP CONSTANT IN PAGE ZERO
 1430         STA CONST.AA FOR TIMING
 1440         LDY #86      CLEAR BUFFER TO ALL 00'S
 1450         LDA #0
 1460         STA TRACK.CNTR
 1470  .1     STA RWTS.BUFFER+255,Y
 1480         DEY          UPPER PORTION
 1490         BNE .1
 1500  .2     STA RWTS.BUFFER,Y
 1510         DEY          LOWER PORTION
 1520         BNE .2
 1530         LDA #80      SET UP AS THOUGH IN TRACK 80
 1540         JSR SETUP.TRACK
 1550         LDA #40      START WITH 40 SYNC'S BTWN SECTORS
 1560         STA SYNC.CNT
 1570  *---------------------------------
 1580  .3     LDA TRACK.CNTR
 1590         JSR SEEK.TRACK
 1600         JSR FORMAT.TRACK
 1610         LDA #ERR.CANT.FORMAT
 1620         BCS .5       ERROR
 1630         LDA #48      TRY UP TO 48 TIMES
 1640         STA RETRY.COUNT
 1650  .4     SEC
 1660         DEC RETRY.COUNT
 1670         BEQ .5       OUT OF RETRIES, ERRCODE=$30
 1680         JSR READ.ADDRESS
 1690         BCS .4       ERROR, TRY AGAIN
 1700         LDA SECTOR
 1710         BNE .4       MUST BE SECOTR 0
 1720         JSR READ.SECTOR
 1730         BCS .4       ERROR, TRY AGAIN
 1740         INC TRACK.CNTR   NEXT TRACK
 1750         LDA TRACK.CNTR
 1760         CMP #35      FINISHED?
 1770         BCC .3       NOT YET
 1780         CLC          INDICATE NO ERROR
 1790         BCC .6       ...ALWAYS
 1800  *---------------------------------
 1810  .5     LDY #13      POINT AT ERROR SLOT IN IOB
 1820         STA (IOB.PNTR),Y
 1830         SEC          FLAG ERROR
 1840  .6     LDA MOTOR.OFF,X   STOP DRIVE
 1850         RTS
 1860  *---------------------------------
 1870  *      FORMAT A TRACK
 1880  *---------------------------------
 1890  FORMAT.TRACK
 1900         LDA #0       START WITH SECTOR 0
 1910         STA FMT.SECTOR
 1920         LDY #128     EXTRA SYNC'S BEFORE FIRST SECTOR
 1930         BNE .2       ...ALWAYS
 1940  .1     LDY SYNC.CNT
 1950  .2     JSR WRITE.ADDRESS
 1960         BCS .10      ERROR, EXIT NOW
 1970         JSR WRITE.SECTOR
 1980         BCS .10      ERROR, EXIT NOW
 1990         INC FMT.SECTOR  NEXT SECTOR
 2000         LDA FMT.SECTOR
 2010         CMP #16      FINISHED WITH THIS TRACK?
 2020         BCC .1       NOT YET
 2030  *---------------------------------
 2040  *      VERIFY THE TRACK
 2050  *---------------------------------
 2060         LDY #15      START WITH SECOTR 15
 2070         STY FMT.SECTOR
 2080         LDA #48      RETRY UP TO 48 TIMES
 2090         STA RETRY.COUNT
 2100  .3     STA SECTOR.FLAGS,Y  CLEAR ALL THE SECTOR FLAGS
 2110         DEY
 2120         BPL .3
 2130         LDY SYNC.CNT DELAY A WHILE
 2140  .4     JSR .10      12 CYCLES
 2150         JSR .10      12 CYCLES
 2160         JSR .10      12 CYCLES
 2170         PHA          PHA+PLA=7 CYCLES
 2180         PLA
 2190         NOP          NOP+DEY+BNE=7 CYCLES
 2200         DEY
 2210         BNE .4       WHOLE LOOP = 50 CYCLES
 2220         JSR READ.ADDRESS
 2230         BCS .8       ERROR, TRY AGAIN
 2240         LDA SECTOR   BETTER BE SECTOR 0
 2250         BEQ .6       IT IS, HURRAY!
 2260         LDA #16      REDUCE # SYNC'S BY TWO
 2270         CMP SYNC.CNT UNLESS ALREADY < 16
 2280         LDA SYNC.CNT
 2290         SBC #1       
 2300         STA SYNC.CNT
 2310         CMP #5       IF SYNC.CNT < 5, THERE IS NO HOPE
 2320         BCS .8       >=5, TRY AGAIN
 2330         SEC          FLAG COULDN'T DO IT
 2340         RTS
 2350  .5     JSR READ.ADDRESS
 2360         BCS .7       ERROR, TRY AGAIN
 2370  .6     JSR READ.SECTOR
 2380         BCC .11      GOOD!
 2390  .7     DEC RETRY.COUNT
 2400         BNE .5       TRY AGAIN
 2410  .8     JSR READ.ADDRESS
 2420         BCS .9
 2430         LDA SECTOR
 2440         CMP #15      SECTOR = 15?
 2450         BNE .9       NO
 2460         JSR READ.SECTOR
 2470         BCC FORMAT.TRACK
 2480  .9     DEC RETRY.COUNT
 2490         BNE .8       TRY AGAIN
 2500         SEC          FLAG WE COULDN'T DO IT
 2510  .10    RTS          RETURN
 2520  *---------------------------------
 2530  .11    LDY SECTOR
 2540         LDA SECTOR.FLAGS,Y
 2550         BMI .7       ALREADY READ THIS ONE!
 2560         LDA #$FF
 2570         STA SECTOR.FLAGS,Y
 2580         DEC FMT.SECTOR
 2590         BPL .5
 2600         LDA TRACK.CNTR
 2610         BNE .12
 2620         LDA SYNC.CNT
 2630         CMP #16
 2640         BCC .10
 2650         DEC SYNC.CNT
 2660         DEC SYNC.CNT
 2670  .12    CLC
 2680         RTS
 2690  *---------------------------------
 2700  SECTOR.FLAGS
 2710         .HS FFFFFFFFFFFFFFFF
 2720         .HS FFFFFFFFFFFFFFFF
 2730  *---------------------------------
 2740  PHYSICAL.SECTOR.VECTOR
 2750         .HS 000D0B0907050301
 2760         .HS 0E0C0A080604020F
 2770  *---------------------------------
 2780  *      CLOBBER WHATEVER IS IN RAM CARD
 2790  *---------------------------------
 2800  PATCH1 JSR $FE93    WHAT PATCH REPLACED
 2810         LDA $C081    WRITE-ENABLE RAM CARD
 2820         LDA $C081
 2830         LDA #0       PUT ZERO IN BYTE WE LATER
 2840         STA $E000    TEST TO SEE WHICH LANGUAGE
 2850         JMP $B744    RETURN
 2860  *---------------------------------
 2870  *---------------------------------
 2880  *      VARIOUS ODDS AND ENDS
 2890  *---------------------------------
 2900         .HS 000000
 2910  PATCH2 STA $AA63
 2920         STA $AA70
 2930         STA $AA71
 2940         RTS
 2950  PATCH3 JSR $A75B
 2960         STY $AAB7
 2970         RTS
 2980  PATCH4 JSR $AE7E    FROM $B377
 2990         LDX $B39B
 3000         TXS
 3010         JSR $A316
 3020         TSX
 3030         STX $B39B
 3040         LDA #9       "DISK FULL" ERROR
 3050         JMP $B385

