From 44cab3a37ec245a65cac59b2405de85d8ee65ba9 Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Mon, 24 Jul 2006 18:29:02 +0000 Subject: [PATCH] Sorry I have create a mess in ddraw.c 1. found why createsurface did stop working, fixed 2. Split some surface member betwin gbl and lcl struct 3. Reimplement the revert I did, implement Revision: 23263 and Revision: 23262 again 4. Revert new createsurface code and setdisplay mode code that was intrudes 5. Alot other changes as well. 6. Todo Need remove the old code for HAL and HEL split. 7. move Our ddraw working again with apps it did work with. 8. Almost complete kill the file ddraw_hal.c some api is left be kill for at moment they are in use svn path=/trunk/; revision=23268 --- reactos/dll/directx/ddraw/cleanup.c | 102 +- reactos/dll/directx/ddraw/hal/ddraw_hal.c | 67 +- reactos/dll/directx/ddraw/hal/surface_hal.c | 10 +- reactos/dll/directx/ddraw/main/ddraw_main.c | 880 ++++++++---------- reactos/dll/directx/ddraw/main/surface_main.c | 16 +- reactos/dll/directx/ddraw/rosdraw.h | 24 +- reactos/dll/directx/ddraw/soft/ddraw_hel.c | 59 +- .../ddraw/soft/surface_callbacks_hel.c | 179 +--- reactos/dll/directx/ddraw/startup.c | 12 +- 9 files changed, 586 insertions(+), 763 deletions(-) diff --git a/reactos/dll/directx/ddraw/cleanup.c b/reactos/dll/directx/ddraw/cleanup.c index 918a289b0b3..856f552b14c 100644 --- a/reactos/dll/directx/ddraw/cleanup.c +++ b/reactos/dll/directx/ddraw/cleanup.c @@ -1,51 +1,51 @@ -/* $Id: main.c 21434 2006-04-01 19:12:56Z greatlrd $ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: lib/ddraw/ddraw.c - * PURPOSE: DirectDraw Library - * PROGRAMMER: Magnus Olsen (greatlrd) - * - */ - -#include -#include "rosdraw.h" -#include "d3dhal.h" - -VOID -Cleanup(LPDIRECTDRAW7 iface) -{ - IDirectDrawImpl* This = (IDirectDrawImpl*)iface; - - if (This->mDDrawGlobal.hDD != 0) - { - DdDeleteDirectDrawObject (&This->mDDrawGlobal); - } - - if (This->mpTextures != NULL) - { - DxHeapMemFree(This->mpTextures); - } - - if (This->mpFourCC != NULL) - { - DxHeapMemFree(This->mpFourCC); - } - - if (This->mpvmList != NULL) - { - DxHeapMemFree(This->mpvmList); - } - - if (This->mpModeInfos != NULL) - { - DxHeapMemFree(This->mpModeInfos); - } - - if (This->hdc != NULL) - { - DeleteDC(This->hdc); - } - -} - +/* $Id: main.c 21434 2006-04-01 19:12:56Z greatlrd $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: lib/ddraw/ddraw.c + * PURPOSE: DirectDraw Library + * PROGRAMMER: Magnus Olsen (greatlrd) + * + */ + +#include +#include "rosdraw.h" +#include "d3dhal.h" + +VOID +Cleanup(LPDIRECTDRAW7 iface) +{ + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + + if (This->mDDrawGlobal.hDD != 0) + { + DdDeleteDirectDrawObject (&This->mDDrawGlobal); + } + + if (This->mpTextures != NULL) + { + DxHeapMemFree(This->mpTextures); + } + + if (This->mpFourCC != NULL) + { + DxHeapMemFree(This->mpFourCC); + } + + if (This->mpvmList != NULL) + { + DxHeapMemFree(This->mpvmList); + } + + if (This->mpModeInfos != NULL) + { + DxHeapMemFree(This->mpModeInfos); + } + + if (This->hdc != NULL) + { + DeleteDC(This->hdc); + } + +} + diff --git a/reactos/dll/directx/ddraw/hal/ddraw_hal.c b/reactos/dll/directx/ddraw/hal/ddraw_hal.c index 4724b98fab6..e2f174616cd 100644 --- a/reactos/dll/directx/ddraw/hal/ddraw_hal.c +++ b/reactos/dll/directx/ddraw/hal/ddraw_hal.c @@ -11,6 +11,8 @@ #include "rosdraw.h" + + HRESULT Hal_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps, LPDWORD total, LPDWORD free) @@ -42,7 +44,29 @@ Hal_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps, return mem.ddRVal; } +HRESULT Hal_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags,HANDLE h) +{ + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + DDHAL_WAITFORVERTICALBLANKDATA WaitVectorData; + + if (!(This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_WAITFORVERTICALBLANK)) + { + return DDERR_NODRIVERSUPPORT; + } + + WaitVectorData.lpDD = &This->mDDrawGlobal; + WaitVectorData.dwFlags = dwFlags; + WaitVectorData.hEvent = (DWORD)h; + WaitVectorData.ddRVal = DDERR_NOTPALETTIZED; + + if (This->mDDrawGlobal.lpDDCBtmp->HALDD.WaitForVerticalBlank(&WaitVectorData) != DDHAL_DRIVER_HANDLED) + { + return DDERR_NODRIVERSUPPORT; + } + + return WaitVectorData.ddRVal; +} HRESULT Hal_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine) { @@ -67,31 +91,36 @@ HRESULT Hal_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine) return GetScan.ddRVal; } -HRESULT Hal_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface) + + + + +HRESULT Hal_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight, + DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) { - IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + DDHAL_SETMODEDATA mode; - DDHAL_FLIPTOGDISURFACEDATA FlipGdi; - - if (!(This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_FLIPTOGDISURFACE)) + if (!(This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_SETMODE)) { return DDERR_NODRIVERSUPPORT; } - - FlipGdi.lpDD = &This->mDDrawGlobal; - FlipGdi.ddRVal = DDERR_NOTPALETTIZED; - - if (This->mDDrawGlobal.lpDDCBtmp->HALDD.FlipToGDISurface(&FlipGdi) != DDHAL_DRIVER_HANDLED) - { - return DDERR_NODRIVERSUPPORT; - } - /* FIXME where should FlipGdi.dwToGDI be fill in */ - return FlipGdi.ddRVal; + mode.lpDD = &This->mDDrawGlobal; + mode.ddRVal = DDERR_NODRIVERSUPPORT; + + + + // FIXME : add search for which mode.ModeIndex we should use + // FIXME : fill the mode.inexcl; + // FIXME : fill the mode.useRefreshRate; + + if (This->mDDrawGlobal.lpDDCBtmp->HALDD.SetMode(&mode) != DDHAL_DRIVER_HANDLED) + { + return DDERR_NODRIVERSUPPORT; + } + + return mode.ddRVal; } - - - - diff --git a/reactos/dll/directx/ddraw/hal/surface_hal.c b/reactos/dll/directx/ddraw/hal/surface_hal.c index 8951857ae3d..e68d6a10db7 100644 --- a/reactos/dll/directx/ddraw/hal/surface_hal.c +++ b/reactos/dll/directx/ddraw/hal/surface_hal.c @@ -35,9 +35,9 @@ HRESULT Hal_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rDest, return DDERR_NODRIVERSUPPORT; } - mDdBlt.lpDDDestSurface = This->Owner->mpPrimaryLocals[0]; + mDdBlt.lpDDDestSurface = This->Surf->mpPrimaryLocals[0]; - if (!DdResetVisrgn(This->Owner->mpPrimaryLocals[0], NULL)) + if (!DdResetVisrgn(This->Surf->mpPrimaryLocals[0], NULL)) { return DDERR_NOGDI; } @@ -113,7 +113,7 @@ HRESULT Hal_DDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect, LPDDSURF Lock.lpDD = &This->Owner->mDDrawGlobal; Lock.lpSurfData = NULL; - if (!DdResetVisrgn(&This->Owner->mPrimaryLocal, NULL)) + if (!DdResetVisrgn(&This->Surf->mPrimaryLocal, NULL)) { OutputDebugStringA("Here DdResetVisrgn lock"); return DDERR_UNSUPPORTED; @@ -138,13 +138,13 @@ HRESULT Hal_DDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect, LPDDSURF { RtlZeroMemory(pDDSD,sizeof(DDSURFACEDESC2)); // FIXME the interanl mddsdPrimary shall be DDSURFACEDESC2 - memcpy(pDDSD,&This->Owner->mddsdPrimary,sizeof(DDSURFACEDESC)); + memcpy(pDDSD,&This->Surf->mddsdPrimary,sizeof(DDSURFACEDESC)); pDDSD->dwSize = sizeof(DDSURFACEDESC2); } if (pDDSD->dwSize == sizeof(DDSURFACEDESC)) { RtlZeroMemory(pDDSD,sizeof(DDSURFACEDESC)); - memcpy(pDDSD,&This->Owner->mddsdPrimary,sizeof(DDSURFACEDESC)); + memcpy(pDDSD,&This->Surf->mddsdPrimary,sizeof(DDSURFACEDESC)); pDDSD->dwSize = sizeof(DDSURFACEDESC); } diff --git a/reactos/dll/directx/ddraw/main/ddraw_main.c b/reactos/dll/directx/ddraw/main/ddraw_main.c index 70a62ffd056..40b22b8e846 100644 --- a/reactos/dll/directx/ddraw/main/ddraw_main.c +++ b/reactos/dll/directx/ddraw/main/ddraw_main.c @@ -8,12 +8,13 @@ * */ -#include "rosdraw.h" - /* * IMPLEMENT * Status ok */ + +#include "rosdraw.h" + HRESULT WINAPI Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface, @@ -49,7 +50,6 @@ Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface, Main_DirectDraw_AddRef(iface); return S_OK; } - /* * IMPLEMENT * Status ok @@ -104,6 +104,7 @@ Main_DirectDraw_Release (LPDIRECTDRAW7 iface) } return ref; } + /* * IMPLEMENT * Status ok @@ -131,16 +132,14 @@ Main_DirectDraw_CreateClipper(LPDIRECTDRAW7 iface, DX_WINDBG_trace(); if (pUnkOuter!=NULL) - return DDERR_INVALIDPARAMS; + return CLASS_E_NOAGGREGATION; IDirectDrawClipperImpl* That; That = (IDirectDrawClipperImpl*)HeapAlloc(GetProcessHeap(), 0, sizeof(IDirectDrawClipperImpl)); if (That == NULL) return E_OUTOFMEMORY; - - ZeroMemory(That, sizeof(IDirectDrawClipperImpl)); - + That->lpVtbl = &DirectDrawClipper_Vtable; That->ref = 1; *ppClipper = (LPDIRECTDRAWCLIPPER)That; @@ -148,7 +147,10 @@ Main_DirectDraw_CreateClipper(LPDIRECTDRAW7 iface, return That->lpVtbl->Initialize (*ppClipper, (LPDIRECTDRAW)iface, dwFlags); } - +/* + * IMPLEMENT + * Status ok + */ HRESULT WINAPI Main_DirectDraw_CreatePalette(LPDIRECTDRAW7 iface, DWORD dwFlags, LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE* ppPalette, LPUNKNOWN pUnkOuter) { @@ -258,318 +260,10 @@ HRESULT WINAPI Main_DirectDraw_CreatePalette(LPDIRECTDRAW7 iface, DWORD dwFlags, return DDERR_NODRIVERSUPPORT; } - - -const DDPIXELFORMAT pixelformats[] = -{ - /* 8bpp paletted */ - { sizeof(DDPIXELFORMAT), DDPF_RGB, 0, { 24 }, { 0xFF0000 }, - { 0x00FF00 }, { 0x0000FF } }, - /* 15bpp 5/5/5 */ - { sizeof(DDPIXELFORMAT), DDPF_RGB, 0, { 16 }, { 0x7C00 }, { 0x3E0 }, - { 0x1F } }, - /* 16bpp 5/6/5 */ - { sizeof(DDPIXELFORMAT), DDPF_RGB, 0, { 16 }, { 0xF800 }, { 0x7E0 }, - { 0x1F } }, - /* 24bpp 8/8/8 */ - { sizeof(DDPIXELFORMAT), DDPF_RGB, 0, { 24 }, { 0xFF0000 }, - { 0x00FF00 }, { 0x0000FF } }, - /* 32bpp 8/8/8 */ - { sizeof(DDPIXELFORMAT), DDPF_RGB, 0, { 32 }, { 0xFF0000 }, - { 0x00FF00 }, { 0x0000FF } } -}; - -const DWORD pixelformatsCount = sizeof(pixelformats) / sizeof(DDPIXELFORMAT); - -/* more surface format not adding it */ - /* 4 bit paletted 0 */ - // sizeof(DDPIXELFORMAT), DDPF_RGB | DDPF_PALETTEINDEXED4, 0, 4, 0x00, 0x00, 0x00, 0x00 - - ///* 8bpp paletted 1 */ - //{sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED8, 0, 8, 0, 0, 0, 0}, - - ///* 15bpp 5:5:5 RGB 2 */ - //{sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0x7c00, 0x03e0, 0x001f, 0}, - - ///* 15bpp 1:5:5:5 ARGB 3 */ - //{sizeof(DDPIXELFORMAT), DDPF_RGB | DDPF_ALPHAPIXELS, 0, 16, 0x7c00, 0x03e0, 0x001f, 0x8000}, - - ///* 16bpp 5:6:5 RGB 4 */ - //{sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0xf800, 0x07e0, 0x001f, 0} - - ///* 16bpp 4:4:4:4 ARGB 5 */ - //{sizeof(DDPIXELFORMAT), DDPF_RGB | DDPF_ALPHAPIXELS,´0, 16, 0x0f00, 0x00f0, 0x000f, 0xf000}, - - /* 24bpp 8/8/8 RGB 6 */ - // {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 24 , 0x00FF0000, 0x0000FF00 , 0x000000FF, 0 }, - - /* 32bpp 8:8:8 RGB 7 */ - // {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0}, - - /* 32bpp 8:8:8:8 ARGB 8*/ - // {sizeof(DDPIXELFORMAT), DDPF_RGB | DDPF_ALPHAPIXELS, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000} - - - - /* - * IMPLEMENT - * Status this api is finish and is 100% correct + * stub + * Status not done */ -HRESULT -WINAPI -Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID) -{ - DX_WINDBG_trace(); - - IDirectDrawImpl* This = (IDirectDrawImpl*)iface; - - if (iface==NULL) - { - return DDERR_NOTINITIALIZED; - } - - if (This->InitializeDraw == TRUE) - { - return DDERR_ALREADYINITIALIZED; - } - else - { - This->InitializeDraw = TRUE; - } - - return DD_OK; -} - - - - - - -/* - * IMPLEMENT - * Status - * not finish yet but is working fine - * it prevent memmory leaks at exit - */ - - - - - - -HRESULT WINAPI Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD cooplevel) -{ - // TODO: - // - create a scaner that check which driver we should get the HDC from - // for now we always asume it is the active dirver that should be use. - // - allow more Flags - - DX_WINDBG_trace(); - - IDirectDrawImpl* This = (IDirectDrawImpl*)iface; - DDHAL_SETEXCLUSIVEMODEDATA SetExclusiveMode; - - // check the parameters - if ((This->cooperative_level == cooplevel) && ((HWND)This->mDDrawGlobal.lpExclusiveOwner->hWnd == hwnd)) - return DD_OK; - - if (This->cooperative_level) - return DDERR_EXCLUSIVEMODEALREADYSET; - - if ((cooplevel&DDSCL_EXCLUSIVE) && !(cooplevel&DDSCL_FULLSCREEN)) - return DDERR_INVALIDPARAMS; - - if (cooplevel&DDSCL_NORMAL && cooplevel&DDSCL_FULLSCREEN) - return DDERR_INVALIDPARAMS; - - // set the data - This->mDDrawGlobal.lpExclusiveOwner->hWnd = (ULONG_PTR) hwnd; - This->mDDrawGlobal.lpExclusiveOwner->hDC = (ULONG_PTR)GetDC(hwnd); - - - /* FIXME : fill the mDDrawGlobal.lpExclusiveOwner->dwLocalFlags right */ - //mDDrawGlobal.lpExclusiveOwner->dwLocalFlags - - This->cooperative_level = cooplevel; - - if ((This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_SETEXCLUSIVEMODE)) - { - DX_STUB_str("HAL \n"); - SetExclusiveMode.SetExclusiveMode = This->mDDrawGlobal.lpDDCBtmp->HALDD.SetExclusiveMode; - } - else - { - DX_STUB_str("HEL \n"); - SetExclusiveMode.SetExclusiveMode = This->mDDrawGlobal.lpDDCBtmp->HELDD.SetExclusiveMode; - } - - SetExclusiveMode.lpDD = &This->mDDrawGlobal; - SetExclusiveMode.ddRVal = DDERR_NOTPALETTIZED; - SetExclusiveMode.dwEnterExcl = This->cooperative_level; - - if (SetExclusiveMode.SetExclusiveMode(&SetExclusiveMode) != DDHAL_DRIVER_HANDLED) - { - return DDERR_NODRIVERSUPPORT; - } - - return SetExclusiveMode.ddRVal; -} - -HRESULT WINAPI Main_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight, - DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) -{ - DX_WINDBG_trace(); - - IDirectDrawImpl* This = (IDirectDrawImpl*)iface; - //BOOL dummy = TRUE; - - DX_WINDBG_trace_res((int)dwWidth, (int)dwHeight, (int)dwBPP ); - /* FIXME check the refresrate if it same if it not same do the mode switch */ - if ((This->mDDrawGlobal.vmiData.dwDisplayHeight == dwHeight) && - (This->mDDrawGlobal.vmiData.dwDisplayWidth == dwWidth) && - (This->mDDrawGlobal.vmiData.ddpfDisplay.dwRGBBitCount == dwBPP)) - { - - return DD_OK; - } - - if (This->mDdSetMode.SetMode == NULL ) - { - return DDERR_NODRIVERSUPPORT; - } - - - This->mDdSetMode.ddRVal = DDERR_NODRIVERSUPPORT; - - // FIXME : fill the mode.inexcl; - // FIXME : fill the mode.useRefreshRate; - - /* FIXME - we hardcoding modIndex list we should - try getting it from ReactOS instead and compare it - for now a small hack for do, using VBE 3.0 mode - index table todo it. - */ - - /* 320x200 15, 16, 32 */ - if ((dwHeight == 200) && (dwWidth == 320) && (dwBPP == 15)) - { - This->mDdSetMode.dwModeIndex = 0x10d; - } - - if ((dwHeight == 200) && (dwWidth == 320) && (dwBPP == 16)) - { - This->mDdSetMode.dwModeIndex = 0x10e; - } - - if ((dwHeight == 200) && (dwWidth == 320) && (dwBPP == 32)) - { - This->mDdSetMode.dwModeIndex = 0x10f; - } - - - /* 640x400 8 */ - if ((dwHeight == 400) && (dwWidth == 640) && (dwBPP == 8)) - { - This->mDdSetMode.dwModeIndex = 0x100; - } - - /* 640x480 8, 15, 16 , 32*/ - if ((dwHeight == 480) && (dwWidth == 640) && (dwBPP == 8)) - { - This->mDdSetMode.dwModeIndex = 0x101; - } - - if ((dwHeight == 480) && (dwWidth == 640) && (dwBPP == 15)) - { - This->mDdSetMode.dwModeIndex = 0x110; - } - - if ((dwHeight == 480) && (dwWidth == 640) && (dwBPP == 16)) - { - This->mDdSetMode.dwModeIndex = 0x111; - } - - if ((dwHeight == 480) && (dwWidth == 640) && (dwBPP == 32)) - { - This->mDdSetMode.dwModeIndex = 0x112; - } - - /* 800x600 4, 8, 15, 16 , 32*/ - if ((dwHeight == 600) && (dwWidth == 800) && (dwBPP == 4)) - { - This->mDdSetMode.dwModeIndex = 0x102; - } - - if ((dwHeight == 600) && (dwWidth == 800) && (dwBPP == 8)) - { - This->mDdSetMode.dwModeIndex = 0x103; - } - - if ((dwHeight == 600) && (dwWidth == 800) && (dwBPP == 15)) - { - This->mDdSetMode.dwModeIndex = 0x113; - } - - if ((dwHeight == 600) && (dwWidth == 800) && (dwBPP == 16)) - { - This->mDdSetMode.dwModeIndex = 0x114; - } - - if ((dwHeight == 600) && (dwWidth == 800) && (dwBPP == 32)) - { - This->mDdSetMode.dwModeIndex = 0x115; - } - - /* 1024x768 8, 15, 16 , 32*/ - - if ((dwHeight == 768) && (dwWidth == 1024) && (dwBPP == 4)) - { - This->mDdSetMode.dwModeIndex = 0x104; - } - - if ((dwHeight == 768) && (dwWidth == 1024) && (dwBPP == 8)) - { - This->mDdSetMode.dwModeIndex = 0x105; - } - - if ((dwHeight == 768) && (dwWidth == 1024) && (dwBPP == 15)) - { - This->mDdSetMode.dwModeIndex = 0x116; - } - if ((dwHeight == 768) && (dwWidth == 1024) && (dwBPP == 16)) - { - This->mDdSetMode.dwModeIndex = 0x117; - } - - if ((dwHeight == 768) && (dwWidth == 1024) && (dwBPP == 32)) - { - This->mDdSetMode.dwModeIndex = 0x118; - } - - /* not coding for 1280x1024 */ - - - if (This->mDdSetMode.SetMode(&This->mDdSetMode)==DDHAL_DRIVER_HANDLED); - { - - //if (This->mDdSetMode.ddRVal == DD_OK) - //{ - // // DdReenableDirectDrawObject(&This->mDDrawGlobal, &dummy); - // /* FIXME fill the This->DirectDrawGlobal.vmiData right */ - //} - - return This->mDdSetMode.ddRVal; - } - return DDERR_NODRIVERSUPPORT; -} - - - - - - HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD, LPDIRECTDRAWSURFACE7 *ppSurf, IUnknown *pUnkOuter) { @@ -631,10 +325,10 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE if (pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) { - memcpy(&That->Owner->mddsdPrimary,pDDSD,sizeof(DDSURFACEDESC)); - That->Owner->mddsdPrimary.dwSize = sizeof(DDSURFACEDESC); + memcpy(&That->Surf->mddsdPrimary,pDDSD,sizeof(DDSURFACEDESC)); + That->Surf->mddsdPrimary.dwSize = sizeof(DDSURFACEDESC); This->mDdCanCreateSurface.bIsDifferentPixelFormat = FALSE; - This->mDdCanCreateSurface.lpDDSurfaceDesc = (DDSURFACEDESC*)&That->Owner->mddsdPrimary; + This->mDdCanCreateSurface.lpDDSurfaceDesc = &That->Surf->mddsdPrimary; if (This->mDdCanCreateSurface.CanCreateSurface(&This->mDdCanCreateSurface)== DDHAL_DRIVER_NOTHANDLED) { @@ -654,26 +348,26 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE That->Owner->mPrimaryGlobal.wHeight = (WORD)This->mpModeInfos[0].dwHeight; That->Owner->mPrimaryGlobal.lPitch = This->mpModeInfos[0].lPitch; - memset(&That->Owner->mPrimaryMore, 0, sizeof(DDRAWI_DDRAWSURFACE_MORE)); - That->Owner->mPrimaryMore.dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE); + memset(&That->Surf->mPrimaryMore, 0, sizeof(DDRAWI_DDRAWSURFACE_MORE)); + That->Surf->mPrimaryMore.dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE); - memset(&That->Owner->mPrimaryLocal, 0, sizeof(DDRAWI_DDRAWSURFACE_LCL)); - That->Owner->mPrimaryLocal.lpGbl = &That->Owner->mPrimaryGlobal; - That->Owner->mPrimaryLocal.lpSurfMore = &That->Owner->mPrimaryMore; - That->Owner->mPrimaryLocal.dwProcessId = GetCurrentProcessId(); + memset(&That->Surf->mPrimaryLocal, 0, sizeof(DDRAWI_DDRAWSURFACE_LCL)); + That->Surf->mPrimaryLocal.lpGbl = &That->Owner->mPrimaryGlobal; + That->Surf->mPrimaryLocal.lpSurfMore = &That->Surf->mPrimaryMore; + That->Surf->mPrimaryLocal.dwProcessId = GetCurrentProcessId(); /* FIXME Check the flags if we shall create a primaresurface for overlay or something else Examine windows which flags are being set for we assume this is right unsue I think */ //That->Surf->mPrimaryLocal.dwFlags = DDRAWISURF_PARTOFPRIMARYCHAIN|DDRAWISURF_HASOVERLAYDATA; - That->Owner->mPrimaryLocal.ddsCaps.dwCaps = That->Owner->mddsdPrimary.ddsCaps.dwCaps; - That->Owner->mpPrimaryLocals[0] = &That->Owner->mPrimaryLocal; + That->Surf->mPrimaryLocal.ddsCaps.dwCaps = That->Surf->mddsdPrimary.ddsCaps.dwCaps; + That->Surf->mpPrimaryLocals[0] = &That->Surf->mPrimaryLocal; - This->mDdCreateSurface.lpDDSurfaceDesc = (DDSURFACEDESC*)&That->Owner->mddsdPrimary; - This->mDdCreateSurface.lplpSList = That->Owner->mpPrimaryLocals; + This->mDdCreateSurface.lpDDSurfaceDesc = &That->Surf->mddsdPrimary; + This->mDdCreateSurface.lplpSList = That->Surf->mpPrimaryLocals; This->mDdCreateSurface.dwSCnt = This->mDDrawGlobal.dsList->dwIntRefCnt ; @@ -700,8 +394,8 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE DDSD_ZBUFFERBITDEPTH */ - That->Owner->mddsdPrimary.dwFlags = DDSD_CAPS + DDSD_PIXELFORMAT; - RtlCopyMemory(&That->Owner->mddsdPrimary.ddpfPixelFormat,&This->mDDrawGlobal.vmiData.ddpfDisplay,sizeof(DDPIXELFORMAT)); + That->Surf->mddsdPrimary.dwFlags = DDSD_CAPS + DDSD_PIXELFORMAT; + RtlCopyMemory(&That->Surf->mddsdPrimary.ddpfPixelFormat,&This->mDDrawGlobal.vmiData.ddpfDisplay,sizeof(DDPIXELFORMAT)); //RtlCopyMemory(&That->Surf->mddsdPrimary.ddsCaps,&This->mDDrawGlobal.ddCaps,sizeof(DDCORECAPS)); //RtlCopyMemory(&pDDSD->ddckCKDestOverlay,&This->mDDrawGlobal.ddckCKDestOverlay,sizeof(DDCOLORKEY)); @@ -709,35 +403,35 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE if (This->mDDrawGlobal.vmiData.dwDisplayHeight != 0) { - That->Owner->mddsdPrimary.dwFlags += DDSD_HEIGHT ; - That->Owner->mddsdPrimary.dwHeight = This->mDDrawGlobal.vmiData.dwDisplayHeight; + That->Surf->mddsdPrimary.dwFlags += DDSD_HEIGHT ; + That->Surf->mddsdPrimary.dwHeight = This->mDDrawGlobal.vmiData.dwDisplayHeight; } if (This->mDDrawGlobal.vmiData.dwDisplayWidth != 0) { - That->Owner->mddsdPrimary.dwFlags += DDSD_WIDTH ; - That->Owner->mddsdPrimary.dwWidth = This->mDDrawGlobal.vmiData.dwDisplayWidth; + That->Surf->mddsdPrimary.dwFlags += DDSD_WIDTH ; + That->Surf->mddsdPrimary.dwWidth = This->mDDrawGlobal.vmiData.dwDisplayWidth; } if (This->mDDrawGlobal.vmiData.lDisplayPitch != 0) { - That->Owner->mddsdPrimary.dwFlags += DDSD_PITCH ; - That->Owner->mddsdPrimary.lPitch = This->mDDrawGlobal.vmiData.lDisplayPitch; + That->Surf->mddsdPrimary.dwFlags += DDSD_PITCH ; + That->Surf->mddsdPrimary.lPitch = This->mDDrawGlobal.vmiData.lDisplayPitch; } if ( This->mDDrawGlobal.dwMonitorFrequency != 0) { - That->Owner->mddsdPrimary.dwFlags += DDSD_REFRESHRATE ; - That->Owner->mddsdPrimary.dwRefreshRate = This->mDDrawGlobal.dwMonitorFrequency; + That->Surf->mddsdPrimary.dwFlags += DDSD_REFRESHRATE ; + That->Surf->mddsdPrimary.dwRefreshRate = This->mDDrawGlobal.dwMonitorFrequency; } if (This->mDDrawGlobal.vmiData.ddpfDisplay.dwAlphaBitDepth != 0) { - That->Owner->mddsdPrimary.dwFlags += DDSD_ALPHABITDEPTH ; - That->Owner->mddsdPrimary.dwAlphaBitDepth = This->mDDrawGlobal.vmiData.ddpfDisplay.dwAlphaBitDepth; + That->Surf->mddsdPrimary.dwFlags += DDSD_ALPHABITDEPTH ; + That->Surf->mddsdPrimary.dwAlphaBitDepth = This->mDDrawGlobal.vmiData.ddpfDisplay.dwAlphaBitDepth; } - That->Surf->mpInUseSurfaceLocals[0] = &That->Owner->mPrimaryLocal; + That->Surf->mpInUseSurfaceLocals[0] = &That->Surf->mPrimaryLocal; return DD_OK; } @@ -873,32 +567,209 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE } - - -// This function is exported by the dll -HRESULT WINAPI DirectDrawCreateClipper (DWORD dwFlags, - LPDIRECTDRAWCLIPPER* lplpDDClipper, LPUNKNOWN pUnkOuter) +/* + * stub + * Status not done + */ +HRESULT WINAPI Main_DirectDraw_DuplicateSurface(LPDIRECTDRAW7 iface, LPDIRECTDRAWSURFACE7 src, + LPDIRECTDRAWSURFACE7* dst) { DX_WINDBG_trace(); - - return Main_DirectDraw_CreateClipper(NULL, dwFlags, lplpDDClipper, pUnkOuter); + DX_STUB; } +/* + * IMPLEMENT + * Status ok + */ +HRESULT WINAPI Main_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags, + LPDDSURFACEDESC2 pDDSD, LPVOID context, LPDDENUMMODESCALLBACK2 callback) +{ + + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + DDSURFACEDESC2 desc_callback; + DEVMODE DevMode; + int iMode=0; + + RtlZeroMemory(&desc_callback, sizeof(DDSURFACEDESC2)); + + desc_callback.dwSize = sizeof(DDSURFACEDESC2); + desc_callback.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH; -HRESULT WINAPI Main_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface) + if (dwFlags & DDEDM_REFRESHRATES) + { + desc_callback.dwFlags |= DDSD_REFRESHRATE; + desc_callback.dwRefreshRate = This->mDDrawGlobal.dwMonitorFrequency; + } + + + /* FIXME check if the mode are suppretd before sending it back */ + + while (EnumDisplaySettingsEx(NULL, iMode, &DevMode, 0)) + { + + if (pDDSD) + { + if ((pDDSD->dwFlags & DDSD_WIDTH) && (pDDSD->dwWidth != DevMode.dmPelsWidth)) + continue; + if ((pDDSD->dwFlags & DDSD_HEIGHT) && (pDDSD->dwHeight != DevMode.dmPelsHeight)) + continue; + if ((pDDSD->dwFlags & DDSD_PIXELFORMAT) && (pDDSD->ddpfPixelFormat.dwFlags & DDPF_RGB) && + (pDDSD->ddpfPixelFormat.dwRGBBitCount != DevMode.dmBitsPerPel)) + continue; + } + + desc_callback.dwHeight = DevMode.dmPelsHeight; + desc_callback.dwWidth = DevMode.dmPelsWidth; + + if (DevMode.dmFields & DM_DISPLAYFREQUENCY) + { + desc_callback.dwRefreshRate = DevMode.dmDisplayFrequency; + } + + if (desc_callback.dwRefreshRate == 0) + { + DX_STUB_str("dwRefreshRate = 0, we hard code it to value 60"); + desc_callback.dwRefreshRate = 60; /* Maybe the valye should be biger */ + } + + /* above same as wine */ + if ((pDDSD->dwFlags & DDSD_PIXELFORMAT) && (pDDSD->ddpfPixelFormat.dwFlags & DDPF_RGB) ) + { + switch(DevMode.dmBitsPerPel) + { + case 8: + desc_callback.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); + desc_callback.ddpfPixelFormat.dwFlags = DDPF_RGB; + desc_callback.ddpfPixelFormat.dwFourCC = 0; + desc_callback.ddpfPixelFormat.dwRGBBitCount=8; + /* FIXME right value */ + desc_callback.ddpfPixelFormat.dwRBitMask = 0xFF0000; /* red bitmask */ + desc_callback.ddpfPixelFormat.dwGBitMask = 0; /* Green bitmask */ + desc_callback.ddpfPixelFormat.dwBBitMask = 0; /* Blue bitmask */ + break; + + case 15: + desc_callback.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); + desc_callback.ddpfPixelFormat.dwFlags = DDPF_RGB; + desc_callback.ddpfPixelFormat.dwFourCC = 0; + desc_callback.ddpfPixelFormat.dwRGBBitCount=15; + /* FIXME right value */ + desc_callback.ddpfPixelFormat.dwRBitMask = 0x7C00; /* red bitmask */ + desc_callback.ddpfPixelFormat.dwGBitMask = 0x3E0; /* Green bitmask */ + desc_callback.ddpfPixelFormat.dwBBitMask = 0x1F; /* Blue bitmask */ + break; + + case 16: + desc_callback.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); + desc_callback.ddpfPixelFormat.dwFlags = DDPF_RGB; + desc_callback.ddpfPixelFormat.dwFourCC = 0; + desc_callback.ddpfPixelFormat.dwRGBBitCount=16; + /* FIXME right value */ + desc_callback.ddpfPixelFormat.dwRBitMask = 0xF800; /* red bitmask */ + desc_callback.ddpfPixelFormat.dwGBitMask = 0x7E0; /* Green bitmask */ + desc_callback.ddpfPixelFormat.dwBBitMask = 0x1F; /* Blue bitmask */ + break; + + case 24: + desc_callback.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); + desc_callback.ddpfPixelFormat.dwFlags = DDPF_RGB; + desc_callback.ddpfPixelFormat.dwFourCC = 0; + desc_callback.ddpfPixelFormat.dwRGBBitCount=24; + /* FIXME right value */ + desc_callback.ddpfPixelFormat.dwRBitMask = 0xFF0000; /* red bitmask */ + desc_callback.ddpfPixelFormat.dwGBitMask = 0x00FF00; /* Green bitmask */ + desc_callback.ddpfPixelFormat.dwBBitMask = 0x0000FF; /* Blue bitmask */ + break; + + case 32: + desc_callback.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); + desc_callback.ddpfPixelFormat.dwFlags = DDPF_RGB; + desc_callback.ddpfPixelFormat.dwFourCC = 0; + desc_callback.ddpfPixelFormat.dwRGBBitCount=8; + /* FIXME right value */ + desc_callback.ddpfPixelFormat.dwRBitMask = 0xFF0000; /* red bitmask */ + desc_callback.ddpfPixelFormat.dwGBitMask = 0x00FF00; /* Green bitmask */ + desc_callback.ddpfPixelFormat.dwBBitMask = 0x0000FF; /* Blue bitmask */ + break; + + default: + break; + } + desc_callback.ddsCaps.dwCaps = 0; + if (desc_callback.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) + { + /* FIXME srt DDCS Caps flag */ + desc_callback.ddsCaps.dwCaps |= DDSCAPS_PALETTE; + } + } + + if (DevMode.dmBitsPerPel==15) + { + desc_callback.lPitch = DevMode.dmPelsWidth + (8 - ( DevMode.dmPelsWidth % 8)) % 8; + } + else + { + desc_callback.lPitch = DevMode.dmPelsWidth * (DevMode.dmBitsPerPel / 8); + desc_callback.lPitch = desc_callback.lPitch + (8 - (desc_callback.lPitch % 8)) % 8; + } + + if (callback(&desc_callback, context) == DDENUMRET_CANCEL) + { + return DD_OK; + } + + iMode++; + } + + return DD_OK; +} + +/* + * stub + * Status not done + */ +HRESULT WINAPI +Main_DirectDraw_EnumSurfaces(LPDIRECTDRAW7 iface, DWORD dwFlags, + LPDDSURFACEDESC2 lpDDSD2, LPVOID context, + LPDDENUMSURFACESCALLBACK7 callback) +{ + DX_WINDBG_trace(); + DX_STUB; +} + +/* + * IMPLEMENT + * Status ok + */ +HRESULT WINAPI +Main_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface) { IDirectDrawImpl* This = (IDirectDrawImpl*)iface; - if (This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_FLIPTOGDISURFACE) - { - return Hal_DirectDraw_FlipToGDISurface( iface); - } + if (This->mDdFlipToGDISurface.FlipToGDISurface == NULL) + { + return DDERR_NODRIVERSUPPORT; + } - return Hel_DirectDraw_FlipToGDISurface( iface); + This->mDdFlipToGDISurface.ddRVal = DDERR_NOTPALETTIZED; + This->mDdFlipToGDISurface.dwToGDI = TRUE; + + if (This->mDdFlipToGDISurface.FlipToGDISurface(&This->mDdFlipToGDISurface)==DDHAL_DRIVER_HANDLED); + { + return This->mDdFlipToGDISurface.ddRVal; + } + + return DDERR_NODRIVERSUPPORT; } - -HRESULT WINAPI Main_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps, + +/* + * IMPLEMENT + * Status ok + */ +HRESULT WINAPI +Main_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps, LPDDCAPS pHELCaps) { DX_WINDBG_trace(); @@ -908,10 +779,7 @@ HRESULT WINAPI Main_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps IDirectDrawImpl *This = (IDirectDrawImpl *)iface; if (pDriverCaps != NULL) - { - - - + { Main_DirectDraw_GetAvailableVidMem(iface, &ddscaps, &This->mDDrawGlobal.ddCaps.dwVidMemTotal, @@ -937,6 +805,160 @@ HRESULT WINAPI Main_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps return status; } + + +/* + * IMPLEMENT + * Status this api is finish and is 100% correct + */ +HRESULT +WINAPI +Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID) +{ + DX_WINDBG_trace(); + + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + + if (iface==NULL) + { + return DDERR_NOTINITIALIZED; + } + + if (This->InitializeDraw == TRUE) + { + return DDERR_ALREADYINITIALIZED; + } + else + { + This->InitializeDraw = TRUE; + } + + return DD_OK; +} + +HRESULT WINAPI Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD cooplevel) +{ + // TODO: + // - create a scaner that check which driver we should get the HDC from + // for now we always asume it is the active dirver that should be use. + // - allow more Flags + + DX_WINDBG_trace(); + + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + DDHAL_SETEXCLUSIVEMODEDATA SetExclusiveMode; + + // check the parameters + if ((This->cooperative_level == cooplevel) && ((HWND)This->mDDrawGlobal.lpExclusiveOwner->hWnd == hwnd)) + return DD_OK; + + if (This->cooperative_level) + return DDERR_EXCLUSIVEMODEALREADYSET; + + if ((cooplevel&DDSCL_EXCLUSIVE) && !(cooplevel&DDSCL_FULLSCREEN)) + return DDERR_INVALIDPARAMS; + + if (cooplevel&DDSCL_NORMAL && cooplevel&DDSCL_FULLSCREEN) + return DDERR_INVALIDPARAMS; + + // set the data + This->mDDrawGlobal.lpExclusiveOwner->hWnd = (ULONG_PTR) hwnd; + This->mDDrawGlobal.lpExclusiveOwner->hDC = (ULONG_PTR)GetDC(hwnd); + + + /* FIXME : fill the mDDrawGlobal.lpExclusiveOwner->dwLocalFlags right */ + //mDDrawGlobal.lpExclusiveOwner->dwLocalFlags + + This->cooperative_level = cooplevel; + + if ((This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_SETEXCLUSIVEMODE)) + { + DX_STUB_str("HAL \n"); + SetExclusiveMode.SetExclusiveMode = This->mDDrawGlobal.lpDDCBtmp->HALDD.SetExclusiveMode; + } + else + { + DX_STUB_str("HEL \n"); + SetExclusiveMode.SetExclusiveMode = This->mDDrawGlobal.lpDDCBtmp->HELDD.SetExclusiveMode; + } + + SetExclusiveMode.lpDD = &This->mDDrawGlobal; + SetExclusiveMode.ddRVal = DDERR_NOTPALETTIZED; + SetExclusiveMode.dwEnterExcl = This->cooperative_level; + + if (SetExclusiveMode.SetExclusiveMode(&SetExclusiveMode) != DDHAL_DRIVER_HANDLED) + { + return DDERR_NODRIVERSUPPORT; + } + + return SetExclusiveMode.ddRVal; +} + +HRESULT WINAPI Main_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight, + DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) +{ + DX_WINDBG_trace(); + + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + BOOL dummy = TRUE; + DWORD ret; + + /* FIXME check the refresrate if it same if it not same do the mode switch */ + if ((This->mDDrawGlobal.vmiData.dwDisplayHeight == dwHeight) && + (This->mDDrawGlobal.vmiData.dwDisplayWidth == dwWidth) && + (This->mDDrawGlobal.vmiData.ddpfDisplay.dwRGBBitCount == dwBPP)) + { + + return DD_OK; + } + + /* Check use the Hal or Hel for SetMode */ + if (This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_SETMODE) + { + ret = Hal_DirectDraw_SetDisplayMode(iface, dwWidth, dwHeight, dwBPP, dwRefreshRate, dwFlags); + + } + else + { + ret = Hel_DirectDraw_SetDisplayMode(iface, dwWidth, dwHeight, dwBPP, dwRefreshRate, dwFlags); + } + + if (ret == DD_OK) + { + DdReenableDirectDrawObject(&This->mDDrawGlobal, &dummy); + /* FIXME fill the This->DirectDrawGlobal.vmiData right */ + } + + //This->mDDrawGlobal.lpExclusiveOwner->hDC = (ULONG_PTR)GetDC( (HWND)This->mDDrawGlobal.lpExclusiveOwner->hWnd); + + + + + return ret; +} + + + + + + + + + +// This function is exported by the dll +HRESULT WINAPI DirectDrawCreateClipper (DWORD dwFlags, + LPDIRECTDRAWCLIPPER* lplpDDClipper, LPUNKNOWN pUnkOuter) +{ + DX_WINDBG_trace(); + + return Main_DirectDraw_CreateClipper(NULL, dwFlags, lplpDDClipper, pUnkOuter); +} + + + + + + HRESULT WINAPI Main_DirectDraw_GetDisplayMode(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD) { DX_WINDBG_trace(); @@ -981,21 +1003,12 @@ HRESULT WINAPI Main_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD d IDirectDrawImpl* This = (IDirectDrawImpl*)iface; - if (This->mDdWaitForVerticalBlank.WaitForVerticalBlank == NULL) + if (This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_WAITFORVERTICALBLANK) { - return DDERR_NODRIVERSUPPORT; - } - - This->mDdWaitForVerticalBlank.dwFlags = dwFlags; - This->mDdWaitForVerticalBlank.hEvent = (DWORD)h; - This->mDdWaitForVerticalBlank.ddRVal = DDERR_NOTPALETTIZED; - - if (This->mDdWaitForVerticalBlank.WaitForVerticalBlank(&This->mDdWaitForVerticalBlank) != DDHAL_DRIVER_HANDLED) - { - return DDERR_NODRIVERSUPPORT; + return Hal_DirectDraw_WaitForVerticalBlank( iface, dwFlags, h); } - return This->mDdWaitForVerticalBlank.ddRVal; + return Hel_DirectDraw_WaitForVerticalBlank( iface, dwFlags, h); } HRESULT WINAPI Main_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps, @@ -1055,128 +1068,11 @@ HRESULT WINAPI Main_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface) -HRESULT WINAPI Main_DirectDraw_DuplicateSurface(LPDIRECTDRAW7 iface, LPDIRECTDRAWSURFACE7 src, - LPDIRECTDRAWSURFACE7* dst) -{ - DX_WINDBG_trace(); - DX_STUB; -} - -HRESULT WINAPI Main_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags, - LPDDSURFACEDESC2 pDDSD, LPVOID context, LPDDENUMMODESCALLBACK2 callback) -{ - DX_WINDBG_trace(); - - IDirectDrawImpl* This = (IDirectDrawImpl*)iface; - DDSURFACEDESC2 desc_callback; - DEVMODE DevMode; - int iMode=0; - - if (pDDSD!=NULL) - { - // FIXME fill in pDDSD - } - - RtlZeroMemory(&desc_callback, sizeof(DDSURFACEDESC2)); - desc_callback.dwSize = sizeof(DDSURFACEDESC2); - - desc_callback.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_CAPS | DDSD_PITCH; - - if (dwFlags & DDEDM_REFRESHRATES) - { - desc_callback.dwFlags |= DDSD_REFRESHRATE; - desc_callback.dwRefreshRate = This->mDDrawGlobal.dwMonitorFrequency; - } - - - /// FIXME check if the mode are suppretd before sending it back - - while (EnumDisplaySettingsEx(NULL, iMode, &DevMode, 0)) - { - - if (pDDSD) - { - if ((pDDSD->dwFlags & DDSD_WIDTH) && (pDDSD->dwWidth != DevMode.dmPelsWidth)) - continue; - if ((pDDSD->dwFlags & DDSD_HEIGHT) && (pDDSD->dwHeight != DevMode.dmPelsHeight)) - continue; - if ((pDDSD->dwFlags & DDSD_PIXELFORMAT) && (pDDSD->ddpfPixelFormat.dwFlags & DDPF_RGB) && - (pDDSD->ddpfPixelFormat.dwRGBBitCount != DevMode.dmBitsPerPel)) - continue; - } - - - desc_callback.dwHeight = DevMode.dmPelsHeight; - desc_callback.dwWidth = DevMode.dmPelsWidth; - - if (DevMode.dmFields & DM_DISPLAYFREQUENCY) - { - desc_callback.dwRefreshRate = DevMode.dmDisplayFrequency; - } - - switch(DevMode.dmBitsPerPel) - { - case 8: - memcpy(&desc_callback.ddpfPixelFormat,&pixelformats[0],sizeof(DDPIXELFORMAT)); - break; - - case 15: - memcpy(&desc_callback.ddpfPixelFormat,&pixelformats[1],sizeof(DDPIXELFORMAT)); - break; - - case 16: - memcpy(&desc_callback.ddpfPixelFormat,&pixelformats[2],sizeof(DDPIXELFORMAT)); - break; - case 24: - memcpy(&desc_callback.ddpfPixelFormat,&pixelformats[3],sizeof(DDPIXELFORMAT)); - break; - case 32: - memcpy(&desc_callback.ddpfPixelFormat,&pixelformats[4],sizeof(DDPIXELFORMAT)); - break; - default: - break; - } - - if (desc_callback.ddpfPixelFormat.dwRGBBitCount==15) - { - desc_callback.lPitch = DevMode.dmPelsWidth + (8 - ( DevMode.dmPelsWidth % 8)) % 8; - } - else - { - desc_callback.lPitch = DevMode.dmPelsWidth * (desc_callback.ddpfPixelFormat.dwRGBBitCount / 8); - desc_callback.lPitch = desc_callback.lPitch + (8 - (desc_callback.lPitch % 8)) % 8; - } - - desc_callback.ddsCaps.dwCaps = 0; - if (desc_callback.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) - { - desc_callback.ddsCaps.dwCaps |= DDSCAPS_PALETTE; - } - - if (callback(&desc_callback, context) == DDENUMRET_CANCEL) - { - - return DD_OK; - } - - iMode++; - } - - return DD_OK; -} - -HRESULT WINAPI Main_DirectDraw_EnumSurfaces(LPDIRECTDRAW7 iface, DWORD dwFlags, - LPDDSURFACEDESC2 lpDDSD2, LPVOID context, - LPDDENUMSURFACESCALLBACK7 callback) -{ - DX_WINDBG_trace(); - DX_STUB; -} HRESULT WINAPI Main_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes, LPDWORD pCodes) diff --git a/reactos/dll/directx/ddraw/main/surface_main.c b/reactos/dll/directx/ddraw/main/surface_main.c index ce522edc5ff..4ecdfbbcafd 100644 --- a/reactos/dll/directx/ddraw/main/surface_main.c +++ b/reactos/dll/directx/ddraw/main/surface_main.c @@ -125,7 +125,7 @@ Main_DDrawSurface_AddAttachedSurface(LPDIRECTDRAWSURFACE7 iface, That = (IDirectDrawSurfaceImpl*)pAttach; //FIXME Have I put This and That in right order ?? DdAttachSurface(from, to) - return DdAttachSurface( That->Owner->mpPrimaryLocals[0],This->Owner->mpPrimaryLocals[0]); + return DdAttachSurface( That->Surf->mpPrimaryLocals[0],This->Surf->mpPrimaryLocals[0]); } /* MSDN: "not currently implemented." */ @@ -274,7 +274,7 @@ Main_DDrawSurface_GetCaps(LPDIRECTDRAWSURFACE7 iface, LPDDSCAPS2 pCaps) This = (IDirectDrawSurfaceImpl*)iface; RtlZeroMemory(pCaps,sizeof(DDSCAPS2)); - pCaps->dwCaps = This->Owner->mddsdPrimary.ddsCaps.dwCaps; + pCaps->dwCaps = This->Surf->mddsdPrimary.ddsCaps.dwCaps; return DD_OK; } @@ -321,14 +321,14 @@ Main_DDrawSurface_GetDC(LPDIRECTDRAWSURFACE7 iface, HDC *phDC) for now we aussme the surface exits and create the hDC for it */ - if ((HDC)This->Owner->mPrimaryLocal.hDC == NULL) + if ((HDC)This->Surf->mPrimaryLocal.hDC == NULL) { - This->Owner->mPrimaryLocal.hDC = (ULONG_PTR)GetDC((HWND)This->Owner->mDDrawGlobal.lpExclusiveOwner->hWnd); - *phDC = (HDC)This->Owner->mPrimaryLocal.hDC; + This->Surf->mPrimaryLocal.hDC = (ULONG_PTR)GetDC((HWND)This->Owner->mDDrawGlobal.lpExclusiveOwner->hWnd); + *phDC = (HDC)This->Surf->mPrimaryLocal.hDC; } else { - *phDC = (HDC)This->Owner->mpPrimaryLocals[0]->hDC; + *phDC = (HDC)This->Surf->mpPrimaryLocals[0]->hDC; } return DD_OK; @@ -420,7 +420,7 @@ Main_DDrawSurface_GetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface, } RtlZeroMemory(pDDSD,dwSize); - memcpy(pDDSD, &This->Owner->mddsdPrimary, sizeof(DDSURFACEDESC)); + memcpy(pDDSD, &This->Surf->mddsdPrimary, sizeof(DDSURFACEDESC)); pDDSD->dwSize = dwSize; return DD_OK; @@ -482,7 +482,7 @@ Main_DDrawSurface_ReleaseDC(LPDIRECTDRAWSURFACE7 iface, HDC hDC) /* FIXME check if surface exits or not */ - if ((HDC)This->Owner->mPrimaryLocal.hDC == NULL) + if ((HDC)This->Surf->mPrimaryLocal.hDC == NULL) { return DDERR_GENERIC; } diff --git a/reactos/dll/directx/ddraw/rosdraw.h b/reactos/dll/directx/ddraw/rosdraw.h index bc334661a99..a9f34620b67 100644 --- a/reactos/dll/directx/ddraw/rosdraw.h +++ b/reactos/dll/directx/ddraw/rosdraw.h @@ -71,7 +71,10 @@ typedef struct DWORD *mpFourCC; UINT mcTextures; - DDSURFACEDESC2 *mpTextures; + DDSURFACEDESC *mpTextures; + + + /* ExclusiveOwner */ @@ -82,7 +85,7 @@ typedef struct /* HEL stuff */ DWORD HELMemoryAvilable; - + /* DD Callbacks info */ DDHAL_DESTROYDRIVERDATA mDdDestroyDriver; DDHAL_CREATESURFACEDATA mDdCreateSurface; @@ -95,15 +98,7 @@ typedef struct DDHAL_SETEXCLUSIVEMODEDATA mDdSetExclusiveMode; DDHAL_FLIPTOGDISURFACEDATA mDdFlipToGDISurface; - /* Primarey surface we must reach it from every where */ DDRAWI_DDRAWSURFACE_GBL mPrimaryGlobal; - DDRAWI_DDRAWSURFACE_MORE mPrimaryMore; - DDRAWI_DDRAWSURFACE_LCL mPrimaryLocal; - DDRAWI_DDRAWSURFACE_LCL *mpPrimaryLocals[1]; - DDRAWI_DDRAWCLIPPER_LCL mPrimaryClipperLocal; - DDRAWI_DDRAWCLIPPER_GBL mPrimaryClipperGlobal; - - DDSURFACEDESC2 mddsdPrimary; /* adding a switch */ DWORD devicetype; @@ -113,6 +108,15 @@ typedef struct /******** Surface Object ********/ typedef struct { + /* Primarey surface we must reach it from every where */ + + DDRAWI_DDRAWSURFACE_MORE mPrimaryMore; + DDRAWI_DDRAWSURFACE_LCL mPrimaryLocal; + DDRAWI_DDRAWSURFACE_LCL *mpPrimaryLocals[1]; + DDRAWI_DDRAWCLIPPER_LCL mPrimaryClipperLocal; + DDRAWI_DDRAWCLIPPER_GBL mPrimaryClipperGlobal; + + DDSURFACEDESC mddsdPrimary; DDRAWI_DDRAWSURFACE_LCL *mpInUseSurfaceLocals[1]; diff --git a/reactos/dll/directx/ddraw/soft/ddraw_hel.c b/reactos/dll/directx/ddraw/soft/ddraw_hel.c index 2332dc73a3e..721534b78e9 100644 --- a/reactos/dll/directx/ddraw/soft/ddraw_hel.c +++ b/reactos/dll/directx/ddraw/soft/ddraw_hel.c @@ -21,12 +21,67 @@ HRESULT Hel_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscap return DD_OK; } + +HRESULT Hel_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags,HANDLE h) +{ + DX_STUB; +} + HRESULT Hel_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine) { DX_STUB; } -HRESULT Hel_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface) + + +HRESULT Hel_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight, + DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) { - DX_STUB; + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + + // this only for exclusive mode + if(!(This->cooperative_level & DDSCL_EXCLUSIVE)) + return DDERR_NOEXCLUSIVEMODE; + + // change the resolution using normal WinAPI function + DEVMODE mode; + mode.dmSize = sizeof(mode); + mode.dmPelsWidth = dwWidth; + mode.dmPelsHeight = dwHeight; + mode.dmBitsPerPel = dwBPP; + + //mode.dmDisplayFrequency = dwRefreshRate; + mode.dmFields = 0; + + DX_STUB_str("in hel"); + + if(dwWidth) + mode.dmFields |= DM_PELSWIDTH; + if(dwHeight) + mode.dmFields |= DM_PELSHEIGHT; + if(dwBPP) + mode.dmFields |= DM_BITSPERPEL; + /* + if(dwRefreshRate) + mode.dmFields |= DM_DISPLAYFREQUENCY; + */ + if (ChangeDisplaySettings(&mode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) + return DDERR_UNSUPPORTEDMODE; + + + // TODO: reactivate ddraw object, maximize window, set it in foreground + // and set excluive mode (if implemented by the driver) + + /* FIXME fill the DirectDrawGlobal right the modeindex old and new */ + + //if(dwWidth) + // This->Height = dwWidth; + //if(dwHeight) + // This->Width = dwHeight; + //if(dwBPP) + // This->Bpp = dwBPP; + + return DD_OK; } + + diff --git a/reactos/dll/directx/ddraw/soft/surface_callbacks_hel.c b/reactos/dll/directx/ddraw/soft/surface_callbacks_hel.c index 1f8abd3fc22..ac87f3fcae0 100644 --- a/reactos/dll/directx/ddraw/soft/surface_callbacks_hel.c +++ b/reactos/dll/directx/ddraw/soft/surface_callbacks_hel.c @@ -28,187 +28,16 @@ DWORD CALLBACK HelDdCreateSurface(LPDDHAL_CREATESURFACEDATA lpCreateSurface) DX_STUB; } - +/* DWORD CALLBACK HelDdSetColorKey(LPDDHAL_SETCOLORKEYDATA lpSetColorKey) { DX_STUB; } - +*/ DWORD CALLBACK HelDdSetMode(LPDDHAL_SETMODEDATA SetMode) -{ - // change the resolution using normal WinAPI function - DEVMODE mode; - mode.dmSize = sizeof(DEVMODE); - mode.dmPelsWidth = 0; - mode.dmPelsHeight = 0; - mode.dmBitsPerPel = 0; - - /* FIXME use emuate display to get the res */ - - /* 320x200 15, 16, 32 */ - if (SetMode->dwModeIndex == 0x10d) - { - mode.dmPelsWidth = 320; - mode.dmPelsHeight = 200; - mode.dmBitsPerPel = 15; - } - - if (SetMode->dwModeIndex == 0x10e) - { - mode.dmPelsWidth = 320; - mode.dmPelsHeight = 200; - mode.dmBitsPerPel = 16; - } - - if (SetMode->dwModeIndex == 0x10f) - { - mode.dmPelsWidth = 320; - mode.dmPelsHeight = 200; - mode.dmBitsPerPel = 32; - } - - /* 640x400 8 */ - if (SetMode->dwModeIndex == 0x100) - { - mode.dmPelsWidth = 640; - mode.dmPelsHeight = 400; - mode.dmBitsPerPel = 8; - } - - /* 640x480 8, 15, 16 , 32*/ - if (SetMode->dwModeIndex == 0x101) - { - mode.dmPelsWidth = 640; - mode.dmPelsHeight = 480; - mode.dmBitsPerPel = 8; - } - - if (SetMode->dwModeIndex == 0x110) - { - mode.dmPelsWidth = 640; - mode.dmPelsHeight = 480; - mode.dmBitsPerPel = 15; - } - - if (SetMode->dwModeIndex == 0x111) - { - mode.dmPelsWidth = 640; - mode.dmPelsHeight = 480; - mode.dmBitsPerPel = 16; - } - - if (SetMode->dwModeIndex == 0x112) - { - mode.dmPelsWidth = 640; - mode.dmPelsHeight = 480; - mode.dmBitsPerPel = 32; - } - - /* 800x600 4, 8, 15, 16 , 32*/ - if (SetMode->dwModeIndex == 0x102) - { - mode.dmPelsWidth = 800; - mode.dmPelsHeight = 600; - mode.dmBitsPerPel = 4; - } - - if (SetMode->dwModeIndex == 0x103) - { - mode.dmPelsWidth = 800; - mode.dmPelsHeight = 600; - mode.dmBitsPerPel = 8; - } - - if (SetMode->dwModeIndex == 0x113) - { - mode.dmPelsWidth = 800; - mode.dmPelsHeight = 600; - mode.dmBitsPerPel = 15; - } - - - if (SetMode->dwModeIndex == 0x114) - { - mode.dmPelsWidth = 800; - mode.dmPelsHeight = 600; - mode.dmBitsPerPel = 16; - } - - if (SetMode->dwModeIndex == 0x115) - { - mode.dmPelsWidth = 800; - mode.dmPelsHeight = 600; - mode.dmBitsPerPel = 32; - } - - /* 1024x768 8, 15, 16 , 32*/ - - if (SetMode->dwModeIndex == 0x104) - { - mode.dmPelsWidth = 1024; - mode.dmPelsHeight = 768; - mode.dmBitsPerPel = 4; - } - - if (SetMode->dwModeIndex == 0x105) - { - mode.dmPelsWidth = 1024; - mode.dmPelsHeight = 768; - mode.dmBitsPerPel = 8; - } - - if (SetMode->dwModeIndex == 0x116) - { - mode.dmPelsWidth = 1024; - mode.dmPelsHeight = 768; - mode.dmBitsPerPel = 15; - } - - if (SetMode->dwModeIndex == 0x117) - { - mode.dmPelsWidth = 1024; - mode.dmPelsHeight = 768; - mode.dmBitsPerPel = 16; - } - - if (SetMode->dwModeIndex == 0x118) - { - mode.dmPelsWidth = 1024; - mode.dmPelsHeight = 768; - mode.dmBitsPerPel = 32; - } - - //mode.dmDisplayFrequency = dwRefreshRate; - mode.dmFields = 0; - - DX_STUB_str("in hel"); - - if(mode.dmPelsWidth != 0) - mode.dmFields |= DM_PELSWIDTH; - if(mode.dmPelsHeight != 0) - mode.dmFields |= DM_PELSHEIGHT; - if( mode.dmBitsPerPel != 0) - mode.dmFields |= DM_BITSPERPEL; - /* - if(dwRefreshRate) - mode.dmFields |= DM_DISPLAYFREQUENCY; - */ - - DX_WINDBG_trace_res((int)mode.dmPelsWidth, (int)mode.dmPelsHeight, (int)mode.dmBitsPerPel ); - - if (ChangeDisplaySettings(&mode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) - { - DX_STUB_str("FAIL"); - SetMode->ddRVal = DDERR_UNSUPPORTEDMODE; - } - else - { - DX_STUB_str("OK"); - SetMode->ddRVal = DD_OK; - } - - return DDHAL_DRIVER_HANDLED; +{ + DX_STUB; } DWORD CALLBACK HelDdWaitForVerticalBlank(LPDDHAL_WAITFORVERTICALBLANKDATA lpWaitForVerticalBlank) diff --git a/reactos/dll/directx/ddraw/startup.c b/reactos/dll/directx/ddraw/startup.c index efc85d50f59..f95b4bf0826 100644 --- a/reactos/dll/directx/ddraw/startup.c +++ b/reactos/dll/directx/ddraw/startup.c @@ -291,7 +291,7 @@ StartDirectDrawHal(LPDIRECTDRAW* iface) } This->mcTextures = This->mD3dDriverData.dwNumTextureFormats; - This->mpTextures = (DDSURFACEDESC2*) DxHeapMemAlloc(sizeof(DDSURFACEDESC2) * This->mcTextures); + This->mpTextures = (DDSURFACEDESC*) DxHeapMemAlloc(sizeof(DDSURFACEDESC) * This->mcTextures); if (This->mpTextures == NULL) { DxHeapMemFree( This->mpFourCC); @@ -364,6 +364,16 @@ StartDirectDrawHal(LPDIRECTDRAW* iface) DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS); This->mHALInfo.GetDriverInfo(&DriverInfo); + /* Setup global surface */ + /*This->mPrimaryGlobal.dwGlobalFlags = DDRAWISURFGBL_ISGDISURFACE; + This->mPrimaryGlobal.lpDD = &This->mDDrawGlobal; + This->mPrimaryGlobal.lpDDHandle = &This->mDDrawGlobal; + This->mPrimaryGlobal.wWidth = (WORD)This->mpModeInfos[0].dwWidth; + This->mPrimaryGlobal.wHeight = (WORD)This->mpModeInfos[0].dwHeight; + This->mPrimaryGlobal.lPitch = This->mpModeInfos[0].lPitch;*/ + + /* FIXME free it in cleanup */ + This->mDDrawGlobal.dsList = (LPDDRAWI_DDRAWSURFACE_INT)DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_INT)); return DD_OK; }