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 > Sprites on both screens

#100273 - TheRain - Sun Aug 27, 2006 4:17 am

One of my DS apps now needs to have some sprites on the sub screen in addition to the sprites already on the main screen... I was trying to set up VRAM bank I to serve this purpose, but I'm not sure where in VRAM my sprites will end up and also I'm not sure how to reference this sub screen sprite location in sprite OAM... here's my VRAM and mode set up
Code:

    vramSetMainBanks(   VRAM_A_MAIN_SPRITE,        //A and B maped consecutivly as sprite memory
                       VRAM_B_MAIN_BG_0x6000000,        //map as main BG
                       VRAM_C_SUB_BG_0x6200000 ,  //map C sub BG
                        VRAM_D_MAIN_BG_0x6020000   //using D as BG2
                        );
   
   vramSetBankI(VRAM_I_SUB_SPRITE);
   //set the video mode
    videoSetMode(  MODE_5_2D |
                   DISPLAY_SPR_ACTIVE |    //turn on sprites
               DISPLAY_BG2_ACTIVE |    //This background will be used for pixel draw overlay
                   DISPLAY_BG3_ACTIVE |    //turn on background 3
                   DISPLAY_SPR_2D_BMP_256     //and this in bitmap mode
                    );
       videoSetModeSub(  MODE_5_2D |
               DISPLAY_BG2_ACTIVE|
               DISPLAY_SPR_1D
                    );


And here is part of my sprite setup code for sprite attributes

Code:

   sprites[spritesInitialized].attribute[0] = ATTR0_BMP |  (newbutton.y); //bitmap mode sprite at y=10
   sprites[spritesInitialized].attribute[1] = ATTR1_SIZE_16 | (newbutton.x);   //16x16 sprite placed at x=20
   sprites[spritesInitialized].attribute[2] = ATTR2_ALPHA(1)| ((normalx*2)+(normaly*64));


So what I'm wondering is, how can I make a sprite entry point to a sprite in SUB sprite VRAM space?
_________________
DSMIDI and dSTAR sequencer brought to you by TheRain
http://www.collinmeyermusic.com/dev/

#100276 - tepples - Sun Aug 27, 2006 4:27 am

If you want to use the same sprite cel on both screens, you need to copy it into both sprite cel VRAM banks.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#100277 - TheRain - Sun Aug 27, 2006 4:44 am

no, i'm just not sure how to make OAM reference a tile in sub VRAM.. i understand how to put sprite data into VRAM that's designated for sub sprites... but I find no OAM setting for telling OAM that a sprite is referencing sub sprite VRAM as opposed to main sprite VRAM.

....
....

<edit>

wait... does attribute[2] actually reference directly a VRAM location?
_________________
DSMIDI and dSTAR sequencer brought to you by TheRain
http://www.collinmeyermusic.com/dev/

#100285 - knight0fdragon - Sun Aug 27, 2006 6:11 am

to load a sprite into main OAM you use just OAM
to load it into sub you have to load it into OAM_SUB

the low 10 bits of attribute 2 are used to decide which tile is being used for the sprite, max being 1024 of course
_________________
http://www.myspace.com/knight0fdragonds

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

#100319 - TheRain - Sun Aug 27, 2006 10:21 am

knight0fdragon wrote:
to load a sprite into main OAM you use just OAM
to load it into sub you have to load it into OAM_SUB


right on... thanks man.
_________________
DSMIDI and dSTAR sequencer brought to you by TheRain
http://www.collinmeyermusic.com/dev/