[Shameless progress bump]
Aight, so I've done some more things, and I've fixed the free() bits; turns out that I was using a variable for decompression that technically linked to everything (the code compiles much smaller with it for some reason) so freeing it was freeing all sprite variables, so I've fixed it so now it only frees all the sprite arrays, which frees it in turn. CommandBlockGuy has told me that there is some weird behavior with large programs, which I've found some vague references to in some irrelevant posts. I've been working on the laser animations, which has basically just been me making a butchery of Gimp's functions and proving that I'm not an artist. I might upload some screenshots later, but right now I need to deal with the latest crisis.
I've got the program working even with the freezing and USB errors, but since I've been dealing with it by unplugging the calc and rebooting, it's been getting more and more buggy without any improvement. The calc now decides that it would like to live as a plastic brick until it restarts after a few minutes and clears the RAM. I obviously can't release this mess, and I can't keep trying to live with these bugs, so I'm moving my sprites to appvars. I'm going to be spending my night working on re-writing the convpng.ini as a convimg.yaml, hopefully that won't take too long.
UPDATE EDIT:
So I have good news! The appvar conversion took nearly all of my sanity last night, but I got the yaml remade and everything works! The two missile decompression bits for the "warning" and "incoming" icons aren't breaking anything anymore (that I acn tell) and the lasers and missiles will probably be getting finished animations soon!
And now for the bad news: NOTHING WORKS AND I'M ALMOST OUT OF ALTOIDS.
So now there are 4 decompression bits that are breaking the calc, and it's still freezing on exit and crashing after a random amount of time. So as of now, the only obstacles I can load are the missiles and some of the laser animations. What isn't working so far:
1. Coins
2. Zappers (both parts)
3. 1/3 of the laser animations
The code itself is commented out but updated to the repo now, building it will work and run fine but only missiles will appear after a while since I disabled the spawning loop (the missiles don't have sprites but the corruption doesn't crash the calc). Here's what it looks like:
Code: for(i = 0; i < 4; ++i)
{
//decompressing coin spritesheet:
decompressorVar = gfx_MallocSprite(12, 12);
zx7_Decompress(decompressorVar, coinSheet_tiles_compressed[i]);
coin[i] = decompressorVar;
}
for(i = 0; i < 3; ++i)
{
//zappers:
zapper[i] = gfx_MallocSprite(18, 18);
zapper[i+3] = gfx_MallocSprite(18, 18);
zx7_Decompress(zapper[i], zapperSheet_tiles_compressed[i]);
gfx_FlipSpriteX(zapper[i], zapper[i+3]);
}
for(i=0; i < 8; ++i)
{
//mallocing full electric array:
electric[i] = gfx_MallocSprite(32, 32);
}
for(i = 0; i < 2; ++i)
{
//zapper lightning:
zx7_Decompress(electric[i], electricSheet_tiles_compressed[i]);
gfx_FlipSpriteX(electric[i], electric[i+2]);
gfx_FlipSpriteY(electric[i], electric[i+4]);
gfx_RotateSpriteHalf(electric[i], electric[i+6]);
}
//prepare laser sprite sizes:
for(i = 0; i < 6; ++i)
{
laser_firing[i] = gfx_MallocSprite(30, 37);
}
//laser and powering up animations, also adds flipped ones:
for(i = 0; i < 3; ++i)
{
zx7_Decompress(laser_firing[i], firing_tiles_compressed[i]);
gfx_FlipSpriteY(laser_firing[i], laser_firing[i+3]);
}
...
for(i = 0; i < 4; ++i) free(coin[i]);
for(i = 0; i < 6; ++i) free(zapper[i]);
for(i = 0; i < 8; ++i) free(electric[i]);
for(i = 0; i < 6; ++i) free(laser_firing[i]);
I discovered that not freeing the sprites doesn't have any visible effect, so there may be an issue there somehow that already exists. The move to using appvars has no effect either, although the program size is down to 4628 bytes of pure code (so ~6.5 kb are compressed sprites, I need to fix that). I have a hunch that I'm doing something weird with the flipping, since the decompressorVar was leaving a pointer trail everywhere, maybe my flipping things is sticking pointers where they shouldn't be too, and I'm freeing some arrays twice. I'm going to keep working on the obstacles and menuing, but if I can't find a workaround/fix for this I don't know how I can release it yet.