Beginners question about background and text

Post Reply
wojsza
Posts: 2
Joined: Thu Nov 25, 2010 12:49 pm

Beginners question about background and text

Post by wojsza » Fri Nov 26, 2010 11:17 am

Greet

I've got a question about some background issues, as my first step in developing nds apps I have create a code to colour both of nds screen in particular colour using this code:

Code: Select all

#include <nds.h>
#include <stdio.h>

int main(void) 
{
	videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE); 
	videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);

	vramSetBankA(VRAM_A_MAIN_BG); 
	vramSetBankC(VRAM_C_SUB_BG);

	u16* video_buffer_main = (u16*)BG_BMP_RAM(0);
	u16* video_buffer_sub = (u16*)BG_BMP_RAM_SUB(0);

	BACKGROUND.control[3] = BG_BMP16_256x256 | BG_BMP_BASE(0);
	BACKGROUND_SUB.control[3] = BG_BMP16_256x256 | BG_BMP_BASE(0);

	for(int i=0; i<256*256; i++)
	{
		video_buffer_main[i] = RGB15(31, 0, 0) | BIT(15);
		video_buffer_sub[i] = RGB15(31, 0, 0) | BIT(15);
	}
	
	BG_PALETTE_SUB[255] = RGB15(31,31,31);

	consoleInit(0, 1, BgType_Text4bpp, BgSize_T_256x256, 0, 6, false, true);	
	
	printf("\n\n\tNDS\n");

	while(1)
	{
		swiWaitForVBlank();
	}
	
	return 0;
}
But my question is that when I initialize console, its background goes blue so I'm stuck and need a clue about how to write on pre-define background colour ;p

User avatar
PypeBros
Posts: 40
Joined: Thu Nov 25, 2010 12:00 pm
Location: In a galaxy far, far away
Contact:

Re: Beginners question about background and text

Post by PypeBros » Fri Nov 26, 2010 4:51 pm

the consoleInit may be doing more than I think, but, it looks like you're setting it on the layer #1 that you haven't enabled on videoMode() call.
NDS is the neatest piece of hardware since the C=64! Thanks for making it programmable ^_^

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

Re: Beginners question about background and text

Post by zeromus » Fri Nov 26, 2010 7:05 pm

But my question is that when I initialize console, its background goes blue so I'm stuck and need a clue about how to write on pre-define background colour ;p
there are millions of ways to do that. the way you have chosen may not be the best way. having a bitmap BG is very memory-greedy. but perhaps that's what you wanted.

you have made an error in the method you chose to do it.

your console map/tile base interfere with the BMP base for BG3. there is only one way I can think of to make them fit on the sub screen:

BACKGROUND_SUB.control[3] = BG_BMP16_256x256 | BG_BMP_BASE(2);
consoleInit(0, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true);

analyze gbatek until you understand.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 78 guests