flat assembler
Message board for the users of flat assembler.

Index > Windows > how to create a DDSURFACEDESC2 ?

Author
Thread Post new topic Reply to topic
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
hi,
anyone has idea how to create a DDSURFACEDESC2 ?
it generate the below error
Code:
H:\win32>fasm directx_1.txt
flat assembler  version 1.56
directx_1.txt [150]:
ends
D:\FASM\1.56W\INCLUDE\\macro/struct.inc [13] struct_helper [2]:
   name name
directx_1.txt [142] DDSURFACEDESC2 [14]:
  label .ddckCKDestOverlay              DDCOLORKEY
error: extra characters on line.

    


Code:
struct DDSURFACEDESC2
        .dwSize                         dd ?
        .dwFlags                        dd ?
        .dwHeight                       dd ?
        .dwWidth                        dd ?
  label .lPitch                         dword
       .dwLinearSize                   dd ?
        .dwBackBufferCount              dd ?
  label .dwMipMapCount                  dword
       .dwRefreshRate                  dd ?
        .dwAlphaBitDepth                dd ?
        .dwReserved                     dd ?
        .lpSurface                      dd ?
  label .ddckCKDestOverlay              DDCOLORKEY
  .dwEmptyFaceColor               dd ?
        .ddckCKDestBlt                  DDCOLORKEY
  .ddckCKSrcOverlay               DDCOLORKEY
  .ddckCKSrcBlt                   DDCOLORKEY
  .ddpfPixelFormat                DDPIXELFORMAT
       .ddsCaps                        DDSCAPS
     .dwTextureStage                 dd ?
ends
    
Post 23 Dec 2004, 13:36
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
you are doing something wrong, after "label" directive must be name and then optionaly size, not structure. labels in structure are used for unions, but it is possible only to unions of basic types (byte, word, dword etc.), not structures.
But i think DDCOLORKEY is just alias for dword, so they could be all dwords. It loks like your structure description is wrong, better check some C directdraw headers.
Post 23 Dec 2004, 15:03
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
yup, just check the ddraw.h

from borland bcc
Code:
typedef struct _DDSURFACEDESC2
{
    DWORD               dwSize;
    DWORD               dwFlags;
    DWORD               dwHeight;
    DWORD               dwWidth;
    union
    {
        LONG            lPitch;
        DWORD           dwLinearSize;
    } DUMMYUNIONNAMEN(1);
    DWORD               dwBackBufferCount;
    union
    {
        DWORD           dwMipMapCount;

        DWORD           dwRefreshRate;
        DWORD           dwSrcVBHandle;
    } DUMMYUNIONNAMEN(2);
    DWORD               dwAlphaBitDepth;
    DWORD               dwReserved;
    LPVOID              lpSurface;
    union
    {
        DDCOLORKEY      ddckCKDestOverlay;
        DWORD           dwEmptyFaceColor;
    } DUMMYUNIONNAMEN(3);
    DDCOLORKEY          ddckCKDestBlt;
    DDCOLORKEY          ddckCKSrcOverlay;
    DDCOLORKEY          ddckCKSrcBlt;
    union
    {
        DDPIXELFORMAT   ddpfPixelFormat;
        DWORD           dwFVF;
    } DUMMYUNIONNAMEN(4);
    DDSCAPS2            ddsCaps;
    DWORD               dwTextureStage;
} DDSURFACEDESC2;
    


this is from MSDN,
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/ddraw7/directdraw7/ddref_2oqf.asp

Code:
typedef struct _DDSURFACEDESC2 {
    DWORD         dwSize;
    DWORD         dwFlags;
    DWORD         dwHeight;
    DWORD         dwWidth;
    union
    {
        LONG      lPitch;
        DWORD     dwLinearSize;
    } DUMMYUNIONNAMEN(1);
    DWORD         dwBackBufferCount;
    union
    {
        DWORD     dwMipMapCount;
        DWORD     dwRefreshRate;
    } DUMMYUNIONNAMEN(2);
    DWORD         dwAlphaBitDepth;
    DWORD         dwReserved;
    LPVOID        lpSurface;
    union
    {
        DDCOLORKEY    ddckCKDestOverlay;
        DWORD         dwEmptyFaceColor;
    } DUMMYUNIONNAMEN(3);
    DDCOLORKEY    ddckCKDestBlt;
    DDCOLORKEY    ddckCKSrcOverlay;
    DDCOLORKEY    ddckCKSrcBlt;
    DDPIXELFORMAT ddpfPixelFormat;
    DDSCAPS2      ddsCaps;
    DWORD         dwTextureStage;
} DDSURFACEDESC2, FAR* LPDDSURFACEDESC2; 
    


