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.

Beginners > How to swap screens?

#156589 - mca - Sun May 11, 2008 9:01 pm

Hi,

what's the command to swap screens?
By default libnds assigns the lower NDS touchscreen to the MAIN screen, while the upper NDS screen is assigned to the SUB screen.

How can I change it?

My goal is to assign 256 Kb of memory to the upper NDS screen. AFAIK I can't do it with the SUB screen (max 128 Kb). Is this correct?

Thanks...
mca

#156592 - mca - Sun May 11, 2008 9:24 pm

Hi,

at last found it here:

http://dev-scene.com/NDS/DOCgraphicmodes

Code:
lcdMainOnTop(); //MAIN renders to top screen SUB to bottom
lcdMainOnBottom(); //SUB renders to top screen MAIN to bottom
lcdSwap(); //swap the screens the egines were rendering to


Thanks anyway for this forum and its help...
mca

#156594 - silent_code - Sun May 11, 2008 9:35 pm

one word: exactly. :^)
i personally don't use the swap method. it's better to use the explicit "commands", so you make sure your program behaves consistently. the implicid "command" allows programming logic flaws to mess up the screen positioning and makes it harder to find those flaws.

happy coding! :^)

#156605 - mca - Sun May 11, 2008 10:05 pm

Hi,

now I succesfully swapped screens and initialized video as follows:

Code:
   lcdMainOnTop();
   vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,
             VRAM_B_MAIN_BG_0x06020000,
             VRAM_C_SUB_BG_0x06200000,
             VRAM_D_SUB_SPRITE);

    videoSetMode(MODE_5_2D | // Set the graphics mode to Mode 5
                 DISPLAY_BG0_ACTIVE | // Enable text Output      
                 DISPLAY_BG2_ACTIVE   // Enable BG2 for display
                 );
    videoSetModeSub(MODE_5_2D | // Set the graphics mode to Mode 5
                 DISPLAY_BG3_ACTIVE | // Enable BG3 for display
                 DISPLAY_SPR_ACTIVE | // Enable sprites for display
                 DISPLAY_SPR_1D       // Enable 1D tiled sprites
             );


Now problem is, that no sprite comes up on the SUB screen.
When I had the sprites display on the MAIN screen, all worked fine.

What could be wrong?

Thanks...
mca

#156608 - tepples - Sun May 11, 2008 10:09 pm

Where in VRAM and in OAM are you loading the sub screen's sprites?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#156615 - mca - Sun May 11, 2008 10:34 pm

I use
Code:
dmaCopyHalfWords(3,
                   EmptyTiles,
                   &SPRITE_GFX[TileIdx * EMPTY * OFFSET_MULTIPLIER],
                   EmptyTilesLen);

for copying the sprite data and

Code:
void updateOAM(tOAM * oam) {
    DC_FlushAll();
    dmaCopyHalfWords(3,
                     oam->spriteBuffer,
                     OAM_SUB,
                     SPRITE_COUNT * sizeof(SpriteEntry));
}

for updating the OAM_SUB.

And as I wrote in my previous post, I use VRAM_D_SUB_SPRITE.

I don't understand exactly, how &SPRITE_GFX knows its destination in VRAM_D. How is it set?

#156620 - tepples - Sun May 11, 2008 10:48 pm

mca wrote:
I use
Code:
dmaCopyHalfWords(3,
                   EmptyTiles,
                   &SPRITE_GFX[TileIdx * EMPTY * OFFSET_MULTIPLIER],

Why not SPRITE_GFX_SUB?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#156624 - mca - Sun May 11, 2008 10:55 pm

Thanks,

SPRITE_GFX_SUB and SPRITE_PALETTE_SUB is working.

It isn't sufficient to just use OAM_SUB instead of OAM.

Now I can move on...


@silent_code: good suggestion. I use the explicit commands.