         nam   SCF
         ttl   os9 file manager     

* Disassembled 98/08/23 20:35:14 by Disasm v1.6 (C) 1988 by RML

         ifp1
         use   defsfile
         use   scfdefs
         endc
tylg     set   FlMgr+Objct   
atrv     set   ReEnt+rev
rev      set   $01
         mod   eom,name,tylg,atrv,start,size
u0000    rmb   0
size     equ   .
name     equ   *
         fcs   /SCF/
         fcb   $0D 
start    equ   *
         lbra  Create
         lbra  Open
         lbra  MakDir
         lbra  ChgDir
         lbra  Delete
         lbra  Seek
         lbra  Read
         lbra  Write
         lbra  ReadLn
         lbra  WriteLn
         lbra  GetStat
         lbra  SetStat
         lbra  Term
L0038    puls  y


* ChgDir/Makdir entry
ChgDir
MakDir   comb  
         ldb   #E$BPNam
L003D    rts   


* Open/Create entry
Open
Create   ldx   PD.DEV,y
         stx   <$3B,y
         ldu   PD.RGS,y
         pshs  y
         ldx   R$X,u
         os9   F$PrsNam 
         bcs   L0038
         tsta  
         bmi   L0058
         leax  ,y
         os9   F$PrsNam 
         bcc   L0038
L0058    sty   R$X,u
         puls  y
         ldd   #256
         os9   F$SRqMem 
         bcs   L003D
         stu   PD.BUF,y
         clrb  
         bsr   L008A

* cute message
         fcb   $62,$1B,$59,$6B,$65,$65,$2A,$11,$1C,$0D,$0F
         fcb   $42,$0C,$6C,$62,$6D,$31,$13,$0F,$0B,$49,$0C
         fcb   $72,$7C,$6A,$2B,$08,$00,$02,$11,$00,$79

* put cute message into our newly allocated PD buffer
L008A    puls  x			get PC into X
         clra  
L008D    eora  ,x+
         sta   ,u+
         decb  
         cmpa  #$0D
         bne   L008D
L0096    sta   ,u+
         decb  
         bne   L0096
         ldu   PD.DEV,y
         beq   MakDir
         ldx   V$STAT,u			X = static storage ptr
         lda   <PD.PAG,y		get page len
         sta   V.LINE,x			store in static
         ldx   V$DESC,u
         ldd   <PD.D2P,y
         beq   L00CF
         leax  d,x
         lda   PD.MOD,y
         lsra  
         rorb  
         lsra  
         rolb  
         rola  
         rorb  
         rola  
         pshs  y
         ldy   <$0050
         ldu   <$004A
         stu   <$0050
         os9   I$Attach 
         sty   <$0050
         puls  y
         bcs   L0111
         stu   $0A,y
         ldu   $03,y
L00CF    ldu   $02,u
         clra  
         clrb  
         std   <$3D,y
         sta   <$3F,y
         pshs  b,a
         ldx   <$16,u
         bne   L00E8
         sty   <$16,u
         bra   L00F8
L00E6    tfr   d,x
L00E8    ldb   <$3F,x
         bne   L00EF
         inc   $01,s
L00EF    ldd   <$3D,x
         bne   L00E6
         sty   <$3D,x
L00F8    lda   #$29
         pshs  a
         inc   $02,s
         lbsr  L025B
         lda   $02,s
         leas  $03,s
         deca  
         bcs   L010F
         bne   L010D
         lbra  L0250
L010D    clrb  
         rts   
L010F    bsr   L0149
L0111    pshs  b,cc
         bsr   L0136
         puls  pc,b,cc

Term     pshs  cc
         orcc  #$50
         ldx   $03,y
         bsr   L0182
         ldx   $0A,y
         bsr   L0182
         puls  cc
         tst   $02,y
         beq   L012B

Delete
Seek     clra  
         rts   
L012B    bsr   L0149
         lda   #$2A
         pshs  x,a
         lbsr  L025B
         leas  $03,s
L0136    ldu   $0A,y
         beq   L013D
         os9   I$Detach 
L013D    ldu   $08,y
         beq   L0147
         ldd   #$0100
         os9   F$SRtMem 
L0147    clra  
         rts   
L0149    ldx   #$0001
         pshs  u,y,x,b,a,cc
         ldu   $03,y
         beq   L017B
         ldu   $02,u
         beq   L017B
         ldx   <$16,u
         beq   L017B
         ldd   <$3D,y
         cmpy  <$16,u
         bne   L0172
         std   <$16,u
         bne   L017B
         clr   $04,s
         bra   L017B
