Backgrounds and VRAM layout

Post Reply
Derrik
Posts: 63
Joined: Wed Aug 14, 2013 8:28 pm

Backgrounds and VRAM layout

Post by Derrik » Mon Aug 25, 2014 7:14 pm

I want to have 4 layers of `BgType_Text8bpp` backgrounds on both screens, with extended palettes, each with their own map and tile space in VRAM.

Somehow PAlib managed to do this, but since I've been using libnds, I have not been able to achieve the same thing.

Here is the VRAM configuration I am attempting to use:

http://mtheall.com/vram.html#T0=1&NT0=5 ... TB3=6&S3=0
Mode 0 will support your options.
Works for Main Engine or Sub Engine.

Background 0: Using 32KB for gfx and 2KB for map.
Background 1: Using 24KB for gfx and 2KB for map.
Background 2: Using 32KB for gfx and 2KB for map.
Background 3: Using 32KB for gfx and 2KB for map.
As you can see there is space for all backgrounds and no conflicts, so I wrote this function to initialise graphics:

Code: Select all

videoSetMode(MODE_0_2D);
videoSetModeSub(MODE_0_2D);

vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
vramSetBankB(VRAM_B_MAIN_SPRITE_0x06400000);
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
vramSetBankD(VRAM_D_SUB_SPRITE);
vramSetBankE(VRAM_E_BG_EXT_PALETTE);
vramSetBankF(VRAM_F_SPRITE_EXT_PALETTE);
vramSetBankG(VRAM_G_LCD);
vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
vramSetBankI(VRAM_I_SUB_SPRITE_EXT_PALETTE);

bgExtPaletteEnable();
bgExtPaletteEnableSub();

oamInit(&oamMain, SpriteMapping_1D_128, true);
oamInit(&oamSub, SpriteMapping_1D_128, true);
And this function to init a background layer:

Code: Select all

int init8bitText(u8 screen, int layer) {
	if(screen == 1) return bgInit(layer, BgType_Text8bpp, BgSize_B16_256x256, layer + 28, layer * 2);
	else return bgInitSub(layer, BgType_Text8bpp, BgSize_B16_256x256, layer + 28, layer * 2);
}
The tile base and map base are the same as in the VRAM config tool.

However, even though the tool says that there are no conflicts: when I try to load a background on the sub engine on layer 3, I get corrupted graphics.

Here is a simplified test program that attempts to load backgrounds on all layers of both screens for you to play with:

http://filetrip.net/dl?acx8azBO5O

I can't understand why I can't load a background on layer 3 of the bottom screen with this setup.

sverx
Posts: 94
Joined: Wed Aug 12, 2009 2:56 pm
Location: github.com/sverx
Contact:

Re: Backgrounds and VRAM layout

Post by sverx » Tue Aug 26, 2014 12:28 pm

Try with BgSize_T_256x256 instead of BgSize_B16_256x256

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests