[Fixed] acs sin and cos are broken

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
Jonathan
Posts: 44
Joined: Fri Dec 05, 2003 5:35 am

acs sin and cos are broken

Post by Jonathan »

Andrew Stine stated on irc that he was having trouble with the sin and cos functions of acs. In particular, they seemed to not be returning correct values for certain angle ranges. In sin's case 180 - 360, and for cos 270-360.

I had a quick look at the corresponding code in ZDoom, p_acs.cpp:

Code: Select all

case PCD_SIN:
	STACK(1) = finesine[(STACK(1)<<16)>>ANGLETOFINESHIFT];
	break;
Now I'm not familiar with ZDoom's handling of trig and angles in general, but it looks to me as if the problem is in the shifting of the stack value << 16. STACK(1) is a signed double, so shifting anything above 0x8000 up 16 places will give a negative value, which will then be used as the index to the finesine table, which can't be good.
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Post by randi »

Right you are. That should be unsigned math there. Oopsy.
Post Reply

Return to “Closed Bugs [GZDoom]”