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 > Noob Sprite Problems

#105323 - pettersson - Sat Oct 07, 2006 6:48 pm

Hi, i just started developing for Nintendo DS. Using Mode_5_3D i can't get a simple sprite displayed. Using an emulator (ideas) only the bg image is shown. Running on real hardware, it displays a crippled thingy in the left upper corner, but not the red square as intended.

Here is what i do:
Code:

for (unsigned int idx=0; idx<128; ++idx)
   {
      m_sprites[ idx ].attribute[ 0 ]   = ATTR0_DISABLED;
      m_sprites[ idx ].attribute[ 1 ]   = 0;
      m_sprites[ idx ].attribute[ 2 ]   = 0;
      m_sprites[ idx ].attribute[ 3 ]   = 0;
   }
   
   // get SpriteRotation Pointer.
   SpriteRotation *p_sprite_rotation      = (SpriteRotation*)m_sprites;
   int idx;
   for (idx=0; idx<32; ++idx)
   {
      p_sprite_rotation[ idx ].hdx   = 256;
      p_sprite_rotation[ idx ].hdy   = 0;
      p_sprite_rotation[ idx ].vdx   = 0;
      p_sprite_rotation[ idx ].vdy   = 256;
   }
   
   // enable one single sprite
   m_sprites[ 0 ].attribute[0]   = ATTR0_BMP | ATTR0_ROTSCALE_DOUBLE | 10;
   m_sprites[ 0 ].attribute[1]   = ATTR1_SIZE_32 | 20;
   m_sprites[ 0 ].attribute[2]   = ATTR2_ALPHA(1) | 0;
   
   // copy some stuff to sprite memory...
   for (idx=0; idx<32*32; ++idx)
   {
      SPRITE_GFX[idx] = RGB15(31,0,0) | BIT(15);
   }


m_sprites is copied to OAM every frame.

thanks for any help.

#105347 - ProblemBaby - Sun Oct 08, 2006 12:02 am

have you made your own definitions? then you may double check them, run dualis and look in the Tile Viewer to determine if its a VRAM or OAM problem.

Edit: didnt thinked about that you used Bitmap sprites, you have to select that mode in OAM

#105358 - knight0fdragon - Sun Oct 08, 2006 3:29 am

you need to place the sprite into OAM , do you do this with some kind of update function you call in a loop?
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#105374 - pettersson - Sun Oct 08, 2006 7:59 am

Well, using Dualis, nothing gets displayed at all. But i can see the red sprite in the OAM Viewer (couldn't find it in the Tile Viewer, though). Ideas is only displaying the bg image. Hardware displays nothing.
Code:

vramSetMainBanks( VRAM_A_MAIN_BG_0x6000000,
               VRAM_B_MAIN_BG_0x6020000,
               VRAM_C_SUB_BG_0x6200000,
               VRAM_D_LCD );

vramSetBankE( VRAM_E_MAIN_SPRITE );
vramSetBankF( VRAM_F_MAIN_SPRITE );
vramSetBankG( VRAM_G_MAIN_SPRITE );
vramSetBankI( VRAM_I_LCD );

videoSetMode( MODE_5_3D |
            DISPLAY_BG3_ACTIVE |
            DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D_BMP | DISPLAY_SPR_1D );

that's how i set setup the video. The sprite entries get dmaCopied every vblank.