flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
vid 23 Dec 2004, 15:03
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. |
|||
![]() |
|
vbVeryBeginner 23 Dec 2004, 16:29
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? |
|||
![]() |
|
vid 23 Dec 2004, 18:23
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. |
|||
![]() |
|
vbVeryBeginner 24 Dec 2004, 11:22
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 |
|||
![]() |
|
vid 24 Dec 2004, 14:16
Code: .union1 dd ? ; lPitch or dwLinearSize ... .union2 dd ? ; dwMiniMapCount or dwRefreshRate ... .union3 dq ? ; ddckCKDestOverlay or dwEmptyFaceColor you got it! |
|||
![]() |
|
vbVeryBeginner 24 Dec 2004, 15:59
ok,
so how the "label" plays its role? |
|||
![]() |
|
vbVeryBeginner 24 Dec 2004, 16:10
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 |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.