Thread:Discordstew/@comment-13254338-20140706230420/@comment-15296152-20140707002019

The header is much like that of GRPs. First 4 bytes are the same. 2nd 4 bytes is the length beginning from PETC (which for CHRs should always be 8204 (or h200C). 3rd 4 bytes is the format, which is 2 for GRPs and 3 for CHRs. Next 8 bytes is the name given. 16 bytes after that is the MD5 hash value, and 12 bytes after that is the format string (that ends with RCHR for CHRs).

Now for the data portion. Unlike GRP's 8-bits per pixel, CHRs are 4-bits per pixel. Each 8x8 pixel block is 32-bytes long, and there are 256 blocks sequentially. Viewed by CHRED or PTCUtilities, this is arranged as 32 blocks per row from left to right, with 8 rows from top to bottom, but when reading CHRs manually, it's just one block after another. You have to read them 1 byte at a time, which will be 2-pixels each read, and then you'll have to split them by grabbing the lower 4-bits then the higher 4-bits, using masks via the AND operator.

PixelLow = Pixel & 0x0F;

PixelHigh = (Pixel & 0xF0) >> 4;