XXIIVV
Nasu on Plan 9
Nasu on Plan 914P10

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 + ch2hex
11111000f800
11111000f800
11333220f83e
11333220f83e
11333220f83e
00222220003e
00222220003e
000000000000

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);
		}
}

incoming nasu oekaki tools dito dotgrid metadata potato icn format nmt format ulz format varvara