2010-10-10 19:41:47 +03:00
|
|
|
/*
|
|
|
|
* 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>
|
2010-10-16 22:10:25 +03:00
|
|
|
#include <stdio.h>
|
2010-10-17 00:41:14 +03:00
|
|
|
|
|
|
|
#include "main.h"
|
2010-10-10 19:41:47 +03:00
|
|
|
#include "surface.h"
|
2010-10-16 21:14:26 +03:00
|
|
|
|
2010-11-06 08:28:11 +02:00
|
|
|
void dump_ddscaps(DWORD dwCaps);
|
|
|
|
void dump_ddsd(DWORD dwFlags);
|
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_QueryInterface(IDirectDrawSurfaceImpl *This, REFIID riid, void **obj)
|
2010-10-17 21:38:40 +03:00
|
|
|
{
|
|
|
|
printf("DirectDrawSurface::QueryInterface(This=%p, riid=%08X, obj=%p)\n", This, (unsigned int)riid, obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
ULONG __stdcall ddraw_surface_AddRef(IDirectDrawSurfaceImpl *This)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
|
|
|
printf("DirectDrawSurface::AddRef(This=%p)\n", This);
|
|
|
|
This->Ref++;
|
|
|
|
return This->Ref;
|
|
|
|
}
|
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
ULONG __stdcall ddraw_surface_Release(IDirectDrawSurfaceImpl *This)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-23 17:04:01 +03:00
|
|
|
printf("DirectDrawSurface::Release(This=%p)\n", This);
|
2010-10-16 22:10:25 +03:00
|
|
|
|
|
|
|
This->Ref--;
|
|
|
|
|
|
|
|
if(This->Ref == 0)
|
|
|
|
{
|
2017-11-12 16:10:15 +01:00
|
|
|
if (ddraw->render.thread)
|
|
|
|
{
|
|
|
|
HANDLE thread = ddraw->render.thread;
|
|
|
|
ddraw->render.thread = NULL;
|
|
|
|
WaitForSingleObject(thread, INFINITE);
|
|
|
|
}
|
|
|
|
|
2010-11-06 08:28:11 +02:00
|
|
|
if(This->caps == DDSCAPS_PRIMARYSURFACE)
|
2010-10-17 21:38:40 +03:00
|
|
|
{
|
2010-11-15 22:25:12 +02:00
|
|
|
EnterCriticalSection(&ddraw->cs);
|
|
|
|
ddraw->primary = NULL;
|
|
|
|
LeaveCriticalSection(&ddraw->cs);
|
2010-10-17 21:38:40 +03:00
|
|
|
}
|
2010-10-16 22:10:25 +03:00
|
|
|
if(This->surface)
|
|
|
|
{
|
2010-11-16 17:32:31 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->surface);
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 21:38:40 +03:00
|
|
|
if(This->palette)
|
|
|
|
{
|
2010-10-23 17:04:01 +03:00
|
|
|
IDirectDrawPalette_Release(This->palette);
|
2010-10-17 21:38:40 +03:00
|
|
|
}
|
2010-11-18 16:47:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2010-10-16 22:10:25 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return This->Ref;
|
|
|
|
}
|
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_AddAttachedSurface(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWSURFACE lpDDSurface)
|
2010-10-17 08:44:48 +03:00
|
|
|
{
|
2010-10-23 17:04:01 +03:00
|
|
|
printf("DirectDrawSurface::AddAttachedSurface(This=%p, lpDDSurface=%p)\n", This, lpDDSurface);
|
2010-11-08 18:30:14 +02:00
|
|
|
IDirectDrawSurface_AddRef(lpDDSurface);
|
2010-10-17 08:44:48 +03:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 19:54:45 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_AddOverlayDirtyRect(IDirectDrawSurfaceImpl *This, LPRECT a)
|
|
|
|
{
|
|
|
|
printf("DirectDrawSurface::AddOverlayDirtyRect(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestRect, LPDIRECTDRAWSURFACE lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-23 17:04:01 +03:00
|
|
|
IDirectDrawSurfaceImpl *Source = (IDirectDrawSurfaceImpl *)lpDDSrcSurface;
|
2010-10-17 14:19:48 +03:00
|
|
|
|
2010-10-17 20:11:38 +03:00
|
|
|
#if _DEBUG
|
2010-10-16 22:10:25 +03:00
|
|
|
printf("DirectDrawSurface::Blt(This=%p, lpDestRect=%p, lpDDSrcSurface=%p, lpSrcRect=%p, dwFlags=%d, lpDDBltFx=%p)\n", This, lpDestRect, lpDDSrcSurface, lpSrcRect, (int)dwFlags, lpDDBltFx);
|
2010-10-17 09:36:48 +03:00
|
|
|
if(lpDestRect)
|
|
|
|
{
|
|
|
|
printf(" dest: l: %d t: %d r: %d b: %d\n", (int)lpDestRect->left, (int)lpDestRect->top, (int)lpDestRect->right, (int)lpDestRect->bottom);
|
|
|
|
}
|
|
|
|
if(lpSrcRect)
|
|
|
|
{
|
2010-10-17 09:37:29 +03:00
|
|
|
printf(" src: l: %d t: %d r: %d b: %d\n", (int)lpSrcRect->left, (int)lpSrcRect->top, (int)lpSrcRect->right, (int)lpSrcRect->bottom);
|
2010-10-17 09:36:48 +03:00
|
|
|
}
|
2010-10-17 15:41:52 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if(Source)
|
|
|
|
{
|
2010-10-17 20:11:38 +03:00
|
|
|
int dx=0,dy=0;
|
|
|
|
if (lpDestRect)
|
|
|
|
{
|
|
|
|
dx=lpDestRect->left;
|
|
|
|
dy=lpDestRect->top;
|
|
|
|
}
|
|
|
|
int x0=0,y0=0,x1=Source->width,y1=Source->height;
|
|
|
|
if (lpSrcRect)
|
|
|
|
{
|
|
|
|
x0 = max(x0, lpSrcRect->left);
|
|
|
|
x1 = min(x1, lpSrcRect->right);
|
|
|
|
y0 = max(y0, lpSrcRect->top);
|
|
|
|
y1 = min(y1, lpSrcRect->bottom);
|
|
|
|
}
|
|
|
|
unsigned char* to=This->surface + dy*This->width + dx;
|
|
|
|
unsigned char* from=Source->surface + y0*Source->width + x0;
|
|
|
|
int s = x1-x0;
|
|
|
|
|
2017-11-15 06:33:31 +01:00
|
|
|
if((This->caps & DDSCAPS_PRIMARYSURFACE) && !(This->flags & DDSD_BACKBUFFERCOUNT))
|
|
|
|
{
|
|
|
|
EnterCriticalSection(&ddraw->cs);
|
|
|
|
|
|
|
|
int y;
|
|
|
|
for(y=y0; y<y1; ++y, to+=This->width, from+=Source->width)
|
|
|
|
memcpy(to, from, s);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&ddraw->cs);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int y;
|
|
|
|
for(y=y0; y<y1; ++y, to+=This->width, from+=Source->width)
|
|
|
|
memcpy(to, from, s);
|
|
|
|
}
|
2010-10-17 15:41:52 +03:00
|
|
|
}
|
|
|
|
|
2010-10-16 22:10:25 +03:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 19:54:45 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_BltBatch(IDirectDrawSurfaceImpl *This, LPDDBLTBATCH a, DWORD b, DWORD c)
|
|
|
|
{
|
|
|
|
printf("IDirectDrawSurface::BltBatch(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_BltFast(IDirectDrawSurfaceImpl *This, DWORD a, DWORD b, LPDIRECTDRAWSURFACE c, LPRECT d, DWORD e)
|
|
|
|
{
|
|
|
|
printf("IDirectDrawSurface::BltFast(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-11-08 18:30:14 +02:00
|
|
|
HRESULT __stdcall ddraw_surface_DeleteAttachedSurface(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSurface)
|
2010-10-23 19:54:45 +03:00
|
|
|
{
|
2010-11-08 18:30:14 +02:00
|
|
|
printf("IDirectDrawSurface::DeleteAttachedSurface(This=%p, dwFlags=%d, lpDDSurface=%p)\n", This, (int)dwFlags, lpDDSurface);
|
|
|
|
IDirectDrawSurface_Release(lpDDSurface);
|
2010-10-23 19:54:45 +03:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-29 23:18:42 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_GetSurfaceDesc(IDirectDrawSurfaceImpl *This, LPDDSURFACEDESC lpDDSurfaceDesc)
|
|
|
|
{
|
2011-07-01 10:55:10 +03:00
|
|
|
#if _DEBUG
|
2011-06-29 23:18:42 +03:00
|
|
|
printf("IDirectDrawSurface::GetSurfaceDesc(This=%p, lpDDSurfaceDesc=%p)\n", This, lpDDSurfaceDesc);
|
2011-07-01 10:55:10 +03:00
|
|
|
#endif
|
2011-06-29 23:18:42 +03:00
|
|
|
|
2011-07-01 10:55:10 +03:00
|
|
|
lpDDSurfaceDesc->dwSize = sizeof(DDSURFACEDESC);
|
|
|
|
lpDDSurfaceDesc->dwFlags = DDSD_WIDTH|DDSD_HEIGHT|DDSD_PITCH|DDSD_PIXELFORMAT|DDSD_LPSURFACE;
|
2011-06-29 23:18:42 +03:00
|
|
|
lpDDSurfaceDesc->dwWidth = This->width;
|
|
|
|
lpDDSurfaceDesc->dwHeight = This->height;
|
|
|
|
lpDDSurfaceDesc->lPitch = This->lPitch;
|
2011-07-01 10:55:10 +03:00
|
|
|
lpDDSurfaceDesc->lpSurface = This->surface;
|
2011-06-29 23:18:42 +03:00
|
|
|
lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB;
|
|
|
|
lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = This->bpp;
|
|
|
|
|
2011-07-01 10:55:10 +03:00
|
|
|
if (This->bpp == 16)
|
|
|
|
{
|
|
|
|
/* RGB 555 */
|
|
|
|
lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x7C00;
|
|
|
|
lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x03E0;
|
|
|
|
lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x001F;
|
|
|
|
}
|
|
|
|
|
2011-06-29 23:18:42 +03:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_EnumAttachedSurfaces(IDirectDrawSurfaceImpl *This, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
|
2010-10-23 19:54:45 +03:00
|
|
|
{
|
2011-06-29 23:18:42 +03:00
|
|
|
printf("IDirectDrawSurface::EnumAttachedSurfaces(This=%p, lpContext=%p, lpEnumSurfacesCallback=%p)\n", This, lpContext, lpEnumSurfacesCallback);
|
|
|
|
|
|
|
|
/* this is not actually complete, but Carmageddon seems to call EnumAttachedSurfaces instead of GetSurfaceDesc to get the main surface description */
|
2011-07-01 10:55:10 +03:00
|
|
|
static LPDDSURFACEDESC lpDDSurfaceDesc;
|
|
|
|
lpDDSurfaceDesc = (LPDDSURFACEDESC)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDSURFACEDESC));
|
2011-06-29 23:18:42 +03:00
|
|
|
ddraw_surface_GetSurfaceDesc(This, lpDDSurfaceDesc);
|
|
|
|
lpEnumSurfacesCallback((LPDIRECTDRAWSURFACE)This, lpDDSurfaceDesc, lpContext);
|
2011-07-01 10:55:10 +03:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpDDSurfaceDesc);
|
2011-06-29 23:18:42 +03:00
|
|
|
|
2010-10-23 19:54:45 +03:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_EnumOverlayZOrders(IDirectDrawSurfaceImpl *This, DWORD a, LPVOID b, LPDDENUMSURFACESCALLBACK c)
|
|
|
|
{
|
|
|
|
printf("IDirectDrawSurface::EnumOverlayZOrders(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_Flip(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWSURFACE a, DWORD b)
|
|
|
|
{
|
2011-06-29 23:18:42 +03:00
|
|
|
#if _DEBUG
|
2010-10-23 19:54:45 +03:00
|
|
|
printf("IDirectDrawSurface::Flip(This=%p, ...)\n", This);
|
2011-06-29 23:18:42 +03:00
|
|
|
#endif
|
|
|
|
|
2010-10-23 19:54:45 +03:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_GetAttachedSurface(IDirectDrawSurfaceImpl *This, LPDDSCAPS a, LPDIRECTDRAWSURFACE FAR *b)
|
|
|
|
{
|
|
|
|
printf("IDirectDrawSurface::GetAttachedSurface(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_GetBltStatus(IDirectDrawSurfaceImpl *This, DWORD a)
|
|
|
|
{
|
|
|
|
#if _DEBUG
|
|
|
|
printf("IDirectDrawSurface::GetBltStatus(This=%p, ...)\n", This);
|
|
|
|
#endif
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_GetCaps(IDirectDrawSurfaceImpl *This, LPDDSCAPS lpDDSCaps)
|
2010-10-16 23:22:43 +03:00
|
|
|
{
|
2010-10-23 17:04:01 +03:00
|
|
|
printf("DirectDrawSurface::GetCaps(This=%p, lpDDSCaps=%p)\n", This, lpDDSCaps);
|
2010-10-17 09:09:30 +03:00
|
|
|
lpDDSCaps->dwCaps = This->caps;
|
2010-10-16 23:22:43 +03:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 19:54:45 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_GetClipper(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWCLIPPER FAR *a)
|
|
|
|
{
|
|
|
|
printf("IDirectDrawSurface::GetClipper(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_GetColorKey(IDirectDrawSurfaceImpl *This, DWORD a, LPDDCOLORKEY b)
|
|
|
|
{
|
|
|
|
printf("IDirectDrawSurface::GetColorKey(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_GetDC(IDirectDrawSurfaceImpl *This, HDC FAR *a)
|
|
|
|
{
|
|
|
|
printf("IDirectDrawSurface::GetDC(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_GetFlipStatus(IDirectDrawSurfaceImpl *This, DWORD a)
|
|
|
|
{
|
|
|
|
printf("IDirectDrawSurface::GetFlipStatus(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_GetOverlayPosition(IDirectDrawSurfaceImpl *This, LPLONG a, LPLONG b)
|
|
|
|
{
|
|
|
|
printf("IDirectDrawSurface::GetOverlayPosition(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_GetPalette(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWPALETTE FAR *lplpDDPalette)
|
2010-10-16 23:22:43 +03:00
|
|
|
{
|
2010-10-23 17:04:01 +03:00
|
|
|
printf("DirectDrawSurface::GetPalette(This=%p, lplpDDPalette=%p)\n", This, lplpDDPalette);
|
2011-12-09 14:10:56 +02:00
|
|
|
*lplpDDPalette = (LPDIRECTDRAWPALETTE)This->palette;
|
2010-10-16 23:22:43 +03:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 19:54:45 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_GetPixelFormat(IDirectDrawSurfaceImpl *This, LPDDPIXELFORMAT a)
|
2010-10-16 23:22:43 +03:00
|
|
|
{
|
2010-10-23 19:54:45 +03:00
|
|
|
printf("IDirectDrawSurface::GetPixelFormat(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_Initialize(IDirectDrawSurfaceImpl *This, LPDIRECTDRAW a, LPDDSURFACEDESC b)
|
|
|
|
{
|
|
|
|
printf("IDirectDrawSurface::Initialize(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_IsLost(IDirectDrawSurfaceImpl *This)
|
|
|
|
{
|
2011-06-29 23:18:42 +03:00
|
|
|
#if _DEBUG
|
2010-10-23 19:54:45 +03:00
|
|
|
printf("IDirectDrawSurface::IsLost(This=%p)\n", This);
|
2011-06-29 23:18:42 +03:00
|
|
|
#endif
|
2010-10-16 23:22:43 +03:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_Lock(IDirectDrawSurfaceImpl *This, LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:27:45 +03:00
|
|
|
#if _DEBUG
|
2010-10-16 22:10:25 +03:00
|
|
|
printf("DirectDrawSurface::Lock(This=%p, lpDestRect=%p, lpDDSurfaceDesc=%p, dwFlags=%d, hEvent=%p)\n", This, lpDestRect, lpDDSurfaceDesc, (int)dwFlags, hEvent);
|
|
|
|
|
|
|
|
if(dwFlags & DDLOCK_SURFACEMEMORYPTR)
|
|
|
|
{
|
|
|
|
printf(" dwFlags: DDLOCK_SURFACEMEMORYPTR\n");
|
|
|
|
}
|
|
|
|
if(dwFlags & DDLOCK_WAIT)
|
|
|
|
{
|
|
|
|
printf(" dwFlags: DDLOCK_WAIT\n");
|
|
|
|
}
|
|
|
|
if(dwFlags & DDLOCK_EVENT)
|
|
|
|
{
|
|
|
|
printf(" dwFlags: DDLOCK_EVENT\n");
|
|
|
|
}
|
|
|
|
if(dwFlags & DDLOCK_READONLY)
|
|
|
|
{
|
|
|
|
printf(" dwFlags: DDLOCK_READONLY\n");
|
|
|
|
}
|
|
|
|
if(dwFlags & DDLOCK_WRITEONLY)
|
|
|
|
{
|
|
|
|
printf(" dwFlags: DDLOCK_WRITEONLY\n");
|
|
|
|
}
|
2010-10-17 09:27:45 +03:00
|
|
|
#endif
|
2010-10-16 22:10:25 +03:00
|
|
|
|
2017-11-11 23:32:07 +01:00
|
|
|
HRESULT ret = ddraw_surface_GetSurfaceDesc(This, lpDDSurfaceDesc);
|
|
|
|
|
2017-11-12 18:23:26 +01:00
|
|
|
//EnterCriticalSection(&ddraw->cs);
|
2017-11-11 23:32:07 +01:00
|
|
|
|
|
|
|
return ret;
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
|
|
|
|
2010-10-23 19:54:45 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_ReleaseDC(IDirectDrawSurfaceImpl *This, HDC a)
|
|
|
|
{
|
|
|
|
printf("DirectDrawSurface::ReleaseDC(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_Restore(IDirectDrawSurfaceImpl *This)
|
|
|
|
{
|
|
|
|
printf("DirectDrawSurface::Restore(This=%p)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_SetClipper(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWCLIPPER a)
|
|
|
|
{
|
|
|
|
printf("DirectDrawSurface::SetClipper(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_SetColorKey(IDirectDrawSurfaceImpl *This, DWORD a, LPDDCOLORKEY b)
|
|
|
|
{
|
|
|
|
printf("DirectDrawSurface::SetColorKey(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_SetOverlayPosition(IDirectDrawSurfaceImpl *This, LONG a, LONG b)
|
|
|
|
{
|
|
|
|
printf("DirectDrawSurface::SetOverlayPosition(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_SetPalette(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWPALETTE lpDDPalette)
|
|
|
|
{
|
|
|
|
printf("DirectDrawSurface::SetPalette(This=%p, lpDDPalette=%p)\n", This, lpDDPalette);
|
2010-11-08 18:30:14 +02:00
|
|
|
|
|
|
|
IDirectDrawPalette_AddRef(lpDDPalette);
|
|
|
|
|
|
|
|
if(This->palette)
|
|
|
|
{
|
|
|
|
IDirectDrawPalette_Release(This->palette);
|
|
|
|
}
|
|
|
|
|
2010-10-23 19:54:45 +03:00
|
|
|
This->palette = (IDirectDrawPaletteImpl *)lpDDPalette;
|
2010-11-08 18:30:14 +02:00
|
|
|
|
2010-10-23 19:54:45 +03:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_Unlock(IDirectDrawSurfaceImpl *This, LPVOID lpRect)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:27:45 +03:00
|
|
|
#if _DEBUG
|
2010-10-16 22:10:25 +03:00
|
|
|
printf("DirectDrawSurface::Unlock(This=%p, lpRect=%p)\n", This, lpRect);
|
2010-10-17 09:27:45 +03:00
|
|
|
#endif
|
2017-11-11 23:32:07 +01:00
|
|
|
|
2017-11-12 18:23:26 +01:00
|
|
|
//LeaveCriticalSection(&ddraw->cs);
|
2011-06-29 22:47:29 +03:00
|
|
|
|
2010-10-16 22:10:25 +03:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 19:54:45 +03:00
|
|
|
HRESULT __stdcall ddraw_surface_UpdateOverlay(IDirectDrawSurfaceImpl *This, LPRECT a, LPDIRECTDRAWSURFACE b, LPRECT c, DWORD d, LPDDOVERLAYFX e)
|
2010-10-23 17:04:01 +03:00
|
|
|
{
|
2010-10-23 19:54:45 +03:00
|
|
|
printf("DirectDrawSurface::UpdateOverlay(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_UpdateOverlayDisplay(IDirectDrawSurfaceImpl *This, DWORD a)
|
|
|
|
{
|
|
|
|
printf("DirectDrawSurface::UpdateOverlayDisplay(This=%p, ...)\n", This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __stdcall ddraw_surface_UpdateOverlayZOrder(IDirectDrawSurfaceImpl *This, DWORD a, LPDIRECTDRAWSURFACE b)
|
|
|
|
{
|
|
|
|
printf("DirectDrawSurface::UpdateOverlayZOrder(This=%p, ...)\n", This);
|
2010-10-23 17:04:01 +03:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct IDirectDrawSurfaceImplVtbl siface =
|
2010-10-16 21:14:26 +03:00
|
|
|
{
|
|
|
|
/* IUnknown */
|
2010-10-17 21:38:40 +03:00
|
|
|
ddraw_surface_QueryInterface,
|
2010-10-16 22:10:25 +03:00
|
|
|
ddraw_surface_AddRef,
|
|
|
|
ddraw_surface_Release,
|
2010-10-16 21:14:26 +03:00
|
|
|
/* IDirectDrawSurface */
|
2010-10-17 08:44:48 +03:00
|
|
|
ddraw_surface_AddAttachedSurface,
|
2010-10-23 19:54:45 +03:00
|
|
|
ddraw_surface_AddOverlayDirtyRect,
|
2010-10-16 22:10:25 +03:00
|
|
|
ddraw_surface_Blt,
|
2010-10-23 19:54:45 +03:00
|
|
|
ddraw_surface_BltBatch,
|
|
|
|
ddraw_surface_BltFast,
|
|
|
|
ddraw_surface_DeleteAttachedSurface,
|
|
|
|
ddraw_surface_EnumAttachedSurfaces,
|
|
|
|
ddraw_surface_EnumOverlayZOrders,
|
|
|
|
ddraw_surface_Flip,
|
|
|
|
ddraw_surface_GetAttachedSurface,
|
|
|
|
ddraw_surface_GetBltStatus,
|
2010-10-16 23:22:43 +03:00
|
|
|
ddraw_surface_GetCaps,
|
2010-10-23 19:54:45 +03:00
|
|
|
ddraw_surface_GetClipper,
|
|
|
|
ddraw_surface_GetColorKey,
|
|
|
|
ddraw_surface_GetDC,
|
|
|
|
ddraw_surface_GetFlipStatus,
|
|
|
|
ddraw_surface_GetOverlayPosition,
|
2010-10-16 23:22:43 +03:00
|
|
|
ddraw_surface_GetPalette,
|
2010-10-23 19:54:45 +03:00
|
|
|
ddraw_surface_GetPixelFormat,
|
|
|
|
ddraw_surface_GetSurfaceDesc,
|
|
|
|
ddraw_surface_Initialize,
|
|
|
|
ddraw_surface_IsLost,
|
2010-10-16 22:10:25 +03:00
|
|
|
ddraw_surface_Lock,
|
2010-10-23 19:54:45 +03:00
|
|
|
ddraw_surface_ReleaseDC,
|
2010-10-23 17:04:01 +03:00
|
|
|
ddraw_surface_Restore,
|
2010-10-23 19:54:45 +03:00
|
|
|
ddraw_surface_SetClipper,
|
|
|
|
ddraw_surface_SetColorKey,
|
|
|
|
ddraw_surface_SetOverlayPosition,
|
2010-10-16 23:22:43 +03:00
|
|
|
ddraw_surface_SetPalette,
|
2010-10-16 22:10:25 +03:00
|
|
|
ddraw_surface_Unlock,
|
2010-10-23 19:54:45 +03:00
|
|
|
ddraw_surface_UpdateOverlay,
|
|
|
|
ddraw_surface_UpdateOverlayDisplay,
|
|
|
|
ddraw_surface_UpdateOverlayZOrder
|
2010-10-16 21:14:26 +03:00
|
|
|
};
|
2010-10-16 22:10:25 +03:00
|
|
|
|
2010-10-23 19:25:02 +03:00
|
|
|
HRESULT __stdcall ddraw_CreateSurface(IDirectDrawImpl *This, LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *lpDDSurface, IUnknown FAR * unkOuter)
|
2010-10-23 17:04:01 +03:00
|
|
|
{
|
|
|
|
printf("DirectDraw::CreateSurface(This=%p, lpDDSurfaceDesc=%p, lpDDSurface=%p, unkOuter=%p)\n", This, lpDDSurfaceDesc, lpDDSurface, unkOuter);
|
|
|
|
|
|
|
|
dump_ddsd(lpDDSurfaceDesc->dwFlags);
|
|
|
|
|
2010-10-24 19:47:51 +03:00
|
|
|
IDirectDrawSurfaceImpl *Surface = (IDirectDrawSurfaceImpl *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawSurfaceImpl));
|
2010-10-23 17:04:01 +03:00
|
|
|
|
|
|
|
Surface->lpVtbl = &siface;
|
|
|
|
|
|
|
|
/* private stuff */
|
|
|
|
Surface->bpp = This->bpp;
|
2011-06-29 23:18:42 +03:00
|
|
|
Surface->flags = lpDDSurfaceDesc->dwFlags;
|
2010-10-23 17:04:01 +03:00
|
|
|
|
|
|
|
if(lpDDSurfaceDesc->dwFlags & DDSD_CAPS)
|
|
|
|
{
|
|
|
|
if(lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
|
|
|
{
|
2010-11-13 10:49:46 +02:00
|
|
|
ddraw->primary = Surface;
|
2010-10-24 01:02:08 +03:00
|
|
|
|
2010-10-23 17:04:01 +03:00
|
|
|
Surface->width = This->width;
|
|
|
|
Surface->height = This->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
dump_ddscaps(lpDDSurfaceDesc->ddsCaps.dwCaps);
|
|
|
|
Surface->caps = lpDDSurfaceDesc->ddsCaps.dwCaps;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !(lpDDSurfaceDesc->dwFlags & DDSD_CAPS) || !(lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) )
|
|
|
|
{
|
|
|
|
Surface->width = lpDDSurfaceDesc->dwWidth;
|
|
|
|
Surface->height = lpDDSurfaceDesc->dwHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(Surface->width && Surface->height)
|
|
|
|
{
|
|
|
|
Surface->lXPitch = Surface->bpp / 8;
|
2011-07-01 10:55:10 +03:00
|
|
|
Surface->lPitch = Surface->width * Surface->lXPitch;
|
|
|
|
Surface->surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Surface->lPitch * Surface->height * Surface->lXPitch);
|
2010-10-23 17:04:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
printf(" Surface = %p (%dx%d@%d)\n", Surface, (int)Surface->width, (int)Surface->height, (int)Surface->bpp);
|
|
|
|
|
|
|
|
*lpDDSurface = (LPDIRECTDRAWSURFACE)Surface;
|
|
|
|
|
|
|
|
Surface->Ref = 0;
|
|
|
|
ddraw_surface_AddRef(Surface);
|
2017-11-11 23:32:07 +01:00
|
|
|
|
|
|
|
if(lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
|
|
|
{
|
|
|
|
This->render.thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)This->renderer, NULL, 0, NULL);
|
2017-11-12 20:48:28 +01:00
|
|
|
SetThreadPriority(This->render.thread, THREAD_PRIORITY_BELOW_NORMAL);
|
2017-11-11 23:32:07 +01:00
|
|
|
}
|
2010-10-23 17:04:01 +03:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-17 09:09:30 +03:00
|
|
|
void dump_ddscaps(DWORD dwCaps)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwCaps & DDSCAPS_PRIMARYSURFACE)
|
|
|
|
{
|
|
|
|
printf(" DDSCAPS_PRIMARYSURFACE\n");
|
|
|
|
}
|
|
|
|
if(dwCaps & DDSCAPS_OFFSCREENPLAIN)
|
|
|
|
{
|
|
|
|
printf(" DDSCAPS_OFFSCREENPLAIN\n");
|
|
|
|
}
|
|
|
|
if(dwCaps & DDSCAPS_VIDEOMEMORY)
|
|
|
|
{
|
|
|
|
printf(" DDSCAPS_VIDEOMEMORY\n");
|
|
|
|
}
|
|
|
|
if(dwCaps & DDSCAPS_LOCALVIDMEM)
|
|
|
|
{
|
|
|
|
printf(" DDSCAPS_LOCALVIDMEM\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void dump_ddsd(DWORD dwFlags)
|
|
|
|
{
|
|
|
|
if(dwFlags & DDSD_CAPS)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_CAPS\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_HEIGHT)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_HEIGHT\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_WIDTH)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_WIDTH\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_PITCH)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_PITCH\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_BACKBUFFERCOUNT)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_BACKBUFFERCOUNT\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_ZBUFFERBITDEPTH)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_ZBUFFERBITDEPTH\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_ALPHABITDEPTH)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_ALPHABITDEPTH\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_LPSURFACE)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_LPSURFACE\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_PIXELFORMAT)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_PIXELFORMAT\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_CKDESTOVERLAY)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_CKDESTOVERLAY\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_CKDESTBLT)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_CKDESTBLT\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_CKSRCOVERLAY)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_CKSRCOVERLAY\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_CKSRCBLT)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_CKSRCBLT\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_MIPMAPCOUNT)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_MIPMAPCOUNT\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_REFRESHRATE)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_REFRESHRATE\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_LINEARSIZE)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_LINEARSIZE\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
2010-10-17 09:09:30 +03:00
|
|
|
if(dwFlags & DDSD_ALL)
|
2010-10-16 22:10:25 +03:00
|
|
|
{
|
2010-10-17 09:09:30 +03:00
|
|
|
printf(" DDSD_ALL\n");
|
2010-10-16 22:10:25 +03:00
|
|
|
}
|
|
|
|
}
|