gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Printing on main and sub-screen

#155881 - Roland - Mon May 05, 2008 12:33 am

Hi all,
I'm really new to NDS development, and I'm learning the basics without using high-level libraries such as PAlib, because I really want to learn the architecture without any other abstraction layer.
Anyway, I have to admit that I'm feeling a bit lost (i.e.: I didn't find the documentation for functions like consoleInit() etc...), today I wrote my first "application", well it's just a text printed with printf() that can be moved around with the touchscreen and resized/rotated, nothing else ;p.
Now I'd like to move the text from the lower screen to the upper screen when the user drags it with the pen. The main question is: who decides where the text printed with printf() is actually printed? This is a snippet of the code:
Code:

   lcdMainOnTop();
   videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
   videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE | DISPLAY_BG_EXT_PALETTE);

   vramSetBankA(VRAM_A_MAIN_BG);
   vramSetBankC(VRAM_C_SUB_BG);

   SUB_BG3_CR = BG_TILE_BASE(char_base) | BG_MAP_BASE(screen_base) | ROTBG_SIZE_256x256;
   
   u16* sub_tile = (u16*)CHAR_BASE_BLOCK_SUB(char_base);
   u16* sub_map = (u16*)SCREEN_BASE_BLOCK_SUB(screen_base);

   consoleInit((u16*)fontData, sub_tile, 95, 32, sub_map, CONSOLE_USE_COLOR255, 8);
   printf("Test text!\n");

Most of it is taken from an example I've found in devkitpro. printf() prints the text on the lower screen, this is ok for me, but how can I tell it that I want the text to be printed on the upper screen? And if I want to move the text from the lower to the upper screen what should I do?
Thanx a lot in advance for your help, I'm really willing to learn the basics and that's why I'm experimenting with the example code, but a lot of parts are quite obscure to me :).

C u!

#155882 - silent_code - Mon May 05, 2008 1:04 am

just a short hint: download the sources for libnds (devkitPro is "just" the "vendor" [is that right, wintermute? ;^D ] for the devkitARM compiler package - you use libnds to interface the nds' hw), they are sufficiently documented.

the screens are two seperate entities. you need to assign v(ideo)ram banks and set up their usage. this will tell the hw how you will use the vram and what screen will display it.

so, you need to set up two consoles... might be a bit hard for a starter, i guess. i haven't done it myself (no need to), but i imagine there are other ways of doing it. i have an idea, but i think it might be too confusing and not having done it, i'll better shut up. ;^D

note: make sure you use the forum search function, this topic has already been discussed, iirc.

... and welcome to the community! :^D

happy coding!


Last edited by silent_code on Mon May 05, 2008 1:12 am; edited 1 time in total

#155883 - tepples - Mon May 05, 2008 1:12 am

Roland wrote:
who decides where the text printed with printf() is actually printed?

That's a matter of what you pass to consoleInit().
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#155898 - simonjhall - Mon May 05, 2008 11:45 am

I did a dual-screen console in Q2 by using the regular libnds one on the bottom screen and a '3D' one on the main screen using the same font. You could knock up a similar system, just using a tiled image on the top screen (instead of 3D)? 3D text is a PITA as you can get rendering errors...
If libnds could automatically support screen spanning then that would be just epic. Any takers? ;-)
_________________
Big thanks to everyone who donated for Quake2

#155905 - Roland - Mon May 05, 2008 1:39 pm

Thanx a lot for you helpful hints, I'm downloading libnds sources and I'll surely take a look at them. I'm sorry for the duped topic, I used the search function, but maybe I missed the right topic.
Thank you very much, I hope to come by here in the next days with questions more intelligent than this one :).

#155906 - silent_code - Mon May 05, 2008 1:53 pm

don't run yourself down, it's not a dumb question. ;^D
you're welcome!