object MACRO nm:REQ,ty:REQ

_DATA SEGMENT
_&nm dd 0
_DATA ENDS

&nm MACRO mth:REQ,vars:VARARG
IFB <&vars>
mcall [_&nm],ty&_&mth
ELSE
mcall [_&nm],ty&_&mth,vars
ENDIF
ENDM
ENDM

;Use it like:

object g_d3d, IDirect3D8
object g_device, IDirect3DDevice8

g_device BeginScene
g_device Clear,0,NULL,D3DCLEAR_ZBUFFER,0,fpc(1),0
g_device Release
and _g_device,0 ; make null pointer
Only problem is when you need the address of the object or object pointer. I wanted to make it when there aren't any parameters to the macro it outputs the address label, but MASM doesn't like me. ;) So, you have to prefix the object name with '_' - no biggie, but I wanted to do it he fancy way. :) This is better than it was - the source code will be clearer - IMHO. I will eventually rewrite mcall, but this is a quick fix until then.
Posted on 2001-11-19 02:22:27 by bitRAKE
Posted on 2001-12-03 02:35:53 by NaN
I'd like to solve the problem of having a local object as well. How might I create an object on the stack and then get MASM to 'remember' the type of that object - like in the macro above? Any ideas?
Posted on 2001-12-03 12:54:43 by bitRAKE
I'd like to work on this... but unfortunately this is me procrastinating for my exams :grin:

Lemme know if your still scratching your head after the 21'st :)

NaN
Posted on 2001-12-03 16:30:15 by NaN
The solution is very easy really. Just test if _&nm is defined so it's not redefined in the macro then do it like this:
SillyProc PROC

LOCAL _g_d3d:DWORD,_g_device:DWORD

object g_d3d, IDirect3D8
object g_device, IDirect3DDevice8
Funny how you can't seem to get the right angle on a problem sometimes. Luckily in time I usually work my way around it. :)
Posted on 2001-12-07 00:04:08 by bitRAKE
I have changed all my DX8 programs to Caleb's includes and using the following macro, no changes were needed to my code!
object MACRO nm:REQ,ty:REQ

_DATA SEGMENT
_&nm dd 0
_DATA ENDS

&nm MACRO mth:REQ,vars:VARARG
IFB <&vars>
coinvoke [_&nm], &ty, &mth
ELSE
coinvoke [_&nm], &ty, &mth, vars
ENDIF
ENDM
ENDM
This provides a level of abstraction like the other macro above, whereby the include interfaces used are accessed through just these macros. To change includes just swap object macros and include files.
Posted on 2002-06-15 18:32:41 by bitRAKE
Afternoon, bitRAKE.

That's a pretty useful macro.:alright:

I've used it in (this) <123kb zip> , which is just the basic matrice example, with a texture slapped on it.

As you said... people who use Calebs' include files will be able to change the macro, and the proggy will use his files :grin: .

Cheers,
Scronty
Posted on 2002-06-15 21:32:28 by Scronty
Update:
object MACRO nm:REQ,ty:REQ

IF (OPATTR _&nm) EQ 0
_DATA$obj SEGMENT
_&nm dd 0
_DATA$obj ENDS
ENDIF

&nm MACRO mth:REQ,vars:VARARG
IFB <&vars>
coinvoke [_&nm], &ty, &mth
ELSE
coinvoke [_&nm], &ty, &mth, vars
ENDIF
ENDM
ENDM
Makes this possible...
LoadMatrix4 PROC _lpDevice:LPDIRECT3DDEVICE8,creg:DWORD,matrix:PTR D3DXMATRIX

LOCAL trans:D3DXMATRIX
object lpDevice, IDirect3DDevice8 ; LPDIRECT3DDEVICE8

invoke D3DXMatrixTranspose,ADDR trans,matrix
lpDevice SetVertexShaderConstant,creg,ADDR trans,4
ret
LoadMatrix4 ENDP
Posted on 2002-06-16 12:10:32 by bitRAKE