💾 Archived View for mirrors.apple2.org.za › archive › www.textfiles.com › apple › ANATOMY › file.man… captured on 2023-01-29 at 11:41:17.

View Raw

More Information

-=-=-=-=-=-=-

 LST OFF

SCRATCH = $27
BOOTSLOT = $2B
ROMRWTS = $3E
SECNUM = $3D
OPRND = $44
BUFADR = $42
DOSIMG = $40
IOBADR = $48
DRV0TRAK = $478
DRV1TRAK = $4F8
DOSSTRT = $9D84
DOVERIFY = $A27D
DOCLOSE = $A2EA
RWC2 = $A546
FMDRVR = $A6A8
FMDRVR0 = $A6BC
DOERROR = $A6D2
LOCBUF = $A764
KWDRPRMS = $A909
CURSTAT = $AA51
CMDINDX = $AA5F
RWTSENT = $BD00
REBOOT = $BFC8
DISKFULL = $BFED
MEMTOP = $C000
MONINIT = $FB2F
CLRHOME = $FC58
RDCHAR = $FD0C
PRBYTE = $FDDA
COUT = $FDED
SETKBD = $FE89
SETVID = $FE93

 ORG $AAC1

RWTSPADR DA TBLTYPE
VTOCPADR DA VTOCSB
DIRPADR DA DIRSECBF
 DA MEMTOP

FMFTBL DA NOERROR-1
 DA OPNHNDLR-1
 DA CLSHDLR-1
 DA RDHNDLR-1
 DA WRTHNDLR-1
 DA DELHNDL-1
 DA CATHNDL-1
 DA LCKHNDLR-1
 DA UNLKHDL-1
 DA RENHNDLR-1
 DA POSHNDLR-1
 DA INITHDL-1
 DA VFYHNDL-1
 DA NOERROR-1

FMRSUB DA NOERROR-1
 DA RD1BYTE-1
 DA RDRANGE-1
 DA POSRD1B-1
 DA POSRDR-1
 DA NOERROR-1

FMWSUB DA NOERROR-1
 DA WRT1BYTE-1
 DA WRTRANGE-1
 DA POSWRT1B-1
 DA POSWRTR-1
 DA NOERROR-1

 ORG $AAFD

FMEXT CPX #0
 BEQ FMEXT1
 LDX #2
FMEXT1 STX CMDINDX

FILEMGR TSX
 STX STKSAVE

 JSR LDFMW

 LDA FMOPCOD
 CMP #$D
 BCS FILEMGR1

 ASL 
 TAX 
 LDA FMFTBL+1,X
 PHA 
 LDA FMFTBL,X
 PHA 
 RTS 

 ORG $AB1F

FILEMGR1 JMP RANGERR

OPNHNDLR JSR CMNOPN
 JMP NOERROR

 ORG $AB28

CMNOPN JSR INITFMW

 LDA #$1
 STA SECTLEN+1

 LDX RECNUM+1
 LDA RECNUM
 BNE CMNOPN1
 CPX #0
 BNE CMNOPN1
 INX 
CMNOPN1 STA OPNRCLEN
 STX OPNRCLEN+1

 JSR LCDIRENT
 BCC PLTSDIR

 STX DIRINDX
 LDX CMDINDX
 LDA KWDRPRMS,X
 LDX DIRINDX
 LSR 
 BCS CMNOPN3

 LDA CURSTAT
 CMP #$C0
 BNE CMNOPN2

 JMP LNOTAVL

CMNOPN2 JMP FNOTFND

 ORG $AB64

CMNOPN3 LDA #0
 STA FILESIZE+1,X
 LDA #$1
 STA FILESIZE,X
 STX DIRINDX

 JSR ALLOCSEC

 LDX DIRINDX
 STA TSSECTOR,X
 STA FTSS
 STA CURTSS
 LDA SCALAREA+1
 STA TSTRACK,X
 STA FTSTS
 STA CURTSTS
 LDA FILETYPE
 STA FILTYP,X

 JSR WRTDIRSC

 JSR SELTSBUF
 JSR ZEROBUF
 JSR SETUPRW

 LDX DIRINDX
 LDA #6
 STA RTNCODE

PLTSDIR LDA TSTRACK,X
 STA FTSTS
 LDA TSSECTOR,X
 STA FTSS
 LDA FILTYP,X

 STA FILETYPE
 STA FTYPE

 LDA FILESIZE,X
 STA SECCNT
 LDA FILESIZE+1,X
 STA SECCNT+1
 STX DIRSECIX+1

 LDA #$FF
 STA RELSLRD
 STA RELSLRD+1

 LDA NUMTSENT
 STA SECPERTS

 CLC 
 JMP RDTSLST

 ORG $ABDC

