I've been using windwos game programming for dummies:grin: to learn 2d game programming with directx. I've been using the includes made by x-calibre and co. It's good stuff but sometimes confusion arises from the use of their supplied macros and the way the code is written in c/c++

I've come up with another version of the macro which I think will aid in translating c/c++ sources to asm.
I'm posting it here in case it will be useful for others...

DXINVOKE macro _func:req,_arglist:vararg
;;directx function calling macro by Martial_Code
_strt1 InStr <_func>,<[>
_strt2 InStr _strt1+1,<_func>,<[>
_end2 InStr <_func>,<]>
_end1 InStr _end2+1,<_func>,<]>
if _strt2 eq 0
_string1 SubStr <_func>,1,_strt1
_string2 SubStr <_func>,_end1
_this substr <_func>,_strt1+1,_end1-_strt1-1
mov eax,_this
mov eax,[eax]
_string1 catstr _string1,<eax>,_string2,<,>,_this
IFNB <_arglist>
; %echo invoke _string1,_arglist;testing only can remove
invoke _string1,_arglist
; %echo invoke _string1;;testing only can remove
invoke _string1

pIDDO textequ <IDirectDrawVtbl PTR>
pIDDS textequ <IDirectDrawSurfaceVtbl PTR>
pIDDP textequ <IDirectDrawPaletteVtbl PTR>
pIDDC textequ <IDirectDrawClipperVtbl PTR>

here are three exmaples which show all variations on using the macro...

DXINVOKE (pIDDS[(BITMAP_OBJ ptr[ebx]).lpimage]).mLock,NULL,edx,\


The pIDD? macros are text equates for the various direct draw interfaces.
the %echo lines can be removed and are there for checking only.
if you use the macro with these lines enabled then you will see the end result of the macro which looks like:

invoke (IDirectDrawSurfaceVtbl PTR[eax]).Release,lpddsback
invoke (IDirectDrawSurfaceVtbl PTR[eax]).Release,lpddsprimary
invoke (IDirectDrawVtbl PTR[eax]).Release,lpdd
invoke (IDirectDrawSurfaceVtbl PTR[eax]).Flip,lpddsprimary,NULL,DDFLIP_WAIT
invoke (IDirectDrawSurfaceVtbl PTR[eax]).SetPalette,lpddsprimary,lpddpal
invoke (IDirectDrawVtbl PTR[eax]).CreateSurface,lpdd,edx,ecx,NULL
invoke (IDirectDrawSurfaceVtbl PTR[eax]).SetColorKey,ecx,DDCKEY_SRCBLT,edx
invoke (IDirectDrawSurfaceVtbl PTR[eax]).UnLock,ecx,ddsd.lpSurface

An example file using the macro is attached.
note as with the x-calibre macros, you cannot pass arguments via eax since it is altered by the macro...
Posted on 2002-08-09 18:57:37 by MArtial_Code
I have the swedish translation of that book, great book. But when I've tried to write DX games (in asm[32]), I have failed :( , since I don't know how to interface with COM functions in asm (and DX is/uses COM).
It never worked for me, but I'll try now with this code and I might success.

Thanks in advance MArtial_Code for posting it, it will most likley prove useful :) . The includes by x-calibre & co you're refering to, are they included in the a masm32 package or where can I find them, and do they use DX8(.1)?
Posted on 2002-08-09 19:09:14 by scientica
I've managed to successfully convert all the examples in chapter 10. I'm in the process of debugging the various BOB functions introduced in chapter 11.

I found links on this board but I'm attaching the ddraw.inc and ddraw.lib files along with some others. you'll need the mymacros.inc file to build the project i attached to my first post.
also i think some changes had to be made to windows.inc so i've included that as well. Standard.inc contains various include/includelib statements for often used win32 includes...
Posted on 2002-08-09 19:52:08 by MArtial_Code
here's attachment
Posted on 2002-08-09 20:14:48 by MArtial_Code