"Background API Access"

Enumerations

enum  BgSize {
  BgSize_R_128x128 = (0 << 14),
  BgSize_R_256x256 = (1 << 14),
  BgSize_R_512x512 = (2 << 14),
  BgSize_R_1024x1024 = (3 << 14),
  BgSize_T_256x256 = (0 << 14) | (1 << 16),
  BgSize_T_512x256 = (1 << 14) | (1 << 16),
  BgSize_T_256x512 = (2 << 14) | (1 << 16),
  BgSize_T_512x512 = (3 << 14) | (1 << 16),
  BgSize_ER_128x128 = (0 << 14) | (2 << 16),
  BgSize_ER_256x256 = (1 << 14) | (2 << 16),
  BgSize_ER_512x512 = (2 << 14) | (2 << 16),
  BgSize_ER_1024x1024 = (3 << 14) | (2 << 16),
  BgSize_B8_128x128 = ((0 << 14) | BIT(7) | (3 << 16)),
  BgSize_B8_256x256 = ((1 << 14) | BIT(7) | (3 << 16)),
  BgSize_B8_512x256 = ((2 << 14) | BIT(7) | (3 << 16)),
  BgSize_B8_512x512 = ((3 << 14) | BIT(7) | (3 << 16)),
  BgSize_B8_1024x512 = (1 << 14) | (3 << 16),
  BgSize_B8_512x1024 = (0) | (3 << 16),
  BgSize_B16_128x128 = ((0 << 14) | BIT(7) | BIT(2) | (4 << 16)),
  BgSize_B16_256x256 = ((1 << 14) | BIT(7) | BIT(2) | (4 << 16)),
  BgSize_B16_512x256 = ((2 << 14) | BIT(7) | BIT(2) | (4 << 16)),
  BgSize_B16_512x512 = ((3 << 14) | BIT(7) | BIT(2) | (4 << 16))
}
 

Allowed background Sizes The lower 16 bits of these defines can be used directly to set the background control register bits.

More...
enum  BgType {
  BgType_Text8bpp,
  BgType_Text4bpp,
  BgType_Rotation,
  BgType_ExRotation,
  BgType_Bmp8,
  BgType_Bmp16
}
 

Allowed background types, used in bgInitMain and bgInitSub.

More...

Functions

static void bgClearControlBits (int id, u16 bits)
 Clears the specified bits from the backgrounds control register.
static u16bgGetGfxPtr (int id)
 Gets a pointer to the background graphics.
static int bgGetMapBase (int id)
 Gets the current map base for the supplied background.
static u16bgGetMapPtr (int id)
 Gets a pointer to the background map.
static int bgGetPriority (int id)
 Gets the background priority.
static int bgGetTileBase (int id)
 Gets the background tile base.
static void bgHide (int id)
 Hides the current background via the display control register.
static int bgInit (int layer, BgType type, BgSize size, int mapBase, int tileBase)
 Initializes a background on the main display Sets up background control register with specified settings and defaults to 256 color mode for tiled backgrounds. Sets the rotation/scale attributes for rot/ex rot backgrounds to 1:1 scale and 0 angle of rotation.
static int bgInitSub (int layer, BgType type, BgSize size, int mapBase, int tileBase)
 Initializes a background on the sub display Sets up background control register with specified settings and defaults to 256 color mode for tiled backgrounds. Sets the rotation/scale attributes for rot/ex rot backgrounds to 1:1 scale and 0 angle of rotation.
static void bgMosaicDisable (int id)
 Disables mosaic on the specified background.
static void bgMosaicEnable (int id)
 Enables mosaic on the specified background.
static void bgRotate (int id, int angle)
 Rotates the background counter clockwise by the specified angle. (this rotation is cumulative).
static void bgScroll (int id, int dx, int dy)
 Scrolls the background by the specified relative values.
static void bgScrollf (int id, s32 dx, s32 dy)
 Scrolls the background by the specified relative values (fixed point).
static void bgSet (int id, int angle, s32 sx, s32 sy, s32 scrollX, s32 scrollY, s32 rotCenterX, s32 rotCenterY)
 Sets the rotation and scale of the background and update background control registers.
static void bgSetAffineMatrixScroll (int id, int hdx, int vdx, int hdy, int vdy, int scrollx, int scrolly)
 directly sets the affine matrix and scroll registers of a background.
