Automatic Generated Disassembly of `dos1'



; *** text follows ***

 *=$E000



; This is a commented disassembly of the DOS V1 as used
; in the Commodore 2040 dual disk drive. The disassembly
; is taken from the images of the ROM chips named 
; "901468-06.bin" and "901468-07.bin".
; ;
; Technically the disassembly was produced and merged
; with the comments using the "recomment" utility
; (version 4.08 at least).
; ;
; To create the comments, I compared the ROM source code
; of the 4040 dual disk drive with DOS V2. The uppercase
; comments are copied from the 4040 DOS. I have added the
; (few) lowercase comments myself.
; ;
; In general there is only littel code that remains unchanged,
; if any at all. A lot of code only has minor changes, though.
; Some code has major changes.
; ;
; I found an interesting comment for routine "USER" in the 4040
; ROM. The comment is "ROM 1.1 ADDITIONS" and seems to indicate
; that there was a version before the 2040 DOS version, 
; because the USER command already exists in the 2040.
; ;
; I was unable to completely relate the code to the new version
; as used in the 4040. I could not relate the following methods:
; ED53
; F482
; F67A, F80F, F851
; ;
; 15. May 2005 Andre Fachat (afachat@gmx.de)
; ;
; INIT-DRIVE VEIFY-DIR DUPLICATE MEMORY-OP BLOCK-OP USER POSITION DSKCPY RENAME SCRATCH NEW

 E000  CMDTBL     .byte $49, $56, $44, $4D, $42, $55, $43, $52  ;ivdmbucr
 E008             .byte $53, $4E                                ;sn


; <INTDRV, <VERDIR, <DUPLCT, <MEM, <BLOCK, <USER, <DSKCPY, <RENAME, <SCRTCH, <NEW

 E00A  CJUMPL     .byte $A8, $37, $ED, $ED, $E5, $43, $47, $D3  ;(7...cgS
 E012             .byte $73, $C8                                ;SH


; >INTDRV, >VERDIR, >DUPLCT, >MEM, >BLOCK, >USER, >DSKCPY, >RENAME, >SCRTCH, >NEW

 E014  CJUMPH     .byte $E8, $FC, $F9, $FC, $FD, $FD, $FB, $FB  ;........
 E01C             .byte $F9, $F8
; ;
; original 4040 comment for the next bytes
; the bytes for RENAMEi ($dd), SCRATCH ($1c) and NEW ($9e) seem to be the same at the 
; same place, but DSKCPY is different (here $d9, in 4040 it's $51)
; and LOAD is missing here.
; e
; ; STRUCTURE IMAGES FOR CMDS
; PCMD =8
; .BYT %01010001 ; DSKCPY
; STRUCT  =*-PCMD ; CMDS NOT PARSED
; .BYT %11011101 ; RENAME
; .BYT %00011100 ; SCRATCH
; .BYT %10011110 ; NEW
; LDCMD   =*-STRUCT ; LOAD CMD IMAGE
; .BYT %00011100 ; LOAD
; ;            --- ---
; ;            PGDRPGDR
; ;            FS1 FS2
; ;
; ;   BIT REPS:  NOT PATTERN
; ;              NOT GREATER THAN ONE FILE
; ;              NOT DEFAULT DRIVE(S)
; ;              REQUIRED FILENAME

, $D9, $DD, $1C, $9E            ;..Y.\.

; number of sectors per track (from hi to lo)

 E022  TRKTBL     .byte $15, $14, $12, $11                      ;utrq


; highest track of each speed zone

 E026  CHGTRACKS  .byte $11, $18, $1E, $23                      ;qx^#


; last byte of a BAM track entry per speed zone

 E02A  BAMEND     .byte $1F, $0F, $03, $01                      ;_oca


; list of file modes

 E02E  MODLST     .byte $52, $57, $4D                           ;rwm


; filetypes available "DEL", "SEQ", "PRG", "USR". Note: no "REL"!

 E031  TYPLST     .byte $44, $53, $50, $55                      ;dspu
 E035  TP1LST     .byte $45, $45, $52, $53                      ;eers
 E039  TP2LST     .byte $4C, $51, $47, $52                      ;lqgr


; ;

 E03D             .byte $AA, $AA, $DA                           ;**Z



; start of special routine to be copied to controller buffer

 E040  CODE       .byte $A5, $1B, $10, $3A, $78, $A9, $C1, $95  ;%[p:X)A.
 E048             .byte $03, $A9, $0F, $3D, $EF, $FF, $05, $40  ;c)o=..e@
 E050             .byte $85, $40, $A9, $8C, $95, $05, $58, $B5  ;.@)..ex5
 E058             .byte $05, $D0, $FC, $98, $0A, $0A, $0A, $18  ;eP..jjjx
 E060             .byte $69, $21, $85, $18, $A0, $00, $84, $1F  ;I!.x .._
 E068             .byte $C8, $84, $1B, $C8, $B1, $18, $29, $C0  ;H.[H1x).
 E070             .byte $09, $01, $91, $18, $A4, $1A, $29, $3F  ;ia.x$z)?
 E078             .byte $99, $12, $04, $4C, $47, $FC, $D9, $12  ;.rdlg.Yr
 E080             .byte $04, $D0, $F5, $78, $A9, $19, $85, $0A  ;dP.X)y.j
 E088             .byte $A0, $03, $A9, $00, $91, $18, $A9, $10  ; c)..x)p
 E090             .byte $85, $4E, $A9, $DC, $85, $4C, $A9, $08  ;.n)..l)h
 E098             .byte $25, $82, $F0, $05, $A9, $08, $4C, $C3  ;%..e)hlC
 E0A0             .byte $FE, $A0, $03, $A9, $00, $51, $18, $88  ;. c).qx.
 E0A8             .byte $10, $FB, $A0, $04, $91, $18, $A2, $FF  ;p. d.x".
 E0B0             .byte $86, $81, $84, $08, $E8, $A0, $00, $20  ;...h. . 
 E0B8             .byte $7C, $FF, $88, $D0, $FA, $C6, $08, $D0  ;|..P.FhP
 E0C0             .byte $F6, $A2, $00, $A0, $00, $20, $7C, $FF  ;.". . |.
 E0C8             .byte $88, $D0, $FA, $A9, $DE, $86, $08, $CA  ;.P.)..hJ
 E0D0             .byte $20, $7C, $FF, $85, $4C, $20, $7C, $FF  ; |..l |.
 E0D8             .byte $A9, $DC, $A2, $08, $20, $7C, $FF, $85  ;)."h |..
 E0E0             .byte $4C, $A0, $04, $B1, $18, $24, $4D, $10  ;l d1x$mp
 E0E8             .byte $FC, $85, $80, $24, $41, $88, $10, $F3  ;...$a.p.
 E0F0             .byte $A4, $0A, $20, $7C, $FF, $88, $D0, $FA  ;$j |..P.
 E0F8             .byte $A0, $03, $B1, $18, $85, $08, $18, $69  ; c1x.hxI
 E100             .byte $01, $91, $18, $C5, $15, $F0, $0A, $C8  ;a.xEu.jH
 E108             .byte $45, $08, $51, $18, $91, $18, $4C, $81  ;ehqx.xl.
 E110             .byte $05, $20, $59, $FF, $A2, $FA, $20, $2D  ;e y.". -
 E118             .byte $FF, $70, $06, $C6, $0A, $F0, $1C, $D0  ;.PfFj.\P
 E120             .byte $0F, $A2, $28, $20, $2D, $FF, $50, $0B  ;o"( -.pk
 E128             .byte $E6, $0A, $A5, $0A, $C9, $30, $F0, $0B  ;.j%jI0.k
 E130             .byte $4C, $48, $05, $A5, $1F, $C9, $30, $D0  ;lhe%_I0P
 E138             .byte $0B, $06, $1E, $A9, $FF, $85, $1B, $A9  ;kf^)..[)
 E140             .byte $0C, $4C, $F9, $FE, $A9, $80, $85, $1E  ;ll..)..^
 E148             .byte $A9, $00, $A0, $03, $91, $18, $20, $CE  ;). c.x N
 E150             .byte $FE, $A0, $03, $B1, $18, $18, $69, $01  ;. c1xxIa
 E158             .byte $91, $18, $C5, $15, $D0, $F0, $06, $1E  ;.xEuP.f^
 E160             .byte $E6, $1B, $A5, $1B, $C9, $24, $F0, $12  ;.[%[I$.r
 E168             .byte $A0, $02, $B1, $18, $29, $C0, $05, $1B  ; b1x).e[
 E170             .byte $91, $18, $A6, $12, $FE, $12, $04, $4C  ;.x&r.rdl
 E178             .byte $47, $FC, $A9, $FF, $85, $1B, $4C, $C1  ;g.)..[lA
 E180             .byte $FE                                     ;.


; test for diagnostic ROM


 E181  A2 00     DROMTS     LDX #$00       ; test for diagnostic ROM
 E183  A9 55                LDA #$55      
 E185  CD 00 D0  iE185      CMP DIAGROM   
 E188  D0 03                BNE iE18D     
 E18A  CA                   DEX           
 E18B  D0 F8                BNE iE185     
 E18D  60        iE18D      RTS           

 E18E  D8        DSKINT     CLD            ; RESET drive
 E18F  78                   SEI           
 E190  A2 FF                LDX #$FF      
 E192  9A                   TXS           
 E193  8E 02 02             STX RIOT1IEEEDO
 E196  8E 03 02             STX RIOT1PBDD 
 E199  A9 1C                LDA #$1C       ; DAVO+EOIO+RFDO
 E19B  8D 80 02             STA RIOT2PAD  
 E19E  A9 1F                LDA #$1F      
 E1A0  8D 81 02             STA RIOT2PADD 
 E1A3  A9 38                LDA #$38       ; ERRLED+ACTLDB+ACTLDA
 E1A5  8D 82 02             STA RIOT2PBD  
 E1A8  8D 83 02             STA RIOT2PBDD 
 E1AB  A2 00                LDX #$00       ; test zeropage
 E1AD  8A                   TXA           
 E1AE  A0 55     iE1AE      LDY #$55      
 E1B0  94 00                STY CMDBUF,X  
 E1B2  CA                   DEX           
 E1B3  D0 F9                BNE iE1AE     
 E1B5  AA                   TAX           
 E1B6  A9 AA     iE1B6      LDA #$AA      
 E1B8  16 00                ASL CMDBUF,X  
 E1BA  55 00                EOR CMDBUF,X  
 E1BC  95 00                STA CMDBUF,X  
 E1BE  D0 1E                BNE ZPBAD     
 E1C0  CA                   DEX           
 E1C1  D0 F3                BNE iE1B6     
 E1C3  20 81 E1             JSR DROMTS     ; check for diagnostic ROM
 E1C6  D0 1C                BNE EROMCHK    ; not here, goto E-ROM test
 E1C8  4C 05 D0             JMP DIAGROM+5  ; diagnostic hook
 E1CB  A2 10     ROMTST     LDX #$10      
 E1CD  A0 00                LDY #$00      
 E1CF  98                   TYA           
 E1D0  18                   CLC           
 E1D1  71 30     iE1D1      ADC (IP),Y    
 E1D3  C8                   INY           
 E1D4  D0 FB                BNE iE1D1     
 E1D6  CA                   DEX           
 E1D7  F0 04                BEQ iE1DD     
 E1D9  E6 31                INC IP+1      
 E1DB  D0 F4                BNE iE1D1     
 E1DD  60        iE1DD      RTS           
 E1DE  A9 FF     ZPBAD      LDA #$FF       ; zeropage bad
 E1E0  95 00                STA CMDBUF,X  
 E1E2  D0 FA                BNE ZPBAD      ; endless loop
 E1E4  A9 30     EROMCHK    LDA #$30      
 E1E6  8D 82 02             STA RIOT2PBD  
 E1E9  A9 E0                LDA #$E0      
 E1EB  85 31                STA IP+1      
 E1ED  A9 00                LDA #$00      
 E1EF  85 30                STA IP        
 E1F1  20 CB E1             JSR ROMTST    
 E1F4  C9 00                CMP #$00      
 E1F6  F0 06                BEQ FROMCHK    ; ok, goto F-ROM check
 E1F8  8D 00 E0  BADE       STA CMDTBL     ; this stores into ROM?
 E1FB  4C F8 E1             JMP BADE       ; endless loop
 E1FE  A9 28     FROMCHK    LDA #$28      
 E200  8D 82 02             STA RIOT2PBD  
 E203  A9 F0                LDA #$F0      
 E205  85 31                STA IP+1      
 E207  20 CB E1             JSR ROMTST    
 E20A  C9 00                CMP #$00      
 E20C  F0 06                BEQ DIAGOK    
 E20E  8D 00 F0  BADF       STA xF000      ; this stores into ROM?
 E211  4C 0E E2             JMP BADF       ; endless loop
 E214  A9 00     DIAGOK     LDA #$00      
 E216  8D 82 02             STA RIOT2PBD  
 E219  AD 82 02             LDA RIOT2PBD   ; compute primary IEEE address
 E21C  29 07                AND #$07      
 E21E  09 48                ORA #$48      
 E220  85 33                STA TLKADR    
 E222  49 60                EOR #$60      
 E224  85 32                STA LSNADR    
 E226  A9 81                LDA #$81       ; init command channel
 E228  85 C4                STA CHNRDY+6  
 E22A  A9 30                LDA #$30      
 E22C  8D DF 10             STA CHNDAT+6  
 E22F  20 D6 ED             JSR INTTAB    
 E232  A9 FF                LDA #$FF      
 E234  A2 21                LDX #$21      
 E236  9D B7 10  iE236      STA LINTAB,X  
 E239  CA                   DEX           
 E23A  10 FA                BPL iE236     
 E23C  A9 07                LDA #$07       ; CMDRD
 E23E  8D D5 10             STA LINTAB+30 
 E241  A9 06                LDA #$06       ; CMDWRT
 E243  8D D6 10             STA LINTAB+31 
 E246  A9 3F                LDA #$3F      
 E248  85 3C                STA LINUSE    
 E24A  A9 0F                LDA #$0F      
 E24C  85 6B                STA BUFNUM+12 
 E24E  A9 10                LDA #$10      
 E250  85 6D                STA BUFNUM+14 
 E252  A9 FF                LDA #$FF      
 E254  85 6C                STA BUFNUM+13 
 E256  85 6E                STA BUFNUM+15 
 E258  A9 88                LDA #$88      
 E25A  85 C5                STA CHNRDY+7  
 E25C  A9 01                LDA #$01      
 E25E  85 C4                STA CHNRDY+6  
 E260  A9 00                LDA #$00      
 E262  85 8B                STA BUFUSE    
 E264  A9 E0                LDA #$E0      
 E266  85 8C                STA BUFUSE+1  
 E268  20 49 FD             JSR USRINT     ; init user jump
 E26B  A9 0A                LDA #$0A       ; setup sector offset
 E26D  85 92                STA SECINC    
 E26F  8D 87 02             STA RIOT2ATNPE ; allow ATN to interrupt
 E272  A5 3A     IDLE       LDA CMDWAT    
 E274  F0 08                BEQ IDLE2     
 E276  A9 00                LDA #$00      
 E278  85 3A                STA CMDWAT    
 E27A  78                   SEI           
 E27B  20 44 F0             JSR PARSXQ     ; parse and execute command
 E27E  58        IDLE2      CLI            ; test for drive running or openfile
 E27F  A9 1D                LDA #$1D      
 E281  85 2D                STA TEMP+3    
 E283  A9 00                LDA #$00      
 E285  85 2A                STA TEMP      
 E287  85 2B                STA TEMP+1    
 E289  A6 2D     iE289      LDX TEMP+3     ; look thru LINTAB
 E28B  BD B7 10             LDA LINTAB,X  
 E28E  C9 FF                CMP #$FF       ; for active file
 E290  F0 0E                BEQ iE2A0     
 E292  85 83                STA LINDX     
 E294  20 9D E8             JSR GETACT    
 E297  AA                   TAX           
 E298  BD 99 10             LDA LSTJOB,X   ; determine which drv is on
 E29B  29 01                AND #$01      
 E29D  AA                   TAX           
 E29E  F6 2A                INC TEMP,X    
 E2A0  C6 2D     iE2A0      DEC TEMP+3     ; set flag indicating drive
 E2A2  10 E5                BPL iE289      ; has file open
 E2A4  A0 0E                LDY #$0E       ; look through job queue
 E2A6  B9 03 10  iE2A6      LDA JOBS,Y     ; for jobs still running
 E2A9  10 05                BPL iE2B0     
 E2AB  29 01                AND #$01      
 E2AD  AA                   TAX           
 E2AE  F6 2A                INC TEMP,X     ; set flag indicating drive
 E2B0  88        iE2B0      DEY            ; is active
 E2B1  10 F3                BPL iE2A6     
 E2B3  AD 82 02             LDA RIOT2PBD  
 E2B6  29 E7                AND #$E7       ; 255-ACTLDA-ACTLDB
 E2B8  8D 82 02             STA RIOT2PBD  
 E2BB  A5 2A                LDA TEMP      
 E2BD  F0 08                BEQ iE2C7     
 E2BF  AD 82 02             LDA RIOT2PBD   ; turn on LED if drive flag
 E2C2  09 10                ORA #$10       ; ACTLDB if not 0
 E2C4  8D 82 02             STA RIOT2PBD  
 E2C7  A5 2B     iE2C7      LDA TEMP+1    
 E2C9  F0 08                BEQ iE2D3     
 E2CB  AD 82 02             LDA RIOT2PBD  
 E2CE  09 08                ORA #$08       ; ACTLDA
 E2D0  8D 82 02             STA RIOT2PBD  
 E2D3  4C 7E E2  iE2D3      JMP IDLE2     

 E2D6  A2 FF     ATNIRQ     LDX #$FF       ; IRQ routine (triggered by ATN), listen to PET
 E2D8  9A                   TXS            ; clear stack
 E2D9  AD 87 02             LDA RIOT2ATNPE ; clear IRQ flag
 E2DC  A9 18                LDA #$18       ; DAVO+EOIO
 E2DE  0D 80 02             ORA RIOT2PAD   ; free control lines
 E2E1  8D 80 02             STA RIOT2PAD  
 E2E4  A9 FF                LDA #$FF      
 E2E6  8D 02 02             STA RIOT1IEEEDO ; clear data lines
 E2E9  A9 07     iE2E9      LDA #$07       ; DACO+RFDO+ATNA
 E2EB  0D 80 02             ORA RIOT2PAD  
 E2EE  8D 80 02             STA RIOT2PAD  
 E2F1  2C 80 02  iE2F1      BIT RIOT2PAD  
 E2F4  50 04                BVC iE2FA      ; DAV LO
 E2F6  30 F9                BMI iE2F1      ; ATN LO ATNI HI
 E2F8  10 7B                BPL iE375      ; ATN HI
 E2FA  A9 FB     iE2FA      LDA #$FB       ; 255-RFDO; NRFD LO
 E2FC  2D 80 02             AND RIOT2PAD  
 E2FF  8D 80 02             STA RIOT2PAD  
 E302  29 20                AND #$20       ; save EOI
 E304  85 88                STA EOIFLG    
 E306  AD 00 02             LDA RIOT1IEEEDI
 E309  49 FF                EOR #$FF      
 E30B  85 87                STA DATA       ; save command
 E30D  A9 FD                LDA #$FD       ; 255-DACO; NDAC HI
 E30F  2D 80 02             AND RIOT2PAD  
 E312  8D 80 02             STA RIOT2PAD  
 E315  A0 00                LDY #$00      
 E317  A5 87                LDA DATA      
 E319  29 60                AND #$60      
 E31B  C9 40                CMP #$40       ; TALK?
 E31D  F0 29                BEQ iE348     
 E31F  C9 20                CMP #$20       ; LISTEN?
 E321  F0 06                BEQ iE329     
 E323  C9 60                CMP #$60       ; SECONDARY?
 E325  F0 2F                BEQ iE356     
 E327  D0 44                BNE iE36D      ; OTHER
 E329  A5 87     iE329      LDA DATA      
 E32B  C5 32                CMP LSNADR    
 E32D  F0 0B                BEQ iE33A      ; my listen address
 E32F  C9 3F                CMP #$3F       ; UNLISTEN
 E331  D0 02                BNE iE335     
 E333  84 34                STY LSNACT    
 E335  84 36     iE335      STY ADRSED     ; not primary ADDRSED
 E337  4C 6D E3             JMP iE36D     
 E33A  85 34     iE33A      STA LSNACT    
 E33C  84 35                STY TLKACT    
 E33E  A9 20     iE33E      LDA #$20      
 E340  85 84                STA SA         ; default SA
 E342  85 85                STA ORGSA     
 E344  85 36                STA ADRSED     ; PRIMARY ADDRESSED
 E346  D0 25                BNE iE36D     
 E348  84 35     iE348      STY TLKACT    
 E34A  A5 87                LDA DATA      
 E34C  C5 33                CMP TLKADR    
 E34E  D0 E5                BNE iE335     
 E350  85 35                STA TLKACT    
 E352  84 34                STY LSNACT    
 E354  F0 E8                BEQ iE33E     
 E356  A5 36     iE356      LDA ADRSED    
 E358  F0 13                BEQ iE36D     
 E35A  A5 87                LDA DATA      
 E35C  85 85                STA ORGSA      ; NOT ADDRESSED
 E35E  48                   PHA           
 E35F  29 0F                AND #$0F      
 E361  85 84                STA SA        
 E363  68                   PLA           
 E364  29 F0                AND #$F0       ; CLOSE?
 E366  C9 E0                CMP #$E0      
 E368  D0 03                BNE iE36D     
 E36A  20 0F EC             JSR CLOSE     
 E36D  2C 80 02  iE36D      BIT RIOT2PAD  
 E370  50 FB                BVC iE36D     
 E372  4C E9 E2             JMP iE2E9     
 E375  A5 34     iE375      LDA LSNACT    
 E377  F0 0F                BEQ iE388     
 E379  A9 FA                LDA #$FA       ; 255-RFDO-ATNA
 E37B  2D 80 02             AND RIOT2PAD  
 E37E  8D 80 02             STA RIOT2PAD  
 E381  58                   CLI           
 E382  20 9B E3             JSR LISTEN    
 E385  4C 72 E2             JMP IDLE      
 E388  A9 FC     iE388      LDA #$FC       ; 255-RFDO-ATNA
 E38A  2D 80 02             AND RIOT2PAD  
 E38D  8D 80 02             STA RIOT2PAD  
 E390  58                   CLI           
 E391  A5 35                LDA TLKACT    
 E393  F0 03                BEQ iE398     
 E395  20 2B E4             JSR TALK      
 E398  4C 72 E2  iE398      JMP IDLE      

 E39B  A9 04     LISTEN     LDA #$04       ; RFD HI
 E39D  0D 80 02             ORA RIOT2PAD  
 E3A0  8D 80 02             STA RIOT2PAD  
 E3A3  2C 80 02  iE3A3      BIT RIOT2PAD   ; DAV LO
 E3A6  70 FB                BVS iE3A3     
 E3A8  20 AD E9             JSR FNDWCH     ; WAS LDX SA
 E3AB  B0 05                BCS iE3B2     
 E3AD  B5 BE                LDA CHNRDY,X  
 E3AF  6A                   ROR            ; ok, open for LISTEN
 E3B0  B0 49                BCS iE3FB     
 E3B2  A5 85     iE3B2      LDA ORGSA      ; WAS TXA
 E3B4  29 F0                AND #$F0       ; SA=OPEN?
 E3B6  C9 F0                CMP #$F0      
 E3B8  F0 41                BEQ iE3FB     
 E3BA  A5 84                LDA SA        
 E3BC  C9 01                CMP #$01       ; save?
 E3BE  F0 0E                BEQ iE3CE     
 E3C0  2C 80 02  iE3C0      BIT RIOT2PAD  
 E3C3  50 FB                BVC iE3C0     
 E3C5  A9 FD                LDA #$FD       ; 255-DACO
 E3C7  2D 80 02             AND RIOT2PAD  
 E3CA  8D 80 02             STA RIOT2PAD  
 E3CD  60                   RTS           
 E3CE  A9 FB     iE3CE      LDA #$FB       ; 255-RFDO, ACCEPT ALL DATA
 E3D0  2D 80 02             AND RIOT2PAD  
 E3D3  8D 80 02             STA RIOT2PAD   ; RFD LOW
 E3D6  A9 FD                LDA #$FD       ; 255-DACO
 E3D8  2D 80 02             AND RIOT2PAD  
 E3DB  8D 80 02             STA RIOT2PAD   ; DAC HI
 E3DE  2C 80 02  iE3DE      BIT RIOT2PAD   ; DAV HI
 E3E1  50 FB                BVC iE3DE     
 E3E3  A9 02                LDA #$02       ; DACO
 E3E5  0D 80 02             ORA RIOT2PAD  
 E3E8  8D 80 02             STA RIOT2PAD   ; DAC LOW
 E3EB  A9 04                LDA #$04       ; RFDO, RFD HI
 E3ED  0D 80 02             ORA RIOT2PAD  
 E3F0  8D 80 02             STA RIOT2PAD  
 E3F3  2C 80 02  iE3F3      BIT RIOT2PAD   ; WAIT DAV LOW
 E3F6  50 FB                BVC iE3F3     
 E3F8  4C CE E3             JMP iE3CE      ; Do UNTIL ATn PULLED
 E3FB  A9 FB     iE3FB      LDA #$FB       ; 255-RFDO
 E3FD  2D 80 02             AND RIOT2PAD  
 E400  8D 80 02             STA RIOT2PAD  
 E403  29 20                AND #$20      
 E405  85 88                STA EOIFLG    
 E407  AD 00 02             LDA RIOT1IEEEDI
 E40A  49 FF                EOR #$FF      
 E40C  85 87                STA DATA      
 E40E  78                   SEI           
 E40F  A9 FD                LDA #$FD       ; 255-DACO
 E411  2D 80 02             AND RIOT2PAD  
 E414  8D 80 02             STA RIOT2PAD  
 E417  2C 80 02  iE417      BIT RIOT2PAD  
 E41A  50 FB                BVC iE417     
 E41C  A9 02                LDA #$02       ; DACO
 E41E  0D 80 02             ORA RIOT2PAD  
 E421  8D 80 02             STA RIOT2PAD  
 E424  20 FE E7             JSR PUT       
 E427  58                   CLI           
 E428  4C 9B E3             JMP LISTEN    

 E42B  20 B0 E9  TALK       JSR FNDRCH    
 E42E  B0 06                BCS NOTLK      ; TEST IF CHANNEL READY
 E430  A6 83     iE430      LDX LINDX     
 E432  B5 BE                LDA CHNRDY,X  
 E434  30 01                BMI iE437     
 E436  60        NOTLK      RTS           
 E437  2C 82 02  iE437      BIT RIOT2PBD   ; RFD HI
 E43A  10 FB                BPL iE437     
 E43C  BD D9 10             LDA CHNDAT,X  
 E43F  49 FF                EOR #$FF      
 E441  8D 02 02             STA RIOT1IEEEDO
 E444  B5 BE                LDA CHNRDY,X  
 E446  09 E7                ORA #$E7       ; 255-EOIO-DAVO, DAV LO
 E448  2D 80 02             AND RIOT2PAD  
 E44B  8D 80 02             STA RIOT2PAD  
 E44E  2C 82 02  iE44E      BIT RIOT2PBD  
 E451  10 0D                BPL iE460     
 E453  50 F9                BVC iE44E     
 E455  A9 18                LDA #$18       ; DAVO+EOIO
 E457  0D 80 02             ORA RIOT2PAD  
 E45A  8D 80 02             STA RIOT2PAD  
 E45D  4C 72 E2             JMP IDLE      
 E460  20 D6 EC  iE460      JSR GET       
 E463  2C 82 02  iE463      BIT RIOT2PBD  
 E466  50 FB                BVC iE463     
 E468  A9 FF                LDA #$FF      
 E46A  8D 02 02             STA RIOT1IEEEDO
 E46D  A9 18                LDA #$18       ; DAVO+EOIO
 E46F  0D 80 02             ORA RIOT2PAD  
 E472  8D 80 02             STA RIOT2PAD  
 E475  2C 82 02  iE475      BIT RIOT2PBD  
 E478  70 FB                BVS iE475     
 E47A  50 B4                BVC iE430      ; END OF IEEE

; NEXT TRACK & SECTOR
; RETURNS NEXT AVAILABLE TRACK & SECTOR
; GIVEN CURRENT T & S
; ;
; ALLOCATION IS FROM TRACK 18
; TOWARDS 1 & 35, BY FULL TRACKS

 E47C  20 9D E8  NXTTS      JSR GETACT    
 E47F  0A                   ASL           
 E480  0A                   ASL           
 E481  0A                   ASL           
 E482  AA                   TAX           
 E483  BD 23 10             LDA HDRS+2,X  
 E486  85 81                STA TRACK     
 E488  BD 24 10             LDA HDRS+3,X  
 E48B  85 82                STA SECTOR    
 E48D  A9 02                LDA #$02      
 E48F  85 2A                STA TEMP      
 E491  A6 80     NXTDS      LDX DRVNUM    
 E493  BD 40 E5             LDA IPBM,X    
 E496  85 29                STA BMPNT+1   
 E498  A9 00                LDA #$00      
 E49A  85 28                STA BMPNT     
 E49C  A5 81     iE49C      LDA TRACK     
 E49E  0A                   ASL           
 E49F  0A                   ASL           
 E4A0  A8                   TAY           
 E4A1  B1 28                LDA (BMPNT),Y 
 E4A3  D0 33                BNE FNDNXT    
 E4A5  A5 81                LDA TRACK     
 E4A7  C9 12                CMP #$12      
 E4A9  F0 16                BEQ iE4C1     
 E4AB  90 19                BCC iE4C6     
 E4AD  E6 81                INC TRACK     
 E4AF  A5 81                LDA TRACK     
 E4B1  C9 24                CMP #$24      
 E4B3  D0 E7                BNE iE49C     
 E4B5  A9 11                LDA #$11      
 E4B7  85 81                STA TRACK     
 E4B9  A9 00                LDA #$00      
 E4BB  85 82                STA SECTOR    
 E4BD  C6 2A                DEC TEMP      
 E4BF  D0 DB                BNE iE49C     
 E4C1  A9 72     iE4C1      LDA #$72       ; DSKFUL
 E4C3  4C 90 F0             JMP CMDERR    
 E4C6  C6 81     iE4C6      DEC TRACK     
 E4C8  D0 D2                BNE iE49C     
 E4CA  A9 13                LDA #$13      
 E4CC  85 81                STA TRACK     
 E4CE  A9 00                LDA #$00      
 E4D0  85 82                STA SECTOR    
 E4D2  C6 2A                DEC TEMP      
 E4D4  D0 C6                BNE iE49C     
 E4D6  F0 E9                BEQ iE4C1     

; FIND THE NEXT OPTIMUM SECTOR
; NEXT SECTOR=CURRENT SECTOR+N

 E4D8  A5 82     FNDNXT     LDA SECTOR    
 E4DA  18                   CLC           
 E4DB  65 92                ADC SECINC    
 E4DD  85 82                STA SECTOR    
 E4DF  A5 81                LDA TRACK     
 E4E1  20 B1 E5             JSR MAXSEC    
 E4E4  85 8A                STA LSTSEC    
 E4E6  85 89                STA CMD       
 E4E8  C5 82                CMP SECTOR    
 E4EA  B0 11                BCS iE4FD     
 E4EC  38                   SEC           
 E4ED  A5 82                LDA SECTOR    
 E4EF  E5 8A                SBC LSTSEC    
 E4F1  85 82                STA SECTOR    
 E4F3  F0 08                BEQ iE4FD     
 E4F5  C6 82                DEC SECTOR    
 E4F7  D0 04                BNE iE4FD     
 E4F9  A9 00     iE4F9      LDA #$00      
 E4FB  85 82                STA SECTOR    
 E4FD  20 6B E5  iE4FD      JSR AVAIL     
 E500  20 87 E5  iE500      JSR AV2       
 E503  B0 13                BCS iE518     
 E505  C6 89                DEC CMD       
 E507  10 05                BPL iE50E     
 E509  A9 71                LDA #$71      
 E50B  4C D4 E6             JMP CMDER2    
 E50E  A5 82     iE50E      LDA SECTOR    
 E510  E6 82                INC SECTOR    
 E512  C5 8A                CMP LSTSEC    
 E514  D0 EA                BNE iE500     
 E516  F0 E1                BEQ iE4F9     
 E518  4C A0 E7  iE518      JMP USEDTS    

; RETURNS OPTIMUM INITIAL TRACK, SECTOR

 E51B  A9 11     INTTS      LDA #$11      
 E51D  85 81                STA TRACK     
 E51F  20 5F E5             JSR SETBMP    
 E522  A5 81     iE522      LDA TRACK     
 E524  0A                   ASL           
 E525  0A                   ASL           
 E526  A8                   TAY           
 E527  B1 28                LDA (BMPNT),Y 
 E529  D0 17                BNE FNDSEC    
 E52B  A9 24                LDA #$24      
 E52D  38                   SEC           
 E52E  E5 81                SBC TRACK     
 E530  0A                   ASL           
 E531  0A                   ASL           
 E532  A8                   TAY           
 E533  B1 28                LDA (BMPNT),Y 
 E535  D0 0B                BNE FNDSEC    
 E537  C6 81                DEC TRACK     
 E539  D0 E7                BNE iE522     
 E53B  A9 72                LDA #$72       ; DSKFUL
 E53D  4C 90 F0             JMP CMDERR    
 E540  IPBM       .byte $42, $43                                ;bc

 E542  98        FNDSEC     TYA           
 E543  4A                   LSR           
 E544  4A                   LSR           
 E545  85 81                STA TRACK     
 E547  A9 00                LDA #$00      
 E549  85 82                STA SECTOR    
 E54B  20 6B E5             JSR AVAIL     
 E54E  20 87 E5  iE54E      JSR AV2       
 E551  B0 09                BCS iE55C     
 E553  E6 82                INC SECTOR    
 E555  D0 F7                BNE iE54E     
 E557  A9 71                LDA #$71       ; DIRERR
 E559  4C D4 E6             JMP CMDER2    
 E55C  4C A0 E7  iE55C      JMP USEDTS    

; SET (INDIRECT) BAM PNTR BY DRVNUM

 E55F  A6 80     SETBMP     LDX DRVNUM    
 E561  BD 40 E5             LDA IPBM,X    
 E564  85 29                STA BMPNT+1   
 E566  A9 00                LDA #$00      
 E568  85 28                STA BMPNT     
 E56A  60                   RTS           

; LOAD TRACK BAM INTO TEMP AND FINDS
; AVAILABLE SECTOR ON THE TRACK

 E56B  A5 81     AVAIL      LDA TRACK     
 E56D  0A                   ASL           
 E56E  0A                   ASL           
 E56F  A8                   TAY           
 E570  B1 28                LDA (BMPNT),Y 
 E572  85 2D                STA TEMP+3    
 E574  A2 02                LDX #$02      
 E576  C8        iE576      INY           
 E577  B1 28                LDA (BMPNT),Y 
 E579  95 2A                STA TEMP,X    
 E57B  CA                   DEX           
 E57C  10 F8                BPL iE576     
 E57E  20 93 E5             JSR AVCK      
 E581  A4 82                LDY SECTOR    
 E583  F0 0D                BEQ iE592     
 E585  D0 02                BNE iE589     
 E587  A0 01     AV2        LDY #$01      
 E589  66 2A     iE589      ROR TEMP      
 E58B  66 2B                ROR TEMP+1    
 E58D  66 2C                ROR TEMP+2    
 E58F  88                   DEY           
 E590  D0 F7                BNE iE589     
 E592  60        iE592      RTS           

; BIT MAP VALIDITY CHECK

 E593  A2 00     AVCK       LDX #$00      
 E595  A0 03                LDY #$03      
 E597  D0 06                BNE iE59F      ; (BRANCH)
 E599  E8        iE599      INX           
 E59A  4A        iE59A      LSR           
 E59B  B0 FC                BCS iE599     
 E59D  D0 FB                BNE iE59A     
 E59F  B9 29 00  iE59F      LDA BMPNT+1,Y 
 E5A2  88                   DEY           
 E5A3  10 F5                BPL iE59A     
 E5A5  E4 2D                CPX TEMP+3    
 E5A7  F0 07                BEQ iE5B0     
 E5A9  A9 71                LDA #$71       ; DIRERR
 E5AB  A0 00                LDY #$00      
 E5AD  4C D4 E6             JMP CMDER2    
 E5B0  60        iE5B0      RTS           

; .A=TRACK # ,RETURNS #SECTORS ON THIS TRACK

 E5B1  A2 04     MAXSEC     LDX #$04      
 E5B3  DD BC E5  iE5B3      CMP TRKNUM-1,X
 E5B6  CA                   DEX           
 E5B7  B0 FA                BCS iE5B3     
 E5B9  BD C1 E5             LDA NUMSEC,X  
 E5BC  60        xE5BC      RTS           

 E5BD  TRKNUM     .byte $24, $1F, $19, $12                      ;$_yr
 E5C1  NUMSEC     .byte $11, $12, $14, $15                      ;qrtu

; ;
; this is the original comment on the error table in the 4040
; of course the table here is similar, but still different.
; ;
; ; CONTROLLER ERRORS
; ;  0  (1)  NO ERROR
; ; 20  (2)  CAN'T FIND BLOCK HEADER
; ; 21  (3)  NO SYNCH CHARACTER
; ; 22  (4)  DATA BLOCK NOT PRESENT
; ; 23  (5)  CHECKSUM ERROR IN DATA
; ; 24  (16) BYTE DECODING ERROR
; ; 25  (7)  WRITE-VERIFY ERROR
; ; 26  (8)  WRITE W/ WRITE PROTECT ON
; ; 27  (9)  CHECKSUM ERROR IN HEADER
; ; 28  (10) DATA EXTENDS INTO NEXT BLOCK
; ; 29  (11) DISK I.D. MISMATCH
; .SKIP
; ; COMMAND ERRORS
; ; 30  GENERAL SYNTAX
; ; 31  INVALID COMMAND
; ; 32  LONG LINE
; ; 33  INVALID FILNAME
; ; 34  NO FILE GIVEN
; .SKIP
; ; 50  RECORD NOT PRESENT
; ; 51  OVERFLOW IN RECORD
; ; 52  FILE TOO LARGE
; .SKIP
; ; 60  FILE OPEN FOR WRITE
; ; 61  FILE NOT OPEN
; ; 62  FILE NOT FOUND
; ; 63  FILE EXISTS
; ; 64  FILE TYPE MISMATCH
; ; 65  NO BLOCK
; ; 66  ILLEGAL TRACK OR SECTOR
; ; 67  ILLEGAL SYSTEM T OR S
; .SKIP
; ; 70  NO CHANNELS AVAILABLE
; ; 71  DIRECTORY ERROR
; ; 72  DISK FULL
; ; 73  CBM DOS V2
; .SKIP
; ;  1  FILES SCRATCHED RESPONSE
; .SKIP2
; BADSYN =$30
; BADCMD =$31
; LONGLN =$32
; BADFN =$33
; NOFILE =$34
; NOREC =$50
; RECOVF =$51
; BIGFIL =$52
; FILOPN =$60
; FILNOP =$61
; FLNTFD =$62
; FLEXST =$63
; MISTYP =$64
; NOBLK =$65
; BADTS =$66
; NOCHNL =$70
; DIRERR =$71
; DSKFUL =$72
; CBMV2 =$73
; .PAGE
; ; ERROR MESSAGE TABLE
; ;   LEADING ERRROR NUMBERS,
; ;   TEXT WITH 1ST & LAST CHARS
; ;   OR'ED WITH $80,
; ;   TOKENS FOR KEY WORDS ARE
; ;   LESS THAN $10 (AND'ED W/ $80)

 E5C5  ERRTAB     .byte $00, $A0, $4F, $CB                      ;. oK
 E5C9  e_read     .byte $20, $21, $22, $23, $24, $27, $D2, $45  ; !"#$'Re
 E5D1             .byte $41, $44, $89                           ;ad.
 E5D4  e_write    .byte $25, $28, $8A, $89                      ;%(..
 E5D8  e_prot     .byte $26, $8A, $20, $50, $52, $4F, $54, $45  ;&. prote
 E5E0             .byte $43, $54, $20, $4F, $CE                 ;ct oN
 E5E5  e_id       .byte $29, $88, $20, $49, $44, $85            ;). id.
 E5EB  e_synt     .byte $30, $31, $32, $33, $34, $D3, $59, $4E  ;01234Syn
 E5F3             .byte $54, $41, $58, $89                      ;tax.
 E5F7  e_wfile    .byte $60, $8A, $03, $84                      ;`.c.
 E5FB  e_exist    .byte $63, $83, $20, $45, $58, $49, $53, $54  ;C. exist
 E603             .byte $D3                                     ;S
 E604  e_type     .byte $64, $83, $20, $54, $59, $50, $45, $85  ;D. type.
 E60C  e_block    .byte $65, $CE, $4F, $20, $42, $4C, $4F, $43  ;ENo bloc
 E614             .byte $CB                                     ;K
 E615  e_fnotop   .byte $61, $83, $06, $84                      ;A.f.
 E619  e_fnotfnd  .byte $62, $83, $06, $87                      ;B.f.
 E61D  e_scratchd .byte $01, $83, $53, $20, $53, $43, $52, $41  ;a.s scra
 E625             .byte $54, $43, $48, $45, $C4                 ;tcheD
 E62A  e_nchanl   .byte $70, $CE, $4F, $20, $43, $48, $41, $4E  ;PNo chan
 E632             .byte $4E, $45, $CC                           ;neL
 E635  e_dir      .byte $71, $C4, $49, $52, $89                 ;QDir.
 E63A  e_dskfull  .byte $72, $88, $20, $46, $55, $4C, $CC       ;R. fulL
 E641  t_error    .byte $09, $C5, $52, $52, $4F, $D2            ;iErroR
 E647  t_write    .byte $0A, $D7, $52, $49, $54, $C5            ;jWritE
 E64D  t_file     .byte $03, $C6, $49, $4C, $C5                 ;cFilE
 E652  t_open     .byte $04, $CF, $50, $45, $CE                 ;dOpeN
 E657  t_mismatch .byte $05, $CD, $49, $53, $4D, $41, $54, $43  ;eMismatc
 E65F             .byte $C8                                     ;H
 E660  t_not      .byte $06, $CE, $4F, $D4                      ;fNoT
 E664  t_found    .byte $07, $C6, $4F, $55, $4E, $C4            ;gFounD
 E66A  t_disk     .byte $08, $C4, $49, $53, $CB                 ;hDisK


