Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-10-29 15:47:25 +01:00
parent 62350fcd0a
commit d0e3005880
8 changed files with 183 additions and 487 deletions

Binary file not shown.

Binary file not shown.

View File

@ -186,8 +186,9 @@ CS.RUN.PRINT.DEV
jsr EnterSubDirYA
bcs .9
jmp CS.RUN.ENTER.MSG
.8 clc.9
rts
.8 clc
.9 rts
*--------------------------------------
CS.RUN.PRINT.DIR
>LDA.G bAllmostAll

View File

@ -102,9 +102,6 @@ CS.RUN >INC.G ArgIndex
.5 >LDA.G hSrcBasePath
bne .9
>LDYA ZPPtr1
>SYSCALL puts
>DEBUG
>LDYA ZPPtr1
jsr InitSrcDirYA
bcc CS.RUN
@ -115,7 +112,7 @@ CS.RUN >INC.G ArgIndex
>LDA.G hSrcBasePath
beq .9
>LDYAI 256
>SYSCALL getmem
bcs .99
@ -186,6 +183,9 @@ CS.RUN.LOOP ldy #S.PS.hStdIn
jsr GetEntry
bcs .9
jsr FilterMatch
bcs .8 no match, skip....
ldy #S.STAT.P.DRIVE
lda (ZPFileStat),y ProDOS Device ?
beq .5
@ -230,7 +230,7 @@ CS.RUN.DIR lda bRecurse
cmp #'.'
beq .8
jsr CS.RUN.GetFilePath
jsr CS.RUN.BuildFilePath
>PUSHW ZPRelPath
@ -250,10 +250,7 @@ CS.RUN.DIR lda bRecurse
.8 clc
rts
*--------------------------------------
CS.RUN.FILE jsr FilterMatch
bcs .8 no match, skip....
jsr CS.RUN.GetFilePath
CS.RUN.FILE jsr CS.RUN.BuildFilePath
>PUSHW ZPFullPath
>LDA.G hArcFile
@ -326,7 +323,7 @@ CS.RUN.CheckErr bcs .1
sec
rts
*--------------------------------------
CS.RUN.GetFilePath
CS.RUN.BuildFilePath
>LDA.G hSrcBasePath
>SYSCALL GetMemPtr
>PUSHYA
@ -338,10 +335,7 @@ CS.RUN.GetFilePath
>PUSHW ZPFileName
>LDYA ZPFullPath
>SYSCALL StrCat
>LDYA ZPFullPath
>SYSCALL puts
>DEBUG
rts
*--------------------------------------
CS.RUN.OpenFile >PUSHWZ Aux type

View File

