NightFox’s Lib
|
Functions to load and manage affine tiled backgrounds. More...
Data Structures | |
struct | NF_TYPE_AFFINE_BG |
Struct that holds information about affine tiled backgrounds. More... | |
Functions | |
void | NF_InitAffineBgSys (int screen) |
Initializes the affine background system of the selected screen. More... | |
void | NF_LoadAffineBg (const char *file, const char *name, u32 width, u32 height) |
Load an affine background to RAM from the filesystem. More... | |
void | NF_CreateAffineBg (int screen, u32 layer, const char *name, u32 wrap) |
Create an affine background in a layer using graphics preloaded in RAM. More... | |
void | NF_DeleteAffineBg (int screen, u32 layer) |
Deletes from VRAM the background of the specified screen and layer. More... | |
void | NF_AffineBgTransform (int screen, u32 layer, s32 x_scale, s32 y_scale, s32 x_tilt, s32 y_tilt) |
Modify the transformation matrix of the specified background. More... | |
void | NF_AffineBgMove (int screen, u32 layer, s32 x, s32 y, s32 angle) |
Moves the affine background to the specified position. More... | |
Variables | |
NF_TYPE_AFFINE_BG | NF_AFFINE_BG [2][4] |
Information of all affine backgrounds. | |
Functions to load and manage affine tiled backgrounds.
Affine backgrounds can be rotated and scaled, unlike regular tiled backgrounds.
void NF_AffineBgMove | ( | int | screen, |
u32 | layer, | ||
s32 | x, | ||
s32 | y, | ||
s32 | angle | ||
) |
Moves the affine background to the specified position.
You can also specify the rotation of this background (between -2048 and 2048). Affine backgrounds can't be moved with NF_ScrollBg().
Example:
screen | Screen (0 - 1). |
layer | Layer (2 - 3). |
x | X coordinate. |
y | Y coordinate. |
angle | Rotation angle (-2048 to 2048). |
void NF_AffineBgTransform | ( | int | screen, |
u32 | layer, | ||
s32 | x_scale, | ||
s32 | y_scale, | ||
s32 | x_tilt, | ||
s32 | y_tilt | ||
) |
Modify the transformation matrix of the specified background.
You can change the scale of the X and Y axes, as well as their shear.
Example:
screen | Screen (0 - 1). |
layer | Layer (2 - 3). |
x_scale | Scale X: 0 - 256 (original) - 512 (or more) |
y_scale | Scale Y: 0 - 256 (original) - 512 (or more) |
x_tilt | Tilt X: 0 - 512 (or more) |
y_tilt | Tilt Y: 0 - 512 (or more) |
void NF_CreateAffineBg | ( | int | screen, |
u32 | layer, | ||
const char * | name, | ||
u32 | wrap | ||
) |
Create an affine background in a layer using graphics preloaded in RAM.
Specify if you want the background infinite (wrap = 1) or not (wrap = 0).
Example:
screen | Screen (0 - 1). |
layer | Layer (2 - 3). |
name | Name of the background. |
wrap | True to enable wrap around mode. |
void NF_DeleteAffineBg | ( | int | screen, |
u32 | layer | ||
) |
Deletes from VRAM the background of the specified screen and layer.
Example:
screen | Screen (0 - 1). |
layer | Layer (2 - 3). |
void NF_InitAffineBgSys | ( | int | screen | ) |
Initializes the affine background system of the selected screen.
Once this function is called, only affine backgrounds can be used, and only layers 2 and 3 are available. Also, affine backgrounds can only hold up to 256 tiles each, and they must share a 256 color palette.
The 2D hardware needs to be set to video mode 2.
Example:
screen | Screen (0 - 1). |
void NF_LoadAffineBg | ( | const char * | file, |
const char * | name, | ||
u32 | width, | ||
u32 | height | ||
) |
Load an affine background to RAM from the filesystem.
It is essential to initialize the tiled background buffers before loading any "affine" background. See the documentation of NF_InitTiledBgBuffers().
Affine backgrounds have to be 256x256 or 512x512 pixels in size and they can have up to 256 unique tiles. All backgrounds in the same screen must share the palette. Use the script "Convert_Affine.bat" in the GRIT folder to convert your backgrounds.
Example:
file | File path without extension. |
name | Name used for the BG for other functions. |
width | BG width. |
height | BG height. |