gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > BackGround Question [Resolved]

#162453 - crazycrow - Wed Sep 03, 2008 9:05 am

Hi,
I try to draw something on the BG3 (a shape) , and on the BG2 I have a image display.

I init the screen like that
Code:


vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_LCD,VRAM_C_SUB_BG , VRAM_D_LCD);


 videoSetModeSub( MODE_5_2D | DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE);
    SUB_BG2_CR = BG_BMP8_256x256 | BG_PRIORITY_3 | BG_BMP_BASE(0);
    SUB_BG2_XDX = 256;
    SUB_BG2_XDY = 0;
    SUB_BG2_YDX = 0;
    SUB_BG2_YDY = 256;
    SUB_BG2_CX = 0;
    SUB_BG2_CY = 0;



    SUB_BG3_CR = BG_BMP16_256x256 | BG_PRIORITY_0 | BG_BMP_BASE(4);
    SUB_BG3_XDX = 256;
    SUB_BG3_XDY = 0;
    SUB_BG3_YDX = 0;
    SUB_BG3_YDY = 256;
    SUB_BG3_CX = 0;
    SUB_BG3_CY = 0;


I use BG_BMP_RAM_SUB(0) and BG_BMP_RAM_SUB(4) to draw in.

The probleme is that the shape is not draw, but the image is draw.
With Dualis, I can see in the memory, the BG2 contain the image, and the BG3 , the shape.

Where I have Wrong ?


Last edited by crazycrow on Wed Sep 03, 2008 3:00 pm; edited 1 time in total

#162455 - jimis - Wed Sep 03, 2008 9:52 am

There is a problem with the priorities
More specificaly:
Replace this SUB_BG2_CR = BG_BMP8_256x256 | BG_PRIORITY_3 | BG_BMP_BASE(0);
with SUB_BG2_CR = BG_BMP8_256x256 | BG_PRIORITY_0 | BG_BMP_BASE(0);
and this SUB_BG3_CR = BG_BMP16_256x256 | BG_PRIORITY_0 | BG_BMP_BASE(4);
with this SUB_BG3_CR = BG_BMP16_256x256 | BG_PRIORITY_1 | BG_BMP_BASE(4);

#162458 - crazycrow - Wed Sep 03, 2008 10:22 am

I try it , but doesn't work.

If I have understand, the BG with priority 0 is in front of the BG with priority 1.

I want my bg3 is front of the BG2.

If I keep the priority order, and un put the BG3 in BG_BMP8_256x256, it display something, but not in 16bit, it use the palette of the BG2.

#162461 - crazycrow - Wed Sep 03, 2008 2:59 pm

I have found the problem, I have forgot the transparency of the shape.

It work now.

#162481 - Cydrak - Wed Sep 03, 2008 9:45 pm

Have you run on hardware yet? Bank C is only 128K, which is too small, so the shape may wrap around and clobber your image. You need at least 48K + 96K = 144K for these 256x192 bitmaps.

(Actually you need more--64K + 128K--if the whole 256x256 are shown; if not, then it's okay to re-use the excess, by changing the BMP_BASE(4) to BMP_BASE(3) for example. However, this still won't give you enough room.)

I don't know about Dualis, but be careful: emulators tend to be more lenient.

#162522 - crazycrow - Thu Sep 04, 2008 10:08 am

I use an Image 256x192 , and a shape 50x50 on the top left, for training in DS Dev.

But I haven't actually how the VRAM_X work.

Do you have a tuto or some exemple of each VRAM when vramSetMainBanks is called ?

If I have understand,

VRAM_A_MAIN_BG is active, BG_BMP_BASE(0) = VRAM_A, for the top screen