comparison Render.cpp @ 2475:acac52e9e36a

remove DirectX11.cpp/.h for VS2010, MatrixMultiply and other
author Ritor1
date Thu, 21 Aug 2014 11:24:51 +0600
parents b054ea5daf45
children 0683c0a38282
comparison
equal deleted inserted replaced
2474:273279353509 2475:acac52e9e36a
34 #include "Lights.h" 34 #include "Lights.h"
35 #include "Level/Decoration.h" 35 #include "Level/Decoration.h"
36 #include "Vis.h" 36 #include "Vis.h"
37 #include "Registry.h" 37 #include "Registry.h"
38 #include "Weather.h" 38 #include "Weather.h"
39 #include "MMT.h"
39 40
40 41
41 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") 42 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib")
42 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") 43 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib")
43 44
232 233
233 void Render::RenderTerrainD3D() // New function 234 void Render::RenderTerrainD3D() // New function
234 { 235 {
235 int v6; // ecx@8 236 int v6; // ecx@8
236 struct Polygon *pTilePolygon; // ebx@8 237 struct Polygon *pTilePolygon; // ebx@8
237 // float Light_tile_dist; 238 float Light_tile_dist;
238 239
239 //warning: the game uses CW culling by default, ccw is incosistent 240 //warning: the game uses CW culling by default, ccw is incosistent
240 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); 241 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW);
241 242
242 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ 243 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ
363 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); 364 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f);
364 if ( norm_idx < 0 || norm_idx > uNumTerrainNormals - 1 ) 365 if ( norm_idx < 0 || norm_idx > uNumTerrainNormals - 1 )
365 norm = 0; 366 norm = 0;
366 else 367 else
367 norm = &pTerrainNormals[norm_idx]; 368 norm = &pTerrainNormals[norm_idx];
369 if (for_refactoring)
370 {
371 MessageBoxA(nullptr, "Ritor1: function StackLights_TerrainFace needed refactoring and result - slows", "", 0);
372 __debugbreak();
373 }
368 //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows 374 //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows
369 //pDecalBuilder->_49BE8A(pTilePolygon, norm, &Light_tile_dist, array_50AC10, 4, 1); 375 //pDecalBuilder->_49BE8A(pTilePolygon, norm, &Light_tile_dist, array_50AC10, 4, 1);
370 //unsigned int a5 = 4; 376 //unsigned int a5 = 4;
371 //---------------------------------------------------------------------------- 377 //----------------------------------------------------------------------------
372 378
782 { 788 {
783 v7 = strlen(ddDevId.szDescription); 789 v7 = strlen(ddDevId.szDescription);
784 v20.pDDraw4DevDesc = new char[v7 + 1]; 790 v20.pDDraw4DevDesc = new char[v7 + 1];
785 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); 791 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription);
786 } 792 }
787 memset(&ddsCaps, 0, 0x10u); 793 memset(&ddsCaps, 0, sizeof(ddsCaps));
788 if (FAILED(pDirectDraw4->GetAvailableVidMem(&ddsCaps, (LPDWORD)&v20.uVideoMem, (LPDWORD)&uFreeVideoMem))) 794 if (FAILED(pDirectDraw4->GetAvailableVidMem(&ddsCaps, (LPDWORD)&v20.uVideoMem, (LPDWORD)&uFreeVideoMem)))
789 v20.uVideoMem = 0; 795 v20.uVideoMem = 0;
790 memset(&v10, 0, 0x7Cu); 796 memset(&v10, 0, sizeof(v10));
791 v10.dwSize = 124; 797 v10.dwSize = 124;
792 v10.dwFlags = 6; 798 v10.dwFlags = 6;
793 v10.dwHeight = window->GetWidth(); 799 v10.dwHeight = window->GetWidth();
794 v10.dwWidth = window->GetHeight(); 800 v10.dwWidth = window->GetHeight();
795 v10.ddpfPixelFormat.dwSize = 32; 801 v10.ddpfPixelFormat.dwSize = 32;
1336 { 1342 {
1337 DWORD v26; // [sp-4h] [bp-DCh]@30 1343 DWORD v26; // [sp-4h] [bp-DCh]@30
1338 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 1344 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37
1339 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 1345 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11
1340 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 1346 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28
1341 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 1347 IDirectDrawClipper *lpddclipper; // [sp+C4h] [bp-14h]@18
1342 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 1348 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1
1343 1349
1344 auto hWnd = window->GetApiHandle(); 1350 auto hWnd = window->GetApiHandle();
1345 int game_width = window->GetWidth(); 1351 int game_width = window->GetWidth();
1346 int game_height = window->GetHeight(); 1352 int game_height = window->GetHeight();
1431 pHost->Release(); 1437 pHost->Release();
1432 pHost = NULL; 1438 pHost = NULL;
1433 } 1439 }
1434 return 0; 1440 return 0;
1435 } 1441 }
1436 if ( pHost->CreateClipper(0, &v30, 0) ) 1442 //Создание отсекателя DirectDraw
1443 if ( pHost->CreateClipper(0, &lpddclipper, NULL) )
1437 { 1444 {
1438 sprintf(pErrorMessage, "Init - Failed to create clipper.\n"); 1445 sprintf(pErrorMessage, "Init - Failed to create clipper.\n");
1439 if (pBackBuffer) 1446 if (pBackBuffer)
1440 { 1447 {
1441 pBackBuffer->Release(); 1448 pBackBuffer->Release();
1451 pHost->Release(); 1458 pHost->Release();
1452 pHost = NULL; 1459 pHost = NULL;
1453 } 1460 }
1454 return 0; 1461 return 0;
1455 } 1462 }
1456 v30->SetHWnd(0, hWnd); 1463 lpddclipper->SetHWnd(0, hWnd);
1457 pFrontBuffer->SetClipper(v30); 1464 pFrontBuffer->SetClipper(lpddclipper);
1458 1465
1459 v30->Release(); 1466 lpddclipper->Release();
1460 v30 = NULL; 1467 lpddclipper = NULL;
1468 //
1461 1469
1462 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); 1470 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D);
1463 1471
1464 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; 1472 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
1465 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; 1473 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
1599 return 0; 1607 return 0;
1600 } 1608 }
1601 1609
1602 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); 1610 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2));
1603 ddsd2.dwSize = sizeof(DDSURFACEDESC2); 1611 ddsd2.dwSize = sizeof(DDSURFACEDESC2);
1612 //Подключение полей с достоверными данными
1604 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; 1613 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
1614 //Запрос сложной структуры с возможностью переключения
1605 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; 1615 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
1616 //Присвоение полю счётчика задних буферов значения 1
1606 ddsd2.dwBackBufferCount = 1; 1617 ddsd2.dwBackBufferCount = 1;
1607 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, NULL) ) 1618 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, NULL) )
1608 { 1619 {
1609 sprintf(pErrorMessage, "Init - Failed to create front buffer.\n"); 1620 sprintf(pErrorMessage, "Init - Failed to create front buffer.\n");
1610 if (pHost) 1621 if (pHost)
1615 return 0; 1626 return 0;
1616 } 1627 }
1617 //a3a = &pBackBuffer; 1628 //a3a = &pBackBuffer;
1618 //v14 = *v34; 1629 //v14 = *v34;
1619 memset(&v27, 0, sizeof(DDSCAPS2)); 1630 memset(&v27, 0, sizeof(DDSCAPS2));
1631
1620 v27.dwCaps = DDSCAPS_BACKBUFFER; 1632 v27.dwCaps = DDSCAPS_BACKBUFFER;
1621 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); 1633 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer);
1622 //hWnda = &pDirect3D; 1634 //hWnda = &pDirect3D;
1623 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); 1635 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D);
1636
1624 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) 1637 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer)))
1625 { 1638 {
1626 sprintf(pErrorMessage, "Init - Failed to get D3D interface.\n"); 1639 sprintf(pErrorMessage, "Init - Failed to get D3D interface.\n");
1627 if (pBackBuffer) 1640 if (pBackBuffer)
1628 { 1641 {
1667 pHost = 0; 1680 pHost = 0;
1668 } 1681 }
1669 return 0; 1682 return 0;
1670 } 1683 }
1671 if ( uDeviceID == 2 || uDeviceID == 3 ) 1684 if ( uDeviceID == 2 || uDeviceID == 3 )
1672 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; 1685 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8;
1673 //uDeviceIDa = &pZBuffer; 1686 //uDeviceIDa = &pZBuffer;
1674 if (pHost->CreateSurface(&ddsd2, &pZBuffer, NULL) ) 1687 if (pHost->CreateSurface(&ddsd2, &pZBuffer, NULL) )
1675 { 1688 {
1676 sprintf(pErrorMessage, "Init - Failed to create z-buffer.\n"); 1689 sprintf(pErrorMessage, "Init - Failed to create z-buffer.\n");
1677 if (pBackBuffer) 1690 if (pBackBuffer)
1805 1818
1806 //----- (0049E444) -------------------------------------------------------- 1819 //----- (0049E444) --------------------------------------------------------
1807 unsigned int RenderD3D::GetDeviceCaps() 1820 unsigned int RenderD3D::GetDeviceCaps()
1808 { 1821 {
1809 unsigned int v1; // ebx@1 1822 unsigned int v1; // ebx@1
1810 //RenderD3D *v2; // edi@1
1811 IDirect3DDevice3 *v3; // eax@1
1812 unsigned int result; // eax@2 1823 unsigned int result; // eax@2
1813 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 1824 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1
1814 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 1825 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1
1815 1826
1816 v1 = 0; 1827 v1 = 0;
1817 //v2 = this; 1828
1818 memset(&halCaps, 0, 0xFCu); 1829 memset(&halCaps, 0, sizeof(halCaps));
1819 halCaps.dwSize = 252; 1830 halCaps.dwSize = sizeof(halCaps);
1820 memset(&refCaps, 0, 0xFCu); 1831
1821 v3 = this->pDevice; 1832 memset(&refCaps, 0, sizeof(refCaps));
1822 refCaps.dwSize = 252; 1833 refCaps.dwSize = sizeof(refCaps);
1823 if ( v3->GetCaps(&halCaps, &refCaps) ) 1834
1824 { 1835 if ( this->pDevice->GetCaps(&halCaps, &refCaps) )
1825 result = 1; 1836 result = 1;
1826 }
1827 else 1837 else
1828 { 1838 {
1829 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) ) 1839 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) )
1830 v1 = 2; 1840 v1 = 2;
1831 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ONE) ) 1841 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ONE) )
1832 v1 |= 4u; 1842 v1 |= 4;
1833 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ZERO) ) 1843 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ZERO) )
1834 v1 |= 8u; 1844 v1 |= 8;
1835 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) ) 1845 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) )
1836 v1 |= 0x10u; 1846 v1 |= 16;
1837 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_ONE) ) 1847 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_ONE) )
1838 v1 |= 0x20u; 1848 v1 |= 32;
1839 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) ) 1849 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) )
1840 v1 |= 0x40u; 1850 v1 |= 64;
1841 if ( halCaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY ) 1851 if ( halCaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY )
1842 v1 |= 0x80; 1852 v1 |= 128;
1843 result = v1; 1853 result = v1;
1844 } 1854 }
1845 return result; 1855 return result;
1846 } 1856 }
1847 1857
1861 } 1871 }
1862 1872
1863 //----- (0049E54D) -------------------------------------------------------- 1873 //----- (0049E54D) --------------------------------------------------------
1864 void RenderD3D::Present(bool bForceBlit) 1874 void RenderD3D::Present(bool bForceBlit)
1865 { 1875 {
1866 RECT v5; // [sp+18h] [bp-18h]@1 1876 RECT source_rect; // [sp+18h] [bp-18h]@1
1867 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 1877 struct tagPOINT Point; // [sp+28h] [bp-8h]@4
1868 1878
1869 v5.left = 0; 1879 source_rect.left = 0;
1870 v5.top = 0; 1880 source_rect.top = 0;
1871 v5.bottom = 480;//window->GetHeight(); //Ritor1: проблема с кнопкой "развернуть" 1881 source_rect.bottom = 480;//window->GetHeight(); //Ritor1: проблема с кнопкой "развернуть"
1872 v5.right = 640; //window->GetWidth(); 1882 source_rect.right = 640; //window->GetWidth();
1873 1883
1874 if (bWindowed || bForceBlit) 1884 if (bWindowed || bForceBlit)
1875 { 1885 {
1876 RECT rc; 1886 RECT dest_rect;
1877 GetClientRect(hWindow, &rc); 1887 GetClientRect(hWindow, &dest_rect);
1878 Point.y = 0; 1888 Point.y = 0;
1879 Point.x = 0; 1889 Point.x = 0;
1880 ClientToScreen(hWindow, &Point); 1890 ClientToScreen(hWindow, &Point);
1881 OffsetRect(&rc, Point.x, Point.y); 1891 OffsetRect(&dest_rect, Point.x, Point.y);
1882 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0);//Uninitialized memory access 1892 pFrontBuffer->Blt(&dest_rect, pBackBuffer, &source_rect, DDBLT_WAIT, NULL);
1883 } 1893 }
1884 else 1894 else
1885 pFrontBuffer->Flip(0, 1); 1895 pFrontBuffer->Flip(NULL, DDFLIP_WAIT);
1886 } 1896 }
1887 1897
1888 //----- (0049E5D4) -------------------------------------------------------- 1898 //----- (0049E5D4) --------------------------------------------------------
1889 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) 1899 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim)
1890 { 1900 {
1891 unsigned int v8; // edx@4
1892 unsigned int v9; // ebx@5 1901 unsigned int v9; // ebx@5
1893 unsigned int v10; // eax@5 1902 unsigned int v10; // eax@5
1894 DWORD v11; // edx@5 1903 DWORD v11; // edx@5
1895 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 1904 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1
1896 1905
1897 memset(&ddsd2, 0, 0x7Cu); 1906 memset(&ddsd2, 0, sizeof(ddsd2));
1898 ddsd2.dwSize = 0x7Cu; 1907 ddsd2.dwSize = sizeof(ddsd2);
1899 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; 1908 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
1900 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; 1909 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
1901 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; 1910 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
1902 ddsd2.dwHeight = uTextureHeight; 1911 ddsd2.dwHeight = uTextureHeight;
1903 ddsd2.dwWidth = uTextureWidth; 1912 ddsd2.dwWidth = uTextureWidth;
1904 if ( bMipmaps ) 1913 if ( bMipmaps )
1905 { 1914 {
1906 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) 1915 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth )
1907 { 1916 {
1908 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); 1917 ddsd2.dwMipMapCount = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim);
1909 LABEL_8: 1918 if ( ddsd2.dwMipMapCount )
1910 ddsd2.dwMipMapCount = v8; 1919 {
1911 if ( !v8 ) 1920 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT;
1912 goto LABEL_12; 1921 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
1913 goto LABEL_11; 1922 }
1923 goto LABEL_12;
1914 } 1924 }
1915 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) 1925 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim )
1916 { 1926 {
1917 v8 = GetMaxMipLevels(uMinDeviceTexDim); 1927 ddsd2.dwMipMapCount = GetMaxMipLevels(uMinDeviceTexDim);
1918 goto LABEL_8; 1928 if ( ddsd2.dwMipMapCount )
1929 {
1930 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT;
1931 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
1932 }
1933 goto LABEL_12;
1919 } 1934 }
1920 v9 = GetMaxMipLevels(uTextureWidth); 1935 v9 = GetMaxMipLevels(uTextureWidth);
1921 v10 = GetMaxMipLevels(uMinDeviceTexDim); 1936 v10 = GetMaxMipLevels(uMinDeviceTexDim);
1922 ddsd2.dwMipMapCount = v9 - v10; 1937 ddsd2.dwMipMapCount = v9 - v10;
1923 if ( v9 == v10 ) 1938 if ( v9 == v10 )
1928 goto LABEL_12; 1943 goto LABEL_12;
1929 } 1944 }
1930 } 1945 }
1931 else 1946 else
1932 ddsd2.dwMipMapCount = 1; 1947 ddsd2.dwMipMapCount = 1;
1933 LABEL_11:
1934 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; 1948 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT;
1935 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; 1949 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
1936 LABEL_12: 1950 LABEL_12:
1937 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; 1951 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16;
1938 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); 1952 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
2294 } 2308 }
2295 2309
2296 //----- (0049ED18) -------------------------------------------------------- 2310 //----- (0049ED18) --------------------------------------------------------
2297 void Render::PresentBlackScreen() 2311 void Render::PresentBlackScreen()
2298 { 2312 {
2299 IDirectDrawSurface *v2; // eax@3 2313 IDirectDrawSurface *lpddsback; // eax@3
2300 DDBLTFX v3; // [sp+4h] [bp-74h]@5 2314 DDBLTFX lpDDBltFx; // [sp+4h] [bp-74h]@5
2301 RECT x; // [sp+68h] [bp-10h]@3 2315 RECT dest_rect; // [sp+68h] [bp-10h]@3
2302 2316
2303 memset(&v3, 0, sizeof(DDBLTFX)); 2317 memset(&lpDDBltFx, 0, sizeof(DDBLTFX));
2304 GetWindowRect(window->GetApiHandle(), &x); 2318 lpDDBltFx.dwSize = sizeof(DDBLTFX);
2305 2319
2306 { 2320 GetWindowRect(window->GetApiHandle(), &dest_rect);
2307 v2 = (IDirectDrawSurface *)this->pBackBuffer4; 2321 lpddsback = (IDirectDrawSurface *)this->pBackBuffer4;
2308 } 2322
2309 2323 lpDDBltFx.dwFillColor = 0;
2310 v3.dwFillColor = 0; 2324 lpddsback->Blt(&dest_rect, NULL, NULL, DDBLT_COLORFILL, &lpDDBltFx);
2311 v3.dwSize = 100;
2312 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3);
2313 pRenderer->Present(); 2325 pRenderer->Present();
2314 } 2326 }
2315 2327
2316 //----- (0049EDB6) -------------------------------------------------------- 2328 //----- (0049EDB6) --------------------------------------------------------
2317 void Render::SavePCXScreenshot() 2329 void Render::SavePCXScreenshot()
2952 } 2964 }
2953 2965
2954 //----- (0049FD3A) -------------------------------------------------------- 2966 //----- (0049FD3A) --------------------------------------------------------
2955 void Render::_49FD3A_fullscreen() 2967 void Render::_49FD3A_fullscreen()
2956 { 2968 {
2957 RECT v5; // [sp+8h] [bp-10h]@6 2969 RECT src_rect; // [sp+8h] [bp-10h]@6
2958 2970
2959 if ( this->pRenderD3D ) 2971 if ( this->pRenderD3D )
2960 { 2972 {
2961 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) 2973 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST)
2962 pFrontBuffer4->Restore(); 2974 pFrontBuffer4->Restore();
2963 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) 2975 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST)
2964 pBackBuffer4->Restore(); 2976 pBackBuffer4->Restore();
2965 v5.top = 0; 2977 src_rect.top = 0;
2966 v5.bottom = window->GetHeight(); 2978 src_rect.bottom = window->GetHeight();
2967 v5.left = 0; 2979 src_rect.left = 0;
2968 v5.right = window->GetWidth(); 2980 src_rect.right = window->GetWidth();
2969 this->pBackBuffer4->BltFast(0, 0, this->pFrontBuffer4, &v5, 16); 2981 this->pBackBuffer4->BltFast(NULL, NULL, this->pFrontBuffer4, &src_rect, DDBLTFAST_WAIT);
2970 } 2982 }
2971 } 2983 }
2972 2984
2973 //----- (0049FDBF) -------------------------------------------------------- 2985 //----- (0049FDBF) --------------------------------------------------------
2974 void Render::CreateZBuffer() 2986 void Render::CreateZBuffer()
3132 } 3144 }
3133 3145
3134 //----- (004A597D) -------------------------------------------------------- 3146 //----- (004A597D) --------------------------------------------------------
3135 void Present_NoColorKey() 3147 void Present_NoColorKey()
3136 { 3148 {
3137 //unsigned __int16 *v0; // eax@4
3138 // unsigned __int16 *v1; // esi@4
3139 void *v2; // edi@4 3149 void *v2; // edi@4
3140 //signed int v4; // ebx@4
3141 //signed int v5; // ebx@6
3142 //void *v6; // edi@7
3143 //const void *v7; // esi@7
3144 // signed int v8; // ebx@8
3145 int v9; // eax@10 3150 int v9; // eax@10
3146 unsigned int v10; // esi@10 3151 unsigned int v10; // esi@10
3147 unsigned __int32 v11; // edi@10 3152 unsigned __int32 v11; // edi@10
3148 //int v12; // ecx@10
3149 unsigned int v13; // ebx@10 3153 unsigned int v13; // ebx@10
3150 // int v14; // eax@11
3151 // int v15; // eax@13
3152 // int v16; // eax@14
3153 // int v17; // eax@16
3154 // HRESULT v18; // eax@22
3155 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3 3154 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3
3156 //int v20; // [sp+88h] [bp-1Ch]@10
3157 int v21; // [sp+8Ch] [bp-18h]@10 3155 int v21; // [sp+8Ch] [bp-18h]@10
3158 __int32 v22; // [sp+90h] [bp-14h]@10 3156 __int32 v22; // [sp+90h] [bp-14h]@10
3159 //unsigned __int32 v23; // [sp+94h] [bp-10h]@10
3160 unsigned int v24; // [sp+98h] [bp-Ch]@4 3157 unsigned int v24; // [sp+98h] [bp-Ch]@4
3161 //unsigned int _this; // [sp+9Ch] [bp-8h]@10
3162 //LPVOID v26; // [sp+A0h] [bp-4h]@4
3163 3158
3164 int r_mask = 0xF800; 3159 int r_mask = 0xF800;
3165 int g_mask = 0x7E0; 3160 int g_mask = 0x7E0;
3166 int b_mask = 0x1F; 3161 int b_mask = 0x1F;
3167 3162
3168 //if ( !pRenderer->uNumSceneBegins ) 3163 //if ( !pRenderer->uNumSceneBegins )
3169 { 3164 {
3170 //if ( pRenderer->using_software_screen_buffer ) 3165 //if ( pRenderer->using_software_screen_buffer )
3171 //{ 3166 //{
3172 memset(&Dst, 0, 0x7Cu); 3167 memset(&Dst, 0, sizeof(Dst));
3173 Dst.dwSize = 124; 3168 Dst.dwSize = sizeof(Dst);
3174 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) 3169 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
3175 { 3170 {
3176 //v26 = Dst.lpSurface; 3171 //v26 = Dst.lpSurface;
3177 //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface; 3172 //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface;
3178 v24 = g_mask | b_mask | ((g_mask | b_mask) << 16); 3173 v24 = g_mask | b_mask | ((g_mask | b_mask) << 16);
3305 3300
3306 3301
3307 //----- (0049FFFB) -------------------------------------------------------- 3302 //----- (0049FFFB) --------------------------------------------------------
3308 bool Render::InitializeFullscreen() 3303 bool Render::InitializeFullscreen()
3309 { 3304 {
3310 //Render *v2; // esi@1
3311 //HWND v3; // ebx@1
3312 //void *v4; // eax@2
3313 //RenderD3D *v5; // eax@3
3314 //unsigned int v6; // edx@5
3315 RenderD3D__DevInfo *v7; // ecx@5 3305 RenderD3D__DevInfo *v7; // ecx@5
3316 bool v8; // eax@6 3306 bool v8; // eax@6
3317 //RenderD3D *v9; // ecx@13
3318 unsigned int v10; // eax@13 3307 unsigned int v10; // eax@13
3319 //RenderD3D *v11; // eax@25
3320 // HRESULT v12; // eax@25
3321 int v13; // ecx@25
3322 int v14; // eax@27
3323 signed int v15; // ebx@31 3308 signed int v15; // ebx@31
3324 //bool v16; // eax@35
3325 //char v17; // zf@35
3326 // IDirectDraw4 *v18; // eax@38
3327 // HRESULT v19; // eax@38
3328 //int *v20; // eax@39
3329 int *v22; // eax@42 3309 int *v22; // eax@42
3330 int v23; // ecx@42 3310 int v23; // ecx@42
3331 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 3311 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25
3332 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 3312 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40
3333 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 3313 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25
3334 // DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38
3335 //void *v28; // [sp+2FCh] [bp-10h]@2
3336 int v29; // [sp+308h] [bp-4h]@2 3314 int v29; // [sp+308h] [bp-4h]@2
3337 3315
3338 //__debugbreak(); // Nomad 3316 //__debugbreak(); // Nomad
3339 3317
3340 //v2 = this;
3341 this->using_software_screen_buffer = 0; 3318 this->using_software_screen_buffer = 0;
3342 //this->pColorKeySurface4 = 0; 3319 //this->pColorKeySurface4 = 0;
3343 this->pBackBuffer4 = nullptr; 3320 this->pBackBuffer4 = nullptr;
3344 this->pFrontBuffer4 = nullptr; 3321 this->pFrontBuffer4 = nullptr;
3345 this->pDirectDraw4 = nullptr; 3322 this->pDirectDraw4 = nullptr;
3426 pDirectDraw4 = nullptr; 3403 pDirectDraw4 = nullptr;
3427 Error("Direct3D renderer: The device doesn't support non-square textures."); 3404 Error("Direct3D renderer: The device doesn't support non-square textures.");
3428 } 3405 }
3429 //LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; 3406 //LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1;
3430 bRequiredTextureStagesAvailable = CheckTextureStages(); 3407 bRequiredTextureStagesAvailable = CheckTextureStages();
3431 memset(&halCaps, 0, 0xFCu); 3408
3432 halCaps.dwSize = 252; 3409 memset(&halCaps, 0, sizeof(halCaps));
3433 memset(&refCaps, 0, 0xFCu); 3410 halCaps.dwSize = sizeof(halCaps);
3434 //v11 = pRenderD3D; 3411
3435 refCaps.dwSize = 252; 3412 memset(&refCaps, 0, sizeof(refCaps));
3413 refCaps.dwSize = sizeof(refCaps);
3414
3436 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); 3415 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps));
3437 v13 = halCaps.dwMinTextureWidth; 3416
3417 uMinDeviceTextureDim = halCaps.dwMinTextureWidth;
3438 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) 3418 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight )
3439 v13 = halCaps.dwMinTextureHeight; 3419 uMinDeviceTextureDim = halCaps.dwMinTextureHeight;
3440 v14 = halCaps.dwMaxTextureWidth; 3420 uMinDeviceTextureDim = halCaps.dwMaxTextureWidth;
3441 uMinDeviceTextureDim = v13; 3421 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight )
3442 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) 3422 uMinDeviceTextureDim = halCaps.dwMaxTextureHeight;
3443 v14 = halCaps.dwMaxTextureHeight; 3423 if ( (unsigned int)uMinDeviceTextureDim < 4 )
3444 uMaxDeviceTextureDim = v14;
3445 if ( (unsigned int)v13 < 4 )
3446 uMinDeviceTextureDim = 4; 3424 uMinDeviceTextureDim = 4;
3447 v15 = 1; 3425 v15 = 1;
3448 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); 3426 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true));
3449 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); 3427 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true));
3450 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2)); 3428 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2));
3478 bColorKeySupported = v16; 3456 bColorKeySupported = v16;
3479 if ( !v17 ) 3457 if ( !v17 )
3480 bColorKeySupported = 0; 3458 bColorKeySupported = 0;
3481 if ( bColorKeySupported ) 3459 if ( bColorKeySupported )
3482 { 3460 {
3483 memset(&ddsd2, 0, 0x7Cu); 3461 memset(&ddsd2, 0, sizeof(ddsd2));
3462 ddsd2.dwSize = sizeof(ddsd2);
3484 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; 3463 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask;
3485 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; 3464 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue;
3486 v18 = pDirectDraw4;
3487 ddsd2.dwSize = 124;
3488 ddsd2.dwFlags = 65543; 3465 ddsd2.dwFlags = 65543;
3489 ddsd2.ddsCaps.dwCaps = 2112; 3466 ddsd2.ddsCaps.dwCaps = 2112;
3490 ddsd2.dwWidth = 640; 3467 ddsd2.dwWidth = 640;
3491 ddsd2.dwHeight = 480; 3468 ddsd2.dwHeight = 480;
3492 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, NULL)); 3469 ErrD3D(pDirectDraw4->CreateSurface(&ddsd2, &pColorKeySurface4, NULL));
3493 pBeforePresentFunction = Present_ColorKey; 3470 pBeforePresentFunction = Present_ColorKey;
3494 } 3471 }
3495 else*/ 3472 else*/
3496 { 3473 {
3497 pTargetSurface = nullptr; 3474 pTargetSurface = nullptr;
3498 pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32); 3475 pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32);
3499 if ( !pTargetSurface_unaligned 3476 if ( !pTargetSurface_unaligned )
3500 || (memset(&pDesc, 0, 0x7Cu), 3477 return 0;
3501 pDesc.dwSize = 124, 3478 memset(&pDesc, 0, sizeof(pDesc));
3502 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) 3479 pDesc.dwSize = sizeof(pDesc);
3480 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15) )
3503 return 0; 3481 return 0;
3504 pBackBuffer4->Unlock(NULL); 3482 pBackBuffer4->Unlock(NULL);
3505 v22 = (int *)pTargetSurface_unaligned + 4; 3483 v22 = (int *)pTargetSurface_unaligned + 4;
3506 v23 = (unsigned int)pDesc.lpSurface & 7; 3484 v23 = (unsigned int)pDesc.lpSurface & 7;
3507 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; 3485 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8;
3640 uMinDeviceTextureDim = v12; 3618 uMinDeviceTextureDim = v12;
3641 v13 = halCaps.dwMaxTextureWidth; 3619 v13 = halCaps.dwMaxTextureWidth;
3642 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) 3620 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight )
3643 v13 = halCaps.dwMaxTextureHeight; 3621 v13 = halCaps.dwMaxTextureHeight;
3644 uMaxDeviceTextureDim = v13; 3622 uMaxDeviceTextureDim = v13;
3645 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); 3623 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1));
3646 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); 3624 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1));
3647 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); 3625 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2));
3648 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); 3626 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0));
3649 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); 3627 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0));
3650 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); 3628 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
3651 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); 3629 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2));
3652 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); 3630 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2));
3653 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); 3631 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3));
3654 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); 3632 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2));
3655 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); 3633 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0));
3656 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); 3634 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2));
3657 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); 3635 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2));
3658 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); 3636 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0));
3659 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); 3637 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4));
3660 //} 3638 //}
3661 3639
3662 ddpfPrimarySuface.dwSize = 32; 3640 ddpfPrimarySuface.dwSize = 32;
3663 GetTargetPixelFormat(&ddpfPrimarySuface); 3641 GetTargetPixelFormat(&ddpfPrimarySuface);
3664 ParseTargetPixelFormat(); 3642 ParseTargetPixelFormat();
4240 } 4218 }
4241 4219
4242 //----- (004A139A) -------------------------------------------------------- 4220 //----- (004A139A) --------------------------------------------------------
4243 void Render::CreateDirectDrawPrimarySurface() 4221 void Render::CreateDirectDrawPrimarySurface()
4244 { 4222 {
4245 //Render *v1; // esi@1
4246 //int v2; // ebx@3
4247 // IDirectDraw2 *v3; // eax@3
4248 // HRESULT v4; // eax@3
4249 IDirectDrawSurface *pFrontBuffer; // eax@3 4223 IDirectDrawSurface *pFrontBuffer; // eax@3
4250 DDSCAPS2 *v6; // edx@3 4224 DDSCAPS2 *v6; // edx@3
4251 IDirectDraw4 *v7; // eax@4 4225 IDirectDraw4 *v7; // eax@4
4252 // HRESULT v8; // eax@4
4253 int v9; // ST14_4@5 4226 int v9; // ST14_4@5
4254 IDirectDrawSurface *v10; // ST10_4@5 4227 IDirectDrawSurface *v10; // ST10_4@5
4255 // HRESULT v11; // eax@5
4256 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 4228 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3
4257 // const char *v13; // [sp+0h] [bp-A0h]@0
4258 // int v14; // [sp+4h] [bp-9Ch]@0
4259 // unsigned int v15; // [sp+8h] [bp-98h]@0
4260 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 4229 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3
4261 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 4230 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4
4262 // int a4; // [sp+98h] [bp-8h]@3
4263 4231
4264 //v1 = this; 4232 //v1 = this;
4265 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || 4233 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
4266 //pVersion->pVersionInfo.dwMajorVersion != 4 ) 4234 //pVersion->pVersionInfo.dwMajorVersion != 4 )
4267 { 4235 {
4268 //v2 = 0; 4236 //v2 = 0;
4269 //this->field_4004C = 1; 4237 //this->field_4004C = 1;
4270 memset(&ddsd2, 0, 0x7Cu); 4238 memset(&ddsd2, 0, sizeof(ddsd2));
4271 v7 = this->pDirectDraw4; 4239 ddsd2.dwSize = sizeof(ddsd2);
4240
4272 ddsd2.dwBackBufferCount = 1; 4241 ddsd2.dwBackBufferCount = 1;
4273 ddsd2.dwSize = 0x7Cu;
4274 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; 4242 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
4275 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; 4243 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE;
4276 ErrD3D(v7->CreateSurface(&ddsd2, &pFrontBuffer4, NULL)); 4244 ErrD3D(this->pDirectDraw4->CreateSurface(&ddsd2, &pFrontBuffer4, NULL));
4277 pFrontBuffer = (IDirectDrawSurface *)this->pFrontBuffer4; 4245 pFrontBuffer = (IDirectDrawSurface *)this->pFrontBuffer4;
4278 ppBackBuffer = (IDirectDrawSurface **)&this->pBackBuffer4; 4246 ppBackBuffer = (IDirectDrawSurface **)&this->pBackBuffer4;
4279 } 4247 }
4280 /*else 4248 /*else
4281 { 4249 {
4306 } 4274 }
4307 4275
4308 //----- (004A14F4) -------------------------------------------------------- 4276 //----- (004A14F4) --------------------------------------------------------
4309 void Render::CreateClipper(HWND a2) 4277 void Render::CreateClipper(HWND a2)
4310 { 4278 {
4311 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); 4279 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, NULL));
4312 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); 4280 ErrD3D(pDDrawClipper->SetHWnd(0, a2));
4313 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); 4281 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper));
4314 } 4282 }
4315 4283
4316 //----- (004A15D8) -------------------------------------------------------- 4284 //----- (004A15D8) --------------------------------------------------------
4403 { 4371 {
4404 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); 4372 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr));
4405 } 4373 }
4406 4374
4407 //----- (004A194A) -------------------------------------------------------- 4375 //----- (004A194A) --------------------------------------------------------
4408 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) 4376 void Render::BltBackToFontFast(int a2, int a3, RECT *pSrcRect)
4409 { 4377 {
4410 IDirectDrawSurface *pFront; // eax@3 4378 IDirectDrawSurface *pFront; // eax@3
4411 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 4379 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3
4412 4380
4413 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) 4381 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
4418 /*else 4386 /*else
4419 { 4387 {
4420 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; 4388 pFront = (IDirectDrawSurface *)this->pFrontBuffer2;
4421 pBack = (IDirectDrawSurface *)this->pBackBuffer2; 4389 pBack = (IDirectDrawSurface *)this->pBackBuffer2;
4422 }*/ 4390 }*/
4423 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); 4391 pFront->BltFast(NULL, NULL, pBack, pSrcRect, DDBLTFAST_WAIT);
4424 } 4392 }
4425 4393
4426 //----- (004A1B22) -------------------------------------------------------- 4394 //----- (004A1B22) --------------------------------------------------------
4427 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) 4395 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z)
4428 { 4396 {
9121 9089
9122 9090
9123 //----- (0045E03A) -------------------------------------------------------- 9091 //----- (0045E03A) --------------------------------------------------------
9124 unsigned short *Render::MakeScreenshot(signed int width, signed int height) 9092 unsigned short *Render::MakeScreenshot(signed int width, signed int height)
9125 { 9093 {
9126 unsigned __int16 *v3; // ebx@1 9094 unsigned __int16 *for_pixels; // ebx@1
9127 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 9095 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6
9128 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 9096 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1
9129 float interval_x; // [sp+84h] [bp-20h]@1 9097 float interval_x; // [sp+84h] [bp-20h]@1
9130 float interval_y; // [sp+8Ch] [bp-18h]@1 9098 float interval_y; // [sp+8Ch] [bp-18h]@1
9131 9099
9133 interval_y = game_viewport_height / (double)height; 9101 interval_y = game_viewport_height / (double)height;
9134 9102
9135 pPixels = (unsigned __int16 *)malloc(2 * height * width); 9103 pPixels = (unsigned __int16 *)malloc(2 * height * width);
9136 memset(pPixels, 0 , 2 * height * width); 9104 memset(pPixels, 0 , 2 * height * width);
9137 9105
9138 v3 = pPixels; 9106 for_pixels = pPixels;
9139 9107
9140 BeginSceneD3D(); 9108 BeginSceneD3D();
9141 9109
9142 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) 9110 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
9143 pIndoor->Draw(); 9111 pIndoor->Draw();
9148 Dst.dwSize = sizeof(Dst); 9116 Dst.dwSize = sizeof(Dst);
9149 9117
9150 if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) ) 9118 if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) )
9151 { 9119 {
9152 if (uCurrentlyLoadedLevelType == LEVEL_null) 9120 if (uCurrentlyLoadedLevelType == LEVEL_null)
9153 memset(&v3, 0, sizeof(v3)); 9121 memset(&for_pixels, 0, sizeof(for_pixels));
9154 else 9122 else
9155 { 9123 {
9156 for (uint y = 0; y < (unsigned int)height; ++y) 9124 for (uint y = 0; y < (unsigned int)height; ++y)
9157 { 9125 {
9158 for (uint x = 0; x < (unsigned int)width; ++x) 9126 for (uint x = 0; x < (unsigned int)width; ++x)
9159 { 9127 {
9160 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) 9128 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32)
9161 { 9129 {
9162 unsigned __int32 *p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * (Dst.lPitch/4); 9130 unsigned __int32 *p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * (Dst.lPitch >> 2);
9163 *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); 9131 *for_pixels = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
9164 } 9132 }
9165 else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) 9133 else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16)
9166 { 9134 {
9167 unsigned __int16 * p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch; 9135 unsigned __int16 * p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch;
9168 *v3 = *p; 9136 *for_pixels = *p;
9169 } 9137 }
9170 else 9138 else
9171 assert(false); 9139 assert(false);
9172 ++v3; 9140 ++for_pixels;
9173 } 9141 }
9174 } 9142 }
9175 } 9143 }
9176 ErrD3D(pBackBuffer4->Unlock(NULL)); 9144 ErrD3D(pBackBuffer4->Unlock(NULL));
9177 } 9145 }