f3a4fe1f665f112eead6401c00fc4c898422dd20
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VP_SDK / Examples / nds / hello_world.c
1 /**
2  * \file examples_oneThread.c
3  * \brief How to launch a thread with VP_SDK
4  */
5
6 ///////////////////////////////////////////////
7 // INCLUDES
8
9 #include <nds.h>
10 #include <stdio.h>
11
12
13 volatile int frame = 0;
14
15
16 //---------------------------------------------------------------------------------
17 void Vblank()
18 {
19   //---------------------------------------------------------------------------------
20   frame++;
21 }
22         
23
24 //---------------------------------------------------------------------------------
25 void initNDS()
26 {
27   //---------------------------------------------------------------------------------
28   irqInit();
29   irqSet(IRQ_VBLANK, Vblank);
30   irqEnable(IRQ_VBLANK);
31   videoSetMode(0);      //not using the main screen
32   videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);      //sub bg 0 will be used to print text
33   vramSetBankC(VRAM_C_SUB_BG);
34
35   SUB_BG0_CR = BG_MAP_BASE(31);
36         
37   BG_PALETTE_SUB[255] = RGB15(31,31,31);        //by default font will be rendered with color 255
38         
39   //consoleInit() is a lot more flexible but this gets you up and running quick
40   consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
41 }
42
43
44 //---------------------------------------------------------------------------------
45 int main(int argc, char **argv)
46 {
47   //---------------------------------------------------------------------------------
48   touchPosition touchXY;
49
50   initNDS();
51
52   iprintf("      Hello DS dev'rs\n");
53   iprintf("     www.devkitpro.org\n");
54   iprintf("   www.drunkencoders.com");
55
56   while(1) {
57         
58     swiWaitForVBlank();
59     touchXY=touchReadXY();
60
61     // print at using ansi escape sequence \x1b[line;columnH
62     iprintf("\x1b[10;0HFrame = %d",frame);
63     iprintf("\x1b[16;0HTouch x = %04X, %04X\n", touchXY.x, touchXY.px);
64     iprintf("Touch y = %04X, %04X\n", touchXY.y, touchXY.py);
65         
66   }
67
68   return 0;
69 }
70