Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-10-12 16:20:09 +02:00
parent 8d9f861997
commit 8c1d3887f1
9 changed files with 216 additions and 95 deletions

Binary file not shown.

Binary file not shown.

View File

@ -201,7 +201,7 @@ CORE.Run.7 jsr CORE.GetCharNB
ora #S.PS.F.CLOSEONX ...and close PIPE on exit
sta CORE.PSFlags
bra CORE.ExecCmd.1 Do not skip |
CORE.Run.RTS rts
CORE.Run.RTS rts
*--------------------------------------
* Input : ZPArgVBuf
*--------------------------------------
@ -217,10 +217,13 @@ CORE.ExecCmd.1 lda #0
asl
tax
jmp (J.CMD,x)
CORE.ExecExtCmd >PUSHB CORE.PSFlags
>LDYA ZPArgVBuf
>SYSCALL execv
bcs .9
tax CPID
lda CORE.PSFlags
and #S.PS.F.HOLD

View File

@ -4,10 +4,14 @@ NEW
*--------------------------------------
X.COPY.BUF.SIZE .EQ 4096
*--------------------------------------
ZPPtr1 .EQ ZPBIN
ZPPtr2 .EQ ZPBIN+2
ZPFileName .EQ ZPBIN+4
ZPFileStat .EQ ZPBIN+6
.DUMMY
.OR ZPBIN
ZS.START
ZPPtr1 .BS 2
ZPPtr2 .BS 2
ZPFileName .BS 2
ZPFileStat .BS 2
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
@ -19,7 +23,7 @@ CS.START cld
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #64 SS
.DA #8 ZP
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
@ -44,6 +48,7 @@ CS.INIT
.1 >INC.G ArgCount
>SYSCALL ArgV
bcs .7
>STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
@ -63,10 +68,12 @@ CS.INIT
lda #E.SYN
sec
rts
.3 ldy OptionVars-1,x
lda #$80
sta (pData),y
bra .1
.4 >LDA.G index
.DO X.COPY.TO.DEST=1
@ -74,7 +81,7 @@ CS.INIT
.ELSE
bne .99
.FIN
>LDYA ZPPtr1
jsr InitSrcDirYA
bcc .1 success, scan for any other args
@ -95,7 +102,7 @@ CS.INIT
.DO X.COPY.TO.DEST=1
>LDA.G hDstBasePath
bne .8 we also have a Dst folder
ldy #S.PS.hCWD no dst folder, use actual prefix
ldy #S.PS.hCWD no dst folder, use actual prefix
lda (pPs),y
>SYSCALL GetMemPtr
jsr InitDstDirYA
@ -107,7 +114,7 @@ CS.INIT
bcs .9
txa
>STA.G hSrcFullPath
sta (pData),y
.DO X.COPY.TO.DEST=1
>LDYAI 256
>SYSCALL getmem
@ -125,43 +132,47 @@ CS.RUN ldy #S.PS.hStdIn
bcs CS.INIT.RTS I/O error
tay
bne .15
>SYSCALL GetChar
bcs CS.INIT.RTS I/O error
cmp #$03 Ctrl-C
bne .10
sec
rts Abort....
.10 cmp #$13 Ctrl-S
bne .15
ldy #bPause
lda (pData),y
>LDA.G bPause
eor #$ff
sta (pData),y
.15 ldy #bPause
lda (pData),y
.15 >LDA.G bPause
bpl .1
.8 clc
rts
*--------------------------------------
.1 .DO X.COPY.TO.DEST=1
ldy #bCopy
lda (pData),y
>LDA.G bCopy
beq .2
jsr CS.RUN.Copy
ldy #bCopy Copy completed ?
lda (pData),y
>LDA.G bCopy Copy completed ?
bne .8 no.....exit
clc
ldy #CopyRC
lda (pData),y
>LDA.G CopyRC
.DO X.DELETE.SOURCE=0
beq .20 no copy error
sec
jsr CS.RUN.CheckErr we have an error....
bcs .9
jmp CS.RUN.NEXT
.20 jsr CS.RUN.CheckErr Success!!
jsr CS.RUN.IncCount
jmp CS.RUN.NEXT
@ -178,9 +189,9 @@ CS.RUN ldy #S.PS.hStdIn
.FIN
.2 .DO X.DELETE.SOURCE=1
ldy #hToDelete
lda (pData),y
>LDA.G hToDelete
beq .3
lda #0
sta (pData),y
@ -199,6 +210,7 @@ CS.RUN ldy #S.PS.hStdIn
.3 jsr GetEntry
bcs CS.RUN.LEAVE
jsr FilterMatch
bcs CS.RUN.NEXT no match, skip....
.4 ldy #S.STAT.P.DRIVE
lda (ZPFileStat),y ProDOS Device ?
@ -326,14 +338,16 @@ CS.RUN.FILE jsr CS.RUN.FILE.MSG
>PUSHW L.STAT
ldy #hDstFullPath
jsr CS.RUN.GetPathY
>SYSCALL Stat
bcs .2 File Not exists...go create
ldy #bNoConfirm
lda (pData),y
bmi .2 no prompt, ovverwrite
jsr CS.RUN.OVERWRITE.MSG
bcs .9
.1 >SLEEP
>SYSCALL GetChar
bcs .1
@ -476,25 +490,26 @@ CS.RUN.CopyStart
>STA.G hSrcFile
ldy #hDstFullPath
lda #O.WRONLY+O.CREATE
jsr CS.RUN.Open
bcs .9
ldy #hDstFile
sta (pData),y
ldy #bCopy
>STA.G hDstFile
lda #$ff
sta (pData),y
>STA.G bCopy
inc
ldy #CopyRC Reset RC
sta (pData),y
>LDA.G CopyRC Reset RC
clc
rts
.9 pha
>LDA.G hSrcFile
>SYSCALL fclose
pla
.99 ldy #CopyRC
sta (pData),y
.99 >LDA.G CopyRC
sec
rts
*--------------------------------------
@ -637,6 +652,7 @@ CS.DOEVENT sec
*--------------------------------------
CS.QUIT jsr LeaveSubDir
bcc CS.QUIT
.DO X.COPY.TO.DEST=1
>LDA.G bCopy
bpl .1
@ -644,22 +660,27 @@ CS.QUIT jsr LeaveSubDir
>SYSCALL fclose
>LDA.G hDstFile
>SYSCALL fclose
.1 ldy #hDstFullPath
jsr .7
ldy #hDstFilename
jsr .7
.FIN
ldy #hSrcFullPath
jsr .7
ldy #hFilter
.7 lda (pData),y
beq .9
>SYSCALL FreeMem
.9 clc
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/X.CPMVRM.S
LOAD USR/SRC/BIN/RM.S
LOAD USR/SRC/BIN/CP.S
ASM

