Log In  

I've been doing some experiments with LZW compress/decompress lately to retake some work on my Isometric engine so I could manage bigger tilesets (compress on string or memory, spr bank switching, etc). Reasonably happy on how this is working... it's a straight forward LZW with 256 dictionary size and 16 root symbols (a.k.a. 16 colour indexes). Works quite well for moderately big images but fares quite badly the moment it runs out of dictionary entries as dictionary is not optimized but generated dynamically both in compression and decompression and it potentially wastes entries with low re-usability or even foldable into later entries (f.e. long single colour runs that would do better on RLE)

Unsure if this will help anyone as there's already other compression solutions through the bbs, but here it goes in case you feel like it can be useful.

See the code for info on how to use it, the compression generates a small header (2 bytes for width/height) and the compressed string. The decompression can use pset/sset/mset or an internal pxset function that can write screen-format blocks at arbitrary memory addresses (lower performance than native funcs if you are writing to spr,map or screen though).

The cart shows 3 32x32 sprites (512b) displayed with SPR and compressed->decompressed with LZW equivs along compression ratios info.

Cart #lzw_experiment-0 | 2021-08-27 | Code ▽ | Embed ▽ | Forks ▽ | License: CC4-BY-NC-SA
3

P#96541 2021-08-27 20:59 ( Edited 2021-08-27 21:02)


[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2022-09-27 06:46:44 | 0.006s | Q:11