Hi all,
I've been slowly (sllooooowly) working away on my rRootage port for the past few months. I've been stuck for quite some time on these random crashes that keep occurring. Long story short, I've done a ton of commenting out code to try to narrow it down so I could find a single line of code that I could blame for the crashes.
Take a look at this:
CODE
void drawBulletsWake() {
int i;
Foe *fe;
float x, y, sx, sy;
for ( i=0; i<FOE_MAX; i++ ) {
if ( foe.spc == NOT_EXIST || foe.spc == BATTERY || foe.cnt >= 64 ) continue;
fe = &(foe);
x = (float)fe->pos.x / FIELD_SCREEN_RATIO;
y = -(float)fe->pos.y / FIELD_SCREEN_RATIO;
sx = (float)fe->spos.x / FIELD_SCREEN_RATIO;
sy = -(float)fe->spos.y / FIELD_SCREEN_RATIO;
drawLine(x, y, 0, sx, sy, 0, 150, 180, 90, (63-fe->cnt)*3);
}
}
}
The crashes that occur at rRootage's title screen come from this function. I've been trying to blame it on gpu940 for quite some time, and when I spotted that call to drawLine() there, I thought I had found it.
Guess what? Commenting out the drawLine() call didn't stop the crashes at all. BUT, that continue statement irked me a little bit. You don't really see continue statements very often, so I decided to rework the logic so it works without the continue statement:
CODE
void drawBulletsWake() {
int i;
Foe *fe;
float x, y, sx, sy;
for ( i=0; i<FOE_MAX; i++ ) {
//if ( foe.spc == NOT_EXIST || foe.spc == BATTERY || foe.cnt >= 64 ) continue;
//Changed the above line to the logic below, because it causes hangs -- Albert
//(I know it sounds like gibberish, but it's true...)
if ( foe.spc != NOT_EXIST && foe.spc != BATTERY && foe.cnt < 64 )
{
fe = &(foe);
x = (float)fe->pos.x / FIELD_SCREEN_RATIO;
y = -(float)fe->pos.y / FIELD_SCREEN_RATIO;
sx = (float)fe->spos.x / FIELD_SCREEN_RATIO;
sy = -(float)fe->spos.y / FIELD_SCREEN_RATIO;
drawLine(x, y, 0, sx, sy, 0, 150, 180, 90, (63-fe->cnt)*3);
}
}
}
... and son of a vondruke, the title screen doesn't crash any more. Why the heck would commenting out that continue statement stop crashes from happening? (Could it be something like a compiler bug?)
Any C/ARM guru in here care give me their take?
Thanks guys,
Albert
I've been slowly (sllooooowly) working away on my rRootage port for the past few months. I've been stuck for quite some time on these random crashes that keep occurring. Long story short, I've done a ton of commenting out code to try to narrow it down so I could find a single line of code that I could blame for the crashes.
Take a look at this:
CODE
void drawBulletsWake() {
int i;
Foe *fe;
float x, y, sx, sy;
for ( i=0; i<FOE_MAX; i++ ) {
if ( foe.spc == NOT_EXIST || foe.spc == BATTERY || foe.cnt >= 64 ) continue;
fe = &(foe);
x = (float)fe->pos.x / FIELD_SCREEN_RATIO;
y = -(float)fe->pos.y / FIELD_SCREEN_RATIO;
sx = (float)fe->spos.x / FIELD_SCREEN_RATIO;
sy = -(float)fe->spos.y / FIELD_SCREEN_RATIO;
drawLine(x, y, 0, sx, sy, 0, 150, 180, 90, (63-fe->cnt)*3);
}
}
}
The crashes that occur at rRootage's title screen come from this function. I've been trying to blame it on gpu940 for quite some time, and when I spotted that call to drawLine() there, I thought I had found it.
Guess what? Commenting out the drawLine() call didn't stop the crashes at all. BUT, that continue statement irked me a little bit. You don't really see continue statements very often, so I decided to rework the logic so it works without the continue statement:
CODE
void drawBulletsWake() {
int i;
Foe *fe;
float x, y, sx, sy;
for ( i=0; i<FOE_MAX; i++ ) {
//if ( foe.spc == NOT_EXIST || foe.spc == BATTERY || foe.cnt >= 64 ) continue;
//Changed the above line to the logic below, because it causes hangs -- Albert
//(I know it sounds like gibberish, but it's true...)
if ( foe.spc != NOT_EXIST && foe.spc != BATTERY && foe.cnt < 64 )
{
fe = &(foe);
x = (float)fe->pos.x / FIELD_SCREEN_RATIO;
y = -(float)fe->pos.y / FIELD_SCREEN_RATIO;
sx = (float)fe->spos.x / FIELD_SCREEN_RATIO;
sy = -(float)fe->spos.y / FIELD_SCREEN_RATIO;
drawLine(x, y, 0, sx, sy, 0, 150, 180, 90, (63-fe->cnt)*3);
}
}
}
... and son of a vondruke, the title screen doesn't crash any more. Why the heck would commenting out that continue statement stop crashes from happening? (Could it be something like a compiler bug?)
Any C/ARM guru in here care give me their take?
Thanks guys,
Albert