Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-10-14 07:23:09 +02:00
parent 273b1e514d
commit 5b653c3e4b
8 changed files with 174 additions and 238 deletions

Binary file not shown.

View File

@ -287,7 +287,7 @@ CS.RUN.FILE jsr FilterMatch
bra .9
.2 jsr CS.RUN.Pak
>DEBUG
* >DEBUG
jsr CS.RUN.WriteArcData
bcc .1

View File

@ -24,7 +24,9 @@ ZPOutBufPtr .BS 2
ZPULen .BS 2
ZPnCnt .BS 2
ZPInMask .BS 1
ZPOutLastByte .BS 1
ZPBLOfsLBits .BS 1
ZPBLOfsHBits .BS 1
ZPBLLenBits .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
@ -53,7 +55,6 @@ L.MSG.OK .DA MSG.OK
L.MSG.ERR .DA MSG.ERR
L.MSG.E.IARC .DA MSG.E.IARC
L.MSG.E.OFS .DA MSG.E.OFS
L.MSG.DEBUG .DA MSG.DEBUG
.DA 0
*--------------------------------------
CS.INIT clc
@ -148,6 +149,7 @@ CS.RUN.LOOP jsr CS.RUN.GetByte
bra CS.RUN.LOOP
clc
.99 rts
.9 jmp CS.RUN.E.IARC
.1 cmp #CHNK.T.FILE
bne .9
@ -167,18 +169,21 @@ CS.RUN.LOOP jsr CS.RUN.GetByte
bcs .8 eof
.2 cmp #CHNK.T.DATA
bne .3 Could be a 0 byte file
.20 jsr CS.RUN.GetByte ALG
bcs .9
cmp #0 STORE
bne .9
jsr CS.RUN.GetByte ULEN LO
.20 jsr CS.RUN.GetByte ULEN LO
bcs .9
sta ZPULen
jsr CS.RUN.GetByte ULEN HI
bcs .9
sta ZPULen+1
jsr CS.RUN.GetByte ALG
bcs .9
>DEBUG
cmp #0 STORE
bne .9
jsr CS.RUN.ReadData
bcs .9
jsr CS.RUN.WriteFile
@ -280,12 +285,14 @@ CS.RUN.CheckDir >PUSHEA.G STAT
>SYSCALL mkdir
rts
.1 ldy #STAT+S.STAT.P.TYPE
lda (pData),y
cmp #$F
bne .99
clc
rts
.99 lda #MLI.E.INVPATH
sec
.9 rts
@ -312,15 +319,20 @@ CS.DOEVENT sec
CS.QUIT >LDA.G hFile
beq .1
>SYSCALL fclose
.1 >LDA.G hFullPath
beq .2
>SYSCALL FreeMem
.2 >LDA.G hOutBuf
beq .3
>SYSCALL FreeMem
.3 >LDA.G hInBuf
beq .4
>SYSCALL FreeMem
.4 >LDA.G hArcFile
beq .8
>SYSCALL fclose
@ -339,15 +351,6 @@ MSG.ERR .AZ "[%h]\r\n"
MSG.E.IARC .AZ "Invalid/corrupt archive"
MSG.E.OFS .AZ "UnPak Error at Offset : %L\r\n"
MSG.PAK .AS "PAK"
*--------------------------------------
MSG.DEBUG .AS "Src Length : %D\r\n"
.AS "Pass #1 : %D\r\n"
.AS "Pass #2 : %D\r\n"
.AS "BL Count : %D\r\n"
.AS "REP Count : %D\r\n"
.AS "S3 Count : %D\r\n"
.AS "S4 Count : %D\r\n"
.AZ "STO Count : %D\r\n"
*--------------------------------------
.DUMMY
.OR 0

View File

