mirror of
https://github.com/A2osX/A2osX.git
synced 2024-08-15 04:29:35 +00:00
310 lines
6.3 KiB
Plaintext
310 lines
6.3 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
* PUBLIC
|
||
*--------------------------------------
|
||
K.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
|
||
*--------------------------------------
|
||
* K.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
|
||
*--------------------------------------
|
||
K.FileSearch >PULLW ZPQuickPtr4 ZPQuickPtr1 trashed by ExpandPStrYA
|
||
>PULLYA Get Search list
|
||
jsr K.ExpandPStrYA Expand it
|
||
bcs .99
|
||
|
||
stx K.FileSearch.hSrch
|
||
>STYA ZPQuickPtr2 expanded search list ;
|
||
|
||
stz K.FileSearch.Index
|
||
|
||
.1 stz KrnBuffer256 reset String
|
||
ldx #0
|
||
|
||
ldy K.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 K.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 K.MLIGetFileInfoYA
|
||
bcs .1 Failed...retry next path...
|
||
|
||
lda K.FileSearch.hSrch Discard Expanded hSrch list
|
||
jsr K.FreeMemA
|
||
>LDYAI KrnBuffer256
|
||
jmp K.NewPStrYA
|
||
|
||
.98 lda K.FileSearch.hSrch Discard Expanded hSrch list
|
||
jsr K.FreeMemA
|
||
lda #SYSMGR.ERRFNF
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
K.FileSearch.File .BS 2
|
||
K.FileSearch.hSrch .BS 1
|
||
K.FileSearch.Index .BS 1
|
||
*--------------------------------------
|
||
* K.GetFullPathYA
|
||
* in :
|
||
* Y,A = Filename (PSTRING)
|
||
* out :
|
||
* Y,A = FullPath (PSTRING)
|
||
* X = hMem of FullPath
|
||
*--------------------------------------
|
||
K.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 K.GetMemPtrA
|
||
>PUSHYA
|
||
>PUSHWI KrnBuffer256
|
||
jsr K.PStrCpy
|
||
|
||
.1 >PUSHW ZPQuickPtr3
|
||
>PUSHWI KrnBuffer256
|
||
jsr K.PStrCat
|
||
|
||
>LDYAI KrnBuffer256
|
||
jmp K.NewPStrYA
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
* K.LoadFile
|
||
* in :
|
||
* PULLW = PATH (Handled by....
|
||
* PULLB = MODE ...
|
||
* PULLB = TYPE ...
|
||
* PULLW = AUXTYPE ...FOPEN)
|
||
* out :
|
||
* Y,A = File Length
|
||
* X = hMem of Loaded File
|
||
*--------------------------------------
|
||
K.LoadFile >DEBUG
|
||
jsr K.FOPEN
|
||
bcs .9
|
||
|
||
sta K.LoadFile.hFile
|
||
|
||
ldx #SYS.FSEEK.END
|
||
jsr K.LoadFile.Seek
|
||
bcs .99
|
||
|
||
lda K.LoadFile.hFile
|
||
jsr K.FTELLA
|
||
bcs .99
|
||
>STYA K.LoadFile.Len
|
||
phx
|
||
plx
|
||
bne .98 LEN > 65535 !!???
|
||
|
||
>PUSHYA push len
|
||
>PUSHBI 0
|
||
jsr K.GetMem
|
||
bcs .99
|
||
>STYA K.LoadFile.Mem
|
||
stx K.LoadFile.hMem
|
||
|
||
ldx #SYS.FSEEK.SET
|
||
jsr K.LoadFile.Seek
|
||
bcs .99
|
||
|
||
>PUSHW K.LoadFile.Mem
|
||
>PUSHW K.LoadFile.Len
|
||
>PUSHB K.LoadFile.hFile
|
||
jsr K.FREAD
|
||
bcs .99
|
||
|
||
jsr .99
|
||
|
||
>LDYA K.LoadFile.Len
|
||
ldx K.LoadFile.hMem
|
||
clc
|
||
.9 rts
|
||
|
||
.98 lda #SYSMGR.ERRFTB
|
||
|
||
.99 pha
|
||
lda K.LoadFile.hFile
|
||
jsr K.FCLOSEA
|
||
pla
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
K.LoadFile.Seek >PUSHWI 0
|
||
>PUSHWI 0
|
||
txa
|
||
>PUSHA
|
||
>PUSHB K.LoadFile.hFile
|
||
jmp K.FSEEK
|
||
*--------------------------------------
|
||
* K.LoadFileYA
|
||
* in :
|
||
* Y,A = FilePath (PSTRING)
|
||
* out :
|
||
* Y,A = File Length
|
||
* X = hMem of Loaded File
|
||
*--------------------------------------
|
||
K.LoadFileYA jsr K.MLIOpenYA
|
||
bcc .10
|
||
rts
|
||
|
||
.10 sta K.LoadFile.hRef save ref_num
|
||
stx K.LoadFile.hBuf save Prodos Buffer for freemem
|
||
jsr K.MLIGetEOFA
|
||
bcs .98
|
||
|
||
phx Larger than 64k?
|
||
plx
|
||
beq .1 File too big!!!!
|
||
lda #SYSMGR.ERRFTB
|
||
bra .98
|
||
|
||
.1 >STYA K.LoadFile.Len save Length
|
||
>PUSHYA Push Length for K.GetMem
|
||
>PUSHBI 0
|
||
jsr K.GetMem
|
||
bcs .98
|
||
|
||
>STYA K.LoadFile.Mem
|
||
|
||
stx K.LoadFile.hMem save Segment hMem
|
||
>PUSHW K.LoadFile.Len Push Length for K.MLIRead
|
||
>PUSHW K.LoadFile.Mem Push PTR
|
||
>PUSHB K.LoadFile.hRef Push ref_num
|
||
jsr K.MLIRead
|
||
bcs .97
|
||
|
||
jsr .98 Close File....
|
||
|
||
>LDYA K.LoadFile.Len Return File Length...
|
||
ldx K.LoadFile.hMem ...and hMem to Caller
|
||
clc
|
||
rts
|
||
|
||
.97 pha
|
||
lda K.LoadFile.hMem
|
||
jsr K.FreeMemA freemem because of failed load
|
||
pla
|
||
|
||
.98 pha
|
||
lda K.LoadFile.hRef
|
||
jsr K.MLICloseA
|
||
lda K.LoadFile.hBuf
|
||
jsr K.FreeMemA ProDOS IO Buffer
|
||
pla
|
||
|
||
.99 sec
|
||
rts
|
||
*--------------------------------------
|
||
* PULLW = SrcPtr
|
||
* PULLW = SrcLen
|
||
* PULLW = PATH (Handled by....
|
||
* PULLB = MODE ...
|
||
* PULLB = TYPE ...
|
||
* PULLW = AUXTYPE ...FOPEN)
|
||
*--------------------------------------
|
||
K.SaveFile >PULLW K.LoadFile.Mem
|
||
>PULLW K.LoadFile.Len
|
||
|
||
jsr K.FOPEN
|
||
bcs .9
|
||
|
||
sta K.LoadFile.hFile
|
||
|
||
>PUSHW K.LoadFile.Mem
|
||
|
||
>PUSHW K.LoadFile.Len
|
||
|
||
>PUSHB K.LoadFile.hFile
|
||
jsr K.FWRITE
|
||
bcs .99
|
||
|
||
jsr .99
|
||
clc
|
||
rts
|
||
|
||
.99 pha
|
||
lda K.LoadFile.hFile
|
||
jsr K.FCLOSEA
|
||
pla
|
||
sec
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
K.LoadFile.Filename .BS 2
|
||
K.LoadFile.hFile .BS 1
|
||
K.LoadFile.hMem .BS 1
|
||
K.LoadFile.Mem .BS 2
|
||
K.LoadFile.Len .BS 2
|
||
K.LoadFile.hRef .BS 1
|
||
K.LoadFile.hBuf .BS 1
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE SYS/KERNEL.S.FIO
|
||
LOAD SYS/KERNEL.S
|
||
ASM
|