Code: Select all
#include <nds.h>
#include <stdio.h>
void ClearScreen(void)
{
int i;
for(i = 0; i < 256 * 192; i++)
VRAM_A[i] = RGB15(0, 0, 0);
return;
}
int main(void)
{
// standard
// multi-purpose variables
int i;
int x;
int y;
int z;
// values
u16 valRed;
u16 valGreen;
u16 valBlue;
// increment?
bool incRed;
bool incGreen;
bool incBlue;
irqInit();
irqEnable(IRQ_VBLANK);
videoSetMode(MODE_FB0); // set video mode to frame buffer mode
vramSetBankA(VRAM_A_LCD); // assign first mem bank to lcd
consoleDemoInit(); // initilize console for printf to work
ClearScreen();
// hello world
printf("Hello World!\n");
printf("Hello East Wind!\n");
printf("In Your Neck!");
for(i = 0; i < 256 * 192; i++) // loop through each pixel on top screen
VRAM_A[i] = RGB15(31,0,0); // and make it red
// end hello world
// keypad demo
i = 0;
valRed = 0;
valGreen = 0;
valBlue = 0;
incRed = 1;
incGreen = 1;
incBlue = 1;
while(1)
{
for(x = 0; x < 32; x++)
{
for(y = 0; y < 32; y++)
{
for(z = 0; z < 32; z++)
{
if (incRed)
{
valRed--;
if (valRed = 0) incRed = (1);
}
else
{
valRed++;
if (valRed = 31) incRed = (0);
}
swiWaitForVBlank();
VRAM_A[i] = RGB15(valRed, valGreen, valBlue);
i++;
if (i = 256 * 192) {i = 0;}
iprintf("i = %d, x = %d, y = %d, z = %d\n", i, x, y, z);
iprintf("valRed = %d, valGreen = %d, valBlue = %d\n", valRed, valGreen, valBlue);
iprintf("incRed = %d, incGreen = %d, incBlue = %d\n", incRed, incGreen, incBlue);
}
if (incGreen)
{
valGreen--;
if (valGreen = 0) incGreen = (1);
}
else
{
valGreen++;
if (valGreen = 31) incGreen = (0);
}
swiWaitForVBlank();
VRAM_A[i] = RGB15(valRed, valGreen, valBlue);
i++;
if (i = 256 * 192) {i = 0;}
iprintf("i = %d, x = %d, y = %d, z = %d\n", i, x, y, z);
iprintf("valRed = %d, valGreen = %d, valBlue = %d\n", valRed, valGreen, valBlue);
iprintf("incRed = %d, incGreen = %d, incBlue = %d\n", incRed, incGreen, incBlue);
}
if (incBlue)
{
valBlue--;
if (valBlue = 0) incBlue = (1);
}
else
{
valBlue++;
if (valBlue = 31) incBlue = (0);
}
swiWaitForVBlank();
VRAM_A[i] = RGB15(valRed, valGreen, valBlue);
i++;
if (i = 256 * 192) {i = 0;}
iprintf("i = %d, x = %d, y = %d, z = %d\n", i, x, y, z);
iprintf("valRed = %d, valGreen = %d, valBlue = %d\n", valRed, valGreen, valBlue);
iprintf("incRed = %d, incGreen = %d, incBlue = %d\n", incRed, incGreen, incBlue);
}
iprintf("i = %d, x = %d, y = %d, z = %d\n", i, x, y, z);
iprintf("valRed = %d, valGreen = %d, valBlue = %d\n", valRed, valGreen, valBlue);
iprintf("incRed = %d, incGreen = %d, incBlue = %d\n", incRed, incGreen, incBlue);
}
// end keypad
return 0;
}