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 > text backgrounds using vram banks e+

#119512 - VRMLGHOST - Fri Feb 23, 2007 10:20 pm

I'm curious if its possible to use E&F for 2 main text backgrounds, and H&I for sub text backgrounds.
My understandings of the background control registers suggests their are 5 bits(32) for addressing into maps and 4 bits(16) for addressing into tiles. and guess therefore that they have to come first before any bitmap(ERBs) backgrounds.

can anyone explain this?

Also in the following code, ive specified VRAM_A_MAIN_BG_0x6060000, does that then mean that BG_BMP_BASE(8) would then point to bank E ?

Code:

videoSetMode(   MODE_5_2D |
   DISPLAY_BG0_ACTIVE |
   DISPLAY_BG1_ACTIVE |
   DISPLAY_BG2_ACTIVE |
   DISPLAY_SPR_ACTIVE|
   DISPLAY_SPR_1D_LAYOUT);   

   vramSetBankA( VRAM_A_MAIN_BG_0x6060000 );
   vramSetBankB( VRAM_B_MAIN_SPRITE );
   vramSetBankE( VRAM_E_MAIN_BG );
   vramSetBankF( VRAM_F_MAIN_BG );


[/code]

#119513 - GPFerror - Fri Feb 23, 2007 10:24 pm

here is how i use H&I for text for my libSDL port

Code:
    powerON(POWER_ALL);
   irqInit();
   irqSet(IRQ_VBLANK, on_irq_vblank);
   irqEnable(IRQ_VBLANK);
videoSetMode(MODE_6_2D| DISPLAY_BG2_ACTIVE);
videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);
vramSetMainBanks(VRAM_A_MAIN_BG,VRAM_B_MAIN_BG,VRAM_C_MAIN_BG,VRAM_D_MAIN_BG);
   vramSetBankH(VRAM_H_SUB_BG);
   vramSetBankI(VRAM_I_LCD);
    SUB_BG0_CR = BG_MAP_BASE(8);
BG_PALETTE_SUB[255] = RGB15(31,31,31);
consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(8), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
      BG2_CR = BG_BMP8_1024x512;
        BG2_XDX = ((width / 256) << 8) | (width % 256) ;
        BG2_XDY = 0;
        BG2_YDX = 0;
        BG2_YDY = ((height / 192) << 8) | ((height % 192) + (height % 192) / 3) ;


Probably way overkill for what you need, but maybe helpfull.

Troy(GPF)

#119532 - VRMLGHOST - Sat Feb 24, 2007 1:04 am

cheers GPFerror :D. But .......
I should probably have highlighted that I want an extended background, sprites and tiles on both main and sub screen (I only included half the code - my bad).

So I'm trying to use the later banks for the text background. But im not sure if i can in this case, and either way how to manage it. I think I may be a little confused exactly how the vram ties into the bg control registers. [I could get away without doing this in my current game, however it will help get a better understanding of whats actually going on]