flat assembler
Message board for the users of flat assembler.

Index > Windows > Directx9 Win64 D3DX-Functions

Author
Thread Post new topic Reply to topic
Anunak



Joined: 27 Dec 2011
Posts: 3
Anunak 27 Dec 2011, 09:16
Hello Guys!
I'm actually new to this messageboard. I'm using fasm for a few days to do some programming for Win64. I've used MASM32 before. FASM works pretty fine, but I've some problems with DirectX. As far as I know floating points and _fastcall use the xmm0-xmm3 registers. When disassembling my program it seems to be right, but i can't see anything. It should only show a rectangle with a texture. I've done in C++ and it works. In ASM it doesn't. I think there's a problem with x64/Directx and the Matrix-Functions. But I don't understand, where the fault is.

Have a look a the source code! Any help would be greatly appreciated.


P.S.: When I don't use matrix functions I can see the rectangle. I'm using Matt Childress' include files for x64


Description: Code without matrix functions
Download
Filename: DX1a.ASM
Filesize: 8.02 KB
Downloaded: 316 Time(s)

Description: Code with matrix functions
Download
Filename: DX1.ASM
Filesize: 10 KB
Downloaded: 289 Time(s)

Post 27 Dec 2011, 09:16
View user's profile Send private message Reply with quote
Anunak



Joined: 27 Dec 2011
Posts: 3
Anunak 27 Dec 2011, 11:48
Guys. I solved the problem. Actually I stopped using invoke Macro for these functions. Doesn't work with more than 3 arguments?! Use instead SIMD instructins directly (movss). Have a look. And I forgot to set the SetFVF, but that wasn't the real problem.

Here's the working code

;invoke D3DXMatrixPerspectiveFovLH,addr matProj,float 1.570796327,float 1.0,float 1.0,float 300.0 -> doesn't work, I use now variables and load them with movss

sub rsp,30h
lea rcx,[matProj]
movss xmm1,[PI2]
movss xmm2,[Aspect]
movss xmm3,[zn]
;movss xmm4,[zf]
mov eax,[zn]
mov [rsp+30h+20h],eax
call [D3DXMatrixPerspectiveFovLH]
add rsp,30h
;invoke D3DXMatrixTranslation,addr matTrans,float 0.0,float -5.0,float 0.0
sub rsp,20h
lea rcx,[matTrans]
movss xmm1,[tx]
movss xmm2,[ty]
movss xmm3,[tz]
call [D3DXMatrixTranslation]
add rsp,20h
Post 27 Dec 2011, 11:48
View user's profile Send private message Reply with quote
Anunak



Joined: 27 Dec 2011
Posts: 3
Anunak 01 Jan 2012, 09:23
Here's the correct code. It wasn't a problem of the invoke statement. You should set only float, if it is a float, for the first 4 parameters (fastcall convention), for all other parameters, which are pushed on the stack, you should use dword:

invoke D3DXMatrixPerspectiveFovLH,addr matProj,float [PI2],float [Aspect], float [zn], dword [zf]

The above statement didn't work correctly because of "wrong" parameters in the Clear statement.

cominvk pD3DD9,Clear,0,0,D3DCLEAR_TARGET or D3DCLEAR_ZBUFFER,00205090h,dword (float doesn't work) 1.0, dword 0

Have a nice day.
Post 01 Jan 2012, 09:23
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.