INITFMW LDA #0
 TAX 
INITFMW1 STA FTSTS,X
 INX 
 CPX #$2D
 BNE INITFMW1

 LDA VOLVAL
 EOR #$FF
 STA VOLNUMBR
 LDA DRVVAL
 STA DRVNUMBR
 LDA SLOTVAL
 ASL 
 ASL 
 ASL 
 ASL 
 TAX 
 STX SLOT16

 LDA #$11
 STA TRKNUMBR
 RTS 

 ORG $AC06

CLSHDLR JSR CHKBUF
 JSR CHKTS

 JSR RLSALLC

 LDA #2
 AND FLAGS
 BEQ CLSHDLR2

 JSR RWVTOC
 LDA #0
 CLC 
CLSHDLR1 JSR RDDIRSC
 SEC 
 DEC DIRSECIX
 BNE CLSHDLR1
 LDX DIRSECIX+1
 LDA SECCNT
 STA FILESIZE,X
 LDA SECCNT+1
 STA FILESIZE+1,X
 JSR WRTDIRSC

CLSHDLR2 JMP NOERROR

 ORG $AC3A

RENHNDLR JSR CMNOPN ;LOOKUP FILE

 LDA FTYPE
 BMI FILOCKED

 LDA RECNUM
 STA BUFADR
 LDA RECNUM+1
 STA BUFADR+1
 LDX DIRINDX
 JSR COPFNAM

 JSR WRTDIRSC
 JMP NOERROR

 ORG $AC58

RDHNDLR LDA SUBCODE

 CMP #5
 BCS RDHNDLR1

 ASL 
 TAX 
 LDA FMRSUB+1,X
 PHA 
 LDA FMRSUB,X
 PHA 
 RTS 
RDHNDLR1 JMP RANGERR2

FILOCKED JMP FILELOCK

 ORG $AC70

WRTHNDLR LDA FTYPE
 BMI FILOCKED

 LDA SUBCODE
 CMP #5
 BCS RDHNDLR1

 ASL 
 TAX 
 LDA FMWSUB+1,X
 PHA 
 LDA FMWSUB,X
 PHA 
 RTS 

 ORG $AC87

POSRD1B JSR CALPOSN

RD1BYTE JSR RDABYTE
 STA DATABYTE
 JMP NOERROR

 ORG $AC93

POSRDR JSR CALPOSN

RDRANGE JSR DECRNG
 JSR RDABYTE
 PHA 
 JSR MOVRANG
 LDY #0
 PLA 
 STA (BUFADR),Y
 JMP RDRANGE

 ORG $ACA8

RDABYTE JSR RDNXTDA
 BCS RDABYTE1
 LDA (BUFADR),Y
 PHA 
 JSR INCREC
 JSR INCPOS
 PLA 
 RTS 
RDABYTE1 JMP ENDATA

 ORG $ACBB

POSWRT1B JSR CALPOSN

WRT1BYTE LDA DATABYTE
 JSR WRTBYTE
 JMP NOERROR

 ORG $ACC7

POSWRTR JSR CALPOSN

WRTRANGE JSR MOVRANG
 LDY #0
 LDA (BUFADR),Y
 JSR WRTBYTE
 JSR DECRNG
 JMP WRTRANGE

 ORG $ACDA

WRTBYTE PHA 
 JSR RDNXTDA
 PLA 
 STA (BUFADR),Y
 LDA #$40
 ORA FLAGS
 STA FLAGS
 JSR INCREC
 JMP INCPOS

 ORG $ACEF

LCKHNDLR LDA #$80
 STA ALLCFLG
 BNE UNLKHDL1

 ORG $ACF6

UNLKHDL LDA #0
 STA ALLCFLG
UNLKHDL1 JSR CMNOPN
 LDX DIRINDX
 LDA FILTYP,X
 AND #$7F
 ORA ALLCFLG
 STA FILTYP,X
 JSR WRTDIRSC
UNLKHDL2 JMP NOERROR

 ORG $AD12

POSHNDLR JSR CALPOSN
VFYHNDL2 JMP NOERROR

 ORG $AD18

VFYHNDL JSR CMNOPN

VFYHNDL1 JSR RDNXTDA
 BCS VFYHNDL2
 INC FILEPOSN
 BNE VFYHNDL1
 INC FILEPOSN+1
 JMP VFYHNDL1

 ORG $AD2B

DELHNDL JSR CMNOPN

 LDX DIRINDX
 LDA FILTYP,X
 BPL DELHNDL1
 JMP FILELOCK

