gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Problem with BMP sprites... [solved]

#118090 - Key_46 - Sat Feb 10, 2007 1:20 am

Hi, i am using sprites to render buttons in my ds app. , or, at least, trying... i write the icon in the SPRITE_GFX...in my case, the icon is a 64x64 media player like wmp11 play button, he is the code:

initialization:

Code:

vramSetMainBanks(   VRAM_A_MAIN_SPRITE,
                        VRAM_B_MAIN_SPRITE,
                        VRAM_C_SUB_BG_0x6200000,
                        VRAM_D_MAIN_BG_0x6000000
                        );
    videoSetMode(  MODE_5_2D |
                   DISPLAY_SPR_ACTIVE |
                   DISPLAY_BG0_ACTIVE |
               DISPLAY_SPR_2D_BMP_256
                    );

   videoSetModeSub( MODE_0_2D | DISPLAY_BG0_ACTIVE );

   BG_PALETTE_SUB[0] = RGB15(0,0,0);
   SUB_BG0_CR = BG_MAP_BASE(31);
   BG_PALETTE_SUB[255] = RGB15(31,31,31);
   consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);

irqInit();
   irqSet(IRQ_VBLANK, 0);
   irqEnable(IRQ_VBLANK);


fill SPRITE_GFX:
Code:

for(y=0;y<64;y++)
      for(x=0;x<64;x++)
      {
         SPRITE_GFX[P(x,y,256)]=RGB15(
         COLOR2DSCOLOR(mPlayer_64_data[i + 1]),
         COLOR2DSCOLOR(mPlayer_64_data[i + 2]),
         COLOR2DSCOLOR(mPlayer_64_data[i + 3]))|(1<<15);

                        /*
                          -mPlayer_64_data is a ushort array in a .h file(bitmap).
                          -color2dscolor converts 8bit color to 5bit color.
                        */

         i+=4;
      }


and the sprite itself:
Code:

Sprites[0]->attribute[0] = ATTR0_BMP | ATTR0_ROTSCALE_DOUBLE | sprite_y;
   Sprites[0]->attribute[1] = ATTR1_SIZE_64 | sprite_x;
   Sprites[0]->attribute[2] = ATTR2_ALPHA(1)| 0;
   Sprites[0]->attribute[3] = 0;


*all the OAM functions are copied from DevKit Sprite_Bitmap Example.

the problem is that the sprite's image isn't my bitmap, it is just a light-blue square, i checked the VRAM in Dualis emulator and the image is OK, the OAM viewer in DS says that the sprite 0 's PLAIN is my image, but the FINAL is the blue square...what is the problem?


Last edited by Key_46 on Sat Feb 10, 2007 10:06 am; edited 1 time in total

#118096 - tepples - Sat Feb 10, 2007 3:21 am

If you use ROTSCALE but do not load in a transformation matrix, all you will see is the pixel at the center of the sprite cel. Either load in a matrix or don't use ROTSCALE.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#118131 - Key_46 - Sat Feb 10, 2007 10:02 am

It worked! Tanks