1 | /******************************Module*Header**********************************\
|
---|
2 | *
|
---|
3 | * **************************
|
---|
4 | * * DirectDraw SAMPLE CODE *
|
---|
5 | * **************************
|
---|
6 | *
|
---|
7 | * Module Name: ddenable.c
|
---|
8 | *
|
---|
9 | * Content:
|
---|
10 | *
|
---|
11 | * Copyright (c) 1994-1998 3Dlabs Inc. Ltd. All rights reserved.
|
---|
12 | * Copyright (c) 1995-1999 Microsoft Corporation. All rights reserved.
|
---|
13 | \*****************************************************************************/
|
---|
14 |
|
---|
15 | #include "driver.h"
|
---|
16 | #include "dd.h"
|
---|
17 |
|
---|
18 | #if 0
|
---|
19 | static DWORD APIENTRY DdCreateSurface(PDD_CREATESURFACEDATA lpCreateSurface);
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * DrvGetDirectDrawInfo
|
---|
24 | *
|
---|
25 | * The DrvGetDirectDrawInfo function returns the capabilities of the graphics hardware.
|
---|
26 | *
|
---|
27 | * Parameters:
|
---|
28 | *
|
---|
29 | * dhpdev
|
---|
30 | * Handle to the PDEV returned by the drivers DrvEnablePDEV routine.
|
---|
31 | * pHalInfo
|
---|
32 | * Points to a DD_HALINFO structure in which the driver should return the hardware capabilities that it supports.
|
---|
33 | * pdwNumHeaps
|
---|
34 | * Points to the location in which the driver should return the number of VIDEOMEMORY structures pointed to by pvmList.
|
---|
35 | * pvmList
|
---|
36 | * Points to an array of VIDEOMEMORY structures in which the driver should return information about each display memory chunk that it controls. The driver should ignore this parameter when it is NULL.
|
---|
37 | * pdwNumFourCCCodes
|
---|
38 | * Points to the location in which the driver should return the number of DWORDs pointed to by pdwFourCC.
|
---|
39 | * pdwFourCC
|
---|
40 | * Points to an array of DWORDs in which the driver should return information about each FOURCC that it supports. The driver should ignore this parameter when it is NULL.
|
---|
41 | *
|
---|
42 | * Return Value:
|
---|
43 | *
|
---|
44 | * DrvGetDirectDrawInfo returns TRUE if it succeeds; otherwise, it returns FALSE.
|
---|
45 | *
|
---|
46 | */
|
---|
47 | BOOL APIENTRY DrvGetDirectDrawInfo(
|
---|
48 | DHPDEV dhpdev,
|
---|
49 | DD_HALINFO *pHalInfo,
|
---|
50 | DWORD *pdwNumHeaps,
|
---|
51 | VIDEOMEMORY *pvmList,
|
---|
52 | DWORD *pdwNumFourCCCodes,
|
---|
53 | DWORD *pdwFourCC
|
---|
54 | )
|
---|
55 | {
|
---|
56 | PPDEV pDev = (PPDEV)dhpdev;
|
---|
57 |
|
---|
58 | DISPDBG((0, "%s: %p, %p, %p, %p, %p. %p\n", __FUNCTION__, dhpdev, pHalInfo, pdwNumHeaps, pvmList, pdwNumFourCCCodes, pdwFourCC));
|
---|
59 |
|
---|
60 | *pdwNumFourCCCodes = 0;
|
---|
61 | *pdwNumHeaps = 0;
|
---|
62 |
|
---|
63 | /* Setup the HAL driver caps. */
|
---|
64 | pHalInfo->dwSize = sizeof(DD_HALINFO);
|
---|
65 | pHalInfo->dwFlags = 0;
|
---|
66 |
|
---|
67 | if (!(pvmList && pdwFourCC))
|
---|
68 | {
|
---|
69 | /* Create primary surface attributes */
|
---|
70 | pHalInfo->vmiData.pvPrimary = pDev->pjScreen;
|
---|
71 | pHalInfo->vmiData.fpPrimary = 0;
|
---|
72 | pHalInfo->vmiData.dwDisplayWidth = pDev->cxScreen;
|
---|
73 | pHalInfo->vmiData.dwDisplayHeight = pDev->cyScreen;
|
---|
74 | pHalInfo->vmiData.lDisplayPitch = pDev->lDeltaScreen;
|
---|
75 | pHalInfo->vmiData.ddpfDisplay.dwSize = sizeof(DDPIXELFORMAT);
|
---|
76 | pHalInfo->vmiData.ddpfDisplay.dwFlags = DDPF_RGB;
|
---|
77 | pHalInfo->vmiData.ddpfDisplay.dwRGBBitCount = pDev->ulBitCount;
|
---|
78 | DISPDBG((0, "pvPrimary %x\n", pHalInfo->vmiData.pvPrimary));
|
---|
79 | DISPDBG((0, "fpPrimary %x\n", pHalInfo->vmiData.fpPrimary));
|
---|
80 | DISPDBG((0, "dwDisplayWidth %d\n", pHalInfo->vmiData.dwDisplayWidth));
|
---|
81 | DISPDBG((0, "dwDisplayHeight %d\n", pHalInfo->vmiData.dwDisplayHeight));
|
---|
82 | DISPDBG((0, "lDisplayPitch %d\n", pHalInfo->vmiData.lDisplayPitch));
|
---|
83 | DISPDBG((0, "dwRGBBitCount %d\n", pHalInfo->vmiData.ddpfDisplay.dwRGBBitCount));
|
---|
84 |
|
---|
85 | if (pDev->ulBitmapType == BMF_8BPP)
|
---|
86 | {
|
---|
87 | pHalInfo->vmiData.ddpfDisplay.dwFlags |= DDPF_PALETTEINDEXED8;
|
---|
88 | DISPDBG((0, "DDPF_PALETTEINDEXED8\n"));
|
---|
89 | }
|
---|
90 |
|
---|
91 | pHalInfo->vmiData.ddpfDisplay.dwRBitMask = pDev->flRed;
|
---|
92 | pHalInfo->vmiData.ddpfDisplay.dwGBitMask = pDev->flGreen;
|
---|
93 | pHalInfo->vmiData.ddpfDisplay.dwBBitMask = pDev->flBlue;
|
---|
94 |
|
---|
95 | pHalInfo->vmiData.dwOffscreenAlign = 4;
|
---|
96 | pHalInfo->vmiData.dwZBufferAlign = 4;
|
---|
97 | pHalInfo->vmiData.dwTextureAlign = 4;
|
---|
98 | }
|
---|
99 | pHalInfo->ddCaps.dwSize = sizeof(DDNTCORECAPS);
|
---|
100 | pHalInfo->ddCaps.dwVidMemTotal = pDev->cScreenSize;
|
---|
101 | pHalInfo->ddCaps.dwVidMemFree = pDev->cScreenSize;
|
---|
102 |
|
---|
103 | pHalInfo->ddCaps.dwCaps = DDCAPS_NOHARDWARE; /* ??? */
|
---|
104 | pHalInfo->ddCaps.dwCaps2 = DDCAPS2_CERTIFIED;
|
---|
105 |
|
---|
106 | pHalInfo->ddCaps.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY;
|
---|
107 |
|
---|
108 | #if 0
|
---|
109 | /* DX5 and up */
|
---|
110 | pHalInfo->GetDriverInfo = DdGetDriverInfo;
|
---|
111 | pHalInfo->dwFlags |= DDHALINFO_GETDRIVERINFOSET;
|
---|
112 | #endif
|
---|
113 |
|
---|
114 | /* No 3D capabilities */
|
---|
115 | #if 0
|
---|
116 | if (pHalInfo->lpD3DGlobalDriverData)
|
---|
117 | {
|
---|
118 | LPD3DHAL_GLOBALDRIVERDATA lpD3DGlobalDriverData = (LPD3DHAL_GLOBALDRIVERDATA)pHalInfo->lpD3DGlobalDriverData;
|
---|
119 | lpD3DGlobalDriverData->dwSize = sizeof(D3DHAL_GLOBALDRIVERDATA);
|
---|
120 | }
|
---|
121 | #endif
|
---|
122 |
|
---|
123 | return TRUE;
|
---|
124 | }
|
---|
125 |
|
---|
126 | /**
|
---|
127 | * DrvEnableDirectDraw
|
---|
128 | *
|
---|
129 | * The DrvEnableDirectDraw function enables hardware for DirectDraw use.
|
---|
130 | *
|
---|
131 | * Parameters
|
---|
132 | *
|
---|
133 | * dhpdev
|
---|
134 | * Handle to the PDEV returned by the drivers DrvEnablePDEV routine.
|
---|
135 | * pCallBacks
|
---|
136 | * Points to the DD_CALLBACKS structure to be initialized by the driver.
|
---|
137 | * pSurfaceCallBacks
|
---|
138 | * Points to the DD_SURFACECALLBACKS structure to be initialized by the driver.
|
---|
139 | * pPaletteCallBacks
|
---|
140 | * Points to the DD_PALETTECALLBACKS structure to be initialized by the driver.
|
---|
141 | *
|
---|
142 | * Return Value
|
---|
143 | *
|
---|
144 | * DrvEnableDirectDraw returns TRUE if it succeeds; otherwise, it returns FALSE.
|
---|
145 | *
|
---|
146 | */
|
---|
147 | BOOL APIENTRY DrvEnableDirectDraw(
|
---|
148 | DHPDEV dhpdev,
|
---|
149 | DD_CALLBACKS *pCallBacks,
|
---|
150 | DD_SURFACECALLBACKS *pSurfaceCallBacks,
|
---|
151 | DD_PALETTECALLBACKS *pPaletteCallBacks
|
---|
152 | )
|
---|
153 | {
|
---|
154 | DISPDBG((0, "%s: %p, %p, %p, %p\n", __FUNCTION__, dhpdev, pCallBacks, pSurfaceCallBacks, pPaletteCallBacks));
|
---|
155 |
|
---|
156 | /* Fill in the HAL Callback pointers */
|
---|
157 | pCallBacks->dwSize = sizeof(DD_CALLBACKS);
|
---|
158 | pCallBacks->dwFlags = 0;
|
---|
159 |
|
---|
160 | /*
|
---|
161 | pCallBacks->dwFlags = DDHAL_CB32_CREATESURFACE;
|
---|
162 | pCallBacks->CreateSurface = DdCreateSurface;
|
---|
163 | pCallBacks->CanCreateSurface = DdCanCreateSurface;
|
---|
164 | pCallBacks->WaitForVerticalBlank = DdWaitForVerticalBlank;
|
---|
165 | pCallBacks->GetScanLine = DdGetScanLine;
|
---|
166 | pCallBacks->MapMemory = DdMapMemory;
|
---|
167 | DDHAL_CB32_CANCREATESURFACE | DDHAL_CB32_WAITFORVERTICALBLANK | DDHAL_CB32_MAPMEMORY | DDHAL_CB32_GETSCANLINE
|
---|
168 | */
|
---|
169 | /* Note: pCallBacks->SetMode & pCallBacks->DestroyDriver are unused in Windows 2000 and up */
|
---|
170 |
|
---|
171 | /* Fill in the Surface Callback pointers */
|
---|
172 | pSurfaceCallBacks->dwSize = sizeof(DD_SURFACECALLBACKS);
|
---|
173 | pSurfaceCallBacks->dwFlags = 0;
|
---|
174 |
|
---|
175 | /*
|
---|
176 | pSurfaceCallBacks->dwFlags = DDHAL_SURFCB32_DESTROYSURFACE | DDHAL_SURFCB32_LOCK;
|
---|
177 | pSurfaceCallBacks->DestroySurface = DdDestroySurface;
|
---|
178 | pSurfaceCallBacks->Lock = DdLock;
|
---|
179 | pSurfaceCallBacks->Flip = DdFlip;
|
---|
180 | pSurfaceCallBacks->GetBltStatus = DdGetBltStatus;
|
---|
181 | pSurfaceCallBacks->GetFlipStatus = DdGetFlipStatus;
|
---|
182 | pSurfaceCallBacks->Blt = DdBlt;
|
---|
183 | DDHAL_SURFCB32_FLIP | DDHAL_SURFCB32_BLT | DDHAL_SURFCB32_GETBLTSTATUS | DDHAL_SURFCB32_GETFLIPSTATUS;
|
---|
184 | */
|
---|
185 |
|
---|
186 | // pSurfaceCallBacks.SetColorKey = DdSetColorKey;
|
---|
187 | // pSurfaceCallBacks.dwFlags |= DDHAL_SURFCB32_SETCOLORKEY;
|
---|
188 |
|
---|
189 | /* Fill in the Palette Callback pointers */
|
---|
190 | pPaletteCallBacks->dwSize = sizeof(DD_PALETTECALLBACKS);
|
---|
191 | pPaletteCallBacks->dwFlags = 0;
|
---|
192 |
|
---|
193 | return TRUE;
|
---|
194 | }
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * DrvDisableDirectDraw
|
---|
198 | *
|
---|
199 | * The DrvDisableDirectDraw function disables hardware for DirectDraw use.
|
---|
200 | *
|
---|
201 | * Parameters
|
---|
202 | *
|
---|
203 | * dhpdev
|
---|
204 | * Handle to the PDEV returned by the drivers DrvEnablePDEV routine.
|
---|
205 | *
|
---|
206 | */
|
---|
207 | VOID APIENTRY DrvDisableDirectDraw( DHPDEV dhpdev)
|
---|
208 | {
|
---|
209 | DISPDBG((0, "%s: %p\n", __FUNCTION__, dhpdev));
|
---|
210 | }
|
---|
211 |
|
---|
212 |
|
---|
213 | #if 0
|
---|
214 | /**
|
---|
215 | * DdCreateSurface
|
---|
216 | *
|
---|
217 | * The DdCreateSurface callback function creates a DirectDraw surface.
|
---|
218 | *
|
---|
219 | * lpCreateSurface
|
---|
220 | * Points to a DD_CREATESURFACEDATA structure that contains the information required to create a surface.
|
---|
221 | *
|
---|
222 | * Return Value
|
---|
223 | *
|
---|
224 | * DdCreateSurface returns one of the following callback codes:
|
---|
225 | * DDHAL_DRIVER_HANDLED
|
---|
226 | * DDHAL_DRIVER_NOTHANDLED
|
---|
227 | *
|
---|
228 | */
|
---|
229 | static DWORD APIENTRY DdCreateSurface(PDD_CREATESURFACEDATA lpCreateSurface)
|
---|
230 | {
|
---|
231 | lpCreateSurface->lpDD->fpVidMem = DDHAL_PLEASEALLOC_USERMEM;
|
---|
232 |
|
---|
233 | return DDHAL_DRIVER_NOTHANDLED;
|
---|
234 | }
|
---|
235 | #endif
|
---|