; .A=BCD ERROR #


; RECURSIVE (2) ERROR MESSAGE ROUTINE


 E66F  DD C5 E5  MOVERR     CMP ERRTAB,X   ; .A=BCD ERROR #
 E672  F0 06                BEQ iE67A     
 E674  E8                   INX           
 E675  E0 AA                CPX #$AA       ; ERREND
 E677  90 F6                BCC MOVERR    
 E679  60                   RTS           
 E67A  E8        iE67A      INX            ; SKIP PAST ERROR #'S
 E67B  BD C5 E5             LDA ERRTAB,X  
 E67E  10 FA                BPL iE67A     
 E680  29 7F                AND #$7F      
 E682  C9 10     iE682      CMP #$10      
 E684  90 17                BCC iE69D     
 E686  99 B4 43             STA ERRBUF,Y  
 E689  C8                   INY           
 E68A  E8        iE68A      INX           
 E68B  BD C5 E5             LDA ERRTAB,X  
 E68E  10 F2                BPL iE682     
 E690  48                   PHA            ; LAST CHARACTER
 E691  29 7F                AND #$7F      
 E693  C9 10                CMP #$10      
 E695  90 07                BCC iE69E      ; TOKEN
 E697  99 B4 43             STA ERRBUF,Y  
 E69A  C8                   INY           
 E69B  68                   PLA           
 E69C  60                   RTS           
 E69D  48        iE69D      PHA            ; TOKEN PROCESS
 E69E  48        iE69E      PHA           
 E69F  A9 20                LDA #$20      
 E6A1  99 B4 43             STA ERRBUF,Y   ; IMPLIED LEADING SPACE
 E6A4  C8                   INY           
 E6A5  68                   PLA           
 E6A6  86 2D                STX TEMP+3    
 E6A8  A2 7C                LDX #$7C       ; ERRTOK
 E6AA  20 6F E6             JSR MOVERR     ; RECURSIVE FOR TOKENS
 E6AD  A6 2D                LDX TEMP+3    
 E6AF  68                   PLA           
 E6B0  10 D8                BPL iE68A     
 E6B2  60                   RTS           

; CONTROLLER ERROR ENTRY
; .A= ERROR #
; .X= JOB #

 E6B3  48        ERROR      PHA           
 E6B4  86 8D                STX JOBNUM    
 E6B6  8A                   TXA           
 E6B7  0A                   ASL           
 E6B8  0A                   ASL           
 E6B9  0A                   ASL           
 E6BA  AA                   TAX           
 E6BB  BD 23 10             LDA HDRS+2,X   ; RECALL TRACK,SECTOR
 E6BE  85 81                STA TRACK     
 E6C0  BD 24 10             LDA HDRS+3,X  
 E6C3  85 82                STA SECTOR    
 E6C5  68                   PLA           
 E6C6  29 0F                AND #$0F       ; CONVERT CONTROLLER...
 E6C8  D0 02                BNE iE6CC      ; ...ERRORS TO DOS ERRORS
 E6CA  A9 06                LDA #$06       ; CODE=16-->14
 E6CC  09 20     iE6CC      ORA #$20      
 E6CE  AA                   TAX           
 E6CF  CA                   DEX           
 E6D0  CA                   DEX           
 E6D1  8A                   TXA           
 E6D2  A0 00                LDY #$00      
 E6D4  20 5D E7  CMDER2     JSR ERRMSG    
 E6D7  20 81 E1             JSR DROMTS     ; check for diagnostic ROM
 E6DA  D0 03                BNE iE6DF     
 E6DC  4C 02 D0             JMP DIAGROM+2 
 E6DF  AD 82 02  iE6DF      LDA RIOT2PBD   ; SET ERROR LED
 E6E2  09 20                ORA #$20       ; ERRLED
 E6E4  8D 82 02             STA RIOT2PBD  
 E6E7  20 A9 EE             JSR FREICH     ; FREE INTERNAL CHANNEL
 E6EA  A9 00                LDA #$00       ; CLEAR POINTERS
 E6EC  85 5B                STA x5B        ; the 4040 purges the stack and SEI
 E6EE  85 5C                STA x5C       
 E6F0  A5 83                LDA LINDX     
 E6F2  C9 06                CMP #$06      
 E6F4  B0 08                BCS iE6FE     
 E6F6  A5 34                LDA LSNACT    
 E6F8  D0 21                BNE LSNERR     ; error while listening
 E6FA  A5 35                LDA TLKACT    
 E6FC  D0 03                BNE TLKERR     ; error while talking
 E6FE  4C 72 E2  iE6FE      JMP IDLE      

; TALKER ERROR RECOVERY
; IF COMMAND CHANNEL, RELEASE DAV
; IF DATA CHANNEL, FORCE NOT READY
; AND RELEASE CHANNEL
; this code is different from 4040

 E701  A5 84     TLKERR     LDA SA        
 E703  C9 0F                CMP #$0F      
 E705  F0 09                BEQ iE710     
 E707  A6 83                LDX LINDX     
 E709  A9 80                LDA #$80      
 E70B  95 BE                STA CHNRDY,X  
 E70D  20 32 EB             JSR FRECHN    
 E710  AD 80 02  iE710      LDA RIOT2PAD  
 E713  09 10                ORA #$10       ; DAVO
 E715  8D 80 02             STA RIOT2PAD  
 E718  4C 72 E2             JMP IDLE      

; LISTENER ERROR RECOVERY
; IF COMMAND CHANNEL, RELEASE RFD
; IF DATA CHANNEL, FORCE NOT READY
; AND RELEASE CHANNEL
; this code is different from 4040

 E71B  A5 84     LSNERR     LDA SA        
 E71D  C9 0F                CMP #$0F      
 E71F  F0 0C                BEQ iE72D     
 E721  20 AD E9             JSR FNDWCH    
 E724  A6 83                LDX LINDX     
 E726  A9 00                LDA #$00      
 E728  95 BE                STA CHNRDY,X  
 E72A  20 32 EB             JSR FRECHN    
 E72D  A9 04     iE72D      LDA #$04      
 E72F  0D 80 02             ORA RIOT2PAD  
 E732  29 FE                AND #$FE      
 E734  8D 80 02             STA RIOT2PAD  
 E737  4C 72 E2             JMP IDLE      

; CONVERT HEX TO BCD

 E73A  AA        HEXDEC     TAX           
 E73B  A9 00                LDA #$00      
 E73D  F8                   SED           
 E73E  E0 00     iE73E      CPX #$00      
 E740  F0 07                BEQ iE749     
 E742  18                   CLC           
 E743  69 01                ADC #$01      
 E745  CA                   DEX           
 E746  4C 3E E7             JMP iE73E     
 E749  D8        iE749      CLD           

; CONVERT BCD TO ASCII DEC
; RETURN BCD IN .X
; STORE ASCII IN (TEMP)Y

 E74A  AA        BCDDEC     TAX           
 E74B  4A                   LSR           
 E74C  4A                   LSR           
 E74D  4A                   LSR           
 E74E  4A                   LSR           
 E74F  09 30                ORA #$30      
 E751  91 2A                STA (TEMP),Y  
 E753  C8                   INY           
 E754  8A                   TXA           
 E755  29 0F                AND #$0F      
 E757  09 30                ORA #$30      
 E759  91 2A                STA (TEMP),Y  
 E75B  C8                   INY           
 E75C  60                   RTS           

 E75D  A2 B4     ERRMSG     LDX #$B4       ; <ERRBUF
 E75F  86 2A                STX TEMP      
 E761  A2 43                LDX #$43       ; >ERRBUF
 E763  86 2B                STX TEMP+1    
 E765  20 4A E7             JSR BCDDEC    
 E768  A9 2C                LDA #$2C       ; ","
 E76A  99 B4 43             STA ERRBUF,Y  
 E76D  C8                   INY           
 E76E  AD B4 43             LDA ERRBUF    
 E771  8D E0 10             STA CHNDAT+7   ; CHNDAT+ERRCHN
 E774  A9 B5                LDA #$B5      
 E776  85 5D                STA x5D       
 E778  8A                   TXA            ; ERROR # IN .X
 E779  A2 00                LDX #$00      
 E77B  20 6F E6             JSR MOVERR     ; MOVE MESSAGE
 E77E  A9 2C                LDA #$2C       ; ","
 E780  99 B4 43             STA ERRBUF,Y  
 E783  C8                   INY           
 E784  A5 81                LDA TRACK      ; CONVERT TRACK #
 E786  20 3A E7             JSR HEXDEC    
 E789  A9 2C                LDA #$2C      
 E78B  99 B4 43             STA ERRBUF,Y  
 E78E  C8                   INY           
 E78F  A5 82                LDA SECTOR     ; CONVERT SECTOR #
 E791  20 3A E7             JSR HEXDEC    
 E794  A9 0D                LDA #$0D      
 E796  99 B4 43             STA ERRBUF,Y  
 E799  18                   CLC           
 E79A  98                   TYA           
 E79B  69 B4                ADC #$B4       ; <ERRBUF
 E79D  85 CD                STA LSTCHR+7   ; LSTCHR++ERRCHN; SET LAST CHAR
 E79F  60                   RTS           

; MARK TRACK, SECTOR, (BMPNT) AS USED

 E7A0  A5 81     USEDTS     LDA TRACK      ; CALC INDEX INTO BAM
 E7A2  0A                   ASL           
 E7A3  0A                   ASL            ; 4 BYTES IN BAM PER TRACK
 E7A4  85 2A                STA TEMP       ; SAVE INDEX
 E7A6  A8                   TAY           
 E7A7  B1 28                LDA (BMPNT),Y 
 E7A9  AA                   TAX           
 E7AA  CA                   DEX           
 E7AB  8A                   TXA           
 E7AC  91 28                STA (BMPNT),Y 
 E7AE  A5 82                LDA SECTOR     ; A=SECTOR/8
 E7B0  4A                   LSR           
 E7B1  4A                   LSR           
 E7B2  4A                   LSR            ; FOR WHICH OF THREE BYTES
 E7B3  18                   CLC            ; the 4040 has a "SEC" here (in routing FREUSE) and no "INY" in e7b7 :-)
 E7B4  65 2A                ADC TEMP       ; CALC INDEX
 E7B6  A8                   TAY           
 E7B7  C8                   INY           
 E7B8  A5 82                LDA SECTOR     ; BIT IN THAT BYTE
 E7BA  29 07                AND #$07      
 E7BC  AA                   TAX           
 E7BD  A9 01                LDA #$01       ; this routine calculates(!) the bitmask; the 4040 reads it of a table
 E7BF  CA        iE7BF      DEX           
 E7C0  30 03                BMI iE7C5     
 E7C2  0A                   ASL           
 E7C3  90 FA                BCC iE7BF     
 E7C5  85 2A     iE7C5      STA TEMP      
 E7C7  B1 28                LDA (BMPNT),Y  ; GET THE BYTE
 E7C9  25 2A                AND TEMP       ; TEST IT; Z=1=USED, Z=0=FREE
 E7CB  D0 0D                BNE iE7DA      ; jump when free
 E7CD  A5 81                LDA TRACK      ; USED, "NO ACTION"
 E7CF  0A                   ASL           
 E7D0  0A                   ASL           
 E7D1  A8                   TAY           
 E7D2  B1 28                LDA (BMPNT),Y 
 E7D4  AA                   TAX           
 E7D5  E8                   INX           
 E7D6  8A                   TXA           
 E7D7  91 28                STA (BMPNT),Y 
 E7D9  60                   RTS           
 E7DA  A5 2A     iE7DA      LDA TEMP      
 E7DC  49 FF                EOR #$FF      
 E7DE  31 28                AND (BMPNT),Y  ; MARK SEC USED
 E7E0  91 28                STA (BMPNT),Y 
 E7E2  60                   RTS            ; note the count is not fixed here (as in 4040)!

 E7E3  A5 83     DBLBUF     LDA LINDX      ; TOGGLE ACTIVE BUFFER # IN BUFNUM
 E7E5  0A                   ASL           
 E7E6  AA                   TAX           
 E7E7  B5 5F                LDA BUFNUM,X   ; TOGGLE ACTIVE FLAG
 E7E9  49 80                EOR #$80      
 E7EB  95 5F                STA BUFNUM,X  
 E7ED  30 00                BMI iE7EF      ; not needed...
 E7EF  B5 60     iE7EF      LDA BUFNUM+1,X ; TOGGLE ACTIVE FLAG
 E7F1  49 80                EOR #$80      
 E7F3  95 60                STA BUFNUM+1,X
 E7F5  30 00                BMI iE7F7     
 E7F7  20 9D E8  iE7F7      JSR GETACT     ; GET ACTIVE BUF#
 E7FA  AA                   TAX           
 E7FB  4C 59 E8             JMP WATJOB     ; AND WAIT FOR BUFFER READY

; MAIN ROUTINE TO WRITE TO CHANL

 E7FE  A5 85     PUT        LDA ORGSA      ; IS CHANL CMD OR DATA
 E800  29 8F                AND #$8F      
 E802  C9 0F                CMP #$0F       ; <15
 E804  B0 17                BCS iE81D     
 E806  A6 83                LDX LINDX     
 E808  B5 B6                LDA FILTYP,X  
 E80A  49 08                EOR #$08      
 E80C  F0 05                BEQ iE813     
 E80E  A5 87                LDA DATA       ; SEQ FILE
 E810  4C 35 EA             JMP WRTBYT     ; WRITE BYTE TO CHANL
 E813  A5 87     iE813      LDA DATA       ; RND FILE WRITE
 E815  20 89 E8             JSR PUTBYT     ; WRITE TO CHANL
 E818  A4 83                LDY LINDX      ; PREPARE NXT BYTE
 E81A  4C 2E ED             JMP RNGET2    
 E81D  A9 06     iE81D      LDA #$06       ; CMDCHN
 E81F  85 83                STA LINDX     
 E821  20 B0 EE             JSR GETPNT     ; TEST IF COMM AND BUFFER FULL
 E824  C9 29                CMP #$29      
 E826  F0 05                BEQ iE82D      ; IT IS FULL (>40)
 E828  A5 87                LDA DATA       ; NOT FULL YET
 E82A  20 89 E8             JSR PUTBYT     ; STORE THE BYTE
 E82D  A5 88     iE82D      LDA EOIFLG     ; TST IF LST BYTE OF MSG
 E82F  F0 01                BEQ iE832      ; IT IS
 E831  60                   RTS            ; NOT YET, RETURN
 E832  A5 85     iE832      LDA ORGSA      ; this test is missing in 4040, instead directly gone to e839
 E834  10 03                BPL iE839     
 E836  4C 7A F6             JMP iF67A     
 E839  E6 3A     iE839      INC CMDWAT     ; SET CMD WAITING FLAG
 E83B  60                   RTS           