@ -259,6 +259,7 @@ OPEN lda #S.DIB.S.OPENED
lda #1
sta L91C96.BSR,x
lda #L91C96.1.CR.NOWAIT
sta L91C96.1.CR,x
lda /L91C96.1.CR.NOWAIT
@ -467,16 +468,16 @@ WRITE php
lda (ZPIOCTL),y
sta ZPBufPtr+1
* ldy #S.ETH.SRCMAC+5 Add Src MAC Address
* ldx #5
ldy #S.ETH.SRCMAC+5 Add Src MAC Address
ldx #5
*.4 lda S.DCB.NIC.MAC,x
* sta (ZPBufPtr),y
* dey
* dex
* bpl .4
.4 lda S.DCB.NIC.MAC,x
sta (ZPBufPtr),y
dey
dex
bpl .4
* ldx DEVSLOTx0
ldx DEVSLOTx0
stz L91C96.2.DATA,x write fake status word
stz L91C96.2.DATA,x

View File

@ -3,9 +3,8 @@ NEW
.LIST OFF
*--------------------------------------
TOP.MAX .EQ 32
REP.MAX .EQ 1+254
BL.MIN .EQ 3
BL.MAX .EQ 3+63
BL.MAX .EQ BL.MIN+31
*--------------------------------------
PAK.B.BYTE8.W .EQ 1
PAK.B.BYTE8 .EQ %0
@ -14,15 +13,14 @@ PAK.B.TOP8.W .EQ 5
PAK.B.TOP8 .EQ %10.000
PAK.B.TOP16.W .EQ 6
PAK.B.TOP16 .EQ %110.000
PAK.B.TOP24.W .EQ 7
PAK.B.TOP24 .EQ %1110.000
PAK.B.TOP32.W .EQ 8
PAK.B.TOP32 .EQ %11110.000
PAK.B.REP.W .EQ 6
PAK.B.REP .EQ %111110
PAK.B.BL.W .EQ 6
PAK.B.BL .EQ %111111
PAK.B.TOP24.W .EQ 8
PAK.B.TOP24 .EQ %11100.000
PAK.B.TOP32.W .EQ 8
PAK.B.TOP32 .EQ %11101.000
PAK.B.BL.W .EQ 4
PAK.B.BL .EQ %1111
*--------------------------------------
* Shunk Header :
* WORD : Target UNCompressed Length
@ -43,10 +41,9 @@ S.PAKSTAT.TOP16 .EQ 6
S.PAKSTAT.TOP24 .EQ 8
S.PAKSTAT.TOP32 .EQ 10
S.PAKSTAT.BYTE8 .EQ 12
S.PAKSTAT.REPN .EQ 14
S.PAKSTAT.BL .EQ 16
S.PAKSTAT.BL .EQ 14
*
S.PAKSTAT .EQ 18
S.PAKSTAT .EQ 16
*--------------------------------------
LIBPAK.Pak .EQ 4
*--------------------------------------

View File

@ -16,11 +16,8 @@ CHNK.FILE.FNLEN .EQ 4
CHNK.DIR.FNLEN .EQ 1
*
CHNK.DATA.ULEN .EQ 1
CHNK.DATA.T .EQ 3
CHNK.DATA.T.STORE .EQ 0
CHNK.DATA.T.PAK .EQ $C0
*
CHNK.DATA.PAK.TOPLEN .EQ 3
CHNK.DATA.PAK.BLBITS .EQ 3
CHNK.DATA.PAK.TOPLEN .EQ 1
*--------------------------------------
MAN
SAVE INC/PAK.I

View File

