Zal0 / ZGB

Game Boy / Color engine with lots of features
MIT License
694 stars 51 forks source link

Var initis for sprite_manager_updateables[] #25

Closed bbbbbr closed 3 years ago

bbbbbr commented 3 years ago

I split this one out from the others since it isn't clear whether it's the approach you would take.

It's branched from the other PR so it has those changes rolled in, my bad. I could re-PR it on a clean branch if needed.

Initialize sprite_manager_updatables[] to zero to fix non-initialized RAM exeption.

If I remember correctly, currently SDCC will only initialize the first element of an array that is initialized with SomeArray[N] = {0}; instead of all elements. So this just adds an init function.

Zal0 commented 3 years ago

I was checking this issue and found out that the reason why this was happening is because of some access to Sprite::unique_id, because this var is not initialized when spawning sprites manually (not defined within tiles in the maps) Checking the sprite type first and then the unique_is seems a better solution for now