Permalink
Browse files

Initial work

  • Loading branch information...
0 parents commit 53137e4d8d3c3def286f98b1ff19c8aaa15d42a0 @hifi committed Oct 10, 2010
Showing with 4,082 additions and 0 deletions.
  1. +5 −0 Makefile
  2. +4 −0 ddraw.def
  3. +3,791 −0 ddraw.h
  4. +160 −0 main.c
  5. +18 −0 palette.c
  6. +45 −0 palette.h
  7. +18 −0 surface.c
  8. +41 −0 surface.h
@@ -0,0 +1,5 @@
+all:
+ i586-mingw32msvc-gcc -Wall -Wl,--enable-stdcall-fixup -shared -s -o ddraw.dll main.c palette.c surface.c ddraw.def
+
+clean:
+ rm -f ddraw.dll
@@ -0,0 +1,4 @@
+LIBRARY ddraw.dll
+
+EXPORTS
+ DirectDrawCreate @1
3,791 ddraw.h

Large diffs are not rendered by default.

Oops, something went wrong.
160 main.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2010 Toni Spets <toni.spets@iki.fi>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include "ddraw.h"
+
+#include "palette.h"
+#include "surface.h"
+
+typedef struct
+{
+ /* IUnknown */
+ HRESULT (*QueryInterface)(void *, REFIID, void **);
+ ULONG (*AddRef)(void *);
+ ULONG (*Release)(void *);
+
+ /* IDirectDraw */
+ HRESULT (*Compact)(void *);
+ HRESULT (*CreateClipper)(void *);
+ HRESULT (*CreatePalette)(void *, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR *, IUnknown FAR *);
+ HRESULT (*CreateSurface)(void *, LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *);
+ HRESULT (*DuplicateSurface)(void *);
+ HRESULT (*EnumDisplayModes)(void *);
+ HRESULT (*EnumSurfaces)(void *);
+ HRESULT (*FlipToGDISurface)(void *);
+ HRESULT (*GetCaps)(void *);
+ HRESULT (*GetDisplayMode)(void *);
+ HRESULT (*GetFourCCCodes)(void *);
+ HRESULT (*GetGDISurface)(void *);
+ HRESULT (*GetMonitorFrequency)(void *);
+ HRESULT (*SetScanLine)(void *);
+ HRESULT (*GetVerticalBlankStatus)(void *);
+ HRESULT (*Initialize)(void *);
+ HRESULT (*RestoreDisplayMode)(void *);
+ HRESULT (*SetCooperativeLevel)(void *, HWND, DWORD);
+ HRESULT (*SetDisplayMode)(void *, DWORD, DWORD, DWORD, DWORD, DWORD);
+ HRESULT (*WaitForVerticalBlank)(void *);
+} fakeDirectDraw;
+
+typedef struct
+{
+ fakeDirectDraw *Functions;
+
+ ULONG Ref;
+
+} fakeDirectDrawObject;
+
+HRESULT ddraw_CreatePalette(void *This, LPPALETTEENTRY DDColorArray, LPDIRECTDRAWPALETTE FAR * DDPalette, IUnknown FAR * unkOuter)
+{
+ printf("DirectDraw::CreatePalette(This=%p, DDColorArray=%p, DDPalette=%p, unkOuter=%p)\n", This, DDColorArray, DDPalette, unkOuter);
+ return DD_OK;
+}
+
+HRESULT ddraw_CreateSurface(void *This, LPDDSURFACEDESC DDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *DDSurface, IUnknown FAR * unkOuter)
+{
+ printf("DirectDraw::CreateSurface(This=%p, DDSurfaceDesc=%p, DDSurface=%p, unkOuter=%p)\n", This, DDSurfaceDesc, DDSurface, unkOuter);
+ return DD_OK;
+}
+
+HRESULT ddraw_SetCooperativeLevel(void *This, HWND hWnd, DWORD dwFlags)
+{
+ printf("DirectDraw::SetCooperativeLevel(This=%p, hWnd=0x%08X, dwFlags=0x%08X)\n", This, (unsigned int)hWnd, (unsigned int)dwFlags);
+ return DD_OK;
+}
+
+HRESULT ddraw_SetDisplayMode(void *This, DWORD width, DWORD height, DWORD bpp, DWORD refreshRate, DWORD flags)
+{
+ printf("DirectDraw::SetDisplayMode(This=%p, width=%d, height=%d, bpp=%d, refreshRate=%d, flags=0x%08X)\n",
+ This, (unsigned int)width, (unsigned int)height, (unsigned int)bpp, (unsigned int)refreshRate, (unsigned int)flags);
+ return DD_OK;
+}
+
+HRESULT QueryInterface(void *This, REFIID riid, void **obj)
+{
+ printf("QueryInterface(This=%p, riid=%08X, obj=%p)\n", This, (unsigned int)riid, obj);
+ return S_OK;
+}
+
+ULONG AddRef(void *This)
+{
+ printf("AddRef(This=%p)\n", This);
+ ((fakeDirectDrawObject *)This)->Ref++;
+ return ((fakeDirectDrawObject *)This)->Ref;
+}
+
+ULONG Release(void *This)
+{
+ printf("Release(This=%p)\n", This);
+ ((fakeDirectDrawObject *)This)->Ref--;
+
+ if(((fakeDirectDrawObject *)This)->Ref == 0)
+ {
+ free(This);
+ return 0;
+ }
+
+ return ((fakeDirectDrawObject *)This)->Ref;
+}
+
+HRESULT null()
+{
+ printf("Warning: null method called!\n");
+ return DD_OK;
+}
+
+fakeDirectDraw iface =
+{
+ /* IUnknown */
+ QueryInterface,
+ AddRef,
+ Release,
+ /* IDirectDraw */
+ null, //Compact,
+ null, //CreateClipper,
+ ddraw_CreatePalette,
+ ddraw_CreateSurface,
+ null, //DuplicateSurface,
+ null, //EnumDisplayModes,
+ null, //EnumSurfaces,
+ null, //FlipToGDISurface,
+ null, //GetCaps,
+ null, //GetDisplayMode,
+ null, //GetFourCCCodes,
+ null, //GetGDISurface,
+ null, //GetMonitorFrequency,
+ null, //GetScanLine,
+ null, //GetVerticalBlankStatus,
+ null, //Initialize,
+ null, //RestoreDisplayMode,
+ ddraw_SetCooperativeLevel,
+ ddraw_SetDisplayMode,
+ null //WaitForVerticalBlank
+};
+
+HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnknown FAR* pUnkOuter)
+{
+ printf("DirectDrawCreate(lpGUID=%p, lplpDD=%p, pUnkOuter=%p)\n", lpGUID, lplpDD, pUnkOuter);
+
+ fakeDirectDrawObject *This = (fakeDirectDrawObject *)malloc(sizeof(fakeDirectDrawObject));
+ This->Ref = 1;
+ This->Functions = &iface;
+ printf(" This = %p\n", This);
+ *lplpDD = (LPDIRECTDRAW)This;
+
+ return DD_OK;
+}
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2010 Toni Spets <toni.spets@iki.fi>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <windows.h>
+#include "palette.h"
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010 Toni Spets <toni.spets@iki.fi>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef PALETTE_H
+#define PALETTE_H
+
+#include <windows.h>
+#include "ddraw.h"
+
+typedef struct
+{
+ /* IUnknown */
+ HRESULT (*QueryInterface)(void *, REFIID, void **);
+ ULONG (*AddRef)(void *);
+ ULONG (*Release)(void *);
+
+ /* IDirectDrawPalette */
+ HRESULT (*GetCaps)(void *, LPDWORD);
+ HRESULT (*GetEntries)(void *, DWORD, DWORD, DWORD, LPPALETTEENTRY);
+ HRESULT (*Initialize)(void *, LPDIRECTDRAW, DWORD, LPPALETTEENTRY);
+ HRESULT (*SetEntries)(void *, DWORD, DWORD, DWORD, LPPALETTEENTRY);
+} fakeDirectDrawPalette;
+
+typedef struct
+{
+ fakeDirectDrawPalette *Functions;
+
+ ULONG Ref;
+
+} fakeDirectDrawPaletteObject;
+
+#endif
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2010 Toni Spets <toni.spets@iki.fi>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <windows.h>
+#include "surface.h"
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010 Toni Spets <toni.spets@iki.fi>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef SURFACE_H
+#define SURFACE_H
+
+#include <windows.h>
+#include "ddraw.h"
+
+typedef struct
+{
+ /* IUnknown */
+ HRESULT (*QueryInterface)(void *, REFIID, void **);
+ ULONG (*AddRef)(void *);
+ ULONG (*Release)(void *);
+
+ /* IDirectDrawSurface */
+} fakeDirectDrawSurface;
+
+typedef struct
+{
+ fakeDirectDrawSurface *Functions;
+
+ ULONG Ref;
+
+} fakeDirectDrawSurfaceObject;
+
+#endif

0 comments on commit 53137e4

Please sign in to comment.