pfusik / zlib6502 Goto Github PK
View Code? Open in Web Editor NEW6502 inflate routine
6502 inflate routine
I'm pretty sure this file: rep16.bin.gz will not decode properly. The literal/length Huffman tree has 256 symbols whose code length is 9. This will overflow nBitCode_totalCount
.
I imagine this is not a very common case but nonetheless I think it should be fixed. I've not the 6502 experience to suggest a good approach but it is clear that at most only one code length of the tree can possibly have 256 symbols. I expect handling that possible special case shouldn't add too much code or slow things down very much.
It pains me to report this bug as the subroutine is a wonderful piece of work with some very good insights into the deflate format from an 8-bit perspective.
This file has 258 symbols with code length 9 and 4 symbols with code length 10. The 258 symbols of code length 9 include all 256 literal values. And, of course, there are some other code lengths in order to balance out the tree.
Constructed as before by crafting an input file and passing it to gzip -9
. Here's hoping the code handles this case correctly already.
I am trying to decompress data behind the basic or the kernal ROM on a commodore 64.
If you are not familiar with the C64, in the shadowed areas, reads return the ROM data, writes go to the RAM under it.
Decompressing the exact same data to regular RAM and then using memcpy to the shadowed area work perfectly.
I suspect inflatemem reads from the destination area during decompression.
I looked at the inflatemem source but I can't figure out if my theory is correct.
I would really appreciate any help/insight you could provide.
Here's a compressed file with 258 literal/length symbols having the same code length:
Specifically, symbols 0 through 257 have 10 bit Huffman codes. All 256 literals appear and have the same code length.
This file was generated by crafting an input file and passing it to "gzip -9". It would be possible to add a few more "length" symbols with Huffman code length 10 but I'm guessing this is a sufficient test case.
With 256 literals the same length nBitCode_literalCount
will have an entry that overflows to zero.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.