#104475 - smoggie83 - Fri Sep 29, 2006 4:10 pm
I am trying to display text above a background but no matter what i try it wont display any text that i tell it too! any ideas anyone?
Cheers
Dave
Code: |
#include <nds.h> #include <nds/arm9/console.h> #include <stdio.h> //make file automaticaly makes a header file for access //to the binary data in any file ending in .bin that is in //the data folder. It also links in that data to your project #include "drunkenlogo_bin.h" #include "palette_bin.h" #include "diceRoll_bin.h" #include "diceRollPalette_bin.h" #include "players_bin.h" #include "playersPalette_bin.h" enum { CONTINUOUS, SINGLE } TouchType = CONTINUOUS; volatile int frame = 0; //--------------------------------------------------------------------------------- void Vblank() { //--------------------------------------------------------------------------------- frame++; } void initVideo() { //enable vram and map it to the right places vramSetMainBanks( VRAM_A_MAIN_BG_0x6000000, //map A and B to main background memory VRAM_B_LCD, VRAM_C_SUB_BG_0x6200000, //map C to sub background memory VRAM_D_LCD //map D to LCD free space //allows adjacent banks to overflow into D if a bug like that was ever to occur ); //map a bank for use with sprites //vramSetBankE(VRAM_E_MAIN_SPRITE); //mapping E to main sprites gives us 64k for sprites //(64k is the max space that 1024 tiles take up in 256 color mode) //set the video mode videoSetMode( MODE_5_2D | DISPLAY_BG3_ACTIVE //turn on background 3 ); videoSetModeSub(MODE_5_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_1D ); } void initBackgrounds() { //setup exrot bg 3 on main as a 16bit color background BG3_CR = BG_BMP8_256x256 ; //attributes of the affine translation matrix BG3_XDX = 1 << 8; //scale x BG3_XDY = 0; //rotation x BG3_YDX = 0; //rotation y BG3_YDY = 1 << 8; //scale y BG3_CX = 0; //translation x BG3_CY = 0; //translation y //setup exrot bg 3 on sub SUB_BG3_CR = BG_BMP8_256x256 ; //attributes of the affine translation matrix SUB_BG3_XDX = 1 << 8; //scale x SUB_BG3_XDY = 0; //rotation x SUB_BG3_YDX = 0; //scale y SUB_BG3_YDY = 1 << 8; //scale y SUB_BG3_CX = 0; //translation x SUB_BG3_CY = 0; //translation y } int main(void) { //--------------------------------------------------------------------------------- int min_x = 4096 , min_y = 4096, max_x = 0, max_y = 0; int min_px = 4096 , min_py = 4096, max_px = 0 , max_py = 0; touchPosition touch; powerON(POWER_ALL); //initialise the interrupt system irqInit(); //install our simple vblank handler irqSet(IRQ_VBLANK, Vblank); //enable the interrupt irqEnable(IRQ_VBLANK); //set the mode for 2 text layers and two extended background layers initVideo(); ///////////////set up our bitmap background/////////////////////// initBackgrounds(); // black backdrop BG_PALETTE[0]=RGB15(0,0,0); SUB_BG0_CR = BG_COLOR_256;//use bg0 for the text //SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE[255] = RGB15(200,0,0);//by default font rendered with color 255 //consoleInit() is a lot more flexible but this gets you up and running quick consoleInitDefault((u16*)SCREEN_BASE_BLOCK(31), (u16*)CHAR_BASE_BLOCK(0), 16); dmaCopy(drunkenlogo_bin, BG_GFX, 256*192); dmaCopy(palette_bin, BG_PALETTE, 256*2); dmaCopy(drunkenlogo_bin, BG_GFX_SUB, 256*192); dmaCopy(palette_bin, BG_PALETTE_SUB, 256*2); while(1) { swiWaitForVBlank(); // read the button states scanKeys(); // read the touchscreen coordinates touch=touchReadXY(); int pressed = keysDown(); // buttons pressed this loop int held = keysHeld(); // buttons currently held // Right Shoulder button toggles the mode if ( pressed & KEY_R) TouchType ^= SINGLE; iprintf("\xTEST TEXT HERE!!!"); if ( TouchType == SINGLE && !(pressed & KEY_TOUCH) ) continue; if ( !(held & KEY_TOUCH) || touch.x == 0 || touch.y == 0) continue; if ( touch.x > max_x) max_x = touch.x; if ( touch.y > max_y) max_y = touch.y; if ( touch.px > max_px) max_px = touch.px; if ( touch.py > max_py) max_py = touch.py; if ( touch.x < min_x) min_x = touch.x; if ( touch.y < min_y) min_y = touch.y; if ( touch.px < min_px) min_px = touch.px; if ( touch.py < min_py) min_py = touch.py; } return 0; } |
Cheers
Dave