Chr
In computing, chr is a type of file format commonly used for graphics (i.e. 3D Max Characters and Homebrew NES Dev Graphics) and character sets.
chr Files In NES Dev
Usage
chr files are used to draw 8x8 tiles for homebrew NES development. To draw graphics for the NES such as backgrounds or sprites, they must be pieced together using 8x8 pixel tiles constrained to 4 colors.
Contents
The contents of a chr file can be summed up as multiple lines of bit strings. For example, take the first line of the chr file for the game Super Mario Bros.
<syntaxhighlight lang="C"> 000000000011000011110001111100010000000011110001110000100100001000000110011001100000000000000000000000000000000000000000000111110000001111110011111101111111 </syntaxhighlight>
When reading the file, it is interpreted as 2 equal length bit strings, such as
<syntaxhighlight lang="C"> String 1 = 0000000000110000111100011111000100000000111100011100001001000010011001100110 String 2 = 0000000000000000000000000000000000000000000000011111001111110011111101111111 </syntaxhighlight>
The position of these 2 bit strings represent a pixel in an 8x8 tile, going in row-column order. The color of the pixel can be found out using a simple formula:
String 1 bit | String 2 bit | Color |
---|---|---|
0 | 0 | 0 |
1 | 0 | 1 |
0 | 1 | 2 |
1 | 1 | 3 |
The color is irrelevant because it is chosen through the code by the programmer with the attribute table, so it is the bit combination that is significant and there is no storage of color values