From SMS Power!

Development: VRAM Memory Map

The most common VRAM layout for Master System and Game Gear games looks like this:

AddressContains
$0000 - $1FFFGraphics for tiles 0 - 255
$2000 - $37FFGraphics for tiles 256 - 447
$3800 - $3EFFTilemap
$3F00 - $3FFFSprite Attribute Table (SAT)

For this arrangement, both VDP Register 2 which controls the Tilemap address, and VDP Register 5 which controls the Sprite Attribute Table address are set to $ff.

Sprite Tiles

The sprite attribute table only allocates one byte to specify the tile index for a sprite, which limits the possible indexes to between 0 and 255.

VDP Register 6 can be changed to decide whether the sprite index points to the graphics starting at either $0000 or $2000.
For example you could load graphics for a dog to $0000 and a cat to $2000. If you set a sprite's tile index to 0 and VDP Register 6 is set to $FB then the sprite will be the dog, but if the register is set to $FF then the sprite will be the cat.

As the Tilemap and Sprite Attribute Table occupy the upper part of VRAM, this means that you can use 256 unique tiles for sprites if VDP Register 6 is $FB or 192 unique tiles for sprites if VDP Register 6 is $FF.

VDP Register 6Sprite Tiles StartUnique Tile count
$FB$0000256
$FF$2000192

Background Tiles

As a tilemap entry uses 9 bits to store the tile index, the possible values are 0 to 511 so the background can use any tile.

Freeing up more space for tiles

Depending on how the software works, it's possible to use some space in the Tilemap and Sprite Attribute table to store extra tile graphics.

As there is a 64 byte long stretch of unused space in the Sprite Attribute Table, 2 extra tiles can be loaded in at $3F40. These will be at sprite index 250 ($FA) and tilemap index 506 ($1FA).

If the game does not scroll vertically, the tilemap data for the 4 lowest rows of the tilemap between $3E00 and $3EFF can be used to store 8 extra tiles. These will be located starting at sprite index 240 ($F0) and tilemap index 496 ($1F0).

If you restrict your software to using a maximum of 31 or 15 sprites, part of the Sprite Allocation Table itself can be used to store tiles. If for example we decide to use 31 sprites at most, we can put $D0 in the Y coordinate entry of the 32nd sprite at $3F1F to ensure that the following 32 sprites won't be drawn. The 32 bytes of remaining Y coordinates between $3F20 and $3F3F and the 64 bytes between $3FC0 and $3FFF which would store the X coordinates and tile indexes of those sprites are then free to store a total 3 extra tile graphics.

Additional Tilemaps

If you are willing to sacrifice some tile graphics space, you can also reserve some VRAM for an additional Tilemap. Using VDP Register 2 you can then switch from one Tilemap to another instantly.

Potential uses for this include:


Retrieved from //www.smspower.org/Development/VRAMMemoryMap
Page last modified on Thu Mar 07, 2024 3:52 pm