Page 1 of 1

sub engine LCD access

Posted: Sat May 30, 2009 11:25 pm
by The4thcircle
Hi there, I'm just starting to get into DS coding, and I'm making a little paint program.

This isn't about that though, what it is about is me trying to wrestle control of the sub engine.

Is there any way to get the sub engine to accept a raw LCD screenbuffer?

I've done it on the top but the bottom seems... reluctant. I know I could set it to use the main engine for the bottom screen but then I'm left trying to get direct LCD control on the TOP screen.

My ides sort of needs both simultaneously. Is that even possible?

Stripping out the unneeded parts, the sequence I'm essentially doing is:


vramSetMainBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_LCD, VRAM_D_LCD);

videoSetMode(MODE_FB1);
videoSetModeSub(MODE_FB2);

//do stuff on VRAM_C
videoSetMode(MODE_FB3);
//do stuff on VRAM_A
videoSetModeSub(MODE_FB1);
//do stuff on VRAM_B

and so on. I'm sort of doing a pass the parcel with the unused vram acting as my working buffer.

it displays just fine on the main engine but my sub engine screen stays resolutely blank.
Any advice?


-T4C

Re: sub engine LCD access

Posted: Sun May 31, 2009 1:11 am
by vuurrobin
the sub engine doesn't have a framebuffer mode.

see here for all the posible modes:
http://www.dev-scene.com/NDS/Tutorials_Day_2#2D

Re: sub engine LCD access

Posted: Wed Jun 03, 2009 9:27 pm
by Al_Bro
If you're just wanting direct access to the sub-engine then it can be done. I've got a test program that uses the main engine for 3D and I've experimented with using banks H and I for the sub-engine (there's just enough RAM there).

Try something like:

Code: Select all

	videoSetModeSub(MODE_5_2D);
	vramSetBankH(VRAM_H_SUB_BG);
	vramSetBankI(VRAM_I_SUB_BG_0x06208000);
	int SubPtr = bgInitSub(2, BgType_Bmp8, BgSize_B8_256x256, 0, 0);
	for(int i=0; i < 256; i++)
	{
		BG_PALETTE_SUB[i] = RGB15(i & 0x1F, i & 0x1F, i & 0x1F);
	}
	u16 *SubData = bgGetGfxPtr(SubPtr);
	for(int y=0; y < 128; y++)
	{
		for(int x=0; x < 192 / 2; x++)
			SubData[x + y * 192 / 2] = ((x * 2) & 0xFF) | (((x * 2 + 1) << 8) & 0xFF00);
	}
Of course, that's not a practical application - you'd want to make sure you use a proper palette and it's quite likely to contain some bugs (design or otherwise!).