forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

fpu exception?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
nataku92



Joined: 27 Dec 2005
Posts: 5

PostPosted: Mon Jul 24, 2006 8:34 am    Post subject: fpu exception? Reply with quote

I keep on getting an exception as shown by this image:


I've narrowed it down to a for loop in my update function that checks a whether a line segment(a bullet's previous position to its current position) intersects a circle(a person). Both the bullets and people are stored in a vector. The code is as follows:
Code:

   for(unsigned int k=0; k<mBullets.size(); k++) {
      Vector2D p1(mBullets[k]->pX,mBullets[k]->pY);
      Vector2D p2(mBullets[k]->mX,mBullets[k]->mY);
      Vector2D O = p1;
      Vector2D D = p2-p1;
      for(unsigned int j=0; j<mPeople.size(); j++) {
         Vector2D C(mPeople[j]->GetX(),mPeople[j]->GetY());
         float t = D.Dot(C-O)/D.Dot(D);
         if (t < 0) {
            t = 0;
         }
         else if (t > 1) {
            t = 1;
         }
   
         Vector2D closest = O+t*D;
         Vector2D d = C - closest;
         float ll = d.Dot(d);
         int r = 16;
         if (ll < r * r) {
            mPeople[j]->mHealth -= 20;
            mPeople[j]->SetSpeed(mPeople[j]->GetSpeed()*0.5f);
            mBullets.erase(mBullets.begin()+k);
            k--; //makes up for the erase to prevent skipping bullets
         }
      }
   }


It seems that the if (ll < r * r) { block at the end is causing the probem, since no exception happens if I comment out all the lines in the block. However, if I put any statement, even a simple one declaring an arbitrary int or something (like int random = 0;), it gives me the exception again. Any help or suggestions?

Thanks

btw, I'm using dr_watson's JGE++ Engine
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Mon Jul 24, 2006 2:56 pm    Post subject: Reply with quote

remember precedence
this
if (ll < r * r) {

might be this
if ((ll < r) * r) {

or this
if (ll < (r * r)) {
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
nataku92



Joined: 27 Dec 2005
Posts: 5

PostPosted: Mon Jul 24, 2006 3:57 pm    Post subject: Reply with quote

still the same error T_T

its even weirder since I use almost the same exact code in a preceding for block to check the mPeople vector against line segments (walls) and that works fine. The only notable differences are that I use an array to hold the walls, while I use a vector for the bullets. Not really sure if that means anything though..
Back to top
View user's profile Send private message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Mon Jul 24, 2006 4:46 pm    Post subject: Reply with quote

Could this line:
float t = D.Dot(C-O)/D.Dot(D);
Ever be divide by 0? If so, that might be the problem.

Else, type in psp-addr2line myapp.elf 0x089014CC which should give you the line of the problem.
Back to top
View user's profile Send private message
nataku92



Joined: 27 Dec 2005
Posts: 5

PostPosted: Mon Jul 24, 2006 4:55 pm    Post subject: Reply with quote

Ahhh thanks so much!! I forgot that the first time a bullet is initialized, its current and previous positions are the same. -.-'

Thanks!!

hm now to find out if that DEADBEEF thing is just some giant coincidence >_>
Back to top
View user's profile Send private message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Mon Jul 24, 2006 5:06 pm    Post subject: Reply with quote

Nope. Some of the registers are set to DEADBEEF so you know if they've been changed.
http://forums.ps2dev.org/viewtopic.php?t=6013
Back to top
View user's profile Send private message
Oobles
Site Admin


Joined: 17 Jan 2004
Posts: 362
Location: Melbourne, Australia

PostPosted: Mon Jul 24, 2006 5:07 pm    Post subject: Reply with quote

You might like to read this thread regarding DEADBEEF.

http://forums.ps2dev.org/viewtopic.php?t=6013

Regards,
David. aka Oobles.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Mon Jul 24, 2006 7:49 pm    Post subject: Reply with quote

I call snap :)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group