static void bgSetCenter (int id, int x, int y)
 Sets the center of rotation for the supplied background.
static void bgSetCenterf (int id, s32 x, s32 y)
 Sets the center of rotation for the supplied background (fixed point).
static vuint16bgSetControlBits (int id, u16 bits)
 allows direct access to background control for the chosen layer, returns a pointer to the current control bits
static void bgSetMapBase (int id, unsigned int base)
 Sets the background map base.
static void bgSetMosaic (unsigned int dx, unsigned int dy)
 Sets the horizontal and vertical mosaic values for all backgrounds.
static void bgSetMosaicSub (unsigned int dx, unsigned int dy)
 Sets the horizontal and vertical mosaic values for all backgrounds (Sub Display).
static void bgSetPriority (int id, unsigned int priority)
 Sets the background priority.
static void bgSetRotate (int id, int angle)
 Sets the rotation angle of the specified background and updates the transform matrix.
static void bgSetRotateScale (int id, int angle, s32 sx, s32 sy)
 Sets the rotation and scale of the background and update background control registers.
static void bgSetScale (int id, s32 sx, s32 sy)
 Sets the scale of the specified background.
static void bgSetScroll (int id, int x, int y)
 Sets the scroll hardware to the specified location.
static void bgSetScrollf (int id, s32 x, s32 y)
 Sets the scroll hardware to the specified location (fixed point).
static void bgSetTileBase (int id, unsigned int base)
 Sets the background map base.
static void bgShow (int id)
 Shows the current background via the display control register.
void bgUpdate (void)
 Must be called once per frame to update scroll/scale/and rotation of backgrounds.
static void bgWrapOff (int id)
 turns wrap off for a background. has no effect on text backgrounds, which are always wrapped.
static void bgWrapOn (int id)
 turns wrap on for a background. has no effect on text backgrounds, which are always wrapped.

Enumeration Type Documentation

enum BgSize

Allowed background Sizes The lower 16 bits of these defines can be used directly to set the background control register bits.

Enumerator:
BgSize_R_128x128 

128 x 128 pixel rotation background

BgSize_R_256x256 

256 x 256 pixel rotation background

BgSize_R_512x512 

512 x 512 pixel rotation background

BgSize_R_1024x1024 

1024 x 1024 pixel rotation background

BgSize_T_256x256 

256 x 256 pixel text background

BgSize_T_512x256 

512 x 256 pixel text background

BgSize_T_256x512 

256 x 512 pixel text background

BgSize_T_512x512 

512 x 512 pixel text background

BgSize_ER_128x128 

128 x 128 pixel extended rotation background

BgSize_ER_256x256 

256 x 256 pixel extended rotation background

BgSize_ER_512x512 

512 x 512 pixel extended rotation background

BgSize_ER_1024x1024 

1024 x 1024 extended pixel rotation background

BgSize_B8_128x128 

128 x 128 pixel 8 bit bitmap background

BgSize_B8_256x256 

256 x 256 pixel 8 bit bitmap background

BgSize_B8_512x256 

512 x 256 pixel 8 bit bitmap background

BgSize_B8_512x512 

512 x 512 pixel 8 bit bitmap background

BgSize_B8_1024x512 

1024 x 512 pixel 8 bit bitmap background

BgSize_B8_512x1024 

512 x 1024 pixel 8 bit bitmap background

BgSize_B16_128x128 

128 x 128 pixel 16 bit bitmap background

BgSize_B16_256x256 

256 x 256 pixel 16 bit bitmap background

BgSize_B16_512x256 

512 x 512 pixel 16 bit bitmap background

BgSize_B16_512x512 

1024 x 1024 pixel 16 bit bitmap background

enum BgType

Allowed background types, used in bgInitMain and bgInitSub.

Enumerator:
BgType_Text8bpp 

8bpp Tiled background with 16 bit tile indexes and no allowed rotation or scaling

BgType_Text4bpp 

4bpp Tiled background with 16 bit tile indexes and no allowed rotation or scaling

BgType_Rotation 

Tiled background with 8 bit tile indexes Can be scaled and rotated.

BgType_ExRotation 

Tiled background with 16 bit tile indexes Can be scaled and rotated.

BgType_Bmp8 

