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 > Console Confusion

#167993 - Conutmonky - Mon Apr 06, 2009 7:31 am

Hello,

I am rather new to DS development. So far I have something where I can show a background on the top and bottom screens, have some sprites on the bottom screen and some movement, which is fine. However a lot of this came through tutorials and me trying different things, and I have missed some of the basic stuff that i'm not sure how to do.

So my question now is, how can I select is my sprites are displayed on the main screen vs the sub screen? If I enable sprites to be displayed on both, it seems that the sprites are displayed on my main screen by default. Also similarly with text: how can I choose where to display my text?

An example:

videoSetModeSub(MODE_5_2D | DISPLAY_BG1_ACTIVE);

PrintConsole topScreen;
consoleInit(&topScreen, 1, BgType_Text4bpp, BgSize_T_256x256, 31, 0, flase, true);
iprintf("Hello World");

The consoleInit is telling the topScreen object to use BG layer 1, which should be enabled on the sub screen. What is telling iprintf to use that console? Right now it is coming through as garbage on the sub screen, which is almost right.


And what would tell my sprites to use the main screen and not the Sub console if both had sprites enabled?


Any help would be great,

Thanks,
Mike

#167998 - TwentySeven - Mon Apr 06, 2009 1:53 pm

Probably the first thing to do is to stop refering to them as top screen and bottom screen. Rather, use the terms main screen and sub screen.

I'm having trouble following what you want to do because of that.

#168001 - sverx - Mon Apr 06, 2009 3:06 pm

You've got two OAMs where you define your sprites: if you define an object (your sprite) in the main OAM the sprite will appear on the main screen, if you define an object in the SUB_OAM it will appear on the sub screen...

#168024 - Conutmonky - Tue Apr 07, 2009 1:33 am

Thank you for the reply. I have been programming for a little while, but not on the DS so i'm just trying to get my head around the hardware and initialization.

So looking through this forum (I have been trying to search for my answers which has been useful) I noticed that there is consoleInit and BgInit I believe included with libnds. Are they both for initializing the same thing? Or what is the term "console" referring to then in this setting?

I have been trying to take consoleDemoInit() and write out the actual code to get one of the backgrounds to display text and I can't seem to do it correctly. It seems to be better for me to know what these functions are doing rather than relying on them. So what I tried that didn't work:

vramSetBankC(VRAM_C_MAIN_BG);
videoSetMode(MODE_0_2D | DISPLAY_BG1_ACTIVE);
REG_BG1CNT=BG_64x64;
iprintf("Hello");

I'm not sure how to tell iprintf that is should be using BG1 on the Main screen, and I'm also not sure that I have included everything I needed to for the REG_BG1CNT. It compiles fine but shows a white screen. Is there anywhere that outlines exactly what consoleDemoInit does?

Thanks again, I look forward to becoming a part of this community!

Mike