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 > Best resource for understanding video modes and memory?

#92194 - TheRain - Wed Jul 12, 2006 1:01 am

So far, one of the biggest hurdles for learning DS programming with libds has been understanding video modes and how vram is mapped and such... are there any good resources for understanding this??

#92238 - kvance - Wed Jul 12, 2006 7:56 am

I couldn't find one resource that had it all. There are a lot of good graphics examples in the nds-examples package, which you can download separately from devkitPro. As far as info, these pages were useful for me:

http://tobw.net/dswiki/index.php?title=Graphic_modes
http://www.double.co.nz/nintendo_ds/nds_develop10.html
http://www.dspassme.com/programmers_guide/tutorial/using_tiles.html

I summarized what I learned about using the hardware backgrounds here, but it probably only scratches the surface.
_________________
Corner Office: dev LJ
HexxagonDS, dsmzx, more...

#92299 - TheRain - Wed Jul 12, 2006 5:58 pm

kvance wrote:

http://tobw.net/dswiki/index.php?title=Graphic_modes


Actually, that is exactly what I was looking for! That resource is so good... thanks!

#92348 - TheRain - Thu Jul 13, 2006 12:04 am

Ok, so here's what I don't get....

Say I'm setting up my video mode like so:
videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE | DISPLAY_BG2_ACTIVE);

What I'm TRYING to do is to have two backgrounds, completely different bitmaps loaded into them from two seperate bin's and have them both visible on the screen at once. Then I'm going to set up alpha blending modes between them.

What I don't understand is, how do I know what memory is mapped to BG3 or BG2? If I'm setting up my VRAM with
Code:
vramSetMainBanks(VRAM_Ablah,VRAM_BBlah,VRAM_CBlah,VRAM_DBlah);

what part of this commands which background is assigned what place in VRAM?

Right now I have this:
Code:

videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE | DISPLAY_BG2_ACTIVE);   
vramSetMainBanks(   VRAM_A_MAIN_BG_0x6000000, VRAM_B_MAIN_BG_0x6020000,VRAM_C_MAIN_BG_0x6040000 , VRAM_D_LCD);

u16* background2 = (u16*)(0x06020000);

dmaCopy(back1_bin, BG_GFX, 256*192*2);
dmaCopy(back2_bin, background2, 256*192*2);

and when the program is run, both backgrounds have back1_bin displaying on them... I've been trying to sort it out by changing these values around but I can't makes sense of it.

#92349 - kvance - Thu Jul 13, 2006 12:23 am

TheRain wrote:
Code:

videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE | DISPLAY_BG2_ACTIVE);   
vramSetMainBanks(   VRAM_A_MAIN_BG_0x6000000, VRAM_B_MAIN_BG_0x6020000,VRAM_C_MAIN_BG_0x6040000 , VRAM_D_LCD);

u16* background2 = (u16*)(0x06020000);

dmaCopy(back1_bin, BG_GFX, 256*192*2);
dmaCopy(back2_bin, background2, 256*192*2);

and when the program is run, both backgrounds have back1_bin displaying on them... I've been trying to sort it out by changing these values around but I can't makes sense of it.

You're right, nothing has mapped a background to a memory location yet. All the backgrounds are probably defaulting to 16bpp bitmaps at 0x6000000, so they both look the same. Try something like this to set the BG control registers:

Code:
BG2_CR = BG_BMP16_256x256 | BG_BMP_BASE(0);
BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(8); /* 0x20000 divided by 0x4000 */

_________________
Corner Office: dev LJ
HexxagonDS, dsmzx, more...

#92355 - TheRain - Thu Jul 13, 2006 2:32 am

perfect! that fixed it right up ;)