; TEST IF JOB (.X) IS DONE YET
; IF NOT DONE RETURN
; IF OK THEN RETURN ELSE REDO IT

 E83C  BD 03 10  TSTJOB     LDA JOBS,X    
 E83F  30 14                BMI NOTYET    
 E841  F0 14                BEQ OK        
 E843  C9 01                CMP #$01      
 E845  F0 10                BEQ OK        
 E847  DE A8 10             DEC ERRCNT,X   ; REDO UNTIL ERRCNT=0
 E84A  10 03                BPL AGAIN     
 E84C  4C B3 E6             JMP ERROR     
 E84F  BD 99 10  AGAIN      LDA LSTJOB,X  
 E852  9D 03 10             STA JOBS,X    
 E855  38        NOTYET     SEC           
 E856  60                   RTS           
 E857  18        OK         CLC           
 E858  60                   RTS           

; WAIT UNTIL JOB(.X) IS DONE
; RETURN WHEN DONE

 E859  20 3C E8  WATJOB     JSR TSTJOB    
 E85C  B0 FB                BCS WATJOB    
 E85E  60                   RTS           

 E85F  A2 0E                LDX #$0E       ; this routine seems to be unused?
 E861  20 59 E8  iE861      JSR WATJOB    
 E864  CA                   DEX           
 E865  10 FA                BPL iE861     
 E867  60                   RTS           

; SET HEADER OF ACTIVE BUFFER OF THE
; CURRENT LINDX TO TRACK,SECTOR,ID

 E868  20 9D E8  SETHDR     JSR GETACT    
 E86B  AA        SETH       TAX           
 E86C  0A                   ASL           
 E86D  0A                   ASL           
 E86E  0A                   ASL           
 E86F  A8                   TAY           
 E870  A5 81                LDA TRACK     
 E872  99 23 10             STA HDRS+2,Y   ; SEt TRACK
 E875  A5 82                LDA SECTOR    
 E877  99 24 10             STA HDRS+3,Y   ; SET SECTOR
 E87A  A5 80                LDA DRVNUM     ; GET PROPER ID(DRVNUM)
 E87C  0A                   ASL           
 E87D  AA                   TAX           
 E87E  B5 8E                LDA DISKID,X  
 E880  99 21 10             STA HDRS,Y    
 E883  B5 8F                LDA DISKID+1,X
 E885  99 22 10             STA HDRS+1,Y  
 E888  60                   RTS           

; PUT .A INTO ACTIVE BUFFER OF LINDX

 E889  48        PUTBYT     PHA            ; SAVE .A
 E88A  20 9D E8             JSR GETACT     ; GET ACTIVE BUF#
 E88D  10 06                BPL iE895      ; BRANCH IF THERE IS ONE
 E88F  68                   PLA            ; NO BUFFER ERROR
 E890  A9 61                LDA #$61       ; FILNOP
 E892  4C 90 F0             JMP CMDERR     ; JMP TO ERROR ROUTINE
 E895  0A        iE895      ASL            ; SAVE THE BYTE IN BUFFER
 E896  AA                   TAX           
 E897  68                   PLA           
 E898  81 3D                STA (BUFTAB,X)
 E89A  F6 3D                INC BUFTAB,X   ; INC THE BUFFER POINTER
 E89C  60                   RTS            ; Z=1 IF LAST CHAR SLOT IN BUFFER

 E89D  A5 83     GETACT     LDA LINDX     
 E89F  0A                   ASL           
 E8A0  AA                   TAX           
 E8A1  B5 5F                LDA BUFNUM,X  
 E8A3  10 02                BPL iE8A7     
 E8A5  B5 60                LDA BUFNUM+1,X
 E8A7  60        iE8A7      RTS           

; INITIALIZE DRIVES (COMMAND)

 E8A8  20 99 F0  INTDRV     JSR SIMPRS    
 E8AB  20 C1 E8             JSR INITDR    
 E8AE  A5 CF                LDA IMAGE      ; USED AS FLAG FOR BOTH DRIVES
 E8B0  10 0C                BPL iE8BE     
 E8B2  20 12 F2             JSR TOGDRV    
 E8B5  20 0A EF             JSR SETLDS    
 E8B8  20 C1 E8             JSR INITDR    
 E8BB  20 12 F2             JSR TOGDRV    
 E8BE  4C 75 F0  iE8BE      JMP ENDCMD    

; INITIALIZE DRIVE (DRVNUM)
; in 4040 this is called INITSU

 E8C1  20 CE EB  INITDR     JSR CLDCHN     ; missing in 4040
 E8C4  A5 80                LDA DRVNUM     ; DO A BUMP TO TRK 1
 E8C6  18                   CLC            ; READ IN BIT MAP (18.00)
 E8C7  69 0D                ADC #$0D       ; BAMJOB; AND SAVE DISK ID
 E8C9  85 8D                STA JOBNUM    
 E8CB  AA                   TAX           
 E8CC  A9 01                LDA #$01      
 E8CE  9D 12 10             STA x1012,X   
 E8D1  A5 80                LDA DRVNUM    
 E8D3  09 C0                ORA #$C0       ; SEEK
 E8D5  20 08 E9             JSR DOIT      
 E8D8  A9 12                LDA #$12      
 E8DA  A6 8D                LDX JOBNUM    
 E8DC  9D 12 10             STA x1012,X   
 E8DF  A5 80                LDA DRVNUM    
 E8E1  09 B0                ORA #$B0       ; READ
 E8E3  20 08 E9             JSR DOIT      
 E8E6  A5 8D                LDA JOBNUM    
 E8E8  AA                   TAX           
 E8E9  0A                   ASL           
 E8EA  0A                   ASL           
 E8EB  0A                   ASL           
 E8EC  A8                   TAY           
 E8ED  A9 00                LDA #$00      
 E8EF  99 24 10             STA HDRS+3,Y  
 E8F2  A5 80                LDA DRVNUM    
 E8F4  09 80                ORA #$80      
 E8F6  20 08 E9             JSR DOIT      
 E8F9  A5 80                LDA DRVNUM    
 E8FB  0A                   ASL           
 E8FC  AA                   TAX           
 E8FD  B9 21 10             LDA HDRS,Y    
 E900  95 8E                STA DISKID,X  
 E902  B9 22 10             LDA HDRS+1,Y  
 E905  95 8F                STA DISKID+1,X
 E907  60                   RTS           

; DO JOB IN .A, SET UP ERROR COUNT
; AND LSTJOB. RETURN WHEN JOB DONE OK
; JMP TO ERROR IF ERROR RETURNS
; this code is vastly different from 4040

 E908  85 89     DOIT       STA CMD       
 E90A  A9 0A     DOIT2      LDA #$0A      
 E90C  9D A8 10             STA ERRCNT,X  
 E90F  BD 12 10             LDA x1012,X   
 E912  F0 1E                BEQ iE932     
 E914  C9 24                CMP #$24      
 E916  B0 1A                BCS iE932     
 E918  A5 89     iE918      LDA CMD       
 E91A  9D 03 10             STA JOBS,X    
 E91D  9D 99 10             STA LSTJOB,X  
 E920  BD 03 10  iE920      LDA JOBS,X    
 E923  30 FB                BMI iE920     
 E925  C9 01                CMP #$01      
 E927  F0 08                BEQ iE931     
 E929  DE A8 10             DEC ERRCNT,X  
 E92C  D0 EA                BNE iE918     
 E92E  4C B3 E6             JMP ERROR     
 E931  60        iE931      RTS           
 E932  85 81     iE932      STA TRACK     
 E934  8A                   TXA           
 E935  0A                   ASL           
 E936  0A                   ASL           
 E937  0A                   ASL           
 E938  AA                   TAX           
 E939  BD 24 10             LDA HDRS+3,X  
 E93C  85 82                STA SECTOR    
 E93E  A9 20                LDA #$20      
 E940  4C D4 E6             JMP CMDER2    

; START DOUBLE BUFFERING
; USE TRACK,SECTOR AS STARTING BLOCK

 E943  20 9D E8  STRDBL     JSR GETACT    
 E946  20 68 E8             JSR SETHDR    
 E949  20 6A E9             JSR RDBUF     
 E94C  20 59 E8             JSR WATJOB    
 E94F  20 D4 E9             JSR GETBYT    
 E952  85 81                STA TRACK     
 E954  20 D4 E9             JSR GETBYT    
 E957  85 82                STA SECTOR    
 E959  A5 81                LDA TRACK     
 E95B  D0 01                BNE iE95E     
 E95D  60                   RTS           
 E95E  20 E3 E7  iE95E      JSR DBLBUF    
 E961  20 68 E8             JSR SETHDR    
 E964  20 6A E9             JSR RDBUF     
 E967  4C E3 E7             JMP DBLBUF    

; START A READ JOB ON TRACK, SECTOR

 E96A  A9 80     RDBUF      LDA #$80       ; READ
 E96C  D0 02                BNE iE970     

; START A WRITE JOB ON TRACK, SECTOR

 E96E  A9 90     WRTBUF     LDA #$90       ; WRITE
 E970  85 89     iE970      STA CMD       
 E972  20 9D E8             JSR GETACT    
 E975  AA                   TAX           
 E976  0A                   ASL           
 E977  0A                   ASL           
 E978  0A                   ASL           
 E979  A8                   TAY           
 E97A  B9 23 10             LDA HDRS+2,Y  
 E97D  F0 B3                BEQ iE932     
 E97F  C9 24                CMP #$24      
 E981  B0 AF                BCS iE932     
 E983  9D 12 10             STA x1012,X   
 E986  A9 0A                LDA #$0A      
 E988  9D A8 10             STA ERRCNT,X  
 E98B  BD 99 10             LDA LSTJOB,X  
 E98E  29 01                AND #$01      
 E990  05 89                ORA CMD       
 E992  9D 99 10             STA LSTJOB,X  
 E995  9D 03 10             STA JOBS,X    
 E998  8A                   TXA           
 E999  48                   PHA           
 E99A  0A                   ASL           
 E99B  AA                   TAX           
 E99C  A9 00                LDA #$00      
 E99E  95 3D                STA BUFTAB,X  
 E9A0  A5 83                LDA LINDX     
 E9A2  0A                   ASL           
 E9A3  AA                   TAX           
 E9A4  F6 6F                INC BUFNUM+16,X
 E9A6  D0 02                BNE iE9AA     
 E9A8  F6 70                INC BUFNUM+17,X
 E9AA  68        iE9AA      PLA           
 E9AB  AA                   TAX           
 E9AC  60                   RTS           

 E9AD  38        FNDWCH     SEC           
 E9AE  B0 01                BCS iE9B1     
 E9B0  18        FNDRCH     CLC           
 E9B1  08        iE9B1      PHP           
 E9B2  A5 84                LDA SA        
 E9B4  C9 11                CMP #$11       ; MAXSA+1
 E9B6  90 02                BCC iE9BA     
 E9B8  29 0F                AND #$0F      
 E9BA  0A        iE9BA      ASL           
 E9BB  28                   PLP           
 E9BC  69 00                ADC #$00      
 E9BE  AA                   TAX           
 E9BF  BD B7 10             LDA LINTAB,X  
 E9C2  85 83                STA LINDX     
 E9C4  AA                   TAX           
 E9C5  C9 FF                CMP #$FF      
 E9C7  F0 01                BEQ iE9CA     
 E9C9  60                   RTS           
 E9CA  38        iE9CA      SEC           
 E9CB  60                   RTS           

 E9CC  20 9D E8  GETPRE     JSR GETACT    
 E9CF  0A                   ASL           
 E9D0  AA                   TAX           
 E9D1  A4 83                LDY LINDX     
 E9D3  60                   RTS           

; READ BYTE FROM ACTIVE BUFFER
; AND SET FLAG IF LAST DATA BYTE
; IF LAST THEN Z=1 ELSE Z=0

 E9D4  20 CC E9  GETBYT     JSR GETPRE    
 E9D7  B9 C6 00             LDA LSTCHR,Y  
 E9DA  F0 12                BEQ iE9EE     
 E9DC  A1 3D                LDA (BUFTAB,X)
 E9DE  48                   PHA           
 E9DF  B5 3D                LDA BUFTAB,X  
 E9E1  D9 C6 00             CMP LSTCHR,Y  
 E9E4  D0 04                BNE iE9EA     
 E9E6  A9 FF                LDA #$FF      
 E9E8  95 3D                STA BUFTAB,X  
 E9EA  68        iE9EA      PLA           
 E9EB  F6 3D                INC BUFTAB,X  
 E9ED  60                   RTS           
 E9EE  A1 3D     iE9EE      LDA (BUFTAB,X)
 E9F0  F6 3D                INC BUFTAB,X  
 E9F2  60                   RTS           

; READ A CHAR FROM FILE AND READ NEXT
; BLOCK OF FILE IF NEEDED.
; SET CHNRDY=EOI IF END OF FILE

 E9F3  20 D4 E9  RDBYT      JSR GETBYT    
 E9F6  D0 31                BNE iEA29     
 E9F8  85 87                STA DATA      
 E9FA  B9 C6 00             LDA LSTCHR,Y  
 E9FD  F0 08                BEQ iEA07     
 E9FF  A9 80                LDA #$80       ; EOIOUT
 EA01  99 BE 00             STA CHNRDY,Y  
 EA04  A5 87                LDA DATA      
 EA06  60                   RTS           
 EA07  20 E3 E7  iEA07      JSR DBLBUF    
 EA0A  20 D4 E9             JSR GETBYT    
 EA0D  C9 00                CMP #$00      
 EA0F  F0 19                BEQ iEA2A     
 EA11  85 81                STA TRACK     
 EA13  20 D4 E9             JSR GETBYT    
 EA16  85 82                STA SECTOR    
 EA18  20 E3 E7             JSR DBLBUF    
 EA1B  20 66 EA             JSR SETDRN    
 EA1E  20 68 E8             JSR SETHDR    
 EA21  20 6A E9             JSR RDBUF     
 EA24  20 E3 E7             JSR DBLBUF    
 EA27  A5 87                LDA DATA      
 EA29  60        iEA29      RTS           
 EA2A  20 D4 E9  iEA2A      JSR GETBYT    
 EA2D  A4 83                LDY LINDX     
 EA2F  99 C6 00             STA LSTCHR,Y  
 EA32  A5 87                LDA DATA      
 EA34  60                   RTS           

; WRITE A CHAR TO CHANL AND WRITE
; BUFFER OUT TO DISK IF ITS FULL

 EA35  20 89 E8  WRTBYT     JSR PUTBYT    
 EA38  F0 01                BEQ iEA3B     
 EA3A  60                   RTS           
 EA3B  20 66 EA  iEA3B      JSR SETDRN    
 EA3E  20 7C E4             JSR NXTTS     
 EA41  A5 81                LDA TRACK     
 EA43  20 89 E8             JSR PUTBYT    
 EA46  A5 82                LDA SECTOR    
 EA48  20 89 E8             JSR PUTBYT    
 EA4B  20 6E E9             JSR WRTBUF    
 EA4E  A9 02                LDA #$02      
 EA50  20 89 EE             JSR SETPNT    
 EA53  20 E3 E7             JSR DBLBUF    
 EA56  4C 68 E8             JMP SETHDR    

; INC POINTER OF ACTIVE BUFFER
; BY .A

 EA59  85 2A     INCPTR     STA TEMP       ; SCOTT PATCH
 EA5B  20 B0 EE             JSR GETPNT    
 EA5E  18                   CLC           
 EA5F  65 2A                ADC TEMP      
 EA61  95 3D                STA BUFTAB,X  
 EA63  85 93                STA DIRBUF    
 EA65  60                   RTS           

; SET DRVNUM TO DRIVE INDICATED BY
; LSTJOB OF ACTIVE BUFFER

 EA66  20 9D E8  SETDRN     JSR GETACT    
 EA69  AA                   TAX           
 EA6A  BD 99 10             LDA LSTJOB,X  
 EA6D  29 01                AND #$01      
 EA6F  85 80                STA DRVNUM    
 EA71  60                   RTS           

; OPEN A READ CHANL WITH 2 BUFFERS
; WILL INSERT SA IN LINTAB
; AND INITS ALL POINTERS.

 EA72  A9 02     OPNRCH     LDA #$02       ; GET TWO DATA BUFFERS
 EA74  20 F3 EA             JSR GETRCH    
 EA77  20 98 EA             JSR INTPNT    
 EA7A  20 43 E9             JSR STRDBL     ; READ 1ST ONE OR TWO BLOCKS
 EA7D  A6 83                LDX LINDX     
 EA7F  A9 88                LDA #$88       ; RDYTLK
 EA81  95 BE                STA CHNRDY,X  
 EA83  A9 02                LDA #$02      
 EA85  95 B6                STA FILTYP,X  
 EA87  A5 81                LDA TRACK     
 EA89  D0 04                BNE iEA8F     
 EA8B  A5 82                LDA SECTOR    
 EA8D  95 C6                STA LSTCHR,X   ; SET LAST CHAR PTR
 EA8F  20 F3 E9  iEA8F      JSR RDBYT      ; SEQUENTIAL SET UP
 EA92  A6 83                LDX LINDX     
 EA94  9D D9 10             STA CHNDAT,X  
 EA97  60                   RTS           

; INITIALIZE VARIABLES FOR OPEN CHANL
; LSTJOB,SETS ACTIVE BUFFER#,LSTCHR,
; BUFFER POINTERS IN BUFTAB=2

 EA98  A5 83     INTPNT     LDA LINDX     
 EA9A  0A                   ASL           
 EA9B  AA                   TAX           
 EA9C  A5 80                LDA DRVNUM    
 EA9E  B4 5F                LDY BUFNUM,X  
 EAA0  99 99 10             STA LSTJOB,Y  
 EAA3  B4 60                LDY BUFNUM+1,X
 EAA5  99 99 10             STA LSTJOB,Y  
 EAA8  99 03 10             STA JOBS,Y    
 EAAB  B5 5F                LDA BUFNUM,X  
 EAAD  0A                   ASL           
 EAAE  A8                   TAY           
 EAAF  A9 02                LDA #$02      
 EAB1  99 3D 00             STA BUFTAB,Y  
 EAB4  B5 60                LDA BUFNUM+1,X
 EAB6  09 80                ORA #$80      
 EAB8  95 60                STA BUFNUM+1,X
 EABA  0A                   ASL           
 EABB  A8                   TAY           
 EABC  A9 02                LDA #$02      
 EABE  99 3D 00             STA BUFTAB,Y  
 EAC1  A9 00                LDA #$00      
 EAC3  95 6F                STA BUFNUM+16,X
 EAC5  95 70                STA BUFNUM+17,X
 EAC7  A6 83                LDX LINDX     
 EAC9  A9 00                LDA #$00      
 EACB  95 C6                STA LSTCHR,X  
 EACD  60                   RTS           

; OPEN A WRITE CHANNEL WITH 2 BUFFERS

 EACE  20 1B E5  OPNWCH     JSR INTTS      ; GET FIRST TRACK,SECTOR
 EAD1  A9 02                LDA #$02      
 EAD3  20 E6 EA             JSR GETWCH    
 EAD6  A6 83                LDX LINDX     
 EAD8  A9 02                LDA #$02      
 EADA  95 B6                STA FILTYP,X  
 EADC  A9 01                LDA #$01      
 EADE  95 BE                STA CHNRDY,X  
 EAE0  20 98 EA             JSR INTPNT    
 EAE3  4C 68 E8             JMP SETHDR    

; .A=#BUFFERS NEEDED
; SETS UP BUFFER # AND ALLOCATES LINDX
; for write

 EAE6  85 2A     GETWCH     STA TEMP       ; SAVE #BUFS NEEDED
 EAE8  20 AD E9             JSR FNDWCH    
 EAEB  B0 03                BCS iEAF0     
 EAED  20 66 EB             JSR iEB66     
 EAF0  38        iEAF0      SEC           
 EAF1  B0 0B                BCS iEAFE     

; .A=#BUFFERS NEEDED
; SETS UP BUFFER # AND ALLOCATES LINDX
; for read

 EAF3  85 2A     GETRCH     STA TEMP       ; SAVE #BUFS NEEDED
 EAF5  20 B0 E9             JSR FNDRCH    
 EAF8  B0 03                BCS iEAFD     
 EAFA  20 5F EB             JSR iEB5F     
 EAFD  18        iEAFD      CLC           
 EAFE  08        iEAFE      PHP            ; save r/w flag (.C)
 EAFF  20 F6 EB             JSR FNDLNX    
 EB02  85 83                STA LINDX     
 EB04  A5 84                LDA SA        
 EB06  0A                   ASL           
 EB07  28                   PLP           
 EB08  69 00                ADC #$00      
 EB0A  AA                   TAX           
 EB0B  A5 83                LDA LINDX     
 EB0D  9D B7 10             STA LINTAB,X  
 EB10  0A        iEB10      ASL           
 EB11  A8                   TAY           
 EB12  A9 FF                LDA #$FF      
 EB14  99 5F 00             STA BUFNUM,Y  
 EB17  99 60 00             STA BUFNUM+1,Y
 EB1A  C6 2A     iEB1A      DEC TEMP      
 EB1C  30 13                BMI iEB31     
 EB1E  20 88 EB             JSR GETBUF    
 EB21  10 08                BPL iEB2B     
 EB23  20 6E EB             JSR RELBUF    
 EB26  A9 70                LDA #$70      
 EB28  4C 90 F0             JMP CMDERR    
 EB2B  99 5F 00  iEB2B      STA BUFNUM,Y  
 EB2E  C8                   INY           
 EB2F  D0 E9                BNE iEB1A     
 EB31  60        iEB31      RTS           

; FREE CHANL ASSOCIATED WITH SA
; FREE READ AND WRITE CHANLS
; DONT FREE CHANL 15

 EB32  A5 84     FRECHN     LDA SA        
 EB34  C9 0F                CMP #$0F      
 EB36  D0 01                BNE iEB39     
 EB38  60                   RTS           
 EB39  20 5F EB  iEB39      JSR iEB5F     
 EB3C  4C 66 EB             JMP iEB66     

 EB3F  BD B7 10  iEB3F      LDA LINTAB,X  
 EB42  C9 FF                CMP #$FF      
 EB44  F0 18                BEQ iEB5E     
 EB46  85 83                STA LINDX     
 EB48  A9 FF                LDA #$FF      
 EB4A  9D B7 10             STA LINTAB,X  
 EB4D  20 6E EB             JSR RELBUF    
 EB50  A6 83                LDX LINDX     
 EB52  A9 01                LDA #$01      
 EB54  CA        iEB54      DEX           
 EB55  30 03                BMI iEB5A     
 EB57  0A                   ASL           
 EB58  D0 FA                BNE iEB54     
 EB5A  05 3C     iEB5A      ORA LINUSE    
 EB5C  85 3C                STA LINUSE    
 EB5E  60        iEB5E      RTS           

 EB5F  A5 84     iEB5F      LDA SA        
 EB61  0A                   ASL           
 EB62  AA                   TAX           
 EB63  4C 3F EB             JMP iEB3F     

 EB66  A5 84     iEB66      LDA SA        
 EB68  0A                   ASL           
 EB69  AA                   TAX           
 EB6A  E8                   INX           
 EB6B  4C 3F EB             JMP iEB3F     

; GIVEN SA, FREE ITS READ CHANL
; RELEASE BUFFERS (LINDX)

 EB6E  A5 83     RELBUF     LDA LINDX     
 EB70  0A                   ASL           
 EB71  AA                   TAX           
 EB72  B5 5F                LDA BUFNUM,X  
 EB74  C9 FF                CMP #$FF      
 EB76  F0 03                BEQ iEB7B     
 EB78  20 B0 EB             JSR FREBUF    
 EB7B  A5 83     iEB7B      LDA LINDX     
 EB7D  0A                   ASL           
 EB7E  AA                   TAX           
 EB7F  B5 60                LDA BUFNUM+1,X
 EB81  C9 FF                CMP #$FF      
 EB83  F0 D9                BEQ iEB5E     
 EB85  4C B0 EB             JMP FREBUF    

; GET A FREE BUFFER #

 EB88  A9 FF     GETBUF     LDA #$FF      
 EB8A  85 2B                STA TEMP+1    
 EB8C  A2 0F                LDX #$0F      
 EB8E  26 8B     iEB8E      ROL BUFUSE    
 EB90  26 8C                ROL BUFUSE+1  
 EB92  B0 05                BCS iEB99     
 EB94  86 2B                STX TEMP+1    
 EB96  38                   SEC           
 EB97  B0 0E                BCS iEBA7     
 EB99  CA        iEB99      DEX           
 EB9A  10 F2                BPL iEB8E     
 EB9C  A6 2B     iEB9C      LDX TEMP+1    
 EB9E  30 05                BMI iEBA5     
 EBA0  A9 00                LDA #$00      
 EBA2  9D 03 10             STA JOBS,X    
 EBA5  8A        iEBA5      TXA           
 EBA6  60                   RTS           
 EBA7  26 8B     iEBA7      ROL BUFUSE    
 EBA9  26 8C                ROL BUFUSE+1  
 EBAB  CA                   DEX           
 EBAC  10 F9                BPL iEBA7     
 EBAE  30 EC                BMI iEB9C     

; ALLOCATE

 EBB0  29 0F     FREBUF     AND #$0F      
 EBB2  A8                   TAY           
 EBB3  C8                   INY           
 EBB4  A2 10                LDX #$10      
 EBB6  66 8C     iEBB6      ROR BUFUSE+1  
 EBB8  66 8B                ROR BUFUSE    
 EBBA  88                   DEY           
 EBBB  D0 01                BNE iEBBE     
 EBBD  18                   CLC           
 EBBE  CA        iEBBE      DEX           
 EBBF  10 F5                BPL iEBB6     
 EBC1  60                   RTS           

 EBC2  A9 0E     CLRCHN     LDA #$0E      
 EBC4  85 84                STA SA        
 EBC6  20 32 EB  iEBC6      JSR FRECHN    
 EBC9  C6 84                DEC SA        
 EBCB  D0 F9                BNE iEBC6     
 EBCD  60                   RTS           

 EBCE  A9 1D     CLDCHN     LDA #$1D      
 EBD0  85 2D                STA TEMP+3    
 EBD2  A6 2D     iEBD2      LDX TEMP+3    
 EBD4  BD B7 10             LDA LINTAB,X  
 EBD7  C9 FF                CMP #$FF      
 EBD9  F0 16                BEQ iEBF1     
 EBDB  85 83                STA LINDX     
 EBDD  8A                   TXA           
 EBDE  4A                   LSR           
 EBDF  85 84                STA SA        
 EBE1  20 9D E8             JSR GETACT    
 EBE4  AA                   TAX           
 EBE5  BD 99 10             LDA LSTJOB,X  
 EBE8  29 01                AND #$01      
 EBEA  C5 80                CMP DRVNUM    
 EBEC  D0 03                BNE iEBF1     
 EBEE  20 32 EB             JSR FRECHN    
 EBF1  C6 2D     iEBF1      DEC TEMP+3    
 EBF3  10 DD                BPL iEBD2     
 EBF5  60                   RTS           

; FIND A FREE LINDX TO USE
; MARK AS USED IN LINUSE

 EBF6  A0 00     FNDLNX     LDY #$00      
 EBF8  A9 01                LDA #$01      
 EBFA  24 3C     iEBFA      BIT LINUSE     ; 1=FREE 0=USED
 EBFC  D0 09                BNE iEC07     
 EBFE  C8                   INY           
 EBFF  0A                   ASL           
 EC00  D0 F8                BNE iEBFA     
 EC02  A9 70                LDA #$70       ; NOCHNL; NO FREE LINDX AVAILABLE
 EC04  4C 90 F0             JMP CMDERR    
 EC07  49 FF     iEC07      EOR #$FF       ; TOGGLE BIT MASK
 EC09  25 3C                AND LINUSE     ; MARK BIT USED
 EC0B  85 3C                STA LINUSE    
 EC0D  98                   TYA            ; RETURN LINDX IN .A
 EC0E  60                   RTS           