Bitmap background with 8 bit color values which index into a 256 color palette.

BgType_Bmp16 

Bitmap background with 16 bit color values of the form aBBBBBGGGGGRRRRR (if 'a' is set the pixel will be rendered...if not the pixel will be transparent).


Function Documentation

static void bgClearControlBits ( int  id,
u16  bits 
) [inline, static]

Clears the specified bits from the backgrounds control register.

Parameters:
id background id returned from bgInit or bgInitSub
bits sets the specified bits to clear in the backgrounds control register
static u16* bgGetGfxPtr ( int  id  )  [inline, static]
static int bgGetMapBase ( int  id  )  [inline, static]

Gets the current map base for the supplied background.

Parameters:
id background id returned from bgInit or bgInitSub
Returns:
background map base
Note:
this is the integer offset of the base not a pointer to the map
Examples:
Graphics/Backgrounds/Double_Buffer/source/main.cpp.
static u16* bgGetMapPtr ( int  id  )  [inline, static]

Gets a pointer to the background map.

Parameters:
id background id returned from bgInit or bgInitSub
Returns:
A pointer to the map
Examples:
Graphics/Backgrounds/all_in_one/source/advanced.cpp, Graphics/Backgrounds/all_in_one/source/basic.cpp, Graphics/Backgrounds/all_in_one/source/handmade.cpp, and Graphics/Backgrounds/all_in_one/source/scrolling.cpp.
static int bgGetPriority ( int  id  )  [inline, static]

Gets the background priority.

Parameters:
id background id returned from bgInit or bgInitSub
Returns:
background priority
static int bgGetTileBase ( int  id  )  [inline, static]

Gets the background tile base.

Parameters:
id background id returned from bgInit or bgInitSub
Returns:
background tile base
static void bgHide ( int  id  )  [inline, static]

Hides the current background via the display control register.

Parameters:
id background id returned from bgInit or bgInitSub
Examples:
Graphics/Backgrounds/all_in_one/source/advanced.cpp.
static int bgInit ( int  layer,
BgType  type,
BgSize  size,
int  mapBase,
int  tileBase 
) [inline, static]

Initializes a background on the main display Sets up background control register with specified settings and defaults to 256 color mode for tiled backgrounds. Sets the rotation/scale attributes for rot/ex rot backgrounds to 1:1 scale and 0 angle of rotation.

Parameters:
layer background hardware layer to init. Must be 0 - 3
type the type of background to init
size the size of the background
mapBase the 2k offset into vram the tile map will be placed
--OR--
the 16k offset into vram the bitmap data will be placed for bitmap backgrounds
tileBase the 16k offset into vram the tile graphics data will be placed
Returns:
the background id to be used in the supporting functions
Note:
tileBase is unused for bitmap backgrounds
Examples:
Graphics/Backgrounds/16bit_color_bmp/source/template.cpp, Graphics/Backgrounds/256_color_bmp/source/main.cpp, Graphics/Backgrounds/all_in_one/source/advanced.cpp, Graphics/Backgrounds/all_in_one/source/basic.cpp, Graphics/Backgrounds/all_in_one/source/handmade.cpp, Graphics/Backgrounds/all_in_one/source/scrolling.cpp, Graphics/Backgrounds/Double_Buffer/source/main.cpp, and Graphics/Backgrounds/rotation/source/main.cpp.
static int bgInitSub ( int  layer,
BgType  type,
BgSize  size,
int  mapBase,
int  tileBase 
) [inline, static]

Initializes a background on the sub display Sets up background control register with specified settings and defaults to 256 color mode for tiled backgrounds. Sets the rotation/scale attributes for rot/ex rot backgrounds to 1:1 scale and 0 angle of rotation.

Parameters:
layer background hardware layer to init. Must be 0 - 3
type the type of background to init
size the size of the background
mapBase the 2k offset into vram the tile map will be placed
--OR--
the 16k offset into vram the bitmap data will be placed for bitmap backgrounds
tileBase the 16k offset into vram the tile graphics data will be placed
Returns:
the background id to be used in the supporting functions
Note:
tileBase is unused for bitmap backgrounds
Examples:
Graphics/3D/3D_Both_Screens/source/template.c.
static void bgMosaicDisable ( int  id  )  [inline, static]

