#71402 - mlequim - Sun Feb 12, 2006 4:42 pm
Hi,
I have done a first test to display in the sub screen an image in tiles mode but I get nothing (except some pixels), maybe someone can help me ?
I have first decomposed the image in tiles with "gfx2fba -t8". The tiles are in stage2.bin.
here is the code modified from an example. the part of the example works fine (display of an image in the upper screen in bitmap mode), but my part works not lol ! I want to display tiles in the sub screen, this part works not.
I have done a first test to display in the sub screen an image in tiles mode but I get nothing (except some pixels), maybe someone can help me ?
I have first decomposed the image in tiles with "gfx2fba -t8". The tiles are in stage2.bin.
here is the code modified from an example. the part of the example works fine (display of an image in the upper screen in bitmap mode), but my part works not lol ! I want to display tiles in the sub screen, this part works not.
Code: |
#include <nds.h> #include <nds/arm9/console.h> //basic print funcionality #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 "image2_bin.h" // NORMAL #include "palette2_bin.h" #include "stage2_bin.h" // TILES #include "palette4_bin.h" unsigned char map[16 * 16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48, 49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64, 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80, 81,82,83,84,85,83,87,88,89,90,91,92,93,94,95,96, 97,98,99,100,101, 102, 103, 104, 105,106,107,108,109,110,111,112, 113, 114, 115, 116, 117, 118, 119, 120,121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}; int main(void) { //irqs are nice irqInit(); irqSet(IRQ_VBLANK, 0); //set the mode for 2 text layers and two extended background layers videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE); //set the sub background up for text display (we could just print to one //of the main display text backgrounds just as easily videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text //set the first bank as background memory and the third as sub background memory //B and D are not used vramSetMainBanks(VRAM_A_MAIN_BG_0x6000000, VRAM_B_LCD, VRAM_C_SUB_BG , VRAM_D_LCD); ////////////////set up text background for text///////////////////// 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("\n\n\tAgonisma DS\n"); iprintf("\tPremier essais\n"); ///////////////set up our bitmap background/////////////////////// BG3_CR = BG_BMP8_256x256; //these are rotation backgrounds so you must set the rotation attributes: //these are fixed point numbers with the low 8 bits the fractional part //this basicaly gives it a 1:1 translation in x and y so you get a nice flat bitmap BG3_XDX = 1 << 8; BG3_XDY = 0; BG3_YDX = 0; BG3_YDY = 1 << 8; //our bitmap looks a bit better if we center it so scroll down (256 - 192) / 2 // BG3_CX = 0; // BG3_CY = 32 << 8; dmaCopy(image2_bin, BG_GFX, 256*256); dmaCopy(palette2_bin, BG_PALETTE, 256*2); u16* vramMap = (u16*)BG_MAP_BASE(31); dmaCopy(stage2_bin, BG_GFX_SUB, 256*192/4); dmaCopy(palette4_bin, BG_PALETTE_SUB, 256*3/4); dmaCopy(map, vramMap, 100); for (int i=0;i<1000;i++) {vramMap[i]=i;} while(1)swiWaitForVBlank(); return 0; } |