; CLOSE THE FILE ASSOCIATED WITH SA
; this routine is massively different, partly due to REL files in 4040

 EC0F  A5 84     CLOSE      LDA SA        
 EC11  F0 3D                BEQ iEC50      ; DIRECTORY CLOSE
 EC13  C9 0F                CMP #$0F      
 EC15  F0 1B                BEQ CLSALL     ; CLOSE CMD CHANL
 EC17  20 AD E9             JSR FNDWCH    
 EC1A  B0 13                BCS iEC2F     
 EC1C  A6 83                LDX LINDX     
 EC1E  B5 B6                LDA FILTYP,X  
 EC20  29 0E                AND #$0E      
 EC22  C9 08                CMP #$08      
 EC24  F0 06                BEQ iEC2C     
 EC26  20 5E EC             JSR iEC5E     
 EC29  20 53 ED             JSR iED53     
 EC2C  20 87 EC  iEC2C      JSR MAPOUT    
 EC2F  4C 32 EB  iEC2F      JMP FRECHN    
 EC32  A9 00     CLSALL     LDA #$00      
 EC34  85 84                STA SA        
 EC36  20 AD E9  iEC36      JSR FNDWCH    
 EC39  B0 09                BCS iEC44     
 EC3B  20 5E EC             JSR iEC5E     
 EC3E  20 53 ED             JSR iED53     
 EC41  20 87 EC             JSR MAPOUT    
 EC44  20 32 EB  iEC44      JSR FRECHN    
 EC47  E6 84                INC SA        
 EC49  A5 84                LDA SA        
 EC4B  C9 0F                CMP #$0F      
 EC4D  D0 E7                BNE iEC36     
 EC4F  60                   RTS           
 EC50  A9 00     iEC50      LDA #$00      
 EC52  85 38                STA DIRLST     ; CLEAR DIR LIST
 EC54  20 32 EB             JSR FRECHN    
 EC57  A9 10                LDA #$10       ; in 4040 JMP FREICH
 EC59  85 84                STA SA        
 EC5B  4C 32 EB             JMP FRECHN    

 EC5E  20 B0 EE  iEC5E      JSR GETPNT    
 EC61  C9 02                CMP #$02      
 EC63  D0 07                BNE iEC6C     
 EC65  A9 0D                LDA #$0D      
 EC67  20 89 E8             JSR PUTBYT    
 EC6A  A9 03                LDA #$03      
 EC6C  85 2A     iEC6C      STA TEMP      
 EC6E  C6 2A                DEC TEMP      
 EC70  20 9D E8             JSR GETACT    
 EC73  0A                   ASL           
 EC74  AA                   TAX           
 EC75  A9 00                LDA #$00      
 EC77  95 3D                STA BUFTAB,X  
 EC79  81 3D                STA (BUFTAB,X)
 EC7B  F6 3D                INC BUFTAB,X  
 EC7D  A5 2A                LDA TEMP      
 EC7F  81 3D                STA (BUFTAB,X)
 EC81  20 6E E9             JSR WRTBUF    
 EC84  4C 59 E8             JMP WATJOB    

; WRITE OUT THE BIT MAP TO
; THE DRIVE IN LSTJOB(ACTIVE)

 EC87  20 9D E8  MAPOUT     JSR GETACT    
 EC8A  AA                   TAX           
 EC8B  BD 99 10             LDA LSTJOB,X  
 EC8E  29 01                AND #$01      
 EC90  48                   PHA            ; CHECK BAM BEFORE WRITING
 EC91  AA                   TAX           
 EC92  A9 00                LDA #$00      
 EC94  85 82                STA SECTOR    
 EC96  BD 40 E5             LDA IPBM,X    
 EC99  85 2F                STA TEMP+5    
 EC9B  A9 00                LDA #$00      
 EC9D  85 2E                STA TEMP+4    
 EC9F  A9 01                LDA #$01      
 ECA1  85 81                STA TRACK     

; VERIFY THE BAM BLOCK COUNT
; MATCHES THE BITS

 ECA3  A5 81     MAPCHK     LDA TRACK     
 ECA5  0A                   ASL           
 ECA6  0A                   ASL           
 ECA7  A8                   TAY           
 ECA8  B1 2E                LDA (TEMP+4),Y
 ECAA  85 2D                STA TEMP+3    
 ECAC  C8                   INY           
 ECAD  B1 2E                LDA (TEMP+4),Y
 ECAF  85 2A                STA TEMP      
 ECB1  C8                   INY           
 ECB2  B1 2E                LDA (TEMP+4),Y
 ECB4  85 2B                STA TEMP+1    
 ECB6  C8                   INY           
 ECB7  B1 2E                LDA (TEMP+4),Y
 ECB9  85 2C                STA TEMP+2    
 ECBB  20 93 E5             JSR AVCK      
 ECBE  E6 81                INC TRACK     
 ECC0  A5 81                LDA TRACK     
 ECC2  C9 24                CMP #$24       ; MAXTRK
 ECC4  D0 DD                BNE MAPCHK    
 ECC6  A9 12                LDA #$12      
 ECC8  85 81                STA TRACK     
 ECCA  68                   PLA           
 ECCB  A8                   TAY           
 ECCC  18                   CLC           
 ECCD  69 0D                ADC #$0D       ; BAMJOB
 ECCF  AA                   TAX           
 ECD0  98                   TYA           
 ECD1  09 90                ORA #$90       ; WRITE
 ECD3  4C 08 E9             JMP DOIT      

; GET NEXT CHAR FROM A CHANL

 ECD6  A6 83     GET        LDX LINDX     
 ECD8  B5 BE                LDA CHNRDY,X  
 ECDA  29 08                AND #$08      
 ECDC  D0 13                BNE iECF1     
 ECDE  B5 B6                LDA FILTYP,X  
 ECE0  49 08                EOR #$08      
 ECE2  4A                   LSR           
 ECE3  D0 07                BNE iECEC     
 ECE5  A9 89                LDA #$89      
 ECE7  95 BE                STA CHNRDY,X  
 ECE9  4C 1A ED             JMP iED1A     
 ECEC  A9 00     iECEC      LDA #$00      
 ECEE  95 BE                STA CHNRDY,X  
 ECF0  60                   RTS           
 ECF1  A5 84     iECF1      LDA SA        
 ECF3  F0 54                BEQ iED49     
 ECF5  C9 0F                CMP #$0F      
 ECF7  D0 19                BNE iED12     
 ECF9  20 D4 E9             JSR GETBYT    
 ECFC  D0 45                BNE GET3      
 ECFE  85 87                STA DATA      
 ED00  A9 B4                LDA #$B4      
 ED02  20 89 EE             JSR SETPNT    
 ED05  AD 82 02             LDA RIOT2PBD  
 ED08  29 DF                AND #$DF      
 ED0A  8D 82 02             STA RIOT2PBD  
 ED0D  A5 87                LDA DATA      
 ED0F  4C 43 ED             JMP GET3      
 ED12  A6 83     iED12      LDX LINDX     
 ED14  B5 B6                LDA FILTYP,X  
 ED16  49 08                EOR #$08      
 ED18  D0 26                BNE SEQGET    
 ED1A  20 9D E8  iED1A      JSR GETACT    
 ED1D  0A                   ASL           
 ED1E  AA                   TAX           
 ED1F  A4 83                LDY LINDX     
 ED21  B5 3D                LDA BUFTAB,X  
 ED23  D9 C6 00             CMP LSTCHR,Y   ; UP TO LST CHAR YET
 ED26  D0 04                BNE RNGET1     ; NOT YET
 ED28  A9 00                LDA #$00       ; READ THE WHOLE THING
 ED2A  95 3D                STA BUFTAB,X   ; WRAP PNTR TO 0
 ED2C  F6 3D     RNGET1     INC BUFTAB,X   ; GET THE NEXT CHAR
 ED2E  A1 3D     RNGET2     LDA (BUFTAB,X)
 ED30  99 D9 10             STA CHNDAT,Y   ; SAVE CHAR IN
 ED33  B5 3D                LDA BUFTAB,X  
 ED35  D9 C6 00             CMP LSTCHR,Y  
 ED38  D0 05                BNE RNGET3    
 ED3A  A9 81                LDA #$81       ; RNDEOI
 ED3C  99 BE 00             STA CHNRDY,Y   ; THIS IS LAST CHAR
 ED3F  60        RNGET3     RTS            ; SEND EOI WITH IT
 ED40  20 F3 E9  SEQGET     JSR RDBYT      ; READ THE NEXT BYTE
 ED43  A6 83     GET3       LDX LINDX     
 ED45  9D D9 10             STA CHNDAT,X   ; STORE IN CHNDAT
 ED48  60                   RTS           
 ED49  A5 38     iED49      LDA DIRLST    
 ED4B  F0 C5                BEQ iED12     
 ED4D  20 F0 EF             JSR GETDIR    
 ED50  4C 43 ED             JMP GET3      

 ED53  A6 83     iED53      LDX LINDX     
 ED55  8E EB 10             STX x10EB     
 ED58  A5 84                LDA SA        
 ED5A  48                   PHA           
 ED5B  BD E1 10             LDA CHNDAT+8,X
 ED5E  48                   PHA           
 ED5F  29 1F                AND #$1F      
 ED61  85 82                STA SECTOR    
 ED63  68                   PLA           
 ED64  29 E0                AND #$E0      
 ED66  09 02                ORA #$02      
 ED68  85 D8                STA INDEX     
 ED6A  B5 B6                LDA FILTYP,X  
 ED6C  29 01                AND #$01      
 ED6E  85 80                STA DRVNUM    
 ED70  A9 12                LDA #$12      
 ED72  85 81                STA TRACK     
 ED74  20 88 EB             JSR GETBUF    
 ED77  48                   PHA           
 ED78  85 8D                STA JOBNUM    
 ED7A  20 1D EE             JSR DRTRD     
 ED7D  A0 00                LDY #$00      
 ED7F  BD CE EE             LDA BUFIND,X  
 ED82  85 9C                STA F2PTR     
 ED84  A5 D8                LDA INDEX     
 ED86  85 9B                STA F1PTR     
 ED88  B1 9B                LDA (F1PTR),Y 
 ED8A  10 25                BPL iEDB1     
 ED8C  29 8F                AND #$8F      
 ED8E  91 9B                STA (F1PTR),Y 
 ED90  C8                   INY           
 ED91  B1 9B                LDA (F1PTR),Y 
 ED93  85 81                STA TRACK     
 ED95  84 2C                STY TEMP+2    
 ED97  A0 1B                LDY #$1B      
 ED99  B1 9B                LDA (F1PTR),Y 
 ED9B  48                   PHA           
 ED9C  88                   DEY           
 ED9D  B1 9B                LDA (F1PTR),Y 
 ED9F  A4 2C                LDY TEMP+2    
 EDA1  91 9B                STA (F1PTR),Y 
 EDA3  C8                   INY           
 EDA4  B1 9B                LDA (F1PTR),Y 
 EDA6  85 82                STA SECTOR    
 EDA8  68                   PLA           
 EDA9  91 9B                STA (F1PTR),Y 
 EDAB  20 B6 F9             JSR DELFIL    
 EDAE  4C B5 ED             JMP iEDB5     
 EDB1  09 80     iEDB1      ORA #$80      
 EDB3  91 9B                STA (F1PTR),Y 
 EDB5  AD EB 10  iEDB5      LDA x10EB     
 EDB8  0A                   ASL           
 EDB9  AA                   TAX           
 EDBA  A0 1C                LDY #$1C      
 EDBC  B5 6F                LDA BUFNUM+16,X
 EDBE  91 9B                STA (F1PTR),Y 
 EDC0  C8                   INY           
 EDC1  B5 70                LDA BUFNUM+17,X
 EDC3  91 9B                STA (F1PTR),Y 
 EDC5  68                   PLA           
 EDC6  AA                   TAX           
 EDC7  A9 90                LDA #$90      
 EDC9  05 80                ORA DRVNUM    
 EDCB  20 08 E9             JSR DOIT      
 EDCE  8A                   TXA           
 EDCF  20 B0 EB             JSR FREBUF    
 EDD2  68                   PLA           
 EDD3  85 84                STA SA        
 EDD5  60                   RTS           

; INITIALIZE BUFFER PNTR TABLE
; this function is much longer in 4040

 EDD6  A2 00     INTTAB     LDX #$00      
 EDD8  A0 00                LDY #$00      
 EDDA  A9 00     iEDDA      LDA #$00      
 EDDC  95 3D                STA BUFTAB,X  
 EDDE  E8                   INX           
 EDDF  B9 CE EE             LDA BUFIND,Y  
 EDE2  95 3D                STA BUFTAB,X  
 EDE4  E8                   INX           
 EDE5  C8                   INY           
 EDE6  C9 43                CMP #$43      
 EDE8  D0 F0                BNE iEDDA     
 EDEA  A9 B4                LDA #$B4      
 EDEC  85 5D                STA x5D       
 EDEE  A9 43                LDA #$43      
 EDF0  85 5E                STA x5E       
 EDF2  60                   RTS           

; READ NEXT BUFFER OF A FILE
; FOLLOW LINKS IN FIRST TWO BYTES
; END OF FILE IF 1ST BYTE=0
; 2ND CHAR LENGTH

 EDF3  20 9D E8  NXTBUF     JSR GETACT    
 EDF6  0A                   ASL           
 EDF7  AA                   TAX           
 EDF8  A9 00                LDA #$00      
 EDFA  95 3D                STA BUFTAB,X  
 EDFC  A1 3D                LDA (BUFTAB,X)
 EDFE  F0 05                BEQ iEE05     
 EE00  D6 3D                DEC BUFTAB,X  
 EE02  4C F3 E9             JMP RDBYT     
 EE05  60        iEE05      RTS           

; READ TRACK, SECTOR FROM HEADER

 EE06  20 B0 E9  CURBLK     JSR FNDRCH    
 EE09  20 9D E8             JSR GETACT    
 EE0C  85 8D                STA JOBNUM    
 EE0E  0A                   ASL           
 EE0F  0A                   ASL           
 EE10  0A                   ASL           
 EE11  AA                   TAX           
 EE12  BD 24 10             LDA HDRS+3,X  
 EE15  85 82                STA SECTOR    
 EE17  BD 23 10             LDA HDRS+2,X  
 EE1A  85 81                STA TRACK     
 EE1C  60                   RTS           

; DIRECT BLOCK READ

 EE1D  A9 80     DRTRD      LDA #$80       ; READ
 EE1F  D0 02                BNE iEE23     

; DIRECT BLOCK WRITE

 EE21  A9 90     DRTWRT     LDA #$90       ; WRITE
 EE23  05 80     iEE23      ORA DRVNUM    
 EE25  85 89                STA CMD       
 EE27  A5 8D                LDA JOBNUM    
 EE29  20 6B E8             JSR SETH      
 EE2C  A6 8D                LDX JOBNUM    
 EE2E  A5 81                LDA TRACK     
 EE30  9D 12 10             STA x1012,X   
 EE33  4C 0A E9             JMP DOIT2     

; OPEN INTERNAL READ CHANL (SA=16)

 EE36  A9 10     OPNIRD     LDA #$10       ; IRSA
 EE38  85 84                STA SA        
 EE3A  20 72 EA             JSR OPNRCH    
 EE3D  A9 02                LDA #$02      
 EE3F  4C 89 EE             JMP SETPNT    

; OPEN INTERNAL WRITE CHANL (SA=16)

 EE42  A9 10     iEE42      LDA #$10      
 EE44  85 84                STA SA        
 EE46  4C CE EA             JMP OPNWCH    

; ALLOCATE NEXT DIRECTORY BLOCK ON 18
; AND MARK AS USED IN BAM

 EE49  20 06 EE  NXDRBK     JSR CURBLK    
 EE4C  20 9D E8             JSR GETACT    
 EE4F  85 3B                STA x3B       
 EE51  A9 01                LDA #$01      
 EE53  85 2A                STA TEMP      
 EE55  A5 92                LDA SECINC    
 EE57  48                   PHA           
 EE58  A9 03                LDA #$03       ; INCR SECTOR BY 3 IN DIRECTORY
 EE5A  85 92                STA SECINC    
 EE5C  20 91 E4             JSR NXTDS     
 EE5F  68                   PLA           
 EE60  85 92                STA SECINC    
 EE62  A9 00                LDA #$00      
 EE64  20 89 EE             JSR SETPNT    
 EE67  A5 81                LDA TRACK     
 EE69  20 89 E8             JSR PUTBYT    
 EE6C  A5 82                LDA SECTOR    
 EE6E  20 89 E8             JSR PUTBYT    
 EE71  20 6E E9             JSR WRTBUF    
 EE74  20 59 E8             JSR WATJOB    
 EE77  A9 00                LDA #$00      
 EE79  20 89 EE             JSR SETPNT    
 EE7C  20 89 E8  iEE7C      JSR PUTBYT    
 EE7F  D0 FB                BNE iEE7C     
 EE81  20 89 E8             JSR PUTBYT    
 EE84  A9 FF                LDA #$FF      
 EE86  4C 89 E8             JMP PUTBYT    

; .A=NEW PNTR VALUE

 EE89  85 2A     SETPNT     STA TEMP      
 EE8B  20 9D E8             JSR GETACT    
 EE8E  0A                   ASL           
 EE8F  AA                   TAX           
 EE90  B5 3E                LDA BUFTAB+1,X
 EE92  85 94                STA DIRBUF+1  
 EE94  A5 2A                LDA TEMP      
 EE96  95 3D                STA BUFTAB,X  
 EE98  85 93                STA DIRBUF    
 EE9A  60                   RTS           

 EE9B  85 2A                STA TEMP      
 EE9D  A9 07                LDA #$07      
 EE9F  85 83                STA LINDX     
 EEA1  20 6E EB             JSR RELBUF    
 EEA4  A5 83                LDA LINDX     
 EEA6  4C 10 EB             JMP iEB10     

; FREE THE INTERNAL CHANL (SA=16)

 EEA9  A9 10     FREICH     LDA #$10       ; in the 4040 there are two calls to FRECHN, with .A as #IRSA and #IWSA
 EEAB  85 84                STA SA        
 EEAD  4C 32 EB             JMP FRECHN    

; READ THE ACTIVE BUFFER POINTER

 EEB0  20 9D E8  GETPNT     JSR GETACT    
 EEB3  0A                   ASL           
 EEB4  AA                   TAX           
 EEB5  B5 3E                LDA BUFTAB+1,X
 EEB7  85 94                STA DIRBUF+1  
 EEB9  B5 3D                LDA BUFTAB,X  
 EEBB  85 93                STA DIRBUF    
 EEBD  60                   RTS           

; DIRECT READ BYTE, .A=BYTE# TO READ

 EEBE  85 2C     DRDBYT     STA TEMP+2    
 EEC0  20 9D E8             JSR GETACT    
 EEC3  AA                   TAX           
 EEC4  BD CE EE             LDA BUFIND,X  
 EEC7  85 2D                STA TEMP+3    
 EEC9  A0 00                LDY #$00      
 EECB  B1 2C                LDA (TEMP+2),Y
 EECD  60                   RTS           

; INDEX TABLE CONTAINING HIGH 
; BYTE ADRESS OF BUFFERS

 EECE  BUFIND     .byte $11, $12, $13, $20, $21, $22, $23, $30  ;qrs !"#0
 EED6             .byte $31, $32, $33, $40, $41, $42, $43       ;123@abc


; POINT BMPNT AT BAM


; MARK A TRACK, SECTOR AS FREE IN BAM


 EEDD  20 5F E5  FRETS      JSR SETBMP     ; POINT BMPNT AT BAM
 EEE0  A5 81                LDA TRACK      ; CALC INDEX INTO BAM - in 4040 done in subrouting FREUSE
 EEE2  0A                   ASL           
 EEE3  0A                   ASL           
 EEE4  85 2A                STA TEMP      
 EEE6  A8                   TAY           
 EEE7  B1 28                LDA (BMPNT),Y 
 EEE9  AA                   TAX           
 EEEA  E8                   INX           
 EEEB  8A                   TXA           
 EEEC  91 28                STA (BMPNT),Y 
 EEEE  A5 82                LDA SECTOR    
 EEF0  4A                   LSR           
 EEF1  4A                   LSR           
 EEF2  4A                   LSR           
 EEF3  18                   CLC           
 EEF4  65 2A                ADC TEMP      
 EEF6  A8                   TAY           
 EEF7  C8                   INY           
 EEF8  A5 82                LDA SECTOR    
 EEFA  29 07                AND #$07      
 EEFC  AA                   TAX           
 EEFD  A9 01                LDA #$01      
 EEFF  CA        iEEFF      DEX           
 EF00  30 03                BMI iEF05     
 EF02  0A                   ASL           
 EF03  90 FA                BCC iEEFF     
 EF05  11 28     iEF05      ORA (BMPNT),Y  ; free it
 EF07  91 28                STA (BMPNT),Y 
 EF09  60                   RTS           

; TURN ON ACTIVITY LED SPECIFIED
; BY DRVNUM

 EF0A  A9 E7     SETLDS     LDA #$E7       ; clear both LEDs
 EF0C  2D 82 02             AND RIOT2PBD  
 EF0F  8D 82 02             STA RIOT2PBD   ; the 4040 does not store it back, but puts it on stack. Avoiding possible IO side effects
 EF12  A5 80                LDA DRVNUM    
 EF14  F0 09                BEQ iEF1F     
 EF16  A9 08                LDA #$08       ; LED1
 EF18  0D 82 02             ORA RIOT2PBD  
 EF1B  8D 82 02             STA RIOT2PBD  
 EF1E  60                   RTS           
 EF1F  A9 10     iEF1F      LDA #$10       ; LED0
 EF21  0D 82 02             ORA RIOT2PBD  
 EF24  8D 82 02             STA RIOT2PBD  
 EF27  60                   RTS           

; START THE DIRECTORY LOADING FUNCTION
; GET THE BUFFER AND GET IT STARTED

 EF28  A9 00     iEF28      LDA #$00      
 EF2A  85 84                STA SA        
 EF2C  A9 01                LDA #$01       ; ALLOCATE CHANL AND 1 BUFFER
 EF2E  20 F3 EA             JSR GETRCH    
 EF31  A9 00                LDA #$00      
 EF33  20 89 EE             JSR SETPNT    
 EF36  A6 83                LDX LINDX     
 EF38  A9 00                LDA #$00      
 EF3A  95 C6                STA LSTCHR,X  
 EF3C  20 9D E8             JSR GETACT    
 EF3F  AA                   TAX           
 EF40  A5 80                LDA DRVNUM    
 EF42  9D 99 10             STA LSTJOB,X  
 EF45  A9 00                LDA #$00      
 EF47  95 3D                STA BUFTAB,X  
 EF49  A9 01                LDA #$01       ; PUT SAL IN BUFFER
 EF4B  20 89 E8             JSR PUTBYT    
 EF4E  A9 04                LDA #$04       ; PUT SAH IN BUFFER
 EF50  20 89 E8             JSR PUTBYT    
 EF53  A9 01                LDA #$01       ; INSERT FHONEY LINKS (0101)
 EF55  20 89 E8             JSR PUTBYT    
 EF58  20 89 E8             JSR PUTBYT    
 EF5B  A5 80                LDA DRVNUM     ; the 4040 reads NBTEMP here
 EF5D  20 89 E8             JSR PUTBYT     ; PUT IN DRVNUM
 EF60  A9 00                LDA #$00      
 EF62  20 89 E8             JSR PUTBYT    
 EF65  20 E2 EF             JSR MOVBUF     ; GET DISK NAME
 EF68  20 9D E8             JSR GETACT    
 EF6B  0A                   ASL           
 EF6C  AA                   TAX           
 EF6D  D6 3D                DEC BUFTAB,X  
 EF6F  D6 3D                DEC BUFTAB,X  
 EF71  A9 00                LDA #$00       ; END OF THIS LINE
 EF73  20 89 E8             JSR PUTBYT    
 EF76  A9 01     DIR1       LDA #$01       ; INSERT FHONEY LINKS ($0101)
 EF78  20 89 E8             JSR PUTBYT    
 EF7B  20 89 E8             JSR PUTBYT    
 EF7E  20 51 F5             JSR GETNAM     ; GET #BUFRS AND FILE NAME
 EF81  90 2B                BCC DIR3       ; TEST IF LAST ENTRY
 EF83  AD ED 10             LDA NBTEMP    
 EF86  20 89 E8             JSR PUTBYT    
 EF89  AD EE 10             LDA NBTEMP+1  
 EF8C  20 89 E8             JSR PUTBYT    
 EF8F  20 E2 EF             JSR MOVBUF    
 EF92  A9 00                LDA #$00       ; END OF ENTRY
 EF94  20 89 E8             JSR PUTBYT    
 EF97  D0 DD                BNE DIR1      
 EF99  20 9D E8  DIR10      JSR GETACT    
 EF9C  0A                   ASL           
 EF9D  AA                   TAX           
 EF9E  A9 00                LDA #$00      
 EFA0  95 3D                STA BUFTAB,X  
 EFA2  A9 88                LDA #$88       ; RDYTLK
 EFA4  A4 83                LDY LINDX     
 EFA6  85 38                STA DIRLST    
 EFA8  99 BE 00             STA CHNRDY,Y   ; DIRECTORY LIST BUFFER FULL
 EFAB  A5 87                LDA DATA      
 EFAD  60                   RTS           
 EFAE  AD ED 10  DIR3       LDA NBTEMP     ; THIS IS END OF LOAD
 EFB1  20 89 E8             JSR PUTBYT    
 EFB4  AD EE 10             LDA NBTEMP+1  
 EFB7  20 89 E8             JSR PUTBYT    
 EFBA  20 E2 EF             JSR MOVBUF    
 EFBD  20 9D E8             JSR GETACT    
 EFC0  0A                   ASL           
 EFC1  AA                   TAX           
 EFC2  D6 3D                DEC BUFTAB,X  
 EFC4  D6 3D                DEC BUFTAB,X  
 EFC6  A9 00                LDA #$00       ; END OF LISTING (000)
 EFC8  20 89 E8             JSR PUTBYT    
 EFCB  20 89 E8             JSR PUTBYT    
 EFCE  20 89 E8             JSR PUTBYT    
 EFD1  20 9D E8             JSR GETACT    
 EFD4  0A                   ASL           
 EFD5  A8                   TAY           
 EFD6  B9 3D 00             LDA BUFTAB,Y  
 EFD9  A6 83                LDX LINDX     
 EFDB  95 C6                STA LSTCHR,X  
 EFDD  D6 C6                DEC LSTCHR,X  
 EFDF  4C 99 EF             JMP DIR10     

; TRANSFRE FILE NAME TO LISTING BUFFER

 EFE2  A0 00     MOVBUF     LDY #$00      
 EFE4  B9 B4 42  iEFE4      LDA NAMBUF,Y  
 EFE7  20 89 E8             JSR PUTBYT    
 EFEA  C8                   INY           
 EFEB  C0 1B                CPY #$1B       ; in 4040 src this is #27, not a constant
 EFED  D0 F5                BNE iEFE4     
 EFEF  60                   RTS           

; GET CHAR FOR DIRECTORY LOADING

 EFF0  20 D4 E9  GETDIR     JSR GETBYT    
 EFF3  F0 01                BEQ iEFF6     
 EFF5  60                   RTS           
 EFF6  85 87     iEFF6      STA DATA      
 EFF8  A4 83                LDY LINDX     
 EFFA  B9 C6 00             LDA LSTCHR,Y  
 EFFD  F0 08                BEQ iF007     
; *** EFFF: Warning: Possibly modifyable opcode. ***

 EFFF  A9 80                LDA #$80       ; EOIOUT
 F001  99 BE 00             STA CHNRDY,Y  
 F004  A5 87                LDA DATA      
 F006  60                   RTS           
 F007  4C 76 EF  iF007      JMP DIR1      

; CALC THE NUMBER OF FREE BLOCKS ON DRVNUM

 F00A  A6 80     NUMFRE     LDX DRVNUM    
 F00C  BD 40 E5             LDA IPBM,X    
 F00F  85 2B                STA TEMP+1    
 F011  A9 04                LDA #$04      
 F013  85 2A                STA TEMP       ; 0 LOW PTR
 F015  A9 00                LDA #$00      
 F017  8D ED 10             STA NBTEMP    
 F01A  8D EE 10             STA NBTEMP+1  
 F01D  A9 22                LDA #$22      
 F01F  85 2C                STA TEMP+2    
 F021  A0 00     iF021      LDY #$00      
 F023  18                   CLC           
 F024  B1 2A                LDA (TEMP),Y  
 F026  6D ED 10             ADC NBTEMP    
 F029  8D ED 10             STA NBTEMP    
 F02C  AD EE 10             LDA NBTEMP+1  
 F02F  69 00                ADC #$00      
 F031  8D EE 10             STA NBTEMP+1  
 F034  A5 2A                LDA TEMP      
 F036  18        iF036      CLC           
 F037  69 04                ADC #$04      
 F039  C9 48                CMP #$48       ; DON'T COUNT THE DIR
 F03B  F0 F9                BEQ iF036     
 F03D  85 2A                STA TEMP      
 F03F  C6 2C                DEC TEMP+2    
 F041  D0 DE                BNE iF021     
 F043  60                   RTS           

