....(deleted)
Read down there
Posted on 2003-02-28 07:17:35 by Johannson
It looks like a directdraw include problem to me... probably the direct3D version 8 includes redefine some of the constants and structures in directdraw version 7 includes... can not say more without checking both includes ...

you should grab the Chris Hobbs tetris example for a simple 2D DirectDraw based game and grow from there .... IMHO :)

besides that, ... i would not use PM_REMOVE in the PeekMessage function
Posted on 2003-02-28 16:22:07 by BogdanOntanu
thanks for the answer, i completely rewrote the stuff and i'm currently using other .inc files....
a new problem occured :)

push DDSCL_EXCLUSIVE OR DDSCL_FULLSCREEN
push handle
mov eax,
push eax
mov eax,
call DWORD PTR


This is my SetCooperativeLevel method for example. But it never returns DD_OK; always an error. So maybe i'm just using the wrong call.
In my ddraw.def file IDirectDraw7 is declared as following:


;>>>>>>>>>>>>>>> IDirectDraw7 <<<<<<<<<<<<<<<
DECLARE_INTERFACE <IDirectDraw7_>
; /*** IUnknown methods ***/
INHERIT_IUnknown
; /*** IDirectDraw methods ***/
STDMETHOD <Compact>
STDMETHOD <CreateClipper>,:DWORD,:DWORD,:DWORD
STDMETHOD <CreatePalette>,:DWORD,:DWORD,:DWORD,:DWORD
STDMETHOD <CreateSurface>,:DWORD,:DWORD,:DWORD
STDMETHOD <DuplicateSurface>,:DWORD,:DWORD
STDMETHOD <EnumDisplayModes>,:DWORD,:DWORD,:DWORD,:DWORD
STDMETHOD <EnumSurfaces>,:DWORD,:DWORD,:DWORD,:DWORD
STDMETHOD <FlipToGDISurface>
STDMETHOD <GetCaps>,:DWORD,:DWORD
STDMETHOD <GetDisplayMode>,:DWORD
STDMETHOD <GetFourCCCodes>,:DWORD,:DWORD
STDMETHOD <GetGDISurface>,:DWORD
STDMETHOD <GetMonitorFrequency>,:DWORD
STDMETHOD <GetScanLine>,:DWORD
STDMETHOD <GetVerticalBlankStatus>,:DWORD
STDMETHOD <Initialize>,:DWORD
STDMETHOD <RestoreDisplayMode>
STDMETHOD <SetCooperativeLevel>,:DWORD,:DWORD
; /*** SetDisplayMode changed in v2 ***/
; /*** dwRefreshRate & dwFlags added ***/
STDMETHOD <SetDisplayMode>,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
STDMETHOD <WaitForVerticalBlank>,:DWORD,:DWORD
; /*** Added in the v2 interface ***/
; /*** IDirectDraw2 methods ***/
STDMETHOD <GetAvailableVidMem>,:DWORD,:DWORD,:DWORD
; /*** Added in the V4 Interface ***/
; /*** IDirectDraw7 methods ***/
STDMETHOD <GetSurfaceFromDC>,:DWORD,:DWORD
STDMETHOD <RestoreAllSurfaces>
STDMETHOD <TestCooperativeLevel>
STDMETHOD <GetDeviceIdentifier>,:DWORD,:DWORD
STDMETHOD <StartModeTest>,:DWORD,:DWORD,:DWORD
STDMETHOD <EvaluateMode>,:DWORD,:DWORD

LPDIRECTDRAW7 typedef PTR


any suggestions?
Posted on 2003-02-28 16:25:55 by Johannson
This is HE code and it works...looks the same as yours...

DDO_SetCooperativeLevel is equ to 80 in my include
the order of the methods looks like yours also... hiwever you should check (via a print) the above value... your <STDMETHOD> is more complex :))



;===============================
; 2. Greedly set the coperative level so that it's in exclusive mode
;===============================
push (DDSCL_EXCLUSIVE OR DDSCL_FULLSCREEN OR DDSCL_ALLOWREBOOT)

mov eax,[hwndmain]
push eax

mov eax,[lpDD]
push eax ; DD Object

mov eax,[eax] ; vtable addr
call [eax+DDO_SetCooperativeLevel] ; call address for SetCooperativeLevel

;check for error
.IF eax != DD_OK
Call OutputDebugStringA, offset szSetCooperativeLevelFail
jmp end_loop
.ENDIF
Posted on 2003-02-28 17:21:33 by BogdanOntanu
Thanks again :)

The only problem is,in my .def file ,there are no numbers set at all (like DDO_SetCooperativeLevel is equ to 80). So i just used the name IDirectDraw7_ and the function name with the call. But dunno what to do now
Posted on 2003-02-28 17:29:35 by Johannson
What error code do you get instead of DD_OK?

Besides use a debug print function to print the value of IDirectDraw7_SetCooperativeLevel same for returne error code


like:


mov eax,IDirectDraw7_SetCooperativeLevel
invoke dwoa,eax,offset debug_string
invoke OutputDebugStringA,offset debugstring


