Tilemap Compression

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
Very interested
Posts: 101
Joined: Fri Apr 15, 2016 2:21 pm

Tilemap Compression

Post by themrcul » Sun Dec 22, 2019 1:02 am

Hello gentlemen,
Up until now I have been compressing my tilesets and sprite tilesets but not my tilemap (plane mappings).

Lately I have been thinking about how much ROM space my plane mappings will be if I leave them uncompressed, and realised that I need to implement some sort of compression otherwise whatever project I attempt will simply not fit in ROM.

Rather than invent the wheel I did some cursory research into what people did back in the day, and it appears that, at least for the Sonic games, Enigma compression was used for tilemaps.
Being an RLE style compression specifically optimised for how tilemap data is usually stored (possibly many repeated runs of the same palette, priority and flip bits, adjacent tiles quite possibly being an incremented address in VRAM in relation to each other, etc), it compresses tilemap data efficiently and, best of all, has random access possibility which is necessary for sending columns and/or rows to VRAM for efficient scrolling while using a minimal use of CPU and RAM to do so.

All that being said, has anyone implemented this sort of compression in their games yet? Has anyone located or written their own version of Enigma that they would be willing to share??
I thought about using the standard LZ4W compressor/decompressor but that does not do random access, and I would need to implement zones of areas in the tilemap and possibly decompress several areas of the tilemap into RAM in order to send the correct columns/rows to VRAM which could get very complicated very quickly! So a random access RLE style compression format specifically tailored to tilemap data is of course ideal!

Very interested
Posts: 505
Joined: Sat Jul 30, 2016 12:33 am

Re: Tilemap Compression

Post by Miquel » Sun Dec 22, 2019 2:20 am

I haven’t studied 16bit Sonic games in detail, but I’m pretty confident they use a several level metatile as main compression system. In that case I don’t think is possible to compress the metatiles themselves, but I don’t know about the (top) map.

Be sure to understand what I'm talking about because most games back then used metatiles and build/compress algorithms based on metatiles.

Aplib is my favorite compression utility, it’s simple, good compression factor but takes too much time to do it on demand, but you can use it several frames ahead is perfect, also (only) the compression algorithm is not public. You can see an example on the SGDK.

Enigma allows random access? I didn’t know that. Is a big point. In that case for sure use it if you need to decompress columns with the benefit of global compression. In case you game goes forward and backward, be sure you compression algorithm allows it.
HELP. Spanish TVs are brain washing people to be hostile to me.

Post Reply