Bginit using registers

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

Bginit using registers

Post by conutmonky » Thu May 14, 2009 9:12 am

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

User avatar
vuurrobin
Posts: 219
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: Bginit using registers

Post by vuurrobin » Thu May 14, 2009 10:32 am

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.

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

Re: Bginit using registers

Post by conutmonky » Fri May 15, 2009 1:36 am

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

User avatar
vuurrobin
Posts: 219
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: Bginit using registers

Post by vuurrobin » Fri May 15, 2009 8:03 am

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

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests