flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > C header for DirectDraw7? |
Author |
|
revolution 18 Oct 2015, 09:16
Moved to High Level Languages.
|
|||
18 Oct 2015, 09:16 |
|
typedef 19 Oct 2015, 00:06
Write a proxy library (DLL/LIB) in FASM and you'll be set.
|
|||
19 Oct 2015, 00:06 |
|
borbonhause 19 Oct 2015, 21:21
typedef wrote: Write a proxy library (DLL/LIB) in FASM and you'll be set. That sounds really painful for some reason For starters I have to find out what each word in this line means: Code: extern HRESULT WINAPI DirectDrawCreateEx( GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid,IUnknown FAR *pUnkOuter ); In this line, GUID, FAR and IUnknown are main mysteries. Have to get this down to the basic C types somehow. |
|||
19 Oct 2015, 21:21 |
|
borbonhause 20 Oct 2015, 09:05
I'll just use this for now, I guess...
Code: extern int DirectDrawCreate( void* lpGuid, void* lplpDD, void* pUnkOuter ); Since lpGuid and pUnkOuter will always be NULL, they don't even matter. But lplpDD on the other hand, is there the fun starts. lplpDD is, let's see, is a pointer to an array of function pointers? How to describe it in C? Found good hints in header about how it should look like in the end, look at these lines: Code: STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; #if !defined(__cplusplus) || defined(CINTERFACE) #define IDirectDraw_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) #else #define IDirectDraw_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) #endif |
|||
20 Oct 2015, 09:05 |
|
borbonhause 20 Oct 2015, 09:31
Um, no, lplpDD is a pointer to a structure of function pointers, but each member of this structure still takes exactly 4 bytes, so it's not that different from an array...
|
|||
20 Oct 2015, 09:31 |
|
revolution 20 Oct 2015, 09:33
I am surprised that there is not already header/library files for C available for download.
borbonhause: Are you sure that they are not already available? |
|||
20 Oct 2015, 09:33 |
|
borbonhause 20 Oct 2015, 09:50
revolution wrote: I am surprised that there is not already header/library files for C available for download. They are available, they are just too scary to look at. Well, look for yourself: ftp://sccn.ucsd.edu/pub/LSL/lsl-dependencies/external_libs/EmbarcaderoXE/shared/4.4.0-msvc/include/ddraw.h http://blogs.msdn.com/b/oldnewthing/archive/2004/10/05/238050.aspx You may ask why the hell I even look inside instead of just including it. The reason is, well, I'm moving to a different compiler, and there are problems. So instead I'm just trying to copypaste bare minimum of stuff necessary. _________________ If you found bad grammar in my post, please PM me about it. |
|||
20 Oct 2015, 09:50 |
|
revolution 20 Oct 2015, 09:58
borbonhause wrote: They are available, they are just too scary to look at. If you want to create a new simpler one then I think that is a good idea. If you have the time and energy to do that. But specifically what problems are you having with your compiler? Is it some incompatibility? I ask because maybe you should be looking more closely at your compiler instead to make sure it is going to give you a good output. |
|||
20 Oct 2015, 09:58 |
|
borbonhause 20 Oct 2015, 16:00
revolution wrote:
Well, in fact, I'm doing the same thing with a compiler itself. I'm trying to delete or rewrite stuff I don't need, don't understand or don't like. I'm editing TCC in this way right now. Sooner or later I'll have to dig into all headers, why not to do this now. _________________ If you found bad grammar in my post, please PM me about it. |
|||
20 Oct 2015, 16:00 |
|
borbonhause 22 Oct 2015, 07:39
So, I need to turn this:
Code: #undef INTERFACE #define INTERFACE IDirectDraw DECLARE_INTERFACE_( IDirectDraw, IUnknown ) { /*** IUnknown methods ***/ STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; STDMETHOD_(ULONG,AddRef) (THIS) PURE; STDMETHOD_(ULONG,Release) (THIS) PURE; /*** IDirectDraw methods ***/ STDMETHOD(Compact)(THIS) PURE; STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *) PURE; STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * ) PURE; STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK ) PURE; STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK ) PURE; STDMETHOD(FlipToGDISurface)(THIS) PURE; STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC) PURE; STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE FAR *) PURE; STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; STDMETHOD(RestoreDisplayMode)(THIS) PURE; STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD) PURE; STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; }; into something like this: Code: struct IDirectDraw { /*HRESULT*/ int (*QueryInterface)(struct IDirectDraw *this, /*REFIID*/ int riid , void* ppvObj ); /*ULONG*/ int (*AddRef)(struct IDirectDraw *this); /*ULONG*/ int (*Release)(struct IDirectDraw *this); /*HRESULT*/ int (*Compact)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*CreateClipper)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*CreatePalette)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*CreateSurface)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*DuplicateSurface)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*EnumDisplayModes)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*EnumSurfaces)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*FlipToGDISurface)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*GetDisplayMode)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*GetFourCCCodes)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*GetGDISurface)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*GetMonitorFrequency)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*GetScanLine)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*GetVerticalBlankStatus)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*Initialize)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*RestoreDisplayMode)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*SetCooperativeLevel)(struct IDirectDraw *this, HWND a, int b); /*HRESULT*/ int (*SetDisplayMode)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); /*HRESULT*/ int (*WaitForVerticalBlank)(struct IDirectDraw *this, int __XXXXXXXXXXXX__); }; hm... Looks like that's it. It doesn't work yet, but at least it compiles. _________________ If you found bad grammar in my post, please PM me about it. |
|||
22 Oct 2015, 07:39 |
|
borbonhause 22 Oct 2015, 10:17
By the way, anyone knows where to download DirectX SDK for version 7 or 8? Currently I don't care that much about the newer versions.
|
|||
22 Oct 2015, 10:17 |
|
borbonhause 24 Oct 2015, 02:26
Just a bookmark:
http://blogs.msdn.com/b/oldnewthing/archive/2004/02/05/68017.aspx _________________ If you found bad grammar in my post, please PM me about it. |
|||
24 Oct 2015, 02:26 |
|
typedef 25 Oct 2015, 05:15
Also make sure you get the calling convention right.
|
|||
25 Oct 2015, 05:15 |
|
borbonhause 02 Nov 2015, 11:50
typedef wrote: Also make sure you get the calling convention right. Yeah, thanks for a reminder. I found out about the existence of the IDirectDrawVtbl structure. Vtbl stands for Vtable, https://en.wikipedia.org/wiki/Virtual_method_table. Also look here, he reverce engeneered one directdraw game and gave some interesting and simple to digest info http://f0dder.reteam.org/essay02.htm. IDirectDraw and IDirectDrawVtbl even filled automatically for you on creation, if you add them in IDA. I wonder where IDA holds the definitions of a structures it's familiar with... What is a preferrable name, lpDD or lplpDD? What's used more often? These are the same thing, don't they? My objective is: get a simple C program with a working DDraw in it. _________________ If you found bad grammar in my post, please PM me about it. |
|||
02 Nov 2015, 11:50 |
|
borbonhause 03 Nov 2015, 16:36
Tomorrow I'll try to bring all directdraw code examples I managed to find into one. One is very simple, but it only opens black window, no real way to see if anything actually works. Another one is good, but too complex for me. Third works in fullscreen, which somehow bugs everything and had forced me to reload a few times.
|
|||
03 Nov 2015, 16:36 |
|
borbonhause 08 Nov 2015, 10:46
Can somebody write an example of drawing green square in the black DirectDraw window? I'm kind of stuck here.
Anybody here knows DirectDraw? |
|||
08 Nov 2015, 10:46 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.