View File

@ -17,6 +17,13 @@ X.MAX.RECURSE .EQ 8
* CC : match
* CS : no match
*--------------------------------------
*DEBUG.HERE >LDYA ZPFileName
* >SYSCALL puts
* >LDYA ZPPtr2
* >SYSCALL puts
* >DEBUG
* rts
FilterMatch >LDA.G index
dec
bne .8 in a subdir, match everything
@ -27,33 +34,36 @@ FilterMatch >LDA.G index
ldy #S.STAT.FSID
lda (ZPFileStat),y
bne .10 not prodos...
>LDYA ZPPtr2 CI compare
>SYSCALL strupr
.10 lda (ZPPtr2) Get pattern 1st byte
* jsr DEBUG.HERE
.10 lda (ZPPtr2) Get first pattern byte
beq .8 Match always if empty
ldy #0
bra .2
bra .21
.1 inc ZPPtr2 Make PTR2 (pattern) advance to next char
bne .2
inc ZPPtr2+1
.2 lda (ZPPtr2) get pattern char
.1 jsr FilterMatch.NextPtr2 get next pattern char
beq .41 end of pattern...
.21 cmp #'*'
.2 cmp #'*'
beq .5
.3 lda (ZPFileName) we must match ? or regular char, check if at end of string
.3 lda (ZPFileName),y we must match ? or regular char, check if at end of string
beq .9 no char left, exit with error
lda (ZPPtr2) get back pattern char
cmp #'?'
beq .4 no need to compare, any char will match
cmp (ZPFileName),y Regular Char, compare with string at Y
bne .9 no match, exit
.4 iny advance to next char to compare bra .1 continue if remaining char in pattern
.4 iny advance to next char to compare
bra .1 continue if remaining char in pattern
.41 lda (ZPFileName),y end of pattern, but end of string ?
beq .8 yes, string matched entirely
@ -61,10 +71,7 @@ FilterMatch >LDA.G index
.9 sec
rts
.5 inc ZPPtr2 Make PTR2 advance to next char
bne .6
inc ZPPtr2+1
.6 lda (ZPPtr2) we have '*', last char of pattern ?
.5 jsr FilterMatch.NextPtr2 we have '*', last char of pattern ?
beq .8 yes, match everything, including empty string
lda (ZPPtr2) get next char of pattern
@ -84,13 +91,22 @@ FilterMatch >LDA.G index
iny
bra .1 go check remaining char in pattern...
.8 clc
.8 clc
FilterMatch.RTS
rts
*--------------------------------------
InitSrcDirYA >SYSCALL RealPath
bcc .10
FilterMatch.NextPtr2
inc ZPPtr2 Make PTR2 advance to next char
bne .1
inc ZPPtr2+1
.1 lda (ZPPtr2)
rts
.10 >STYA ZPPtr1
*--------------------------------------
InitSrcDirYA >SYSCALL RealPath
bcs FilterMatch.RTS
>STYA ZPPtr1
txa
>STA.G hFullPath
@ -107,36 +123,42 @@ InitSrcDirYA >SYSCALL RealPath
>LDA.G STAT+S.STAT.P.TYPE
cmp #S.FI.T.DIR
bne .4 TYPE not a DIR, extract....
bra .5 TYPE=DIR, do not extract pattern .ELSE
bra .5 TYPE=DIR, do not extract pattern
.ELSE
bra .4
.FIN
.1 ldy #0 TYPE is not DIR, check if wc
.11 iny
lda (ZPPtr1),y Get Src Path Len
bne .11
.1 jsr GetPtr1Len TYPE is not DIR, check if wc
dey
ldx #0 Init Wildcard count
.2 lda (ZPPtr1),y search backward for a /
cmp #'/'
beq .3
cmp #'?' Test if some wildcard chars....
beq .21
cmp #'*'
bne .22
.21 inx inc wildcard count
.22 dey
bne .2
.3 txa
beq .91 no wc, file not found....
.4 ldy #0
.41 iny Search end of string.....
lda (ZPPtr1),y
bne .41
.4 jsr GetPtr1Len Search end of string.....
lda #'/'
.42 dey
cmp (ZPPtr1),y Search backward /
bne .42
tya
sec +1 to skip '/'
adc ZPPtr1
@ -145,6 +167,7 @@ InitSrcDirYA >SYSCALL RealPath
lda ZPPtr1+1
adc #0
sta ZPPtr2+1
>SYSCALL strdup
bcs .9
txa
@ -152,6 +175,7 @@ InitSrcDirYA >SYSCALL RealPath
lda #0
sta (ZPPtr2)
.5 >LDYAI 256
>SYSCALL GetMem Get a 256 buffer to store BasePath
bcs .9
@ -159,11 +183,8 @@ InitSrcDirYA >SYSCALL RealPath
txa
>STA.G hSrcBasePath
ldy #$ff
.6 iny
lda (ZPPtr1),y
sta (ZPPtr2),y
bne .6
jsr StrcpyPtr1ptr2
dey
lda #'/'
cmp (ZPPtr2),y
@ -174,9 +195,11 @@ InitSrcDirYA >SYSCALL RealPath
iny
lda #0
sta (ZPPtr2),y
.7 >LDYA ZPPtr2
>SYSCALL OpenDir
bcs .9
ldy #hDIRs
sta (pData),y set hDIRs[0] = Src Hdir
ldy #index
@ -185,6 +208,7 @@ InitSrcDirYA >SYSCALL RealPath
jsr .9 Cleanup
clc
rts
.91 lda #MLI.E.FNOTFND
.9 pha
@ -206,18 +230,19 @@ InitDstDirYA >SYSCALL RealPath
>LDYA ZPPtr1
>SYSCALL Stat
bcs .1 File/DIR does not exists, go extract DstFileName
>LDA.G STAT+S.STAT.P.TYPE
cmp #S.FI.T.DIR
beq .5 Dst is a directory...no destfilename
.1 ldy #0
.11 iny Search end of string.....
lda (ZPPtr1),y
bne .11
.1 jsr GetPtr1Len Search end of string.....
lda #'/'
.2 dey
cmp (ZPPtr1),y Search backward /
bne .2
tya
sec +1 to skip '/'
adc ZPPtr1
@ -234,22 +259,23 @@ InitDstDirYA >SYSCALL RealPath
lda #0
sta (ZPPtr2)
.5 >LDYAI 256
>SYSCALL GetMem Get a 256 buffer to store DstBasePath
bcs .9
>STYA ZPPtr2
txa
>STA.G hDstBasePath
ldy #$ff
.6 iny
lda (ZPPtr1),y
sta (ZPPtr2),y
bne .6
jsr StrcpyPtr1ptr2
dey
lda #'/'
cmp (ZPPtr2),y
beq .7
iny
sta (ZPPtr2),y
iny
@ -420,10 +446,8 @@ EnterSubDirY lda (pData),y
>LDYA ZPPtr1
>SYSCALL StrCat
.1 ldy #0
.2 iny
lda (ZPPtr1),y
bne .2
.1 jsr GetPtr1Len
dey
lda #'/'
cmp (ZPPtr1),y
@ -474,24 +498,41 @@ BasePath.. .DO X.COPY.TO.DEST=1
jsr BasePath..1
.FIN
ldy #hSrcBasePath
BasePath..1 lda (pData),y
>SYSCALL GetMemPtr
>STYA ZPPtr1 save full path
ldy #$ff
.1 iny
lda (ZPPtr1),y get len
bne .1
jsr GetPtr1Len get len
dey discard ending /
.2 dey
lda (ZPPtr1),y
cmp #'/'
bne .2
iny
lda #0
sta (ZPPtr1),y cut DIR2/ from /dir1/DIR2/
rts
*--------------------------------------
GetPtr1Len ldy #$ff
.1 iny
lda (ZPPtr1),y get len
bne .1
rts
*--------------------------------------
StrcpyPtr1ptr2 ldy #$ff
.1 iny
lda (ZPPtr1),y
sta (ZPPtr2),y
bne .1
rts
*--------------------------------------
GetFilenameLen ldy #$ff
.1 iny