@ -11,25 +11,29 @@ NEW
.INB INC/PAK.I
.INB INC/LIBPAK.I
.INB INC/MLI.E.I
*--------------------------------------
CHUNK.MAX .EQ 32
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPPtr1 .BS 2
ZPPtr2 .BS 2
ZPFileName .BS 2
ZPFileStat .BS 2
ZPFullPath .BS 2
ZPRelPath .BS 2
ZPSrcBufPtr .BS 2
ZPDstBufPtr .BS 2
bAppend .BS 1
bRecurse .BS 1
ZPSrcFileSize .BS 2
ZPDstTableOfs .BS 2
ZPChunkIndex .BS 1
ZPChunkCnt .BS 1
hSrcFile .BS 1
hDstFile .BS 1
bPause .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
@ -53,12 +57,12 @@ CS.START cld
.DA CS.QUIT
L.LIBPAK .DA LIBPAK
L.MSG.USAGE .DA MSG.USAGE
L.MSG.DIR .DA MSG.DIR
L.MSG.FILE .DA MSG.FILE
L.MSG.SRCFILE .DA MSG.SRCFILE
L.MSG.CHUNK .DA MSG.CHUNK
L.MSG.OK .DA MSG.OK
L.MSG.ERR .DA MSG.ERR
L.MSG.E.IARC .DA MSG.E.IARC
L.ARC.Header .DA ARC.Header
L.TAG .DA TAG
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBPAK
@ -69,17 +73,27 @@ CS.INIT >LDYA L.LIBPAK
.9 rts
*--------------------------------------
CS.RUN >INC.G ArgIndex
CS.RUN ldy #S.PS.ARGC
lda (pPs),y
cmp #2
bne .9
jsr CS.RUN.CheckSrcFile
bcs .99
>PUSHW.G STATBUF+S.STAT.P.AUXTYPE
>PUSHB.G STATBUF+S.STAT.P.TYPE
>PUSHBI O.CREATE+O.WRONLY
lda #2
>SYSCALL ArgV
bcs .8
>STYA ZPPtr1
>SYSCALL FOpen
bcs .99
lda (ZPPtr1)
cmp #'-'
bne .4
sta hDstFile
jsr CS.RUN.CheckOpt
bcc CS.RUN
bra CS.RUN.START
.9 >PUSHBI 0
>LDYA L.MSG.USAGE
@ -88,82 +102,31 @@ CS.RUN >INC.G ArgIndex
sec
.99 rts
*--------------------------------------
.4 >LDA.G ArcName
bne .5
CS.RUN.START >PUSHB.G PAKME.HEADER+7
>PUSHW ZPSrcFileSize
>PUSHW.G PAKME.HEADER+5
lda #1
>SYSCALL ArgV
>PUSHYA
>PUSHBI 7
>LDYA L.MSG.SRCFILE
>SYSCALL printf
>LDA.G ArgIndex
>STA.G ArcName
bra CS.RUN
.5 >LDA.G hSrcBasePath
bne .9
>LDYA ZPPtr1
jsr InitSrcDirYA
bcc CS.RUN
rts
.8 >LDA.G ArcName
beq .9
>LDA.G hSrcBasePath
beq .9
>LDYAI 256
>SYSCALL getmem
bcs .99
>STYA ZPFullPath
txa
>STA.G hSrcFullPath
>LDA.G hSrcBasePath
>SYSCALL GetMemPtr
>STYA ZPPtr1
ldy #$ff
.80 iny
lda (ZPPtr1),y
bne .80
tya
clc
adc ZPFullPath
sta ZPRelPath
lda ZPFullPath+1
adc #0
sta ZPRelPath+1
jsr CS.RUN.OpenArc
.98 bcs .99
>LDYAI CHNK.SIZE
>SYSCALL getmem
bcs .99
>STYA ZPSrcBufPtr
txa
>STA.G hSrcBuf
>LDYAI CHNK.SIZE
>SYSCALL getmem
bcs .98
>STYA ZPDstBufPtr
txa
>STA.G hDstBuf
*--------------------------------------
CS.RUN.LOOP ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL feof
bcs .99
bcs .9
tay
bne .1
>SYSCALL GetChar
bcs .99
bcs .9
cmp #$03 Ctrl-C
beq .99 Abort....
beq .9 Abort....
cmp #$13 Ctrl-S
bne .1
@ -176,382 +139,158 @@ CS.RUN.LOOP ldy #S.PS.hStdIn
.1 lda bPause
bne CS.RUN.LOOP Pause...
*--------------------------------------
jsr GetEntry
bcs .9
.7 inc ZPChunkIndex
ldy #S.STAT.P.DRIVE
lda (ZPFileStat),y ProDOS Device ?
beq .5
jsr CS.RUN.DEV
bcc CS.RUN.LOOP
rts
.5 ldy #S.STAT.P.TYPE
lda (ZPFileStat),y
cmp #$0F Directory ?
bne .6
jsr CS.RUN.DIR
bcs .99
bra .8
.6 jsr CS.RUN.FILE
bcs .99
bra .8
.9 jsr LeaveSubDir
bcs .90
jsr BasePath..
.8 jsr GetNextEntry
jmp CS.RUN.LOOP
.90 lda #0
sec
.99 rts
*--------------------------------------
CS.RUN.DEV lda #E.BADPATH
sec
rts
*--------------------------------------
CS.RUN.DIR lda bRecurse
bpl .8
lda (ZPFileName)
cmp #'.'
beq .8
jsr CS.RUN.GetFilePath
>PUSHW ZPRelPath
>PUSHBI 2
>LDYA L.MSG.DIR
>SYSCALL printf
bcs .9
jsr CS.RUN.WriteArcHdrDir
bcs .9
>LDYA ZPFileName
jsr EnterSubDirYA
.9 jmp CS.RUN.CheckErr
.8 clc
rts
*--------------------------------------
CS.RUN.FILE jsr FilterMatch
bcs .8 no match, skip....
jsr CS.RUN.GetFilePath
>PUSHW ZPFullPath
>LDA.G hArcFile
lda ZPChunkIndex
asl
clc
adc #PAKME.TABLE
tay
lda OF.Table.hPath-1,y
>SYSCALL getmemptr
>SYSCALL strcmp
bcc .8
>PUSHW ZPRelPath
lda (pData),y
pha
iny
lda (pData),y
ply
>PUSHBI 2
>LDYA L.MSG.FILE
>SYSCALL printf
bcs .9
jsr CS.RUN.WriteArcHdrFile
bcs .9
jsr CS.RUN.OpenFile
bcs .9
.1 lda #'.'
>SYSCALL putchar
jsr CS.RUN.ReadFile
bcc .2
cmp #MLI.E.EOF
bne .4
jsr CS.RUN.CloseFile
bra .9
.2 jsr CS.RUN.Pak
bcs .3
jsr CS.RUN.WritePakData
bcc .1
bra .4
.3 jsr CS.RUN.WriteSrcData
bcc .1
.4 pha
jsr CS.RUN.CloseFile
pla
sec
.9 jmp CS.RUN.CheckErr
.8 clc
rts
*--------------------------------------
CS.RUN.CheckErr bcs .1
>LDYA L.MSG.OK
>SYSCALL puts
rts
.1 pha
>PUSHA
>PUSHBI 1
>LDYA L.MSG.ERR
>SYSCALL printf
pla
sec
rts
*--------------------------------------
CS.RUN.GetFilePath
>LDA.G hSrcBasePath
>SYSCALL GetMemPtr
>PUSHYA
lda ZPChunkIndex
>PUSHA
>PUSHBI 3
>LDYA L.MSG.CHUNK
>SYSCALL printf
>LDYA ZPFullPath
dec ZPChunkCnt
bne CS.RUN.LOOP
>SYSCALL StrCpy
>PUSHW ZPFileName
>LDYA ZPFullPath
>SYSCALL StrCat
rts
.8 lda #0
sec
.9 rts
*--------------------------------------
CS.RUN.OpenFile >PUSHWZ Aux type
CS.RUN.CheckSrcFile
>PUSHWZ Aux type
>PUSHBI 0 Type
>PUSHBI O.RDONLY
>LDYA ZPFullPath
>SYSCALL FOpen
bcs .9
>STA.G hFile
.9 rts
*--------------------------------------
CS.RUN.ReadFile >PUSHWI CHNK.SIZE
>PUSHW ZPSrcBufPtr
>LDA.G hFile
>SYSCALL fread
bcs .9
>STYA.G Shunk.SrcSize
.9 rts
*--------------------------------------
CS.RUN.CloseFile
>LDA.G hFile
>SYSCALL fclose
bcs .9
>STZ.G hFile
.9 rts
*--------------------------------------
CS.RUN.Pak >PUSHEA.G PAKSTAT
>PUSHW ZPDstBufPtr
>PUSHW.G Shunk.SrcSize
>PUSHW ZPSrcBufPtr
>LIBCALL hLIB,LIBPAK.Pak
bcs .9
>STYA.G Shunk.DstSize
.9 rts
*--------------------------------------
CS.RUN.OpenArc >PUSHWZ Aux type
>PUSHBI $CF PAK
bit bAppend
bmi .1
>PUSHBI O.CREATE+O.WRONLY
>LDA.G ArcName
>SYSCALL Argv
>SYSCALL FOpen
bcs .9
>STA.G hArcFile
>PUSHW L.ARC.Header
>LDA.G hArcFile
>SYSCALL fputs
.9 rts
*--------------------------------------
.1 >PUSHBI O.RDWR
>LDA.G ArcName
>SYSCALL Argv
lda #1
>SYSCALL ArgV
>SYSCALL FOpen
bcs .9
>STA.G hArcFile
bcs .99
pha
>PUSHWI 3
>PUSHW ZPSrcBufPtr
pla
>SYSCALL fread
bcs .9
sta hSrcFile
cpy #3
bne .99
>PUSHEA.G STATBUF
lda hSrcFile
>SYSCALL fstat
.99 bcs .9
>LDA.G STATBUF+S.STAT.SIZE+3
dey
.2 lda ARC.Header,y
cmp (ZPSrcBufPtr),y
bne .99
ora (pData),y
bne .90
dey
bpl .2
lda (pData),y
sta ZPSrcFileSize+1
dey
lda (pData),y
sta ZPSrcFileSize
jsr CS.RUN.CheckTAG
bcs .9
jsr CS.RUN.GetTable
bcs .9
>PUSHBI SEEK.END
>PUSHWI 0
>PUSHWI 0
>LDA.G hArcFile
>SYSCALL fseek
bcc .8
cmp #MLI.E.EOF
bne .99
clc
.8 rts
.99 >LDYA L.MSG.E.IARC
>SYSCALL puts
lda #E.SYN
rts
.90 lda #MLI.E.INCFF
sec
rts
.9
CS.RUN.CheckSrcFile.RTS
rts
*--------------------------------------
CS.RUN.WriteArcHdrDir
lda #CHNK.T.DIR
jsr CS.RUN.WriteArcByteA
bcc CS.RUN.WriteArcHdr
CS.RUN.CheckTAG >PUSHBI SEEK.SET
>PUSHWZ
lda ZPSrcFileSize
sec
sbc #10
tay
lda ZPSrcFileSize+1
sbc #0
>PUSHYA
lda hSrcFile
>SYSCALL fseek
bcs CS.RUN.CheckSrcFile.RTS
>PUSHWI 10
>PUSHEA.G PAKME.HEADER
lda hSrcFile
>SYSCALL fread
bcs CS.RUN.CheckSrcFile.RTS
ldx #4
ldy #PAKME.HEADER+4
.1 lda TAG,x
cmp (pData),y
bne .90
dey
dex
bpl .1
clc
rts
CS.RUN.WriteArcHdrFile
lda #CHNK.T.FILE
jsr CS.RUN.WriteArcByteA
bcs CS.RUN.WriteArcHdr.9
ldy #S.STAT.P.TYPE
jsr CS.RUN.WriteArcByteY
bcs CS.RUN.WriteArcHdr.9
ldy #S.STAT.P.AUXTYPE
jsr CS.RUN.WriteArcByteY
bcs CS.RUN.WriteArcHdr.9
ldy #S.STAT.P.AUXTYPE+1
jsr CS.RUN.WriteArcByteY
bcs CS.RUN.WriteArcHdr.9
CS.RUN.WriteArcHdr
ldy #$ff
.1 iny
lda (ZPRelPath),y
bne .1
tya
jsr CS.RUN.WriteArcByteA
bcs CS.RUN.WriteArcHdr.9
>PUSHW ZPRelPath
>LDA.G hArcFile
>SYSCALL fputs
CS.RUN.WriteArcHdr.9
rts
*--------------------------------------
CS.RUN.WriteSrcData
lda #CHNK.T.DATA
jsr CS.RUN.WriteArcByteA
bcs .9
>PUSHW.G Shunk.SrcSize
>PUSHBI 2
>LDYA L.MSG.DBG
>SYSCALL printf
>LDA.G Shunk.SrcSize
jsr CS.RUN.WriteArcByteA
bcs .9
>LDA.G Shunk.SrcSize+1
jsr CS.RUN.WriteArcByteA
bcs .9
lda #0 NO COMPRESSION
jsr CS.RUN.WriteArcByteA
bcs .9
>PUSHW.G Shunk.SrcSize
>PUSHW ZPSrcBufPtr
>LDA.G hArcFile
>SYSCALL fwrite
.90 lda #MLI.E.INCFF
sec
.9 rts
*--------------------------------------
CS.RUN.WritePakData
lda #CHNK.T.DATA
jsr CS.RUN.WriteArcByteA
CS.RUN.GetTable >PUSHBI SEEK.SET
>PUSHWZ
>LDA.G PAKME.HEADER+8
sec
>SBC.G PAKME.HEADER+5
sta ZPDstTableOfs+1
pha
>LDA.G PAKME.HEADER+9
>SBC.G PAKME.HEADER+6
sta ZPDstTableOfs
ply
>PUSHYA
lda hSrcFile
>SYSCALL fseek
bcs .9
* >PUSHW.G Shunk.DstSize
* >PUSHBI 2
* >LDYA L.MSG.DBG
* >SYSCALL printf
>LDA.G PAKME.HEADER+7
sta ZPChunkCnt
>LDA.G Shunk.DstSize
jsr CS.RUN.WriteArcByteA
bcs .9
asl
tay
lda #0
>PUSHYA
>LDA.G Shunk.DstSize+1
jsr CS.RUN.WriteArcByteA
bcs .9
>PUSHEA.G PAKME.TABLE
lda hSrcFile
>SYSCALL fread
>PUSHW.G Shunk.DstSize
>PUSHW ZPDstBufPtr
>LDA.G hArcFile
>SYSCALL fwrite
.9 rts
*--------------------------------------
CS.RUN.WriteArcByteY
lda (ZPFileStat),y
CS.RUN.WriteArcByteA
>PUSHA
>LDA.G hArcFile
>SYSCALL fputc
rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT jsr LeaveSubDir
bcc CS.QUIT
>LDA.G hFilter
beq .1
>SYSCALL FreeMem
.1 >LDA.G hSrcFullPath
CS.QUIT lda hDstFile
beq .2
>SYSCALL FreeMem
>SYSCALL fclose
.2 >LDA.G hArcFile
.2 lda hSrcFile
beq .3
>SYSCALL fclose
@ -571,39 +310,15 @@ CS.QUIT jsr LeaveSubDir
.8 clc
rts
*--------------------------------------
CS.RUN.CheckOpt ldy #1
lda (ZPPtr1),y
ldx #OptionVars-OptionList-1
.2 cmp OptionList,x
beq .3
dex
bpl .2
sec
rts
.3 ldy OptionVars,x
lda #$ff
sta 0,y
clc
rts
*--------------------------------------
.INB USR/SRC/BIN/X.FILEENUM.S
*--------------------------------------
CS.END
*--------------------------------------
OptionList .AS "AaRr"
OptionVars .DA #bAppend,#bAppend,#bRecurse,#bRecurse
*--------------------------------------
MSG.USAGE .AZ "Usage : PAKME SourceBIN PackedBIN\r\n"
MSG.SRCFILE .AZ "Source File : %s, Org=$%H Size=%D, %d Chunks.\r\n"
MSG.CHUNK .AZ " Chunk #%02d : Ofs=%D\r\n"
MSG.OK .AZ "[OK]"
MSG.ERR .AZ "[%h]\r\n"
MSG.E.IARC .AZ "Invalid/corrupt archive"
MSG.DIR .AZ "Reading Dir:%s..."
MSG.FILE .AZ "Adding File:%s..."
ARC.Header .AZ "PAKME"
TAG .AZ "PAKME"
*--------------------------------------
LIBPAK .AZ "libpak"
hLIB .BS 1
@ -611,19 +326,15 @@ hLIB .BS 1
.DUMMY
.OR 0
DS.START
ArgIndex .BS 1
ArcName .BS 1
hSrcFullPath .BS 1
hFile .BS 1
hArcFile .BS 1
hSrcBuf .BS 1
hDstBuf .BS 1
Shunk.SrcSize .BS 2
Shunk.DstSize .BS 2
STATBUF .BS S.STAT
PAKME.HEADER .BS 10
PAKME.TABLE .BS CHUNK.MAX*2
PAKSTAT .BS S.PAKSTAT
DS.END .ED
*--------------------------------------