well not exactlly like that but i hope you get the ideea
Posted on 2003-02-28 18:17:14 by BogdanOntanu
eax contains 80070057h after the call
IDirectDraw7_SetCooperativeLevel is 50...

according to ollydebug :)
Posted on 2003-02-28 18:51:01 by Johannson
Well AFAIK the 80070057h is invalid parameters
And 50h=80decimal so that looks like ok

maybe you should check

the: push
or the: push

are you sure that the DirectDrawCreate function returned the right lpDD ?

or maybe the DDSCL_EXCLUSIVE OR DDSCL_FULLSCREEN are not having the right value?
here are my includes for those flags


;========================
; SETCOOPERATIVELEVEL FLAGS
;========================
DDSCL_FULLSCREEN = 00000001h
DDSCL_ALLOWREBOOT = 00000002h
DDSCL_NOWINDOWCHANGES = 00000004h
DDSCL_NORMAL = 00000008h
DDSCL_EXCLUSIVE = 00000010h
DDSCL_ALLOWMODEX = 00000040h
Posted on 2003-02-28 19:10:03 by BogdanOntanu
DDInit PROC handle:DWORD

inv DirectDrawCreate, NULL, OFFSET lpDD, NULL

.IF eax != DD_OK
inv Fehler, handle, OFFSET sZDDObjekt
invoke ExitProcess, 0
ret
.ENDIF

and that's the only thing in front of the setcooplevel method...maybe something's wrong there?
Posted on 2003-02-28 19:10:03 by Johannson
I do not know if in MASM you can use invoke with offset
i guess you should use ADDR

because invoke is a macro AFAIK, however TASM uses "call" and "offset" so take care at conversions
Posted on 2003-02-28 19:14:00 by BogdanOntanu
hmm..i tried everything you said...nothing worked....offset is just fine....well..i dunno what's wrong..

.DATA
lpDD LPDIRECTDRAW7 0


DDInit PROC handle:DWORD

inv DirectDrawCreate, NULL, OFFSET lpDD, NULL ;DirectDraw7 Objekt

.IF eax != DD_OK
inv Fehler, handle, OFFSET sZDDObjekt
invoke ExitProcess, 0
ret
.ENDIF


push DDSCL_EXCLUSIVE OR DDSCL_FULLSCREEN
mov eax,handle
push eax
mov eax,lpDD
push eax
mov eax,
call DWORD PTR


.IF eax != DD_OK
inv Fehler, handle, OFFSET sZDDCooperativeLevel
invoke ExitProcess, 0
ret
.ENDIF


That's the whole code..and i can't really find an error.....maybe it still has to do with eh eax + ????
Posted on 2003-02-28 19:17:14 by Johannson
But then again i doubt you will get "invalid params" return is lpDD is not valid, more likely a GPF :(

check the parameters of SetCooperativeLevel like the winmain handle is it ok?

Also i do NOT think you can use Olly to debug DirectX full screen applications... it will prevent you from switching to fullscreeen or you will not see it if sucessfully :(
Posted on 2003-02-28 19:17:15 by BogdanOntanu
check post above ;)
Posted on 2003-02-28 19:19:36 by Johannson
The thing is,i doesn't even switch to full mode,i'm far away from that ;)
and here's the rest of the code...till DDinit is invoked

start:
inv GetModuleHandle, NULL
mov hInstance, eax
inv GetCommandLine
mov CommandLine, eax
inv WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
inv ExitProcess, eax

winmain:
blablabla window creation......
mov hWnd, eax
inv ShowWindow, hWnd, SW_SHOWDEFAULT
inv DDInit, hWnd
Posted on 2003-02-28 19:23:47 by Johannson
Well,

For sure you do not have an IDirectDraw7 interface using DirectDrawCreate...you must use QuerryInterface with the right IID_ for the interface, all you get is IDirectDraw1 interface ... however this is not the problem now :(

It HAS to BE one of your parameters, most likely the "handle"... sice LpDD looks ok (DirectDraw create returns ok?) and the Method index is also the same as my own code (that works :) )

Hmmm "handle" is quite an common name, maybe it is a good ideea to rename it to something more peculiar... and avoid namespace colisions... (just paranoia now)
Posted on 2003-02-28 21:35:49 by BogdanOntanu
Bogdan,i'm trying it with mcall right now.

Just one question...IID_IDirectDraw7 is defined as what and where?
Posted on 2003-03-01 07:39:45 by Johannson
Ah fuck that crap, i tried everything now..set

IID_IDirectDraw7 dd 015e65ec0h
dw 03b9ch,011d2h
db 0b9h,02fh,000h,060h,097h,097h,0eah,05bh

btw....don't know if that's right!copied it from another asm.file...

but always the same..can't set cooperative level...BAH!
Posted on 2003-03-01 08:01:58 by Johannson
hmm bogdan,i completely rewrote the stuff....seems to work now..at least the initialisation...but the programm just quits after getting called....i'll fix that...
Posted on 2003-03-01 14:32:44 by Johannson