Keyboard and background

Post Reply
Leon
Posts: 3
Joined: Thu Mar 15, 2012 3:35 pm

Keyboard and background

Post by Leon » Thu Mar 15, 2012 4:05 pm

Not being able to find much info about the onscreen keyboard, I have some questions:

I'm trying to get a keyboard on top of a background image. Not sure if this is possible at all with the default keyboard. Can anyone point me to a good example/tutorial on how to use the keyboard in combination with backgrounds (either the default keyboard or a custom one)?

As a shortcut, after having used the keyboard with

Code: Select all

   consoleDemoInit();
	keyboardDemoInit();
	keyboardShow();
is there a way to reset (or re-init) the bottom screen so I can use

Code: Select all

	videoSetModeSub(MODE_5_2D);
	vramSetBankC(VRAM_C_SUB_BG_0x06200000);

	int bg3sub = bgInitSub(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);		
	
   dmaCopy(mysubimg1Bitmap, bgGetGfxPtr(bg3sub), 256*256);
	dmaCopy(mysubimg1Pal, BG_PALETTE_SUB, 256*2);	
after having used the keyboard.

Both pieces of code separate work fine but not in the same app.... Reusing consoleDemoInit(); doesn't do the trick.
I'm sure it's my perception of the statements that causes the problem here. I still haven't quite figured out how the videomemory of the DS works.

Thanks for your time.

WinterMute
Site Admin
Posts: 1845
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Keyboard and background

Post by WinterMute » Sat Mar 17, 2012 1:48 am

Should just be a matter of clearing BG3 when you display keyboard again I think, something like this :-

Code: Select all

#include <nds.h>

#include "mysubimg1.h"

int bg3sub;

void displayBitmap() {
	videoSetModeSub(MODE_5_2D);
	vramSetBankC(VRAM_C_SUB_BG_0x06200000);

	bg3sub = bgInitSub(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);      
   
	dmaCopy(mysubimg1Bitmap, bgGetGfxPtr(bg3sub), 256*256);
	dmaCopy(mysubimg1Pal, BG_PALETTE_SUB, 256*2);
}

void displayKeyboard() {
	consoleDemoInit();
	keyboardDemoInit();
	keyboardShow();
}

int showkeys = 0;

//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------

	displayKeyboard();
	while(1) {
		swiWaitForVBlank();
		scanKeys();
		if(keysDown()&KEY_START){
			showkeys = !showkeys;
			if(showkeys) {
				displayBitmap();
			} else {
				dmaFillWords(0,bgGetGfxPtr(bg3sub), 256*256);
				displayKeyboard();
			}
		}
	}
	return 0;
}
Help keep devkitPro toolchains free, Donate today

Personal Blog

Leon
Posts: 3
Joined: Thu Mar 15, 2012 3:35 pm

Re: Keyboard and background

Post by Leon » Sat Mar 17, 2012 10:28 am

Ah.... right. I just didn't clear the background with

Code: Select all

dmaFillWords(0,bgGetGfxPtr(bg3sub), 256*256);
Works like a charm now... alternating that is.

No way of showing them both together? I'd thought that since the default keyboard is using layer 3, using layer 2 with the image and setting priority to layer 3 would do the trick but alas...

Like said, I still don't get the memory thing completely. If memory is set as default,

Code: Select all

vramSetBankC(VRAM_C_SUB_BG_0x06200000);
and the keyboard has the default settings

Code: Select all

keyboardInit(NULL, 3, BgType_Text4bpp, BgSize_T_256x512, 20, 0, false, true) 
where does bg2sub then fit in?

Code: Select all

bg2sub = bgInitSub(2, BgType_Bmp8, BgSize_B8_256x256, ?,0);   
Can you mix BgTypes at all? Is there a way to display an image on Text4bpp? You see.... I'm confused :oops:

WinterMute
Site Admin
Posts: 1845
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Keyboard and background

Post by WinterMute » Mon Mar 19, 2012 2:27 am

I'm not entirely clear on what you're trying to do here, if you display an image on top of the keyboard graphics then you won't see the keyboard any more. A more detailed explanation of how you want the display to appear might help.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Leon
Posts: 3
Joined: Thu Mar 15, 2012 3:35 pm

Re: Keyboard and background

Post by Leon » Mon Mar 19, 2012 1:18 pm

The idea is to show a keyboard on top of a background image.

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

Re: Keyboard and background

Post by mtheall » Fri Mar 30, 2012 12:21 am

If you need help managing your VRAM, try http://mtheall.com/vram.php

Post Reply

Who is online

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