fpu exception?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
nataku92
Posts: 5
Joined: Tue Dec 27, 2005 10:33 am

fpu exception?

Post by nataku92 »

I keep on getting an exception as shown by this image:
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: Select all

	for&#40;unsigned int k=0; k<mBullets.size&#40;&#41;; k++&#41; &#123;
		Vector2D p1&#40;mBullets&#91;k&#93;->pX,mBullets&#91;k&#93;->pY&#41;;
		Vector2D p2&#40;mBullets&#91;k&#93;->mX,mBullets&#91;k&#93;->mY&#41;;
		Vector2D O = p1;
		Vector2D D = p2-p1;
		for&#40;unsigned int j=0; j<mPeople.size&#40;&#41;; j++&#41; &#123;
			Vector2D C&#40;mPeople&#91;j&#93;->GetX&#40;&#41;,mPeople&#91;j&#93;->GetY&#40;&#41;&#41;;
			float t = D.Dot&#40;C-O&#41;/D.Dot&#40;D&#41;;
			if &#40;t < 0&#41; &#123;
				t = 0;
			&#125;
			else if &#40;t > 1&#41; &#123;
				t = 1;
			&#125;
	
			Vector2D closest = O+t*D;
			Vector2D d = C - closest;
			float ll = d.Dot&#40;d&#41;;
			int r = 16;
			if &#40;ll < r * r&#41; &#123;
				mPeople&#91;j&#93;->mHealth -= 20;
				mPeople&#91;j&#93;->SetSpeed&#40;mPeople&#91;j&#93;->GetSpeed&#40;&#41;*0.5f&#41;;
				mBullets.erase&#40;mBullets.begin&#40;&#41;+k&#41;;
				k--; //makes up for the erase to prevent skipping bullets
			&#125;
		&#125;
	&#125;
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
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

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
nataku92
Posts: 5
Joined: Tue Dec 27, 2005 10:33 am

Post by nataku92 »

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..
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

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.
nataku92
Posts: 5
Joined: Tue Dec 27, 2005 10:33 am

Post by nataku92 »

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 >_>
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

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
Oobles
Site Admin
Posts: 347
Joined: Sat Jan 17, 2004 9:49 am
Location: Melbourne, Australia
Contact:

Post by Oobles »

You might like to read this thread regarding DEADBEEF.

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

Regards,
David. aka Oobles.
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

I call snap :)
Post Reply