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 > sprite subscreen do not show up [SOLVED]

#152306 - a128 - Thu Mar 13, 2008 4:17 pm

yet another sprite problem

Main screen is 3D
Sub screen a layer of backgrounds where also some sprites should appear.

it's ok BUT no sprite appears on subscreen

Code:

  // Setup the Main screen for 3D
                videoSetMode(MODE_0_3D );

                vramSetBankA(VRAM_A_TEXTURE); //128Kbyte
      vramSetBankB(VRAM_B_TEXTURE); // 128Kbyte
      
      //SUB SCREEN
      vramSetBankC(VRAM_C_SUB_BG);
      vramSetBankD(VRAM_D_SUB_SPRITE);
      vramSetBankH(VRAM_H_SUB_BG);
   // sub screen
         videoSetModeSub(MODE_5_2D |
               DISPLAY_SPR_ACTIVE |    //turn on sprites
               DISPLAY_SPR_1D_BMP  |    //and this in bitmap mode
               DISPLAY_BG3_ACTIVE  | // race track as ROT backgound
               DISPLAY_BG0_ACTIVE /*console*/);


               // text
         SUB_BG0_CR =
            BG_MAP_BASE(15) |
            BG_PRIORITY(0) |
            BG_256_COLOR;

         BG_PALETTE_SUB[0] =RGB15(10,23,31);
         BG_PALETTE_SUB[255] = RGB15(31,0,0);

         consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(15), (u16*)CHAR_BASE_BLOCK_SUB(0), 8);

         video_buffer =  (u16*)BG_BMP_RAM_SUB(2);

         // create background image
         SUB_BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(2) | BG_PRIORITY(1) ;

         SUB_BG3_XDX = 1 << 8;
         SUB_BG3_XDY = 0;
         SUB_BG3_YDX = 0;
         SUB_BG3_YDY = 1 << 8;
         SUB_BG3_CX = 0;
         SUB_BG3_CY = 0;
 

//SPRITE TEST SETUP

//turn off all the sprites
                      InitSprites(); 

         sprites[0].attribute[0] = ATTR0_BMP | ATTR0_ROTSCALE_DOUBLE | 30;
         sprites[0].attribute[1] = ATTR1_SIZE_32 | 40;
         sprites[0].attribute[2] = ATTR2_ALPHA(1)| 0;

         // red 32*32 square for 1d bitmap mode
      for(int i=0;i<32*32;i++)
         SPRITE_GFX[i]=RGB15(31,0,0)|(1<<15); //dont forget alpha bit

         
//OAM update
         DC_FlushRange(sprites,128*sizeof(SpriteEntry));
     dmaCopy(sprites, OAM_SUB, 128 * sizeof(SpriteEntry));


Last edited by a128 on Thu Mar 13, 2008 4:43 pm; edited 1 time in total

#152307 - eKid - Thu Mar 13, 2008 4:36 pm

One thing to note is that ATTR2_ALPHA ranges from 0->15, it should be 15 for full opacity. And I guess "SPRITE_GFX" should be changed to "SPRITE_GFX_SUB".

#152308 - a128 - Thu Mar 13, 2008 4:43 pm

done. it works! thanks