Setting up VRAM banks

Post Reply
TiagoGomes
Posts: 5
Joined: Wed Feb 20, 2013 4:03 pm
Location: Brazil

Setting up VRAM banks

Post by TiagoGomes » Wed Feb 20, 2013 4:16 pm

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.

mtheall
Posts: 211
Joined: Thu Feb 03, 2011 10:47 pm

Re: Setting up VRAM banks

Post by mtheall » Mon Feb 25, 2013 4:10 pm


mtheall
Posts: 211
Joined: Thu Feb 03, 2011 10:47 pm

Re: Setting up VRAM banks

Post by mtheall » Mon Feb 25, 2013 4:14 pm

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.

TiagoGomes
Posts: 5
Joined: Wed Feb 20, 2013 4:03 pm
Location: Brazil

Re: Setting up VRAM banks

Post by TiagoGomes » Sat Mar 16, 2013 5:03 pm

I actually figured out what the problem was and the solution may be found on the following post.
Thanks for the help.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests