Coding

 Reply to this postStart new topic

Some FPU questions

DK22
post Nov 13 2011, 08:27 AM
Post #1


Member

Posts: 197
From: Liberty City, Shoreside
Joined: 15-July 10



I saw that "fst" and "fstp" instructions in .exe used in this way (example):
CODE
fstp    [esp+0C8h+var_B8]

Would this right?
CODE
float fCoordX;
float flt_0125 = 0.125;
...
__asm
{
    mov ax, wordCoordX
    movzx eax, ax
    mov fCoordX, eax
    fild fCoordX
    fmul ds:flt_0125
    fstp fCoordX
}

In other words, I have 2-bytes coord, stored in wordCoordX. I need to transform it to 4-bytes float.

This post has been edited by DK22: Nov 13 2011, 09:08 AM
Go to the top of the page
 
+Quote Post
Silent
post Nov 13 2011, 11:56 AM
Post #2


The master of cut retort

Group Icon

Posts: 239
From: Warsaw, PL
Joined: 21-July 10



Yeah, that looks proper, but why not just typecast it in C++? Typecasting should produce similar results.

CODE
float fCoordX = (float)wordCoordX;


This post has been edited by Silent: Nov 13 2011, 11:57 AM
Go to the top of the page
 
+Quote Post
DK22
post Nov 13 2011, 12:14 PM
Post #3


Member

Posts: 197
From: Liberty City, Shoreside
Joined: 15-July 10



I tried this. But then I had lags...

I insert my code to CAutomobile__preRender, when I used this
CODE
float fCoordX = (float)wordCoordX;

then, all automobiles was without wheels (o_O) Idk why...

Also I wanted to ask about CGeneral__GetAtanOfXY...
What is the 1st param and second? X Y or Y X ?
Cause on Cpp it is
CODE
Angle = atan2(coordY, coordX)

And dont ask why I dont use cpp's function... I have problems with compiling...

This post has been edited by DK22: Nov 13 2011, 12:45 PM
Go to the top of the page
 
+Quote Post
Deji
post Nov 13 2011, 02:23 PM
Post #4


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Well, the easiest way to test atan is to do "atan2(0.0, 1.0)" and see what angle it produces, if the result is 90 degrees then the it is atan2(coordy, coordx)...


--------------------
Go to the top of the page
 
+Quote Post
Wesser
post Nov 13 2011, 10:25 PM
Post #5


The Assistant

Posts: 84
From: Matera, IT
Joined: 16-June 11



You can avoid the first line by overwriting the second one with this:
CODE
movzx   eax, wordCoordX

FPU atan computes st(1) / st(0), so I guess it is atan2(x, y), unlike ANSI built-in function.
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members: