1
0
mirror of https://github.com/A2osX/A2osX.git synced 2025-03-22 11:32:55 +00:00

Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-10-09 07:45:36 +02:00
parent e5cd10d138
commit c13c9698da
2 changed files with 119 additions and 82 deletions

@ -18,16 +18,6 @@ PAK.B.REPn.W .EQ 8
PAK.B.BL .EQ %11111
PAK.B.BL.W .EQ 5
*--------------------------------------
* STRINGn : 0 xxxx (1-16)
* {
* BYTE8 : 0 xxxxxxxx
* TOP8 : 10 xxx
* TOP16 : 110 xxx
* TOP24 : 1110 xxx
* REPn : 1111 xxxx (1-16)
* }
* BACKLINK : 1 OfsPtr Len
*--------------------------------------
* Shunk Header :
* WORD : Target UNCompressed Length
* !!! USED TO STOP UNPACK,NO EOF TOKEN!!!
@ -54,3 +44,5 @@ LIBPAK.Pak .EQ 4
*--------------------------------------
MAN
SAVE INC/LIBPAK.I
LOAD USR/SRC/LIB/LIBPAK.S
ASM

@ -99,6 +99,8 @@ Pak >PULLW Pak.SrcPtr
dey
bpl .7
>DEBUG
>LDYA Pak.Stat+S.PAKSTAT.PASS2
clc
@ -143,7 +145,12 @@ Pak.Run.1 inc Pak.SrcCnt
inc Pak.SrcCnt+1
beq .8 0 byte left...
.1 jsr Pak.ScanBL
.1 Pak.ScanRep
bcs .10
10 jsr Pak.ScanBL
bcc .2
lda (ZPSrcPtr) Not found...
@ -173,9 +180,109 @@ Pak.Run.1 inc Pak.SrcCnt
inc Pak.SrcCnt+1
bmi .1
.8 clc
.8 clc
.9 rts
*--------------------------------------
Pak.ScanRep >LDYA Pak.SrcCnt make sure not going past End Buffer
>STYA ZPCnt while reading ahead
lda (ZPSrcPtr)
ldy #0
.1 inc ZPCnt
bne .2
inc ZPCnt+1
beq .3 Last Src Data
.2 iny
cmp (ZPSrcPtr),y
bne .4
.3 cpy #REP.MAX
bne .1
.4 dey
beq .9
clc
rts
.9 sec
rts
*--------------------------------------
Pak.ScanBL >LDYA Pak.SrcPtr Start at beginning of Src buf
>STYA ZPSrcBLPtr
lda #$ff
sta Pak.bBLFound
stz Pak.BestBLLen
.1 lda ZPSrcBLPtr
sec
sbc ZPSrcPtr
sta ZPBLCnt
lda ZPSrcBLPtr+1
sbc ZPSrcPtr+1
sta ZPBLCnt+1 ZPSrcBLPtr < !BlCnt < ZPSrcPtr
bcs .8 ZPSrcBLPtr = ZPSrcPtr, exit
>LDYA Pak.SrcCnt make sure not going past End Buffer
>STYA ZPCnt while reading ahead
ldy #0 ...or Y = BL.MAX
.2 inc ZPBLCnt
bne .3
inc ZPBLCnt+1
beq .6 ZPSrcBLPtr = ZPSrcPtr
.3 inc ZPCnt
bne .4
inc ZPCnt+1
beq .6 Last Src Data
.4 lda (ZPSrcPtr),y
cmp (ZPSrcBLPtr),y
bne .6 End of string matching
.5 iny
cpy #BL.MAX
bne .2 Max BL len
.6 cpy #BL.MIN
bcc .7 not long enough
cpy Pak.BestBLLen
bcc .7 not better ...
* beq .7 !!! same...but closer !!!
sty Pak.BestBLLen
lda ZPSrcPtr
sec
sbc ZPSrcBLPtr
sta Pak.BestBL
lda ZPSrcPtr+1
sbc ZPSrcBLPtr+1
sta Pak.BestBL+1
stz Pak.bBLFound
.7 inc ZPSrcBLPtr
bne .1
inc ZPSrcBLPtr+1
bra .1
.8 rol Pak.bBLFound
rts
*--------------------------------------
Pak.ComputeBLBits
ldx #8
lda Pak.BL.Longest
@ -264,75 +371,13 @@ Pak.BuildTOPTable
rts
*--------------------------------------
Pak.ScanBL >LDYA Pak.SrcPtr Start at beginning of Src buf
>STYA ZPSrcBLPtr
lda #$ff
sta Pak.bBLFound
stz Pak.BestBLLen
Pak.PutRep bit Pak.bPass2
bmi Pak.PutRep.2
.1 lda ZPSrcBLPtr
sec
sbc ZPSrcPtr
sta ZPBLCnt
lda ZPSrcBLPtr+1
sbc ZPSrcPtr+1
sta ZPBLCnt+1 ZPSrcBLPtr < !BlCnt < ZPSrcPtr
bcs .8 ZPSrcBLPtr = ZPSrcPtr, exit
>LDYA Pak.SrcCnt make sure not going past End Buffer
>STYA ZPCnt while reading ahead
ldy #0 ...or Y = BL.MAX
.2 inc ZPBLCnt
bne .3
inc ZPBLCnt+1
beq .6 ZPSrcBLPtr = ZPSrcPtr
.3 inc ZPCnt
bne .4
inc ZPCnt+1
beq .6 Last Src Data
.4 lda (ZPSrcPtr),y
cmp (ZPSrcBLPtr),y
bne .6 End of string matching
.5 iny
cpy #BL.MAX
bne .2 Max BL len
.6 cpy #BL.MIN
bcc .7 not long enough
cpy Pak.BestBLLen
bcc .7 not better ...
* beq .7 !!! same...but closer !!!
sty Pak.BestBLLen
lda ZPSrcPtr
sec
sbc ZPSrcBLPtr
sta Pak.BestBL
lda ZPSrcPtr+1
sbc ZPSrcBLPtr+1
sta Pak.BestBL+1
stz Pak.bBLFound
.7 inc ZPSrcBLPtr
bne .1
inc ZPSrcBLPtr+1
bra .1
.8 rol Pak.bBLFound
Pak.PutRep.2
clc
rts
*--------------------------------------
Pak.PutBL ldx #S.PAKSTAT.BL
@ -395,6 +440,8 @@ Pak.PutBL ldx #S.PAKSTAT.BL
Pak.PutByte bit Pak.bPass2
bmi Pak.PutByte.2
bra .5
cmp Pak.LastByte
sta Pak.LastByte
bne .5
@ -429,9 +476,7 @@ Pak.PutByte bit Pak.bPass2
clc
rts
Pak.PutByte.2
Pak.PutA.2.Out ldy Pak.Shnk+S.PAKSHNK.TOPCNT
Pak.PutByte.2 ldy Pak.Shnk+S.PAKSHNK.TOPCNT
.1 cmp Pak.Shnk+S.PAKSHNK.TOPBYTES-1,y
beq .3
@ -518,6 +563,7 @@ Pak.Out.PutCA jsr Pak.Out.PutBitC
bcs Pak.Out.Put.rts
dey
bne .1
Pak.Out.Put.rts rts
*--------------------------------------
Pak.Out.PutYBits
@ -611,7 +657,6 @@ Pak.PrintStats lda Pak.BL.OfsBitsL
>PUSHBI 25
>LDYA L.MSG.Top24
>SYSCALL printf
>DEBUG
rts
*--------------------------------------
PrintBl >LDYA Pak.BestBL