DXGL r739 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r738‎ | r739 | r740 >
Date:06:00, 3 September 2017
Author:admin
Status:new
Tags:
Comment:
Fix up Source Color Key Override test.
Modified paths:
  • /dxgltest/Tests2D.cpp (modified) (history)
  • /dxgltest/surfacegen.cpp (modified) (history)

Diff [purge]

Index: dxgltest/Tests2D.cpp
@@ -936,14 +936,13 @@
937937 r1.bottom = 7;
938938 break;
939939 }
940 - //sprites[0].surface->Blt(NULL, sprites[2].surface, NULL, DDBLT_WAIT|DDBLT_KEYSRCOVERRIDE, &bltfx);
941 - sprites[0].surface->Blt(NULL, sprites[2].surface, NULL, DDBLT_WAIT, NULL);
 940+ sprites[0].surface->Blt(NULL, sprites[2].surface, NULL, DDBLT_WAIT|DDBLT_KEYSRCOVERRIDE, &bltfx);
942941 temp1->GetDC(&hDCdest);
943942 sprites[0].surface->GetDC(&hDCsrc);
944943 if (ddver > 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
945944 else ddsd.dwSize = sizeof(DDSURFACEDESC);
946945 temp1->GetSurfaceDesc(&ddsd);
947 - StretchBlt(hDCdest, ((ddsd.dwWidth / 2) - 128), ((ddsd.dwHeight / 2) - 128), 256, 256,
 946+ StretchBlt(hDCdest, ((ddsd.dwWidth / 2) - 128), ((ddsd.dwHeight / 2) + 128), 256, -256,
948947 hDCsrc, 0, 0, r1.right, r1.bottom, SRCCOPY);
949948 sprites[0].surface->ReleaseDC(hDCsrc);
950949 SetBkColor(hDCdest, RGB(0, 0, 255));
@@ -950,7 +949,7 @@
951950 SetTextColor(hDCdest, RGB(255, 255, 255));
952951 _tcscpy(message, _T("Source Color Key Override Test"));
953952 TextOut(hDCdest, 0, 0, message, _tcslen(message));
954 - _stprintf(message, _T("Color: 0x%08X"), bltfx.ddckSrcColorkey.dwColorSpaceHighValue);
 953+ _stprintf(message, _T("Color: 0x%08X "), bltfx.ddckSrcColorkey.dwColorSpaceHighValue);
955954 TextOut(hDCdest, 0, 16, message, _tcslen(message));
956955 temp1->ReleaseDC(hDCdest);
957956 if (backbuffers) temp1->Release();
Index: dxgltest/surfacegen.cpp
@@ -1287,7 +1287,7 @@
12881288 {
12891289 int x, y;
12901290 DWORD i;
1291 - if (!index)
 1291+ if (index)
12921292 {
12931293 switch (bpp)
12941294 {
@@ -1296,11 +1296,12 @@
12971297 {
12981298 for (int x = 0; x < 16; x++)
12991299 {
1300 - i = x + (y << 4);
 1300+ i = x + ((15 - y) << 4);
13011301 buffer[x + (ddsd.lPitch*y)] = i;
13021302 }
13031303 }
13041304 break;
 1305+ case 15:
13051306 for (int y = 1; y < 8; y++)
13061307 {
13071308 for (int x = 0; x < 32; x++)
@@ -1307,30 +1308,31 @@
13081309 {
13091310 switch (y)
13101311 {
1311 - case 1:
 1312+ case 7:
13121313 i = x << 10;
13131314 break;
1314 - case 2:
 1315+ case 6:
13151316 i = x << 5;
13161317 break;
1317 - case 3:
 1318+ case 5:
13181319 i = x;
13191320 break;
13201321 case 4:
13211322 i = x + (x << 5);
13221323 break;
1323 - case 5:
 1324+ case 3:
13241325 i = x + (x << 10);
13251326 break;
1326 - case 6:
 1327+ case 2:
13271328 i = (x << 5) + (x << 10);
13281329 break;
1329 - case 7:
 1330+ case 1:
13301331 default:
13311332 i = x + (x << 5) + (x << 10);
13321333 break;
13331334 }
1334 - buffer[(x * 2) + (ddsd.lPitch*(y - 1))] = i;
 1335+ buffer[(x * 2) + (ddsd.lPitch*(y - 1))] = (char)i;
 1336+ buffer[((x * 2) + (ddsd.lPitch*(y - 1))) + 1] = (char)(i >> 8);
13351337 }
13361338 }
13371339 break;
@@ -1341,31 +1343,31 @@
13421344 {
13431345 switch (y)
13441346 {
1345 - case 1:
 1347+ case 7:
13461348 i = (x >> 1) << 11;
13471349 break;
1348 - case 2:
 1350+ case 6:
13491351 i = x << 5;
13501352 break;
1351 - case 3:
 1353+ case 5:
13521354 i = x >> 1;
13531355 break;
13541356 case 4:
13551357 i = (x >> 1) + (x << 5);
13561358 break;
1357 - case 5:
 1359+ case 3:
13581360 i = (x >> 1) + ((x >> 1) << 11);
13591361 break;
1360 - case 6:
 1362+ case 2:
13611363 i = (x << 5) + ((x >> 1) << 11);
13621364 break;
1363 - case 7:
 1365+ case 1:
13641366 default:
13651367 i = (x >> 1) + (x << 5) + ((x >> 1) << 11);
13661368 break;
13671369 }
13681370 buffer[(x * 2) + (ddsd.lPitch*(y - 1))] = (char)i;
1369 - buffer[((x * 2) + (ddsd.lPitch*(y - 1))) + 1] = (char)i >> 8;
 1371+ buffer[((x * 2) + (ddsd.lPitch*(y - 1))) + 1] = (char)(i >> 8);
13701372 }
13711373 }
13721374 break;
@@ -1376,32 +1378,32 @@
13771379 {
13781380 switch (y)
13791381 {
1380 - case 1:
 1382+ case 7:
13811383 i = x << 16;
13821384 break;
1383 - case 2:
 1385+ case 6:
13841386 i = x << 8;
13851387 break;
1386 - case 3:
 1388+ case 5:
13871389 i = x;
13881390 break;
13891391 case 4:
13901392 i = x + (x << 8);
13911393 break;
1392 - case 5:
 1394+ case 3:
13931395 i = x + (x << 16);
13941396 break;
1395 - case 6:
 1397+ case 2:
13961398 i = (x << 8) + (x << 16);
13971399 break;
1398 - case 7:
 1400+ case 1:
13991401 default:
14001402 i = x + (x << 8) + (x << 16);
14011403 break;
14021404 }
14031405 buffer[(x * 3) + (ddsd.lPitch*(y - 1))] = (char)i;
1404 - buffer[((x * 3) + (ddsd.lPitch*(y - 1))) + 1] = (char)i >> 8;
1405 - buffer[((x * 3) + (ddsd.lPitch*(y - 1))) + 2] = (char)i >> 16;
 1406+ buffer[((x * 3) + (ddsd.lPitch*(y - 1))) + 1] = (char)(i >> 8);
 1407+ buffer[((x * 3) + (ddsd.lPitch*(y - 1))) + 2] = (char)(i >> 16);
14061408 }
14071409 }
14081410 break;
@@ -1413,32 +1415,32 @@
14141416 {
14151417 switch (y)
14161418 {
1417 - case 1:
 1419+ case 7:
14181420 i = x << 16;
14191421 break;
1420 - case 2:
 1422+ case 6:
14211423 i = x << 8;
14221424 break;
1423 - case 3:
 1425+ case 5:
14241426 i = x;
14251427 break;
14261428 case 4:
14271429 i = x + (x << 8);
14281430 break;
1429 - case 5:
 1431+ case 3:
14301432 i = x + (x << 16);
14311433 break;
1432 - case 6:
 1434+ case 2:
14331435 i = (x << 8) + (x << 16);
14341436 break;
1435 - case 7:
 1437+ case 1:
14361438 default:
14371439 i = x + (x << 8) + (x << 16);
14381440 break;
14391441 }
14401442 buffer[(x * 4) + (ddsd.lPitch*(y - 1))] = (char)i;
1441 - buffer[((x * 4) + (ddsd.lPitch*(y - 1))) + 1] = (char)i >> 8;
1442 - buffer[((x * 4) + (ddsd.lPitch*(y - 1))) + 2] = (char)i >> 16;
 1443+ buffer[((x * 4) + (ddsd.lPitch*(y - 1))) + 1] = (char)(i >> 8);
 1444+ buffer[((x * 4) + (ddsd.lPitch*(y - 1))) + 2] = (char)(i >> 16);
14431445 buffer[((x * 4) + (ddsd.lPitch*(y - 1))) + 3] = 0;
14441446 }
14451447 }
@@ -1454,7 +1456,7 @@
14551457 {
14561458 for (int x = 0; x < 16; x++)
14571459 {
1458 - i = ((x + (y << 4)) + 128) & 255;
 1460+ i = ((x + ((15 - y) << 4)) + 128) & 255;
14591461 buffer[x + (ddsd.lPitch*y)] = i;
14601462 }
14611463 }
@@ -1466,30 +1468,31 @@
14671469 {
14681470 switch (y)
14691471 {
1470 - case 7:
1471 - i = (32 - x) << 10;
 1472+ case 1:
 1473+ i = (31 - x) << 10;
14721474 break;
1473 - case 6:
1474 - i = (32 - x) << 5;
 1475+ case 2:
 1476+ i = (31 - x) << 5;
14751477 break;
 1478+ case 3:
 1479+ i = (31 - x);
 1480+ break;
14761481 case 5:
1477 - i = (32 - x);
 1482+ i = (31 - x) + ((31 - x) << 5);
14781483 break;
14791484 case 4:
1480 - i = x + ((32 - x) << 5);
 1485+ i = (31 - x) + ((31 - x) << 10);
14811486 break;
1482 - case 3:
1483 - i = x + ((32 - x) << 10);
 1487+ case 6:
 1488+ i = ((31 - x) << 5) + ((31 - x) << 10);
14841489 break;
1485 - case 2:
1486 - i = ((32 - x) << 5) + ((32 - x) << 10);
1487 - break;
1488 - case 1:
 1490+ case 7:
14891491 default:
1490 - i = (32 - x) + ((32 - x) << 5) + ((32 - x) << 10);
 1492+ i = (31 - x) + ((31 - x) << 5) + ((31 - x) << 10);
14911493 break;
14921494 }
1493 - buffer[(x * 2) + (ddsd.lPitch*(y - 1))] = i;
 1495+ buffer[(x * 2) + (ddsd.lPitch*(y - 1))] = (char)i;
 1496+ buffer[((x * 2) + (ddsd.lPitch*(y - 1))) + 1] = (char)(i >> 8);
14941497 }
14951498 }
14961499 break;
@@ -1500,30 +1503,31 @@
15011504 {
15021505 switch (y)
15031506 {
1504 - case 7:
1505 - i = ((64 - x) >> 1) << 11;
 1507+ case 1:
 1508+ i = ((63 - x) >> 1) << 11;
15061509 break;
1507 - case 6:
1508 - i = (64 - x) << 5;
 1510+ case 2:
 1511+ i = (63 - x) << 5;
15091512 break;
 1513+ case 3:
 1514+ i = (63 - x) >> 1;
 1515+ break;
15101516 case 5:
1511 - i = (64 - x) >> 1;
 1517+ i = ((63 - x) >> 1) + ((63 - x) << 5);
15121518 break;
15131519 case 4:
1514 - i = ((64 - x) >> 1) + ((64 - x) << 5);
 1520+ i = ((63 - x) >> 1) + (((63 - x) >> 1) << 11);
15151521 break;
1516 - case 3:
1517 - i = ((64 - x) >> 1) + (((64 - x) >> 1) << 11);
 1522+ case 6:
 1523+ i = ((63 - x) << 5) + (((63 - x) >> 1) << 11);
15181524 break;
1519 - case 2:
1520 - i = ((64 - x) << 5) + (((64 - x) >> 1) << 11);
1521 - break;
1522 - case 1:
 1525+ case 7:
15231526 default:
1524 - i = ((64 - x) >> 1) + ((64 - x) << 5) + (((64 - x) >> 1) << 11);
 1527+ i = ((63 - x) >> 1) + ((63 - x) << 5) + (((63 - x) >> 1) << 11);
15251528 break;
15261529 }
1527 - buffer[(x * 2) + (ddsd.lPitch*(y - 1))] = i;
 1530+ buffer[(x * 2) + (ddsd.lPitch*(y - 1))] = (char)i;
 1531+ buffer[((x * 2) + (ddsd.lPitch*(y - 1))) + 1] = (char)(i >> 8);
15281532 }
15291533 }
15301534 break;
@@ -1534,32 +1538,32 @@
15351539 {
15361540 switch (y)
15371541 {
1538 - case 7:
1539 - i = (256 - x) << 16;
 1542+ case 1:
 1543+ i = (255 - x) << 16;
15401544 break;
1541 - case 6:
1542 - i = (256 - x) << 8;
 1545+ case 2:
 1546+ i = (255 - x) << 8;
15431547 break;
 1548+ case 3:
 1549+ i = (255 - x);
 1550+ break;
15441551 case 5:
1545 - i = (256 - x);
 1552+ i = (255 - x) + ((255 - x) << 8);
15461553 break;
15471554 case 4:
1548 - i = (256 - x) + ((256 - x) << 8);
 1555+ i = (255 - x) + ((255 - x) << 16);
15491556 break;
1550 - case 3:
1551 - i = (256 - x) + ((256 - x) << 16);
 1557+ case 6:
 1558+ i = ((255 - x) << 8) + ((255 - x) << 16);
15521559 break;
1553 - case 2:
1554 - i = ((256 - x) << 8) + ((256 - x) << 16);
1555 - break;
1556 - case 1:
 1560+ case 7:
15571561 default:
1558 - i = (256 - x) + ((256 - x) << 8) + ((256 - x) << 16);
 1562+ i = (255 - x) + ((255 - x) << 8) + ((255 - x) << 16);
15591563 break;
15601564 }
15611565 buffer[(x * 3) + (ddsd.lPitch*(y - 1))] = (char)i;
1562 - buffer[((x * 3) + (ddsd.lPitch*(y - 1))) + 1] = (char)i >> 8;
1563 - buffer[((x * 3) + (ddsd.lPitch*(y - 1))) + 2] = (char)i >> 16;
 1566+ buffer[((x * 3) + (ddsd.lPitch*(y - 1))) + 1] = (char)(i >> 8);
 1567+ buffer[((x * 3) + (ddsd.lPitch*(y - 1))) + 2] = (char)(i >> 16);
15641568 }
15651569 }
15661570 break;
@@ -1571,32 +1575,32 @@
15721576 {
15731577 switch (y)
15741578 {
1575 - case 7:
1576 - i = (256 - x) << 16;
 1579+ case 1:
 1580+ i = (255 - x) << 16;
15771581 break;
1578 - case 6:
1579 - i = (256 - x) << 8;
 1582+ case 2:
 1583+ i = (255 - x) << 8;
15801584 break;
 1585+ case 3:
 1586+ i = (255 - x);
 1587+ break;
15811588 case 5:
1582 - i = (256 - x);
 1589+ i = (255 - x) + ((255 - x) << 8);
15831590 break;
15841591 case 4:
1585 - i = (256 - x) + ((256 - x) << 8);
 1592+ i = (255 - x) + ((255 - x) << 16);
15861593 break;
1587 - case 3:
1588 - i = (256 - x) + ((256 - x) << 16);
 1594+ case 6:
 1595+ i = ((255 - x) << 8) + ((255 - x) << 16);
15891596 break;
1590 - case 2:
1591 - i = ((256 - x) << 8) + ((256 - x) << 16);
1592 - break;
1593 - case 1:
 1597+ case 7:
15941598 default:
1595 - i = (256 - x) + ((256 - x) << 8) + ((256 - x) << 16);
 1599+ i = (255 - x) + ((255 - x) << 8) + ((255 - x) << 16);
15961600 break;
15971601 }
15981602 buffer[(x * 4) + (ddsd.lPitch*(y - 1))] = (char)i;
1599 - buffer[((x * 4) + (ddsd.lPitch*(y - 1))) + 1] = (char)i >> 8;
1600 - buffer[((x * 4) + (ddsd.lPitch*(y - 1))) + 2] = (char)i >> 16;
 1603+ buffer[((x * 4) + (ddsd.lPitch*(y - 1))) + 1] = (char)(i >> 8);
 1604+ buffer[((x * 4) + (ddsd.lPitch*(y - 1))) + 2] = (char)(i >> 16);
16011605 buffer[((x * 4) + (ddsd.lPitch*(y - 1))) + 3] = 0;
16021606 }
16031607 }