#47100 - LOst? - Tue Jul 05, 2005 5:10 am
I haven't understood VRAM banks yet. As a GBA programmer, and with no DS emulator showing how big VRAM is or how it is divided, I'm kinda lost when it comes to optimizing graphics.
I want to use backgrounds shared between the two displays. I also want to dynamically update tile art in VRAM at different locations to animate backgrounds.
#47191 - rize - Wed Jul 06, 2005 7:25 am
The first place to start is nds/arm9/video.h
Or you can go here: http://www.drunkencoders.com/documents/DS/ndslib.htm and check the bottom of the doc for the vram chat with the defines from video.h
Here you can see defines that essentially tell you what you can use the vram banks for. The ndslib documentation shows how big the banks are:
A = 128
B = 128
C = 128
D = 128
E = 64
F = 16
G = 16
H = 32
I = 16
Each bank has an associated define (VRAM_A, VRAM_B etc.) that points to the start of that bank in memory.
However, when used for background tiles, the first 4 banks are mapped to lower memory locations. Notice in the video.h the defines for things like VRAM_A_MAIN_BG_0x06000000 etc. You can actually set bank D before A for example.
If you want both screens to have equal capabilities,you're pretty much stuck with a particular configuration (again look at the video.h to see how things map out).
A = main tiles
B = main sprite
C = sub tiles
D = sub sprites
You can swap A and B, but there's hardly a point. It appears that, except for the non main banks, sub tiles and sprites have to go on C and D respectively. So if you want equal capabilities, you need to use that config.
Further, if you're using extended palettes you can only use 16 KB for sub sprites at most so to keep things equal you'd have to limit yourself to 16 KB for main sprites also. However, extended palettes (16 palettes, * 256 entires * 2 bytes per entry) only take up 8 KB anyway. The thing is you can have multiple slots and switch between them for things like palette animation if you want.
E = main tile extended palettes (64; only 32 usable)
F = main sprite extended palettes (16)
G = alternate main sprite extended palettes (16)
H = sub tile extened palettes (32)
I = sub sprite extended palettes (16)
So if you want both screens to have equal capability, you're stuck with that configuration or something very close to it. If you're doing something where the sub screen would only be used for menus and requires minimal sprite and tile resources, you could devote all of the first 4 banks to main tiles and sprites. I'm not sure if you can simultaneously use banks A and B together for sprites. Probably.
You can do tile animation in a number of ways. One way is to simply change the tile base and have subsequent animations for tiles at a different base. However, you'd also need to duplicate any non animated tiles. Another way would be to keep track of some tiles in your tilemap and change them as they animate. Modifying the actual tile graphics of the animated tiles probably isn't the best idea, but if it's a very small number of tiles it may be the easiest way to accomplish the deed.
Don't forget about palette animation either if you just need something that glows or something like that.
#47210 - tepples - Wed Jul 06, 2005 1:57 pm
rize wrote: |
Another way would be to keep track of some tiles in your tilemap and change them as they animate. Modifying the actual tile graphics of the animated tiles probably isn't the best idea, but if it's a very small number of tiles it may be the easiest way to accomplish the deed. |
A lot of Game Boy, Sega Genesis, Super NES, and GBA games use this technique, so it can't be too bad an idea.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#47265 - rize - Wed Jul 06, 2005 10:24 pm
Well, it would be faster to already have the graphics loaded and just modify the which tiles the tilemap points to. However, if it's not too many tiles then it could be done anyway. And the DS has more cycles to burn than the previous platforms you mentioned. So yeah. It's definitely the most straightforward way of doing it from a coding perspective.
#47403 - dovoto - Fri Jul 08, 2005 4:19 pm
tepples wrote: |
rize wrote: | Another way would be to keep track of some tiles in your tilemap and change them as they animate. Modifying the actual tile graphics of the animated tiles probably isn't the best idea, but if it's a very small number of tiles it may be the easiest way to accomplish the deed. |
A lot of Game Boy, Sega Genesis, Super NES, and GBA games use this technique, so it can't be too bad an idea. |
On GBA you can easily animate every tile on the screen every frame using this method....and still have enough time left over for good game play and sound...it should not be an issue on the DS. To me, this method is a much better use of resources than page fliping whole tile sets when many of the tiles are redundant.
_________________
www.drunkencoders.com
#47461 - cory1492 - Sat Jul 09, 2005 2:39 am
Wow, that answer a tonne of the questions I have been trying to find solutions for, thanks for asking about this LOst?
#47475 - LOst? - Sat Jul 09, 2005 1:09 pm
cory1492 wrote: |
Wow, that answer a tonne of the questions I have been trying to find solutions for, thanks for asking about this LOst? |
No problem =)
This answers many questions. Myself is just happy with the NDSlib manual since I got everything else working for now. Thank you all repliers!