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 > Mapping Vram H to sub BG...

#174836 - relminator - Fri Jul 23, 2010 8:02 am

Sorry for double posting as my net time is kind of limited these days.

Video.h
Code:
typedef enum {
   VRAM_H_LCD                = 0,
   VRAM_H_SUB_BG             = 1,
   VRAM_H_SUB_BG_EXT_PALETTE = 2,
} VRAM_H_TYPE;


256 * 192 = 48kb

Code:
Bank H                       0x06898000          0x0689FFFF          32KB 
Bank I                       0x068A0000          0x068A3FFF          16KB


Bank H is just 32 KB. Does it mean that bank I gets mapped to sub BG also?

I wanna map this as LCD since I want to do some per pixel stuff on the sub screen.


Also when I call:

Code:
gluTexLoadPal();


Is the pallete loaded in vram bank E?


So far this is how I've been using the VRAM.

A = filled by two gltextures at 64 kb each so all of 128 kb is filled.

B = Some textures but still have a lot left.

C = Not used yet (only by consoledemoInit())

D = VRAM_D_SUB_SPRITE (But still lots of stuff free)

E = Unused but I'm not sure if glpalette uses it.

F, G, H, I = not used.

Thanks!
_________________
http://rel.betterwebber.com

#174839 - elhobbs - Fri Jul 23, 2010 2:49 pm

I use H and I for a 256x192 8bit subscreen
Code:

vramSetBankH(VRAM_H_SUB_BG); 
vramSetBankI(VRAM_I_SUB_BG_0x06208000);
since it does not have enough memory for 256x256 weird things happen if you try to use background scrolling.

libnds is hardcoded to use E for palettes. I moved palettes to F but I had to build custom palette loading code - really just copied the libnds code and switched it to F.

this is the layout that I use for cquake
Code:

vramSetMainBanks(VRAM_A_TEXTURE, VRAM_B_TEXTURE, VRAM_C_TEXTURE, VRAM_D_TEXTURE);
vramSetBankE(VRAM_E_MAIN_BG);
vramSetBankF(VRAM_F_TEX_PALETTE);
vramSetBankG(VRAM_G_MAIN_BG_0x06010000);
vramSetBankH(VRAM_H_SUB_BG);
vramSetBankI(VRAM_I_SUB_BG_0x06208000);

videoSetModeSub(MODE_5_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG2_ACTIVE);
ds_bg_sub = bgInitSub(2,BgType_Bmp8,BgSize_B8_256x256,0,0);

videoSetMode(MODE_3_3D | DISPLAY_BG1_ACTIVE | DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE);
consoleInit(0,1, BgType_Text4bpp, BgSize_T_256x256, 14,0, true,true);
BG_PALETTE[0]=0;         
BG_PALETTE[255]=0xffff;

ds_bg_text = bgInit(2,BgType_Text4bpp,BgSize_T_256x256,15,0);
ds_bg_main = bgInit(3,BgType_Bmp8,BgSize_B8_256x256,2,0);
 


A-D = textures
E & G = main bg 256x192 8bit ,1 console plus an additional text layer
F = palettes
H & I = sub bg 256x192 8bit

#174840 - relminator - Fri Jul 23, 2010 3:15 pm

Thanks dude!!! I'm not gonna scroll the sub BG so all is well.

BTW, what does it mean when you do this?

Code:
vramSetBankH(VRAM_H_SUB_BG);
vramSetBankI(VRAM_I_SUB_BG_0x06208000);

_________________
http://rel.betterwebber.com

#174842 - DiscoStew - Fri Jul 23, 2010 4:39 pm

relminator wrote:
Thanks dude!!! I'm not gonna scroll the sub BG so all is well.

BTW, what does it mean when you do this?

Code:
vramSetBankH(VRAM_H_SUB_BG);
vramSetBankI(VRAM_I_SUB_BG_0x06208000);


http://nocash.emubase.de/gbatek.htm#dsmemorycontrolvram

It just assigns the bank to a specific function and/or address for operation. VRAM H gets set to BG usage with an address at 06200000h, and VRAM I gets set to BG usage with an address at 0x6208000h, which is right after the 32KB section designated with VRAM H. VRAM I is incapable of being assigned at any other area for Sub BGs, so for programmer understandability, the address was included in the #define.
_________________
DS - It's all about DiscoStew

#174843 - elhobbs - Fri Jul 23, 2010 6:05 pm

relminator wrote:
Thanks dude!!! I'm not gonna scroll the sub BG so all is well.

BTW, what does it mean when you do this?

Code:
vramSetBankH(VRAM_H_SUB_BG);
vramSetBankI(VRAM_I_SUB_BG_0x06208000);
it maps a continuous 48k for the sub screen background - which is enough to use a 256x192 8bit background.

the sub background starts at 0x06200000. bank H is 32k or 0x8000 in hex. this maps I right after H.

#174846 - relminator - Sat Jul 24, 2010 1:14 am

Thanks guys.
_________________
http://rel.betterwebber.com