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 output + Dual screen 3D?

#162061 - AntonioND - Sun Aug 24, 2008 4:37 pm

Hello!

I was wondering if it was possible to use libnds console when I use dual screen 3D. I use VRAM_A and VRAM_B for texture memory, VRAM_C and VRAM_D as framebuffers and VRAM_E as palette memory for textures. I am using this code:
Code:
videoSetModeSub(MODE_0_2D | DISPLAY_BG1_ACTIVE);
vramSetBankH(VRAM_H_SUB_BG);
SUB_BG0_CR |= BG_PRIORITY_1;
SUB_BG1_CR |= BG_MAP_BASE(15) | BG_PRIORITY_0;
consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(15), (u16*)CHAR_BASE_BLOCK_SUB(0), CONSOLE_USE_COLOR255);
BG_PALETTE_SUB[255]=0xff00;
iprintf("Can you see this?");

Obviously, it doesn't work because I change screens every frame...
Code:
if(screen == 0)   
   {
   vramSetBankC(VRAM_C_SUB_BG); vramSetBankD(VRAM_D_LCD);
   SetRegCapture(true, 0, 31, 3, 0, 3, 0, 0);
   }      
else
   {
    vramSetBankC(VRAM_C_LCD); vramSetBankD(VRAM_D_SUB_SPRITE);
    SetRegCapture(true, 0, 31, 2, 0, 3, 0, 0);
   }   

lcdSwap();
screen ^= 1;


How can I setup the console every frame in order to see the text OK? I think I can't because VRAM_F and VRAM_G can only output to main bg; VRAM_H and VRAM_I can only output to sub bg...

I hope someone can help me...

PS: Sorry for my bad english.

#162068 - silent_code - Sun Aug 24, 2008 9:06 pm

Look into the Bezier curve code floating around this forum. I posted the whole thing with an image on both screens plus text.
You will probably have to change a few things, but it should get you there. I think it's possible.
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.

#162083 - Cydrak - Mon Aug 25, 2008 4:41 am

He's asking about 3D, though, and here the engines are constantly toggling screens, aren't they? The only "swappable" banks are C and D, already taken...

So, first, a hackish solution: Put the console map in RAM, and DMA every vblank to the right area (F/G, H/I).

Another is to put the console on F or G. Then you need to arrange a layered (2D) capture instead of a 3D one. (Notice that 3D still works, it's on BG0 as usual.) When you swap screens, you should show/hide/scroll the console layer depending on where you want it. If you want a "tall," two-screen console, you'll have to write your own. It's really not that hard--a really cheapo implementation wouldn't break 50 lines. You could use libnds' console as a starting point.

Both methods have a caveat, though: the DMA or capture has to be restarted every frame (maybe DMA can be convinced to repeat, not sure). Thing is, if you have a console and you crash, most likely you want to see the last thing printed.

The only way I can think to ensure that is to replicate the console text on F, C (when it's mapped as SUB_BG), and H (when C is busy being redrawn). This way, you would always have an up to date console onscreen, rather than buffered. Although, to see it, you would have to avoid framebuffer display (as used for blur, faux bloom, etc).

#162086 - silent_code - Mon Aug 25, 2008 7:05 am

Yepp, I know he's talking about dual 3D and I thought it would be somewhat easier after seeing how it's been done in the aforementioned demo. ;^)

Good luck. :^D
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.

#162089 - AntonioND - Mon Aug 25, 2008 12:28 pm

Cydrak wrote:
Another is to put the console on F or G. Then you need to arrange a layered (2D) capture instead of a 3D one. (Notice that 3D still works, it's on BG0 as usual.) When you swap screens, you should show/hide/scroll the console layer depending on where you want it.


Thank you guys, I managed to do what you said. Now I have sub screen 3D, main screen 3D + console, but in the console output there are lots of vertical lines. What am I doing wrong?
Code:
videoSetMode(MODE_0_3D | DISPLAY_BG1_ACTIVE);
vramSetBankF(VRAM_F_MAIN_BG);
 
BG_PALETTE[255] = 0xFFFF;
BG1_CR = BG_MAP_BASE(0) | BG_PRIORITY(0);
BG0_CR = BG_PRIORITY(1);
 
consoleInitDefault((u16*)SCREEN_BASE_BLOCK(0), (u16*)CHAR_BASE_BLOCK(0), CONSOLE_USE_COLOR255);


Code:
if(Screen == 0)   
   {
   BG1_CR = BG_MAP_BASE(0) | BG_PRIORITY(0);
   BG0_CR = BG_PRIORITY(1);

   vramSetBankC(VRAM_C_SUB_BG); vramSetBankD(VRAM_D_LCD);
   SetRegCapture(true, 0, 31, 3, 0, 3, 0/* 3d + bg + obj*/, 0);
   }      
else
   {
   BG1_CR = BG_PRIORITY(1); BG0_CR = BG_PRIORITY(0);
   
    vramSetBankC(VRAM_C_LCD); vramSetBankD(VRAM_D_SUB_SPRITE);
   SetRegCapture(true, 0, 31, 2, 0, 3, 1 , 0);
   }   

lcdSwap();
Screen ^= 1;


(I guess this is better than noting :P)
http://img145.imageshack.us/img145/4161/8226312mw6.png


Last edited by AntonioND on Tue Aug 26, 2008 4:02 pm; edited 1 time in total

#162092 - Cydrak - Mon Aug 25, 2008 5:34 pm

silent_code wrote:
Yepp, I know he's talking about dual 3D and I thought it would be somewhat easier after seeing how it's been done in the aforementioned demo. ;^)

Ahh, the banking stuff? I was all confused since I didn't see any 3D in your demo, but I think I see what you mean. (Putting H and C on SUB_BG, as done in the first post, certainly won't work as well. :-)

Code:
BG1_CR = BG_MAP_BASE(0) | BG_PRIORITY(0);
consoleInitDefault((u16*)SCREEN_BASE_BLOCK(0), (u16*)CHAR_BASE_BLOCK(0), CONSOLE_USE_COLOR255);

The reason this doesn't work is that you always need BG_MAP_BASE and BG_TILE_BASE for a tiled layer (and of course, they should not overlap). Here both are zero, so your console scribbled text over part of the font. Try putting the tiles at 0 and the map at 8K (map base 4).

#162093 - AntonioND - Mon Aug 25, 2008 6:14 pm

Cydrak wrote:
The reason this doesn't work is that you always need BG_MAP_BASE and BG_TILE_BASE for a tiled layer (and of course, they should not overlap). Here both are zero, so your console scribbled text over part of the font. Try putting the tiles at 0 and the map at 8K (map base 4).


You guys are great! Thanks, that made everything go OK.
I'm used to PAlib and I don't know how to use this kind of things...

Thanks again.

Bye.

#162101 - silent_code - Mon Aug 25, 2008 9:09 pm

You are totally welcome. :^)

@ Cydrak: Yepp, that's what I was talking about. :^D
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.