X-Git-Url: http://git.maemo.org/git/?p=mardrone;a=blobdiff_plain;f=mardrone%2FARDrone_SDK_Version_1_8_20110726%2FARDroneLib%2FVP_SDK%2FExamples%2Fnds%2Fhello_world.c;fp=mardrone%2FARDrone_SDK_Version_1_8_20110726%2FARDroneLib%2FVP_SDK%2FExamples%2Fnds%2Fhello_world.c;h=f3a4fe1f665f112eead6401c00fc4c898422dd20;hp=0000000000000000000000000000000000000000;hb=9ec9bc13b75d30bc45535c54a652934debfcea92;hpb=ae0a3c2dc0898400aca0dd6b439c5db8044db7b2 diff --git a/mardrone/ARDrone_SDK_Version_1_8_20110726/ARDroneLib/VP_SDK/Examples/nds/hello_world.c b/mardrone/ARDrone_SDK_Version_1_8_20110726/ARDroneLib/VP_SDK/Examples/nds/hello_world.c new file mode 100644 index 0000000..f3a4fe1 --- /dev/null +++ b/mardrone/ARDrone_SDK_Version_1_8_20110726/ARDroneLib/VP_SDK/Examples/nds/hello_world.c @@ -0,0 +1,70 @@ +/** + * \file examples_oneThread.c + * \brief How to launch a thread with VP_SDK + */ + +/////////////////////////////////////////////// +// INCLUDES + +#include +#include + + +volatile int frame = 0; + + +//--------------------------------------------------------------------------------- +void Vblank() +{ + //--------------------------------------------------------------------------------- + frame++; +} + + +//--------------------------------------------------------------------------------- +void initNDS() +{ + //--------------------------------------------------------------------------------- + irqInit(); + irqSet(IRQ_VBLANK, Vblank); + irqEnable(IRQ_VBLANK); + videoSetMode(0); //not using the main screen + videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text + vramSetBankC(VRAM_C_SUB_BG); + + SUB_BG0_CR = BG_MAP_BASE(31); + + BG_PALETTE_SUB[255] = RGB15(31,31,31); //by default font will be rendered with color 255 + + //consoleInit() is a lot more flexible but this gets you up and running quick + consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); +} + + +//--------------------------------------------------------------------------------- +int main(int argc, char **argv) +{ + //--------------------------------------------------------------------------------- + touchPosition touchXY; + + initNDS(); + + iprintf(" Hello DS dev'rs\n"); + iprintf(" www.devkitpro.org\n"); + iprintf(" www.drunkencoders.com"); + + while(1) { + + swiWaitForVBlank(); + touchXY=touchReadXY(); + + // print at using ansi escape sequence \x1b[line;columnH + iprintf("\x1b[10;0HFrame = %d",frame); + iprintf("\x1b[16;0HTouch x = %04X, %04X\n", touchXY.x, touchXY.px); + iprintf("Touch y = %04X, %04X\n", touchXY.y, touchXY.py); + + } + + return 0; +} +