; PARSE & EXECUTE STRING IN CMDBUF
; in 4040 there is some code in PARSXQ before this code here

 F044  20 59 F1  PARSXQ     JSR CMDSET     ; SET VARIABLES, REGS
 F047  B9 00 00             LDA CMDBUF,Y  
 F04A  85 97                STA CHAR      
 F04C  A2 09                LDX #$09       ; NCMDS-1
 F04E  BD 00 E0  iF04E      LDA CMDTBL,X  
 F051  C5 97                CMP CHAR      
 F053  F0 08                BEQ iF05D     
 F055  CA                   DEX           
 F056  10 F6                BPL iF04E     
 F058  A9 31                LDA #$31       ; BADCMD, NO SUCH CMD
 F05A  4C 90 F0             JMP CMDERR    
 F05D  86 96     iF05D      STX CMDNUM     ; X= CMD #
 F05F  E0 06                CPX #$06       ; PCMD, CMDS NOT PARSED
 F061  90 03                BCC iF066     
 F063  20 AB F0             JSR TAGCMD     ; SET TABLES, POINTERS &PATTERNS
 F066  A6 96     iF066      LDX CMDNUM    
 F068  BD 0A E0             LDA CJUMPL,X  
 F06B  85 2A                STA TEMP      
 F06D  BD 14 E0             LDA CJUMPH,X  
 F070  85 2B                STA TEMP+1    
 F072  6C 2A 00             JMP (TEMP)     ; COMMAND TABLE JUMP

; SUCCESSFUL COMMAND TERMINATION

 F075  A0 00     ENDCMD     LDY #$00      
 F077  98                   TYA           
 F078  84 81                STY TRACK     
 F07A  84 82     SCREND     STY SECTOR     ; SCRATCH ENTRY
 F07C  84 5B                STY x5B        ; CB
 F07E  20 5D E7             JSR ERRMSG    
 F081  A5 80                LDA DRVNUM    
 F083  85 D2                STA LSTDRV    
 F085  AD 82 02             LDA RIOT2PBD  
 F088  29 DF                AND #$DF      
 F08A  8D 82 02             STA RIOT2PBD  
 F08D  4C A9 EE             JMP FREICH     ; FREE INTERNAL CHANNELS (? label should be FREICH)

; COMMAND LEVEL ERROR PROCESSING

 F090  A0 00     CMDERR     LDY #$00      
 F092  84 81                STY TRACK     
 F094  84 82                STY SECTOR    
 F096  4C D4 E6             JMP CMDER2    

 F099  A2 00     SIMPRS     LDX #$00       ; SIMPLE PARSER
 F09B  86 9D                STX FILTBL    
 F09D  A9 3A                LDA #$3A       ; ":"
 F09F  20 17 F1             JSR PARSE     
 F0A2  F0 04                BEQ iF0A8     
 F0A4  88                   DEY           
 F0A5  88                   DEY           
 F0A6  84 9D                STY FILTBL    
 F0A8  4C EC F1  iF0A8      JMP SETANY     ; SET DRIVE#

; TAG COMMAND STRING
; SET UP CMD STRUCTURE
; IMAGE & FILE STREAM PTRS
; Note: in 4040 the code up to the first PARSE is in subroutine PRSCLN

 F0AB  A0 00     TAGCMD     LDY #$00      
 F0AD  A2 00                LDX #$00      
 F0AF  A9 3A                LDA #$3A       ; ":"
 F0B1  20 17 F1             JSR PARSE      ; FIND POS'N OF ":"
 F0B4  D0 05                BNE iF0BB     
 F0B6  A9 34     iF0B6      LDA #$34       ; NOFILE, NONE, NO FILES
 F0B8  4C 90 F0             JMP CMDERR    
 F0BB  88        iF0BB      DEY           
 F0BC  88                   DEY           
 F0BD  84 9D                STY FILTBL     ; ":"-1 STARTS FS1
 F0BF  8A                   TXA           
 F0C0  D0 F4                BNE iF0B6      ; ERR: "," BEFORE ":"
 F0C2  A9 3D     iF0C2      LDA #$3D       ; SEARCH "="
 F0C4  20 17 F1             JSR PARSE     
 F0C7  8A                   TXA            ; ?FILE COUNT = 1-1?
 F0C8  F0 02                BEQ iF0CC     
 F0CA  A9 40                LDA #$40       ; %01000000, G1-BIT
 F0CC  09 21     iF0CC      ORA #$21       ; %00100001, E1,^E2-BITS
 F0CE  85 CF                STA IMAGE      ; FS STRUCTURE
 F0D0  E8                   INX           
 F0D1  86 99                STX F1CNT     
 F0D3  86 9A                STX R0         ; F2CNT, INIT FOR NO FS2
 F0D5  A5 CE                LDA PATFLG    
 F0D7  F0 0A                BEQ iF0E3     
 F0D9  A9 80                LDA #$80       ; %10000000, P1-BIT
 F0DB  05 CF                ORA IMAGE     
 F0DD  85 CF                STA IMAGE     
 F0DF  A9 00                LDA #$00      
 F0E1  85 CE                STA PATFLG     ; CLEAR PATTERN FLAG
 F0E3  98        iF0E3      TYA            ; PTR TO FS2
 F0E4  F0 21                BEQ iF107      ; FS2 NOT HERE
 F0E6  95 9D                STA FILTBL,X  
 F0E8  A5 99                LDA F1CNT      ; FS2 IS HERE NOW,...
 F0EA  85 9C                STA F2PTR      ; ...NOW SET F2 PTR
 F0EC  A9 8D                LDA #$8D       ; FIND CR-SHIFTED
 F0EE  20 17 F1             JSR PARSE      ; PARSE REST OF CMD STRING
 F0F1  E8                   INX            ; ADVANCE FILTBL PTR TO END
 F0F2  86 9A                STX R0         ; F2CNT, SAVE IT
 F0F4  CA                   DEX            ; RESTORE FOR TEST
 F0F5  A5 CE                LDA PATFLG     ; SAVE LAST PATTERN
 F0F7  F0 02                BEQ iF0FB      ; ?ANY PATTERN?
 F0F9  A9 08                LDA #$08       ; %1000, YES, P2-BIT
 F0FB  E4 99     iF0FB      CPX F1CNT      ; ?F2CNT=F1CNT+1?
 F0FD  F0 02                BEQ iF101     
 F0FF  09 04                ORA #$04       ; %0100, G2-BIT
 F101  09 03     iF101      ORA #$03       ; %0011, E2-BIT, ^E2-BIT
 F103  45 CF                EOR IMAGE      ; EOR CLEARS ^E2-BIT
 F105  85 CF                STA IMAGE     
 F107  A6 96     iF107      LDX CMDNUM    
 F109  3D 18 E0             AND CJUMPH+4,X ; MATCH CMD TEMPLATE (orignal label: STRUCT)
 F10C  D0 01                BNE iF10F     
 F10E  60                   RTS           
 F10F  8D E9 10  iF10F      STA ERWORD     ; **COULD BE WARNING
 F112  A9 30                LDA #$30       ; BADSYN, ERR: BAD SYNTAX
 F114  4C 90 F0             JMP CMDERR    

; PARSE STRING
; LOOKS FOR SPECIAL CHARS,
; RETURNING WHEN VAR'BL CHAR
; IS FOUND
; A: VAR'BL CHAR
; X: IN,OUT: INDEX, FILTBL+1
; Y: IN: INDEX, CMDBUF
; OUT: NEW PTR, =0 IF NONE
; (Z=1) IF Y=0

 F117  85 97     PARSE      STA CHAR       ; SAVE VAR'BL CHAR
 F119  C4 95     iF119      CPY CMDSIZ     ; STAY IN STRING
 F11B  B0 2A                BCS iF147     
 F11D  B9 00 00             LDA CMDBUF,Y   ; MATCH CHAR
 F120  C8                   INY           
 F121  C5 97                CMP CHAR      
 F123  F0 24                BEQ iF149      ; FOUND CHAR
 F125  C9 2A                CMP #$2A       ; MATCH PATTERN CHAR ("*" in this case)
 F127  F0 04                BEQ iF12D     
 F129  C9 3F                CMP #$3F       ; "?"
 F12B  D0 02                BNE iF12F     
 F12D  E6 CE     iF12D      INC PATFLG     ; SET PATTERN FLAG
 F12F  C9 2C     iF12F      CMP #$2C       ; MATCH FILE SEPARATOR (",")
 F131  D0 E6                BNE iF119     
 F133  98                   TYA           
 F134  95 9E                STA FILTBL+1,X ; PUT PTRS IN TABLE
 F136  A5 CE                LDA PATFLG     ; SAVE PATTERN FOR EA FILE
 F138  29 7F                AND #$7F      
 F13A  F0 06                BEQ iF142     
 F13C  A9 80                LDA #$80       ; RETAIN PATTERN PRESENCE...
 F13E  95 AC                STA FILTRK,X  
 F140  85 CE                STA PATFLG     ; ... BUT CLEAR COUNT
 F142  E8        iF142      INX           
 F143  E0 04                CPX #$04       ; MXFILS-1
 F145  90 D2                BCC iF119      ; NO MORE THAN MXFILS
 F147  A0 00     iF147      LDY #$00       ; Y=0 (Z=1)
 F149  A5 95     iF149      LDA CMDSIZ    
 F14B  95 9E                STA FILTBL+1,X
 F14D  A5 CE                LDA PATFLG    
 F14F  29 7F                AND #$7F      
 F151  F0 04                BEQ iF157     
 F153  A9 80                LDA #$80      
 F155  95 AC                STA FILTRK,X  
 F157  98        iF157      TYA            ; Z IS SET
 F158  60                   RTS           

; INITIALIZE COMMAND TABLES, PTRS, ETC.

 F159  A4 5B     CMDSET     LDY x5B        ; in 4040 source this is "LDY BUFTAB+CBPTR", but what does it mean?
 F15B  F0 14                BEQ iF171     
 F15D  88                   DEY           
 F15E  F0 10                BEQ iF170     
 F160  B9 00 00             LDA CMDBUF,Y  
 F163  C9 0D                CMP #$0D       ; CR
 F165  F0 0A                BEQ iF171     
 F167  88                   DEY           
 F168  B9 00 00             LDA CMDBUF,Y  
 F16B  C9 0D                CMP #$0D       ; CR
 F16D  F0 02                BEQ iF171     
 F16F  C8                   INY           
 F170  C8        iF170      INY           
 F171  84 95     iF171      STY CMDSIZ     ; SEt CMD STRING SIZE
 F173  C0 29                CPY #$29       ; CMDLEN-1
 F175  A0 FF                LDY #$FF      
 F177  90 07                BCC CMDRST    
 F179  84 96                STY CMDNUM    
 F17B  A9 32                LDA #$32       ; LONGLN, LONG LINE ERROR
 F17D  4C 90 F0             JMP CMDERR    

; CLEAR VARIABLES, TABLES

 F180  C8        CMDRST     INY            ; in 4040, .Y is explicitely set to 0
 F181  84 5B     iF181      STY x5B        ; "BUFTAB+CBPTR"
 F183  98                   TYA           
 F184  85 DA                STA TYPFLG    
 F186  85 9B                STA F1PTR     
 F188  85 9C                STA F2PTR     
 F18A  85 99                STA F1CNT     
 F18C  85 9A                STA R0         ; F2CNT
 F18E  85 CE                STA PATFLG    
 F190  8D E9 10             STA ERWORD    
 F193  A2 05                LDX #$05       ; MXFILS
 F195  95 9C     iF195      STA F2PTR,X   
 F197  95 A1                STA xA1,X      ; FILENT-1
 F199  95 A6                STA xA6,X      ; FILDAT-1
 F19B  95 AB                STA xAB,X      ; FILTRK-1
 F19D  95 B0                STA xB0,X      ; FILSEC-1
 F19F  CA                   DEX           
 F1A0  D0 F3                BNE iF195     
 F1A2  60                   RTS           

; SET 1ST DRIVE AND TABLE POINTERS

 F1A3  A5 9A     ONEDRV     LDA R0        
 F1A5  85 99                STA F1CNT     
 F1A7  A9 01                LDA #$01      
 F1A9  85 9A                STA R0        
 F1AB  85 9C                STA F2PTR     

; SET UP ALL DRIVES FROM F2CNT

 F1AD  A4 D2     ALLDRS     LDY LSTDRV     ; ET UP DRIVE #'S...
 F1AF  A2 00                LDX #$00       ; ... INTO FILE ENTRY TABLE...
 F1B1  86 9B     iF1B1      STX F1PTR      ; ... ON SECTOR PTR BYTE
 F1B3  B5 9D                LDA FILTBL,X  
 F1B5  20 C5 F1             JSR SETDRV    
 F1B8  A6 9B                LDX F1PTR     
 F1BA  95 9D                STA FILTBL,X   ; INCR PTR PAST ":"
 F1BC  98                   TYA            ; BITS REP DRIVES
 F1BD  95 A7                STA FILDAT,X   ; BIT7: DEFAULT
 F1BF  E8                   INX            ; BIT0: DRIVE #
 F1C0  E4 9A                CPX R0        
 F1C2  90 ED                BCC iF1B1     
 F1C4  60                   RTS           

; SET DRIVE NUMBER
; DETERMINES DRIVE # FROm TEST OR
; USES DEFAULT (-D)
; A: IN,OUT: INDEX, CMDBUF
; Y: IN: DEFAULT DRIVE
; OUT: DRIVE NUMBER, - IF DEFAULT

 F1C5  AA        SETDRV     TAX            ; X=CMDBUF INDEX
 F1C6  A9 3A                LDA #$3A       ; ":"
 F1C8  D5 01                CMP CMDBUF+1,X ; FOR XXX:FILE
 F1CA  F0 0B                BEQ iF1D7      ; ^
 F1CC  D5 00                CMP CMDBUF,X   ; FOR XXX:FILE
 F1CE  D0 15                BNE iF1E5      ; ...^
 F1D0  E8                   INX            ; FOUND ":", SO ...
 F1D1  98        iF1D1      TYA            ; DRIVE= DEFAULT
 F1D2  29 01     iF1D2      AND #$01       ; CONVERT TO NUMERIC
 F1D4  A8        iF1D4      TAY            ; RESTORE DRIVE
 F1D5  8A                   TXA            ; A=INDEX && XXXXFILE
 F1D6  60                   RTS            ; ...............^
 F1D7  B5 00     iF1D7      LDA CMDBUF,X  
 F1D9  E8                   INX            ; XXX:FILE
 F1DA  E8                   INX            ; ..--^
 F1DB  C9 30                CMP #$30       ; FOR XX0:FILE
 F1DD  F0 F3                BEQ iF1D2      ; ........^
 F1DF  C9 31                CMP #$31       ; FOR XX1:FILE
 F1E1  F0 EF                BEQ iF1D2      ; ........^
 F1E3  D0 EC                BNE iF1D1      ; CMD:FILE OR XX,:FILE ; here points to the "F" in FILE twice
 F1E5  98        iF1E5      TYA            ; FOR XXX,FILE OR XX=FILE
 F1E6  09 80                ORA #$80       ; ........^          ^
 F1E8  29 81                AND #$81       ; DRIVE= -DEFAULT
 F1EA  D0 E8                BNE iF1D4      ; FINISH TESTING

; SET DRIVE FROM ANY CONFIG

 F1EC  A9 00     SETANY     LDA #$00      
 F1EE  85 CF                STA IMAGE     
 F1F0  A4 9D                LDY FILTBL    
 F1F2  B9 00 00  iF1F2      LDA CMDBUF,Y  
 F1F5  C9 30                CMP #$30      
 F1F7  F0 12                BEQ iF20B     
 F1F9  C9 31                CMP #$31      
 F1FB  F0 0E                BEQ iF20B     
 F1FD  C8                   INY           
 F1FE  C4 95                CPY CMDSIZ    
 F200  B0 05                BCS iF207     
 F202  A4 95                LDY CMDSIZ    
 F204  88                   DEY           
 F205  D0 EB                BNE iF1F2     
 F207  C6 CF     iF207      DEC IMAGE     
 F209  A5 D2                LDA LSTDRV    
 F20B  29 01     iF20B      AND #$01      
 F20D  85 80                STA DRVNUM    
 F20F  4C 0A EF             JMP SETLDS    

; TOGGLE DRVNUM

 F212  A5 80     TOGDRV     LDA DRVNUM    
 F214  49 01                EOR #$01      
 F216  29 01                AND #$01      
 F218  85 80                STA DRVNUM    
 F21A  60                   RTS           

; SET PTRS TO ONE FILE STREAM & CHK TYPE

 F21B  A0 00     FS1SET     LDY #$00      
 F21D  A5 99                LDA F1CNT     
 F21F  C5 9A                CMP R0         ; R0 aka F2CNT
 F221  F0 15                BEQ iF238     
 F223  C6 9A                DEC R0        
 F225  A4 9A                LDY R0        
 F227  B9 9D 00             LDA FILTBL,Y  
 F22A  A8                   TAY           
 F22B  B9 00 00             LDA CMDBUF,Y   ; in 4040 this is an indirect indexed LDA (DB),Y
 F22E  A0 03                LDY #$03       ; NTYPES-1
 F230  D9 31 E0  iF230      CMP TYPLST,Y  
 F233  F0 03                BEQ iF238     
 F235  88                   DEY           
 F236  D0 F8                BNE iF230     
 F238  98        iF238      TYA           
 F239  0A                   ASL           
 F23A  85 DA                STA TYPFLG    
 F23C  60                   RTS           

; TEST CHAR In ACCUM FOR "0" OR "1"

 F23D  C9 30     TST0V1     CMP #$30      
 F23F  F0 06                BEQ iF247     
 F241  C9 31                CMP #$31      
 F243  F0 02                BEQ iF247     
 F245  09 80                ORA #$80      
 F247  29 81     iF247      AND #$81      
 F249  60                   RTS           

; OPTSCH OPTIMAL SEARCH FOR LOOKUP
; AND FNDFIL

 F24A  A9 00     OPTSCH     LDA #$00       ; DETERMINE OPTIMAL SEARCH
 F24C  85 2A                STA TEMP       ; INIT DRIVE MASK
 F24E  85 D1                STA DRVFLG    
 F250  85 D1                STA DRVFLG    
 F252  48                   PHA           
 F253  A6 9A                LDX R0        
 F255  68        iF255      PLA           
 F256  05 2A                ORA TEMP      
 F258  48                   PHA           
 F259  A9 01                LDA #$01      
 F25B  85 2A                STA TEMP      
 F25D  CA                   DEX           
 F25E  30 0F                BMI iF26F     
 F260  B5 A7                LDA FILDAT,X  
 F262  10 04                BPL iF268     
 F264  06 2A                ASL TEMP      
 F266  06 2A                ASL TEMP      
 F268  4A        iF268      LSR           
 F269  90 EA                BCC iF255     
 F26B  06 2A                ASL TEMP      
 F26D  D0 E6                BNE iF255      ; (BRANCH)
 F26F  68        iF26F      PLA           
 F270  AA                   TAX           
 F271  BD 89 F2             LDA SCHTBL-1,X
 F274  48                   PHA           
 F275  29 03                AND #$03      
 F277  85 D0                STA DRVCNT    
 F279  68                   PLA           
 F27A  0A                   ASL           
 F27B  10 09                BPL iF286     
 F27D  A5 A7                LDA FILDAT    
 F27F  29 01     iF27F      AND #$01      
 F281  85 80                STA DRVNUM    
 F283  4C 0A EF             JMP SETLDS     ; in 4040 before JMP comment "*RSR ADD FOR AUTO INIT" and auto init code?
 F286  2A        iF286      ROL           
; *** F287: Warning: Possibly modifyable opcode. ***

 F287  4C 7F F2             JMP iF27F     

; *** Invalid reference F28A ignored.

 F28A  SCHTBL     .byte $00, $80, $41, $01, $01, $01, $01, $81  ;..aaaaa.
 F292             .byte $81, $81, $81, $42, $42, $42, $42       ;...bbbb

; LOOK Up ALL FILES IN STREAM
; AND FILL TABLES W/ INFO


 F299  20 4A F2  LOOKUP     JSR OPTSCH    
 F29C  A9 00     iF29C      LDA #$00      
 F29E  85 D6                STA DELIND    
 F2A0  20 CE F3             JSR SRCHST     ; START SEARCH
 F2A3  D0 18                BNE iF2BD     
 F2A5  C6 D0     iF2A5      DEC DRVCNT    
 F2A7  10 01                BPL iF2AA     
 F2A9  60                   RTS            ; NO MORE DRIVE SEARCHES
 F2AA  A9 01     iF2AA      LDA #$01       ; TOGGLE DRIVE #
 F2AC  85 D1                STA DRVFLG    
 F2AE  20 12 F2             JSR TOGDRV    
 F2B1  20 0A EF             JSR SETLDS     ; TURN ON LEDS
 F2B4  F0 E6                BEQ iF29C      ; (BRANCH)
 F2B6  D0 E4                BNE iF29C     
 F2B8  20 29 F4  iF2B8      JSR SEARCH     ; FIND VALID FN
 F2BB  F0 0E                BEQ iF2CB      ; END OF SEARCH
 F2BD  20 14 F3  iF2BD      JSR COMPAR     ; COMPARE DIR W/ TABLE
 F2C0  A5 D3                LDA FOUND      ; FOUND FLAG
 F2C2  F0 01                BEQ iF2C5      ; ALL FN'S NOT FOUND, YET
 F2C4  60                   RTS           
 F2C5  A5 37     iF2C5      LDA ENTFND    
 F2C7  30 EF                BMI iF2B8     
 F2C9  10 F2                BPL iF2BD     
 F2CB  A5 D3     iF2CB      LDA FOUND     
 F2CD  F0 D6                BEQ iF2A5     
 F2CF  60                   RTS           

; FIND NEXT FILE NAME MATCHING
; ANY FILE IN STREAM & RETURN
; WITH ENTRY FOUND STUFFED INTO
; TABLES

 F2D0  20 19 F4  FFRE       JSR SRRE       ; FIND FILE RE-ENTRY
 F2D3  F0 17                BEQ iF2EC     
 F2D5  D0 23                BNE iF2FA     
 F2D7  A9 01     iF2D7      LDA #$01      
 F2D9  85 D1                STA DRVFLG    
 F2DB  20 12 F2             JSR TOGDRV    
 F2DE  20 0A EF             JSR SETLDS    
 F2E1  A9 00     FFST       LDA #$00       ; FIND FILE START ENTRY
 F2E3  85 D6                STA DELIND    
 F2E5  20 CE F3             JSR SRCHST    
 F2E8  D0 10                BNE iF2FA     
 F2EA  85 D3                STA FOUND     
 F2EC  A5 D3     iF2EC      LDA FOUND     
 F2EE  D0 23                BNE iF313     
 F2F0  C6 D0                DEC DRVCNT    
 F2F2  10 E3                BPL iF2D7     
 F2F4  60                   RTS           
 F2F5  20 29 F4  FNDFIL     JSR SEARCH     ; FIND FILE CONTINUOUS...
 F2F8  F0 F2                BEQ iF2EC      ; ... RE-ENTRY, NO CHANNEL ACTIVITY
 F2FA  20 14 F3  iF2FA      JSR COMPAR     ; COMPARE FILE NAMES
 F2FD  A6 37                LDX ENTFND    
 F2FF  10 06                BPL iF307     
 F301  A5 D3                LDA FOUND     
 F303  F0 F0                BEQ FNDFIL    
 F305  D0 0C                BNE iF313     
 F307  A5 DA     iF307      LDA TYPFLG    
 F309  F0 08                BEQ iF313      ; NO TYPE RESTRICTION
 F30B  B5 A7                LDA FILDAT,X  
 F30D  29 1E                AND #$1E      
 F30F  C5 DA                CMP TYPFLG    
 F311  D0 E2                BNE FNDFIL    
 F313  60        iF313      RTS           

; COMPARE ALL FILENAMES IN STREAM TABLE
; WITH EACH VALID ENTRY IN THE
; DIRECTORY. MATCHES ARE TABULATED

 F314  A2 FF     COMPAR     LDX #$FF      
 F316  86 37                STX ENTFND    
 F318  E8                   INX           
 F319  86 CE                STX PATFLG    
 F31B  20 B4 F3             JSR CMPCHK    
 F31E  F0 06                BEQ iF326     
 F320  60        iF320      RTS            ; ALL ARE FOUND
 F321  20 BC F3  iF321      JSR CC10      
 F324  D0 FA                BNE iF320     
 F326  A5 80     iF326      LDA DRVNUM    
 F328  55 A7                EOR FILDAT,X  
 F32A  4A                   LSR           
 F32B  90 0A                BCC iF337      ; RIGHT DRIVE
 F32D  29 40                AND #$40      
 F32F  F0 F0                BEQ iF321      ; NO DEFAULT
 F331  A9 02                LDA #$02      
 F333  C5 D0                CMP DRVCNT    
 F335  F0 EA                BEQ iF321      ; DON'T USE DEFAULT
 F337  B5 9D     iF337      LDA FILTBL,X   ; GOOD DRIVE MATCH
 F339  AA                   TAX           
 F33A  20 2F F5             JSR FNDLMT    
 F33D  A0 03                LDY #$03      
 F33F  B1 93                LDA (DIRBUF),Y ; in 4040 the CMDBUF,x and (DIRBUF),y are exchanged, so the char is always in .A and can directly compared with
 F341  E4 98     iF341      CPX LIMIT      ; this compare and the branch is later in 4040
 F343  B0 DC                BCS iF321      ; END OF PATTERN
 F345  D5 00                CMP CMDBUF,X  
 F347  F0 06                BEQ iF34F      ; CHARS ARE =
 F349  A9 3F                LDA #$3F       ; "?"
 F34B  D5 00                CMP CMDBUF,X  
 F34D  D0 5C                BNE iF3AB      ; NO SINGLE PATTERN
 F34F  C8        iF34F      INY           
 F350  E8                   INX           
 F351  B1 93                LDA (DIRBUF),Y
 F353  C9 A0                CMP #$A0      
 F355  F0 04                BEQ iF35B      ; END OF FILENAME
 F357  C0 13                CPY #$13      
 F359  90 E6                BCC iF341      ; in 4040 this is at different place as BCS, with comment "END OF FILENAME"
 F35B  A9 2A     iF35B      LDA #$2A       ; "*"
 F35D  D5 00                CMP CMDBUF,X   ; STAR MATCHES ALL
 F35F  F0 04                BEQ iF365     
 F361  E4 98                CPX LIMIT     
 F363  90 BC                BCC iF321     
 F365  A6 9C     iF365      LDX F2PTR      ; FILENAMES MATCH
 F367  86 37                STX ENTFND    
 F369  B5 AC                LDA FILTRK,X   ; STORE INFO IN TABLES
 F36B  29 80                AND #$80      
 F36D  85 CE                STA PATFLG    
 F36F  95 AC                STA FILTRK,X  
 F371  A5 D8                LDA INDEX     
 F373  29 E0                AND #$E0      
 F375  85 2A                STA TEMP      
 F377  A5 82                LDA SECTOR    
 F379  05 2A                ORA TEMP      
 F37B  95 A2                STA FILENT,X  
 F37D  A0 00                LDY #$00      
 F37F  B1 93                LDA (DIRBUF),Y
 F381  C8                   INY           
 F382  48                   PHA           
 F383  29 40                AND #$40      
 F385  85 2A                STA TEMP      
 F387  68                   PLA           
 F388  0A                   ASL           
 F389  29 1E                AND #$1E      
 F38B  B0 02                BCS iF38F     
 F38D  09 20                ORA #$20      
 F38F  05 2A     iF38F      ORA TEMP      
 F391  85 2A                STA TEMP      
 F393  A9 80                LDA #$80      
 F395  35 A7                AND FILDAT,X  
 F397  05 80                ORA DRVNUM    
 F399  05 2A                ORA TEMP      
 F39B  95 A7                STA FILDAT,X  
 F39D  B1 93                LDA (DIRBUF),Y
 F39F  15 AC                ORA FILTRK,X  
 F3A1  95 AC                STA FILTRK,X  
 F3A3  C8                   INY           
 F3A4  B1 93                LDA (DIRBUF),Y
 F3A6  95 B1                STA FILSEC,X  
 F3A8  4C B4 F3             JMP CMPCHK     ; here is a change from 4040
 F3AB  A9 2A     iF3AB      LDA #$2A      
 F3AD  D5 00                CMP CMDBUF,X  
 F3AF  F0 B4                BEQ iF365     
 F3B1  4C 21 F3             JMP iF321     

