writing directly to the sub engine's framebuffer.

Post Reply
akaitora
Posts: 3
Joined: Thu Jun 02, 2011 3:10 pm

writing directly to the sub engine's framebuffer.

Post by akaitora » Thu Jun 02, 2011 3:14 pm

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!

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

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

Post by elhobbs » Thu Jun 02, 2011 3:47 pm

I do not think frame buffer modes are supported by the sub-screen/secondary graphics engine.

akaitora
Posts: 3
Joined: Thu Jun 02, 2011 3:10 pm

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

Post by akaitora » Thu Jun 02, 2011 3:57 pm

So it is not possible to write directly to the sub engine's framebuffer?

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

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

Post by zeromus » Thu Jun 02, 2011 5:41 pm

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.

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

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

Post by mtheall » Fri Jun 03, 2011 11:39 pm

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.

akaitora
Posts: 3
Joined: Thu Jun 02, 2011 3:10 pm

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

Post by akaitora » Sat Jun 04, 2011 4:30 am

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!

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests