在nds的子屏幕上绘制图像
我对 libdns 完全陌生。我尝试更改示例 Graphics\Backgrounds\256_color_bmp 在子屏幕上显示背景。
这是我的代码。您知道在子屏幕上显示 hey_typBitmap 缺少什么吗?我已经设法在顶部屏幕上显示新图像。
#include <nds.h>
#include <stdio.h>
#include "drunkenlogo.h"
#include "hey_typ.h"
int main(void)
{
videoSetMode(MODE_5_2D);
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
videoSetModeSub(MODE_5_2D);
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);
dmaCopy(hey_typBitmap, bgGetGfxPtr(bg3), 256*256);
dmaCopy(hey_typPal, BG_PALETTE, 256*2);
int bg2 = bgInit(2, BgType_Bmp8, BgSize_B8_256x256, 0,0);
dmaCopy(drunkenlogoBitmap, bgGetGfxPtr(bg2), 256*256);
dmaCopy(drunkenlogoPal, BG_PALETTE, 256*2);
while(1)swiWaitForVBlank();
return 0;
}
I am totally new to libdns. I try to change the sample Graphics\Backgrounds\256_color_bmp
to display the background on the subscreen.
Here is my code. Do you have any idea what is missing to display hey_typBitmap on the subscreen? I already managed to display the new image on the top screen.
#include <nds.h>
#include <stdio.h>
#include "drunkenlogo.h"
#include "hey_typ.h"
int main(void)
{
videoSetMode(MODE_5_2D);
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
videoSetModeSub(MODE_5_2D);
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);
dmaCopy(hey_typBitmap, bgGetGfxPtr(bg3), 256*256);
dmaCopy(hey_typPal, BG_PALETTE, 256*2);
int bg2 = bgInit(2, BgType_Bmp8, BgSize_B8_256x256, 0,0);
dmaCopy(drunkenlogoBitmap, bgGetGfxPtr(bg2), 256*256);
dmaCopy(drunkenlogoPal, BG_PALETTE, 256*2);
while(1)swiWaitForVBlank();
return 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在模式5下,DS有3个可用的背景层,并调用
bgInit with 2 返回对同一屏幕上不同层的引用。如果您想在子屏幕上使用图层,请使用
bgInitSub
。还有 2 个调色板;一个在主屏幕上,另一个在子屏幕上。子屏幕调色板位于
BG_PALETTE_SUB
。希望这段代码能够在第二个屏幕上显示图像(用
/* ! */
标记的更改):In mode 5 the DS has 3 background layers available, and calling
bgInit
with 2 returns a reference to a different layer on the same screen. If you want to use a layer on the sub-screen, usebgInitSub
.There are 2 palettes too; one on the main screen and a different one on the sub-screen. The sub-screen palette is at
BG_PALETTE_SUB
.Hopefully this code will show the image on the second screen (changes marked with
/* ! */
):