; CHECK TABLES FOR UNFOUND FILES

 F3B4  A9 FF     CMPCHK     LDA #$FF      
 F3B6  85 D3                STA FOUND     
 F3B8  A5 9A                LDA R0        
 F3BA  85 9C                STA F2PTR     
 F3BC  C6 9C     CC10       DEC F2PTR     
 F3BE  10 01                BPL iF3C1     
 F3C0  60                   RTS            ; TABLE EXHAUSTED
 F3C1  A6 9C     iF3C1      LDX F2PTR     
 F3C3  B5 AC                LDA FILTRK,X  
 F3C5  30 02                BMI iF3C9     
 F3C7  D0 F3                BNE CC10      
 F3C9  A9 00     iF3C9      LDA #$00      
 F3CB  85 D3                STA FOUND     
 F3CD  60                   RTS           

; SEARCH DIRECTORY
; RETURNS WITH VALID ENTRY W/ DELIND=0
; OR RETURNS W/ 1ST DELETED ENTRY
; DELIND=1
; e
; SRCHST WILL INITIATE A SEARCH
; SEARCH WILL CONTINUE A SEARCH

 F3CE  A0 00     SRCHST     LDY #$00       ; INIT DELETED SECTOR
 F3D0  84 D5                STY DELSEC    
 F3D2  88                   DEY           
 F3D3  84 37                STY ENTFND    
 F3D5  A9 12                LDA #$12       ; START SEARCH AT BEGINNING
 F3D7  85 81                STA TRACK     
 F3D9  A9 01                LDA #$01      
 F3DB  85 82                STA SECTOR    
 F3DD  85 D7                STA LSTBUF    
 F3DF  20 36 EE             JSR OPNIRD     ; OPEN INTERNAL READ CHNL
 F3E2  A5 D7     iF3E2      LDA LSTBUF     ; LAST BUFFER IF 0
 F3E4  D0 01                BNE iF3E7     
 F3E6  60                   RTS            ; (Z=1)
 F3E7  A9 07     iF3E7      LDA #$07      
 F3E9  85 D9                STA FILCNT    
 F3EB  A9 00                LDA #$00       ; READ TRACK #
 F3ED  20 BE EE             JSR DRDBYT    
 F3F0  85 D7                STA LSTBUF     ; UPDATE END FLAG
 F3F2  20 B0 EE  iF3F2      JSR GETPNT    
 F3F5  C6 D9                DEC FILCNT    
 F3F7  A0 00                LDY #$00      
 F3F9  B1 93                LDA (DIRBUF),Y ; READ FILE TYPE
 F3FB  D0 14                BNE iF411     
 F3FD  A5 D5                LDA DELSEC     ; DELETED ENTRY FOUND
 F3FF  D0 28                BNE SEARCH     ; DELETED ENTRY ALREADY FOUND
 F401  20 06 EE             JSR CURBLK     ; GET CURRENT SECTOR
 F404  A5 82                LDA SECTOR    
 F406  85 D5                STA DELSEC    
 F408  A5 93                LDA DIRBUF     ; GET CURRENT INDEX
 F40A  A6 D6                LDX DELIND     ; BIT1: WANT DELETED ENTRY
 F40C  85 D6                STA DELIND    
 F40E  F0 19                BEQ SEARCH     ; NEED VALID ENTRY
 F410  60                   RTS           
 F411  A2 01     iF411      LDX #$01      
 F413  E4 D6                CPX DELIND     ; ?LOOKING FOR DELETED?
 F415  D0 2A                BNE iF441      ; NO!
 F417  F0 10                BEQ SEARCH    
 F419  A9 12     SRRE       LDA #$12      
 F41B  85 81                STA TRACK     
 F41D  A5 D4                LDA DIRSEC    
 F41F  85 82                STA SECTOR    
 F421  20 36 EE             JSR OPNIRD    
 F424  A5 D8                LDA INDEX     
 F426  20 89 EE             JSR SETPNT    
 F429  A9 FF     SEARCH     LDA #$FF      
 F42B  85 37                STA ENTFND    
 F42D  A5 D9                LDA FILCNT     ; ADJUST FILE COUNT
 F42F  30 09                BMI iF43A     
 F431  A9 20                LDA #$20       ; INCR BY 32
 F433  20 59 EA             JSR INCPTR    
 F436  D0 BA                BNE iF3F2      ; these two branches are later replaced by a JMP :-)
 F438  F0 B8                BEQ iF3F2     
 F43A  20 F3 ED  iF43A      JSR NXTBUF     ; NEW BUFFER
 F43D  D0 A3                BNE iF3E2      ; in 4040 replaced by JMP, with comment "(BRANCH)" :-)
 F43F  F0 A1                BEQ iF3E2     
 F441  A5 93     iF441      LDA DIRBUF     ; FOUND VALID ENTRY
 F443  85 D8                STA INDEX      ; SAVE INDEX
 F445  20 06 EE             JSR CURBLK     ; GET SECTOR
 F448  A5 82                LDA SECTOR    
 F44A  85 D4                STA DIRSEC    
 F44C  60                   RTS            ; (Z=0)

; TRANSFER FILENAME FROM CMD TO BUFFER.
; A=STRING SIZE. 
; X=STARTING INDEX IN CMDBUF.
; Y=BUFFER #

 F44D  48        TRNAME     PHA           
 F44E  20 2F F5             JSR FNDLMT    
 F451  20 66 F4             JSR TRCMBF    
 F454  68                   PLA           
 F455  38                   SEC           
 F456  E5 2D                SBC TEMP+3    
 F458  AA                   TAX           
 F459  F0 0A                BEQ iF465     
 F45B  90 08                BCC iF465     
 F45D  A9 A0                LDA #$A0      
 F45F  91 93     iF45F      STA (DIRBUF),Y
 F461  C8                   INY           
 F462  CA                   DEX           
 F463  D0 FA                BNE iF45F     
 F465  60        iF465      RTS           

; TRANSFER CMD BUFFER TO OTHER BUFFER
; USES CURRENT BUFFER PTR.
; LIMIT ENDING INDEX+1 IN CMD BUF
; X=STARTING INDEX IN CMD BUF
; Y=BUFFER#

 F466  98        TRCMBF     TYA           
 F467  0A                   ASL           
 F468  A8                   TAY           
 F469  B9 3D 00             LDA BUFTAB,Y  
 F46C  85 93                STA DIRBUF    
 F46E  B9 3E 00             LDA BUFTAB+1,Y
 F471  85 94                STA DIRBUF+1  
 F473  A0 00                LDY #$00      
 F475  B5 00     iF475      LDA CMDBUF,X  
 F477  91 93                STA (DIRBUF),Y
 F479  C8                   INY           
 F47A  F0 05                BEQ iF481     
 F47C  E8                   INX           
 F47D  E4 98                CPX LIMIT     
 F47F  90 F4                BCC iF475     
 F481  60        iF481      RTS           

; TODO

 F482  A5 84     iF482      LDA SA        
 F484  48                   PHA           
 F485  A5 83                LDA LINDX     
 F487  48                   PHA           
 F488  A5 82                LDA SECTOR    
 F48A  48                   PHA           
 F48B  A5 81                LDA TRACK     
 F48D  48                   PHA           
 F48E  A9 10                LDA #$10      
 F490  85 84                STA SA        
 F492  20 06 EE             JSR CURBLK    
 F495  A6 8D                LDX JOBNUM    
 F497  BD 99 10             LDA LSTJOB,X  
 F49A  A6 9B                LDX F1PTR     
 F49C  55 A7                EOR FILDAT,X  
 F49E  4A                   LSR           
 F49F  90 14                BCC iF4B5     
 F4A1  B5 A7                LDA FILDAT,X  
 F4A3  29 01                AND #$01      
 F4A5  85 80                STA DRVNUM    
 F4A7  A2 01                LDX #$01      
 F4A9  86 D6                STX DELIND    
 F4AB  CA                   DEX           
 F4AC  86 D5                STX DELSEC    
 F4AE  20 CE F3             JSR SRCHST    
 F4B1  F0 1B                BEQ iF4CE     
 F4B3  D0 24                BNE iF4D9     
 F4B5  A5 D5     iF4B5      LDA DELSEC    
 F4B7  F0 0C                BEQ iF4C5     
 F4B9  C5 82                CMP SECTOR    
 F4BB  F0 1C                BEQ iF4D9     
 F4BD  85 82                STA SECTOR    
 F4BF  20 1D EE             JSR DRTRD     
 F4C2  4C D9 F4             JMP iF4D9     
 F4C5  A9 01     iF4C5      LDA #$01      
 F4C7  85 D6                STA DELIND    
 F4C9  20 29 F4             JSR SEARCH    
 F4CC  D0 0B                BNE iF4D9     
 F4CE  20 49 EE  iF4CE      JSR NXDRBK    
 F4D1  A5 82                LDA SECTOR    
 F4D3  85 D5                STA DELSEC    
 F4D5  A9 02                LDA #$02      
 F4D7  85 D6                STA DELIND    
 F4D9  A5 D6     iF4D9      LDA DELIND    
 F4DB  20 89 EE             JSR SETPNT    
 F4DE  A5 DC                LDA xDC       
 F4E0  20 89 E8             JSR PUTBYT    
 F4E3  68                   PLA           
 F4E4  A6 9B                LDX F1PTR     
 F4E6  95 AC                STA FILTRK,X  
 F4E8  20 89 E8             JSR PUTBYT    
 F4EB  68                   PLA           
 F4EC  A6 9B                LDX F1PTR     
 F4EE  95 B1                STA FILSEC,X  
 F4F0  20 89 E8             JSR PUTBYT    
 F4F3  20 9D E8             JSR GETACT    
 F4F6  A8                   TAY           
 F4F7  A6 9B                LDX F1PTR     
 F4F9  B5 9D                LDA FILTBL,X  
 F4FB  AA                   TAX           
 F4FC  A9 10                LDA #$10      
 F4FE  20 4D F4             JSR TRNAME    
 F501  A0 17                LDY #$17      
 F503  A9 00                LDA #$00      
 F505  91 93     iF505      STA (DIRBUF),Y
 F507  C8                   INY           
 F508  C0 1B                CPY #$1B      
 F50A  90 F9                BCC iF505     
 F50C  20 21 EE             JSR DRTWRT    
 F50F  68                   PLA           
 F510  85 83                STA LINDX     
 F512  68                   PLA           
 F513  85 84                STA SA        
 F515  A6 9B                LDX F1PTR     
 F517  A5 D5                LDA DELSEC    
 F519  29 1F                AND #$1F      
 F51B  95 A2                STA FILENT,X  
 F51D  A5 D6                LDA DELIND    
 F51F  29 E0                AND #$E0      
 F521  15 A2                ORA FILENT,X  
 F523  95 A2                STA FILENT,X  
 F525  A5 DC                LDA xDC       
 F527  0A                   ASL           
 F528  29 1E                AND #$1E      
 F52A  05 80                ORA DRVNUM    
 F52C  95 A7                STA FILDAT,X  
 F52E  60                   RTS           

; FIND THE LIMIT OF THE STRING IN CMDBUF
; POINTED TO BY X

 F52F  A9 00     FNDLMT     LDA #$00      
 F531  85 2D                STA TEMP+3    
 F533  8A                   TXA           
 F534  48                   PHA           
 F535  B5 00     iF535      LDA CMDBUF,X  
 F537  C9 2C                CMP #$2C       ; "."
 F539  F0 11                BEQ iF54C     
 F53B  C9 3D                CMP #$3D       ; "="
 F53D  F0 0D                BEQ iF54C     
 F53F  E6 2D                INC TEMP+3    
 F541  E8                   INX           
 F542  A9 0F                LDA #$0F      
 F544  C5 2D                CMP TEMP+3    
 F546  90 04                BCC iF54C     
 F548  E4 95                CPX CMDSIZ    
 F54A  90 E9                BCC iF535     
 F54C  86 98     iF54C      STX LIMIT     
 F54E  68                   PLA           
 F54F  AA                   TAX           
 F550  60                   RTS           

; GET FILE ENTRY FROM DIRECTORY
; CALLED BY STDIR, GETDIR; SAVE VARIABLES

 F551  A5 84     GETNAM     LDA SA         ; SAVE VARIABLES
 F553  48                   PHA           
 F554  A5 83                LDA LINDX     
 F556  48                   PHA           
 F557  20 61 F5             JSR GNSUB     
 F55A  68                   PLA           
 F55B  85 83                STA LINDX     
 F55D  68                   PLA           
 F55E  85 84                STA SA        
 F560  60                   RTS           

 F561  A9 10     GNSUB      LDA #$10       ; IRSA
 F563  85 84                STA SA        
 F565  20 B0 E9             JSR FNDRCH    
 F568  20 B0 EE             JSR GETPNT    
 F56B  A5 37                LDA ENTFND    
 F56D  10 07                BPL iF576      ; MORE FILES
 F56F  20 5D F6             JSR MSGFRE     ; SEND BLOCKS FREE
 F572  18                   CLC            ; (C=0) = END
 F573  4C 22 F6             JMP iF622      ; TERMINATE
 F576  A5 D1     iF576      LDA DRVFLG    
 F578  F0 1F                BEQ iF599     
 F57A  C6 D1                DEC DRVFLG     ; (DRVFLG=-1) = NEW DIR
 F57C  D0 0C                BNE iF58A     
 F57E  C6 D1                DEC DRVFLG     ; (DRVFLG=-1) =
 F580  20 12 F2             JSR TOGDRV     ; SEND BLOCKS FREE
 F583  20 5D F6             JSR MSGFRE    
 F586  38                   SEC           
 F587  4C 12 F2             JMP TOGDRV    
 F58A  A9 00     iF58A      LDA #$00      
 F58C  8D EE 10             STA NBTEMP+1  
 F58F  85 D1                STA DRVFLG    
 F591  20 2E F6             JSR NEWDIR    
 F594  8E ED 10             STX NBTEMP    
 F597  38                   SEC           
 F598  60                   RTS           
 F599  A2 18     iF599      LDX #$18       ; DIRLEN; SET NUMBER BLOCKS
 F59B  A0 1D                LDY #$1D       ; & ADJUST SPACING
 F59D  B1 93                LDA (DIRBUF),Y
 F59F  8D EE 10             STA NBTEMP+1  
 F5A2  F0 02                BEQ iF5A6     
 F5A4  A2 16                LDX #$16       ; DIRLEN-2
 F5A6  88        iF5A6      DEY           
 F5A7  B1 93                LDA (DIRBUF),Y
 F5A9  8D ED 10             STA NBTEMP    
 F5AC  E0 16                CPX #$16       ; DIRLEN-2
 F5AE  F0 0A                BEQ iF5BA     
 F5B0  C9 0A                CMP #$0A      
 F5B2  90 06                BCC iF5BA     
 F5B4  CA                   DEX           
 F5B5  C9 64                CMP #$64      
 F5B7  90 01                BCC iF5BA     
 F5B9  CA                   DEX           
 F5BA  20 23 F6  iF5BA      JSR BLKNB      ; CLEAR NAME BUFFER
 F5BD  B1 93                LDA (DIRBUF),Y ; SEt TYPE CHARS
 F5BF  48                   PHA           
 F5C0  0A                   ASL            ; (USED IN BCS)
 F5C1  68                   PLA           
 F5C2  29 0F                AND #$0F      
 F5C4  A8                   TAY           
 F5C5  B9 39 E0             LDA TP2LST,Y  
 F5C8  9D B4 42             STA NAMBUF,X  
 F5CB  CA                   DEX           
 F5CC  B9 35 E0             LDA TP1LST,Y  
 F5CF  9D B4 42             STA NAMBUF,X  
 F5D2  CA                   DEX           
 F5D3  B9 31 E0             LDA TYPLST,Y  
 F5D6  9D B4 42             STA NAMBUF,X  
 F5D9  CA                   DEX           
 F5DA  CA                   DEX           
 F5DB  B0 05                BCS iF5E2      ; (FROM ASL)
 F5DD  A9 2A                LDA #$2A       ; "*"; FILE NOT CLOSED
 F5DF  9D B5 42             STA NAMBUF+1,X
 F5E2  A9 A0     iF5E2      LDA #$A0      
 F5E4  9D B4 42             STA NAMBUF,X  
 F5E7  CA                   DEX           
 F5E8  A0 12                LDY #$12      
 F5EA  B1 93     iF5EA      LDA (DIRBUF),Y
 F5EC  9D B4 42             STA NAMBUF,X  
 F5EF  CA                   DEX           
 F5F0  88                   DEY           
 F5F1  C0 03                CPY #$03      
 F5F3  B0 F5                BCS iF5EA     
 F5F5  A9 22                LDA #$22       ; '"' SEND NAME IN QUOTES
 F5F7  9D B4 42             STA NAMBUF,X  
 F5FA  E8        iF5FA      INX           
 F5FB  E0 20                CPX #$20      
 F5FD  B0 0B                BCS iF60A     
 F5FF  BD B4 42             LDA NAMBUF,X  
 F602  C9 22                CMP #$22       ; '"'
 F604  F0 04                BEQ iF60A     
 F606  C9 A0                CMP #$A0      
 F608  D0 F0                BNE iF5FA     
 F60A  A9 22     iF60A      LDA #$22       ; '"'
 F60C  9D B4 42             STA NAMBUF,X  
 F60F  E8        iF60F      INX           
 F610  E0 20                CPX #$20      
 F612  B0 0A                BCS iF61E     
 F614  A9 7F                LDA #$7F      
 F616  3D B4 42             AND NAMBUF,X  
 F619  9D B4 42             STA NAMBUF,X  
 F61C  10 F1                BPL iF60F     
 F61E  20 F5 F2  iF61E      JSR FNDFIL    
 F621  38                   SEC           
 F622  60        iF622      RTS           

 F623  A0 1B     BLKNB      LDY #$1B       ; BLANK NAMBUF
 F625  A9 20                LDA #$20      
 F627  99 B3 42  iF627      STA NAMBUF-1,Y
 F62A  88                   DEY           
 F62B  D0 FA                BNE iF627     
 F62D  60                   RTS           

; NEW DIRECTORY IN LISTING

 F62E  20 23 F6  NEWDIR     JSR BLKNB     
 F631  A9 FF                LDA #$FF      
 F633  85 2A                STA TEMP      
 F635  A6 80                LDX DRVNUM    
 F637  BD 40 E5             LDA IPBM,X    
 F63A  85 94                STA DIRBUF+1  
 F63C  A9 90                LDA #$90      
 F63E  85 93                STA DIRBUF    
 F640  A0 15                LDY #$15      
 F642  B1 93     iF642      LDA (DIRBUF),Y ; the 4040 adds version check here (write out "1" when no version on disk)
 F644  99 B6 42             STA NAMBUF+2,Y
 F647  88                   DEY           
 F648  10 F8                BPL iF642     
 F64A  A9 12                LDA #$12      
 F64C  8D B4 42             STA NAMBUF    
 F64F  A9 22                LDA #$22      
 F651  8D B5 42             STA NAMBUF+1  
 F654  8D C6 42             STA NAMBUF+18 
 F657  A9 20                LDA #$20      
 F659  8D C7 42             STA NAMBUF+19 
 F65C  60                   RTS           

 F65D  20 23 F6  MSGFRE     JSR BLKNB     
 F660  A0 0B                LDY #$0B       ; MSGLEN-1
 F662  B9 6E F6  iF662      LDA FREMSG,Y  
 F665  99 B4 42             STA NAMBUF,Y  
 F668  88                   DEY           
 F669  10 F7                BPL iF662     
 F66B  4C 0A F0             JMP NUMFRE    


; blocks free message

 F66E  FREMSG     .byte $42, $4C, $4F, $43, $4B, $53, $20, $46  ;blocks f
 F676             .byte $52, $45, $45, $2E                      ;ree.

; TODO


 F67A  A5 84     iF67A      LDA SA        
 F67C  C9 0F                CMP #$0F      
 F67E  D0 06                BNE iF686     
 F680  20 C2 EB             JSR CLRCHN    
 F683  4C 44 F0             JMP PARSXQ    
 F686  85 86     iF686      STA x86       
 F688  20 59 F1             JSR CMDSET    
 F68B  86 96                STX CMDNUM    
 F68D  A6 00                LDX CMDBUF    
 F68F  A5 86                LDA x86       
 F691  D0 26                BNE iF6B9     
 F693  E0 2A                CPX #$2A      
 F695  D0 22                BNE iF6B9     
 F697  A5 7F                LDA x7F       
 F699  F0 45                BEQ iF6E0     
 F69B  4A                   LSR           
 F69C  85 81                STA TRACK     
 F69E  A9 00                LDA #$00      
 F6A0  2A                   ROL           
 F6A1  85 80                STA DRVNUM    
 F6A3  09 04                ORA #$04      
 F6A5  85 A7                STA FILDAT    
 F6A7  AD EA 10             LDA x10EA     
 F6AA  85 82                STA SECTOR    
 F6AC  20 72 EA             JSR OPNRCH    
 F6AF  A5 A7                LDA FILDAT    
 F6B1  A6 83     iF6B1      LDX LINDX     
 F6B3  99 B6 00             STA FILTYP,Y  
 F6B6  4C 75 F0             JMP ENDCMD    
 F6B9  E0 24     iF6B9      CPX #$24      
 F6BB  D0 1C                BNE iF6D9     
 F6BD  A5 86                LDA x86       
 F6BF  D0 03                BNE iF6C4     
 F6C1  4C 51 F8             JMP iF851     
 F6C4  20 99 F0  iF6C4      JSR SIMPRS    
 F6C7  A9 12                LDA #$12      
 F6C9  85 81                STA TRACK     
 F6CB  A9 00                LDA #$00      
 F6CD  85 82                STA SECTOR    
 F6CF  20 72 EA             JSR OPNRCH    
 F6D2  A5 80                LDA DRVNUM    
 F6D4  09 02                ORA #$02      
 F6D6  4C B1 F6             JMP iF6B1     
 F6D9  E0 23     iF6D9      CPX #$23      
 F6DB  D0 0A                BNE iF6E7     
 F6DD  4C 6A FD             JMP OPNBLK    
 F6E0  A9 04     iF6E0      LDA #$04      
 F6E2  85 DA                STA TYPFLG    
 F6E4  20 C1 E8             JSR INITDR    
 F6E7  A2 00     iF6E7      LDX #$00      
 F6E9  A9 3A                LDA #$3A      
 F6EB  20 17 F1             JSR PARSE     
 F6EE  F0 0C                BEQ iF6FC     
 F6F0  8A                   TXA           
 F6F1  F0 05                BEQ iF6F8     
 F6F3  A9 30                LDA #$30      
 F6F5  4C 90 F0             JMP CMDERR    
 F6F8  88        iF6F8      DEY           
 F6F9  F0 01                BEQ iF6FC     
 F6FB  88                   DEY           
 F6FC  84 9D     iF6FC      STY FILTBL    
 F6FE  A9 8D                LDA #$8D      
 F700  20 17 F1             JSR PARSE     
 F703  E8                   INX           
 F704  86 9A                STX R0        
 F706  20 A3 F1             JSR ONEDRV    
 F709  20 4A F2             JSR OPTSCH    
 F70C  20 E1 F2             JSR FFST      
 F70F  A6 86                LDX x86       
 F711  86 84                STX SA        
 F713  E0 02                CPX #$02      
 F715  B0 0C                BCS iF723     
 F717  A9 02                LDA #$02      
 F719  85 DC                STA xDC       
 F71B  86 DB                STX xDB       
 F71D  8A                   TXA           
 F71E  D0 3D                BNE iF75D     
 F720  4C C9 F7             JMP iF7C9     
 F723  A2 00     iF723      LDX #$00      
 F725  86 DB                STX xDB       
 F727  E8                   INX           
 F728  86 DC                STX xDC       
 F72A  E4 99                CPX F1CNT     
 F72C  B0 2B                BCS iF759     
 F72E  B5 9D                LDA FILTBL,X  
 F730  A8                   TAY           
 F731  B9 00 00             LDA CMDBUF,Y  
 F734  A0 03                LDY #$03      
 F736  D9 31 E0  iF736      CMP TYPLST,Y  
 F739  F0 04                BEQ iF73F     
 F73B  88                   DEY           
 F73C  D0 F8                BNE iF736     
 F73E  C8                   INY           
 F73F  84 DC     iF73F      STY xDC       
 F741  E8                   INX           
 F742  E4 99                CPX F1CNT     
 F744  B0 13                BCS iF759     
 F746  B5 9D                LDA FILTBL,X  
 F748  A8                   TAY           
 F749  B9 00 00             LDA CMDBUF,Y  
 F74C  A0 02                LDY #$02      
 F74E  D9 2E E0  iF74E      CMP MODLST,Y  
 F751  F0 04                BEQ iF757     
 F753  88                   DEY           
 F754  10 F8                BPL iF74E     
 F756  C8                   INY           
 F757  84 DB     iF757      STY xDB       
 F759  A6 DB     iF759      LDX xDB       
 F75B  F0 6C                BEQ iF7C9     
 F75D  A5 CE     iF75D      LDA PATFLG    
 F75F  F0 05                BEQ iF766     
 F761  A9 33                LDA #$33      
 F763  4C 90 F0             JMP CMDERR    
 F766  A9 20     iF766      LDA #$20      
 F768  24 A7                BIT FILDAT    
 F76A  F0 0C                BEQ iF778     
 F76C  A5 DB                LDA xDB       
 F76E  C9 02                CMP #$02      
 F770  F0 6D                BEQ iF7DF     
 F772  20 DE F9             JSR DELDIR    
 F775  4C 0F F8             JMP iF80F     
 F778  A5 AC     iF778      LDA FILTRK    
 F77A  29 3F                AND #$3F      
 F77C  D0 03                BNE iF781     
 F77E  4C 0F F8             JMP iF80F     
 F781  A5 00     iF781      LDA CMDBUF    
 F783  C9 40                CMP #$40      
 F785  F0 05                BEQ iF78C     
 F787  A9 63                LDA #$63      
 F789  4C 90 F0             JMP CMDERR    
 F78C  A5 A7     iF78C      LDA FILDAT    
 F78E  29 1F                AND #$1F      
 F790  48                   PHA           
 F791  4A                   LSR           
 F792  C5 DC                CMP xDC       
 F794  D0 52                BNE iF7E8     
 F796  20 CE EA             JSR OPNWCH    
 F799  A5 83                LDA LINDX     
 F79B  8D EB 10             STA x10EB     
 F79E  A9 10                LDA #$10      
 F7A0  85 84                STA SA        
 F7A2  20 B0 E9             JSR FNDRCH    
 F7A5  A5 D8                LDA INDEX     
 F7A7  20 89 EE             JSR SETPNT    
 F7AA  A0 1A                LDY #$1A      
 F7AC  A5 81                LDA TRACK     
 F7AE  91 93                STA (DIRBUF),Y
 F7B0  C8                   INY           
 F7B1  A5 82                LDA SECTOR    
 F7B3  91 93                STA (DIRBUF),Y
 F7B5  A5 A2                LDA FILENT    
 F7B7  AE EB 10             LDX x10EB     
 F7BA  9D E1 10             STA CHNDAT+8,X
 F7BD  68                   PLA           
 F7BE  95 B6                STA FILTYP,X  
 F7C0  20 06 EE             JSR CURBLK    
 F7C3  20 21 EE             JSR DRTWRT    
 F7C6  4C 75 F0             JMP ENDCMD    
 F7C9  A5 AC     iF7C9      LDA FILTRK    
 F7CB  29 3F                AND #$3F      
 F7CD  D0 05                BNE iF7D4     
 F7CF  A9 62                LDA #$62      
 F7D1  4C 90 F0             JMP CMDERR    
 F7D4  A9 20     iF7D4      LDA #$20      
 F7D6  24 A7                BIT FILDAT    
 F7D8  F0 05                BEQ iF7DF     
 F7DA  A9 60                LDA #$60      
 F7DC  4C 90 F0             JMP CMDERR    
 F7DF  A5 A7     iF7DF      LDA FILDAT    
 F7E1  4A                   LSR           
 F7E2  29 0F                AND #$0F      
 F7E4  C5 DC                CMP xDC       
 F7E6  F0 05                BEQ iF7ED     
 F7E8  A9 64     iF7E8      LDA #$64      
 F7EA  4C 90 F0             JMP CMDERR    
 F7ED  A5 AC     iF7ED      LDA FILTRK    
 F7EF  29 3F                AND #$3F      
 F7F1  85 81                STA TRACK     
 F7F3  85 2E                STA TEMP+4    
 F7F5  A5 B1                LDA FILSEC    
 F7F7  85 82                STA SECTOR    
 F7F9  85 2F                STA TEMP+5    
 F7FB  20 72 EA             JSR OPNRCH    
 F7FE  A4 83                LDY LINDX     
 F800  A5 A2                LDA FILENT    
 F802  99 E1 10             STA CHNDAT+8,Y
 F805  A5 A7                LDA FILDAT    
 F807  29 1F                AND #$1F      
 F809  99 B6 00             STA FILTYP,Y  
 F80C  4C 3B F8             JMP iF83B     

 F80F  20 CE EA  iF80F      JSR OPNWCH    
 F812  A5 81                LDA TRACK     
 F814  48                   PHA           
 F815  A5 82                LDA SECTOR    
 F817  48                   PHA           
 F818  20 82 F4             JSR iF482     
 F81B  A6 83                LDX LINDX     
 F81D  A5 D5                LDA DELSEC    
 F81F  29 1F                AND #$1F      
 F821  9D E1 10             STA CHNDAT+8,X
 F824  A5 D6                LDA DELIND    
 F826  29 E0                AND #$E0      
 F828  1D E1 10             ORA CHNDAT+8,X
 F82B  9D E1 10             STA CHNDAT+8,X
 F82E  A5 DC                LDA xDC       
 F830  0A                   ASL           
 F831  05 80                ORA DRVNUM    
 F833  95 B6                STA FILTYP,X  
 F835  68                   PLA           
 F836  85 2F                STA TEMP+5    
 F838  68                   PLA           
 F839  85 2E                STA TEMP+4    
 F83B  A6 86     iF83B      LDX x86       
 F83D  CA                   DEX           
 F83E  CA                   DEX           
 F83F  10 0D                BPL iF84E     
 F841  A5 80                LDA DRVNUM    
 F843  4A                   LSR           
 F844  A5 2E                LDA TEMP+4    
 F846  2A                   ROL           
 F847  85 7F                STA x7F       
 F849  A5 2F                LDA TEMP+5    
 F84B  8D EA 10             STA x10EA     
 F84E  4C 75 F0  iF84E      JMP ENDCMD    

 F851  A9 08     iF851      LDA #$08      
 F853  85 96                STA CMDNUM    
 F855  A6 95                LDX CMDSIZ    
 F857  CA                   DEX           
 F858  D0 12                BNE iF86C     
 F85A  A9 2A                LDA #$2A      
 F85C  85 00                STA CMDBUF    
 F85E  A9 80                LDA #$80      
 F860  85 AC                STA FILTRK    
 F862  05 D2                ORA LSTDRV    
 F864  85 A7                STA FILDAT    
 F866  E6 99                INC F1CNT     
 F868  E6 9A                INC R0        
 F86A  D0 3B                BNE iF8A7     
 F86C  CA        iF86C      DEX           
 F86D  D0 1B                BNE iF88A     
 F86F  A5 01                LDA CMDBUF+1  
 F871  20 3D F2             JSR TST0V1    
 F874  30 14                BMI iF88A     
 F876  29 01                AND #$01      
 F878  85 A7                STA FILDAT    
 F87A  E6 99                INC F1CNT     
 F87C  E6 9A                INC R0        
 F87E  E6 9D                INC FILTBL    
 F880  A9 80                LDA #$80      
 F882  85 AC                STA FILTRK    
 F884  A9 2A                LDA #$2A      
 F886  85 01                STA CMDBUF+1  
 F888  D0 1D                BNE iF8A7     
 F88A  A2 00     iF88A      LDX #$00      
 F88C  A9 3A                LDA #$3A      
 F88E  20 17 F1             JSR PARSE     
 F891  D0 07                BNE iF89A     
 F893  A0 00                LDY #$00      
 F895  20 81 F1             JSR iF181     
 F898  A0 03                LDY #$03      
 F89A  88        iF89A      DEY           
 F89B  88                   DEY           
 F89C  84 9D                STY FILTBL    
 F89E  20 C2 F0             JSR iF0C2     
 F8A1  20 1B F2             JSR FS1SET    
 F8A4  20 AD F1             JSR ALLDRS    
 F8A7  20 4A F2  iF8A7      JSR OPTSCH    
 F8AA  20 2E F6             JSR NEWDIR    
 F8AD  20 E1 F2             JSR FFST      
 F8B0  20 28 EF             JSR iEF28     
 F8B3  20 D4 E9             JSR GETBYT    
 F8B6  A6 83                LDX LINDX     
 F8B8  9D D9 10             STA CHNDAT,X  
 F8BB  A5 80                LDA DRVNUM    
 F8BD  85 D2                STA LSTDRV    
 F8BF  09 04                ORA #$04      
 F8C1  95 B6                STA FILTYP,X  
 F8C3  A9 00                LDA #$00      
 F8C5  85 5B                STA x5B       
 F8C7  60                   RTS           

