开发者

How would one draw to the sub display of a ds as if it was a framebuffer?

I need to draw raw pixel data to the Nintendo DS's "sub" screen, such as if I was drawing to the main sc开发者_Python百科reen in "framebuffer" mode or "Extended Rotation" mode. How can I do this with the current version of libnds (which seems to place restrictions on the use of VRAM_C)?


#include <nds.h>

int main(void) 
{
int x, y;

//set the mode to allow for an extended rotation background
videoSetMode(MODE_5_2D);
videoSetModeSub(MODE_5_2D);

//allocate a vram bank for each display
vramSetBankA(VRAM_A_MAIN_BG);
vramSetBankC(VRAM_C_SUB_BG);

//create a background on each display
int bgMain = bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0,0);
int bgSub = bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 0,0);

u16* videoMemoryMain = bgGetGfxPtr(bgMain);
u16* videoMemorySub = bgGetGfxPtr(bgSub);


//initialize it with a color
for(x = 0; x < 256; x++)
    for(y = 0; y < 256; y++)
    {
        videoMemoryMain[x + y * 256] = ARGB16(1, 31, 0, 0);
        videoMemorySub[x + y * 256] = ARGB16(1, 0, 0, 31);
    }

while(1) 
{
    swiWaitForVBlank();
}

}

Here is a simple example which creates a 16 bit frame buffer on the main and sub screens and fills each with either red or blue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