@ -9,13 +9,14 @@ NEW
.INB INC/A2OSX.I
.INB INC/LIBPAK.I
*--------------------------------------
STATS .EQ 0
*--------------------------------------
ZPSrcPtr .EQ ZPLIB
ZPDstPtr .EQ ZPLIB+2
ZPStatPtr .EQ ZPLIB+4
ZPSrcBLPtr .EQ ZPLIB+8
ZPCnt .EQ ZPLIB+10
ZPBLCnt .EQ ZPLIB+12
ZPSrcBLPtr .EQ ZPLIB+6
ZPCnt .EQ ZPLIB+8
ZPBLCnt .EQ ZPLIB+10
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
@ -34,8 +35,11 @@ CS.START cld
.1 .DA LIB.LOAD
.DA LIB.UNLOAD
.DA Pak
.DO STATS=1
L.MSG.Stats .DA MSG.Stats
L.MSG.TopBytes .DA MSG.TopBytes
.FIN
L.MSG.BL .DA MSG.BL
.DA 0
*--------------------------------------
LIB.LOAD
@ -77,7 +81,9 @@ Pak >PULLW Pak.SrcPtr
jsr Pak.ComputeLenBits
jsr Pak.BuildTOPTable
.DO STATS=1
jsr Pak.PrintStats
.FIN
* PASS #2 : store with TOP bytes
@ -88,7 +94,10 @@ Pak >PULLW Pak.SrcPtr
jsr Pak.Run
bcs .9
.DO STATS=1
jsr Pak.PrintStats
>DEBUG
.FIN
ldy #S.PAKSTAT-1
@ -105,8 +114,6 @@ Pak >PULLW Pak.SrcPtr
Pak.Run >LDYA Pak.SrcPtr
>STYA ZPSrcPtr
stz Pak.Rep.Longest
stz Pak.BL.Longest
stz Pak.BL.Farest
stz Pak.BL.Farest+1
@ -121,9 +128,6 @@ Pak.Run >LDYA Pak.SrcPtr
sta Pak.SrcCnt+1
sta Pak.DstCnt+1
stz Pak.RepCnt
stz Pak.LastByte
ldx #S.PAKSTAT.PASS1
bit Pak.bPass2
bpl .1
@ -142,17 +146,7 @@ Pak.Run.1 inc Pak.SrcCnt
inc Pak.SrcCnt+1
beq .8 0 byte left...
.1 jsr Pak.ScanRep
bcs .2
jsr Pak.PutRep
bcs .9
ldy Pak.RepCnt
stz Pak.RepCnt
bra .6
.2 jsr Pak.ScanBL
.1 jsr Pak.ScanBL
bcs .20
jsr Pak.PutBL
@ -188,41 +182,6 @@ Pak.Run.1 inc Pak.SrcCnt
inc ZPSrcPtr+1
bra Pak.Run.1
*--------------------------------------
Pak.ScanRep >LDYA Pak.SrcCnt make sure not going past End Buffer
>STYA ZPCnt while reading ahead
lda Pak.LastByte
ldy #0
.1 inc ZPCnt
bne .2
inc ZPCnt+1
beq .4 Last Src Data
.2 cmp (ZPSrcPtr),y
bne .4
iny
cpy #REP.MAX
bne .1
.4 tya
beq .9
sty Pak.RepCnt
cpy Pak.Rep.Longest
bcc .8
sty Pak.Rep.Longest
.8 clc
rts
.9 sec
rts
*--------------------------------------
Pak.ScanBL >LDYA Pak.SrcPtr Start at beginning of Src buf
>STYA ZPSrcBLPtr
@ -295,31 +254,12 @@ Pak.ScanBL >LDYA Pak.SrcPtr Start at beginning of Src buf
rts
*--------------------------------------
Pak.ComputeLenBits
lda Pak.Rep.Longest
tax
dec Longest=1, one bit
beq .15
ldx #8
.14 asl
bcs .15
dex
bra .14
.15 stx Pak.Rep.LenBits
txa
asl
asl
asl
asl
asl
sta Pak.Shnk+S.PAKSHNK.TOPCNT
ldx #8
ldx #0
lda Pak.BL.Longest
beq .10
ldx #8
dec
dec
dec
@ -331,21 +271,25 @@ Pak.ComputeLenBits
.10 stx Pak.BL.LenBits
ldx #8
ldx #0
ldy #0
lda Pak.BL.Farest+1
beq .22
ldy #8
ldx #8
.2 asl
bcs .4
dey
bra .2
.22 lda Pak.BL.Farest
beq .4
ldx #8
.3 asl
bcs .4
dex
@ -390,7 +334,7 @@ Pak.BuildTOPTable
sbc Pak.CntH,x
bcs .3 not better or equal...
stx Pak.LastByte save new score index...
stx Pak.Top.Best save new score index...
lda Pak.CntL,x
sta Pak.Cnt ...and value
@ -403,7 +347,7 @@ Pak.BuildTOPTable
bit Pak.bStop
bmi .8
lda Pak.LastByte
lda Pak.Top.Best
sta Pak.Shnk+S.PAKSHNK.TOPBYTES,y
tax
stz Pak.CntL,x Discard this entry
@ -412,41 +356,10 @@ Pak.BuildTOPTable
cpy #TOP.MAX
bne .1
.8 sty Pak.TOP.Count
tya
ora Pak.Shnk+S.PAKSHNK.TOPCNT
sta Pak.Shnk+S.PAKSHNK.TOPCNT
.8 sty Pak.Shnk+S.PAKSHNK.TOPCNT
rts
*--------------------------------------
Pak.PutRep ldx #S.PAKSTAT.REPN
jsr Pak.UpdateStats
bit Pak.bPass2
bmi Pak.PutRep.2
ldx #S.PAKSTAT.BYTE8
jsr Pak.UpdateStats
ldx #S.PAKSTAT.PASS1
jsr Pak.UpdateStats
clc
rts
Pak.PutRep.2 ldy #PAK.B.REP.W
lda #PAK.B.REP
jsr Pak.Out.PutYBits
bcs .9
lda Pak.RepCnt
dec remap 1-8 to 0-7 range
ldy Pak.Rep.LenBits
jmp Pak.Out.PutYBits
.9 rts
*--------------------------------------
Pak.PutBL ldx #S.PAKSTAT.BL
jsr Pak.UpdateStats
@ -505,9 +418,7 @@ Pak.PutBL ldx #S.PAKSTAT.BL
.9 rts
*--------------------------------------
Pak.PutByte8 sta Pak.LastByte
bit Pak.bPass2
Pak.PutByte8 bit Pak.bPass2
bmi Pak.PutByte8.2
.5 tax
@ -525,7 +436,7 @@ Pak.PutByte8 sta Pak.LastByte
clc
rts
Pak.PutByte8.2 ldy Pak.TOP.Count
Pak.PutByte8.2 ldy Pak.Shnk+S.PAKSHNK.TOPCNT
.1 cmp Pak.Shnk+S.PAKSHNK.TOPBYTES-1,y
beq .3
@ -583,7 +494,7 @@ Pak.Out.Init lda Pak.Shnk+S.PAKSHNK.BLBITS
bcs .9
iny
cpy Pak.TOP.Count
cpy Pak.Shnk+S.PAKSHNK.TOPCNT
bne .1
lda #$80
@ -666,6 +577,7 @@ Pak.UpdateStats inc Pak.Stat,x
inc Pak.Stat+1,x
.8 rts
*--------------------------------------
.DO STATS=1
Pak.PrintStats lda Pak.BL.OfsBitsL
clc
adc Pak.BL.OfsBitsH
@ -676,10 +588,6 @@ Pak.PrintStats lda Pak.BL.OfsBitsL
>PUSHB Pak.BL.Longest
>PUSHW Pak.Stat+S.PAKSTAT.BL
>PUSHB Pak.REP.LenBits
>PUSHB Pak.REP.Longest
>PUSHW Pak.Stat+S.PAKSTAT.REPN
ldx #S.PAKSTAT.BYTE8
.1 >PUSHW Pak.Stat,x
@ -687,7 +595,9 @@ Pak.PrintStats lda Pak.BL.OfsBitsL
dex
bpl .1
>PUSHBI 25
>PUSHW Pak.Shnk+S.PAKSHNK.ULEN
>PUSHBI 23
>LDYA L.MSG.Stats
>SYSCALL printf
@ -697,15 +607,37 @@ Pak.PrintStats lda Pak.BL.OfsBitsL
dex
bpl .2
>PUSHB Pak.TOP.Count
>PUSHB Pak.Shnk+S.PAKSHNK.TOPCNT
>PUSHBI TOP.MAX+1
>LDYA L.MSG.TopBytes
>SYSCALL printf
rts
.FIN
*--------------------------------------
PrintBl >LDYA Pak.BestBL
>STYA ZPSrcBLPtr
PrintBl lda ZPSrcPtr
sec
sbc Pak.BestBL
sta ZPSrcBLPtr
lda ZPSrcPtr+1
sbc Pak.BestBL+1
sta ZPSrcBLPtr+1
>PUSHW Pak.BestBL
>PUSHB Pak.BestBLLen
lda ZPSrcPtr
sec
sbc Pak.SrcPtr
tay
lda ZPSrcPtr+1
sbc Pak.SrcPtr+1
>PUSHYA
>PUSHBI 5
>LDYA L.MSG.BL
>SYSCALL printf
lda #'{'
>SYSCALL putchar
@ -737,19 +669,22 @@ PrintBl >LDYA Pak.BestBL
*--------------------------------------
CS.END
*--------------------------------------
MSG.Stats .AS "\r\nPass 1 : %5D\r\n"
.DO STATS=1
MSG.Stats .AS "\r\nLength : %5D\r\n"
.AS "Pass 1 : %5D\r\n"
.AS "Pass 2 : %5D\r\n"
.AS "Top 8 : %5D\r\n"
.AS "Top 16 : %5D\r\n"
.AS "Top 24 : %5D\r\n"
.AS "Top 32 : %5D\r\n"
.AS "Byte 8 : %5D\r\n"
.AS "Rep : %5D, Longest : %d (%d bits)\r\n"
.AZ "BL : %5D, Longest : %d (%d bits), Farest : %D (%d bits)\r\n"
MSG.TopBytes .AZ "Top : %2d:%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h\r\n"
MSG.TopBytes .AZ "Top : %5d, %h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h\r\n"
.FIN
TOP.Bits .DA #PAK.B.TOP8,#PAK.B.TOP16,#PAK.B.TOP24,#PAK.B.TOP32
TOP.BitCnt .DA #PAK.B.TOP8.W,#PAK.B.TOP16.W,#PAK.B.TOP24.W,#PAK.B.TOP32.W
TOP.Stat .DA #S.PAKSTAT.TOP8,#S.PAKSTAT.TOP16,#S.PAKSTAT.TOP24,#S.PAKSTAT.TOP32
MSG.BL .AZ "o=%D,l=%d,d=%D:"
*--------------------------------------
Pak.SrcPtr .BS 2
@ -758,8 +693,6 @@ Pak.DstCnt .BS 2
Pak.bPass2 .BS 1
Pak.TOP.Count .BS 1
Pak.BL.Longest .BS 1
Pak.BL.Farest .BS 2
@ -771,15 +704,11 @@ Pak.bBLFound .BS 1
Pak.BestBLLen .BS 1
Pak.BestBL .BS 2
Pak.Top.Best .BS 1
Pak.Cnt .BS 2
Pak.bStop .BS 1
Pak.Rep.Longest .BS 1
Pak.Rep.LenBits .BS 1
Pak.RepCnt .BS 1
Pak.LastByte .BS 1
Pak.Out.Byte .BS 1
Pak.Out.Mask .BS 1
*--------------------------------------

