examples: Cleanup and translate more examples to English

This commit is contained in:
Antonio Niño Díaz 2023-05-18 17:37:16 +01:00
parent 4c92c8c864
commit 2b4aab4ba8
7 changed files with 445 additions and 612 deletions

View File

@ -1,174 +1,152 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// Affine backgrounds example
// http://www.nightfoxandco.com/
/*
-------------------------------------------------
NightFox's Lib Template
Ejemplo de fondos Affine
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>
// Function that runs after a scanline is drawn. By modifying the values of the
// fade registers it's possible to add a shading effect.
void hblank_handler(void)
{
// If the current line is inside the screen
if (REG_VCOUNT < 192)
{
// Calculate fade value based on the line
int fade = (0x0F - (((REG_VCOUNT + 1) * 16) / 192));
// Defines especiales del ejemplo
#define VLINE *(vu16*)0x04000006 // Obtiene via registro la linea actual del dibujado
// Funcion encargada del sombreado
void Shading(void);
/*
-------------------------------------------------
Main() - Bloque general del programa
-------------------------------------------------
*/
int main(int argc, char **argv) {
// 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();
// Define el ROOT e inicializa el sistema de archivos
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS"); // Define la carpeta ROOT para usar NITROFS
// Inicializa el motor 2D
NF_Set2D(0, 2); // Modo 2D_2 en la pantalla superior
NF_Set2D(1, 2); // Modo 2D_2 en la pantalla inferior
// Inicializa los fondos tileados
NF_InitTiledBgBuffers(); // Inicializa los buffers para almacenar fondos
NF_InitAffineBgSys(0); // Inicializa los fondos affine para la pantalla superior
NF_InitAffineBgSys(1); // Iniciliaza los fondos affine para la pantalla inferior
// Carga los archivos de fondo desde NitroFS a la RAM
NF_LoadAffineBg("bg/waves512", "waves", 512, 512); // Carga el fondo para la capa 3, pantalla superior
NF_LoadAffineBg("bg/navygrid", "grid", 256, 256); // Carga el fondo para la capa 2, pantalla superior
NF_LoadAffineBg("bg/flag512", "flag", 512, 512); // Carga el fondo para la capa 3, pantalla inferior
// Crea los fondos de la pantalla Superior
NF_CreateAffineBg(0, 3, "waves", 1);
NF_CreateAffineBg(0, 2, "grid", 0);
// Crea los fondos de la pantalla Inferior
NF_CreateAffineBg(1, 3, "flag", 1);
// Definimos que funcion se ejecutara al final de cada linea de dibujado (HBLANK)
irqSet(IRQ_HBLANK, Shading);
// Para finalizar, habilitamos la interrupcion
irqEnable(IRQ_HBLANK);
// Variable para la lectura del keypad
u16 keys = 0;
// Variables para el control de movimiento
s32 x = 0;
s32 y = 0;
s32 angle = 0;
s32 zoom = 256;
u8 n = 0;
// Efectos especiales de sombreado
REG_BLDCNT = BLEND_FADE_WHITE | BLEND_SRC_BG3; // Fade a blanco
REG_BLDCNT_SUB = BLEND_FADE_BLACK | BLEND_SRC_BG3; // Fade a negro
// Bucle (repite para siempre)
while(1) {
// Lee el teclado
scanKeys();
keys = keysHeld();
// Calcula el desplazamiento del centro
if (keys & KEY_UP) y -= 2;
if (y < 0) y = 0;
if (keys & KEY_DOWN) y += 2;
if (y > 512) y = 512;
if (keys & KEY_LEFT) x -= 2;
if (x < 0) x = 0;
if (keys & KEY_RIGHT) x += 2;
if (x > 512) x = 512;
// Calcula el Zoom
if (keys & KEY_A) zoom -= 2;
if (zoom < 0) zoom = 0;
if (keys & KEY_B) zoom += 2;
if (zoom > 512) zoom = 512;
// Calcula el angulo
if (keys & KEY_X) angle -= 2;
if (angle < 0) angle += 2048;
if (keys & KEY_Y) angle += 2;
if (angle > 2048) angle -= 2048;
swiWaitForVBlank(); // Espera al sincronismo vertical
// Modifica los parametros del fondo Affine
for (n = 0; n < 2; n ++) {
// Zoom
NF_AffineBgTransform(n, 3, zoom, zoom, 0, 0);
// Posicion del centro
NF_AffineBgCenter(n, 3, x, y);
// Rotacion
NF_AffineBgMove(n, 3, 0, 0, angle);
}
}
return 0;
REG_BLDY = fade >> 1; // Top screen
REG_BLDY_SUB = fade; // Bottom screen
}
}
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");
// Funcion de Shading
void Shading(void) {
// Initialize 2D engine in both screens and use mode 2
NF_Set2D(0, 2);
NF_Set2D(1, 2);
// Si la linea de dibujado esta en pantalla
if (VLINE < 192) {
// Calcula el valor del sombreado segun la linea
s16 fade = (0x0F - (((VLINE + 1) * 16) / 192));
// Sombreado "Blanco"
REG_BLDY = (fade >> 1);
// Sombreado "Negro"
REG_BLDY_SUB = fade;
}
// Initialize tiled backgrounds system
NF_InitTiledBgBuffers(); // Initialize storage buffers
NF_InitAffineBgSys(0); // Top screen
NF_InitAffineBgSys(1); // Bottom screen
// Load background files from NitroFS
NF_LoadAffineBg("bg/waves512", "waves", 512, 512);
NF_LoadAffineBg("bg/navygrid", "grid", 256, 256);
NF_LoadAffineBg("bg/flag512", "flag", 512, 512);
// Create top screen backgrounds
NF_CreateAffineBg(0, 3, "waves", 1);
NF_CreateAffineBg(0, 2, "grid", 0);
// Create bottom screen backgrounds
NF_CreateAffineBg(1, 3, "flag", 1);
// Register a function to be called after a screen line has been drawn (when
// the horizontal blanking period starts)
irqSet(IRQ_HBLANK, hblank_handler);
irqEnable(IRQ_HBLANK);
// Movement variables
s32 x = 0;
s32 y = 0;
s32 angle = 0;
s32 zoom = 256;
// Setup fading registers. The top screen fades to white and the bottom one
// fades to black.
REG_BLDCNT = BLEND_FADE_WHITE | BLEND_SRC_BG3;
REG_BLDCNT_SUB = BLEND_FADE_BLACK | BLEND_SRC_BG3;
while (1)
{
scanKeys(); // Read keypad
uint16_t keys = keysHeld(); // Keys currently pressed
// Move center of the backgrounds
if (keys & KEY_UP)
{
y -= 2;
if (y < 0)
y = 0;
}
if (keys & KEY_DOWN)
{
y += 2;
if (y > 512)
y = 512;
}
if (keys & KEY_LEFT)
{
x -= 2;
if (x < 0)
x = 0;
}
if (keys & KEY_RIGHT)
{
x += 2;
if (x > 512)
x = 512;
}
// Change zoom
if (keys & KEY_A)
{
zoom -= 2;
if (zoom < 0)
zoom = 0;
}
if (keys & KEY_B)
{
zoom += 2;
if (zoom > 512)
zoom = 512;
}
// Change angle
if (keys & KEY_X)
{
angle -= 2;
if (angle < 0)
angle += 2048;
}
if (keys & KEY_Y)
{
angle += 2;
if (angle > 2048)
angle -= 2048;
}
swiWaitForVBlank(); // Wait for the screen refresh
// Update parameters of the affine backgrounds
for (int n = 0; n < 2; n ++)
{
NF_AffineBgTransform(n, 3, zoom, zoom, 0, 0);
NF_AffineBgCenter(n, 3, x, y);
NF_AffineBgMove(n, 3, 0, 0, angle);
}
}
return 0;
}

