Optiroc / SuperFamiconv

Flexible and composable tile graphics converter supporting Super Nintendo, Game Boy, Game Boy Color, Game Boy Advance, Mega Drive, PC Engine and WonderSwan formats.
MIT License
143 stars 20 forks source link

Tile scrambler #33

Open basxto opened 3 years ago

basxto commented 3 years ago

When a tilemap is used, the actual tile order in vram does not really matter. So it would be cool to have an option to reorder them.

The easiest versions would be:

Those two could even get combined.

More complex versions would reorder them to improve tile compression:

This would be an option of superfamiconv tiles, I'd call it --scramble or --reorder

Optiroc commented 3 months ago

Reordering to improve compression is a cool idea! I’m a bit intimidated by search space / algorithmic complexity of it though…

basxto commented 3 months ago

Optimizing for repeated byte sequences in LZ would be indeed quite complex. Runs should be easier, but yes, there would be always some complexity.

For runs it would be: What symbol a tile starts with and with which it ends and how often those are repeated; with planes in mind that would be per tile per lane.

For a start it might be enough to have a permutation format, that would allow scrambling or reordering with external tools. That would also split ordering from conversion and allow to order it once and then convert it a lot of times (unconverted images in a git repo).