How to draw backgrounds in sub screen

Post Reply
happyspider
Posts: 1
Joined: Wed Mar 23, 2011 12:18 am

How to draw backgrounds in sub screen

Post by happyspider » Wed Mar 23, 2011 12:29 am

I am an absolute beginner programming libnds.

How can I draw a picture on the subscreen?

Here is my code so far. It only shows a picture on the top screen.

Code: Select all

#include <nds.h>
#include <stdio.h>
#include "drunkenlogo.h"
#include "hey_typ.h"

int main(void)
{
    // set the mode for 2 text layers and two extended background layers
	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;
}

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

Re: How to draw backgrounds in sub screen

Post by mtheall » Fri Mar 25, 2011 9:54 pm

You have to do the same thing you did with the top screen, but with bgInitSub. Also, the palette address will be BG_PALETTE_SUB.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests