Because "Tilemap" and "Character map" can be easy to mix up, I'll just explain both here. The tilemap is a list of the background tiles, being indices pointing towards a character in VRAM. Characters are the tiles you perceive when playing a game: they are the blocks in Mario, but also sprites. To keep it short, a character is the raw image data used for a tile, most of the times 8 by 8 pixels, and the tilemap tells the PPU what characters to draw where.
$2107 - $210A: Tilemap location assignment
The hardware registers $2107
through $210A
are used to assign the size and location of the background layers.
Each of the registers is made up of 2 parts: aaaaaabb
wherein the 6 a-bits make up the location of the tilemap in VRAM divided by 2048 (shift left 11 times). Always check if the starting location of your tilemap is on a multiple of 2048! Because of VRAM only being 64K large, the upmost bit will always be a zero.
The two b-bits are used to declare the size of the tilemap: 00: 32x32 tiles, 01: 64x32 tiles, 10: 32x64 tiles, 11: 64x64 tiles. Using 32x32 tiles with 8x8 px characters (character size is declared in $2105
) will net a 256x256 px background and a 64x64 tile BG with 16x16 px characters will result in an 1024x1024 pixel background. Both of these are very unwieldy; the first because of it being exactly the same width as the screen, making it only useful as a still image, and the second because of it eating up an 8th of the VRAM capacity for a single layer of tile data.
When using a tilemap of 64 tiles wide, the tilemap will be split in two. Instead of making each row of entries 128 bytes large, the tilemap will be split vertically through the middle. The first table will then contain the first 32 tiles of each row while the second table, stored right after the first, will contain the latter 32 tiles. This does not occur when using a tilemap that is 32x64.
$210B & $210C: Character location assignment
$210B (low byte) | $210C (high byte) |
---|---|
bbbbaaaa | ddddcccc |
Herein, a represents the starting location of characters for layer 1, b for layer 2, c for layer 3, and d for layer 4. All of these values have to be multiplied by 8192 to get to the real location in VRAM (aaaa = real location >> 13). Because VRAM is only 64K, the most significant bit of all of the numbers have to be 0.