L016D    ldx   <$3D,x
         beq   L0180
L0172    cmpy  <$3D,x
         bne   L016D
         std   <$3D,x
L017B    clra  
         clrb  
         std   <$3D,y
L0180    puls  pc,u,y,x,b,a,cc
L0182    leax  ,x
         beq   Delete
         ldx   $02,x
         ldb   ,y
         lda   $05,y
         pshs  y,x,b,a
         cmpa  $03,x
         bne   L01CA
         ldx   <$0050
         leax  <$30,x
         clra  
L0198    cmpb  a,x
         beq   L01CA
         inca  
         cmpa  #$10
         bcs   L0198
         pshs  y
         ldd   #$1B0C
         bsr   L01FA
         puls  y
         ldx   <$0050
         lda   $01,x
         sta   ,s
         os9   F$GProcP 
         leax  <$30,y
         ldb   $01,s
         clra  
L01B9    cmpb  a,x
         beq   L01C4
         inca  
         cmpa  #$10
         bcs   L01B9
         clr   ,s
L01C4    lda   ,s
         ldx   $02,s
         sta   $03,x
L01CA    puls  pc,y,x,b,a
GetStat  lda   <$3F,y
         lbne  L04C6
         ldx   $06,y
         lda   $02,x
         cmpa  #$00
         bne   L01F8
         pshs  y,x,a
         lda   #$28
         sta   $02,x
         ldu   $06,x
         pshs  u
         bsr   L01F8
         puls  u
         puls  y,x,a
         sta   $02,x
         ldd   $06,x
         stu   $06,x
         bcs   L01F6
         std   <$34,y
L01F6    clrb  
L01F7    rts   
L01F8    ldb   #$09
L01FA    pshs  a
         clra  
         ldx   $03,y
         ldu   $02,x
         ldx   ,x
         addd  $09,x
         leax  d,x
         puls  a
         pshs  u,y,x
         jsr   ,x
         puls  pc,u,y,x

SetStat  lbsr  L04A2
L0212    bsr   L021B
         pshs  b,cc
         lbsr  L0453
         puls  pc,b,cc
L021B    lda   $02,u
         ldb   #$0C
         cmpa  #$00
         bne   L01FA
         ldx   <$27,y
         pshs  y,x
         ldx   <$0050
         lda   $06,x
         ldb   <$00D0
         ldx   $04,u
         leau  <$20,y
         ldy   #$001A
         os9   F$Move   
         puls  y,x
         bcs   L01F7
         pshs  x
         ldd   <$27,y
         cmpd  ,s++
         beq   L0250
         ldu   $03,y
         ldu   $02,u
         beq   L0250
         stb   $07,u
L0250    ldx   <$34,y
         lda   #$28
         pshs  x,a
         bsr   L025B
         puls  pc,x,a
L025B    pshs  u,y,x
         ldx   $06,y
         ldu   $06,x
         lda   $02,x
         pshs  u,y,x,a
         ldd   <$10,s
         std   $06,x
         lda   $0F,s
         sta   $02,x
         ldb   #$0C
         lbsr  L04A7
         bsr   L0212
         puls  u,y,x,a
         stu   $06,x
         sta   $02,x
         bcc   L0282
         cmpb  #$D0
         beq   L0282
         coma  
L0282    puls  pc,u,y,x

Read     lbsr  L04A2
         bcc   L028A
L0289    rts   
L028A    inc   $0C,y
         ldx   $06,u
         beq   L02DC
         pshs  x
         lbsr  L03B5
         lbsr  L03E2
         bcs   L02A4
         tsta  
         beq   L02C4
         cmpa  <$2C,y
         bne   L02BC
L02A2    ldb   #$D3
L02A4    leas  $02,s
         pshs  b
         bsr   L02D5
         comb  
         puls  pc,b
L02AD    tfr   x,d
         tstb  
         bne   L02B7
         lbsr  L042B
         ldu   $08,y
L02B7    lbsr  L03E2
         bcs   L02A4
L02BC    tst   <$24,y
         beq   L02C4
         lbsr  L0565
L02C4    leax  $01,x
         sta   ,u+
         beq   L02CF
         cmpa  <$2B,y
         beq   L02D3
L02CF    cmpx  ,s
         bcs   L02AD
L02D3    leas  $02,s
L02D5    lbsr  L042B
         ldu   $06,y
         stx   $06,u
L02DC    lbra  L0453

