2015-03-14 21:48:35 +00:00
|
|
|
|
PR#3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
PREFIX /A2OSX.SRC
|
2017-03-15 16:44:15 +00:00
|
|
|
|
LOMEM $A00
|
2015-03-14 21:48:35 +00:00
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
2016-10-26 20:51:06 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* #FileSearch
|
2016-11-01 14:37:28 +00:00
|
|
|
|
* Search a file in the provided PATH list
|
|
|
|
|
* And return, if found, the full path to it.
|
2016-10-26 20:51:06 +00:00
|
|
|
|
* ##In:
|
2016-10-29 19:58:21 +00:00
|
|
|
|
* PUSHW = Ptr to Search Path (PSTR) %LIB%;/SYS/SLIB
|
|
|
|
|
* PUSHW = Ptr to File Name (PSTR)
|
2016-11-01 14:37:28 +00:00
|
|
|
|
* ##Out:
|
|
|
|
|
* CC : success
|
|
|
|
|
* Y,A = PSTR to FilePath (PSTR)
|
|
|
|
|
* X = hMem to FilePath
|
|
|
|
|
* CS : not found
|
2016-10-26 20:51:06 +00:00
|
|
|
|
*\--------------------------------------
|
2017-01-12 17:43:45 +00:00
|
|
|
|
K.FileSearch >PULLW ZPPtr4 ZPPtr1 trashed by ExpandPStrYA
|
2016-08-17 06:25:58 +00:00
|
|
|
|
>PULLYA Get Search list
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL ExpandPStrYA Expand it (SYSCALL to BNK1)
|
2016-10-07 06:09:25 +00:00
|
|
|
|
bcs .99
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-07 06:09:25 +00:00
|
|
|
|
stx K.FileSearch.hSrch
|
2017-01-12 17:43:45 +00:00
|
|
|
|
>STYA ZPPtr3 ZPPtr2 trashed by K.STAT !!! expanded search list ;
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2016-09-21 15:20:37 +00:00
|
|
|
|
stz K.FileSearch.Index
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-09-26 06:18:51 +00:00
|
|
|
|
.1 stz KrnBuf256 reset String
|
2016-08-17 06:25:58 +00:00
|
|
|
|
ldx #0
|
2016-06-07 06:10:18 +00:00
|
|
|
|
|
2016-09-21 15:20:37 +00:00
|
|
|
|
ldy K.FileSearch.Index
|
2016-06-07 06:10:18 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
.2 tya
|
2017-01-12 17:43:45 +00:00
|
|
|
|
cmp (ZPPtr3) end of src string ?
|
2016-08-17 06:25:58 +00:00
|
|
|
|
beq .3 end of string, try it....
|
|
|
|
|
iny
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr3),y
|
2016-08-17 06:25:58 +00:00
|
|
|
|
cmp #';'
|
2016-10-07 06:09:25 +00:00
|
|
|
|
beq .3
|
2016-08-17 06:25:58 +00:00
|
|
|
|
inx
|
2016-09-26 06:18:51 +00:00
|
|
|
|
sta KrnBuf256,x
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bra .2
|
2016-10-06 15:50:20 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
.3 txa
|
|
|
|
|
beq .98 String is empty....nothing to try
|
|
|
|
|
|
2016-09-21 15:20:37 +00:00
|
|
|
|
sty K.FileSearch.Index save current index
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
ldy #0
|
2016-06-07 06:10:18 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
.4 iny
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr4),y Append Fiename...
|
2016-08-17 06:25:58 +00:00
|
|
|
|
inx
|
2016-09-26 06:18:51 +00:00
|
|
|
|
sta KrnBuf256,x
|
2016-08-17 06:25:58 +00:00
|
|
|
|
tya
|
2017-01-12 17:43:45 +00:00
|
|
|
|
cmp (ZPPtr4)
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bne .4
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2016-09-26 16:00:52 +00:00
|
|
|
|
stx KrnBuf256 set string length
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2016-09-26 16:00:52 +00:00
|
|
|
|
>PUSHWI KrnSTAT
|
|
|
|
|
>PUSHWI KrnBuf256
|
|
|
|
|
jsr K.STAT
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bcs .1 Failed...retry next path...
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2016-09-21 15:20:37 +00:00
|
|
|
|
lda K.FileSearch.hSrch Discard Expanded hSrch list
|
|
|
|
|
jsr K.FreeMemA
|
2016-10-06 15:50:20 +00:00
|
|
|
|
|
2016-10-21 15:03:41 +00:00
|
|
|
|
bra K.GetFullPathYA.NewStr
|
2016-10-07 06:09:25 +00:00
|
|
|
|
|
|
|
|
|
.98 lda K.FileSearch.hSrch Discard Expanded hSrch list
|
|
|
|
|
jsr K.FreeMemA
|
|
|
|
|
lda #SYSMGR.ERRFNF
|
|
|
|
|
sec
|
2016-10-21 15:03:41 +00:00
|
|
|
|
.99 rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
K.FileSearch.hSrch .BS 1
|
|
|
|
|
K.FileSearch.Index .BS 1
|
2016-10-26 20:51:06 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* #GetFullPathYA
|
|
|
|
|
* ##In :
|
2016-10-29 19:58:21 +00:00
|
|
|
|
* Y,A = Filename (PSTR)
|
2016-11-01 14:37:28 +00:00
|
|
|
|
* ##Out :
|
|
|
|
|
* CC : success
|
|
|
|
|
* Y,A = FullPath (PSTR)
|
|
|
|
|
* X = hMem of FullPath
|
|
|
|
|
* CS : A = Error Code
|
2016-10-26 20:51:06 +00:00
|
|
|
|
*\--------------------------------------
|
2017-01-12 17:43:45 +00:00
|
|
|
|
K.GetFullPathYA >STYA ZPPtr3 Ptr1 & 2 used by StrCpy
|
|
|
|
|
lda (ZPPtr3)
|
2016-10-21 15:03:41 +00:00
|
|
|
|
beq K.GetFullPathYA.9
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-09-26 06:18:51 +00:00
|
|
|
|
stz KrnBuf256
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
|
|
|
|
ldy #1
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda (ZPPtr3),y
|
2016-08-17 06:25:58 +00:00
|
|
|
|
cmp #'/' full path starting with '/'?
|
|
|
|
|
beq .1 yes, do not append to current prefix
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hPREFIX
|
|
|
|
|
lda (pPs),y
|
2016-09-21 15:20:37 +00:00
|
|
|
|
jsr K.GetMemPtrA
|
2016-08-17 06:25:58 +00:00
|
|
|
|
>PUSHYA
|
2016-09-26 06:18:51 +00:00
|
|
|
|
>PUSHWI KrnBuf256
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL PStrCpy
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
.1 >PUSHW ZPPtr3
|
2016-09-26 06:18:51 +00:00
|
|
|
|
>PUSHWI KrnBuf256
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL PStrCat
|
2016-10-21 15:03:41 +00:00
|
|
|
|
K.GetFullPathYA.NewStr
|
2016-09-26 06:18:51 +00:00
|
|
|
|
>LDYAI KrnBuf256
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL NewPStrYA
|
2016-10-06 15:50:20 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2016-10-21 15:03:41 +00:00
|
|
|
|
K.GetFullPathYA.9
|
|
|
|
|
sec
|
2016-08-17 06:25:58 +00:00
|
|
|
|
rts
|
2016-10-26 20:51:06 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* #LoadFile
|
|
|
|
|
* ##In:
|
|
|
|
|
* PUSHW = AUXTYPE (Handled by....
|
|
|
|
|
* PUSHB = TYPE ...
|
|
|
|
|
* PUSHB = MODE ...
|
2017-01-12 17:43:45 +00:00
|
|
|
|
* PUSHW = PATH ...FOpen)
|
2016-10-26 20:51:06 +00:00
|
|
|
|
* ##Out:
|
|
|
|
|
* Y,A = File Length
|
|
|
|
|
* X = hMem of Loaded File
|
|
|
|
|
*\--------------------------------------
|
2017-01-12 17:43:45 +00:00
|
|
|
|
K.LoadFile jsr K.FOpen
|
2016-09-20 16:00:51 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2016-09-21 15:20:37 +00:00
|
|
|
|
sta K.LoadFile.hFile
|
2016-09-20 16:00:51 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
ldx #SYS.FSeek.END
|
2016-09-21 15:20:37 +00:00
|
|
|
|
jsr K.LoadFile.Seek
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
lda K.LoadFile.hFile
|
2017-01-12 17:43:45 +00:00
|
|
|
|
jsr K.FTellA
|
2016-09-21 15:20:37 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
>STYA K.LoadFile.Len
|
|
|
|
|
phx
|
|
|
|
|
plx
|
|
|
|
|
bne .98 LEN > 65535 !!???
|
2016-09-20 16:00:51 +00:00
|
|
|
|
|
2016-09-21 15:20:37 +00:00
|
|
|
|
>PUSHYA push len
|
|
|
|
|
>PUSHBI 0
|
|
|
|
|
jsr K.GetMem
|
|
|
|
|
bcs .99
|
|
|
|
|
>STYA K.LoadFile.Mem
|
|
|
|
|
stx K.LoadFile.hMem
|
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
ldx #SYS.FSeek.SET
|
2016-09-21 15:20:37 +00:00
|
|
|
|
jsr K.LoadFile.Seek
|
2016-09-30 15:04:55 +00:00
|
|
|
|
bcs .97
|
2016-09-20 16:00:51 +00:00
|
|
|
|
|
2016-09-21 15:20:37 +00:00
|
|
|
|
>PUSHW K.LoadFile.Mem
|
|
|
|
|
>PUSHW K.LoadFile.Len
|
|
|
|
|
>PUSHB K.LoadFile.hFile
|
2017-01-12 17:43:45 +00:00
|
|
|
|
jsr K.FRead
|
2016-09-30 15:04:55 +00:00
|
|
|
|
bcs .97
|
2016-09-20 16:00:51 +00:00
|
|
|
|
|
|
|
|
|
jsr .99
|
2016-09-21 15:20:37 +00:00
|
|
|
|
|
|
|
|
|
>LDYA K.LoadFile.Len
|
|
|
|
|
ldx K.LoadFile.hMem
|
2016-09-20 16:00:51 +00:00
|
|
|
|
clc
|
2016-09-21 15:20:37 +00:00
|
|
|
|
.9 rts
|
2016-09-30 15:04:55 +00:00
|
|
|
|
|
|
|
|
|
.97 pha
|
|
|
|
|
lda K.LoadFile.hMem
|
|
|
|
|
jsr K.FreeMemA
|
|
|
|
|
pla
|
|
|
|
|
.HS 2C
|
2016-09-20 16:00:51 +00:00
|
|
|
|
|
2016-09-21 15:20:37 +00:00
|
|
|
|
.98 lda #SYSMGR.ERRFTB
|
|
|
|
|
|
2016-09-20 16:00:51 +00:00
|
|
|
|
.99 pha
|
2016-09-21 15:20:37 +00:00
|
|
|
|
lda K.LoadFile.hFile
|
2016-10-29 19:58:21 +00:00
|
|
|
|
jsr K.FCloseA
|
2016-09-20 16:00:51 +00:00
|
|
|
|
pla
|
|
|
|
|
sec
|
2016-09-21 15:20:37 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.LoadFile.Seek >PUSHWI 0
|
|
|
|
|
>PUSHWI 0
|
|
|
|
|
txa
|
|
|
|
|
>PUSHA
|
|
|
|
|
>PUSHB K.LoadFile.hFile
|
2017-01-12 17:43:45 +00:00
|
|
|
|
jmp K.FSeek
|
2016-10-26 20:51:06 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* #SaveFile
|
|
|
|
|
* ##In:
|
|
|
|
|
* PUSHW = SrcLen
|
|
|
|
|
* PUSHW = SrcPtr
|
|
|
|
|
* PUSHW = AUXTYPE (Handled by....
|
|
|
|
|
* PUSHB = TYPE ...
|
|
|
|
|
* PUSHB = MODE ...
|
2017-01-12 17:43:45 +00:00
|
|
|
|
* PUSHW = PATH ...FOpen)
|
2016-10-26 20:51:06 +00:00
|
|
|
|
*\--------------------------------------
|
2017-01-12 17:43:45 +00:00
|
|
|
|
K.SaveFile jsr K.FOpen
|
2016-09-20 16:00:51 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2016-09-21 15:20:37 +00:00
|
|
|
|
sta K.LoadFile.hFile
|
2016-09-20 16:00:51 +00:00
|
|
|
|
|
2016-09-21 15:20:37 +00:00
|
|
|
|
>PUSHB K.LoadFile.hFile
|
2017-01-12 17:43:45 +00:00
|
|
|
|
jsr K.FWrite
|
2016-09-20 16:00:51 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
jsr .99
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.99 pha
|
2016-09-21 15:20:37 +00:00
|
|
|
|
lda K.LoadFile.hFile
|
2016-10-29 19:58:21 +00:00
|
|
|
|
jsr K.FCloseA
|
2016-09-20 16:00:51 +00:00
|
|
|
|
pla
|
|
|
|
|
sec
|
2016-10-21 15:03:41 +00:00
|
|
|
|
rts
|
2016-09-20 16:00:51 +00:00
|
|
|
|
|
2016-10-21 15:03:41 +00:00
|
|
|
|
|
|
|
|
|
.9 >POP 4 Discard SrcPtr & SrcLen
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2016-09-20 16:00:51 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-21 15:20:37 +00:00
|
|
|
|
K.LoadFile.hFile .BS 1
|
|
|
|
|
K.LoadFile.hMem .BS 1
|
|
|
|
|
K.LoadFile.Mem .BS 2
|
|
|
|
|
K.LoadFile.Len .BS 2
|
2016-01-09 22:40:19 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
MAN
|
2015-11-22 22:30:06 +00:00
|
|
|
|
SAVE SYS/KERNEL.S.FIO
|
2015-03-14 21:48:35 +00:00
|
|
|
|
LOAD SYS/KERNEL.S
|
|
|
|
|
ASM
|