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 > Bitmaps modes on the DS?

#44210 - jmva16 - Tue May 31, 2005 2:40 am

I have looked through many documents and searched this forum and it seems nobody has successfully used a bitmap mode on the ds yet. Is this true? I would like to do what MODE 4 was for the GBA. I don't need backgrounds or sprites, I just want to write images to a framebuffer that go through a palette lookup. Has anybody had any success with this type of operation?

I read on the Wiki http://www.bottledlight.com/ds/index.php/Video/2DCore that as long as you set the extended mode to 1, the display modes are the same as the GBA. I think this information is old because I have had no success at this and these posts: http://forum.gbadev.org/viewtopic.php?t=5264 seem to contradict that. Can anybody explain this further?

#44238 - Abcd1234 - Tue May 31, 2005 6:11 am

The docs are rather inaccurate here (in fact, the bit about GBA modes being directly supported is, AFAIK, totally wrong). So, my first suggestion is that you read the docs that come with ndslib. They're much more accurate on some of these topics (video in particular).

Anyway, to answer your question, the DS doesn't actually have a native bitmapped mode. Instead, you can simply make use of an extended rotation background by setting it up in 8-bit bitmapped mode. In my own project, I switched the display to Mode 5 (MODE_5_2D, in ndslib parlance), which provides one with 2 text backgrounds and 2 extended rotation backgrounds, with BG0 being available for 3D. Then, I switched BG2 to a 256x256, 8 bit background (I don't have the exact flags specifications on hand... with ndslib, the value is BG_BMP8_256x256) using palette 0. The only other important bit is to make sure to assign the VRAM banks appropriately. And that's it! Oh, and of course, set up the palette, but that works the same as on a GBA. Good luck!

#44253 - dovoto - Tue May 31, 2005 8:59 am

If you have ndslib you have example code for using "bitmap modes". They are in ndslib/exaples/arm9/2D. May want to check out http://www.drunkencoders.com/documents/DS/ndslib.htm for a decent description of 2D modes.
_________________
www.drunkencoders.com

#44390 - jmva16 - Wed Jun 01, 2005 6:57 am

Thank you for the posts. You guys rock. I am trying your suggestions now. I have had success with following configuration. I set MODE_5_2D and BG3 active. I set BG3 to BG_BMP8_256x256. I loaded BG_PALETTE with my palette and wrote my image to 0x6000000. This is working with the emulator (I have not tried it on my hardware yet).

I do not understand the part where I write to 0x6000000. How does it know this is BG3? I would have expected to have to set a vram bank as MAIN_BG and written to it, however I am then confused at to which bank would be BG3 as opposed to BG0, BG1, and BG2 (the text backgrounds and the other extended rotation background). I also do not understand the BG_BMP_BASE(x) macro and the offsets mentioned in Dovoto's ndslib.htm document. Can anybody shed some light on this for me?

#44418 - Darkain - Wed Jun 01, 2005 5:52 pm

jmva16 wrote:
Thank you for the posts. You guys rock. I am trying your suggestions now. I have had success with following configuration. I set MODE_5_2D and BG3 active. I set BG3 to BG_BMP8_256x256. I loaded BG_PALETTE with my palette and wrote my image to 0x6000000. This is working with the emulator (I have not tried it on my hardware yet).

I do not understand the part where I write to 0x6000000. How does it know this is BG3? I would have expected to have to set a vram bank as MAIN_BG and written to it, however I am then confused at to which bank would be BG3 as opposed to BG0, BG1, and BG2 (the text backgrounds and the other extended rotation background). I also do not understand the BG_BMP_BASE(x) macro and the offsets mentioned in Dovoto's ndslib.htm document. Can anybody shed some light on this for me?



put 2 and 2 together, and you answered your own question.

BG_BMP_BASE sets where in the BG_GFX mem the image is located, in 16KBYTE increments... so, set it to 1, and it starts at 0x06004000, 2 would be 0x06008000, and so on down the line.
_________________
-=- Darkain Dragoon -=-
http://www.darkain.com
DarkStar for Nintendo DS

#44441 - LunarCrisis - Wed Jun 01, 2005 9:20 pm

With the ability to use these BGs to display bitmaps and sprites at the same time, I'm wondering what purpose framebuffer mode has at all.
_________________
If a tree falls in the forest and no one is there to hear it, why the heck do you care?

#44478 - tepples - Thu Jun 02, 2005 3:28 am

Perhaps framebuffer mode takes input in the format that the sample-3D-core-output register produces for the 3D-on-both-screens effect.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#44496 - LunarCrisis - Thu Jun 02, 2005 8:22 am

tepples wrote:
Perhaps framebuffer mode takes input in the format that the sample-3D-core-output register produces for the 3D-on-both-screens effect.

I'm not sure I understand, since the 3D and framebuffers are both only available on the main screen, what would the framebuffer taking the right input help?
_________________
If a tree falls in the forest and no one is there to hear it, why the heck do you care?

#44503 - tepples - Thu Jun 02, 2005 10:37 am

LunarCrisis wrote:
since the 3D and framebuffers are both only available on the main screen

I didn't know that. Sorry. Should I just refrain from commenting on topical issues in the DS development forum until after I've got a job that pays enough for me to afford to buy a DS and PassMe for myself?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#49337 - spunky - Thu Jul 28, 2005 10:25 pm

hey guys.. I got it working in BMP8 mode with the main palette.
When setting BMP16 however and writing to BG_GFX something like RGB15(31, 0, 31) does not result in the right colors, its really weird.
Blue works fine when shifting it 10 to the left, the rest is screwed up.
Is there a different pixel bytes layout in this mode?

Thanks a lot
Marius

#49340 - MrAdults - Thu Jul 28, 2005 11:35 pm

There is also an alpha bit, something like

Code:
x = RGB15(31, 0, 31)|(1<<15);


may give you your desired results.

-Rich

#49348 - spunky - Fri Jul 29, 2005 12:29 am

no that didnt do it :\ for some reason the palette is still having influence it seems:

here are some code excerpts:
Code:

videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE);

VRAM_A_CR = 1 | VRAM_OFFSET(0) | VRAM_ENABLE; //background>VRAM_A_MAIN_BG_0x6000000 

//setup bg
BG2_XDX = 0x100; BG2_XDY = 0; BG2_YDX = 0;
BG2_YDY = 0x100; BG2_CY = 0; BG2_CX = 0;

for(int i = 0; i < 256*256; i++)
    (BG_GFX)[i] = RGB15(31, 0, 0) | (1<<10); //transparent bit didnt make a difference


whats wrong :( PLUS setting it to BMP8_256x256 with a palette works perfectly fine on the emulator ( dualis ) but not on the hardware..
the bmp16 mode works on both.. but with freaky results

#49351 - spunky - Fri Jul 29, 2005 12:59 am

stop taking it back.. seems to work now, but dont ask me why..
I keep overlooking the tiny things :\

#49352 - headspin - Fri Jul 29, 2005 1:00 am

You have (1 << 10), that should be (1<<15)
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#49360 - spunky - Fri Jul 29, 2005 2:41 am

*ashamed* yes. :(