
 1000  *---------------------------------
 1010  *      DOS 3.3 BOOT ROM $C600.C6FF
 1020  *
 1030  *      COMMENTS BY BOB SANDER-CEDERLOF
 1040  *                  JULY, 4, 1981
 1050  *---------------------------------
 1060  *      DISK CONTROLLER ADDRESSES
 1070  *---------------------------------
 1080  PHOFF  .EQ $C080    PHASE-OFF
 1090  PHON   .EQ $C081    PHASE-ON
 1100  MTROFF .EQ $C088    MOTOR OFF
 1110  MTRON  .EQ $C089    MOTOR ON
 1120  DRV0EN .EQ $C08A    DRIVE 0 ENABLE
 1130  DRV1EN .EQ $C08B    DRIVE 1 ENABLE
 1140  Q6L    .EQ $C08C    SET Q6 LOW
 1150  Q6H    .EQ $C08D    SET Q6 HIGH
 1160  Q7L    .EQ $C08E    SET Q7 LOW
 1170  Q7H    .EQ $C08F    SET Q7 HIGH
 1180  *
 1190  *      Q6    Q7     USE OF Q6 AND Q7 LINES
 1200  *     ----  ----    ----------------------
 1210  *     LOW   LOW     READ (DISK TO SHIFT REGISTER)
 1220  *     LOW   HIGH    WRITE (SHIFT REGISTER TO DISK)
 1230  *     HIGH  LOW     SENSE WRITE PROTECT
 1240  *     HIGH  HIGH    LOAD SHIFT REGISTER FROM DATA BUS
 1250  *---------------------------------
 1260  BUFFER.PNTR .EQ $26,27
 1270  SLOT16 .EQ $2B      SLOT NUMBER TIMES 16
 1280  SECTOR .EQ $3D
 1290  TRACK  .EQ $41
 1300  STACK      .EQ $0100
 1310  POST.NYBBLE.CODES .EQ $02D6
 1320  LITTLE.BUFFER     .EQ $0300
 1330  MON.RTS    .EQ $FF58
 1340  MON.WAIT   .EQ $FCA8
 1350  *---------------------------------
 1360         .OR $C600
 1370         .TA $0800
 1380  *---------------------------------
 1390  BOOT.3.3
 1400         LDX #$20     REDUNDANT INSTRUCTION, USED
 1410  *                   TO IDENTIFY CONTROLLER CARD
 1420  *---------------------------------
 1430  *      GENERATE POST-NYBBLE CONVERSION TABLE
 1440  *          FILLS IN THOSE SLOTS WHOSE INDEX
 1450  *          RELATIVE TO POST.NYBBLE.CODES IS
 1460  *          A VALID NYBBLE CODE.  (VALID CODES
 1470  *          HAVE AT MOST ONE PAIR OF ADJACENT
 1480  *          0-BITS, AND AT LEAST ONE PAIR OF
 1490  *          ADJACENT 1-BITS IN BITS 0-6.)
 1500  *---------------------------------
 1510         LDY #0
 1520         LDX #3       COULD BE ANY VALUE FROM 0 TO $16
 1530  *                   3 USED FOR CONTROLLER ID
 1540  .1     STX $3C      CHECK CODE FOR VALID NYBBLE
 1550         TXA
 1560         ASL
 1570         BIT $3C      TEST (X .AND. 2*X)
 1580         BEQ .3       NO ADJACENT 1-BITS, NO GOOD
 1590         ORA $3C      TEST ADJACENT 0-BITS
 1600         EOR #$FF     CHANGE TO 1'S FOR TEST
 1610         AND #$7E     DON'T CARE ABOUT BIT 7
 1620  .2     BCS .3       NOT VALID NYBBLE CODE
 1630         LSR
 1640         BNE .2
 1650         TYA
 1660         STA POST.NYBBLE.CODES+$80,X
 1670         INY
 1680  .3     INX
 1690         BPL .1
 1700  *---------------------------------
 1710         JSR MON.RTS  GET THIS LOCATION ON STACK
 1720         TSX          FIND THE PAGE BYTE ON STACK
 1730         LDA STACK,X
 1740         ASL          ISOLATE SLOT NUMBER
 1750         ASL          AND MULTIPLY BY 16
 1760         ASL
 1770         ASL
 1780         STA SLOT16   SLOT NUMBER TIMES 16
 1790         TAX
 1800         LDA Q7L,X    SET UP TO READ DRIVE
 1810         LDA Q6L,X
 1820         LDA DRV0EN,X ENABLE DRIVE 0
 1830         LDA MTRON,X  TURN ON MOTOR
 1840  *---------------------------------
 1850  *      MOVE TO TRACK 0 (ASSUME WORST CASE
 1860  *      INITIAL POSITION OF TRACK 40).
 1870  *---------------------------------
 1880         LDY #80      80 HALF-TRACKS
 1890  .4     LDA PHOFF,X  STEPPER MOTOR PHASE OFF
 1900         TYA          COMPUTE NEXT PHASE
 1910         AND #3       YIELDS 3,2,1,0
 1920         ASL          YIELDS 6,4,2,0
 1930         ORA SLOT16   MERGE WITH SLOT*16
 1940         TAX
 1950         LDA PHON,X   STEPPER MOTOR PHASE ON
 1960         LDA #86      WAIT 19.2 MILLISECONDS
 1970         JSR MON.WAIT NO CHANGE TO X OR Y, A=0
 1980         DEY          NEXT HALF-TRACK
 1990         BPL .4
 2000  *---------------------------------
 2010  *      A=0, X=SLOT*16
 2020  *---------------------------------
 2030         STA BUFFER.PNTR   ($00 --> LOW BYTE OF PNTR)
 2040         STA SECTOR 0
 2050         STA TRACK 0
 2060         LDA #8       BUFFER AT $0800
 2070         STA BUFFER.PNTR+1  ($08 --> HI-BYTE OF PNTR)
 2080  *---------------------------------
 2090  READ.SECTOR
 2100  .1     CLC          FLAG CLEAR, LOOK FOR $D5 AA 96
 2110  .2     PHP          SAVE FLAG ON STACK
 2120  .3     LDA Q6L,X    READ DISK
 2130         BPL .3
 2140  .4     EOR #$D5
 2150         BNE .3       NO
 2160  .5     LDA Q6L,X    READ DISK
 2170         BPL .5
 2180         CMP #$AA
 2190         BNE .4
 2200         NOP
 2210  .6     LDA Q6L,X    READ DISK
 2220         BPL .6
 2230         CMP #$96
 2240         BEQ .7       FOUND ADDRESS MARK: $D5 AA 96
 2250         PLP          RETRIEVE FLAG
 2260         BCC .1       LOOKING FOR ADDRESS HEADER
 2270         EOR #$AD     LOOKING FOR DATA HEADER
 2280         BEQ FILL.BUFFER
 2290         BNE .1       START ALL OVER
 2300  *---------------------------------
 2310  .7     LDY #3       READ VOLUME, TRACK, SECTOR
 2320  .8     STA $40
 2330  .9     LDA Q6L,X    READ DISK
 2340         BPL .9
 2350         ROL          SAVE UPPER SLICE
 2360         STA $3C
 2370  .10    LDA Q6L,X    READ DISK
 2380         BPL .10
 2390         AND $3C      MERGE SLICES
 2400         DEY          3RD BYTE YET?
 2410         BNE .8       NO, GET ANOTHER
 2420         PLP          THROW AWAY FLAG
 2430         CMP SECTOR   CORRECT SECTOR?
 2440         BNE .1       NO
 2450         LDA $40      CORRECT TRACK?
 2460         CMP TRACK
 2470         BNE .1       NO
 2480         BCS .2       YES, SET FLAG FOR DATA HEADER
 2490  *                   AND BRANCH BACK ALWAYS
 2500  *---------------------------------
 2510  *      A=0 ON ENTRY
 2520  *---------------------------------
 2530  FILL.BUFFER
 2540         LDY #86      READ 86 BYTES
 2550  .1     STY $3C
 2560  .2     LDY Q6L,X    READ BYTE
 2570         BPL .2
 2580         EOR POST.NYBBLE.CODES,Y  DECODE BYTE
 2590         LDY $3C
 2600         DEY
 2610         STA LITTLE.BUFFER,Y
 2620         BNE .1
 2630  *---------------------------------
 2640  .3     STY $3C      Y=0
 2650  .4     LDY Q6L,X    READ BYTE
 2660         BPL .4
 2670         EOR POST.NYBBLE.CODES,Y DECODE BYTE
 2680         LDY $3C
 2690         STA (BUFFER.PNTR),Y
 2700         INY
 2710         BNE .3
 2720  .5     LDY Q6L,X    READ CHECKSUM BYTE
 2730         BPL .5
 2740         EOR POST.NYBBLE.CODES,Y
 2750  .6     BNE READ.SECTOR  BAD CHECKSUM, START OVER
 2760  *---------------------------------
 2770         LDY #0
 2780  .7     LDX #86      PATCH THE 6+2 BACK TOGETHER
 2790  .8     DEX
 2800         BMI .7       FINISHED A TRIP
 2810         LDA (BUFFER.PNTR),Y
 2820         LSR LITTLE.BUFFER,X
 2830         ROL
 2840         LSR LITTLE.BUFFER,X
 2850         ROL
 2860         STA (BUFFER.PNTR),Y
 2870         INY
 2880         BNE .8
 2890  *---------------------------------
 2900         INC BUFFER.PNTR+1  POINT AT NEXT PAGE
 2910         INC SECTOR    POINT AT NEXT SECOTR
 2920         LDA SECTOR
 2930         CMP $0800    SEE IF HAVE READ ENUF SECTORS
 2940         LDX SLOT16
 2950         BCC .6       NOT ENUF SECTORS YET
 2960         JMP $0801    GO TO REST OF BOOT
 2970  *---------------------------------
 2980         .HS 0000000000  UNUSED BYTES IN ROM