DELHNDL1 LDX DIRINDX
 LDA TSTRACK,X
 STA FTSTS
 STA FILESIZE-1,X
 LDA #$FF
 STA TSTRACK,X
 LDY TSSECTOR,X
 STY FTSS

 JSR WRTDIRSC

 CLC 
RDNXTS JSR RDTSLST
 BCS RDNXTS3
 JSR SELTSBUF
 LDY #$C
RDNXTS1 STY DIRINDX
 LDA (BUFADR),Y

 BMI RDNXTS2
 BEQ RDNXTS2

 PHA 
 INY 
 LDA (BUFADR),Y
 TAY 
 PLA 
 JSR FREESCT

RDNXTS2 LDY DIRINDX
 INY 
 INY 
 BNE RDNXTS1

 LDA CURTSTS
 LDY CURTSS
 JSR FREESCT
 SEC 
 BCS RDNXTS
RDNXTS3 JSR WRTVTOC
 JMP NOERROR

 ORG $AD89

FREESCT SEC
 JSR RRBITMP
 LDA #0
 LDX #5
FREESCT1 STA SCALAREA,X
 DEX 
 BPL FREESCT1
 RTS 

 ORG $AD98

CATHNDL JSR INITFMW

 LDA #$FF
 STA VOLNUMBR

 JSR RWVTOC

 LDA #$16
 STA CNTR

 JSR SKIPLN
 JSR SKIPLN
 LDX #$B
CATHNDL1 LDA DISKVOL,X
 JSR COUT
 DEX 
 BPL CATHNDL1

 STX OPRND+1
 LDA VOLFND
 STA OPRND
 JSR PRTDEC
 JSR SKIPLN
 JSR SKIPLN

 CLC 
RDNXTDIR JSR RDDIRSC
 BCS DONEXT2
 LDX #0
GTRKNUM STX DIRINDX
 LDA TSTRACK,X

 BEQ DONEXT2
 BMI DONEXT

 LDY #" "
 LDA FILTYP,X
 BPL GTRKNUM1
 LDY #"*"
GTRKNUM1 TYA
 JSR COUT

 LDA FILTYP,X
 AND #$7F
 LDY #7
 ASL 
GTRKNUM2 ASL
 BCS GTRKNUM3
 DEY 
 BNE GTRKNUM2
GTRKNUM3 LDA FTTBL,Y
 JSR COUT
 LDA #$A0
 JSR COUT

 LDA FILESIZE,X
 STA OPRND
 LDA FILESIZE+1,X
 STA OPRND+1
 JSR PRTDEC
 LDA #$A0
 JSR COUT
 INX 
 INX 
 INX 

 LDY #$1D
GTRKNUM4 LDA TSTRACK,X
 JSR COUT
 INX 
 DEY 
 BPL GTRKNUM4
 JSR SKIPLN

DONEXT JSR NXTDIREN
 BCC GTRKNUM
 BCS RDNXTDIR

DONEXT2 JMP NOERROR

SKIPLN LDA #$8D
 JSR COUT
 DEC CNTR
 BNE SKIPLN1
 JSR RDCHAR
 LDA #$15
 STA CNTR
SKIPLN1 RTS

 ORG $AE42

PRTDEC LDY #2
PRTDEC1 LDA #0
 PHA 
PRTDEC2 LDA OPRND
 CMP DECTBL,Y
 BCC PRTDEC3
 SBC DECTBL,Y
 STA OPRND
 LDA OPRND+1
 SBC #0
 STA OPRND+1
 PLA 
 ADC #0
 PHA 
 JMP PRTDEC2
PRTDEC3 PLA
 ORA #$B0
 JSR COUT
 DEY 
 BPL PRTDEC1
 RTS 

 ORG $AE6A

LDFMW JSR SELBUF
 LDY #0
 STY RTNCODE
LDFMW1 LDA (BUFADR),Y
 STA FTSTS,Y
 INY 
 CPY #$2D
 BNE LDFMW1
 CLC 
 RTS 

 ORG $AE7E

SAVFMW JSR SELBUF
 LDY #0
SAVFMW1 LDA FTSTS,Y
 STA (BUFADR),Y
 INY 
 CPY #$2D
 BNE SAVFMW1
 RTS 

 ORG $AE8E

INITHDL JSR INITFMW
 LDA #4

 JSR STCMDCD

 LDA VOLNUMBR
 EOR #$FF
 STA DSKVOL

 LDA #$11
 STA NXTTOALC

 LDA #$1
 STA ALLCDIR

 LDX #$38
 LDA #0
INITHDL1 STA VTOCSB,X
 INX 
 BNE INITHDL1

 LDX #$C
INITHDL2 CPX #$8C
 BEQ INITHDL4
 LDY #3
