video.h File Reference

contains the basic defnitions for controlling the video hardware. More...

#include <nds/ndstypes.h>
#include <nds/arm9/sassert.h>

Defines

#define ARGB16(a, r, g, b)   ( ((a) << 15) | (r)|((g)<<5)|((b)<<10))
 Macro to convert 5 bit r g b components plus 1 bit alpha into a single 16 bit ARGB triplet.
#define OAM   ((u16*)0x07000000)
 pointer to Object Attribute Memory
#define OAM_SUB   ((u16*)0x07000400)
 pointer to Object Attribute Memory (Sub engine)
#define RGB15(r, g, b)   ((r)|((g)<<5)|((b)<<10))
 Macro to convert 5 bit r g b components into a single 15 bit RGB triplet.
#define SCREEN_HEIGHT   192
 Screen height in pixels.
#define SCREEN_WIDTH   256
 Screen width in pixels.
#define VRAM_A   ((u16*)0x6800000)
 pointer to vram bank A mapped as LCD
#define VRAM_B   ((u16*)0x6820000)
 pointer to vram bank B mapped as LCD
#define VRAM_C   ((u16*)0x6840000)
 pointer to vram bank C mapped as LCD
#define VRAM_D   ((u16*)0x6860000)
 pointer to vram bank D mapped as LCD
#define VRAM_E   ((u16*)0x6880000)
 pointer to vram bank E mapped as LCD
#define VRAM_E_EXT_PALETTE   ((_ext_palette *)VRAM_E)
 Used for accessing vram E as an extended palette.
#define VRAM_F   ((u16*)0x6890000)
 pointer to vram bank F mapped as LCD
#define VRAM_F_EXT_PALETTE   ((_ext_palette *)VRAM_F)
 Used for accessing vram F as an extended palette.
#define VRAM_F_EXT_SPR_PALETTE   ((_palette *)VRAM_F)
 Used for accessing vram F as an extended sprite palette.
#define VRAM_G   ((u16*)0x6894000)
 pointer to vram bank G mapped as LCD
#define VRAM_G_EXT_PALETTE   ((_ext_palette *)VRAM_G)
 Used for accessing vram G as an extended palette.
#define VRAM_G_EXT_SPR_PALETTE   ((_palette *)VRAM_G)
 Used for accessing vram G as an extended sprite palette.
#define VRAM_H   ((u16*)0x6898000)
 pointer to vram bank H mapped as LCD
#define VRAM_H_EXT_PALETTE   ((_ext_palette *)VRAM_H)
 Used for accessing vram H as an extended palette.
#define VRAM_I   ((u16*)0x68A0000)
 pointer to vram bank I mapped as LCD
#define VRAM_I_EXT_SPR_PALETTE   ((_palette *)VRAM_I)
 Used for accessing vram I as an extended sprite palette.

Typedefs

typedef _palette _ext_palette [16]
 An array of 16 256-color palettes.
typedef u16 _palette [256]
 an array of 256 15-bit RGB values

Enumerations

enum  VideoMode { ,
  MODE_1_2D = 0x10001,
  MODE_2_2D = 0x10002,
  MODE_3_2D = 0x10003,
  MODE_4_2D = 0x10004,
  MODE_5_2D = 0x10005,
  MODE_6_2D = 0x10006,
  MODE_0_3D = (0x10000 | (1 << 8) | (1<<3) ),
  MODE_1_3D = (0x10001 | (1 << 8) | (1<<3) ),
  MODE_2_3D = (0x10002 | (1 << 8) | (1<<3) ),
  MODE_3_3D = (0x10003 | (1 << 8) | (1<<3) ),
  MODE_4_3D = (0x10004 | (1 << 8) | (1<<3) ),
  MODE_5_3D = (0x10005 | (1 << 8) | (1<<3) ),
  MODE_6_3D = (0x10006 | (1 << 8) | (1<<3) ),
  MODE_FIFO = (3<<16),
  MODE_FB0 = (0x00020000),
  MODE_FB1 = (0x00060000),
  MODE_FB2 = (0x000A0000),
  MODE_FB3 = (0x000E0000)
}
 The allowed video modes of the 2D processors
. More...
enum  VRAM_A_TYPE
 Allowed VRAM bank A modes.
enum  VRAM_B_TYPE
 Allowed VRAM bank B modes.
enum  VRAM_C_TYPE
 Allowed VRAM bank C modes.
enum  VRAM_D_TYPE
 Allowed VRAM bank D modes.
enum  VRAM_E_TYPE
 Allowed VRAM bank E modes.
enum  VRAM_F_TYPE
 Allowed VRAM bank F modes.