View File

@ -312,6 +312,13 @@ Pak.ComputeLenBits
bra .14
.15 stx Pak.Rep.LenBits
txa
asl
asl
asl
asl
asl
sta Pak.Shnk+S.PAKSHNK.TOPCNT
ldx #8
lda Pak.BL.Longest
@ -408,7 +415,9 @@ Pak.BuildTOPTable
cpy #TOP.MAX
bne .1
.8 sty Pak.Shnk+S.PAKSHNK.TOPCNT
.8 tya
ora Pak.Shnk+S.PAKSHNK.TOPCNT
sta Pak.Shnk+S.PAKSHNK.TOPCNT
rts
*--------------------------------------

View File

@ -49,8 +49,10 @@ K.ExpandStr stz ENV.hMem Reset Intermediate string...
ror ENV.bExp Toggle Expanded flag
lda (ZPPtr1)
bne .30
lda #'$' End of string, output $
bra .22
.30 stz ENV.VarEndChar
cmp #'{' "${VAR]"?
bne .31
@ -59,25 +61,31 @@ K.ExpandStr stz ENV.hMem Reset Intermediate string...
jsr SHARED.NextCharPtr1 skip "{"
bra .40
.31 jsr ZP.IsDigit $0 ... $9 ?
bcs .32
and #$0f
jsr K.ArgV
bcs .35 Arg# is undefined, do not append anything
jsr ENV.AddYAToBuf
bra .35
.32 ldx #ENV.SysVars.Cnt-1
.33 cmp ENV.SysVars,x
beq .34
dex
bpl .33
bra .40
.34 jsr ENV.SysVar
.35 jsr SHARED.NextCharPtr1 skip $x
bra .10
.40 jsr ENV.ExpandStrVar
bcc .70
.50 jsr ENV.FindVarP1
@ -96,21 +104,24 @@ K.ExpandStr stz ENV.hMem Reset Intermediate string...
lda ENV.VarEndChar
beq .10
jsr SHARED.NextCharPtr1 skip "}"
.73 jmp .10
bra .35 skip "}" and loop
.80 lda ENV.hMem working from our temp string ?
beq .81 no...
jsr K.FreeMem yes, discard....
.81 ldx ENV.BufLen
stz K.Buf256,x
>LDYAI K.Buf256
jsr K.strdup
bcs K.FileSearch.RTS
stx ENV.hMem save this as temp string, in case of recurse
bit ENV.bExp SELF MODIFIED Did we expand something ?
bit ENV.bExp Did we expand something ?
bpl K.FileSearch.RTS No, exit with Y,A from STRDUP
jmp .1 Yes, start over with hPStr
jmp .1 Yes, start over with ENV.hMem
*/--------------------------------------
* # FileSearch
* Search a file in the provided PATH list

