     $F1A9/61865:   Find free sector and allocate

    Jump from $DCDA:

    F1A9: A9 01     LDA #$01
    F1AB: 0D F9 02  ORA $02F9
    F1AE: 8D F9 02  STA $02F9
    F1B1: A5 86     LDA $86
    F1B3: 48        PHA
    F1B4: A9 01     LDA #$01        ; track counter
    F1B6: 85 86     STA $86

    Jump from $F1E4:

    F1B8: AD 85 FE  LDA $FE85       ; 18, directory track
    F1BB: 38        SEC
    F1BC: E5 86     SBC $86         ; minus counter
    F1BE: 85 80     STA $80         ; save as track number
    F1C0: 90 09     BCC $F1CB       ; result <= zero?
    F1C2: F0 07     BEQ $F1CB       ; then try top half of directory
    F1C4: 20 11 F0  JSR $F011       ; find BAM field for this track
    F1C7: B1 6D     LDA ($6D),Y     ; number of free blocks in this track
    F1C9: D0 1B     BNE $F1E6       ; free blocks exist

    Jump from $F1C0, $F1C2:

    F1CB: AD 85 FE  LDA $FE85       ; 18, directory track
    F1CE: 18        CLC
    F1CF: 65 86     ADC $86         ; plus counter
    F1D1: 85 80     STA $80         ; save as track number
    F1D3: E6 86     INC $86         ; increment counter
    F1D5: CD D7 FE  CMP $FED7       ; 36, max track number plus one
    F1D8: 90 05     BCC $F1DF       ; smaller, then ok
    F1DA: A9 67     LDA #$67
    F1DC: 20 45 E6  JSR $E645       ; 67, 'illegal track or sector'

    Jump from $F1D8:

    F1DF: 20 11 F0  JSR $F011       ; find BAM field for this track
    F1E2: B1 6D     LDA ($6D),Y     ; number of free blocks?
    F1E4: F0 D2     BEQ $F1B8       ; no more free blocks?

    Jump from $F1C9:

    F1E6: 68        PLA
    F1E7: 85 86     STA $86
    F1E9: A9 00     LDA #$00
    F1EB: 85 81     STA $81         ; sector 0
    F1ED: 20 FA F1  JSR $F1FA       ; find free sector
    F1F0: F0 03     BEQ $F1F5       ; not found?
    F1F2: 4C 90 EF  JMP $EF90       ; allocate block in BAM

    Jump from $F1F0, $F1A6:

    F1F5: A9 71     LDA #$71
    F1F7: 20 45 E6  JSR $E645       ; 71, 'dir error'

        Previous Page / Next Page