Disables mosaic on the specified background.

Parameters:
id background id returned from bgInit or bgInitSub
static void bgMosaicEnable ( int  id  )  [inline, static]

Enables mosaic on the specified background.

Parameters:
id background id returned from bgInit or bgInitSub
Examples:
Graphics/Backgrounds/all_in_one/source/advanced.cpp.
static void bgRotate ( int  id,
int  angle 
) [inline, static]

Rotates the background counter clockwise by the specified angle. (this rotation is cumulative).

Parameters:
id background id returned from bgInit or bgInitSub
angle the angle of counter clockwise rotation (-32768 to 32767)
static void bgScroll ( int  id,
int  dx,
int  dy 
) [inline, static]

Scrolls the background by the specified relative values.

Parameters:
id background id returned from bgInit or bgInitSub
dx horizontal scroll
dy vertical scroll
Note:
while valid for text backgrounds the fractional part will be ignored
static void bgScrollf ( int  id,
s32  dx,
s32  dy 
) [inline, static]

Scrolls the background by the specified relative values (fixed point).

Parameters:
id background id returned from bgInit or bgInitSub
dx the 8 bits fractional fixed point horizontal scroll
dy the 8 bits fractional fixed point vertical scroll
Note:
while valid for text backgrounds the fractional part will be ignored
static void bgSet ( int  id,
int  angle,
s32  sx,
s32  sy,
s32  scrollX,
s32  scrollY,
s32  rotCenterX,
s32  rotCenterY 
) [inline, static]

Sets the rotation and scale of the background and update background control registers.

Parameters:
id background id returned from bgInit or bgInitSub
angle the angle of counter clockwise rotation (-32768 to 32767)
sx the 24.8 bit fractional fixed point inverse horizontal scaling to apply
sy the 24.8 bit fractional fixed point inverse vertical scaling to apply
scrollX the 24.8 bit fractional fixed point horizontal scroll to apply
scrollY the 24.8 bit fractional fixed point vertical scroll to apply
rotCenterX the 24.8 bit fractional fixed point center of rotation x component
rotCenterY the 24.8 bit fractional fixed point center of rotation y component
static void bgSetAffineMatrixScroll ( int  id,
int  hdx,
int  vdx,
int  hdy,
int  vdy,
int  scrollx,
int  scrolly 
) [inline, static]

directly sets the affine matrix and scroll registers of a background.

With this, you have more freedom to set the matrix, but it might be more difficult to use if you're not used to affine transformation matrix. This will ignore (but not erase) any values set using the bg rotating, scaling or center functions.

Parameters:
id The id returned by bgInit or bgInitSub.
hdx The change in x per horizontal pixel.
vdx The change in x per vertical pixel.
hdy The change in y per horizontal pixel.
vdy The change in y per vertical pixel.
scrollx The horizontal scroll/offset value of the background.
scrolly The vertical scroll/offset value of the background.
static void bgSetCenter ( int  id,
int  x,
int  y 
) [inline, static]

Sets the center of rotation for the supplied background.

Parameters:
id background id returned from bgInit or bgInitSub
x center x
y center y
Examples:
Graphics/Backgrounds/all_in_one/source/advanced.cpp, and Graphics/Backgrounds/rotation/source/main.cpp.
static void bgSetCenterf ( int  id,
s32  x,
s32  y 
) [inline, static]

Sets the center of rotation for the supplied background (fixed point).

Parameters:
id background id returned from bgInit or bgInitSub
x the 8 bits fractional center x
y the 8 bits fractional center y
Note:
while valid for text backgrounds the fractional part will be ignored
static vuint16* bgSetControlBits ( int  id,
u16  bits 
) [inline, static]

allows direct access to background control for the chosen layer, returns a pointer to the current control bits

Parameters:
id background id returned from bgInit or bgInitSub
bits sets the specified bits to set in the backgrounds control register
Returns:
a pointer to the appropriate background control register
Examples:
Graphics/Backgrounds/all_in_one/source/scrolling.cpp.
static void bgSetMapBase ( int  id,
unsigned int  base 
) [inline, static]

Sets the background map base.