ReadLn   lbsr  L04A2
         bcs   L0289
         ldx   $06,u
         beq   L02D5
         tst   $06,u
         beq   L02EF
         ldx   #$0100
L02EF    pshs  x
         ldd   #$FFFF
         std   $0D,y
         lbsr  L03B5
L02F9    lbsr  L03E2
         bcs   L0370
         tsta  
         beq   L030C
         ldb   #$29
L0303    cmpa  b,y
         beq   L032C
         incb  
         cmpb  #$31
         bls   L0303
L030C    cmpx  $0D,y
         bls   L0312
         stx   $0D,y
L0312    leax  $01,x
         cmpx  ,s
         bcs   L0322
         lda   <$33,y
         lbsr  L0565
         leax  -$01,x
         bra   L02F9
L0322    lbsr  L0403
         sta   ,u+
         lbsr  L0413
         bra   L02F9
L032C    pshs  pc,x
         leax  >L033F,pcr
         subb  #$29
         lslb  
         leax  b,x
         stx   $02,s
         puls  x
         jsr   [,s++]
         bra   L02F9
L033F    bra   L03BB
         bra   L03A5
         bra   L0351
         bra   L0366
         bra   L0381
         bra   L038B
         puls  pc
         bra   L03A5
         bra   L03A5
L0351    leas  $02,s
         sta   ,u
         lbsr  L0413
         ldu   $06,y
         leax  $01,x
         stx   $06,u
         lbsr  L042B
         leas  $02,s
         lbra  L0453
L0366    leas  $02,s
         leax  ,x
         lbeq  L02A2
         bra   L030C
L0370    pshs  b
         lda   #$0D
         sta   ,u
         bsr   L037D
         puls  b
         lbra  L02A4
L037D    lda   #$0D
         bra   L03D7
L0381    lda   <$2B,y
         sta   ,u
         bsr   L03B5
L0388    lbsr  L0418
L038B    cmpx  $0D,y
         beq   L03A2
         leax  $01,x
         cmpx  $02,s
         bcc   L03A0
         lda   ,u+
         beq   L0388
         cmpa  <$2B,y
         bne   L0388
         leau  -$01,u
L03A0    leax  -$01,x
L03A2    rts   
L03A3    bsr   L03BF
L03A5    leax  ,x
         beq   L03B5
         tst   <$23,y
         beq   L03A3
         tst   <$24,y
         beq   L03B5
         bsr   L037D
L03B5    ldx   #$0000
         ldu   $08,y
L03BA    rts   
L03BB    leax  ,x
         beq   L03A2
L03BF    leau  -$01,u
         leax  -$01,x
         tst   <$24,y
         beq   L03BA
         tst   <$22,y
         beq   L03D4
         bsr   L03D4
         lda   #$20
         lbsr  L0565
L03D4    lda   <$32,y
L03D7    lbra  L0565
L03DA    pshs  u,y,x
         ldx   $0A,y
         ldu   $03,y
         bra   L03EA
L03E2    pshs  u,y,x
         ldx   $03,y
         ldu   $0A,y
         beq   L03F1
L03EA    ldu   $02,u
         ldb   <$28,y
         stb   $07,u
L03F1    leax  ,x
         beq   L0401
         tfr   u,d
         ldu   $02,x
         std   $09,u
         ldu   #$0003
         lbsr  L05CC
L0401    puls  pc,u,y,x
L0403    tst   <$21,y
         beq   L0412
         cmpa  #$61
         bcs   L0412
         cmpa  #$7A
         bhi   L0412
         suba  #$20
L0412    rts   
L0413    tst   <$24,y
         beq   L0412
L0418    cmpa  #$20
         bcc   L0420
         cmpa  #$0D
         bne   L0423
L0420    lbra  L0565
L0423    pshs  a
         lda   #$2E
         bsr   L0420
         puls  pc,a
L042B    pshs  y,x
         ldd   ,s
         beq   L0451
         tstb  
         bne   L0435
         deca  
L0435    clrb  
         ldu   $06,y
         ldu   $04,u
         leau  d,u
         clra  
         ldb   $01,s
         bne   L0442
         inca  
L0442    pshs  b,a
         lda   <$00D0
         ldx   <$0050
         ldb   $06,x
         ldx   $08,y
         puls  y
         os9   F$Move   
L0451    puls  pc,y,x
L0453    ldx   <$0050
         lda   ,x
         ldx   $03,y
         bsr   L045D
         ldx   $0A,y
L045D    beq   L0467
         ldx   $02,x
         cmpa  $04,x
         bne   L0467
         clr   $04,x
