Allocating Graphics from OAM
Posted: Mon Jun 25, 2012 5:35 am
I'm having a bit of difficulty getting sprites to be allocated to me by the oamAllocateGfx function - or, rather, getting pointers into VRAM offsets. Currently I have a function that is supposed to setup the sprites in VRAM so I can use them later, but not necessarily put them into sprites - that would be the idea, anyway:
toolGfxLoc is a global array of pointers designed to keep track of the graphics' addresses for use in the oamSet() function later. From what I can tell, though, oamAllocateGfx is returning the same address every time. I've checked VRAM in DeSmuME's tile viewer, and only one sprite's tiles is displaying - comment out the last line, and it is the one previous, and so on.
I've been able to get sprites to display by calling oamAllocateGfx, dmaCopyHalfWords, and oamSet in that order, so my guess is that somewhere in the oamSet function, the OamState gets updated to know that it ought to proceed to the next offset. If this is the case, how should I go about setting up my sprites into memory if I don't want them assigned to a sprite in OAM immediately? Or is that simply not an option with libnds's current implementation?
Code: Select all
void setupToolSprites()
{
for(int i = 0; i < NUM_TOOLTYPES; ++i)
{
toolGfxLoc[i] = oamAllocateGfx(&oamSub, SpriteSize_32x32, SpriteColorFormat_16Color);
}
// Copy sprites into VRAM
dmaCopyHalfWords(3, Cursor_ToolTiles, toolGfxLoc[0], Cursor_ToolTilesLen);
dmaCopyHalfWords(3, Marquee_ToolTiles, toolGfxLoc[1], Marquee_ToolTilesLen);
dmaCopyHalfWords(3, Brush_ToolTiles, toolGfxLoc[2], Brush_ToolTilesLen);
dmaCopyHalfWords(3, Bucket_ToolTiles, toolGfxLoc[3], Bucket_ToolTilesLen);
dmaCopyHalfWords(3, Gradient_ToolTiles, toolGfxLoc[4], Gradient_ToolTilesLen);
dmaCopyHalfWords(3, Rectangle_ToolTiles, toolGfxLoc[5], Rectangle_ToolTilesLen);
}
I've been able to get sprites to display by calling oamAllocateGfx, dmaCopyHalfWords, and oamSet in that order, so my guess is that somewhere in the oamSet function, the OamState gets updated to know that it ought to proceed to the next offset. If this is the case, how should I go about setting up my sprites into memory if I don't want them assigned to a sprite in OAM immediately? Or is that simply not an option with libnds's current implementation?