Is this possible? Or is there some marco that covers this? Here's the code:


OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

Render PROC PUBLIC
LOCAL D3D[0]:_D3D

mov .EBP,ebp
mov ebp,[D3Dvt]

push 0
push one
push 0FF0000FFh
push D3DCLEAR_TARGET
push 0
push 0
push [g_pd3dDevice]
call D3D.Clear

push [g_pd3dDevice]
call D3D.BeginScene

push [g_pd3dDevice]
call D3D.EndScene

push 0
push 0
push 0
push 0

push [g_pd3dDevice]
call D3D.Present

mov ebp,.EBP
ret
Render endp

OPTION PROLOGUE:PROLOGUEDEF
OPTION EPILOGUE:EPILOGUEDEF

It's Direct3D 9. I'm highjacking ebp. So call D3D.Clear is really something like call . I'd really like to find a way to put all those pushes on the same line like invoke.

Thanks.
Posted on 2003-03-27 06:39:27 by ThoughtCriminal
Here is a snippet from a window procedure that invokes via a register. The important part is in blue color, the rest serves as an example of usage. The assumptions are: "currentWndProc" holds either the address of a function (then call it) or zero (then don't call it). Those functions, in turn, return zero if they handle the message, or something else if they don't.


.DATA
currentWndProc dd 0 ; the current plug-in's window procedure

.CODE

; Application window procedure

App_WndProc proc hWnd, uMsg, wParam, lParam

; Pass Msg to plug-in, if possible (if so, then EAX must not be 0)

mov eax, currentWndProc
test eax, eax ; any plug-in active?
je @F

[COLOR=blue] lpfnWndProc typedef PROTO :DWORD, :DWORD, :DWORD, :DWORD
invoke lpfnWndProc ptr (eax), hWnd, uMsg, wParam, lParam[/COLOR]
test eax, eax ; Msg handled by plug-in?
jz @done

; Arriving here? ==> No plug-in active, or Msg not handled

@@: cmp uMsg, WM_LBUTTONDOWN
je @wmlbuttondown

; remainder of the window procedure snipped

Regards, Frank
Posted on 2003-03-27 07:28:55 by Frank
Another example:




.386
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

myproto typedef proto :dword,:dword,:dword,:dword

.data
msg db 'How are you?',0
capt db 'Hello my friend!',0
.data?
.code
start:
mov eax,MessageBox
invoke myproto ptr eax,0,addr msg,addr capt,MB_OK
invoke ExitProcess,0
end start

Posted on 2003-03-27 07:50:04 by Vortex
Thanks! My quick test works great:


invoke CD3D PTR D3D.Clear,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL

Still learning new uses for TYPEDEF :grin:
Posted on 2003-03-28 00:54:48 by ThoughtCriminal
Alright, this is even more of a challenge.....


LCALL@4 TYPEDEF proto :dword
FCALL@4 TYPEDEF PTR LCALL@4

vt@0 EQU FCALL@0 PTR
.
.
Render PROC PUBLIC
LOCAL D3D[0]:_D3D
mov .EBP,ebp
mov ebp,[D3Dvt]

invoke vt@28 D3D.Clear,[g_pd3dDevice] ,0,0,D3DCLEAR_TARGET,0FF0000FFh,f1x0,0

invoke vt@4 D3D.BeginScene,[g_pd3dDevice]

invoke vt@4 D3D.EndScene,[g_pd3dDevice]

invoke vt@20 D3D.Present,[g_pd3dDevice],0,0,0,0

mov ebp,.EBP
ret
Render endp

I'm making it more compact by combining the type and the pointer operator, but I'd like to compact it more.
I'd like to be able to say something like:

invoke DevClear, where it will expand to invoke vt@28 D3D.Clear, but the stucture is giving me some problems. Is there a way to reference a structure member in an equate? ie:

DevClear TEXTEQU vt@28 D3D.Clear

or

DevClear EQU vt@28 D3D.Clear

or

?

So far I get A2076: jump destination must specify a label.

I would like to wrap this up so the invokes already know the number of parameters.

Any ideas?

Thanks.
Posted on 2003-03-28 04:32:09 by ThoughtCriminal
If anyone is curious.....

DevClear TEXTEQU <vt@28 D3D.Clear>

Works and lets me hide some uneeded 'code bloat'.
Posted on 2003-03-29 10:28:29 by ThoughtCriminal
Something like this works for me:
	LCALL@0 TYPEDEF proto

FCALL@0 TYPEDEF PTR LCALL@0

LCALL@4 TYPEDEF proto :dword
FCALL@4 TYPEDEF PTR LCALL@4



xObject STRUCT
Copy FCALL@4 PTR ?
Release FCALL@0 PTR ?
Set FCALL@4 PTR ?
xObject ENDS


Render PROC
LOCAL oTemp[0]:xObject

invoke [oTemp].Copy, eax

ret
Render ENDP
All the type stuff can be put into the structure.
Posted on 2003-03-29 10:54:42 by bitRAKE
Thanks! It looks like the direction I'm headed. I'm not sure if that will work will a com vtable however. So I still might have to adjust ebp to the start of the table.

Does the invoke make it a call to an offset from ebp?


.
.
.
.
.


Just tried it. My original method structure had every method as a DWORD. I guess I missed that I could put the type info there instead :rolleyes: . Thanks BitRAKE.

I like the pre-appending:

invoke .Clear, ,0,0,D3DCLEAR_TARGET,0FF0000FFh,f1x0,0

That will take care of problems for which COM objects Release method I'm calling.
:alright:
Posted on 2003-03-29 23:08:45 by ThoughtCriminal