View File

@ -28,7 +28,7 @@ int main(int argc, char **argv)
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS");
// Initialize 2D engine in both screens and use bitmap mode
// Initialize 2D engine in both screens and use mode 5
NF_Set2D(0, 5);
NF_Set2D(1, 5);
@ -80,7 +80,7 @@ int main(int argc, char **argv)
swiWaitForVBlank(); // Wait for the screen refresh
// Send backbuffer to the screen
// Send backbuffers to the screen
NF_Flip16bitsBackBuffer(0);
NF_Flip16bitsBackBuffer(1);
}

View File

@ -1,141 +1,104 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// Example to load 8, 16 and 24 bit BMP files.
// http://www.nightfoxandco.com
/*
-------------------------------------------------
NightFox's Lib Template
Carga de archivos BMP de 8, 16 y 24 bits.
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>
#define MAX_BMP_FILES 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 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) {
// Initialize backbuffers
NF_Init16bitsBackBuffer(0);
NF_Init16bitsBackBuffer(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_Enable16bitsBackBuffer(0);
NF_Enable16bitsBackBuffer(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_LoadBMP("bmp/bmp8bits", 0);
NF_LoadBMP("bmp/bmp16bits", 1);
NF_LoadBMP("bmp/bmp24bits", 2);
// Inicializa el motor 2D en modo BITMAP
NF_Set2D(0, 5); // Modo 2D_5 en ambas pantallas
NF_Set2D(1, 5);
// Variables
s8 img1 = 0;
s8 img2 = 1;
// Inicializa los fondos en modo "BITMAP"
NF_InitBitmapBgSys(0, 1);
NF_InitBitmapBgSys(1, 1);
// Draw screens on the backbuffers
NF_Draw16bitsImage(0, img1, 0, 0, false);
NF_Draw16bitsImage(1, img2, 0, 0, false);
// Inicializa los buffers para guardar fondos en formato BITMAP
NF_Init16bitsBgBuffers();
while (1)
{
scanKeys(); // Read keypad
u16 keys = keysHeld(); // Keys currently pressed
// Inicializa el backbuffer
NF_Init16bitsBackBuffer(0);
NF_Init16bitsBackBuffer(1);
if ((keys & KEY_UP) || (keys & KEY_DOWN))
{
if (keys & KEY_UP)
{
img1 --;
img2 --;
if (img1 < 0)
img1 = (MAX_BMP_FILES - 1);
if (img2 < 0)
img2 = (MAX_BMP_FILES - 1);
}
if (keys & KEY_DOWN)
{
img1 ++;
img2 ++;
if (img1 > (MAX_BMP_FILES - 1))
img1 = 0;
if (img2 > (MAX_BMP_FILES - 1))
img2 = 0;
}
// Habilita el backbuffer
NF_Enable16bitsBackBuffer(0);
NF_Enable16bitsBackBuffer(1);
// Draw images on the backbuffers
NF_Draw16bitsImage(0, img1, 0, 0, false);
NF_Draw16bitsImage(1, img2, 0, 0, false);
}
// Carga los archivos BITMAP
NF_LoadBMP("bmp/bmp8bits", 0);
NF_LoadBMP("bmp/bmp16bits", 1);
NF_LoadBMP("bmp/bmp24bits", 2);
swiWaitForVBlank(); // Wait for the screen refresh
// Variables
s8 img1 = 0;
s8 img2 = 1;
u16 keys = 0;
// Dibuja las imagenes en los backbuffers
NF_Draw16bitsImage(0, img1, 0, 0, false);
NF_Draw16bitsImage(1, img2, 0, 0, false);
// Repite para siempre
while (1) {
// Lee el teclado
scanKeys();
keys = keysDown();
// Segun la tecla pulsada
if ((keys & KEY_UP) || (keys & KEY_DOWN)) {
if (keys & KEY_UP) {
img1 --;
img2 --;
if (img1 < 0) img1 = (MAX_BMP_FILES - 1);
if (img2 < 0) img2 = (MAX_BMP_FILES - 1);
}
if (keys & KEY_DOWN) {
img1 ++;
img2 ++;
if (img1 > (MAX_BMP_FILES - 1)) img1 = 0;
if (img2 > (MAX_BMP_FILES - 1)) img2 = 0;
}
// Dibuja las imagenes en los backbuffers
NF_Draw16bitsImage(0, img1, 0, 0, false);
NF_Draw16bitsImage(1, img2, 0, 0, false);
}
// Sincronismo Vertical
swiWaitForVBlank();
// Manda el backbuffer a la pantalla
NF_Flip16bitsBackBuffer(0);
NF_Flip16bitsBackBuffer(1);
}
return 0;
// Send backbuffers to the screen
NF_Flip16bitsBackBuffer(0);
NF_Flip16bitsBackBuffer(1);
}
return 0;
}

View File

@ -1,191 +1,165 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// Example of loading BMP files and scrolling them.
// http://www.nightfoxandco.com
/*
-------------------------------------------------
NightFox's Lib Template
Carga de archivos BMP y Scroll
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>
#define SPEED 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();
/*
-------------------------------------------------
Main() - Bloque general del programa
-------------------------------------------------
*/
// Initialize NitroFS and set it as the root folder of the filesystem
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS");
int main(int argc, char **argv) {
// Initialize 2D engine in both screens and use mode 5
NF_Set2D(0, 5);
NF_Set2D(1, 5);
// 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 bitmap backgrounds system
NF_InitBitmapBgSys(0, 1);
NF_InitBitmapBgSys(1, 1);
// 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_Init16bitsBgBuffers();
// Inicializa el motor 2D en modo BITMAP
NF_Set2D(0, 5); // Modo 2D_5 en ambas pantallas
NF_Set2D(1, 5);
// Initialize backbuffers
NF_Init16bitsBackBuffer(0);
NF_Init16bitsBackBuffer(1);
// Inicializa los fondos en modo "BITMAP"
NF_InitBitmapBgSys(0, 1);
NF_InitBitmapBgSys(1, 1);
// Enable backbuffers
NF_Enable16bitsBackBuffer(0);
NF_Enable16bitsBackBuffer(1);
// Inicializa los buffers para guardar fondos en formato BITMAP
NF_Init16bitsBgBuffers();
// Load bitmap files from NitroFS
NF_LoadBMP("bmp/lostend", 0);
// Inicializa el backbuffer
NF_Init16bitsBackBuffer(0);
NF_Init16bitsBackBuffer(1);
// Variables
s16 x = 0;
s16 y = 0;
s16 right = 0;
s16 bottom = 0;
u16 mini_x = 0;
u16 mini_y = 0;
u16 desp_x = 0;
u16 desp_y = 0;
u32 scr_idx = 0;
u32 img_idx = 0;
// Habilita el backbuffer
NF_Enable16bitsBackBuffer(0);
NF_Enable16bitsBackBuffer(1);
// Calculate drawing canvas size
if (NF_BG16B[0].width > 256)
right = 256;
else
right = NF_BG16B[0].width;
// Carga los archivos BITMAP
NF_LoadBMP("bmp/lostend", 0);
if (NF_BG16B[0].height > 192)
bottom = 192;
else
bottom = NF_BG16B[0].height;
// Variables
u16 keys = 0;
s16 x = 0;
s16 y = 0;
s16 scr_x = 0;
s16 scr_y = 0;
s16 right = 0;
s16 bottom = 0;
u16 mini_x = 0;
u16 mini_y = 0;
u16 desp_x = 0;
u16 desp_y = 0;
u32 scr_idx = 0;
u32 img_idx = 0;
// Calculate thumbnail size and offsets to place on the screen
if (NF_BG16B[0].width >= NF_BG16B[0].height)
{
mini_x = right;
mini_y = (NF_BG16B[0].height * right) / NF_BG16B[0].width;
desp_y = (192 - mini_y) >> 1;
}
else
{
mini_x = (NF_BG16B[0].width * bottom) / NF_BG16B[0].height;
mini_y = bottom;
desp_x = (256 - mini_x) >> 1;
}
// Calcula los limites de dibujado
if (NF_BG16B[0].width > 256) {
right = 256;
} else {
right = NF_BG16B[0].width;
}
if (NF_BG16B[0].height > 192) {
bottom = 192;
} else {
bottom = NF_BG16B[0].height;
}
// Generate thumbnail
for (int scr_y = 0; scr_y < mini_y; scr_y ++)
{
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);
img_idx = (((scr_y * NF_BG16B[0].height) / mini_y) * NF_BG16B[0].width)
+ ((scr_x * NF_BG16B[0].width) / mini_x);
// Calcula el tamaño de la miniatura y el desplazamiento para posicionarla en pantalla
if (NF_BG16B[0].width >= NF_BG16B[0].height) { // Si la imagen es mas ancha que alta
mini_x = right;
mini_y = (int)((NF_BG16B[0].height * right) / NF_BG16B[0].width);
desp_y = (int)((192 - mini_y) >> 1);
} else { // Si es mas alta que ancha
mini_x = (int)((NF_BG16B[0].width * bottom) / NF_BG16B[0].height);
mini_y = bottom;
desp_x = (int)((256 - mini_x) >> 1);
}
*(NF_16BITS_BACKBUFFER[1] + scr_idx) = NF_BG16B[0].buffer[img_idx];
}
}
// Genera la miniatura
for (scr_y = 0; scr_y < mini_y; scr_y ++) {
for (scr_x = 0; scr_x < mini_x; scr_x ++ ) {
// Calcula los offsets
scr_idx = ((scr_y + desp_y) << 8) + (scr_x + desp_x);
img_idx = (int)((((scr_y * NF_BG16B[0].height) / mini_y) * NF_BG16B[0].width) + ((scr_x * NF_BG16B[0].width) / mini_x));
// Escribe los valores
*(NF_16BITS_BACKBUFFER[1] + scr_idx) = NF_BG16B[0].buffer[img_idx];
}
}
// Manda el backbuffer a la pantalla
NF_Flip16bitsBackBuffer(1);
// Send backbuffer to screen
NF_Flip16bitsBackBuffer(1);
// Repite para siempre
while (1) {
while (1)
{
scanKeys(); // Read keypad
uint16_t keys = keysHeld(); // Keys currently pressed
// Lee el teclado
scanKeys();
keys = keysHeld();
if (NF_BG16B[0].width > 256)
{
if (keys & KEY_LEFT)
{
x -= SPEED;
if (x < 0)
x = 0;
}
if (keys & KEY_RIGHT)
{
x += SPEED;
if (x > (NF_BG16B[0].width - 256))
x = (NF_BG16B[0].width - 256);
}
}
if (NF_BG16B[0].height > 192)
{
if (keys & KEY_UP)
{
y -= SPEED;
if (y < 0)
y = 0;
}
if (keys & KEY_DOWN)
{
y += SPEED;
if (y > (NF_BG16B[0].height - 192))
y = (NF_BG16B[0].height - 192);
}
}
// Lee el teclado
if (NF_BG16B[0].width > 256) {
if (keys & KEY_LEFT) {
x -= SPEED;
if (x < 0) x = 0;
}
if (keys & KEY_RIGHT) {
x += SPEED;
if (x > (NF_BG16B[0].width - 256)) x = (NF_BG16B[0].width - 256);
}
}
if (NF_BG16B[0].height > 192) {
if (keys & KEY_UP) {
y -= SPEED;
if (y < 0) y = 0;
}
if (keys & KEY_DOWN) {
y += SPEED;
if (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_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));
// Dibuja la imagen en el BackBuffer
for (scr_y = 0; scr_y < bottom; scr_y ++) {
for(scr_x = 0; scr_x < right; scr_x ++ ) {
// Calcula los offsets
scr_idx = (scr_y << 8) + scr_x;
img_idx = (((scr_y + y) * NF_BG16B[0].width) + (scr_x + x));
// Escribe los valores
*(NF_16BITS_BACKBUFFER[0] + scr_idx) = NF_BG16B[0].buffer[img_idx];
}
}
*(NF_16BITS_BACKBUFFER[0] + scr_idx) = NF_BG16B[0].buffer[img_idx];
}
}
// Sincronismo Vertical
swiWaitForVBlank();
swiWaitForVBlank(); // Wait for the screen refresh
// Manda el backbuffer a la pantalla
NF_Flip16bitsBackBuffer(0);
}
return 0;
// Send backbuffer to the screen
NF_Flip16bitsBackBuffer(0);
}
return 0;
}

