Tiles and Planes: How Graphics Work

The Megadrive / Genesis uses three planes to display graphics. Planes A and B are used for the 2 scrolling playfields and 1 Sprite plane. Each plane is made up of tiles. Each tile is made of an 8×8 sprite. These tiles are the basic units when it comes to loading and displaying graphics on the Megadrive.

Creating a Tile

In order to demonstrate how graphics work, we are going to create a struct which contains data for a tile. For each pixel we will give it a hexadecimal value that will represent the colour index of the chosen palette. We can use values from 0 to 15 (F in hex) with a total of 16 possible values.

This means that the colour palette can have 16 different colours.

I have created a MI_TILE constant to reference the tile, we will then load this tile into the first position (1) of the VRAM.

To show this tile on screen we use the following code;

VDP_loadTileData: This loads the tile at position 1. We don’t load it at 0, because that would fill the background with the tile. Remember Position 0 in VRAM is for the background tiling.

VDP_setTileMapXY: This draws the tile on Plane A at position 5,5. This is in tiles remember and not in pixels. 1 Tile is 8×8 pixels, so in pixels this is the position 40,40. Since we have not previously defined a palette, the Sega Genesis Development Kit uses grey as a default.

When we compile the code and run it in the Genesis emulator we get;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s