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 > RAMBANKS AGAIN

#71826 - Payk - Tue Feb 14, 2006 7:08 pm

u16* frontBuffer = (u16*)(0x06000000);
will point to a vrambank which is opened like:
VRAM_D_MAIN_BG_0x6000000

ok so how can i make a buffer for both screens (each of them with own buffer)

beacause VRAM_D_SUB_BG_0x6000000
will just bring an error. hmhmh... is there no way to map it to sub_screen for framebuffering ?

THANX

#71834 - realstar - Tue Feb 14, 2006 7:49 pm

I think something like this should work but I use
extended rotation backgrounds so I am not sure.

// Setup a framebuffer for MAIN
videoSetMode(MODE_FB0);

// Map vramA as MAIN
vramSetBankA(VRAM_A_MAIN_BG_0x6000000);

// Setup a framebuffer for SUB
videoSetModeSub(MODE_FB0);

// Map vramC as SUB
vramSetBankC(VRAM_C_SUB_BG);

// pointers to buffers
u16* frontBuffer = (u16*) BG_GFX; // 0x6000000
u16* frontBuffer2 = (u16*) BG_GFX_SUB; // 0x6200000

You can find a good description of the modes
available and vram mapping here:
http://tobw.net/dswiki/index.php?title=Graphic_modes

#71840 - Payk - Tue Feb 14, 2006 8:49 pm

Code:
 
u16* frontBuffer = (u16*) BG_GFX;// 0x6000000
u16* frontBuffer2 = (u16*) BG_GFX_SUB; // 0x6200000

    vramSetMainBanks(   VRAM_A_MAIN_SPRITE,        //A and B maped consecutivly as sprite memory
                        VRAM_B_MAIN_SPRITE,        //this gives us 256KB which is the max
                        VRAM_C_SUB_BG,     //map C to bg for touchscreen
                        VRAM_D_MAIN_BG_0x6000000); //map D to background memory

 
  //Window screen
   videoSetMode(  MODE_3_2D |
                   DISPLAY_SPR_ACTIVE |    //turn on sprites
                   DISPLAY_SPR_2D |        //this is used when in tile mode
                   DISPLAY_SPR_1D_BMP |    //and this in bitmap mode
                   DISPLAY_BG3_ACTIVE);
    BG3_CR = BG_BMP16_256x256;
    BG3_XDX = 1 << 8;
    BG3_XDY = 0;
    BG3_YDX = 0;
    BG3_YDY = 1 << 8;
    BG3_CX = 0;
    BG3_CY = 0;
       for(int iy = 0; iy < 196 ; iy++)
            for(int ix = 0; ix < 256 ; ix++)
                frontBuffer[iy * 256 + ix] = bg1[iy * 256 + ix] | BIT(15);

  //Touchscreen
    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);
   SUB_BG0_CR = BG_BMP16_256x256;
               
       for(int iy = 0; iy < 196 ; iy++)
            for(int ix = 0; ix < 256 ; ix++)
                frontBuffer2[iy * 256 + ix] = bg1[iy * 256 + ix] | BIT(15);


ok i dont needed framerbuffer. i set up all like that. there comes a LCDSWAP() later. so touchscreen is here the top screen in reality. but doesnt matter. on touchscreen (here is it topscreen) gives just whitescreen and other screen with sprites runs fine. so Why SUB_BG0 is not visible (and note i use same picture for both screens (just for now) so its not because of pic)
THANX (and i read the artcicle and tryed out...)

#71843 - Payk - Tue Feb 14, 2006 9:05 pm

Forget it i set up correctly now thanx anyway that link is QL