so, are they incompatible? how to solve it?
and i more question. sizeof.STRUCTURENAME counts the union as a pointer or as a union structured size?
Post 23 Dec 2004, 16:29
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
now i see, the problem is how to declare
union
{
DDCOLORKEY ddckCKDestOverlay;
DWORD dwEmptyFaceColor;
}
i suppose DDCOLORKEY is dword sized, then you can just use normal dword declaration instead of DDCOLORKEY declaration, or reverse order of arguments if you want to be sure.
Code:
truct DDSURFACEDESC2 
        .dwSize                         dd ? 
        .dwFlags                        dd ? 
        .dwHeight                       dd ? 
        .dwWidth                        dd ? 
  label .lPitch                         dword 
        .dwLinearSize                   dd ? 
        .dwBackBufferCount              dd ? 
  label .dwMipMapCount                  dword 
        .dwRefreshRate                  dd ? 
        .dwAlphaBitDepth                dd ? 
        .dwReserved                     dd ? 
        .lpSurface                      dd ? 
  label .dwEmptyFaceColor               dword
        .ddckCKDestOverlay              DDCOLORKEY 
        .ddckCKDestBlt                  DDCOLORKEY 
        .ddckCKSrcOverlay               DDCOLORKEY 
        .ddckCKSrcBlt                   DDCOLORKEY 
        .ddpfPixelFormat                DDPIXELFORMAT 
        .ddsCaps                        DDSCAPS 
        .dwTextureStage                 dd ? 
ends
    

this won't work if you have union of two structures but you can use it for this case.
Post 23 Dec 2004, 18:23
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
hi, this is what i understood from the C source, plez correct me if i am wrong.

Code:
struct DDSURFACEDESC2
      .dwSize                         dd ?
        .dwFlags                        dd ?
        .dwHeight                       dd ?
        .dwWidth                        dd ?
        .union1                         dd ?    ; lPitch or dwLinearSize
    .dwBackBufferCount              dd ?
        .union2                         dd ?    ; dwMiniMapCount or dwRefreshRate
   .dwAlphaBitDepth                dd ?
        .dwReserved                     dd ?
        .lpSurface                      dd ?
        .union3                         dq ?    ; ddckCKDestOverlay or dwEmptyFaceColor
     .ddckCKDestBlt                  DDCOLORKEY
  .ddckCKSrcOverlay               DDCOLORKEY
  .ddckCKSrcBlt                   DDCOLORKEY
  .ddpfPixelFormat                DDPIXELFORMAT
       .ddsCaps                        DDSCAPS2
    .dwTextureStage                 dd ?
ends
    


does this C Language UNION concept applies to assembly language?, somebody plez tell me.

Code:
Listing 20.2. The members of a union share the same memory location.
1:  /* 20L02.c:  Memory sharing in unions */
2:  #include <stdio.h>
3:
4:  main(void)
5:  {
6:     union employee {
7:        int start_year;
8:        int dpt_code;
9:        int id_number;
10:    } info;
11:
12:    /* initialize start_year */
13:    info.start_year = 1997;
14:    /* initialize dpt_code */
15:    info.dpt_code = 8;
16:    /* initialize id */
17:    info.id_number = 1234;
18:
19:    /* display content of union */
20:    printf("Start Year:  %d\n", info.start_year);
21:    printf("Dpt. Code:   %d\n", info.dpt_code);
22:    printf("ID Number:   %d\n", info.id_number);
23:
24:    return 0;
25: }

After the executable 20L02.exe is created and executed, the following output is displayed on the screen:

OUTPUT

C:\app>20L02
Start Year:  1234
Dpt. Code:   1234
ID Number:   1234
C:\app>
    


sincerely,
sulaiman chang
Post 24 Dec 2004, 11:22
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Code:
.union1                         dd ?    ; lPitch or dwLinearSize 
...
        .union2                         dd ?    ; dwMiniMapCount or dwRefreshRate 
... 
       .union3                         dq ?    ; ddckCKDestOverlay or dwEmptyFaceColor 
    

you got it!
Post 24 Dec 2004, 14:16
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
ok,
so how the
"label" plays its role?
Post 24 Dec 2004, 15:59
View user's profile Send private message Visit poster's website Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
yup
privalov direct draw examples clears me up

Code:
struct DDSURFACEDESC
  .dwSize            dd ?
     .dwFlags           dd ?
     .dwHeight          dd ?
     .dwWidth           dd ?
  label .dwLinearSize           dword
    .lPitch            dd ?
     .dwBackBufferCount dd ?
  label .dwZBufferBitDepth dword
  label .dwRefreshRate      dword
    .dwMipMapCount     dd ?
     .dwAlphaBitDepth   dd ?
     .dwReserved        dd ?
     .lpSurface         dd ?
     .ddckCKDestOverlay DDCOLORKEY
       .ddckCKDestBlt     DDCOLORKEY
       .ddckCKSrcOverlay  DDCOLORKEY
       .ddckCKSrcBlt      DDCOLORKEY
       .ddpfPixelFormat   DDPIXELFORMAT
    .ddsCaps           DDSCAPS
ends
    
Post 24 Dec 2004, 16:10
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.