Page 1 of 1

SPR_releaseSprite breaks on large sprites

Posted: Sun May 29, 2016 11:08 am
by Grind
Best way to describe this is with code.

Code: Select all

// Load 2 large sprites (bigger than 4x4)
Sprite *spr[2] = {
    	SPR_addSprite(&SPR_Igor, 80, 80, TILE_ATTR(PAL2, 1, 0, 0)),
    	SPR_addSprite(&SPR_Balfrog, 160, 80, TILE_ATTR(PAL3, 1, 0, 0))
};

// Release and re-add first one
SPR_releaseSprite(spr[0]);
spr[0] = SPR_addSprite(&SPR_Igor, 80, 120, TILE_ATTR(PAL2, 1, 0, 0));
// Second sprite has been chopped
I haven't looked at the SPR_releaseSprite code but it seems to be freeing the wrong entries in the sprite list whenever a large sprite exists. This has caused very amusing behaviour, like half the HUD taking place of an enemy, and jumping spikes (scarier than the boss :shock: ).

Happy to say though that the laggy areas are running at 60 now.

Image

Re: SPR_releaseSprite breaks on large sprites

Posted: Mon May 30, 2016 12:08 pm
by Stef
Thanks fo the report, i found the problem :) Turn out that i forgot to update some pieces of my code (i made at least 3 complete different implementation of Sprite Engine and i had some part of code based on previous one).
Fix is pushed on github (sprite_eng.c file) but i will do a proper new SGDK release to address it !

Re: SPR_releaseSprite breaks on large sprites

Posted: Tue May 31, 2016 3:59 pm
by Grind
Great, now it works perfectly! Keeping the old libmd.a around in case I want to entertain myself again :mrgreen:

Re: SPR_releaseSprite breaks on large sprites

Posted: Tue May 31, 2016 5:43 pm
by Stef
Haha :D Glad you confirmed it's fixed ;)