ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

startup.c
Go to the documentation of this file.
00001 /* $Id: main.c 21434 2006-04-01 19:12:56Z greatlrd $
00002  *
00003  * COPYRIGHT:            See COPYING in the top level directory
00004  * PROJECT:              ReactOS kernel
00005  * FILE:                 lib/ddraw/ddraw.c
00006  * PURPOSE:              DirectDraw Library
00007  * PROGRAMMER:           Magnus Olsen (greatlrd)
00008  *
00009  */
00010 
00011 #include "rosdraw.h"
00012 
00013 DDRAWI_DIRECTDRAW_GBL ddgbl;
00014 DDRAWI_DDRAWSURFACE_GBL ddSurfGbl;
00015 
00016 WCHAR classname[128];
00017 WNDCLASSW wnd_class;
00018 
00019 
00020 HRESULT WINAPI
00021 Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
00022                    REFIID id, BOOL reenable)
00023 {
00024     LPDDRAWI_DIRECTDRAW_INT This;
00025 
00026     DX_WINDBG_trace();
00027     BOOL linking = FALSE;
00028 
00029     if (pIface == NULL)
00030     {
00031         return DDERR_INVALIDPARAMS;
00032     }
00033 
00034     This = (LPDDRAWI_DIRECTDRAW_INT)*pIface;
00035 
00036     DX_STUB_str("Linking?\n")
00037 
00038     _SEH2_TRY
00039     {
00040         linking = This->lpLcl ? TRUE:FALSE;
00041     }
00042     _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
00043     {
00044         linking = FALSE;
00045     }
00046     _SEH2_END;
00047 
00048     /* fixme linking too second link when we shall not doing it */
00049     if (!linking)
00050     {
00051         /* We do not have a DirectDraw interface, we need alloc it*/
00052         LPDDRAWI_DIRECTDRAW_INT memThis;
00053 
00054         DX_STUB_str("1. no linking\n");
00055 
00056         DxHeapMemAlloc(memThis, sizeof(DDRAWI_DIRECTDRAW_INT));
00057         if (memThis == NULL)
00058         {
00059             return DDERR_OUTOFMEMORY;
00060         }
00061 
00062         This = memThis;
00063 
00064         /* Fixme release memory alloc if we fail */
00065 
00066         DxHeapMemAlloc(This->lpLcl, sizeof(DDRAWI_DIRECTDRAW_LCL));
00067         if (This->lpLcl == NULL)
00068         {
00069             return DDERR_OUTOFMEMORY;
00070         }
00071     }
00072     else
00073     {
00074         /* We got the DirectDraw interface alloc and we need create the link */
00075         LPDDRAWI_DIRECTDRAW_INT  newThis;
00076 
00077         DX_STUB_str("2.linking\n");
00078 
00079         /* step 1.Alloc the new  DDRAWI_DIRECTDRAW_INT for the lnking */
00080         DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
00081         if (newThis == NULL)
00082         {
00083             return DDERR_OUTOFMEMORY;
00084         }
00085 
00086         /* step 2 check if it not DDCREATE_HARDWAREONLY we got if so we fail */
00087         if ((pGUID) && (pGUID != (LPGUID)DDCREATE_HARDWAREONLY))
00088         {
00089             if (pGUID !=NULL)
00090             {
00091                 This = newThis;
00092                 return DDERR_INVALIDDIRECTDRAWGUID;
00093             }
00094         }
00095 
00096         /* step 3 do the link the old interface are store in the new one */
00097         newThis->lpLink = This;
00098 
00099         /* step 4 we need create new local directdraw struct for the new linked interface */
00100         DxHeapMemAlloc(newThis->lpLcl, sizeof(DDRAWI_DIRECTDRAW_LCL));
00101         if (newThis->lpLcl == NULL)
00102         {
00103             This = newThis;
00104             return DDERR_OUTOFMEMORY;
00105         }
00106 
00107         This = newThis;
00108     }
00109 
00110     This->lpLcl->lpGbl = &ddgbl;
00111 
00112     *pIface = (LPDIRECTDRAW)This;
00113 
00114     /* Get right interface we whant */
00115 
00116     This->lpVtbl = 0;
00117     if (IsEqualGUID(&IID_IDirectDraw7, id))
00118     {
00119         /* DirectDraw7 Vtable */
00120         This->lpVtbl = &DirectDraw7_Vtable;
00121         This->lpLcl->dwLocalFlags = This->lpLcl->dwLocalFlags + DDRAWILCL_DIRECTDRAW7;
00122         *pIface = (LPDIRECTDRAW)&This->lpVtbl;
00123         Main_DirectDraw_AddRef(This);
00124     }
00125     else if (IsEqualGUID(&IID_IDirectDraw4, id))
00126     {
00127         /* DirectDraw4 Vtable */
00128         This->lpVtbl = &DirectDraw4_Vtable;
00129         *pIface = (LPDIRECTDRAW)&This->lpVtbl;
00130         Main_DirectDraw_AddRef(This);
00131     }
00132     else if (IsEqualGUID(&IID_IDirectDraw2, id))
00133     {
00134         /* DirectDraw2 Vtable */
00135         This->lpVtbl = &DirectDraw2_Vtable;
00136         *pIface = (LPDIRECTDRAW)&This->lpVtbl;
00137         Main_DirectDraw_AddRef(This);
00138     }
00139     else if (IsEqualGUID(&IID_IDirectDraw, id))
00140     {
00141         /* DirectDraw Vtable */
00142         This->lpVtbl = &DirectDraw_Vtable;
00143         *pIface = (LPDIRECTDRAW)&This->lpVtbl;
00144         Main_DirectDraw_AddRef(This);
00145     }
00146 
00147     if ( This->lpVtbl != 0)
00148     {
00149         DX_STUB_str("Got iface\n");
00150 
00151         if (StartDirectDraw((LPDIRECTDRAW)This, pGUID, FALSE) == DD_OK)
00152         {
00153             /*
00154             RtlZeroMemory(&wnd_class, sizeof(wnd_class));
00155             wnd_class.style = CS_HREDRAW | CS_VREDRAW;
00156             wnd_class.lpfnWndProc = DefWindowProcW;
00157             wnd_class.cbClsExtra = 0;
00158             wnd_class.cbWndExtra = 0;
00159             wnd_class.hInstance = GetModuleHandleW(0);
00160             wnd_class.hIcon = 0;
00161             wnd_class.hCursor = 0;
00162             wnd_class.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
00163             wnd_class.lpszMenuName = NULL;
00164             wnd_class.lpszClassName = classname;
00165             if(!RegisterClassW(&wnd_class))
00166             {
00167                 DX_STUB_str("DDERR_GENERIC");
00168                 return DDERR_GENERIC;
00169             }
00170             */
00171             This->lpLcl->hDD = ddgbl.hDD;
00172             return DD_OK;
00173         }
00174     }
00175 
00176     return DDERR_INVALIDPARAMS;
00177 }
00178 
00179 
00180 HRESULT WINAPI
00181 StartDirectDraw(LPDIRECTDRAW iface, LPGUID lpGuid, BOOL reenable)
00182 {
00183     LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
00184     DWORD hal_ret = DD_FALSE;
00185     DWORD hel_ret = DD_FALSE;
00186     DWORD devicetypes = 0;
00187     DWORD dwFlags = 0;
00188 
00189 
00190     DX_WINDBG_trace();
00191 
00192 
00193     /*
00194      * ddgbl.dwPDevice  is not longer in use in windows 2000 and higher
00195      * I am using it for device type
00196      * devicetypes = 1 : both hal and hel are enable
00197      * devicetypes = 2 : both hal are enable
00198      * devicetypes = 3 : both hel are enable
00199      * devicetypes = 4 :loading a guid drv from the register
00200      */
00201 
00202     ddgbl.lpDriverHandle = &ddgbl;
00203     ddgbl.hDDVxd = -1;
00204 
00205     if (reenable == FALSE)
00206     {
00207         if ((!IsBadReadPtr(This->lpLink,sizeof(LPDIRECTDRAW))) && (This->lpLink == NULL))
00208         {
00209             RtlZeroMemory(&ddgbl, sizeof(DDRAWI_DIRECTDRAW_GBL));
00210             This->lpLcl->lpGbl->dwRefCnt++;
00211             if (ddgbl.lpDDCBtmp == NULL)
00212             {
00213                 // LPDDHAL_CALLBACKS
00214                 DxHeapMemAlloc( ddgbl.lpDDCBtmp , sizeof(DDHAL_CALLBACKS));
00215                 if (ddgbl.lpDDCBtmp == NULL)
00216                 {
00217                     DX_STUB_str("Out of memmory\n");
00218                     return DD_FALSE;
00219                 }
00220             }
00221         }
00222 
00223         DxHeapMemAlloc(ddgbl.lpModeInfo, sizeof(DDHALMODEINFO));
00224         if (!ddgbl.lpModeInfo)
00225         {
00226             return DDERR_OUTOFMEMORY;
00227         }
00228 
00229     }
00230     /* Windows handler are by set of SetCooperLevel
00231      * so do not set it
00232      */
00233 
00234     if (reenable == FALSE)
00235     {
00236         if (lpGuid == NULL)
00237         {
00238             devicetypes= 1;
00239 
00240             /* Create HDC for default, hal and hel driver */
00241             // This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
00242             This->lpLcl->hDC = (ULONG_PTR)CreateDCA("DISPLAY",NULL,NULL,NULL);
00243 
00244             /* cObsolete is undoc in msdn it being use in CreateDCA */
00245             RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
00246             RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
00247             dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
00248         }
00249         else if (lpGuid == (LPGUID) DDCREATE_HARDWAREONLY)
00250         {
00251             devicetypes = 2;
00252             /* Create HDC for default, hal driver */
00253             // This->lpLcl->hWnd =(ULONG_PTR) GetActiveWindow();
00254             This->lpLcl->hDC = (ULONG_PTR)CreateDCA("DISPLAY",NULL,NULL,NULL);
00255 
00256             /* cObsolete is undoc in msdn it being use in CreateDCA */
00257             RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
00258             RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
00259             dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
00260         }
00261         else if (lpGuid == (LPGUID) DDCREATE_EMULATIONONLY)
00262         {
00263             devicetypes = 3;
00264 
00265             /* Create HDC for default, hal and hel driver */
00266             //This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
00267             This->lpLcl->hDC = (ULONG_PTR)CreateDCA("DISPLAY",NULL,NULL,NULL);
00268 
00269             /* cObsolete is undoc in msdn it being use in CreateDCA */
00270             RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
00271             RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
00272 
00273             dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
00274         }
00275         else
00276         {
00277             /* FIXME : need getting driver from the GUID that have been pass in from
00278              * the register. we do not support that yet
00279              */
00280              devicetypes = 4;
00281              //This->lpLcl->hDC = (ULONG_PTR) NULL ;
00282              //This->lpLcl->hDC = (ULONG_PTR)CreateDCA("DISPLAY",NULL,NULL,NULL);
00283         }
00284 
00285         /*
00286         if ( (HDC)This->lpLcl->hDC == NULL)
00287         {
00288             DX_STUB_str("DDERR_OUTOFMEMORY\n");
00289             return DDERR_OUTOFMEMORY ;
00290         }
00291         */
00292     }
00293 
00294     This->lpLcl->lpDDCB = ddgbl.lpDDCBtmp;
00295 
00296     /* Startup HEL and HAL */
00297     This->lpLcl->lpDDCB = This->lpLcl->lpGbl->lpDDCBtmp;
00298     This->lpLcl->dwProcessId = GetCurrentProcessId();
00299     switch (devicetypes)
00300     {
00301             case 2:
00302               hal_ret = StartDirectDrawHal(iface, reenable);
00303               This->lpLcl->lpDDCB->HELDD.dwFlags = 0;
00304               break;
00305 
00306             case 3:
00307               hel_ret = StartDirectDrawHel(iface, reenable);
00308               This->lpLcl->lpDDCB->HALDD.dwFlags = 0;
00309               break;
00310 
00311             default:
00312               hal_ret = StartDirectDrawHal(iface, reenable);
00313               hel_ret = StartDirectDrawHel(iface, reenable);
00314               break;
00315     }
00316 
00317     if (hal_ret!=DD_OK)
00318     {
00319         if (hel_ret!=DD_OK)
00320         {
00321             DX_STUB_str("DDERR_NODIRECTDRAWSUPPORT\n");
00322             return DDERR_NODIRECTDRAWSUPPORT;
00323         }
00324         dwFlags |= DDRAWI_NOHARDWARE;
00325         DX_STUB_str("No hardware support\n");
00326     }
00327 
00328     if (hel_ret!=DD_OK)
00329     {
00330         dwFlags |= DDRAWI_NOEMULATION;
00331 
00332     }
00333     else
00334     {
00335         dwFlags |= DDRAWI_EMULATIONINITIALIZED;
00336     }
00337 
00338     /* Fill some basic info for Surface */
00339     This->lpLcl->lpGbl->dwFlags =  This->lpLcl->lpGbl->dwFlags | dwFlags | DDRAWI_ATTACHEDTODESKTOP;
00340     This->lpLcl->lpDDCB = This->lpLcl->lpGbl->lpDDCBtmp;
00341     This->lpLcl->hDD = ddgbl.hDD;
00342 
00343     ddgbl.rectDevice.top = 0;
00344     ddgbl.rectDevice.left = 0;
00345     ddgbl.rectDevice.right = ddgbl.vmiData.dwDisplayWidth;
00346     ddgbl.rectDevice.bottom = ddgbl.vmiData.dwDisplayHeight;
00347 
00348     ddgbl.rectDesktop.top = 0;
00349     ddgbl.rectDesktop.left = 0;
00350     ddgbl.rectDesktop.right = ddgbl.vmiData.dwDisplayWidth;
00351     ddgbl.rectDesktop.bottom = ddgbl.vmiData.dwDisplayHeight;
00352 
00353     ddgbl.dwMonitorFrequency = GetDeviceCaps(GetWindowDC(NULL),VREFRESH);
00354     ddgbl.lpModeInfo->dwWidth      = ddgbl.vmiData.dwDisplayWidth;
00355     ddgbl.lpModeInfo->dwHeight     = ddgbl.vmiData.dwDisplayHeight;
00356     ddgbl.lpModeInfo->dwBPP        = ddgbl.vmiData.ddpfDisplay.dwRGBBitCount;
00357     ddgbl.lpModeInfo->lPitch       = ddgbl.vmiData.lDisplayPitch;
00358     ddgbl.lpModeInfo->wRefreshRate = ddgbl.dwMonitorFrequency;
00359     ddgbl.lpModeInfo->dwRBitMask = ddgbl.vmiData.ddpfDisplay.dwRBitMask;
00360     ddgbl.lpModeInfo->dwGBitMask = ddgbl.vmiData.ddpfDisplay.dwGBitMask;
00361     ddgbl.lpModeInfo->dwBBitMask = ddgbl.vmiData.ddpfDisplay.dwBBitMask;
00362     ddgbl.lpModeInfo->dwAlphaBitMask = ddgbl.vmiData.ddpfDisplay.dwRGBAlphaBitMask;
00363 
00364     return DD_OK;
00365 }
00366 
00367 
00368 HRESULT WINAPI
00369 StartDirectDrawHel(LPDIRECTDRAW iface, BOOL reenable)
00370 {
00371     LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
00372 
00373     if (reenable == FALSE)
00374     {
00375         if (ddgbl.lpDDCBtmp == NULL)
00376         {
00377             DxHeapMemAlloc(ddgbl.lpDDCBtmp, sizeof(DDHAL_CALLBACKS));
00378             if ( ddgbl.lpDDCBtmp == NULL)
00379             {
00380                 return DD_FALSE;
00381             }
00382         }
00383     }
00384 
00385     ddgbl.lpDDCBtmp->HELDD.CanCreateSurface     = HelDdCanCreateSurface;
00386     ddgbl.lpDDCBtmp->HELDD.CreateSurface        = HelDdCreateSurface;
00387     ddgbl.lpDDCBtmp->HELDD.CreatePalette        = HelDdCreatePalette;
00388     ddgbl.lpDDCBtmp->HELDD.DestroyDriver        = HelDdDestroyDriver;
00389     ddgbl.lpDDCBtmp->HELDD.FlipToGDISurface     = HelDdFlipToGDISurface;
00390     ddgbl.lpDDCBtmp->HELDD.GetScanLine          = HelDdGetScanLine;
00391     ddgbl.lpDDCBtmp->HELDD.SetColorKey          = HelDdSetColorKey;
00392     ddgbl.lpDDCBtmp->HELDD.SetExclusiveMode     = HelDdSetExclusiveMode;
00393     ddgbl.lpDDCBtmp->HELDD.SetMode              = HelDdSetMode;
00394     ddgbl.lpDDCBtmp->HELDD.WaitForVerticalBlank = HelDdWaitForVerticalBlank;
00395 
00396     ddgbl.lpDDCBtmp->HELDD.dwFlags =  DDHAL_CB32_CANCREATESURFACE     |
00397                                           DDHAL_CB32_CREATESURFACE        |
00398                                           DDHAL_CB32_CREATEPALETTE        |
00399                                           DDHAL_CB32_DESTROYDRIVER        |
00400                                           DDHAL_CB32_FLIPTOGDISURFACE     |
00401                                           DDHAL_CB32_GETSCANLINE          |
00402                                           DDHAL_CB32_SETCOLORKEY          |
00403                                           DDHAL_CB32_SETEXCLUSIVEMODE     |
00404                                           DDHAL_CB32_SETMODE              |
00405                                           DDHAL_CB32_WAITFORVERTICALBLANK ;
00406 
00407     ddgbl.lpDDCBtmp->HELDD.dwSize = sizeof(This->lpLcl->lpDDCB->HELDD);
00408 
00409     ddgbl.lpDDCBtmp->HELDDSurface.AddAttachedSurface = HelDdSurfAddAttachedSurface;
00410     ddgbl.lpDDCBtmp->HELDDSurface.Blt = HelDdSurfBlt;
00411     ddgbl.lpDDCBtmp->HELDDSurface.DestroySurface = HelDdSurfDestroySurface;
00412     ddgbl.lpDDCBtmp->HELDDSurface.Flip = HelDdSurfFlip;
00413     ddgbl.lpDDCBtmp->HELDDSurface.GetBltStatus = HelDdSurfGetBltStatus;
00414     ddgbl.lpDDCBtmp->HELDDSurface.GetFlipStatus = HelDdSurfGetFlipStatus;
00415     ddgbl.lpDDCBtmp->HELDDSurface.Lock = HelDdSurfLock;
00416     ddgbl.lpDDCBtmp->HELDDSurface.reserved4 = HelDdSurfreserved4;
00417     ddgbl.lpDDCBtmp->HELDDSurface.SetClipList = HelDdSurfSetClipList;
00418     ddgbl.lpDDCBtmp->HELDDSurface.SetColorKey = HelDdSurfSetColorKey;
00419     ddgbl.lpDDCBtmp->HELDDSurface.SetOverlayPosition = HelDdSurfSetOverlayPosition;
00420     ddgbl.lpDDCBtmp->HELDDSurface.SetPalette = HelDdSurfSetPalette;
00421     ddgbl.lpDDCBtmp->HELDDSurface.Unlock = HelDdSurfUnlock;
00422     ddgbl.lpDDCBtmp->HELDDSurface.UpdateOverlay = HelDdSurfUpdateOverlay;
00423     ddgbl.lpDDCBtmp->HELDDSurface.dwFlags = DDHAL_SURFCB32_ADDATTACHEDSURFACE |
00424                                                 DDHAL_SURFCB32_BLT                |
00425                                                 DDHAL_SURFCB32_DESTROYSURFACE     |
00426                                                 DDHAL_SURFCB32_FLIP               |
00427                                                 DDHAL_SURFCB32_GETBLTSTATUS       |
00428                                                 DDHAL_SURFCB32_GETFLIPSTATUS      |
00429                                                 DDHAL_SURFCB32_LOCK               |
00430                                                 DDHAL_SURFCB32_RESERVED4          |
00431                                                 DDHAL_SURFCB32_SETCLIPLIST        |
00432                                                 DDHAL_SURFCB32_SETCOLORKEY        |
00433                                                 DDHAL_SURFCB32_SETOVERLAYPOSITION |
00434                                                 DDHAL_SURFCB32_SETPALETTE         |
00435                                                 DDHAL_SURFCB32_UNLOCK             |
00436                                                 DDHAL_SURFCB32_UPDATEOVERLAY;
00437 
00438     ddgbl.lpDDCBtmp->HELDDSurface.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDSurface);
00439 
00440     /*
00441     This->lpLcl->lpDDCB->HELDDPalette.DestroyPalette  = HelDdPalDestroyPalette;
00442     This->lpLcl->lpDDCB->HELDDPalette.SetEntries = HelDdPalSetEntries;
00443     This->lpLcl->lpDDCB->HELDDPalette.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDPalette);
00444     */
00445 
00446     /*
00447     This->lpLcl->lpDDCB->HELDDExeBuf.CanCreateExecuteBuffer = HelDdExeCanCreateExecuteBuffer;
00448     This->lpLcl->lpDDCB->HELDDExeBuf.CreateExecuteBuffer = HelDdExeCreateExecuteBuffer;
00449     This->lpLcl->lpDDCB->HELDDExeBuf.DestroyExecuteBuffer = HelDdExeDestroyExecuteBuffer;
00450     This->lpLcl->lpDDCB->HELDDExeBuf.LockExecuteBuffer = HelDdExeLockExecuteBuffer;
00451     This->lpLcl->lpDDCB->HELDDExeBuf.UnlockExecuteBuffer = HelDdExeUnlockExecuteBuffer;
00452     */
00453 
00454     return DD_OK;
00455 }
00456 
00457 
00458 HRESULT WINAPI
00459 StartDirectDrawHal(LPDIRECTDRAW iface, BOOL reenable)
00460 {
00461     LPDWORD mpFourCC = NULL;
00462     DDHALINFO mHALInfo;
00463     BOOL newmode = FALSE;
00464     LPDDSURFACEDESC mpTextures;
00465     D3DHAL_CALLBACKS mD3dCallbacks;
00466     D3DHAL_GLOBALDRIVERDATA mD3dDriverData;
00467     DDHAL_DDEXEBUFCALLBACKS mD3dBufferCallbacks;
00468     LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
00469     DDHAL_GETDRIVERINFODATA DdGetDriverInfo = { 0 };
00470 
00471     DX_WINDBG_trace();
00472 
00473     RtlZeroMemory(&mHALInfo, sizeof(DDHALINFO));
00474     RtlZeroMemory(&mD3dCallbacks, sizeof(D3DHAL_CALLBACKS));
00475     RtlZeroMemory(&mD3dDriverData, sizeof(D3DHAL_GLOBALDRIVERDATA));
00476     RtlZeroMemory(&mD3dBufferCallbacks, sizeof(DDHAL_DDEXEBUFCALLBACKS));
00477 
00478     if (reenable == FALSE)
00479     {
00480         if (ddgbl.lpDDCBtmp == NULL)
00481         {
00482             DxHeapMemAlloc(ddgbl.lpDDCBtmp, sizeof(DDHAL_CALLBACKS));
00483             if ( ddgbl.lpDDCBtmp == NULL)
00484             {
00485                 return DD_FALSE;
00486             }
00487         }
00488     }
00489     else
00490     {
00491         RtlZeroMemory(ddgbl.lpDDCBtmp,sizeof(DDHAL_CALLBACKS));
00492     }
00493 
00494     /*
00495      *  Startup DX HAL step one of three
00496      */
00497     if (!DdCreateDirectDrawObject(This->lpLcl->lpGbl, (HDC)This->lpLcl->hDC))
00498     {
00499        DxHeapMemFree(ddgbl.lpDDCBtmp);
00500        return DD_FALSE;
00501     }
00502 
00503     /* Some card disable the dx after it have been created so
00504      * we are force reanble it
00505      */
00506     if (!DdReenableDirectDrawObject(This->lpLcl->lpGbl, &newmode))
00507     {
00508       DxHeapMemFree(ddgbl.lpDDCBtmp);
00509       return DD_FALSE;
00510     }
00511 
00512     if (!DdQueryDirectDrawObject(This->lpLcl->lpGbl,
00513                                  &mHALInfo,
00514                                  &ddgbl.lpDDCBtmp->HALDD,
00515                                  &ddgbl.lpDDCBtmp->HALDDSurface,
00516                                  &ddgbl.lpDDCBtmp->HALDDPalette,
00517                                  &mD3dCallbacks,
00518                                  &mD3dDriverData,
00519                                  &mD3dBufferCallbacks,
00520                                  NULL,
00521                                  mpFourCC,
00522                                  NULL))
00523     {
00524       DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo);
00525       DxHeapMemFree(ddgbl.lpDDCBtmp);
00526       // FIXME Close DX first and second call
00527       return DD_FALSE;
00528     }
00529 
00530     /* Alloc mpFourCC */
00531     if (This->lpLcl->lpGbl->lpdwFourCC != NULL)
00532     {
00533         DxHeapMemFree(This->lpLcl->lpGbl->lpdwFourCC);
00534     }
00535 
00536     if (mHALInfo.ddCaps.dwNumFourCCCodes > 0 )
00537     {
00538 
00539         DxHeapMemAlloc(mpFourCC, sizeof(DWORD) * (mHALInfo.ddCaps.dwNumFourCCCodes + 2));
00540 
00541         if (mpFourCC == NULL)
00542         {
00543             DxHeapMemFree(ddgbl.lpDDCBtmp);
00544             // FIXME Close DX first and second call
00545             return DD_FALSE;
00546         }
00547     }
00548 
00549     /* Alloc mpTextures */
00550 #if 0
00551     DX_STUB_str("1 Here\n");
00552 
00553     if (This->lpLcl->lpGbl->texture != NULL)
00554     {
00555         DxHeapMemFree(This->lpLcl->lpGbl->texture;
00556     }
00557 
00558     mpTextures = NULL;
00559     if (mD3dDriverData.dwNumTextureFormats > 0)
00560     {
00561         mpTextures = (DDSURFACEDESC*) DxHeapMemAlloc(sizeof(DDSURFACEDESC) * mD3dDriverData.dwNumTextureFormats);
00562         if (mpTextures == NULL)
00563         {
00564             DxHeapMemFree(mpFourCC);
00565             DxHeapMemFree(ddgbl.lpDDCBtmp);
00566             // FIXME Close DX first and second call
00567         }
00568     }
00569 
00570     DX_STUB_str("2 Here\n");
00571 
00572 #else
00573       mpTextures = NULL;
00574 #endif
00575 
00576 
00577     /* Get all basic data from the driver */
00578     if (!DdQueryDirectDrawObject(
00579                                  This->lpLcl->lpGbl,
00580                                  &mHALInfo,
00581                                  &ddgbl.lpDDCBtmp->HALDD,
00582                                  &ddgbl.lpDDCBtmp->HALDDSurface,
00583                                  &ddgbl.lpDDCBtmp->HALDDPalette,
00584                                  &mD3dCallbacks,
00585                                  &mD3dDriverData,
00586                                  &ddgbl.lpDDCBtmp->HALDDExeBuf,
00587                                  (DDSURFACEDESC*)mpTextures,
00588                                  mpFourCC,
00589                                  NULL))
00590     {
00591         DxHeapMemFree(mpFourCC);
00592         DxHeapMemFree(mpTextures);
00593         DxHeapMemFree(ddgbl.lpDDCBtmp);
00594         // FIXME Close DX first and second call
00595         return DD_FALSE;
00596     }
00597 
00598     memcpy(&ddgbl.vmiData, &mHALInfo.vmiData,sizeof(VIDMEMINFO));
00599 
00600 
00601     memcpy(&ddgbl.ddCaps,  &mHALInfo.ddCaps,sizeof(DDCORECAPS));
00602 
00603     This->lpLcl->lpGbl->dwNumFourCC        = mHALInfo.ddCaps.dwNumFourCCCodes;
00604     This->lpLcl->lpGbl->lpdwFourCC         = mpFourCC;
00605     // This->lpLcl->lpGbl->dwMonitorFrequency = mHALInfo.dwMonitorFrequency;     // 0
00606     This->lpLcl->lpGbl->dwModeIndex        = mHALInfo.dwModeIndex;
00607     // This->lpLcl->lpGbl->dwNumModes         = mHALInfo.dwNumModes;
00608     // This->lpLcl->lpGbl->lpModeInfo         = mHALInfo.lpModeInfo;
00609 
00610     /* FIXME convert mpTextures to DDHALMODEINFO */
00611     // DxHeapMemFree( mpTextures);
00612 
00613     /* FIXME D3D setup mD3dCallbacks and mD3dDriverData */
00614 
00615 
00616 
00617 
00618     if (mHALInfo.dwFlags & DDHALINFO_GETDRIVERINFOSET)
00619     {
00620         DdGetDriverInfo.dwSize = sizeof (DDHAL_GETDRIVERINFODATA);
00621         DdGetDriverInfo.guidInfo = GUID_MiscellaneousCallbacks;
00622         DdGetDriverInfo.lpvData = (PVOID)&ddgbl.lpDDCBtmp->HALDDMiscellaneous;
00623         DdGetDriverInfo.dwExpectedSize = sizeof (DDHAL_DDMISCELLANEOUSCALLBACKS);
00624 
00625         if(mHALInfo.GetDriverInfo (&DdGetDriverInfo) == DDHAL_DRIVER_NOTHANDLED || DdGetDriverInfo.ddRVal != DD_OK)
00626         {
00627             DxHeapMemFree(mpFourCC);
00628             DxHeapMemFree(mpTextures);
00629             DxHeapMemFree(ddgbl.lpDDCBtmp);
00630             // FIXME Close DX fristcall and second call
00631             return DD_FALSE;
00632         }
00633 
00634         RtlZeroMemory(&DdGetDriverInfo, sizeof(DDHAL_GETDRIVERINFODATA));
00635         DdGetDriverInfo.dwSize = sizeof (DDHAL_GETDRIVERINFODATA);
00636         DdGetDriverInfo.guidInfo = GUID_Miscellaneous2Callbacks;
00637 
00638         /* FIXME
00639         DdGetDriverInfo.lpvData = (PVOID)&ddgbl.lpDDCBtmp->HALDDMiscellaneous;
00640         DdGetDriverInfo.dwExpectedSize = sizeof (DDHAL_DDMISCELLANEOUS2CALLBACKS);
00641 
00642         if(mHALInfo.GetDriverInfo (&DdGetDriverInfo) == DDHAL_DRIVER_NOTHANDLED || DdGetDriverInfo.ddRVal != DD_OK)
00643         {
00644             DxHeapMemFree(mpFourCC);
00645             DxHeapMemFree(mpTextures);
00646             DxHeapMemFree(ddgbl.lpDDCBtmp);
00647             // FIXME Close DX fristcall and second call
00648             return DD_FALSE;
00649         }
00650         DD_MISCELLANEOUS2CALLBACKS
00651         {
00652             DWORD                dwSize;
00653             DWORD                dwFlags;
00654             PDD_ALPHABLT         AlphaBlt;  // unsuse acoding msdn and always set to NULL
00655             PDD_CREATESURFACEEX  CreateSurfaceEx;
00656             PDD_GETDRIVERSTATE   GetDriverState;
00657             PDD_DESTROYDDLOCAL   DestroyDDLocal;
00658         }
00659           DDHAL_MISC2CB32_CREATESURFACEEX
00660           DDHAL_MISC2CB32_GETDRIVERSTATE
00661           DDHAL_MISC2CB32_DESTROYDDLOCAL
00662         */
00663     }
00664 
00665     if (mHALInfo.dwFlags & DDHALINFO_GETDRIVERINFO2)
00666     {
00667         This->lpLcl->lpGbl->dwFlags = This->lpLcl->lpGbl->dwFlags | DDRAWI_DRIVERINFO2;
00668     }
00669 
00670 
00671     return DD_OK;
00672 }

Generated on Sat May 26 2012 04:17:29 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.