View File

@ -17,13 +17,6 @@ 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
@ -38,8 +31,6 @@ FilterMatch >LDA.G index
>LDYA ZPPtr2 CI compare
>SYSCALL strupr
* jsr DEBUG.HERE
.10 lda (ZPPtr2) Get first pattern byte
beq .8 Match always if empty
@ -74,7 +65,6 @@ FilterMatch >LDA.G index
.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
cmp #'*' another '*' ?
beq .5 yes, '**' = '*', go next char
cmp #'?' '*?' ? we must match a least one char

View File

@ -87,6 +87,7 @@ IO.OPEN.REG >MLICALL MLIGETFILEINFO
bcc IO.OPEN.REG.E Already Exists
bit IO.Open.FLAGS Create if not exists ?
bpl IO.OPEN.RTS No, return MLI error
ldx #2 Yes, Create...
.1 lda IO.Open.TYPE,x
sta K.MLI.PARAMS+4,x File type,Aux type

View File

@ -25,7 +25,6 @@ NEW
PAKME.Table .DA A2osX.MAIN
.DA A2osX.AUX
.DA A2osX.GP
* .DA A2osX.GPX
.DA A2osX.D1
.DA A2osX.D2
.DA A2osX.E0
@ -111,10 +110,10 @@ DevMgr.FreeMem .EQ *
.EP
A2osX.E0.E .EQ *
*--------------------------------------
.AS "PAKME"
* .DA #7
.DA #7
.DA PAKME.Table-$2000
.AS "PAKME" TAG
.DA $2000 BIN ORG
.DA #6 Chunk Count
.DA PAKME.Table Chunks
*--------------------------------------
.INB USR/SRC/SYS/KERNEL.S.CTRL
MAN