Here some code I'm currently using in my project:
I'm using VRAM_F and VRAM_G for Main BG Ext. palettes, VRAM_H for Sub BG Ext. palettes.
Video Modes are MODE_0_3D and MODE_0_2D (Main/Sub).
BG Ext. palettes enabled for both screens
VRAM Inits:
Code: Select all
// Setup VRAM
//vramSetBankA(VRAM_A_LCD); Used by NitroEngine
//vramSetBankB(VRAM_B_LCD); Used by NitroEngine
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
vramSetBankD(VRAM_D_MAIN_BG_0x06000000);
//vramSetBankE(VRAM_E_LCD); Used by NitroEngine
vramSetBankF(VRAM_F_BG_EXT_PALETTE_SLOT01);
vramSetBankG(VRAM_G_BG_EXT_PALETTE_SLOT23);
vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
vramSetBankI(VRAM_I_LCD);
Loading BGs:
Code: Select all
vramSetBankF(VRAM_F_LCD);
vramSetBankG(VRAM_G_LCD);
vramSetBankH(VRAM_H_LCD);
PictureBG1 = bgInit(1, BgType_Text8bpp, BgSize_T_256x256, 4,2);
dmaCopy(bg_splash_1b_Tiles, bgGetGfxPtr(PictureBG1), sizeof(bg_splash_1b_Tiles));
dmaCopy(bg_splash_1b_Map, bgGetMapPtr(PictureBG1), sizeof(bg_splash_1b_Map));
dmaCopy(bg_splash_1b_Pal, (u16*)(VRAM_F + (1 << 12) + (0 << 8)), sizeof(bg_splash_1b_Pal));
PictureBG1Sub = bgInitSub(1, BgType_Text8bpp, BgSize_T_256x256, 4,2);
dmaCopy(bg_splash_1t_Tiles, bgGetGfxPtr(PictureBG1Sub), sizeof(bg_splash_1t_Tiles));
dmaCopy(bg_splash_1t_Map, bgGetMapPtr(PictureBG1Sub), sizeof(bg_splash_1t_Map));
dmaCopy(bg_splash_1t_Pal, (u16*)(VRAM_H + (1 << 12) + (0 << 8)), sizeof(bg_splash_1t_Pal));
PictureBG2 = bgInit(2, BgType_Text8bpp, BgSize_T_256x256, 5,4);
dmaCopy(bg_splash_2b_Tiles, bgGetGfxPtr(PictureBG2), sizeof(bg_splash_2b_Tiles));
dmaCopy(bg_splash_2b_Map, bgGetMapPtr(PictureBG2), sizeof(bg_splash_2b_Map));
dmaCopy(bg_splash_2b_Pal, (u16*)(VRAM_F + (2 << 12) + (0 << 8)), sizeof(bg_splash_2b_Pal));
PictureBG2Sub = bgInitSub(2, BgType_Text8bpp, BgSize_T_256x256, 5,4);
dmaCopy(bg_supaplex_Tiles, bgGetGfxPtr(PictureBG2Sub), sizeof(bg_supaplex_Tiles));
dmaCopy(bg_supaplex_Map, bgGetMapPtr(PictureBG2Sub), sizeof(bg_supaplex_Map));
dmaCopy(bg_supaplex_Pal, (u16*)(VRAM_H + (2 << 12) + (0 << 8)), sizeof(bg_supaplex_Pal));
vramSetBankF(VRAM_F_BG_EXT_PALETTE_SLOT01);
vramSetBankG(VRAM_G_BG_EXT_PALETTE_SLOT23);
vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
All BGs were converted using PAGfx as "TileBg" and are 256x256 pixels^2 large.
In case of Main BG2, the palette actually is stored in VRAM_G, but VRAM_F still is the base address.
It also didn't work for me until I used
Code: Select all
VRAM_F_BG_EXT_PALETTE_SLOT01
VRAM_G_BG_EXT_PALETTE_SLOT23
instead of just
Code: Select all
VRAM_F_BG_EXT_PALETTE
VRAM_G_BG_EXT_PALETTE