Index: ddraw/glDirectDraw.cpp |
— | — | @@ -330,6 +330,7 @@ |
331 | 331 | HRESULT EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback)
|
332 | 332 | {
|
333 | 333 | if(!lpEnumModesCallback) return DDERR_INVALIDPARAMS;
|
| 334 | + if (dwFlags & 0xFFFFFFFC) return DDERR_INVALIDPARAMS;
|
334 | 335 | bool match;
|
335 | 336 | DWORD modenum = 0;
|
336 | 337 | DWORD modemax = 128;
|
— | — | @@ -795,6 +796,7 @@ |
796 | 797 | {
|
797 | 798 | TRACE_ENTER(1,14,this);
|
798 | 799 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 800 | + if (!fullscreen) TRACE_RET(HRESULT, 23, DDERR_NOEXCLUSIVEMODE);
|
799 | 801 | TRACE_EXIT(23,DD_OK);
|
800 | 802 | return DD_OK;
|
801 | 803 | }
|
— | — | @@ -924,6 +926,7 @@ |
925 | 927 | HRESULT error = DD_OK;
|
926 | 928 | if(primary)
|
927 | 929 | {
|
| 930 | + if (!primary->GetBackbuffer()) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
928 | 931 | if(primary->flipcount)
|
929 | 932 | {
|
930 | 933 | while(primary->flipcount != 0)
|
— | — | @@ -1234,6 +1237,7 @@ |
1235 | 1238 | TRACE_ENTER(3,14,this,13,hWnd,9,dwFlags);
|
1236 | 1239 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1237 | 1240 | if(hWnd && !IsWindow(hWnd)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 1241 | + if ((dwFlags & DDSCL_EXCLUSIVE) && !hWnd) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
1238 | 1242 | if(dwFlags & 0xFFFFE020) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1239 | 1243 | this->hWnd = hWnd;
|
1240 | 1244 | winstyle = GetWindowLongPtrA(hWnd,GWL_STYLE);
|
— | — | @@ -1374,6 +1378,9 @@ |
1375 | 1379 | {
|
1376 | 1380 | TRACE_ENTER(6,14,this,8,dwWidth,8,dwHeight,8,dwBPP,8,dwRefreshRate,9,dwFlags);
|
1377 | 1381 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 1382 | + if (dwFlags & 0xFFFFFFFE) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 1383 | + if ((dwBPP != 4) && (dwBPP != 8) && (dwBPP != 15) && (dwBPP != 16) && (dwBPP != 24) && (dwBPP != 32))
|
| 1384 | + TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
1378 | 1385 | DEBUG("IDirectDraw::SetDisplayMode: implement multiple monitors\n");
|
1379 | 1386 | DEVMODE newmode,newmode2;
|
1380 | 1387 | DEVMODE currmode;
|
Index: ddraw/glDirectDrawPalette.c |
— | — | @@ -173,7 +173,12 @@ |
174 | 174 | else entrysize = sizeof(PALETTEENTRY);
|
175 | 175 | if((dwStartingEntry + dwCount) > allentries) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
176 | 176 | memcpy(((char *)This->palette)+(dwStartingEntry*entrysize),lpEntries,dwCount*entrysize);
|
177 | | - TRACE_EXIT(23,DD_OK);
|
| 177 | + if (!(This->flags & DDPCAPS_ALLOW256))
|
| 178 | + {
|
| 179 | + memcpy(&This->palette[0], DefaultPalette, 4);
|
| 180 | + memcpy(&This->palette[255], DefaultPalette + 1020, 4);
|
| 181 | + }
|
| 182 | + TRACE_EXIT(23, DD_OK);
|
178 | 183 | return DD_OK;
|
179 | 184 | }
|
180 | 185 |
|
— | — | @@ -205,6 +210,10 @@ |
206 | 211 | glDirectDrawPalette *newpal;
|
207 | 212 | TRACE_ENTER(3,9,dwFlags,14,lpDDColorArray,14,lplpDDPalette);
|
208 | 213 | if (!lplpDDPalette) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 214 | + if (dwFlags & 0xFFFFF000) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 215 | + if ((dwFlags & DDPCAPS_8BIT) && (dwFlags & DDPCAPS_8BITENTRIES)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 216 | + if (((dwFlags & DDPCAPS_1BIT) || (dwFlags & DDPCAPS_2BIT) || (dwFlags & DDPCAPS_4BIT)) && (dwFlags & DDPCAPS_ALLOW256))
|
| 217 | + TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
209 | 218 | newpal = (glDirectDrawPalette*)malloc(sizeof(glDirectDrawPalette));
|
210 | 219 | if (!newpal) TRACE_RET(HRESULT, 23, DDERR_OUTOFMEMORY);
|
211 | 220 | ZeroMemory(newpal, sizeof(glDirectDrawPalette));
|
— | — | @@ -211,7 +220,11 @@ |
212 | 221 | newpal->refcount = 1;
|
213 | 222 | newpal->flags = dwFlags;
|
214 | 223 | newpal->lpVtbl = &glDirectDrawPalette_iface;
|
215 | | - if(lpDDColorArray == NULL) memcpy(newpal->palette,DefaultPalette,1024);
|
| 224 | + if (lpDDColorArray == NULL)
|
| 225 | + {
|
| 226 | + if (dwFlags & 0x800) memcpy(newpal->palette, DefaultPalette, 1024);
|
| 227 | + else return DDERR_INVALIDPARAMS;
|
| 228 | + }
|
216 | 229 | else
|
217 | 230 | {
|
218 | 231 | if(newpal->flags & DDPCAPS_1BIT)
|
— | — | @@ -223,7 +236,15 @@ |
224 | 237 | else if(newpal->flags & DDPCAPS_4BIT)
|
225 | 238 | if(newpal->flags & DDPCAPS_8BITENTRIES) memcpy(newpal->palette,lpDDColorArray,16);
|
226 | 239 | else memcpy(newpal->palette,lpDDColorArray,16*sizeof(PALETTEENTRY));
|
227 | | - else memcpy(newpal->palette,lpDDColorArray,256*sizeof(PALETTEENTRY));
|
| 240 | + else
|
| 241 | + {
|
| 242 | + memcpy(newpal->palette, lpDDColorArray, 256 * sizeof(PALETTEENTRY));
|
| 243 | + if (!(dwFlags & DDPCAPS_ALLOW256))
|
| 244 | + {
|
| 245 | + memcpy(&newpal->palette[0], DefaultPalette, 4);
|
| 246 | + memcpy(&newpal->palette[255], DefaultPalette + 1020, 4);
|
| 247 | + }
|
| 248 | + }
|
228 | 249 | }
|
229 | 250 | if(lplpDDPalette) *lplpDDPalette = (LPDIRECTDRAWPALETTE)newpal;
|
230 | 251 | TRACE_EXIT(23,DD_OK);
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -125,7 +125,7 @@ |
126 | 126 | }
|
127 | 127 | if(ddInterface->GetBPP() == 8)
|
128 | 128 | {
|
129 | | - if (!palettein) glDirectDrawPalette_Create(DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_PRIMARYSURFACE,NULL,(LPDIRECTDRAWPALETTE*)&palette);
|
| 129 | + if (!palettein) glDirectDrawPalette_Create(DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_PRIMARYSURFACE|0x800,NULL,(LPDIRECTDRAWPALETTE*)&palette);
|
130 | 130 | else
|
131 | 131 | {
|
132 | 132 | palette = palettein;
|
— | — | @@ -759,6 +759,7 @@ |
760 | 760 | TRACE_ENTER(3,14,this,14,lpDDSurfaceTargetOverride,9,dwFlags);
|
761 | 761 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
762 | 762 | HRESULT ret = Flip2(lpDDSurfaceTargetOverride,dwFlags);
|
| 763 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
763 | 764 | if(ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
764 | 765 | {
|
765 | 766 | if(ddInterface->lastsync)
|
— | — | @@ -1282,7 +1283,7 @@ |
1283 | 1284 | if(palette)
|
1284 | 1285 | {
|
1285 | 1286 | glDirectDrawPalette_Release(palette);
|
1286 | | - if(!lpDDPalette) glDirectDrawPalette_Create(DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_PRIMARYSURFACE,NULL,(LPDIRECTDRAWPALETTE*)&palette);
|
| 1287 | + if(!lpDDPalette) glDirectDrawPalette_Create(DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_PRIMARYSURFACE|0x800,NULL,(LPDIRECTDRAWPALETTE*)&palette);
|
1287 | 1288 | }
|
1288 | 1289 | if(lpDDPalette)
|
1289 | 1290 | {
|
Index: dxgltest/Tests2D.cpp |
— | — | @@ -574,6 +574,7 @@ |
575 | 575 | ddinterface->CreateSurface(&ddsd, &sprites[0].surface, NULL);
|
576 | 576 | ddsrender->GetPalette(&palette);
|
577 | 577 | error = sprites[0].surface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
| 578 | + if(palette) palette->Release();
|
578 | 579 | DrawGradients(ddsd, (unsigned char *)ddsd.lpSurface, hWnd, palette, 1, 0);
|
579 | 580 | error = sprites[0].surface->Unlock(NULL);
|
580 | 581 | sprites[0].width = (float)ddsd.dwWidth;
|