mirror of
https://github.com/knightfox75/nds_nflib.git
synced 2025-06-18 16:55:32 -04:00
Enable -Wextra
- Fix most new warnings (silence a few of them, though). - Replace all sprintf() by the safer snprintf().
This commit is contained in:
parent
4a257af310
commit
0c0a9e743e
@ -75,7 +75,7 @@ DEFINES += -D__NDS__ -DARM9
|
||||
|
||||
ARCH := -march=armv5te -mtune=arm946e-s
|
||||
|
||||
WARNFLAGS := -Wall
|
||||
WARNFLAGS := -Wall -Wextra -Wno-sign-compare
|
||||
|
||||
INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \
|
||||
$(foreach path,$(LIBDIRS),-I$(path)/include)
|
||||
|
@ -365,7 +365,7 @@ bool NF_GetSpriteVflip(u8 screen, u8 id) {
|
||||
void NF_SpriteFrame(u8 screen, u8 id, u16 frame) {
|
||||
|
||||
// Verifica el rango de Id's de Sprites
|
||||
if ((id < 0) || (id > 127)) {
|
||||
if (id > 127) {
|
||||
NF_Error(106, "Sprite", 127);
|
||||
}
|
||||
|
||||
@ -416,19 +416,19 @@ void NF_SpriteFrame(u8 screen, u8 id, u16 frame) {
|
||||
void NF_EnableSpriteRotScale(u8 screen, u8 sprite, u8 id, bool doublesize) {
|
||||
|
||||
// Verifica el rango de Id's de Sprites
|
||||
if ((sprite < 0) || (sprite > 127)) {
|
||||
if (sprite > 127) {
|
||||
NF_Error(106, "Sprite", 127);
|
||||
}
|
||||
|
||||
// Verifica el rango de Id's de Rotacion
|
||||
if ((id < 0) || (id > 31)) {
|
||||
if (id > 31) {
|
||||
NF_Error(106, "RotScale", 127);
|
||||
}
|
||||
|
||||
// Verifica si el Sprite esta creado
|
||||
if (!NF_SPRITEOAM[screen][sprite].created) {
|
||||
char text[4];
|
||||
sprintf(text, "%d", screen);
|
||||
snprintf(text, sizeof(text), "%d", screen);
|
||||
NF_Error(112, text, sprite);
|
||||
}
|
||||
|
||||
@ -443,14 +443,14 @@ void NF_EnableSpriteRotScale(u8 screen, u8 sprite, u8 id, bool doublesize) {
|
||||
void NF_DisableSpriteRotScale(u8 screen, u8 sprite) {
|
||||
|
||||
// Verifica el rango de Id's de Sprites
|
||||
if ((sprite < 0) || (sprite > 127)) {
|
||||
if (sprite > 127) {
|
||||
NF_Error(106, "Sprite", 127);
|
||||
}
|
||||
|
||||
// Verifica si el Sprite esta creado
|
||||
if (!NF_SPRITEOAM[screen][sprite].created) {
|
||||
char text[4];
|
||||
sprintf(text, "%d", screen);
|
||||
snprintf(text, sizeof(text), "%d", screen);
|
||||
NF_Error(112, text, sprite);
|
||||
}
|
||||
|
||||
@ -478,20 +478,14 @@ void NF_SpriteRotScale(u8 screen, u8 id, s16 angle, u16 sx, u16 sy) {
|
||||
in -= 512;
|
||||
}
|
||||
// Limites del factor X
|
||||
if (sx < 0) {
|
||||
sx = 0;
|
||||
}
|
||||
if (sx > 512) {
|
||||
sx = 512;
|
||||
}
|
||||
// Limites del factor Y
|
||||
if (sy < 0) {
|
||||
sy = 0;
|
||||
}
|
||||
if (sy > 512) {
|
||||
sy = 512;
|
||||
}
|
||||
|
||||
|
||||
// Si es un numero negativo...
|
||||
if (in < 0) {
|
||||
in = -in; // Pasa a positivo (para poder hacer el bitshift)
|
||||
|
@ -145,7 +145,7 @@ void NF_LoadAffineBg(const char* file, const char* name, u16 width, u16 height)
|
||||
char filename[256];
|
||||
|
||||
// Carga el archivo .IMG
|
||||
sprintf(filename, "%s/%s.img", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.img", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -170,7 +170,7 @@ void NF_LoadAffineBg(const char* file, const char* name, u16 width, u16 height)
|
||||
|
||||
|
||||
// Carga el archivo .MAP
|
||||
sprintf(filename, "%s/%s.map", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.map", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -191,7 +191,7 @@ void NF_LoadAffineBg(const char* file, const char* name, u16 width, u16 height)
|
||||
// swiWaitForVBlank(); // Espera al cierre del archivo (Usar en caso de corrupcion de datos)
|
||||
|
||||
// Carga el archivo .PAL
|
||||
sprintf(filename, "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -214,7 +214,7 @@ void NF_LoadAffineBg(const char* file, const char* name, u16 width, u16 height)
|
||||
fclose(file_id); // Cierra el archivo
|
||||
|
||||
// Guarda el nombre del Fondo
|
||||
sprintf(NF_TILEDBG[slot].name, "%s", name);
|
||||
snprintf(NF_TILEDBG[slot].name, sizeof(NF_TILEDBG[slot].name), "%s", name);
|
||||
|
||||
// Y las medidas
|
||||
NF_TILEDBG[slot].width = width;
|
||||
@ -245,7 +245,7 @@ void NF_CreateAffineBg(u8 screen, u8 layer, const char* name, u8 wrap) {
|
||||
if ((layer != 2) && (layer != 3)) NF_Error(118, name, 0);
|
||||
|
||||
// Busca el fondo solicitado
|
||||
sprintf(bg, "%s", name); // Obten el nombre del fondo a buscar
|
||||
snprintf(bg, sizeof(bg), "%s", name); // Obten el nombre del fondo a buscar
|
||||
for (n = 0; n < NF_SLOTS_TBG; n ++) { // Busca en todos los slots
|
||||
if (strcmp(bg, NF_TILEDBG[n].name) == 0) { // Si lo encuentras
|
||||
slot = n; // Guarda el slot a usar
|
||||
@ -461,7 +461,7 @@ void NF_DeleteAffineBg(u8 screen, u8 layer) {
|
||||
// Verifica que el fondo esta creado
|
||||
if (!NF_TILEDBG_LAYERS[screen][layer].created) {
|
||||
char text[32];
|
||||
sprintf(text, "%d", screen);
|
||||
snprintf(text, sizeof(text), "%d", screen);
|
||||
NF_Error(105, text, layer); // Si no existe, error
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ void NF_SetRootFolder(const char* folder) {
|
||||
if (strcmp(folder, "NITROFS") == 0) { // Si se debe iniciar el modo NitroFS y FAT
|
||||
|
||||
// Define NitroFS como la carpeta inicial
|
||||
sprintf(NF_ROOTFOLDER, "%s", "");
|
||||
snprintf(NF_ROOTFOLDER, sizeof(NF_ROOTFOLDER), "%s", "");
|
||||
// Check if NitroFS exists.
|
||||
// NitroFS must be mounted beforehand for this to work.
|
||||
if(access("nitro:/", F_OK) == 0) {
|
||||
@ -217,7 +217,7 @@ void NF_SetRootFolder(const char* folder) {
|
||||
} else { // Si se debe iniciar solo la FAT
|
||||
|
||||
// Define la carpeta inicial de la FAT
|
||||
sprintf(NF_ROOTFOLDER, "%s", folder);
|
||||
snprintf(NF_ROOTFOLDER, sizeof(NF_ROOTFOLDER), "%s", folder);
|
||||
|
||||
// Check where the NDS is running from
|
||||
bool init_ok = false;
|
||||
|
@ -211,9 +211,9 @@ void NF_Load16bitsImage(const char* file, u8 slot, u16 size_x, u16 size_y) {
|
||||
|
||||
// Funcion NF_Load16bImgData();
|
||||
void NF_Load16bImgData(const char* file, u8 slot, u16 x, u16 y, u8 type) {
|
||||
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((slot < 0) || (slot >= NF_SLOTS_BG16B)) {
|
||||
if (slot >= NF_SLOTS_BG16B) {
|
||||
if (type == 0) {
|
||||
NF_Error(106, "16 Bits Bg's", NF_SLOTS_BG16B);
|
||||
} else {
|
||||
@ -235,7 +235,7 @@ void NF_Load16bImgData(const char* file, u8 slot, u16 x, u16 y, u8 type) {
|
||||
u32 size = 0;
|
||||
|
||||
// Carga el archivo .IMG
|
||||
sprintf(filename, "%s/%s.img", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.img", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -397,9 +397,9 @@ void NF_Reset8bitsBgBuffers(void) {
|
||||
|
||||
// Funcion NF_Load8bitsBg();
|
||||
void NF_Load8bitsBg(const char* file, u8 slot) {
|
||||
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((slot < 0) || (slot >= NF_SLOTS_BG8B)) {
|
||||
if (slot >= NF_SLOTS_BG8B) {
|
||||
NF_Error(106, "8 Bits Bg's", NF_SLOTS_BG8B);
|
||||
}
|
||||
|
||||
@ -419,7 +419,7 @@ void NF_Load8bitsBg(const char* file, u8 slot) {
|
||||
u32 size = 0;
|
||||
|
||||
// Carga el archivo .IMG
|
||||
sprintf(filename, "%s/%s.img", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.img", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -442,7 +442,7 @@ void NF_Load8bitsBg(const char* file, u8 slot) {
|
||||
NF_BG8B[slot].data_size = size; // Guarda el tamaño del buffer
|
||||
|
||||
// Carga el archivo .PAL
|
||||
sprintf(filename, "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
|
@ -60,7 +60,7 @@ void NF_ResetCmapBuffers(void) {
|
||||
void NF_LoadColisionMap(const char* file, u8 id, u16 width, u16 height) {
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_CMAP)) {
|
||||
if (id >= NF_SLOTS_CMAP) {
|
||||
NF_Error(106, "Colision Map", NF_SLOTS_CMAP);
|
||||
}
|
||||
|
||||
@ -78,9 +78,9 @@ void NF_LoadColisionMap(const char* file, u8 id, u16 width, u16 height) {
|
||||
|
||||
// Variable para almacenar el path al archivo
|
||||
char filename[256];
|
||||
|
||||
|
||||
// Carga el archivo .CMP
|
||||
sprintf(filename, "%s/%s.cmp", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.cmp", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -114,7 +114,7 @@ void NF_LoadColisionMap(const char* file, u8 id, u16 width, u16 height) {
|
||||
void NF_UnloadColisionMap(u8 id) {
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_CMAP)) {
|
||||
if (id >= NF_SLOTS_CMAP) {
|
||||
NF_Error(106, "Colision Map", NF_SLOTS_CMAP);
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ void NF_SetTile(u8 slot, s32 x, s32 y, u16 value) {
|
||||
void NF_LoadColisionBg(const char* file, u8 id, u16 width, u16 height) {
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_CMAP)) {
|
||||
if (id >= NF_SLOTS_CMAP) {
|
||||
NF_Error(106, "Colision Map", NF_SLOTS_CMAP);
|
||||
}
|
||||
|
||||
@ -239,9 +239,9 @@ void NF_LoadColisionBg(const char* file, u8 id, u16 width, u16 height) {
|
||||
|
||||
// Variable para almacenar el path al archivo
|
||||
char filename[256];
|
||||
|
||||
|
||||
// Carga el archivo .DAT (TILES)
|
||||
sprintf(filename, "%s/%s.dat", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.dat", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -261,7 +261,7 @@ void NF_LoadColisionBg(const char* file, u8 id, u16 width, u16 height) {
|
||||
fclose(file_id); // Cierra el archivo
|
||||
|
||||
// Carga el archivo .CMP
|
||||
sprintf(filename, "%s/%s.cmp", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.cmp", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -295,7 +295,7 @@ void NF_LoadColisionBg(const char* file, u8 id, u16 width, u16 height) {
|
||||
void NF_UnloadColisionBg(u8 id) {
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_CMAP)) {
|
||||
if (id >= NF_SLOTS_CMAP) {
|
||||
NF_Error(106, "Colision Map", NF_SLOTS_CMAP);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ void NF_LoadBMP(const char* file, u8 slot) {
|
||||
char filename[256];
|
||||
|
||||
// Carga el archivo .BMP
|
||||
sprintf(filename, "%s/%s.bmp", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.bmp", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
|
||||
if (file_id) { // Si el archivo existe...
|
||||
|
@ -79,7 +79,7 @@ void NF_ResetRawSoundBuffers(void) {
|
||||
void NF_LoadRawSound(const char* file, u16 id, u16 freq, u8 format) {
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_RAWSOUND)) {
|
||||
if (id >= NF_SLOTS_RAWSOUND) {
|
||||
NF_Error(106, "Raw Sound", NF_SLOTS_RAWSOUND);
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ void NF_LoadRawSound(const char* file, u16 id, u16 freq, u8 format) {
|
||||
char filename[256];
|
||||
|
||||
// Carga el archivo .RAW
|
||||
sprintf(filename, "%s/%s.raw", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.raw", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -138,10 +138,12 @@ void NF_LoadRawSound(const char* file, u16 id, u16 freq, u8 format) {
|
||||
void NF_UnloadRawSound(u8 id) {
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_RAWSOUND)) NF_Error(106, "RAW Sound", NF_SLOTS_RAWSOUND);
|
||||
if (id >= NF_SLOTS_RAWSOUND)
|
||||
NF_Error(106, "RAW Sound", NF_SLOTS_RAWSOUND);
|
||||
|
||||
// Verifica si el sonido existe
|
||||
if (NF_RAWSOUND[id].available) NF_Error(110, "RAW Sound", id);
|
||||
if (NF_RAWSOUND[id].available)
|
||||
NF_Error(110, "RAW Sound", id);
|
||||
|
||||
// Vacia los buffers de la Id. seleccionada
|
||||
free(NF_BUFFER_RAWSOUND[id]);
|
||||
@ -164,10 +166,12 @@ void NF_UnloadRawSound(u8 id) {
|
||||
u8 NF_PlayRawSound(u8 id, u8 volume, u8 pan, bool loop, u16 loopfrom) {
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_RAWSOUND)) NF_Error(106, "RAW Sound", NF_SLOTS_RAWSOUND);
|
||||
if (id >= NF_SLOTS_RAWSOUND)
|
||||
NF_Error(106, "RAW Sound", NF_SLOTS_RAWSOUND);
|
||||
|
||||
// Verifica si el sonido existe
|
||||
if (NF_RAWSOUND[id].available) NF_Error(110, "RAW Sound", id);
|
||||
if (NF_RAWSOUND[id].available)
|
||||
NF_Error(110, "RAW Sound", id);
|
||||
|
||||
return soundPlaySample(NF_BUFFER_RAWSOUND[id], NF_RAWSOUND[id].format, NF_RAWSOUND[id].size, NF_RAWSOUND[id].freq, volume, pan, loop, loopfrom);
|
||||
|
||||
|
@ -205,10 +205,10 @@ void NF_InitSpriteSys(int screen, ...) {
|
||||
|
||||
|
||||
// Funcion NF_LoadSpriteGfx();
|
||||
void NF_LoadSpriteGfx(const char* file, u16 id, u16 width, u16 height) {
|
||||
void NF_LoadSpriteGfx(const char *file, u16 id, u16 width, u16 height) {
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_SPR256GFX)) {
|
||||
if (id >= NF_SLOTS_SPR256GFX) {
|
||||
NF_Error(106, "Sprite GFX", NF_SLOTS_SPR256GFX);
|
||||
}
|
||||
|
||||
@ -228,7 +228,7 @@ void NF_LoadSpriteGfx(const char* file, u16 id, u16 width, u16 height) {
|
||||
char filename[256];
|
||||
|
||||
// Carga el archivo .IMG
|
||||
sprintf(filename, "%s/%s.img", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.img", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -262,7 +262,7 @@ void NF_LoadSpriteGfx(const char* file, u16 id, u16 width, u16 height) {
|
||||
void NF_UnloadSpriteGfx(u16 id) {
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_SPR256GFX)) {
|
||||
if (id >= NF_SLOTS_SPR256GFX) {
|
||||
NF_Error(106, "Sprite GFX", NF_SLOTS_SPR256GFX);
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ void NF_LoadSpritePal(const char* file, u8 id) {
|
||||
u32 pal_size = 0;
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_SPR256PAL)) {
|
||||
if (id >= NF_SLOTS_SPR256PAL) {
|
||||
NF_Error(106, "Sprite PAL", NF_SLOTS_SPR256PAL);
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ void NF_LoadSpritePal(const char* file, u8 id) {
|
||||
char filename[256];
|
||||
|
||||
// Carga el archivo .PAL
|
||||
sprintf(filename, "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -345,7 +345,7 @@ void NF_LoadSpritePal(const char* file, u8 id) {
|
||||
void NF_UnloadSpritePal(u8 id) {
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_SPR256PAL)) {
|
||||
if (id >= NF_SLOTS_SPR256PAL) {
|
||||
NF_Error(106, "Sprite PAL", NF_SLOTS_SPR256PAL);
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ void NF_UnloadSpritePal(u8 id) {
|
||||
void NF_VramSpriteGfx(u8 screen, u16 ram, u16 vram, bool keepframes) {
|
||||
|
||||
// Verifica el rango de Id's de RAM
|
||||
if ((ram < 0) || (ram >= NF_SLOTS_SPR256GFX)) {
|
||||
if (ram >= NF_SLOTS_SPR256GFX) {
|
||||
NF_Error(106, "Sprite GFX", (NF_SLOTS_SPR256GFX - 1));
|
||||
}
|
||||
|
||||
@ -380,7 +380,7 @@ void NF_VramSpriteGfx(u8 screen, u16 ram, u16 vram, bool keepframes) {
|
||||
}
|
||||
|
||||
// Verifica el rango de Id's de VRAM
|
||||
if ((vram < 0) || (vram > 127)) {
|
||||
if (vram > 127) {
|
||||
NF_Error(106, "VRAM GFX", 127);
|
||||
}
|
||||
|
||||
@ -645,7 +645,7 @@ void NF_VramSpriteGfxDefrag(u8 screen) {
|
||||
void NF_VramSpritePal(u8 screen, u8 id, u8 slot) {
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_SPR256PAL)) {
|
||||
if (id >= NF_SLOTS_SPR256PAL) {
|
||||
NF_Error(106, "Sprite PAL", NF_SLOTS_SPR256PAL);
|
||||
}
|
||||
|
||||
@ -655,7 +655,7 @@ void NF_VramSpritePal(u8 screen, u8 id, u8 slot) {
|
||||
}
|
||||
|
||||
// Verifica si te has salido de rango (Paleta)
|
||||
if ((slot < 0) || (slot > 15)) {
|
||||
if (slot > 15) {
|
||||
NF_Error(106, "Sprite Palette Slot", 15);
|
||||
}
|
||||
|
||||
@ -684,12 +684,12 @@ void NF_VramSpritePal(u8 screen, u8 id, u8 slot) {
|
||||
void NF_CreateSprite(u8 screen, u8 id, u16 gfx, u8 pal, s16 x, s16 y) {
|
||||
|
||||
// Verifica el rango de Id's de Sprites
|
||||
if ((id < 0) || (id > 127)) {
|
||||
if (id > 127) {
|
||||
NF_Error(106, "Sprite", 127);
|
||||
}
|
||||
|
||||
// Verifica el rango de Id's de Gfx
|
||||
if ((gfx < 0) || (gfx > 127)) {
|
||||
if (gfx > 127) {
|
||||
NF_Error(106, "Sprite GFX", 127);
|
||||
}
|
||||
|
||||
@ -699,7 +699,7 @@ void NF_CreateSprite(u8 screen, u8 id, u16 gfx, u8 pal, s16 x, s16 y) {
|
||||
}
|
||||
|
||||
// Verifica el rango de slots de paletas
|
||||
if ((pal < 0) || (pal > 15)) {
|
||||
if (pal > 15) {
|
||||
NF_Error(106, "Sprite Palette Slot", 15);
|
||||
}
|
||||
|
||||
@ -794,14 +794,14 @@ void NF_CreateSprite(u8 screen, u8 id, u16 gfx, u8 pal, s16 x, s16 y) {
|
||||
void NF_DeleteSprite(u8 screen, u8 id) {
|
||||
|
||||
// Verifica el rango de Id's de Sprites
|
||||
if ((id < 0) || (id > 127)) {
|
||||
if (id > 127) {
|
||||
NF_Error(106, "Sprite", 127);
|
||||
}
|
||||
|
||||
// Verifica si el Sprite esta creado
|
||||
if (!NF_SPRITEOAM[screen][id].created) {
|
||||
char text[4];
|
||||
sprintf(text, "%d", screen);
|
||||
snprintf(text, sizeof(text), "%d", screen);
|
||||
NF_Error(112, text, id);
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ void NF_Init3dSpriteSys(void) {
|
||||
void NF_Vram3dSpriteGfx(u16 ram, u16 vram, bool keepframes) {
|
||||
|
||||
// Verifica el rango de Id's de RAM
|
||||
if ((ram < 0) || (ram >= NF_SLOTS_SPR256GFX)) {
|
||||
if (ram >= NF_SLOTS_SPR256GFX) {
|
||||
NF_Error(106, "Sprite GFX", (NF_SLOTS_SPR256GFX - 1));
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ void NF_Vram3dSpriteGfx(u16 ram, u16 vram, bool keepframes) {
|
||||
}
|
||||
|
||||
// Verifica el rango de Id's de VRAM
|
||||
if ((vram < 0) || (vram >= NF_3DSPRITES)) {
|
||||
if (vram >= NF_3DSPRITES) {
|
||||
NF_Error(106, "VRAM GFX", (NF_3DSPRITES - 1));
|
||||
}
|
||||
|
||||
@ -442,7 +442,7 @@ void NF_Vram3dSpriteGfxDefrag(void) {
|
||||
void NF_Vram3dSpritePal(u8 id, u8 slot) {
|
||||
|
||||
// Verifica el rango de Id's
|
||||
if ((id < 0) || (id >= NF_SLOTS_SPR256PAL)) {
|
||||
if (id >= NF_SLOTS_SPR256PAL) {
|
||||
NF_Error(106, "Sprite PAL", NF_SLOTS_SPR256PAL);
|
||||
}
|
||||
|
||||
@ -452,7 +452,7 @@ void NF_Vram3dSpritePal(u8 id, u8 slot) {
|
||||
}
|
||||
|
||||
// Verifica si te has salido de rango (Paleta)
|
||||
if ((slot < 0) || (slot > 31)) {
|
||||
if (slot > 31) {
|
||||
NF_Error(106, "Sprite Palette Slot", 31);
|
||||
}
|
||||
|
||||
@ -474,12 +474,12 @@ void NF_Vram3dSpritePal(u8 id, u8 slot) {
|
||||
void NF_Create3dSprite(u16 id, u16 gfx, u16 pal, s16 x, s16 y) {
|
||||
|
||||
// Verifica el rango de Id's de Sprites
|
||||
if ((id < 0) || (id > (NF_3DSPRITES - 1))) {
|
||||
if (id > (NF_3DSPRITES - 1)) {
|
||||
NF_Error(106, "3D Sprite", (NF_3DSPRITES - 1));
|
||||
}
|
||||
|
||||
// Verifica el rango de Id's de Gfx
|
||||
if ((gfx < 0) || (gfx > (NF_3DSPRITES - 1))) {
|
||||
if (gfx > (NF_3DSPRITES - 1)) {
|
||||
NF_Error(106, "3D Sprite GFX", (NF_3DSPRITES - 1));
|
||||
}
|
||||
|
||||
@ -489,7 +489,7 @@ void NF_Create3dSprite(u16 id, u16 gfx, u16 pal, s16 x, s16 y) {
|
||||
}
|
||||
|
||||
// Verifica el rango de slots de paletas
|
||||
if ((pal < 0) || (pal > 31)) {
|
||||
if (pal > 31) {
|
||||
NF_Error(106, "3D Sprite Palette Slot", 31);
|
||||
}
|
||||
|
||||
@ -538,7 +538,7 @@ void NF_Create3dSprite(u16 id, u16 gfx, u16 pal, s16 x, s16 y) {
|
||||
void NF_Delete3dSprite(u16 id) {
|
||||
|
||||
// Verifica el rango de Id's de Sprites
|
||||
if ((id < 0) || (id > (NF_3DSPRITES - 1))) {
|
||||
if (id > (NF_3DSPRITES - 1)) {
|
||||
NF_Error(106, "3D Sprite", (NF_3DSPRITES - 1));
|
||||
}
|
||||
|
||||
@ -723,7 +723,7 @@ void NF_Show3dSprite(u16 id, bool show) {
|
||||
void NF_Set3dSpriteFrame(u16 id, u16 frame) {
|
||||
|
||||
// Verifica el rango de Id's de Sprites
|
||||
if ((id < 0) || (id > (NF_3DSPRITES - 1))) {
|
||||
if (id > (NF_3DSPRITES - 1)) {
|
||||
NF_Error(106, "3D Sprite", (NF_3DSPRITES - 1));
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ void NF_LoadTextFont(const char* file, const char* name, u16 width, u16 height,
|
||||
char filename[256];
|
||||
|
||||
// Carga el archivo .FNT
|
||||
sprintf(filename, "%s/%s.fnt", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.fnt", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -123,7 +123,7 @@ void NF_LoadTextFont(const char* file, const char* name, u16 width, u16 height,
|
||||
memset(NF_BUFFER_BGMAP[slot], 0, NF_TILEDBG[slot].mapsize);
|
||||
|
||||
// Carga el archivo .PAL
|
||||
sprintf(filename, "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -143,7 +143,7 @@ void NF_LoadTextFont(const char* file, const char* name, u16 width, u16 height,
|
||||
fclose(file_id); // Cierra el archivo
|
||||
|
||||
// Guarda el nombre del Fondo
|
||||
sprintf(NF_TILEDBG[slot].name, "%s", name);
|
||||
snprintf(NF_TILEDBG[slot].name, sizeof(NF_TILEDBG[slot].name), "%s", name);
|
||||
|
||||
// Y las medidas
|
||||
NF_TILEDBG[slot].width = width;
|
||||
@ -171,7 +171,7 @@ void NF_CreateTextLayer(u8 screen, u8 layer, u8 rotation, const char* name) {
|
||||
NF_CreateTiledBg(screen, layer, name);
|
||||
|
||||
// Busca el numero de slot donde esta cargada la fuente
|
||||
sprintf(bg, "%s", name); // Obten el nombre del fondo a buscar
|
||||
snprintf(bg, sizeof(bg), "%s", name); // Obten el nombre del fondo a buscar
|
||||
for (n = 0; n < NF_SLOTS_TBG; n ++) { // Busca en todos los slots
|
||||
if (strcmp(bg, NF_TILEDBG[n].name) == 0) { // Si lo encuentras
|
||||
slot = n; // Guarda el slot a usar
|
||||
|
@ -68,7 +68,7 @@ void NF_LoadTextFont16(const char* file, const char* name, u16 width, u16 height
|
||||
char filename[256];
|
||||
|
||||
// Carga el archivo .fnt
|
||||
sprintf(filename, "%s/%s.fnt", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.fnt", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -104,7 +104,7 @@ void NF_LoadTextFont16(const char* file, const char* name, u16 width, u16 height
|
||||
memset(NF_BUFFER_BGMAP[slot], 0, NF_TILEDBG[slot].mapsize);
|
||||
|
||||
// Carga el archivo .PAL
|
||||
sprintf(filename, "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -127,7 +127,7 @@ void NF_LoadTextFont16(const char* file, const char* name, u16 width, u16 height
|
||||
fclose(file_id); // Cierra el archivo
|
||||
|
||||
// Guarda el nombre del Fondo
|
||||
sprintf(NF_TILEDBG[slot].name, "%s", name);
|
||||
snprintf(NF_TILEDBG[slot].name, sizeof(NF_TILEDBG[slot].name), "%s", name);
|
||||
|
||||
// Y las medidas
|
||||
NF_TILEDBG[slot].width = width;
|
||||
@ -150,7 +150,7 @@ void NF_CreateTextLayer16(u8 screen, u8 layer, u8 rotation, const char* name) {
|
||||
NF_CreateTiledBg(screen, layer, name);
|
||||
|
||||
// Busca el numero de slot donde esta cargada la fuente
|
||||
sprintf(bg, "%s", name); // Obten el nombre del fondo a buscar
|
||||
snprintf(bg, sizeof(bg), "%s", name); // Obten el nombre del fondo a buscar
|
||||
for (n = 0; n < NF_SLOTS_TBG; n ++) { // Busca en todos los slots
|
||||
if (strcmp(bg, NF_TILEDBG[n].name) == 0) { // Si lo encuentras
|
||||
slot = n; // Guarda el slot a usar
|
||||
|
@ -55,7 +55,7 @@ void NF_InitTiledBgBuffers(void) {
|
||||
NF_BUFFER_BGTILES[n] = NULL; // Buffer para los tiles
|
||||
NF_BUFFER_BGMAP[n] = NULL; // Buffer para el map
|
||||
NF_BUFFER_BGPAL[n] = NULL; // Buffer para la paleta
|
||||
sprintf(NF_TILEDBG[n].name, "xxxNONAMExxx"); // Nombre del Tileset
|
||||
snprintf(NF_TILEDBG[n].name, sizeof(NF_TILEDBG[n].name), "xxxNONAMExxx");
|
||||
NF_TILEDBG[n].tilesize = 0; // Tamaño del Tileset
|
||||
NF_TILEDBG[n].mapsize = 0; // Tamaño del Mapa
|
||||
NF_TILEDBG[n].palsize = 0; // Tamaño de la Paleta
|
||||
@ -205,7 +205,7 @@ void NF_LoadTiledBg(const char* file, const char* name, u16 width, u16 height) {
|
||||
char filename[256];
|
||||
|
||||
// Carga el archivo .IMG
|
||||
sprintf(filename, "%s/%s.img", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.img", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -225,7 +225,7 @@ void NF_LoadTiledBg(const char* file, const char* name, u16 width, u16 height) {
|
||||
fclose(file_id); // Cierra el archivo
|
||||
|
||||
// Carga el archivo .MAP
|
||||
sprintf(filename, "%s/%s.map", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.map", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -245,7 +245,7 @@ void NF_LoadTiledBg(const char* file, const char* name, u16 width, u16 height) {
|
||||
fclose(file_id); // Cierra el archivo
|
||||
|
||||
// Carga el archivo .PAL
|
||||
sprintf(filename, "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -268,7 +268,7 @@ void NF_LoadTiledBg(const char* file, const char* name, u16 width, u16 height) {
|
||||
fclose(file_id); // Cierra el archivo
|
||||
|
||||
// Guarda el nombre del Fondo
|
||||
sprintf(NF_TILEDBG[slot].name, "%s", name);
|
||||
snprintf(NF_TILEDBG[slot].name, sizeof(NF_TILEDBG[slot].name), "%s", name);
|
||||
|
||||
// Y las medidas
|
||||
NF_TILEDBG[slot].width = width;
|
||||
@ -320,7 +320,7 @@ void NF_LoadTilesForBg(const char* file, const char* name, u16 width, u16 height
|
||||
char filename[256];
|
||||
|
||||
// Carga el archivo .IMG
|
||||
sprintf(filename, "%s/%s.img", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.img", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -361,7 +361,7 @@ void NF_LoadTilesForBg(const char* file, const char* name, u16 width, u16 height
|
||||
|
||||
|
||||
// Carga el archivo .PAL
|
||||
sprintf(filename, "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -384,7 +384,7 @@ void NF_LoadTilesForBg(const char* file, const char* name, u16 width, u16 height
|
||||
fclose(file_id); // Cierra el archivo
|
||||
|
||||
// Guarda el nombre del Fondo
|
||||
sprintf(NF_TILEDBG[slot].name, "%s", name);
|
||||
snprintf(NF_TILEDBG[slot].name, sizeof(NF_TILEDBG[slot].name), "%s", name);
|
||||
|
||||
// Y las medidas
|
||||
NF_TILEDBG[slot].width = width;
|
||||
@ -403,7 +403,7 @@ void NF_UnloadTiledBg(const char* name) {
|
||||
char bg[32]; // Nombre
|
||||
|
||||
// Busca el fondo solicitado
|
||||
sprintf(bg, "%s", name); // Obten el nombre del fondo a buscar
|
||||
snprintf(bg, sizeof(bg), "%s", name); // Obten el nombre del fondo a buscar
|
||||
for (n = 0; n < NF_SLOTS_TBG; n ++) { // Busca en todos los slots
|
||||
if (strcmp(bg, NF_TILEDBG[n].name) == 0) { // Si lo encuentras
|
||||
slot = n; // Guarda el slot a usar
|
||||
@ -424,7 +424,7 @@ void NF_UnloadTiledBg(const char* name) {
|
||||
NF_BUFFER_BGPAL[slot] = NULL;
|
||||
|
||||
// Resetea las variables para ese fondo
|
||||
sprintf(NF_TILEDBG[slot].name, "xxxNONAMExxx"); // Nombre del Tileset
|
||||
snprintf(NF_TILEDBG[slot].name, sizeof(NF_TILEDBG[slot].name), "xxxNONAMExxx");
|
||||
NF_TILEDBG[slot].tilesize = 0; // Tamaño del Tileset
|
||||
NF_TILEDBG[slot].mapsize = 0; // Tamaño del Mapa
|
||||
NF_TILEDBG[slot].palsize = 0; // Tamaño de la Paleta
|
||||
@ -445,7 +445,7 @@ void NF_CreateTiledBg(u8 screen, u8 layer, const char* name) {
|
||||
char bg[32]; // Nombre
|
||||
|
||||
// Busca el fondo solicitado
|
||||
sprintf(bg, "%s", name); // Obten el nombre del fondo a buscar
|
||||
snprintf(bg, sizeof(bg), "%s", name); // Obten el nombre del fondo a buscar
|
||||
for (n = 0; n < NF_SLOTS_TBG; n ++) { // Busca en todos los slots
|
||||
if (strcmp(bg, NF_TILEDBG[n].name) == 0) { // Si lo encuentras
|
||||
slot = n; // Guarda el slot a usar
|
||||
@ -719,7 +719,7 @@ void NF_DeleteTiledBg(u8 screen, u8 layer) {
|
||||
// Verifica que el fondo esta creado
|
||||
if (!NF_TILEDBG_LAYERS[screen][layer].created) {
|
||||
char text[32];
|
||||
sprintf(text, "%d", screen);
|
||||
snprintf(text, sizeof(text), "%d", screen);
|
||||
NF_Error(105, text, layer); // Si no existe, error
|
||||
}
|
||||
|
||||
@ -810,7 +810,7 @@ u32 NF_GetTileMapAddress(u8 screen, u8 layer, u16 tile_x, u16 tile_y) {
|
||||
// Verifica que el fondo esta creado
|
||||
if (!NF_TILEDBG_LAYERS[screen][layer].created) {
|
||||
char text[32];
|
||||
sprintf(text, "%d", screen);
|
||||
snprintf(text, sizeof(text), "%d", screen);
|
||||
NF_Error(105, text, layer); // Si no existe, error
|
||||
}
|
||||
|
||||
@ -881,7 +881,7 @@ void NF_UpdateVramMap(u8 screen, u8 layer) {
|
||||
// Verifica que el fondo esta creado
|
||||
if (!NF_TILEDBG_LAYERS[screen][layer].created) {
|
||||
char text[32];
|
||||
sprintf(text, "%d", screen);
|
||||
snprintf(text, sizeof(text), "%d", screen);
|
||||
NF_Error(105, text, layer); // Si no existe, error
|
||||
}
|
||||
|
||||
@ -946,7 +946,7 @@ void NF_BgSetPalColor(u8 screen, u8 layer, u8 number, u8 r, u8 g, u8 b) {
|
||||
// Verifica que el fondo esta creado
|
||||
if (!NF_TILEDBG_LAYERS[screen][layer].created) {
|
||||
char text[32];
|
||||
sprintf(text, "%d", screen);
|
||||
snprintf(text, sizeof(text), "%d", screen);
|
||||
NF_Error(105, text, layer); // Si no existe, error
|
||||
}
|
||||
|
||||
@ -982,7 +982,7 @@ void NF_BgEditPalColor(u8 screen, u8 layer, u8 number, u8 r, u8 g, u8 b) {
|
||||
// Verifica que el fondo esta creado
|
||||
if (!NF_TILEDBG_LAYERS[screen][layer].created) {
|
||||
char text[32];
|
||||
sprintf(text, "%d", screen);
|
||||
snprintf(text, sizeof(text), "%d", screen);
|
||||
NF_Error(105, text, layer); // Si no existe, error
|
||||
}
|
||||
|
||||
@ -1007,7 +1007,7 @@ void NF_BgUpdatePalette(u8 screen, u8 layer) {
|
||||
// Verifica que el fondo esta creado
|
||||
if (!NF_TILEDBG_LAYERS[screen][layer].created) {
|
||||
char text[32];
|
||||
sprintf(text, "%d", screen);
|
||||
snprintf(text, sizeof(text), "%d", screen);
|
||||
NF_Error(105, text, layer); // Si no existe, error
|
||||
}
|
||||
|
||||
@ -1044,7 +1044,7 @@ void NF_BgGetPalColor(u8 screen, u8 layer, u8 number, u8* r, u8* g, u8* b) {
|
||||
// Verifica que el fondo esta creado
|
||||
if (!NF_TILEDBG_LAYERS[screen][layer].created) {
|
||||
char text[32];
|
||||
sprintf(text, "%d", screen);
|
||||
snprintf(text, sizeof(text), "%d", screen);
|
||||
NF_Error(105, text, layer); // Si no existe, error
|
||||
}
|
||||
|
||||
@ -1121,7 +1121,7 @@ void NF_LoadExBgPal(const char* file, u8 slot) {
|
||||
char filename[256];
|
||||
|
||||
// Carga el archivo .PAL
|
||||
sprintf(filename, "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.pal", NF_ROOTFOLDER, file);
|
||||
file_id = fopen(filename, "rb");
|
||||
if (file_id) { // Si el archivo existe...
|
||||
// Obten el tamaño del archivo
|
||||
@ -1219,7 +1219,7 @@ void NF_SetExBgPal(u8 screen, u8 layer, u8 pal) {
|
||||
// Verifica que el fondo esta creado
|
||||
if (!NF_TILEDBG_LAYERS[screen][layer].created) {
|
||||
char text[32];
|
||||
sprintf(text, "%d", screen);
|
||||
snprintf(text, sizeof(text), "%d", screen);
|
||||
NF_Error(105, text, layer); // Si no existe, error
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user