View File

@ -8,7 +8,7 @@ NEW
* ZPnCnt = !ZPULen
* ZPPtr1
* ZPPtr2
* ZPInMask,ZPOutLastByte
* ZPInMask,ZPBLOfsLBits,ZPBLOfsHBits,ZPBLLenBits
*--------------------------------------
X.Unpak lda (ZPInBufPtr) ULEN LO
eor #$ff
@ -23,14 +23,9 @@ X.Unpak lda (ZPInBufPtr) ULEN LO
jsr X.Unpak.NextByte
lda (ZPInBufPtr) CHNK.DATA.T
beq X.Unpak.T.STORE
sec
rts
X.Unpak.T.STORE ldy #0 start at 1 to skip CHNK.DATA.T
bne X.Unpak.PAK
*--------------------------------------
X.Unpak.STORE ldy #0
.1 iny
bne .2
@ -38,13 +33,34 @@ X.Unpak.T.STORE ldy #0 start at 1 to skip CHNK.DATA.T
inc ZPInBufPtr+1
.2 lda (ZPInBufPtr),y
jsr X.Unpak.PutByte.1
jsr X.Unpak.PutByte
bne .1
clc
rts
*--------------------------------------
X.Unpak.PAK pha A = BLBITS
and #$70
lsr
lsr
lsr
lsr
sta ZPBLLenBits
X.Unpak.T.PAK jsr X.Unpak.NextByte skip CHNK.DATA.T
pla
ldx #8
and #$0f
tax
cmp #8
bcc .10
ldx #8
and #7
.10 stx ZPBLOfsLBits
sta ZPBLOfsHBits
jsr X.Unpak.NextByte get TOPCNT
lda (ZPInBufPtr) CHNK.DATA.PAK.TOPLEN
clc
@ -57,7 +73,7 @@ X.Unpak.T.PAK jsr X.Unpak.NextByte skip CHNK.DATA.T
lda #$80
sta ZPInMask
*--------------------------------------
.1 lda ZPnCnt
ora ZPnCnt+1
bne .2
@ -66,9 +82,6 @@ X.Unpak.T.PAK jsr X.Unpak.NextByte skip CHNK.DATA.T
rts
*--------------------------------------
.2 jsr X.Unpak.GetBitInC
bcs .7 ->BACKLINK
jsr X.Unpak.GetBitInC
bcs .3 ->TOP
* BYTE8
jsr X.Unpak.GetByteInA
@ -83,7 +96,7 @@ X.Unpak.T.PAK jsr X.Unpak.NextByte skip CHNK.DATA.T
bra .51
*--------------------------------------
.4 jsr X.Unpak.GetBitInC
bcs .5 ->TOP24
bcs .5 ->TOP32
* TOP16
ldx #3
jsr X.Unpak.GetXBitInA
@ -92,11 +105,11 @@ X.Unpak.T.PAK jsr X.Unpak.NextByte skip CHNK.DATA.T
bra .51
*--------------------------------------
.5 jsr X.Unpak.GetBitInC
bcs .6 ->REPn
* TOP24
ldx #3
bcs .6 ->BACKLINK
* TOP32
ldx #4
jsr X.Unpak.GetXBitInA
ora #16
ora #32
.51 tay
lda (ZPInBufPtr),y
@ -106,47 +119,45 @@ X.Unpak.T.PAK jsr X.Unpak.NextByte skip CHNK.DATA.T
clc
rts
*--------------------------------------
* REPn
.6 lda ZPOutLastByte
.61 jsr X.Unpak.PutByte.1
* BACKLINK : 1111 OfsLBits OfsHBits LenBits
.6 ldx ZPBLOfsLBits
jsr X.Unpak.GetXBitInA
clc
adc ZPOutBufPtr
sta ZPPtr2
php
lda ZPBLOfsHBits
beq .61
tax
jsr X.Unpak.GetXBitInA
.61 plp
adc ZPOutBufPtr+1
sta ZPPtr2+1
ldx ZPBLLenBits
jsr X.Unpak.GetXBitInA
inc +1
inc +1
inc +1
tay
.62 lda (ZPPtr2),y
jsr X.Unpak.PutByte
beq .99
dey
bpl .61 +1
bne .62
bra .1
.99 sec
rts
*--------------------------------------
* BACKLINK : 1 oooooooo OOOO llllll
.7 jsr X.Unpak.GetByteInA
clc
adc ZPOutBufPtr
sta ZPPtr2
php
ldx #4
jsr X.Unpak.GetXBitInA
plp
adc ZPOutBufPtr+1
sta ZPPtr2+1
jsr X.Unpak.GetByteInA
inc +1
inc +1
* inc +1
tay
.71 lda (ZPPtr2),y
jsr X.Unpak.PutByte
beq .99
dey
bpl .71 +1
bra .1
*--------------------------------------
X.Unpak.GetByteInA
ldx #8
@ -188,9 +199,7 @@ X.Unpak.NextByte
.8 rts
*--------------------------------------
X.Unpak.PutByte sta ZPOutLastByte
X.Unpak.PutByte.1
sta (ZPOutBufPtr)
X.Unpak.PutByte sta (ZPOutBufPtr)
inc ZPOutBufPtr
bne .1
inc ZPOutBufPtr+1