# HG changeset patch
# User Ritor1
# Date 1408598691 -21600
# Node ID acac52e9e36a42bde49da764d6aa24196efb9719
# Parent 273279353509e72937f3e628aa5b84d2ce2627ce
remove DirectX11.cpp/.h for VS2010, MatrixMultiply and other
diff -r 273279353509 -r acac52e9e36a Build/Visual Studio 2010/World of Might and Magic.vcxproj
--- a/Build/Visual Studio 2010/World of Might and Magic.vcxproj Tue Aug 19 23:25:45 2014 +0100
+++ b/Build/Visual Studio 2010/World of Might and Magic.vcxproj Thu Aug 21 11:24:51 2014 +0600
@@ -98,7 +98,6 @@
-
@@ -262,7 +261,6 @@
-
diff -r 273279353509 -r acac52e9e36a Build/Visual Studio 2010/World of Might and Magic.vcxproj.filters
--- a/Build/Visual Studio 2010/World of Might and Magic.vcxproj.filters Tue Aug 19 23:25:45 2014 +0100
+++ b/Build/Visual Studio 2010/World of Might and Magic.vcxproj.filters Thu Aug 21 11:24:51 2014 +0600
@@ -309,9 +309,6 @@
Engine\Graphics
-
- Engine\Graphics
-
Engine\Graphics
@@ -573,6 +570,7 @@
Engine\Graphics
+
@@ -1016,9 +1014,6 @@
Engine\Graphics
-
- Engine\Graphics
-
Engine\Graphics
@@ -1157,9 +1152,6 @@
Engine
-
- Engine
-
Engine
@@ -1271,60 +1263,18 @@
GUI\UI
-
- GUI\UI
-
-
- GUI\UI
-
-
- GUI\UI
-
GUI\UI
-
- GUI\UI
-
-
- GUI\UI
-
-
- GUI\UI
-
-
- GUI\UI
-
-
- GUI\UI
-
-
- GUI\UI
-
-
- GUI\UI
-
-
- GUI\UI
-
-
- GUI\UI
-
-
- GUI\UI\Books
-
-
- GUI\UI\Books
-
-
- GUI\UI\Books
-
Engine\Graphics
Engine\Graphics
+
+
+
@@ -1360,9 +1310,8 @@
Engine\Objects
-
- GUI\NewUI\Core
-
+
+
@@ -1393,4 +1342,7 @@
lib\OpenAL\lib\x86
+
+
+
\ No newline at end of file
diff -r 273279353509 -r acac52e9e36a IndoorCameraD3D.cpp
--- a/IndoorCameraD3D.cpp Tue Aug 19 23:25:45 2014 +0100
+++ b/IndoorCameraD3D.cpp Thu Aug 21 11:24:51 2014 +0600
@@ -690,21 +690,18 @@
// 50D9D0: using guessed type char static_sub_437906_byte_50D9D0_init_flag;
//----- (004378BA) --------------------------------------------------------
-void IndoorCameraD3D::MatrixMultiply(Matrix3x3_float_ *a1, Matrix3x3_float_ *a2, Matrix3x3_float_ *out)
+void IndoorCameraD3D::MatrixMultiply(Matrix3x3_float_ *ma, Matrix3x3_float_ *mb, Matrix3x3_float_ *m_out)
{
- float *v4; // ecx@1
- double v10; // st7@3
- double v11; // st6@3
+ float sum;
- v4 = (float *)out;
- for ( uint i = 0; i < 3; i++ )
- {
- for ( uint j = 0; j < 3; j++ )
- {
- v10 = a2->v[2][j] * a1->v[i][2] + a2->v[0][j] * a1->v[i][0];
- v11 = a2->v[1][j] * a1->v[i][1];
- *v4 = v10 + v11;
- ++v4;
+ for ( uint row = 0; row < 3; row++ )
+ {
+ for ( uint col = 0; col < 3; col++ )
+ {
+ sum = 0;
+ for ( int index = 0; index < 3; index++ )
+ sum += ma->v[row][index]*mb->v[index][col];
+ m_out->v[row][col] = sum;
}
}
}
@@ -712,18 +709,11 @@
//----- (004376E7) --------------------------------------------------------
void IndoorCameraD3D::CreateWorldMatrixAndSomeStuff()
{
- //IndoorCameraD3D *v1; // esi@1
-// double v2; // st7@1
- //signed int v3; // edi@1
- //int v4; // eax@1
- //double v5; // st7@2
- //double v6; // st7@3
Matrix3x3_float_ m1; // [sp+10h] [bp-B8h]@1
Matrix3x3_float_ m2; // [sp+34h] [bp-94h]@1
Matrix3x3_float_ m3; // [sp+58h] [bp-70h]@1
Matrix3x3_float_ m4; // [sp+7Ch] [bp-4Ch]@1
Matrix3x3_float_ m5; // [sp+A0h] [bp-28h]@1
-// float v12; // [sp+C4h] [bp-4h]@1
//RotationZ(0)
m5._11 = cosf(0); m5._12 = sinf(0); m5._13 = 0;
diff -r 273279353509 -r acac52e9e36a MMT.cpp
--- a/MMT.cpp Tue Aug 19 23:25:45 2014 +0100
+++ b/MMT.cpp Thu Aug 21 11:24:51 2014 +0600
@@ -17,6 +17,7 @@
#include "ErrorHandling.h"
#include "Bink_Smacker.h"
#include "Game.h"
+#include "Log.h"
void ShowLogoVideo()
@@ -180,6 +181,7 @@
png_byte tmp = ptr[2];
ptr[2] = ptr[0];
ptr[0] = ptr[3];
+ //ptr[3] = 255 - ptr[3]; // alpha mask gradient
ptr[3] = 255 - tmp;
tex->pPalette16[i] = Color16(ptr[0], ptr[1], ptr[2]);
tex->pLevelOfDetail0_prolly_alpha_mask[i] = ptr[3];
diff -r 273279353509 -r acac52e9e36a OSWindow.cpp
--- a/OSWindow.cpp Tue Aug 19 23:25:45 2014 +0100
+++ b/OSWindow.cpp Thu Aug 21 11:24:51 2014 +0600
@@ -21,6 +21,7 @@
#include "ErrorHandling.h"
#include "Log.h"
#include "Registry.h"
+#include "MMT.h"
bool wizard_eye = false; //включить на постоянно око чародея
@@ -494,6 +495,11 @@
//pMouse->uCursorTextureID = pIcons_LOD->LoadTexture(cursor_name, TEXTURE_16BIT_PALETTE);
//hCurs1 = LoadCursor(NULL, L"Target");
+ if (for_refactoring)
+ {
+ MessageBoxA(nullptr, "Ritor1: original cursor(Target) isn't loading", "", 0);
+ __debugbreak();
+ }
SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(NULL, IDC_CROSS));
}
@@ -506,9 +512,14 @@
void OSWindow::SetFullscreenMode()
{
- SetMenu(api_handle, nullptr);
+ //Ritor1: Error. Window size change in this function(Ошибка. При переходе на полноэкранный режим размеры окна изменяются в этой функции)
+ SetMenu(api_handle, nullptr);//640,480 - 640,500
+ /*bool m = false;
+ HMENU h_menu = GetMenu(api_handle);
+ m = DestroyMenu(h_menu);//как вариант - удалить меню*/
+
SetWindowLongW(api_handle, GWL_EXSTYLE, WS_EX_TOPMOST);
- SetWindowLongW(api_handle, GWL_STYLE, WS_VISIBLE | WS_POPUP);
+ SetWindowLongW(api_handle, GWL_STYLE, WS_VISIBLE | WS_POPUP);//648, 534
SetWindowPos(api_handle, HWND_TOP, 0, 0, -1, -1, SWP_NOSIZE | SWP_SHOWWINDOW);
}
diff -r 273279353509 -r acac52e9e36a Render.cpp
--- a/Render.cpp Tue Aug 19 23:25:45 2014 +0100
+++ b/Render.cpp Thu Aug 21 11:24:51 2014 +0600
@@ -36,6 +36,7 @@
#include "Vis.h"
#include "Registry.h"
#include "Weather.h"
+#include "MMT.h"
//#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib")
@@ -234,7 +235,7 @@
{
int v6; // ecx@8
struct Polygon *pTilePolygon; // ebx@8
-// float Light_tile_dist;
+ float Light_tile_dist;
//warning: the game uses CW culling by default, ccw is incosistent
pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW);
@@ -365,6 +366,11 @@
norm = 0;
else
norm = &pTerrainNormals[norm_idx];
+ if (for_refactoring)
+ {
+ MessageBoxA(nullptr, "Ritor1: function StackLights_TerrainFace needed refactoring and result - slows", "", 0);
+ __debugbreak();
+ }
//pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows
//pDecalBuilder->_49BE8A(pTilePolygon, norm, &Light_tile_dist, array_50AC10, 4, 1);
//unsigned int a5 = 4;
@@ -784,10 +790,10 @@
v20.pDDraw4DevDesc = new char[v7 + 1];
strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription);
}
- memset(&ddsCaps, 0, 0x10u);
+ memset(&ddsCaps, 0, sizeof(ddsCaps));
if (FAILED(pDirectDraw4->GetAvailableVidMem(&ddsCaps, (LPDWORD)&v20.uVideoMem, (LPDWORD)&uFreeVideoMem)))
v20.uVideoMem = 0;
- memset(&v10, 0, 0x7Cu);
+ memset(&v10, 0, sizeof(v10));
v10.dwSize = 124;
v10.dwFlags = 6;
v10.dwHeight = window->GetWidth();
@@ -1338,7 +1344,7 @@
DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37
DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11
D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28
- IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18
+ IDirectDrawClipper *lpddclipper; // [sp+C4h] [bp-14h]@18
LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1
auto hWnd = window->GetApiHandle();
@@ -1433,7 +1439,8 @@
}
return 0;
}
- if ( pHost->CreateClipper(0, &v30, 0) )
+ //Создание отсекателя DirectDraw
+ if ( pHost->CreateClipper(0, &lpddclipper, NULL) )
{
sprintf(pErrorMessage, "Init - Failed to create clipper.\n");
if (pBackBuffer)
@@ -1453,11 +1460,12 @@
}
return 0;
}
- v30->SetHWnd(0, hWnd);
- pFrontBuffer->SetClipper(v30);
-
- v30->Release();
- v30 = NULL;
+ lpddclipper->SetHWnd(0, hWnd);
+ pFrontBuffer->SetClipper(lpddclipper);
+
+ lpddclipper->Release();
+ lpddclipper = NULL;
+ //
pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D);
@@ -1601,8 +1609,11 @@
memset(&ddsd2, 0, sizeof(DDSURFACEDESC2));
ddsd2.dwSize = sizeof(DDSURFACEDESC2);
+ //Подключение полей с достоверными данными
ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
+ //Запрос сложной структуры с возможностью переключения
ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
+ //Присвоение полю счётчика задних буферов значения 1
ddsd2.dwBackBufferCount = 1;
if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, NULL) )
{
@@ -1617,10 +1628,12 @@
//a3a = &pBackBuffer;
//v14 = *v34;
memset(&v27, 0, sizeof(DDSCAPS2));
+
v27.dwCaps = DDSCAPS_BACKBUFFER;
//v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer);
//hWnda = &pDirect3D;
pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D);
+
if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer)))
{
sprintf(pErrorMessage, "Init - Failed to get D3D interface.\n");
@@ -1669,7 +1682,7 @@
return 0;
}
if ( uDeviceID == 2 || uDeviceID == 3 )
- BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u;
+ BYTE1(ddsd2.ddsCaps.dwCaps) |= 8;
//uDeviceIDa = &pZBuffer;
if (pHost->CreateSurface(&ddsd2, &pZBuffer, NULL) )
{
@@ -1807,39 +1820,36 @@
unsigned int RenderD3D::GetDeviceCaps()
{
unsigned int v1; // ebx@1
- //RenderD3D *v2; // edi@1
- IDirect3DDevice3 *v3; // eax@1
unsigned int result; // eax@2
D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1
D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1
v1 = 0;
- //v2 = this;
- memset(&halCaps, 0, 0xFCu);
- halCaps.dwSize = 252;
- memset(&refCaps, 0, 0xFCu);
- v3 = this->pDevice;
- refCaps.dwSize = 252;
- if ( v3->GetCaps(&halCaps, &refCaps) )
- {
+
+ memset(&halCaps, 0, sizeof(halCaps));
+ halCaps.dwSize = sizeof(halCaps);
+
+ memset(&refCaps, 0, sizeof(refCaps));
+ refCaps.dwSize = sizeof(refCaps);
+
+ if ( this->pDevice->GetCaps(&halCaps, &refCaps) )
result = 1;
- }
else
{
if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) )
v1 = 2;
if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ONE) )
- v1 |= 4u;
+ v1 |= 4;
if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ZERO) )
- v1 |= 8u;
+ v1 |= 8;
if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) )
- v1 |= 0x10u;
+ v1 |= 16;
if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_ONE) )
- v1 |= 0x20u;
+ v1 |= 32;
if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) )
- v1 |= 0x40u;
+ v1 |= 64;
if ( halCaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY )
- v1 |= 0x80;
+ v1 |= 128;
result = v1;
}
return result;
@@ -1863,39 +1873,38 @@
//----- (0049E54D) --------------------------------------------------------
void RenderD3D::Present(bool bForceBlit)
{
- RECT v5; // [sp+18h] [bp-18h]@1
+ RECT source_rect; // [sp+18h] [bp-18h]@1
struct tagPOINT Point; // [sp+28h] [bp-8h]@4
- v5.left = 0;
- v5.top = 0;
- v5.bottom = 480;//window->GetHeight(); //Ritor1: проблема с кнопкой "развернуть"
- v5.right = 640; //window->GetWidth();
+ source_rect.left = 0;
+ source_rect.top = 0;
+ source_rect.bottom = 480;//window->GetHeight(); //Ritor1: проблема с кнопкой "развернуть"
+ source_rect.right = 640; //window->GetWidth();
if (bWindowed || bForceBlit)
{
- RECT rc;
- GetClientRect(hWindow, &rc);
+ RECT dest_rect;
+ GetClientRect(hWindow, &dest_rect);
Point.y = 0;
Point.x = 0;
ClientToScreen(hWindow, &Point);
- OffsetRect(&rc, Point.x, Point.y);
- pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0);//Uninitialized memory access
+ OffsetRect(&dest_rect, Point.x, Point.y);
+ pFrontBuffer->Blt(&dest_rect, pBackBuffer, &source_rect, DDBLT_WAIT, NULL);
}
else
- pFrontBuffer->Flip(0, 1);
+ pFrontBuffer->Flip(NULL, DDFLIP_WAIT);
}
//----- (0049E5D4) --------------------------------------------------------
bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim)
{
- unsigned int v8; // edx@4
unsigned int v9; // ebx@5
unsigned int v10; // eax@5
DWORD v11; // edx@5
DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1
- memset(&ddsd2, 0, 0x7Cu);
- ddsd2.dwSize = 0x7Cu;
+ memset(&ddsd2, 0, sizeof(ddsd2));
+ ddsd2.dwSize = sizeof(ddsd2);
ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
@@ -1905,17 +1914,23 @@
{
if ( (signed int)uTextureHeight <= (signed int)uTextureWidth )
{
- v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim);
-LABEL_8:
- ddsd2.dwMipMapCount = v8;
- if ( !v8 )
- goto LABEL_12;
- goto LABEL_11;
+ ddsd2.dwMipMapCount = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim);
+ if ( ddsd2.dwMipMapCount )
+ {
+ ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT;
+ ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
+ }
+ goto LABEL_12;
}
if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim )
{
- v8 = GetMaxMipLevels(uMinDeviceTexDim);
- goto LABEL_8;
+ ddsd2.dwMipMapCount = GetMaxMipLevels(uMinDeviceTexDim);
+ if ( ddsd2.dwMipMapCount )
+ {
+ ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT;
+ ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
+ }
+ goto LABEL_12;
}
v9 = GetMaxMipLevels(uTextureWidth);
v10 = GetMaxMipLevels(uMinDeviceTexDim);
@@ -1930,7 +1945,6 @@
}
else
ddsd2.dwMipMapCount = 1;
-LABEL_11:
ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT;
ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
LABEL_12:
@@ -2296,20 +2310,18 @@
//----- (0049ED18) --------------------------------------------------------
void Render::PresentBlackScreen()
{
- IDirectDrawSurface *v2; // eax@3
- DDBLTFX v3; // [sp+4h] [bp-74h]@5
- RECT x; // [sp+68h] [bp-10h]@3
-
- memset(&v3, 0, sizeof(DDBLTFX));
- GetWindowRect(window->GetApiHandle(), &x);
-
- {
- v2 = (IDirectDrawSurface *)this->pBackBuffer4;
- }
-
- v3.dwFillColor = 0;
- v3.dwSize = 100;
- v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3);
+ IDirectDrawSurface *lpddsback; // eax@3
+ DDBLTFX lpDDBltFx; // [sp+4h] [bp-74h]@5
+ RECT dest_rect; // [sp+68h] [bp-10h]@3
+
+ memset(&lpDDBltFx, 0, sizeof(DDBLTFX));
+ lpDDBltFx.dwSize = sizeof(DDBLTFX);
+
+ GetWindowRect(window->GetApiHandle(), &dest_rect);
+ lpddsback = (IDirectDrawSurface *)this->pBackBuffer4;
+
+ lpDDBltFx.dwFillColor = 0;
+ lpddsback->Blt(&dest_rect, NULL, NULL, DDBLT_COLORFILL, &lpDDBltFx);
pRenderer->Present();
}
@@ -2954,7 +2966,7 @@
//----- (0049FD3A) --------------------------------------------------------
void Render::_49FD3A_fullscreen()
{
- RECT v5; // [sp+8h] [bp-10h]@6
+ RECT src_rect; // [sp+8h] [bp-10h]@6
if ( this->pRenderD3D )
{
@@ -2962,11 +2974,11 @@
pFrontBuffer4->Restore();
if (pBackBuffer4->IsLost() == DDERR_SURFACELOST)
pBackBuffer4->Restore();
- v5.top = 0;
- v5.bottom = window->GetHeight();
- v5.left = 0;
- v5.right = window->GetWidth();
- this->pBackBuffer4->BltFast(0, 0, this->pFrontBuffer4, &v5, 16);
+ src_rect.top = 0;
+ src_rect.bottom = window->GetHeight();
+ src_rect.left = 0;
+ src_rect.right = window->GetWidth();
+ this->pBackBuffer4->BltFast(NULL, NULL, this->pFrontBuffer4, &src_rect, DDBLTFAST_WAIT);
}
}
@@ -3134,32 +3146,15 @@
//----- (004A597D) --------------------------------------------------------
void Present_NoColorKey()
{
- //unsigned __int16 *v0; // eax@4
-// unsigned __int16 *v1; // esi@4
void *v2; // edi@4
- //signed int v4; // ebx@4
- //signed int v5; // ebx@6
- //void *v6; // edi@7
- //const void *v7; // esi@7
-// signed int v8; // ebx@8
int v9; // eax@10
unsigned int v10; // esi@10
unsigned __int32 v11; // edi@10
- //int v12; // ecx@10
unsigned int v13; // ebx@10
-// int v14; // eax@11
-// int v15; // eax@13
-// int v16; // eax@14
-// int v17; // eax@16
-// HRESULT v18; // eax@22
DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3
- //int v20; // [sp+88h] [bp-1Ch]@10
int v21; // [sp+8Ch] [bp-18h]@10
__int32 v22; // [sp+90h] [bp-14h]@10
- //unsigned __int32 v23; // [sp+94h] [bp-10h]@10
unsigned int v24; // [sp+98h] [bp-Ch]@4
- //unsigned int _this; // [sp+9Ch] [bp-8h]@10
- //LPVOID v26; // [sp+A0h] [bp-4h]@4
int r_mask = 0xF800;
int g_mask = 0x7E0;
@@ -3169,8 +3164,8 @@
{
//if ( pRenderer->using_software_screen_buffer )
//{
- memset(&Dst, 0, 0x7Cu);
- Dst.dwSize = 124;
+ memset(&Dst, 0, sizeof(Dst));
+ Dst.dwSize = sizeof(Dst);
if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
{
//v26 = Dst.lpSurface;
@@ -3307,37 +3302,19 @@
//----- (0049FFFB) --------------------------------------------------------
bool Render::InitializeFullscreen()
{
- //Render *v2; // esi@1
- //HWND v3; // ebx@1
- //void *v4; // eax@2
- //RenderD3D *v5; // eax@3
- //unsigned int v6; // edx@5
RenderD3D__DevInfo *v7; // ecx@5
bool v8; // eax@6
- //RenderD3D *v9; // ecx@13
unsigned int v10; // eax@13
- //RenderD3D *v11; // eax@25
-// HRESULT v12; // eax@25
- int v13; // ecx@25
- int v14; // eax@27
signed int v15; // ebx@31
- //bool v16; // eax@35
- //char v17; // zf@35
-// IDirectDraw4 *v18; // eax@38
-// HRESULT v19; // eax@38
- //int *v20; // eax@39
int *v22; // eax@42
int v23; // ecx@42
D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25
DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40
D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25
-// DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38
- //void *v28; // [sp+2FCh] [bp-10h]@2
int v29; // [sp+308h] [bp-4h]@2
//__debugbreak(); // Nomad
- //v2 = this;
this->using_software_screen_buffer = 0;
//this->pColorKeySurface4 = 0;
this->pBackBuffer4 = nullptr;
@@ -3428,21 +3405,22 @@
}
//LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1;
bRequiredTextureStagesAvailable = CheckTextureStages();
- memset(&halCaps, 0, 0xFCu);
- halCaps.dwSize = 252;
- memset(&refCaps, 0, 0xFCu);
- //v11 = pRenderD3D;
- refCaps.dwSize = 252;
+
+ memset(&halCaps, 0, sizeof(halCaps));
+ halCaps.dwSize = sizeof(halCaps);
+
+ memset(&refCaps, 0, sizeof(refCaps));
+ refCaps.dwSize = sizeof(refCaps);
+
ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps));
- v13 = halCaps.dwMinTextureWidth;
+
+ uMinDeviceTextureDim = halCaps.dwMinTextureWidth;
if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight )
- v13 = halCaps.dwMinTextureHeight;
- v14 = halCaps.dwMaxTextureWidth;
- uMinDeviceTextureDim = v13;
- if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight )
- v14 = halCaps.dwMaxTextureHeight;
- uMaxDeviceTextureDim = v14;
- if ( (unsigned int)v13 < 4 )
+ uMinDeviceTextureDim = halCaps.dwMinTextureHeight;
+ uMinDeviceTextureDim = halCaps.dwMaxTextureWidth;
+ if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight )
+ uMinDeviceTextureDim = halCaps.dwMaxTextureHeight;
+ if ( (unsigned int)uMinDeviceTextureDim < 4 )
uMinDeviceTextureDim = 4;
v15 = 1;
ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true));
@@ -3480,26 +3458,26 @@
bColorKeySupported = 0;
if ( bColorKeySupported )
{
- memset(&ddsd2, 0, 0x7Cu);
+ memset(&ddsd2, 0, sizeof(ddsd2));
+ ddsd2.dwSize = sizeof(ddsd2);
ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask;
ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue;
- v18 = pDirectDraw4;
- ddsd2.dwSize = 124;
ddsd2.dwFlags = 65543;
ddsd2.ddsCaps.dwCaps = 2112;
ddsd2.dwWidth = 640;
ddsd2.dwHeight = 480;
- ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, NULL));
+ ErrD3D(pDirectDraw4->CreateSurface(&ddsd2, &pColorKeySurface4, NULL));
pBeforePresentFunction = Present_ColorKey;
}
else*/
{
pTargetSurface = nullptr;
pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32);
- if ( !pTargetSurface_unaligned
- || (memset(&pDesc, 0, 0x7Cu),
- pDesc.dwSize = 124,
- !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) )
+ if ( !pTargetSurface_unaligned )
+ return 0;
+ memset(&pDesc, 0, sizeof(pDesc));
+ pDesc.dwSize = sizeof(pDesc);
+ if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15) )
return 0;
pBackBuffer4->Unlock(NULL);
v22 = (int *)pTargetSurface_unaligned + 4;
@@ -3642,21 +3620,21 @@
if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight )
v13 = halCaps.dwMaxTextureHeight;
uMaxDeviceTextureDim = v13;
- ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u));
- ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
- ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u));
+ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1));
+ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1));
+ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2));
ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0));
ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0));
- ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
- ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u));
- ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u));
- ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u));
- ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u));
+ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
+ ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2));
+ ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2));
+ ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3));
+ ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2));
ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0));
- ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u));
- ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u));
+ ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2));
+ ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2));
ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0));
- ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u));
+ ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4));
//}
ddpfPrimarySuface.dwSize = 32;
@@ -4242,24 +4220,14 @@
//----- (004A139A) --------------------------------------------------------
void Render::CreateDirectDrawPrimarySurface()
{
- //Render *v1; // esi@1
- //int v2; // ebx@3
-// IDirectDraw2 *v3; // eax@3
-// HRESULT v4; // eax@3
IDirectDrawSurface *pFrontBuffer; // eax@3
DDSCAPS2 *v6; // edx@3
IDirectDraw4 *v7; // eax@4
-// HRESULT v8; // eax@4
int v9; // ST14_4@5
IDirectDrawSurface *v10; // ST10_4@5
-// HRESULT v11; // eax@5
IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3
-// const char *v13; // [sp+0h] [bp-A0h]@0
-// int v14; // [sp+4h] [bp-9Ch]@0
-// unsigned int v15; // [sp+8h] [bp-98h]@0
DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3
DDSCAPS2 v17; // [sp+88h] [bp-18h]@4
-// int a4; // [sp+98h] [bp-8h]@3
//v1 = this;
//if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
@@ -4267,13 +4235,13 @@
{
//v2 = 0;
//this->field_4004C = 1;
- memset(&ddsd2, 0, 0x7Cu);
- v7 = this->pDirectDraw4;
+ memset(&ddsd2, 0, sizeof(ddsd2));
+ ddsd2.dwSize = sizeof(ddsd2);
+
ddsd2.dwBackBufferCount = 1;
- ddsd2.dwSize = 0x7Cu;
ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE;
- ErrD3D(v7->CreateSurface(&ddsd2, &pFrontBuffer4, NULL));
+ ErrD3D(this->pDirectDraw4->CreateSurface(&ddsd2, &pFrontBuffer4, NULL));
pFrontBuffer = (IDirectDrawSurface *)this->pFrontBuffer4;
ppBackBuffer = (IDirectDrawSurface **)&this->pBackBuffer4;
}
@@ -4308,7 +4276,7 @@
//----- (004A14F4) --------------------------------------------------------
void Render::CreateClipper(HWND a2)
{
- ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0));
+ ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, NULL));
ErrD3D(pDDrawClipper->SetHWnd(0, a2));
ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper));
}
@@ -4405,7 +4373,7 @@
}
//----- (004A194A) --------------------------------------------------------
-void Render::BltBackToFontFast(int a2, int a3, RECT *a4)
+void Render::BltBackToFontFast(int a2, int a3, RECT *pSrcRect)
{
IDirectDrawSurface *pFront; // eax@3
IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3
@@ -4420,7 +4388,7 @@
pFront = (IDirectDrawSurface *)this->pFrontBuffer2;
pBack = (IDirectDrawSurface *)this->pBackBuffer2;
}*/
- pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT);
+ pFront->BltFast(NULL, NULL, pBack, pSrcRect, DDBLTFAST_WAIT);
}
//----- (004A1B22) --------------------------------------------------------
@@ -9123,7 +9091,7 @@
//----- (0045E03A) --------------------------------------------------------
unsigned short *Render::MakeScreenshot(signed int width, signed int height)
{
- unsigned __int16 *v3; // ebx@1
+ unsigned __int16 *for_pixels; // ebx@1
DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6
unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1
float interval_x; // [sp+84h] [bp-20h]@1
@@ -9135,7 +9103,7 @@
pPixels = (unsigned __int16 *)malloc(2 * height * width);
memset(pPixels, 0 , 2 * height * width);
- v3 = pPixels;
+ for_pixels = pPixels;
BeginSceneD3D();
@@ -9150,7 +9118,7 @@
if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) )
{
if (uCurrentlyLoadedLevelType == LEVEL_null)
- memset(&v3, 0, sizeof(v3));
+ memset(&for_pixels, 0, sizeof(for_pixels));
else
{
for (uint y = 0; y < (unsigned int)height; ++y)
@@ -9159,17 +9127,17 @@
{
if (Dst.ddpfPixelFormat.dwRGBBitCount == 32)
{
- unsigned __int32 *p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * (Dst.lPitch/4);
- *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
+ unsigned __int32 *p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * (Dst.lPitch >> 2);
+ *for_pixels = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
}
else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16)
{
unsigned __int16 * p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch;
- *v3 = *p;
+ *for_pixels = *p;
}
else
assert(false);
- ++v3;
+ ++for_pixels;
}
}
}
diff -r 273279353509 -r acac52e9e36a Render.h
--- a/Render.h Tue Aug 19 23:25:45 2014 +0100
+++ b/Render.h Thu Aug 21 11:24:51 2014 +0600
@@ -222,7 +222,7 @@
virtual void RestoreFrontBuffer();
virtual void RestoreBackBuffer();
virtual void BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags);
- virtual void BltBackToFontFast(int a2, int a3, RECT *a4);
+ virtual void BltBackToFontFast(int a2, int a3, RECT *pSrcRect);
virtual void BeginSceneD3D();
virtual unsigned int GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6);
diff -r 273279353509 -r acac52e9e36a RenderD3D11.h
--- a/RenderD3D11.h Tue Aug 19 23:25:45 2014 +0100
+++ b/RenderD3D11.h Thu Aug 21 11:24:51 2014 +0600
@@ -48,7 +48,7 @@
virtual void RestoreFrontBuffer();
virtual void RestoreBackBuffer();
virtual void BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags);
- virtual void BltBackToFontFast(int a2, int a3, RECT *a4);
+ virtual void BltBackToFontFast(int a2, int a3, RECT *pSrcRect);
virtual void BeginSceneD3D();
virtual unsigned int GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6);
diff -r 273279353509 -r acac52e9e36a UI/UIPopup.cpp
--- a/UI/UIPopup.cpp Tue Aug 19 23:25:45 2014 +0100
+++ b/UI/UIPopup.cpp Thu Aug 21 11:24:51 2014 +0600
@@ -445,7 +445,7 @@
PlayerSpeech speech; // [sp-8h] [bp-1F4h]@79
DDBLTFX Dst; // [sp+Ch] [bp-1E0h]@18
DDSURFACEDESC2 pDesc; // [sp+70h] [bp-17Ch]@18
- RECT v84; // [sp+ECh] [bp-100h]@26
+ RECT dest_rect; // [sp+ECh] [bp-100h]@26
const char *string_name[10]; // [sp+FCh] [bp-F0h]@145
const char *content[11]; // [sp+124h] [bp-C8h]@127
unsigned char resistances[11]; // [sp+124h] [bp-C8h]@127
@@ -525,11 +525,14 @@
//if ( pRenderer->pRenderD3D )
{
v106.uScreenSpaceY = v115 + v106.uViewportY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferHeight;
- memset(&Dst, 0, 0x64u);
- Dst.dwSize = 100;
+
+ memset(&Dst, 0, sizeof(Dst));
+ Dst.dwSize = sizeof(Dst);
Dst.dwFillColor = 0;
- memset(&pDesc, 0, 0x7Cu);
- pDesc.dwSize = 124;
+
+ memset(&pDesc, 0, sizeof(pDesc));
+ pDesc.dwSize = sizeof(pDesc);
+
pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->GetSurfaceDesc(&pDesc);
v107 = 0;
uint i = 0;
@@ -555,11 +558,12 @@
dst_w = v106.uViewportW;
pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, 0x7FF);
pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, 0x7FF);
- v84.left = v106.uViewportX;
- v84.top = v106.uViewportY;
- v84.right = v106.uViewportZ;
- v84.bottom = v106.uViewportW;
- ErrD3D(pRenderer->pBackBuffer4->Blt(&v84, 0, 0, 16778240u, &Dst));
+ dest_rect.left = v106.uViewportX;
+ dest_rect.top = v106.uViewportY;
+ dest_rect.right = v106.uViewportZ;
+ dest_rect.bottom = v106.uViewportW;
+
+ ErrD3D(pRenderer->pBackBuffer4->Blt(&dest_rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &Dst));
/*if ( pRenderer->uTargetGBits == 5 )
{
__debugbreak(); // no monster popup for r5g5b5 will be
@@ -609,8 +613,8 @@
}
else*/
{
- memset(&pDesc, 0, 0x7Cu);
- pDesc.dwSize = 124;
+ memset(&pDesc, 0, sizeof(pDesc));
+ pDesc.dwSize = sizeof(pDesc);
if ( pRenderer->LockSurface_DDraw4(pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface, &pDesc, DDLOCK_WAIT) )
{
ushort* src = (unsigned __int16 *)pDesc.lpSurface;
diff -r 273279353509 -r acac52e9e36a Vis.cpp
--- a/Vis.cpp Tue Aug 19 23:25:45 2014 +0100
+++ b/Vis.cpp Thu Aug 21 11:24:51 2014 +0600
@@ -112,21 +112,8 @@
//----- (004C12C3) --------------------------------------------------------
bool Vis::IsPolygonOccludedByBillboard(RenderVertexSoft *vertices, int num_vertices, float x, float y)
{
- //signed int v5; // esi@1
- //RenderBillboardD3D *v6; // edi@2
- //double v7; // st7@9
- //int v8; // edx@9
- //RenderVertexSoft *v9; // ecx@10
- //char result; // al@24
- //Vis *thisa; // [sp+10h] [bp-8h]@1
- //float thisb; // [sp+10h] [bp-8h]@9
- //signed int v13; // [sp+14h] [bp-4h]@1
- //float a3a; // [sp+28h] [bp+10h]@9
- //float a4a; // [sp+2Ch] [bp+14h]@9
-
int v13 = -1;
//v5 = 0;
- //thisa = this;
//v6 = pRenderer->pBillboardRenderListD3D;
for (uint i = 0; i < pRenderer->uNumBillboardsToDraw; ++i)
@@ -145,7 +132,7 @@
if ( v13 == -1 )
return false;
- //v8 = num_vertices;
+ // //Bounding rectangle(Ограничивающий прямоугольник)-------------------------
//v7 = 3.4028235e38;
float min_x = FLT_MAX;
//a4a = 3.4028235e38;
@@ -156,9 +143,6 @@
float max_y = -FLT_MAX;
for (int i = 0; i < num_vertices; ++i)
{
- //v9 = a1;
- //do
- //{
RenderVertexSoft* v = &vertices[i];
if (v->vWorldViewProjX < min_x)
@@ -170,11 +154,8 @@
min_y = v->vWorldViewProjY;
if (v->vWorldViewProjY > max_y)
max_y = v->vWorldViewProjY;
- //++v9;
- //--v8;
- //}
- //while ( v8 );
}
+ // //--------------------------------
if (min_x < pRenderer->pBillboardRenderListD3D[v13].pQuads[0].pos.x || pRenderer->pBillboardRenderListD3D[v13].pQuads[0].pos.y > min_y ||
pRenderer->pBillboardRenderListD3D[v13].pQuads[3].pos.x < max_x || pRenderer->pBillboardRenderListD3D[v13].pQuads[1].pos.y < max_y)