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 > how do I draw on both screens? [Renamed]

#52963 - spencer723 - Mon Sep 05, 2005 1:33 am

I'm a bit new at this but how do I draw on both screens? Say I was making a 3D game would I just call it like glViewPort(0, 0, 255, 384);? Or would I do lcdSwap(); then draw? If possible could I get an example? Thanks.

#52993 - Mr Snowflake - Mon Sep 05, 2005 11:25 am

Currently we only can do 3d on 1 screen AFAIK.
_________________
http://www.mrsnowflake.be

#53015 - spencer723 - Mon Sep 05, 2005 2:34 pm

Alright, how would I draw on both screens in a 2D game? Or how could I draw 3D on one screen and 2D on the other?

#53048 - Mr Snowflake - Mon Sep 05, 2005 7:31 pm

Take a look at the ndslib (or libnds :)) docs, there are 2 different defines to set the correct video mode.
_________________
http://www.mrsnowflake.be

#53049 - cybereality - Mon Sep 05, 2005 7:36 pm

In order to draw to the screen you need to initiate the screen mode. For the first screen it would look something like this:

videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE);
BG2_CR = BG_BMP16_256x256;

For a second screen it is similar except for the SUB prefix:

videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
SUB_BG3_CR = BG_BMP16_256x256;

Make sure to set the Video RAM memory banks:

vramSetMainBanks(VRAM_A_MAIN_BG,VRAM_B_MAIN_BG,VRAM_C_SUB_BG,VRAM_D_SUB_SPRITE);

Depending on what you are doing the actual code may be different, but that is the basic idea. If your having trouble, I suggest looking into PA_Lib as it has a lot of built in functions for displaying sprites and useful things like that.

// cybereality

#53147 - spencer723 - Tue Sep 06, 2005 11:44 am

Thanks! How easy is PA_LIB and would you suggest it for newbie programmers for NDS?

#53792 - revo - Mon Sep 12, 2005 12:06 am

I don't want to start new topic with similar question. Can somebody show me code to set up framebuffer mode on both screens? The simplest example would be modification of Chris Double code from http://www.double.co.nz/nintendo_ds/nds_develop2.html
_________________
[ sorry for all mistakes, but my english isn't as good as I wish it to be ]

#53803 - cybereality - Mon Sep 12, 2005 2:35 am

From what I gathered, you can only use framebuffer mode on one screen at once. I assume you can get around this by using Mode5 and drawing directly to BG_GFX and BG_GFX_SUB.
_________________
// cybereality

#53807 - doublec - Mon Sep 12, 2005 3:06 am

That is correct, you can only use a framebuffer on one screen. Mode 5 extended rotation background is probably your best choice.

#53816 - headspin - Mon Sep 12, 2005 5:42 am

I wonder if there is some interrupt trick during HBLANK or VBLANK with vramSetMainBanks() or something to switch banks quickly enough and allow a framebuffer on both screens.
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#53820 - DekuTree64 - Mon Sep 12, 2005 6:36 am

Hmm, the only reason I know of to ever use framebuffer mode at all is that bitmap BGs use the upper bit of each pixel as alpha. Not having to set that bit in framebuffer mode can save you a cycle per pixel, depending on what you're doing.
Other than that, bitmap BGs are way more useful, since you can have other BGs/sprites around, and scroll/rotate/scale them.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#53827 - revo - Mon Sep 12, 2005 11:11 am

let's say, that I like framebuffer mode ;) I have written few functions some time ago for drawing bitmaps and other stuff I need, and I wanted to use them in app that will work on both screens.

I'll take closer look to other display modes, thx for info.
_________________
[ sorry for all mistakes, but my english isn't as good as I wish it to be ]