How to initialize VRAM and BGs for GL2D right

Post Reply
JoshuaBehrens
Posts: 3
Joined: Thu Aug 09, 2012 11:35 am

How to initialize VRAM and BGs for GL2D right

Post by JoshuaBehrens » Thu Aug 09, 2012 12:01 pm

I'm new to nds-programming, so this might be somewhere solved, but I didn't find it already.

I didn't understand the way the VRAM works especially how to set the banks right. For drawing I'm using the GL2D-Calls. Therefore I'm not loading the images into oam, am I?
I found two interesting sites:
http://mtheall.com/banks.html
and
http://mtheall.com/vram.html
It's a nice visualization but on the first site I don't know how to correctly set the values for my needs. On the second site the same.

I have an orthogonally 3D perspective for the lowers creen ( by using lcdMainOnBottom( ) ). And there shall be some 2D objects not just the console on the upper screen. I'm using two textures "compiled" using grit. Together they size 58kb as asm-code.

Hope you can help me understand the system.

mtheall
Posts: 210
Joined: Thu Feb 03, 2011 10:47 pm

Re: How to initialize VRAM and BGs for GL2D right

Post by mtheall » Thu Aug 09, 2012 10:40 pm

Indeed those pages are interesting. :D
The vram.html page is for helping you map your backgrounds into VRAM. Due to the nature of your question, I think you would be uninterested in this page.
The banks.html page is for helping you map the various VRAM banks to the functions you need them for. I've never used GL2D, so I don't know what it expects your mappings to be.

If you are using GL2D then you are not using OAM. OAM is for sprites (with the 2D hardware engine), but GL2D uses textured quads (with the 3D hardware engine).

However, you haven't really presented a problem that needs to be solved. If you simply want more information about how VRAM and the 2D/3D engines work with it, you're probably best to join #dsdev on irc.blitzed.org and ask any questions. We are more than happy to help.

JoshuaBehrens
Posts: 3
Joined: Thu Aug 09, 2012 11:35 am

Re: How to initialize VRAM and BGs for GL2D right

Post by JoshuaBehrens » Fri Aug 10, 2012 12:31 am

I copied some lines out of an example. So this is my "memory setup":

Code: Select all

videoSetMode(MODE_0_3D);
vramSetBankA(VRAM_A_TEXTURE);
I can image it's not enough. What do I need?

relminator
Posts: 84
Joined: Sun Apr 11, 2010 10:43 am

Re: How to initialize VRAM and BGs for GL2D right

Post by relminator » Fri Aug 17, 2012 5:16 am

I generally just do this:

Code: Select all

videoSetMode( MODE_5_3D );
	videoSetModeSub( MODE_5_2D );
	
	vramSetBankA( VRAM_A_TEXTURE );     
	vramSetBankB( VRAM_B_TEXTURE );     
	vramSetBankC( VRAM_C_TEXTURE );     
	vramSetBankD( VRAM_D_SUB_SPRITE );	// oam fonts et al
	vramSetBankH( VRAM_H_SUB_BG );		// Our sub BG  
	vramSetBankI( VRAM_I_SUB_BG_0x06208000 ); // H + I makes 256*192
	vramSetBankF(VRAM_F_TEX_PALETTE);
	

then:

Code: Select all

       // Bg
	SubBG3 = bgInitSub( 3, BgType_Bmp8, BgSize_B8_256x256, 0, 0 );
	
	// Oam
	oamInit(&oamSub, SpriteMapping_1D_128, false);
	
Here's an example:

http://rel.phatcode.net/junk.php?id=119

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 6 guests