A2osX/SHARED/X.UNPAK.S.txt

239 lines
3.9 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-10-14 05:23:09 +00:00
* ZPInMask,ZPBLOfsLBits,ZPBLOfsHBits,ZPBLLenBits
2019-09-24 15:25:07 +00:00
*--------------------------------------
2019-10-17 10:36:45 +00:00
X.Unpak jsr X.Unpak.GetByte CHNK.DATA.T
2019-10-16 14:31:49 +00:00
tax
2019-10-14 05:23:09 +00:00
bne X.Unpak.PAK
*--------------------------------------
2019-10-17 10:36:45 +00:00
X.Unpak.STORE jsr X.Unpak.GetULEN
2019-10-02 15:21:03 +00:00
2019-10-17 10:36:45 +00:00
ldy #0
.1 lda (ZPInBufPtr),y
iny
2019-10-02 15:21:03 +00:00
bne .2
2019-09-24 15:25:07 +00:00
2019-10-02 15:21:03 +00:00
inc ZPInBufPtr+1
2019-10-17 10:36:45 +00:00
.2 jsr X.Unpak.PutByte
2019-10-02 15:21:03 +00:00
bne .1
clc
rts
2019-10-14 05:23:09 +00:00
*--------------------------------------
X.Unpak.PAK pha A = BLBITS
and #$70
lsr
lsr
lsr
lsr
sta ZPBLLenBits
pla
and #$0f
2019-10-16 14:31:49 +00:00
ldx #0
2019-10-14 05:23:09 +00:00
cmp #8
bcc .10
2019-10-16 14:31:49 +00:00
2019-10-14 05:23:09 +00:00
and #7
2019-10-16 14:31:49 +00:00
tax
lda #8
2019-10-14 05:23:09 +00:00
2019-10-16 14:31:49 +00:00
.10 sta ZPBLOfsLBits
stx ZPBLOfsHBits
2019-10-14 15:58:16 +00:00
2019-10-17 10:36:45 +00:00
jsr X.Unpak.GetULEN
2019-10-16 06:09:13 +00:00
2019-10-17 10:36:45 +00:00
jsr X.Unpak.GetByte get TOPCNT
2019-10-16 06:09:13 +00:00
2019-10-16 14:31:49 +00:00
ldx ZPInBufPtr ZPPtr1 = TOP table
stx ZPPtr1
ldx ZPInBufPtr+1
stx ZPPtr1+1
2019-10-14 15:58:16 +00:00
2019-09-24 15:25:07 +00:00
clc
2019-09-25 15:34:43 +00:00
adc ZPInBufPtr skip TOP table
2019-10-14 15:58:16 +00:00
sta ZPInBufPtr
2019-10-15 15:32:50 +00:00
bcc .11
2019-09-24 15:25:07 +00:00
2019-10-15 15:32:50 +00:00
inc ZPInBufPtr+1
2019-09-24 15:25:07 +00:00
2019-10-15 15:32:50 +00:00
.11 lda #$80
2019-09-24 15:25:07 +00:00
sta ZPInMask
2019-10-14 05:23:09 +00:00
*--------------------------------------
2019-10-15 15:33:51 +00:00
.2 jsr X.Unpak.GetBitInC
2019-10-15 15:32:50 +00:00
bcs .3 ->TOP
2019-09-25 15:34:43 +00:00
* BYTE8
2019-10-15 06:43:24 +00:00
ldx #8
jsr X.Unpak.GetXBitInA
2019-09-25 15:34:43 +00:00
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-10-14 05:23:09 +00:00
bcs .5 ->TOP32
2019-09-25 15:34:43 +00:00
* TOP16
ldx #3
2019-09-24 15:25:07 +00:00
jsr X.Unpak.GetXBitInA
2019-10-15 06:43:24 +00:00
ora #%1000
2019-09-25 15:34:43 +00:00
bra .51
*--------------------------------------
.5 jsr X.Unpak.GetBitInC
2019-10-14 05:23:09 +00:00
bcs .6 ->BACKLINK
* TOP32
ldx #4
2019-09-25 15:34:43 +00:00
jsr X.Unpak.GetXBitInA
2019-10-15 06:43:24 +00:00
ora #%10000
2019-09-25 15:34:43 +00:00
.51 tay
2019-10-14 15:58:16 +00:00
lda (ZPPtr1),y
2019-09-25 15:34:43 +00:00
.52 jsr X.Unpak.PutByte
2019-10-16 20:42:21 +00:00
bne .80
.99 sec
rts
2019-09-25 15:34:43 +00:00
*--------------------------------------
2019-10-14 05:23:09 +00:00
* BACKLINK : 1111 OfsLBits OfsHBits LenBits
.6 ldx ZPBLOfsLBits
2019-10-16 14:31:49 +00:00
2019-10-14 05:23:09 +00:00
jsr X.Unpak.GetXBitInA
2019-10-16 14:31:49 +00:00
2019-10-15 15:32:50 +00:00
eor #$ff
2019-10-15 06:43:24 +00:00
sec
2019-10-15 15:32:50 +00:00
adc ZPOutBufPtr
2019-09-24 15:25:07 +00:00
sta ZPPtr2
2019-10-15 15:32:50 +00:00
2019-10-14 05:23:09 +00:00
lda ZPBLOfsHBits
beq .61
2019-10-15 15:32:50 +00:00
php
2019-10-14 05:23:09 +00:00
tax
2019-09-24 15:25:07 +00:00
jsr X.Unpak.GetXBitInA
2019-10-15 15:32:50 +00:00
plp
2019-10-14 05:23:09 +00:00
2019-10-16 14:31:49 +00:00
.61 eor #$ff
2019-10-15 15:32:50 +00:00
adc ZPOutBufPtr+1
2019-09-24 15:25:07 +00:00
sta ZPPtr2+1
2019-10-14 05:23:09 +00:00
ldx ZPBLLenBits
jsr X.Unpak.GetXBitInA
2019-09-24 15:25:07 +00:00
inc +1
inc +1
2019-10-14 05:23:09 +00:00
inc +1
2019-10-15 15:32:50 +00:00
tax
ldy #0
2019-09-24 15:25:07 +00:00
2019-10-15 15:32:50 +00:00
.62 lda (ZPPtr2),y
2019-09-24 15:25:07 +00:00
jsr X.Unpak.PutByte
2019-10-16 20:42:21 +00:00
bne .63
dex
bne .99
clc
rts
2019-09-24 15:25:07 +00:00
2019-10-16 20:42:21 +00:00
.63 iny
2019-10-15 15:32:50 +00:00
dex
bne .62
2019-10-16 15:23:29 +00:00
.80 lda ZPnCnt
2019-10-16 20:42:21 +00:00
and ZPnCnt+1
inc
2019-10-16 14:31:49 +00:00
bne .2
2019-10-15 15:32:50 +00:00
2019-10-16 14:31:49 +00:00
clc
rts
2019-09-24 15:25:07 +00:00
*--------------------------------------
2019-10-17 10:36:45 +00:00
X.Unpak.GetULEN jsr X.Unpak.GetByte ULEN LO
eor #$ff
sta ZPnCnt
jsr X.Unpak.GetByte ULEN HI
eor #$ff
sta ZPnCnt+1
rts
*--------------------------------------
2019-09-24 15:25:07 +00:00
X.Unpak.GetXBitInA
lda #0
2019-10-16 15:23:29 +00:00
.1 pha
jsr X.Unpak.GetBitInC
pla
2019-09-24 15:25:07 +00:00
rol
dex
bne .1
rts
*--------------------------------------
X.Unpak.GetBitInC
clc
2019-10-14 15:58:16 +00:00
lda (ZPInBufPtr)
2019-09-24 15:25:07 +00:00
and ZPInMask
beq .1
2019-10-16 15:23:29 +00:00
2019-09-24 15:25:07 +00:00
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
rts
*--------------------------------------
2019-10-17 10:36:45 +00:00
X.Unpak.GetByte lda (ZPInBufPtr)
2019-09-25 15:34:43 +00:00
X.Unpak.NextByte
2019-10-14 15:58:16 +00:00
inc ZPInBufPtr
2019-09-24 15:25:07 +00:00
bne .8
2019-10-14 15:58:16 +00:00
inc ZPInBufPtr+1
2019-09-24 15:25:07 +00:00
2019-09-25 15:34:43 +00:00
.8 rts
2019-09-24 15:25:07 +00:00
*--------------------------------------
2019-10-16 15:23:29 +00:00
X.Unpak.PutByte inc ZPnCnt
bne .1
inc ZPnCnt+1
beq .8
.1 sta (ZPOutBufPtr)
2019-10-16 14:31:49 +00:00
2019-09-24 15:25:07 +00:00
inc ZPOutBufPtr
2019-10-16 15:23:29 +00:00
bne .8
2019-09-24 15:25:07 +00:00
inc ZPOutBufPtr+1
2019-10-16 14:31:49 +00:00
.8 rts
2019-09-24 15:25:07 +00:00
*--------------------------------------
.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