A2osX/SHARED/X.UNPAK.S.txt

212 lines
3.6 KiB
Plaintext
Raw Normal View History

2019-09-24 15:25:07 +00:00
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* ZPInBufPtr = Ptr to Shunk Data
* ZPOutBufPtr = Ptr to Uncompressed Data
*--------------------------------------
2019-10-02 15:21:03 +00:00
* ZPnCnt = !ZPULen
2019-09-24 15:25:07 +00:00
* ZPPtr1
* ZPPtr2
2019-09-25 15:34:43 +00:00
* ZPInMask,ZPOutLastByte
2019-09-24 15:25:07 +00:00
*--------------------------------------
2019-09-25 15:34:43 +00:00
X.Unpak lda (ZPInBufPtr) ULEN LO
2019-09-24 15:25:07 +00:00
eor #$ff
sta ZPnCnt
2019-09-25 15:34:43 +00:00
jsr X.Unpak.NextByte
2019-09-24 15:25:07 +00:00
2019-09-25 15:34:43 +00:00
lda (ZPInBufPtr) ULEN HI
2019-10-02 15:21:03 +00:00
eor #$ff
2019-09-25 15:34:43 +00:00
sta ZPnCnt+1
2019-09-24 15:25:07 +00:00
2019-09-25 15:34:43 +00:00
jsr X.Unpak.NextByte
2019-09-24 15:25:07 +00:00
2019-10-02 15:21:03 +00:00
lda (ZPInBufPtr) CHNK.DATA.T
beq X.Unpak.T.STORE
cmp #CHNK.DATA.T.PAK
beq X.Unpak.T.PAK
sec
rts
X.Unpak.T.STORE ldy #0 start at 1 to skip CHNK.DATA.T
.1 iny
bne .2
2019-09-24 15:25:07 +00:00
2019-10-02 15:21:03 +00:00
inc ZPInBufPtr+1
.2 lda (ZPInBufPtr),y
jsr X.Unpak.PutByte.1
bne .1
clc
rts
X.Unpak.T.PAK jsr X.Unpak.NextByte skip CHNK.DATA.T
lda (ZPInBufPtr) CHNK.DATA.PAK.TOPLEN
2019-09-24 15:25:07 +00:00
clc
2019-09-25 15:34:43 +00:00
adc ZPInBufPtr skip TOP table
2019-09-24 15:25:07 +00:00
sta ZPPtr1
2019-10-02 15:21:03 +00:00
lda ZPInBufPtr+1 ZPInBufPtr = TOPs
2019-09-24 15:25:07 +00:00
adc #0
2019-10-02 15:21:03 +00:00
sta ZPPtr1+1 ZPPtr1 = DATA
2019-09-24 15:25:07 +00:00
lda #$80
sta ZPInMask
.1 lda ZPnCnt
ora ZPnCnt+1
bne .2
clc
rts
*--------------------------------------
.2 jsr X.Unpak.GetBitInC
2019-09-25 15:34:43 +00:00
bcs .7 ->BACKLINK
jsr X.Unpak.GetBitInC
bcs .3 ->TOP
* BYTE8
jsr X.Unpak.GetByteInA
bra .52
2019-09-24 15:25:07 +00:00
*--------------------------------------
.3 jsr X.Unpak.GetBitInC
2019-09-25 15:34:43 +00:00
bcs .4 ->TOP16
* TOP8
ldx #3
2019-09-24 15:25:07 +00:00
jsr X.Unpak.GetXBitInA
2019-09-25 15:34:43 +00:00
bra .51
2019-09-24 15:25:07 +00:00
*--------------------------------------
.4 jsr X.Unpak.GetBitInC
2019-09-25 15:34:43 +00:00
bcs .5 ->TOP24
* TOP16
ldx #3
2019-09-24 15:25:07 +00:00
jsr X.Unpak.GetXBitInA
2019-09-25 15:34:43 +00:00
ora #8
2019-09-24 15:25:07 +00:00
2019-09-25 15:34:43 +00:00
bra .51
*--------------------------------------
.5 jsr X.Unpak.GetBitInC
bcs .6 ->REPn
* TOP24
ldx #3
jsr X.Unpak.GetXBitInA
ora #16
.51 tay
lda (ZPInBufPtr),y
.52 jsr X.Unpak.PutByte
bne .2
clc
rts
*--------------------------------------
* REPn
.6 lda ZPOutLastByte
.61 jsr X.Unpak.PutByte.1
2019-09-24 15:25:07 +00:00
beq .99
dey
2019-09-25 15:34:43 +00:00
bpl .61 +1
2019-09-24 15:25:07 +00:00
bra .1
.99 sec
rts
*--------------------------------------
2019-09-25 15:34:43 +00:00
* BACKLINK : 1 oooooooo OOOO llllll
.7 jsr X.Unpak.GetByteInA
2019-09-24 15:25:07 +00:00
clc
adc ZPOutBufPtr
sta ZPPtr2
php
2019-09-25 15:34:43 +00:00
ldx #4
2019-09-24 15:25:07 +00:00
jsr X.Unpak.GetXBitInA
plp
adc ZPOutBufPtr+1
sta ZPPtr2+1
jsr X.Unpak.GetByteInA
inc +1
inc +1
* inc +1
tay
2019-09-25 15:34:43 +00:00
.71 lda (ZPPtr2),y
2019-09-24 15:25:07 +00:00
jsr X.Unpak.PutByte
beq .99
dey
2019-09-25 15:34:43 +00:00
bpl .71 +1
2019-09-24 15:25:07 +00:00
bra .1
*--------------------------------------
X.Unpak.GetByteInA
ldx #8
X.Unpak.GetXBitInA
lda #0
.1 jsr X.Unpak.GetBitInC
rol
dex
bne .1
rts
*--------------------------------------
X.Unpak.GetBitInC
pha
clc
lda (ZPPtr1)
and ZPInMask
beq .1
sec
.1 php
lsr ZPInMask
2019-09-25 15:34:43 +00:00
bcc .8
2019-09-24 15:25:07 +00:00
ror ZPInMask
2019-09-25 15:34:43 +00:00
jsr X.Unpak.NextByte
.8 plp
pla
rts
*--------------------------------------
X.Unpak.NextByte
2019-09-24 15:25:07 +00:00
inc ZPPtr1
bne .8
inc ZPPtr1+1
2019-09-25 15:34:43 +00:00
.8 rts
2019-09-24 15:25:07 +00:00
*--------------------------------------
X.Unpak.PutByte sta ZPOutLastByte
X.Unpak.PutByte.1
sta (ZPOutBufPtr)
inc ZPOutBufPtr
bne .1
inc ZPOutBufPtr+1
.1 inc ZPnCnt
bne .2
inc ZPnCnt+1
.2 rts
*--------------------------------------
.LIST ON
X.Unpak.Size .EQ *-X.Unpak
.LIST OFF
*--------------------------------------
MAN
SAVE USR/SRC/SHARED/X.UNPAK.S
LOAD USR/SRC/BIN/UNPAK.S
ASM