INITHDL3 LDA FREEMASK,Y
 STA BITMAP,X
 INX 
 DEY 
 BPL INITHDL3
 CPX #$44
 BNE INITHDL2
 LDX #$48
 BNE INITHDL2
INITHDL4 JSR WRTVTOC

 LDX #0
 TXA 
INITHDL5 STA DIRSECBF,X
 INX 
 BNE INITHDL5
 JSR PRWTSDIR

 LDA #$11

 LDY NUMSCTRS
 DEY 
 DEY 
 STA TNUM

INITHDL6 STA TSNXTDIR
INITHDL7 STY TSNXTDIR+1
 INY 
 STY SNUM
 LDA #2
 JSR STCMDCD
 LDY TSNXTDIR+1
 DEY 
 BMI INITHDL8
 BNE INITHDL7
 TYA
 BEQ INITHDL6
INITHDL8 JSR RWTSPRMS

 JSR PUTDOS
 JMP NOERROR

 ORG $AF08

SELBUF LDX #0
 BEQ SELDABUF1

SELTSBUF LDX #2
 BNE SELDABUF1

SLDABUF LDX #4
SELDABUF1 LDA WBADR,X
 STA BUFADR
 LDA WBADR+1,X
 STA BUFADR+1
 RTS 

 ORG $AF1D

CHKBUF BIT FLAGS
 BVS CHKBUF1
 RTS 
CHKBUF1 JSR PREPDATA
 LDA #2
 JSR RWTSDRVR
 LDA #$BF
 AND FLAGS
 STA FLAGS
 RTS 

 ORG $AF34

CHKTS LDA FLAGS
 BMI SETUPRW
 RTS 
SETUPRW JSR PREPRWTS
 LDA #2
 JSR RWTSDRVR
 LDA #$7F
 AND FLAGS
 STA FLAGS
 RTS 

 ORG $AF4B

PREPRWTS LDA TSLSTADR
 STA USRBUF
 LDA TSLSTADR+1
 STA USRBUF+1
 LDX CURTSTS
 LDY CURTSS
 RTS 

 ORG $AF5E

RDTSLST PHP

 JSR CHKTS
 JSR PREPRWTS
 JSR SELTSBUF
 PLP 
 BCS RDTSLST1

 LDX FTSTS
 LDY FTSS
 JMP OLDRWTS

RDTSLST1 LDY #$1

 LDA (BUFADR),Y
 BEQ RDTSLST2

 TAX 
 INY 
 LDA (BUFADR),Y
 TAY 
 JMP OLDRWTS

RDTSLST2 LDA FMOPCOD
 CMP #4
 BEQ RDTSLST3
 SEC 
 RTS 

RDTSLST3 JSR ALLOCSEC
 LDY #2
 STA (BUFADR),Y
 PHA 
 DEY 
 LDA SCALAREA+1
 STA (BUFADR),Y
 PHA 
 JSR SETUPRW
 JSR ZEROBUF
 LDY #5
 LDA RELSLAST
 STA (BUFADR),Y
 INY 
 LDA RELSLAST+1
 STA (BUFADR),Y
 PLA 
 TAX 
 PLA 
 TAY 
 LDA #2
 BNE OLDRWTS1

OLDRWTS LDA #$1
OLDRWTS1 STX CURTSTS
 STY CURTSS
 JSR RWTSDRVR

 LDY #5
 LDA (BUFADR),Y
 STA RELSFRST
 CLC 
 ADC SECPERTS
 STA RELSLAST
 INY 
 LDA (BUFADR),Y
 STA RELSFRST+1
 ADC SECPERTS+1
 STA RELSLAST+1
 CLC 
 RTS 

 ORG $AFDC

RDDASEC JSR PREPDATA
 LDA #$1
 JMP RWTSDRVR

PREPDATA LDY DATASADR
 LDA DATASADR+1
 STY USRBUF
 STA USRBUF+1
 LDX CURDATS
 LDY CURDAS
 RTS 

 ORG $AFF7

RWVTOC LDA #$1
 BNE WRTVTOC1
WRTVTOC LDA #2
WRTVTOC1 LDY VTOCPADR
 STY USRBUF
 LDY VTOCPADR+1
 STY USRBUF+1
 LDX TRKNUMBR
 LDY #0
 JMP RWTSDRVR

 ORG $B011

RDDIRSC PHP
 JSR PRWTSDIR
 PLP 
 BCS RDDIRSC1

 LDY FRSTTS+1
 LDX FRSTTS
 BNE RDDIRSC3
RDDIRSC1 LDX TSNXTDIR
 BNE RDDIRSC2

 SEC 
 RTS 

