mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
Going towards TS support in mainline
This commit is contained in:
parent
706874f7f9
commit
517eef41dc
9
main.c
9
main.c
@ -175,12 +175,6 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
|
|||||||
|
|
||||||
This->render.run = TRUE;
|
This->render.run = TRUE;
|
||||||
|
|
||||||
/* currently we only support 8 bit modes */
|
|
||||||
if(bpp != 8)
|
|
||||||
{
|
|
||||||
return DDERR_INVALIDMODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
This->mode.dmSize = sizeof(DEVMODE);
|
This->mode.dmSize = sizeof(DEVMODE);
|
||||||
This->mode.dmDriverExtra = 0;
|
This->mode.dmDriverExtra = 0;
|
||||||
|
|
||||||
@ -422,6 +416,9 @@ HRESULT __stdcall ddraw_WaitForVerticalBlank(IDirectDrawImpl *This, DWORD a, HAN
|
|||||||
HRESULT __stdcall ddraw_QueryInterface(IDirectDrawImpl *This, REFIID riid, void **obj)
|
HRESULT __stdcall ddraw_QueryInterface(IDirectDrawImpl *This, REFIID riid, void **obj)
|
||||||
{
|
{
|
||||||
printf("DirectDraw::QueryInterface(This=%p, riid=%08X, obj=%p)\n", This, (unsigned int)riid, obj);
|
printf("DirectDraw::QueryInterface(This=%p, riid=%08X, obj=%p)\n", This, (unsigned int)riid, obj);
|
||||||
|
|
||||||
|
*obj = This;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@ DWORD WINAPI render_soft_main(void)
|
|||||||
|
|
||||||
PBITMAPINFO bmi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFO) + (sizeof(RGBQUAD) * 256) + 1024);
|
PBITMAPINFO bmi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFO) + (sizeof(RGBQUAD) * 256) + 1024);
|
||||||
|
|
||||||
bmi->bmiHeader.biSize = sizeof(BITMAPINFO);
|
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
bmi->bmiHeader.biWidth = ddraw->width;
|
bmi->bmiHeader.biWidth = ddraw->width;
|
||||||
bmi->bmiHeader.biHeight = -ddraw->height;
|
bmi->bmiHeader.biHeight = -ddraw->height;
|
||||||
bmi->bmiHeader.biPlanes = 1;
|
bmi->bmiHeader.biPlanes = 1;
|
||||||
bmi->bmiHeader.biBitCount = 8;
|
bmi->bmiHeader.biBitCount = ddraw->bpp;
|
||||||
bmi->bmiHeader.biCompression = BI_RGB;
|
bmi->bmiHeader.biCompression = BI_RGB;
|
||||||
|
|
||||||
SelectObject(memDC, surface);
|
SelectObject(memDC, surface);
|
||||||
@ -58,9 +58,9 @@ DWORD WINAPI render_soft_main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
EnterCriticalSection(&ddraw->cs);
|
EnterCriticalSection(&ddraw->cs);
|
||||||
if (ddraw->primary && ddraw->primary->palette)
|
if (ddraw->primary && (ddraw->primary->palette || ddraw->bpp == 16))
|
||||||
{
|
{
|
||||||
if (ddraw->primary->palette->data_rgb == NULL)
|
if (ddraw->primary->palette && ddraw->primary->palette->data_rgb == NULL)
|
||||||
{
|
{
|
||||||
ddraw->primary->palette->data_rgb = &bmi->bmiColors[1];
|
ddraw->primary->palette->data_rgb = &bmi->bmiColors[1];
|
||||||
}
|
}
|
||||||
|
30
surface.c
30
surface.c
@ -151,15 +151,27 @@ HRESULT __stdcall ddraw_surface_DeleteAttachedSurface(IDirectDrawSurfaceImpl *Th
|
|||||||
|
|
||||||
HRESULT __stdcall ddraw_surface_GetSurfaceDesc(IDirectDrawSurfaceImpl *This, LPDDSURFACEDESC lpDDSurfaceDesc)
|
HRESULT __stdcall ddraw_surface_GetSurfaceDesc(IDirectDrawSurfaceImpl *This, LPDDSURFACEDESC lpDDSurfaceDesc)
|
||||||
{
|
{
|
||||||
|
#if _DEBUG
|
||||||
printf("IDirectDrawSurface::GetSurfaceDesc(This=%p, lpDDSurfaceDesc=%p)\n", This, lpDDSurfaceDesc);
|
printf("IDirectDrawSurface::GetSurfaceDesc(This=%p, lpDDSurfaceDesc=%p)\n", This, lpDDSurfaceDesc);
|
||||||
|
#endif
|
||||||
|
|
||||||
lpDDSurfaceDesc->dwFlags = DDSD_WIDTH|DDSD_HEIGHT|DDSD_PITCH|DDSD_PIXELFORMAT;
|
lpDDSurfaceDesc->dwSize = sizeof(DDSURFACEDESC);
|
||||||
|
lpDDSurfaceDesc->dwFlags = DDSD_WIDTH|DDSD_HEIGHT|DDSD_PITCH|DDSD_PIXELFORMAT|DDSD_LPSURFACE;
|
||||||
lpDDSurfaceDesc->dwWidth = This->width;
|
lpDDSurfaceDesc->dwWidth = This->width;
|
||||||
lpDDSurfaceDesc->dwHeight = This->height;
|
lpDDSurfaceDesc->dwHeight = This->height;
|
||||||
lpDDSurfaceDesc->lPitch = This->lPitch;
|
lpDDSurfaceDesc->lPitch = This->lPitch;
|
||||||
|
lpDDSurfaceDesc->lpSurface = This->surface;
|
||||||
lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB;
|
lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB;
|
||||||
lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = This->bpp;
|
lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = This->bpp;
|
||||||
|
|
||||||
|
if (This->bpp == 16)
|
||||||
|
{
|
||||||
|
/* RGB 555 */
|
||||||
|
lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x7C00;
|
||||||
|
lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x03E0;
|
||||||
|
lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x001F;
|
||||||
|
}
|
||||||
|
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,10 +180,11 @@ HRESULT __stdcall ddraw_surface_EnumAttachedSurfaces(IDirectDrawSurfaceImpl *Thi
|
|||||||
printf("IDirectDrawSurface::EnumAttachedSurfaces(This=%p, lpContext=%p, lpEnumSurfacesCallback=%p)\n", This, lpContext, lpEnumSurfacesCallback);
|
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 */
|
/* this is not actually complete, but Carmageddon seems to call EnumAttachedSurfaces instead of GetSurfaceDesc to get the main surface description */
|
||||||
LPDDSURFACEDESC lpDDSurfaceDesc = malloc(sizeof(DDSURFACEDESC));
|
static LPDDSURFACEDESC lpDDSurfaceDesc;
|
||||||
|
lpDDSurfaceDesc = (LPDDSURFACEDESC)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDSURFACEDESC));
|
||||||
ddraw_surface_GetSurfaceDesc(This, lpDDSurfaceDesc);
|
ddraw_surface_GetSurfaceDesc(This, lpDDSurfaceDesc);
|
||||||
free(lpDDSurfaceDesc);
|
|
||||||
lpEnumSurfacesCallback((LPDIRECTDRAWSURFACE)This, lpDDSurfaceDesc, lpContext);
|
lpEnumSurfacesCallback((LPDIRECTDRAWSURFACE)This, lpDDSurfaceDesc, lpContext);
|
||||||
|
HeapFree(GetProcessHeap(), 0, lpDDSurfaceDesc);
|
||||||
|
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
@ -302,12 +315,7 @@ HRESULT __stdcall ddraw_surface_Lock(IDirectDrawSurfaceImpl *This, LPRECT lpDest
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lpDDSurfaceDesc->dwSize = sizeof(DDSURFACEDESC);
|
return ddraw_surface_GetSurfaceDesc(This, lpDDSurfaceDesc);
|
||||||
lpDDSurfaceDesc->dwFlags = DDSD_LPSURFACE|DDSD_PITCH;
|
|
||||||
lpDDSurfaceDesc->lpSurface = This->surface;
|
|
||||||
lpDDSurfaceDesc->lPitch = This->lPitch;
|
|
||||||
|
|
||||||
return DD_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT __stdcall ddraw_surface_ReleaseDC(IDirectDrawSurfaceImpl *This, HDC a)
|
HRESULT __stdcall ddraw_surface_ReleaseDC(IDirectDrawSurfaceImpl *This, HDC a)
|
||||||
@ -466,9 +474,9 @@ HRESULT __stdcall ddraw_CreateSurface(IDirectDrawImpl *This, LPDDSURFACEDESC lpD
|
|||||||
|
|
||||||
if(Surface->width && Surface->height)
|
if(Surface->width && Surface->height)
|
||||||
{
|
{
|
||||||
Surface->lPitch = Surface->width;
|
|
||||||
Surface->lXPitch = Surface->bpp / 8;
|
Surface->lXPitch = Surface->bpp / 8;
|
||||||
Surface->surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Surface->width * Surface->height * Surface->lXPitch);
|
Surface->lPitch = Surface->width * Surface->lXPitch;
|
||||||
|
Surface->surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Surface->lPitch * Surface->height * Surface->lXPitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" Surface = %p (%dx%d@%d)\n", Surface, (int)Surface->width, (int)Surface->height, (int)Surface->bpp);
|
printf(" Surface = %p (%dx%d@%d)\n", Surface, (int)Surface->width, (int)Surface->height, (int)Surface->bpp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user