Nintendo DS 2D HW Tutorials
Lesson 1: Nintendo DS Hardware Overview
Table of content
Welcome to the first tutorial of my Nintendo DS 2D Hardware lessons series.
This lesson will overview most information regarding the Nintendo DS’d 2D hardware backgrouds, basic terms and theory, and some of the abilities and limitations of tiled backgrounds.
A tiled background (also called a text BG) consists of a collection of tiles and a map. A palette is a collection of either 16 or 256 colors. A tile is a collection of 64 pixels forming a rectangle 8 pixels wide and 8 pixels tall. A tile’s colors are defined by the tile’s color palette. A tile set is a collection of tiles. A tile set can contain up to 1024 tiles, and the tiles are numbered by their position in the tile set. The number given to a tile in a tile set is called tile index. The first tile in a tile set has an index of 0, an the last tile has an index of 1023. A map is a collection of 32×32 (or more) tiles. A map contains tile index data and other flags, explained later.
Tile – Collection of 64 pixels forming an 8×8 rectangle.
Tile Set – Collection of 1024 tiles numerically ordered from 0 to 1023.
Palette – A collection of 256 colors (or 16 sub-palettes of 16 colors each).
Map – A 2D array of 32×32 tiles (dependent on the BG set up).
Map Bases and Tile Bases
The terms map base and tile base refer to a location in the VRAM (Video RAM – where our video data is being saved) that stores map data or tile data. As you might have guessed, map bases store a map’s data and tile bases store tiles’ data. Since the basic size of a map is 32×32 tiles, and each tile entry of a map is 2 bytes (Will be explained later), each map base sized 32x32x2 bytes, or 2Kbytes.
As been told before, a tile is a collection of 64 pixels. But what is the size of a pixel? The DS supports two different color modes for tiles in text backgrounds. The 256-color mode specifies a pixel to be an index to the 256-color palette. The index is an integer between 0 – 255, respectively. Such a pixel is stored as a 8 bits (one byte). This coloring mode is often called an 8-bit color mode.
On the other hand, in the other color mode, 16-color mode, tiles use a 16 colors palette. Pixel values range from 0 to 15, inclusive. Such pixels occupy 4 bits, or half a byte. This mode has the advantage of requiring less memory, thus allowing for many more kinds of tiles and other graphic elements that are stored in VRAM. However, because only 16 colors can be displayed per-tile, the image might not look as good.
A single tile base is 16Kbytes. Which means 16384b / (1b * 64) of tiles in 8bit (1b) mode, which results a 256 tiles per tile base. Since 4bit (Half a byte) is half the size, it will occupy half the space and double the capacity – 512 tiles in 16 colors mode per tile base.
Different color modes effect differently on tile base capacity
Map bases always have 32×32 entries. To create bigger BGs (Like 64×64) you need to use several map bases. As for tile bases – If you want to make use of the full tileset (1024 tiles), you will have to use several tile bases – 4 Tile bases for 256col full tileset, and 2 Tile bases for full tileset of 16col mode. Since the Map bases and the Tile bases are located on the same region in VRAM, they can overlap. Since a map base is 2Kbytes and a Tile base is 16Kbytes, each Tile base contains 8 Map bases.
Sub core – This core is considered as the weakest core. It has only 5 different Video modes.
Main core – This core is working the same as the sub core, but has more features. It is able to reallocate more VRAM, and has the ability to render basic vertex 3D with a 2048 polygon limit and several vertex shaders such as Toon Shading. It also has an extra video mode called Mode6. In addition, the display capture device is capable to take a capture screens only from this core.
Overview on the DS’s video modes.
Please note that BG0 can be replaced by a 3D layer in any mode.
There are three different BG types, Each with it’s own unique attributes. All of the BGs except for the Extended Rotoscale BG are made of Map, Tiles and Palette. Extended Rotoscale BGs are made of an Image buffer (Called Framebuffer) and a Palette if the BG is working in 256 colors mode. Extended rotoscale BGs are also capable of being used as a normal rotate scale background with a full tileset (normal rotoscale BG has only 256 tiles) in a full 256 extended palette mode.
Scaling – Another hardware feature that lets you change the background’s zoom value, making it look closer or further on both X and Y axis.
Rotating - In addition to zooming, rotascale BGs can also be rotated by any degree.
I’m sure that you have read a lot of info and you must be confused. Don’t be nervous – it IS a lot of info. Don’t forget that this page can be used as reference any time. If anything is unclear, feel free to ask me questions on the contact page.
Please report any mistakes or typos you see on this page, to let other readers enjoy this tutorial.