View File

@ -1,95 +1,56 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// Example that shows how to get the user language
// http://www.nightfoxandco.com
/*
-------------------------------------------------
NightFox's Lib Template
Ejemplo de obtencion del idioma del usuario
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>
// Includes librerias propias
#include <nf_lib.h>
int main(int argc, char **argv)
{
// Initialize 2D hardware and default console
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
// Print on the screen the user language
switch (NF_GetLanguage())
{
case 0:
printf("Japanese");
break;
case 1:
printf("English");
break;
case 2:
printf("French");
break;
case 3:
printf("German");
break;
case 4:
printf("Italian");
break;
case 5:
printf("Spanish");
break;
case 6:
printf("Chinese");
break;
default:
printf("Error");
break;
}
while(1)
{
swiWaitForVBlank();
}
/*
-------------------------------------------------
Main() - Bloque general del programa
-------------------------------------------------
*/
int main(int argc, char **argv) {
// Inicializa las pantallas
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
swiWaitForVBlank();
// Imprime en pantalla el idioma del usuario
switch (NF_GetLanguage()) {
case 0 : // Japanese
printf("Japanese");
break;
case 1 : // English
printf("English");
break;
case 2 : // French
printf("French");
break;
case 3 : // German
printf("German");
break;
case 4 : // Italian
printf("Italian");
break;
case 5 : // Spanish
printf("Spanish");
break;
case 6 : // Chinese
printf("Chinese");
break;
default:
printf("Error");
break;
}
// Bucle (repite para siempre)
while(1) {
swiWaitForVBlank(); // Espera al sincronismo vertical
}
return 0;
return 0;
}