L0467    rts   
L0468    pshs  x,a
         ldx   $02,x
         lda   $04,x
         beq   L048A
         cmpa  ,s
         beq   L049F
         pshs  a
         bsr   L0453
         puls  a
         os9   F$IOQu   
         inc   $0F,y
         ldx   <$0050
         ldb   <$19,x
         puls  x,a
         beq   L0468
         coma  
         rts   
L048A    lda   ,s
         sta   $04,x
         sta   $03,x
         lda   <$2F,y
         sta   $0D,x
         ldd   <$30,y
         std   $0B,x
         ldd   <$38,y
         std   $0F,x
L049F    clra  
         puls  pc,x,a
L04A2    lda   <$3F,y
         bne   L04C4
L04A7    ldx   <$0050
         lda   ,x
         clr   $0F,y
         ldx   $03,y
         bsr   L0468
         bcs   L04C1
         ldx   $0A,y
         beq   L04BB
         bsr   L0468
         bcs   L04C1
L04BB    tst   $0F,y
         bne   L04A2
         clr   $0C,y
L04C1    ldu   $06,y
         rts   
L04C4    leas  $02,s
L04C6    ldb   #$DC
         cmpa  #$02
         bcs   L04D3
         lda   $05,y
         ldb   #$00
         os9   F$Send   
L04D3    inc   <$3F,y
         orcc  #$01
         rts   

WriteLn  bsr   L04A2
         bra   L04E1

Write    bsr   L04A2
         inc   $0C,y
L04E1    ldx   $06,u
         beq   L055A
         pshs  x
         ldx   #$0000
         bra   L04F1
L04EC    tfr   u,d
         tstb  
         bne   L0523
L04F1    pshs  y,x
         ldd   ,s
         ldu   $06,y
         ldx   $04,u
         leax  d,x
         ldd   $06,u
         subd  ,s
         cmpd  #$0020
         bls   L0508
         ldd   #$0020
L0508    pshs  b,a
         ldd   $08,y
         inca  
         subd  ,s
         tfr   d,u
         lda   #$0D
         sta   -$01,u
         ldy   <$0050
         lda   $06,y
         ldb   <$00D0
         puls  y
         os9   F$Move   
         puls  y,x
L0523    lda   ,u+
         tst   $0C,y
         bne   L053D
         lbsr  L0403
         cmpa  #$0A
         bne   L053D
         lda   #$0D
         tst   <$25,y
         bne   L053D
         bsr   L0573
         bcs   L055D
         lda   #$0A
L053D    bsr   L0573
         bcs   L055D
         leax  $01,x
         cmpx  ,s
         bcc   L0554
         lda   -$01,u
         beq   L04EC
         cmpa  <$2B,y
         bne   L04EC
         tst   $0C,y
         bne   L04EC
L0554    leas  $02,s
L0556    ldu   $06,y
         stx   $06,u
L055A    lbra  L0453
L055D    leas  $02,s
         pshs  b,cc
         bsr   L0556
         puls  pc,b,cc
L0565    pshs  u,x,a
         ldx   $0A,y
         beq   L0571
         cmpa  #$0D
         beq   L05A2
L056F    bsr   L05C9
L0571    puls  pc,u,x,a
L0573    pshs  u,x,a
         ldx   $03,y
         cmpa  #$0D
         bne   L056F
         ldu   $02,x
         tst   $08,u
         bne   L0590
         tst   $0C,y
         bne   L05A2
         tst   <$27,y
         beq   L05A2
         dec   $07,u
         bne   L05A2
         bra   L059A
L0590    lbsr  L03DA
         bcs   L059A
         cmpa  <$2F,y
         bne   L0590
L059A    lbsr  L03DA
         cmpa  <$2F,y
         beq   L059A
L05A2    ldu   $02,x
         clr   $08,u
         lda   #$0D
         bsr   L05C9
         tst   $0C,y
         bne   L05C7
         ldb   <$26,y
         pshs  b
         tst   <$25,y
         beq   L05BE
         lda   #$0A
L05BA    bsr   L05C9
         bcs   L05C5
L05BE    lda   #$00
         dec   ,s
         bpl   L05BA
         clra  
L05C5    leas  $01,s
L05C7    puls  pc,u,x,a
L05C9    ldu   #$0006
L05CC    pshs  u,y,x,a
         ldu   $02,x
         clr   $05,u
         ldx   ,x
         ldd   $09,x
         addd  $05,s
         leax  d,x
         lda   ,s+
         jsr   ,x
         puls  pc,u,y,x
         emod
eom      equ   *
