Shorten the code by one byte.

This commit is contained in:
Piotr Fusik 2017-02-07 11:18:27 +01:00
parent 15c46f525e
commit bc8b90cf24
2 changed files with 18 additions and 17 deletions

View File

@ -11,9 +11,11 @@ In 2007 I optimized it so it is about 30% shorter and 10% faster than before.
Compilation
-----------
Use [xasm](https://github.com/pfusik/xasm).
The routine uses three memory areas:
* `inflate` - code and initialized data (509 bytes)
* `inflate` - code and initialized data (508 bytes)
* `inflate_data` - uninitialized data (764 bytes)
* `inflate_zp` - variables on zero page
@ -23,15 +25,12 @@ You must select these locations at compile time, for example:
(escape the dollars if in Unix shell or Makefile).
Source code uses [xasm](https://github.com/pfusik/xasm) syntax.
This cross-assembler includes many original syntax extensions.
Usage
-----
The `inflate` routine assumes that the compressed and uncompressed data fit
in the memory. Before calling `inflate` set the locations of compressed
and uncompressed data in zero-page variables:
The `inflate` routine assumes that the compressed and the uncompressed data
fit in the memory. Before calling `inflate`, set the locations
of the compressed and the uncompressed data in the zero-page variables:
mwa #compressedData inflate_zp
mwa #uncompressedData inflate_zp+2
@ -69,8 +68,8 @@ which used the standard [zlib library](http://www.zlib.net/).
However, better compression can be obtained with [7-Zip](http://7-zip.org/).
It supports the gzip format which is a thin layer on top of DEFLATE.
My program `gzip2deflate` extracts the DEFLATE stream from a gzip file.
It reads gzip on standard input and writer DEFLATE to standard output.
I recommend using it like this:
It reads gzip on its standard input and writes DEFLATE to its standard output.
I recommend using it this way:
7z a -tgzip -mx=9 -so dummy INPUT_FILE | gzip2deflate >OUTPUT_FILE.dfl
@ -80,11 +79,11 @@ If you don't have 7-Zip, use:
If you are looking for maximum compression, [KZIP](http://advsys.net/ken/utils.htm)
is also worth a try. It creates ZIP files, so I wrote `zip2deflate` to extract
DEFLATE data from ZIP.
DEFLATE data from a ZIP.
Windows binaries of `gzip2deflate` and `zip2deflate` are
[available for download](http://pfusik.github.io/zlib6502/2deflate.zip).
For other platforms you will need to compile these programs yourself.
For other platforms, you will need to compile these programs yourself.
zlib?
-----
@ -92,7 +91,7 @@ zlib?
This project is named zlib6502, but only supports DEFLATE decompression.
Someday I'm going to include more functions, including compression.
Meanwhile, you may look at [cc65](https://github.com/oliverschmidt/cc65) `zlib.h`.
Meanwhile, you may look at [cc65](https://github.com/cc65/cc65) `zlib.h`.
This is my old code, which includes an old version of `inflate`
plus zlib-compatible `uncompress`, `adler32` and `crc32`.
@ -101,7 +100,7 @@ License
This code is licensed under the standard zlib license.
Copyright (C) 2000-2013 Piotr Fusik
Copyright (C) 2000-2017 Piotr Fusik
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@ -1,10 +1,10 @@
; inflate - uncompress data stored in the DEFLATE format
; by Piotr Fusik <fox@scene.pl>
; Last modified: 2007-06-17
; Last modified: 2017-02-07
; Compile with xasm (http://xasm.atari.org/), for example:
; xasm inflate.asx /l /d:inflate=$b700 /d:inflate_data=$b900 /d:inflate_zp=$f0
; inflate is 509 bytes of code and initialized data
; inflate is 508 bytes of code and initialized data
; inflate_data is 764 bytes of uninitialized data
; inflate_zp is 10 bytes on page zero
@ -349,9 +349,10 @@ fetchCode_nextBit
clc
rts
fetchCode_control
add nBitCode_controlOffset-1,x
; sec
adc nBitCode_controlOffset-1,x
tax
lda codeToControlSymbol,x
lda codeToControlSymbol-1,x
sec
rts
@ -405,6 +406,7 @@ copyByte
ldy #0
; Write a byte
storeByte
; ldy #0
sta (outputPointer),y
inc outputPointer
bne storeByte_return