Setting up VRAM banks
Posted: 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:
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.
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 ) );
}
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.