Much
tile compression on the NES, Game Boy, and Super NES works by repeating entire bytes. This works on tiles with blank areas or vertical lines.
Attachment:
pb53_illustrated.png [ 1.44 KiB | Viewed 2465 times ]
This glyph for 'A' transforms into the following tile data:
Code:
3c 69 69 7e 69 69 69 00 00 00 00 00 00 00 00 00
The PB53 codec first looks for consecutively repeated bytes within each 8-byte run, which roughly correspond to a pixel row being the same as the row above it:
Code:
3c 69 << 7e 69 << << 00 00 << << << << << << <<
Then it encodes which bytes are repeats:
Code:
00100110 01111111 = 26 7f
Interleaving these with the bytes that aren't consecutive repeats gives the isolated packet PB8 representation:
Code:
26 3c 69 7e 69 00 7f 00
But because some specific data patterns for a single plane (all $00, all $FF, identical to the first, or the ones' complement of the first) are so common, PB53 has short codes for them. The code for eight $00 bytes is
$80, producing the following 7-byte PB53 representation:
Code:
26 3c 69 7e 69 00 80
The compression format used in Codemasters games (
cracked by tokumaru) and an
improved format designed by tokumaru are more horizontal level pixel RLE. Because they run once for each pixel rather than each byte, they take longer to decompress, but in some cases, they perform better.