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 bra .9
.2 jsr CS.RUN.Pak .2 jsr CS.RUN.Pak
>DEBUG * >DEBUG
jsr CS.RUN.WriteArcData jsr CS.RUN.WriteArcData
bcc .1 bcc .1

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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