nds中的helloworld

本文介绍了一个使用DevKitPro编写的简单DS程序示例,演示了如何在DS平台上显示文本并读取触摸屏输入。

这次用的是devkitpro...
编译的是他的2D中一个例子..稍微改了改...
有兴趣的可以编写一个nds,2d 恋爱游戏..烧录以后玩玩看.. 

图片还是放不上来.....

/*---------------------------------------------------------------------------------

    $Id: main.cpp,v 1.7 2006/06/18 21:32:41 wntrmute Exp $

    Simple console print demo
    -- dovoto

    $Log: main.cpp,v $
    Revision 1.7  2006/06/18 21:32:41  wntrmute
    tidy up examples
    
    Revision 1.6  2005/09/16 12:20:32  wntrmute
    corrected iprintfs
    
    Revision 1.5  2005/09/12 18:32:38  wntrmute
    removed *printAt replaced with ansi escape sequences
    
    Revision 1.4  2005/09/05 00:32:19  wntrmute
    removed references to IPC struct
    replaced with API functions
    
    Revision 1.3  2005/08/31 03:02:39  wntrmute
    updated for new stdio support
    
    Revision 1.2  2005/08/03 06:36:30  wntrmute
    added logging
    added display of pixel co-ords
    

---------------------------------------------------------------------------------
*/

#include 
<nds.h>

#include 
<stdio.h>

volatile int frame = 0;

//---------------------------------------------------------------------------------
void Vblank() {
//---------------------------------------------------------------------------------
    frame++;
}

    
//---------------------------------------------------------------------------------
int main(void{
//---------------------------------------------------------------------------------
    touchPosition touchXY;

    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);

    iprintf(
"  Hello World! ");
    iprintf(
"  nds programming ");
    iprintf(
"  www.madcraze.com ");

    
while(1{
    
        swiWaitForVBlank();
        touchXY
=touchReadXY();

        
// print at using ansi escape sequence [line;columnH 
        iprintf("[10;0HFrame = %d",frame);
        iprintf(
"[16;0HTouch x = %04X, %04X ", touchXY.x, touchXY.px);
        iprintf(
"Touch y = %04X, %04X ", touchXY.y, touchXY.py);        
    
    }


    
return 0;
}

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值