mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
633 lines
13 KiB
Plaintext
633 lines
13 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
* PUBLIC
|
||
*--------------------------------------
|
||
S.CheckPrefixYA >STYA MLICALL.PARAMS+1
|
||
>STYA ZPQuickPtr1
|
||
lda (ZPQuickPtr1)
|
||
beq .98
|
||
tax
|
||
ldy #1
|
||
lda (ZPQuickPtr1),y
|
||
cmp #'/'
|
||
bne .98
|
||
cpx #1 "/" allowed for listing online volumes
|
||
beq .8
|
||
>MLICALL MLIGETFILEINFO
|
||
bcs .98 No, invalid path...
|
||
lda MLICALL.PARAMS+4 Check file type
|
||
cmp #$0F Directory?
|
||
bne .98
|
||
.8 clc
|
||
rts
|
||
.98 lda #SYSMGR.ERRIDIR
|
||
.99 sec
|
||
rts
|
||
*--------------------------------------
|
||
* S.FileSearch
|
||
* in :
|
||
* PULLW = PSTR to File Name (PSTRING)
|
||
* PULLW = PSTR to Search Path (PSTRING) %LIB%;/SYS/SLIB
|
||
* out :
|
||
* Y,A = PSTR to FilePath (PSTRING)
|
||
* X = hMem to FilePath
|
||
*--------------------------------------
|
||
S.FileSearch >PULLW ZPQuickPtr4 ZPQuickPtr1 trashed by ExpandPStrYA
|
||
>PULLYA Get Search list
|
||
jsr S.ExpandPStrYA Expand it
|
||
bcs .99
|
||
|
||
stx S.FileSearch.hSrch
|
||
>STYA ZPQuickPtr2 expanded search list ;
|
||
|
||
stz S.FileSearch.Index
|
||
|
||
.1 stz KrnBuffer256 reset String
|
||
ldx #0
|
||
|
||
ldy S.FileSearch.Index
|
||
|
||
.2 tya
|
||
cmp (ZPQuickPtr2) end of src string ?
|
||
beq .3 end of string, try it....
|
||
iny
|
||
lda (ZPQuickPtr2),y
|
||
cmp #';'
|
||
beq .3
|
||
inx
|
||
sta KrnBuffer256,x
|
||
bra .2
|
||
|
||
.3 txa
|
||
beq .98 String is empty....nothing to try
|
||
|
||
sty S.FileSearch.Index save current index
|
||
|
||
ldy #0
|
||
|
||
.4 iny
|
||
lda (ZPQuickPtr4),y Append Fiename...
|
||
inx
|
||
sta KrnBuffer256,x
|
||
tya
|
||
cmp (ZPQuickPtr4)
|
||
bne .4
|
||
|
||
stx KrnBuffer256 set string length
|
||
|
||
>LDYAI KrnBuffer256
|
||
jsr S.MLIGetFileInfoYA
|
||
bcs .1 Failed...retry next path...
|
||
|
||
lda S.FileSearch.hSrch Discard Expanded hSrch list
|
||
jsr S.FreeMemA
|
||
>LDYAI KrnBuffer256
|
||
jmp S.NewPStrYA
|
||
|
||
.98 lda S.FileSearch.hSrch Discard Expanded hSrch list
|
||
jsr S.FreeMemA
|
||
lda #SYSMGR.ERRFNF
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
S.FileSearch.File .BS 2
|
||
S.FileSearch.hSrch .BS 1
|
||
S.FileSearch.Index .BS 1
|
||
*--------------------------------------
|
||
* S.GetFullPathYA
|
||
* in :
|
||
* Y,A = Filename (PSTRING)
|
||
* out :
|
||
* Y,A = FullPath (PSTRING)
|
||
* X = hMem of FullPath
|
||
*--------------------------------------
|
||
S.GetFullPathYA >STYA ZPQuickPtr3 Ptr1 & 2 used by StrCpy
|
||
lda (ZPQuickPtr3)
|
||
beq .9
|
||
|
||
stz KrnBuffer256
|
||
|
||
ldy #1
|
||
lda (ZPQuickPtr3),y
|
||
cmp #'/' full path starting with '/'?
|
||
beq .1 yes, do not append to current prefix
|
||
|
||
ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
jsr S.GetMemPtrA
|
||
>PUSHYA
|
||
>PUSHWI KrnBuffer256
|
||
jsr S.PStrCpy
|
||
|
||
.1 >PUSHW ZPQuickPtr3
|
||
>PUSHWI KrnBuffer256
|
||
jsr S.PStrCat
|
||
|
||
>LDYAI KrnBuffer256
|
||
jmp S.NewPStrYA
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
* S.LoadFileYA
|
||
* in :
|
||
* Y,A = FilePath (PSTRING)
|
||
* out :
|
||
* Y,A = File Length
|
||
* X = hMem of Loaded File
|
||
*--------------------------------------
|
||
S.LoadFileYA jsr S.MLIOpenYA
|
||
bcc .10
|
||
rts
|
||
|
||
.10 sta S.LoadFile.hRef save ref_num
|
||
stx S.LoadFile.hBuf save Prodos Buffer for freemem
|
||
jsr S.MLIGetEOFA
|
||
bcs .98
|
||
|
||
phx Larger than 64k?
|
||
plx
|
||
beq .1 File too big!!!!
|
||
lda #SYSMGR.ERRFTB
|
||
bra .98
|
||
|
||
.1 >STYA S.LoadFile.Len save Length
|
||
>PUSHYA Push Length for S.GetMem
|
||
>PUSHBI 0
|
||
jsr S.GetMem
|
||
bcs .98
|
||
|
||
>STYA S.LoadFile.Mem
|
||
|
||
stx S.LoadFile.hMem save Segment hMem
|
||
>PUSHW S.LoadFile.Len Push Length for S.MLIRead
|
||
>PUSHW S.LoadFile.Mem Push PTR
|
||
>PUSHB S.LoadFile.hRef Push ref_num
|
||
jsr S.MLIRead
|
||
bcs .97
|
||
|
||
jsr .98 Close File....
|
||
|
||
>LDYA S.LoadFile.Len Return File Length...
|
||
ldx S.LoadFile.hMem ...and hMem to Caller
|
||
clc
|
||
rts
|
||
|
||
.97 pha
|
||
lda S.LoadFile.hMem
|
||
jsr S.FreeMemA freemem because of failed load
|
||
pla
|
||
|
||
.98 pha
|
||
lda S.LoadFile.hRef
|
||
jsr S.MLICloseA
|
||
lda S.LoadFile.hBuf
|
||
jsr S.FreeMemA ProDOS IO Buffer
|
||
pla
|
||
|
||
.99 sec
|
||
rts
|
||
*--------------------------------------
|
||
S.LoadFile.hRef .BS 1
|
||
S.LoadFile.hBuf .BS 1
|
||
S.LoadFile.hMem .BS 1
|
||
S.LoadFile.Mem .BS 2
|
||
S.LoadFile.Len .BS 2
|
||
*--------------------------------------
|
||
* S.ListDirInitYA
|
||
* in :
|
||
* Y,A = PSTR /DIR,/DIR/*.?s
|
||
* out :
|
||
* A = hMem of Dir Listing
|
||
*--------------------------------------
|
||
S.ListDirInitYA >STYA ZPQuickPtr3 Store path
|
||
|
||
lda (ZPQuickPtr3)
|
||
tay
|
||
ldx #0
|
||
|
||
.1 lda (ZPQuickPtr3),y reverse read path until '/' found
|
||
cmp #'/'
|
||
beq .2
|
||
inx
|
||
dey
|
||
bne .1
|
||
|
||
.2 stx TmpFileName store file pattern len in buffer
|
||
txa
|
||
beq .4 no pattern ?
|
||
|
||
lda (ZPQuickPtr3)
|
||
tay
|
||
|
||
.3 lda (ZPQuickPtr3),y
|
||
sta TmpFileName,x
|
||
dey
|
||
dex
|
||
bne .3
|
||
|
||
tya
|
||
sta (ZPQuickPtr3) remove pattern from path
|
||
|
||
.4 >PUSHWI S.LISTDIR.SIZE get LISTDIR Struct
|
||
>PUSHBI S.MEM.F.INIT0 reset all bytes
|
||
jsr S.GetMem
|
||
bcs .99
|
||
|
||
stx S.ListDirInitYA.hDir
|
||
>STYA ZPQuickPtr4 Store LISTDIR Struct
|
||
|
||
>LDYA ZPQuickPtr3
|
||
jsr S.NewPStrYA
|
||
bcs .99
|
||
|
||
txa
|
||
ldy #S.LISTDIR.hPATH
|
||
sta (ZPQuickPtr4),y
|
||
|
||
lda TmpFileName
|
||
beq .5
|
||
>LDYAI TmpFileName
|
||
jsr S.NewPStrYA
|
||
bcs .99
|
||
|
||
txa
|
||
ldy #S.LISTDIR.hPATTERN
|
||
sta (ZPQuickPtr4),y
|
||
|
||
.5 lda (ZPQuickPtr3)
|
||
cmp #1 length = 1 ? ('/')
|
||
bne .6
|
||
|
||
jsr S.ListDirInitAV
|
||
bcs .98
|
||
lda S.ListDirInitYA.hDir
|
||
rts
|
||
|
||
.6 jsr S.ListDirInitAD
|
||
bcs .98
|
||
lda S.ListDirInitYA.hDir
|
||
rts
|
||
|
||
.98 pha
|
||
lda S.ListDirInitYA.hDir Discard S.LISTDIR
|
||
jsr S.ListDirCloseA
|
||
pla
|
||
.99 sec
|
||
rts
|
||
*--------------------------------------
|
||
S.ListDirInitYA.hDir .BS 1
|
||
*--------------------------------------
|
||
S.ListDirInitAV >PUSHWI 256
|
||
>PUSHBI 0
|
||
jsr S.GetMem
|
||
bcs .99
|
||
>PUSHYA push buffer for online call
|
||
txa
|
||
sta (ZPQuickPtr4) save hONLINE buffer
|
||
>PUSHBI 0 All devices
|
||
jsr S.MLIOnline
|
||
bcs .98
|
||
ldy #S.LISTDIR.ONLINEPTR
|
||
|
||
* lda #0 make index point first Entry
|
||
* sta (ZPQuickPtr4),y
|
||
|
||
clc
|
||
rts
|
||
|
||
.98 lda (ZPQuickPtr4)
|
||
jsr S.FreeMemA
|
||
.99 sec
|
||
rts
|
||
*--------------------------------------
|
||
S.ListDirInitAD
|
||
* lda #0
|
||
* sta (ZPQuickPtr4) reset hONLINE
|
||
|
||
>LDYA ZPQuickPtr3 Open DIR
|
||
jsr S.MLIOpenYA
|
||
bcs .99
|
||
ldy #S.LISTDIR.REFNUM
|
||
sta (ZPQuickPtr4),y save ref_num
|
||
txa
|
||
ldy #S.LISTDIR.hIOBUF
|
||
sta (ZPQuickPtr4),y save ProDOS IO buffer hMem
|
||
|
||
>PUSHWI 512 get Read buffer
|
||
>PUSHBI 0
|
||
jsr S.GetMem
|
||
bcs .99
|
||
txa
|
||
ldy #S.LISTDIR.hREADBUF save Read Buffer hMem
|
||
sta (ZPQuickPtr4),y
|
||
jsr S.ListDirReadBlock
|
||
bcs .99
|
||
>STYA ZPQuickPtr1
|
||
|
||
ldy #$23 get entry_length
|
||
lda (ZPQuickPtr1),y
|
||
ldy #S.LISTDIR.EL
|
||
sta (ZPQuickPtr4),y
|
||
|
||
ldy #$24 get entry_per_block
|
||
lda (ZPQuickPtr1),y
|
||
ldy #S.LISTDIR.EPB
|
||
sta (ZPQuickPtr4),y
|
||
|
||
ldy #$25 get File_count LO
|
||
lda (ZPQuickPtr1),y
|
||
clc
|
||
adc #1 Add 1 for VOL/DIR Header
|
||
ldy #S.LISTDIR.FC
|
||
sta (ZPQuickPtr4),y
|
||
|
||
ldy #$26 get File_count HI
|
||
lda (ZPQuickPtr1),y
|
||
adc #0
|
||
ldy #S.LISTDIR.FC+1
|
||
sta (ZPQuickPtr4),y
|
||
|
||
* ldy #S.LISTDIR.FI
|
||
* lda #0
|
||
* sta (ZPQuickPtr4),y
|
||
* iny
|
||
* sta (ZPQuickPtr4),y set FI to $0000
|
||
clc
|
||
.99 rts
|
||
*--------------------------------------
|
||
* S.DirListNextA
|
||
* A = S.LISTDIR hMEM
|
||
* out :
|
||
* A = hMem To Dir Entry
|
||
*--------------------------------------
|
||
S.ListDirNextA jsr S.GetMemPtrA Get PTR to S.LISTDIR
|
||
>STYA R.CX
|
||
lda (R.CX) Online Data?
|
||
beq S.ListDirNextAD no,list files
|
||
*--------------------------------------
|
||
S.ListDirNextAV jsr S.GetMemPtrA
|
||
>STYA ZPQuickPtr1 ZPQuickPtr1 = Online DATA
|
||
.10 ldy #S.LISTDIR.ONLINEPTR
|
||
lda (R.CX),y
|
||
cmp #16
|
||
beq .9
|
||
|
||
inc
|
||
sta (R.CX),y
|
||
dec
|
||
asl
|
||
asl
|
||
asl
|
||
asl
|
||
tay
|
||
|
||
lda (ZPQuickPtr1),y
|
||
and #$0F
|
||
beq .10
|
||
|
||
sta TmpFileName
|
||
ldx #0
|
||
.1 iny
|
||
inx
|
||
lda (ZPQuickPtr1),y
|
||
sta TmpFileName,x
|
||
cpx TmpFileName
|
||
bne .1
|
||
|
||
>PUSHWI 16
|
||
>PUSHBI 0
|
||
jsr S.GetMem
|
||
bcs .9
|
||
|
||
>STYA ZPQuickPtr2
|
||
|
||
ldy #15
|
||
.2 lda TmpFileName,y
|
||
sta (ZPQuickPtr2),y
|
||
dey
|
||
bpl .2
|
||
|
||
lda (ZPQuickPtr2) Mark Record as "VOL"
|
||
ora #$C0
|
||
sta (ZPQuickPtr2)
|
||
|
||
txa Get back hMem of Volume.Name
|
||
clc
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
S.ListDirNextAD stz S.ListDirNext.hRec Reset Return Record hMem
|
||
ldy #S.LISTDIR.FI File Index = File count ?
|
||
lda (R.CX),y
|
||
ldy #S.LISTDIR.FC
|
||
cmp (R.CX),y
|
||
bne .1
|
||
ldy #S.LISTDIR.FI+1
|
||
lda (R.CX),y
|
||
ldy #S.LISTDIR.FC+1
|
||
cmp (R.CX),y
|
||
bne .1
|
||
sec yes, exit no more file
|
||
rts
|
||
*--------------------------------------
|
||
.1 ldy #S.LISTDIR.EIB Entry Index in block = Entry per block ?
|
||
lda (R.CX),y
|
||
ldy #S.LISTDIR.EPB
|
||
cmp (R.CX),y
|
||
bne .2
|
||
jsr S.ListDirReadBlock
|
||
bcc .3
|
||
rts
|
||
*--------------------------------------
|
||
.2 ldy #S.LISTDIR.hREADBUF
|
||
lda (R.CX),y
|
||
jsr S.GetMemPtrA
|
||
.3 >STYA R.AX R.AX = READ BUFFER
|
||
ldy #S.LISTDIR.BLKPTR
|
||
lda (R.CX),y
|
||
clc
|
||
adc R.AX
|
||
sta R.AX
|
||
iny
|
||
lda (R.CX),y
|
||
adc R.AX+1
|
||
sta R.AX+1
|
||
|
||
lda (R.AX) Is is a deleted file ? (storage_type=0)
|
||
and #$F0
|
||
beq .5
|
||
|
||
cmp #$F0 Volume header ?
|
||
beq .30 yes, do not filter
|
||
cmp #$E0 Directory header ?
|
||
beq .30 yes, do not filter
|
||
|
||
ldy #S.LISTDIR.hPATTERN any filter ?
|
||
lda (R.CX),y
|
||
beq .30
|
||
|
||
jsr S.GetMemPtrA
|
||
>PUSHYA push Filter PTR
|
||
|
||
lda (R.AX)
|
||
and #$0F
|
||
sta TmpFileName
|
||
tay
|
||
.31 lda (R.AX),y
|
||
sta TmpFileName,y
|
||
dey
|
||
bne .31
|
||
|
||
>PUSHWI TmpFileName push Filename PTR
|
||
jsr S.PStrMatch
|
||
bcs .5 no match
|
||
|
||
.30 ldy #S.LISTDIR.EL Get Entry length
|
||
lda (R.CX),y
|
||
tay
|
||
lda #0
|
||
>PUSHYA Get an entry_length buffer
|
||
>PUSHBI 0
|
||
jsr S.GetMem
|
||
bcs .99
|
||
>STYA R.BX R.BX = DEST RECORD
|
||
stx S.ListDirNext.hRec
|
||
|
||
ldy #S.LISTDIR.EL
|
||
lda (R.CX),y
|
||
tay
|
||
dey
|
||
.4 lda (R.AX),y
|
||
sta (R.BX),y
|
||
dey
|
||
bpl .4
|
||
|
||
.5 ldy #S.LISTDIR.EIB Set ENTRY INDEX IN BLOCK +=1
|
||
lda (R.CX),y
|
||
inc
|
||
sta (R.CX),y
|
||
|
||
ldy #S.LISTDIR.EL Set BLOCK PTR +=entry_length
|
||
lda (R.CX),y
|
||
ldy #S.LISTDIR.BLKPTR
|
||
clc
|
||
adc (R.CX),y
|
||
sta (R.CX),y
|
||
iny
|
||
lda (R.CX),y
|
||
adc #0
|
||
sta (R.CX),y
|
||
|
||
lda (R.AX)
|
||
and #$E0 is storage_type = $F or $E ?
|
||
cmp #$E0 yes, do NOT increase FI
|
||
bne .6
|
||
|
||
ldy #S.LISTDIR.FI Increase FILE INDEX
|
||
lda (R.CX),y
|
||
inc
|
||
sta (R.CX),y
|
||
bne .6
|
||
iny
|
||
lda (R.CX),y
|
||
inc
|
||
sta (R.CX),y
|
||
|
||
.6 lda S.ListDirNext.hRec
|
||
bne .8
|
||
jmp S.ListDirNextAD Nothing to return, start over for next file entry
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
.99 sec
|
||
rts
|
||
*--------------------------------------
|
||
* S.ListDirReadBlock
|
||
* In :
|
||
* CX = LISTDIR
|
||
* Out :
|
||
* Y,A = READ BUFFER
|
||
*--------------------------------------
|
||
S.ListDirReadBlock
|
||
ldy #S.LISTDIR.REFNUM
|
||
lda (R.CX),y get ref_num
|
||
sta MLICALL.PARAMS+1
|
||
ldy #S.LISTDIR.hREADBUF
|
||
lda (R.CX),y get READ BUFFER
|
||
jsr S.GetMemPtrA
|
||
>STYA MLICALL.PARAMS+2
|
||
>LDYAI 512
|
||
>STYA MLICALL.PARAMS+4
|
||
>MLICALL MLIREAD
|
||
bcs .9
|
||
ldy #S.LISTDIR.BLKPTR set BLKPTR to $0004
|
||
lda #4
|
||
sta (R.CX),y
|
||
iny
|
||
lda #0
|
||
sta (R.CX),y
|
||
ldy #S.LISTDIR.EIB set EIB to 0
|
||
sta (R.CX),y
|
||
>LDYA MLICALL.PARAMS+2
|
||
.9 rts
|
||
*--------------------------------------
|
||
S.ListDirNext.hRec .BS 1
|
||
*--------------------------------------
|
||
* S.DirListCloseA
|
||
* in :
|
||
* A = hS.LISTDIR
|
||
*--------------------------------------
|
||
S.ListDirCloseA pha
|
||
jsr S.GetMemPtrA
|
||
>STYA ZPQuickPtr1
|
||
ldy #S.LISTDIR.REFNUM
|
||
lda (ZPQuickPtr1),y
|
||
beq .1
|
||
jsr S.MLICloseA
|
||
bcs * If Close Failed, we cannot free IOBUF
|
||
|
||
.1 ldy #S.LISTDIR.hIOBUF
|
||
lda (ZPQuickPtr1),y
|
||
beq .2
|
||
jsr S.FreeMemA
|
||
|
||
.2 ldy #S.LISTDIR.hREADBUF
|
||
lda (ZPQuickPtr1),y
|
||
beq .3
|
||
jsr S.FreeMemA
|
||
|
||
.3 ldy #S.LISTDIR.hONLINE
|
||
lda (ZPQuickPtr1),y
|
||
beq .4
|
||
jsr S.FreeMemA
|
||
|
||
.4 ldy #S.LISTDIR.hPATTERN
|
||
lda (ZPQuickPtr1),y
|
||
beq .5
|
||
jsr S.FreeMemA
|
||
|
||
.5 ldy #S.LISTDIR.hPATH
|
||
lda (ZPQuickPtr1),y
|
||
beq .6
|
||
jsr S.FreeMemA
|
||
|
||
.6 pla
|
||
jsr S.FreeMemA
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
TmpFileName .BS 16
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE SYS/KERNEL.S.FIO
|
||
LOAD SYS/KERNEL.S
|
||
ASM
|