Background image & text on DS

Post Reply
t377y000
Posts: 52
Joined: Wed Jun 02, 2010 3:14 am
Location: United States

Background image & text on DS

Post by t377y000 » Sat Sep 01, 2012 3:58 am

hi i'm trying to make a menu. on the DS/DSi top screen
a background image with text over it.

seem to be can't seem to i get it to work the background shows abit of static. that's the closest i have gotten it to work so far.

im useing these methods

Code: Select all

videoSetMode(MODE_4_2D);
vramSetBankA(VRAM_A_MAIN_BG);

"then for text"
consoleInit(0,0, BgType_Text4bpp, BgSize_T_256x256, 31,0, true, true);
printf("\x1b[1;1Hinsert text here");

"then for background"
int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);
dmaCopy(gridbgBitmap, bgGetGfxPtr(bg3), 256*256);
dmaCopy(gridbgPal, BG_PALETTE, 256*2);
here's a screenshot of the dilemma i am having.
Image

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

Re: Background image & text on DS

Post by elhobbs » Sat Sep 01, 2012 2:24 pm

Your console and your background are using the same memory.

t377y000
Posts: 52
Joined: Wed Jun 02, 2010 3:14 am
Location: United States

Re: Background image & text on DS

Post by t377y000 » Sat Sep 01, 2012 9:32 pm

elhobbs wrote:Your console and your background are using the same memory.
there any way i can make them use different memories?

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

Re: Background image & text on DS

Post by elhobbs » Sun Sep 02, 2012 4:14 am

Change the console from 31,0 to 4,0 and the background from 0,0 to 5,0.

t377y000
Posts: 52
Joined: Wed Jun 02, 2010 3:14 am
Location: United States

Re: Background image & text on DS

Post by t377y000 » Tue Sep 04, 2012 4:11 am

elhobbs wrote:Change the console from 31,0 to 4,0 and the background from 0,0 to 5,0.
hi thanks that kinda helped, im still having problems tho.

now im using this.

Code: Select all

videoSetMode(MODE_4_2D);
vramSetBankA(VRAM_A_MAIN_BG);

"then for text"
consoleInit(0,0, BgType_Text4bpp, BgSize_T_256x256, 4,0, true, true);
printf("\x1b[1;1Hinsert text here");

"then for background"
int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 5,0);
dmaCopy(gridbgBitmap, bgGetGfxPtr(bg3), 256*256);
dmaCopy(gridbgPal, BG_PALETTE, 256*2);
here's the screenshot.
Image

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

Re: Background image & text on DS

Post by elhobbs » Tue Sep 04, 2012 4:00 pm

are you loading the console first? does the background look ok if you disable the console? if you are loading the console first and then loading the palette for the background (or not loading the console) and it still looks bad then there is a problem converting your graphic in your build process. Since you are loading the background and the console on the main display they are sharing a palette. so either move the console to the sub display or make sure your palette is console friendly - and make sure you load the background palette after the console.

t377y000
Posts: 52
Joined: Wed Jun 02, 2010 3:14 am
Location: United States

Re: Background image & text on DS

Post by t377y000 » Wed Sep 05, 2012 3:38 am

elhobbs wrote:are you loading the console first? does the background look ok if you disable the console? if you are loading the console first and then loading the palette for the background (or not loading the console) and it still looks bad then there is a problem converting your graphic in your build process. Since you are loading the background and the console on the main display they are sharing a palette. so either move the console to the sub display or make sure your palette is console friendly - and make sure you load the background palette after the console.

im loading the background image 1st, then the text.
& when i disable the console yes the background image shows normally.

just tried loading the text before console, the image seems to work now but now the text is black. i wanted to use colors in the text. "im using the "printf("\x1b[32;1m");" for color text.

this is how it looks when loading background before console text.
Image

this is how it looks when loading console text before background.
Image

t377y000
Posts: 52
Joined: Wed Jun 02, 2010 3:14 am
Location: United States

Re: Background image & text on DS

Post by t377y000 » Wed Sep 05, 2012 10:11 am

hey thanks i figured i out. turns out i needed to change the file size in the "dmacopy"

Code: Select all

videoSetMode(MODE_4_2D);
vramSetBankA(VRAM_A_MAIN_BG);

"then for text"
consoleInit(0,0, BgType_Text4bpp, BgSize_T_256x256, 4,0, true, true);
printf("\x1b[1;1Hinsert text here");

"then for background"
int bg = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 5,0);
dmaCopy(gridbgBitmap, bgGetGfxPtr(bg), 256*256);
dmaCopy(gridbgPal, BG_PALETTE, 128);
i also got it working on both screens. :D

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

Re: Background image & text on DS

Post by elhobbs » Wed Sep 05, 2012 2:03 pm

I was trying to point out that the console and the background share a palette. dmaCopy expects the size to be in bytes. by changing the palette load to 128 bytes you are limiting your background to images that are 64 colors or less. which in this case is fine. however, you will likely find (depending on the palette for your background) that all of the default 16 colors that the console provides for text are not what you expect. the console sets up the palette like so for 4 bit:

Code: Select all

			//set up the palette for color printing
			palette[1 * 16 - 1] = RGB15(0,0,0); //30 normal black
			palette[2 * 16 - 1] = RGB15(15,0,0); //31 normal red
			palette[3 * 16 - 1] = RGB15(0,15,0); //32 normal green
			palette[4 * 16 - 1] = RGB15(15,15,0); //33 normal yellow

			palette[5 * 16 - 1] = RGB15(0,0,15); //34 normal blue
			palette[6 * 16 - 1] = RGB15(15,0,15); //35 normal magenta
			palette[7 * 16 - 1] = RGB15(0,15,15); //36 normal cyan
			palette[8 * 16 - 1] = RGB15(24,24,24); //37 normal white

			palette[9 * 16 - 1 ] = RGB15(15,15,15); //40 bright black
			palette[10 * 16 - 1] = RGB15(31,0,0); //41 bright red
			palette[11 * 16 - 1] = RGB15(0,31,0); //42 bright green
			palette[12 * 16 - 1] = RGB15(31,31,0);	//43 bright yellow

			palette[13 * 16 - 1] = RGB15(0,0,31); //44 bright blue
			palette[14 * 16 - 1] = RGB15(31,0,31);	//45 bright magenta
			palette[15 * 16 - 1] = RGB15(0,31,31);	//46 bright cyan
			palette[16 * 16 - 1] = RGB15(31,31,31); //47 & 39 bright white
essentially it treats it as 16 4bit palettes with the last entry being the font color. as you can see there is ample opportunity for conflict.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests