Page 1 of 1

Setting up VRAM banks

Posted: Wed Feb 20, 2013 4:16 pm
by TiagoGomes
I've been working on a project for Nintendo DS but I'm stuck trying to setup the VRAM.
This is the code I use to setup video:

Code: Select all

  System::System( void )
  {
    videoSetMode   ( MODE_5_2D );
    videoSetModeSub( MODE_5_2D );

    vramSetBankA( VRAM_A_MAIN_BG );
    vramSetBankC( VRAM_C_SUB_BG  );

    consoleInit( NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 4, 0, true, true );
    
    bgIndex = bgInit( 3, BgType_Bmp16, BgSize_B16_256x256, 5, 0 );
    this->mainScreen.setFrameBuffer( ( u16 * ) bgGetGfxPtr( bgIndex ) );
    
    bgIndex = bgInitSub( 3, BgType_Bmp16, BgSize_B16_256x256, 0, 0 );
    this->subScreen.setFrameBuffer( ( u16 * ) bgGetGfxPtr( bgIndex ) );
  }
The basic idea is having a frame buffer for each screen and have console text being output to the main screen.

My main problem is that I can't figure out how to properly map the memory, which leads to graphic artifacts on the console whenever I try to draw on the screen and print text. From what I searched on the forum, it's probably caused by shared VRAM memory.

I'd appreciate if anyone could help me with this problem and give me some insight on proper VRAM mapping in general.

Re: Setting up VRAM banks

Posted: Mon Feb 25, 2013 4:10 pm
by mtheall

Re: Setting up VRAM banks

Posted: Mon Feb 25, 2013 4:14 pm
by mtheall
These are the settings you have, and these are probably the settings you want. In the first, you are going over the 128KB boundary, so this won't work unless you have VRAM_A and VRAM_B set to MAIN_BG.

Notice how the map base for bitmap backgrounds is an offset into VRAM in 16KB chunks. The map base for tiled backgrounds is offset by 2KB chunks. Also note that the console uses 128 tiles.

Re: Setting up VRAM banks

Posted: Sat Mar 16, 2013 5:03 pm
by TiagoGomes
I actually figured out what the problem was and the solution may be found on the following post.
Thanks for the help.