RDDIRSC2 LDY TSNXTDIR+1
RDDIRSC3 STX DIRTS
 STY DIRTS+1
 LDA #$1
 JSR RWTSDRVR
 CLC 
 RTS 

 ORG $B037

WRTDIRSC JSR PRWTSDIR
 LDX DIRTS
 LDY DIRTS+1
 LDA #2
 JMP RWTSDRVR

PRWTSDIR LDA DIRPADR
 STA USRBUF
 LDA DIRPADR+1
 STA USRBUF+1
 RTS 

 ORG $B052

RWTSDRVR STX TNUM
 STY SNUM
STCMDCD STA CMDCODE
 CMP #2
 BNE STCMDCD1

 ORA FLAGS
 STA FLAGS

STCMDCD1 LDA VOLNUMBR
 EOR #$FF
 STA VOLEXPT

 LDA SLOT16
 STA SNUM16
 LDA DRVNUMBR
 STA DNUM
 LDA SECTLEN
 STA BYTCNT
 LDA SECTLEN+1
 STA BYTCNT+1
 LDA #$1
 STA TBLTYPE

 LDY RWTSPADR
 LDA RWTSPADR+1
 JSR CLLRWTS

 LDA VOLFND
 STA VOLVAL
 LDA #$FF
 STA VOLEXPT

 BCS STCMDCD2
 RTS 

 ORG $B0A1

STCMDCD2 LDA ERRRCODE
 LDY #7
 CMP #$20
 BEQ STCMDCD3
 LDY #4
 CMP #$10
 BEQ STCMDCD3
 LDY #8
STCMDCD3 TYA
 JMP SETERRR

 ORG $B0B6

RDNXTDA LDA FILEPOSN
 CMP RELSLRD
 BNE RDNXTDA1
 LDA FILEPOSN+1
 CMP RELSLRD+1
 BEQ SLDBUF2

RDNXTDA1 JSR CHKBUF

RDNXTDA2 LDA FILEPOSN+1
 CMP RELSFRST+1
 BCC RDNXTDA4 ;go if <
 BNE RDNXTDA3 ;go if >
 LDA FILEPOSN
 CMP RELSFRST
 BCC RDNXTDA4

RDNXTDA3 LDA FILEPOSN+1
 CMP RELSLAST+1
 BCC FNDTS
 BNE RDNXTDA4
 LDA FILEPOSN
 CMP RELSLAST
 BCC FNDTS

RDNXTDA4 JSR RDTSLST
 BCC RDNXTDA2
 RTS

 ORG $B0F3

FNDTS SEC 
 LDA FILEPOSN
 SBC RELSFRST
 ASL 
 ADC #$C
 TAY 
 JSR SELTSBUF
 LDA (BUFADR),Y
 BNE READOLD
 LDA FMOPCOD
 CMP #4
 BEQ FNDTS1
 SEC 
 RTS 
FNDTS1 JSR ADDATA
 JMP SAVSECNM

 ORG $B114

READOLD STA CURDATS
 INY 
 LDA (BUFADR),Y
 STA CURDAS
 JSR RDDASEC

SAVSECNM LDA FILEPOSN
 STA RELSLRD
 LDA FILEPOSN+1
 STA RELSLRD+1

SLDBUF2 JSR SLDABUF
 LDY FILEPOSN+2
 CLC 
 RTS 

 ORG $B134

ADDATA STY CNTR

 JSR ALLOCSEC

 LDY CNTR
 INY 
 STA (BUFADR),Y
 STA CURDAS
 DEY 
 LDA SCALAREA+1
 STA (BUFADR),Y
 STA CURDATS

 JSR SLDABUF
 JSR ZEROBUF

 LDA #$C0
 ORA FLAGS
 STA FLAGS
 RTS 

 ORG $B15B

INCREC LDX RECNUMBR
 STX RECNUM
 LDX RECNUMBR+1
 STX RECNUM+1
 LDX BYTEOFFS
 LDY BYTEOFFS+1
 STX VOLVAL
 STY DRVVAL
 INX 
 BNE INCREC1
 INY 
INCREC1 CPY OPNRCLEN+1
 BNE INCREC2
 CPX OPNRCLEN
 BNE INCREC2
 LDX #0
 LDY #0
 INC RECNUMBR
 BNE INCREC2
 INC RECNUMBR+1
INCREC2 STX BYTEOFFS
 STY BYTEOFFS+1
 RTS 

 ORG $B194

INCPOS INC FILEPOSN+2
 BNE INCPOS1
 INC FILEPOSN
 BNE INCPOS1
 INC FILEPOSN+1
INCPOS1 RTS

 ORG $B1A2