enum  VRAM_G_TYPE
 Allowed VRAM bank G modes.
enum  VRAM_H_TYPE
 Allowed VRAM bank H modes.
enum  VRAM_I_TYPE
 Allowed VRAM bank I modes.

Functions

void setBrightness (int screen, int level)
static bool video3DEnabled ()
 determine if 3D is enabled
static void videoBgDisable (int number)
 disables the specified background on the main engine
static void videoBgDisableSub (int number)
 disables the specified background on the sub engine
static void videoBgEnable (int number)
 enables the specified background on the main engine
static void videoBgEnableSub (int number)
 enables the specified background on the sub engine
static int videoGetMode ()
 return the main 2D engine video mode
static int videoGetModeSub ()
 return the main 2D engine video mode
static void videoSetMode (u32 mode)
 the main 2D engine video mode
static void videoSetModeSub (u32 mode)
 the sub 2D engine video mode
void vramRestoreMainBanks (u32 vramTemp)
 Set the main 4 bank modes.
static void vramSetBankA (VRAM_A_TYPE a)
 Set bank A to the indicated mapping.
static void vramSetBankB (VRAM_B_TYPE b)
 Set bank B to the indicated mapping.
static void vramSetBankC (VRAM_C_TYPE c)
 Set bank C to the indicated mapping.
static void vramSetBankD (VRAM_D_TYPE d)
 Set bank D to the indicated mapping.
static void vramSetBankE (VRAM_E_TYPE e)
 Set bank E to the indicated mapping.
static void vramSetBankF (VRAM_F_TYPE f)
 Set bank F to the indicated mapping.
static void vramSetBankG (VRAM_G_TYPE g)
 Set bank G to the indicated mapping.
static void vramSetBankH (VRAM_H_TYPE h)
 Set bank H to the indicated mapping.
static void vramSetBankI (VRAM_I_TYPE i)
 Set bank I to the indicated mapping.
u32 vramSetMainBanks (VRAM_A_TYPE a, VRAM_B_TYPE b, VRAM_C_TYPE c, VRAM_D_TYPE d)
 Set the main 4 bank modes.


Detailed Description

contains the basic defnitions for controlling the video hardware.

Intro

Video.h contains the basic defnitions for controlling the video hardware.

Video Ram Banks

The Nintendo DS has nine banks of video memory which may be put to a variety of uses. They can hold the graphics for your sprites, the textures for your 3D space ships, the tiles for your 2D platformer, or a direct map of pixels to render to the screen. Figuring out how to effectively utilize this flexible but limited amount of memory will be one the most challenging endeavors you will face early homebrew development.

The nine banks can be utilized as enumerated by the VRAM types. Banks are labled A-I. In order to utilize 2D or 3D texture graphics, memory must be mapped for these purposes.

For instance: If you initialize a 2D background on the main engine you will be expected to define both an offset for its map data and an offset for its tile graphics (bitmapped backgrounds differ slightly). These offsets are referenced from the start of 2D background graphics memory. On the main display 2D background graphics begin at 0x6000000.

Without mapping a VRAM bank to this location data written to your background tile and map offsets will be lost.

VRAM banks can be mapped to specific addresses for specific purposes. In our case, any of the 4 main banks amd several of the smaller ones can be mapped to the main 2D background engine.(A B C and D banks are refered to as ìmainî because they are 128KB and flexible in usage)

	vramSetBankA(VRAM_A_MAIN_BG);
	

The above would map the 128KB of VRAM_A to 0x6000000 for use as main background graphics and maps (you can offset the mapping as well and the available offsets are defined in the VRAM_A_TYPE enumberation)


Enumeration Type Documentation

enum VideoMode

The allowed video modes of the 2D processors
.

Main 2D engine
______________________________
|Mode | BG0 | BG1 | BG2 |BG3 |           T = Text
|  0  |  T  |  T  |  T  |  T |           R = Rotation
|  1  |  T  |  T  |  T  |  R |           E = Extended Rotation
|  2  |  T  |  T  |  R  |  R |           L = Large Bitmap background
|  3  |  T  |  T  |  T  |  E |
|  4  |  T  |  T  |  R  |  E |
|  5  |  T  |  T  |  E  |  E |
|  6  |     |  L  |     |    |
-----------------------------

Sub 2D engine
______________________________
|Mode | BG0 | BG1 | BG2 |BG3 |
|  0  |  T  |  T  |  T  |  T |
|  1  |  T  |  T  |  T  |  R |
|  2  |  T  |  T  |  R  |  R |
|  3  |  T  |  T  |  T  |  E |
|  4  |  T  |  T  |  R  |  E |
|  5  |  T  |  T  |  E  |  E |
-----------------------------

