Page 1 of 1

Bginit using registers

Posted: Thu May 14, 2009 9:12 am
by conutmonky
Hello again,

I'm trying to understand exactly what bgInit does and so i'm recreating the init using the registers. However it isn't quite working. What does work:

int bg1 = bgInit(3, BgType_ExRotation, BgSize_ER_256x256, 0,1);

dmaCopy(mikeTiles, bgGetGfxPtr(bg1), mikeTilesLen);
dmaCopy(mikePal, BG_PALETTE, mikePalLen);
dmaCopy(mikeMap, bgGetMapPtr(bg1), mikeMapLen);

What doesn't work:

videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
vramSetBankA(VRAM_A_MAIN_BG);
REG_BG3CNT = BG_MAP_BASE(0) | BG_TILE_BASE(1) | BG_COLOR_256 | BG_PRIORITY(2);

REG_BG3PA = 1 << 8;
REG_BG3PB = 0;
REG_BG3PC = 0;
REG_BG3PD = 1 << 8;

dmaCopy(mikeTiles, BG_TILE_RAM(1), mikeTilesLen);
dmaCopy(mikePal, BG_PALETTE, mikePalLen);
dmaCopy(mikeMap, BG_MAP_BASE(0), mikeMapLen);

Now my problem (i believe) is that i'm not sure how to specify using the registers the size and type of my background, mainly the 256x256 and text type. But when I look at the registry options, none of them are what I expect (i.e. BG_RS_16x16, etc. since I am using text tiles at 8x8) and i don't know what it defaults to.

My grit:
# Set the warning/log level to 3
-W3

# Tile image
-gt

#Include map
-m

#8 bit
-gB8

Thanks for any help,
Mike

Re: Bginit using registers

Posted: Thu May 14, 2009 10:32 am
by vuurrobin
if you look here, you see that background 3 is an extended rotation background in mode 5. it is already determent in hardware, so you don't have to specify it.

as for the size, I think you need to include BG_BMP8_256x256 when initialising REG_BG3CNT.

Re: Bginit using registers

Posted: Fri May 15, 2009 1:36 am
by conutmonky
Thanks for the reply. So if I want a text background 256x256 I can still use the BMP8 definition? There isn't a hidden BG_TEXT_256x256 enum or anything like that?

Thanks,
Mike

Re: Bginit using registers

Posted: Fri May 15, 2009 8:03 am
by vuurrobin
sorry, you need to use BG_32x32 to specefy that you want to use a text background with 32*32 tiles (= 256*256 pixels) and BG_COLOR_256 for a 256 color text background.

if you look here, you can see al the different enums:
http://libnds.devkitpro.org/a00108.html ... 2ea5e90460