mirror of
https://github.com/pfusik/zlib6502.git
synced 2024-06-08 13:29:27 +00:00
Shorten the labels.
This commit is contained in:
parent
ebbddee192
commit
fd18d5618d
116
inflate.asx
116
inflate.asx
|
@ -20,17 +20,17 @@ outputPointer equ inflate_zp+2 ; 2 bytes
|
||||||
getBit_buffer equ inflate_zp+4 ; 1 byte
|
getBit_buffer equ inflate_zp+4 ; 1 byte
|
||||||
|
|
||||||
getBits_base equ inflate_zp+5 ; 1 byte
|
getBits_base equ inflate_zp+5 ; 1 byte
|
||||||
inflateStoredBlock_pageCounter equ inflate_zp+5 ; 1 byte
|
inflateStored_pageCounter equ inflate_zp+5 ; 1 byte
|
||||||
|
|
||||||
inflateCodes_sourcePointer equ inflate_zp+6 ; 2 bytes
|
inflateCodes_sourcePointer equ inflate_zp+6 ; 2 bytes
|
||||||
inflateDynamicBlock_lengthIndex equ inflate_zp+6 ; 1 byte
|
inflateDynamic_symbol equ inflate_zp+6 ; 1 byte
|
||||||
inflateDynamicBlock_lastLength equ inflate_zp+7 ; 1 byte
|
inflateDynamic_lastLength equ inflate_zp+7 ; 1 byte
|
||||||
inflateDynamicBlock_tempCodes equ inflate_zp+7 ; 1 byte
|
inflateDynamic_tempCodes equ inflate_zp+7 ; 1 byte
|
||||||
|
|
||||||
inflateCodes_lengthMinus2 equ inflate_zp+8 ; 1 byte
|
inflateCodes_lengthMinus2 equ inflate_zp+8 ; 1 byte
|
||||||
inflateDynamicBlock_allCodes equ inflate_zp+8 ; 1 byte
|
inflateDynamic_allCodes equ inflate_zp+8 ; 1 byte
|
||||||
|
|
||||||
inflateDynamicBlock_primaryCodes equ inflate_zp+9 ; 1 byte
|
inflateDynamic_primaryCodes equ inflate_zp+9 ; 1 byte
|
||||||
|
|
||||||
|
|
||||||
; Argument values for getBits
|
; Argument values for getBits
|
||||||
|
@ -70,33 +70,33 @@ inflate_blockLoop
|
||||||
lsr @
|
lsr @
|
||||||
php
|
php
|
||||||
tax
|
tax
|
||||||
bne inflateCompressedBlock
|
bne inflateCompressed
|
||||||
|
|
||||||
; Copy uncompressed block
|
; Copy uncompressed block
|
||||||
; ldy #0
|
; ldy #0
|
||||||
sty getBit_buffer
|
sty getBit_buffer
|
||||||
jsr getWord
|
jsr getWord
|
||||||
jsr getWord
|
jsr getWord
|
||||||
sta inflateStoredBlock_pageCounter
|
sta inflateStored_pageCounter
|
||||||
; jmp inflateStoredBlock_firstByte
|
; jmp inflateStored_firstByte
|
||||||
bcs inflateStoredBlock_firstByte
|
bcs inflateStored_firstByte
|
||||||
inflateStoredBlock_copyByte
|
inflateStored_copyByte
|
||||||
jsr getByte
|
jsr getByte
|
||||||
inflateStoreByte
|
inflateStoreByte
|
||||||
jsr storeByte
|
jsr storeByte
|
||||||
bcc inflateCodes_loop
|
bcc inflateCodes_loop
|
||||||
inflateStoredBlock_firstByte
|
inflateStored_firstByte
|
||||||
inx
|
inx
|
||||||
bne inflateStoredBlock_copyByte
|
bne inflateStored_copyByte
|
||||||
inc inflateStoredBlock_pageCounter
|
inc inflateStored_pageCounter
|
||||||
bne inflateStoredBlock_copyByte
|
bne inflateStored_copyByte
|
||||||
|
|
||||||
inflate_nextBlock
|
inflate_nextBlock
|
||||||
plp
|
plp
|
||||||
bcc inflate_blockLoop
|
bcc inflate_blockLoop
|
||||||
rts
|
rts
|
||||||
|
|
||||||
inflateCompressedBlock
|
inflateCompressed
|
||||||
|
|
||||||
; Decompress a block with fixed Huffman trees:
|
; Decompress a block with fixed Huffman trees:
|
||||||
; :144 dta 8
|
; :144 dta 8
|
||||||
|
@ -106,23 +106,23 @@ inflateCompressedBlock
|
||||||
; :2 dta 8 ; codes with no meaning
|
; :2 dta 8 ; codes with no meaning
|
||||||
; :30 dta 5+DISTANCE_TREE
|
; :30 dta 5+DISTANCE_TREE
|
||||||
; ldy #0
|
; ldy #0
|
||||||
inflateFixedBlock_setCodeLengths
|
inflateFixed_setCodeLengths
|
||||||
lda #4
|
lda #4
|
||||||
cpy #144
|
cpy #144
|
||||||
rol @
|
rol @
|
||||||
sta literalSymbolCodeLength,y
|
sta literalSymbolCodeLength,y
|
||||||
cpy #CONTROL_SYMBOLS
|
cpy #CONTROL_SYMBOLS
|
||||||
bcs inflateFixedBlock_noControlSymbol
|
bcs inflateFixed_noControlSymbol
|
||||||
lda #5+DISTANCE_TREE
|
lda #5+DISTANCE_TREE
|
||||||
cpy #LENGTH_SYMBOLS
|
cpy #LENGTH_SYMBOLS
|
||||||
bcs inflateFixedBlock_setControlCodeLength
|
bcs inflateFixed_setControlCodeLength
|
||||||
cpy #24
|
cpy #24
|
||||||
adc #2-DISTANCE_TREE
|
adc #2-DISTANCE_TREE
|
||||||
inflateFixedBlock_setControlCodeLength
|
inflateFixed_setControlCodeLength
|
||||||
sta controlSymbolCodeLength,y
|
sta controlSymbolCodeLength,y
|
||||||
inflateFixedBlock_noControlSymbol
|
inflateFixed_noControlSymbol
|
||||||
iny
|
iny
|
||||||
bne inflateFixedBlock_setCodeLengths
|
bne inflateFixed_setCodeLengths
|
||||||
|
|
||||||
dex
|
dex
|
||||||
beq inflateCodes
|
beq inflateCodes
|
||||||
|
@ -135,13 +135,13 @@ inflateFixedBlock_noControlSymbol
|
||||||
; Use temporary codes to get lengths of literal/length and distance codes
|
; Use temporary codes to get lengths of literal/length and distance codes
|
||||||
; ldx #0
|
; ldx #0
|
||||||
; sec
|
; sec
|
||||||
inflateDynamicBlock_decodeLength
|
inflateDynamic_decodeLength
|
||||||
php
|
php
|
||||||
stx inflateDynamicBlock_lengthIndex
|
stx inflateDynamic_symbol
|
||||||
; Fetch a temporary code
|
; Fetch a temporary code
|
||||||
jsr fetchPrimaryCode
|
jsr fetchPrimaryCode
|
||||||
; Temporary code 0..15: put this length
|
; Temporary code 0..15: put this length
|
||||||
bpl inflateDynamicBlock_verbatimLength
|
bpl inflateDynamic_verbatimLength
|
||||||
; Temporary code 16: repeat last length 3 + getBits(2) times
|
; Temporary code 16: repeat last length 3 + getBits(2) times
|
||||||
; Temporary code 17: put zero length 3 + getBits(3) times
|
; Temporary code 17: put zero length 3 + getBits(3) times
|
||||||
; Temporary code 18: put zero length 11 + getBits(7) times
|
; Temporary code 18: put zero length 11 + getBits(7) times
|
||||||
|
@ -154,32 +154,32 @@ inflateDynamicBlock_decodeLength
|
||||||
tay
|
tay
|
||||||
lda #0
|
lda #0
|
||||||
cpx #GET_3_BITS
|
cpx #GET_3_BITS
|
||||||
scs:lda inflateDynamicBlock_lastLength
|
scs:lda inflateDynamic_lastLength
|
||||||
inflateDynamicBlock_verbatimLength
|
inflateDynamic_verbatimLength
|
||||||
iny
|
iny
|
||||||
ldx inflateDynamicBlock_lengthIndex
|
ldx inflateDynamic_symbol
|
||||||
plp
|
plp
|
||||||
inflateDynamicBlock_storeLength
|
inflateDynamic_storeLength
|
||||||
bcc inflateDynamicBlock_controlSymbolCodeLength
|
bcc inflateDynamic_controlSymbolCodeLength
|
||||||
sta literalSymbolCodeLength,x+
|
sta literalSymbolCodeLength,x+
|
||||||
cpx #1
|
cpx #1
|
||||||
inflateDynamicBlock_storeNext
|
inflateDynamic_storeNext
|
||||||
dey
|
dey
|
||||||
bne inflateDynamicBlock_storeLength
|
bne inflateDynamic_storeLength
|
||||||
sta inflateDynamicBlock_lastLength
|
sta inflateDynamic_lastLength
|
||||||
; jmp inflateDynamicBlock_decodeLength
|
; jmp inflateDynamic_decodeLength
|
||||||
beq inflateDynamicBlock_decodeLength
|
beq inflateDynamic_decodeLength
|
||||||
inflateDynamicBlock_controlSymbolCodeLength
|
inflateDynamic_controlSymbolCodeLength
|
||||||
cpx inflateDynamicBlock_primaryCodes
|
cpx inflateDynamic_primaryCodes
|
||||||
bcc inflateDynamicBlock_storeControl
|
bcc inflateDynamic_storeControl
|
||||||
; the code lengths we skip here were zero-initialized
|
; the code lengths we skip here were zero-initialized
|
||||||
; in inflateDynamicBlock_clearCodeLengths
|
; in inflateDynamic_clearCodeLengths
|
||||||
sne:ldx #LENGTH_SYMBOLS
|
sne:ldx #LENGTH_SYMBOLS
|
||||||
ora #DISTANCE_TREE
|
ora #DISTANCE_TREE
|
||||||
inflateDynamicBlock_storeControl
|
inflateDynamic_storeControl
|
||||||
sta controlSymbolCodeLength,x+
|
sta controlSymbolCodeLength,x+
|
||||||
cpx inflateDynamicBlock_allCodes
|
cpx inflateDynamic_allCodes
|
||||||
bcc inflateDynamicBlock_storeNext
|
bcc inflateDynamic_storeNext
|
||||||
dey
|
dey
|
||||||
; ldy #0
|
; ldy #0
|
||||||
; jmp inflateCodes
|
; jmp inflateCodes
|
||||||
|
@ -245,35 +245,35 @@ inflateCodes_copyByte
|
||||||
buildTempHuffmanTree
|
buildTempHuffmanTree
|
||||||
; ldy #0
|
; ldy #0
|
||||||
tya
|
tya
|
||||||
inflateDynamicBlock_clearCodeLengths
|
inflateDynamic_clearCodeLengths
|
||||||
sta literalSymbolCodeLength,y
|
sta literalSymbolCodeLength,y
|
||||||
sta literalSymbolCodeLength+TOTAL_SYMBOLS-256,y
|
sta literalSymbolCodeLength+TOTAL_SYMBOLS-256,y
|
||||||
iny
|
iny
|
||||||
bne inflateDynamicBlock_clearCodeLengths
|
bne inflateDynamic_clearCodeLengths
|
||||||
; numberOfPrimaryCodes = 257 + getBits(5)
|
; numberOfPrimaryCodes = 257 + getBits(5)
|
||||||
; numberOfDistanceCodes = 1 + getBits(5)
|
; numberOfDistanceCodes = 1 + getBits(5)
|
||||||
; numberOfTemporaryCodes = 4 + getBits(4)
|
; numberOfTemporaryCodes = 4 + getBits(4)
|
||||||
ldx #3
|
ldx #3
|
||||||
inflateDynamicBlock_getHeader
|
inflateDynamic_getHeader
|
||||||
lda inflateDynamicBlock_headerBits-1,x
|
lda inflateDynamic_headerBits-1,x
|
||||||
jsr getBits
|
jsr getBits
|
||||||
; sec
|
; sec
|
||||||
adc inflateDynamicBlock_headerBase-1,x
|
adc inflateDynamic_headerBase-1,x
|
||||||
sta inflateDynamicBlock_tempCodes-1,x
|
sta inflateDynamic_tempCodes-1,x
|
||||||
dex
|
dex
|
||||||
bne inflateDynamicBlock_getHeader
|
bne inflateDynamic_getHeader
|
||||||
|
|
||||||
; Get lengths of temporary codes in the order stored in tempCodeLengthOrder
|
; Get lengths of temporary codes in the order stored in inflateDynamic_tempSymbols
|
||||||
; ldx #0
|
; ldx #0
|
||||||
inflateDynamicBlock_getTempCodeLengths
|
inflateDynamic_getTempCodeLengths
|
||||||
lda #GET_3_BITS
|
lda #GET_3_BITS
|
||||||
jsr getBits
|
jsr getBits
|
||||||
ldy tempCodeLengthOrder,x
|
ldy inflateDynamic_tempSymbols,x
|
||||||
sta literalSymbolCodeLength,y
|
sta literalSymbolCodeLength,y
|
||||||
ldy #0
|
ldy #0
|
||||||
inx
|
inx
|
||||||
cpx inflateDynamicBlock_tempCodes
|
cpx inflateDynamic_tempCodes
|
||||||
bcc inflateDynamicBlock_getTempCodeLengths
|
bcc inflateDynamic_getTempCodeLengths
|
||||||
|
|
||||||
; Build Huffman trees basing on code lengths (in bits)
|
; Build Huffman trees basing on code lengths (in bits)
|
||||||
; stored in the *SymbolCodeLength arrays
|
; stored in the *SymbolCodeLength arrays
|
||||||
|
@ -419,11 +419,13 @@ storeByte_return
|
||||||
getNPlus1Bits_mask
|
getNPlus1Bits_mask
|
||||||
dta GET_1_BIT,GET_2_BITS,GET_3_BITS,GET_4_BITS,GET_5_BITS,GET_6_BITS,GET_7_BITS
|
dta GET_1_BIT,GET_2_BITS,GET_3_BITS,GET_4_BITS,GET_5_BITS,GET_6_BITS,GET_7_BITS
|
||||||
|
|
||||||
tempCodeLengthOrder
|
inflateDynamic_tempSymbols
|
||||||
dta GET_2_BITS,GET_3_BITS,GET_7_BITS,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15
|
dta GET_2_BITS,GET_3_BITS,GET_7_BITS,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15
|
||||||
|
|
||||||
inflateDynamicBlock_headerBits dta GET_4_BITS,GET_5_BITS,GET_5_BITS
|
inflateDynamic_headerBits
|
||||||
inflateDynamicBlock_headerBase dta 3,LENGTH_SYMBOLS,0
|
dta GET_4_BITS,GET_5_BITS,GET_5_BITS
|
||||||
|
inflateDynamic_headerBase
|
||||||
|
dta 3,LENGTH_SYMBOLS,0
|
||||||
|
|
||||||
org inflate_data
|
org inflate_data
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user