How to load a sprite table
How to load a sprite table
Hello everyone.. I was wondering if there is a way to load a whole sprite table and then separate sprites inside the game itself... what I mean is (I don't know if it's really called sprite table >.<) load an image with all the frames of different sprites (like different ways a character can walk) and then "disassemble" it in different sprites to load in memory and then display them separated... is it possible? how can I do it? I'm trying to work something out with oamTables and stuff like that but I can't get it right, please help thanks
Re: How to load a sprite table
I'm sure if I'll be able to answer this correctly, but I can try. If you're starting with a vertical framestrip of a sprite, lets say 16 x 16 in one frame and 10 frames long, what you'll have once grit (or whatever conversion program you use) converts the image is an array that in which each 256 byte chunk is each frame. So lets say in this case you have mysprite[2560], and we're looking at the libnds example for SimpleSprite.
Since we have the gfx pointer already setup, all we need to do is write the correct frame into that memory location. We could use DMA instead of the for loop that the example uses to do it like this:
I'm not sure if you're looking for something more complicated than this, but it's a start. Keep in mind, you'd need to handle the palette too...
Since we have the gfx pointer already setup, all we need to do is write the correct frame into that memory location. We could use DMA instead of the for loop that the example uses to do it like this:
Code: Select all
//set these up so we're not using magic numbers in our code
int length = 16;
int width = 16;
int frame = 4;
DC_FlushRange(mysprite + length*width*frame, length*width);
dmaCopy(mysprite + length*width*frame, gfx, length*width);
Re: How to load a sprite table
this is very useful, really thanks.. for the palette though... can't I just use the whole palette (like the originalSpritePal) that contains ALL the code of the sprites? will it work? I'm getting a lot of troubles trying to figure this stuff out because the examples and tutorials, even though they provide a really nice theoretical basis, they all have different examples and the documentation is really messed up badly @_@Sylus101 wrote:I'm sure if I'll be able to answer this correctly, but I can try. If you're starting with a vertical framestrip of a sprite, lets say 16 x 16 in one frame and 10 frames long, what you'll have once grit (or whatever conversion program you use) converts the image is an array that in which each 256 byte chunk is each frame. So lets say in this case you have mysprite[2560], and we're looking at the libnds example for SimpleSprite.
Since we have the gfx pointer already setup, all we need to do is write the correct frame into that memory location. We could use DMA instead of the for loop that the example uses to do it like this:
I'm not sure if you're looking for something more complicated than this, but it's a start. Keep in mind, you'd need to handle the palette too...Code: Select all
//set these up so we're not using magic numbers in our code int length = 16; int width = 16; int frame = 4; DC_FlushRange(mysprite + length*width*frame, length*width); dmaCopy(mysprite + length*width*frame, gfx, length*width);
Re: How to load a sprite table
I added an example to libnds which does nearly exactly this. It uses grit to parse the frames though.
Its in the svn and will be out with next libnds release (which is forthcomming).
examples/nds/Graphics/Sprites/animate_simple
http://devkitpro.svn.sourceforge.net/vi ... te_simple/
Its in the svn and will be out with next libnds release (which is forthcomming).
examples/nds/Graphics/Sprites/animate_simple
http://devkitpro.svn.sourceforge.net/vi ... te_simple/
Who is online
Users browsing this forum: Ahrefs [Bot] and 5 guests