MOVRANG LDY DATABYTE
 LDX DATABYTE+1
 STY BUFADR
 STX BUFADR+1
 INC DATABYTE
 BNE MOVRANG1
 INC DATABYTE+1
MOVRANG1 RTS

 ORG $B1B5

DECRNG LDY SLOTVAL
 BNE DECRNG1
 LDX FILETYPE
 BEQ DECRNG2
 DEC FILETYPE
DECRNG1 DEC SLOTVAL
 RTS
DECRNG2 JMP NOERROR

 ORG $B1C9

LCDIRENT JSR RWVTOC
 LDA FNADR
 STA BUFADR
 LDA FNADR+1
 STA BUFADR+1

 LDA #$1
INITDIR STA CNTR

 LDA #0
 STA DIRSECIX
 CLC 

INCSECOF INC DIRSECIX
 JSR RDDIRSC
 BCS PASS2

 LDX #0
GETRACK STX DIRINDX
 LDA TSTRACK,X
 BEQ DOPASS2
 BMI CHKPASS
 LDY #0
 INX 
 INX 

GETRACK1 INX
 LDA (BUFADR),Y
 CMP TSTRACK,X
 BNE GETRACK2
 INY 
 CPY #$1E
 BNE GETRACK1

 LDX DIRINDX
 CLC 
 RTS 

 ORG $B20B

GETRACK2 JSR NXTDIREN
 BCC GETRACK
 BCS INCSECOF
DOPASS2 LDY CNTR
 BNE INITDIR
CHKPASS LDY CNTR
 BNE GETRACK2

 ORG $B21C

COPFNAM LDY #0
 INX 
 INX 
COPFNAM1 INX
 LDA (BUFADR),Y
 STA TSTRACK,X
 INY 
 CPY #$1E
 BNE COPFNAM1
 LDX DIRINDX
 SEC 
 RTS 

 ORG $B230

NXTDIREN CLC 
 LDA DIRINDX
 ADC #$23
 TAX 
 CPX #$F5
 RTS 
PASS2 LDA #0
 LDY CNTR
 BNE INITDIR
 JMP DSKFULL

 ORG $B244

ALLOCSEC LDA SCALAREA+1
 BEQ NOTRKAVL

TSTNXT DEC SCALAREA
 BMI NOSECAVL

 CLC 
 LDX #4
TSTNXT1 ROL SCALAREA+1,X
 DEX 
 BNE TSTNXT1

 BCC TSTNXT

 INC SECCNT
 BNE TSTNXT2
 INC SECCNT+1
TSTNXT2 LDA SCALAREA
 RTS 

 ORG $B265

NOSECAVL LDA #0
 STA SCALAREA+1

NOTRKAVL LDA #0
 STA ALLCFLG
 JSR RWVTOC

ADDIRCTN CLC 
 LDA NXTTOALC
 ADC ALLCDIR
 BEQ SCNDTIME
 CMP NUMTRKS
 BCC ADIRTRK1

 LDA #$FF
 BNE ADIRTRK
SCNDTIME LDA ALLCFLG
 BNE DODSKFUL
 LDA #$1
 STA ALLCFLG

ADIRTRK STA ALLCDIR
 CLC 
 ADC #$11
ADIRTRK1 STA NXTTOALC
 STA SCALAREA+1
 TAY 
 ASL 
 ASL 
 TAY 
 LDX #4
 CLC 
ADIRTRK2 LDA BTMPEND,Y
 STA SCALAREA+1,X
 BEQ ADIRTRK3
 SEC 
 LDA #0
 STA BTMPEND,Y
ADIRTRK3 DEY
 DEX 
 BNE ADIRTRK2
 BCC ADDIRCTN

 JSR WRTVTOC
 LDA NUMSCTRS
 STA SCALAREA
 BNE TSTNXT
DODSKFUL JMP DSKFULL

 ORG $B2C3

RLSALLC LDA SCALAREA+1
 BNE RLSALLC1
 RTS 
RLSALLC1 PHA
 JSR RWVTOC
 LDY SCALAREA
 PLA 
 CLC 
 JSR RRBITMP
 LDA #0
 STA SCALAREA+1
 JMP WRTVTOC

 ORG $B2DD

RRBITMP LDX #$FC
RRBITMP1 ROR TMPBITMP,X
 INX 
 BNE RRBITMP1
 INY 
 CPY NUMSCTRS
 BNE RRBITMP
 ASL 
 ASL 
 TAY 
 BEQ RRBITMP3
 LDX #4
RRBITMP2 LDA SCALAREA+1,X
 ORA BTMPEND,Y
 STA BTMPEND,Y
 DEY 
 DEX 
 BNE RRBITMP2
