🍩 Donut NES CHR Codec 🗜️

Donut is a compression codec for the native texture data of a Nintendo Entertainment System (NES). It operates by a fixed decoded block size of 64 bytes, and saves about 45% in compressed size. Compared to 47% saved by Tokumaru's tile compression but much faster.

Along with the space savings Donut decoding features real time decoding speed of about 16~32 tiles per NTSC frame and a flexible decoding address to allow direct placement in a PPU buffer format at runtime.

Downloads

NES demo (to be finished)

Compressor and cc65 Decompresion routines (updated 2023-12-21)

The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

The Donut Codec is included in the standard library of NESFab

Frequently Asked Questions (FAQ)

Is this Y2K-compliant?
Yes. Donut doesn't handle dates. Also I wasn't even programing computers back then.

Lossy or lossless compression?
Lossless, unless you specify bits to lose with the encoder's "don't care bits" option. This may be useful for static images that have sprite overlays.

How does this compare to ZIP/Deflate?
Donut is worst, but good luck getting Deflate implmented and running on a 6502 machine with only 2K of RAM. Tangentially LZ4 is also better then Donut for general data and has been implmented for the NES.

What Copyright License is this?
Public domain.

Where's the GitHub page?
I am not intrested in maintaining an official GitHub repository at this time.

Do I have to include donut.s for my NESDev Compo '2x or Mapper 28 Project?
No.

Will this work with CHR ROM?
No, to upload to PPU adresses $0000~$1fff the cartridge configuration will need to map RAM there.

Does this work for a SNES Project?
While I have not tried it myself, I've been told that block decompression gives decent results when compiled for the 65c816 and ran in 8-bit mode. This is not too surprising as most SNES texture data is still a bytewise planner format.