Enumerator:
MODE_1_2D  4 2D backgrounds
MODE_2_2D  4 2D backgrounds
MODE_3_2D  4 2D backgrounds
MODE_4_2D  4 2D backgrounds
MODE_5_2D  4 2D backgrounds
MODE_6_2D  4 2D backgrounds
MODE_0_3D  4 2D backgrounds
MODE_1_3D  3 2D backgrounds 1 3D background (Main engine only)
MODE_2_3D  3 2D backgrounds 1 3D background (Main engine only)
MODE_3_3D  3 2D backgrounds 1 3D background (Main engine only)
MODE_4_3D  3 2D backgrounds 1 3D background (Main engine only)
MODE_5_3D  3 2D backgrounds 1 3D background (Main engine only)
MODE_6_3D  3 2D backgrounds 1 3D background (Main engine only)
MODE_FIFO  3 2D backgrounds 1 3D background (Main engine only)
MODE_FB0  video display from main memory
MODE_FB1  video display directly from VRAM_A in LCD mode
MODE_FB2  video display directly from VRAM_B in LCD mode
MODE_FB3  video display directly from VRAM_C in LCD mode


Function Documentation

void setBrightness ( int  screen,
int  level 
)

Parameters:
screen 1 = main screen, 2 = subscreen, 3 = both
level -16 = black, 0 = full brightness, 16 = white

static bool video3DEnabled (  )  [inline, static]

determine if 3D is enabled

Returns:
true if 3D is enabled

static void videoBgDisable ( int  number  )  [inline, static]

disables the specified background on the main engine

Parameters:
number the background number (0-3)

static void videoBgDisableSub ( int  number  )  [inline, static]

disables the specified background on the sub engine

Parameters:
number the background number (0-3)

static void videoBgEnable ( int  number  )  [inline, static]

enables the specified background on the main engine

Parameters:
number the background number (0-3)

static void videoBgEnableSub ( int  number  )  [inline, static]

enables the specified background on the sub engine

Parameters:
number the background number (0-3)

static int videoGetMode (  )  [inline, static]

return the main 2D engine video mode

Returns:
the video mode

static int videoGetModeSub (  )  [inline, static]

return the main 2D engine video mode

Returns:
the video mode

static void videoSetMode ( u32  mode  )  [inline, static]

static void videoSetModeSub ( u32  mode  )  [inline, static]

void vramRestoreMainBanks ( u32  vramTemp  ) 

Set the main 4 bank modes.

Parameters:
vramTemp restores the main 4 banks to the value encoded in vramTemp (returned from vramSetMainBanks)

static void vramSetBankA ( VRAM_A_TYPE  a  )  [inline, static]

static void vramSetBankB ( VRAM_B_TYPE  b  )  [inline, static]

Set bank B to the indicated mapping.

Parameters:
b the mapping of the bank
Examples:
Graphics/Backgrounds/all_in_one/source/basic.cpp, and Graphics/Sprites/allocation_test/source/main.c.

static void vramSetBankC ( VRAM_C_TYPE  c  )  [inline, static]

static void vramSetBankD ( VRAM_D_TYPE  d  )  [inline, static]

static void vramSetBankE ( VRAM_E_TYPE  e  )  [inline, static]

Set bank E to the indicated mapping.

Parameters:
e the mapping of the bank

static void vramSetBankF ( VRAM_F_TYPE  f  )  [inline, static]

Set bank F to the indicated mapping.

Parameters:
f the mapping of the bank

static void vramSetBankG ( VRAM_G_TYPE  g  )  [inline, static]

Set bank G to the indicated mapping.

Parameters:
g the mapping of the bank

static void vramSetBankH ( VRAM_H_TYPE  h  )  [inline, static]

Set bank H to the indicated mapping.

Parameters:
h the mapping of the bank

static void vramSetBankI ( VRAM_I_TYPE  i  )  [inline, static]

Set bank I to the indicated mapping.

Parameters:
i the mapping of the bank

u32 vramSetMainBanks ( VRAM_A_TYPE  a,
VRAM_B_TYPE  b,
VRAM_C_TYPE  c,
VRAM_D_TYPE  d 
)

Set the main 4 bank modes.

Parameters:
a mapping mode of VRAM_A
b mapping mode of VRAM_B
c mapping mode of VRAM_C
d mapping mode of VRAM_D
Returns:
the previous mode
Examples:
Graphics/Sprites/fire_and_sprites/source/main.cpp, and input/Touch_Pad/touch_test/source/main.c.


Generated on Sun Mar 7 12:47:55 2010 for libnds by  doxygen 1.5.7.1