View File

@ -1,141 +1,99 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// Example of using RAW sounds
// http://www.nightfoxandco.com
/*
-------------------------------------------------
NightFox's Lib Template
Ejemplo de sonidos en formato RAW
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 DS audio hardware
soundEnable();
/*
-------------------------------------------------
Main() - Bloque general del programa
-------------------------------------------------
*/
// Initialize tiled backgrounds system
NF_InitTiledBgBuffers(); // Initialize storage buffers
NF_InitTiledBgSys(0); // Top screen
NF_InitTiledBgSys(1); // Bottom screen
int main(int argc, char **argv) {
// Initialize top screen text engine
NF_InitTextSys(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();
// Initialize audio buffers
NF_InitRawSoundBuffers();
// Define el ROOT e inicializa el sistema de archivos
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS"); // Define la carpeta ROOT para usar NITROFS
// Load background files from NitroFS
NF_LoadTiledBg("bg/layer3", "moon", 256, 256);
// Inicializa el motor 2D
NF_Set2D(0, 0); // Modo 2D_0 en ambas pantallas
NF_Set2D(1, 0);
// Load font files from NitroFS
NF_LoadTextFont("fnt/default", "normal", 256, 256, 0);
// Inicializa el engine de audio de la DS
soundEnable();
// Load audio files from NitroFS
NF_LoadRawSound("sfx/sample", 0, 11025, 0);
NF_LoadRawSound("sfx/music", 1, 22050, 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 backgrounds
NF_CreateTiledBg(0, 3, "moon");
NF_CreateTiledBg(1, 3, "moon");
// Inicializa el motor de texto
NF_InitTextSys(0); // Inicializa el texto para la pantalla superior
// Create text layer
NF_CreateTextLayer(0, 0, 0, "normal");
// Inicializa los buffers de sonido
NF_InitRawSoundBuffers();
// Write some text in each text layer
NF_WriteText(0, 0, 1, 1, "L or R play voice.");
NF_WriteText(0, 0, 1, 2, "A or B STOP/PLAY music.");
NF_WriteText(0, 0, 1, 4, "L o R reproducir una voz.");
NF_WriteText(0, 0, 1, 5, "A or B musica STOP/PLAY");
// 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
// Update text layers
NF_UpdateTextLayers();
// Carga la fuente por defecto para el texto
NF_LoadTextFont("fnt/default", "normal", 256, 256, 0); // Carga la seccion "normal" de la fuente
// Start background music
u8 sound_id = NF_PlayRawSound(1, 127, 64, true, 0);
// Carga los samples de sonido en formato RAW
NF_LoadRawSound("sfx/sample", 0, 11025, 0);
NF_LoadRawSound("sfx/music", 1, 22050, 0);
while (1)
{
scanKeys(); // Read keypad
u16 newpress = keysDown(); // Keys just pressed
// Crea los fondos de la pantalla superior
NF_CreateTiledBg(0, 3, "moon");
// Crea los fondos de la pantalla inferior
NF_CreateTiledBg(1, 3, "moon");
// Pause music, but don't remove it from memory
if (newpress & KEY_A)
soundPause(sound_id);
// Crea una capa de texto
NF_CreateTextLayer(0, 0, 0, "normal");
// Resume music from the start of the file
if (newpress & KEY_B)
soundResume(sound_id);
// Escribe un texto en cada capa de texto
NF_WriteText(0, 0, 1, 1, "L or R play voice.");
NF_WriteText(0, 0, 1, 2, "A or B STOP/PLAY music.");
NF_WriteText(0, 0, 1, 4, "L o R reproducir una voz.");
NF_WriteText(0, 0, 1, 5, "A or B musica STOP/PLAY");
// Play a different sound effect on top of the music
if (newpress & KEY_R)
NF_PlayRawSound(0, 127, 127, false, 0);
if (newpress & KEY_L)
NF_PlayRawSound(0, 127, 0, false, 0);
// Actualiza las capas de texto
NF_UpdateTextLayers();
// Variables
u16 newpress = 0;
u8 sound_id = 0;
// Inicia la musica de fondo
sound_id = NF_PlayRawSound(1, 127, 64, true, 0);
// Bucle (repite para siempre)
while(1) {
// Lee el teclado
scanKeys();
newpress = keysDown();
// Detiene el sonido, pero no la borra de la memoria de sonido
if (newpress & KEY_A) soundPause(sound_id);
// Vuelve a reproducir el sonido, pero desde el principio
if (newpress & KEY_B) soundResume(sound_id);
// Para eliminar el sonido de la memoria de sonido (no del buffer de la libreria)
// usa la funcion soundKill();
// Reproduce el sonido
if (newpress & KEY_R) NF_PlayRawSound(0, 127, 127, false, 0);
if (newpress & KEY_L) NF_PlayRawSound(0, 127, 0, false, 0);
swiWaitForVBlank(); // Espera al sincronismo vertical
}
return 0;
swiWaitForVBlank(); // Wait for the screen refresh
}
return 0;
}

View File

@ -4,7 +4,6 @@
//
// NightFox's Lib Template
// http://www.nightfoxandco.com
// Inicio 10 de Octubre del 2009
#include <stdio.h>