Hello assembly-community !! :)

I want to use DirectX with _NASM_ and now i run into some
little problems.
Setting a screen-resolution works fine, but i cant get
the CreateSurface Method to work.


Everything is fine. I get my screen in the Resolution i want
(800x600x32 | 320x200x32 | 1600x1200x32 | ... ).

Next step is to create a surface, but i get a DDERR_INVALIDEPARAMS
error -> so it looks like my DDSURFACEDESC2 structure isnt right.

Thats from the DX7-SDK:

typedef struct _DDSURFACEDESC2 {
DWORD dwSize;
DWORD dwFlags;
DWORD dwHeight;
DWORD dwWidth;

LONG lPitch;
DWORD dwLinearSize;

DWORD dwBackBufferCount;

DWORD dwMipMapCount;
DWORD dwRefreshRate;

DWORD dwAlphaBitDepth;
DWORD dwReserved;
LPVOID lpSurface;

DDCOLORKEY ddckCKDestOverlay;
DWORD dwEmptyFaceColor;

DDCOLORKEY ddckCKSrcOverlay;
DDPIXELFORMAT ddpfPixelFormat;
DDSCAPS2 ddsCaps;
DWORD dwTextureStage;

Hmmmm... i cant use UNION in my program, so i read a text
about it -> Thats what i understood:
-- UNIONS are references to the same memory, but mostly
-- used to access different data types on the same memory location.

So i would translate:

DDCOLORKEY ddckCKDestOverlay;
DWORD dwEmptyFaceColor;

to 2 simple DWORD values:

dwColorSpaceLowValue: RESD 1
dwColorSpaceHighValue: RESD 1

Now i think "dwEmptyFaceColor" is the same as "dwColorSpaceLowValue".
Hope thats right so far...

Can anybody help me with this little Problem please ??
I can only use NASM, and i want to know how this
UNIONS look _low-level_: is it only 1 dword, or is it 5 dwords ?? ;)

Another Problem for a NASM user:

I?m now using DirectDrawCreate() to make my DX-Object.
I dont know which Version of DX is used for this function
(i have DX8.0a installed), so i want to use DirectDrawCreateEx().

Its the same like DirectDrawCreate(), but has a new
Parameter "REFIID iid" for compatibility.
I want to use DirectX 7, so i need to call this function
with "IID_IDirectDraw7". I think thats a GUID (or so..).

Now i found the following:
IID_IDirectDraw7 = <{015e65ec0h,03b9ch,011d2h,{0b9h,02fh,000h,060h,097h,097h,0eah,05bh}}>

Nice... :confused:

That looks like C/C++ or MASM, not like low level assembly.
How can i translate that to plain assembly - to simple bytes ??

Is it a String i pass to DirectDrawCreateEx(), or is it
a pointer to a memory location where i write this
values to ??

Hope somebody can tell me how i can simply use this
GUID the low-level-way.

IID_IDirectDraw7: db "{015e65ec0h,03b9ch,011d2h,{0b9h,02fh,000h,060h,097h,097h,0eah,05bh}}",0
doesnt seem to work... :confused:

And before you ask: :tongue:
Yes, i?ve read everything from Ernie and from Caleb etc...
...but most stuff is high-level MASM, not plain ASM like NASM -
so i have some little problems to understand some things.

Keep up the good work, guys (greets to Ernie and Caleb) !! :alright:

Posted on 2002-03-03 12:59:00 by Danilo
Hi Danilo !

The token UNION means that the structure-elements within a UNION-constructs refers all to the same position (and alloc the same memory-size (which is the one of the largest element within)) so instead of adding both elements you must take only one of them: namely the one with the biggest size !

In your "example" both types are dwords, so it doesn't matter which one you use ...

One of the possible mistakes with DirectDraw->CreateSurface is that the versions of both the method and the parameters (structures) must be the same. So if you have opened a DirectDraw7-interface and you call the method CreateSurface then you have to use the DDSURFACEDESC7 structure.
Another mistake could be that the structure isn't proper initialized. So the field dwsize must be filled with the right value (sizeof DDSURFACEDESC7) !

Here is a list of fields, which must be initialized (ddsd is the surface description structure):


I hope this will help you ...

Greetings, CALEB
Posted on 2002-03-03 16:47:01 by Caleb
Hello Caleb !!

>One of the possible mistakes with DirectDraw->CreateSurface is that
>the versions of both the method and the parameters (structures)
>must be the same

Sure, i know.

But with DirectDrawCreate() i cant say which Version
of DX i want to use.
I got now DirectDrawCreateEx() to work with the
GUID "IID_IDirectDraw7" and everything works fine. :cool:
(Didnt know how the GUID is represented in memory)

Thanks for your help, Caleb !! :alright:

Posted on 2002-03-04 14:28:24 by Danilo