Log In  


Cart [#37857#] | Copy | Code | 2017-02-26 | Link

This cartridge doesn't have a very impressive test, but the code might be useful to some of you.

This is an implementation of the LZW compression and decompression routines with variable-width coding, commonly used in a few image formats. I've nibble-aligned the codec, and I provide an interface where you can give addresses for compression/decompression.

The way I envision using this is: construct rooms in map #1, then when you're finished, compress them to map #2 or elsewhere in map #1, then store them to the cartridge. When you're finished building rooms, you only need to include the emit/read symbol functions and decomp, which total to about 340 tokens. You can make a table of addresses for loading these rooms during runtime, and it's pretty fast, all things considered.

As for compression ratio, this demo shows a case where it's pretty bad - you could conceivably end up with bigger data than you started with if your data was sufficiently random, but for maps this is often not the case. If you build a table (as described above), you could mix entries for compressed data and entries for "literal" data to only compress when it helps.

In the future, I might provide an interface for compressing sub-rectangles of the map to avoid having to compress empty space (even though, in theory, this will be highly compressible).

Hope you find it useful!

P#37858 2017-02-26 15:15

Log in to post a comment


New User | Account Help
:: New User
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2017-06-29 09:06 | 0.180s | 1572k | Q:14