#117159 - Balkman - Fri Feb 02, 2007 12:38 am
I've done plenty of game programming on a PC using both Direct X and OpenGL, so I understand the basics of game programming and logic. So feel free to get into detail with any responses. The following questions are ones that deal specifically with the hardware of the NDS.
1) I need a ton of sprite data to be loaded all at once. Can sprite data be read and displayed from main memory, or does it have to be sitting in a VRAM bank? I am asking this because I need more video memory than the four 128k banks (A-D) provided.
2) What are the smaller VRAM banks E-I generally used for? Can I use them for the background?
3) The OAM has a limit of 128 unique sprites. I haven't done 2D animation on the DS yet, but is each frame going to count as one of these 128? Or can I have 128 animating sprites at once?
(I've done 2D sprite animation in Direct X before, is it basically the same logic?… large sprite sheet with all frames on it, and move the index around?)
4) There is an OAM Main, and OAM Sub, both of which are large enough to hold data for 128 sprites. Does this mean I can have a total of 256? If not, what is the purpose of the sub OAM and the sub Palette?
5) Does the DS do anything special when you dynamically allocate memory? Is there a special way it handles heap memory? Or does it just use a piece of the 4MB main memory?
#117164 - tepples - Fri Feb 02, 2007 12:54 am
Balkman wrote: |
I've done plenty of game programming on a PC using both Direct X and OpenGL, so I understand the basics of game programming and logic. So feel free to get into detail with any responses. The following questions are ones that deal specifically with the hardware of the NDS.
1) I need a ton of sprite data to be loaded all at once. Can sprite data be read and displayed from main memory, or does it have to be sitting in a VRAM bank? I am asking this because I need more video memory than the four 128k banks (A-D) provided. |
Yes, you can copy each frame of animation from main memory to VRAM. If you have a 32x32 pixel sprite in 256 colors, reserve a 1024 byte block of VRAM and then copy each frame in as needed. My guide to sprite cel VRAM was written for the GBA, but the techniques still apply to the DS.
Quote: |
2) What are the smaller VRAM banks E-I generally used for? Can I use them for the background? |
Mostly sub-screen stuff while the main screen is in 3D mode using VRAM for textures.
Quote: |
3) The OAM has a limit of 128 unique sprites. I haven't done 2D animation on the DS yet, but is each frame going to count as one of these 128? Or can I have 128 animating sprites at once? |
You can have 128 animating sprites at once on each screen. Each sprite struct contains (at least) an X coordinate, a Y coordinate, and an index into the sprite sheet. Using one 128 KiB bank of VRAM, you can have each sprite displaying a different 32x32 pixel cel and still animate each cel of each sprite separately.
Quote: |
4) There is an OAM Main, and OAM Sub, both of which are large enough to hold data for 128 sprites. Does this mean I can have a total of 256? If not, what is the purpose of the sub OAM and the sub Palette? |
Main is one 2D core and sub is the other. The major difference between the two cores is that main can replace one of the backgrounds with a 3D (pseudo OpenGL) layer, using the other three layers as a HUD and/or skyplane. You can send main to the top screen or to the touch screen using lcdMainOnTop() or lcdMainOnBottom().
Quote: |
5) Does the DS do anything special when you dynamically allocate memory? Is there a special way it handles heap memory? Or does it just use a piece of the 4MB main memory? |
malloc() just uses part of the main memory.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#117173 - dannyboy - Fri Feb 02, 2007 1:34 am
Balkman wrote: |
2) What are the smaller VRAM banks E-I generally used for? Can I use them for the background? |
This page has all the information for what each RAM bank can be used for. In particular though, BANK E is 64KB and can be used for a 256*192 8 bit background for the main screen. Bank H and I can be used for the sub background, but they only total 48KB. So you either compromise on the size or the colour depth.
Balkman wrote: |
4) There is an OAM Main, and OAM Sub, both of which are large enough to hold data for 128 sprites. Does this mean I can have a total of 256? If not, what is the purpose of the sub OAM and the sub Palette? |
The DS has two screens. So it's 128 sprites per screen.
#117177 - tepples - Fri Feb 02, 2007 2:13 am
And if you need more than 128 sprites at once, such as if you are developing a DoDonPachi clone, you can use horizontal blanking time to load a new display list into OAM.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#117182 - Goosey - Fri Feb 02, 2007 3:04 am
tepples wrote: |
And if you need more than 128 sprites at once, such as if you are developing a DoDonPachi clone, you can use horizontal blanking time to load a new display list into OAM. |
Or use 3D Mode isometric projection and quads to simulate sprites.
#117203 - HyperHacker - Fri Feb 02, 2007 10:00 am
3D eats up more battery power though.
_________________
I'm a PSP hacker now, but I still <3 DS.
#117214 - Vich - Fri Feb 02, 2007 12:29 pm
HyperHacker wrote: |
3D eats up more battery power though. |
Do you have any idea on how much more? (since this is quite interesting to know for my current project)
_________________
[project website] [personal website]
#117270 - Balkman - Fri Feb 02, 2007 11:59 pm
Quote: |
Yes, you can copy each frame of animation from main memory to VRAM. If you have a 32x32 pixel sprite in 256 colors, reserve a 1024 byte block of VRAM and then copy each frame in as needed. My guide to sprite cel VRAM was written for the GBA, but the techniques still apply to the DS. |
Yes this is good news. I thought I would have had to have all the frames of animation sitting in VRAM at all times. So aparently it's not slow to copy data from main memory to video ram on the DS each frame. I know this is unheard of on any type of PC game programming.
Quote: |
Or use 3D Mode isometric projection and quads to simulate sprites. |
I like that idea, but I'm gonna stick with just 2d as this is my first DS project.
Thanks everyone for helping me out with this.
#117283 - HyperHacker - Sat Feb 03, 2007 5:17 am
Vich wrote: |
HyperHacker wrote: | 3D eats up more battery power though. |
Do you have any idea on how much more? (since this is quite interesting to know for my current project) |
No, but you could measure. On a full charge, have a program just do powerON(POWER_ALL_2D) and time how long it takes to kill the battery. Charge it again and do the same test with powerON(POWER_ALL).
_________________
I'm a PSP hacker now, but I still <3 DS.
#117414 - silent_code - Sun Feb 04, 2007 7:53 pm
i don't believe it will be a too representative measuring. i guess the hardware has some logic that knows when it's in idle mode and it'll save power that way.
for an ideal measuring one had a game that uses the 2d core in one version and the 3d core in another, but the games are essentially the same. like when "emulating" 2d with 3d. only then will it be possible to know the difference in power consumption.
but, it's just a guess anyway.