How to free a generated sprite?

Previous topic - Next topic

fuzzy70

The answer to this is probably easy & obvious but it is eluding me at the moment & driving me nuts  :D

I am modifying my fastflood fill routine to make it easier to fill a part of the screen or a sprite & also some optimisations (not to the fill routine itself as that's pretty much maxed as I can get it). When doing a fill on a screen it grabs the entire screen with SPRITE2MEM, does the fill then dumps the entire array back to a sprite. Writing the entire array back then calling MEM2SPRITE is far from optimal if say the area that has been filled is only small (say 50x70 pixels) as the bigger the array the longer MEM2SPRITE takes.

My solution is to copy only the modified area to a new sprite with an ID created with GENSPRITE hence making the call to MEM2SPRITE faster when dealing with smaller areas.

Once the sprite has been drawn how do I delete it from memory otherwise every call to the routine will create a new sprite & end up with loads of basically dead & useless sprites taking up memory. I don't really want 1 sprite left in memory after the routine is called as even that sprite is not needed once it has been drawn.

Lee

"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

MrTAToad


fuzzy70

Quote from: MrTAToad on 2013-Jun-04
Use LOADSPRITE "",<id>

Thanks MrTAToad, like I said it was more than likely obvious & simple but the penny wouldn't drop  :D

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

spicypixel

Quote from: fuzzy70 on 2013-Jun-04
Quote from: MrTAToad on 2013-Jun-04
Use LOADSPRITE "",<id>

Thanks MrTAToad, like I said it was more than likely obvious & simple but the penny wouldn't drop  :D

Lee

I had some issues when developing for iOS (not sure why or how now) when I used LOADSPRITE "" but all was fine when I used LOADSPRITE "FREEME" <--- any filename that doesn't exist
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

fuzzy70

Quote from: spicypixel on 2013-Jun-05
I had some issues when developing for iOS (not sure why or how now) when I used LOADSPRITE "" but all was fine when I used LOADSPRITE "FREEME" <--- any filename that doesn't exist

Thanks Spicy, will keep that in mind. Not that I develop anything for iOS (maybe someday I will) but handy to include in case another platform may have issues with a blank filename :)

Lee

Sent from my HTC Wildfire using Tapatalk 2

"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)