|
Post by landeel on Oct 21, 2015 17:48:34 GMT -5
My game runs pretty well on emulators, but on real genesis I'm experiencing severe graphical corruption and after a few seconds, freezes. Tried 2 different consoles, same issue. Looks like the problem happens when the command "freesprite" is called. Any idea what's going on? Any BEX bugs I should know? Should freesprite be called only during vblank, or something like that? If I hide the sprites in the corner of the screen instead of freeing them, will this impact performance? Thanks.
EDIT: forgot to mention, calling "movesprite" and then calling "freesprite" right after it will always trigger the problem.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Oct 21, 2015 20:42:06 GMT -5
Sounds like a timing issue. Are you doing this during the VBLANK? If not, try a VALT command in between each command.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Oct 22, 2015 14:10:16 GMT -5
This is not an answer to your question.
I've never experienced this problem but I think that's because of coding style differences. I tend to minimize allocating/de-allocating resources. I make an object like player0 and swap graphics using propsprite when needed. I also just move the sprite off-screen instead of destroying it.
|
|
|
Post by landeel on Oct 25, 2015 17:11:32 GMT -5
I have moved "freesprite" to the beginning of my vblank. Also added a "if VBlankOn()=0 then valt" before it, just in case. Looks like it's running stable now, played for many minutes on my real genesis, no glitches.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 11, 2017 12:11:43 GMT -5
I decided to talk with Sik about this issue a bit today, and I sent him the ASM code snippet of the FreeSprite routine.
It appears the reason for this is because when you free the sprite handle 0, the routine doesn't check and it becomes -1, which causes the issue.
The work-around for this is to modify the BEX ASM library and manually compile it from the command line (which is very tedious). I've updated the SecondBASIC library and will be available in the next release.
If you don't want to switch over to SecondBASIC, there's a potentially easy fix: - I believe BEX will always create the first sprite of the app (or after a FreeAllSprite command), the first sprite will always be linked to 0. Make a 1 by 1 sprite, and keep it off screen and never free that sprite. If you use a FreeAllSprite command, just remake that sprite and tuck it away somewhere.
- Another suggestion is to move all sprites off screen before freeing them. Unsure if this will actually work or not, but it's worth testing out.
|
|
|
Post by landeel on Mar 11, 2017 12:55:04 GMT -5
I have already changed my code to recycle the sprites instead of freeing them. But I will try it some other time.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 11, 2017 14:08:45 GMT -5
Totally understand. I just wanted to post possible solutions in case someone else runs into this issue.
|
|