mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
add partial support for DDBLT_KEYSRC
This commit is contained in:
parent
8e53cdc5fa
commit
7f0eef570b
@ -101,7 +101,7 @@ struct IDirectDrawClipperImplVtbl ciface =
|
|||||||
|
|
||||||
HRESULT __stdcall ddraw_CreateClipper(IDirectDrawImpl *This, DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter )
|
HRESULT __stdcall ddraw_CreateClipper(IDirectDrawImpl *This, DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter )
|
||||||
{
|
{
|
||||||
printf("DirectDraw::CreateClipper(This=%p, dwFlags=%d, DDClipper=%p, unkOuter=%p)\n", This, (int)dwFlags, lplpDDClipper, pUnkOuter);
|
printf("DirectDraw::CreateClipper(This=%p, dwFlags=%08X, DDClipper=%p, unkOuter=%p)\n", This, (int)dwFlags, lplpDDClipper, pUnkOuter);
|
||||||
|
|
||||||
IDirectDrawClipperImpl *Clipper = (IDirectDrawClipperImpl *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawClipperImpl));
|
IDirectDrawClipperImpl *Clipper = (IDirectDrawClipperImpl *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawClipperImpl));
|
||||||
Clipper->lpVtbl = &ciface;
|
Clipper->lpVtbl = &ciface;
|
||||||
|
@ -151,7 +151,7 @@ HRESULT __stdcall ddraw_EnumDisplayModes(IDirectDrawImpl *This, DWORD dwFlags, L
|
|||||||
DEVMODE m;
|
DEVMODE m;
|
||||||
DDSURFACEDESC s;
|
DDSURFACEDESC s;
|
||||||
|
|
||||||
printf("DirectDraw::EnumDisplayModes(This=%p, dwFlags=%d, lpDDSurfaceDesc=%p, lpContext=%p, lpEnumModesCallback=%p)\n", This, (unsigned int)dwFlags, lpDDSurfaceDesc, lpContext, lpEnumModesCallback);
|
printf("DirectDraw::EnumDisplayModes(This=%p, dwFlags=%08X, lpDDSurfaceDesc=%p, lpContext=%p, lpEnumModesCallback=%p)\n", This, (unsigned int)dwFlags, lpDDSurfaceDesc, lpContext, lpEnumModesCallback);
|
||||||
|
|
||||||
if (lpDDSurfaceDesc != NULL)
|
if (lpDDSurfaceDesc != NULL)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ HRESULT __stdcall ddraw_palette_GetEntries(IDirectDrawPaletteImpl *This, DWORD d
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
printf("DirectDrawPalette::GetEntries(This=%p, dwFlags=%d, dwBase=%d, dwNumEntries=%d, lpEntries=%p)\n", This, (int)dwFlags, (int)dwBase, (int)dwNumEntries, lpEntries);
|
printf("DirectDrawPalette::GetEntries(This=%p, dwFlags=%08X, dwBase=%d, dwNumEntries=%d, lpEntries=%p)\n", This, (int)dwFlags, (int)dwBase, (int)dwNumEntries, lpEntries);
|
||||||
|
|
||||||
for(i=dwBase;i<dwBase+dwNumEntries;i++)
|
for(i=dwBase;i<dwBase+dwNumEntries;i++)
|
||||||
{
|
{
|
||||||
@ -43,7 +43,7 @@ HRESULT __stdcall ddraw_palette_SetEntries(IDirectDrawPaletteImpl *This, DWORD d
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
#if _DEBUG_X
|
#if _DEBUG_X
|
||||||
printf("DirectDrawPalette::SetEntries(This=%p, dwFlags=%d, dwStartingEntry=%d, dwCount=%d, lpEntries=%p)\n", This, (int)dwFlags, (int)dwStartingEntry, (int)dwCount, lpEntries);
|
printf("DirectDrawPalette::SetEntries(This=%p, dwFlags=%08X, dwStartingEntry=%d, dwCount=%d, lpEntries=%p)\n", This, (int)dwFlags, (int)dwStartingEntry, (int)dwCount, lpEntries);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(i=dwStartingEntry;i<dwStartingEntry+dwCount;i++)
|
for(i=dwStartingEntry;i<dwStartingEntry+dwCount;i++)
|
||||||
@ -125,7 +125,7 @@ struct IDirectDrawPaletteImplVtbl piface =
|
|||||||
|
|
||||||
HRESULT __stdcall ddraw_CreatePalette(IDirectDrawImpl *This, DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR * lpDDPalette, IUnknown FAR * unkOuter)
|
HRESULT __stdcall ddraw_CreatePalette(IDirectDrawImpl *This, DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR * lpDDPalette, IUnknown FAR * unkOuter)
|
||||||
{
|
{
|
||||||
printf("DirectDraw::CreatePalette(This=%p, dwFlags=%d, DDColorArray=%p, DDPalette=%p, unkOuter=%p)\n", This, (int)dwFlags, lpDDColorArray, lpDDPalette, unkOuter);
|
printf("DirectDraw::CreatePalette(This=%p, dwFlags=%08X, DDColorArray=%p, DDPalette=%p, unkOuter=%p)\n", This, (int)dwFlags, lpDDColorArray, lpDDPalette, unkOuter);
|
||||||
|
|
||||||
IDirectDrawPaletteImpl *Palette = (IDirectDrawPaletteImpl *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawPaletteImpl));
|
IDirectDrawPaletteImpl *Palette = (IDirectDrawPaletteImpl *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawPaletteImpl));
|
||||||
Palette->lpVtbl = &piface;
|
Palette->lpVtbl = &piface;
|
||||||
|
102
src/surface.c
102
src/surface.c
@ -91,7 +91,35 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR
|
|||||||
IDirectDrawSurfaceImpl *Source = (IDirectDrawSurfaceImpl *)lpDDSrcSurface;
|
IDirectDrawSurfaceImpl *Source = (IDirectDrawSurfaceImpl *)lpDDSrcSurface;
|
||||||
|
|
||||||
#if _DEBUG_X
|
#if _DEBUG_X
|
||||||
printf("DirectDrawSurface::Blt(This=%p, lpDestRect=%p, lpDDSrcSurface=%p, lpSrcRect=%p, dwFlags=%d, lpDDBltFx=%p)\n", This, lpDestRect, lpDDSrcSurface, lpSrcRect, (int)dwFlags, lpDDBltFx);
|
printf("DirectDrawSurface::Blt(This=%p, lpDestRect=%p, lpDDSrcSurface=%p, lpSrcRect=%p, dwFlags=%08X, lpDDBltFx=%p)\n", This, lpDestRect, lpDDSrcSurface, lpSrcRect, (int)dwFlags, lpDDBltFx);
|
||||||
|
|
||||||
|
if (dwFlags & DDBLT_ALPHADEST) printf(" DDBLT_ALPHADEST\n");
|
||||||
|
if (dwFlags & DDBLT_ALPHADESTCONSTOVERRIDE) printf(" DDBLT_ALPHADESTCONSTOVERRIDE\n");
|
||||||
|
if (dwFlags & DDBLT_ALPHADESTNEG) printf(" DDBLT_ALPHADESTNEG\n");
|
||||||
|
if (dwFlags & DDBLT_ALPHADESTSURFACEOVERRIDE) printf(" DDBLT_ALPHADESTSURFACEOVERRIDE\n");
|
||||||
|
if (dwFlags & DDBLT_ALPHAEDGEBLEND) printf(" DDBLT_ALPHAEDGEBLEND\n");
|
||||||
|
if (dwFlags & DDBLT_ALPHASRC) printf(" DDBLT_ALPHASRC\n");
|
||||||
|
if (dwFlags & DDBLT_ALPHASRCCONSTOVERRIDE) printf(" DDBLT_ALPHASRCCONSTOVERRIDE\n");
|
||||||
|
if (dwFlags & DDBLT_ALPHASRCNEG) printf(" DDBLT_ALPHASRCNEG\n");
|
||||||
|
if (dwFlags & DDBLT_ALPHASRCSURFACEOVERRIDE) printf(" DDBLT_ALPHASRCSURFACEOVERRIDE\n");
|
||||||
|
if (dwFlags & DDBLT_ASYNC) printf(" DDBLT_ASYNC\n");
|
||||||
|
if (dwFlags & DDBLT_COLORFILL) printf(" DDBLT_COLORFILL\n");
|
||||||
|
if (dwFlags & DDBLT_DDFX) printf(" DDBLT_DDFX\n");
|
||||||
|
if (dwFlags & DDBLT_DDROPS) printf(" DDBLT_DDROPS\n");
|
||||||
|
if (dwFlags & DDBLT_KEYDEST) printf(" DDBLT_KEYDEST\n");
|
||||||
|
if (dwFlags & DDBLT_KEYDESTOVERRIDE) printf(" DDBLT_KEYDESTOVERRIDE\n");
|
||||||
|
if (dwFlags & DDBLT_KEYSRC) printf(" DDBLT_KEYSRC\n");
|
||||||
|
if (dwFlags & DDBLT_KEYSRCOVERRIDE) printf(" DDBLT_KEYSRCOVERRIDE\n");
|
||||||
|
if (dwFlags & DDBLT_ROP) printf(" DDBLT_ROP\n");
|
||||||
|
if (dwFlags & DDBLT_ROTATIONANGLE) printf(" DDBLT_ROTATIONANGLE\n");
|
||||||
|
if (dwFlags & DDBLT_ZBUFFER) printf(" DDBLT_ZBUFFER\n");
|
||||||
|
if (dwFlags & DDBLT_ZBUFFERDESTCONSTOVERRIDE) printf(" DDBLT_ZBUFFERDESTCONSTOVERRIDE\n");
|
||||||
|
if (dwFlags & DDBLT_ZBUFFERDESTOVERRIDE) printf(" DDBLT_ZBUFFERDESTOVERRIDE\n");
|
||||||
|
if (dwFlags & DDBLT_ZBUFFERSRCCONSTOVERRIDE) printf(" DDBLT_ZBUFFERSRCCONSTOVERRIDE\n");
|
||||||
|
if (dwFlags & DDBLT_ZBUFFERSRCOVERRIDE) printf(" DDBLT_ZBUFFERSRCOVERRIDE\n");
|
||||||
|
if (dwFlags & DDBLT_WAIT) printf(" DDBLT_WAIT\n");
|
||||||
|
if (dwFlags & DDBLT_DEPTHFILL) printf(" DDBLT_DEPTHFILL\n");
|
||||||
|
|
||||||
if(lpDestRect)
|
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);
|
printf(" dest: l: %d t: %d r: %d b: %d\n", (int)lpDestRect->left, (int)lpDestRect->top, (int)lpDestRect->right, (int)lpDestRect->bottom);
|
||||||
@ -123,28 +151,58 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR
|
|||||||
|
|
||||||
if (Source)
|
if (Source)
|
||||||
{
|
{
|
||||||
int dx = 0, dy = 0;
|
if (dwFlags & DDBLT_KEYSRC)
|
||||||
if (lpDestRect)
|
|
||||||
{
|
{
|
||||||
dx = lpDestRect->left;
|
int src_w = lpSrcRect ? lpSrcRect->right - lpSrcRect->left : Source->width;
|
||||||
dy = lpDestRect->top;
|
int src_h = lpSrcRect ? lpSrcRect->bottom - lpSrcRect->top : Source->height;
|
||||||
}
|
int src_x = lpSrcRect ? lpSrcRect->left : 0;
|
||||||
int x0 = 0, y0 = 0, x1 = Source->width, y1 = Source->height;
|
int src_y = lpSrcRect ? lpSrcRect->top : 0;
|
||||||
if (lpSrcRect)
|
int dst_x = lpDestRect ? lpDestRect->left : 0;
|
||||||
{
|
int dst_y = lpDestRect ? lpDestRect->top : 0;
|
||||||
x0 = max(x0, lpSrcRect->left);
|
|
||||||
x1 = min(x1, lpSrcRect->right);
|
|
||||||
y0 = max(y0, lpSrcRect->top);
|
|
||||||
y1 = min(y1, lpSrcRect->bottom);
|
|
||||||
}
|
|
||||||
unsigned char* to = (unsigned char *)This->surface + dy*This->width + dx;
|
|
||||||
unsigned char* from = (unsigned char *)Source->surface + y0*Source->width + x0;
|
|
||||||
int s = x1 - x0;
|
|
||||||
|
|
||||||
int y;
|
unsigned char* dstSurface = (unsigned char *)This->surface;
|
||||||
for (y = y0; y < y1; ++y, to += This->width, from += Source->width)
|
unsigned char* srcSurface = (unsigned char *)Source->surface;
|
||||||
|
|
||||||
|
int y1, x1;
|
||||||
|
for (y1 = 0; y1 < src_h; y1++)
|
||||||
|
{
|
||||||
|
int ydst = This->width * (y1 + dst_y);
|
||||||
|
int ysrc = Source->width * (y1 + src_y);
|
||||||
|
|
||||||
|
for (x1 = 0; x1 < src_w; x1++)
|
||||||
|
{
|
||||||
|
unsigned char index = srcSurface[x1 + src_x + ysrc];
|
||||||
|
|
||||||
|
if (index != Source->colorKey.dwColorSpaceLowValue)
|
||||||
|
dstSurface[x1 + dst_x + ydst] = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
memcpy(to, from, s);
|
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 = (unsigned char *)This->surface + dy*This->width + dx;
|
||||||
|
unsigned char* from = (unsigned char *)Source->surface + y0*Source->width + x0;
|
||||||
|
int s = x1 - x0;
|
||||||
|
|
||||||
|
int y;
|
||||||
|
for (y = y0; y < y1; ++y, to += This->width, from += Source->width)
|
||||||
|
{
|
||||||
|
memcpy(to, from, s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +316,7 @@ HRESULT __stdcall ddraw_surface_BltFast(IDirectDrawSurfaceImpl *This, DWORD dst_
|
|||||||
|
|
||||||
HRESULT __stdcall ddraw_surface_DeleteAttachedSurface(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSurface)
|
HRESULT __stdcall ddraw_surface_DeleteAttachedSurface(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSurface)
|
||||||
{
|
{
|
||||||
printf("IDirectDrawSurface::DeleteAttachedSurface(This=%p, dwFlags=%d, lpDDSurface=%p)\n", This, (int)dwFlags, lpDDSurface);
|
printf("IDirectDrawSurface::DeleteAttachedSurface(This=%p, dwFlags=%08X, lpDDSurface=%p)\n", This, (int)dwFlags, lpDDSurface);
|
||||||
IDirectDrawSurface_Release(lpDDSurface);
|
IDirectDrawSurface_Release(lpDDSurface);
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
@ -431,7 +489,7 @@ HRESULT __stdcall ddraw_surface_IsLost(IDirectDrawSurfaceImpl *This)
|
|||||||
HRESULT __stdcall ddraw_surface_Lock(IDirectDrawSurfaceImpl *This, LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent)
|
HRESULT __stdcall ddraw_surface_Lock(IDirectDrawSurfaceImpl *This, LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent)
|
||||||
{
|
{
|
||||||
#if _DEBUG_X
|
#if _DEBUG_X
|
||||||
printf("DirectDrawSurface::Lock(This=%p, lpDestRect=%p, lpDDSurfaceDesc=%p, dwFlags=%d, hEvent=%p)\n", This, lpDestRect, lpDDSurfaceDesc, (int)dwFlags, hEvent);
|
printf("DirectDrawSurface::Lock(This=%p, lpDestRect=%p, lpDDSurfaceDesc=%p, dwFlags=%08X, hEvent=%p)\n", This, lpDestRect, lpDDSurfaceDesc, (int)dwFlags, hEvent);
|
||||||
|
|
||||||
if(dwFlags & DDLOCK_SURFACEMEMORYPTR)
|
if(dwFlags & DDLOCK_SURFACEMEMORYPTR)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user