Changeset 503 for trunk/src/ddraw/OS2DDRAW.CPP
- Timestamp:
- Aug 16, 1999, 2:40:48 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ddraw/OS2DDRAW.CPP
r423 r503 21 21 #include "os2ddrawmodes.h" 22 22 #include "os2DDWindow.h" 23 23 #include "os2palset.h" 24 #include <odincrt.h> 24 25 #define KEY_DIRECT2 "\\Software\\Win32OS2\\Direct2" 25 26 #define KEY_DIRECT2DRAW "\\Software\\Win32OS2\\Direct2\\Draw" … … 36 37 HKEY hkDirectDraw2; 37 38 DWORD dwVSize, dwVType; 39 ULONG rc; 38 40 39 41 // Setup table for 3d devices … … 126 128 } 127 129 128 ULONG rc = DiveOpen( &hDive, 129 FALSE, 130 &pFrameBuffer); 130 ODIN_FS_BEGIN 131 rc = DiveOpen( &hDive, 132 FALSE, 133 &pFrameBuffer); 134 ODIN_FS_END 131 135 if(rc) 132 136 { … … 160 164 if(hDive) 161 165 DiveClose(hDive); 166 if(hDiveColorConv) 167 DiveClose(hDiveColorConv); 168 169 // Safty call in case the program did set the pal to all black 170 // so if the destructor gets called we might be able change this back 171 OS2ResetPhysPalette(); 162 172 } 163 173 //****************************************************************************** … … 199 209 *ppvObj = This; 200 210 DrawAddRef(This); 211 201 212 return(DD_OK); 202 213 } … … 218 229 { 219 230 OS2IDirectDraw *me = (OS2IDirectDraw *)This; 231 ULONG rc; 220 232 221 233 #ifdef DEBUG … … 230 242 if(me->Referenced == 0) 231 243 { 232 delete me;233 r eturn(0);244 ODIN_delete(me); 245 rc = 0; 234 246 } 235 247 else 236 r eturnme->Referenced;248 rc = me->Referenced; 237 249 } 238 250 else 239 return(0); 251 rc = 0; 252 253 return rc; 240 254 } 241 255 //****************************************************************************** … … 254 268 { 255 269 OS2IDirectDraw *me = (OS2IDirectDraw *)This; 256 OS2IDirectDrawClipper *newclip = new OS2IDirectDrawClipper(me);270 OS2IDirectDrawClipper *newclip; 257 271 HRESULT rc; 258 272 273 ODIN_FS_BEGIN 274 275 newclip = new OS2IDirectDrawClipper(me); 276 259 277 #ifdef DEBUG 260 278 WriteLog("CreateClipper\n"); … … 262 280 263 281 if(newclip == NULL) 264 return(DDERR_OUTOFMEMORY); 265 266 newclip->Vtbl.AddRef((IDirectDrawClipper *)newclip); 267 rc = newclip->GetLastError(); 268 if(rc != DD_OK) 269 { 270 *lplpDD = NULL; 271 delete newclip; 282 { 283 rc = DDERR_OUTOFMEMORY; 272 284 } 273 285 else 274 *lplpDD = (IDirectDrawClipper *)newclip; 286 { 287 newclip->Vtbl.AddRef((IDirectDrawClipper *)newclip); 288 rc = newclip->GetLastError(); 289 if(rc != DD_OK) 290 { 291 *lplpDD = NULL; 292 delete newclip; 293 } 294 else 295 *lplpDD = (IDirectDrawClipper *)newclip; 296 } 297 298 ODIN_FS_END 275 299 276 300 return(rc); … … 285 309 OS2IDirectDraw *me = (OS2IDirectDraw *)This; 286 310 OS2IDirectDrawPalette *newpal; 287 HRESULT rc ;311 HRESULT rc = DD_OK; 288 312 int palsize = 0; 289 313 314 ODIN_FS_BEGIN 315 290 316 if(dwFlags & DDPCAPS_8BITENTRIES) 291 317 { 292 318 // We Don't support Indexed palettes... 293 319 294 r eturnDDERR_INVALIDPARAMS;320 rc = DDERR_INVALIDPARAMS; 295 321 } 296 322 … … 305 331 306 332 if(palsize == 0) 307 return DDERR_INVALIDPARAMS; 308 309 #ifdef DEBUG 310 WriteLog("CreatePalette with %d colors\n", palsize); 311 #endif 312 313 newpal = new OS2IDirectDrawPalette(me, palsize, lpColorTable, dwFlags); 314 if(newpal == NULL) 315 return(DDERR_OUTOFMEMORY); 316 317 newpal->Vtbl.AddRef((IDirectDrawPalette *)newpal); 318 rc = newpal->GetLastError(); 319 if(rc != DD_OK) 320 { 321 *lplpDD = NULL; 322 delete newpal; 323 } 324 else 325 *lplpDD = (IDirectDrawPalette *)newpal; 333 rc = DDERR_INVALIDPARAMS; 334 335 if(DD_OK == rc) 336 { 337 #ifdef DEBUG 338 WriteLog("CreatePalette with %d colors\n", palsize); 339 #endif 340 341 newpal = new OS2IDirectDrawPalette(me, palsize, lpColorTable, dwFlags); 342 343 if(newpal == NULL) 344 { 345 rc = DDERR_OUTOFMEMORY; 346 } 347 else 348 { 349 newpal->Vtbl.AddRef((IDirectDrawPalette *)newpal); 350 rc = newpal->GetLastError(); 351 352 if(DD_OK != rc) 353 { 354 *lplpDD = NULL; 355 delete newpal; 356 } 357 else 358 *lplpDD = (IDirectDrawPalette *)newpal; 359 } 360 } 361 362 ODIN_FS_END 326 363 327 364 return(rc); … … 336 373 OS2IDirectDrawSurface *newsurf; 337 374 HRESULT rc; 375 376 ODIN_FS_BEGIN 338 377 339 378 #ifdef DEBUG … … 351 390 352 391 newsurf = new OS2IDirectDrawSurface(me, (LPDDSURFACEDESC2)lpDDSurfaceDesc); 353 354 392 if(newsurf == NULL) 355 return(DDERR_OUTOFMEMORY); 356 357 newsurf->Vtbl.AddRef((IDirectDrawSurface *)newsurf); 358 rc = newsurf->GetLastError(); 359 if(rc != DD_OK) 360 { 361 WriteLog("Error createing Surface\n\n"); 362 *lplpDD = NULL; 363 delete newsurf; 393 { 394 rc = DDERR_OUTOFMEMORY; 364 395 } 365 396 else 366 *lplpDD = (IDirectDrawSurface *)newsurf; 367 368 WriteLog("New Surface created at %08X\n\n", newsurf); 397 { 398 newsurf->Vtbl.AddRef((IDirectDrawSurface *)newsurf); 399 rc = newsurf->GetLastError(); 400 if(rc != DD_OK) 401 { 402 WriteLog("Error createing Surface\n\n"); 403 *lplpDD = NULL; 404 delete newsurf; 405 } 406 else 407 *lplpDD = (IDirectDrawSurface *)newsurf; 408 409 WriteLog("New Surface created at %08X\n\n", newsurf); 410 } 411 412 ODIN_FS_END 413 369 414 return(rc); 370 415 } … … 379 424 HRESULT rc; 380 425 381 #ifdef DEBUG 382 WriteLog("CreateSurface4\n"); 383 WriteLog("dwSize %d\n", lpDDSurfaceDesc2->dwSize); 384 WriteLog("dwHeight %d\n", lpDDSurfaceDesc2->dwHeight); 385 WriteLog("dwWidth %d\n", lpDDSurfaceDesc2->dwWidth); 386 WriteLog("lPitch %d\n", lpDDSurfaceDesc2->lPitch); 387 WriteLog("dwBackBufferCount %d\n", lpDDSurfaceDesc2->dwBackBufferCount); 388 WriteLog("dwMipMapCount %d\n", lpDDSurfaceDesc2->dwMipMapCount); 389 WriteLog("dwAlphaBitDepth %d\n", lpDDSurfaceDesc2->dwAlphaBitDepth); 390 WriteLog("ddsCaps.dwCaps %X\n", lpDDSurfaceDesc2->ddsCaps.dwCaps); 391 #endif 426 ODIN_FS_BEGIN 427 428 #ifdef DEBUG 429 WriteLog("CreateSurface4\n"); 430 WriteLog("dwSize %d\n", lpDDSurfaceDesc2->dwSize); 431 WriteLog("dwHeight %d\n", lpDDSurfaceDesc2->dwHeight); 432 WriteLog("dwWidth %d\n", lpDDSurfaceDesc2->dwWidth); 433 WriteLog("lPitch %d\n", lpDDSurfaceDesc2->lPitch); 434 WriteLog("dwBackBufferCount %d\n", lpDDSurfaceDesc2->dwBackBufferCount); 435 WriteLog("dwMipMapCount %d\n", lpDDSurfaceDesc2->dwMipMapCount); 436 WriteLog("dwAlphaBitDepth %d\n", lpDDSurfaceDesc2->dwAlphaBitDepth); 437 WriteLog("ddsCaps.dwCaps %X\n", lpDDSurfaceDesc2->ddsCaps.dwCaps); 438 #endif 392 439 393 440 newsurf = new OS2IDirectDrawSurface(me, lpDDSurfaceDesc2); 394 441 395 442 if(newsurf == NULL) 396 return(DDERR_OUTOFMEMORY); 397 398 newsurf->Vtbl.AddRef((IDirectDrawSurface *)newsurf); 399 rc = newsurf->GetLastError(); 400 if(rc != DD_OK) 401 { 402 WriteLog("Error createing Surface\n\n"); 403 *lplpDD = NULL; 404 delete newsurf; 443 { 444 rc =DDERR_OUTOFMEMORY; 405 445 } 406 446 else 407 *lplpDD = (IDirectDrawSurface4 *)newsurf; 408 409 WriteLog("New Surface created at %08X\n\n", newsurf); 447 { 448 newsurf->Vtbl.AddRef((IDirectDrawSurface *)newsurf); 449 rc = newsurf->GetLastError(); 450 if(rc != DD_OK) 451 { 452 WriteLog("Error createing Surface\n\n"); 453 *lplpDD = NULL; 454 455 delete newsurf; 456 } 457 else 458 *lplpDD = (IDirectDrawSurface4 *)newsurf; 459 460 WriteLog("New Surface created at %08X\n\n", newsurf); 461 } 462 463 ODIN_FS_END 410 464 411 465 return(rc); … … 416 470 { 417 471 #ifdef DEBUG 418 WriteLog("DuplicateSurface \n");472 WriteLog("DuplicateSurface NIY\n"); 419 473 #endif 420 474 return(DD_OK); … … 425 479 { 426 480 #ifdef DEBUG 427 WriteLog("DuplicateSurface \n");481 WriteLog("DuplicateSurface4 NIY\n"); 428 482 #endif 429 483 … … 454 508 } 455 509 510 511 ODIN_FS_BEGIN 456 512 457 513 // Setting up the surface … … 481 537 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesDive[0].iBits; 482 538 if(!lpDDEnumModesCallback(&DDSurfAct,lpContext)) 539 { 540 {ODIN_FS_END 483 541 return (DD_OK); 542 } 484 543 } 485 544 // Don't know the flag for Mode X so we skip reporting it … … 550 609 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesDive[0].iBits; 551 610 if(!lpDDEnumModesCallback(&DDSurfAct,lpContext)) 611 { 612 {ODIN_FS_END 552 613 return (DD_OK); 614 } 553 615 } 554 616 // Don't know the flag for Mode X so we skip reporting it … … 619 681 620 682 if (lpDDSurfaceDesc->dwFlags & !(DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT)) 683 { 684 {ODIN_FS_END 621 685 return(DDERR_INVALIDPARAMS); 686 } 622 687 623 688 iMode = 2; … … 652 717 } 653 718 719 ODIN_FS_END 720 654 721 return(DD_OK); 655 722 } … … 665 732 666 733 #ifdef DEBUG 667 WriteLog("EnumDisplayModes4 \n");734 WriteLog("EnumDisplayModes4 NIY\n"); 668 735 #endif 669 736 return(DD_OK); … … 674 741 { 675 742 #ifdef DEBUG 676 WriteLog("EnumSurfaces \n");743 WriteLog("EnumSurfaces NIY\n"); 677 744 #endif 678 745 … … 684 751 { 685 752 #ifdef DEBUG 686 WriteLog("EnumSurfaces4 \n");753 WriteLog("EnumSurfaces4 NIY\n"); 687 754 #endif 688 755 … … 694 761 { 695 762 #ifdef DEBUG 696 WriteLog("FlipToGDISurface \n");763 WriteLog("FlipToGDISurface NIY\n"); 697 764 #endif 698 765 … … 718 785 719 786 // Clear structure so we only have to set the supported flags 787 788 ODIN_FS_BEGIN 720 789 memset(lpDDDriverCaps,0,sizeof(DDCAPS)); 790 ODIN_FS_END 721 791 722 792 // Reset the size … … 1063 1133 { 1064 1134 #ifdef DEBUG 1065 WriteLog("GetGDISurface \n");1135 WriteLog("GetGDISurface NYI\n"); 1066 1136 #endif 1067 1137 … … 1073 1143 { 1074 1144 #ifdef DEBUG 1075 WriteLog("GetGDISurface \n");1145 WriteLog("GetGDISurface NYI\n"); 1076 1146 #endif 1077 1147 … … 1089 1159 if(NULL==lpdwFreq) 1090 1160 return(DDERR_INVALIDPARAMS); 1161 1162 ODIN_FS_BEGIN 1091 1163 1092 1164 if(DD_OK==DrawWaitForVerticalBlank(This, dwFlags, 0)) … … 1110 1182 *lpdwFreq = 70; 1111 1183 } 1184 1185 ODIN_FS_END 1186 1112 1187 return(DD_OK); 1113 1188 } … … 1140 1215 HRESULT __stdcall DrawGetVerticalBlankStatus(THIS , LPBOOL lpbIsInVB) 1141 1216 { 1217 int rc; 1142 1218 #ifdef DEBUG 1143 1219 WriteLog("GetVerticalBlankStatus\n"); … … 1145 1221 if(NULL==lpbIsInVB) 1146 1222 return(DDERR_INVALIDPARAMS); 1147 if(0==io_init1()) // try to get IOPL for the thread 1223 1224 ODIN_FS_BEGIN 1225 rc = io_init1(); 1226 ODIN_FS_END 1227 1228 if(0==rc) // try to get IOPL for the thread 1148 1229 { 1149 1230 *lpbIsInVB = (c_inb1(0x3da)&0x08)!=0; 1150 io_exit1(); // reset IOPL 1231 ODIN_FS_BEGIN 1232 io_exit1(); // reset IOPL 1233 ODIN_FS_END 1151 1234 return(DD_OK); 1152 1235 } … … 1186 1269 me->hwndClient = hwndClient; 1187 1270 #if 0 1188 OS2DDSubclassWindow(hwndClient);1271 OS2DDSubclassWindow(hwndClient); 1189 1272 #endif 1190 1273 return(DD_OK); … … 1200 1283 OS2IDirectDraw *me = (OS2IDirectDraw *)This; 1201 1284 1202 #ifdef DEBUG 1203 WriteLog("SetDisplayMode2 to %dx%d with %d bits colors\n", dwWidth, dwHeight, dwBPP); 1204 #endif 1285 #ifdef DEBUG 1286 WriteLog("SetDisplayMode2 to %dx%d with %d bits colors\n", dwWidth, dwHeight, dwBPP); 1287 #endif 1288 1205 1289 me->screenwidth = dwWidth; 1206 1290 me->screenheight = dwHeight; … … 1247 1331 { 1248 1332 HRESULT rc; 1333 int rci; 1334 1249 1335 #ifdef DEBUG 1250 1336 WriteLog("WaitForVerticalBlank\n"); … … 1254 1340 return (DDERR_UNSUPPORTED); 1255 1341 1256 if(io_init1()) // try to get IOPL for the thread 1342 ODIN_FS_BEGIN 1343 rci = io_init1(); 1344 ODIN_FS_END 1345 1346 if(rci) // try to get IOPL for the thread 1257 1347 return (DDERR_UNSUPPORTED); // we failed so return error that we don't support this 1258 1348 … … 1283 1373 } 1284 1374 1285 io_exit1(); 1375 ODIN_FS_BEGIN 1376 io_exit1(); 1377 ODIN_FS_END 1286 1378 1287 1379 return (rc); … … 1344 1436 { 1345 1437 #ifdef DEBUG 1346 WriteLog("GetSurfaceFromDC Unimplemented Stub\n");1438 WriteLog("GetSurfaceFromDC NYI\n"); 1347 1439 #endif 1348 1440 … … 1379 1471 if(NULL==lpdddi) 1380 1472 return DDERR_INVALIDPARAMS; 1473 1474 ODIN_FS_BEGIN 1381 1475 1382 1476 memset( lpdddi, … … 1388 1482 strcpy( lpdddi->szDescription, 1389 1483 "ODIN DD Emulation Driver"); 1484 1485 ODIN_FS_END 1486 1390 1487 return(DD_OK); 1391 1488 } … … 1396 1493 DWORD dwVType, dwVSize; 1397 1494 HKEY hkDirectDraw2; 1495 1496 ODIN_FS_BEGIN 1398 1497 1399 1498 if (bScale) … … 1410 1509 bScale = FALSE; 1411 1510 } 1412 } 1413 //****************************************************************************** 1414 //****************************************************************************** 1415 1511 1512 ODIN_FS_END 1513 } 1514 //****************************************************************************** 1515 //****************************************************************************** 1516
Note:
See TracChangeset
for help on using the changeset viewer.