examples: Cleanup and translate the remaining examples to English

This commit is contained in:
Antonio Niño Díaz 2023-05-21 20:31:06 +01:00
parent 4d4cb6ab8e
commit 498a0a2464
33 changed files with 696 additions and 944 deletions

View File

@ -67,7 +67,7 @@ int main(int argc, char **argv)
s16 iy = 4;
// Initialize sprite variables and create the sprites
for (int n = 0; n < MAXSPRITES; n ++)
for (int n = 0; n < MAXSPRITES; n++)
{
x[n] = 128 - 32;
y[n] = 96 - 32;
@ -87,7 +87,7 @@ int main(int argc, char **argv)
u16 keys = keysHeld(); // Keys currently pressed
// Move sprites that follow the main one
for (int n = MAXSPRITES - 1; n > 0; n --)
for (int n = MAXSPRITES - 1; n > 0; n--)
{
x[n] = x[n - 1];
y[n] = y[n - 1];

View File

@ -52,13 +52,13 @@ int main(int argc, char **argv)
NF_LoadTiledBg("bg/bg3", "bg3", 256, 256);
// Load sprite files from NitroFS
for (int n = 0; n < SPRITEMAXNUM; n ++)
for (int n = 0; n < SPRITEMAXNUM; n++)
NF_LoadSpriteGfx("sprite/numbers", n, 16, 16);
NF_LoadSpritePal("sprite/numbers", 0);
// Transfer the required sprites to VRAM
for (int n = 0; n < SPRITEMAXNUM; n ++)
for (int n = 0; n < SPRITEMAXNUM; n++)
NF_Vram3dSpriteGfx(n, n, true);
NF_Vram3dSpritePal(0, 0);
@ -103,7 +103,7 @@ int main(int argc, char **argv)
while (1)
{
// Move sprites
for (int n = 0; n < SPRITEMAXNUM; n ++)
for (int n = 0; n < SPRITEMAXNUM; n++)
{
x[n] += ix[n];
if ((x[n] < 0) || (x[n] > (255 - NF_3DSPRITE[n].width)))
@ -113,7 +113,7 @@ int main(int argc, char **argv)
if ((y[n] < 0) || (y[n] > (191 - NF_3DSPRITE[n].height)))
iy[n] = -iy[n];
timer[n] ++;
timer[n]++;
if (timer[n] > 19)
{
timer[n] = 0;

View File

@ -74,7 +74,7 @@ int main(int argc, char **argv)
s16 iy[MAXSPRITES];
// Initialize sprite variables and create the sprites
for (int n = 0; n < MAXSPRITES; n ++)
for (int n = 0; n < MAXSPRITES; n++)
{
int r = n % 2;
@ -103,7 +103,7 @@ int main(int argc, char **argv)
u16 keys = keysDown();
// Move sprites
for (int n = 0; n < MAXSPRITES; n ++)
for (int n = 0; n < MAXSPRITES; n++)
{
x[n] += ix[n];
if ((x[n] < 0) || (x[n] > (255 - NF_3DSPRITE[n].width)))

View File

@ -54,13 +54,13 @@ int main(int argc, char **argv)
NF_LoadTiledBg("bg/bg1", "bg1", 2048, 256);
// Load sprite files from NitroFS
for (int n = 0; n < SPRITEMAXNUM; n ++)
for (int n = 0; n < SPRITEMAXNUM; n++)
NF_LoadSpriteGfx("sprite/numbers", n, 16, 16);
NF_LoadSpritePal("sprite/numbers", 0);
// Transfer the required sprites to VRAM
for (int n = 0; n < SPRITEMAXNUM; n ++)
for (int n = 0; n < SPRITEMAXNUM; n++)
NF_Vram3dSpriteGfx(n, n, true);
NF_Vram3dSpritePal(0, 0);
@ -84,7 +84,7 @@ int main(int argc, char **argv)
int layer = 0;
// Inicializa las variables
for (int n = 0; n < SPRITEMAXNUM; n ++)
for (int n = 0; n < SPRITEMAXNUM; n++)
{
x[n] = rand() % 239;
y[n] = rand() % 175;
@ -115,7 +115,7 @@ int main(int argc, char **argv)
u16 keys = keysHeld(); // Keys currently pressed
// Move all sprites
for (int n = 0; n < SPRITEMAXNUM; n ++)
for (int n = 0; n < SPRITEMAXNUM; n++)
{
x[n] += ix[n];
if ((x[n] < 0) || (x[n] > (255 - NF_3DSPRITE[n].width)))

View File

@ -123,12 +123,12 @@ int main(int argc, char **argv)
// Change the priority of the sprite
if ((keys & KEY_A) && (prio > 0))
{
prio --;
prio--;
NF_Set3dSpritePriority(TARGET, prio);
}
if ((keys & KEY_B) && (prio < (MAXSPRITES - 1)))
{
prio ++;
prio++;
NF_Set3dSpritePriority(TARGET, prio);
}

View File

@ -58,7 +58,7 @@ int main(int argc, char **argv)
NF_VramSpritePal(0, 0, 0);
// Create sprites and set their priority layer
for (int b = 0; b < 3; b ++)
for (int b = 0; b < 3; b++)
{
NF_CreateSprite(0, b, 0, 0, -16, -16);
NF_SpriteLayer(0, b, 3);
@ -83,13 +83,13 @@ int main(int argc, char **argv)
bool right = false;
// Handle collisions and fall of all balls
for (int b = 0; b < 3; b ++)
for (int b = 0; b < 3; b++)
{
down = true; // If this remains true, there is no collision
// Check all pixels of the lower half of the ball to see if there is
// a collision.
for (int n = 0; n < 16; n ++)
for (int n = 0; n < 16; n++)
{
// Blue pixels are index 4
if (NF_GetPoint(0, (x[b] + n), (y[b] + py[n])) == 4)
@ -117,15 +117,15 @@ int main(int argc, char **argv)
// Free fall
if (down)
y[b] ++;
y[b]++;
// Move right
if (right)
x[b] ++;
x[b]++;
// Move left
if (left)
x[b] --;
x[b]--;
// If the ball exits the screen from the bottom move it to the top
if (y[b] > 192)

View File

@ -75,13 +75,13 @@ int main(int argc, char **argv)
u16 keys = keysHeld(); // Keys currently pressed
if (keys & KEY_UP)
y --;
y--;
if (keys & KEY_DOWN)
y ++;
y++;
if (keys & KEY_LEFT)
x --;
x--;
if (keys & KEY_RIGHT)
x ++;
x++;
// Movement limits
if (x < 0)

View File

@ -95,13 +95,13 @@ int main(int argc, char **argv)
u16 keys = keysHeld(); // Keys currently pressed
if (keys & KEY_UP)
y --;
y--;
if (keys & KEY_DOWN)
y ++;
y++;
if (keys & KEY_LEFT)
x --;
x--;
if (keys & KEY_RIGHT)
x ++;
x++;
// Limites del movimiento
if (x < 0)

View File

@ -82,7 +82,7 @@ int main(int argc, char **argv)
s8 bola_spx[32];
s8 bola_spy[32];
for (int n = 0; n < 32; n ++)
for (int n = 0; n < 32; n++)
{
bola_x[n] = rand() % 223;
bola_y[n] = rand() % 159;
@ -118,9 +118,9 @@ int main(int argc, char **argv)
// Draw a 16x16 block around the touchscreen coordinates in the
// bottom screen.
for (int dy = 0; dy < 16; dy ++)
for (int dy = 0; dy < 16; dy++)
{
for (int dx = 0; dx < 16; dx ++)
for (int dx = 0; dx < 16; dx++)
{
u16 idx = ((y + dy) << 8) + (x + dx);
NF_8BITS_BACKBUFFER[1].data[idx] = 0;
@ -136,7 +136,7 @@ int main(int argc, char **argv)
NF_Flip8bitsBackBuffer(1, 0);
// Move the sprites
for (int n = 0; n < 32; n ++)
for (int n = 0; n < 32; n++)
{
bola_x[n] += bola_spx[n];
if ((bola_x[n] < 0) || (bola_x[n] > 223))

View File

@ -122,14 +122,14 @@ int main(int argc, char **argv)
// Move background
if ((keys & KEY_LEFT) && (bg_x[0] > 8))
bg_x[0] --;
bg_x[0]--;
if ((keys & KEY_RIGHT) && (bg_x[0] < 247))
bg_x[0] ++;
bg_x[0]++;
// Calculate parallax
bg_x[1] = (int)(bg_x[0] / 1.5);
bg_x[2] = (int)(bg_x[1] / 1.5);
bg_x[3] = (int)(bg_x[2] / 1.5);
bg_x[1] = bg_x[0] / 1.5;
bg_x[2] = bg_x[1] / 1.5;
bg_x[3] = bg_x[2] / 1.5;
// Wait for the screen refresh
swiWaitForVBlank();

View File

@ -69,9 +69,9 @@ int main(int argc, char **argv)
// Flip vertically all the tiles in the map of the bottom screen, and copy
// them to a temporary buffer
for (int y = 0; y < 24; y ++)
for (int y = 0; y < 24; y++)
{
for (int x = 0; x < 32; x ++)
for (int x = 0; x < 32; x++)
{
NF_SetTileVflip(1, 3, x, y);
mapa[x][y] = NF_GetTileOfMap(1, 3, x, y);
@ -79,9 +79,9 @@ int main(int argc, char **argv)
}
// Now copy the tiles in reverse order to flip the image correctly
for (int y = 0; y < 24; y ++)
for (int y = 0; y < 24; y++)
{
for (int x = 0; x < 32; x ++)
for (int x = 0; x < 32; x++)
{
NF_SetTileOfMap(1, 3, x, (23 - y), mapa[x][y]);
}
@ -94,7 +94,7 @@ int main(int argc, char **argv)
s8 inc = 1;
int x = 0;
for (int y = 0; y < 192; y ++)
for (int y = 0; y < 192; y++)
{
x += inc;
bgx[y] = x;

View File

@ -89,9 +89,9 @@ int main(int argc, char **argv)
int zoom_y = 0;
// Fill buffer
for (int y = square_y; y < (square_y + 96); y ++)
for (int y = square_y; y < square_y + 96; y++)
{
for (int x = square_x; x < (square_x + 128); x ++)
for (int x = square_x; x < square_x + 128; x++)
{
u32 rgb;
u32 red, green, blue;
@ -145,7 +145,7 @@ int main(int argc, char **argv)
// Draw the vertical line that splits both halves
if (zoom_x == 126)
{
for (int i = 0; i < 4; i ++)
for (int i = 0; i < 4; i++)
{
r[i] = 5;
g[i] = 10;

View File

@ -90,9 +90,9 @@ int main(int argc, char **argv)
int zoom_y = 0;
// Fill buffer
for (int y = square_y; y < (square_y + 64); y ++)
for (int y = square_y; y < (square_y + 64); y++)
{
for (int x = square_x; x < (square_x + 85); x ++)
for (int x = square_x; x < (square_x + 85); x++)
{
u32 rgb;
u32 red, green, blue;
@ -158,7 +158,7 @@ int main(int argc, char **argv)
// Draw the vertical line that splits both halves
if (zoom_x == 126)
{
for (int i = 1; i < 5; i ++)
for (int i = 1; i < 5; i++)
{
r[i] = 5;
g[i] = 10;

View File

@ -143,7 +143,7 @@ int main(int argc, char **argv)
swiWaitForVBlank();
// Update parameters of the affine backgrounds
for (int n = 0; n < 2; n ++)
for (int n = 0; n < 2; n++)
{
NF_AffineBgTransform(n, 3, zoom, zoom, 0, 0);
NF_AffineBgCenter(n, 3, x, y);

View File

@ -137,7 +137,7 @@ int main(int argc, char **argv)
}
// Move balls
for (int n = 0; n < 32; n ++)
for (int n = 0; n < 32; n++)
{
bola_x[n] += bola_spx[n];
if ((bola_x[n] < 0) || (bola_x[n] > 223))
@ -164,7 +164,7 @@ int main(int argc, char **argv)
blink ^= 1;
// "Dissolve" background effect
alpha_timer ++;
alpha_timer++;
if (alpha_timer > 5)
{
alpha_timer = 0;

View File

@ -34,9 +34,9 @@ void InitAnimatedBg(void)
}
// Generate map of water background
for (int y = 0; y < MAP_Y; y ++)
for (int y = 0; y < MAP_Y; y++)
{
for (int x = 0; x < MAP_X; x ++)
for (int x = 0; x < MAP_X; x++)
{
// Calculate the map 4x4 region to fill
int start_x = x << 2;
@ -81,9 +81,9 @@ void AnimateWater(void)
WATER_SPEED = 0;
// Change the required tiles for the animation
for (int y = 0; y < MAP_Y; y ++)
for (int y = 0; y < MAP_Y; y++)
{
for (int x = 0; x < MAP_X; x ++)
for (int x = 0; x < MAP_X; x++)
{
// Calculate the map 4x4 region to fill
int start_x = x << 2;

View File

@ -38,9 +38,9 @@ int main(int argc, char **argv)
while (1)
{
// Fill buffer
for (int y = 0; y < 256; y ++)
for (int y = 0; y < 256; y++)
{
for (int x = 0; x < 256; x ++)
for (int x = 0; x < 256; x++)
{
// Calculate new color
r++;

View File

@ -118,7 +118,7 @@ int main(int argc, char **argv)
}
// Draw the window
for (int y = sqr_ya; y < sqr_yb; y ++)
for (int y = sqr_ya; y < sqr_yb; y++)
{
u32 offset = (y << 8) + sqr_xa;

View File

@ -86,7 +86,7 @@ int main(int argc, char **argv)
swiWaitForVBlank();
// Update background scroll during vertical blanking to avoid tearing
for (int n = 0; n < 4; n ++)
for (int n = 0; n < 4; n++)
NF_ScrollBg(1, n, bg_x[n], bg_y[n]);
}

View File

@ -1,97 +1,57 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// Example of loading 16-bit bitmap backgrounds.
// http://www.nightfoxandco.com
/*
-------------------------------------------------
NightFox's Lib Template
Ejemplo carga de fondos en 16bits (modo BITMAP)
Requiere DevkitARM
Requiere NightFox's Lib
Codigo por NightFox
http://www.nightfoxandco.com
Inicio 10 de Octubre del 2009
-------------------------------------------------
*/
/*
-------------------------------------------------
Includes
-------------------------------------------------
*/
// Includes C
#include <stdio.h>
#include <string.h>
#include <unistd.h>
// Includes propietarios NDS
#include <nds.h>
#include <filesystem.h>
// Includes librerias propias
#include <nf_lib.h>
int main(int argc, char **argv)
{
// Prepare a NitroFS initialization screen
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Initialize NitroFS and set it as the root folder of the filesystem
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS");
// Initialize 2D engine in both screens and use mode 5
NF_Set2D(0, 5);
NF_Set2D(1, 5);
// Initialize bitmap backgrounds system
NF_InitBitmapBgSys(0, 1);
NF_InitBitmapBgSys(1, 1);
/*
-------------------------------------------------
Main() - Bloque general del programa
-------------------------------------------------
*/
// Initialize storage buffers
NF_Init16bitsBgBuffers();
int main(int argc, char **argv) {
// Load bitmap background files from NitroFS
NF_Load16bitsBg("bmp/bitmap16", 0);
// Pantalla de espera inicializando NitroFS
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Tranfer image to VRAM of both screens
NF_Copy16bitsBuffer(0, 0, 0);
NF_Copy16bitsBuffer(1, 0, 0);
// Define el ROOT e inicializa el sistema de archivos
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS"); // Define la carpeta ROOT para usar NITROFS
// It's not needed to use it any longer, so remove it from RAM
NF_Unload16bitsBg(0);
// Inicializa el motor 2D en modo BITMAP
NF_Set2D(0, 5); // Modo 2D_5 en ambas pantallas
NF_Set2D(1, 5);
// Inicializa los fondos en modo "BITMAP"
NF_InitBitmapBgSys(0, 1);
NF_InitBitmapBgSys(1, 1);
// Inicializa los buffers para guardar fondos en formato BITMAP
NF_Init16bitsBgBuffers();
// Carga el archivo BITMAP de imagen en formato RAW a la RAM
NF_Load16bitsBg("bmp/bitmap16", 0);
// Tranfiere la imagen a la VRAM de ambas pantallas
NF_Copy16bitsBuffer(0, 0, 0);
NF_Copy16bitsBuffer(1, 0, 0);
// Si no es necesario usarla mas, borrala de la RAM
NF_Unload16bitsBg(0);
// Repite para siempre
while (1) {
// Sincronismo Vertical
swiWaitForVBlank();
}
return 0;
while (1)
{
// Wait for the screen refresh
swiWaitForVBlank();
}
return 0;
}

View File

@ -1,190 +1,132 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// Example of using a 8-bit bitmap backbuffer.
// http://www.nightfoxandco.com
/*
-------------------------------------------------
NightFox's Lib Template
Ejemplo basico de BackBuffer en 8bits (modo BITMAP)
Requiere DevkitARM
Requiere NightFox's Lib
Codigo por NightFox
http://www.nightfoxandco.com
Inicio 10 de Octubre del 2009
-------------------------------------------------
*/
/*
-------------------------------------------------
Includes
-------------------------------------------------
*/
// Includes C
#include <stdio.h>
#include <string.h>
#include <unistd.h>
// Includes propietarios NDS
#include <nds.h>
#include <filesystem.h>
// Includes librerias propias
#include <nf_lib.h>
int main(int argc, char **argv)
{
// Prepare a NitroFS initialization screen
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Initialize NitroFS and set it as the root folder of the filesystem
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS");
// Initialize 2D engine in both screens and use mode 5
NF_Set2D(0, 5);
NF_Set2D(1, 5);
// Initialize bitmap backgrounds system
NF_InitBitmapBgSys(0, 0);
NF_InitBitmapBgSys(1, 0);
/*
-------------------------------------------------
Main() - Bloque general del programa
-------------------------------------------------
*/
// Initialize storage buffers
NF_Init8bitsBgBuffers();
int main(int argc, char **argv) {
// Initialize backbuffers
NF_Init8bitsBackBuffer(0);
NF_Init8bitsBackBuffer(1);
// Pantalla de espera inicializando NitroFS
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Enable backbuffers
NF_Enable8bitsBackBuffer(0);
NF_Enable8bitsBackBuffer(1);
// Define el ROOT e inicializa el sistema de archivos
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS"); // Define la carpeta ROOT para usar NITROFS
// Load bitmap files from NitroFS
NF_Load8bitsBg("bmp/img8b_1", 0);
NF_Load8bitsBg("bmp/img8b_2", 1);
NF_Load8bitsBg("bmp/img8b_3", 2);
// Inicializa el motor 2D en modo BITMAP
NF_Set2D(0, 5); // Modo 2D_5 en ambas pantallas
NF_Set2D(1, 5);
// Transfer image to the backbuffer of the top screen
NF_Copy8bitsBuffer(0, 2, 1);
// Transfer image to layer 3 of the top screen
NF_Copy8bitsBuffer(0, 1, 0);
// Transfer image to layer 3 of the bottom screen
NF_Copy8bitsBuffer(1, 1, 2);
// Inicializa los fondos en modo "BITMAP"
NF_InitBitmapBgSys(0, 0);
NF_InitBitmapBgSys(1, 0);
// Copy palette of the bottom screen to the palette of the backbuffer
for (int n = 0; n < 256; n++)
NF_8BITS_BACKBUFFER[1].pal[n] = *((u16*)(0x05000400 + (n << 1)));
// Inicializa los buffers para guardar fondos en formato BITMAP
NF_Init8bitsBgBuffers();
// Set last color of the palette to red to draw using read
NF_8BITS_BACKBUFFER[1].pal[255] = RGB15(31, 0, 0);
// Inicializa el BackBuffer
NF_Init8bitsBackBuffer(0);
NF_Init8bitsBackBuffer(1);
bool show = true;
// Habilita el BackBuffer en la pantalla inferior
NF_Enable8bitsBackBuffer(0);
NF_Enable8bitsBackBuffer(1);
while (1)
{
// Read keys and touchscreen
scanKeys();
touchPosition touchscreen;
touchRead(&touchscreen);
u16 keys_held = keysHeld();
u16 keys_down = keysDown();
// Carga el archivo BITMAP de imagen en formato RAW a la RAM
NF_Load8bitsBg("bmp/img8b_1", 0);
NF_Load8bitsBg("bmp/img8b_2", 1);
NF_Load8bitsBg("bmp/img8b_3", 2);
// Check if the touch screen is pressed
if (keys_held & KEY_TOUCH)
{
int x = touchscreen.px;
if (x > 247)
x = 247;
// Tranfiere las imagenes a la pantalla superior, backbuffer
NF_Copy8bitsBuffer(0, 2, 1);
// Tranfiere las imagenes a la pantalla superior, capa 3
NF_Copy8bitsBuffer(0, 1, 0);
// Transfiere la imagen a la pantalla inferior, capa 3
NF_Copy8bitsBuffer(1, 1, 2);
int y = touchscreen.py;
if (y > 183)
y = 183;
// Copia la paleta de la pantalla inferior al backbuffer
u16 n = 0;
for (n = 0; n < 256; n ++) {
NF_8BITS_BACKBUFFER[1].pal[n] = *((u16*)(0x05000400 + (n << 1)));
}
// Draw a 8x8 block in both screens
for (int dy = 0; dy < 9; dy++)
{
for (int dx = 0; dx < 9; dx++)
{
u32 idx = ((y + dy) << 8) + (x + dx);
// Se dibujara en color rojo
NF_8BITS_BACKBUFFER[1].pal[255] = RGB15(31, 0, 0);
NF_8BITS_BACKBUFFER[0].data[idx] = 0; // Top screen
NF_8BITS_BACKBUFFER[1].data[idx] = 255; // Bottom screen
}
}
}
// Variables del control del touchpad
u16 keys = 0;
touchPosition touchscreen;
s16 x = 0;
s16 y = 0;
// Press A to hide or show layer 3 of the bottom screen
if (keys_down & KEY_A)
{
show = !show;
if (show)
NF_ShowBg(1, 3);
else
NF_HideBg(1, 3);
}
// Control del dibujado
u16 idx = 0;
u16 dx = 0;
u16 dy = 0;
// Press X to restore the image in the top screen
if (keys_down & KEY_X)
NF_Copy8bitsBuffer(0, 2, 1);
// Control de fondo
bool show = true;
// Press B to delete the drawing layer
if (keys_down & KEY_B)
memset(NF_8BITS_BACKBUFFER[1].data, 0, 65536);
// Copy backbuffer of the top screen to layer 2
NF_Flip8bitsBackBuffer(0, 0);
// Repite para siempre
while (1) {
// Copy backbuffer of the bottom screen to layer 2
NF_Flip8bitsBackBuffer(1, 0);
// Lectura de posicion del stylus
scanKeys(); // Lee el touchpad via Libnds
touchRead(&touchscreen);
keys = keysHeld(); // Verifica el estado del touchscreen
// Si presionas sobre el keypad...
if (keys & KEY_TOUCH) {
// Lee el touchpad
x = (touchscreen.px);
if (x > 247) x = 247;
y = (touchscreen.py);
if (y > 183) y = 183;
// Dibuja un pixel de 8x8
for (dy = 0; dy < 9; dy ++) {
for (dx = 0; dx < 9; dx ++) {
idx = ((y + dy) << 8) + (x + dx);
// Pantalla superior
NF_8BITS_BACKBUFFER[0].data[idx] = 0;
// Pantalla inferior
NF_8BITS_BACKBUFFER[1].data[idx] = 255;
}
}
}
// Lee las teclas pulsadas
keys = keysDown();
// Presiona A para escoder/mostrar capas 3 pantalla inferior
if (keys & KEY_A) {
show = !show;
if (show) {
// Cambia el valor del color transparente a ROSA
NF_8BITS_BACKBUFFER[1].pal[0] = RGB15(31, 0, 31);
// Muestra la capa 3 de la pantalla inferior
NF_ShowBg(1, 3);
} else {
// Cambia el valor del color transparente a NEGRO
NF_8BITS_BACKBUFFER[1].pal[0] = RGB15(0, 0, 0);
// Esconde la capa 3 de la pantalla inferior
NF_HideBg(1, 3);
}
}
// Presiona X restaura imagen superior
if (keys & KEY_X) NF_Copy8bitsBuffer(0, 2, 1);
// Presiona B para borrar la capa de dibujado
if (keys & KEY_B) memset(NF_8BITS_BACKBUFFER[1].data, 0, 65536);
// Copia el BackBuffer de la pantalla superior a la capa 2
NF_Flip8bitsBackBuffer(0, 0);
// Copia el BackBuffer de la pantalla inferior a la capa 2
NF_Flip8bitsBackBuffer(1, 0);
// Sincronismo Vertical
swiWaitForVBlank();
}
return 0;
// Wait for the screen refresh
swiWaitForVBlank();
}
return 0;
}

View File

@ -1,161 +1,124 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// Example of extended palettes for backgrounds.
// http://www.nightfoxandco.com
/*
-------------------------------------------------
NightFox's Lib Template
Ejemplo de paletas extendidas para fondos
Requiere DevkitARM
Requiere NightFox's Lib
Codigo por NightFox
http://www.nightfoxandco.com
Inicio 10 de Octubre del 2009
-------------------------------------------------
*/
/*
-------------------------------------------------
Includes
-------------------------------------------------
*/
// Includes C
#include <stdio.h>
#include <time.h>
// Includes propietarios NDS
#include <nds.h>
#include <filesystem.h>
// Includes librerias propias
#include <nf_lib.h>
// Algunos defines interesantes
#define RED 1
#define GREEN 2
#define BLUE 3
int main(int argc, char **argv)
{
// Prepare a NitroFS initialization screen
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Initialize NitroFS and set it as the root folder of the filesystem
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS");
// Initialize 2D engine in both screens and use mode 0
NF_Set2D(0, 0);
NF_Set2D(1, 0);
// Initialize tiled backgrounds system
NF_InitTiledBgBuffers(); // Initialize storage buffers
NF_InitTiledBgSys(0); // Top screen
NF_InitTiledBgSys(1); // Bottom screen
/*
-------------------------------------------------
Main() - Bloque general del programa
-------------------------------------------------
*/
// Initialize text system
NF_InitTextSys(0); // Top screen
NF_InitTextSys(1); // Bottom screen
int main(int argc, char **argv) {
// Load background files from NitroFS
NF_LoadTiledBg("bg/blue", "top", 256, 256);
NF_LoadTiledBg("bg/blue", "bottom", 256, 256);
// Pantalla de espera inicializando NitroFS
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Load extended background palette files from NitroFS
NF_LoadExBgPal("bg/red", RED);
NF_LoadExBgPal("bg/green", GREEN);
NF_LoadExBgPal("bg/blue", BLUE);
// Define el ROOT e inicializa el sistema de archivos
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS"); // Define la carpeta ROOT para usar NITROFS
// Load text font files from NitroFS
NF_LoadTextFont("fnt/default", "up", 256, 256, 0);
NF_LoadTextFont("fnt/default", "down", 256, 256, 0);
// Inicializa el motor 2D
NF_Set2D(0, 0); // Modo 2D_0 en ambas pantallas
NF_Set2D(1, 0);
// Transfer all palettes for background 3
for (int n = 1; n < 4; n++)
{
NF_VramExBgPal(0, 3, n, n);
NF_VramExBgPal(1, 3, n, n);
}
// Inicializa los fondos tileados
NF_InitTiledBgBuffers(); // Inicializa los buffers para almacenar fondos
NF_InitTiledBgSys(0); // Inicializa los fondos Tileados para la pantalla superior
NF_InitTiledBgSys(1); // Iniciliaza los fondos Tileados para la pantalla inferior
// Create top screen background
NF_CreateTiledBg(0, 3, "top");
// Inicializa el motor de texto (requiere tener los fondos tileados inicializados)
NF_InitTextSys(0); // Inicializa el texto para la pantalla superior
NF_InitTextSys(1); // Inicializa el texto para la pantalla inferior
// Create bottom screen backgrounds
NF_CreateTiledBg(1, 3, "bottom");
// Carga los archivos de fondo desde la FAT / NitroFS a la RAM
NF_LoadTiledBg("bg/blue", "top", 256, 256); // Carga el fondo para la pantalla inferior
NF_LoadTiledBg("bg/blue", "bottom", 256, 256); // Carga el fondo para la pantalla inferior
// Carga las paletas extendidas
NF_LoadExBgPal("bg/red", RED);
NF_LoadExBgPal("bg/green", GREEN);
NF_LoadExBgPal("bg/blue", BLUE);
// Create text layers
NF_CreateTextLayer(0, 0, 0, "up");
NF_CreateTextLayer(1, 0, 0, "down");
// Carga la fuente por defecto para el texto
NF_LoadTextFont("fnt/default", "up", 256, 256, 0); // Carga la seccion "normal" de la fuente, tamaño del mapa 256x256
NF_LoadTextFont("fnt/default", "down", 256, 256, 0);
// Variables
int color = RED;
int x = 0;
int y = 0;
// Tranfiere las paletas del fondo 3
u8 n = 0;
for (n = 1; n < 4; n ++) {
NF_VramExBgPal(0, 3, n, n);
NF_VramExBgPal(1, 3, n, n);
}
while (1)
{
// Change the pakette used by this tile
NF_SetTilePal(0, 3, x, y, color);
// Crea los fondos de la pantalla superior
NF_CreateTiledBg(0, 3, "top");
// Crea los fondos de la pantalla inferior
NF_CreateTiledBg(1, 3, "bottom");
// Print debug information
char text[50];
sprintf(text, "X:%02d Y:%02d ExPal:%02d ", x, y, color);
NF_WriteText(0, 0, 1, 1, text);
// Crea una capa de texto
NF_CreateTextLayer(0, 0, 0, "up");
NF_CreateTextLayer(1, 0, 0, "down");
// Calculate the next tile
x++;
if (x > 31)
{
x = 0;
y++;
if (y > 23)
{
y = 0;
// Variables
u8 color = RED;
u8 x = 0;
u8 y = 0;
char text[32];
// When the bottom of the screen is reached, change to the next
// extended palette.
NF_SetExBgPal(1, 3, color);
// Bucle (repite para siempre)
while(1) {
color++;
if (color > BLUE)
color = RED;
}
}
// Cambia el la paleta que usara este tile
NF_SetTilePal(0, 3, x, y, color);
// Update copy of the map in VRAM from the copy in RAM
NF_UpdateVramMap(0, 3);
// Texto
sprintf(text, "X:%02d Y:%02d ExPal:%02d ", x, y, color);
NF_WriteText(0, 0, 1, 1, text);
// Update text layers
NF_UpdateTextLayers();
// Calcula el siguiente tile
x ++;
if (x > 31) {
x = 0;
y ++;
if (y > 23) {
y = 0;
// Cambia la paleta extendida del fondo inferior
NF_SetExBgPal(1, 3, color);
// Texto
sprintf(text, "ExPal:%02d ", color);
NF_WriteText(1, 0, 1, 1, text);
// Y realiza un cambio de paleta si toca
color ++;
if (color > BLUE) color = RED;
}
}
// Ahora actualiza el mapa en la VRAM
NF_UpdateVramMap(0, 3);
// Actualiza las capas de texto
NF_UpdateTextLayers();
swiWaitForVBlank(); // Espera al sincronismo vertical
}
return 0;
// Wait for the screen refresh
swiWaitForVBlank();
}
return 0;
}

View File

@ -1,184 +1,157 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// Example of mixing bitmap and tiled backgrounds.
// http://www.nightfoxandco.com
/*
-------------------------------------------------
NightFox's Lib Template
Ejemplo basico modo mixto para fondos (tiled + bitmap)
Requiere DevkitARM
Requiere NightFox's Lib
Codigo por NightFox
http://www.nightfoxandco.com
Inicio 10 de Octubre del 2009
-------------------------------------------------
*/
/*
-------------------------------------------------
Includes
-------------------------------------------------
*/
// Includes C
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
// Includes propietarios NDS
#include <nds.h>
#include <filesystem.h>
// Includes librerias propias
#include <nf_lib.h>
int main(int argc, char **argv)
{
// Set random seed based on the current time
srand(time(NULL));
// Prepare a NitroFS initialization screen
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Initialize NitroFS and set it as the root folder of the filesystem
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS");
// Initialize 2D engine in both screens and use mode 5. Layers 0 to 2 are
// tiled backgrounds, layer 3 is an 8-bit bitmap background.
NF_Set2D(0, 5);
NF_Set2D(1, 5);
/*
-------------------------------------------------
Main() - Bloque general del programa
-------------------------------------------------
*/
// Initialize mixed background system
NF_InitMixedBgSys(0);
NF_InitMixedBgSys(1);
int main(int argc, char **argv) {
// Initialize tiled backgrounds system
NF_InitTiledBgBuffers();
// Pantalla de espera inicializando NitroFS
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Initialize text system
NF_InitTextSys(0); // Top screen
// Define el ROOT e inicializa el sistema de archivos
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS"); // Define la carpeta ROOT para usar NITROFS
// Initialize storage buffers
NF_Init8bitsBgBuffers();
// Inicializa el motor 2D en modo BITMAP
NF_Set2D(0, 5); // Modo 2D_5 en ambas pantallas
NF_Set2D(1, 5);
// Initialize sprite system
NF_InitSpriteBuffers(); // Initialize storage buffers
NF_InitSpriteSys(0); // Top screen
NF_InitSpriteSys(1); // Bottom screen
// Inicializa los fondos en modo Mixto
// Capas 0 - 2 tiled // Capa 3 bitmap 8 bits
NF_InitMixedBgSys(0);
NF_InitMixedBgSys(1);
// Load background files from NitroFS
NF_LoadTiledBg("bg/bg0", "tiled_bg", 1024, 256);
// Inicializa los fondos tileados
NF_InitTiledBgBuffers(); // Inicializa los buffers para almacenar fondos
// Load text font files from NitroFS
NF_LoadTextFont16("fnt/font16", "text_bg0", 256, 256, 0);
NF_LoadTextFont16("fnt/font16", "text_bg1", 256, 256, 0);
// Inicializa el motor de texto (requiere tener los fondos tileados inicializados)
NF_InitTextSys(0); // Inicializa el texto para la pantalla inferior
// Load bitmap files from NitroFS
NF_Load8bitsBg("bmp/img8b_1", 0);
NF_Load8bitsBg("bmp/img8b_2", 1);
// Inicializa los buffers para guardar fondos en formato BITMAP
NF_Init8bitsBgBuffers();
// Load sprite files from NitroFS
NF_LoadSpriteGfx("sprite/bola", 0, 32, 32);
NF_LoadSpritePal("sprite/bola", 0);
// Inicializa los Sprites
NF_InitSpriteBuffers(); // Inicializa los buffers para almacenar sprites y paletas
NF_InitSpriteSys(0); // Inicializa los sprites para la pantalla superior
NF_InitSpriteSys(1); // Inicializa los sprites para la pantalla inferior
// Create bottom screen background
NF_CreateTiledBg(1, 0, "tiled_bg");
// Carga el fondo para la capa 0, pantalla inferior
NF_LoadTiledBg("bg/bg0", "tiled_bg", 1024, 256);
// Create text layers
NF_CreateTextLayer16(0, 0, 0, "text_bg0");
NF_CreateTextLayer16(0, 1, 0, "text_bg1");
// Carga la fuente por defecto para el texto
NF_LoadTextFont16("fnt/font16", "text_bg0", 256, 256, 0);
NF_LoadTextFont16("fnt/font16", "text_bg1", 256, 256, 0);
// Write some text in the top screen in white
NF_WriteText16(0, 0, 1, 1, "Text over bitmap");
NF_WriteText16(0, 0, 1, 3, "Text on layers 0 & 1");
NF_WriteText16(0, 0, 1, 4, "Bitmap on layer 3");
// Carga el archivo BITMAP de imagen en formato RAW a la RAM
NF_Load8bitsBg("bmp/img8b_1", 0);
NF_Load8bitsBg("bmp/img8b_2", 1);
// Write the same text in another layer in black, this will be the shadow
NF_DefineTextColor(0, 1, 1, 0, 0, 0); // Black
NF_SetTextColor(0, 1, 1);
NF_WriteText16(0, 1, 1, 1, "Text over bitmap");
NF_WriteText16(0, 1, 1, 3, "Text on layers 0 & 1");
NF_WriteText16(0, 1, 1, 4, "Bitmap on layer 3");
NF_LoadSpriteGfx("sprite/bola", 0, 32, 32); // Bola azul
NF_LoadSpritePal("sprite/bola", 0);
// Small scroll for the black background to simulate the shadow
NF_ScrollBg(0, 0, 1, 1);
// Crea el fondo tileado en la capa inferior
NF_CreateTiledBg(1, 0, "tiled_bg");
// Update text layers
NF_UpdateTextLayers();
// Crea las capas de texto
NF_CreateTextLayer16(0, 0, 0, "text_bg0");
NF_CreateTextLayer16(0, 1, 0, "text_bg1");
// Define el color negro para texto de la capa 1
NF_DefineTextColor(0, 1, 1, 0, 0, 0); // Negro
// Escribe un texto en la pantalla superior
NF_WriteText16(0, 0, 1, 1, "Text over bitmap");
NF_WriteText16(0, 0, 1, 3, "Text on layers 0 & 1");
NF_WriteText16(0, 0, 1, 4, "Bitmap on layer 3");
NF_ScrollBg(0, 0, 1, 1);
// Y escribe un texto a modo de sombra
NF_SetTextColor(0, 1, 1);
NF_WriteText16(0, 1, 1, 1, "Text over bitmap");
NF_WriteText16(0, 1, 1, 3, "Text on layers 0 & 1");
NF_WriteText16(0, 1, 1, 4, "Bitmap on layer 3");
// Actualiza las capas de texto
NF_UpdateTextLayers();
// Transfer image to layer 3 of the top screen
NF_Copy8bitsBuffer(0, 1, 0);
// Tranfiere las imagenes a la pantalla superior, capa 3
NF_Copy8bitsBuffer(0, 1, 0);
// Transfiere la imagen a la pantalla inferior, capa 3
NF_Copy8bitsBuffer(1, 1, 1);
// Transfer image to layer 3 of the bottom screen
NF_Copy8bitsBuffer(1, 1, 1);
// Transfiere a la VRAM los sprites necesarios
NF_VramSpriteGfx(0, 0, 0, true); // Bola, manten los frames adicionales en RAM
NF_VramSpritePal(0, 0, 0);
NF_VramSpriteGfx(1, 0, 0, true);
NF_VramSpritePal(1, 0, 0);
// Transfer the required sprites to VRAM
NF_VramSpriteGfx(0, 0, 0, true); // Ball: Keep all frames in VRAM
NF_VramSpritePal(0, 0, 0);
NF_VramSpriteGfx(1, 0, 0, true); // Ball: Keep all frames in VRAM
NF_VramSpritePal(1, 0, 0);
// Variables generales y inicializacion del random
u8 n = 0;
srand(time(NULL));
// Setup and create ball sprites
s16 bola_x[32];
s16 bola_y[32];
s8 bola_spx[32];
s8 bola_spy[32];
// Crea las bolas en ambas pantallas
s16 bola_x[32];
s16 bola_y[32];
s8 bola_spx[32];
s8 bola_spy[32];
for (n = 0; n < 32; n ++) {
bola_x[n] = (rand() % 223); // Calcula posiciones
bola_y[n] = (rand() % 159);
bola_spx[n] = (rand() % 3) + 1;
bola_spy[n] = (rand() % 3) + 1;
NF_CreateSprite(0, n, 0, 0, bola_x[n], bola_y[n]); // Crea sprites
NF_CreateSprite(1, n, 0, 0, bola_x[n], bola_y[n]);
NF_SpriteLayer(0, n, 3); // Se dibujaran sobre la capa 3
NF_SpriteLayer(1, n, 3);
}
for (int n = 0; n < 32; n++)
{
bola_x[n] = rand() % 223;
bola_y[n] = rand() % 159;
bola_spx[n] = (rand() % 3) + 1;
bola_spy[n] = (rand() % 3) + 1;
NF_CreateSprite(0, n, 0, 0, bola_x[n], bola_y[n]);
NF_CreateSprite(1, n, 0, 0, bola_x[n], bola_y[n]);
NF_SpriteLayer(0, n, 3);
NF_SpriteLayer(1, n, 3);
}
// Repite para siempre
while (1) {
while (1)
{
// Move balls
for (int n = 0; n < 32; n++)
{
bola_x[n] += bola_spx[n];
if ((bola_x[n] < 0) || (bola_x[n] > 223))
bola_spx[n] *= -1;
// Mueve las bolas
for (n = 0; n < 32; n ++) {
bola_x[n] += bola_spx[n];
if ((bola_x[n] < 0) || (bola_x[n] > 223)) bola_spx[n] *= -1;
bola_y[n] += bola_spy[n];
if ((bola_y[n] < 0) || (bola_y[n] > 159)) bola_spy[n] *= -1;
NF_MoveSprite(0, n, bola_x[n], bola_y[n]);
NF_MoveSprite(1, n, bola_x[n], bola_y[n]);
}
bola_y[n] += bola_spy[n];
if ((bola_y[n] < 0) || (bola_y[n] > 159))
bola_spy[n] *= -1;
// Actualiza el array de OAM
NF_SpriteOamSet(0);
NF_SpriteOamSet(1);
NF_MoveSprite(0, n, bola_x[n], bola_y[n]);
NF_MoveSprite(1, n, bola_x[n], bola_y[n]);
}
swiWaitForVBlank(); // Espera al sincronismo vertical
// Update OAM array
NF_SpriteOamSet(0);
NF_SpriteOamSet(1);
// Actualiza el OAM
oamUpdate(&oamMain);
oamUpdate(&oamSub);
// Wait for the screen refresh
swiWaitForVBlank();
}
return 0;
// Update OAM
oamUpdate(&oamMain);
oamUpdate(&oamSub);
}
return 0;
}

View File

@ -1,154 +1,122 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// Basic background palette effects.
// http://www.nightfoxandco.com
/*
-------------------------------------------------
NightFox's Lib Template
Ejemplo basico de efectos de paletas
Requiere DevkitARM
Requiere NightFox's Lib
Codigo por NightFox
http://www.nightfoxandco.com
Inicio 10 de Octubre del 2009
-------------------------------------------------
*/
/*
-------------------------------------------------
Includes
-------------------------------------------------
*/
// Includes C
#include <stdio.h>
// Includes propietarios NDS
#include <nds.h>
#include <filesystem.h>
// Includes librerias propias
#include <nf_lib.h>
int main(int argc, char **argv)
{
// Prepare a NitroFS initialization screen
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Initialize NitroFS and set it as the root folder of the filesystem
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS");
// Initialize 2D engine in both screens and use mode 0
NF_Set2D(0, 0);
NF_Set2D(1, 0);
// Initialize tiled backgrounds system
NF_InitTiledBgBuffers(); // Initialize storage buffers
NF_InitTiledBgSys(0); // Top screen
NF_InitTiledBgSys(1); // Bottom screen
/*
-------------------------------------------------
Main() - Bloque general del programa
-------------------------------------------------
*/
// Initialize text system
NF_InitTextSys(0);
int main(int argc, char **argv) {
// Load background files from NitroFS
NF_LoadTiledBg("bg/layer3", "moon", 256, 256);
// Pantalla de espera inicializando NitroFS
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Load text font files from NitroFS
NF_LoadTextFont("fnt/default", "normal", 256, 256, 0);
NF_LoadTextFont("fnt/default", "right", 256, 256, 1);
NF_LoadTextFont("fnt/default", "left", 256, 256, 2);
// Define el ROOT e inicializa el sistema de archivos
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS"); // Define la carpeta ROOT para usar NITROFS
// Create top screen background
NF_CreateTiledBg(0, 3, "moon");
// Inicializa el motor 2D
NF_Set2D(0, 0); // Modo 2D_0 en ambas pantallas
NF_Set2D(1, 0);
// Create bottom screen backgrounds
NF_CreateTiledBg(1, 3, "moon");
// Inicializa los fondos tileados
NF_InitTiledBgBuffers(); // Inicializa los buffers para almacenar fondos
NF_InitTiledBgSys(0); // Inicializa los fondos Tileados para la pantalla superior
NF_InitTiledBgSys(1); // Iniciliaza los fondos Tileados para la pantalla inferior
// Create text layers
NF_CreateTextLayer(0, 0, 0, "normal");
NF_CreateTextLayer(0, 1, 1, "right");
NF_CreateTextLayer(0, 2, 2, "left");
// Inicializa el motor de texto (requiere tener los fondos tileados inicializados)
NF_InitTextSys(0); // Inicializa el texto para la pantalla superior
// Scroll text background to offset the unused space in the background
NF_ScrollBg(0, 2, 0, 63);
// Carga los archivos de fondo desde la FAT / NitroFS a la RAM
NF_LoadTiledBg("bg/layer3", "moon", 256, 256); // Carga el fondo para la capa 3, pantalla inferior
// Print text in all layers
NF_BgSetPalColor(0, 0, 1, 31, 31, 0); // Set color
NF_WriteText(0, 0, 1, 1, "Hola Mundo!\n Hello World!"); // Normal orientation
NF_BgEditPalColor(0, 1, 1, 0, 31, 31); // Set color
NF_BgUpdatePalette(0, 1);
NF_WriteText(0, 1, 1, 1, "Hola Mundo!\n Hello World!"); // Rotated clockwise
NF_WriteText(0, 2, 1, 1, "Hola Mundo!\n Hello World!"); // Rotated counter-clockwise
// Carga la fuente por defecto para el texto
NF_LoadTextFont("fnt/default", "normal", 256, 256, 0); // Carga la seccion "normal" de la fuente, tamaño del mapa 256x256
NF_LoadTextFont("fnt/default", "right", 256, 256, 1); // Carga la seccion "rotar derecha" de la fuente, tamaño del mapa 256x256
NF_LoadTextFont("fnt/default", "left", 256, 256, 2); // Carga la seccion "rotar izquierda· de la fuente, tamaño del mapa 256x256
// Update all text layers
NF_UpdateTextLayers();
// Crea los fondos de la pantalla superior
NF_CreateTiledBg(0, 3, "moon");
// Crea los fondos de la pantalla inferior
NF_CreateTiledBg(1, 3, "moon");
// Variables
u32 myvar = 0;
u8 speed = 0;
// Crea una capa de texto
NF_CreateTextLayer(0, 0, 0, "normal");
NF_CreateTextLayer(0, 1, 1, "right");
NF_CreateTextLayer(0, 2, 2, "left");
while (1)
{
myvar++;
// Compensa el espacio "muerto" de la pantalla al rotar el texto a la izquierda
// Desplazandolo 64 pixeles en vertical
NF_ScrollBg(0, 2, 0, 63);
char mytext[32];
snprintf(mytext, sizeof(mytext), "Contador: %lu", myvar);
NF_WriteText(0, 0, 1, 5, mytext);
NF_WriteText(0, 1, 1, 5, mytext);
NF_WriteText(0, 2, 1, 5, mytext);
// Escribe un texto en cada capa de texto
NF_BgSetPalColor(0, 0, 1, 31, 31, 0); // Color del texto
NF_WriteText(0, 0, 1, 1, "Hola Mundo!\n Hello World!"); // Normal
NF_BgEditPalColor(0, 1, 1, 0, 31, 31); // Color del texto
NF_BgUpdatePalette(0, 1);
NF_WriteText(0, 1, 1, 1, "Hola Mundo!\n Hello World!"); // Rotado derecha
NF_WriteText(0, 2, 1, 1, "Hola Mundo!\n Hello World!"); // Rotado izquierda
// Update text layers
NF_UpdateTextLayers();
// Actualiza las capas de texto
NF_UpdateTextLayers();
// Sunset effect by modifying the palette
speed++;
if (speed > 30)
{
speed = 0;
for (int n = 1; n < 256; n++)
{
u8 r, g, b;
NF_BgGetPalColor(1, 3, n, &r, &g, &b);
int cR = r;
int cG = g;
int cB = b;
// Variables
char mytext[32];
u32 myvar = 0;
u8 r, g, b;
s16 cR, cG, cB;
u8 speed = 0;
u16 n = 0;
cR--;
if (cR < 0)
cR = 0;
// Bucle (repite para siempre)
while(1) {
cG--;
if (cG < 0)
cG = 0;
myvar ++;
snprintf(mytext, sizeof(mytext), "Contador: %lu", myvar);
NF_WriteText(0, 0, 1, 5, mytext);
NF_WriteText(0, 1, 1, 5, mytext);
NF_WriteText(0, 2, 1, 5, mytext);
NF_BgEditPalColor(1, 3, n, cR, cG, cB);
}
NF_BgUpdatePalette(1, 3);
}
NF_UpdateTextLayers(); // Actualiza las capas de texto
// Efecto añochecer modificando la paleta
speed ++;
if (speed > 30) {
speed = 0;
for (n = 1; n < 256; n ++) {
NF_BgGetPalColor(1, 3, n, &r, &g, &b);
cR = r;
cG = g;
cB = b;
cR --;
if (cR < 0) cR = 0;
cG --;
if (cG < 0) cG = 0;
NF_BgEditPalColor(1, 3, n, cR, cG, cB);
}
NF_BgUpdatePalette(1, 3);
}
//
swiWaitForVBlank(); // Espera al sincronismo vertical
}
return 0;
// Wait for the screen refresh
swiWaitForVBlank();
}
return 0;
}

View File

@ -84,7 +84,7 @@ int main(int argc, char **argv)
s8 bola_spx[32];
s8 bola_spy[32];
for (int n = 0; n < 32; n ++)
for (int n = 0; n < 32; n++)
{
bola_x[n] = rand() % 223;
bola_y[n] = rand() % 159;
@ -112,14 +112,14 @@ int main(int argc, char **argv)
if (pj_anim > 5)
{
pj_anim = 0;
pj_frame ++;
pj_frame++;
if (pj_frame > 11)
pj_frame = 0;
NF_SpriteFrame(1, 0, pj_frame);
}
// Move balls
for (int n = 0; n < 32; n ++)
for (int n = 0; n < 32; n++)
{
bola_x[n] += bola_spx[n];
if ((bola_x[n] < 0) || (bola_x[n] > 223))

View File

@ -1,199 +1,178 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// Example of changing tiles in a tiled background.
// http://www.nightfoxandco.com
/*
-------------------------------------------------
NightFox's Lib Template
Ejemplo de cambio de tiles
Requiere DevkitARM
Requiere NightFox's Lib
Codigo por NightFox
http://www.nightfoxandco.com
Inicio 10 de Octubre del 2009
-------------------------------------------------
*/
/*
-------------------------------------------------
Includes
-------------------------------------------------
*/
// Includes C
#include <stdio.h>
// Includes propietarios NDS
#include <nds.h>
#include <filesystem.h>
// Includes librerias propias
#include <nf_lib.h>
int main(int argc, char **argv)
{
// Prepare a NitroFS initialization screen
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Initialize NitroFS and set it as the root folder of the filesystem
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS");
// Initialize 2D engine in both screens and use mode 0
NF_Set2D(0, 0);
NF_Set2D(1, 0);
// Initialize tiled backgrounds system
NF_InitTiledBgBuffers(); // Initialize storage buffers
NF_InitTiledBgSys(0); // Top screen
NF_InitTiledBgSys(1); // Bottom screen
/*
-------------------------------------------------
Main() - Bloque general del programa
-------------------------------------------------
*/
// Initialize sprite system
NF_InitSpriteBuffers(); // Initialize storage buffers
NF_InitSpriteSys(0); // Top screen
NF_InitSpriteSys(1); // Bottom screen
int main(int argc, char **argv) {
// Initialize text system
NF_InitTextSys(0); // Top screen
// Pantalla de espera inicializando NitroFS
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Load background files from NitroFS
NF_LoadTiledBg("bg/layer3", "moon", 256, 256);
NF_LoadTiledBg("bg/colmap", "boxes", 768, 512);
// Define el ROOT e inicializa el sistema de archivos
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS"); // Define la carpeta ROOT para usar NITROFS
// Load sprite files from NitroFS
NF_LoadSpriteGfx("sprite/puntero", 0, 8, 8);
NF_LoadSpritePal("sprite/puntero", 0);
// Inicializa el motor 2D
NF_Set2D(0, 0); // Modo 2D_0 en ambas pantallas
NF_Set2D(1, 0);
// Load text font files from NitroFS
NF_LoadTextFont("fnt/default", "normal", 256, 256, 0);
// Inicializa los fondos tileados
NF_InitTiledBgBuffers(); // Inicializa los buffers para almacenar fondos
NF_InitTiledBgSys(0); // Inicializa los fondos Tileados para la pantalla superior
NF_InitTiledBgSys(1); // Iniciliaza los fondos Tileados para la pantalla inferior
// Create top screen background
NF_CreateTiledBg(0, 3, "moon");
// Inicializa los Sprites
NF_InitSpriteBuffers(); // Inicializa los buffers para almacenar sprites y paletas
NF_InitSpriteSys(0); // Inicializa los sprites para la pantalla superior
NF_InitSpriteSys(1); // Inicializa los sprites para la pantalla inferior
// Create bottom screen backgrounds
NF_CreateTiledBg(1, 3, "moon");
NF_CreateTiledBg(1, 2, "boxes");
// Inicializa el motor de texto
NF_InitTextSys(0); // Inicializa el texto para la pantalla superior
// Create a text layer
NF_CreateTextLayer(0, 2, 0, "normal");
// Carga los archivos de fondo desde la FAT / NitroFS a la RAM
NF_LoadTiledBg("bg/layer3", "moon", 256, 256); // Carga el fondo para la capa 3, pantalla inferior
NF_LoadTiledBg("bg/colmap", "boxes", 768, 512); // Carga el fondo para la capa 2, pantalla inferior
// Transfer the required sprites to VRAM
NF_VramSpriteGfx(1, 0, 0, true);
NF_VramSpritePal(1, 0, 0);
// Carga los archivos de sprites desde la FAT / NitroFS a la RAM
NF_LoadSpriteGfx("sprite/puntero", 0, 8, 8); // Puntero
NF_LoadSpritePal("sprite/puntero", 0);
// Create sprite and set its priority layer
NF_CreateSprite(1, 0, 0, 0, 124, 92);
NF_SpriteLayer(1, 0, 2);
// Carga la fuente por defecto para el texto
NF_LoadTextFont("fnt/default", "normal", 256, 256, 0);
// Background scroll variables
s16 x = 128;
s16 y = 96;
// Crea los fondos de la pantalla superior
NF_CreateTiledBg(0, 3, "moon");
// Crea los fondos de la pantalla inferior
NF_CreateTiledBg(1, 3, "moon");
NF_CreateTiledBg(1, 2, "boxes");
while (1)
{
// Read keys
scanKeys();
u16 keys = keysHeld();
// Crea una capa de texto
NF_CreateTextLayer(0, 2, 0, "normal");
if (keys & KEY_UP)
y--;
if (keys & KEY_DOWN)
y++;
// Transfiere a la VRAM los sprites necesarios
NF_VramSpriteGfx(1, 0, 0, true); // Puntero
NF_VramSpritePal(1, 0, 0);
if (keys & KEY_LEFT)
x--;
if (keys & KEY_RIGHT)
x++;
// Crea el Sprite del puntero en la pantalla inferior
NF_CreateSprite(1, 0, 0, 0, 124, 92); // Crea el puntero en la pantalla inferior
NF_SpriteLayer(1, 0, 2); // Y la capa sobre la que se dibujara
// Movement limits
if (x < 0)
x = 0;
if (x > 767)
x = 767;
// Variable para la lectura del keypad
u16 keys = 0;
if (y < 0)
y = 0;
if (y > 511)
y = 511;
// Variables para el control de movimiento
s16 x = 128;
s16 y = 96;
s16 spr_x = 0;
s16 spr_y = 0;
s16 bg_x = 0;
s16 bg_y = 0;
s16 tilenum = 0;
// Calculate background scroll from the coordinates of the pointer
int bg_x = x - 128;
if (bg_x < 0)
bg_x = 0;
if (bg_x > 512)
bg_x = 512;
// Buffer de texto
char mytext[32];
int bg_y = y - 96;
if (bg_y < 0)
bg_y = 0;
if (bg_y > 320)
bg_y = 320;
// Pointer sprite position
int spr_x = (x - bg_x) - 4;
int spr_y = (y - bg_y) - 4;
NF_MoveSprite(1, 0, spr_x, spr_y);
// Print pointer position
char mytext[32];
sprintf(mytext,"x:%d y:%d ", x, y);
NF_WriteText(0, 2, 1, 1, mytext);
// Bucle (repite para siempre)
while(1) {
// Change the tile under the pointer if the user presses a button
if (keys & KEY_B)
NF_SetTileOfMap(1, 2, x >> 3, y >> 3, 0);
if (keys & KEY_A)
NF_SetTileOfMap(1, 2, x >> 3, y >> 3, 1);
if (keys & KEY_Y)
NF_SetTileOfMap(1, 2, x >> 3, y >> 3, 2);
if (keys & KEY_X)
NF_SetTileOfMap(1, 2, x >> 3, y >> 3, 3);
// Lee el teclado
scanKeys();
keys = keysHeld();
if (keys & KEY_UP) y --;
if (keys & KEY_DOWN) y ++;
if (keys & KEY_LEFT) x --;
if (keys & KEY_RIGHT) x ++;
NF_UpdateVramMap(1, 2);
// Limites del movimiento
if (x < 0) x = 0;
if (x > 767) x = 767;
if (y < 0) y = 0;
if (y > 511) y = 511;
// Print the color of the tile under the pointer
int tilenum = NF_GetTileOfMap(1, 2, x >> 3, y >> 3);
switch (tilenum)
{
case 0:
sprintf(mytext,"Tile: Vacio / Void / %d ", tilenum);
break;
case 1:
sprintf(mytext,"Tile: Azul / Blue / %d ", tilenum);
break;
case 2:
sprintf(mytext,"Tile: Verde / Green / %d ", tilenum);
break;
case 3:
sprintf(mytext,"Tile: Rojo / Red / %d ", tilenum);
break;
}
// Posicion del fondo
bg_x = (x - 128);
if (bg_x < 0) bg_x = 0;
if (bg_x > 512) bg_x = 512;
bg_y = (y - 96);
if (bg_y < 0) bg_y = 0;
if (bg_y > 320) bg_y = 320;
NF_WriteText(0, 2, 1, 3, mytext);
// Posicion del Sprite
spr_x = (x - bg_x) - 4;
spr_y = (y - bg_y) - 4;
NF_MoveSprite(1, 0, spr_x, spr_y);
// Update text layers
NF_UpdateTextLayers();
// Imprime la posicion del cursor
sprintf(mytext,"x:%d y:%d ", x, y);
NF_WriteText(0, 2, 1, 1, mytext);
// Update OAM array
NF_SpriteOamSet(1);
if (keys & KEY_B) NF_SetTileOfMap(1, 2, (x >> 3), (y >> 3), 0);
if (keys & KEY_A) NF_SetTileOfMap(1, 2, (x >> 3), (y >> 3), 1);
if (keys & KEY_Y) NF_SetTileOfMap(1, 2, (x >> 3), (y >> 3), 2);
if (keys & KEY_X) NF_SetTileOfMap(1, 2, (x >> 3), (y >> 3), 3);
NF_UpdateVramMap(1, 2);
// Wait for the screen refresh
swiWaitForVBlank();
// Imprime el nº de tile
tilenum = NF_GetTileOfMap(1, 2, (x >> 3),(y >> 3));
switch (tilenum) {
case 0:
sprintf(mytext,"Tile: Vacio / Void / %d ", tilenum);
break;
case 1:
sprintf(mytext,"Tile: Azul / Blue / %d ", tilenum);
break;
case 2:
sprintf(mytext,"Tile: Verde / Green / %d ", tilenum);
break;
case 3:
sprintf(mytext,"Tile: Rojo / Red / %d ", tilenum);
break;
}
// Update OAM
oamUpdate(&oamSub);
NF_WriteText(0, 2, 1, 3, mytext);
NF_UpdateTextLayers(); // Actualiza las capas de texto
NF_SpriteOamSet(1); // Actualiza el Array del OAM
swiWaitForVBlank(); // Espera al sincronismo vertical
oamUpdate(&oamSub); // Actualiza a VRAM el OAM Secundario
NF_ScrollBg(1, 2, bg_x, bg_y); // Actualiza el scroll
}
return 0;
// Update scroll
NF_ScrollBg(1, 2, bg_x, bg_y);
}
return 0;
}

View File

@ -1,117 +1,84 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// Example of flipping background tiles horizontally and verticaly.
// http://www.nightfoxandco.com
/*
-------------------------------------------------
NightFox's Lib Template
Ejemplo de Hflip y Vflip de tiles del fondo
Requiere DevkitARM
Requiere NightFox's Lib
Codigo por NightFox
http://www.nightfoxandco.com
Inicio 10 de Octubre del 2009
-------------------------------------------------
*/
/*
-------------------------------------------------
Includes
-------------------------------------------------
*/
// Includes C
#include <stdio.h>
// Includes propietarios NDS
#include <nds.h>
#include <filesystem.h>
// Includes librerias propias
#include <nf_lib.h>
int main(int argc, char **argv)
{
// Prepare a NitroFS initialization screen
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Variables
u16 mapa[32][24]; // Almacena el mapa (32x24 tiles)
// Initialize NitroFS and set it as the root folder of the filesystem
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS");
// Initialize 2D engine in both screens and use mode 0
NF_Set2D(0, 0);
NF_Set2D(1, 0);
// Initialize tiled backgrounds system
NF_InitTiledBgBuffers(); // Initialize storage buffers
NF_InitTiledBgSys(0); // Top screen
NF_InitTiledBgSys(1); // Bottom screen
// Load background files from NitroFS
NF_LoadTiledBg("bg/nfl", "nfl", 256, 256);
// Create top screen background
NF_CreateTiledBg(0, 3, "nfl");
/*
-------------------------------------------------
Main() - Bloque general del programa
-------------------------------------------------
*/
// Create bottom screen backgrounds
NF_CreateTiledBg(1, 3, "nfl");
int main(int argc, char **argv) {
// Temporary map storage (32x24 tiles)
u16 mapa[32][24];
// Pantalla de espera inicializando NitroFS
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("\n NitroFS init. Please wait.\n\n");
printf(" Iniciando NitroFS,\n por favor, espere.\n\n");
swiWaitForVBlank();
// Invert tiles of the bottom screen and write it to the temporary buffer
for (int y = 0; y < 24; y++)
{
for (int x = 0; x < 32; x++)
{
NF_SetTileHflip(1, 3, x, y);
NF_SetTileVflip(1, 3, x, y); // Comment out for mirror effect
mapa[x][y] = NF_GetTileOfMap(1, 3, x, y);
}
}
// Define el ROOT e inicializa el sistema de archivos
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS"); // Define la carpeta ROOT para usar NITROFS
// Place tiles in inverse order
for (int y = 0; y < 24; y++)
{
for (int x = 0; x < 32; x++)
{
// Comment out for mirror effect
NF_SetTileOfMap(1, 3, 31 - x, 23 - y, mapa[x][y]);
// Inicializa el motor 2D
NF_Set2D(0, 0); // Modo 2D_0 en ambas pantallas
NF_Set2D(1, 0);
// Uncomment for mirror effect
//NF_SetTileOfMap(1, 3, 31 - x, y, mapa[x][y]);
}
}
// Inicializa los fondos tileados
NF_InitTiledBgBuffers(); // Inicializa los buffers para almacenar fondos
NF_InitTiledBgSys(0); // Inicializa los fondos Tileados para la pantalla superior
NF_InitTiledBgSys(1); // Iniciliaza los fondos Tileados para la pantalla inferior
// Update copy of the map in VRAM with the copy in RAM
NF_UpdateVramMap(1, 3);
// Carga los archivos de fondo desde la FAT / NitroFS a la RAM
NF_LoadTiledBg("bg/nfl", "nfl", 256, 256); // Carga el fondo para la pantalla inferior
// Crea los fondos de la pantalla superior
NF_CreateTiledBg(0, 3, "nfl");
// Crea los fondos de la pantalla inferior
NF_CreateTiledBg(1, 3, "nfl");
// Invierte todos los tiles del mapa de la pantalla inferior y copia los tiles al buffer temporal
u8 x = 0;
u8 y = 0;
for (y = 0; y < 24; y ++) {
for (x = 0; x < 32; x ++) {
NF_SetTileHflip(1, 3, x, y);
NF_SetTileVflip(1, 3, x, y); // *** Comenta esta linea para el efecto espejo
mapa[x][y] = NF_GetTileOfMap(1, 3, x, y);
}
}
// Ahora coloca los tiles en orden inverso para compensar la imagen
for (y = 0; y < 24; y ++) {
for (x = 0; x < 32; x ++) {
NF_SetTileOfMap(1, 3, (31 - x), (23 - y), mapa[x][y]); // *** Usa esta linea para el efecto rotado 180º
// NF_SetTileOfMap(1, 3, (31 - x), y, mapa[x][y]); // *** Usa esta linea para el efecto espejo
}
}
// Y para finalizar, actualiza el mapa en la VRAM
NF_UpdateVramMap(1, 3);
// Bucle (repite para siempre)
while(1) {
swiWaitForVBlank(); // Espera al sincronismo vertical
}
return 0;
while (1)
{
// Wait for the screen refresh
swiWaitForVBlank();
}
return 0;
}

View File

@ -71,8 +71,8 @@ int main(int argc, char **argv)
{
if (keys & KEY_UP)
{
img1 --;
img2 --;
img1--;
img2--;
if (img1 < 0)
img1 = (MAX_BMP_FILES - 1);
if (img2 < 0)
@ -80,8 +80,8 @@ int main(int argc, char **argv)
}
if (keys & KEY_DOWN)
{
img1 ++;
img2 ++;
img1++;
img2++;
if (img1 > (MAX_BMP_FILES - 1))
img1 = 0;
if (img2 > (MAX_BMP_FILES - 1))

View File

@ -90,9 +90,9 @@ int main(int argc, char **argv)
}
// Generate thumbnail
for (int scr_y = 0; scr_y < mini_y; scr_y ++)
for (int scr_y = 0; scr_y < mini_y; scr_y++)
{
for (int scr_x = 0; scr_x < mini_x; scr_x ++)
for (int scr_x = 0; scr_x < mini_x; scr_x++)
{
// Calculate source and destination offsets
scr_idx = ((scr_y + desp_y) << 8) + (scr_x + desp_x);
@ -123,7 +123,7 @@ int main(int argc, char **argv)
{
x += SPEED;
if (x > (NF_BG16B[0].width - 256))
x = (NF_BG16B[0].width - 256);
x = NF_BG16B[0].width - 256;
}
}
if (NF_BG16B[0].height > 192)
@ -138,18 +138,18 @@ int main(int argc, char **argv)
{
y += SPEED;
if (y > (NF_BG16B[0].height - 192))
y = (NF_BG16B[0].height - 192);
y = NF_BG16B[0].height - 192;
}
}
// Draw image on the framebuffer
for (int scr_y = 0; scr_y < bottom; scr_y ++)
for (int scr_y = 0; scr_y < bottom; scr_y++)
{
for (int scr_x = 0; scr_x < right; scr_x ++ )
for (int scr_x = 0; scr_x < right; scr_x++)
{
// Calculate source and destination offsets
scr_idx = (scr_y << 8) + scr_x;
img_idx = (((scr_y + y) * NF_BG16B[0].width) + (scr_x + x));
img_idx = ((scr_y + y) * NF_BG16B[0].width) + (scr_x + x);
*(NF_16BITS_BACKBUFFER[0] + scr_idx) = NF_BG16B[0].buffer[img_idx];
}

View File

@ -62,7 +62,7 @@ int main(int argc, char **argv)
// Generate a few colors randomly
srand(time(NULL));
for (int n = 4; n < 10; n ++)
for (int n = 4; n < 10; n++)
{
NF_DefineTextColor(1, 0, n,
(rand() % 31) + 1,
@ -80,7 +80,7 @@ int main(int argc, char **argv)
NF_WriteText16(1, 0, 1, 4, "Azul / Blue");
// Print text with random colors
for (int n = 4; n < 10; n ++)
for (int n = 4; n < 10; n++)
{
NF_SetTextColor(1, 0, n);
NF_WriteText16(1, 0, 1, n + 1, "Random Aa 0123456789 Ññ Çç");
@ -103,7 +103,7 @@ int main(int argc, char **argv)
speed = 0;
// Generate new colors randomly
for (int n = 4; n < 10; n ++)
for (int n = 4; n < 10; n++)
{
NF_DefineTextColor(1, 0, n,
(rand() % 31) + 1,
@ -112,7 +112,7 @@ int main(int argc, char **argv)
}
// Print text with the new random colors
for (int n = 4; n < 10; n ++)
for (int n = 4; n < 10; n++)
{
NF_SetTextColor(1, 0, n);
NF_WriteText16(1, 0, 1, n + 1, "Random Aa 0123456789 Ññ Çç");

View File

@ -62,7 +62,7 @@ int main(int argc, char **argv)
// Generate a few colors randomly
srand(time(NULL));
for (int n = 4; n < 16; n ++)
for (int n = 4; n < 16; n++)
{
NF_DefineTextColor(1, 0, n,
(rand() % 31) + 1,
@ -80,7 +80,7 @@ int main(int argc, char **argv)
NF_WriteText(1, 0, 1, 4, "Azul / Blue");
// Print text with random colors
for (int n = 4; n < 16; n ++)
for (int n = 4; n < 16; n++)
{
NF_SetTextColor(1, 0, n);
NF_WriteText(1, 0, 1, n + 1, "Random color");
@ -103,7 +103,7 @@ int main(int argc, char **argv)
speed = 0;
// Generate new colors randomly
for (int n = 4; n < 16; n ++)
for (int n = 4; n < 16; n++)
{
NF_DefineTextColor(1, 0, n,
(rand() % 31) + 1,
@ -112,7 +112,7 @@ int main(int argc, char **argv)
}
// Print text with the new random colors
for (int n = 4; n < 16; n ++)
for (int n = 4; n < 16; n++)
{
NF_SetTextColor(1, 0, n);
NF_WriteText(1, 0, 1, n + 1, "Random color");

View File

@ -64,7 +64,7 @@ int main(int argc, char **argv)
s8 delay = 0;
// Print 96 text lines
for (int n = 0; n < 96; n ++)
for (int n = 0; n < 96; n++)
{
sprintf(mytext," Linea: %02d", n);
NF_WriteText(0, 0, 0, n, mytext);
@ -76,13 +76,13 @@ int main(int argc, char **argv)
while (1)
{
delay ++;
delay++;
if (delay > 10) {
delay = 0;
// Print 96 text lines
for (int n = 0; n < 96; n ++)
for (int n = 0; n < 96; n++)
{
sprintf(mytext,"%04d", contador);
NF_WriteText(0, 0, 26, n, mytext);

View File

@ -142,7 +142,7 @@ s16 LookForServer(void)
// Get the local IP and extract its range (for example, "192.168.0.")
sprintf(temp, "%s", inet_ntoa(NF_IP));
for (int n = 0; n < strlen(temp); n ++)
for (int n = 0; n < strlen(temp); n++)
{
myip[n] = temp[n];
char c = temp[n];
@ -163,7 +163,7 @@ s16 LookForServer(void)
// Scan all possible IPs
p = 0;
for (int n = 1; n < 255; n ++)
for (int n = 1; n < 255; n++)
{
scanKeys();
u16 keys = keysDown();