library: Make some functions static inline

This commit is contained in:
Antonio Niño Díaz 2023-05-15 02:12:04 +01:00
parent dcf452b33b
commit b31a3e7d20
10 changed files with 59 additions and 92 deletions

View File

@ -24,6 +24,8 @@ extern "C" {
#include <nds.h>
#include "nf_sprite256.h"
/// Init 2D mode for the selected screen.
///
/// Modes:
@ -95,7 +97,11 @@ void NF_ScrollBg(u8 screen, u8 layer, s16 x, s16 y);
/// @param id Sprite ID (0 - 127).
/// @param x X coordinate.
/// @param y Y coordinate.
void NF_MoveSprite(u8 screen, u8 id, s16 x, s16 y);
static inline void NF_MoveSprite(u8 screen, u8 id, s16 x, s16 y)
{
NF_SPRITEOAM[screen][id].x = x;
NF_SPRITEOAM[screen][id].y = y;
}
/// Selects the layer where a sprite will be drawn.
///
@ -110,7 +116,10 @@ void NF_MoveSprite(u8 screen, u8 id, s16 x, s16 y);
/// @param screen Screen (0 - 1).
/// @param id Sprite ID (0 - 127).
/// @param layer Layer (0 - 3).
void NF_SpriteLayer(u8 screen, u8 id, u8 layer);
static inline void NF_SpriteLayer(u8 screen, u8 id, u8 layer)
{
NF_SPRITEOAM[screen][id].layer = layer;
}
/// Shows or hides a sprite.
///
@ -127,7 +136,10 @@ void NF_SpriteLayer(u8 screen, u8 id, u8 layer);
/// @param screen Screen (0 - 1).
/// @param id Sprite ID (0 - 127).
/// @param show Set to true to show the sprite, false otherwise.
void NF_ShowSprite(u8 screen, u8 id, bool show);
static inline void NF_ShowSprite(u8 screen, u8 id, bool show)
{
NF_SPRITEOAM[screen][id].hide = !show;
}
/// Sets the horizontal flip state of a sprite.
///
@ -140,7 +152,10 @@ void NF_ShowSprite(u8 screen, u8 id, bool show);
/// @param screen Screen (0 - 1).
/// @param id Sprite ID (0 - 127).
/// @param hflip Set to true to flip the sprite, false otherwise.
void NF_HflipSprite(u8 screen, u8 id, bool hflip);
static inline void NF_HflipSprite(u8 screen, u8 id, bool hflip)
{
NF_SPRITEOAM[screen][id].hflip = hflip;
}
/// Gets the horizontal flip state of a sprite.
///
@ -153,7 +168,10 @@ void NF_HflipSprite(u8 screen, u8 id, bool hflip);
/// @param screen Screen (0 - 1).
/// @param id Sprite ID (0 - 127).
/// @return hflip Returns true if the sprite is flipped, false otherwise.
bool NF_GetSpriteHflip(u8 screen, u8 id);
static inline bool NF_GetSpriteHflip(u8 screen, u8 id)
{
return NF_SPRITEOAM[screen][id].hflip;
}
/// Sets the vertical flip state of a sprite.
///
@ -166,7 +184,10 @@ bool NF_GetSpriteHflip(u8 screen, u8 id);
/// @param screen Screen (0 - 1).
/// @param id Sprite ID (0 - 127).
/// @param vflip Set to true to flip the sprite, false otherwise.
void NF_VflipSprite(u8 screen, u8 id, bool vflip);
static inline void NF_VflipSprite(u8 screen, u8 id, bool vflip)
{
NF_SPRITEOAM[screen][id].vflip = vflip;
}
/// Gets the vertical flip state of a sprite.
///
@ -179,7 +200,10 @@ void NF_VflipSprite(u8 screen, u8 id, bool vflip);
/// @param screen Screen (0 - 1).
/// @param id Sprite ID (0 - 127).
/// @return vflip Returns true if the sprite is flipped, false otherwise.
bool NF_GetSpriteVflip(u8 screen, u8 id);
static inline bool NF_GetSpriteVflip(u8 screen, u8 id)
{
return NF_SPRITEOAM[screen][id].vflip;
}
/// Selects which frame of the animation of a sprite is shown.
///

View File

@ -14,6 +14,8 @@ extern "C" {
#include <nds.h>
#include "nf_tiledbg.h"
/// @file nf_affinebg.h
/// @brief Affine background support.
@ -89,7 +91,10 @@ void NF_LoadAffineBg(const char *file, const char *name, u16 width, u16 height);
/// ```
///
/// @param name Name of the background.
void NF_UnloadAffineBg(const char *name);
static inline void NF_UnloadAffineBg(const char *name)
{
NF_UnloadTiledBg(name);
}
/// Create an affine background in a layer using graphics preloaded in RAM.
///
@ -170,7 +175,11 @@ void NF_AffineBgMove(u8 screen, u8 layer, s32 x, s32 y, s32 angle);
/// @param layer Layer (2 - 3).
/// @param x X coordinate.
/// @param y Y coordinate.
void NF_AffineBgCenter(u8 screen, u8 layer, s32 x, s32 y);
static inline void NF_AffineBgCenter(u8 screen, u8 layer, s32 x, s32 y)
{
NF_AFFINE_BG[screen][layer].x_center = x;
NF_AFFINE_BG[screen][layer].y_center = y;
}
/// @}

View File

@ -102,7 +102,10 @@ void NF_DmaMemCopy(void *destination, const void *source, u32 size);
/// 6 : Chinese
///
/// @return The language ID.
u8 NF_GetLanguage(void);
static inline u8 NF_GetLanguage(void)
{
return PersonalData->language;
}
/// @}

View File

@ -255,7 +255,11 @@ void NF_Swap3dSpritePriority(u16 id_a, u16 id_b);
/// @param id Sprite ID (0 - 255).
/// @param x X coordinate.
/// @param y Y coordinate.
void NF_Move3dSprite(u16 id, s16 x, s16 y);
static inline void NF_Move3dSprite(u16 id, s16 x, s16 y)
{
NF_3DSPRITE[id].x = x;
NF_3DSPRITE[id].y = y;
}
/// Show or hide a 3D sprite.
///
@ -271,7 +275,10 @@ void NF_Move3dSprite(u16 id, s16 x, s16 y);
///
/// @param id Sprite ID (0 - 255).
/// @param show True to show the sprite, false to hide it.
void NF_Show3dSprite(u16 id, bool show);
static inline void NF_Show3dSprite(u16 id, bool show)
{
NF_3DSPRITE[id].show = show;
}
/// Select the frame of an animation to display in the 3D sprite.
///

View File

@ -226,7 +226,10 @@ void NF_DefineTextColor(u8 screen, u8 layer, u8 color, u8 r, u8 g, u8 b);
/// @param screen Screen (0 - 1)
/// @param layer Background layer (0 - 3)
/// @param color Color number (0 - 15)
void NF_SetTextColor(u8 screen, u8 layer, u8 color);
static inline void NF_SetTextColor(u8 screen, u8 layer, u8 color)
{
NF_TEXT[screen][layer].pal = color;
}
/// @}

View File

@ -279,47 +279,6 @@ void NF_ScrollBg(u8 screen, u8 layer, s16 x, s16 y) {
}
void NF_MoveSprite(u8 screen, u8 id, s16 x, s16 y) {
NF_SPRITEOAM[screen][id].x = x; // Coordenada X
NF_SPRITEOAM[screen][id].y = y; // Coordenada Y
}
void NF_SpriteLayer(u8 screen, u8 id, u8 layer) {
NF_SPRITEOAM[screen][id].layer = layer; // Capa sobre la que esta el sprite
}
void NF_ShowSprite(u8 screen, u8 id, bool show) {
NF_SPRITEOAM[screen][id].hide = !show; // Muestra o oculta el sprite
}
void NF_HflipSprite(u8 screen, u8 id, bool hflip) {
NF_SPRITEOAM[screen][id].hflip = hflip; // Volteado horizontal;
}
bool NF_GetSpriteHflip(u8 screen, u8 id) {
return NF_SPRITEOAM[screen][id].hflip;
}
void NF_VflipSprite(u8 screen, u8 id, bool vflip) {
NF_SPRITEOAM[screen][id].vflip = vflip; // Volteado vertical;
}
bool NF_GetSpriteVflip(u8 screen, u8 id) {
return NF_SPRITEOAM[screen][id].vflip;
}
void NF_SpriteFrame(u8 screen, u8 id, u16 frame) {
// Verifica el rango de Id's de Sprites

View File

@ -203,10 +203,6 @@ void NF_LoadAffineBg(const char* file, const char* name, u16 width, u16 height)
}
void NF_UnloadAffineBg(const char* name) {
NF_UnloadTiledBg(name);
}
void NF_CreateAffineBg(u8 screen, u8 layer, const char* name, u8 wrap) {
// Variables
@ -622,10 +618,3 @@ void NF_AffineBgMove(u8 screen, u8 layer, s32 x, s32 y, s32 angle) {
NF_AFFINE_BG[screen][layer].y = y;
}
void NF_AffineBgCenter(u8 screen, u8 layer, s32 x, s32 y) {
NF_AFFINE_BG[screen][layer].x_center = x;
NF_AFFINE_BG[screen][layer].y_center = y;
}

View File

@ -305,9 +305,3 @@ void NF_DmaMemCopy(void* destination, const void* source, u32 size) {
}
}
u8 NF_GetLanguage(void) {
return PersonalData->language;
}

View File

@ -648,21 +648,6 @@ void NF_Swap3dSpritePriority(u16 id_a, u16 id_b) {
}
void NF_Move3dSprite(u16 id, s16 x, s16 y) {
// Actualiza las coordenadas del Sprite
NF_3DSPRITE[id].x = x;
NF_3DSPRITE[id].y = y;
}
void NF_Show3dSprite(u16 id, bool show) {
// Actualiza el flag de visibilidad
NF_3DSPRITE[id].show = show;
}
void NF_Set3dSpriteFrame(u16 id, u16 frame) {
// Verifica el rango de Id's de Sprites

View File

@ -452,9 +452,3 @@ void NF_DefineTextColor(u8 screen, u8 layer, u8 color, u8 r, u8 g, u8 b) {
}
}
void NF_SetTextColor(u8 screen, u8 layer, u8 color) {
NF_TEXT[screen][layer].pal = color;
}