RRBITMP3 RTS

 ORG $B300

CALPOSN LDA RECNUM
 STA FILEPOSN+2
 STA RECNUMBR
 LDA RECNUM+1
 STA FILEPOSN
 STA RECNUMBR+1
 LDA #0
 STA FILEPOSN+1
 LDY #$10
CALPOSN1 TAX
 LDA FILEPOSN+2
 LSR 
 BCS CALPOSN2
 TXA 
 BCC CALPOSN3
CALPOSN2 CLC
 LDA FILEPOSN+1
 ADC OPNRCLEN
 STA FILEPOSN+1
 TXA 
 ADC OPNRCLEN+1
CALPOSN3 ROR
 ROR FILEPOSN+1
 ROR FILEPOSN
 ROR FILEPOSN+2
 DEY 
 BNE CALPOSN1
 LDA VOLVAL
 STA BYTEOFFS
 ADC FILEPOSN+2
 STA FILEPOSN+2
 LDA DRVVAL
 STA BYTEOFFS+1
 ADC FILEPOSN
 STA FILEPOSN
 LDA #0
 ADC FILEPOSN+1
 STA FILEPOSN+1
 RTS 

 ORG $B35F

LNOTAVL LDA #$1
 BNE SETERRR
RANGERR LDA #2
 BNE SETERRR
RANGERR2 LDA #3
 BNE SETERRR
 LDA #4
 BNE SETERRR
ENDATA LDA #5
 BNE SETERRR
FNOTFND LDA #6
 BNE SETERRR
DSKFULL JMP DISKFULL
 NOP 
FILELOCK LDA #$A
 BNE SETERRR
NOERROR LDA RTNCODE
 CLC 
 BCC SETERRR1

 ORG $B385

SETERRR SEC
SETERRR1 PHP
 STA RTNCODE
 LDA #0
 STA IOBADR
 JSR SAVFMW
 PLP 
 LDX STKSAVE
 TXS 
 RTS 

 ORG $B397

DIRTS DS 2
 DS 2
STKSAVE DS 1
DIRINDX DS 1
CNTR DS 1
ALLCFLG DS 2
FREEMASK DS 4
DECTBL HEX 010A64
FTTBL ASC "TIABSRAB"
DISKVOL ASC " EMULOV KSID"
VTOCSB DS 1
FRSTTS DS 2
DOSRLS HEX 03
 DS 2
DSKVOL DS $21
NUMTSENT DS 9
NXTTOALC DS 1
ALLCDIR DS 3
NUMTRKS DS 1
NUMSCTRS DS 3
BITMAP DS 3
BTMPEND DS $C5
DIRSECBF DS 1
TSNXTDIR DS 10
TSTRACK DS 1
TSSECTOR DS 1
FILTYP DS $1F
FILESIZE DS $F
TMPBITMP DS $AE
PTCHSAV DS $17

FMOPCOD DS 1
SUBCODE DS 1
RECNUM DS 2
VOLVAL DS 1
DRVVAL DS 1
SLOTVAL DS 1
FILETYPE DS 1
DATABYTE = *
FNADR DS 2
RTNCODE DS 2
WBADR DS 2
TSLSTADR DS 2
DATASADR DS 2
 DS 4
FTSTS DS 1
FTSS DS 1
CURTSTS DS 1
CURTSS DS 1
FLAGS DS 1
CURDATS DS 1
CURDAS DS 1
DIRSECIX DS 2
SECPERTS DS 2
RELSFRST DS 2
RELSLAST DS 2
RELSLRD DS 2
SECTLEN DS 2
FILEPOSN DS 3
 DS 1
OPNRCLEN DS 2
RECNUMBR DS 2
BYTEOFFS DS 2
SECCNT DS 2
SCALAREA DS 1
 DS 5
FTYPE DS 1
SLOT16 DS 1
DRVNUMBR DS 1
VOLNUMBR DS 1
TRKNUMBR DS 6

 ORG $800

BOOT HEX 01
 LDA SCRATCH
 CMP #9
 BNE BOOT1
 LDA BOOTSLOT
 LSR 
 LSR 
 LSR 
 LSR 
 ORA #$C0
 STA ROMRWTS+1
 LDA #$5C
 STA ROMRWTS
 CLC 
 LDA FRSTPAG
 ADC NUMSECS
 STA FRSTPAG
BOOT1 LDX NUMSECS
 BMI BOOT2
 LDA SECTABL,X
 STA SECNUM
 DEC NUMSECS
 LDA FRSTPAG
 STA SCRATCH
 DEC FRSTPAG
 LDX BOOTSLOT
 JMP (ROMRWTS)
