NightFox’s Lib
Functions
2D video setup

Functions to setup the 2D video modes of the NDS, as well as to activate or deactivate background layers or scroll them. More...

Functions

void NF_Set2D (int screen, u32 mode)
 Init 2D mode for the selected screen. More...
 
void NF_ShowBg (int screen, u32 layer)
 Makes the BG of the selected layer and screen visible. More...
 
void NF_HideBg (int screen, u32 layer)
 Makes the BG of the selected layer and screen invisible. More...
 
void NF_ScrollBg (int screen, u32 layer, s32 x, s32 y)
 Moves the BG of the selected layer and screen to the specified coordinates. More...
 
void NF_SpriteFrame (int screen, u32 id, u32 frame)
 Selects which frame of the animation of a sprite is shown. More...
 
void NF_EnableSpriteRotScale (int screen, u32 sprite, u32 id, bool doublesize)
 Makes a sprite available to be rotated and scaled. More...
 
void NF_DisableSpriteRotScale (int screen, u32 sprite)
 Disables the rotation and scalation of sprite. More...
 
void NF_SpriteRotScale (int screen, u8 id, s32 angle, u32 sx, u32 sy)
 Setup the rotation and scalation values of a RotSet. More...
 

Detailed Description

Functions to setup the 2D video modes of the NDS, as well as to activate or deactivate background layers or scroll them.

Function Documentation

◆ NF_DisableSpriteRotScale()

void NF_DisableSpriteRotScale ( int  screen,
u32  sprite 
)

Disables the rotation and scalation of sprite.

Example:

// Disable rotation and scalation of sprite 46 of screen 0.
void NF_DisableSpriteRotScale(int screen, u32 sprite)
Disables the rotation and scalation of sprite.
Definition: nf_2d.c:379
Parameters
screenScreen (0 - 1).
spriteSprite ID (0 - 127).

◆ NF_EnableSpriteRotScale()

void NF_EnableSpriteRotScale ( int  screen,
u32  sprite,
u32  id,
bool  doublesize 
)

Makes a sprite available to be rotated and scaled.

You must specify which rotset of the 32 availables will be used by the sprite. Multiple sprites can share the same rotset. If "doublesize" is disabled, the max size for sprites is 32x32. Otherwise the sprite will be clipped.

If you enable RotScale for a sprite the flip states will be ignored.

Example:

// Enables the rotation and scalation for sprite 111 in screen 1, using the
// RotSet 12, with “doublesize” disabled.
NF_EnableSpriteRotScale(1, 111, 12, false);
void NF_EnableSpriteRotScale(int screen, u32 sprite, u32 id, bool doublesize)
Makes a sprite available to be rotated and scaled.
Definition: nf_2d.c:355
Parameters
screenScreen (0 - 1).
spriteSprite ID (0 - 127).
idRotSet ID (0 - 31).
doublesizeSet to true to enable double size mode.

◆ NF_HideBg()

void NF_HideBg ( int  screen,
u32  layer 
)

Makes the BG of the selected layer and screen invisible.

Example:

// Makes the BG of layer 2 in screen 0 (top) invisible
NF_HideBg(0, 2);
void NF_HideBg(int screen, u32 layer)
Makes the BG of the selected layer and screen invisible.
Definition: nf_2d.c:96
Parameters
screenScreen (0 - 1).
layerLayer (0 - 3).

◆ NF_ScrollBg()

void NF_ScrollBg ( int  screen,
u32  layer,
s32  x,
s32  y 
)

Moves the BG of the selected layer and screen to the specified coordinates.

If the map is taller or wider than 512, it must be kept in RAM all the time.

Example:

// Move the BG of layer 1 and screen 0 to the coordinates (128, 96)
NF_ScrollBg(0, 1, 128, 96);
void NF_ScrollBg(int screen, u32 layer, s32 x, s32 y)
Moves the BG of the selected layer and screen to the specified coordinates.
Definition: nf_2d.c:138
Parameters
screenScreen (0 - 1).
layerLayer (0 - 3).
xX coordinate.
yY coordinate.

◆ NF_Set2D()

void NF_Set2D ( int  screen,
u32  mode 
)

Init 2D mode for the selected screen.

Modes: 0 - Tiled BGs (256 colors). 2 - Affine BGs of 8 bits in layers 2 & 3 5 - Bitmap BGs at 8 or 16 bits.

Example:

// Init 2D mode for tiled BGs and sprites on screen 1 (bottom)
NF_Set2D(1, 0);
void NF_Set2D(int screen, u32 mode)
Init 2D mode for the selected screen.
Definition: nf_2d.c:18
Parameters
screenScreen (0 - 1).
modeMode (0, 2, 5).

◆ NF_ShowBg()

void NF_ShowBg ( int  screen,
u32  layer 
)

Makes the BG of the selected layer and screen visible.

Use this command to make visible a BG previously hidden with NF_HideBg().

Example:

// Makes the BG of layer 2 in screen 0 (top) visible
NF_ShowBg(0, 2);
void NF_ShowBg(int screen, u32 layer)
Makes the BG of the selected layer and screen visible.
Definition: nf_2d.c:54
Parameters
screenScreen (0 - 1).
layerLayer (0 - 3).

◆ NF_SpriteFrame()

void NF_SpriteFrame ( int  screen,
u32  id,
u32  frame 
)

Selects which frame of the animation of a sprite is shown.

Example:

// Sprite 20 of screen 0 shows frame 5.
NF_SpriteFrame(0, 20, 5);
void NF_SpriteFrame(int screen, u32 id, u32 frame)
Selects which frame of the animation of a sprite is shown.
Definition: nf_2d.c:308
Parameters
screenScreen (0 - 1).
idSprite ID (0 - 127).
frameThe frame to show.

◆ NF_SpriteRotScale()

void NF_SpriteRotScale ( int  screen,
u8  id,
s32  angle,
u32  sx,
u32  sy 
)

Setup the rotation and scalation values of a RotSet.

All sprites assigned to this RotSet will rotate and scale using those values. Rotation angles are in 512 base. This means the rotation will go from -512 to 512 (-360 to 360 degrees). Scale values go from 0 to 512. A 100% scale is 256.

Example:

// Rotate all sprites with RotSet 16 by 90 degrees to the right, with 100%
// scale in both directions, on screen 0.
NF_SpriteRotScale(0, 16, 128, 256, 256);
// Rotate all sprites with RotSet 10 by 180 degrees to the left, scaling the
// X size by 200% and the Y size by 100%, on screen 1.
NF_SpriteRotScale(1, 10, -256, 512, 256);
void NF_SpriteRotScale(int screen, u8 id, s32 angle, u32 sx, u32 sy)
Setup the rotation and scalation values of a RotSet.
Definition: nf_2d.c:399
Parameters
screenScreen (0 - 1).
idSprite ID (0 - 127).
angleAngle (-512 to 512).
sxX scale (0 to 512), 100% = 256.
syY scale (0 to 512), 100% = 256.