Archived

This topic is now archived and is closed to further replies.

MindFlayer

DirectX8 & Asm!

Recommended Posts

OK. I know how to code win32 & GDI in asm but DirectX brings me some difficulties... Does someone know any tutorials on DirectX-asm? Press any key to continue or any other key to quit...

Share this post


Link to post
Share on other sites
there are some on this site. just go to the tutorials section.


Never underestimante the power of stupid people in large groups.

Share this post


Link to post
Share on other sites
I have exactly opposite problem. Meaning, I know exactly how to use DirectX with asm, but doing the same in C++ brings me LOTS of difficulties (no kidding). So, if you wanna ask a concrete question, either ask it here or mail me.

Share this post


Link to post
Share on other sites
Thanks for replying Friday13!

My problem is this:
Normally I would create a D3D-object in C++ like this:

    
LPDIRECT3D8 g_pD3D = NULL;

// Then I would get the current desktop display mode, so I can set up a backbuffer of the same format.


D3DDISPLAYMODE d3ddm;

if( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) ) { ... }


I have no idea how to implement the above code to ASM. That call to GetAdapterDisplayMode() is really strange to do in ASM. Oh yeah, I didn't mention earlier, I am using only Turbo Assembler and I don't know if MASM is better... Does someone know about that?

-Viljami Korhonen




Press any key to continue or any other key to quit...

Edited by - MindFlayer on August 3, 2001 5:51:14 AM

Edited by - MindFlayer on August 3, 2001 5:52:43 AM

Share this post


Link to post
Share on other sites
Well, unless you''ve omitted some code, I wouldn''t
think calling NULL->SomeMethod may be advisable.

Normally, what you do first is obtain a valid
interface to D3D8, like this:

push 120 ;D3D_SDK_VERSION
call Direct3DCreate8

;no-zero means success

or eax,eax
jnz got_d3d8

;else error
call HandleError
jmp BailOut

got_d3d8:
mov [D3D8],eax
------------------------------------------

You call the methods of any interface like this:
...
push param3
push param2
push param1

mov eax,[Interface]
push eax
mov ecx,[eax]
call dword ptr [ecx+MethodOrdinal*4]


where MethodOrdinal is the method''s order of appearance in
d3d8.h file. For instance, GetAdapterDisplayMode appears 8th
(starting with 0 for QueryInterface) in the list of IDirect3D8 methods, so you call it like this:

push offset My_D3DDISPLAYMODE
push AdapterNo

mov eax,[D3D8]
push eax
mov ecx,[eax]
call dword ptr [ecx+8*4] ;means D3D8->GetAdapterDisplayMode

;zero means success

or eax, eax
jz EverythingOK

;else error

;--------------------------------------------------

I personally use MASM ''cos TASM doesn''t understand MMX and SSE,
but generally I don''t really think there''s big difference.

Share this post


Link to post
Share on other sites
Afternoon, MindFlayer.

There are some examples of DX8 in assembly (using MASM) here:
http://www16.brinkster.com/scronty/

Cheers,
Scronty

- Has the world gone mad, or am I at work?"

Share this post


Link to post
Share on other sites
Thanks for you too, Scronty. I''ll check those tutorials when my Internet connection agrees with me .

Press any key to continue or any other key to quit...

Share this post


Link to post
Share on other sites