#152565 - ben0bi - Mon Mar 17, 2008 8:50 pm
is there a simple way to manage the oam memory?
i have the following problem: i want to make much much units. everyone has eventually another sprite.
to show the right units on the screen, i have to determine the visible ones and then copy their sprites and position/rotation data to oam. (and flush away the invisible ones to get the memory)
or can i load ONE sprite to oam and use it for several instances? (how?)
now please look at the following code:
by simply changing the oam id (sprInfo->oamID) everything works until several sprites are loaded (because palette len is ever the same). then the tileIdx will overrun because it is calculated somewhat like this:
sprEntry->tileIdx= actualTileIdx;
actualTileIdx+=mypicBitmapLen;
now, i cannot set actualTileIdx - = oldpicBitmapLen because on this position could be another sprite.
its no problem with the palette, but the new tileIdx would eventually overlap other sprites if i use the stuff above or the old tileIdx.
now my question: is there something provided to manage this issue?
(wich e.G. shifts all space behind the old position "left" with oldBitmapLen (so i can use actualTileIdx -= oldpicBitmapLen)
or is there another way to show one sprite image on multiple positions/angles at the same time?
i have the following problem: i want to make much much units. everyone has eventually another sprite.
to show the right units on the screen, i have to determine the visible ones and then copy their sprites and position/rotation data to oam. (and flush away the invisible ones to get the memory)
or can i load ONE sprite to oam and use it for several instances? (how?)
now please look at the following code:
Code: |
/* Copy over the sprite palette */ dmaCopyHalfWords(OAM_SPRITE_DMA_CHANNEL, ppicturePal, &SPRITE_PALETTE[sprInfo->oamId * OAM_COLORS_PER_PALETTE], picturePalLEN); /* Copy the sprite graphics to sprite graphics memory */ dmaCopyHalfWords(OAM_SPRITE_DMA_CHANNEL, ppictureTiles, &SPRITE_GFX[sprEntry->tileIdx * OAM_MAINSPR_OFFSET_MULTIPLIER], pictureTilesLEN); |
by simply changing the oam id (sprInfo->oamID) everything works until several sprites are loaded (because palette len is ever the same). then the tileIdx will overrun because it is calculated somewhat like this:
sprEntry->tileIdx= actualTileIdx;
actualTileIdx+=mypicBitmapLen;
now, i cannot set actualTileIdx - = oldpicBitmapLen because on this position could be another sprite.
its no problem with the palette, but the new tileIdx would eventually overlap other sprites if i use the stuff above or the old tileIdx.
now my question: is there something provided to manage this issue?
(wich e.G. shifts all space behind the old position "left" with oldBitmapLen (so i can use actualTileIdx -= oldpicBitmapLen)
or is there another way to show one sprite image on multiple positions/angles at the same time?