SPR_releaseSprite breaks on large sprites

SGDK only sub forum

Moderator: Stef

Post Reply
Grind
Very interested
Posts: 64
Joined: Fri Jun 13, 2014 1:26 pm
Location: US
Contact:

SPR_releaseSprite breaks on large sprites

Post by Grind » Sun May 29, 2016 11:08 am

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
Attachments
sprite_issue.zip
(10.51 KiB) Downloaded 60 times

Stef
Very interested
Posts: 2976
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: SPR_releaseSprite breaks on large sprites

Post by Stef » Mon May 30, 2016 12:08 pm

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 !

Grind
Very interested
Posts: 64
Joined: Fri Jun 13, 2014 1:26 pm
Location: US
Contact:

Re: SPR_releaseSprite breaks on large sprites

Post by Grind » Tue May 31, 2016 3:59 pm

Great, now it works perfectly! Keeping the old libmd.a around in case I want to entertain myself again :mrgreen:

Stef
Very interested
Posts: 2976
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: SPR_releaseSprite breaks on large sprites

Post by Stef » Tue May 31, 2016 5:43 pm

Haha :D Glad you confirmed it's fixed ;)

Post Reply