All pastes #104562 Raw Edit

Someone

public text v1 · immutable
#104562 ·published 2006-07-29 00:09 UTC
rendered paste body
#include <nds.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <nds/arm9/console.h> //basic print funcionality

#define MYBASE 8
#define MYOFFSET 31

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

        powerON(POWER_ALL);

        videoSetMode(MODE_5_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG3_ACTIVE);
        videoSetModeSub(MODE_5_2D | DISPLAY_BG0_ACTIVE);
        vramSetBankA(VRAM_A_MAIN_BG);
        vramSetBankB(VRAM_B_MAIN_BG);
        vramSetBankC(VRAM_C_SUB_BG);

        SUB_BG0_CR = BG_MAP_BASE(31);
        BG3_CR = BG_BMP16_256x256 | BG_PRIORITY_3;
        BG0_CR = BG_MAP_BASE(MYBASE+MYOFFSET) | BG_TILE_BASE(MYBASE) | BG_PRIORITY_0;

        BG3_XDX = 1 << 8;
        BG3_XDY = 0;
        BG3_YDX = 0;
        BG3_YDY = 1 << 8;

        BG_PALETTE[255] = RGB15(31,31,31);      //by default font will be rendered with color 255

        consoleInitDefault((u16*)SCREEN_BASE_BLOCK(MYBASE+MYOFFSET), (u16*)CHAR_BASE_BLOCK(MYBASE), 16);

        int i,j;
        for(i = 0; i < 192; i++) {
                //BG_GFX[i] = RGB15(31,0,31);
                for(j = 0; j < 256; j++) {
                        if(i == 20)
                                BG_GFX[j+(256*i)] = RGB15(31,31,31) | BIT(15);
                        else if(i == 172)
                                BG_GFX[j+(256*i)] = RGB15(0,0,31) | BIT(15);
                        else
                                BG_GFX[j+(256*i)] = RGB15(0,0,31-(int)(i*0.16)) | BIT(15);
                }
        }



        while(1) {

                touchXY=touchReadXY();
                iprintf("\x1b[10;0HTouch x = %04X, %04X\n", touchXY.x, touchXY.px);
                iprintf("Touch y = %04X, %04X\n", touchXY.y, touchXY.py);

        }

        return 0;
}