Page 1 of 1

writing directly to the sub engine's framebuffer.

Posted: Thu Jun 02, 2011 3:14 pm
by akaitora
So I am following the nds graphics tutorial at dev-scene. They have a code snippet which demonstrates how to fill the top screen's frame buffer with a red color. As a test, I wanted to do the same thing but for the bottom screen. I read that the ds has 2 graphics engine, 1 for the top screen (Main engine) and 1 for the bottom screen (Sub engine). I also read that you can make either engine use any combo of the vram memory. So I wrote the following example.

Code: Select all

#include <nds.h>
#include <stdio.h>
 
int main(void)
{
	//set frame buffer mode 0
	videoSetModeSub(MODE_FB0);
 
	//enable VRAM A for writing by the cpu and use 
	//as a framebuffer by video hardware
	vramSetBankA(VRAM_A_LCD);

	//fill video memory with the chosen color
	for(i = 0; i < 256*192; i++)
		VRAM_A[i] = RGB15(31,0,0); 

	while(1)
	{ 
		swiWaitForVBlank();
	}
 
	return 0;
}
This doesn't seem to fill the bottom screen with a red color. What am I doing wrong? Thanks!

Re: writing directly to the sub engine's framebuffer.

Posted: Thu Jun 02, 2011 3:47 pm
by elhobbs
I do not think frame buffer modes are supported by the sub-screen/secondary graphics engine.

Re: writing directly to the sub engine's framebuffer.

Posted: Thu Jun 02, 2011 3:57 pm
by akaitora
So it is not possible to write directly to the sub engine's framebuffer?

Re: writing directly to the sub engine's framebuffer.

Posted: Thu Jun 02, 2011 5:41 pm
by zeromus
it's vram framebuffer display mode that youre trying to use, and that does not work on the sub engine. use bgInit with BgType_Bmp16 instead which works pretty much the same way on both engines.

"any engine use any combo" is an exaggeration. You can mix and match according to 100 rules.

Re: writing directly to the sub engine's framebuffer.

Posted: Fri Jun 03, 2011 11:39 pm
by mtheall
I'm assuming you specifically want to use framebuffer mode on the sub engine. It's perfectly possible to use it on the bottom screen; you just have to set the main engine to display to the bottom screen. To use it on the sub engine, that's not possible. You'll have to go with something like zeromus said. Just set up a background on the sub screen to use BgType_Bmp16 and write to its map data. The only difference is that in framebuffer mode, alpha bit is ignored, but in Bmp16 mode, you have to set it to 1 if you want that pixel to display. Alpha bit is bit 15.

Re: writing directly to the sub engine's framebuffer.

Posted: Sat Jun 04, 2011 4:30 am
by akaitora
I guess I figured it out. I need to call

lcdMainOnBottom()

to make the Main engine render to the bottom screen and

lcdMainOnTop()

to make the Main engine render to the top screen. Thanks for your help!