; NEW: INITIALIZE A DISK, DISK IS
; SOFT-SECTORED, BIT AVAIL. MAP,
; DIRECTORY, & 1ST BLOCK ARE ALL INITED

 F8C8  20 A3 F1  NEW        JSR ONEDRV    
 F8CB  A5 A7                LDA FILDAT     ; SET UP DRIVE#
 F8CD  10 05                BPL iF8D4     
 F8CF  A9 33                LDA #$33       ; BADFN
 F8D1  4C 90 F0             JMP CMDERR    
 F8D4  29 01     iF8D4      AND #$01      
 F8D6  85 80                STA DRVNUM    
 F8D8  0A                   ASL           
 F8D9  AA                   TAX           
 F8DA  20 0A EF             JSR SETLDS    
 F8DD  A4 9E                LDY FILTBL+1   ; GET DISK ID
 F8DF  C4 95                CPY CMDSIZ     ; IS THIS NEW OR CLEAR?
 F8E1  F0 13                BEQ iF8F6      ; END OF CMD STRING
 F8E3  B9 00 00             LDA CMDBUF,Y  
 F8E6  95 8E                STA DISKID,X   ; STORE IN PROPER DRIVE
 F8E8  B9 01 00             LDA CMDBUF+1,Y ; (Y=0)
 F8EB  95 8F                STA DISKID+1,X
 F8ED  A9 01                LDA #$01       ; ...IN TRACK, TRACK=1
 F8EF  85 81                STA TRACK     
 F8F1  20 14 FB             JSR FORMAT     ; TRANSFER FORMAT TO RAM
 F8F4  F0 03                BEQ iF8F9     
 F8F6  20 C1 E8  iF8F6      JSR INITDR    
 F8F9  A6 80     iF8F9      LDX DRVNUM    
 F8FB  BD 40 E5             LDA IPBM,X     ; load high byte of buffer for drive, either $4200 or $4300?
 F8FE  85 31                STA IP+1      
 F900  A9 00                LDA #$00      
 F902  85 30                STA IP        
 F904  A8                   TAY           
 F905  91 30     iF905      STA (IP),Y     ; clear buffer
 F907  C8                   INY           
 F908  D0 FB                BNE iF905     
 F90A  8A                   TXA            ; X contains the drive
 F90B  18                   CLC           
 F90C  69 0D                ADC #$0D       ; BAMJOB, BUF#13 + DRVNUM
 F90E  85 8D                STA JOBNUM     ; either 13 or 14 (dezimal)
 F910  0A                   ASL           
 F911  AA                   TAX            ; either 26 or 28 (dezimal) = $1a or $1c
 F912  A9 90                LDA #$90      
 F914  95 3D                STA BUFTAB,X   ; store either into $57 or $59
 F916  A9 04                LDA #$04      
 F918  85 82                STA SECTOR    
 F91A  A9 12                LDA #$12       ; directory track (18)
 F91C  85 81                STA TRACK     
 F91E  20 21 EE  iF91E      JSR DRTWRT     ; loop over directory starting with SECTOR=4 until SECTOR contains #1
 F921  A5 82                LDA SECTOR     ; write each sector with interleave of 3
 F923  18                   CLC           
 F924  69 03                ADC #$03       ; secs 4,7,10,13,16,19,22, 3,6,9,12,15,18,21, 2,5,8,11,14,17,20
 F926  85 82                STA SECTOR    
 F928  C9 14                CMP #$14      
 F92A  90 F2                BCC iF91E     
 F92C  E9 13                SBC #$13      
 F92E  85 82                STA SECTOR    
 F930  AA                   TAX           
 F931  CA                   DEX           
 F932  D0 EA                BNE iF91E     
 F934  A0 01                LDY #$01       ; end of loop, SECTOR contains $01
 F936  A9 FF                LDA #$FF      
 F938  91 30                STA (IP),Y     ; end of file marker (followup sector in second byte in sector  = $ff)
 F93A  20 21 EE             JSR DRTWRT     ; CLEAR DIRECTORY (write t=18/s=1)
 F93D  C6 82                DEC SECTOR     ; move pointer to BAM block
 F93F  20 AC FC             JSR iFCAC     
 F942  A0 48                LDY #$48      
 F944  A9 12                LDA #$12      
 F946  91 30                STA (IP),Y    
 F948  C8                   INY           
 F949  A9 FC                LDA #$FC      
 F94B  91 30                STA (IP),Y    
 F94D  A4 8D                LDY JOBNUM    
 F94F  A6 9D                LDX FILTBL    
 F951  A9 1B                LDA #$1B      
 F953  20 4D F4             JSR TRNAME     ; TRANSFER CMD BUF TO BUF0
 F956  A0 12                LDY #$12      
 F958  A5 80                LDA DRVNUM     ; SET UP CURRENT I.D.
 F95A  0A                   ASL           
 F95B  AA                   TAX           
 F95C  B5 8E                LDA DISKID,X  
 F95E  91 93                STA (DIRBUF),Y
 F960  C8                   INY           
 F961  B5 8F                LDA DISKID+1,X
 F963  91 93                STA (DIRBUF),Y
 F965  C8                   INY           
 F966  A9 20                LDA #$20       ; add two spaces. Newer versions add "DOSVER+$30" and "VERNUM" -> "2A"
 F968  91 93                STA (DIRBUF),Y
 F96A  C8                   INY           
 F96B  91 93                STA (DIRBUF),Y
 F96D  20 21 EE             JSR DRTWRT     ; WRITE IT OUT
 F970  4C 75 F0             JMP ENDCMD    

; SCRATCH FILE(S)

 F973  20 1B F2  SCRTCH     JSR FS1SET     ; SET UP FOR 1 STREAM
 F976  20 AD F1             JSR ALLDRS    
 F979  20 4A F2             JSR OPTSCH    
 F97C  A9 00                LDA #$00      
 F97E  8D EB 10             STA x10EB     
 F981  20 E1 F2             JSR FFST      
 F984  30 22                BMI iF9A8     
 F986  20 DE F9  iF986      JSR DELDIR     ; DELETE DIRECTORY; in 4040 before this a test for active file is inserted
 F989  A6 37                LDX ENTFND     ; in 4040 before this a REL-file test is inserted
 F98B  A9 20                LDA #$20      
 F98D  35 A7                AND FILDAT,X  
 F98F  D0 0F                BNE iF9A0      ; CREATED, NOT CLOSED
 F991  A6 37                LDX ENTFND     ; no needed
 F993  B5 AC                LDA FILTRK,X   ; DELETE BY LINKS
 F995  29 7F                AND #$7F      
 F997  85 81                STA TRACK     
 F999  B5 B1                LDA FILSEC,X  
 F99B  85 82                STA SECTOR    
 F99D  20 B6 F9             JSR DELFIL    
 F9A0  EE EB 10  iF9A0      INC x10EB     
 F9A3  20 D0 F2             JSR FFRE      
 F9A6  10 DE                BPL iF986     
 F9A8  AD EB 10  iF9A8      LDA x10EB      ; FINISHED SET
 F9AB  85 81                STA TRACK      ; FILE COUNT
 F9AD  A9 01                LDA #$01      
 F9AF  A0 00                LDY #$00      
 F9B1  84 82                STY SECTOR    
 F9B3  4C 7A F0             JMP SCREND     ; END OF SCRATCH

 F9B6  20 DD EE  DELFIL     JSR FRETS      ; DELETE FILE BY LINKS
 F9B9  20 36 EE             JSR OPNIRD     ; UPDATE BAM
 F9BC  A9 00     DEL2       LDA #$00      
 F9BE  20 89 EE             JSR SETPNT    
 F9C1  20 F3 E9             JSR RDBYT     
 F9C4  85 81                STA TRACK     
 F9C6  20 F3 E9             JSR RDBYT     
 F9C9  85 82                STA SECTOR    
 F9CB  A5 81                LDA TRACK     
 F9CD  D0 06                BNE iF9D5     
 F9CF  20 87 EC             JSR MAPOUT    
 F9D2  4C 32 EB             JMP FRECHN    
 F9D5  20 DD EE  iF9D5      JSR FRETS     
 F9D8  20 F3 ED             JSR NXTBUF    
 F9DB  4C BC F9             JMP DEL2      

 F9DE  A0 00     DELDIR     LDY #$00      
 F9E0  98                   TYA           
 F9E1  91 93                STA (DIRBUF),Y
 F9E3  C8                   INY           
 F9E4  91 93                STA (DIRBUF),Y
 F9E6  88                   DEY           
 F9E7  20 9D E8             JSR GETACT    
 F9EA  4C 21 EE             JMP DRTWRT    

; DUPLICATE DISK

 F9ED  A9 3D     DUPLCT     LDA #$3D       ; "=" SPECIAL CASE 
 F9EF  20 17 F1             JSR PARSE     
 F9F2  D0 05                BNE iF9F9     
 F9F4  A9 30     iF9F4      LDA #$30      
 F9F6  4C 90 F0             JMP CMDERR    
 F9F9  B9 00 00  iF9F9      LDA CMDBUF,Y  
 F9FC  20 3D F2             JSR TST0V1    
 F9FF  30 F3                BMI iF9F4     
 FA01  AA                   TAX           
 FA02  88                   DEY           
 FA03  88                   DEY           
 FA04  B9 00 00             LDA CMDBUF,Y  
 FA07  20 3D F2             JSR TST0V1    
 FA0A  30 E8                BMI iF9F4     
 FA0C  49 01                EOR #$01      
 FA0E  85 80                STA DRVNUM    
 FA10  A9 18                LDA #$18       ; LED0+LED1
 FA12  0D 82 02             ORA RIOT2PBD  
 FA15  8D 82 02             STA RIOT2PBD  
 FA18  20 C1 E8             JSR INITDR     ; INIT SRC
 FA1B  A5 80                LDA DRVNUM    
 FA1D  49 01                EOR #$01      
 FA1F  85 80                STA DRVNUM    
 FA21  0A                   ASL           
 FA22  A8                   TAY           
 FA23  49 02                EOR #$02      
 FA25  AA                   TAX           
 FA26  B5 8E                LDA DISKID,X  
 FA28  99 8E 00             STA DISKID,Y  
 FA2B  B5 8F                LDA DISKID+1,X
 FA2D  99 8F 00             STA DISKID+1,Y
 FA30  A9 01                LDA #$01      
 FA32  85 81                STA TRACK     
 FA34  20 14 FB             JSR FORMAT     ; FORMAT DST DRIVE

; COPY BLOCKS FROM ONE DRIVE TO OTHER

 FA37  A5 81     CPYD1      LDA TRACK     
 FA39  20 B1 E5             JSR MAXSEC    
 FA3C  85 82                STA SECTOR    
 FA3E  C6 82                DEC SECTOR    
 FA40  20 51 FA             JSR CPYTRK     ; COPY ONE TRACK
 FA43  E6 81                INC TRACK     
 FA45  A5 81                LDA TRACK     
 FA47  C9 24                CMP #$24       ; MAXTRK
 FA49  D0 EC                BNE CPYD1     
 FA4B  20 C1 E8             JSR INITDR    
 FA4E  4C 75 F0             JMP ENDCMD    

; COPY ONE TRACK

 FA51  20 62 FA  CPYTRK     JSR iFA62     
 FA54  20 6D FA  iFA54      JSR SETRH     
 FA57  20 A0 FA             JSR READS      ; READ 10 SECTORS
 FA5A  20 D8 FA             JSR WRITES     ; WRITE 10 SECTORS
 FA5D  A5 82                LDA SECTOR    
 FA5F  10 F3                BPL iFA54     
 FA61  60                   RTS           

 FA62  A2 0A     iFA62      LDX #$0A      
 FA64  A5 81                LDA TRACK     
 FA66  9D 12 10  iFA66      STA x1012,X   
 FA69  CA                   DEX           
 FA6A  10 FA                BPL iFA66     
 FA6C  60                   RTS           

 FA6D  A5 80     SETRH      LDA DRVNUM    
 FA6F  49 01                EOR #$01      
 FA71  85 89                STA CMD       
 FA73  A9 0A                LDA #$0A      
 FA75  85 2C                STA TEMP+2    
 FA77  A5 2C     iFA77      LDA TEMP+2     ; the 4040 has this up to fa95 in subroutine SETH
 FA79  0A                   ASL           
 FA7A  0A                   ASL           
 FA7B  0A                   ASL           
 FA7C  A8                   TAY           
 FA7D  A5 80                LDA DRVNUM    
 FA7F  0A                   ASL           
 FA80  AA                   TAX           
 FA81  B5 8E                LDA DISKID,X  
 FA83  99 21 10             STA HDRS,Y    
 FA86  B5 8F                LDA DISKID+1,X
 FA88  99 22 10             STA HDRS+1,Y  
 FA8B  A5 81                LDA TRACK     
 FA8D  99 23 10             STA HDRS+2,Y  
 FA90  A5 82                LDA SECTOR    
 FA92  99 24 10             STA HDRS+3,Y  
 FA95  C6 82                DEC SECTOR    
 FA97  30 06                BMI iFA9F     
 FA99  C6 2C                DEC TEMP+2    
 FA9B  10 DA                BPL iFA77     
 FA9D  E6 2C                INC TEMP+2    
 FA9F  60        iFA9F      RTS           

; READ TEMP+2 BLOCKS IN

 FAA0  A5 89     READS      LDA CMD       
 FAA2  09 80                ORA #$80       ; READ
 FAA4  85 89                STA CMD       
 FAA6  A6 2C                LDX TEMP+2    
 FAA8  9D 03 10  iFAA8      STA JOBS,X    
 FAAB  E0 0A                CPX #$0A      
 FAAD  F0 03                BEQ iFAB2     
 FAAF  E8                   INX           
 FAB0  D0 F6                BNE iFAA8     
 FAB2  A6 2C     iFAB2      LDX TEMP+2    
 FAB4  A0 0A                LDY #$0A      
 FAB6  BD 03 10  iFAB6      LDA JOBS,X    
 FAB9  30 FB                BMI iFAB6     
 FABB  C9 04                CMP #$04      
 FABD  F0 11                BEQ iFAD0     
 FABF  C9 01                CMP #$01      
 FAC1  F0 0D                BEQ iFAD0     
 FAC3  88                   DEY           
 FAC4  10 03                BPL iFAC9     
 FAC6  4C B3 E6             JMP ERROR     
 FAC9  A5 89     iFAC9      LDA CMD       
 FACB  9D 03 10             STA JOBS,X    
 FACE  30 E6                BMI iFAB6     
 FAD0  E0 0A     iFAD0      CPX #$0A      
 FAD2  F0 03                BEQ iFAD7     
 FAD4  E8                   INX           
 FAD5  D0 DF                BNE iFAB6     
 FAD7  60        iFAD7      RTS           

; WRITE TEMP+2 BUFFERS OUT

 FAD8  A9 90     WRITES     LDA #$90       ; #WRITE
 FADA  05 80                ORA DRVNUM    
 FADC  85 89                STA CMD       
 FADE  A6 2C                LDX TEMP+2    
 FAE0  BC 03 10  iFAE0      LDY JOBS,X    
 FAE3  C0 04                CPY #$04      
 FAE5  D0 09                BNE iFAF0     
 FAE7  A9 01                LDA #$01      
 FAE9  9D 03 10             STA JOBS,X    
 FAEC  A5 89                LDA CMD       
 FAEE  D0 03                BNE iFAF3     
 FAF0  9D 03 10  iFAF0      STA JOBS,X    
 FAF3  E0 0A     iFAF3      CPX #$0A      
 FAF5  F0 03                BEQ iFAFA     
 FAF7  E8                   INX           
 FAF8  D0 E6                BNE iFAE0     
 FAFA  A6 2C     iFAFA      LDX TEMP+2    
 FAFC  BD 03 10  iFAFC      LDA JOBS,X    
 FAFF  30 FB                BMI iFAFC     
 FB01  C9 01                CMP #$01      
 FB03  F0 07                BEQ iFB0C     
 FB05  A5 89                LDA CMD       
 FB07  9D 03 10             STA JOBS,X    
 FB0A  30 F0                BMI iFAFC     
 FB0C  E0 0A     iFB0C      CPX #$0A      
 FB0E  F0 03                BEQ iFB13     
 FB10  E8                   INX           
 FB11  D0 E9                BNE iFAFC     
 FB13  60        iFB13      RTS           

; TRANSFER FORMAT CODE TO BUFFER 0
; & START CONTROLLER FORMATTING

 FB14  A0 00     FORMAT     LDY #$00      
 FB16  B9 40 E0  iFB16      LDA CODE,Y    
 FB19  99 00 11             STA BUFS,Y    
 FB1C  B9 40 E1             LDA CODE+256,Y
 FB1F  99 00 12             STA BUFS+256,Y
 FB22  C8                   INY           
 FB23  D0 F1                BNE iFB16     
 FB25  A9 00                LDA #$00      
 FB27  20 6B E8             JSR SETH      
 FB2A  A9 01                LDA #$01      
 FB2C  8D 12 10             STA x1012     
 FB2F  A5 80                LDA DRVNUM    
 FB31  09 E0                ORA #$E0       ; or with EXEC
 FB33  8D 03 10             STA JOBS      
 FB36  AD 03 10  iFB36      LDA JOBS      
 FB39  30 FB                BMI iFB36     
 FB3B  C9 01                CMP #$01      
 FB3D  F0 07                BEQ iFB46     
 FB3F  A9 03                LDA #$03      
 FB41  A2 00                LDX #$00      
 FB43  4C B3 E6             JMP ERROR     
 FB46  60        iFB46      RTS           

; DSKCPY CHECK FOR TYPE AND PARSES SPECIAL CASE

 FB47  20 AD F1  DSKCPY     JSR ALLDRS    
 FB4A  20 4A F2             JSR OPTSCH    
 FB4D  20 99 F2             JSR LOOKUP    
 FB50  A5 A8                LDA FILDAT+1  
 FB52  4A                   LSR           
 FB53  29 0F                AND #$0F      
 FB55  85 DC                STA xDC       
 FB57  20 16 FC             JSR CHKIO     
 FB5A  A5 A7                LDA FILDAT    
 FB5C  29 01                AND #$01      
 FB5E  85 80                STA DRVNUM    
 FB60  A9 00                LDA #$00      
 FB62  85 9B                STA F1PTR     
 FB64  20 42 EE             JSR iEE42     
 FB67  20 82 F4             JSR iF482     
 FB6A  A4 83                LDY LINDX     
 FB6C  8C EB 10             STY x10EB     
 FB6F  A6 9B                LDX F1PTR     
 FB71  B5 A2                LDA FILENT,X  
 FB73  99 E1 10             STA CHNDAT+8,Y
 FB76  A5 80                LDA DRVNUM    
 FB78  4A                   LSR           
 FB79  A5 DC                LDA xDC       
 FB7B  2A                   ROL           
 FB7C  99 B6 00             STA FILTYP,Y  
 FB7F  A6 99                LDX F1CNT     
 FB81  86 9C     iFB81      STX F2PTR     
 FB83  B5 B1                LDA FILSEC,X  
 FB85  85 82                STA SECTOR    
 FB87  B5 AC                LDA FILTRK,X  
 FB89  29 3F                AND #$3F      
 FB8B  85 81                STA TRACK     
 FB8D  B5 A7                LDA FILDAT,X  
 FB8F  29 01                AND #$01      
 FB91  85 80                STA DRVNUM    
 FB93  20 36 EE             JSR OPNIRD    
 FB96  A5 83                LDA LINDX     
 FB98  8D EC 10             STA x10EC     
 FB9B  10 11                BPL iFBAE     
 FB9D  AD EB 10  iFB9D      LDA x10EB     
 FBA0  85 83                STA LINDX     
 FBA2  68                   PLA           
 FBA3  20 35 EA             JSR WRTBYT    
 FBA6  20 0A EF             JSR SETLDS    
 FBA9  AD EC 10             LDA x10EC     
 FBAC  85 83                STA LINDX     
 FBAE  20 F3 E9  iFBAE      JSR RDBYT     
 FBB1  48                   PHA           
 FBB2  20 0A EF             JSR SETLDS    
 FBB5  A6 83                LDX LINDX     
 FBB7  B5 BE                LDA CHNRDY,X  
 FBB9  C9 80                CMP #$80      
 FBBB  D0 E0                BNE iFB9D     
 FBBD  AD EB 10             LDA x10EB     
 FBC0  85 83                STA LINDX     
 FBC2  68                   PLA           
 FBC3  20 35 EA             JSR WRTBYT    
 FBC6  A6 9C                LDX F2PTR     
 FBC8  E8                   INX           
 FBC9  E4 9A                CPX R0        
 FBCB  90 B4                BCC iFB81     
 FBCD  20 0F EC             JSR CLOSE     
 FBD0  4C 75 F0             JMP ENDCMD    

; RENAME FILE NAME IN DIRECTORY

 FBD3  20 AD F1  RENAME     JSR ALLDRS     ; SET BOTH DRIVE #'S
 FBD6  A5 A8                LDA FILDAT+1  
 FBD8  29 01                AND #$01      
 FBDA  85 A8                STA FILDAT+1  
 FBDC  C5 A7                CMP FILDAT    
 FBDE  F0 02                BEQ iFBE2      ; SAME DRIVE #'S
 FBE0  09 80                ORA #$80       ; CHECK BOTH DRIVES FOR NAME
 FBE2  85 A7     iFBE2      STA FILDAT    
 FBE4  20 4A F2             JSR OPTSCH    
 FBE7  20 99 F2             JSR LOOKUP     ; LOOK UP BOTH NAMES
 FBEA  20 16 FC             JSR CHKIO      ; CHECK FOR EXISTENCE
 FBED  A5 A8                LDA FILDAT+1  
 FBEF  29 01                AND #$01      
 FBF1  85 80                STA DRVNUM    
 FBF3  A5 A3                LDA xA3       
 FBF5  48                   PHA           
 FBF6  29 1F                AND #$1F      
 FBF8  85 82                STA SECTOR    
 FBFA  20 1D EE             JSR DRTRD      ; in 4040 different code with comment "POSIBLE BUG"
 FBFD  68                   PLA           
 FBFE  29 E0                AND #$E0       ; SET SECTOR INDEX
 FC00  09 05                ORA #$05       ; ;+5
 FC02  20 89 EE             JSR SETPNT    
 FC05  20 9D E8             JSR GETACT    
 FC08  A8                   TAY           
 FC09  A6 9D                LDX FILTBL    
 FC0B  A9 10                LDA #$10      
 FC0D  20 4D F4             JSR TRNAME     ; TRANSFER NAME
 FC10  20 21 EE             JSR DRTWRT     ; WRITE SECTOR OUT
 FC13  4C 75 F0             JMP ENDCMD    

; CHECK I/O FILE FOR EXIST
; this is different from 4040

 FC16  A6 9A     CHKIO      LDX R0        
 FC18  CA        iFC18      DEX           
 FC19  E4 99                CPX F1CNT     
 FC1B  90 0B                BCC iFC28     
 FC1D  B5 AC                LDA FILTRK,X  
 FC1F  29 7F                AND #$7F      
 FC21  D0 F5                BNE iFC18     
 FC23  A9 62                LDA #$62      
 FC25  4C 90 F0             JMP CMDERR    
 FC28  B5 AC     iFC28      LDA FILTRK,X  
 FC2A  29 7F                AND #$7F      
 FC2C  F0 05                BEQ iFC33     
 FC2E  A9 63                LDA #$63      
 FC30  4C 90 F0             JMP CMDERR    
 FC33  CA        iFC33      DEX           
 FC34  10 F2                BPL iFC28     
 FC36  60                   RTS           