BOOT2 INC FRSTPAG
 INC FRSTPAG
 JSR SETKBD
 JSR SETVID
 JSR MONINIT
 LDX BOOTSLOT
 JMP (JMP2BOOT)

SECTABL HEX 000D0B0907
 HEX 0503010E0C
 HEX 0A080604
 HEX 02
 HEX 0F

APPFLG DFB 0
APDPTCH JSR LOCBUF
 BCS APDPTCH1
 LDA #0
 TAY 
 STA APPFLG
 STA (DOSIMG),Y
APDPTCH1 LDA RTNCODE
 JMP DOERROR
 LDA APPFLG
 BEQ APDPTCH2
 INC RECNUM
 BNE APDPTCH2
 INC RECNUM+1
APDPTCH2 LDA #0
 STA APPFLG
 JMP RWC2
 STA SUBCODE
 JSR FMDRVR
 JSR DOCLOSE
 JMP DOVERIFY
 LDY #$13
APDPTCH3 LDA (BUFADR),Y
 BNE APDPTCH6
 INY 
 CPY #$17
 BNE APDPTCH3
 LDY #$19
APDPTCH4 LDA (BUFADR),Y
 STA PTCHSAV,Y
 INY 
 CPY #$1D
 BNE APDPTCH4
APDPTCH5 JMP FMDRVR0
APDPTCH6 LDX #$FF
 STX APPFLG
 BNE APDPTCH5

 DS 19
 DS 24
 DS 31

JMP2BOOT DS 1
FRSTPAG HEX 36
NUMSECS HEX 09

 ORG $3600

 STX SNUM16
 STX SLOTFND
 LDA #$1
 STA DRVFND
 STA DNUM
 LDA NUMPGS
 STA NSECSRW
 LDA #2
 STA TNUM
 LDA #4
 STA SNUM
 LDY FRSTBOOT+1
 DEY 
 STY USRBUF+1
 LDA #$1
 STA CMDCODE
 TXA 
 LSR 
 LSR 
 LSR 
 LSR 
 TAX 
 LDA #0
 STA DRV1TRAK,X
 STA DRV0TRAK,X
 JSR RWPAGES
 LDX #$FF
 TXS 
 STX VOLEXPT
 JMP REBOOT
 JSR SETKBD
 JMP DOSSTRT

PUTDOS LDA FRSTBOOT+1
 SEC 
 SBC USRBUF+1
 STA NSECSRW
 LDA FRSTBOOT+1
 STA USRBUF+1
 DEC USRBUF+1
 LDA #2
 STA TNUM
 LDA #4
 STA SNUM
 LDA #2
 STA CMDCODE
 JSR RWPAGES
 LDA FRSTBOOT+1
 STA FRSTPAG
 CLC 
 ADC #9
 STA USRBUF+1
 LDA #$A
 STA NSECSRW
 SEC 
 SBC #$1
 STA NUMSECS
 STA SNUM
 JSR RWPAGES
 RTS 
 DS 6
RWPAGES LDA RWTSPPTR+1
 LDY RWTSPPTR
 JSR CLLRWTS
 LDY SNUM
 DEY 
 BPL RWPAGES1
 LDY #$F
 NOP 
 NOP 
 DEC TNUM
RWPAGES1 STY SNUM
 DEC USRBUF+1
 DEC NSECSRW
 BNE RWPAGES
 RTS 

 ORG $B7B5

CLLRWTS PHP
 SEI 
 JSR RWTSENT
 BCS CLLRWTS1
 PLP 
 CLC 
 RTS 
CLLRWTS1 PLP
 SEC 
 RTS 
RWTSPRMS LDA SUBCODE
 STA USRBUF+1
 LDA #0
 STA USRBUF
 LDA VOLNUMBR
 EOR #$FF
 STA VOLEXPT
 RTS 
ZEROBUF LDA #0
 TAY 
ZEROBUF1 STA (BUFADR),Y
 INY 
 BNE ZEROBUF1
 RTS 
 HEX 00
NUMPGS HEX 1B
NSECSRW HEX 000A1B
RWTSPPTR DA $B7E8
FRSTBOOT DA $B600
IOB = *
TBLTYPE HEX 01
SNUM16 HEX 60
DNUM HEX 01
VOLEXPT HEX FF
TNUM HEX 0C
SNUM HEX 08
 DA DVCTBL
USRBUF DA $9600
BYTCNT DA $100
CMDCODE HEX 02
ERRRCODE HEX 07
VOLFND HEX FE
SLOTFND HEX 60
DRVFND HEX 01
UNUSED HEX 000000
DVCTBL HEX 01EFD800
000000
DVCTBL HEX 01EFD800