Bitmps and Text

Post Reply
conutmonky
Posts: 3
Joined: Tue Apr 07, 2009 10:10 am

Bitmps and Text

Post by conutmonky » Tue Apr 07, 2009 10:20 am

Hello,

I am trying to display bitmap images on a background, and then some text on top of it. Right now the two images are displayed fine. I am configuring my background using the registers and not the BgInit functions, and so when looking at using the consoleInit and PrintConsole features they aren't working. Is there a way to display text while leaving my background init like this rather then using BgInit? I need a lower level way of printing I think, and to configure which screen to print to and where. Any help would be great.

lcdMainOnBottom();

vramSetBankA(VRAM_A_MAIN_BG);
vramSetBankC(VRAM_C_SUB_BG);

videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE);
videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);

REG_BG2CNT = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_PRIORITY(3);

REG_BG2PA = 1 << 8;
REG_BG2PB = 0;
REG_BG2PC = 0;
REG_BG2PD = 1 << 8;

REG_BG3CNT_SUB = BG_BMP16_256x256 | BG_BMP_BASE(0);

REG_BG3PA_SUB = 1<< 8;
REG_BG3PB_SUB = 0;
REG_BG3PC_SUB = 0;
REG_BG3PD_SUB = 1 << 8;

dmaCopyHalfWords(DMA_CHANNEL, fleurBitmap, (uint16 *)BG_BMP_RAM(0), fleurBitmapLen);
dmaCopyHalfWords(DMA_CHANNEL, mikeBitmap, (uint16 *)BG_BMP_RAM_SUB(0), mikeBitmapLen);

iprintf("Hello World");


Thanks in advance,
Mike

Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

Re: Bitmps and Text

Post by Sylus101 » Tue Apr 07, 2009 9:44 pm

Well, you should still be able to get it to work with consoleInit. The parameters for the function will let you specify your offset, but there is a bit of an issue with what you have to start with.

Are the backgrounds you're copying in both full size, 256 x 256, or are they to be stationary and just 256 x 192?

If they're 256 x 256 then you will not be able to display any background text with this memory configuration. The background would take up the entire 128K in each VRAM Bank.

If they're 256 x 192, then you have 32k free in each bank. What I recommend, is to initialize the console with a mapbase of 0 and charbase of 1 for whichever screen you want the text on, layer 0 most likely. Then set a BG_BMP_BASE(2); for the 16 bit bg, and write to (uint16 *)BG_BMP_RAM(2) or (uint16*)BG_BMP_RAM_SUB(2) depending on screen.

I'm doing something similar with 2 8 bit backgrounds and 1 printConsole for my Sub Engine and it works nicely so this should be fine. Here's your code very slightly modified if you were putting the text bg on the sub engine (top screen I suppose in your case):

Code: Select all

lcdMainOnBottom();

vramSetBankA(VRAM_A_MAIN_BG);
vramSetBankC(VRAM_C_SUB_BG);

videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE);
videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);

REG_BG2CNT = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_PRIORITY(3);

REG_BG2PA = 1 << 8;
REG_BG2PB = 0;
REG_BG2PC = 0;
REG_BG2PD = 1 << 8;

REG_BG3CNT_SUB = BG_BMP16_256x256 | BG_BMP_BASE(2);

REG_BG3PA_SUB = 1<< 8;
REG_BG3PB_SUB = 0;
REG_BG3PC_SUB = 0;
REG_BG3PD_SUB = 1 << 8;

dmaCopyHalfWords(DMA_CHANNEL, fleurBitmap, (uint16 *)BG_BMP_RAM(0), fleurBitmapLen);
dmaCopyHalfWords(DMA_CHANNEL, mikeBitmap, (uint16 *)BG_BMP_RAM_SUB(2), mikeBitmapLen);

PrintConsole bottomScreen = *consoleInit(0, 0, BgType_Text4bpp, BgSize_T_256x256, 0, 1, false, true);

iprintf("Hello World");
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

Prometheus
Posts: 2
Joined: Mon Jul 12, 2010 2:44 am

Re: Bitmps and Text

Post by Prometheus » Mon Jul 12, 2010 7:28 am

What I recommend, is to initialize the console with a mapbase of 0 and charbase of 1 for whichever screen you want the text on, layer 0 most likely. Then set a BG_BMP_BASE(2); for the 16 bit bg, and write to (uint16 *)BG_BMP_RAM(2) or (uint16*)BG_BMP_RAM_SUB(2) depending on screen.
Can you explain in a little bit more in depth why you decided to start the console with a mapbase of 0 and charbase of 1 and why we have to set BG_BMP_BASE to 2?

Thanks in advance.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest