【问题标题】:How would one draw to the sub display of a ds as if it was a framebuffer?将如何绘制到 ds 的子显示,就好像它是一个帧缓冲区一样?
【发布时间】:2011-09-24 01:46:56
【问题描述】:

我需要在 Nintendo DS 的“子”屏幕上绘制原始像素数据,例如在“帧缓冲区”模式或“扩展旋转”模式下绘制到主屏幕。如何使用当前版本的 libnds 执行此操作(这似乎限制了 VRAM_C 的使用)?

【问题讨论】:

    标签: c nintendo-ds libnds devkitpro


    【解决方案1】:
    #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();
    }
    
    }
    

    这是一个简单的示例,它在主屏幕和子屏幕上创建一个 16 位帧缓冲区,并用红色或蓝色填充每个缓冲区。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-10
      • 1970-01-01
      • 2011-08-31
      • 1970-01-01
      • 1970-01-01
      • 2019-09-27
      • 1970-01-01
      相关资源
      最近更新 更多