; VALIDATE FILES WITH BAM
; CREATE NEW BAM ACCORDING TO
; CONTENTS OF FILES ENTERED IN DIR

 FC37  20 99 F0  VERDIR     JSR SIMPRS     ; EXTRACT DRIVE #
 FC3A  20 0A EF             JSR SETLDS    
 FC3D  20 C1 E8             JSR INITDR     ; INIT THE DRIVE FOR NAME, ID
 FC40  20 A1 FC             JSR NEWMAP     ; SET NEW BAM
 FC43  A9 00                LDA #$00      
 FC45  85 D6                STA DELIND    
 FC47  20 CE F3             JSR SRCHST     ; SEARCH FOR FIRST FILE
 FC4A  D0 23                BNE iFC6F      ; FOUND ONE
 FC4C  A9 00     iFC4C      LDA #$00       ; SET DIRECTORY SECTORS...
 FC4E  85 82                STA SECTOR     ; ... IN BAM
 FC50  A9 12                LDA #$12      
 FC52  85 81                STA TRACK     
 FC54  20 79 FC             JSR MRKBAM    
 FC57  20 87 EC             JSR MAPOUT     ; WRITE OUT BAM
 FC5A  4C 75 F0             JMP ENDCMD    
 FC5D  C8        iFC5D      INY           
 FC5E  B1 93                LDA (DIRBUF),Y
 FC60  85 81                STA TRACK     
 FC62  C8                   INY           
 FC63  B1 93                LDA (DIRBUF),Y
 FC65  85 82                STA SECTOR     ; in 4040 here is inserted PHA .... REL-File Side Sector code ... PLA; NOW DO DATA BLOCKS
 FC67  20 79 FC             JSR MRKBAM     ; SET BIT USED IN BAM
 FC6A  20 19 F4  iFC6A      JSR SRRE       ; SEARCH FOR MORE
 FC6D  F0 DD                BEQ iFC4C      ; NO MORE FILES
 FC6F  B1 93     iFC6F      LDA (DIRBUF),Y
 FC71  30 EA                BMI iFC5D     
 FC73  20 DE F9             JSR DELDIR     ; NOT CLOSED DELETE DIR
 FC76  4C 6A FC             JMP iFC6A     

; MARK BAM WITH FILE SECTORS

 FC79  20 5F E5  MRKBAM     JSR SETBMP    
 FC7C  20 A0 E7             JSR USEDTS    
 FC7F  20 36 EE             JSR OPNIRD    
 FC82  A9 00     iFC82      LDA #$00      
 FC84  20 89 EE             JSR SETPNT    
 FC87  20 D4 E9             JSR GETBYT    
 FC8A  85 81                STA TRACK     
 FC8C  20 D4 E9             JSR GETBYT    
 FC8F  85 82                STA SECTOR    
 FC91  A5 81                LDA TRACK     
 FC93  D0 03                BNE iFC98     
 FC95  4C 32 EB             JMP FRECHN    
 FC98  20 A0 E7  iFC98      JSR USEDTS    
 FC9B  20 F3 ED             JSR NXTBUF    
 FC9E  4C 82 FC             JMP iFC82     

 FCA1  A5 80     NEWMAP     LDA DRVNUM     ; create BAM
 FCA3  18                   CLC           
 FCA4  69 42                ADC #$42      
 FCA6  85 31                STA IP+1       ; buffer is $4200 for drive 0 or $4300 for drive 1
 FCA8  A9 00                LDA #$00      
 FCAA  85 30                STA IP        
 FCAC  A5 82     iFCAC      LDA SECTOR     ; track(!) count, not sector
 FCAE  48                   PHA           
 FCAF  A2 00                LDX #$00      
 FCB1  A0 00                LDY #$00       ; start with track=0 (=illegal), place for link address
 FCB3  84 82                STY SECTOR    
 FCB5  BD 22 E0  iFCB5      LDA TRKTBL,X  
 FCB8  91 30                STA (IP),Y     ; fill buffer with data (sector/track, #$ff, #$ff, e02a+x) for each track
 FCBA  C8                   INY            ; i.e. about 35*4=140 bytes, where x is number of speedzone
 FCBB  A9 FF                LDA #$FF      
 FCBD  91 30                STA (IP),Y    
 FCBF  C8                   INY           
 FCC0  91 30                STA (IP),Y    
 FCC2  C8                   INY           
 FCC3  BD 2A E0             LDA BAMEND,X   ; lookup, do not compute (as in later DOS versions) last entry in BAM sector map for track
 FCC6  91 30                STA (IP),Y    
 FCC8  C8                   INY           
 FCC9  E6 82                INC SECTOR    
 FCCB  BD 26 E0             LDA CHGTRACKS,X                ; check track with track where speed zone changes
 FCCE  C5 82                CMP SECTOR    
 FCD0  B0 E3                BCS iFCB5      ; if not new speed zone, go to next track
 FCD2  E8                   INX           
 FCD3  E0 04                CPX #$04       ; compare with number of speed zones
 FCD5  90 DE                BCC iFCB5     
 FCD7  A0 00                LDY #$00       ; write track link address
 FCD9  A9 12                LDA #$12       ; track 18
 FCDB  91 30                STA (IP),Y    
 FCDD  C8                   INY           
 FCDE  98                   TYA            ; sector 1
 FCDF  91 30                STA (IP),Y    
 FCE1  C8                   INY           
 FCE2  91 30                STA (IP),Y     ; version 1
 FCE4  C8                   INY           
 FCE5  A9 00                LDA #$00       ; fill byte 0
 FCE7  91 30                STA (IP),Y    
 FCE9  68                   PLA           
 FCEA  85 82                STA SECTOR    
 FCEC  60                   RTS           

; MEMORY ACCESS COMMANDS
; "-" MUST BE 2ND CHAR

 FCED  A5 01     MEM        LDA CMDBUF+1  
 FCEF  C9 2D                CMP #$2D       ; "-"
 FCF1  D0 30                BNE MEMERR    
 FCF3  A5 02                LDA CMDBUF+2  
 FCF5  C9 57                CMP #$57       ; "W"
 FCF7  F0 2F                BEQ MEMWRT     ; WRITE
 FCF9  C9 52                CMP #$52       ; "R"
 FCFB  F0 12                BEQ MEMRD      ; READ
 FCFD  C9 45                CMP #$45       ; "E"
 FCFF  D0 22                BNE MEMERR     ; ERROR
 FD01  20 38 FD             JSR iFD38      ; copy address
 FD04  20 0C FD             JSR MEMEX      ; EXECUTE
 FD07  A9 00     iFD07      LDA #$00      
 FD09  85 5B                STA x5B       
 FD0B  60                   RTS           
 FD0C  6C 2A 00  MEMEX      JMP (TEMP)    
 FD0F  20 38 FD  MEMRD      JSR iFD38      ; copy address
 FD12  B1 2A                LDA (TEMP),Y  
 FD14  8D B4 42             STA NAMBUF    
 FD17  8D E0 10             STA CHNDAT+7  
 FD1A  A9 B4                LDA #$B4      
 FD1C  85 5D                STA x5D       
 FD1E  85 CD                STA LSTCHR+7  
 FD20  4C 07 FD             JMP iFD07     
 FD23  A9 31     MEMERR     LDA #$31       ; BADCMD
 FD25  4C 90 F0             JMP CMDERR    
 FD28  20 38 FD  MEMWRT     JSR iFD38      ; WRITE; copy address
 FD2B  B9 06 00  iFD2B      LDA CMDBUF+6,Y
 FD2E  91 2A                STA (TEMP),Y   ; TRANSFER FROM CMDBUF
 FD30  C8                   INY           
 FD31  C4 05                CPY CMDBUF+5   ; # OF BYTES TO WRITE
 FD33  90 F6                BCC iFD2B     
 FD35  4C 07 FD             JMP iFD07     

 FD38  A5 03     iFD38      LDA CMDBUF+3   ; copy address from command to tmp
 FD3A  85 2A                STA TEMP      
 FD3C  A5 04                LDA CMDBUF+4  
 FD3E  85 2B                STA TEMP+1    
 FD40  A0 00                LDY #$00      
 FD42  60                   RTS           

; ROM 1.1 ADDITIONS
; USER COMMANDS

 FD43  A4 01     USER       LDY CMDBUF+1  
 FD45  C0 30                CPY #$30      
 FD47  D0 09                BNE iFD52      ; "0" RESETS PNTR
 FD49  A9 EA     USRINT     LDA #$EA       ; #<UBLOCK; SET DEFAULT BLOCK ADD
 FD4B  85 DD                STA USRJMP    
 FD4D  A9 FF                LDA #$FF       ; #>UBLOCK
 FD4F  85 DE                STA USRJMP+1  
 FD51  60                   RTS           
 FD52  20 58 FD  iFD52      JSR USREXC     ; EXECUTE CODE BY TABLE
 FD55  4C 75 F0             JMP ENDCMD    

 FD58  88        USREXC     DEY            ; ENTRY IS (((INDEX-1)AND$F)*2)
 FD59  98                   TYA           
 FD5A  29 0F                AND #$0F      
 FD5C  0A                   ASL           
 FD5D  A8                   TAY           
 FD5E  B1 DD                LDA (USRJMP),Y
 FD60  85 30                STA IP        
 FD62  C8                   INY           
 FD63  B1 DD                LDA (USRJMP),Y
 FD65  85 31                STA IP+1      
 FD67  6C 30 00             JMP (IP)      

; OPEN DIRECT ACCESS BUFFER
; FROM OPEN "#"

 FD6A  A6 95     OPNBLK     LDX CMDSIZ    
 FD6C  CA                   DEX           
 FD6D  D0 0D                BNE iFD7C     
 FD6F  A9 01                LDA #$01       ; GET ANY BUFFER
 FD71  20 F3 EA             JSR GETRCH    
 FD74  4C BA FD             JMP iFDBA     
 FD77  A9 70     iFD77      LDA #$70       ; NOCHNL
 FD79  4C 90 F0             JMP CMDERR    
 FD7C  A0 01     iFD7C      LDY #$01       ; BUFFER # IS REQUESTED
 FD7E  20 41 FE             JSR iFE41     
 FD81  A6 B1                LDX FILSEC    
 FD83  E0 0D                CPX #$0D       ; BAMJOB; MUST BE LESS THAN 13
 FD85  B0 F0                BCS iFD77     
 FD87  A9 00                LDA #$00      
 FD89  85 2A                STA TEMP      
 FD8B  85 2B                STA TEMP+1    
 FD8D  38                   SEC           
 FD8E  26 2A     iFD8E      ROL TEMP      
 FD90  26 2B                ROL TEMP+1    
 FD92  CA                   DEX           
 FD93  10 F9                BPL iFD8E     
 FD95  A5 2A                LDA TEMP      
 FD97  25 8B                AND BUFUSE    
 FD99  D0 DC                BNE iFD77      ; BUFFER IS USED
 FD9B  A5 2B                LDA TEMP+1    
 FD9D  25 8C                AND BUFUSE+1  
 FD9F  D0 D6                BNE iFD77      ; BUF IS USED
 FDA1  A5 2A                LDA TEMP      
 FDA3  05 8B                ORA BUFUSE     ; SET BUFFER AS USED
 FDA5  85 8B                STA BUFUSE    
 FDA7  A5 2B                LDA TEMP+1    
 FDA9  05 8C                ORA BUFUSE+1  
 FDAB  85 8C                STA BUFUSE+1  
 FDAD  A9 00                LDA #$00       ; SET UP CHANNEL
 FDAF  20 F3 EA             JSR GETRCH    
 FDB2  A5 83                LDA LINDX     
 FDB4  0A                   ASL           
 FDB5  AA                   TAX           
 FDB6  A5 B1                LDA FILSEC    
 FDB8  95 5F                STA BUFNUM,X  
 FDBA  A5 84     iFDBA      LDA SA        
 FDBC  0A                   ASL           
 FDBD  AA                   TAX           
 FDBE  BD B7 10             LDA LINTAB,X   ; SET LINDX TABLE
 FDC1  9D B8 10             STA LINTAB+1,X ; the 4040 has LINTAB and LINTAB+1 folded together by ORing with #$40
 FDC4  A8                   TAY           
 FDC5  A9 FF                LDA #$FF      
 FDC7  99 C6 00             STA LSTCHR,Y  
 FDCA  A9 89                LDA #$89       ; RNDRDY
 FDCC  99 BE 00             STA CHNRDY,Y   ; SET CHANNEL READY
 FDCF  98                   TYA           
 FDD0  0A                   ASL           
 FDD1  AA                   TAX           
 FDD2  B5 5F                LDA BUFNUM,X  
 FDD4  99 D9 10             STA CHNDAT,Y   ; BUFFER # AS 1ST CHAR
 FDD7  0A                   ASL           
 FDD8  AA                   TAX           
 FDD9  A9 01                LDA #$01      
 FDDB  95 3D                STA BUFTAB,X  
 FDDD  A9 08                LDA #$08       ; DIRTYP+DIRTYP
 FDDF  99 B6 00             STA FILTYP,Y   ; SET DIRECT FILE TYPE
 FDE2  4C 75 F0             JMP ENDCMD    

; BLOCK COMMANDS

 FDE5  A0 00     BLOCK      LDY #$00      
 FDE7  A2 00                LDX #$00      
 FDE9  A9 2D                LDA #$2D       ; "-" SEPARATES CMD FROM SUBCMD
 FDEB  20 17 F1             JSR PARSE      ; LOCATE SUB-CMD
 FDEE  D0 0A                BNE iFDFA     
 FDF0  A9 31     iFDF0      LDA #$31       ; BADCMD
 FDF2  4C 90 F0             JMP CMDERR    
 FDF5  A9 30     iFDF5      LDA #$30       ; BADSYN
 FDF7  4C 90 F0             JMP CMDERR    
 FDFA  8A        iFDFA      TXA           
 FDFB  D0 F8                BNE iFDF5     
 FDFD  A2 05                LDX #$05       ; NBCMDS-1; FIND COMMAND
 FDFF  B9 00 00             LDA CMDBUF,Y  
 FE02  DD 22 FE  iFE02      CMP BCTAB,X   
 FE05  F0 05                BEQ iFE0C     
 FE07  CA                   DEX           
 FE08  10 F8                BPL iFE02     
 FE0A  30 E4                BMI iFDF0     
 FE0C  86 96     iFE0C      STX CMDNUM     ; found command
 FE0E  20 34 FE             JSR BLKPAR     ; PARSE PARAMS
 FE11  A5 96                LDA CMDNUM    
 FE13  0A                   ASL           
 FE14  AA                   TAX           
 FE15  BD 29 FE             LDA BCJMP+1,X 
 FE18  85 2B                STA TEMP+1    
 FE1A  BD 28 FE             LDA BCJMP,X   
 FE1D  85 2A                STA TEMP      
 FE1F  6C 2A 00             JMP (TEMP)     ; GOTO COMMAND

 FE22  BCTAB      .byte $41, $46, $52, $57, $45, $50            ;afrwep


; NBCMDS = *-BCTAB
; BLOCK-ALLOCATE, BLOCK-FREE, BLOCK-READ, BLOCK-WRITE, BLOCK-EXECUTE, BLOCK-POINTER 

 FE28  BCJMP      .word BLKALC  
xFE29      = * - 1 ;   referenced;
 FE2A             .word BLKFRE  , BLKRD   , BLKWT   , BLKEXC  
 FE32             .word BLKPTR  


; PARSE BLOCK PARMS


 FE34  A0 00     BLKPAR     LDY #$00       ; PARSE BLOCK PARMS
 FE36  A2 00                LDX #$00      
 FE38  A9 3A                LDA #$3A       ; ":"
 FE3A  20 17 F1             JSR PARSE     
 FE3D  D0 02                BNE iFE41      ; FOUND ":"
 FE3F  A0 03                LDY #$03       ; ELSE CHAR #3 IS BEGINNING
 FE41  B9 00 00  iFE41      LDA CMDBUF,Y  
 FE44  C9 20                CMP #$20       ; " "
 FE46  F0 08                BEQ iFE50     
 FE48  C9 1D                CMP #$1D       ; SKIP CHARACTER
 FE4A  F0 04                BEQ iFE50     
 FE4C  C9 2C                CMP #$2C       ; ","
 FE4E  D0 06                BNE iFE56     
 FE50  C8        iFE50      INY           
 FE51  C4 95                CPY CMDSIZ    
 FE53  90 EC                BCC iFE41     
 FE55  60                   RTS            ; THAT'S ALL
 FE56  20 63 FE  iFE56      JSR ASCHEX    
 FE59  E6 99                INC F1CNT     
 FE5B  A4 9C                LDY F2PTR     
 FE5D  E0 04                CPX #$04       ; MXFILS-1
 FE5F  90 EF                BCC iFE50     
 FE61  B0 92                BCS iFDF5      ; BAD SYNTAX

; CONVERT ASCII TO HEX (BINARY)
; & STORE CONVERSION IN TABLES
; .Y=PTR INTO CMDBUF

 FE63  A9 00     ASCHEX     LDA #$00      
 FE65  85 2A                STA TEMP      
 FE67  85 2B                STA TEMP+1    
 FE69  85 2D                STA TEMP+3    
 FE6B  A2 FF                LDX #$FF      
 FE6D  B9 00 00  iFE6D      LDA CMDBUF,Y   ; TEST FOR DEC #
 FE70  C9 40                CMP #$40      
 FE72  B0 17                BCS iFE8B      ; NON-NUMERIC TERMINATES
 FE74  C9 30                CMP #$30      
 FE76  90 13                BCC iFE8B      ; NON-NUMERIC
 FE78  29 0F                AND #$0F      
 FE7A  48                   PHA           
 FE7B  A5 2B                LDA TEMP+1     ; SHIFT DIGITS (*10)
 FE7D  85 2C                STA TEMP+2    
 FE7F  A5 2A                LDA TEMP      
 FE81  85 2B                STA TEMP+1    
 FE83  68                   PLA           
 FE84  85 2A                STA TEMP      
 FE86  C8                   INY           
 FE87  C4 95                CPY CMDSIZ    
 FE89  90 E2                BCC iFE6D      ; STILL IN STRING
 FE8B  84 9C     iFE8B      STY F2PTR      ; CONVERT DIGITS TO...
 FE8D  18                   CLC            ; ...BINARY BY DEC TABLE
 FE8E  A9 00                LDA #$00      
 FE90  E8        iFE90      INX           
 FE91  E0 03                CPX #$03      
 FE93  B0 0F                BCS iFEA4     
 FE95  B4 2A                LDY TEMP,X    
 FE97  88        iFE97      DEY           
 FE98  30 F6                BMI iFE90     
 FE9A  7D AF FE             ADC DECTAB,X  
 FE9D  90 F8                BCC iFE97     
 FE9F  18                   CLC           
 FEA0  E6 2D                INC TEMP+3    
 FEA2  D0 F3                BNE iFE97     
 FEA4  48        iFEA4      PHA           
 FEA5  A6 99                LDX F1CNT     
 FEA7  A5 2D                LDA TEMP+3    
 FEA9  95 AC                STA FILTRK,X   ; STORE RESULT IN TABLE
 FEAB  68                   PLA           
 FEAC  95 B1                STA FILSEC,X  
 FEAE  60                   RTS           


; DECIMAL TABLE

 FEAF  DECTAB     .byte $01, $0A, $64                           ;ajD

; BLOCK-FREE


 FEB2  20 B9 FF  BLKFRE     JSR BLKTST    
 FEB5  20 DD EE             JSR FRETS     
 FEB8  4C 75 F0             JMP ENDCMD    

; BLOCK-ALLOCATE

 FEBB  20 B9 FF  BLKALC     JSR BLKTST    
 FEBE  A6 80                LDX DRVNUM    
 FEC0  BD 40 E5             LDA IPBM,X    
 FEC3  85 29                STA BMPNT+1   
 FEC5  20 6B E5  iFEC5      JSR AVAIL     
 FEC8  20 87 E5  iFEC8      JSR AV2       
 FECB  B0 25                BCS iFEF2     
 FECD  A6 82                LDX SECTOR    
 FECF  E8                   INX           
 FED0  86 82                STX SECTOR    
 FED2  8E E9 10             STX ERWORD     ; SET NOT AVAIL FLAG
 FED5  E4 9A                CPX R0        
 FED7  90 EF                BCC iFEC8     
 FED9  A9 00                LDA #$00      
 FEDB  85 82                STA SECTOR    
 FEDD  A6 81                LDX TRACK     
 FEDF  E8                   INX           
 FEE0  86 81                STX TRACK     
 FEE2  E0 24                CPX #$24      
 FEE4  B0 05                BCS iFEEB     
 FEE6  20 C9 FF             JSR iFFC9      ; similar to TSCHK in 4040
 FEE9  90 DA                BCC iFEC5     
 FEEB  85 81     iFEEB      STA TRACK     
 FEED  A9 65     iFEED      LDA #$65       ; NOBLK
 FEEF  4C D4 E6             JMP CMDER2    
 FEF2  AE E9 10  iFEF2      LDX ERWORD     ; FINISHED SEARCH
 FEF5  D0 F6                BNE iFEED      ; BLOCK WASN'T AVAILABLE
 FEF7  20 A0 E7             JSR USEDTS     ; BLOCK AVAIL, SET AS USED
 FEFA  4C 75 F0             JMP ENDCMD    

 FEFD  20 E4 FF  BLKRD2     JSR BKOTST     ; TEST PARAMS
 FF00  4C 1D EE             JMP DRTRD      ; GET BYTE W/O INC

 FF03  20 CC E9  GETSIM     JSR GETPRE    
 FF06  A1 3D                LDA (BUFTAB,X)
 FF08  60                   RTS           

; BLOCK READ

 FF09  20 FD FE  BLKRD      JSR BLKRD2    
 FF0C  A9 00                LDA #$00      
 FF0E  20 89 EE             JSR SETPNT    
 FF11  20 03 FF             JSR GETSIM     ; Y=LINDX
 FF14  20 1D FF             JSR iFF1D     
 FF17  20 2C ED             JSR RNGET1    
 FF1A  4C 75 F0             JMP ENDCMD    

 FF1D  99 C6 00  iFF1D      STA LSTCHR,Y  
 FF20  A9 89                LDA #$89       ; RNDRDY
 FF22  99 D9 10             STA CHNDAT,Y  
 FF25  60                   RTS           

; USER DIRECT READ, LSTCHR=$FF

 FF26  20 34 FE  UBLKRD     JSR BLKPAR    
 FF29  20 FD FE             JSR BLKRD2    
 FF2C  A4 83                LDY LINDX     
 FF2E  B9 C6 00             LDA LSTCHR,Y  
 FF31  99 D9 10             STA CHNDAT,Y  
 FF34  A9 FF                LDA #$FF      
 FF36  20 1D FF             JSR iFF1D     
 FF39  A9 00                LDA #$00      
 FF3B  20 89 EE             JSR SETPNT    
 FF3E  4C 75 F0             JMP ENDCMD     ; (RTS)

; BLOCK WRITE

 FF41  20 E4 FF  BLKWT      JSR BKOTST    
 FF44  20 B0 EE             JSR GETPNT    
 FF47  A8                   TAY           
 FF48  88                   DEY           
 FF49  C9 02                CMP #$02      
 FF4B  B0 02                BCS iFF4F     
 FF4D  A0 01                LDY #$01      
 FF4F  A9 00     iFF4F      LDA #$00       ; SET RECORD SIZE
 FF51  20 89 EE             JSR SETPNT    
 FF54  98                   TYA           
 FF55  20 89 E8             JSR PUTBYT    
 FF58  8A                   TXA           
 FF59  48                   PHA           
 FF5A  20 21 EE             JSR DRTWRT     ; WRITE BLOCK
 FF5D  68                   PLA           
 FF5E  AA                   TAX           
 FF5F  20 2E ED             JSR RNGET2    
 FF62  4C 75 F0             JMP ENDCMD    

; USER DIRECT WRITE, NO LSTCHR

 FF65  20 34 FE  UBLKWT     JSR BLKPAR    
 FF68  20 E4 FF             JSR BKOTST    
 FF6B  20 21 EE             JSR DRTWRT    
 FF6E  4C 75 F0             JMP ENDCMD    

; BLOCK-EXECUTE

 FF71  20 FD FE  BLKEXC     JSR BLKRD2     ; READ BLOCK & EXECUTE
 FF74  A9 00                LDA #$00      
 FF76  85 2A                STA TEMP      
 FF78  A6 8D                LDX JOBNUM    
 FF7A  BD CE EE             LDA BUFIND,X  
 FF7D  85 2B                STA TEMP+1    
 FF7F  20 85 FF             JSR iFF85      ; INDIRECT JSR
 FF82  4C 75 F0             JMP ENDCMD    

 FF85  6C 2A 00  iFF85      JMP (TEMP)    

; BUFFER-POINTER, SET BUFFER POINTER

 FF88  20 9A FF  BLKPTR     JSR BUFTST    
 FF8B  A5 8D                LDA JOBNUM    
 FF8D  0A                   ASL           
 FF8E  AA                   TAX           
 FF8F  A4 B2                LDY FILSEC+1  
 FF91  88                   DEY           
 FF92  94 3D                STY BUFTAB,X  
 FF94  20 1A ED             JSR iED1A      ; in 4040 JSR GETPRE, JSR RNDGET2; SET UP GET
 FF97  4C 75 F0             JMP ENDCMD    

; TEST FOR ALLOCATED BUFFER..
; ..RELATED TO SA

 FF9A  A6 9B     BUFTST     LDX F1PTR     
 FF9C  E6 9B                INC F1PTR     
 FF9E  B5 B1                LDA FILSEC,X  
 FFA0  A8                   TAY           
 FFA1  88                   DEY           
 FFA2  88                   DEY           
 FFA3  C0 0D                CPY #$0D       ; BAMJOB
 FFA5  90 05                BCC iFFAC     
 FFA7  A9 70     iFFA7      LDA #$70       ; NOCHNL
 FFA9  4C 90 F0             JMP CMDERR    
 FFAC  85 84     iFFAC      STA SA        
 FFAE  20 B0 E9             JSR FNDRCH    
 FFB1  B0 F4                BCS iFFA7     
 FFB3  20 9D E8             JSR GETACT    
 FFB6  85 8D                STA JOBNUM    
 FFB8  60                   RTS           

; TEST FOR LEGAL BLOCK &..
; ..SET UP DRV, TRK, SEC

 FFB9  A6 9B     BLKTST     LDX F1PTR     
 FFBB  B5 B1                LDA FILSEC,X  
 FFBD  29 01                AND #$01      
 FFBF  85 80                STA DRVNUM    
 FFC1  B5 B3                LDA FILSEC+2,X
 FFC3  85 82                STA SECTOR    
 FFC5  B5 B2                LDA FILSEC+1,X
 FFC7  85 81                STA TRACK     
 FFC9  A5 81     iFFC9      LDA TRACK      ; in 4040 separated out into TSCHK
 FFCB  AA                   TAX           
 FFCC  CA                   DEX           
 FFCD  E0 23                CPX #$23      
 FFCF  B0 0E                BCS iFFDF     
 FFD1  20 B1 E5             JSR MAXSEC    
 FFD4  85 9A                STA R0        
 FFD6  A5 82                LDA SECTOR    
 FFD8  C5 9A                CMP R0        
 FFDA  B0 03                BCS iFFDF     
 FFDC  4C 0A EF             JMP SETLDS    
 FFDF  A9 22     iFFDF      LDA #$22      
 FFE1  4C D4 E6             JMP CMDER2    

 FFE4  20 9A FF  BKOTST     JSR BUFTST     ; TEST BLOCK OPERATION PARAMS
 FFE7  4C B9 FF             JMP BLKTST    

 FFEA  xFFEA      .word UBLKRD  , UBLKWT  , BUFS+512 , BUFS+515 
 FFF2             .word BUFS+518 , DIAGROM+8 , DIAGROM+11 , DIAGROM+14 

 FFFA             .word DIAGROM+213 , DSKINT  , ATNIRQ  


; Misassembly source 4.08 15 May 2005   Generated  Sun May 15 20:12:16 CEST 2005



Formatted to HTML by recomment 4.08 15 May 2005 reassembler.

Misassembled from dos1 by fachat@newton using header file dos1.hdr in a 2-pass run at Sun May 15 20:12:16 CEST 2005 .