CHR is a 2-bit graphics format.
The CHR
file contains a series of bits equivalent to pixels in a 8x8 tile. The data for each tile is made up of 128 bits, where the first 64 bits are the first channel, the next 64 bits the second channel, and their overlap result in a total of 4 possible colors.
ch1 + ch2 | hex | ||||||||
---|---|---|---|---|---|---|---|---|---|
1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | f8 | 00 |
1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | f8 | 00 |
1 | 1 | 3 | 3 | 3 | 2 | 2 | 0 | f8 | 3e |
1 | 1 | 3 | 3 | 3 | 2 | 2 | 0 | f8 | 3e |
1 | 1 | 3 | 3 | 3 | 2 | 2 | 0 | f8 | 3e |
0 | 0 | 2 | 2 | 2 | 2 | 2 | 0 | 00 | 3e |
0 | 0 | 2 | 2 | 2 | 2 | 2 | 0 | 00 | 3e |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 00 | 00 |
This is the standard format for the Famicom and Varvara ecosystems, to view and edit chr files, try Nasu. To convert images from the tga format, use tgachr.
Uint8 tile[16] = { 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x00 }; void draw_chr(Uint32 *dst, int x, int y, Uint8 *sprite) { int v, h; for(v = 0; v < 8; v++) for(h = 0; h < 8; h++) { int ch1 = ((sprite[v] >> h) & 0x1); int ch2 = (((sprite[v + 8] >> h) & 0x1) << 1); put_pixel(dst, x + 7 - h, y + v, ch1 + ch2); } }
- ICN/CHR Toolchain, viewer and converter.
incoming nasu oekaki tools dito dotgrid metadata potato icn format nmt format ulz format varvara