View File

@ -400,20 +400,27 @@ PS.Load.HEADER .AZ "#!/"
* Buf256+IOBUF(?)+PS.ArgV[1,...] -> #S.PS.hARGV
*--------------------------------------
PS.AddArgV ldy #$ff In both cases, remove ARGV[0]
.60 iny
lda (PS.ArgV),y
bne .60
tya
sec
adc PS.ArgV
sta PS.ArgV
bcc .70
inc PS.ArgV+1 Skip old ARGV[0] = scriptename
.70 >LDYAI K.Buf256
jsr K.strlen
>STYA PS.ArgSize
lda K.IOBuf is there a /BIN/SHELL ?
beq .10
>LDYAI K.IOBuf
jsr K.strlen
jsr PS.AddYAp12ArgSize
@ -421,32 +428,44 @@ PS.AddArgV ldy #$ff In both cases, remove ARGV[0]
.10 ldx #0 For now, 0 args...
lda K.IOBuf
beq .11 +1 for scriptpath
inx
.11 >LDYA PS.ArgV
>STYA ZPPtr1
.1 lda (ZPPtr1)
beq .4
inx
ldy #0
.2 iny
lda (ZPPtr1),y
bne .2
* lda #0
jsr PS.AddYAp12ArgSize
.3 jsr SHARED.AddYp1ToPtr1
jsr SHARED.AddYp1ToPtr1
bra .1
.4 txa
ldy #S.PS.ARGC
sta (PS.NewPSPtr),y
>LDYA PS.ArgSize Add 1 for ending 0
iny
bne .5
inc
.5 jsr K.GetMem
bcs PS.AddPtr1ToStrVUntil0.RTS
.5 iny Add ONE MORE ?????!!!!
bne .51
inc
.51 jsr K.GetMem
bcs .9
>STYA ZPPtr2 Target Buffer
txa
ldy #S.PS.hARGV
@ -456,28 +475,32 @@ PS.AddArgV ldy #$ff In both cases, remove ARGV[0]
jsr PS.AddYAToStrV
lda K.IOBuf
beq .6
>LDYAI K.IOBuf
jsr PS.AddYAToStrV
.6 >LDYA PS.ArgV
>STYA ZPPtr1
*--------------------------------------
PS.AddPtr1ToStrVUntil0
.1 lda (ZPPtr1)
.7 lda (ZPPtr1)
sta (ZPPtr2)
beq .8 Ending \0
jsr PS.AddPtr1ToStrV
bra .1
bra .7
.8 clc
PS.AddPtr1ToStrVUntil0.RTS
rts
.9 rts
*--------------------------------------
PS.AddYAToStrV >STYA ZPPtr1
PS.AddPtr1ToStrV
ldy #$ff
.2 iny
lda (ZPPtr1),y
sta (ZPPtr2),y
bne .2
jsr SHARED.AddYp1ToPtr1
jmp SHARED.AddYp1ToPtr2
*--------------------------------------

View File

@ -84,32 +84,45 @@ K.StrCpy clc
*\--------------------------------------
K.StrDup >STYA .1+1
>STYA .4+1
lda #0
tay
.1 ldx $ffff,y
beq .2
iny
bne .1
inc
inc .1+2
bne .1
.2 iny Add one for ending 0
bne .3
inc
.3 jsr K.GetMem
bcs K.StrDup.RTS
>STYA .5+1
phy
pha
ldy #0
.4 lda $ffff,y
.4 lda $ffff,y
.5 sta $ffff,y
beq K.StrDup.8
iny
bne .4
inc .4+2
inc .5+2
bne .4
K.StrDup.8 pla
ply
clc