📄 ddraw_main.c
字号:
{
//LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
DX_WINDBG_trace();
if (iface==NULL)
{
return DDERR_NOTINITIALIZED;
}
return DDERR_ALREADYINITIALIZED;
}
/*
* IMPLEMENT
* Status ok
*/
HRESULT WINAPI
Main_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface)
{
DX_WINDBG_trace();
ChangeDisplaySettings(NULL, 0);
return DD_OK;
}
/*
* IMPLEMENT
* Status ok
*/
HRESULT WINAPI
Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD cooplevel)
{
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
DX_WINDBG_trace();
if (cooplevel & DDSCL_FULLSCREEN)
{
This->lpLcl->dwLocalFlags |= DDRAWILCL_ISFULLSCREEN;
}
if (cooplevel & DDSCL_EXCLUSIVE)
{
This->lpLcl->lpGbl->lpExclusiveOwner = This->lpLcl;
}
/* This code should be a callback */
This->lpLcl->hWnd = hwnd;
This->lpLcl->hFocusWnd = hwnd;
ReCreateDirectDraw((LPDIRECTDRAW*)iface);
// 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
//
// DDHAL_SETEXCLUSIVEMODEDATA SetExclusiveMode;
//DX_WINDBG_trace();
//
//
// // check the parameters
// if ((HWND)This->lpLcl->lpGbl->lpExclusiveOwner->hWnd == hwnd)
// return DD_OK;
//
//
// if ((cooplevel&DDSCL_EXCLUSIVE) && !(cooplevel&DDSCL_FULLSCREEN))
// return DDERR_INVALIDPARAMS;
// if (cooplevel&DDSCL_NORMAL && cooplevel&DDSCL_FULLSCREEN)
// return DDERR_INVALIDPARAMS;
// // set the data
// This->lpLcl->lpGbl->lpExclusiveOwner->hWnd = (ULONG_PTR) hwnd;
// This->lpLcl->lpGbl->lpExclusiveOwner->hDC = (ULONG_PTR)GetDC(hwnd);
//
///* FIXME : fill the mDDrawGlobal.lpExclusiveOwner->dwLocalFlags right */
////mDDrawGlobal.lpExclusiveOwner->dwLocalFlags
// SetExclusiveMode.ddRVal = DDERR_NOTPALETTIZED;
//if ((This->lpLcl->lpGbl->lpDDCBtmp->cbDDCallbacks.dwFlags & DDHAL_CB32_SETEXCLUSIVEMODE))
// {
//
// SetExclusiveMode.SetExclusiveMode = This->lpLcl->lpGbl->lpDDCBtmp->cbDDCallbacks.SetExclusiveMode;
// SetExclusiveMode.lpDD = This->lpLcl->lpGbl;
// SetExclusiveMode.dwEnterExcl = cooplevel;
// if (SetExclusiveMode.SetExclusiveMode(&SetExclusiveMode) != DDHAL_DRIVER_HANDLED)
// {
// return DDERR_NODRIVERSUPPORT;
// }
// }
//
// return SetExclusiveMode.ddRVal;
DX_STUB_DD_OK;
}
/*
* IMPLEMENT
* Status ok
*/
HRESULT WINAPI
Main_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight,
DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
{
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
BOOL dummy = TRUE;
DEVMODE DevMode;
int iMode=0;
int Width=0;
int Height=0;
int BPP=0;
DDHAL_SETMODEDATA mDdSetMode;
DX_WINDBG_trace();
/* FIXME check the refresrate if it same if it not same do the mode switch */
if ((This->lpLcl->lpGbl->vmiData.dwDisplayHeight == dwHeight) &&
(This->lpLcl->lpGbl->vmiData.dwDisplayWidth == dwWidth) &&
(This->lpLcl->lpGbl->vmiData.ddpfDisplay.dwRGBBitCount == dwBPP))
{
return DD_OK;
}
mDdSetMode.ddRVal = DDERR_NOTINITIALIZED;
mDdSetMode.dwModeIndex = 0;
mDdSetMode.inexcl = 0;
mDdSetMode.lpDD = This->lpLcl->lpGbl;
mDdSetMode.useRefreshRate = FALSE;
mDdSetMode.SetMode = This->lpLcl->lpDDCB->cbDDCallbacks.SetMode;
if (mDdSetMode.SetMode == NULL)
{
return DDERR_NODRIVERSUPPORT;
}
/* Check use the Hal or Hel for SetMode */
// this only for exclusive mode
/*if(!(This->cooperative_level & DDSCL_EXCLUSIVE))
{
return DDERR_NOEXCLUSIVEMODE;
}*/
DevMode.dmSize = (WORD)sizeof(DEVMODE);
DevMode.dmDriverExtra = 0;
while (EnumDisplaySettingsEx(NULL, iMode, &DevMode, 0 ) != 0)
{
if ((dwWidth == DevMode.dmPelsWidth) && (dwHeight == DevMode.dmPelsHeight) && ( dwBPP == DevMode.dmBitsPerPel))
{
Width = DevMode.dmPelsWidth;
Height = DevMode.dmPelsHeight;
BPP = DevMode.dmBitsPerPel;
break;
}
iMode++;
}
if ((dwWidth != DevMode.dmPelsWidth) || (dwHeight != DevMode.dmPelsHeight) || ( dwBPP != DevMode.dmBitsPerPel))
{
return DDERR_UNSUPPORTEDMODE;
}
mDdSetMode.dwModeIndex = iMode;
mDdSetMode.SetMode(&mDdSetMode);
DdReenableDirectDrawObject(This->lpLcl->lpGbl, &dummy);
/* FIXME fill the This->DirectDrawGlobal.vmiData right */
//This->lpLcl->lpGbl->lpExclusiveOwner->hDC = (ULONG_PTR)GetDC( (HWND)This->lpLcl->lpGbl->lpExclusiveOwner->hWnd);
return mDdSetMode.ddRVal;
}
/*
* IMPLEMENT
* Status ok
*/
HRESULT WINAPI
Main_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags,
HANDLE h)
{
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
DDHAL_WAITFORVERTICALBLANKDATA mDdWaitForVerticalBlank;
DX_WINDBG_trace();
if (!(This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags & DDHAL_CB32_WAITFORVERTICALBLANK))
{
return DDERR_NODRIVERSUPPORT;
}
if (mDdWaitForVerticalBlank.WaitForVerticalBlank == NULL)
{
return DDERR_NODRIVERSUPPORT;
}
mDdWaitForVerticalBlank.bIsInVB = DDWAITVB_BLOCKBEGIN ; /* return begin ? */
mDdWaitForVerticalBlank.ddRVal = DDERR_NOTINITIALIZED;
mDdWaitForVerticalBlank.dwFlags = dwFlags;
mDdWaitForVerticalBlank.hEvent = (DWORD)h;
mDdWaitForVerticalBlank.lpDD = This->lpLcl->lpGbl;
mDdWaitForVerticalBlank.WaitForVerticalBlank = This->lpLcl->lpDDCB->cbDDCallbacks.WaitForVerticalBlank;
if (mDdWaitForVerticalBlank.WaitForVerticalBlank(&mDdWaitForVerticalBlank)
!= DDHAL_DRIVER_HANDLED)
{
return DDERR_NODRIVERSUPPORT;
}
return mDdWaitForVerticalBlank.ddRVal;
}
/*
* IMPLEMENT
* Status ok
*/
HRESULT WINAPI
Main_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps,
LPDWORD total, LPDWORD free)
{
DDHAL_GETAVAILDRIVERMEMORYDATA mem;
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
DX_WINDBG_trace();
/* Only Hal version exists acodring msdn */
if (!(This->lpLcl->lpDDCB->cbDDMiscellaneousCallbacks.dwFlags & DDHAL_MISCCB32_GETAVAILDRIVERMEMORY))
{
return DDERR_NODRIVERSUPPORT;
}
mem.lpDD = This->lpLcl->lpGbl;
mem.ddRVal = DDERR_NOTPALETTIZED;
mem.DDSCaps.dwCaps = ddscaps->dwCaps;
mem.ddsCapsEx.dwCaps2 = ddscaps->dwCaps2;
mem.ddsCapsEx.dwCaps3 = ddscaps->dwCaps3;
mem.ddsCapsEx.dwCaps4 = ddscaps->dwCaps4;
if (This->lpLcl->lpDDCB->cbDDMiscellaneousCallbacks.GetAvailDriverMemory(&mem) == DDHAL_DRIVER_HANDLED);
{
if (total !=NULL)
{
*total = mem.dwTotal;
}
*free = mem.dwFree;
return mem.ddRVal;
}
return DDERR_NODRIVERSUPPORT;
}
/*
* Stub
* Status todo
*/
HRESULT WINAPI Main_DirectDraw_GetSurfaceFromDC(LPDIRECTDRAW7 iface, HDC hdc,
LPDIRECTDRAWSURFACE7 *lpDDS)
{
DX_WINDBG_trace();
DX_STUB;
}
/*
* Stub
* Status todo
*/
HRESULT WINAPI Main_DirectDraw_RestoreAllSurfaces(LPDIRECTDRAW7 iface)
{
DX_WINDBG_trace();
DX_STUB;
}
/*
* Stub
* Status todo
*/
HRESULT WINAPI Main_DirectDraw_TestCooperativeLevel(LPDIRECTDRAW7 iface)
{
DX_WINDBG_trace();
DX_STUB;
}
/*
* Stub
* Status todo
*/
HRESULT WINAPI Main_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
LPDDDEVICEIDENTIFIER2 pDDDI, DWORD dwFlags)
{
DX_WINDBG_trace();
DX_STUB;
}
/*
* Stub
* Status todo
*/
HRESULT WINAPI Main_DirectDraw_StartModeTest(LPDIRECTDRAW7 iface, LPSIZE pModes,
DWORD dwNumModes, DWORD dwFlags)
{
DX_WINDBG_trace();
DX_STUB;
}
/*
* Stub
* Status todo
*/
HRESULT WINAPI Main_DirectDraw_EvaluateMode(LPDIRECTDRAW7 iface,DWORD a,DWORD* b)
{
DX_WINDBG_trace();
DX_STUB;
}
IDirectDraw7Vtbl DirectDraw7_Vtable =
{
Main_DirectDraw_QueryInterface,
Main_DirectDraw_AddRef,
Main_DirectDraw_Release,
Main_DirectDraw_Compact,
Main_DirectDraw_CreateClipper,
Main_DirectDraw_CreatePalette,
Main_DirectDraw_CreateSurface,
Main_DirectDraw_DuplicateSurface,
Main_DirectDraw_EnumDisplayModes,
Main_DirectDraw_EnumSurfaces,
Main_DirectDraw_FlipToGDISurface,
Main_DirectDraw_GetCaps,
Main_DirectDraw_GetDisplayMode,
Main_DirectDraw_GetFourCCCodes,
Main_DirectDraw_GetGDISurface,
Main_DirectDraw_GetMonitorFrequency,
Main_DirectDraw_GetScanLine,
Main_DirectDraw_GetVerticalBlankStatus,
Main_DirectDraw_Initialize,
Main_DirectDraw_RestoreDisplayMode,
Main_DirectDraw_SetCooperativeLevel,
Main_DirectDraw_SetDisplayMode,
Main_DirectDraw_WaitForVerticalBlank,
Main_DirectDraw_GetAvailableVidMem,
Main_DirectDraw_GetSurfaceFromDC,
Main_DirectDraw_RestoreAllSurfaces,
Main_DirectDraw_TestCooperativeLevel,
Main_DirectDraw_GetDeviceIdentifier,
Main_DirectDraw_StartModeTest,
Main_DirectDraw_EvaluateMode
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -