mirror of
https://github.com/pfusik/zlib6502.git
synced 2024-06-01 12:41:27 +00:00
Shorten the code by one byte.
This commit is contained in:
parent
15c46f525e
commit
bc8b90cf24
25
README.md
25
README.md
|
@ -11,9 +11,11 @@ In 2007 I optimized it so it is about 30% shorter and 10% faster than before.
|
||||||
Compilation
|
Compilation
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
Use [xasm](https://github.com/pfusik/xasm).
|
||||||
|
|
||||||
The routine uses three memory areas:
|
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_data` - uninitialized data (764 bytes)
|
||||||
* `inflate_zp` - variables on zero page
|
* `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).
|
(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
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
The `inflate` routine assumes that the compressed and uncompressed data fit
|
The `inflate` routine assumes that the compressed and the uncompressed data
|
||||||
in the memory. Before calling `inflate` set the locations of compressed
|
fit in the memory. Before calling `inflate`, set the locations
|
||||||
and uncompressed data in zero-page variables:
|
of the compressed and the uncompressed data in the zero-page variables:
|
||||||
|
|
||||||
mwa #compressedData inflate_zp
|
mwa #compressedData inflate_zp
|
||||||
mwa #uncompressedData inflate_zp+2
|
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/).
|
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.
|
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.
|
My program `gzip2deflate` extracts the DEFLATE stream from a gzip file.
|
||||||
It reads gzip on standard input and writer DEFLATE to standard output.
|
It reads gzip on its standard input and writes DEFLATE to its standard output.
|
||||||
I recommend using it like this:
|
I recommend using it this way:
|
||||||
|
|
||||||
7z a -tgzip -mx=9 -so dummy INPUT_FILE | gzip2deflate >OUTPUT_FILE.dfl
|
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)
|
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
|
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
|
Windows binaries of `gzip2deflate` and `zip2deflate` are
|
||||||
[available for download](http://pfusik.github.io/zlib6502/2deflate.zip).
|
[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?
|
zlib?
|
||||||
-----
|
-----
|
||||||
|
@ -92,7 +91,7 @@ zlib?
|
||||||
This project is named zlib6502, but only supports DEFLATE decompression.
|
This project is named zlib6502, but only supports DEFLATE decompression.
|
||||||
Someday I'm going to include more functions, including compression.
|
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`
|
This is my old code, which includes an old version of `inflate`
|
||||||
plus zlib-compatible `uncompress`, `adler32` and `crc32`.
|
plus zlib-compatible `uncompress`, `adler32` and `crc32`.
|
||||||
|
|
||||||
|
@ -101,7 +100,7 @@ License
|
||||||
|
|
||||||
This code is licensed under the standard zlib 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
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
|
10
inflate.asx
10
inflate.asx
|
@ -1,10 +1,10 @@
|
||||||
; inflate - uncompress data stored in the DEFLATE format
|
; inflate - uncompress data stored in the DEFLATE format
|
||||||
; by Piotr Fusik <fox@scene.pl>
|
; 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:
|
; 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 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_data is 764 bytes of uninitialized data
|
||||||
; inflate_zp is 10 bytes on page zero
|
; inflate_zp is 10 bytes on page zero
|
||||||
|
|
||||||
|
@ -349,9 +349,10 @@ fetchCode_nextBit
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
fetchCode_control
|
fetchCode_control
|
||||||
add nBitCode_controlOffset-1,x
|
; sec
|
||||||
|
adc nBitCode_controlOffset-1,x
|
||||||
tax
|
tax
|
||||||
lda codeToControlSymbol,x
|
lda codeToControlSymbol-1,x
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
@ -405,6 +406,7 @@ copyByte
|
||||||
ldy #0
|
ldy #0
|
||||||
; Write a byte
|
; Write a byte
|
||||||
storeByte
|
storeByte
|
||||||
|
; ldy #0
|
||||||
sta (outputPointer),y
|
sta (outputPointer),y
|
||||||
inc outputPointer
|
inc outputPointer
|
||||||
bne storeByte_return
|
bne storeByte_return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user