Parameters:
id background id returned from bgInit or bgInitSub
base the 2k offset into vram for the backgrounds tile map or the 16k offset for bitmap graphics
Examples:
Graphics/Backgrounds/Double_Buffer/source/main.cpp.
static void bgSetMosaic ( unsigned int  dx,
unsigned int  dy 
) [inline, static]

Sets the horizontal and vertical mosaic values for all backgrounds.

Parameters:
dx horizontal mosaic value (between 0 and 15)
dy vertical mosaic value (between 0 and 15)
Examples:
Graphics/Backgrounds/all_in_one/source/advanced.cpp.
static void bgSetMosaicSub ( unsigned int  dx,
unsigned int  dy 
) [inline, static]

Sets the horizontal and vertical mosaic values for all backgrounds (Sub Display).

Parameters:
dx horizontal mosaic value (between 0 and 15)
dy vertical mosaic value (between 0 and 15)
static void bgSetPriority ( int  id,
unsigned int  priority 
) [inline, static]

Sets the background priority.

Parameters:
id background id returned from bgInit or bgInitSub
priority background priority (0-3), higher level priority will result in background rendering on top of lower level
Examples:
Graphics/Backgrounds/all_in_one/source/advanced.cpp.
static void bgSetRotate ( int  id,
int  angle 
) [inline, static]

Sets the rotation angle of the specified background and updates the transform matrix.

Parameters:
id background id returned from bgInit or bgInitSub
angle the angle of counter clockwise rotation (0 to 511)
Examples:
Graphics/Backgrounds/all_in_one/source/advanced.cpp.
static void bgSetRotateScale ( int  id,
int  angle,
s32  sx,
s32  sy 
) [inline, static]

Sets the rotation and scale of the background and update background control registers.

Parameters:
id background id returned from bgInit or bgInitSub
angle the angle of counter clockwise rotation (-32768 to 32767)
sx the 24.8 bit fractional fixed point horizontal scaling to apply
sy the 24.8 bit fractional fixed point vertical scaling to apply
Examples:
Graphics/Backgrounds/rotation/source/main.cpp, and Graphics/Printing/rotscale_text/source/main.c.
static void bgSetScale ( int  id,
s32  sx,
s32  sy 
) [inline, static]

Sets the scale of the specified background.

Parameters:
id background id returned from bgInit or bgInitSub
sx the 24.8 bit fractional fixed point horizontal scaling to apply
sy the 24.8 bit fractional fixed point vertical scaling to apply
Examples:
Graphics/Backgrounds/all_in_one/source/advanced.cpp.
static void bgSetScroll ( int  id,
int  x,
int  y 
) [inline, static]

Sets the scroll hardware to the specified location.

Parameters:
id background id returned from bgInit or bgInitSub
x the horizontal scroll
y the vertical scroll
Examples:
Graphics/Backgrounds/all_in_one/source/advanced.cpp, Graphics/Backgrounds/all_in_one/source/scrolling.cpp, Graphics/Backgrounds/rotation/source/main.cpp, and Graphics/Printing/rotscale_text/source/main.c.
static void bgSetScrollf ( int  id,
s32  x,
s32  y 
) [inline, static]

Sets the scroll hardware to the specified location (fixed point).

Parameters:
id background id returned from bgInit or bgInitSub
x the 8 bits fractional fixed point horizontal scroll
y the 8 bits fractional fixed point vertical scroll
Note:
while valid for text backgrounds the fractional part will be ignored
static void bgSetTileBase ( int  id,
unsigned int  base 
) [inline, static]

Sets the background map base.

Parameters:
id background id returned from bgInit or bgInitSub
base the 16k offset into vram for the backgrounds tile map ignored for bitmap graphics
static void bgShow ( int  id  )  [inline, static]

Shows the current background via the display control register.

Parameters:
id background id returned from bgInit or bgInitSub
Examples:
Graphics/Backgrounds/all_in_one/source/advanced.cpp.
static void bgWrapOff ( int  id  )  [inline, static]

turns wrap off for a background. has no effect on text backgrounds, which are always wrapped.

Parameters:
id background id returned from bgInit or bgInitSub
static void bgWrapOn ( int  id  )  [inline, static]

turns wrap on for a background. has no effect on text backgrounds, which are always wrapped.

Parameters:
id background id returned from bgInit or bgInitSub
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated on Sat Oct 2 12:55:14 2010 for libnds by  doxygen 1.6.3