Designing

Okay... we have our skeleton code, we are ready to add things to it. Before we start coding, we must think about what exactly we are going to make.

First lets overview some things. The DS screen resolution is 256x192 pixels, there are two screens. We have an input directional pad, A/B/X/Y buttons, two shoulder buttons, start/select buttons, and a touchscreen button.

Now, unlike the GBA, which only has one display engine that goes with one screen, the DS basically duplicated the display engine so it has display engine A and B. Display engine A is more powerful than B so it can be considered to be the main display engine. Display engine B can be called the sub display engine. In this tutorial we will only use the main display engine.

Both display engines can be switched into a bunch of video modes. There is a very very good document about DS hardware called GBATEK. It's written by the author of the no$gba emulator. It's called GBATEK because it dates back to when GBA homebrew was very popular. Now it has a complete DS section that explains the inner workings all of the hardware in great detail. One of the sections of GBATEK contain a list of the video modes each display engine can use. I pretty much copied that section to make the table below.

Video modes

The video mode is composed of multiple settings. First, we have 7 background modes. Here is a list of the BG modes the DS can use, each BG mode has different behavior for each of the backgrounds.

ModeBG0BG1BG2BG3
0Text/3DTextTextText
1Text/3DTextTextAffine
2Text/3DTextAffineAffine
3Text/3DTextTextExtended
4Text/3DTextAffineExtended
5Text/3DTextExtendedExtended
63DNot usedLargeNot used

Each display engine has 4 backgrounds, BG0, BG1, BG2, and BG3. We see in mode 2 that BG2 and BG3 are set to Affine mode. This mode similar to the one available on the GBA, it allows 8-bit tile display that can be rotated and/or scaled.

Extended BGs have superpowers and may be used to display rot/scale (rot/scale means it can be rotated and scaled!) bitmaps.

Mode 0 will be okay for our purpose in this game. Here is another picture of the game highlighting the different entities.

BG0 will be used to draw the bricks. BG1 will be used to draw the top gradient (alpha blended with backdrop). And the ball will use sprites. All of the BGs will use 16 color tiles, and will have no rotation effects applied, so a Text (plain) BG will work for us. It's called a Text BG because the tiles can also be called characters. So the text bg displays an array of tiles/characters on the screen.

Now, along with the BG mode, there is another setting that affects the display. GBATEK calls it the display mode. There are 4 display modes that the main engine can use.

Display ModeDescription
0Display off. Screen becomes white. It is still rendered, but not displayed.
1Normal display (backgrounds+sprites)
2VRAM display (bitmap display from VRAM memory block)
3Main memory display (view bitmap in main ram)

We will use mode 1 to display our backgrounds and sprite.

Now, the sub display engine is not as powerful as the main display engine. The sub display cannot use display modes 2 and 3, it also cannot render any 3D stuff so BG mode 6 is off limits, and BG0 is always text. The main display engine can use BG0 to display 3D graphics.

Input

The input is simple, we will use only the directional pad to tweak the velocity of the bouncing ball.

Previous: Setting up your projectContentsNext: Program Flow