Page 1 of 1
Removing a sprite from screen
Posted: Thu Sep 17, 2015 1:10 pm
by matteus
Hi,
I'm using the sprite engine, I use SPR_clear after a sprite has finished animating on screen. However I'm still seeing tiles left in VRAM?
Code: Select all
case 3:
VDP_setPalette(PAL3, ghoul_sprite.palette->data);
SPR_initSprite(&sprites[0], (SpriteDefinition*)&ghoul_sprite, EMEMYSPRITE_POSITION_X, ENEMYSPRITE_POSITION_Y, TILE_ATTR(PAL3, TRUE, FALSE, FALSE));
SPR_setAnim(&sprites[0], ANIM_DEFEATED);
break;
// code lower down in next case statement
case 4:
if (AnimFrame < 7) {
SPR_nextFrame(&sprites[0]);
SPR_update(sprites, 1);
AnimFrame++;
} else {
SPR_clear();
updateStatistics();
}
Re: Removing a sprite from screen
Posted: Thu Sep 17, 2015 7:54 pm
by Stef
SPR_clear() just clear sprites from display, tiles won't necessary be cleared from VRAM which rely from the internal VRAM cache logic part.
Why do you want to removes tiles from VRAM ?
Re: Removing a sprite from screen
Posted: Thu Sep 17, 2015 9:35 pm
by matteus
I wondered if this maybe causing the corruption? But I guess you overwrite anything left behind in VRAM that's no longer used! I'm starting to get a real understanding of how this all works

Loving it too!
Re: Removing a sprite from screen
Posted: Thu Sep 17, 2015 9:48 pm
by Stef
Yeah exactly at some point i will overwrite it when it will not be anymore in use. But as i told you, unfortunately there is still some issues with the sprite engine i need to fix. Be sure to have a big enough cache to start with... but i know that sometime it's just because of slow update which make corruption to appears on screen. Do you use compressed sprites data ? if yes, try to disable it to see if it helps.
Re: Removing a sprite from screen
Posted: Thu Sep 17, 2015 10:44 pm
by matteus
I disabled compression earlier today and it fixed the issue and the frame rate went mad! Is there any way to calculate when a sprite has finished an animation loop?
Re: Removing a sprite from screen
Posted: Fri Sep 18, 2015 8:05 am
by Stef
matteus wrote:I disabled compression earlier today and it fixed the issue and the frame rate went mad! Is there any way to calculate when a sprite has finished an animation loop?
Yeah compression can be very slow ! The next version will include faster compression algorithm so you will be able to keep compression and good frame rate

About the animation loop, the sprite definition contains everything to define how the sprite will animate but rescomp always assume classic loop animation. If you want to interrupt the "auto animation" just set the timer field to 0 :
so the sprite engine won't change frame automatically.
Then to know if you are of the last animation frame you can use this :
Code: Select all
// last sequence animation frame ?
if (sprite->seqInd == (sprite->animation->length - 1)) // do something
The thing is that you can even build your own 'Animation' and 'SpriteDefinition' structures to have finer control of the auto animation from the Sprite Engine, by default rescomp generate simple looping animation in these structures but they support more than that (just read the doxygen doc about them).
Re: Removing a sprite from screen
Posted: Fri Sep 18, 2015 6:06 pm
by matteus
Thanks for this Stef! I'll look to modify my code to reflect this

Re: Removing a sprite from screen
Posted: Tue Sep 22, 2015 2:36 pm
by matteus
Hey Stef,
You refer to the last animation frame as this:
Code: Select all
// last sequence animation frame ?
if (sprite->seqInd == (sprite->animation->length - 1)) // do something
I can't access the sprite as it's in the sprite array, so how'd I get around this?
Re: Removing a sprite from screen
Posted: Tue Sep 22, 2015 2:46 pm
by matteus
Code: Select all
if (sprites[0].seqInd == (sprites[0].animation->length - 1)) {
okay sorted

Re: Removing a sprite from screen
Posted: Tue Sep 22, 2015 8:10 pm
by Stef
yeah it depends about how you access it, in my example it was as if i did first :