mirror of
https://github.com/pfusik/zlib6502.git
synced 2024-06-08 13:29:27 +00:00
Shorten by one byte.
This commit is contained in:
parent
fd18d5618d
commit
8498d8fde7
|
@ -15,7 +15,7 @@ Use [xasm](https://github.com/pfusik/xasm).
|
||||||
|
|
||||||
The routine uses three memory areas:
|
The routine uses three memory areas:
|
||||||
|
|
||||||
* `inflate` - code and constants (502 bytes)
|
* `inflate` - code and constants (501 bytes)
|
||||||
* `inflate_data` - uninitialized data (764 bytes)
|
* `inflate_data` - uninitialized data (764 bytes)
|
||||||
* `inflate_zp` - variables on zero page
|
* `inflate_zp` - variables on zero page
|
||||||
|
|
||||||
|
|
58
inflate.asx
58
inflate.asx
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
; Compile with xasm (http://xasm.atari.org/), for example:
|
; Compile with xasm (http://xasm.atari.org/), for example:
|
||||||
; xasm inflate.asx /l /d:inflate=$b700 /d:inflate_data=$b900 /d:inflate_zp=$f0
|
; xasm inflate.asx /l /d:inflate=$b700 /d:inflate_data=$b900 /d:inflate_zp=$f0
|
||||||
; inflate is 502 bytes of code and constants
|
; inflate is 501 bytes of code and constants
|
||||||
; inflate_data is 764 bytes of uninitialized data
|
; inflate_data is 764 bytes of uninitialized data
|
||||||
; inflate_zp is 10 bytes on page zero
|
; inflate_zp is 10 bytes on page zero
|
||||||
|
|
||||||
|
@ -69,7 +69,6 @@ inflate_blockLoop
|
||||||
jsr getBits
|
jsr getBits
|
||||||
lsr @
|
lsr @
|
||||||
php
|
php
|
||||||
tax
|
|
||||||
bne inflateCompressed
|
bne inflateCompressed
|
||||||
|
|
||||||
; Copy uncompressed block
|
; Copy uncompressed block
|
||||||
|
@ -82,9 +81,7 @@ inflate_blockLoop
|
||||||
bcs inflateStored_firstByte
|
bcs inflateStored_firstByte
|
||||||
inflateStored_copyByte
|
inflateStored_copyByte
|
||||||
jsr getByte
|
jsr getByte
|
||||||
inflateStoreByte
|
|
||||||
jsr storeByte
|
jsr storeByte
|
||||||
bcc inflateCodes_loop
|
|
||||||
inflateStored_firstByte
|
inflateStored_firstByte
|
||||||
inx
|
inx
|
||||||
bne inflateStored_copyByte
|
bne inflateStored_copyByte
|
||||||
|
@ -97,35 +94,42 @@ inflate_nextBlock
|
||||||
rts
|
rts
|
||||||
|
|
||||||
inflateCompressed
|
inflateCompressed
|
||||||
|
; A=1: fixed block, initialize with fixed codes
|
||||||
|
; A=2: dynamic block, start by clearing all code length
|
||||||
|
; A=3: invalid compressed data, not handled here
|
||||||
|
eor #2
|
||||||
|
|
||||||
; Decompress a block with fixed Huffman trees:
|
; ldy #0
|
||||||
|
inflateCompressed_setCodeLengths
|
||||||
|
tax
|
||||||
|
beq inflateCompressed_setLiteralCodeLength
|
||||||
|
; fixed Huffman literal codes:
|
||||||
; :144 dta 8
|
; :144 dta 8
|
||||||
; :112 dta 9
|
; :112 dta 9
|
||||||
; :24 dta 7
|
|
||||||
; :6 dta 8
|
|
||||||
; :2 dta 8 ; codes with no meaning
|
|
||||||
; :30 dta 5+DISTANCE_TREE
|
|
||||||
; ldy #0
|
|
||||||
inflateFixed_setCodeLengths
|
|
||||||
lda #4
|
lda #4
|
||||||
cpy #144
|
cpy #144
|
||||||
rol @
|
rol @
|
||||||
|
inflateCompressed_setLiteralCodeLength
|
||||||
sta literalSymbolCodeLength,y
|
sta literalSymbolCodeLength,y
|
||||||
cpy #CONTROL_SYMBOLS
|
beq inflateCompressed_setControlCodeLength
|
||||||
bcs inflateFixed_noControlSymbol
|
; fixed Huffman control codes:
|
||||||
|
; :24 dta 7
|
||||||
|
; :6 dta 8
|
||||||
|
; :2 dta 8 ; meaningless codes
|
||||||
|
; :30 dta 5+DISTANCE_TREE
|
||||||
lda #5+DISTANCE_TREE
|
lda #5+DISTANCE_TREE
|
||||||
cpy #LENGTH_SYMBOLS
|
cpy #LENGTH_SYMBOLS
|
||||||
bcs inflateFixed_setControlCodeLength
|
bcs inflateCompressed_setControlCodeLength
|
||||||
cpy #24
|
cpy #24
|
||||||
adc #2-DISTANCE_TREE
|
adc #2-DISTANCE_TREE
|
||||||
inflateFixed_setControlCodeLength
|
inflateCompressed_setControlCodeLength
|
||||||
sta controlSymbolCodeLength,y
|
cpy #CONTROL_SYMBOLS
|
||||||
inflateFixed_noControlSymbol
|
scs:sta controlSymbolCodeLength,y
|
||||||
iny
|
iny
|
||||||
bne inflateFixed_setCodeLengths
|
bne inflateCompressed_setCodeLengths
|
||||||
|
|
||||||
dex
|
tax
|
||||||
beq inflateCodes
|
bne inflateCodes
|
||||||
|
|
||||||
; Decompress a block reading Huffman trees first
|
; Decompress a block reading Huffman trees first
|
||||||
|
|
||||||
|
@ -173,7 +177,7 @@ inflateDynamic_controlSymbolCodeLength
|
||||||
cpx inflateDynamic_primaryCodes
|
cpx inflateDynamic_primaryCodes
|
||||||
bcc inflateDynamic_storeControl
|
bcc inflateDynamic_storeControl
|
||||||
; the code lengths we skip here were zero-initialized
|
; the code lengths we skip here were zero-initialized
|
||||||
; in inflateDynamic_clearCodeLengths
|
; in inflateCompressed_setControlCodeLength
|
||||||
sne:ldx #LENGTH_SYMBOLS
|
sne:ldx #LENGTH_SYMBOLS
|
||||||
ora #DISTANCE_TREE
|
ora #DISTANCE_TREE
|
||||||
inflateDynamic_storeControl
|
inflateDynamic_storeControl
|
||||||
|
@ -187,9 +191,13 @@ inflateDynamic_storeControl
|
||||||
; Decompress a block
|
; Decompress a block
|
||||||
inflateCodes
|
inflateCodes
|
||||||
jsr buildHuffmanTree
|
jsr buildHuffmanTree
|
||||||
|
; jmp inflateCodes_loop
|
||||||
|
beq inflateCodes_loop
|
||||||
|
inflateCodes_literal
|
||||||
|
jsr storeByte
|
||||||
inflateCodes_loop
|
inflateCodes_loop
|
||||||
jsr fetchPrimaryCode
|
jsr fetchPrimaryCode
|
||||||
bcc inflateStoreByte
|
bcc inflateCodes_literal
|
||||||
beq inflate_nextBlock
|
beq inflate_nextBlock
|
||||||
; Copy sequence from look-behind buffer
|
; Copy sequence from look-behind buffer
|
||||||
; ldy #0
|
; ldy #0
|
||||||
|
@ -244,12 +252,6 @@ inflateCodes_copyByte
|
||||||
|
|
||||||
buildTempHuffmanTree
|
buildTempHuffmanTree
|
||||||
; ldy #0
|
; ldy #0
|
||||||
tya
|
|
||||||
inflateDynamic_clearCodeLengths
|
|
||||||
sta literalSymbolCodeLength,y
|
|
||||||
sta literalSymbolCodeLength+TOTAL_SYMBOLS-256,y
|
|
||||||
iny
|
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user