A2osX/SHARED/X.UNPAK.S.txt
2019-09-25 17:34:43 +02:00

189 lines
3.2 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* ZPInBufPtr = Ptr to Shunk Data
* ZPOutBufPtr = Ptr to Uncompressed Data
*--------------------------------------
* ZPPtr1
* ZPPtr2
* ZPnCnt = !ZPULen
* ZPInMask,ZPOutLastByte
*--------------------------------------
X.Unpak lda (ZPInBufPtr) ULEN LO
eor #$ff
sta ZPnCnt
jsr X.Unpak.NextByte
lda (ZPInBufPtr) ULEN HI
sta ZPnCnt+1
jsr X.Unpak.NextByte
lda (ZPInBufPtr) TOPLEN
clc
adc ZPInBufPtr skip TOP table
sta ZPPtr1
lda ZPInBufPtr+1
adc #0
sta ZPPtr1+1
jsr X.Unpak.NextByte
lda #$80
sta ZPInMask
.1 lda ZPnCnt
ora ZPnCnt+1
bne .2
clc
rts
*--------------------------------------
.2 jsr X.Unpak.GetBitInC
bcs .7 ->BACKLINK
jsr X.Unpak.GetBitInC
bcs .3 ->TOP
* BYTE8
jsr X.Unpak.GetByteInA
bra .52
*--------------------------------------
.3 jsr X.Unpak.GetBitInC
bcs .4 ->TOP16
* TOP8
ldx #3
jsr X.Unpak.GetXBitInA
bra .51
*--------------------------------------
.4 jsr X.Unpak.GetBitInC
bcs .5 ->TOP24
* TOP16
ldx #3
jsr X.Unpak.GetXBitInA
ora #8
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
beq .99
dey
bpl .61 +1
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
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
bcc .8
ror ZPInMask
jsr X.Unpak.NextByte
.8 plp
pla
rts
*--------------------------------------
X.Unpak.NextByte
inc ZPPtr1
bne .8
inc ZPPtr1+1
.8 rts
*--------------------------------------
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