Possible bug... need help verifying.
Posted: Thu May 28, 2009 4:37 pm
I didn't want to post this in bug reports, because I'm not 100% where my issue is. I'm going to hope to do this without being terribly vague...
I have 2 computers that I work on and use googlecode svn to update between the two. I only update my projects this way, not the devkitpro folder. On one, my work computer I'm still on devkitARM 25 and libnds 1.3.2. This will be Computer 1. On my home machine, I've updated recently and am on devkitARM 26 and libnds 1.3.3 (Computer 2).
The best I can do in laying groundwork, is that I have a structure for my sprites, and there are 3 declared as pointers for bullets, targets, and dirt (for a graphic when a bullet hits the ground and small dirt particles fly about). I'm using malloc() for these pointers to allocate a certain amount of each for each stage of the game. The calls to malloc() are successful and not returning NULL. The pointers are declared globally above main() and passed as parameters to any functions using them.
The piece of code that is giving me fits of rage at this point... is a function (defined in a separate source) with all 3 as parameters:
A single bullet instance is passed to it, and the whole target and dirt struct pointers as well. Called in main it's like this:
On Computer 1, everything works fine. Basically if a bullet hits no target and strikes the ground, a dirt splash sprite is created by getting an instance handle and using dirt[handle].element in spots to update information about that sprite (that it's alive, it's location, gfx, animation parameters, etc...).
On Computer 2, none of the information applied to that structure instance is kept, even inside the function. For example, if I add this inside the function:
The output is:
alive - 1
alive - 0
When I saw that... I was totally dumbfounded. If a bullet hits a target, the target instance affected has parameters modified in exactly the same way and those work correctly. Removing the dirt parameter and using extern to bring the dirt pointer into scope at the top of the source with the function fixes the whole thing, but I don't want that to be the solution.
Before finally posting I tried one more thing... I made the dirt pointer an array and removed the malloc() for it. This worked keeping the parameter in the function. I should mention that when a handle is retrieved it happens from the top down, so if I had 8 possible dirt sprites the first handle would be 7. Is it possible that malloc() is somehow returning a pointer correctly but not to enough space?? This could be refuted though, as bringing the pointer into scope worked...
EDIT - I realized that I hadn't tried on hardware (I always do that...) and found that it's locking up on me completely somewhere in the main game loop compiled with R26 and 1.3.3...
The nds output using R25 and 1.3.2 work fine.
I have 2 computers that I work on and use googlecode svn to update between the two. I only update my projects this way, not the devkitpro folder. On one, my work computer I'm still on devkitARM 25 and libnds 1.3.2. This will be Computer 1. On my home machine, I've updated recently and am on devkitARM 26 and libnds 1.3.3 (Computer 2).
The best I can do in laying groundwork, is that I have a structure for my sprites, and there are 3 declared as pointers for bullets, targets, and dirt (for a graphic when a bullet hits the ground and small dirt particles fly about). I'm using malloc() for these pointers to allocate a certain amount of each for each stage of the game. The calls to malloc() are successful and not returning NULL. The pointers are declared globally above main() and passed as parameters to any functions using them.
The piece of code that is giving me fits of rage at this point... is a function (defined in a separate source) with all 3 as parameters:
Code: Select all
void BulletUpdate(spriteMember *bullet, spriteMember *target, spriteMember *dirt)
Code: Select all
BulletUpdate(&bullet[i], target, dirt);
On Computer 2, none of the information applied to that structure instance is kept, even inside the function. For example, if I add this inside the function:
Code: Select all
dirt[handle].alive = 1;
iprintf("alive - %d\n", dirt[handle].alive);
iprintf("alive - %d\n", dirt[handle].alive);
while(1)swiWaitForVBlank();
alive - 1
alive - 0
When I saw that... I was totally dumbfounded. If a bullet hits a target, the target instance affected has parameters modified in exactly the same way and those work correctly. Removing the dirt parameter and using extern to bring the dirt pointer into scope at the top of the source with the function fixes the whole thing, but I don't want that to be the solution.
Before finally posting I tried one more thing... I made the dirt pointer an array and removed the malloc() for it. This worked keeping the parameter in the function. I should mention that when a handle is retrieved it happens from the top down, so if I had 8 possible dirt sprites the first handle would be 7. Is it possible that malloc() is somehow returning a pointer correctly but not to enough space?? This could be refuted though, as bringing the pointer into scope worked...
EDIT - I realized that I hadn't tried on hardware (I always do that...) and found that it's locking up on me completely somewhere in the main game loop compiled with R26 and 1.3.3...
The nds output using R25 and 1.3.2 work fine.