📄 ddraw.c
字号:
//==========================================================================;
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE.
//
// Copyright (c) 1992 - 1996 Microsoft Corporation. All Rights Reserved.
//
//==========================================================================;
#include "strmini.h"
#include "ksmedia.h"
#include "ddkmapi.h"
#include "capmain.h"
#include "capdebug.h"
#define _NO_COM
#include "ddkernel.h"
#define DD_OK 0
// The following should be defined in ddkmapi.h, but for some reason are not!
#ifndef booboo // DDKERNELCAPS_SKIPFIELDS
/*
* Indicates that the device supports field skipping.
*/
#define DDKERNELCAPS_SKIPFIELDS 0x00000001l
/*
* Indicates that the device can support software autoflipping.
*/
#define DDKERNELCAPS_AUTOFLIP 0x00000002l
/*
* Indicates that the device can switch between bob and weave.
*/
#define DDKERNELCAPS_SETSTATE 0x00000004l
/*
* Indicates that a client can gain direct access to the frame buffer.
*/
#define DDKERNELCAPS_LOCK 0x00000008l
/*
* Indicates that a client can manually flip the video port.
*/
#define DDKERNELCAPS_FLIPVIDEOPORT 0x00000010l
/*
* Indicates that a client can manually flip the overlay.
*/
#define DDKERNELCAPS_FLIPOVERLAY 0x00000020l
/*
* Indicates that the device supports a fast, asynchronous transfer
* mechanism to system memory.
*/
#define DDKERNELCAPS_TRANSFER_SYSMEM 0x00000040l
/*
* Indicates that the device supports a fast, asynchronous transfer
* mechanism via AGP.
*/
#define DDKERNELCAPS_TRANSFER_AGP 0x00000080l
/*
* Indicates that the device can report the polarity (even/odd) of
* the curent video field.
*/
#define DDKERNELCAPS_FIELDPOLARITY 0x00000100l
/****************************************************************************
*
* DDKERNELCAPS IRQ CAPS
*
****************************************************************************/
/*
* The device can generate display VSYNC IRQs
*/
#define DDIRQ_DISPLAY_VSYNC 0x00000001l
/*
* Reserved
*/
#define DDIRQ_RESERVED1 0x00000002l
/*
* The device can generate video ports VSYNC IRQs using video port 0
*/
#define DDIRQ_VPORT0_VSYNC 0x00000004l
/*
* The device can generate video ports line IRQs using video port 0
*/
#define DDIRQ_VPORT0_LINE 0x00000008l
/*
* The device can generate video ports VSYNC IRQs using video port 1
*/
#define DDIRQ_VPORT1_VSYNC 0x00000010l
/*
* The device can generate video ports line IRQs using video port 1
*/
#define DDIRQ_VPORT1_LINE 0x00000020l
/*
* The device can generate video ports VSYNC IRQs using video port 2
*/
#define DDIRQ_VPORT2_VSYNC 0x00000040l
/*
* The device can generate video ports line IRQs using video port 2
*/
#define DDIRQ_VPORT2_LINE 0x00000080l
/*
* The device can generate video ports VSYNC IRQs using video port 3
*/
#define DDIRQ_VPORT3_VSYNC 0x00000100l
/*
* The device can generate video ports line IRQs using video port 3
*/
#define DDIRQ_VPORT3_LINE 0x00000200l
/*
* The device can generate video ports VSYNC IRQs using video port 4
*/
#define DDIRQ_VPORT4_VSYNC 0x00000400l
/*
* The device can generate video ports line IRQs using video port 4
*/
#define DDIRQ_VPORT4_LINE 0x00000800l
/*
* The device can generate video ports VSYNC IRQs using video port 5
*/
#define DDIRQ_VPORT5_VSYNC 0x00001000l
/*
* The device can generate video ports line IRQs using video port 5
*/
#define DDIRQ_VPORT5_LINE 0x00002000l
/*
* The device can generate video ports VSYNC IRQs using video port 6
*/
#define DDIRQ_VPORT6_VSYNC 0x00004000l
/*
* The device can generate video ports line IRQs using video port 6
*/
#define DDIRQ_VPORT6_LINE 0x00008000l
/*
* The device can generate video ports VSYNC IRQs using video port 7
*/
#define DDIRQ_VPORT7_VSYNC 0x00010000l
/*
* The device can generate video ports line IRQs using video port 7
*/
#define DDIRQ_VPORT7_LINE 0x00020000l
/*
* The device can generate video ports VSYNC IRQs using video port 8
*/
#define DDIRQ_VPORT8_VSYNC 0x00040000l
/*
* The device can generate video ports line IRQs using video port 8
*/
#define DDIRQ_VPORT8_LINE 0x00080000l
/*
* The device can generate video ports VSYNC IRQs using video port 9
*/
#define DDIRQ_VPORT9_VSYNC 0x00010000l
/*
* The device can generate video ports line IRQs using video port 9
*/
#define DDIRQ_VPORT9_LINE 0x00020000l
#endif
DWORD FAR PASCAL
DirectDrawEventCallback (
DWORD dwEvent, PVOID pContext, DWORD dwParam1, DWORD dwParam2
)
{
switch (dwEvent)
{
case DDNOTIFY_PRERESCHANGE:
{
PSTREAMEX pStrmEx = (PSTREAMEX)pContext;
PHW_DEVICE_EXTENSION pHwDevExt = pStrmEx->pHwDevExt;
int StreamNumber = pStrmEx->pStreamObject->StreamNumber;
DbgLogInfo(("Testcap: DDNOTIFY_PRERESCHANGE; stream = %d\n", StreamNumber));
pStrmEx->PreEventOccurred = TRUE;
}
break;
case DDNOTIFY_POSTRESCHANGE:
{
PSTREAMEX pStrmEx = (PSTREAMEX)pContext;
PHW_DEVICE_EXTENSION pHwDevExt = pStrmEx->pHwDevExt;
int StreamNumber = pStrmEx->pStreamObject->StreamNumber;
DbgLogInfo(("Testcap: DDNOTIFY_POSTRESCHANGE; stream = %d\n", StreamNumber));
pStrmEx->PostEventOccurred = TRUE;
DbgLogInfo(("Testcap: Before Attempted Renegotiation due to DDNOTIFY_POSTRESCHANGE\n"));
// AttemptRenegotiation(pStrmEx);
DbgLogInfo(("Testcap: Afer Attempted Renegotiation due to DDNOTIFY_POSTRESCHANGE\n"));
}
break;
case DDNOTIFY_PREDOSBOX:
{
PSTREAMEX pStrmEx = (PSTREAMEX)pContext;
PHW_DEVICE_EXTENSION pHwDevExt = pStrmEx->pHwDevExt;
int StreamNumber = pStrmEx->pStreamObject->StreamNumber;
DbgLogInfo(("Testcap: DDNOTIFY_PREDOSBOX; stream = %d\n", StreamNumber));
pStrmEx->PreEventOccurred = TRUE;
}
break;
case DDNOTIFY_POSTDOSBOX:
{
PSTREAMEX pStrmEx = (PSTREAMEX)pContext;
PHW_DEVICE_EXTENSION pHwDevExt = pStrmEx->pHwDevExt;
int StreamNumber = pStrmEx->pStreamObject->StreamNumber;
DbgLogInfo(("Testcap: DDNOTIFY_POSTDOSBOX; stream = %d\n", StreamNumber));
pStrmEx->PostEventOccurred = TRUE;
DbgLogInfo(("Testcap: Before Attempted Renegotiation due to DDNOTIFY_POSTDOSBOX\n"));
// AttemptRenegotiation(pStrmEx);
DbgLogInfo(("Testcap: After Attempted Renegotiation due to DDNOTIFY_POSTDOSBOX\n"));
}
break;
case DDNOTIFY_CLOSEDIRECTDRAW:
{
PSTREAMEX pStrmEx = (PSTREAMEX)pContext;
PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pContext;
DbgLogInfo(("Testcap: DDNOTIFY_CLOSEDIRECTDRAW\n"));
pStrmEx->KernelDirectDrawHandle = 0;
pStrmEx->UserDirectDrawHandle = 0;
}
break;
case DDNOTIFY_CLOSESURFACE:
{
PHW_STREAM_REQUEST_BLOCK pSrb = (PHW_STREAM_REQUEST_BLOCK)pContext;
PSRB_EXTENSION pSrbExt = (PSRB_EXTENSION)pSrb->SRBExtension;
DbgLogInfo(("Testcap: DDNOTIFY_CLOSESURFACE\n"));
pSrbExt->KernelSurfaceHandle = 0;
}
break;
default:
TRAP;
break;
}
return 0;
}
BOOL
RegisterForDirectDrawEvents (
PSTREAMEX pStrmEx
)
{
PHW_DEVICE_EXTENSION pHwDevExt = pStrmEx->pHwDevExt;
int StreamNumber = pStrmEx->pStreamObject->StreamNumber;
DDREGISTERCALLBACK ddRegisterCallback;
DWORD ddOut;
DbgLogInfo(("Testcap: Stream %d registering for DirectDraw events\n", StreamNumber));
// =============== DDEVENT_PRERESCHANGE ===============
RtlZeroMemory(&ddRegisterCallback, sizeof(ddRegisterCallback));
RtlZeroMemory(&ddOut, sizeof(ddOut));
ddRegisterCallback.hDirectDraw = pStrmEx->KernelDirectDrawHandle;
ddRegisterCallback.dwEvents = DDEVENT_PRERESCHANGE;
ddRegisterCallback.pfnCallback = DirectDrawEventCallback;
ddRegisterCallback.pContext = pStrmEx;
DxApi(DD_DXAPI_REGISTER_CALLBACK, &ddRegisterCallback, sizeof(ddRegisterCallback), &ddOut, sizeof(ddOut));
if (ddOut != DD_OK) {
DbgLogInfo(("Testcap: DD_DXAPI_REGISTER_CALLBACK failed.\n"));
TRAP;
return FALSE;
}
// =============== DDEVENT_POSTRESCHANGE ==============
RtlZeroMemory(&ddRegisterCallback, sizeof(ddRegisterCallback));
RtlZeroMemory(&ddOut, sizeof(ddOut));
ddRegisterCallback.hDirectDraw = pStrmEx->KernelDirectDrawHandle;
ddRegisterCallback.dwEvents = DDEVENT_POSTRESCHANGE;
ddRegisterCallback.pfnCallback = DirectDrawEventCallback;
ddRegisterCallback.pContext = pStrmEx;
DxApi(DD_DXAPI_REGISTER_CALLBACK, &ddRegisterCallback, sizeof(ddRegisterCallback), &ddOut, sizeof(ddOut));
if (ddOut != DD_OK) {
DbgLogInfo(("Testcap: DD_DXAPI_REGISTER_CALLBACK failed.\n"));
TRAP;
return FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -