2496
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
|
6
|
|
7 #include "ZlibWrapper.h"
|
|
8 #include "ErrorHandling.h"
|
|
9
|
|
10 #include "Render.h"
|
|
11 #include "MediaPlayer.h"
|
|
12 #include "Sprites.h"
|
|
13 #include "Mouse.h"
|
|
14 #include "Engine/Graphics/GammaControl.h"
|
|
15 #include "stru6.h"
|
|
16 #include "GUIWindow.h"
|
|
17 #include "DecalBuilder.h"
|
|
18 #include "ParticleEngine.h"
|
|
19 #include "Outdoor.h"
|
|
20 #include "Party.h"
|
|
21 #include "LOD.h"
|
|
22 #include "Viewport.h"
|
|
23 #include "OurMath.h"
|
|
24 #include "PaletteManager.h"
|
|
25 #include "Timer.h"
|
|
26 #include "Game.h"
|
|
27 #include "LightmapBuilder.h"
|
|
28 #include "ObjectList.h"
|
|
29 #include "SpriteObject.h"
|
|
30 #include "DecorationList.h"
|
|
31 #include "Actor.h"
|
|
32 #include "Log.h"
|
|
33 #include "MM7.h"
|
|
34 #include "Lights.h"
|
|
35 #include "Engine/Graphics/Level/Decoration.h"
|
|
36 #include "Vis.h"
|
|
37 #include "Registry.h"
|
|
38 #include "Weather.h"
|
|
39 #include "MMT.h"
|
|
40
|
|
41
|
|
42 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib")
|
|
43 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib")
|
|
44
|
|
45 struct IDirectDrawClipper *pDDrawClipper;
|
|
46 struct IRender *pRenderer; // idb
|
|
47 struct RenderVertexD3D3 pVertices[50];
|
|
48 int uNumDecorationsDrawnThisFrame; // weak
|
|
49 RenderBillboard pBillboardRenderList[500];
|
|
50 unsigned int uNumBillboardsToDraw;
|
|
51 int uNumSpritesDrawnThisFrame; // weak
|
|
52
|
|
53 RenderVertexSoft array_507D30[50];
|
|
54 RenderVertexSoft array_50AC10[50];
|
|
55 RenderVertexSoft array_73D150[20];
|
|
56
|
|
57 RenderVertexD3D3 d3d_vertex_buffer[50];
|
|
58
|
|
59 /* 384 */
|
|
60 #pragma pack(push, 1)
|
|
61 struct PCXHeader_1
|
|
62 {
|
|
63 char manufacturer;
|
|
64 char version;
|
|
65 char encoding;
|
|
66 char bpp;
|
|
67 __int16 left;
|
|
68 __int16 up;
|
|
69 __int16 right;
|
|
70 __int16 bottom;
|
|
71 __int16 hdpi;
|
|
72 __int16 vdpi;
|
|
73 };
|
|
74 #pragma pack(pop)
|
|
75
|
|
76 /* 385 */
|
|
77 #pragma pack(push, 1)
|
|
78 struct PCXHeader_2
|
|
79 {
|
|
80 char reserved;
|
|
81 char planes;
|
|
82 __int16 pitch;
|
|
83 __int16 palette_info;
|
|
84 };
|
|
85 #pragma pack(pop)
|
|
86
|
|
87 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst);
|
|
88 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2);
|
|
89 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6);
|
|
90 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb
|
|
91
|
|
92 //----- (0049E79F) --------------------------------------------------------
|
|
93 bool Render::CheckTextureStages()
|
|
94 {
|
|
95 bool v0; // edi@1
|
|
96 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1
|
|
97 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1
|
|
98 DWORD v4; // [sp+14h] [bp-Ch]@1
|
|
99 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1
|
|
100 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1
|
|
101
|
|
102 v0 = false;
|
|
103 pRenderD3D->CreateTexture(64, 64, &pSurface1, &pTexture1, true, false, 32);
|
|
104 pRenderD3D->CreateTexture(64, 64, &pSurface2, &pTexture2, true, false, 32);
|
|
105
|
|
106 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture1));
|
|
107 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
108 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2));
|
|
109 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2));
|
|
110 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2));
|
|
111 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2));
|
|
112 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1));
|
|
113
|
|
114 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture2));
|
|
115 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
|
|
116 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1));
|
|
117 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7));
|
|
118 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2));
|
|
119 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1));
|
|
120 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2));
|
|
121 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2));
|
|
122 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1));
|
|
123
|
|
124 if ( !pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 )
|
|
125 v0 = true;
|
|
126 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1));
|
|
127 pTexture1->Release();
|
|
128 pTexture2->Release();
|
|
129 pSurface1->Release();
|
|
130 pSurface2->Release();
|
|
131 return v0;
|
|
132 }
|
|
133
|
|
134
|
|
135 //----- (00440CB8) --------------------------------------------------------
|
|
136 void Render::DrawBillboardList_BLV()
|
|
137 {
|
|
138 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1
|
|
139
|
|
140 soft_billboard.sParentBillboardID = -1;
|
|
141 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget;
|
|
142 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer;
|
|
143 soft_billboard.uTargetPitch = uTargetSurfacePitch;
|
|
144 soft_billboard.uViewportX = pBLVRenderParams->uViewportX;
|
|
145 soft_billboard.uViewportY = pBLVRenderParams->uViewportY;
|
|
146 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1;
|
|
147 soft_billboard.uViewportW = pBLVRenderParams->uViewportW;
|
|
148
|
|
149 pODMRenderParams->uNumBillboards = ::uNumBillboardsToDraw;
|
|
150 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i)
|
|
151 {
|
|
152 RenderBillboard* p = &pBillboardRenderList[i];
|
|
153
|
|
154 soft_billboard.uScreenSpaceX = p->uScreenSpaceX;
|
|
155 soft_billboard.sParentBillboardID = i;
|
|
156 soft_billboard.uScreenSpaceY = p->uScreenSpaceY;
|
|
157 soft_billboard._screenspace_x_scaler_packedfloat = p->_screenspace_x_scaler_packedfloat;
|
|
158 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat;
|
|
159 soft_billboard.sZValue = p->sZValue;
|
|
160 soft_billboard.uFlags = p->field_1E;
|
|
161 soft_billboard.sTintColor = p->sTintColor;
|
|
162 if ( p->HwSpriteID != -1 )
|
|
163 {
|
|
164 if ( pRenderD3D )
|
|
165 DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[p->HwSpriteID], p->dimming_level);
|
|
166 else
|
|
167 {
|
|
168 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1);
|
|
169 if (p->field_1E & 0x0100)
|
|
170 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette];
|
|
171 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 )
|
|
172 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1);
|
|
173 if ( p->HwSpriteID >= 0 )
|
|
174 pSprites_LOD->pSpriteHeaders[p->HwSpriteID].DrawSprite_sw(&soft_billboard, 1);
|
|
175 }
|
|
176 }
|
|
177 }
|
|
178 }
|
|
179
|
|
180 //----- (004A16A5) --------------------------------------------------------
|
|
181 bool Render::AreRenderSurfacesOk()
|
|
182 {
|
|
183 return pFrontBuffer4 && pBackBuffer4;
|
|
184 }
|
|
185
|
|
186
|
|
187 //----- (004A19D8) --------------------------------------------------------
|
|
188 unsigned int BlendColors(unsigned int a1, unsigned int a2)
|
|
189 {
|
|
190 /*signed __int64 v2; // ST10_8@1
|
|
191 double v3; // st7@1
|
|
192 float v4; // ST24_4@1
|
|
193 double v5; // ST10_8@1
|
|
194 int v6; // ST1C_4@1
|
|
195 float v7; // ST24_4@1
|
|
196 double v8; // ST10_8@1
|
|
197 unsigned __int8 v9; // ST20_1@1
|
|
198 float v10; // ST24_4@1
|
|
199 double v11; // ST10_8@1
|
|
200 float v12; // ST24_4@1
|
|
201 double v13; // ST08_8@1*/
|
|
202
|
|
203 uint alpha = (uint)floorf(0.5f + (a1 >> 24) / 255.0f *
|
|
204 (a2 >> 24) / 255.0f * 255.0f),
|
|
205 red = (uint)floorf(0.5f + ((a1 >> 16) & 0xFF) / 255.0f *
|
|
206 ((a2 >> 16) & 0xFF) / 255.0f * 255.0f),
|
|
207 green = (uint)floorf(0.5f + ((a1 >> 8) & 0xFF) / 255.0f *
|
|
208 ((a2 >> 8) & 0xFF) / 255.0f * 255.0f),
|
|
209 blue = (uint)floorf(0.5f + ((a1 >> 0) & 0xFF) / 255.0f *
|
|
210 ((a2 >> 0) & 0xFF) / 255.0f * 255.0f);
|
|
211 return (alpha << 24) | (red << 16) | (green << 8) | blue;
|
|
212 /*v2 = a1 >> 24;
|
|
213 v3 = (double)v2 / 255.0f;
|
|
214 HIDWORD(v2) = 0;
|
|
215 LODWORD(v2) = a2 >> 24;
|
|
216 v4 = v3 * (double)v2 / 255.0f * 255.0;
|
|
217 v5 = v4 + 6.7553994e15;
|
|
218 v6 = LODWORD(v5);
|
|
219 v7 = (double)((a1 >> 16) & 0xFFi64) / 255.0f * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0;
|
|
220 v8 = v7 + 6.7553994e15;
|
|
221 v9 = LOBYTE(v8);
|
|
222 v10 = (double)((unsigned __int16)a1 >> 8) / 255.0f * (double)((unsigned __int16)a2 >> 8) / 255.0f * 255.0;
|
|
223 v11 = v10 + 6.7553994e15;
|
|
224 v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0;
|
|
225 v13 = v12 + 6.7553994e15;
|
|
226 return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/
|
|
227 }
|
|
228
|
|
229
|
|
230 void Render::RenderTerrainD3D() // New function
|
|
231 {
|
|
232 int v6; // ecx@8
|
|
233 struct Polygon *pTilePolygon; // ebx@8
|
|
234 float Light_tile_dist;
|
|
235
|
|
236 //warning: the game uses CW culling by default, ccw is incosistent
|
|
237 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW);
|
|
238
|
|
239 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ
|
|
240
|
|
241 //Ãåíåðàöèÿ ìåñòîïîëîæåíèÿ âåðøèí-------------------------------------------------------------------------
|
|
242 //ðåø¸òêà âåðøèí äåëèòñÿ íà äâå ÷àñòè îò -64 äî 0 è îò 0 äî 64
|
|
243 //
|
|
244 // -64 X 0 64
|
|
245 // --------------- 64
|
|
246 // | | |
|
|
247 // | | |
|
|
248 // | | |
|
|
249 // 0|------+------| Z
|
|
250 // | | |
|
|
251 // | | |
|
|
252 // | | |
|
|
253 // ---------------
|
|
254 // -64
|
|
255
|
|
256 int blockScale = 512;
|
|
257 int heightScale = 32;
|
|
258 for (unsigned int z = 0; z < 128; ++z)
|
|
259 {
|
|
260 for (unsigned int x = 0; x < 128; ++x)
|
|
261 {
|
|
262 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale;
|
|
263 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale;
|
|
264 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x];
|
|
265 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1);
|
|
266 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0);
|
|
267 }
|
|
268 }
|
|
269 //-------(Îòñå÷åíèå íåâèäèìîé ÷àñòè êàðòû)------------------------------------------------------------------------------------------
|
|
270 float direction = (float)(pGame->pIndoorCameraD3D->sRotationY / 256);//direction of the camera(íàïðâëåíèå êàìåðû)
|
|
271 //0-East(B)
|
|
272 //1-NorthEast(CB)
|
|
273 //2-North(C)
|
|
274 //3-WestNorth(CÇ)
|
|
275 //4-West(Ç)
|
|
276 //5-SouthWest(ÞÇ)
|
|
277 //6-South(Þ)
|
|
278 //7-SouthEast(ÞÂ)
|
|
279 unsigned int Start_X, End_X, Start_Z, End_Z;
|
|
280 if ( direction >= 0 && direction < 1.0 )//East(B) - NorthEast(CB)
|
|
281 {
|
|
282 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 127;
|
|
283 Start_Z = 0, End_Z = 127;
|
|
284 }
|
|
285 else if (direction >= 1.0 && direction < 3.0)//NorthEast(CB) - WestNorth(CÇ)
|
|
286 {
|
|
287 Start_X = 0, End_X = 127;
|
|
288 Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ + 1;
|
|
289 }
|
|
290 else if (direction >= 3.0 && direction < 5.0)//WestNorth(CÇ) - SouthWest(ÞÇ)
|
|
291 {
|
|
292 Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 2;
|
|
293 Start_Z = 0, End_Z = 127;
|
|
294 }
|
|
295 else if ( direction >= 5.0 && direction < 7.0 )//SouthWest(ÞÇ) - //SouthEast(ÞÂ)
|
|
296 {
|
|
297 Start_X = 0, End_X = 127;
|
|
298 Start_Z = pODMRenderParams->uMapGridCellZ - 2, End_Z = 127;
|
|
299 }
|
|
300 else//SouthEast(ÞÂ) - East(B)
|
|
301 {
|
|
302 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 127;
|
|
303 Start_Z = 0, End_Z = 127;
|
|
304 }
|
|
305 for (unsigned int z = Start_Z; z < End_Z; ++z)
|
|
306 {
|
|
307 for (unsigned int x = Start_X; x < End_X; ++x)
|
|
308 {
|
|
309 pTilePolygon = &array_77EC08[pODMRenderParams->uNumPolygons];
|
|
310 pTilePolygon->flags = 0;
|
|
311 pTilePolygon->field_32 = 0;
|
|
312 pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z);
|
|
313 pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID];
|
|
314 if (pTilePolygon->uTileBitmapID == 0xFFFF)
|
|
315 continue;
|
|
316
|
|
317 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z);
|
|
318 pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z);
|
|
319 pTilePolygon->field_32 = 0;
|
|
320 pTilePolygon->field_59 = 1;
|
|
321 pTilePolygon->sTextureDeltaU = 0;
|
|
322 pTilePolygon->sTextureDeltaV = 0;
|
|
323 // x,z x+1,z
|
|
324 // .____________.
|
|
325 // | |
|
|
326 // | |
|
|
327 // | |
|
|
328 // | |
|
|
329 // | |
|
|
330 // .____________.
|
|
331 // x,z+1 x+1,z+1
|
|
332 memcpy(&array_73D150[0], &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));//x, z
|
|
333 array_73D150[0].u = 0;
|
|
334 array_73D150[0].v = 0;
|
|
335 memcpy(&array_73D150[1], &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z
|
|
336 array_73D150[1].u = 1;
|
|
337 array_73D150[1].v = 0;
|
|
338 memcpy(&array_73D150[2], &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z + 1
|
|
339 array_73D150[2].u = 1;
|
|
340 array_73D150[2].v = 1;
|
|
341 memcpy(&array_73D150[3], &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));//x, z + 1
|
|
342 array_73D150[3].u = 0;
|
|
343 array_73D150[3].v = 1;
|
|
344 //v58 = 0;
|
|
345 //if (v58 == 4) // if all y == first y; primitive in xz plane
|
|
346 //pTile->field_32 |= 0x0001;
|
|
347 pTilePolygon->pODMFace = nullptr;
|
|
348 pTilePolygon->uNumVertices = 4;
|
|
349 pTilePolygon->field_59 = 5;
|
|
350
|
|
351 //shading (çàòåíåíèå)----------------------------------------------------------------------------
|
|
352 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1];
|
|
353 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2];
|
|
354 assert(norm_idx < uNumTerrainNormals);
|
|
355
|
|
356 Vec3_float_* norm = &pTerrainNormals[norm_idx];
|
|
357 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) -
|
|
358 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) -
|
|
359 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0));
|
|
360 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f);
|
|
361 if ( norm_idx < 0 || norm_idx > uNumTerrainNormals - 1 )
|
|
362 norm = 0;
|
|
363 else
|
|
364 norm = &pTerrainNormals[norm_idx];
|
|
365 if (for_refactoring)
|
|
366 {
|
|
367 MessageBoxA(nullptr, "Ritor1: function StackLights_TerrainFace needed refactoring and result - slows", "", 0);
|
|
368 __debugbreak();
|
|
369 }
|
|
370 //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows
|
|
371 //pDecalBuilder->_49BE8A(pTilePolygon, norm, &Light_tile_dist, array_50AC10, 4, 1);
|
|
372 //unsigned int a5 = 4;
|
|
373 //----------------------------------------------------------------------------
|
|
374
|
|
375 ++pODMRenderParams->uNumPolygons;
|
|
376 ++pODMRenderParams->field_44;
|
|
377 assert(pODMRenderParams->uNumPolygons < 20000);
|
|
378
|
|
379 pTilePolygon->uBModelID = 0;
|
|
380 pTilePolygon->uBModelFaceID = 0;
|
|
381 pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6;
|
|
382 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k)
|
|
383 {
|
|
384 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft));
|
|
385 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
|
|
386 }
|
|
387 //---------Draw distance(Äàëüíîñòü îòðèñîâêè)-------------------------------
|
|
388 int temp = pODMRenderParams->shading_dist_mist;
|
|
389 if ( draw_terrain_dist_mist )
|
|
390 pODMRenderParams->shading_dist_mist = 0x5000;
|
|
391 bool neer_clip = array_73D150[0].vWorldViewPosition.x < 8.0
|
|
392 || array_73D150[1].vWorldViewPosition.x < 8.0
|
|
393 || array_73D150[2].vWorldViewPosition.x < 8.0
|
|
394 || array_73D150[3].vWorldViewPosition.x < 8.0;
|
|
395 bool far_clip = (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x
|
|
396 || (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x
|
|
397 || (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x
|
|
398 || (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x;
|
|
399
|
|
400 /* int v33 = 0;
|
|
401 static stru154 static_sub_0048034E_stru_154;
|
|
402 pGame->pLightmapBuilder->std__vector_000004_size = 0;
|
|
403 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
|
|
404 {
|
|
405 if ( neer_clip )
|
|
406 v33 = 3;
|
|
407 else
|
|
408 v33 = far_clip != 0 ? 5 : 0;
|
|
409 static_sub_0048034E_stru_154.ClassifyPolygon(norm, Light_tile_dist);
|
|
410 if ( pDecalBuilder->uNumDecals > 0 )
|
|
411 pDecalBuilder->ApplyDecals(31 - pTilePolygon->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1);
|
|
412 }
|
|
413 if ( stru_F8AD28.uNumLightsApplied > 0 )
|
|
414 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33);*/
|
|
415
|
|
416 if ( !byte_4D864C || ~pGame->uFlags & 0x80 )
|
|
417 {
|
|
418 //if ( neer_clip ) //Ritor1: Äà¸ò èñêàæåíèÿ íà ïîäú¸ìå, âîçìîæíî òðåáóåòñÿ ô-öèÿ Áåçüå
|
|
419 //{
|
|
420 // pTilePolygon->uNumVertices = ODM_NearClip(pTilePolygon->uNumVertices);
|
|
421 // ODM_Project(pTilePolygon->uNumVertices);
|
|
422 //}
|
|
423 if ( far_clip )
|
|
424 {
|
|
425 pTilePolygon->uNumVertices = ODM_FarClip(pTilePolygon->uNumVertices);
|
|
426 ODM_Project(pTilePolygon->uNumVertices);
|
|
427 }
|
|
428 }
|
|
429 pODMRenderParams->shading_dist_mist = temp;
|
|
430
|
|
431 // check the transparency and texture (tiles) mapping (ïðîâåðêà ïðîçðà÷íîñòè è íàëîæåíèå òåêñòóð (òàéëîâ))----------------------
|
|
432 bool transparent = false;
|
|
433 if ( !( pTilePolygon->flags & 1 ) ) // íå ïîääåðæèâàåòñÿ TextureFrameTable
|
|
434 {
|
|
435 if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id)
|
|
436 {
|
|
437 //transparent = false;
|
|
438 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
|
|
439 }
|
|
440 else
|
|
441 {
|
|
442 v6 = pTilePolygon->uTileBitmapID;
|
|
443 if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) )
|
|
444 transparent = true;
|
|
445 }
|
|
446
|
|
447 assert(v6 < 1000); // many random crashes here
|
|
448
|
|
449 // for all shore tiles - draw a tile water under them since they're half-empty
|
|
450 if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX
|
|
451 DrawBorderTiles(pTilePolygon);
|
|
452
|
|
453 pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true);
|
|
454 }
|
|
455 //else //çäåñü óæå ïîãðàíè÷íûå òàéëû âîäû
|
|
456 //pTile->DrawBorderTiles();
|
|
457 //--------------------------------------------------------------------------------------------------------------------------------
|
|
458
|
|
459 --pODMRenderParams->uNumPolygons;
|
|
460 --pODMRenderParams->field_44;
|
|
461 }
|
|
462 }
|
|
463 }
|
|
464
|
|
465 //----- (004811A3) --------------------------------------------------------
|
|
466 void Render::DrawBorderTiles(struct Polygon *poly)
|
|
467 {
|
|
468 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false);
|
|
469 DrawTerrainPolygon(poly->uNumVertices, poly,
|
|
470 pBitmaps_LOD->pHardwareTextures[pHDWaterBitmapIDs[hd_water_current_frame]], false, true);
|
|
471
|
|
472 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true);
|
|
473 //DrawTerrainPolygon(poly->uNumVertices, poly, pBitmaps_LOD->pHardwareTextures[poly->uTileBitmapID], true, true);
|
|
474 }
|
|
475
|
|
476
|
|
477 //----- (0047BACF) --------------------------------------------------------
|
|
478 void Render::TransformBillboardsAndSetPalettesODM()
|
|
479 {
|
|
480 //int v0; // edi@1
|
|
481 //char *v1; // esi@2
|
|
482 //unsigned int v2; // edx@3
|
|
483 //int v3; // eax@3
|
|
484 //int v4; // edi@3
|
|
485 //int v5; // eax@3
|
|
486 //__int16 v6; // di@3
|
|
487 //int v7; // eax@3
|
|
488 //int v8; // ebx@4
|
|
489 // unsigned __int16 *v9; // eax@7
|
|
490 // char v10; // zf@9
|
|
491 //DWORD v11; // eax@13
|
|
492 // int v12; // eax@13
|
|
493 // int v13; // eax@14
|
|
494 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1
|
|
495 // int v15; // [sp+54h] [bp-10h]@13
|
|
496 //int v16; // [sp+58h] [bp-Ch]@1
|
|
497 //int v17; // [sp+5Ch] [bp-8h]@2
|
|
498 // int v18; // [sp+60h] [bp-4h]@13
|
|
499
|
|
500 billboard.sParentBillboardID = -1;
|
|
501 billboard.pTarget = pRenderer->pTargetSurface;
|
|
502 billboard.pTargetZ = pRenderer->pActiveZBuffer;
|
|
503 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch;
|
|
504 billboard.uViewportX = pViewport->uViewportTL_X;
|
|
505 billboard.uViewportY = pViewport->uViewportTL_Y;
|
|
506 billboard.uViewportZ = pViewport->uViewportBR_X - 1;
|
|
507 billboard.uViewportW = pViewport->uViewportBR_Y;
|
|
508 pODMRenderParams->uNumBillboards = uNumBillboardsToDraw;
|
|
509
|
|
510 for (unsigned int i = 0; i < ::uNumBillboardsToDraw; ++i)
|
|
511 {
|
|
512 billboard.uScreenSpaceX = pBillboardRenderList[i].uScreenSpaceX;
|
|
513 billboard.uScreenSpaceY = pBillboardRenderList[i].uScreenSpaceY;
|
|
514 billboard.sParentBillboardID = i;
|
|
515 billboard._screenspace_x_scaler_packedfloat = pBillboardRenderList[i]._screenspace_x_scaler_packedfloat;
|
|
516 billboard.sTintColor = pBillboardRenderList[i].sTintColor;
|
|
517 billboard._screenspace_y_scaler_packedfloat = pBillboardRenderList[i]._screenspace_y_scaler_packedfloat;
|
|
518 billboard.sZValue = pBillboardRenderList[i].sZValue;
|
|
519 billboard.uFlags = pBillboardRenderList[i].field_1E;
|
|
520 if (pBillboardRenderList[i].HwSpriteID != -1)
|
|
521 {
|
|
522 if (!pRenderD3D) __debugbreak(); // no sw rendering
|
|
523 //if (pRenderer->pRenderD3D)
|
|
524 TransformBillboard(&billboard,
|
|
525 &pSprites_LOD->pHardwareSprites[pBillboardRenderList[i].HwSpriteID],
|
|
526 pBillboardRenderList[i].dimming_level, &pBillboardRenderList[i]);
|
|
527 /*else
|
|
528 {
|
|
529 assert(false);
|
|
530
|
|
531 auto v1 = (char *)&pBillboard->uScreenSpaceY;
|
|
532 if ( *(v1 - 10) & 2 )
|
|
533 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1);
|
|
534 else
|
|
535 v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1));
|
|
536 v10 = (*(v1 - 9) & 1) == 0;
|
|
537 billboard.pPalette = v9;
|
|
538 if ( !v10 )
|
|
539 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)];
|
|
540 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 )
|
|
541 {
|
|
542 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount());
|
|
543 v15 = abs(v12);
|
|
544 v18 = (unsigned __int64)(15i64 * v15) >> 16;
|
|
545 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1);
|
|
546 }
|
|
547 v13 = *((short *)v1 - 8);
|
|
548 if ( v13 >= 0 )
|
|
549 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1);
|
|
550 }*/
|
|
551 }
|
|
552 }
|
|
553 }
|
|
554
|
|
555 //----- (0047AF11) --------------------------------------------------------
|
|
556 void Render::DrawSpriteObjects_ODM()
|
|
557 {
|
|
558 SpriteFrame *frame; // eax@10
|
|
559 unsigned int v6; // eax@10
|
|
560 int v9; // ecx@10
|
|
561 int v17; // ecx@25
|
|
562 int v18; // eax@25
|
|
563 // int v22; // ST3C_4@29
|
|
564 signed __int64 v23; // qtt@30
|
|
565 int v26; // eax@31
|
|
566 // char v27; // zf@31
|
|
567 int v30; // [sp+14h] [bp-2Ch]@23
|
|
568 int v37; // [sp+1Ch] [bp-24h]@23
|
|
569 int a6; // [sp+20h] [bp-20h]@10
|
|
570 int v42; // [sp+2Ch] [bp-14h]@23
|
|
571 int y; // [sp+30h] [bp-10h]@10
|
|
572 int x; // [sp+34h] [bp-Ch]@10
|
|
573 int z; // [sp+38h] [bp-8h]@10
|
|
574 signed __int16 v46; // [sp+3Ch] [bp-4h]@12
|
|
575
|
|
576 //v41 = 0;
|
|
577 for (unsigned int i = 0; i < uNumSpriteObjects; ++i)
|
|
578 {
|
|
579 SpriteObject* object = &pSpriteObjects[i];
|
|
580 //auto v0 = (char *)&pSpriteObjects[i].uSectorID;
|
|
581 //v0 = (char *)&pSpriteObjects[0].uSectorID;
|
|
582 //do
|
|
583 //{
|
|
584 if (!object->uObjectDescID) // item probably pciked up
|
|
585 continue;
|
|
586
|
|
587 assert(object->uObjectDescID < pObjectList->uNumObjects);
|
|
588 ObjectDesc* object_desc = &pObjectList->pObjects[object->uObjectDescID];
|
|
589 if (object_desc->NoSprite())
|
|
590 continue;
|
|
591
|
|
592 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)];
|
|
593 //if ( !(v1->uFlags & 1) )
|
|
594 //{
|
|
595 //v2 = *((short *)v0 - 14)
|
|
596 //v2 = object->uType;
|
|
597 if ( (object->uType < 1000 || object->uType >= 10000) && (object->uType < 500 || object->uType >= 600)
|
|
598 || pGame->pStru6Instance->_4A81CA(object) )
|
|
599 {
|
|
600 //a5 = *(short *)v0;
|
|
601 x = object->vPosition.x;
|
|
602 y = object->vPosition.y;
|
|
603 z = object->vPosition.z;
|
|
604 frame = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID);
|
|
605 a6 = frame->uGlowRadius * object->field_22_glow_radius_multiplier;
|
|
606 v6 = stru_5C6E00->Atan2(object->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y);
|
|
607 //LOWORD(v7) = object->uFacing;
|
|
608 //v8 = v36;
|
|
609 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7;
|
|
610 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[v9];
|
|
611 if ( frame->uFlags & 0x20 )
|
|
612 {
|
|
613 //v8 = v36;
|
|
614 z -= fixpoint_mul(frame->scale, pSprites_LOD->pSpriteHeaders[(signed __int16)frame->pHwSpriteIDs[v9]].uHeight) / 2;
|
|
615 }
|
|
616 v46 = 0;
|
|
617 if ( frame->uFlags & 2 )
|
|
618 v46 = 2;
|
|
619 //v11 = (int *)(256 << v9);
|
|
620 if ( (256 << v9) & frame->uFlags )
|
|
621 v46 |= 4;
|
|
622 if ( frame->uFlags & 0x40000 )
|
|
623 v46 |= 0x40;
|
|
624 if ( frame->uFlags & 0x20000 )
|
|
625 LOBYTE(v46) = v46 | 0x80;
|
|
626 if ( a6 )
|
|
627 {
|
|
628 //LOBYTE(v11) = _4E94D3_light_type;
|
|
629 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFF, 0xFF, 0xFF, _4E94D3_light_type);
|
|
630 }
|
|
631 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
632 {
|
|
633 v30 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y)
|
|
634 + fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y);
|
|
635 v37 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_sine_y);
|
|
636 v42 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x)
|
|
637 + fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_cosine_x);
|
|
638 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 )
|
|
639 {
|
|
640 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) - v37;
|
|
641 v18 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x)
|
|
642 - fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_sine_x);
|
|
643 if ( abs(v42) >= abs(v17) )
|
|
644 {
|
|
645 LODWORD(v23) = 0;
|
|
646 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad);
|
|
647
|
|
648 object->uAttributes |= 1;
|
|
649 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex;
|
|
650 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID;
|
|
651 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42);
|
|
652 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame;
|
|
653 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42);
|
|
654 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46;
|
|
655 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x;
|
|
656 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y;
|
|
657 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z;
|
|
658 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16);
|
|
659 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16);
|
|
660 HIWORD(v26) = HIWORD(v42);
|
|
661 LOWORD(v26) = 0;
|
|
662 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i));
|
|
663 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0;
|
|
664 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0;
|
|
665 if ( !(object->uAttributes & 0x20) )
|
|
666 {
|
|
667 if ( !pRenderD3D )
|
|
668 {
|
|
669 __debugbreak();
|
|
670 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0;
|
|
671 }
|
|
672 }
|
|
673 //if (::uNumBillboardsToDraw >= 500)
|
|
674 // return;
|
|
675 assert(::uNumBillboardsToDraw < 500);
|
|
676 ++::uNumBillboardsToDraw;
|
|
677 ++uNumSpritesDrawnThisFrame;
|
|
678 }
|
|
679 }
|
|
680 }
|
|
681 else
|
|
682 {
|
|
683 v42 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y)
|
|
684 + fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y);
|
|
685 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 )
|
|
686 {
|
|
687 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y)
|
|
688 - fixpoint_mul(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16), pGame->pIndoorCameraD3D->int_sine_y);
|
|
689 v18 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
|
|
690 if ( abs(v42) >= abs(v17) )
|
|
691 {
|
|
692 LODWORD(v23) = 0;
|
|
693 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad);
|
|
694
|
|
695 object->uAttributes |= 1;
|
|
696 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex;
|
|
697 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID;
|
|
698 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42);
|
|
699 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame;
|
|
700 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42);
|
|
701 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46;
|
|
702 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x;
|
|
703 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y;
|
|
704 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z;
|
|
705 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16);
|
|
706 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16);
|
|
707 HIWORD(v26) = HIWORD(v42);
|
|
708 LOWORD(v26) = 0;
|
|
709 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i));
|
|
710 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0;
|
|
711 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0;
|
|
712 if ( !(object->uAttributes & 0x20) )
|
|
713 {
|
|
714 if ( !pRenderD3D )
|
|
715 {
|
|
716 __debugbreak();
|
|
717 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0;
|
|
718 }
|
|
719 }
|
|
720 //if (::uNumBillboardsToDraw >= 500)
|
|
721 // return;
|
|
722 assert(::uNumBillboardsToDraw < 500);
|
|
723 ++::uNumBillboardsToDraw;
|
|
724 ++uNumSpritesDrawnThisFrame;
|
|
725 }
|
|
726 }
|
|
727 }
|
|
728 }
|
|
729 }
|
|
730 }
|
|
731
|
|
732 //----- (0049D9BC) --------------------------------------------------------
|
|
733 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut)
|
|
734 {
|
|
735 size_t v4; // eax@1
|
|
736 size_t v5; // eax@1
|
|
737 size_t v7; // eax@13
|
|
738 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11
|
|
739 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16*/
|
|
740 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14
|
|
741 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14
|
|
742 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19
|
|
743 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18
|
|
744 int is_there_a_compatible_screen_mode; // [sp+4C8h] [bp-34h]@16
|
|
745 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1
|
|
746 LPDIRECTDRAW pDirectDraw = nullptr; // [sp+4F4h] [bp-8h]@4
|
|
747 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7
|
|
748
|
|
749 v4 = strlen(lpDriverName);
|
|
750 v20.pDriverName = new char[v4 + 1];
|
|
751 v5 = strlen(lpDevDesc);
|
|
752 v20.pDeviceDesc = new char[v5 + 1];
|
|
753 strcpy(v20.pDriverName, lpDriverName);
|
|
754 strcpy(v20.pDeviceDesc, lpDevDesc);
|
|
755 if ( lpGUID )
|
|
756 {
|
|
757 v20.pGUID = new GUID;
|
|
758 memcpy(v20.pGUID, lpGUID, 0x10);
|
|
759 }
|
|
760 else
|
|
761 v20.pGUID = 0;
|
|
762
|
|
763 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0)))
|
|
764 {
|
|
765 delete [] v20.pDriverName;
|
|
766 delete [] v20.pDeviceDesc;
|
|
767 delete v20.pGUID;
|
|
768 }
|
|
769 else
|
|
770 {
|
|
771 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4)))
|
|
772 {
|
|
773 delete [] v20.pDriverName;
|
|
774 delete [] v20.pDeviceDesc;
|
|
775 delete v20.pGUID;
|
|
776 pDirectDraw->Release();
|
|
777 }
|
|
778 else
|
|
779 {
|
|
780 pDirectDraw->Release();
|
|
781 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1)))
|
|
782 v20.pDDraw4DevDesc = 0;
|
|
783 else
|
|
784 {
|
|
785 v7 = strlen(ddDevId.szDescription);
|
|
786 v20.pDDraw4DevDesc = new char[v7 + 1];
|
|
787 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription);
|
|
788 }
|
|
789 memset(&ddsCaps, 0, sizeof(ddsCaps));
|
|
790 if (FAILED(pDirectDraw4->GetAvailableVidMem(&ddsCaps, (LPDWORD)&v20.uVideoMem, (LPDWORD)&uFreeVideoMem)))
|
|
791 v20.uVideoMem = 0;
|
|
792 memset(&v10, 0, sizeof(v10));
|
|
793 v10.dwSize = 124;
|
|
794 v10.dwFlags = 6;
|
|
795 v10.dwHeight = window->GetWidth();
|
|
796 v10.dwWidth = window->GetHeight();
|
|
797 v10.ddpfPixelFormat.dwSize = 32;
|
|
798
|
|
799 is_there_a_compatible_screen_mode = false;
|
|
800 if ( FAILED(pDirectDraw4->EnumDisplayModes(0, 0, &is_there_a_compatible_screen_mode, (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator))
|
|
801 || !is_there_a_compatible_screen_mode
|
|
802 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3)))
|
|
803 {
|
|
804 delete [] v20.pDriverName;
|
|
805 delete [] v20.pDeviceDesc;
|
|
806 //free(v20.pDDraw4DevDesc);
|
|
807 delete [] v20.pDDraw4DevDesc;
|
|
808 delete v20.pGUID;
|
|
809 pDirectDraw4->Release();
|
|
810 }
|
|
811 else
|
|
812 {
|
|
813 aux.pInfo = pOut;
|
|
814 aux.ptr_4 = &v20;
|
|
815 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux);
|
|
816 delete [] v20.pDriverName;
|
|
817 delete [] v20.pDeviceDesc;
|
|
818 delete [] v20.pDDraw4DevDesc;
|
|
819 delete v20.pGUID;
|
|
820 pDirectDraw4->Release();
|
|
821 pDirectDraw4 = 0;
|
|
822 pDirect3D3->Release();
|
|
823 }
|
|
824 }
|
|
825 }
|
|
826 return 1;
|
|
827 }
|
|
828
|
|
829 //----- (0049D784) --------------------------------------------------------
|
|
830 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6)
|
|
831 {
|
|
832 signed int v7; // edi@1
|
|
833
|
|
834 v7 = -1;
|
|
835 if ( pHWDesc->dwFlags )
|
|
836 {
|
|
837 if ( !a6->ptr_4->pGUID )
|
|
838 v7 = 0;
|
|
839 if ( pHWDesc->dwFlags && a6->ptr_4->pGUID )
|
|
840 v7 = 1;
|
|
841 }
|
|
842 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID )
|
|
843 v7 = 2;
|
|
844 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID )
|
|
845 v7 = 3;
|
|
846 if ( v7 != -1 )
|
|
847 {
|
|
848 a6->pInfo[v7].bIsDeviceCompatible = 1;
|
|
849 a6->pInfo[v7].uCaps = 0;
|
|
850 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) )
|
|
851 a6->pInfo[v7].uCaps |= 2;
|
|
852 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) )
|
|
853 a6->pInfo[v7].uCaps |= 4;
|
|
854 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) )
|
|
855 a6->pInfo[v7].uCaps |= 8;
|
|
856 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) )
|
|
857 a6->pInfo[v7].uCaps |= 16;
|
|
858 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) )
|
|
859 a6->pInfo[v7].uCaps |= 32;
|
|
860 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) )
|
|
861 a6->pInfo[v7].uCaps |= 64;
|
|
862 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) )
|
|
863 BYTE1(a6->pInfo[v7].uCaps) |= 1;
|
|
864 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 )
|
|
865 LOBYTE(a6->pInfo[v7].uCaps) |= 0x80;
|
|
866
|
|
867 a6->pInfo[v7].pName = new char[strlen(lpDeviceName) + 1];
|
|
868 strcpy(a6->pInfo[v7].pName, lpDeviceName);
|
|
869
|
|
870 a6->pInfo[v7].pDescription = new char[strlen(lpDeviceDesc) + 1];
|
|
871 strcpy(a6->pInfo[v7].pDescription, lpDeviceDesc);
|
|
872
|
|
873 a6->pInfo[v7].pGUID = new GUID;
|
|
874 memcpy(a6->pInfo[v7].pGUID, lpGUID, 0x10);
|
|
875
|
|
876 a6->pInfo[v7].pDriverName = new char[strlen(a6->ptr_4->pDriverName) + 1];
|
|
877 strcpy(a6->pInfo[v7].pDriverName, a6->ptr_4->pDriverName);
|
|
878
|
|
879 a6->pInfo[v7].pDeviceDesc = new char[strlen(a6->ptr_4->pDeviceDesc) + 1];
|
|
880 strcpy(a6->pInfo[v7].pDeviceDesc, a6->ptr_4->pDeviceDesc);
|
|
881
|
|
882 a6->pInfo[v7].pDDraw4DevDesc = new char[strlen(a6->ptr_4->pDDraw4DevDesc) + 1];
|
|
883 strcpy(a6->pInfo[v7].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc);
|
|
884
|
|
885 if ( a6->ptr_4->pGUID )
|
|
886 {
|
|
887 a6->pInfo[v7].pDirectDrawGUID = new GUID;
|
|
888 memcpy(a6->pInfo[v7].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10);
|
|
889 }
|
|
890 else
|
|
891 a6->pInfo[v7].pDirectDrawGUID = 0;
|
|
892 a6->pInfo[v7].uVideoMem = a6->ptr_4->uVideoMem;
|
|
893 }
|
|
894 return 1;
|
|
895 }
|
|
896
|
|
897 //----- (0049D75C) --------------------------------------------------------
|
|
898 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *found_compatible_mode)
|
|
899 {
|
|
900 if ( pSurfaceDesc->ddsCaps.dwCaps | DDSCAPS_3DDEVICE /*&& pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16*/ )
|
|
901 {
|
|
902 *found_compatible_mode = 1;
|
|
903 return S_OK;
|
|
904 }
|
|
905 return 1;
|
|
906 }
|
|
907
|
|
908 //----- (0047A95E) --------------------------------------------------------
|
|
909 void Render::PrepareDecorationsRenderList_ODM()
|
|
910 {
|
|
911 unsigned int v6; // edi@9
|
|
912 int v7; // eax@9
|
|
913 SpriteFrame *v8; // eax@9
|
|
914 unsigned __int16 *v10; // eax@9
|
|
915 int v13; // ecx@9
|
|
916 int v14; // ecx@20
|
|
917 char v15; // dl@20
|
|
918 signed int v16; // eax@20
|
|
919 int v17; // eax@23
|
|
920 int v18; // ecx@24
|
|
921 int v19; // eax@24
|
|
922 int v20; // ecx@24
|
|
923 int v21; // ebx@26
|
|
924 int v22; // eax@26
|
|
925 signed __int64 v24; // qtt@31
|
|
926 int v25; // ebx@31
|
|
927 __int16 v29; // cx@37
|
|
928 int v30; // ecx@37
|
|
929 int v31; // ebx@37
|
|
930 Particle_sw local_0; // [sp+Ch] [bp-98h]@7
|
|
931 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9
|
|
932 int v38; // [sp+88h] [bp-1Ch]@9
|
|
933 int v40; // [sp+90h] [bp-14h]@24
|
|
934 int v41; // [sp+94h] [bp-10h]@24
|
|
935 int v42; // [sp+98h] [bp-Ch]@9
|
|
936 int b; // [sp+A0h] [bp-4h]@22
|
|
937
|
|
938 for (unsigned int i = 0; i < uNumLevelDecorations; ++i)
|
|
939 {
|
|
940 //LevelDecoration* decor = &pLevelDecorations[i];
|
|
941 if ((!(pLevelDecorations[i].uFlags & LEVEL_DECORATION_OBELISK_CHEST)
|
|
942 || pLevelDecorations[i].IsObeliskChestActive()) && !(pLevelDecorations[i].uFlags & LEVEL_DECORATION_INVISIBLE))
|
|
943 {
|
|
944 DecorationDesc* decor_desc = &pDecorationList->pDecorations[pLevelDecorations[i].uDecorationDescID];
|
|
945 if ( (char)decor_desc->uFlags >= 0 )
|
|
946 {
|
|
947 if ( !(decor_desc->uFlags & 0x22) )
|
|
948 {
|
|
949 v6 = pMiscTimer->uTotalGameTimeElapsed;
|
|
950 v7 = abs(pLevelDecorations[i].vPosition.x + pLevelDecorations[i].vPosition.y);
|
|
951
|
|
952 #pragma region "New: seasons change"
|
|
953 extern bool change_seasons;
|
|
954 if (change_seasons)
|
|
955 switch (pParty->uCurrentMonth)
|
|
956 {
|
|
957 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites
|
|
958 case 11: case 0: case 1: // winter
|
|
959 switch (decor_desc->uSpriteID)
|
|
960 {
|
|
961 //case 468: //bush02 grows on swamps, which are evergreeen actually
|
|
962 case 548: // flower10
|
|
963 case 547: // flower09
|
|
964 case 541: // flower03
|
|
965 case 539: continue; // flower01
|
|
966
|
|
967 case 483: // tree01
|
|
968 case 486: // tree04
|
|
969 case 492: // tree10
|
|
970 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2);
|
|
971 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7);
|
|
972 break;
|
|
973
|
|
974 default:
|
|
975 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
|
|
976 }
|
|
977 break;
|
|
978
|
|
979 case 2: case 3: case 4: // spring
|
|
980 switch (decor_desc->uSpriteID)
|
|
981 {
|
|
982 }
|
|
983 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
|
|
984 break;
|
|
985
|
|
986 case 8: case 9: case 10: // autumn
|
|
987 switch (decor_desc->uSpriteID)
|
|
988 {
|
|
989 //case 468: //bush02 grows on swamps, which are evergreeen actually
|
|
990 case 548: // flower10
|
|
991 case 547: // flower09
|
|
992 case 541: // flower03
|
|
993 case 539: continue; // flower01
|
|
994
|
|
995 case 483: // tree01
|
|
996 case 486: // tree04
|
|
997 case 492: // tree10
|
|
998 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1);
|
|
999 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7);
|
|
1000 break;
|
|
1001
|
|
1002 default:
|
|
1003 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
|
|
1004 }
|
|
1005 break;
|
|
1006
|
|
1007 case 5: case 6: case 7: // summer
|
|
1008 //all green by default
|
|
1009 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
|
|
1010 break;
|
|
1011
|
|
1012 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12);
|
|
1013 }
|
|
1014 else
|
|
1015 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
|
|
1016 #pragma endregion
|
|
1017 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
|
|
1018
|
|
1019 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x,
|
|
1020 pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y);
|
|
1021 v38 = 0;
|
|
1022 v13 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + pLevelDecorations[i].field_10_y_rot - (signed int)v10) >> 8) & 7;
|
|
1023 v37 = (unsigned __int16 *)v13;
|
|
1024 if ( v8->uFlags & 2 )
|
|
1025 v38 = 2;
|
|
1026 if ( (256 << v13) & v8->uFlags )
|
|
1027 v38 |= 4;
|
|
1028 if ( v8->uFlags & 0x40000 )
|
|
1029 v38 |= 0x40;
|
|
1030 if ( v8->uFlags & 0x20000 )
|
|
1031 LOBYTE(v38) = v38 | 0x80;
|
|
1032 if ( v8->uGlowRadius )
|
|
1033 {
|
|
1034 if ( pRenderD3D && bUseColoredLights )
|
|
1035 {
|
|
1036 v14 = /*255;//*/decor_desc->uColoredLightRed;
|
|
1037 v15 = /*255;//*/decor_desc->uColoredLightGreen;
|
|
1038 v16 = /*255;//*/decor_desc->uColoredLightBlue;
|
|
1039 }
|
|
1040 else
|
|
1041 {
|
|
1042 v16 = 255;
|
|
1043 v14 = 255;
|
|
1044 v15 = 255;
|
|
1045 }
|
|
1046 pStationaryLightsStack->AddLight(pLevelDecorations[i].vPosition.x, pLevelDecorations[i].vPosition.y, pLevelDecorations[i].vPosition.z + decor_desc->uDecorationHeight / 2,
|
|
1047 v8->uGlowRadius, v14, v15, v16, _4E94D0_light_type);
|
|
1048 }
|
|
1049 v17 = (pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16;
|
|
1050 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
1051 {
|
|
1052 v40 = (pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16;
|
|
1053 v18 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y);
|
|
1054 v41 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x);
|
|
1055 v19 = fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_cosine_x);
|
|
1056 v20 = v19 + fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x);
|
|
1057 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 )
|
|
1058 {
|
|
1059 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_sine_y);
|
|
1060 v22 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_sine_x);
|
|
1061 if ( 2 * abs(v20) >= abs(v21) )
|
|
1062 {
|
|
1063 LODWORD(v24) = 0;
|
|
1064 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad);
|
|
1065 v25 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v24 / v20, v21) + 0x8000) >> 16);
|
|
1066 v40 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(v24 / v20, v22) + 0x8000) >> 16);
|
|
1067 v41 = fixpoint_mul(v8->scale, v24 / v20);
|
|
1068 if ( pRenderD3D )
|
|
1069 b = fixpoint_mul(pSprites_LOD->pHardwareSprites[v8->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41);
|
|
1070 else
|
|
1071 {
|
|
1072 __debugbreak();
|
|
1073 b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[v8->pHwSpriteIDs[(int)v37]].uWidth / 2, v41);
|
|
1074 }
|
|
1075 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X )
|
|
1076 {
|
|
1077 if (::uNumBillboardsToDraw >= 500)
|
|
1078 return;
|
|
1079 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37];
|
|
1080 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41;
|
|
1081 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41;
|
|
1082 v29 = v38;
|
|
1083 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25;
|
|
1084 HIBYTE(v29) |= 2;
|
|
1085 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex;
|
|
1086 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29;
|
|
1087 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x;
|
|
1088 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y;
|
|
1089 pBillboardRenderList[::uNumBillboardsToDraw].world_z = pLevelDecorations[i].vPosition.z;
|
|
1090 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40;
|
|
1091 HIWORD(v30) = HIWORD(v20);
|
|
1092 v31 = PID(OBJECT_Decoration,i);
|
|
1093 LOWORD(v30) = 0;
|
|
1094 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0;
|
|
1095 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31;
|
|
1096 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0;
|
|
1097 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8;
|
|
1098 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0;
|
|
1099 ::uNumBillboardsToDraw++;
|
|
1100 ++uNumDecorationsDrawnThisFrame;
|
|
1101 }
|
|
1102 }
|
|
1103 continue;
|
|
1104 }
|
|
1105 }
|
|
1106 else
|
|
1107 {
|
|
1108 v42 = (pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16;
|
|
1109 v40 = (pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16;
|
|
1110 v20 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y);
|
|
1111 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 )
|
|
1112 {
|
|
1113 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_y);
|
|
1114 v22 = (pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
|
|
1115 v42 = v22;
|
|
1116 if ( 2 * abs(v20) >= abs(v21) )
|
|
1117 {
|
|
1118 LODWORD(v24) = 0;
|
|
1119 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad);
|
|
1120 v25 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v24 / v20, v21) + 0x8000) >> 16);
|
|
1121 v40 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(v24 / v20, v42) + 0x8000) >> 16);
|
|
1122 v41 = fixpoint_mul(v8->scale, v24 / v20);
|
|
1123 if ( pRenderD3D )
|
|
1124 b = fixpoint_mul(pSprites_LOD->pHardwareSprites[v8->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41);
|
|
1125 else
|
|
1126 {
|
|
1127 __debugbreak();
|
|
1128 b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[v8->pHwSpriteIDs[(int)v37]].uWidth / 2, v41);
|
|
1129 }
|
|
1130 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X )
|
|
1131 {
|
|
1132 if (::uNumBillboardsToDraw >= 500)
|
|
1133 return;
|
|
1134 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = v8->pHwSpriteIDs[(int)v37];
|
|
1135 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41;
|
|
1136 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41;
|
|
1137 v29 = v38;
|
|
1138 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25;
|
|
1139 HIBYTE(v29) |= 2;
|
|
1140 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex;
|
|
1141 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29;
|
|
1142 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x;
|
|
1143 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y;
|
|
1144 pBillboardRenderList[::uNumBillboardsToDraw].world_z = pLevelDecorations[i].vPosition.z;
|
|
1145 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40;
|
|
1146 HIWORD(v30) = HIWORD(v20);
|
|
1147 v31 = PID(OBJECT_Decoration,i);
|
|
1148 LOWORD(v30) = 0;
|
|
1149 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0;
|
|
1150 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31;
|
|
1151 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0;
|
|
1152 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8;
|
|
1153 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0;
|
|
1154 ::uNumBillboardsToDraw++;
|
|
1155 ++uNumDecorationsDrawnThisFrame;
|
|
1156 }
|
|
1157 }
|
|
1158 continue;
|
|
1159 }
|
|
1160 }
|
|
1161 }
|
|
1162 }
|
|
1163 else
|
|
1164 {
|
|
1165 memset(&local_0, 0, 0x68);
|
|
1166 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
|
|
1167 local_0.uDiffuse = 0xFF3C1E;
|
|
1168 local_0.x = (double)pLevelDecorations[i].vPosition.x;
|
|
1169 local_0.y = (double)pLevelDecorations[i].vPosition.y;
|
|
1170 local_0.z = (double)pLevelDecorations[i].vPosition.z;
|
|
1171 local_0.r = 0.0;
|
|
1172 local_0.g = 0.0;
|
|
1173 local_0.b = 0.0;
|
|
1174 local_0.flt_28 = 1.0;
|
|
1175 local_0.timeToLive = (rand() & 0x80) + 128;
|
|
1176 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01");
|
|
1177 pGame->pParticleEngine->AddParticle(&local_0);
|
|
1178 }
|
|
1179 }
|
|
1180 }
|
|
1181 }
|
|
1182
|
|
1183 //----- (0049D717) --------------------------------------------------------
|
|
1184 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst)
|
|
1185 {
|
|
1186 if ( Src->dwFlags & (0x400 | 0x2000))
|
|
1187 {
|
|
1188 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask )
|
|
1189 {
|
|
1190 memcpy(Dst, Src, sizeof(DDPIXELFORMAT));
|
|
1191 return 0;
|
|
1192 }
|
|
1193 if ( !Dst->dwSize )
|
|
1194 {
|
|
1195 memcpy(Dst, Src, sizeof(DDPIXELFORMAT));
|
|
1196 return 1;
|
|
1197 }
|
|
1198 }
|
|
1199 return 1;
|
|
1200 }
|
|
1201
|
|
1202 //----- (0049DC28) --------------------------------------------------------
|
|
1203 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices)
|
|
1204 {
|
|
1205 RenderD3D__DevInfo *v2; // eax@1
|
|
1206
|
|
1207 v2 = new RenderD3D__DevInfo[4];// 4 items
|
|
1208 *pOutDevices = v2;
|
|
1209 memset(v2, 0, sizeof(v2));
|
|
1210 DirectDrawEnumerateExA((LPDDENUMCALLBACKEXA)RenderD3D__DeviceEnumerator, *pOutDevices, DDENUM_ATTACHEDSECONDARYDEVICES);
|
|
1211 }
|
|
1212
|
|
1213 //----- (0049DC58) --------------------------------------------------------
|
|
1214 RenderD3D::RenderD3D()
|
|
1215 {
|
|
1216 this->pHost = nullptr;
|
|
1217 this->pDirect3D = nullptr;
|
|
1218 this->pUnk = nullptr;
|
|
1219 this->pBackBuffer = nullptr;
|
|
1220 this->pFrontBuffer = nullptr;
|
|
1221 this->pZBuffer = nullptr;
|
|
1222 this->pDevice = nullptr;
|
|
1223 this->pViewport = nullptr;
|
|
1224 this->field_40 = 1;
|
|
1225 this->field_44 = 10;
|
|
1226 GetAvailableDevices(&this->pAvailableDevices);
|
|
1227 }
|
|
1228
|
|
1229 //----- (0049DC90) --------------------------------------------------------
|
|
1230 void RenderD3D::Release()
|
|
1231 {
|
|
1232 if ( !this->bWindowed )
|
|
1233 {
|
|
1234 if ( this->pHost )
|
|
1235 {
|
|
1236 this->pHost->RestoreDisplayMode();
|
|
1237 this->pHost->SetCooperativeLevel(this->hWindow, DDSCL_NORMAL);
|
|
1238 this->pHost->FlipToGDISurface();
|
|
1239 }
|
|
1240 }
|
|
1241
|
|
1242 for (int i = 0; i < 4; i++)
|
|
1243 {
|
|
1244 delete[] this->pAvailableDevices[i].pDriverName;
|
|
1245 this->pAvailableDevices[i].pDriverName = nullptr;
|
|
1246
|
|
1247 delete[] this->pAvailableDevices[i].pDeviceDesc;
|
|
1248 this->pAvailableDevices[i].pDeviceDesc = nullptr;
|
|
1249
|
|
1250 delete[] this->pAvailableDevices[i].pDDraw4DevDesc;
|
|
1251 this->pAvailableDevices[i].pDDraw4DevDesc = nullptr;
|
|
1252
|
|
1253 delete this->pAvailableDevices[i].pDirectDrawGUID;
|
|
1254 this->pAvailableDevices[i].pDirectDrawGUID = nullptr;
|
|
1255
|
|
1256 delete[] this->pAvailableDevices[i].pName;
|
|
1257 this->pAvailableDevices[i].pName = nullptr;
|
|
1258
|
|
1259 delete[] this->pAvailableDevices[i].pDescription;
|
|
1260 this->pAvailableDevices[i].pDescription = nullptr;
|
|
1261
|
|
1262 delete this->pAvailableDevices[i].pGUID;
|
|
1263 this->pAvailableDevices[i].pGUID = nullptr;
|
|
1264 }
|
|
1265
|
|
1266 delete[] this->pAvailableDevices;
|
|
1267 this->pAvailableDevices = NULL;
|
|
1268
|
|
1269 if ( this->pViewport )
|
|
1270 {
|
|
1271 this->pViewport->Release();
|
|
1272 this->pViewport = NULL;
|
|
1273 }
|
|
1274
|
|
1275 if ( this->pUnk )
|
|
1276 {
|
|
1277 this->pUnk->Release();
|
|
1278 this->pUnk = NULL;
|
|
1279 }
|
|
1280
|
|
1281 if ( this->pZBuffer )
|
|
1282 {
|
|
1283 this->pZBuffer->Release();
|
|
1284 this->pZBuffer = NULL;
|
|
1285 }
|
|
1286
|
|
1287 if ( this->pDevice )
|
|
1288 {
|
|
1289 this->pDevice->Release();
|
|
1290 this->pDevice = NULL;
|
|
1291 }
|
|
1292
|
|
1293 if ( this->pDirect3D )
|
|
1294 {
|
|
1295 this->pDirect3D->Release();
|
|
1296 this->pDirect3D = NULL;
|
|
1297 }
|
|
1298
|
|
1299 if ( this->pBackBuffer )
|
|
1300 {
|
|
1301 this->pBackBuffer->Release();
|
|
1302 this->pBackBuffer = NULL;
|
|
1303 }
|
|
1304
|
|
1305 if ( this->pFrontBuffer )
|
|
1306 {
|
|
1307 this->pFrontBuffer->Release();
|
|
1308 this->pFrontBuffer = NULL;
|
|
1309 }
|
|
1310
|
|
1311 if ( this->pHost )
|
|
1312 {
|
|
1313 this->pHost->Release();
|
|
1314 this->pHost = NULL;
|
|
1315 }
|
|
1316 }
|
|
1317
|
|
1318 //----- (0049DE14) --------------------------------------------------------
|
|
1319 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window)
|
|
1320 {
|
|
1321 DWORD v26; // [sp-4h] [bp-DCh]@30
|
|
1322 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37
|
|
1323 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11
|
|
1324 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28
|
|
1325 IDirectDrawClipper *lpddclipper; // [sp+C4h] [bp-14h]@18
|
|
1326 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1
|
|
1327
|
|
1328 auto hWnd = window->GetApiHandle();
|
|
1329 int game_width = window->GetWidth();
|
|
1330 int game_height = window->GetHeight();
|
|
1331
|
|
1332 this->bWindowed = bWindowed;
|
|
1333 this->hWindow = hWnd;
|
|
1334
|
|
1335 //Ñîçäàíèå îáúåêòà DirectDraw
|
|
1336 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, NULL)))
|
|
1337 {
|
|
1338 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n");
|
|
1339 return 0;
|
|
1340 }
|
|
1341
|
|
1342 //Çàïðîñ èíòåðôåéñà IDirectDraw4
|
|
1343 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost)))
|
|
1344 {
|
|
1345 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n");
|
|
1346 if (lpDD)
|
|
1347 lpDD->Release();
|
|
1348 return 0;
|
|
1349 }
|
|
1350 lpDD->Release();
|
|
1351 lpDD = NULL;
|
|
1352
|
|
1353 //Çàäà¸ì óðîâåíü ñîâìåñòíîãî äîñòóïà äëÿ ïðèëîæåíèÿ DirectDraw â îêîííîì ðåæèìå
|
|
1354 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID)
|
|
1355 {
|
|
1356 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL)))
|
|
1357 {
|
|
1358 sprintf(pErrorMessage, "Init - Failed to set cooperative level.\n");
|
|
1359 if (pHost)
|
|
1360 {
|
|
1361 pHost->Release();
|
|
1362 pHost = NULL;
|
|
1363 }
|
|
1364 return 0;
|
|
1365 }
|
|
1366
|
|
1367 //
|
|
1368 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2));
|
|
1369 ddsd2.dwSize = sizeof(DDSURFACEDESC2);
|
|
1370 ddsd2.dwFlags = DDSD_CAPS;
|
|
1371 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
|
1372 //Ñîçäà¸ì ïåðâè÷íóþ ïîâåðõíîñòü
|
|
1373 if ( FAILED(pHost->CreateSurface(&ddsd2, &pFrontBuffer, NULL)) )
|
|
1374 {
|
|
1375 sprintf(pErrorMessage, "Init - Failed to create front buffer.\n");
|
|
1376 if (pHost)
|
|
1377 {
|
|
1378 pHost->Release();
|
|
1379 pHost = NULL;
|
|
1380 }
|
|
1381 return 0;
|
|
1382 }
|
|
1383 ddsd2.dwSize = sizeof(DDSURFACEDESC2);
|
|
1384 pHost->GetDisplayMode(&ddsd2);
|
|
1385 if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 )
|
|
1386 {
|
|
1387 sprintf(pErrorMessage, "Init - Desktop isn't in 16 bit mode.\n");
|
|
1388 if (pFrontBuffer)
|
|
1389 {
|
|
1390 pFrontBuffer->Release();
|
|
1391 pFrontBuffer = NULL;
|
|
1392 }
|
|
1393 if (pHost)
|
|
1394 {
|
|
1395 pHost->Release();
|
|
1396 pHost = NULL;
|
|
1397 }
|
|
1398 return 0;
|
|
1399 }
|
|
1400
|
|
1401 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
|
|
1402 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
|
|
1403 ddsd2.dwWidth = game_width;
|
|
1404 ddsd2.dwHeight = game_height;
|
|
1405 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, NULL) )
|
|
1406 {
|
|
1407 sprintf(pErrorMessage, "Init - Failed to create back buffer.\n");
|
|
1408 if (pFrontBuffer)
|
|
1409 {
|
|
1410 pFrontBuffer->Release();
|
|
1411 pFrontBuffer = NULL;
|
|
1412 }
|
|
1413 if (pHost)
|
|
1414 {
|
|
1415 pHost->Release();
|
|
1416 pHost = NULL;
|
|
1417 }
|
|
1418 return 0;
|
|
1419 }
|
|
1420 //Ñîçäàíèå îòñåêàòåëÿ DirectDraw
|
|
1421 if ( pHost->CreateClipper(0, &lpddclipper, NULL) )
|
|
1422 {
|
|
1423 sprintf(pErrorMessage, "Init - Failed to create clipper.\n");
|
|
1424 if (pBackBuffer)
|
|
1425 {
|
|
1426 pBackBuffer->Release();
|
|
1427 pBackBuffer = NULL;
|
|
1428 }
|
|
1429 if (pFrontBuffer)
|
|
1430 {
|
|
1431 pFrontBuffer->Release();
|
|
1432 pFrontBuffer= NULL;
|
|
1433 }
|
|
1434 if (pHost)
|
|
1435 {
|
|
1436 pHost->Release();
|
|
1437 pHost = NULL;
|
|
1438 }
|
|
1439 return 0;
|
|
1440 }
|
|
1441 lpddclipper->SetHWnd(0, hWnd);
|
|
1442 pFrontBuffer->SetClipper(lpddclipper);
|
|
1443
|
|
1444 lpddclipper->Release();
|
|
1445 lpddclipper = NULL;
|
|
1446 //
|
|
1447
|
|
1448 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D);
|
|
1449
|
|
1450 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
|
1451 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
|
|
1452 ddsd2.dwWidth = game_width;
|
|
1453 ddsd2.dwHeight = game_height;
|
|
1454
|
|
1455 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID,
|
|
1456 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator,
|
|
1457 &ddsd2.ddpfPixelFormat) )
|
|
1458 {
|
|
1459 sprintf(pErrorMessage, "Init - Failed to enumerate Z buffer formats.\n");
|
|
1460 if (pBackBuffer)
|
|
1461 {
|
|
1462 pBackBuffer->Release();
|
|
1463 pBackBuffer = NULL;
|
|
1464 }
|
|
1465 if (pFrontBuffer)
|
|
1466 {
|
|
1467 pFrontBuffer->Release();
|
|
1468 pFrontBuffer= NULL;
|
|
1469 }
|
|
1470 if (pHost)
|
|
1471 {
|
|
1472 pHost->Release();
|
|
1473 pHost = NULL;
|
|
1474 }
|
|
1475 return 0;
|
|
1476 }
|
|
1477 if ( uDeviceID == 2 || uDeviceID == 3 )
|
|
1478 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
|
|
1479
|
|
1480 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, NULL) )
|
|
1481 {
|
|
1482 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) )
|
|
1483 {
|
|
1484 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, pBackBuffer, &pDevice, 0) )
|
|
1485 {
|
|
1486 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2));
|
|
1487 d3dvp2.dvClipWidth = 2.0;
|
|
1488 d3dvp2.dvClipY = 1.0;
|
|
1489 d3dvp2.dvClipHeight = 2.0;
|
|
1490 d3dvp2.dvMaxZ = 1.0;
|
|
1491 d3dvp2.dvMinZ = 0.0;
|
|
1492 goto LABEL_54;
|
|
1493 }
|
|
1494 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n");
|
|
1495 if (pDirect3D)
|
|
1496 {
|
|
1497 pDirect3D->Release();
|
|
1498 pDirect3D = NULL;
|
|
1499 }
|
|
1500 if (pZBuffer)
|
|
1501 {
|
|
1502 pZBuffer->Release();
|
|
1503 pZBuffer = NULL;
|
|
1504 }
|
|
1505 if (pBackBuffer)
|
|
1506 {
|
|
1507 pBackBuffer->Release();
|
|
1508 pBackBuffer = NULL;
|
|
1509 }
|
|
1510 if (pFrontBuffer)
|
|
1511 {
|
|
1512 pFrontBuffer->Release();
|
|
1513 pFrontBuffer= NULL;
|
|
1514 }
|
|
1515 if (pHost)
|
|
1516 {
|
|
1517 pHost->Release();
|
|
1518 pHost = NULL;
|
|
1519 }
|
|
1520 return 0;
|
|
1521 }
|
|
1522 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n");
|
|
1523 if (pZBuffer)
|
|
1524 {
|
|
1525 pZBuffer->Release();
|
|
1526 pZBuffer = NULL;
|
|
1527 }
|
|
1528 if (pBackBuffer)
|
|
1529 {
|
|
1530 pBackBuffer->Release();
|
|
1531 pBackBuffer = NULL;
|
|
1532 }
|
|
1533 if (pFrontBuffer)
|
|
1534 {
|
|
1535 pFrontBuffer->Release();
|
|
1536 pFrontBuffer= NULL;
|
|
1537 }
|
|
1538 if (pHost)
|
|
1539 {
|
|
1540 pHost->Release();
|
|
1541 pHost = NULL;
|
|
1542 }
|
|
1543 return 0;
|
|
1544 }
|
|
1545 sprintf(pErrorMessage, "Init - Failed to create z-buffer.\n");
|
|
1546 if (pBackBuffer)
|
|
1547 {
|
|
1548 pBackBuffer->Release();
|
|
1549 pBackBuffer = NULL;
|
|
1550 }
|
|
1551 if (pFrontBuffer)
|
|
1552 {
|
|
1553 pFrontBuffer->Release();
|
|
1554 pFrontBuffer= NULL;
|
|
1555 }
|
|
1556 if (pHost)
|
|
1557 {
|
|
1558 pHost->Release();
|
|
1559 pHost = NULL;
|
|
1560 }
|
|
1561 return 0;
|
|
1562 }
|
|
1563 if ( uDeviceID == 1 )
|
|
1564 v26 = 1045;
|
|
1565 else
|
|
1566 v26 = 1041;
|
|
1567 if (pHost->SetCooperativeLevel(hWnd, v26) )
|
|
1568 {
|
|
1569 sprintf(pErrorMessage, "Init - Failed to set cooperative level.\n");
|
|
1570 if (pHost)
|
|
1571 {
|
|
1572 pHost->Release();
|
|
1573 pHost = NULL;
|
|
1574 }
|
|
1575 return 0;
|
|
1576 }
|
|
1577 if (pHost->SetDisplayMode(window->GetWidth(), window->GetHeight(), 16, 0, 0) )
|
|
1578 {
|
|
1579 sprintf(pErrorMessage, "Init - Failed to set display mode.\n");
|
|
1580 if (pHost)
|
|
1581 {
|
|
1582 pHost->Release();
|
|
1583 pHost = NULL;
|
|
1584 }
|
|
1585 return 0;
|
|
1586 }
|
|
1587
|
|
1588 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2));
|
|
1589 ddsd2.dwSize = sizeof(DDSURFACEDESC2);
|
|
1590 //Ïîäêëþ÷åíèå ïîëåé ñ äîñòîâåðíûìè äàííûìè
|
|
1591 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
|
|
1592 //Çàïðîñ ñëîæíîé ñòðóêòóðû ñ âîçìîæíîñòüþ ïåðåêëþ÷åíèÿ
|
|
1593 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
|
|
1594 //Ïðèñâîåíèå ïîëþ ñ÷¸ò÷èêà çàäíèõ áóôåðîâ çíà÷åíèÿ 1
|
|
1595 ddsd2.dwBackBufferCount = 1;
|
|
1596 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, NULL) )
|
|
1597 {
|
|
1598 sprintf(pErrorMessage, "Init - Failed to create front buffer.\n");
|
|
1599 if (pHost)
|
|
1600 {
|
|
1601 pHost->Release();
|
|
1602 pHost = NULL;
|
|
1603 }
|
|
1604 return 0;
|
|
1605 }
|
|
1606 //a3a = &pBackBuffer;
|
|
1607 //v14 = *v34;
|
|
1608 memset(&v27, 0, sizeof(DDSCAPS2));
|
|
1609
|
|
1610 v27.dwCaps = DDSCAPS_BACKBUFFER;
|
|
1611 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer);
|
|
1612 //hWnda = &pDirect3D;
|
|
1613 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D);
|
|
1614
|
|
1615 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer)))
|
|
1616 {
|
|
1617 sprintf(pErrorMessage, "Init - Failed to get D3D interface.\n");
|
|
1618 if (pBackBuffer)
|
|
1619 {
|
|
1620 pBackBuffer->Release();
|
|
1621 pBackBuffer = NULL;
|
|
1622 }
|
|
1623 if (pFrontBuffer)
|
|
1624 {
|
|
1625 pFrontBuffer->Release();
|
|
1626 pFrontBuffer= NULL;
|
|
1627 }
|
|
1628 if (pHost)
|
|
1629 {
|
|
1630 pHost->Release();
|
|
1631 pHost = NULL;
|
|
1632 }
|
|
1633 return 0;
|
|
1634 }
|
|
1635
|
|
1636 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
|
1637 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
|
|
1638 ddsd2.dwWidth = 640;
|
|
1639 ddsd2.dwHeight = 480;
|
|
1640 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID,
|
|
1641 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator,
|
|
1642 &ddsd2.ddpfPixelFormat) )
|
|
1643 {
|
|
1644 sprintf(pErrorMessage, "Init - Failed to enumerate Z buffer formats.\n");
|
|
1645 if (pBackBuffer)
|
|
1646 {
|
|
1647 pBackBuffer->Release();
|
|
1648 pBackBuffer = 0;
|
|
1649 }
|
|
1650 if (pFrontBuffer)
|
|
1651 {
|
|
1652 pFrontBuffer->Release();
|
|
1653 pFrontBuffer= 0;
|
|
1654 }
|
|
1655 if (pHost)
|
|
1656 {
|
|
1657 pHost->Release();
|
|
1658 pHost = 0;
|
|
1659 }
|
|
1660 return 0;
|
|
1661 }
|
|
1662 if ( uDeviceID == 2 || uDeviceID == 3 )
|
|
1663 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8;
|
|
1664 //uDeviceIDa = &pZBuffer;
|
|
1665 if (pHost->CreateSurface(&ddsd2, &pZBuffer, NULL) )
|
|
1666 {
|
|
1667 sprintf(pErrorMessage, "Init - Failed to create z-buffer.\n");
|
|
1668 if (pBackBuffer)
|
|
1669 {
|
|
1670 pBackBuffer->Release();
|
|
1671 pBackBuffer = 0;
|
|
1672 }
|
|
1673 if (pFrontBuffer)
|
|
1674 {
|
|
1675 pFrontBuffer->Release();
|
|
1676 pFrontBuffer= 0;
|
|
1677 }
|
|
1678 if (pHost)
|
|
1679 {
|
|
1680 pHost->Release();
|
|
1681 pHost = 0;
|
|
1682 }
|
|
1683 return 0;
|
|
1684 }
|
|
1685 if (pBackBuffer->AddAttachedSurface(pZBuffer))
|
|
1686 {
|
|
1687 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n");
|
|
1688 if (pZBuffer)
|
|
1689 {
|
|
1690 pZBuffer->Release();
|
|
1691 pZBuffer = 0;
|
|
1692 }
|
|
1693 if (pBackBuffer)
|
|
1694 {
|
|
1695 pBackBuffer->Release();
|
|
1696 pBackBuffer = 0;
|
|
1697 }
|
|
1698 if (pFrontBuffer)
|
|
1699 {
|
|
1700 pFrontBuffer->Release();
|
|
1701 pFrontBuffer= 0;
|
|
1702 }
|
|
1703 if (pHost)
|
|
1704 {
|
|
1705 pHost->Release();
|
|
1706 pHost = 0;
|
|
1707 }
|
|
1708 return 0;
|
|
1709 }
|
|
1710 //v33 = &pDevice;
|
|
1711 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, pBackBuffer, &pDevice, 0) )
|
|
1712 {
|
|
1713 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n");
|
|
1714 if (pDirect3D)
|
|
1715 {
|
|
1716 pDirect3D->Release();
|
|
1717 pDirect3D = 0;
|
|
1718 }
|
|
1719 if (pZBuffer)
|
|
1720 {
|
|
1721 pZBuffer->Release();
|
|
1722 pZBuffer = 0;
|
|
1723 }
|
|
1724 if (pBackBuffer)
|
|
1725 {
|
|
1726 pBackBuffer->Release();
|
|
1727 pBackBuffer = 0;
|
|
1728 }
|
|
1729 if (pFrontBuffer)
|
|
1730 {
|
|
1731 pFrontBuffer->Release();
|
|
1732 pFrontBuffer= 0;
|
|
1733 }
|
|
1734 if (pHost)
|
|
1735 {
|
|
1736 pHost->Release();
|
|
1737 pHost = 0;
|
|
1738 }
|
|
1739 return 0;
|
|
1740 }
|
|
1741 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2));
|
|
1742 d3dvp2.dvClipWidth = 2.0;
|
|
1743 d3dvp2.dvClipY = 1.0;
|
|
1744 d3dvp2.dvClipHeight = 2.0;
|
|
1745 d3dvp2.dvMaxZ = 1.0;
|
|
1746
|
|
1747 LABEL_54:
|
|
1748 d3dvp2.dwSize = sizeof(D3DVIEWPORT2);
|
|
1749 //v17 = *hWnda;
|
|
1750 d3dvp2.dwWidth = game_width;
|
|
1751 d3dvp2.dwHeight = game_height;
|
|
1752 d3dvp2.dvClipX = -1.0;
|
|
1753 //v18 = v17->lpVtbl;
|
|
1754 //v32 = &v4->pViewport;
|
|
1755 if (pDirect3D->CreateViewport(&pViewport, 0))
|
|
1756 {
|
|
1757 sprintf(pErrorMessage, "Init - Failed to create viewport.\n");
|
|
1758 if (pDevice)
|
|
1759 {
|
|
1760 pDevice->Release();
|
|
1761 pDevice = 0;
|
|
1762 }
|
|
1763 if (pDirect3D)
|
|
1764 {
|
|
1765 pDirect3D->Release();
|
|
1766 pDirect3D = 0;
|
|
1767 }
|
|
1768 if (pZBuffer)
|
|
1769 {
|
|
1770 pZBuffer->Release();
|
|
1771 pZBuffer = 0;
|
|
1772 }
|
|
1773 if (pBackBuffer)
|
|
1774 {
|
|
1775 pBackBuffer->Release();
|
|
1776 pBackBuffer = 0;
|
|
1777 }
|
|
1778 if (pFrontBuffer)
|
|
1779 {
|
|
1780 pFrontBuffer->Release();
|
|
1781 pFrontBuffer= 0;
|
|
1782 }
|
|
1783 if (pHost)
|
|
1784 {
|
|
1785 pHost->Release();
|
|
1786 pHost = 0;
|
|
1787 }
|
|
1788 return 0;
|
|
1789 }
|
|
1790
|
|
1791 pDevice->AddViewport(pViewport);
|
|
1792 pViewport->SetViewport2(&d3dvp2);
|
|
1793 pDevice->SetCurrentViewport(pViewport);
|
|
1794 return 1;
|
|
1795 }
|
|
1796
|
|
1797 //----- (0049E444) --------------------------------------------------------
|
|
1798 unsigned int RenderD3D::GetDeviceCaps()
|
|
1799 {
|
|
1800 unsigned int v1; // ebx@1
|
|
1801 unsigned int result; // eax@2
|
|
1802 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1
|
|
1803 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1
|
|
1804
|
|
1805 v1 = 0;
|
|
1806
|
|
1807 memset(&halCaps, 0, sizeof(halCaps));
|
|
1808 halCaps.dwSize = sizeof(halCaps);
|
|
1809
|
|
1810 memset(&refCaps, 0, sizeof(refCaps));
|
|
1811 refCaps.dwSize = sizeof(refCaps);
|
|
1812
|
|
1813 if ( this->pDevice->GetCaps(&halCaps, &refCaps) )
|
|
1814 result = 1;
|
|
1815 else
|
|
1816 {
|
|
1817 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) )
|
|
1818 v1 = 2;
|
|
1819 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ONE) )
|
|
1820 v1 |= 4;
|
|
1821 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ZERO) )
|
|
1822 v1 |= 8;
|
|
1823 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) )
|
|
1824 v1 |= 16;
|
|
1825 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_ONE) )
|
|
1826 v1 |= 32;
|
|
1827 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) )
|
|
1828 v1 |= 64;
|
|
1829 if ( halCaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY )
|
|
1830 v1 |= 128;
|
|
1831 result = v1;
|
|
1832 }
|
|
1833 return result;
|
|
1834 }
|
|
1835
|
|
1836 //----- (0049E4FC) --------------------------------------------------------
|
|
1837 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear)
|
|
1838 {
|
|
1839 uint uClearFlags = 0;
|
|
1840
|
|
1841 if (bClearColor)
|
|
1842 uClearFlags |= D3DCLEAR_TARGET;
|
|
1843 if (bClearDepth)
|
|
1844 uClearFlags |= D3DCLEAR_ZBUFFER;
|
|
1845
|
|
1846 D3DRECT rects[] = {{0, 0, window->GetWidth(), window->GetHeight()}};
|
|
1847 if (uClearFlags)
|
|
1848 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0);
|
|
1849 }
|
|
1850
|
|
1851 //----- (0049E54D) --------------------------------------------------------
|
|
1852 void RenderD3D::Present(bool bForceBlit)
|
|
1853 {
|
|
1854 RECT source_rect; // [sp+18h] [bp-18h]@1
|
|
1855 struct tagPOINT Point; // [sp+28h] [bp-8h]@4
|
|
1856
|
|
1857 source_rect.left = 0;
|
|
1858 source_rect.top = 0;
|
|
1859 source_rect.bottom = 480;//window->GetHeight(); //Ritor1: ïðîáëåìà ñ êíîïêîé "ðàçâåðíóòü"
|
|
1860 source_rect.right = 640; //window->GetWidth();
|
|
1861
|
|
1862 if (bWindowed || bForceBlit)
|
|
1863 {
|
|
1864 RECT dest_rect;
|
|
1865 GetClientRect(hWindow, &dest_rect);
|
|
1866 Point.y = 0;
|
|
1867 Point.x = 0;
|
|
1868 ClientToScreen(hWindow, &Point);
|
|
1869 OffsetRect(&dest_rect, Point.x, Point.y);
|
|
1870 pFrontBuffer->Blt(&dest_rect, pBackBuffer, &source_rect, DDBLT_WAIT, NULL);
|
|
1871 }
|
|
1872 else
|
|
1873 pFrontBuffer->Flip(NULL, DDFLIP_WAIT);
|
|
1874 }
|
|
1875
|
|
1876 //----- (0049E5D4) --------------------------------------------------------
|
|
1877 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim)
|
|
1878 {
|
|
1879 unsigned int v9; // ebx@5
|
|
1880 unsigned int v10; // eax@5
|
|
1881 DWORD v11; // edx@5
|
|
1882 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1
|
|
1883
|
|
1884 memset(&ddsd2, 0, sizeof(ddsd2));
|
|
1885 ddsd2.dwSize = sizeof(ddsd2);
|
|
1886 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
|
1887 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
|
1888 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
|
|
1889 ddsd2.dwHeight = uTextureHeight;
|
|
1890 ddsd2.dwWidth = uTextureWidth;
|
|
1891 if ( bMipmaps )
|
|
1892 {
|
|
1893 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth )
|
|
1894 {
|
|
1895 ddsd2.dwMipMapCount = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim);
|
|
1896 if ( ddsd2.dwMipMapCount )
|
|
1897 {
|
|
1898 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT;
|
|
1899 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
|
|
1900 }
|
|
1901 goto LABEL_12;
|
|
1902 }
|
|
1903 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim )
|
|
1904 {
|
|
1905 ddsd2.dwMipMapCount = GetMaxMipLevels(uMinDeviceTexDim);
|
|
1906 if ( ddsd2.dwMipMapCount )
|
|
1907 {
|
|
1908 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT;
|
|
1909 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
|
|
1910 }
|
|
1911 goto LABEL_12;
|
|
1912 }
|
|
1913 v9 = GetMaxMipLevels(uTextureWidth);
|
|
1914 v10 = GetMaxMipLevels(uMinDeviceTexDim);
|
|
1915 ddsd2.dwMipMapCount = v9 - v10;
|
|
1916 if ( v9 == v10 )
|
|
1917 {
|
|
1918 ddsd2.dwFlags = 0x1007;
|
|
1919 __debugbreak(); // warning C4700: uninitialized local variable 'v11' used
|
|
1920 ddsd2.ddsCaps.dwCaps = v11;
|
|
1921 goto LABEL_12;
|
|
1922 }
|
|
1923 }
|
|
1924 else
|
|
1925 ddsd2.dwMipMapCount = 1;
|
|
1926 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT;
|
|
1927 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
|
|
1928 LABEL_12:
|
|
1929 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16;
|
|
1930 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
|
|
1931 if (bAlphaChannel)
|
|
1932 {
|
|
1933 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
|
|
1934 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00;
|
|
1935 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0;
|
|
1936 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F;
|
|
1937 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000;
|
|
1938 }
|
|
1939 else
|
|
1940 {
|
|
1941 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
|
1942 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800;
|
|
1943 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0;
|
|
1944 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F;
|
|
1945 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0;
|
|
1946 }
|
|
1947 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, NULL)))
|
|
1948 return false;
|
|
1949 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture)))
|
|
1950 {
|
|
1951 (*pOutSurface)->Release();
|
|
1952 *pOutSurface = 0;
|
|
1953 return false;
|
|
1954 }
|
|
1955 return true;
|
|
1956 }
|
|
1957
|
|
1958 //----- (004A5190) --------------------------------------------------------
|
|
1959 void RenderD3D::HandleLostResources()
|
|
1960 {
|
|
1961 pBitmaps_LOD->ReleaseLostHardwareTextures();
|
|
1962 pBitmaps_LOD->_410423_move_textures_to_device();
|
|
1963 pSprites_LOD->ReleaseLostHardwareSprites();
|
|
1964 }
|
|
1965
|
|
1966 //----- (004A2050) --------------------------------------------------------
|
|
1967 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture)
|
|
1968 {
|
|
1969 unsigned int v6; // ebx@1
|
|
1970 int v8; // eax@7
|
|
1971 unsigned int v41; // eax@29
|
|
1972 //unsigned int v54; // [sp+5Ch] [bp-Ch]@3
|
|
1973 signed int a2; // [sp+64h] [bp-4h]@4
|
|
1974
|
|
1975 v6 = 0;
|
|
1976 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 )
|
|
1977 {
|
|
1978 //v54 = pGame->pLightmapBuilder->std__vector_000004_size;
|
|
1979 if ( pGame->pLightmapBuilder->std__vector_000004_size)
|
|
1980 a2 = -1;
|
|
1981 pGame->AlterGamma_ODM(a4, &a2);
|
|
1982 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related)
|
|
1983 {
|
|
1984 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0);
|
|
1985 pGame->pLightmapBuilder->DrawLightmaps(/*v8, 0*/);
|
|
1986 }
|
|
1987 else
|
|
1988 {
|
|
1989 if ( !pGame->pLightmapBuilder->std__vector_000004_size || byte_4D864C && pGame->uFlags & 2 )
|
|
1990 {
|
|
1991 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
1992 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
|
|
1993 if (bUsingSpecular)
|
|
1994 {
|
|
1995 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
1996 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
1997 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
1998 }
|
|
1999 for (uint i = 0; i < uNumVertices; ++i)
|
|
2000 {
|
|
2001
|
|
2002 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX;
|
|
2003 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY;
|
|
2004 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist);
|
|
2005 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001);
|
|
2006 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0);
|
|
2007 pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse);
|
|
2008
|
|
2009 if ( this->bUsingSpecular )
|
|
2010 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x);
|
|
2011 else
|
|
2012 d3d_vertex_buffer[i].specular = 0;
|
|
2013 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u;
|
|
2014 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
|
|
2015
|
|
2016 }
|
|
2017
|
|
2018 if (a4->uAttributes & FACE_OUTLINED)
|
|
2019 {
|
|
2020 int color;
|
|
2021 if (GetTickCount() % 300 >= 150)
|
|
2022 color = 0xFFFF2020;
|
|
2023 else color = 0xFF901010;
|
|
2024
|
|
2025 for (uint i = 0; i < uNumVertices; ++i)
|
|
2026 d3d_vertex_buffer[i].diffuse = color;
|
|
2027 }
|
|
2028
|
|
2029 pRenderD3D->pDevice->SetTexture(0, pTexture);
|
|
2030 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
2031 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
2032 d3d_vertex_buffer,
|
|
2033 uNumVertices,
|
|
2034 D3DDP_DONOTLIGHT);
|
|
2035 }
|
|
2036 else
|
|
2037 {
|
|
2038 for (uint i = 0; i < uNumVertices; ++i)
|
|
2039 {
|
|
2040
|
|
2041 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX;
|
|
2042 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY;
|
|
2043 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist);
|
|
2044 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001);
|
|
2045 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0);
|
|
2046 if ( this->bUsingSpecular )
|
|
2047 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x);
|
|
2048 else
|
|
2049 d3d_vertex_buffer[i].specular = 0;
|
|
2050 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u;
|
|
2051 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
|
|
2052
|
|
2053 }
|
|
2054
|
|
2055 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
2056 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
2057 if (bUsingSpecular)
|
|
2058 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
2059
|
|
2060 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
|
2061 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
2062 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
|
|
2063 d3d_vertex_buffer,
|
|
2064 uNumVertices,
|
|
2065 D3DDP_DONOTLIGHT));
|
|
2066 //v50 = (const char *)v5->pRenderD3D->pDevice;
|
|
2067 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
2068 //(*(void (**)(void))(*(int *)v50 + 88))();
|
|
2069 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/);
|
|
2070 for (uint i = 0; i < uNumVertices; ++i)
|
|
2071 {
|
|
2072 d3d_vertex_buffer[i].diffuse = a2;
|
|
2073 }
|
|
2074 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture));
|
|
2075 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
2076 if ( !pRenderer->bUsingSpecular )
|
|
2077 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
2078
|
|
2079 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
2080 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO));
|
|
2081 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR));
|
|
2082 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
2083 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
|
|
2084 d3d_vertex_buffer,
|
|
2085 uNumVertices,
|
|
2086 D3DDP_DONOTLIGHT));
|
|
2087 if (bUsingSpecular)
|
|
2088 {
|
|
2089 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
2090
|
|
2091 for (uint i = 0; i < uNumVertices; ++i)
|
|
2092 {
|
|
2093 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000;
|
|
2094 d3d_vertex_buffer[i].specular = 0;
|
|
2095 }
|
|
2096
|
|
2097 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
|
2098 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA));
|
|
2099 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA));
|
|
2100 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
2101 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
|
|
2102 d3d_vertex_buffer,
|
|
2103 uNumVertices,
|
|
2104 D3DDP_DONOTLIGHT));
|
|
2105 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
2106 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl;
|
|
2107 v41 = GetLevelFogColor();
|
|
2108 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF);
|
|
2109 v6 = 0;
|
|
2110 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0);
|
|
2111 }
|
|
2112 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
2113 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
2114 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6));
|
|
2115 }
|
|
2116 }
|
|
2117 }
|
|
2118 }
|
|
2119 // 4D864C: using guessed type char byte_4D864C;
|
|
2120
|
|
2121 //----- (0049EB79) --------------------------------------------------------
|
|
2122 Render::~Render()
|
|
2123 {
|
|
2124 free(this->pDefaultZBuffer);
|
|
2125 this->pD3DBitmaps.Release();
|
|
2126 this->pD3DSprites.Release();
|
|
2127 Release();
|
|
2128 this->bWindowMode = 1;
|
|
2129 //nullsub_1();
|
|
2130 //nullsub_1();
|
|
2131 }
|
|
2132
|
|
2133
|
|
2134 //----- (0049E992) --------------------------------------------------------
|
|
2135 Render::Render()
|
|
2136 {
|
|
2137 //Render *v1; // esi@1
|
|
2138 // int v2; // eax@1
|
|
2139 // char v3; // zf@1
|
|
2140
|
|
2141 //v1 = this;
|
|
2142 this->pDirectDraw4 = nullptr;
|
|
2143 this->pFrontBuffer4 = nullptr;
|
|
2144 this->pBackBuffer4 = nullptr;
|
|
2145 //this->pColorKeySurface4 = 0;
|
|
2146 //this->pDirectDraw2 = 0;
|
|
2147 //this->pFrontBuffer2 = 0;
|
|
2148 //this->pBackBuffer2 = 0;
|
|
2149 //this->pSomeSurface2 = 0;
|
|
2150 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps);
|
|
2151 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites);
|
|
2152 this->bWindowMode = 1;
|
|
2153 //this->field_40054 = 0;
|
|
2154 //this->field_10 = 640;
|
|
2155 //this->field_14 = 480;
|
|
2156 //this->field_40030 = 0;
|
|
2157 //this->field_4002C = 0;
|
|
2158 this->pActiveZBuffer = nullptr;
|
|
2159 this->pDefaultZBuffer = nullptr;
|
|
2160 this->raster_clip_y = 0;
|
|
2161 this->raster_clip_x = 0;
|
|
2162 this->raster_clip_z = 639;
|
|
2163 this->raster_clip_w = 479;
|
|
2164 //this->field_4003C = 0x004EED80;
|
|
2165 //this->field_40040 = dword_4EED78;
|
|
2166 this->uClipZ = 640;
|
|
2167 //this->field_40044 = 2;
|
|
2168 //this->field_40048 = 6;
|
|
2169 this->pFrontBuffer4 = nullptr;
|
|
2170 this->pBackBuffer4 = nullptr;
|
|
2171 //this->pColorKeySurface4 = 0;
|
|
2172 this->pDirectDraw4 = nullptr;
|
|
2173 this->pRenderD3D = 0;
|
|
2174 this->uNumSceneBegins = 0;
|
|
2175 this->uNumD3DSceneBegins = 0;
|
|
2176 this->using_software_screen_buffer = 0;
|
|
2177 this->pTargetSurface = nullptr;
|
|
2178 this->uTargetSurfacePitch = 0;
|
|
2179 this->uClipY = 0;
|
|
2180 this->uClipX = 0;
|
|
2181 this->uClipW = 480;
|
|
2182 this->bClip = 1;
|
|
2183 //this->bColorKeySupported = 0;
|
|
2184 this->bRequiredTextureStagesAvailable = 0;
|
|
2185 this->bTinting = 1;
|
|
2186 //LOBYTE(this->field_103668) = 0;
|
|
2187 uNumBillboardsToDraw = 0;
|
|
2188 bFogEnabled = false;
|
|
2189
|
|
2190 hd_water_tile_id = -1;
|
|
2191 hd_water_current_frame = 0;
|
|
2192 }
|
|
2193
|
|
2194 bool Render::Initialize(OSWindow *window/*, bool bColoredLights, uint32_t uDetailLevel, bool bTinting*/)
|
|
2195 {
|
|
2196 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0);
|
|
2197
|
|
2198 this->window = window;
|
|
2199 //bStartInWindow = true;
|
|
2200 //windowed_mode_width = windowed_width;
|
|
2201 //windowed_mode_height = windowed_height;
|
|
2202
|
|
2203 uDesiredDirect3DDevice = ReadWindowsRegistryInt("D3D Device", 0);
|
|
2204
|
|
2205 bUseColoredLights = ReadWindowsRegistryInt("Colored Lights", false);
|
|
2206 uLevelOfDetail = ReadWindowsRegistryInt("Detail Level", 1);
|
|
2207 bTinting = ReadWindowsRegistryInt("Tinting", 1) != 0;
|
|
2208
|
|
2209 bool r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl");
|
|
2210 bool r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl");
|
|
2211
|
|
2212 return r1 && r2;
|
|
2213 }
|
|
2214
|
|
2215
|
|
2216 //----- (0049ECC4) --------------------------------------------------------
|
|
2217 void Render::ClearBlack()
|
|
2218 {
|
|
2219 //if (pRenderD3D)
|
|
2220 {
|
|
2221 if (using_software_screen_buffer)
|
|
2222 pRenderD3D->ClearTarget(true, 0, false, 0.0);
|
|
2223 }
|
|
2224 //else
|
|
2225 //memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2));
|
|
2226 }
|
|
2227
|
|
2228 //----- (0049ED18) --------------------------------------------------------
|
|
2229 void Render::PresentBlackScreen()
|
|
2230 {
|
|
2231 IDirectDrawSurface *lpddsback; // eax@3
|
|
2232 DDBLTFX lpDDBltFx; // [sp+4h] [bp-74h]@5
|
|
2233 RECT dest_rect; // [sp+68h] [bp-10h]@3
|
|
2234
|
|
2235 memset(&lpDDBltFx, 0, sizeof(DDBLTFX));
|
|
2236 lpDDBltFx.dwSize = sizeof(DDBLTFX);
|
|
2237
|
|
2238 GetWindowRect(window->GetApiHandle(), &dest_rect);
|
|
2239 lpddsback = (IDirectDrawSurface *)this->pBackBuffer4;
|
|
2240
|
|
2241 lpDDBltFx.dwFillColor = 0;
|
|
2242 lpddsback->Blt(&dest_rect, NULL, NULL, DDBLT_COLORFILL, &lpDDBltFx);
|
|
2243 pRenderer->Present();
|
|
2244 }
|
|
2245
|
|
2246 //----- (0049EDB6) --------------------------------------------------------
|
|
2247 void Render::SavePCXScreenshot()
|
|
2248 {
|
|
2249 int v5; // eax@8
|
|
2250 FILE *pOutFile; // edi@10
|
|
2251 unsigned short *v8; // eax@11
|
|
2252 signed int v12; // eax@18
|
|
2253 char v15[56]; // [sp+Ch] [bp-158h]@10
|
|
2254 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7
|
|
2255 char color_map[48]; // [sp+C4h] [bp-A0h]@10
|
|
2256 char Filename[40]; // [sp+F4h] [bp-70h]@3
|
|
2257 char *lineB; // [sp+11Ch] [bp-48h]@14
|
|
2258 char *lineG; // [sp+120h] [bp-44h]@14
|
|
2259 FILE *File; // [sp+128h] [bp-3Ch]@3
|
|
2260 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10
|
|
2261 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10
|
|
2262 char *lineRGB; // [sp+148h] [bp-1Ch]@10
|
|
2263 void *surface; // [sp+14Ch] [bp-18h]@8
|
|
2264 unsigned int image_width; // [sp+150h] [bp-14h]@4
|
|
2265 int pitch; // [sp+154h] [bp-10h]@4
|
|
2266 char v31; // [sp+15Ah] [bp-Ah]@25
|
|
2267 unsigned char pict_byte; // [sp+15Bh] [bp-9h]@17
|
|
2268 unsigned short *line_picture_data; // [sp+15Ch] [bp-8h]@10
|
|
2269 byte test_byte; // [sp+163h] [bp-1h]@17
|
|
2270
|
|
2271 int num_r_bits = 5;
|
|
2272 int num_g_bits = 6;
|
|
2273 int num_b_bits = 5;
|
|
2274
|
|
2275 int r_mask = 0xF800;
|
|
2276 int g_mask = 0x7E0;
|
|
2277 int b_mask = 0x1F;
|
|
2278
|
|
2279 if ( !this->pRenderD3D || this->using_software_screen_buffer )
|
|
2280 {
|
|
2281 sprintf(Filename, "screen%0.2i.pcx", ScreenshotFileNumber++ % 100);
|
|
2282 File = fopen(Filename, "wb");
|
|
2283 if ( File )
|
|
2284 {
|
|
2285 pitch = this->GetRenderWidth();
|
|
2286 if ( pitch & 1 )
|
|
2287 pitch = pitch + 1;
|
|
2288 if ( this->pRenderD3D )
|
|
2289 {
|
|
2290 memset(&Dst, 0, sizeof(Dst));
|
|
2291 Dst.dwSize = sizeof(Dst);
|
|
2292 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
|
|
2293 return;
|
|
2294 surface = Dst.lpSurface;
|
|
2295 v5 = Dst.lPitch / 2;
|
|
2296 }
|
|
2297 else
|
|
2298 {
|
|
2299 pRenderer->BeginScene();
|
|
2300 surface = pRenderer->pTargetSurface;
|
|
2301 v5 = pRenderer->uTargetSurfacePitch;
|
|
2302 }
|
|
2303 header1.right = GetRenderWidth() - 1;
|
|
2304 header1.left = 0;
|
|
2305 header1.bottom = this->GetRenderHeight() - 1;
|
|
2306 header1.up = 0;
|
|
2307 header2.pitch = pitch;
|
|
2308 memset(color_map, 0, sizeof(color_map));
|
|
2309 memset(v15, 0, sizeof(v15));
|
|
2310 header2.reserved = 0;
|
|
2311 header1.manufacturer = 10;
|
|
2312 pOutFile = File;
|
|
2313 header1.version = 5;
|
|
2314 header1.encoding = 1;
|
|
2315 header1.bpp = 8;
|
|
2316 header1.hdpi = 75;
|
|
2317 header1.vdpi = 75;
|
|
2318 header2.planes = 3;
|
|
2319 header2.palette_info = 1;
|
|
2320 fwrite(&header1, 1, 1, File);
|
|
2321 fwrite(&header1.version, 1, 1, pOutFile);
|
|
2322 fwrite(&header1.encoding, 1, 1, pOutFile);
|
|
2323 fwrite(&header1.bpp, 1, 1, pOutFile);
|
|
2324 fwrite(&header1.left, 2, 1, pOutFile);
|
|
2325 fwrite(&header1.up, 2, 1, pOutFile);
|
|
2326 fwrite(&header1.right, 2, 1, pOutFile);
|
|
2327 fwrite(&header1.bottom, 2, 1, pOutFile);
|
|
2328 fwrite(&header1.hdpi, 2, 1, pOutFile);
|
|
2329 fwrite(&header1.vdpi, 2, 1, pOutFile);
|
|
2330 fwrite(color_map, 0x30, 1, pOutFile);
|
|
2331 fwrite(&header2, 1, 1, pOutFile);
|
|
2332 fwrite(&header2.planes, 1, 1, pOutFile);
|
|
2333 fwrite(&header2.pitch, 2, 1, pOutFile);
|
|
2334 fwrite(&header2.palette_info, 2, 1, pOutFile);
|
|
2335 fwrite(v15, 0x3Au, 1, pOutFile);
|
|
2336 lineRGB = (char *)malloc(3 * GetRenderWidth() + 6);
|
|
2337 if ( this->GetRenderHeight() > 0 )
|
|
2338 {
|
|
2339 image_width = 3 * pitch;
|
|
2340 //v24 = 2 * v5;
|
|
2341 v8 = (unsigned short *)surface;
|
|
2342 for ( unsigned int y = 0; y < this->GetRenderHeight(); y++ )
|
|
2343 {
|
|
2344 line_picture_data = v8;
|
|
2345 if ( GetRenderWidth() > 0 )
|
|
2346 {
|
|
2347 lineG = (char *)lineRGB + pitch;
|
|
2348 lineB = (char *)lineRGB + 2 * pitch;
|
|
2349 for ( uint x = 0; x < this->GetRenderWidth(); x++ )
|
|
2350 {
|
|
2351 //int p = *line_picture_data; //0x2818
|
|
2352 //int for_rad = (pRenderer->uTargetGBits + pRenderer->uTargetBBits );//16 = 8 + 8
|
|
2353 //int value = (pRenderer->uTargetRMask & *line_picture_data);//0 = 0xFF0000 & 0x2818
|
|
2354 //int result = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits );
|
|
2355 lineRGB[x] = (uTargetRMask & *line_picture_data) >> (uTargetGBits + uTargetBBits );// + pRenderer->uTargetRBits - 8);
|
|
2356 lineG[x] = (uTargetGMask & *line_picture_data) >> (uTargetBBits);// + pRenderer->uTargetGBits - 8);
|
|
2357 //int value2 = (pRenderer->uTargetGMask & *line_picture_data); //10240 = 0xFF00 & 0x2818
|
|
2358 //int result2 = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits);
|
|
2359 lineB[x] = (uTargetBMask & *line_picture_data);// << (8 - pRenderer->uTargetBBits);
|
|
2360 //int value3 = (pRenderer->uTargetBMask & *line_picture_data);//24 = 0xFF & 0x2818
|
|
2361 line_picture_data += 2;
|
|
2362 }
|
|
2363 }
|
|
2364 for ( uint i = 0; i < image_width; i += test_byte )
|
|
2365 {
|
|
2366 pict_byte = lineRGB[i];
|
|
2367 for ( test_byte = 1; test_byte < 0x3F; ++test_byte )
|
|
2368 {
|
|
2369 v12 = i + test_byte;
|
|
2370 if ( lineRGB[v12] != pict_byte )
|
|
2371 break;
|
|
2372 if ( !(v12 % pitch) )
|
|
2373 break;
|
|
2374 }
|
|
2375 if ( i + test_byte > image_width )
|
|
2376 test_byte = 3 * pitch - i;
|
|
2377 if ( test_byte > 1 || pict_byte >= 0xC0 )
|
|
2378 {
|
|
2379 v31 = test_byte | 0xC0;
|
|
2380 fwrite(&v31, 1, 1, pOutFile);
|
|
2381 }
|
|
2382 fwrite(&pict_byte, 1, 1, pOutFile);
|
|
2383 }
|
|
2384 v8 += v5;
|
|
2385 }
|
|
2386 }
|
|
2387 if ( this->pRenderD3D )
|
|
2388 ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL));
|
|
2389 else
|
|
2390 pRenderer->EndScene();
|
|
2391
|
|
2392 free(lineRGB);
|
|
2393 fclose(pOutFile);
|
|
2394 }
|
|
2395 }
|
|
2396 }
|
|
2397
|
|
2398 //----- (0049F1BC) --------------------------------------------------------
|
|
2399 void Render::SaveWinnersCertificate(const char *a1)
|
|
2400 {
|
|
2401 unsigned int v6; // eax@8
|
|
2402 //FILE *v7; // edi@10
|
|
2403 // int v8; // ecx@11
|
|
2404 unsigned short *v9; // eax@11
|
|
2405 int v10; // eax@13
|
|
2406 signed int v13; // eax@18
|
|
2407 // char v14; // zf@27
|
|
2408 // HRESULT v15; // eax@29
|
|
2409 char v16[56]; // [sp+Ch] [bp-12Ch]@10
|
|
2410 __int16 v17; // [sp+44h] [bp-F4h]@10
|
|
2411 DDSURFACEDESC2 Dst; // [sp+48h] [bp-F0h]@7
|
|
2412 // int v19; // [sp+58h] [bp-E0h]@8
|
|
2413 // unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8
|
|
2414 char color_map[48]; // [sp+C4h] [bp-74h]@10
|
|
2415 // unsigned int v22; // [sp+F4h] [bp-44h]@11
|
|
2416 char *lineB; // [sp+F8h] [bp-40h]@14
|
|
2417 int image_width; // [sp+FCh] [bp-3Ch]@11
|
|
2418 int v25; // [sp+100h] [bp-38h]@4
|
|
2419 FILE *File; // [sp+104h] [bp-34h]@3
|
|
2420 char Str; // [sp+108h] [bp-30h]@10
|
|
2421 char v28; // [sp+109h] [bp-2Fh]@10
|
|
2422 char v29; // [sp+10Ah] [bp-2Eh]@10
|
|
2423 char v30; // [sp+10Bh] [bp-2Dh]@10
|
|
2424 __int16 v31; // [sp+10Ch] [bp-2Ch]@10
|
|
2425 __int16 v32; // [sp+10Eh] [bp-2Ah]@10
|
|
2426 __int16 v33; // [sp+110h] [bp-28h]@10
|
|
2427 __int16 v34; // [sp+112h] [bp-26h]@10
|
|
2428 __int16 v35; // [sp+114h] [bp-24h]@10
|
|
2429 __int16 v36; // [sp+116h] [bp-22h]@10
|
|
2430 char v37; // [sp+118h] [bp-20h]@10
|
|
2431 char v38; // [sp+119h] [bp-1Fh]@10
|
|
2432 __int16 v39; // [sp+11Ah] [bp-1Eh]@10
|
|
2433 __int16 v40; // [sp+11Ch] [bp-1Ch]@10
|
|
2434 char *lineRGB; // [sp+120h] [bp-18h]@10
|
|
2435 void *surface; // [sp+124h] [bp-14h]@8
|
|
2436 int pitch; // [sp+128h] [bp-10h]@4
|
|
2437 char v44; // [sp+12Fh] [bp-9h]@25
|
|
2438 char *lineG; // [sp+130h] [bp-8h]@10
|
|
2439 unsigned char pict_byte; // [sp+137h] [bp-1h]@17
|
|
2440 byte test_byte;
|
|
2441
|
|
2442 int num_r_bits = 5;
|
|
2443 int num_g_bits = 6;
|
|
2444 int num_b_bits = 5;
|
|
2445
|
|
2446 int r_mask = 0xF800;
|
|
2447 int g_mask = 0x7E0;
|
|
2448 int b_mask = 0x1F;
|
|
2449
|
|
2450 if ( !this->pRenderD3D || this->using_software_screen_buffer )
|
|
2451 {
|
|
2452 static int _4EFA84_num_winners_certificates = 0;
|
|
2453 ++_4EFA84_num_winners_certificates;
|
|
2454
|
|
2455 File = fopen(a1, "wb");
|
|
2456 if ( File )
|
|
2457 {
|
|
2458 v25 = this->GetRenderWidth();
|
|
2459 pitch = v25;
|
|
2460 if ( pitch & 1 )
|
|
2461 pitch = pitch + 1;
|
|
2462 if ( this->pRenderD3D )
|
|
2463 {
|
|
2464 memset(&Dst, 0, 0x7C);
|
|
2465 Dst.dwSize = 124;
|
|
2466 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) )
|
|
2467 return;
|
|
2468 surface = Dst.lpSurface;
|
|
2469 v6 = Dst.lPitch / 2;
|
|
2470 }
|
|
2471 else
|
|
2472 {
|
|
2473 pRenderer->BeginScene();
|
|
2474 surface = pRenderer->pTargetSurface;
|
|
2475 v6 = pRenderer->uTargetSurfacePitch;
|
|
2476 }
|
|
2477 v33 = this->GetRenderWidth() - 1;
|
|
2478 v31 = 0;
|
|
2479 v34 = (short)this->GetRenderHeight() - 1;
|
|
2480 v32 = 0;
|
|
2481 v39 = pitch;
|
|
2482 memset(&color_map, 0, sizeof(color_map));
|
|
2483 memset(&v16, 0, sizeof(v16));
|
|
2484 v37 = 0;
|
|
2485 Str = 10;
|
|
2486 v17 = 0;
|
|
2487 v28 = 5;
|
|
2488 v29 = 1;
|
|
2489 v30 = 8;
|
|
2490 v35 = 75;
|
|
2491 v36 = 75;
|
|
2492 v38 = 3;
|
|
2493 v40 = 1;
|
|
2494 fwrite(&Str, 1, 1, File);
|
|
2495 fwrite(&v28, 1, 1, File);
|
|
2496 fwrite(&v29, 1, 1, File);
|
|
2497 fwrite(&v30, 1, 1, File);
|
|
2498 fwrite(&v31, 2, 1, File);
|
|
2499 fwrite(&v32, 2, 1, File);
|
|
2500 fwrite(&v33, 2, 1, File);
|
|
2501 fwrite(&v34, 2, 1, File);
|
|
2502 fwrite(&v35, 2, 1, File);
|
|
2503 fwrite(&v36, 2, 1, File);
|
|
2504 fwrite(&color_map, 0x30, 1, File);
|
|
2505 fwrite(&v37, 1, 1, File);
|
|
2506 fwrite(&v38, 1, 1, File);
|
|
2507 fwrite(&v39, 2, 1, File);
|
|
2508 fwrite(&v40, 2, 1, File);
|
|
2509 fwrite(&v16, 0x3A, 1, File);
|
|
2510 lineRGB = (char *)malloc(3 * (v25 + 2));
|
|
2511 if ( (signed int)this->GetRenderHeight() > 0 )
|
|
2512 {
|
|
2513 image_width = 3 * pitch;
|
|
2514 v9 = (unsigned short *)surface;
|
|
2515 for ( uint j = 0; j < this->GetRenderHeight(); j++)
|
|
2516 {
|
|
2517 a1 = (const char *)v9;
|
|
2518 if ( v25 > 0 )
|
|
2519 {
|
|
2520 lineG = (char *)lineRGB + pitch;
|
|
2521 lineB = (char *)lineRGB + 2 * pitch;
|
|
2522 for ( v10 = 0; v10 < v25; v10++ )
|
|
2523 {
|
|
2524 lineRGB[v10] = (signed int)(r_mask & *(short *)a1) >> (num_g_bits + num_b_bits + num_r_bits - 8);
|
|
2525 lineG[v10] = (signed int)(g_mask & *(short *)a1) >> (num_b_bits + num_g_bits - 8);
|
|
2526 lineB[v10] = (b_mask & *(short *)a1) << (8 - num_b_bits);
|
|
2527 a1 += 2;
|
|
2528 }
|
|
2529 }
|
|
2530 for ( uint i = 0; i < image_width; i += test_byte )
|
|
2531 {
|
|
2532 pict_byte = lineRGB[i];
|
|
2533 for ( test_byte = 1; test_byte < 0x3F; test_byte )
|
|
2534 {
|
|
2535 v13 = i + test_byte;
|
|
2536 if ( lineRGB[v13] != pict_byte )
|
|
2537 break;
|
|
2538 if ( !(v13 % pitch) )
|
|
2539 break;
|
|
2540 }
|
|
2541 if ( i + test_byte > image_width )
|
|
2542 test_byte = 3 * pitch - i;
|
|
2543 if ( test_byte > 1 || pict_byte >= 0xC0 )
|
|
2544 {
|
|
2545 v44 = test_byte | 0xC0;
|
|
2546 fwrite(&v44, 1, 1, File);
|
|
2547 }
|
|
2548 fwrite(&pict_byte, 1, 1, File);
|
|
2549 }
|
|
2550 v9 += pitch;
|
|
2551 }
|
|
2552 }
|
|
2553 if ( this->pRenderD3D )
|
|
2554 ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL));
|
|
2555 else
|
|
2556 pRenderer->EndScene();
|
|
2557 free(lineRGB);
|
|
2558 fclose(File);
|
|
2559 }
|
|
2560 }
|
|
2561 }
|
|
2562
|
|
2563 //----- (0049F5A2) --------------------------------------------------------
|
|
2564 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size )
|
|
2565 {
|
|
2566 void *v8; // esi@3
|
|
2567 void *v9; // esi@3
|
|
2568 unsigned short* v11; // eax@4
|
|
2569 // int v13; // eax@8
|
|
2570 // int v14; // ecx@8
|
|
2571 signed int v15; // eax@11
|
|
2572 // char v16; // zf@20
|
|
2573 // int result; // eax@21
|
|
2574 char v18[58]; // [sp+Ch] [bp-ACh]@3
|
|
2575 char v20[48]; // [sp+48h] [bp-70h]@3
|
|
2576 char *lineG; // [sp+78h] [bp-40h]@7
|
|
2577 char *lineB; // [sp+7Ch] [bp-3Ch]@7
|
|
2578 int v23; // [sp+80h] [bp-38h]@4
|
|
2579 int v24; // [sp+84h] [bp-34h]@4
|
|
2580 int v25; // [sp+88h] [bp-30h]@4
|
|
2581 int v26; // [sp+8Ch] [bp-2Ch]@4
|
|
2582 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3
|
|
2583 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3
|
|
2584 char *lineRGB; // [sp+A8h] [bp-10h]@3
|
|
2585 int pitch; // [sp+ACh] [bp-Ch]@1
|
|
2586 char v43; // [sp+B3h] [bp-5h]@18
|
|
2587 int i; // [sp+B4h] [bp-4h]@6
|
|
2588 unsigned short* line_picture_data;
|
|
2589 byte test_byte;
|
|
2590 unsigned char pict_byte;
|
|
2591
|
|
2592 int num_r_bits = 5;
|
|
2593 int num_g_bits = 6;
|
|
2594 int num_b_bits = 5;
|
|
2595
|
|
2596 int r_mask = 0xF800;
|
|
2597 int g_mask = 0x7E0;
|
|
2598 int b_mask = 0x1F;
|
|
2599
|
|
2600 pitch = wight;
|
|
2601 if ( wight & 1 )
|
|
2602 pitch = wight + 1;
|
|
2603 Src.left = 0;
|
|
2604 Src.up = 0;
|
|
2605 Src.right = wight - 1;
|
|
2606 Src.bottom = heidth - 1;
|
|
2607 v27.pitch = pitch;
|
|
2608 memset(&v20, 0, 0x30u);
|
|
2609 memset(&v18, 0, 0x38u);
|
|
2610 v8 = data_buff;
|
|
2611 v27.reserved = 0;
|
|
2612 *(_WORD *)&v18[56] = 0;
|
|
2613 Src.manufacturer = 10;
|
|
2614 Src.version = 5;
|
|
2615 Src.encoding = 1;
|
|
2616 Src.bpp = 8;
|
|
2617 Src.hdpi = 75;
|
|
2618 Src.vdpi = 75;
|
|
2619 v27.planes = 3;
|
|
2620 v27.palette_info = 1;
|
|
2621 memcpy(data_buff, &Src, 1);
|
|
2622 v8 = (char *)v8 + 1;
|
|
2623 memcpy(v8, &Src.version, 1);
|
|
2624 v8 = (char *)v8 + 1;
|
|
2625 memcpy(v8, &Src.encoding, 1);
|
|
2626 v8 = (char *)v8 + 1;
|
|
2627 memcpy(v8, &Src.bpp, 1);
|
|
2628 v8 = (char *)v8 + 1;
|
|
2629 memcpy(v8, &Src.left, 2);
|
|
2630 v8 = (char *)v8 + 2;
|
|
2631 memcpy(v8, &Src.up, 2);
|
|
2632 v8 = (char *)v8 + 2;
|
|
2633 memcpy(v8, &Src.right, 2);
|
|
2634 v8 = (char *)v8 + 2;
|
|
2635 memcpy(v8, &Src.bottom, 2);
|
|
2636 v8 = (char *)v8 + 2;
|
|
2637 memcpy(v8, &Src.hdpi, 2);
|
|
2638 v8 = (char *)v8 + 2;
|
|
2639 memcpy(v8, &Src.vdpi, 2);
|
|
2640 v8 = (char *)v8 + 2;
|
|
2641 memcpy(v8, &v20, 0x30u);
|
|
2642 v8 = (char *)v8 + 48;
|
|
2643 memcpy(v8, &v27, 1u);
|
|
2644 v8 = (char *)v8 + 1;
|
|
2645 memcpy(v8, &v27.planes, 1);
|
|
2646 v8 = (char *)v8 + 1;
|
|
2647 memcpy(v8, &v27.pitch, 2);
|
|
2648 v8 = (char *)v8 + 2;
|
|
2649 memcpy(v8, &v27.palette_info, 2);
|
|
2650 v8 = (char *)v8 + 2;
|
|
2651 memcpy(v8, &v18, 0x3Au);
|
|
2652 v9 = (char *)v8 + 58;
|
|
2653
|
|
2654 lineRGB = (char*)malloc(3 * (wight + 2));
|
|
2655 if ( heidth > 0 )
|
|
2656 {
|
|
2657 v26 = 3 * pitch;
|
|
2658 v23 = 2 * wight;
|
|
2659 v11 = picture_data;
|
|
2660 v24 = (int)picture_data;
|
|
2661 for ( v25 = heidth; v25; v25-- )
|
|
2662 {
|
|
2663 line_picture_data = v11;
|
|
2664 if ( wight > 0 )
|
|
2665 {
|
|
2666 lineG = (char *)lineRGB + pitch;
|
|
2667 lineB = (char *)lineRGB + 2 * pitch;
|
|
2668 for ( uint i = 0; i < wight; i++ )
|
|
2669 {
|
|
2670 lineRGB[i] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8);
|
|
2671 lineG[i] = (signed int)(g_mask & *line_picture_data) >> ( num_b_bits + num_g_bits- 8);
|
|
2672 lineB[i] = (b_mask & *line_picture_data) << (8 - num_b_bits);
|
|
2673 line_picture_data += 1;
|
|
2674 }
|
|
2675 }
|
|
2676 for ( i = 0; i < v26; v9 = (char *)v9 + 1 )
|
|
2677 {
|
|
2678 pict_byte = lineRGB[i];
|
|
2679 for ( test_byte = 1; test_byte < 63; ++test_byte )
|
|
2680 {
|
|
2681 v15 = i + test_byte;
|
|
2682 if ( lineRGB[v15] != pict_byte )//Uninitialized memory access
|
|
2683 break;
|
|
2684 if ( !(v15 % pitch) )
|
|
2685 break;
|
|
2686 }
|
|
2687 if ( i + test_byte > v26 )
|
|
2688 test_byte = 3 * pitch - i;
|
|
2689 if ( test_byte > 1 || pict_byte >= 192 )
|
|
2690 {
|
|
2691 v43 = test_byte | 0xC0;
|
|
2692 memcpy(v9, &v43, 1);
|
|
2693 v9 = (char *)v9 + 1;
|
|
2694 }
|
|
2695 memcpy(v9, &pict_byte, 1);
|
|
2696 i += test_byte;
|
|
2697 }
|
|
2698 v11 += wight;
|
|
2699 }
|
|
2700 }
|
|
2701 free(lineRGB);
|
|
2702 *(int *)packed_size = (char *)v9 - data_buff;
|
|
2703 }
|
|
2704
|
|
2705 //----- (0049F8B5) --------------------------------------------------------
|
|
2706 void Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height)
|
|
2707 {
|
|
2708 FILE *result; // eax@1
|
|
2709 FILE *pOutFile; // edi@4
|
|
2710 unsigned short* v9; // eax@5
|
|
2711 // int v10; // eax@7
|
|
2712 signed int v12; // eax@12
|
|
2713 // char v13; // zf@21
|
|
2714 char v14[56]; // [sp+4h] [bp-A0h]@4
|
|
2715 __int16 v15; // [sp+3Ch] [bp-68h]@4
|
|
2716 char color_map[48]; // [sp+40h] [bp-64h]@4
|
|
2717 int v18; // [sp+74h] [bp-30h]@5
|
|
2718 // char *v19; // [sp+78h] [bp-2Ch]@5
|
|
2719 int image_width; // [sp+7Ch] [bp-28h]@5
|
|
2720 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4
|
|
2721 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4
|
|
2722 char *lineRGB; // [sp+98h] [bp-Ch]@4
|
|
2723 int pitch; // [sp+9Ch] [bp-8h]@2
|
|
2724 char *lineB; // [sp+A0h] [bp-4h]@8
|
|
2725 char *lineG;
|
|
2726 unsigned short* line_pictute_data;
|
|
2727 byte test_byte;
|
|
2728 char v43;
|
|
2729
|
|
2730 int num_r_bits = 5;
|
|
2731 int num_g_bits = 6;
|
|
2732 int num_b_bits = 5;
|
|
2733
|
|
2734 int r_mask = 0xF800;
|
|
2735 int g_mask = 0x7E0;
|
|
2736 int b_mask = 0x1F;
|
|
2737
|
|
2738 result = fopen(Filename, "wb");
|
|
2739 Filename = (const char *)result;
|
|
2740 if ( result )
|
|
2741 {
|
|
2742 pitch = width;
|
|
2743 if ( width & 1 )
|
|
2744 pitch = width + 1;
|
|
2745 header1.left = 0;
|
|
2746 header1.up = 0;
|
|
2747 header1.right = width - 1;
|
|
2748 header1.bottom = height - 1;
|
|
2749 header2.pitch = pitch;
|
|
2750 memset(color_map, 0, sizeof(color_map));
|
|
2751 header2.reserved = 0;
|
|
2752 memset(v14, 0, sizeof(v14));
|
|
2753 v15 = 0;
|
|
2754 header1.manufacturer = 10;
|
|
2755 header1.version = 5;
|
|
2756 header1.encoding = 1;
|
|
2757 header1.bpp = 8;
|
|
2758 header1.hdpi = 75;
|
|
2759 header1.vdpi = 75;
|
|
2760 header2.planes = 3;
|
|
2761 header2.palette_info = 1;
|
|
2762 fwrite(&header1, 1, 1, (FILE *)Filename);
|
|
2763 pOutFile = (FILE *)Filename;
|
|
2764 fwrite(&header1.version, 1, 1, (FILE *)Filename);
|
|
2765 fwrite(&header1.encoding, 1, 1, pOutFile);
|
|
2766 fwrite(&header1.bpp, 1, 1, pOutFile);
|
|
2767 fwrite(&header1.left, 2, 1, pOutFile);
|
|
2768 fwrite(&header1.up, 2, 1, pOutFile);
|
|
2769 fwrite(&header1.right, 2, 1, pOutFile);
|
|
2770 fwrite(&header1.bottom, 2, 1, pOutFile);
|
|
2771 fwrite(&header1.hdpi, 2, 1, pOutFile);
|
|
2772 fwrite(&header1.vdpi, 2, 1, pOutFile);
|
|
2773 fwrite(color_map, 0x30u, 1, pOutFile);
|
|
2774 fwrite(&header2, 1, 1, pOutFile);
|
|
2775 fwrite(&header2.planes, 1, 1, pOutFile);
|
|
2776 fwrite(&header2.pitch, 2, 1, pOutFile);
|
|
2777 fwrite(&header2.palette_info, 2, 1, pOutFile);
|
|
2778 fwrite(v14, 0x3Au, 1, pOutFile);
|
|
2779
|
|
2780 lineRGB = (char *)malloc(3 * (width + 2));
|
|
2781 //Ïðè ñîõðàíåíèè èçîáðàæåíèÿ ïîäðÿä èäóùèå ïèêñåëè îäèíàêîâîãî öâåòà îáúåäèíÿþòñÿ è âìåñòî óêàçàíèÿ öâåòà äëÿ êàæäîãî ïèêñåëÿ
|
|
2782 //óêàçûâàåòñÿ öâåò ãðóïïû ïèêñåëåé è èõ êîëè÷åñòâî.
|
|
2783 image_width = 3 * pitch;
|
|
2784 v9 = picture_data;
|
|
2785 for ( v18 = 0; v18 < height; v18++ )//ñòîëáåö
|
|
2786 {
|
|
2787 line_pictute_data = v9;
|
|
2788 lineG = (char *)lineRGB + pitch;
|
|
2789 lineB = (char *)lineRGB + 2 * pitch;
|
|
2790
|
|
2791 for ( int i = 0; i < width; i++ )//ñòðîêà
|
|
2792 {
|
|
2793 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8);
|
|
2794 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8);
|
|
2795 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits);
|
|
2796 line_pictute_data += 1;
|
|
2797 }
|
|
2798 test_byte = 1;
|
|
2799 for ( int i = 0; (signed int)i < image_width; i += test_byte )
|
|
2800 {
|
|
2801 unsigned char pic_byte = lineRGB[i];
|
|
2802 for ( test_byte; test_byte < 63; ++test_byte )// ðàñ÷¸ò êîëè÷åñòâà îäèíàêîâûõ öâåòîâ
|
|
2803 {
|
|
2804 v12 = i + test_byte;
|
|
2805 if ( lineRGB[v12] != pic_byte )
|
|
2806 break;
|
|
2807 if ( !(v12 % pitch) )
|
|
2808 break;
|
|
2809 }
|
|
2810 if ( i + test_byte > image_width )
|
|
2811 test_byte = 3 * pitch - i;
|
|
2812 if ( test_byte > 1 || pic_byte >= 0xC0 )
|
|
2813 {
|
|
2814 v43 = test_byte | 0xC0;//òåñò-áàéò îáúåäèíåíèÿ
|
|
2815 fwrite(&v43, 1, 1, pOutFile);
|
|
2816 }
|
|
2817 fwrite(&pic_byte, 1, 1, pOutFile);
|
|
2818 }
|
|
2819 v9 += width;
|
|
2820 }
|
|
2821 free(lineRGB);
|
|
2822 fclose(pOutFile);
|
|
2823 }
|
|
2824 }
|
|
2825
|
|
2826 //----- (0049FBCD) --------------------------------------------------------
|
|
2827 void Render::ClearTarget(unsigned int uColor)
|
|
2828 {
|
|
2829 //if (pRenderD3D)
|
|
2830 {
|
|
2831 if (using_software_screen_buffer)
|
|
2832 pRenderD3D->ClearTarget(true, uColor, false, 0.0);
|
|
2833 }
|
|
2834 //else
|
|
2835 //memset32(pTargetSurface, uColor, field_10 * field_14 / 2);
|
|
2836 }
|
|
2837
|
|
2838
|
|
2839 //----- (0049FC37) --------------------------------------------------------
|
|
2840 void Render::Present()
|
|
2841 {
|
|
2842 //struct tagRECT Rect; // [sp+8h] [bp-28h]@11
|
|
2843 //RECT a4; // [sp+18h] [bp-18h]@11
|
|
2844 //struct tagPOINT Point; // [sp+28h] [bp-8h]@11
|
|
2845
|
|
2846 if ( !pRenderD3D || this->using_software_screen_buffer )
|
|
2847 {
|
|
2848 this->pBeforePresentFunction();
|
|
2849 if ( this->pRenderD3D )
|
|
2850 {
|
|
2851 if ( this->using_software_screen_buffer )
|
|
2852 pRenderD3D->Present(false);
|
|
2853 }
|
|
2854 else
|
|
2855 __debugbreak(); // no sr
|
|
2856 /*{
|
|
2857 if ( this->bWindowMode )
|
|
2858 {
|
|
2859 RestoreFrontBuffer();
|
|
2860 GetClientRect(this->hWnd, &Rect);
|
|
2861 Point.y = 0;
|
|
2862 Point.x = 0;
|
|
2863 ClientToScreen(this->hWnd, &Point);
|
|
2864 OffsetRect(&Rect, Point.x, Point.y);
|
|
2865 a4.top = 0;
|
|
2866 a4.bottom = 480;
|
|
2867 a4.left = 0;
|
|
2868 a4.right = 640;
|
|
2869 PresentRect(&Rect, &a4);
|
|
2870 }
|
|
2871 else
|
|
2872 {
|
|
2873 RestoreFrontBuffer();
|
|
2874 a4.top = 0;
|
|
2875 a4.bottom = 480;
|
|
2876 a4.left = 0;
|
|
2877 a4.right = 640;
|
|
2878 BltBackToFontFast(0, 0, &a4);
|
|
2879 }
|
|
2880 }*/
|
|
2881 }
|
|
2882 }
|
|
2883
|
|
2884 //----- (0049FD3A) --------------------------------------------------------
|
|
2885 void Render::_49FD3A_fullscreen()
|
|
2886 {
|
|
2887 RECT src_rect; // [sp+8h] [bp-10h]@6
|
|
2888
|
|
2889 if ( this->pRenderD3D )
|
|
2890 {
|
|
2891 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST)
|
|
2892 pFrontBuffer4->Restore();
|
|
2893 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST)
|
|
2894 pBackBuffer4->Restore();
|
|
2895 src_rect.top = 0;
|
|
2896 src_rect.bottom = window->GetHeight();
|
|
2897 src_rect.left = 0;
|
|
2898 src_rect.right = window->GetWidth();
|
|
2899 this->pBackBuffer4->BltFast(NULL, NULL, this->pFrontBuffer4, &src_rect, DDBLTFAST_WAIT);
|
|
2900 }
|
|
2901 }
|
|
2902
|
|
2903 //----- (0049FDBF) --------------------------------------------------------
|
|
2904 void Render::CreateZBuffer()
|
|
2905 {
|
|
2906 if (!pDefaultZBuffer)
|
|
2907 {
|
|
2908 pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000);
|
|
2909 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B)
|
|
2910 }
|
|
2911 }
|
|
2912
|
|
2913 //----- (0049FE05) --------------------------------------------------------
|
|
2914 void Render::Release()
|
|
2915 {
|
|
2916 //Render *v1; // esi@1
|
|
2917 //RenderD3D *v2; // ecx@1
|
|
2918 //char v3; // zf@4
|
|
2919 //void *v4; // ebx@6
|
|
2920 // IDirectDraw *v5; // eax@10
|
|
2921 // IDirectDrawSurface2 *v6; // eax@11
|
|
2922 // IDirectDrawSurface2 *v7; // eax@13
|
|
2923 // IDirectDrawSurface2 *v8; // eax@15
|
|
2924 // IDirectDraw2 *v9; // eax@17
|
|
2925 // IDirectDraw4 *v10; // eax@19
|
|
2926 // IDirectDrawSurface4 *v11; // eax@20
|
|
2927 // IDirectDrawSurface4 *v12; // eax@22
|
|
2928 // IDirectDrawSurface4 *v13; // eax@24
|
|
2929 // IDirectDraw4 *v14; // eax@26
|
|
2930 // unsigned __int16 **v15; // ebx@28
|
|
2931 // void **v16; // esi@29
|
|
2932
|
|
2933 // v1 = this;
|
|
2934 if (pRenderD3D)
|
|
2935 {
|
|
2936 if ( this->using_software_screen_buffer )
|
|
2937 {
|
|
2938 pRenderD3D->ClearTarget(true, 0, false, 1.0);
|
|
2939 pRenderD3D->Present(0);
|
|
2940 pRenderD3D->ClearTarget(true, 0, false, 1.0);
|
|
2941 }
|
|
2942 //this->pColorKeySurface4 = 0;
|
|
2943 this->pBackBuffer4 = nullptr;
|
|
2944 this->pFrontBuffer4 = nullptr;
|
|
2945 this->pDirectDraw4 = nullptr;
|
|
2946 delete [] this->pTargetSurface_unaligned;
|
|
2947 this->pTargetSurface = nullptr;
|
|
2948 this->pTargetSurface_unaligned = nullptr;
|
|
2949 if (pRenderD3D)
|
|
2950 {
|
|
2951 pRenderD3D->Release();
|
|
2952 delete pRenderD3D;
|
|
2953 }
|
|
2954 pRenderD3D = nullptr;
|
|
2955 }
|
|
2956 else
|
|
2957 ;//__debugbreak(); // no sr
|
|
2958 /*{
|
|
2959 if ( bWinNT4_0 == 1 )
|
|
2960 {
|
|
2961 v5 = (IDirectDraw *)this->pDirectDraw2;
|
|
2962 if ( !v5 )
|
|
2963 return;
|
|
2964 v5->SetCooperativeLevel(this->hWnd, 8u);
|
|
2965 this->pDirectDraw2->FlipToGDISurface();
|
|
2966 v6 = this->pSomeSurface2;
|
|
2967 if ( v6 )
|
|
2968 {
|
|
2969 v6->Release();
|
|
2970 this->pSomeSurface2 = 0;
|
|
2971 }
|
|
2972 v7 = this->pBackBuffer2;
|
|
2973 if ( v7 )
|
|
2974 {
|
|
2975 v7->Release();
|
|
2976 this->pBackBuffer2 = 0;
|
|
2977 }
|
|
2978 v8 = this->pFrontBuffer2;
|
|
2979 if ( v8 )
|
|
2980 {
|
|
2981 v8->Release();
|
|
2982 this->pFrontBuffer2 = 0;
|
|
2983 }
|
|
2984 v9 = this->pDirectDraw2;
|
|
2985 if ( v9 )
|
|
2986 {
|
|
2987 v9->Release();
|
|
2988 this->pDirectDraw2 = 0;
|
|
2989 }
|
|
2990 }
|
|
2991 else
|
|
2992 {
|
|
2993 v10 = this->pDirectDraw4;
|
|
2994 if ( !v10 )
|
|
2995 return;
|
|
2996 v10->SetCooperativeLevel(this->hWnd, 1032u);
|
|
2997 this->pDirectDraw4->FlipToGDISurface();
|
|
2998 v11 = this->pColorKeySurface4;
|
|
2999 if ( v11 )
|
|
3000 {
|
|
3001 v11->Release();
|
|
3002 this->pColorKeySurface4 = 0;
|
|
3003 }
|
|
3004 v12 = this->pBackBuffer4;
|
|
3005 if ( v12 )
|
|
3006 {
|
|
3007 v12->Release();
|
|
3008 this->pBackBuffer4 = 0;
|
|
3009 }
|
|
3010 v13 = this->pFrontBuffer4;
|
|
3011 if ( v13 )
|
|
3012 {
|
|
3013 v13->Release();
|
|
3014 this->pFrontBuffer4 = 0;
|
|
3015 }
|
|
3016 v14 = this->pDirectDraw4;
|
|
3017 if ( v14 )
|
|
3018 {
|
|
3019 v14->Release();
|
|
3020 this->pDirectDraw4 = 0;
|
|
3021 }
|
|
3022 }
|
|
3023 v15 = &this->pTargetSurface;
|
|
3024 if ( this->pTargetSurface )
|
|
3025 {
|
|
3026 v16 = (void **)&this->ptr_400E8;
|
|
3027 free(*v16);
|
|
3028 *v15 = 0;
|
|
3029 *v16 = 0;
|
|
3030 }
|
|
3031 }*/
|
|
3032 }
|
|
3033
|
|
3034 void Present32(unsigned __int32 *src, unsigned int src_pitch,
|
|
3035 unsigned __int32 *dst, unsigned int dst_pitch)
|
|
3036 {
|
|
3037 for (uint y = 0; y < 8; ++y)
|
|
3038 memcpy(dst + y * dst_pitch,
|
|
3039 src + y * src_pitch, src_pitch * sizeof(__int32));
|
|
3040
|
|
3041 for (uint y = 8; y < 352; ++y)
|
|
3042 {
|
|
3043 memcpy(dst + y * dst_pitch,
|
|
3044 src + y * src_pitch, 8 * sizeof(__int32));
|
|
3045 memcpy(dst + 8 + game_viewport_width + y * dst_pitch,
|
|
3046 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32));
|
|
3047 }
|
|
3048
|
|
3049 for (uint y = 352; y < 480; ++y)
|
|
3050 memcpy(dst + y * dst_pitch,
|
|
3051 src + y * src_pitch, src_pitch * sizeof(__int32));
|
|
3052
|
|
3053 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
|
|
3054 {
|
|
3055 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x)
|
|
3056 {
|
|
3057 //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask))
|
|
3058 if (src[x + y * src_pitch] != 0xFF00FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask))
|
|
3059 dst[x + y * dst_pitch] = src[x + y * src_pitch];
|
|
3060 }
|
|
3061 }
|
|
3062 }
|
|
3063
|
|
3064 //----- (004A597D) --------------------------------------------------------
|
|
3065 void Present_NoColorKey()
|
|
3066 {
|
|
3067 void *v2; // edi@4
|
|
3068 int v9; // eax@10
|
|
3069 unsigned int v10; // esi@10
|
|
3070 unsigned __int32 v11; // edi@10
|
|
3071 unsigned int v13; // ebx@10
|
|
3072 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3
|
|
3073 int v21; // [sp+8Ch] [bp-18h]@10
|
|
3074 __int32 v22; // [sp+90h] [bp-14h]@10
|
|
3075 unsigned int v24; // [sp+98h] [bp-Ch]@4
|
|
3076
|
|
3077 int r_mask = 0xF800;
|
|
3078 int g_mask = 0x7E0;
|
|
3079 int b_mask = 0x1F;
|
|
3080
|
|
3081 //if ( !pRenderer->uNumSceneBegins )
|
|
3082 {
|
|
3083 //if ( pRenderer->using_software_screen_buffer )
|
|
3084 //{
|
|
3085 memset(&Dst, 0, sizeof(Dst));
|
|
3086 Dst.dwSize = sizeof(Dst);
|
|
3087 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
|
|
3088 {
|
|
3089 //v26 = Dst.lpSurface;
|
|
3090 //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface;
|
|
3091 v24 = g_mask | b_mask | ((g_mask | b_mask) << 16);
|
|
3092 //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface;
|
|
3093 //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch;
|
|
3094 //v1 = pRenderer->pTargetSurface;
|
|
3095 v2 = Dst.lpSurface;
|
|
3096
|
|
3097
|
|
3098 /*for (uint y = 0; y < 480; ++y)
|
|
3099 {
|
|
3100 auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch);
|
|
3101 for (uint x = 0; x < 640; ++x)
|
|
3102 pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask;
|
|
3103 }*/
|
|
3104
|
|
3105 if (!FORCE_16_BITS)
|
|
3106 Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4);
|
|
3107 else
|
|
3108 {
|
|
3109 ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface;
|
|
3110 short* pDst = (__int16 *)Dst.lpSurface;
|
|
3111
|
|
3112 for (uint y = 0; y < 8; ++y)
|
|
3113 memcpy(pDst + y * Dst.lPitch / 2,
|
|
3114
|
|
3115 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16));
|
|
3116
|
|
3117 for (uint y = 8; y < 352; ++y)
|
|
3118 {
|
|
3119 memcpy(pDst + y * Dst.lPitch / 2,
|
|
3120 pSrc + y * window->GetWidth(), 8 * sizeof(__int16));
|
|
3121 memcpy(pDst + 8 + game_viewport_width/*462*/ + y * Dst.lPitch / 2,
|
|
3122 pSrc + 8 + game_viewport_width/*462*/ + y * window->GetWidth(), 174/*172*/ * sizeof(__int16));
|
|
3123 }
|
|
3124
|
|
3125 for (uint y = 352; y < window->GetHeight(); ++y)
|
|
3126 memcpy(pDst + y * Dst.lPitch / 2,
|
|
3127 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16));
|
|
3128
|
|
3129
|
|
3130 ushort* pSrc_x1y1 = pSrc + window->GetWidth() * pViewport->uViewportTL_Y + pViewport->uViewportTL_X;
|
|
3131 //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)];
|
|
3132 short* pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportTL_Y + pViewport->uViewportTL_X;
|
|
3133 //v23 = (unsigned __int32)((char *)v26 + 4 * (((signed int)pViewport->uViewportX >> 1) + (Dst.lPitch >> 2) * pViewport->uViewportY));
|
|
3134 v9 = ((signed int)pViewport->uViewportTL_X >> 1) - ((signed int)pViewport->uViewportBR_X >> 1);
|
|
3135 //v20 = ((signed int)pViewport->uViewportZ >> 1) - ((signed int)pViewport->uViewportX >> 1);
|
|
3136 v22 = 4 * ((Dst.lPitch / 4) + v9);
|
|
3137 v21 = 4 * v9 + 1280;
|
|
3138
|
|
3139 //auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1;
|
|
3140 //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1);
|
|
3141 v10 = (int)pSrc_x1y1;
|
|
3142 v11 = (int)pDst_x1y1;
|
|
3143 int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;
|
|
3144 v13 = v24;
|
|
3145
|
|
3146 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
|
|
3147 {
|
|
3148 //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2,
|
|
3149 // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16));
|
|
3150 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x)
|
|
3151 {
|
|
3152 if (pSrc[y * window->GetWidth() + x] != (g_mask | b_mask))
|
|
3153 pDst[y * Dst.lPitch / 2 + x] = pSrc[y * window->GetWidth() + x];
|
|
3154 }
|
|
3155 }
|
|
3156 }
|
|
3157
|
|
3158 ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL));
|
|
3159
|
|
3160 /* while ( 1 )
|
|
3161 {
|
|
3162 while ( 1 )
|
|
3163 {
|
|
3164 v14 = *(int *)v10;
|
|
3165 v10 += 4;
|
|
3166 if ( v14 == v13 )
|
|
3167 break;
|
|
3168 if ( (short)v14 == (short)v13 )
|
|
3169 {
|
|
3170 *(int *)v11 = *(int *)v11 & 0xFFFF | v14 & 0xFFFF0000;
|
|
3171 v11 += 4;
|
|
3172 --uHalfWidth;
|
|
3173 if ( !uHalfWidth )
|
|
3174 goto LABEL_21;
|
|
3175 }
|
|
3176 else
|
|
3177 {
|
|
3178 v15 = __ROL__(v14, 16);
|
|
3179 if ( (short)v15 == (short)v13 )
|
|
3180 {
|
|
3181 v17 = __ROR__(v15, 16);
|
|
3182 *(int *)v11 = *(int *)v11 & 0xFFFF0000 | (unsigned __int16)v17;
|
|
3183 v11 += 4;
|
|
3184 --uHalfWidth;
|
|
3185 if ( !uHalfWidth )
|
|
3186 goto LABEL_21;
|
|
3187 }
|
|
3188 else
|
|
3189 {
|
|
3190 v16 = __ROR__(v15, 16);
|
|
3191 *(int *)v11 = v16;
|
|
3192 v11 += 4;
|
|
3193 --uHalfWidth;
|
|
3194 if ( !uHalfWidth )
|
|
3195 goto LABEL_21;
|
|
3196 }
|
|
3197 }
|
|
3198 }
|
|
3199 v11 += 4;
|
|
3200 --uHalfWidth;
|
|
3201 if ( !uHalfWidth )
|
|
3202 {
|
|
3203 LABEL_21:
|
|
3204 v10 += v21;
|
|
3205 v11 += v22;
|
|
3206 uHalfWidth = v20;
|
|
3207 if ( !--uNumLines )
|
|
3208 {
|
|
3209 ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL));
|
|
3210 return;
|
|
3211 }
|
|
3212 }
|
|
3213 }*/
|
|
3214 }
|
|
3215 //}
|
|
3216 }
|
|
3217 }
|
|
3218
|
|
3219
|
|
3220 //----- (0049FFFB) --------------------------------------------------------
|
|
3221 bool Render::InitializeFullscreen()
|
|
3222 {
|
|
3223 RenderD3D__DevInfo *v7; // ecx@5
|
|
3224 bool v8; // eax@6
|
|
3225 unsigned int v10; // eax@13
|
|
3226 signed int v15; // ebx@31
|
|
3227 int *v22; // eax@42
|
|
3228 int v23; // ecx@42
|
|
3229 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25
|
|
3230 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40
|
|
3231 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25
|
|
3232 int v29; // [sp+308h] [bp-4h]@2
|
|
3233
|
|
3234 //__debugbreak(); // Nomad
|
|
3235
|
|
3236 this->using_software_screen_buffer = 0;
|
|
3237 //this->pColorKeySurface4 = 0;
|
|
3238 this->pBackBuffer4 = nullptr;
|
|
3239 this->pFrontBuffer4 = nullptr;
|
|
3240 this->pDirectDraw4 = nullptr;
|
|
3241 //this->bColorKeySupported = 0;
|
|
3242 Release();
|
|
3243 //v3 = hWnd;
|
|
3244 this->window = window;
|
|
3245 CreateZBuffer();
|
|
3246
|
|
3247 /*if (!bUserDirect3D)
|
|
3248 {
|
|
3249 CreateDirectDraw();
|
|
3250 SetDirectDrawCooperationMode(hWnd, 1);
|
|
3251 SetDirectDrawDisplayMode(640u, 480u, 16u);
|
|
3252 CreateDirectDrawPrimarySurface();
|
|
3253 v15 = 1;
|
|
3254 }
|
|
3255 else
|
|
3256 {*/
|
|
3257 pRenderD3D = new RenderD3D;
|
|
3258 //v28 = pRenderD3D;
|
|
3259 //v6 = uDesiredDirect3DDevice;
|
|
3260 v29 = -1;
|
|
3261 v7 = pRenderD3D->pAvailableDevices;
|
|
3262 if ( pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible )
|
|
3263 v8 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, /*0*/true, window);
|
|
3264 else
|
|
3265 {
|
|
3266 if ( v7[1].bIsDeviceCompatible )
|
|
3267 v8 = pRenderD3D->CreateDevice(1, /*0*/true, window);
|
|
3268 else
|
|
3269 {
|
|
3270 if ( !v7->bIsDeviceCompatible )
|
|
3271 Error("There aren't any D3D devices to create.");
|
|
3272
|
|
3273 v8 = pRenderD3D->CreateDevice(0, /*0*/true, window);
|
|
3274 }
|
|
3275 }
|
|
3276 if ( !v8 )
|
|
3277 Error("D3Drend->Init failed.");
|
|
3278
|
|
3279 //v9 = pRenderD3D;
|
|
3280 pBackBuffer4 = pRenderD3D->pBackBuffer;
|
|
3281 pFrontBuffer4 = pRenderD3D->pFrontBuffer;
|
|
3282 pDirectDraw4 = pRenderD3D->pHost;
|
|
3283 v10 = pRenderD3D->GetDeviceCaps();
|
|
3284 if ( v10 & 1 )
|
|
3285 {
|
|
3286 if ( pRenderD3D )
|
|
3287 {
|
|
3288 pRenderD3D->Release();
|
|
3289 delete pRenderD3D;
|
|
3290 }
|
|
3291 pRenderD3D = nullptr;
|
|
3292 pBackBuffer4 = nullptr;
|
|
3293 pFrontBuffer4 = nullptr;
|
|
3294 pDirectDraw4 = nullptr;
|
|
3295 Error("Direct3D renderer: The device failed to return capabilities.");
|
|
3296 }
|
|
3297 if ( v10 & 0x3E )
|
|
3298 {
|
|
3299 if ( pRenderD3D )
|
|
3300 {
|
|
3301 pRenderD3D->Release();
|
|
3302 delete pRenderD3D;
|
|
3303 }
|
|
3304 //pColorKeySurface4 = 0;
|
|
3305 pRenderD3D = nullptr;
|
|
3306 pBackBuffer4 = nullptr;
|
|
3307 pFrontBuffer4 = nullptr;
|
|
3308 pDirectDraw4 = nullptr;
|
|
3309 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes.");
|
|
3310 }
|
|
3311 if ( (v10 & 0x80) != 0 )
|
|
3312 {
|
|
3313 if ( pRenderD3D )
|
|
3314 {
|
|
3315 pRenderD3D->Release();
|
|
3316 delete pRenderD3D;
|
|
3317 }
|
|
3318 pRenderD3D = nullptr;
|
|
3319 pBackBuffer4 = nullptr;
|
|
3320 pFrontBuffer4 = nullptr;
|
|
3321 pDirectDraw4 = nullptr;
|
|
3322 Error("Direct3D renderer: The device doesn't support non-square textures.");
|
|
3323 }
|
|
3324 //LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1;
|
|
3325 bRequiredTextureStagesAvailable = CheckTextureStages();
|
|
3326
|
|
3327 memset(&halCaps, 0, sizeof(halCaps));
|
|
3328 halCaps.dwSize = sizeof(halCaps);
|
|
3329
|
|
3330 memset(&refCaps, 0, sizeof(refCaps));
|
|
3331 refCaps.dwSize = sizeof(refCaps);
|
|
3332
|
|
3333 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps));
|
|
3334
|
|
3335 uMinDeviceTextureDim = halCaps.dwMinTextureWidth;
|
|
3336 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight )
|
|
3337 uMinDeviceTextureDim = halCaps.dwMinTextureHeight;
|
|
3338 uMinDeviceTextureDim = halCaps.dwMaxTextureWidth;
|
|
3339 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight )
|
|
3340 uMinDeviceTextureDim = halCaps.dwMaxTextureHeight;
|
|
3341 if ( (unsigned int)uMinDeviceTextureDim < 4 )
|
|
3342 uMinDeviceTextureDim = 4;
|
|
3343 v15 = 1;
|
|
3344 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true));
|
|
3345 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true));
|
|
3346 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2));
|
|
3347 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false));
|
|
3348 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false));
|
|
3349 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false));
|
|
3350 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
|
|
3351 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2));
|
|
3352 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2));
|
|
3353 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3));
|
|
3354 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2));
|
|
3355 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0));
|
|
3356 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2));
|
|
3357 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2));
|
|
3358 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0));
|
|
3359 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4));
|
|
3360 //}
|
|
3361 ddpfPrimarySuface.dwSize = 32;
|
|
3362 GetTargetPixelFormat(&ddpfPrimarySuface);
|
|
3363 ParseTargetPixelFormat();
|
|
3364
|
|
3365 if (!pRenderD3D)
|
|
3366 {
|
|
3367 __debugbreak();
|
|
3368 pBeforePresentFunction = 0;//nullsub_1;
|
|
3369 }
|
|
3370 //else
|
|
3371 //{
|
|
3372 /*v16 = IsColorKeySupported(pDirectDraw4);
|
|
3373 v17 = uAcquiredDirect3DDevice == v15;
|
|
3374 bColorKeySupported = v16;
|
|
3375 if ( !v17 )
|
|
3376 bColorKeySupported = 0;
|
|
3377 if ( bColorKeySupported )
|
|
3378 {
|
|
3379 memset(&ddsd2, 0, sizeof(ddsd2));
|
|
3380 ddsd2.dwSize = sizeof(ddsd2);
|
|
3381 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask;
|
|
3382 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue;
|
|
3383 ddsd2.dwFlags = 65543;
|
|
3384 ddsd2.ddsCaps.dwCaps = 2112;
|
|
3385 ddsd2.dwWidth = 640;
|
|
3386 ddsd2.dwHeight = 480;
|
|
3387 ErrD3D(pDirectDraw4->CreateSurface(&ddsd2, &pColorKeySurface4, NULL));
|
|
3388 pBeforePresentFunction = Present_ColorKey;
|
|
3389 }
|
|
3390 else*/
|
|
3391 {
|
|
3392 pTargetSurface = nullptr;
|
|
3393 pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32);
|
|
3394 if ( !pTargetSurface_unaligned )
|
|
3395 return 0;
|
|
3396 memset(&pDesc, 0, sizeof(pDesc));
|
|
3397 pDesc.dwSize = sizeof(pDesc);
|
|
3398 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15) )
|
|
3399 return 0;
|
|
3400 pBackBuffer4->Unlock(NULL);
|
|
3401 v22 = (int *)pTargetSurface_unaligned + 4;
|
|
3402 v23 = (unsigned int)pDesc.lpSurface & 7;
|
|
3403 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8;
|
|
3404 uTargetSurfacePitch = window->GetWidth();
|
|
3405 pBeforePresentFunction = Present_NoColorKey;
|
|
3406 v15 = 1;
|
|
3407 pTargetSurface = (unsigned __int32 *)((char *)v22 + 2 * v23);
|
|
3408 }
|
|
3409 using_software_screen_buffer = v15;
|
|
3410 //}
|
|
3411 bWindowMode = 0;
|
|
3412 pParty->uFlags |= 2;
|
|
3413 pViewport->SetFOV(flt_6BE3A0 * 65536.0f);
|
|
3414 return v15 != 0;
|
|
3415 }
|
|
3416
|
|
3417 //----- (004A05F3) --------------------------------------------------------
|
|
3418 bool Render::SwitchToWindow()
|
|
3419 {
|
|
3420 bool v7; // eax@7
|
|
3421 unsigned int v9; // eax@12
|
|
3422 int v12; // eax@24
|
|
3423 int v13; // eax@26
|
|
3424 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24
|
|
3425 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37
|
|
3426 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24
|
|
3427 int v29; // [sp+308h] [bp-4h]@2
|
|
3428
|
|
3429 pParty->uFlags |= PARTY_FLAGS_1_0002;
|
|
3430 pViewport->SetFOV(flt_6BE3A0 * 65536.0f);
|
|
3431 using_software_screen_buffer = 0;
|
|
3432 Release();
|
|
3433 //pColorKeySurface4 = 0;
|
|
3434 pBackBuffer4 = nullptr;
|
|
3435 pFrontBuffer4 = nullptr;
|
|
3436 pDirectDraw4 = nullptr;
|
|
3437 //bColorKeySupported = 0;
|
|
3438 CreateZBuffer();
|
|
3439 /*if (!bUserDirect3D)
|
|
3440 {
|
|
3441 CreateDirectDraw();
|
|
3442 SetDirectDrawCooperationMode(hWnd, 0);
|
|
3443 field_4004C = 1;
|
|
3444 CreateFrontBuffer();
|
|
3445 CreateClipper(hWnd);
|
|
3446 CreateBackBuffer();
|
|
3447 field_40030 = 0;
|
|
3448 field_18_locked_pitch = 0;
|
|
3449 }
|
|
3450 else
|
|
3451 {*/
|
|
3452 /*v3 = malloc(0x148u);
|
|
3453 thisa = (RenderD3D *)v3;
|
|
3454 v29 = 0;
|
|
3455 if ( v3 )
|
|
3456 v4 = RenderD3D::RenderD3D((RenderD3D *)v3);
|
|
3457 else
|
|
3458 v4 = 0;*/
|
|
3459 pRenderD3D = new RenderD3D;
|
|
3460 //v4 = pRenderD3D;
|
|
3461 //v5 = uDesiredDirect3DDevice;
|
|
3462 v29 = -1;
|
|
3463 //v6 = pRenderD3D->pAvailableDevices;
|
|
3464 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible &&
|
|
3465 uDesiredDirect3DDevice != 1 )
|
|
3466 {
|
|
3467 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, true, window);
|
|
3468 }
|
|
3469 else
|
|
3470 {
|
|
3471 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible )
|
|
3472 Error("There aren't any D3D devices to init.");
|
|
3473
|
|
3474 v7 = pRenderD3D->CreateDevice(0, true, window);
|
|
3475 }
|
|
3476 if ( !v7 )
|
|
3477 Error("D3Drend->Init failed.");
|
|
3478
|
|
3479 //v8 = pRenderD3D;
|
|
3480 //pColorKeySurface4 = 0;
|
|
3481 pBackBuffer4 = pRenderD3D->pBackBuffer;
|
|
3482 pFrontBuffer4 = pRenderD3D->pFrontBuffer;
|
|
3483 pDirectDraw4 = pRenderD3D->pHost;
|
|
3484 v9 = pRenderD3D->GetDeviceCaps();
|
|
3485 if ( v9 & 1 )
|
|
3486 {
|
|
3487 if (pRenderD3D)
|
|
3488 {
|
|
3489 pRenderD3D->Release();
|
|
3490 delete pRenderD3D;
|
|
3491 }
|
|
3492 pRenderD3D = nullptr;
|
|
3493 pBackBuffer4 = nullptr;
|
|
3494 pFrontBuffer4 = nullptr;
|
|
3495 pDirectDraw4 = nullptr;
|
|
3496 Error("Direct3D renderer: The device failed to return capabilities.");
|
|
3497 }
|
|
3498 if ( v9 & 0x3E )
|
|
3499 {
|
|
3500 if (pRenderD3D)
|
|
3501 {
|
|
3502 pRenderD3D->Release();
|
|
3503 delete pRenderD3D;
|
|
3504 }
|
|
3505 //pColorKeySurface4 = 0;
|
|
3506 pRenderD3D = nullptr;
|
|
3507 pBackBuffer4 = nullptr;
|
|
3508 pFrontBuffer4 = nullptr;
|
|
3509 pDirectDraw4 = nullptr;
|
|
3510 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes.");
|
|
3511 }
|
|
3512 if (v9 & 0x80)
|
|
3513 {
|
|
3514 if (pRenderD3D)
|
|
3515 {
|
|
3516 pRenderD3D->Release();
|
|
3517 delete pRenderD3D;
|
|
3518 }
|
|
3519 pRenderD3D = nullptr;
|
|
3520 pBackBuffer4 = nullptr;
|
|
3521 pFrontBuffer4 = nullptr;
|
|
3522 pDirectDraw4 = nullptr;
|
|
3523 Error("Direct3D renderer: The device doesn't support non-square textures.");
|
|
3524 }
|
|
3525 //LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1;
|
|
3526 bRequiredTextureStagesAvailable = CheckTextureStages();
|
|
3527
|
|
3528 memset(&halCaps, 0, sizeof(halCaps));
|
|
3529 halCaps.dwSize = sizeof(halCaps);
|
|
3530
|
|
3531 memset(&refCaps, 0, sizeof(refCaps));
|
|
3532 refCaps.dwSize = sizeof(refCaps);
|
|
3533
|
|
3534 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps));
|
|
3535 v12 = halCaps.dwMinTextureWidth;
|
|
3536 if ( (unsigned int)halCaps.dwMinTextureWidth > halCaps.dwMinTextureHeight )
|
|
3537 v12 = halCaps.dwMinTextureHeight;
|
|
3538 uMinDeviceTextureDim = v12;
|
|
3539 v13 = halCaps.dwMaxTextureWidth;
|
|
3540 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight )
|
|
3541 v13 = halCaps.dwMaxTextureHeight;
|
|
3542 uMaxDeviceTextureDim = v13;
|
|
3543 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1));
|
|
3544 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1));
|
|
3545 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2));
|
|
3546 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0));
|
|
3547 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0));
|
|
3548 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
|
|
3549 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2));
|
|
3550 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2));
|
|
3551 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3));
|
|
3552 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2));
|
|
3553 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0));
|
|
3554 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2));
|
|
3555 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2));
|
|
3556 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0));
|
|
3557 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4));
|
|
3558 //}
|
|
3559
|
|
3560 ddpfPrimarySuface.dwSize = 32;
|
|
3561 GetTargetPixelFormat(&ddpfPrimarySuface);
|
|
3562 ParseTargetPixelFormat();
|
|
3563
|
|
3564 if ( !pRenderD3D )
|
|
3565 {
|
|
3566 __debugbreak();
|
|
3567 //pBeforePresentFunction = 0;//nullsub_1;
|
|
3568 //goto LABEL_47;
|
|
3569 }
|
|
3570 /*v14 = IsColorKeySupported(pDirectDraw4);
|
|
3571 v15 = uAcquiredDirect3DDevice == 1;
|
|
3572 bColorKeySupported = v14;
|
|
3573 if ( !v15 )
|
|
3574 bColorKeySupported = 0;*/
|
|
3575 //if ( bColorKeySupported )
|
|
3576 if (false)
|
|
3577 {
|
|
3578 /*memset(&ddsd2, 0, 0x7Cu);
|
|
3579 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask;
|
|
3580 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue;
|
|
3581 v16 = pDirectDraw4;
|
|
3582 ddsd2.dwSize = 124;
|
|
3583 ddsd2.dwFlags = 65543;
|
|
3584 ddsd2.ddsCaps.dwCaps = 2112;
|
|
3585 ddsd2.dwWidth = 640;
|
|
3586 ddsd2.dwHeight = 480;
|
|
3587 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, NULL));
|
|
3588 pBeforePresentFunction = Present_ColorKey;*/
|
|
3589 using_software_screen_buffer = 1;
|
|
3590 //LABEL_47:
|
|
3591 bWindowMode = 1;
|
|
3592 //hWnd = hWnd;
|
|
3593 return 0;
|
|
3594 }
|
|
3595 pTargetSurface = 0;
|
|
3596 pTargetSurface_unaligned = 0;
|
|
3597
|
|
3598 uint num_pixels = window->GetWidth() * window->GetHeight();
|
|
3599 pTargetSurface_unaligned = new unsigned int[num_pixels];
|
|
3600
|
|
3601 if (!pTargetSurface_unaligned)
|
|
3602 return false;
|
|
3603
|
|
3604 memset(&pDesc, 0, sizeof(pDesc));
|
|
3605 pDesc.dwSize = sizeof(pDesc);
|
|
3606 if (!pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT))
|
|
3607 {
|
|
3608 delete [] pTargetSurface_unaligned;
|
|
3609 return false;
|
|
3610 }
|
|
3611
|
|
3612 memset32(pTargetSurface_unaligned, -1, num_pixels);
|
|
3613
|
|
3614 pRenderer->pBackBuffer4->Unlock(NULL);
|
|
3615 /*v19 = pTargetSurface_unaligned;
|
|
3616 v20 = (unsigned int)pDesc.lpSurface & 7;
|
|
3617 v21 = (unsigned int)ptr_400E8 & 7;
|
|
3618 if ( v21 == v20 )
|
|
3619 pTargetSurface = (unsigned __int16 *)v19;
|
|
3620 else
|
|
3621 {
|
|
3622 if ( (signed int)v21 >= v20 )
|
|
3623 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16);
|
|
3624 else
|
|
3625 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16);
|
|
3626 pTargetSurface = (unsigned __int16 *)v22;
|
|
3627 }*/
|
|
3628 pTargetSurface = pTargetSurface_unaligned;
|
|
3629 uTargetSurfacePitch = window->GetWidth();
|
|
3630 pBeforePresentFunction = Present_NoColorKey;
|
|
3631 using_software_screen_buffer = 1;
|
|
3632 bWindowMode = 1;
|
|
3633 return 0;
|
|
3634 }
|
|
3635
|
|
3636
|
|
3637 //----- (0044F2B2) --------------------------------------------------------
|
|
3638 bool Render::IsGammaSupported()
|
|
3639 {
|
|
3640 // bool result; // eax@3
|
|
3641 // HRESULT v1; // eax@4
|
|
3642
|
|
3643 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
3644 {
|
|
3645 DDCAPS halCaps; // [sp+0h] [bp-180h]@4
|
|
3646 memset(&halCaps, 0, sizeof(DDCAPS));
|
|
3647 halCaps.dwSize = sizeof(DDCAPS);
|
|
3648
|
|
3649 ErrD3D(pDirectDraw4->GetCaps(&halCaps, 0));
|
|
3650 return (halCaps.dwCaps2 >> 17) & 1;
|
|
3651 }
|
|
3652 /*else
|
|
3653 return false;*/
|
|
3654 }
|
|
3655
|
|
3656 //----- (004A0BEE) --------------------------------------------------------
|
|
3657 void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor)
|
|
3658 {
|
|
3659 signed int lower_bound; // eax@17
|
|
3660 // signed int left_bound;
|
|
3661 unsigned int v21; // edi@46
|
|
3662 int v22; // esi@47
|
|
3663 int v23; // ebx@47
|
|
3664 signed int v24; // edx@50
|
|
3665 signed int v25; // esi@52
|
|
3666 unsigned __int16 *v26; // ecx@52
|
|
3667 int v27; // ebx@54
|
|
3668 int v28; // edi@55
|
|
3669 int v29; // edx@55
|
|
3670 int v30; // ebx@60
|
|
3671 int v31; // edx@61
|
|
3672 int v32; // edi@61
|
|
3673 signed int upper_bound; // [sp+18h] [bp-4h]@28
|
|
3674 unsigned int uXa; // [sp+24h] [bp+8h]@49
|
|
3675 int uYb; // [sp+28h] [bp+Ch]@47
|
|
3676 bool left_border_x = false;
|
|
3677 bool right_border_x = false;
|
|
3678 bool left_border_z = false;
|
|
3679 bool right_border_z = false;
|
|
3680 bool upper_border_y = false;
|
|
3681 bool bottom_border_y = false;
|
|
3682 bool upper_border_w = false;
|
|
3683 bool bottom_border_w = false;
|
|
3684
|
|
3685 if ( uX < this->raster_clip_x )// x âûõîäèò çà ðàìêè ëåâîé ãðàíèöû
|
|
3686 left_border_x = true;
|
|
3687 if ( uX > this->raster_clip_z )// x âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû
|
|
3688 right_border_x = true;
|
|
3689
|
|
3690 if ( uZ < this->raster_clip_x )// z âûõîäèò çà ðàìêè ëåâîé ãðàíèöû
|
|
3691 left_border_z = true;
|
|
3692 if ( uZ > this->raster_clip_z )// z âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû
|
|
3693 right_border_z = true;
|
|
3694
|
|
3695 if ( uY < this->raster_clip_y )// y âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû
|
|
3696 upper_border_y = true;
|
|
3697 if ( uY > this->raster_clip_w )// y âûõîäèò çà ðàìêè íèæíåé ãðàíèöû
|
|
3698 bottom_border_y = true;
|
|
3699
|
|
3700 if ( uW < this->raster_clip_y )// w âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû
|
|
3701 upper_border_w = true;
|
|
3702 if ( uW > this->raster_clip_w )// w âûõîäèò çà ðàìêè íèæíåé ãðàíèöû
|
|
3703 bottom_border_w = true;
|
|
3704
|
|
3705 if ( (left_border_x && left_border_z) || (right_border_x && right_border_z )
|
|
3706 || (upper_border_y && upper_border_w) || (bottom_border_y && bottom_border_w))
|
|
3707 return;
|
|
3708
|
|
3709 if ( left_border_x || left_border_z || right_border_x || right_border_z
|
|
3710 || upper_border_y || upper_border_w || bottom_border_y || bottom_border_w)
|
|
3711 {
|
|
3712 if ( left_border_x || left_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left (ëåâàÿ ãðàíèöà)
|
|
3713 {
|
|
3714 if ( left_border_x )//left_border = true; õ ìåíüøå ëåâîé ãðàíèöû
|
|
3715 {
|
|
3716 uY += (uW - uY) * ((this->raster_clip_x - uX) / (uZ - uX));//t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ)
|
|
3717 uX = this->raster_clip_x;
|
|
3718 }
|
|
3719 else if ( left_border_z )//z ìåíüøå ëåâîé ãðàíèöû
|
|
3720 {
|
|
3721 uZ = this->raster_clip_x;
|
|
3722 uW += (uY - uW) * ((this->raster_clip_x - uZ) / (uX - uZ));
|
|
3723 }
|
|
3724 }
|
|
3725
|
|
3726 if ( right_border_x || right_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )//for right (ïðàâàÿ ãðàíèöà)
|
|
3727 {
|
|
3728 if ( right_border_x ) //right_border = true; õ áîëüøå ïðàâîé ãðàíèöû
|
|
3729 {
|
|
3730 uY += (uY - uW) * ((this->raster_clip_z - uX) / (uZ - uX));
|
|
3731 uX = this->raster_clip_z;
|
|
3732 }
|
|
3733 else if ( right_border_z )//z áîëüøå ïðàâîé ãðàíèöû
|
|
3734 {
|
|
3735 uW += (uW - uY) * ((this->raster_clip_z - uZ) / (uX - uZ));
|
|
3736 uZ = this->raster_clip_z;
|
|
3737 }
|
|
3738 }
|
|
3739
|
|
3740 upper_bound = 0;
|
|
3741 if ( uY < this->raster_clip_y )
|
|
3742 upper_bound = 2;
|
|
3743 if ( uY > this->raster_clip_w )
|
|
3744 upper_bound |= 1;
|
|
3745
|
|
3746 lower_bound = 0;
|
|
3747 if ( uW < this->raster_clip_y )
|
|
3748 lower_bound = 2;
|
|
3749 if ( uW > this->raster_clip_w )
|
|
3750 lower_bound |= 1;
|
|
3751
|
|
3752 if ( !(lower_bound & upper_bound) )//for up and down(äëÿ âåðõà è íèçà)
|
|
3753 {
|
|
3754 lower_bound ^= upper_bound;
|
|
3755 if ( lower_bound & 2 )
|
|
3756 {
|
|
3757 if ( upper_bound & 2 )
|
|
3758 {
|
|
3759 uX += (uZ - uX) * ((this->raster_clip_y - uY) / (uW - uY));
|
|
3760 uY = this->raster_clip_y;
|
|
3761 }
|
|
3762 else
|
|
3763 {
|
|
3764 uZ += (uX - uZ) * ((this->raster_clip_y - uW) / (uY - uW));
|
|
3765 uW = this->raster_clip_y;
|
|
3766 }
|
|
3767 }
|
|
3768 if ( lower_bound & 1 )
|
|
3769 {
|
|
3770 if ( upper_bound & 1 )
|
|
3771 {
|
|
3772 uX += (uZ - uX) * ((this->raster_clip_w - uY) / (uW - uY));
|
|
3773 uY = this->raster_clip_w;
|
|
3774 }
|
|
3775 else
|
|
3776 {
|
|
3777 uZ += (uX - uZ) * ((this->raster_clip_w - uW) / (uY - uW));
|
|
3778 uW = this->raster_clip_w;
|
|
3779 }
|
|
3780 }
|
|
3781 }
|
|
3782 }
|
|
3783 v21 = pRenderer->uTargetSurfacePitch;
|
|
3784 if ( pRenderer->uTargetSurfacePitch )
|
|
3785 {
|
|
3786 //v12 = uX + uY * pRenderer->uTargetSurfacePitch;
|
|
3787 v22 = uW - uY;
|
|
3788 v23 = v22;
|
|
3789 uYb = v22;
|
|
3790 if ( v22 < 0 )
|
|
3791 {
|
|
3792 v23 = -v22;
|
|
3793 uYb = -v22;
|
|
3794 v21 = -pRenderer->uTargetSurfacePitch;
|
|
3795 }
|
|
3796 uXa = uZ - uX;
|
|
3797 if ((signed)(uZ - uX) >= 0)
|
|
3798 v24 = 1;
|
|
3799 else
|
|
3800 {
|
|
3801 uXa = -uXa;
|
|
3802 v24 = -1;
|
|
3803 }
|
|
3804 v25 = 0;
|
|
3805
|
|
3806 v26 = (unsigned __int16 *)this->pTargetSurface;
|
|
3807 if ( v26 )
|
|
3808 {
|
|
3809 if ( (signed int)uXa <= v23 )//ðèñóåì âåðòèêàëüíóþ ëèíèþ
|
|
3810 {
|
|
3811 v30 = v23 + 1;
|
|
3812 if ( v30 > 0 )
|
|
3813 {
|
|
3814 v31 = 2 * v24;
|
|
3815 v32 = 2 * v21;
|
|
3816 //v12 = (int)&v26[v12];
|
|
3817 int y = 0;
|
|
3818 int x = 0;
|
|
3819 for ( v30; v30; --v30 )
|
|
3820 {
|
|
3821 v25 += uXa;
|
|
3822 //*(short *)v12 = uColor;
|
|
3823 //v12 += v32;
|
|
3824 WritePixel16(uX + x, uY + y, uColor);
|
|
3825 if ( v32 >= 0 )
|
|
3826 y += 1;
|
|
3827 else
|
|
3828 y -= 1;
|
|
3829 if ( v25 > 0 )
|
|
3830 {
|
|
3831 v25 -= uYb;
|
|
3832 //v12 += v31;
|
|
3833 if ( v31 >= 0 )
|
|
3834 x += 1;
|
|
3835 else
|
|
3836 x -= 1;
|
|
3837 }
|
|
3838 }
|
|
3839 }
|
|
3840 }
|
|
3841 else//ðèñóåì ãîðèçîíòàëüíóþ ëèíèþ
|
|
3842 {
|
|
3843 v27 = uXa + 1;
|
|
3844 if ( (signed int)(uXa + 1) > 0 )
|
|
3845 {
|
|
3846 v28 = 2 * v21;
|
|
3847 v29 = 2 * v24;
|
|
3848 int y = 0;
|
|
3849 int x = 0;
|
|
3850 //v12 = (int)&v26[v12];
|
|
3851 for ( v27; v27; --v27 )
|
|
3852 {
|
|
3853 v25 += uYb;
|
|
3854 //*(short *)v12 = uColor;
|
|
3855 //v12 += v29;
|
|
3856 WritePixel16(uX + x, uY + y, uColor);
|
|
3857 if ( v29 >= 0 )
|
|
3858 x += 1;
|
|
3859 else
|
|
3860 x -= 1;
|
|
3861 if ( v25 > (signed int)uXa )
|
|
3862 {
|
|
3863 v25 -= uXa;
|
|
3864 //v12 += v28;
|
|
3865 if ( v28 >= 0 )
|
|
3866 y += 1;
|
|
3867 else
|
|
3868 y -= 1;
|
|
3869 }
|
|
3870 }
|
|
3871 }
|
|
3872 }
|
|
3873 }
|
|
3874 }
|
|
3875 return;
|
|
3876 }
|
|
3877
|
|
3878 //----- (004A0E80) --------------------------------------------------------
|
|
3879 void Render::ClearZBuffer(int a2, int a3)
|
|
3880 {
|
|
3881 memset32(this->pActiveZBuffer, -65536, 0x4B000);
|
|
3882 }
|
|
3883
|
|
3884 //----- (004A0E97) --------------------------------------------------------
|
|
3885 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
|
|
3886 {
|
|
3887 this->raster_clip_x = uX;
|
|
3888 this->raster_clip_y = uY;
|
|
3889 this->raster_clip_z = uZ;
|
|
3890 this->raster_clip_w = uW;
|
|
3891 }
|
|
3892
|
|
3893 //----- (004A0EB6) --------------------------------------------------------
|
|
3894 void Render::ParseTargetPixelFormat()
|
|
3895 {
|
|
3896 signed int v2; // ecx@1
|
|
3897 DWORD uRedMask; // edx@1
|
|
3898 unsigned int uGreenMask; // esi@5
|
|
3899 signed int v5; // ecx@5
|
|
3900 unsigned int uBlueMask; // edx@9
|
|
3901 signed int v7; // ecx@9
|
|
3902 //unsigned int v8; // ecx@13
|
|
3903
|
|
3904 v2 = 0;
|
|
3905 uRedMask = this->ddpfPrimarySuface.dwRBitMask;
|
|
3906 this->uTargetBBits = 0;
|
|
3907 this->uTargetGBits = 0;
|
|
3908 this->uTargetRBits = 0;
|
|
3909 do
|
|
3910 {
|
|
3911 if ( (1 << v2) & uRedMask )
|
|
3912 ++this->uTargetRBits;
|
|
3913 ++v2;
|
|
3914 }
|
|
3915 while ( v2 < 32 );
|
|
3916 uGreenMask = this->ddpfPrimarySuface.dwGBitMask;
|
|
3917 v5 = 0;
|
|
3918 do
|
|
3919 {
|
|
3920 if ( (1 << v5) & uGreenMask )
|
|
3921 ++this->uTargetGBits;
|
|
3922 ++v5;
|
|
3923 }
|
|
3924 while ( v5 < 32 );
|
|
3925 uBlueMask = this->ddpfPrimarySuface.dwBBitMask;
|
|
3926 v7 = 0;
|
|
3927 do
|
|
3928 {
|
|
3929 if ( (1 << v7) & uBlueMask )
|
|
3930 ++this->uTargetBBits;
|
|
3931 ++v7;
|
|
3932 }
|
|
3933 while ( v7 < 32 );
|
|
3934 this->uTargetGMask = uGreenMask;
|
|
3935 this->uTargetRMask = this->ddpfPrimarySuface.dwRBitMask;
|
|
3936 this->uTargetBMask = uBlueMask;
|
|
3937 }
|
|
3938
|
|
3939 //----- (004A0F40) --------------------------------------------------------
|
|
3940 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags)
|
|
3941 {
|
|
3942 HRESULT result; // eax@1
|
|
3943 HRESULT v6; // eax@4
|
|
3944 char v9; // [sp+Bh] [bp-1h]@1
|
|
3945
|
|
3946 v9 = 1;
|
|
3947 result = pSurface->Lock(NULL, pDesc, uLockFlags, NULL);
|
|
3948 /*
|
|
3949 Êîãäà îáúåêò DirectDrawSurface òåðÿåò ïîâåðõíîñòíóþ ïàìÿòü, ìåòîäû âîçâðàòÿò DDERR_SURFACELOST
|
|
3950 è íå âûïîëíÿò íèêàêóþ äðóãóþ ôóíêöèþ. Ìåòîä IDirectDrawSurface::Restore ïåðåðàñïðåäåëèò ïîâåðõíîñòíóþ ïàìÿòü
|
|
3951 è ïîâòîðíî ïðèñîåäèíèò åå ê îáúåêòó DirectDrawSurface.
|
|
3952 */
|
|
3953 if ( result == DDERR_SURFACELOST )
|
|
3954 {
|
|
3955 v6 = pSurface->Restore();//Âîññòàíàâëèâàåò ïîòåðÿííóþ ïîâåðõíîñòü. Ýòî ïðîèñõîäèò, êîãäà ïîâåðõíîñòíàÿ ïàìÿòü,
|
|
3956 //ñâÿçàííàÿ ñ îáúåêòîì DirectDrawSurface áûëà îñâîáîæäåíà.
|
|
3957 if ( v6 )
|
|
3958 {
|
|
3959 if ( v6 != DDERR_IMPLICITLYCREATED )//DDERR_IMPLICITLYCREATED - Ïîâåðõíîñòü íå ìîæåò áûòü âîññòàíîâëåíà,
|
|
3960 //ïîòîìó ÷òî îíà - íåÿâíî ñîçäàííàÿ ïîâåðõíîñòü.
|
|
3961 {
|
|
3962 v9 = 0;
|
|
3963 result = (bool)memset(pDesc, 0, 4);
|
|
3964 LOBYTE(result) = v9;
|
|
3965 return 0;
|
|
3966 }
|
|
3967 pRenderer->pFrontBuffer4->Restore();
|
|
3968 pSurface->Restore();
|
|
3969 }
|
|
3970 result = pSurface->Lock(NULL, pDesc, DDLOCK_WAIT, NULL);
|
|
3971 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY )//DDERR_SURFACEBUSY - Äîñòóï ê ýòîé ïîâåðõíîñòè îòêàçàí,
|
|
3972 //ïîòîìó ÷òî ïîâåðõíîñòü áëîêèðîâàíà äðóãîé íèòüþ. DDERR_INVALIDRECT - Îáåñïå÷èâàåìûé ïðÿìîóãîëüíèê íåäîïóñòèì.
|
|
3973 {
|
|
3974 v9 = 0;
|
|
3975 result = (bool)memset(pDesc, 0, 4);
|
|
3976 LOBYTE(result) = v9;
|
|
3977 return result;
|
|
3978 }
|
|
3979 ErrD3D(result);
|
|
3980 if ( result )
|
|
3981 {
|
|
3982 //v8 = 0;
|
|
3983 //v7 = 2161;
|
|
3984 //LABEL_19:
|
|
3985 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8);
|
|
3986 v9 = 0;
|
|
3987 result = (bool)memset(pDesc, 0, 4);
|
|
3988 LOBYTE(result) = v9;
|
|
3989 return result;
|
|
3990 }
|
|
3991 if ( pRenderD3D )
|
|
3992 pRenderD3D->HandleLostResources();
|
|
3993 result = pRenderer->pDirectDraw4->RestoreAllSurfaces();
|
|
3994 }
|
|
3995 else
|
|
3996 {
|
|
3997 if ( result )
|
|
3998 {
|
|
3999 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY )
|
|
4000 {
|
|
4001 v9 = 0;
|
|
4002 result = (bool)memset(pDesc, 0, 4);
|
|
4003 LOBYTE(result) = v9;
|
|
4004 return result;
|
|
4005 }
|
|
4006 ErrD3D(result);
|
|
4007 //v8 = 0;
|
|
4008 //v7 = 2199;
|
|
4009 //goto LABEL_19;
|
|
4010 }
|
|
4011 }
|
|
4012 return true;
|
|
4013 }
|
|
4014
|
|
4015
|
|
4016 //----- (004A10E4) --------------------------------------------------------
|
|
4017 void Render::CreateDirectDraw()
|
|
4018 {
|
|
4019 //Render *v1; // edi@1
|
|
4020 // HRESULT v2; // eax@1
|
|
4021 // HRESULT v3; // eax@5
|
|
4022 // int v6; // [sp-Ch] [bp-20h]@3
|
|
4023 // unsigned int v9; // [sp+0h] [bp-14h]@0
|
|
4024 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1
|
|
4025
|
|
4026 //v1 = this;
|
|
4027 ErrD3D(DirectDrawCreate(0, &lpDD, 0));
|
|
4028
|
|
4029 pDirectDraw4 = nullptr;
|
|
4030
|
|
4031 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4));
|
|
4032
|
|
4033 lpDD->Release();
|
|
4034 lpDD = nullptr;
|
|
4035 }
|
|
4036
|
|
4037 //----- (004A1169) --------------------------------------------------------
|
|
4038 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen)
|
|
4039 {
|
|
4040 DWORD flags; // eax@1
|
|
4041
|
|
4042 //Óñòàíîâêà âçàèìîäåéñòâèÿ äëÿ ïîëíîýêðàííîãî è îêîííîãî ðåæèìîâ
|
|
4043 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : DDSCL_NORMAL;
|
|
4044
|
|
4045 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED));
|
|
4046 }
|
|
4047
|
|
4048 //----- (004A11C6) --------------------------------------------------------
|
|
4049 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP)
|
|
4050 {
|
|
4051 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0));
|
|
4052 }
|
|
4053
|
|
4054 //----- (004A121C) --------------------------------------------------------
|
|
4055 void Render::CreateFrontBuffer()
|
|
4056 {
|
|
4057 //Render *v1; // esi@1
|
|
4058 IDirectDraw *pDD; // eax@3
|
|
4059 IDirectDrawSurface **pOutSurf; // esi@3
|
|
4060 struct _DDSURFACEDESC *v4; // edx@3
|
|
4061 //// HRESULT v5; // eax@5
|
|
4062 int v6; // [sp-8h] [bp-8Ch]@3
|
|
4063 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3
|
|
4064
|
|
4065 //v1 = this;
|
|
4066 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
|
|
4067 //pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
4068 {
|
|
4069 memset(&a2, 0, sizeof(a2));
|
|
4070 a2.dwSize = sizeof(a2);
|
|
4071
|
|
4072 pDD = (IDirectDraw *)this->pDirectDraw4;
|
|
4073 a2.dwFlags = 1;
|
|
4074 a2.ddsCaps.dwCaps = 512;//DDSCAPS_PRIMARYSURFACE = 0x200
|
|
4075
|
|
4076 v6 = 2357;
|
|
4077 pOutSurf = (IDirectDrawSurface **)&this->pFrontBuffer4;
|
|
4078 v4 = (struct _DDSURFACEDESC *)&a2;
|
|
4079 }
|
|
4080 /*else
|
|
4081 {
|
|
4082 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here
|
|
4083 pDD = (IDirectDraw *)v1->pDirectDraw2;
|
|
4084 a2.lPitch = 108;
|
|
4085 a2.dwBackBufferCount = 1;
|
|
4086 a2.dwTextureStage = 512;
|
|
4087 v6 = 2346;
|
|
4088 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2;
|
|
4089 v4 = (struct _DDSURFACEDESC *)&a2.lPitch;
|
|
4090 }*/
|
|
4091 ErrD3D(pDD->CreateSurface(v4, pOutSurf, NULL));
|
|
4092 }
|
|
4093
|
|
4094 //----- (004A12CD) --------------------------------------------------------
|
|
4095 void Render::CreateBackBuffer()
|
|
4096 {
|
|
4097 //Render *v1; // esi@1
|
|
4098 IDirectDraw *v2; // eax@3
|
|
4099 IDirectDrawSurface **ppBackBuffer; // esi@3
|
|
4100 struct _DDSURFACEDESC *v4; // edx@3
|
|
4101 // HRESULT v5; // eax@5
|
|
4102 int v6; // [sp-8h] [bp-8Ch]@3
|
|
4103 unsigned int v7; // [sp-4h] [bp-88h]@3
|
|
4104 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3
|
|
4105
|
|
4106 //v1 = this;
|
|
4107 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
|
|
4108 // pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
4109 {
|
|
4110 memset(&a2, 0, sizeof(a2));
|
|
4111 a2.dwSize = sizeof(a2);
|
|
4112
|
|
4113 v2 = (IDirectDraw *)this->pDirectDraw4;
|
|
4114 a2.dwFlags = 7;
|
|
4115 a2.ddsCaps.dwCaps = 2112;//0x840 = DDSCAPS_SYSTEMMEMORY = 0x800 | DDSCAPS_OFFSCREENPLAIN = 0x40
|
|
4116 a2.dwWidth = window->GetWidth();
|
|
4117 a2.dwHeight = window->GetHeight();
|
|
4118
|
|
4119 v7 = 0;
|
|
4120 v6 = 2387;
|
|
4121 ppBackBuffer = (IDirectDrawSurface **)&this->pBackBuffer4;
|
|
4122 v4 = (struct _DDSURFACEDESC *)&a2;
|
|
4123 }
|
|
4124 /*else
|
|
4125 {
|
|
4126 memset(&a2.lPitch, 0, 0x6Cu);
|
|
4127 v2 = (IDirectDraw *)v1->pDirectDraw2;
|
|
4128 a2.lPitch = 108;
|
|
4129 a2.dwBackBufferCount = 7;
|
|
4130 v7 = 0;
|
|
4131 a2.dwTextureStage = 2112;
|
|
4132 a2.dwAlphaBitDepth = 640;
|
|
4133 a2.dwMipMapCount = 480;
|
|
4134 v6 = 2374;
|
|
4135 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2;
|
|
4136 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2
|
|
4137 }*/
|
|
4138 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, NULL));
|
|
4139 }
|
|
4140
|
|
4141 //----- (004A139A) --------------------------------------------------------
|
|
4142 void Render::CreateDirectDrawPrimarySurface()
|
|
4143 {
|
|
4144 IDirectDrawSurface *pFrontBuffer; // eax@3
|
|
4145 DDSCAPS2 *v6; // edx@3
|
|
4146 IDirectDraw4 *v7; // eax@4
|
|
4147 int v9; // ST14_4@5
|
|
4148 IDirectDrawSurface *v10; // ST10_4@5
|
|
4149 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3
|
|
4150 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3
|
|
4151 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4
|
|
4152
|
|
4153 //v1 = this;
|
|
4154 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
|
|
4155 //pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
4156 {
|
|
4157 //v2 = 0;
|
|
4158 //this->field_4004C = 1;
|
|
4159 memset(&ddsd2, 0, sizeof(ddsd2));
|
|
4160 ddsd2.dwSize = sizeof(ddsd2);
|
|
4161
|
|
4162 ddsd2.dwBackBufferCount = 1;
|
|
4163 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
|
|
4164 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE;
|
|
4165 ErrD3D(this->pDirectDraw4->CreateSurface(&ddsd2, &pFrontBuffer4, NULL));
|
|
4166 pFrontBuffer = (IDirectDrawSurface *)this->pFrontBuffer4;
|
|
4167 ppBackBuffer = (IDirectDrawSurface **)&this->pBackBuffer4;
|
|
4168 }
|
|
4169 /*else
|
|
4170 {
|
|
4171 v2 = 0;
|
|
4172 this->field_4004C = 1;
|
|
4173
|
|
4174 DDSURFACEDESC ddsd;
|
|
4175 memset(&ddsd, 0, sizeof(DDSURFACEDESC));
|
|
4176
|
|
4177 ddsd.lpSurface = (LPVOID)1;
|
|
4178 ddsd.lPitch = 108;
|
|
4179 ddsd.dwBackBufferCount = 33;
|
|
4180 ddsd.ddsCaps.dwCaps = 8728;
|
|
4181 ErrD3D(pDirectDraw2->CreateSurface(&ddsd, (IDirectDrawSurface **)&pFrontBuffer2, NULL));
|
|
4182
|
|
4183 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2;
|
|
4184 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2;
|
|
4185 }*/
|
|
4186 __debugbreak(); // warning C4700: uninitialized local variable 'v6' used
|
|
4187 v9 = (int)v6;
|
|
4188 v10 = pFrontBuffer; // BUG
|
|
4189
|
|
4190 v17.dwCaps = 4;
|
|
4191 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer);
|
|
4192 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer);
|
|
4193 //v1->field_40030 = v2;
|
|
4194 //v1->field_18_locked_pitch = v2;
|
|
4195 }
|
|
4196
|
|
4197 //----- (004A14F4) --------------------------------------------------------
|
|
4198 void Render::CreateClipper(HWND a2)
|
|
4199 {
|
|
4200 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, NULL));
|
|
4201 ErrD3D(pDDrawClipper->SetHWnd(0, a2));
|
|
4202 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper));
|
|
4203 }
|
|
4204
|
|
4205 //----- (004A15D8) --------------------------------------------------------
|
|
4206 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut)
|
|
4207 {
|
|
4208 pFrontBuffer4->GetPixelFormat(pOut);
|
|
4209 }
|
|
4210
|
|
4211 //----- (004A1605) --------------------------------------------------------
|
|
4212 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow)
|
|
4213 {
|
|
4214 signed int v4; // eax@3
|
|
4215
|
|
4216 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
|
|
4217 //pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
4218 {
|
|
4219 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3
|
|
4220
|
|
4221 memset(&pDesc, 0, sizeof(pDesc));
|
|
4222 pDesc.dwSize = sizeof(pDesc);
|
|
4223
|
|
4224 LockSurface_DDraw4(this->pBackBuffer4, &pDesc, DDLOCK_WAIT);
|
|
4225 *pOutSurfacePtr = pDesc.lpSurface;
|
|
4226 v4 = pDesc.lPitch;
|
|
4227 }
|
|
4228 /*else
|
|
4229 {
|
|
4230 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3
|
|
4231 memset(&pDesc.lPitch, 0, 0x6Cu);
|
|
4232 pDesc.lPitch = 108;
|
|
4233 LockSurface_DDraw2(this->pBackBuffer2, &pDesc, 1);
|
|
4234 *pOutSurfacePtr = (void *)pDesc.lpSurface;
|
|
4235 v4 = pDesc.dwReserved;
|
|
4236 }*/
|
|
4237 *pOutPixelsPerRow = v4 >> 1;
|
|
4238 }
|
|
4239
|
|
4240 //----- (004A16E1) --------------------------------------------------------
|
|
4241 void Render::UnlockBackBuffer()
|
|
4242 {
|
|
4243 ErrD3D(pBackBuffer4->Unlock(NULL));
|
|
4244 }
|
|
4245
|
|
4246 //----- (004A172E) --------------------------------------------------------
|
|
4247 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow)
|
|
4248 {
|
|
4249 signed int v4; // eax@3
|
|
4250
|
|
4251 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
4252 {
|
|
4253 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3
|
|
4254
|
|
4255 memset(&pDesc, 0, sizeof(pDesc));
|
|
4256 pDesc.dwSize = sizeof(pDesc);
|
|
4257
|
|
4258 LockSurface_DDraw4(this->pFrontBuffer4, &pDesc, DDLOCK_WAIT);
|
|
4259 *pOutSurface = pDesc.lpSurface;
|
|
4260 v4 = pDesc.lPitch;
|
|
4261 }
|
|
4262 /*else
|
|
4263 {
|
|
4264 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3
|
|
4265 memset(&pDesc.lPitch, 0, 0x6Cu);
|
|
4266 pDesc.lPitch = 108;
|
|
4267 LockSurface_DDraw2(this->pFrontBuffer2, &pDesc, 1);
|
|
4268 *pOutSurface = (void *)pDesc.lpSurface;
|
|
4269 v4 = pDesc.dwReserved;
|
|
4270 }*/
|
|
4271 *pOutPixelsPerRow = v4 >> 1;
|
|
4272 }
|
|
4273
|
|
4274 //----- (004A17C7) --------------------------------------------------------
|
|
4275 void Render::UnlockFrontBuffer()
|
|
4276 {
|
|
4277 ErrD3D(pFrontBuffer4->Unlock(NULL));
|
|
4278 }
|
|
4279
|
|
4280 //----- (004A1814) --------------------------------------------------------
|
|
4281 void Render::RestoreFrontBuffer()
|
|
4282 {
|
|
4283 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST )
|
|
4284 pFrontBuffer4->Restore();
|
|
4285 }
|
|
4286
|
|
4287 //----- (004A184C) --------------------------------------------------------
|
|
4288 void Render::RestoreBackBuffer()
|
|
4289 {
|
|
4290 if ( pBackBuffer4->IsLost() == DDERR_SURFACELOST )
|
|
4291 pBackBuffer4->Restore();
|
|
4292 }
|
|
4293
|
|
4294 //----- (004A18F5) --------------------------------------------------------
|
|
4295 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags)
|
|
4296 {
|
|
4297 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr));
|
|
4298 }
|
|
4299
|
|
4300 //----- (004A194A) --------------------------------------------------------
|
|
4301 void Render::BltBackToFontFast(int a2, int a3, RECT *pSrcRect)
|
|
4302 {
|
|
4303 IDirectDrawSurface *pFront; // eax@3
|
|
4304 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3
|
|
4305
|
|
4306 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
4307 {
|
|
4308 pFront = (IDirectDrawSurface *)this->pFrontBuffer4;
|
|
4309 pBack = (IDirectDrawSurface *)this->pBackBuffer4;
|
|
4310 }
|
|
4311 /*else
|
|
4312 {
|
|
4313 pFront = (IDirectDrawSurface *)this->pFrontBuffer2;
|
|
4314 pBack = (IDirectDrawSurface *)this->pBackBuffer2;
|
|
4315 }*/
|
|
4316 pFront->BltFast(NULL, NULL, pBack, pSrcRect, DDBLTFAST_WAIT);
|
|
4317 }
|
|
4318
|
|
4319 //----- (004A1B22) --------------------------------------------------------
|
|
4320 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z)
|
|
4321 {
|
|
4322 unsigned int v7; // edx@6
|
|
4323
|
|
4324 if (uNumBillboardsToDraw >= 999 )
|
|
4325 return 0;
|
|
4326 if (!uNumBillboardsToDraw)
|
|
4327 {
|
|
4328 uNumBillboardsToDraw = 1;
|
|
4329 return 0;
|
|
4330 }
|
|
4331
|
|
4332 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch
|
|
4333 {
|
|
4334 v7 = left + (right - left) / 2;
|
|
4335 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order)
|
|
4336 right = v7;
|
|
4337 else
|
|
4338 left = v7 + 1;
|
|
4339 }
|
|
4340
|
|
4341 if (z > pRenderer->pBillboardRenderListD3D[v7].z_order )
|
|
4342 {
|
|
4343 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 )
|
|
4344 v7 = pRenderer->uNumBillboardsToDraw;
|
|
4345 else
|
|
4346 {
|
|
4347 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 )
|
|
4348 {
|
|
4349 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ )
|
|
4350 {
|
|
4351 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i],
|
|
4352 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - (i + 1)],
|
|
4353 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i]));
|
|
4354 }
|
|
4355 }
|
|
4356 ++v7;
|
|
4357 }
|
|
4358 uNumBillboardsToDraw++;
|
|
4359 return v7;
|
|
4360 }
|
|
4361 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order )
|
|
4362 {
|
|
4363 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 )
|
|
4364 {
|
|
4365 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ )
|
|
4366 {
|
|
4367 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i],
|
|
4368 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw -(i + 1)],
|
|
4369 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i]));
|
|
4370 }
|
|
4371 }
|
|
4372 uNumBillboardsToDraw++;
|
|
4373 return v7;
|
|
4374 }
|
|
4375 return v7;
|
|
4376 }
|
|
4377
|
|
4378 //----- (004A1E9D) --------------------------------------------------------
|
|
4379 unsigned int Render::GetBillboardDrawListSize()
|
|
4380 {
|
|
4381 return pRenderer->uNumBillboardsToDraw;
|
|
4382 }
|
|
4383
|
|
4384 //----- (004A1EA3) --------------------------------------------------------
|
|
4385 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID)
|
|
4386 {
|
|
4387 return pRenderer->pBillboardRenderListD3D[uBillboardID].sParentBillboardID;
|
|
4388 }
|
|
4389
|
|
4390 //----- (004A1EB6) --------------------------------------------------------
|
|
4391 void Render::BeginSceneD3D()
|
|
4392 {
|
|
4393 if (!uNumD3DSceneBegins++)
|
|
4394 {
|
|
4395 //if (pRenderD3D)
|
|
4396 {
|
|
4397 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0);
|
|
4398 pRenderer->uNumBillboardsToDraw = 0;
|
|
4399 pRenderD3D->pDevice->BeginScene();
|
|
4400
|
|
4401 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
|
|
4402 uFogColor = GetLevelFogColor();
|
|
4403 else
|
|
4404 uFogColor = 0;
|
|
4405
|
|
4406 if ( uFogColor & 0xFF000000 )
|
|
4407 {
|
|
4408 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1);
|
|
4409 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF);
|
|
4410 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0);
|
|
4411 bUsingSpecular = true;
|
|
4412 }
|
|
4413 else
|
|
4414 {
|
|
4415 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0);
|
|
4416 bUsingSpecular = 0;
|
|
4417 }
|
|
4418 }
|
|
4419 /*else
|
|
4420 {
|
|
4421 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch);
|
|
4422 if (pTargetSurface)
|
|
4423 field_18_locked_pitch = uTargetSurfacePitch;
|
|
4424 else
|
|
4425 --uNumD3DSceneBegins;
|
|
4426 }*/
|
|
4427 }
|
|
4428 }
|
|
4429
|
|
4430 //----- (004A1FE1) --------------------------------------------------------
|
|
4431 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene()
|
|
4432 {
|
|
4433 --uNumD3DSceneBegins;
|
|
4434 if (uNumD3DSceneBegins)
|
|
4435 return;
|
|
4436
|
|
4437 if (pRenderD3D)
|
|
4438 {
|
|
4439 pGame->draw_debug_outlines();
|
|
4440 DoRenderBillboards_D3D();
|
|
4441 pGame->pStru6Instance->RenderSpecialEffects();
|
|
4442 pRenderD3D->pDevice->EndScene();
|
|
4443 }
|
|
4444 else
|
|
4445 pGame->pStru6Instance->RenderSpecialEffects();
|
|
4446 }
|
|
4447
|
|
4448 //----- (004A2031) --------------------------------------------------------
|
|
4449 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6)
|
|
4450 {
|
|
4451 // __debugbreak(); // should not fire outside decal builder
|
|
4452 return ::GetActorTintColor(tint, a4, a2, a5, a6);
|
|
4453 }
|
|
4454
|
|
4455 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function
|
|
4456 {
|
|
4457 int v5; // ebx@1
|
|
4458 int v6; // edi@1
|
|
4459 int v8; // eax@7
|
|
4460 float v9; // eax@12
|
|
4461 float *v10; // esi@12
|
|
4462 float v11; // ecx@14
|
|
4463 double v12; // st7@14
|
|
4464 double v13; // st7@14
|
|
4465 double v14; // st7@14
|
|
4466 signed int v15; // eax@14
|
|
4467 int v16; // eax@15
|
|
4468 float v17; // ST48_4@15
|
|
4469 char v18; // zf@17
|
|
4470 int v19; // eax@18
|
|
4471 int v20; // eax@18
|
|
4472 int v21; // edx@20
|
|
4473 signed int v22; // ecx@20
|
|
4474 int v23; // eax@20
|
|
4475 const char *v24; // ST4C_4@20
|
|
4476 unsigned int v25; // ST50_4@20
|
|
4477 int v26; // ST54_4@20
|
|
4478 int v27; // eax@20
|
|
4479 _UNKNOWN *v28; // eax@21
|
|
4480 int v29; // ecx@23
|
|
4481 int v30; // eax@23
|
|
4482 int v31; // eax@23
|
|
4483 int v32; // eax@24
|
|
4484 int v33; // eax@25
|
|
4485 int v34; // eax@25
|
|
4486 int v35; // eax@25
|
|
4487 int v36; // eax@25
|
|
4488 signed int v37; // ecx@26
|
|
4489 int v38; // eax@26
|
|
4490 _UNKNOWN *v39; // eax@27
|
|
4491 int v40; // edx@28
|
|
4492 int v41; // eax@29
|
|
4493 int v42; // eax@29
|
|
4494 int v43; // eax@29
|
|
4495 int v44; // eax@29
|
|
4496 unsigned int v46; // eax@29
|
|
4497 int v47; // eax@30
|
|
4498 int v48; // eax@30
|
|
4499 int v49; // eax@30
|
|
4500 double v52; // st6@35
|
|
4501 const char *v55; // [sp+4Ch] [bp-1Ch]@20
|
|
4502 int v57; // [sp+5Ch] [bp-Ch]@3
|
|
4503 signed int v59; // [sp+60h] [bp-8h]@12
|
|
4504 int v61; // [sp+64h] [bp-4h]@4
|
|
4505 int i;
|
|
4506
|
|
4507 v6 = (int)this;
|
|
4508 v5 = 0;
|
|
4509 if (!this->uNumD3DSceneBegins)
|
|
4510 return;
|
|
4511
|
|
4512
|
|
4513
|
|
4514
|
|
4515 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
|
|
4516 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
|
|
4517 if (this->bUsingSpecular)
|
|
4518 {
|
|
4519 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
|
|
4520 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
|
|
4521 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
|
|
4522 }
|
|
4523
|
|
4524 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX;
|
|
4525 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY;
|
|
4526 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist);
|
|
4527 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097);
|
|
4528 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0);
|
|
4529 pVertices[0].specular = 0;
|
|
4530 pVertices[0].texcoord.x = array_50AC10[0].u;
|
|
4531 pVertices[0].texcoord.y = array_50AC10[0].v;
|
|
4532
|
|
4533 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX;
|
|
4534 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY;
|
|
4535 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist);
|
|
4536 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097);
|
|
4537 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0);
|
|
4538 pVertices[1].specular = 0;
|
|
4539 pVertices[1].texcoord.x = array_50AC10[3].u;
|
|
4540 pVertices[1].texcoord.y = array_50AC10[3].v;
|
|
4541
|
|
4542 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX;
|
|
4543 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY;
|
|
4544 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist);
|
|
4545 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097);
|
|
4546 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0);
|
|
4547 pVertices[2].specular = 0;
|
|
4548 pVertices[2].texcoord.x = array_50AC10[1].u;
|
|
4549 pVertices[2].texcoord.y = array_50AC10[1].v;
|
|
4550
|
|
4551 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3));
|
|
4552 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3));
|
|
4553
|
|
4554 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX;
|
|
4555 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY;
|
|
4556 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist);
|
|
4557 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097);
|
|
4558 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0);
|
|
4559 pVertices[5].specular = 0;
|
|
4560 pVertices[5].texcoord.x = array_50AC10[2].u;
|
|
4561 pVertices[5].texcoord.y = array_50AC10[2].v;
|
|
4562
|
|
4563
|
|
4564 this->pRenderD3D->pDevice->SetTexture(0, pTexture);
|
|
4565 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT);
|
|
4566
|
|
4567 }*/
|
|
4568
|
|
4569 //----- (004A26BC) --------------------------------------------------------
|
|
4570 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders)
|
|
4571 {
|
|
4572 unsigned int v8; // ebx@1
|
|
4573 int v11; // eax@5
|
|
4574 int v20; // eax@14
|
|
4575 unsigned int v45; // eax@28
|
|
4576
|
|
4577 v8 = 0;
|
|
4578 if (!this->uNumD3DSceneBegins)
|
|
4579 return;
|
|
4580 if ( uNumVertices < 3)
|
|
4581 return;
|
|
4582
|
|
4583 //v61 = pVertices;
|
|
4584
|
|
4585 /* v9 = pGame->pLightmapBuilder;
|
|
4586 v65 = v9;
|
|
4587 v10 = v9->std__vector_000004_size;*/
|
|
4588 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related)
|
|
4589 {
|
|
4590 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0);
|
|
4591 pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/);
|
|
4592 }
|
|
4593 else
|
|
4594 {
|
|
4595 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size ||
|
|
4596 byte_4D864C && pGame->uFlags & 2 )
|
|
4597 {
|
|
4598 if (clampAtTextureBorders)
|
|
4599 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
|
|
4600 else
|
|
4601 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
|
|
4602
|
|
4603 if (transparent || this->bUsingSpecular)
|
|
4604 {
|
|
4605 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
|
|
4606 if (transparent)
|
|
4607 {
|
|
4608 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
|
|
4609 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
|
4610 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO);
|
|
4611 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
|
|
4612 }
|
|
4613 else
|
|
4614 {
|
|
4615 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
|
|
4616 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
|
|
4617 }
|
|
4618 }
|
|
4619
|
|
4620 for (uint i = 0; i < uNumVertices; ++i)
|
|
4621 {
|
|
4622
|
|
4623 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX;
|
|
4624 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY;
|
|
4625 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist);
|
|
4626 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001);
|
|
4627 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0);
|
|
4628 if ( this->bUsingSpecular )
|
|
4629 {
|
|
4630 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x);
|
|
4631 }
|
|
4632 else
|
|
4633 {
|
|
4634 d3d_vertex_buffer[i].specular = 0;
|
|
4635 }
|
|
4636 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u;
|
|
4637 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
|
|
4638 }
|
|
4639
|
|
4640 this->pRenderD3D->pDevice->SetTexture(0, a5);
|
|
4641 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16);
|
|
4642 if (transparent)
|
|
4643 {
|
|
4644 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
4645 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
4646 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
4647 }
|
|
4648 }
|
|
4649 else
|
|
4650 {
|
|
4651 for (uint i = 0; i < uNumVertices; ++i)
|
|
4652 {
|
|
4653
|
|
4654 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX;
|
|
4655 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY;
|
|
4656 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist);
|
|
4657 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001);
|
|
4658 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0);
|
|
4659 if ( this->bUsingSpecular )
|
|
4660 {
|
|
4661 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x);
|
|
4662 }
|
|
4663 else
|
|
4664 {
|
|
4665 d3d_vertex_buffer[i].specular = 0;
|
|
4666 }
|
|
4667 __debugbreak(); // warning C4700: uninitialized local variable 'v20' used
|
|
4668 d3d_vertex_buffer[i].specular = v20;
|
|
4669 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u;
|
|
4670 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
|
|
4671 }
|
|
4672 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
4673 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
4674 if (pRenderer->bUsingSpecular)
|
|
4675 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
4676
|
|
4677 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));
|
|
4678 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
4679 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
4680 d3d_vertex_buffer,
|
|
4681 uNumVertices,
|
|
4682 16));
|
|
4683 //v63 = (const char *)v7->pRenderD3D->pDevice;
|
|
4684 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
4685 //(*(void (**)(void))(*(int *)v63 + 88))();
|
|
4686 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/);
|
|
4687 for (uint i = 0; i < uNumVertices; ++i)
|
|
4688 {
|
|
4689 d3d_vertex_buffer[i].diffuse = -1;
|
|
4690 }
|
|
4691 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5));
|
|
4692 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
4693 if ( !pRenderer->bUsingSpecular )
|
|
4694 {
|
|
4695 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
4696 }
|
|
4697 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
4698 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO));
|
|
4699 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR));
|
|
4700 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
4701 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
4702 d3d_vertex_buffer,
|
|
4703 uNumVertices,
|
|
4704 16));
|
|
4705 if ( pRenderer->bUsingSpecular )
|
|
4706 {
|
|
4707 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
4708 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));
|
|
4709 for (uint i = 0; i < uNumVertices; ++i)
|
|
4710 {
|
|
4711 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000;
|
|
4712 d3d_vertex_buffer[i].specular = 0;
|
|
4713 }
|
|
4714
|
|
4715 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem
|
|
4716 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA));
|
|
4717 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA));
|
|
4718 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
4719 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
4720 d3d_vertex_buffer,
|
|
4721 uNumVertices,
|
|
4722 16));
|
|
4723 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
4724 //v44 = pRenderer->pRenderD3D->pDevice;
|
|
4725 v45 = GetLevelFogColor();
|
|
4726 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF));
|
|
4727 v8 = 0;
|
|
4728 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
|
|
4729 }
|
|
4730 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
4731 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
4732 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8));
|
|
4733 }
|
|
4734 }
|
|
4735
|
|
4736 //if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES)
|
|
4737 if (pGame->pIndoorCameraD3D->debug_flags & ODM_RENDER_DRAW_TERRAIN_OUTLINES)
|
|
4738 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0);
|
|
4739 }
|
|
4740 // 4A26BC: could not find valid save-restore pair for esi
|
|
4741 // 4D864C: using guessed type char byte_4D864C;
|
|
4742
|
|
4743 //----- (004A2DA3) --------------------------------------------------------
|
|
4744 void Render::DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture)
|
|
4745 {
|
|
4746 int v7; // eax@7
|
|
4747
|
|
4748 if ( !this->uNumD3DSceneBegins )
|
|
4749 return;
|
|
4750 if ( uNumVertices >= 3 )
|
|
4751 {
|
|
4752 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
|
|
4753 if ( this->bUsingSpecular )
|
|
4754 {
|
|
4755 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
|
|
4756 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
|
|
4757 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
|
|
4758 }
|
|
4759 for ( uint i = 0; i < uNumVertices; ++i )
|
|
4760 {
|
|
4761 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX;
|
|
4762 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY;
|
|
4763 pVertices[i].pos.z = 0.99989998;
|
|
4764 pVertices[i].rhw = array_50AC10[i]._rhw;
|
|
4765
|
|
4766 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0);
|
|
4767 v7 = 0;
|
|
4768 if (this->bUsingSpecular)
|
|
4769 v7 = sub_47C3D7_get_fog_specular(0, 1, array_50AC10[i].vWorldViewPosition.x);
|
|
4770 pVertices[i].specular = v7;
|
|
4771 pVertices[i].texcoord.x = array_50AC10[i].u;
|
|
4772 pVertices[i].texcoord.y = array_50AC10[i].v;
|
|
4773 }
|
|
4774 pRenderD3D->pDevice->SetTexture(0, pTexture);
|
|
4775 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
4776 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT);
|
|
4777 }
|
|
4778 }
|
|
4779
|
|
4780 //----- (004A2ED5) --------------------------------------------------------
|
|
4781 void Render::DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture)
|
|
4782 {
|
|
4783 int v5; // eax@3
|
|
4784
|
|
4785 if ( this->uNumD3DSceneBegins )
|
|
4786 {
|
|
4787 if ( uNumVertices >= 3 )
|
|
4788 {
|
|
4789 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
4790 v5 = 31 - (pSkyPolygon->dimming_level & 0x1F);
|
|
4791 if ( v5 < pOutdoor->max_terrain_dimming_level )
|
|
4792 v5 = pOutdoor->max_terrain_dimming_level;
|
|
4793 for (uint i = 0; i < (unsigned int)uNumVertices; ++i)
|
|
4794 {
|
|
4795 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
|
|
4796 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
|
|
4797 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
|
|
4798 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw;
|
|
4799 d3d_vertex_buffer[i].diffuse = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8);
|
|
4800 d3d_vertex_buffer[i].specular = 0;
|
|
4801 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u;
|
|
4802 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v;
|
|
4803 }
|
|
4804 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture));
|
|
4805 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
4806 d3d_vertex_buffer, uNumVertices, 28));
|
|
4807 }
|
|
4808 }
|
|
4809 }
|
|
4810
|
|
4811 //----- (00479A53) --------------------------------------------------------
|
|
4812 void Render::DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID)
|
|
4813 {
|
|
4814 BLVFace *pFace; // esi@1
|
|
4815 double v5; // st7@3
|
|
4816 signed __int64 v6; // qax@3
|
|
4817 int v12; // edx@7
|
|
4818 int v13; // eax@7
|
|
4819 int v17; // edi@9
|
|
4820 double v18; // st7@9
|
|
4821 signed int v19; // ebx@9
|
|
4822 void *v20; // ecx@9
|
|
4823 int v21; // ebx@11
|
|
4824 int v22; // eax@14
|
|
4825 signed __int64 v23; // qtt@16
|
|
4826 double v28; // st7@20
|
|
4827 double v33; // st6@23
|
|
4828 const void *v35; // ecx@31
|
|
4829 int v36; // eax@31
|
|
4830 const void *v37; // edi@31
|
|
4831 signed __int64 v38; // qax@31
|
|
4832 int v39; // ecx@31
|
|
4833 int v40; // ebx@33
|
|
4834 int v41; // eax@36
|
|
4835 signed __int64 v42; // qtt@39
|
|
4836 int v43; // eax@39
|
|
4837 double v48; // st7@41
|
|
4838 double v51; // st7@46
|
|
4839 struct Polygon pSkyPolygon; // [sp+14h] [bp-160h]@6
|
|
4840 unsigned int v63; // [sp+120h] [bp-54h]@7
|
|
4841 unsigned int v65; // [sp+128h] [bp-4Ch]@1
|
|
4842 unsigned int v66; // [sp+12Ch] [bp-48h]@7
|
|
4843 __int64 v69; // [sp+13Ch] [bp-38h]@3
|
|
4844 int v70; // [sp+144h] [bp-30h]@3
|
|
4845 int X; // [sp+148h] [bp-2Ch]@9
|
|
4846 int v72; // [sp+14Ch] [bp-28h]@7
|
|
4847 float v73; // [sp+150h] [bp-24h]@16
|
|
4848 unsigned int v74; // [sp+154h] [bp-20h]@3
|
|
4849 unsigned int v74_; // [sp+154h] [bp-20h]@3
|
|
4850 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3
|
|
4851 float v76; // [sp+15Ch] [bp-18h]@9
|
|
4852 int v77; // [sp+160h] [bp-14h]@9
|
|
4853 int v78; // [sp+164h] [bp-10h]@7
|
|
4854 void *v79; // [sp+168h] [bp-Ch]@9
|
|
4855 float v80; // [sp+16Ch] [bp-8h]@3
|
|
4856 const void *v81; // [sp+170h] [bp-4h]@7
|
|
4857
|
|
4858 pFace = &pIndoor->pFaces[uFaceID];
|
|
4859 //for floor and wall(for example Selesta)-------------------
|
|
4860 if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor)
|
|
4861 {
|
|
4862 int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x;
|
|
4863 int v55 = (GetTickCount() / 32) + pGame->pIndoorCameraD3D->vPartyPos.y;
|
|
4864 for (uint i = 0; i < uNumVertices; ++i)
|
|
4865 {
|
|
4866 array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f;
|
|
4867 array_507D30[i].v = (v55 + array_507D30[i].v) * 0.25f;
|
|
4868 }
|
|
4869 pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0);
|
|
4870 return;
|
|
4871 }
|
|
4872 //---------------------------------------
|
|
4873 v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)//179
|
|
4874 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0)
|
|
4875 * 65536.0)
|
|
4876 + (double)pBLVRenderParams->uViewportCenterY);
|
|
4877 v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;//0
|
|
4878 v6 = (signed __int64)((double)pBLVRenderParams->uViewportCenterY//183
|
|
4879 - (double)pBLVRenderParams->fov_rad_fixpoint
|
|
4880 / ((cos(v5) * 16192.0 + 0.0000001)
|
|
4881 * 65535.0)
|
|
4882 * (sin(v5) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z));
|
|
4883
|
|
4884 stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0);
|
|
4885 pSkyPolygon.Create_48607B(&stru_8019C8);
|
|
4886 pSkyPolygon.uTileBitmapID = pFace->uBitmapID;
|
|
4887
|
|
4888 pSkyPolygon.pTexture = pBitmaps_LOD->GetTexture(pSkyPolygon.uTileBitmapID);
|
|
4889 if ( !pSkyPolygon.pTexture )
|
|
4890 return;
|
|
4891
|
|
4892 pSkyPolygon.dimming_level = 0;
|
|
4893 pSkyPolygon.uNumVertices = uNumVertices;
|
|
4894
|
|
4895 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
|
|
4896 pSkyPolygon.v_18.y = 0;
|
|
4897 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16);
|
|
4898
|
|
4899 memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices]));
|
|
4900 pSkyPolygon.field_24 = 0x2000000;
|
|
4901
|
|
4902 extern float _calc_fov(int viewport_width, int angle_degree);
|
|
4903 //v64 = (double)(signed int)(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX) * 0.5;
|
|
4904 //v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5);
|
|
4905 v72 = 65536.0f / _calc_fov(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX, 74);
|
|
4906 v12 = pSkyPolygon.pTexture->uWidthMinus1;
|
|
4907 v13 = pSkyPolygon.pTexture->uHeightMinus1;
|
|
4908 //v67 = 1.0 / (double)pSkyPolygon.pTexture->uTextureWidth;
|
|
4909 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13;
|
|
4910 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12;
|
|
4911 v78 = 0;
|
|
4912 //v81 = 0;
|
|
4913 float v68 = 1.0 / (double)pSkyPolygon.pTexture->uTextureHeight;
|
|
4914 if ( (signed int)pSkyPolygon.uNumVertices <= 0 )
|
|
4915 return;
|
|
4916
|
|
4917 int _507D30_idx = 0;
|
|
4918 for ( _507D30_idx; _507D30_idx < pSkyPolygon.uNumVertices; _507D30_idx++ )
|
|
4919 {
|
|
4920 //v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY));
|
|
4921 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY));
|
|
4922 v74 = v77 + pSkyPolygon.ptr_38->angle_from_north;
|
|
4923
|
|
4924 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY));
|
|
4925 v74_ = v77 + pSkyPolygon.ptr_38->angle_from_east;
|
|
4926
|
|
4927 v79 = (void *)(fixpoint_mul(pSkyPolygon.v_18.z, v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY)));
|
|
4928 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX);
|
|
4929 v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0;
|
|
4930 v19 = -pSkyPolygon.field_24;
|
|
4931 v77 = -pSkyPolygon.field_24;
|
|
4932 X = (int)((char *)v79 + pSkyPolygon.v_18.x);
|
|
4933 LODWORD(v76) = (signed __int64)v18;
|
|
4934 v20 = (void *)(v72 * (v70 - LODWORD(v76)));
|
|
4935 while ( 1 )
|
|
4936 {
|
|
4937 v79 = v20;
|
|
4938 if ( !X )
|
|
4939 goto LABEL_14;
|
|
4940 v21 = abs(v19 >> 14);
|
|
4941 if ( v21 <= abs(X) )//0x800 <= 0x28652
|
|
4942 break;
|
|
4943 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y )
|
|
4944 break;
|
|
4945 v19 = v77;
|
|
4946 v20 = v79;
|
|
4947 LABEL_14:
|
|
4948 v79 = (void *)fixpoint_mul(pSkyPolygon.v_18.z, (int)v20);
|
|
4949 v22 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v20);
|
|
4950 --LODWORD(v76);
|
|
4951 v20 = (char *)v20 + v72;
|
|
4952 X = v22 + pSkyPolygon.v_18.x;
|
|
4953 v78 = 1;
|
|
4954 }
|
|
4955 if ( !v78 )
|
|
4956 {
|
|
4957 LODWORD(v23) = v77 << 16;
|
|
4958 HIDWORD(v23) = v77 >> 16;//v23 = 0xfffffe0000000000
|
|
4959 v79 = (void *)(v23 / X);//X = FFFF9014(-28652)
|
|
4960 v77 = v17;
|
|
4961 signed __int64 s = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v17);// s = 0xFFFFFFFF FFFF3EE6
|
|
4962 LODWORD(v80) = v66 + ((signed int)fixpoint_mul(SLODWORD(s), v23 / X) >> 4);
|
|
4963 array_507D30[_507D30_idx].u = ((double)SLODWORD(v80) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth);
|
|
4964
|
|
4965 signed __int64 s2 = v74_ + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v17);
|
|
4966 LODWORD(v80) = v63 + ((signed int)fixpoint_mul(SLODWORD(s2), v23 / X) >> 4);
|
|
4967 array_507D30[_507D30_idx].v = ((double)SLODWORD(v80) * 0.000015259022) * v68;
|
|
4968
|
|
4969 v77 = fixpoint_mul(SLODWORD(s), v23 / X);
|
|
4970 LODWORD(v73) = fixpoint_mul(SLODWORD(s2), v23 / X);
|
|
4971 array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79;
|
|
4972
|
|
4973 //if ( (int)v81 >= pSkyPolygon.uNumVertices )
|
|
4974 //{
|
|
4975 // pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon,
|
|
4976 // pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
|
|
4977 // return;
|
|
4978 //}
|
|
4979 continue;
|
|
4980 }
|
|
4981 break;
|
|
4982 }
|
|
4983 if ( _507D30_idx >= pSkyPolygon.uNumVertices )
|
|
4984 {
|
|
4985 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon,
|
|
4986 pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
|
|
4987 return;
|
|
4988 }
|
|
4989 LODWORD(v73) = 0;
|
|
4990 v80 = v76;
|
|
4991 if ( (signed int)pSkyPolygon.uNumVertices > 0 )
|
|
4992 {
|
|
4993 v28 = (double)SLODWORD(v76);
|
|
4994 LODWORD(v76) = (int)(char *)array_50AC10 + 28;
|
|
4995 uint i = 0;
|
|
4996 for ( v78 = pSkyPolygon.uNumVertices; v78; --v78 )
|
|
4997 {
|
|
4998 ++LODWORD(v73);
|
|
4999 memcpy(&array_50AC10[i], &array_507D30[i], 0x30u);
|
|
5000 LODWORD(v76) += 48;
|
|
5001 if ( v28 < array_507D30[i].vWorldViewProjY | v28 == array_507D30[i].vWorldViewProjY
|
|
5002 || v28 >= array_507D30[i + 1].vWorldViewProjY )
|
|
5003 {
|
|
5004 if ( v28 >= array_507D30[i].vWorldViewProjY || v28 <= array_507D30[i + 1].vWorldViewProjY )
|
|
5005 {
|
|
5006 i++;
|
|
5007 continue;
|
|
5008 }
|
|
5009 v33 = (array_507D30[i + 1].vWorldViewProjX - array_507D30[i].vWorldViewProjX) * v28 / (array_507D30[i + 1].vWorldViewProjY - array_507D30[i].vWorldViewProjY)
|
|
5010 + array_507D30[i + 1].vWorldViewProjX;
|
|
5011 }
|
|
5012 else
|
|
5013 {
|
|
5014 v33 = (array_507D30[i].vWorldViewProjX - array_507D30[i + 1].vWorldViewProjX) * v28 / (array_507D30[i].vWorldViewProjY - array_507D30[i + 1].vWorldViewProjY)
|
|
5015 + array_507D30[i].vWorldViewProjX;
|
|
5016 }
|
|
5017 array_50AC10[i + 1].vWorldViewProjX = v33;
|
|
5018 ++LODWORD(v73);
|
|
5019 *(unsigned int *)LODWORD(v76) = v28;
|
|
5020 LODWORD(v76) += 48;
|
|
5021 i++;
|
|
5022 }
|
|
5023 }
|
|
5024 if ( SLODWORD(v73) <= 0 )
|
|
5025 goto LABEL_40;
|
|
5026 //v34 = (char *)&array_50AC10[0].vWorldViewProjY;
|
|
5027 uint j = 0;
|
|
5028 v65 = v77 >> 14;
|
|
5029 //HIDWORD(v69) = LODWORD(v73);
|
|
5030 for ( int t = (int)LODWORD(v73); t > 1; t-- )
|
|
5031 {
|
|
5032 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjY));
|
|
5033
|
|
5034 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_west_east;
|
|
5035 //v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v35);
|
|
5036 v36 = (int)(fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, (int)v35) + pSkyPolygon.ptr_38->angle_from_north);
|
|
5037
|
|
5038 v81 = v35;
|
|
5039 v74 = v36;
|
|
5040 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_north_south;
|
|
5041 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, (int)v35);
|
|
5042 v78 = (int)v35;
|
|
5043 v75 = (RenderVertexSoft *)((char *)v81 + pSkyPolygon.ptr_38->angle_from_east);
|
|
5044 //v81 = (const void *)pSkyPolygon.v_18.z;
|
|
5045 v78 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v35);
|
|
5046 v37 = (const void *)(v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjX));
|
|
5047 v38 = (signed __int64)(array_50AC10[j].vWorldViewProjY - 1.0);
|
|
5048 v81 = 0;
|
|
5049 LODWORD(v76) = v38;
|
|
5050 v39 = v72 * (v70 - v38);
|
|
5051 while ( 1 )
|
|
5052 {
|
|
5053 v78 = v39;
|
|
5054 if ( !X )
|
|
5055 goto LABEL_36;
|
|
5056 v40 = abs(X);
|
|
5057 if ( abs((signed __int64)v65) <= v40 )
|
|
5058 break;
|
|
5059 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y )
|
|
5060 break;
|
|
5061 v39 = v78;
|
|
5062 LABEL_36:
|
|
5063 v78 = pSkyPolygon.v_18.z;
|
|
5064 v41 = fixpoint_mul(pSkyPolygon.v_18.z, v39);
|
|
5065 --LODWORD(v76);
|
|
5066 v39 += v72;
|
|
5067 X = v41 + pSkyPolygon.v_18.x;
|
|
5068 v81 = (const void *)1;
|
|
5069 }
|
|
5070 if ( v81 )
|
|
5071 {
|
|
5072 v79 = (void *)pSkyPolygon.v_18.z;
|
|
5073 v78 = 2 * LODWORD(v76);
|
|
5074 v81 = (const void *)fixpoint_mul(pSkyPolygon.v_18.z, (((double)v70 - ((double)(2 * LODWORD(v76)) - array_50AC10[j].vWorldViewProjY))
|
|
5075 * (double)v72));
|
|
5076 X = (int)((char *)v81 + pSkyPolygon.v_18.x);
|
|
5077 }
|
|
5078 LODWORD(v42) = v77 << 16;
|
|
5079 HIDWORD(v42) = v77 >> 16;
|
|
5080 v79 = (void *)(v42 / X);
|
|
5081 v81 = v37;
|
|
5082
|
|
5083 //v78 = pSkyPolygon.ptr_38->angle_from_west;
|
|
5084 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37);
|
|
5085 v43 = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37);
|
|
5086 v74 = (unsigned int)v37;
|
|
5087 LODWORD(v76) = v43;
|
|
5088
|
|
5089 //v78 = pSkyPolygon.ptr_38->angle_from_south;
|
|
5090 v75 = (RenderVertexSoft *)((char *)v75 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, (int)v37));
|
|
5091 //v74 = fixpoint_mul(v43, v42 / X);
|
|
5092 v81 = (const void *)fixpoint_mul((int)v75, v42 / X);
|
|
5093
|
|
5094 //v34 += 48;
|
|
5095 //v78 = v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4);
|
|
5096 //v44 = HIDWORD(v69)-- == 1;
|
|
5097 //v45 = (double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022;
|
|
5098 //v78 = v63 + ((signed int)fixpoint_mul((int)v75, v42 / X) >> 4);
|
|
5099 array_50AC10[j].u = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth);
|
|
5100 array_50AC10[j].v = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * v68;
|
|
5101 //v46 = (double)(signed int)v79;
|
|
5102 array_50AC10[j].vWorldViewPosition.x = 0.000015258789 * (double)(signed int)v79;
|
|
5103 array_50AC10[j]._rhw = 65536.0 / (double)(signed int)v79;
|
|
5104 ++j;
|
|
5105 }
|
|
5106 //while ( !v44 );
|
|
5107 LABEL_40:
|
|
5108 uint i = 0;
|
|
5109 if ( SLODWORD(v73) > 0 )
|
|
5110 {
|
|
5111 v48 = (double)SLODWORD(v80);
|
|
5112 for ( HIDWORD(v69) = LODWORD(v73); HIDWORD(v69); --HIDWORD(v69) )
|
|
5113 {
|
|
5114 if ( v48 >= array_50AC10[i].vWorldViewProjY )
|
|
5115 {
|
|
5116 ++i;
|
|
5117 memcpy(&array_507D30[i], &array_50AC10[i], 0x30u);
|
|
5118 }
|
|
5119 }
|
|
5120 }
|
|
5121 pSkyPolygon.uNumVertices = i;
|
|
5122 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
|
|
5123 int pNumVertices = 0;
|
|
5124 if ( SLODWORD(v73) > 0 )
|
|
5125 {
|
|
5126 v51 = (double)SLODWORD(v80);
|
|
5127 for ( v80 = v73; v80 != 0.0; --LODWORD(v80) )
|
|
5128 {
|
|
5129 if ( v51 <= array_50AC10[pNumVertices].vWorldViewProjY )
|
|
5130 {
|
|
5131 ++pNumVertices;
|
|
5132 memcpy(&array_507D30[pNumVertices], &array_50AC10[pNumVertices], 0x30u);
|
|
5133 }
|
|
5134 }
|
|
5135 }
|
|
5136 pRenderer->DrawIndoorSkyPolygon(pNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
|
|
5137 }
|
|
5138
|
|
5139
|
|
5140 //----- (004A2FC0) --------------------------------------------------------
|
|
5141 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8)
|
|
5142 {
|
|
5143 if (!uNumD3DSceneBegins || uNumVertices < 3)
|
|
5144 return;
|
|
5145
|
|
5146 //auto a3 = pFace;
|
|
5147 //auto a6 = uPackedID;
|
|
5148 //v59 = pGame->pLightmapBuilder;
|
|
5149 //v9 = v59->std__vector_000004_size;
|
|
5150
|
|
5151 int sCorrectedColor = uColor;
|
|
5152 if (pGame->pLightmapBuilder->std__vector_000004_size)
|
|
5153 sCorrectedColor = -1;
|
|
5154 pGame->AlterGamma_BLV(pFace, &sCorrectedColor);
|
|
5155
|
|
5156
|
|
5157 if (pFace->uAttributes & FACE_OUTLINED)
|
|
5158 {
|
|
5159 // int color;
|
|
5160 if (GetTickCount() % 300 >= 150)
|
|
5161 uColor = sCorrectedColor = 0xFF20FF20;
|
|
5162 else uColor = sCorrectedColor = 0xFF109010;
|
|
5163 }
|
|
5164
|
|
5165 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related)
|
|
5166 {
|
|
5167 __debugbreak();
|
|
5168 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
|
|
5169 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
5170 for (uint i = 0; i < uNumVertices; ++i)
|
|
5171 {
|
|
5172 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
|
|
5173 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
|
|
5174 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
|
|
5175 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x;
|
|
5176 d3d_vertex_buffer[i].diffuse = sCorrectedColor;
|
|
5177 d3d_vertex_buffer[i].specular = 0;
|
|
5178 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth;
|
|
5179 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight;
|
|
5180 }
|
|
5181
|
|
5182 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
5183 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
|
5184 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
|
|
5185 D3DPT_TRIANGLEFAN,
|
|
5186 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
5187 d3d_vertex_buffer,
|
|
5188 uNumVertices,
|
|
5189 28));
|
|
5190 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/);
|
|
5191 }
|
|
5192 else
|
|
5193 {
|
|
5194 if (!pGame->pLightmapBuilder->std__vector_000004_size ||
|
|
5195 byte_4D864C && pGame->uFlags & 2)
|
|
5196 {
|
|
5197 for (uint i = 0; i < uNumVertices; ++i)
|
|
5198 {
|
|
5199 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
|
|
5200 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
|
|
5201 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
|
|
5202 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x;
|
|
5203 d3d_vertex_buffer[i].diffuse = sCorrectedColor;
|
|
5204 d3d_vertex_buffer[i].specular = 0;
|
|
5205 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth;
|
|
5206 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight;
|
|
5207 }
|
|
5208
|
|
5209 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
5210 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex));
|
|
5211 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
5212 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
5213 d3d_vertex_buffer,
|
|
5214 uNumVertices,
|
|
5215 28));
|
|
5216 }
|
|
5217 else
|
|
5218 {
|
|
5219 for (uint i = 0; i < uNumVertices; ++i)
|
|
5220 {
|
|
5221 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
|
|
5222 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
|
|
5223 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
|
|
5224 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x;
|
|
5225 d3d_vertex_buffer[i].diffuse = uColor;
|
|
5226 d3d_vertex_buffer[i].specular = 0;
|
|
5227 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth;
|
|
5228 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight;
|
|
5229 }
|
|
5230 //__debugbreak();
|
|
5231 //if ( (signed int)uNumVertices > 0 )
|
|
5232 //{
|
|
5233 //v23 = pTex;
|
|
5234 //v24 = (char *)&array_507D30[0].vWorldViewPosition;
|
|
5235 //v25 = (char *)&d3d_vertex_buffer[0].pos.y;
|
|
5236 //pTex = (Texture *)uNumVertices;
|
|
5237 //uint v18;
|
|
5238 //do
|
|
5239 //{
|
|
5240 //v26 = *(float *)v24 * 0.061758894;
|
|
5241 //v27 = *((int *)v24 + 3);
|
|
5242 //*((int *)v25 + 4) = 0;
|
|
5243 //*((int *)v25 - 1) = v27;
|
|
5244 //*(int *)v25 = *((int *)v24 + 4);
|
|
5245 //*((int *)v25 + 3) = uColor;
|
|
5246 //v25 += 32;
|
|
5247 //*((float *)v25 - 7) = 1.0 - 1.0 / v26;
|
|
5248 //v28 = 1.0 / *(float *)v24;
|
|
5249 //v24 += 48;
|
|
5250 //v18 = pTex == (Texture *)1;
|
|
5251 //pTex = (Texture *)((char *)pTex - 1);
|
|
5252 //*((float *)v25 - 6) = v28;
|
|
5253 //a3 = (BLVFace *)v23->uTextureWidth;
|
|
5254 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth;
|
|
5255 //a3 = (BLVFace *)v23->uTextureHeight;
|
|
5256 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight;
|
|
5257 //}
|
|
5258 //while ( !v18 );
|
|
5259 //}
|
|
5260 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
|
|
5261 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
5262 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
|
5263 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
5264 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
5265 d3d_vertex_buffer,
|
|
5266 uNumVertices,
|
|
5267 28));
|
|
5268
|
|
5269 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
5270 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/);
|
|
5271
|
|
5272 for (uint i = 0; i < uNumVertices; ++i)
|
|
5273 d3d_vertex_buffer[i].diffuse = sCorrectedColor;
|
|
5274 /*v33 = uNumVertices;
|
|
5275 if ( (signed int)uNumVertices > 0 )
|
|
5276 {
|
|
5277 v34 = (char *)&d3d_vertex_buffer[0].diffuse;
|
|
5278 do
|
|
5279 {
|
|
5280 *(int *)v34 = uCorrectedColor;
|
|
5281 v34 += 32;
|
|
5282 --v33;
|
|
5283 }
|
|
5284 while ( v33 );
|
|
5285 }*/
|
|
5286 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex));
|
|
5287 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
5288 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
5289 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
5290 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO));
|
|
5291 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR));
|
|
5292 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
5293 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
5294 d3d_vertex_buffer,
|
|
5295 uNumVertices,
|
|
5296 28));
|
|
5297 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
5298 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
5299 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
5300 }
|
|
5301 }
|
|
5302 }
|
|
5303 // 4D864C: using guessed type char byte_4D864C;
|
|
5304
|
|
5305 //----- (004A43B1) --------------------------------------------------------
|
|
5306 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level)
|
|
5307 {
|
|
5308 unsigned int v7; // eax@2
|
|
5309 signed int v11; // eax@9
|
|
5310 signed int v12; // eax@9
|
|
5311 double v15; // st5@12
|
|
5312 double v16; // st4@12
|
|
5313 double v17; // st3@12
|
|
5314 double v18; // st2@12
|
|
5315 int v19; // ecx@14
|
|
5316 double v20; // st3@14
|
|
5317 int v21; // ecx@16
|
|
5318 double v22; // st3@16
|
|
5319 float v27; // [sp+24h] [bp-Ch]@5
|
|
5320 int v28; // [sp+28h] [bp-8h]@2
|
|
5321 float v29; // [sp+2Ch] [bp-4h]@5
|
|
5322 float v31; // [sp+3Ch] [bp+Ch]@5
|
|
5323 float a1; // [sp+40h] [bp+10h]@5
|
|
5324
|
|
5325 if ( this->uNumD3DSceneBegins )
|
|
5326 {
|
|
5327 //v4 = pSoftBillboard;
|
|
5328 //v5 = (double)pSoftBillboard->zbuffer_depth;
|
|
5329 //pSoftBillboarda = pSoftBillboard->zbuffer_depth;
|
|
5330 //v6 = pSoftBillboard->zbuffer_depth;
|
|
5331 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth);
|
|
5332 //v8 = dimming_level;
|
|
5333 //v9 = v7;
|
|
5334 v28 = dimming_level & 0xFF000000;
|
|
5335 if ( dimming_level & 0xFF000000 )
|
|
5336 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Opaque_3;
|
|
5337 else
|
|
5338 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Transparent;
|
|
5339 //v10 = a3;
|
|
5340 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44;
|
|
5341 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue;
|
|
5342 pBillboardRenderListD3D[v7].sParentBillboardID = pSoftBillboard->sParentBillboardID;
|
|
5343 //v25 = pSoftBillboard->uScreenSpaceX;
|
|
5344 //v24 = pSoftBillboard->uScreenSpaceY;
|
|
5345 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat);
|
|
5346 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat);
|
|
5347 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX);
|
|
5348 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY);
|
|
5349 if ( pSoftBillboard->uFlags & 4 )
|
|
5350 v31 = v31 * -1.0;
|
|
5351 if ( pSoftBillboard->sTintColor && this->bTinting )
|
|
5352 {
|
|
5353 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0);
|
|
5354 v12 = BlendColors(pSoftBillboard->sTintColor, v11);
|
|
5355 if ( v28 )
|
|
5356 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1);
|
|
5357 }
|
|
5358 else
|
|
5359 {
|
|
5360 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0);
|
|
5361 }
|
|
5362 //v13 = (double)v25;
|
|
5363 pBillboardRenderListD3D[v7].pQuads[0].specular = 0;
|
|
5364 pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12;
|
|
5365 pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1;
|
|
5366 //v14 = (double)v24;
|
|
5367 //v32 = v14;
|
|
5368 pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29;
|
|
5369 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894);
|
|
5370 pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15;
|
|
5371 v16 = 1.0 / pSoftBillboard->zbuffer_depth;
|
|
5372 pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth;
|
|
5373 pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0;
|
|
5374 pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0;
|
|
5375 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX);
|
|
5376 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight);
|
|
5377 if ( pSoftBillboard->uFlags & 4 )
|
|
5378 v17 = v17 * -1.0;
|
|
5379 pBillboardRenderListD3D[v7].pQuads[1].specular = 0;
|
|
5380 pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12;
|
|
5381 pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1;
|
|
5382 pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29;
|
|
5383 pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15;
|
|
5384 pBillboardRenderListD3D[v7].pQuads[1].rhw = v16;
|
|
5385 pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0;
|
|
5386 pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0;
|
|
5387 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight;
|
|
5388 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth);
|
|
5389 if ( pSoftBillboard->uFlags & 4 )
|
|
5390 v20 = v20 * -1.0;
|
|
5391 pBillboardRenderListD3D[v7].pQuads[2].specular = 0;
|
|
5392 pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12;
|
|
5393 pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX;
|
|
5394 pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29;
|
|
5395 pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15;
|
|
5396 pBillboardRenderListD3D[v7].pQuads[2].rhw = v16;
|
|
5397 pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0;
|
|
5398 pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0;
|
|
5399 v21 = pSprite->uBufferHeight - pSprite->uAreaY;
|
|
5400 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth);
|
|
5401 if ( pSoftBillboard->uFlags & 4 )
|
|
5402 v22 = v22 * -1.0;
|
|
5403 pBillboardRenderListD3D[v7].pQuads[3].specular = 0;
|
|
5404 pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12;
|
|
5405 pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX;
|
|
5406 pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29;
|
|
5407 pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15;
|
|
5408 pBillboardRenderListD3D[v7].pQuads[3].rhw = v16;
|
|
5409 pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0;
|
|
5410 pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0;
|
|
5411 //v23 = pSprite->pTexture;
|
|
5412 pBillboardRenderListD3D[v7].uNumVertices = 4;
|
|
5413 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth;
|
|
5414 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture;
|
|
5415 }
|
|
5416 }
|
|
5417
|
|
5418 //----- (004A354F) --------------------------------------------------------
|
|
5419 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle)
|
|
5420 {
|
|
5421 unsigned int v8; // esi@3
|
|
5422 float v11; // ST28_4@3
|
|
5423 float v16; // ST2C_4@3
|
|
5424 float v17; // ST30_4@3
|
|
5425 signed int v18; // ST18_4@3
|
|
5426 signed int v19; // ST14_4@3
|
|
5427 signed int v20; // ST10_4@3
|
|
5428 signed int v21; // eax@3
|
|
5429 double v22; // st6@3
|
|
5430 float v23; // ST2C_4@3
|
|
5431 float v24; // ST30_4@3
|
|
5432 signed int v25; // ST10_4@3
|
|
5433 signed int v26; // ST14_4@3
|
|
5434 signed int v27; // ST18_4@3
|
|
5435 signed int v28; // eax@3
|
|
5436 double v29; // st6@3
|
|
5437 float v30; // ecx@3
|
|
5438 float v31; // ST2C_4@3
|
|
5439 float v32; // ST30_4@3
|
|
5440 signed int v33; // ST10_4@3
|
|
5441 signed int v34; // ST14_4@3
|
|
5442 signed int v35; // ST18_4@3
|
|
5443 signed int v36; // eax@3
|
|
5444 float v37; // ecx@3
|
|
5445 double v38; // st6@3
|
|
5446 float v39; // ST2C_4@3
|
|
5447 float v40; // ST30_4@3
|
|
5448 signed int v41; // ST10_4@3
|
|
5449 signed int v42; // ST14_4@3
|
|
5450 signed int v43; // ST18_4@3
|
|
5451 signed int v44; // eax@3
|
|
5452 double v45; // st6@3
|
|
5453 float v46; // eax@3
|
|
5454
|
|
5455 if ( this->uNumD3DSceneBegins )
|
|
5456 {
|
|
5457 if (a2->zbuffer_depth)
|
|
5458 {
|
|
5459 //v5 = (double)a2->zbuffer_depth;
|
|
5460 //v6 = v5;
|
|
5461 //v7 = v5;
|
|
5462 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth);
|
|
5463 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1;
|
|
5464 pBillboardRenderListD3D[v8].field_90 = a2->field_44;
|
|
5465 pBillboardRenderListD3D[v8].sZValue = a2->sZValue;
|
|
5466 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID;
|
|
5467 //v9 = a2->uScreenSpaceX;
|
|
5468 //v10 = a2->uScreenSpaceY;
|
|
5469 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat);
|
|
5470 //v12 = (double) a2->uScreenSpaceX;
|
|
5471 //v13 = v12;
|
|
5472 //v14 = (double)(a2->uScreenSpaceY - 12);
|
|
5473 //v15 = v14;
|
|
5474 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX;
|
|
5475 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12);
|
|
5476 v18 = stru_5C6E00->Cos(angle);
|
|
5477 v19 = stru_5C6E00->Sin(angle);
|
|
5478 v20 = stru_5C6E00->Sin(angle);
|
|
5479 v21 = stru_5C6E00->Cos(angle);
|
|
5480 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022
|
|
5481 + (double)(v18 >> 16))
|
|
5482 * v16
|
|
5483 - ((double)(unsigned __int16)v19 * 0.000015259022
|
|
5484 + (double)(v19 >> 16))
|
|
5485 * v17)
|
|
5486 * v11 + (double) a2->uScreenSpaceX;
|
|
5487 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17
|
|
5488 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16
|
|
5489 - 12.0)
|
|
5490 * v11
|
|
5491 + (double)a2->uScreenSpaceY;
|
|
5492 pBillboardRenderListD3D[v8].pQuads[0].specular = 0;
|
|
5493 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse;
|
|
5494 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22;
|
|
5495 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894);
|
|
5496 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth;
|
|
5497 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0;
|
|
5498 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0;
|
|
5499 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX;
|
|
5500 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12);
|
|
5501 v25 = stru_5C6E00->Cos(angle);
|
|
5502 v26 = stru_5C6E00->Sin(angle);
|
|
5503 v27 = stru_5C6E00->Sin(angle);
|
|
5504 v28 = stru_5C6E00->Cos(angle);
|
|
5505 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022
|
|
5506 + (double)(v25 >> 16))
|
|
5507 * v31
|
|
5508 - ((double)(unsigned __int16)v26 * 0.000015259022
|
|
5509 + (double)(v26 >> 16))
|
|
5510 * v32)
|
|
5511 * v11 + (double) a2->uScreenSpaceX;
|
|
5512 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32
|
|
5513 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31
|
|
5514 - 12.0)
|
|
5515 * v11
|
|
5516 + (double)a2->uScreenSpaceY;
|
|
5517 pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z;
|
|
5518 v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw;
|
|
5519 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29;
|
|
5520 pBillboardRenderListD3D[v8].pQuads[1].specular = 0;
|
|
5521 pBillboardRenderListD3D[v8].pQuads[1].rhw = v30;
|
|
5522 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse;
|
|
5523 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0;
|
|
5524 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0;
|
|
5525 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX;
|
|
5526 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12);
|
|
5527 v33 = stru_5C6E00->Cos(angle);
|
|
5528 v34 = stru_5C6E00->Sin(angle);
|
|
5529 v35 = stru_5C6E00->Sin(angle);
|
|
5530 v36 = stru_5C6E00->Cos(angle);
|
|
5531 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022
|
|
5532 + (double)(v33 >> 16))
|
|
5533 * v23
|
|
5534 - ((double)(unsigned __int16)v34 * 0.000015259022
|
|
5535 + (double)(v34 >> 16))
|
|
5536 * v24)
|
|
5537 * v11 + (double) a2->uScreenSpaceX;
|
|
5538 v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z;
|
|
5539 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24
|
|
5540 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23
|
|
5541 - 12.0)
|
|
5542 * v11
|
|
5543 + (double)a2->uScreenSpaceY;
|
|
5544 pBillboardRenderListD3D[v8].pQuads[2].specular = 0;
|
|
5545 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37;
|
|
5546 pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw;
|
|
5547 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse;
|
|
5548 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38;
|
|
5549 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0;
|
|
5550 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0;
|
|
5551 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX;
|
|
5552 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12);
|
|
5553 v41 = stru_5C6E00->Cos(angle);
|
|
5554 v42 = stru_5C6E00->Sin(angle);
|
|
5555 v43 = stru_5C6E00->Sin(angle);
|
|
5556 v44 = stru_5C6E00->Cos(angle);
|
|
5557 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022
|
|
5558 + (double)(v41 >> 16))
|
|
5559 * v39
|
|
5560 - ((double)(unsigned __int16)v42 * 0.000015259022
|
|
5561 + (double)(v42 >> 16))
|
|
5562 * v40)
|
|
5563 * v11 + (double) a2->uScreenSpaceX;
|
|
5564 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40
|
|
5565 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39
|
|
5566 - 12.0)
|
|
5567 * v11
|
|
5568 + (double)a2->uScreenSpaceY;
|
|
5569 v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z;
|
|
5570 pBillboardRenderListD3D[v8].pQuads[3].specular = 0;
|
|
5571 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46;
|
|
5572 pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw;
|
|
5573 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse;
|
|
5574 pBillboardRenderListD3D[v8].pTexture = a3;
|
|
5575 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth;
|
|
5576 pBillboardRenderListD3D[v8].uNumVertices = 4;
|
|
5577 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45;
|
|
5578 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0;
|
|
5579 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0;
|
|
5580 }
|
|
5581 }
|
|
5582 }
|
|
5583
|
|
5584 //----- (004A3AD9) --------------------------------------------------------
|
|
5585 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle)
|
|
5586 {
|
|
5587 double v5; // st7@2
|
|
5588 float v6; // ST28_4@2
|
|
5589 float v7; // ST00_4@2
|
|
5590 unsigned int v8; // esi@2
|
|
5591 //int v9; // eax@2
|
|
5592 //int v10; // ebx@2
|
|
5593 float v11; // ST34_4@2
|
|
5594 double v12; // st7@2
|
|
5595 float v13; // ST2C_4@2
|
|
5596 double v14; // st6@2
|
|
5597 float v15; // ST24_4@2
|
|
5598 float v16; // ST38_4@2
|
|
5599 float v17; // ST3C_4@2
|
|
5600 signed int v18; // ST1C_4@2
|
|
5601 int v19; // ST30_4@2
|
|
5602 signed int v20; // ST20_4@2
|
|
5603 signed int v21; // ST18_4@2
|
|
5604 signed int v22; // eax@2
|
|
5605 double v23; // st6@2
|
|
5606 float v24; // ST20_4@2
|
|
5607 float v25; // ST1C_4@2
|
|
5608 float v26; // ST38_4@2
|
|
5609 float v27; // ST3C_4@2
|
|
5610 signed int v28; // ST18_4@2
|
|
5611 signed int v29; // ST14_4@2
|
|
5612 signed int v30; // ST10_4@2
|
|
5613 signed int v31; // eax@2
|
|
5614 double v32; // st6@2
|
|
5615 float v33; // ST38_4@2
|
|
5616 float v34; // ST3C_4@2
|
|
5617 signed int v35; // ST10_4@2
|
|
5618 signed int v36; // ST14_4@2
|
|
5619 signed int v37; // ST18_4@2
|
|
5620 signed int v38; // eax@2
|
|
5621 double v39; // st6@2
|
|
5622 float v40; // ST38_4@2
|
|
5623 float v41; // ST3C_4@2
|
|
5624 signed int v42; // ST10_4@2
|
|
5625 signed int v43; // ST14_4@2
|
|
5626 signed int v44; // ST18_4@2
|
|
5627 signed int v45; // eax@2
|
|
5628 double v46; // st6@2
|
|
5629
|
|
5630 if ( this->uNumD3DSceneBegins )
|
|
5631 {
|
|
5632 v5 = (double)a2->zbuffer_depth;
|
|
5633 v6 = v5;
|
|
5634 v7 = v5;
|
|
5635 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7));
|
|
5636 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1;
|
|
5637 pBillboardRenderListD3D[v8].field_90 = a2->field_44;
|
|
5638 pBillboardRenderListD3D[v8].sZValue = a2->sZValue;
|
|
5639 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID;
|
|
5640
|
|
5641 //v9 = a2->uScreenSpaceX;
|
|
5642 //v10 = a2->uScreenSpaceY;
|
|
5643 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat);
|
|
5644 v12 = (double)a2->uScreenSpaceX;
|
|
5645 v13 = (double)a2->uScreenSpaceX;
|
|
5646 v14 = (double)(a2->uScreenSpaceY - 12);
|
|
5647 v15 = v14;
|
|
5648 v16 = (double)(a2->uScreenSpaceX - 12) - v12;
|
|
5649 v17 = (double)(a2->uScreenSpaceY - 25) - v14;
|
|
5650 v18 = stru_5C6E00->Cos(angle);
|
|
5651 v19 = angle - stru_5C6E00->uIntegerHalfPi;
|
|
5652 v20 = stru_5C6E00->Sin(angle);
|
|
5653 v21 = stru_5C6E00->Sin(angle);
|
|
5654 v22 = stru_5C6E00->Cos(angle);
|
|
5655 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022
|
|
5656 + (double)(v18 >> 16)) * v16
|
|
5657 - ((double)(unsigned __int16)v20 * 0.000015259022
|
|
5658 + (double)(v20 >> 16)) * v17)
|
|
5659 * v11 + v13;
|
|
5660 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17
|
|
5661 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16
|
|
5662 - 12.0)
|
|
5663 * v11
|
|
5664 + (double)a2->uScreenSpaceY;
|
|
5665 pBillboardRenderListD3D[v8].pQuads[0].specular = 0;
|
|
5666 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse;
|
|
5667 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23;
|
|
5668 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pODMRenderParams->shading_dist_mist);
|
|
5669 pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24;
|
|
5670 v25 = 1.0 / v6;
|
|
5671 pBillboardRenderListD3D[v8].pQuads[0].rhw = v25;
|
|
5672 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0;
|
|
5673 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0;
|
|
5674
|
|
5675 v26 = (double)(a2->uScreenSpaceX - 12) - v13;
|
|
5676 v27 = (double)a2->uScreenSpaceY - v15;
|
|
5677 v28 = stru_5C6E00->Cos(angle);
|
|
5678 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi);
|
|
5679 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi);
|
|
5680 v31 = stru_5C6E00->Cos(angle);
|
|
5681 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022
|
|
5682 + (double)(v28 >> 16)) * v26
|
|
5683 - ((double)(unsigned __int16)v29 * 0.000015259022
|
|
5684 + (double)(v29 >> 16)) * v27)
|
|
5685 * v11 + v13;
|
|
5686 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27
|
|
5687 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26
|
|
5688 - 12.0)
|
|
5689 * v11
|
|
5690 + (double)a2->uScreenSpaceY;
|
|
5691 pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24;
|
|
5692 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32;
|
|
5693 pBillboardRenderListD3D[v8].pQuads[1].specular = 0;
|
|
5694 pBillboardRenderListD3D[v8].pQuads[1].rhw = v25;
|
|
5695 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse;
|
|
5696 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0;
|
|
5697 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0;
|
|
5698
|
|
5699 v33 = (double)(a2->uScreenSpaceX + 12) - v13;
|
|
5700 v34 = (double)a2->uScreenSpaceY - v15;
|
|
5701 v35 = stru_5C6E00->Cos(angle);
|
|
5702 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi);
|
|
5703 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi);
|
|
5704 v38 = stru_5C6E00->Cos(angle);
|
|
5705 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022
|
|
5706 + (double)(v35 >> 16)) * v33
|
|
5707 - ((double)(unsigned __int16)v36 * 0.000015259022
|
|
5708 + (double)(v36 >> 16)) * v34)
|
|
5709 * v11 + v13;
|
|
5710 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34
|
|
5711 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33
|
|
5712 - 12.0)
|
|
5713 * v11
|
|
5714 + (double)a2->uScreenSpaceY;
|
|
5715 pBillboardRenderListD3D[v8].pQuads[2].specular = 0;
|
|
5716 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24;
|
|
5717 pBillboardRenderListD3D[v8].pQuads[2].rhw = v25;
|
|
5718 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse;
|
|
5719 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39;
|
|
5720 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0;
|
|
5721 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0;
|
|
5722
|
|
5723 v40 = (double)(a2->uScreenSpaceX + 12) - v13;
|
|
5724 v41 = (double)(a2->uScreenSpaceY - 25) - v15;
|
|
5725 v42 = stru_5C6E00->Cos(angle);
|
|
5726 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi);
|
|
5727 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi);
|
|
5728 v45 = stru_5C6E00->Cos(angle);
|
|
5729 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022
|
|
5730 + (double)(v42 >> 16)) * v40
|
|
5731 - ((double)(unsigned __int16)v43 * 0.000015259022
|
|
5732 + (double)(v43 >> 16)) * v41)
|
|
5733 * v11 + v13;
|
|
5734 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41
|
|
5735 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40
|
|
5736 - 12.0)
|
|
5737 * v11
|
|
5738 + (double)a2->uScreenSpaceY;
|
|
5739 pBillboardRenderListD3D[v8].pQuads[3].specular = 0;
|
|
5740 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24;
|
|
5741 pBillboardRenderListD3D[v8].pQuads[3].rhw = v25;
|
|
5742 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse;
|
|
5743 pBillboardRenderListD3D[v8].pTexture = a3;
|
|
5744 pBillboardRenderListD3D[v8].z_order = v6;
|
|
5745 pBillboardRenderListD3D[v8].uNumVertices = 4;
|
|
5746 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46;
|
|
5747 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0;
|
|
5748 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0;
|
|
5749 }
|
|
5750 }
|
|
5751
|
|
5752 //----- (004A4023) --------------------------------------------------------
|
|
5753 void Render::TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int dimming_level, RenderBillboard *pBillboard)
|
|
5754 {
|
|
5755 unsigned int v8; // esi@2
|
|
5756 double v14; // st6@14
|
|
5757 double v15; // st5@14
|
|
5758 float v29; // [sp+28h] [bp-8h]@5
|
|
5759 float v30; // [sp+2Ch] [bp-4h]@5
|
|
5760
|
|
5761 if (!uNumD3DSceneBegins)
|
|
5762 return;
|
|
5763
|
|
5764 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth);
|
|
5765
|
|
5766 v30 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_x_scaler_packedfloat);
|
|
5767 v29 = (a2->_screenspace_y_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_y_scaler_packedfloat);
|
|
5768
|
|
5769 unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard);
|
|
5770 if (a2->sTintColor & 0x00FFFFFF && bTinting)
|
|
5771 {
|
|
5772 diffuse = BlendColors(a2->sTintColor, diffuse);
|
|
5773 if (a2->sTintColor & 0xFF000000)
|
|
5774 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1);
|
|
5775 }
|
|
5776
|
|
5777 unsigned int specular = 0;
|
|
5778 if (bUsingSpecular)
|
|
5779 specular = sub_47C3D7_get_fog_specular(0, 0, a2->zbuffer_depth);
|
|
5780
|
|
5781 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX);
|
|
5782 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY);
|
|
5783 if (a2->uFlags & 4)
|
|
5784 v14 *= -1.0;
|
|
5785 pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse;
|
|
5786 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30;
|
|
5787 pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29;
|
|
5788 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist);
|
|
5789 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth;
|
|
5790 pBillboardRenderListD3D[v8].pQuads[0].specular = specular;
|
|
5791 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0;
|
|
5792 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0;
|
|
5793
|
|
5794 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX);
|
|
5795 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY);
|
|
5796 if ( a2->uFlags & 4 )
|
|
5797 v14 = v14 * -1.0;
|
|
5798 pBillboardRenderListD3D[v8].pQuads[1].specular = specular;
|
|
5799 pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse;
|
|
5800 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30;
|
|
5801 pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29;
|
|
5802 pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist);
|
|
5803 pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth;
|
|
5804 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0;
|
|
5805 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0;
|
|
5806
|
|
5807 v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth);
|
|
5808 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY);
|
|
5809 if ( a2->uFlags & 4 )
|
|
5810 v14 *= -1.0;
|
|
5811 pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse;
|
|
5812 pBillboardRenderListD3D[v8].pQuads[2].specular = specular;
|
|
5813 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30;
|
|
5814 pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29;
|
|
5815 pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist);
|
|
5816 pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth;
|
|
5817 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0;
|
|
5818 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0;
|
|
5819
|
|
5820 v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth);
|
|
5821 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY);
|
|
5822 if ( a2->uFlags & 4 )
|
|
5823 v14 *= -1.0;
|
|
5824 pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse;
|
|
5825 pBillboardRenderListD3D[v8].pQuads[3].specular = specular;
|
|
5826 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30;
|
|
5827 pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29;
|
|
5828 pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist);
|
|
5829 pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth;
|
|
5830 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0;
|
|
5831 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0;
|
|
5832
|
|
5833 pBillboardRenderListD3D[v8].uNumVertices = 4;
|
|
5834 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture;
|
|
5835 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth;
|
|
5836 pBillboardRenderListD3D[v8].field_90 = a2->field_44;
|
|
5837 pBillboardRenderListD3D[v8].sZValue = a2->sZValue;
|
|
5838 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID;
|
|
5839
|
|
5840 if (a2->sTintColor & 0xFF000000)
|
|
5841 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_3;
|
|
5842 else
|
|
5843 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Transparent;
|
|
5844 }
|
|
5845
|
|
5846
|
|
5847 //----- (004A49D0) --------------------------------------------------------
|
|
5848 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9)
|
|
5849 {
|
|
5850 int absXDifference; // eax@1
|
|
5851 int absYDifference; // eax@1
|
|
5852 unsigned int smallerabsdiff; // ebx@1
|
|
5853 unsigned int largerabsdiff;
|
|
5854 double v16; // st7@7
|
|
5855 double v17; // st7@7
|
|
5856 double v18; // st6@7
|
|
5857 double v20; // st4@8
|
|
5858 double v21; // st4@10
|
|
5859 double v22; // st4@10
|
|
5860 double v23; // st4@10
|
|
5861 double v25; // st4@11
|
|
5862 double v26; // st4@13
|
|
5863 double v28; // st4@13
|
|
5864 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7
|
|
5865 int xDifference; // [sp+88h] [bp-Ch]@1
|
|
5866 signed int v32; // [sp+8Ch] [bp-8h]@1
|
|
5867 int yDifference; // [sp+90h] [bp-4h]@1
|
|
5868
|
|
5869 xDifference = bankersRounding(dstX - srcX);
|
|
5870 yDifference = bankersRounding(dstY - srcY);
|
|
5871 absYDifference = abs(yDifference);
|
|
5872 absXDifference = abs(xDifference);
|
|
5873 smallerabsdiff = min(absXDifference, absYDifference);
|
|
5874 largerabsdiff = max(absXDifference, absYDifference);
|
|
5875 v32 = (11 * smallerabsdiff >> 5) + largerabsdiff;
|
|
5876 v16 = 1.0 / (double)v32;
|
|
5877 v17 = (double)yDifference * v16 * a4;
|
|
5878 v18 = (double)xDifference * v16 * a4;
|
|
5879 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
|
|
5880 {
|
|
5881 v20 = a3 * 1000.0 / (double)pODMRenderParams->shading_dist_mist;
|
|
5882 v25 = a7 * 1000.0 / (double)pODMRenderParams->shading_dist_mist;
|
|
5883 }
|
|
5884 else
|
|
5885 {
|
|
5886 v20 = a3 * 0.061758894;
|
|
5887 v25 = a7 * 0.061758894;
|
|
5888 }
|
|
5889 v21 = 1.0 / a3;
|
|
5890 v22 = (double)yDifference * v16 * a8;
|
|
5891 v23 = (double)xDifference * v16 * a8;
|
|
5892 v26 = 1.0 - 1.0 / v25;
|
|
5893 v28 = 1.0 / a7;
|
|
5894 v29[0].pos.x = srcX + v17;
|
|
5895 v29[0].pos.y = srcY - v18;
|
|
5896 v29[0].pos.z = 1.0 - 1.0 / v20;
|
|
5897 v29[0].rhw = v21;
|
|
5898 v29[0].diffuse = -1;
|
|
5899 v29[0].specular = 0;
|
|
5900 v29[0].texcoord.x = 1.0;
|
|
5901 v29[0].texcoord.y = 0.0;
|
|
5902
|
|
5903 v29[1].pos.x = v22 + dstX;
|
|
5904 v29[1].pos.y = dstY - v23;
|
|
5905 v29[1].pos.z = v26;
|
|
5906 v29[1].rhw = v28;
|
|
5907 v29[1].diffuse = -16711936;
|
|
5908 v29[1].specular = 0;
|
|
5909 v29[1].texcoord.x = 1.0;
|
|
5910 v29[1].texcoord.y = 1.0;
|
|
5911
|
|
5912 v29[2].pos.x = dstX - v22;
|
|
5913 v29[2].pos.y = v23 + dstY;
|
|
5914 v29[2].pos.z = v26;
|
|
5915 v29[2].rhw = v28;
|
|
5916 v29[2].diffuse = -1;
|
|
5917 v29[2].specular = 0;
|
|
5918 v29[2].texcoord.x = 0.0;
|
|
5919 v29[2].texcoord.y = 1.0;
|
|
5920
|
|
5921 v29[3].pos.x = srcX - v17;
|
|
5922 v29[3].pos.y = v18 + srcY;
|
|
5923 v29[3].pos.z = v29[0].pos.z;
|
|
5924 v29[3].rhw = v21;
|
|
5925 v29[3].diffuse = -1;
|
|
5926 v29[3].specular = 0;
|
|
5927 v29[3].texcoord.x = 0.0;
|
|
5928 v29[3].texcoord.y = 0.0;
|
|
5929 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
5930 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
5931 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
|
|
5932 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
5933 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
5934 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
5935 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a9));
|
|
5936 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
5937 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v29, 4, 24));
|
|
5938 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
5939 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
5940 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
5941 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
5942 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
5943 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
|
|
5944 }
|
|
5945
|
|
5946 //----- (004A4CC9) --------------------------------------------------------
|
|
5947 void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse)
|
|
5948 {
|
|
5949 unsigned int v5; // eax@7
|
|
5950 double v10; // st6@9
|
|
5951 double v11; // st6@10
|
|
5952 int v12; // ebx@13
|
|
5953
|
|
5954 if (a1->uNumVertices < 3)
|
|
5955 return;
|
|
5956
|
|
5957 float depth = 1000000.0;
|
|
5958 for (uint i = 0; i < (unsigned int)a1->uNumVertices; ++i)
|
|
5959 {
|
|
5960 if (a1->field_104[i].z < depth)
|
|
5961 depth = a1->field_104[i * 4].z;
|
|
5962 }
|
|
5963
|
|
5964 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth);
|
|
5965 pBillboardRenderListD3D[v5].field_90 = 0;
|
|
5966 pBillboardRenderListD3D[v5].sParentBillboardID = -1;
|
|
5967 pBillboardRenderListD3D[v5].opacity = RenderBillboardD3D::Opaque_2;
|
|
5968 pBillboardRenderListD3D[v5].pTexture = 0;
|
|
5969 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices;
|
|
5970 pBillboardRenderListD3D[v5].z_order = depth;
|
|
5971
|
|
5972 for (uint i = 0; i < (unsigned int)a1->uNumVertices; ++i)
|
|
5973 {
|
|
5974 pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x;
|
|
5975 pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y;
|
|
5976
|
|
5977 v10 = a1->field_104[i].z;
|
|
5978 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
5979 v11 = v10 * 0.061758894;
|
|
5980 else
|
|
5981 v11 = v10 * 1000.0 / (double)pODMRenderParams->shading_dist_mist;
|
|
5982 pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11;
|
|
5983 pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z;
|
|
5984
|
|
5985 if (diffuse & 0xFF000000)
|
|
5986 v12 = a1->field_104[i].diffuse;
|
|
5987 else
|
|
5988 v12 = diffuse;
|
|
5989 pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12;
|
|
5990 pBillboardRenderListD3D[v5].pQuads[i].specular = 0;
|
|
5991
|
|
5992 pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0;
|
|
5993 pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0;
|
|
5994 }
|
|
5995 }
|
|
5996
|
|
5997 //----- (004A4DE1) --------------------------------------------------------
|
|
5998 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture)
|
|
5999 {
|
|
6000 unsigned __int16 *v13; // ecx@19
|
|
6001 unsigned __int16 *v14; // eax@19
|
|
6002 DWORD v15; // edx@20
|
|
6003 stru350 Dst; // [sp+Ch] [bp-F8h]@12
|
|
6004
|
|
6005 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps);
|
|
6006 if ( pHWLTexture )
|
|
6007 {
|
|
6008 bMipMaps = !strncmp(pName, "HDWTR", 5);
|
|
6009 if ( !pRenderD3D->CreateTexture(pHWLTexture->uWidth, pHWLTexture->uHeight, pOutSurface, pOutTexture, true,
|
|
6010 bMipMaps, uMinDeviceTextureDim) )
|
|
6011 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0);
|
|
6012 if (bMipMaps)
|
|
6013 {
|
|
6014 Dst._450DDE();
|
|
6015 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC);
|
|
6016
|
|
6017 IDirectDrawSurface4 *pNextSurf = *pOutSurface;
|
|
6018 while ( 1 )
|
|
6019 {
|
|
6020 DDSCAPS2 v19;
|
|
6021 memset(&v19, 0, sizeof(DDSCAPS2));
|
|
6022 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP;
|
|
6023
|
|
6024 DDSURFACEDESC2 desc;
|
|
6025 memset(&desc, 0, sizeof(DDSURFACEDESC2));
|
|
6026 desc.dwSize = sizeof(DDSURFACEDESC2);
|
|
6027
|
|
6028 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) )
|
|
6029 {
|
|
6030 // linear scaling
|
|
6031 for (int s = 0; s < desc.dwHeight; ++s)
|
|
6032 for (int t = 0; t < desc.dwWidth; ++t)
|
|
6033 {
|
|
6034 unsigned int resampled_x = t * pHWLTexture->uWidth / desc.dwWidth,
|
|
6035 resampled_y = s * pHWLTexture->uHeight / desc.dwHeight;
|
|
6036 unsigned short sample = pHWLTexture->pPixels[resampled_y * pHWLTexture->uWidth + resampled_x];
|
|
6037
|
|
6038 ((unsigned short *)desc.lpSurface)[s * (desc.lPitch >> 1) + t] = sample;
|
|
6039 }
|
|
6040
|
|
6041
|
|
6042 //bicubic sampling
|
|
6043 //Dst.sub_451007_scale_image_bicubic(pHWLTexture->pPixels, pHWLTexture->uWidth, pHWLTexture->uHeight, pHWLTexture->uWidth,
|
|
6044 // (unsigned short *)desc.lpSurface, desc.dwWidth, desc.dwHeight, desc.lPitch >> 1, 0, 0);
|
|
6045
|
|
6046 ErrD3D(pNextSurf->Unlock(NULL));
|
|
6047 //bMipMaps = 0x4D86ACu;
|
|
6048 }
|
|
6049 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf)))
|
|
6050 break;
|
|
6051 }
|
|
6052 //v20 = -1;
|
|
6053 //nullsub_1();
|
|
6054 }
|
|
6055 else
|
|
6056 {
|
|
6057 DDSCAPS2 v19;
|
|
6058 memset(&v19, 0, sizeof(DDSCAPS2));
|
|
6059 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP;
|
|
6060
|
|
6061 DDSURFACEDESC2 desc;
|
|
6062 memset(&desc, 0, sizeof(DDSURFACEDESC2));
|
|
6063 desc.dwSize = sizeof(DDSURFACEDESC2);
|
|
6064
|
|
6065 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) )
|
|
6066 {
|
|
6067 bMipMaps = 0;
|
|
6068 v13 = pHWLTexture->pPixels;
|
|
6069 v14 = (unsigned __int16 *)desc.lpSurface;
|
|
6070 for(uint bMipMaps = 0; bMipMaps < desc.dwHeight; bMipMaps++)
|
|
6071 {
|
|
6072 for (v15 = 0; v15 < desc.dwWidth; v15++)
|
|
6073 {
|
|
6074 *v14 = *v13;
|
|
6075 ++v14;
|
|
6076 ++v13;
|
|
6077 }
|
|
6078 v14 += (desc.lPitch >> 1) - desc.dwWidth;
|
|
6079 }
|
|
6080 ErrD3D((*pOutSurface)->Unlock(NULL));
|
|
6081 }
|
|
6082 }
|
|
6083 delete [] pHWLTexture->pPixels;
|
|
6084 delete pHWLTexture;
|
|
6085 return true;
|
|
6086 }
|
|
6087 return false;
|
|
6088 }
|
|
6089
|
|
6090 //----- (004A5048) --------------------------------------------------------
|
|
6091 bool Render::MoveSpriteToDevice( Sprite *pSprite )
|
|
6092 {
|
|
6093 HWLTexture *sprite_texture; // eax@1
|
|
6094 unsigned __int16 *v9; // edx@5
|
|
6095 LPVOID v10; // eax@5
|
|
6096 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4
|
|
6097
|
|
6098 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID);
|
|
6099 if ( sprite_texture )
|
|
6100 {
|
|
6101 pSprite->uAreaX = sprite_texture->uAreaX;
|
|
6102 pSprite->uAreaY = sprite_texture->uAreaY;
|
|
6103 pSprite->uBufferWidth = sprite_texture->uBufferWidth;
|
|
6104 pSprite->uBufferHeight = sprite_texture->uBufferHeight;
|
|
6105 pSprite->uAreaWidth = sprite_texture->uAreaWidth;
|
|
6106 pSprite->uAreaHeight = sprite_texture->uAreaHeigth;
|
|
6107 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim))
|
|
6108 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0);
|
|
6109 memset(&Dst, 0, sizeof(DDSURFACEDESC2));
|
|
6110 Dst.dwSize = 124;
|
|
6111 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) )
|
|
6112 {
|
|
6113 v9 = sprite_texture->pPixels;
|
|
6114 v10 = Dst.lpSurface;
|
|
6115 for (uint i=0; i<sprite_texture->uHeight; ++i)
|
|
6116 {
|
|
6117 for (uint j=0; j<sprite_texture->uWidth/2; ++j)
|
|
6118 {
|
|
6119 *(int *)v10 = *(int *)v9;
|
|
6120 v9 += 2;
|
|
6121 v10 = (char *)v10 + 4;
|
|
6122 }
|
|
6123 v10 = (char *)v10 + Dst.lPitch-sprite_texture->uWidth*2;
|
|
6124 }
|
|
6125 ErrD3D(pSprite->pTextureSurface->Unlock(NULL));
|
|
6126 }
|
|
6127 delete [] sprite_texture->pPixels;
|
|
6128 delete sprite_texture;
|
|
6129 return true;
|
|
6130 }
|
|
6131 return false;
|
|
6132 }
|
|
6133
|
|
6134 //----- (004A51CB) --------------------------------------------------------
|
|
6135 void Render::BeginScene()
|
|
6136 {
|
|
6137 //Render *v1; // esi@1
|
|
6138 unsigned int v2; // eax@1
|
|
6139 /*int v3; // eax@5
|
|
6140 unsigned __int16 **v4; // edi@6
|
|
6141 char *v5; // ebx@7*/
|
|
6142 // DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4
|
|
6143
|
|
6144 //v1 = this;
|
|
6145 v2 = this->uNumSceneBegins;
|
|
6146 this->uNumSceneBegins = v2 + 1;
|
|
6147 if ( !v2 )
|
|
6148 {
|
|
6149 if ( this->pRenderD3D )
|
|
6150 {
|
|
6151 /*if ( this->bColorKeySupported )
|
|
6152 {
|
|
6153 memset(&Dst, 0, 0x7Cu);
|
|
6154 Dst.dwSize = 124;
|
|
6155 if ( LockSurface_DDraw4(this->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) )
|
|
6156 {
|
|
6157 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface;
|
|
6158 this->uTargetSurfacePitch = Dst.lPitch >> 1;
|
|
6159 this->field_18_locked_pitch = Dst.lPitch >> 1;
|
|
6160 }
|
|
6161 --this->uNumSceneBegins;
|
|
6162 }*/
|
|
6163 }
|
|
6164 else
|
|
6165 {
|
|
6166 if ( !this->pTargetSurface )
|
|
6167 {
|
|
6168 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch);
|
|
6169 /*if ( this->pTargetSurface )
|
|
6170 {
|
|
6171 this->field_18_locked_pitch = this->uTargetSurfacePitch;
|
|
6172 }*/
|
|
6173 --this->uNumSceneBegins;
|
|
6174 }
|
|
6175 }
|
|
6176 RestoreFrontBuffer();
|
|
6177 }
|
|
6178 }
|
|
6179
|
|
6180 //----- (004A527D) --------------------------------------------------------
|
|
6181 void Render::EndScene()
|
|
6182 {
|
|
6183 if ( this->uNumSceneBegins )
|
|
6184 {
|
|
6185 this->uNumSceneBegins--;
|
|
6186 if ( !this->uNumSceneBegins )
|
|
6187 {
|
|
6188 if ( this->pRenderD3D )
|
|
6189 {
|
|
6190 /*if ( this->bColorKeySupported )
|
|
6191 {
|
|
6192 this->pTargetSurface = 0;
|
|
6193 this->uTargetSurfacePitch = 0;
|
|
6194 this->field_18_locked_pitch = 0;
|
|
6195 ErrD3D(this->pColorKeySurface4->Unlock(NULL));
|
|
6196 }*/
|
|
6197 }
|
|
6198 else
|
|
6199 {
|
|
6200 this->pTargetSurface = 0;
|
|
6201 this->uTargetSurfacePitch = 0;
|
|
6202 //this->field_18_locked_pitch = 0;
|
|
6203 UnlockBackBuffer();
|
|
6204 }
|
|
6205 }
|
|
6206 }
|
|
6207 }
|
|
6208
|
|
6209 //----- (004A52F1) --------------------------------------------------------
|
|
6210 void Render::ScreenFade(unsigned int color, float t)
|
|
6211 {
|
|
6212 unsigned int v3; // esi@1
|
|
6213 unsigned int v7; // eax@6
|
|
6214 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6
|
|
6215 int v40; // [sp+9Ch] [bp-4h]@6
|
|
6216
|
|
6217 v3 = 0;
|
|
6218
|
|
6219 //{
|
|
6220 if (t > 1.0f)
|
|
6221 t = 1.0f;
|
|
6222 else if (t < 0.0f)
|
|
6223 t = 0.0f;
|
|
6224
|
|
6225 v40 = (char)floorf(t * 255.0f + 0.5f);
|
|
6226
|
|
6227 v7 = color | (v40 << 24);
|
|
6228
|
|
6229 v36[0].specular = 0;
|
|
6230 v36[0].pos.x = pViewport->uViewportTL_X;
|
|
6231 v36[0].pos.y = (double)pViewport->uViewportTL_Y;
|
|
6232 v36[0].pos.z = 0.0;
|
|
6233 v36[0].diffuse = v7;
|
|
6234 v36[0].rhw = 1.0;
|
|
6235 v36[0].texcoord.x = 0.0;
|
|
6236 v36[0].texcoord.y = 0.0;
|
|
6237
|
|
6238 v36[1].specular = 0;
|
|
6239 v36[1].pos.x = pViewport->uViewportTL_X;
|
|
6240 v36[1].pos.y = (double)(pViewport->uViewportBR_Y + 1);
|
|
6241 v36[1].pos.z = 0.0;
|
|
6242 v36[1].diffuse = v7;
|
|
6243 v36[1].rhw = 1.0;
|
|
6244 v36[1].texcoord.x = 0.0;
|
|
6245 v36[1].texcoord.y = 0.0;
|
|
6246
|
|
6247 v36[2].specular = 0;
|
|
6248 v36[2].pos.x = (double)pViewport->uViewportBR_X;
|
|
6249 v36[2].pos.y = (double)(pViewport->uViewportBR_Y + 1);
|
|
6250 v36[2].pos.z = 0.0;
|
|
6251 v36[2].diffuse = v7;
|
|
6252 v36[2].rhw = 1.0;
|
|
6253 v36[2].texcoord.x = 0.0;
|
|
6254 v36[2].texcoord.y = 0.0;
|
|
6255
|
|
6256 v36[3].specular = 0;
|
|
6257 v36[3].pos.x = (double)pViewport->uViewportBR_X;
|
|
6258 v36[3].pos.y = (double)pViewport->uViewportTL_Y;
|
|
6259 v36[3].pos.z = 0.0;
|
|
6260 v36[3].diffuse = v7;
|
|
6261 v36[3].rhw = 1.0;
|
|
6262 v36[3].texcoord.x = 0.0;
|
|
6263 v36[3].texcoord.y = 0.0;
|
|
6264
|
|
6265 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));
|
|
6266 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
6267 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
6268 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
6269 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA));
|
|
6270 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA));
|
|
6271 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
6272 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS));
|
|
6273 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
6274 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v36, 4, 28));
|
|
6275 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
6276 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
6277 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
6278 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
6279 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
6280 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS));
|
|
6281 /*}
|
|
6282 else
|
|
6283 {
|
|
6284 v40 = (1.0 - a3) * 65536.0;
|
|
6285 v39 = v40 + 6.7553994e15;
|
|
6286 LODWORD(a3) = LODWORD(v39);
|
|
6287 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1;
|
|
6288 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1;
|
|
6289 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X;
|
|
6290 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch];
|
|
6291 v37 = 2 * v13;
|
|
6292 LODWORD(v40) = (int)v14;
|
|
6293
|
|
6294 int __i = 0;
|
|
6295 v15 = dword_F1B430.data();
|
|
6296 do
|
|
6297 {
|
|
6298 v16 = v3;
|
|
6299 v3 += LODWORD(a3);
|
|
6300 dword_F1B430[__i++] = v16 >> 16;
|
|
6301 }
|
|
6302 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen );
|
|
6303 while (__i < 32);
|
|
6304
|
|
6305 if ( pRenderer->uTargetGBits == 6 )
|
|
6306 {
|
|
6307 v17 = sr_42690D_colors_cvt(this_);
|
|
6308 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F);
|
|
6309 this_ = (((65536 - LODWORD(a3)) * (unsigned __int16)(v17 & 0xF800) & 0xF800FFFF | v18 & 0x1F0000 | (65536 - LODWORD(a3)) * (v17 & 0x7E0) & 0x7E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (unsigned __int16)(v17 & 0xF800) & 0xF800FFFF | v18 & 0x1F0000 | (65536 - LODWORD(a3)) * (v17 & 0x7E0) & 0x7E00000u) >> 16);
|
|
6310 v19 = v40;
|
|
6311 v20 = off_4EFDB0;
|
|
6312 v21 = HIDWORD(v39);
|
|
6313 do
|
|
6314 {
|
|
6315 v22 = v38;
|
|
6316 v31 = v21;
|
|
6317 do
|
|
6318 {
|
|
6319 v23 = (*(int *)((char *)v20
|
|
6320 + ((((unsigned __int16)(*(short *)((char *)v20 + ((*(unsigned int *)LODWORD(v19) & 0xF800u) >> 9)) << 11) | *(unsigned int *)LODWORD(v19) & 0x7FF) & 0x7C0u) >> 4)) << 6) | (*(int *)((char *)v20 + ((((*(int *)((char *)v20 + ((*(unsigned int *)LODWORD(v19) & 0xF800u) >> 9)) << 11) | (*(int *)((char *)v20 + ((*(unsigned int *)LODWORD(v19) & 0xF8000000u) >> 25)) << 27) | *(unsigned int *)LODWORD(v19) & 0x7FF07FF) & 0x7C00000u) >> 20)) << 22) | ((*(int *)((char *)v20 + ((*(unsigned int *)LODWORD(v19) & 0xF800u) >> 9)) << 11) | (*(int *)((char *)v20 + ((*(unsigned int *)LODWORD(v19) & 0xF8000000u) >> 25)) << 27) | *(unsigned int *)LODWORD(v19) & 0x7FF07FF) & 0xF81FF81F;
|
|
6321 result = this_
|
|
6322 + (*((int *)v20
|
|
6323 + (((unsigned __int8)(*((char *)v20
|
|
6324 + ((((unsigned __int16)(*(short *)((char *)v20
|
|
6325 + ((*(unsigned int *)LODWORD(v19) & 0xF800u) >> 9)) << 11) | *(unsigned int *)LODWORD(v19) & 0x7FF) & 0x7C0u) >> 4)) << 6) | *(unsigned int *)LODWORD(v19) & 0x1F) & 0x1F)) | (*(int *)((char *)v20 + ((v23 & 0x1F0000u) >> 14)) << 16) | ((*(int *)((char *)v20 + ((((unsigned __int16)(*(short *)((char *)v20 + ((*(unsigned int *)LODWORD(v19) & 0xF800u) >> 9)) << 11) | *(unsigned int *)LODWORD(v19) & 0x7FF) & 0x7C0u) >> 4)) << 6) | (*(int *)((char *)v20 + ((((*(int *)((char *)v20 + ((*(unsigned int *)LODWORD(v19) & 0xF800u) >> 9)) << 11) | (*(int *)((char *)v20 + ((*(unsigned int *)LODWORD(v19) & 0xF8000000u) >> 25)) << 27) | *(unsigned int *)LODWORD(v19) & 0x7FF07FF) & 0x7C00000u) >> 20)) << 22) | ((*(int *)((char *)v20 + ((*(unsigned int *)LODWORD(v19) & 0xF800u) >> 9)) << 11) | (*(int *)((char *)v20 + ((*(unsigned int *)LODWORD(v19) & 0xF8000000u) >> 25)) << 27) | *(unsigned int *)LODWORD(v19) & 0x7FF07FF) & 0xF81FF81F) & 0xFFE0FFE0);
|
|
6326 *(unsigned int *)LODWORD(v19) = result;
|
|
6327 LODWORD(v19) += 4;
|
|
6328 --v22;
|
|
6329 }
|
|
6330 while ( v22 );
|
|
6331 LODWORD(v19) += v37;
|
|
6332 v21 = v31 - 1;
|
|
6333 }
|
|
6334 while ( v31 != 1 );
|
|
6335 }
|
|
6336 else
|
|
6337 {
|
|
6338 v24 = sr_4268E3_smthn_to_a1r5g5b5(this_);
|
|
6339 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F);
|
|
6340 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3))
|
|
6341 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16);
|
|
6342 v26 = v40;
|
|
6343 v27 = (char *)off_4EFDB0;
|
|
6344 v28 = HIDWORD(v39);
|
|
6345 do
|
|
6346 {
|
|
6347 v29 = v38;
|
|
6348 v32 = v28;
|
|
6349 do
|
|
6350 {
|
|
6351 v30 = 32
|
|
6352 * *(int *)&v27[(((unsigned __int16)(*(short *)&v27[(*(unsigned int *)LODWORD(v26) & 0x7C00u) >> 8] << 10) | *(unsigned int *)LODWORD(v26) & 0x3FF) & 0x3E0u) >> 3] | (*(int *)&v27[(((*(int *)&v27[(*(unsigned int *)LODWORD(v26) & 0x7C00u) >> 8] << 10) | (*(int *)&v27[(*(unsigned int *)LODWORD(v26) & 0x7C000000u) >> 24] << 26) | *(unsigned int *)LODWORD(v26) & 0x3FF03FF) & 0x3E00000u) >> 19] << 21) | ((*(int *)&v27[(*(unsigned int *)LODWORD(v26) & 0x7C00u) >> 8] << 10) | (*(int *)&v27[(*(unsigned int *)LODWORD(v26) & 0x7C000000u) >> 24] << 26) | *(unsigned int *)LODWORD(v26) & 0x3FF03FF) & 0x7C1F7C1F;
|
|
6353 result = this_
|
|
6354 + (*(int *)&v27[4
|
|
6355 * (((unsigned __int8)(32
|
|
6356 * v27[(((unsigned __int16)(*(short *)&v27[(*(unsigned int *)LODWORD(v26) & 0x7C00u) >> 8] << 10) | *(unsigned int *)LODWORD(v26) & 0x3FF) & 0x3E0u) >> 3]) | *(unsigned int *)LODWORD(v26) & 0x1F) & 0x1F)] | (*(int *)&v27[(v30 & 0x1F0000u) >> 14] << 16) | (32 * *(int *)&v27[(((unsigned __int16)(*(short *)&v27[(*(unsigned int *)LODWORD(v26) & 0x7C00u) >> 8] << 10) | *(unsigned int *)LODWORD(v26) & 0x3FF) & 0x3E0u) >> 3] | (*(int *)&v27[(((*(int *)&v27[(*(unsigned int *)LODWORD(v26) & 0x7C00u) >> 8] << 10) | (*(int *)&v27[(*(unsigned int *)LODWORD(v26) & 0x7C000000u) >> 24] << 26) | *(unsigned int *)LODWORD(v26) & 0x3FF03FF) & 0x3E00000u) >> 19] << 21) | ((*(int *)&v27[(*(unsigned int *)LODWORD(v26) & 0x7C00u) >> 8] << 10) | (*(int *)&v27[(*(unsigned int *)LODWORD(v26) & 0x7C000000u) >> 24] << 26) | *(unsigned int *)LODWORD(v26) & 0x3FF03FF) & 0x7C1F7C1F) & 0xFFE0FFE0);
|
|
6357 *(unsigned int *)LODWORD(v26) = result;
|
|
6358 LODWORD(v26) += 4;
|
|
6359 --v29;
|
|
6360 }
|
|
6361 while ( v29 );
|
|
6362 LODWORD(v26) += v37;
|
|
6363 v28 = v32 - 1;
|
|
6364 }
|
|
6365 while ( v32 != 1 );
|
|
6366 }
|
|
6367 }*/
|
|
6368 }
|
|
6369
|
|
6370 //----- (004A5B81) --------------------------------------------------------
|
|
6371 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
|
|
6372 {
|
|
6373 this->bClip = 1;
|
|
6374 this->uClipX = uX;
|
|
6375 this->uClipY = uY;
|
|
6376 this->uClipZ = uZ;
|
|
6377 this->uClipW = uW;
|
|
6378 }
|
|
6379
|
|
6380 //----- (004A5BB6) --------------------------------------------------------
|
|
6381 void Render::ResetTextureClipRect()
|
|
6382 {
|
|
6383 this->bClip = 1;
|
|
6384 this->uClipX = 0;
|
|
6385 this->uClipY = 0;
|
|
6386 this->uClipZ = window->GetWidth();
|
|
6387 this->uClipW = 480;
|
|
6388 }
|
|
6389
|
|
6390 unsigned __int32 Color32(unsigned __int16 color16)
|
|
6391 {
|
|
6392 unsigned __int32 c = color16;
|
|
6393 unsigned int b = (c & 31) * 8;
|
|
6394 unsigned int g = ((c >> 5) & 63) * 4;
|
|
6395 unsigned int r = ((c >> 11) & 31) * 8;
|
|
6396
|
|
6397 return (r << 16) | (g << 8) | b;//
|
|
6398 }
|
|
6399
|
|
6400 //----- (0040DEF3) --------------------------------------------------------
|
|
6401 unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b)
|
|
6402 {
|
|
6403 //return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) +
|
|
6404 // LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) +
|
|
6405 // LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
|
|
6406 return (b >> (8 - 5)) |
|
|
6407 0x7E0 & (g << (6 + 5 - 8)) |
|
|
6408 0xF800 & (r << (6 + 5 + 5 - 8));
|
|
6409 }
|
|
6410
|
|
6411
|
|
6412 //----- (004A5BE3) --------------------------------------------------------
|
|
6413 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4)
|
|
6414 {
|
|
6415 int v4; // edi@3
|
|
6416 unsigned __int16 *v6; // esi@3
|
|
6417 unsigned int v8; // eax@5
|
|
6418 unsigned int v9; // ebx@5
|
|
6419 unsigned int v11; // eax@7
|
|
6420 unsigned int v12; // ebx@8
|
|
6421 unsigned int v15; // eax@14
|
|
6422 int v19; // [sp+10h] [bp-8h]@3
|
|
6423 int v23; // [sp+28h] [bp+10h]@3
|
|
6424
|
|
6425 if ( this->uNumSceneBegins && a4 )
|
|
6426 {
|
|
6427 v4 = a4->uWidth;
|
|
6428 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
|
|
6429 v6 = a4->pPixels;
|
|
6430 v23 = a4->uHeight;
|
|
6431 v19 = v4;
|
|
6432 if ( this->bClip )
|
|
6433 {
|
|
6434 if ( (signed int)uOutX < (signed int)this->uClipX )
|
|
6435 {
|
|
6436 v8 = this->uClipX - uOutX;
|
|
6437 v9 = uOutX - this->uClipX;
|
|
6438 v8 *= 2;
|
|
6439 v4 += v9;
|
|
6440 v6 = (unsigned __int16 *)((char *)v6 + v8);
|
|
6441 //v5 = (unsigned __int16 *)((char *)v5 + v8);
|
|
6442 }
|
|
6443 if ( (signed int)uOutY < (signed int)this->uClipY )
|
|
6444 {
|
|
6445 v11 = this->uClipY - uOutY;
|
|
6446 v6 += v19 * v11;
|
|
6447 v23 += uOutY - this->uClipY;
|
|
6448 //v5 += this->uTargetSurfacePitch * v11;
|
|
6449 }
|
|
6450 v12 = max(this->uClipX, uOutX);
|
|
6451 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ )
|
|
6452 {
|
|
6453 v4 = this->uClipZ - max(this->uClipX, uOutX);
|
|
6454 }
|
|
6455 v15 = max(this->uClipY, uOutY);
|
|
6456 if ( (signed int)(v15 + v23) > (signed int)this->uClipW )
|
|
6457 {
|
|
6458 v23 = this->uClipW - max(this->uClipY, uOutY);
|
|
6459 }
|
|
6460 }
|
|
6461
|
|
6462 for (int y = 0; y < v23; y++)
|
|
6463 {
|
|
6464 for (int x = 0; x < v4; x++)
|
|
6465 {
|
|
6466 WritePixel16(uOutX + x, uOutY + y, *v6);
|
|
6467 //*v5 = *v6;
|
|
6468 //++v5;
|
|
6469 ++v6;
|
|
6470 }
|
|
6471 v6 += v19 - v4;
|
|
6472 //v5 += this->uTargetSurfacePitch - v4;
|
|
6473 }
|
|
6474 }
|
|
6475 }
|
|
6476
|
|
6477 //----- (004A5D33) --------------------------------------------------------
|
|
6478 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture)
|
|
6479 {
|
|
6480 //unsigned __int16 *v7; // ebx@3
|
|
6481 int full_width; // ecx@3
|
|
6482 int full_height; // edi@3
|
|
6483 //int v23; // edi@23
|
|
6484 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3
|
|
6485
|
|
6486 if ( this->uNumSceneBegins && pTexture )
|
|
6487 {
|
|
6488 /*auto v7 = this->pTargetSurface;
|
|
6489 if (FORCE_16_BITS)
|
|
6490 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 2);
|
|
6491 else
|
|
6492 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 4);*/
|
|
6493 full_width = pTexture->uWidth - move_X;
|
|
6494 full_height = pTexture->uHeight - move_Y;
|
|
6495 pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth];
|
|
6496 if ( this->bClip )
|
|
6497 {
|
|
6498 if ( pX < this->uClipX )//åñëè êàäð âûõîäèò çà ïðàâóþ ãðàíèöó
|
|
6499 {
|
|
6500 pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX)));
|
|
6501 full_width += pX - this->uClipX;
|
|
6502 //v7 = (unsigned __int32 *)((char *)v7 + ((FORCE_16_BITS ? 2 : 4) * (this->uClipX - pX)));
|
|
6503 }
|
|
6504 if ( pY < this->uClipY )//åñëè êàäð âûõîäèò çà âåðõíþþ ãðàíèöó
|
|
6505 {
|
|
6506 pTexturea += pTexture->uWidth * (this->uClipY - pY);
|
|
6507 full_height += pY - this->uClipY;
|
|
6508 //v7 = (unsigned __int32 *)((char *)v7 + (FORCE_16_BITS ? 2 : 4) * this->uTargetSurfacePitch * (this->uClipY - pY));
|
|
6509 }
|
|
6510 if ( this->uClipX < pX )//åñëè ïðàâàÿ ãðàíèöà îêíà ìåíüøå õ êîîðäèíàòû êàäðà
|
|
6511 this->uClipX = pX;
|
|
6512 if ( this->uClipY < pY )//åñëè âåðõíÿÿ ãðàíèöà îêíà ìåíüøå y êîîðäèíàòû êàäðà
|
|
6513 this->uClipY = pY;
|
|
6514 if ( (full_width + this->uClipX) > this->uClipZ )//åñëè øèðèíà êàäðà âûõîäèò çà ïðàâóþ ãðàíèöó
|
|
6515 {
|
|
6516 if ( this->uClipX < pX )
|
|
6517 this->uClipX = pX;
|
|
6518 full_width = this->uClipZ - this->uClipX;
|
|
6519 }
|
|
6520 if ( (full_height + this->uClipY) > this->uClipW )//åñëè âûñîòà êàäðà âûõîäèò çà íèæíþþ ãðàíèöó
|
|
6521 {
|
|
6522 if ( this->uClipY < pY )
|
|
6523 this->uClipY = pY;
|
|
6524 full_height = this->uClipW - this->uClipY;
|
|
6525 }
|
|
6526 }
|
|
6527
|
|
6528 for (int y = 0; y < full_height; ++y)
|
|
6529 {
|
|
6530 for (int x = 0; x < full_width; ++x)
|
|
6531 {
|
|
6532 if ( *pTexturea != Color16(0, 0xFFu, 0xFFu) )
|
|
6533 {
|
|
6534 WritePixel16(pX + x, pY + y, *pTexturea);
|
|
6535 /*if (FORCE_16_BITS)
|
|
6536 *(unsigned __int16 *)v7 = *pTexturea;
|
|
6537 else
|
|
6538 *(unsigned __int32 *)v7 = r5g6b5_2_r8g8b8(*pTexturea);*/
|
|
6539 }
|
|
6540 ++pTexturea;
|
|
6541 //++v7;
|
|
6542 }
|
|
6543 //v7 += this->uTargetSurfacePitch - full_width;
|
|
6544 pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width));
|
|
6545 }
|
|
6546 }
|
|
6547 }
|
|
6548
|
|
6549 //----- (004A6E7E) --------------------------------------------------------
|
|
6550 void Render::DrawTranslucent(unsigned int a2, unsigned int a3, Texture *a4)
|
|
6551 {
|
|
6552 int v5; // edx@4
|
|
6553 unsigned int v6; // edi@4
|
|
6554 unsigned int v7; // edx@5
|
|
6555 unsigned int v8; // edx@6
|
|
6556 unsigned int v9; // edx@7
|
|
6557 unsigned int v10; // edx@8
|
|
6558 unsigned int v11; // ebx@9
|
|
6559 unsigned int v12; // esi@11
|
|
6560 unsigned int v13; // edx@12
|
|
6561 unsigned int v14; // ebx@15
|
|
6562 unsigned int v15; // esi@17
|
|
6563 unsigned int v16; // edi@18
|
|
6564 int v18; // [sp+14h] [bp-Ch]@4
|
|
6565 int v19; // [sp+18h] [bp-8h]@4
|
|
6566 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4
|
|
6567
|
|
6568 if ( this->uNumSceneBegins && a4 && a4->pPalette16 )
|
|
6569 {
|
|
6570 //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
|
|
6571 v20 = a4->pLevelOfDetail0_prolly_alpha_mask;
|
|
6572 v5 = a4->uTextureWidth;
|
|
6573 v6 = a4->uTextureHeight;
|
|
6574 v19 = a4->uTextureWidth;
|
|
6575 v18 = a4->uTextureWidth;
|
|
6576 int clipped_out_x = a2;
|
|
6577 int clipped_out_y = a3;
|
|
6578 if ( this->bClip )
|
|
6579 {
|
|
6580 v7 = this->uClipX;
|
|
6581 if ( (signed int)a2 < (signed int)v7 )
|
|
6582 {
|
|
6583 v8 = v7 - a2;
|
|
6584 v20 += v8;
|
|
6585 v19 += a2 - this->uClipX;
|
|
6586 //v4 += v8;
|
|
6587 clipped_out_x = uClipX;
|
|
6588 }
|
|
6589 v9 = this->uClipY;
|
|
6590 if ( (signed int)a3 < (signed int)v9 )
|
|
6591 {
|
|
6592 v10 = v9 - a3;
|
|
6593 v20 += v18 * v10;
|
|
6594 v6 = a3 - this->uClipY + a4->uTextureHeight;
|
|
6595 //v4 += this->uTargetSurfacePitch * v10;
|
|
6596 clipped_out_y = uClipY;
|
|
6597 }
|
|
6598 v11 = this->uClipX;
|
|
6599 v5 = v19;
|
|
6600 if ( (signed int)v11 < (signed int)a2 )
|
|
6601 v11 = a2;
|
|
6602 v12 = this->uClipZ;
|
|
6603 if ( (signed int)(v19 + v11) > (signed int)v12 )
|
|
6604 {
|
|
6605 v13 = this->uClipX;
|
|
6606 if ( (signed int)v13 < (signed int)a2 )
|
|
6607 v13 = a2;
|
|
6608 v5 = v12 - v13;
|
|
6609 }
|
|
6610 v14 = this->uClipY;
|
|
6611 if ( (signed int)v14 < (signed int)a3 )
|
|
6612 v14 = a3;
|
|
6613 v15 = this->uClipW;
|
|
6614 if ( (signed int)(v6 + v14) > (signed int)v15 )
|
|
6615 {
|
|
6616 v16 = this->uClipY;
|
|
6617 if ( (signed int)v16 < (signed int)a3 )
|
|
6618 v16 = a3;
|
|
6619 v6 = v15 - v16;
|
|
6620 }
|
|
6621 }
|
|
6622
|
|
6623 for (uint y = 0; y < v6; ++y)
|
|
6624 {
|
|
6625 for (int x = 0; x < v5; ++x)
|
|
6626 {
|
|
6627 if ( *v20 )
|
|
6628 WritePixel16(clipped_out_x + x, clipped_out_y + y, ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF);
|
|
6629 ++v20;
|
|
6630 }
|
|
6631 v20 += v18 - v5;
|
|
6632 }
|
|
6633
|
|
6634 /*if ( pRenderer->uTargetGBits == 5 )
|
|
6635 {
|
|
6636 if ( (signed int)v6 > 0 )
|
|
6637 {
|
|
6638 v23 = v6;
|
|
6639 do
|
|
6640 {
|
|
6641 if ( v5 > 0 )
|
|
6642 {
|
|
6643 v21 = v5;
|
|
6644 do
|
|
6645 {
|
|
6646 if ( *v20 )
|
|
6647 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF;
|
|
6648 ++v4;
|
|
6649 ++v20;
|
|
6650 --v21;
|
|
6651 }
|
|
6652 while ( v21 );
|
|
6653 }
|
|
6654 v20 += v18 - v5;
|
|
6655 v17 = v23-- == 1;
|
|
6656 v4 += this->uTargetSurfacePitch - v5;
|
|
6657 }
|
|
6658 while ( !v17 );
|
|
6659 }
|
|
6660 }
|
|
6661 else
|
|
6662 {
|
|
6663 if ( (signed int)v6 > 0 )
|
|
6664 {
|
|
6665 v24 = v6;
|
|
6666 do
|
|
6667 {
|
|
6668 if ( v5 > 0 )
|
|
6669 {
|
|
6670 v22 = v5;
|
|
6671 do
|
|
6672 {
|
|
6673 if ( *v20 )
|
|
6674 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF;
|
|
6675 ++v4;
|
|
6676 ++v20;
|
|
6677 --v22;
|
|
6678 }
|
|
6679 while ( v22 );
|
|
6680 }
|
|
6681 v20 += v18 - v5;
|
|
6682 v17 = v24-- == 1;
|
|
6683 v4 += this->uTargetSurfacePitch - v5;
|
|
6684 }
|
|
6685 while ( !v17 );
|
|
6686 }
|
|
6687 }*/
|
|
6688 }
|
|
6689 }
|
|
6690
|
|
6691 //----- (004A6DF5) --------------------------------------------------------
|
|
6692 void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7)
|
|
6693 {
|
|
6694 int width; // ecx@3
|
|
6695 unsigned __int16 *pixels; // ebx@4
|
|
6696 int height; // esi@4
|
|
6697
|
|
6698 if ( !pBitmap || !pTarget)
|
|
6699 return;
|
|
6700
|
|
6701 width = a7->z - a7->x;
|
|
6702 height = a7->w - a7->y;
|
|
6703 pixels = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y;
|
|
6704 for ( int y = 0; y < height; ++y )
|
|
6705 {
|
|
6706 for ( int x = 0; x < width; ++x )
|
|
6707 {
|
|
6708 WritePixel16(a7->x + x, a7->y + y, *pixels);
|
|
6709 ++pixels;
|
|
6710 }
|
|
6711 pixels += uTargetPitch - width;
|
|
6712 }
|
|
6713 }
|
|
6714
|
|
6715 //----- (004A6D87) --------------------------------------------------------
|
|
6716 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16)
|
|
6717 {
|
|
6718 if (!uNumSceneBegins)
|
|
6719 return;
|
|
6720
|
|
6721 unsigned __int32 twoColors = (uColor16 << 16) | uColor16;
|
|
6722 for (uint y = 0; y < uHeight; ++y)
|
|
6723 {
|
|
6724 void *pDst = (char *)pTargetSurface + (FORCE_16_BITS ? 2 : 4) * (uX + (y + uY) * uTargetSurfacePitch);
|
|
6725
|
|
6726 memset32(pDst,
|
|
6727 FORCE_16_BITS ? twoColors : 0xFF000000 | Color32(uColor16), // two colors per int (16bit) or 1 (32bit)
|
|
6728 uWidth / (FORCE_16_BITS ? 2 : 1)); // two pixels per int (16bit) or 1 (32bit)
|
|
6729
|
|
6730 if (FORCE_16_BITS && uWidth & 1) // we may miss one pixel for 16bit
|
|
6731 ((unsigned __int16 *)pTargetSurface)[uX + uWidth - 1 + (y + uY) * uTargetSurfacePitch] = uColor16;
|
|
6732 }
|
|
6733 }
|
|
6734
|
|
6735 //----- (004A6C4F) --------------------------------------------------------
|
|
6736 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth,
|
|
6737 unsigned int uCharHeight, unsigned __int16 *pFontPalette,
|
|
6738 unsigned __int16 uFaceColor, unsigned __int16 uShadowColor)
|
|
6739 {
|
|
6740 unsigned int v9; // edi@2
|
|
6741 unsigned int v10; // esi@2
|
|
6742 unsigned int v12; // ebx@3
|
|
6743 //signed int v13; // edx@5
|
|
6744 int v14; // edx@6
|
|
6745 signed int v15; // ebx@7
|
|
6746 //unsigned int v16; // edx@9
|
|
6747 signed int v17; // edi@10
|
|
6748 signed int v18; // ebx@13
|
|
6749 unsigned int v19; // edx@15
|
|
6750 signed int v20; // esi@16
|
|
6751 unsigned __int16 v22; // dx@24
|
|
6752 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2
|
|
6753
|
|
6754 if (!this->uNumSceneBegins)
|
|
6755 return;
|
|
6756
|
|
6757 v9 = uCharWidth;
|
|
6758 v10 = uCharHeight;
|
|
6759 //v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
|
|
6760 v24 = pFontPixels;
|
|
6761
|
|
6762 int clipped_out_x = uOutX, clipped_out_y = uOutY;
|
|
6763 if ( this->bClip )
|
|
6764 {
|
|
6765 v12 = this->uClipX;
|
|
6766 if ( uOutX < (signed int)v12 )
|
|
6767 {
|
|
6768 v24 = &pFontPixels[v12 - uOutX];
|
|
6769 //v11 += v12 - uOutX;
|
|
6770 clipped_out_x = uClipX;
|
|
6771 v9 = uCharWidth + uOutX - v12;
|
|
6772 }
|
|
6773 //v13 = this->uClipY;
|
|
6774 if ( uOutY < this->uClipY )
|
|
6775 {
|
|
6776 v14 = this->uClipY - uOutY;
|
|
6777 v24 += uCharWidth * v14;
|
|
6778 v10 = uCharHeight + uOutY - this->uClipY;
|
|
6779 //v11 += this->uTargetSurfacePitch * v14;
|
|
6780 clipped_out_y = uClipY;
|
|
6781 }
|
|
6782 v15 = this->uClipX;
|
|
6783 if ( this->uClipX < uOutX )
|
|
6784 v15 = uOutX;
|
|
6785 //v16 = this->uClipZ;
|
|
6786 if ( (signed int)(v9 + v15) > (signed int)this->uClipZ )
|
|
6787 {
|
|
6788 v17 = this->uClipX;
|
|
6789 if ( this->uClipX < uOutX )
|
|
6790 v17 = uOutX;
|
|
6791 v9 = this->uClipZ - v17;
|
|
6792 }
|
|
6793 v18 = this->uClipY;
|
|
6794 if ( this->uClipY < uOutY )
|
|
6795 v18 = uOutY;
|
|
6796 v19 = this->uClipW;
|
|
6797 if ( (signed int)(v10 + v18) > (signed int)v19 )
|
|
6798 {
|
|
6799 v20 = this->uClipY;
|
|
6800 if ( this->uClipY < uOutY )
|
|
6801 v20 = uOutY;
|
|
6802 v10 = v19 - v20;
|
|
6803 }
|
|
6804 }
|
|
6805
|
|
6806 for (uint y = 0; y < v10; ++y)
|
|
6807 {
|
|
6808 for (uint x = 0; x < v9; ++x)
|
|
6809 {
|
|
6810 if (*v24)
|
|
6811 {
|
|
6812 v22 = uShadowColor;
|
|
6813 if ( *v24 != 1 )
|
|
6814 v22 = uFaceColor;
|
|
6815 WritePixel16(clipped_out_x + x, clipped_out_y + y, v22);
|
|
6816 }
|
|
6817 ++v24;
|
|
6818 }
|
|
6819 v24 += uCharWidth - v9;
|
|
6820 //v23 = uOutXa-- == 1;
|
|
6821 //v11 += this->uTargetSurfacePitch - v9;
|
|
6822 }
|
|
6823 }
|
|
6824
|
|
6825 //----- (004A6A68) --------------------------------------------------------
|
|
6826 void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height)
|
|
6827 {
|
|
6828 Texture tex; // [sp+Ch] [bp-48h]@1
|
|
6829
|
|
6830 memcpy(&tex, a4, sizeof(tex));
|
|
6831 tex.uTextureHeight = a4->uTextureHeight - height;
|
|
6832 if ( (signed __int16)tex.uTextureHeight > 0 )
|
|
6833 DrawTextureIndexed(a2, a3, &tex);
|
|
6834 }
|
|
6835
|
|
6836 //----- (004A6AB1) --------------------------------------------------------
|
|
6837 void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 )
|
|
6838 {
|
|
6839 int v8; // edi@2
|
|
6840 unsigned int v9; // esi@2
|
|
6841 unsigned char *v11; // edx@2
|
|
6842 int v14; // edx@6
|
|
6843 signed int v15; // ebx@7
|
|
6844 signed int v17; // edi@10
|
|
6845 signed int v18; // ebx@13
|
|
6846 signed int v20; // esi@16
|
|
6847 unsigned __int16 v24; // si@35
|
|
6848 int v25; // [sp+Ch] [bp-4h]@2
|
|
6849 unsigned int v28; // [sp+20h] [bp+10h]@30
|
|
6850
|
|
6851 int a2 = x;
|
|
6852 int a3 = y;
|
|
6853 uint a6 = uFontHeight;
|
|
6854 if (!this->uNumSceneBegins)
|
|
6855 return;
|
|
6856
|
|
6857 v8 = a5;
|
|
6858 v9 = a6;
|
|
6859 //v10 = &pTargetSurface[x + y * uTargetSurfacePitch];
|
|
6860 v11 = (unsigned char *)font_pixels;
|
|
6861 v25 = (int)font_pixels;
|
|
6862 int clipped_out_x = x;
|
|
6863 int clipped_out_y = y;
|
|
6864 if ( this->bClip )
|
|
6865 {
|
|
6866 if ( a2 < (signed int)this->uClipX )
|
|
6867 {
|
|
6868 v25 = this->uClipX - a2 + (int)font_pixels;
|
|
6869 //v10 += v12 - a2;
|
|
6870 v8 = a5 + a2 - this->uClipX;
|
|
6871 clipped_out_x = uClipX;
|
|
6872 }
|
|
6873 if ( a3 < this->uClipY )
|
|
6874 {
|
|
6875 v14 = this->uClipY - a3;
|
|
6876 v25 += a5 * v14;
|
|
6877 v9 = a6 + a3 - this->uClipY;
|
|
6878 //v10 += this->uTargetSurfacePitch * v14;
|
|
6879 clipped_out_y = uClipY;
|
|
6880 }
|
|
6881 v15 = this->uClipX;
|
|
6882 if ( this->uClipX < a2 )
|
|
6883 v15 = a2;
|
|
6884 if ( v8 + v15 > (signed int)this->uClipZ )
|
|
6885 {
|
|
6886 v17 = this->uClipX;
|
|
6887 if ( v17 < a2 )
|
|
6888 v17 = a2;
|
|
6889 v8 = this->uClipZ - v17;
|
|
6890 }
|
|
6891 v18 = this->uClipY;
|
|
6892 if ( this->uClipY < a3 )
|
|
6893 v18 = a3;
|
|
6894 if ( (signed int)(v9 + v18) > (signed int)this->uClipW )
|
|
6895 {
|
|
6896 v20 = this->uClipY;
|
|
6897 if ( this->uClipY < a3 )
|
|
6898 v20 = a3;
|
|
6899 v9 = this->uClipW - v20;
|
|
6900 }
|
|
6901 v11 = (unsigned char *)v25;
|
|
6902 }
|
|
6903
|
|
6904 if ( a8 )
|
|
6905 {
|
|
6906 v28 = 0x7FF; // 16bit pRenderer->uTargetGMask | pRenderer->uTargetBMask;
|
|
6907 for (uint dy = 0; dy < v9; ++dy)
|
|
6908 {
|
|
6909 for (int dx = 0; dx < v8; ++dx)
|
|
6910 {
|
|
6911 if ( *v11 )
|
|
6912 v24 = pPalette[*v11];
|
|
6913 else
|
|
6914 v24 = v28;
|
|
6915 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, v24);
|
|
6916 //*v10 = v24;
|
|
6917 //++v10;
|
|
6918 ++v11;
|
|
6919 //--v27;
|
|
6920
|
|
6921 }
|
|
6922 v11 += a5 - v8;
|
|
6923 }
|
|
6924 /*if ( (signed int)v9 > 0 )
|
|
6925 {
|
|
6926 v23 = a5;
|
|
6927 v30 = v9;
|
|
6928 do
|
|
6929 {
|
|
6930 if ( v8 > 0 )
|
|
6931 {
|
|
6932 v27 = v8;
|
|
6933 do
|
|
6934 {
|
|
6935 if ( *v11 )
|
|
6936 v24 = pPalette[*v11];
|
|
6937 else
|
|
6938 v24 = v28;
|
|
6939 *v10 = v24;
|
|
6940 ++v10;
|
|
6941 ++v11;
|
|
6942 --v27;
|
|
6943 }
|
|
6944 while ( v27 );
|
|
6945 }
|
|
6946 v11 += v23 - v8;
|
|
6947 v22 = v30-- == 1;
|
|
6948 v10 += this->uTargetSurfacePitch - v8;
|
|
6949 }
|
|
6950 while ( !v22 );
|
|
6951 }*/
|
|
6952 }
|
|
6953 else
|
|
6954 {
|
|
6955 for (uint dy = 0; dy < v9; ++dy)
|
|
6956 {
|
|
6957 for (int dx = 0; dx < v8; ++dx)
|
|
6958 {
|
|
6959 if ( *v11 )
|
|
6960 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, pPalette[*v11]);
|
|
6961 //*v10 = v24;
|
|
6962 //++v10;
|
|
6963 ++v11;
|
|
6964 //--v27;
|
|
6965 }
|
|
6966 v11 += a5 - v8;
|
|
6967 }
|
|
6968
|
|
6969 /*if ( (signed int)v9 > 0 )
|
|
6970 {
|
|
6971 v21 = a5;
|
|
6972 v29 = v9;
|
|
6973 do
|
|
6974 {
|
|
6975 if ( v8 > 0 )
|
|
6976 {
|
|
6977 v26 = v8;
|
|
6978 do
|
|
6979 {
|
|
6980 if ( *v11 )
|
|
6981 *v10 = pPalette[*v11];
|
|
6982 ++v10;
|
|
6983 ++v11;
|
|
6984 --v26;
|
|
6985 }
|
|
6986 while ( v26 );
|
|
6987 }
|
|
6988 v11 += v21 - v8;
|
|
6989 v22 = v29-- == 1;
|
|
6990 v10 += this->uTargetSurfacePitch - v8;
|
|
6991 }
|
|
6992 while ( !v22 );
|
|
6993 }*/
|
|
6994 }
|
|
6995 }
|
|
6996
|
|
6997 //----- (004A68EF) --------------------------------------------------------
|
|
6998 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture)
|
|
6999 {
|
|
7000 DrawMasked(a2, a3, pTexture, 0x07E0);
|
|
7001 }
|
|
7002
|
|
7003
|
|
7004 //----- (004A6776) --------------------------------------------------------
|
|
7005 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4)
|
|
7006 {
|
|
7007 DrawMasked(a2, a3, a4, 0xF800);
|
|
7008 /*Texture *v4; // edi@2
|
|
7009 unsigned int v5; // ebx@4
|
|
7010 unsigned __int16 *v6; // eax@4
|
|
7011 unsigned int v7; // edx@5
|
|
7012 unsigned int v8; // edx@6
|
|
7013 unsigned int v9; // edx@7
|
|
7014 unsigned int v10; // edx@8
|
|
7015 unsigned int v11; // edx@9
|
|
7016 unsigned int v12; // esi@12
|
|
7017 unsigned int v13; // esi@15
|
|
7018 unsigned int v14; // edx@17
|
|
7019 unsigned int v15; // esi@18
|
|
7020 unsigned __int8 *v16; // ebx@22
|
|
7021 char v17; // zf@28
|
|
7022 int v18; // [sp+10h] [bp-10h]@4
|
|
7023 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
|
|
7024 int v20; // [sp+1Ch] [bp-4h]@4
|
|
7025 int a2a; // [sp+28h] [bp+8h]@24
|
|
7026 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22
|
|
7027 unsigned int a4a; // [sp+30h] [bp+10h]@11
|
|
7028
|
|
7029 if ( this->uNumSceneBegins )
|
|
7030 {
|
|
7031 v4 = a4;
|
|
7032 if ( a4 )
|
|
7033 {
|
|
7034 if ( a4->pPalette16 )
|
|
7035 {
|
|
7036 v5 = a4->uTextureHeight;
|
|
7037 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
|
|
7038 v19 = a4->pLevelOfDetail0_prolly_alpha_mask;
|
|
7039 v20 = a4->uTextureWidth;
|
|
7040 v18 = a4->uTextureWidth;
|
|
7041 if ( this->bClip )
|
|
7042 {
|
|
7043 v7 = this->uClipX;
|
|
7044 if ( (signed int)a2 < (signed int)v7 )
|
|
7045 {
|
|
7046 v8 = v7 - a2;
|
|
7047 v19 += v8;
|
|
7048 v20 += a2 - this->uClipX;
|
|
7049 v6 += v8;
|
|
7050 }
|
|
7051 v9 = this->uClipY;
|
|
7052 v5 = a4->uTextureHeight;
|
|
7053 if ( (signed int)a3 < (signed int)v9 )
|
|
7054 {
|
|
7055 v10 = v9 - a3;
|
|
7056 v19 += v18 * v10;
|
|
7057 v5 = a3 - this->uClipY + a4->uTextureHeight;
|
|
7058 v4 = a4;
|
|
7059 v6 += this->uTargetSurfacePitch * v10;
|
|
7060 }
|
|
7061 v11 = this->uClipX;
|
|
7062 if ( (signed int)v11 < (signed int)a2 )
|
|
7063 v11 = a2;
|
|
7064 a4a = this->uClipZ;
|
|
7065 if ( (signed int)(v11 + v20) > (signed int)a4a )
|
|
7066 {
|
|
7067 v12 = this->uClipX;
|
|
7068 if ( (signed int)v12 < (signed int)a2 )
|
|
7069 v12 = a2;
|
|
7070 v20 = a4a - v12;
|
|
7071 }
|
|
7072 v13 = this->uClipY;
|
|
7073 if ( (signed int)v13 < (signed int)a3 )
|
|
7074 v13 = a3;
|
|
7075 v14 = this->uClipW;
|
|
7076 if ( (signed int)(v5 + v13) > (signed int)v14 )
|
|
7077 {
|
|
7078 v15 = this->uClipY;
|
|
7079 if ( (signed int)v15 < (signed int)a3 )
|
|
7080 v15 = a3;
|
|
7081 v5 = v14 - v15;
|
|
7082 }
|
|
7083 }
|
|
7084 if ( (signed int)v5 > 0 )
|
|
7085 {
|
|
7086 a3a = v5;
|
|
7087 v16 = v19;
|
|
7088 do
|
|
7089 {
|
|
7090 if ( v20 > 0 )
|
|
7091 {
|
|
7092 a2a = v20;
|
|
7093 do
|
|
7094 {
|
|
7095 if ( *v16 )
|
|
7096 *v6 = this->uTargetRMask & v4->pPalette16[*v16];
|
|
7097 ++v6;
|
|
7098 ++v16;
|
|
7099 --a2a;
|
|
7100 }
|
|
7101 while ( a2a );
|
|
7102 }
|
|
7103 v16 += v18 - v20;
|
|
7104 v17 = a3a-- == 1;
|
|
7105 v6 += this->uTargetSurfacePitch - v20;
|
|
7106 }
|
|
7107 while ( !v17 );
|
|
7108 }
|
|
7109 }
|
|
7110 }
|
|
7111 }*/
|
|
7112 }
|
|
7113
|
|
7114 //----- (004A68EF) --------------------------------------------------------
|
|
7115 void Render::DrawMasked(signed int a2, signed int a3, Texture *pTexture, unsigned __int16 mask)
|
|
7116 {
|
|
7117 unsigned int v5; // ebx@4
|
|
7118 int v10; // edx@8
|
|
7119 signed int v11; // edx@9
|
|
7120 signed int v12; // esi@12
|
|
7121 signed int v13; // esi@15
|
|
7122 signed int v15; // esi@18
|
|
7123 unsigned __int8 *v16; // ebx@22
|
|
7124 int v18; // [sp+10h] [bp-10h]@4
|
|
7125 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
|
|
7126 int v20; // [sp+1Ch] [bp-4h]@4
|
|
7127
|
|
7128 if (!uNumSceneBegins || !pTexture)
|
|
7129 return;
|
|
7130
|
|
7131 if ( pTexture->pPalette16 )
|
|
7132 {
|
|
7133 v5 = pTexture->uTextureHeight;
|
|
7134 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
|
|
7135 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask;
|
|
7136 v20 = pTexture->uTextureWidth;
|
|
7137 v18 = pTexture->uTextureWidth;
|
|
7138 int clipped_out_x = a2;
|
|
7139 int clipped_out_y = a3;
|
|
7140 if ( this->bClip )
|
|
7141 {
|
|
7142 if ( a2 < this->uClipX )
|
|
7143 {
|
|
7144 v19 += this->uClipX - a2;
|
|
7145 v20 += a2 - this->uClipX;
|
|
7146 clipped_out_x = uClipX;
|
|
7147 }
|
|
7148 v5 = pTexture->uTextureHeight;
|
|
7149 if ( a3 < this->uClipY )
|
|
7150 {
|
|
7151 v10 = this->uClipY - a3;
|
|
7152 v19 += v18 * v10;
|
|
7153 v5 = a3 - this->uClipY + pTexture->uTextureHeight;
|
|
7154 clipped_out_y = uClipY;
|
|
7155 }
|
|
7156 v11 = this->uClipX;
|
|
7157 if ( this->uClipX < a2 )
|
|
7158 v11 = a2;
|
|
7159 if ( v11 + v20 > (signed int)this->uClipZ )
|
|
7160 {
|
|
7161 v12 = this->uClipX;
|
|
7162 if ( this->uClipX < a2 )
|
|
7163 v12 = a2;
|
|
7164 v20 = this->uClipZ - v12;
|
|
7165 }
|
|
7166 v13 = this->uClipY;
|
|
7167 if ( this->uClipY < a3 )
|
|
7168 v13 = a3;
|
|
7169 if ( (signed int)(v5 + v13) > (signed int)this->uClipW )
|
|
7170 {
|
|
7171 v15 = this->uClipY;
|
|
7172 if ( this->uClipY < a3 )
|
|
7173 v15 = a3;
|
|
7174 v5 = this->uClipW - v15;
|
|
7175 }
|
|
7176 }
|
|
7177
|
|
7178 v16 = v19;
|
|
7179 for (uint y = 0; y < v5; ++y)
|
|
7180 {
|
|
7181 for (int x = 0; x < v20; ++x)
|
|
7182 {
|
|
7183 if ( *v16 )
|
|
7184 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v16] & mask);
|
|
7185 ++v16;
|
|
7186 }
|
|
7187 v16 += v18 - v20;
|
|
7188 }
|
|
7189
|
|
7190 /*if ( (signed int)v5 > 0 )
|
|
7191 {
|
|
7192 v22 = v5;
|
|
7193 v16 = v19;
|
|
7194 do
|
|
7195 {
|
|
7196 if ( v20 > 0 )
|
|
7197 {
|
|
7198 v21 = v20;
|
|
7199 do
|
|
7200 {
|
|
7201 if ( *v16 )
|
|
7202 *v6 = this->uTargetGMask & v4->pPalette16[*v16];
|
|
7203 ++v6;
|
|
7204 ++v16;
|
|
7205 --v21;
|
|
7206 }
|
|
7207 while ( v21 );
|
|
7208 }
|
|
7209 v16 += v18 - v20;
|
|
7210 v17 = v22-- == 1;
|
|
7211 v6 += this->uTargetSurfacePitch - v20;
|
|
7212 }
|
|
7213 while ( !v17 );
|
|
7214 }*/
|
|
7215 }
|
|
7216 }
|
|
7217
|
|
7218
|
|
7219 //----- (004A65CC) --------------------------------------------------------
|
|
7220 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8)
|
|
7221 {
|
|
7222 unsigned int uHeight; // edi@6
|
|
7223 unsigned int v14; // edx@11
|
|
7224 unsigned int v16; // edx@14
|
|
7225 unsigned int v17; // edx@17
|
|
7226 unsigned int v19; // edx@20
|
|
7227 int v20; // eax@27
|
|
7228 int v21; // edx@29
|
|
7229 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6
|
|
7230 int Width; // [sp+2Ch] [bp+14h]@6
|
|
7231
|
|
7232 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 )
|
|
7233 {
|
|
7234 v24 = a4->pLevelOfDetail0_prolly_alpha_mask;
|
|
7235 Width = a4->uTextureWidth;
|
|
7236 uHeight = a4->uTextureHeight;
|
|
7237 int clipped_out_x = x;
|
|
7238 int clipped_out_y = y;
|
|
7239 if ( this->bClip )
|
|
7240 {
|
|
7241 if ( (signed int)x < (signed int)this->uClipX )
|
|
7242 {
|
|
7243 v24 += this->uClipX - x;
|
|
7244 Width += x - this->uClipX;
|
|
7245 clipped_out_x = uClipX;
|
|
7246 }
|
|
7247 if ( (signed int)y < (signed int)this->uClipY )
|
|
7248 {
|
|
7249 v24 += a4->uTextureWidth * (this->uClipY - y);
|
|
7250 uHeight = y - this->uClipY + a4->uTextureHeight;
|
|
7251 clipped_out_y = uClipY;
|
|
7252 }
|
|
7253 v14 = this->uClipX;
|
|
7254 if ( (signed int)this->uClipX < (signed int)x )
|
|
7255 v14 = x;
|
|
7256 if ( (signed int)(Width + v14) > (signed int)this->uClipZ )
|
|
7257 {
|
|
7258 v16 = this->uClipX;
|
|
7259 if ( (signed int)this->uClipX < (signed int)x )
|
|
7260 v16 = x;
|
|
7261 Width = this->uClipZ - v16;
|
|
7262 }
|
|
7263 v17 = this->uClipY;
|
|
7264 if ( (signed int)this->uClipY < (signed int)y )
|
|
7265 v17 = y;
|
|
7266 if ( (signed int)(uHeight + v17) > (signed int)this->uClipW )
|
|
7267 {
|
|
7268 v19 = this->uClipY;
|
|
7269 if ( (signed int)this->uClipY < (signed int)y )
|
|
7270 v19 = y;
|
|
7271 uHeight = this->uClipW - v19;
|
|
7272 }
|
|
7273 }
|
|
7274
|
|
7275 for (uint dy = 0; dy < uHeight; ++dy)
|
|
7276 {
|
|
7277 for (int dx = 0; dx < Width; ++dx)
|
|
7278 {
|
|
7279 v20 = *v24;
|
|
7280 if ( v20 >= a7 && v20 <= a8 )
|
|
7281 {
|
|
7282 v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
|
|
7283 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
|
|
7284 v21 = 2 * a8 - v21 - a7;
|
|
7285 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]);
|
|
7286 }
|
|
7287 ++v24;
|
|
7288 }
|
|
7289 v24 += a4->uTextureWidth - Width;
|
|
7290 }
|
|
7291 /*if ( (signed int)v9 > 0 )
|
|
7292 {
|
|
7293 ya = v9;
|
|
7294 v23 = v22 - v27;
|
|
7295 do
|
|
7296 {
|
|
7297 if ( v27 > 0 )
|
|
7298 {
|
|
7299 xa = v27;
|
|
7300 do
|
|
7301 {
|
|
7302 v20 = *v24;
|
|
7303 if ( v20 >= a7 && v20 <= a8 )
|
|
7304 {
|
|
7305 v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
|
|
7306 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
|
|
7307 v21 = 2 * a8 - v21 - a7;
|
|
7308 *v8 = a4->pPalette16[v21];
|
|
7309 }
|
|
7310 ++v8;
|
|
7311 ++v24;
|
|
7312 --xa;
|
|
7313 }
|
|
7314 while ( xa );
|
|
7315 }
|
|
7316 v8 += this->uTargetSurfacePitch - v27;
|
|
7317 v24 += v23;
|
|
7318 --ya;
|
|
7319 }
|
|
7320 while ( ya );
|
|
7321 }*/
|
|
7322 }
|
|
7323 }
|
|
7324
|
|
7325 //----- (004A63E6) --------------------------------------------------------
|
|
7326 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8)
|
|
7327 {
|
|
7328 unsigned int v14; // edx@11
|
|
7329 unsigned int v16; // edx@14
|
|
7330 unsigned int v17; // edx@17
|
|
7331 unsigned int v19; // edx@20
|
|
7332 int v20; // eax@27
|
|
7333 int v21; // edx@29
|
|
7334 int Height; // [sp+10h] [bp-8h]@6
|
|
7335 int Width; // [sp+14h] [bp-4h]@6
|
|
7336 int v27; // [sp+24h] [bp+Ch]@23
|
|
7337 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6
|
|
7338
|
|
7339 if ( this->uNumSceneBegins )
|
|
7340 {
|
|
7341 if ( a4 )
|
|
7342 {
|
|
7343 if ( a4->pPalette16 )
|
|
7344 {
|
|
7345 if ( a5 )
|
|
7346 {
|
|
7347 if ( a5->pPalette16 )
|
|
7348 {
|
|
7349 v28 = a4->pLevelOfDetail0_prolly_alpha_mask;
|
|
7350 Width = a4->uTextureWidth;
|
|
7351 Height = a4->uTextureHeight;
|
|
7352 int clipped_out_x = a2;
|
|
7353 int clipped_out_y = a3;
|
|
7354 if ( this->bClip )
|
|
7355 {
|
|
7356 if ( (signed int)a2 < (signed int)this->uClipX )
|
|
7357 {
|
|
7358 v28 += this->uClipX - a2;
|
|
7359 Width += a2 - this->uClipX;
|
|
7360 clipped_out_x = uClipX;
|
|
7361 }
|
|
7362
|
|
7363 if ( (signed int)a3 < (signed int)this->uClipY )
|
|
7364 {
|
|
7365 v28 += a4->uTextureWidth * (this->uClipY - a3);
|
|
7366 Height += a3 - this->uClipY;
|
|
7367 clipped_out_y = uClipY;
|
|
7368 }
|
|
7369
|
|
7370 v14 = this->uClipX;
|
|
7371 if ( (signed int)this->uClipX < (signed int)a2 )
|
|
7372 v14 = a2;
|
|
7373 if ( (signed int)(Width + v14) > (signed int)this->uClipZ )
|
|
7374 {
|
|
7375 v16 = this->uClipX;
|
|
7376 if ( (signed int)this->uClipX < (signed int)a2 )
|
|
7377 v16 = a2;
|
|
7378 Width = this->uClipZ - v16;
|
|
7379 }
|
|
7380
|
|
7381 v17 = this->uClipY;
|
|
7382 if ( (signed int)this->uClipY < (signed int)a3 )
|
|
7383 v17 = a3;
|
|
7384 if ( (signed int)(Height + v17) > (signed int)this->uClipW )
|
|
7385 {
|
|
7386 v19 = this->uClipY;
|
|
7387 if ( (signed int)this->uClipY < (signed int)a3 )
|
|
7388 v19 = a3;
|
|
7389 Height = this->uClipW - v19;
|
|
7390 }
|
|
7391 }
|
|
7392
|
|
7393 v27 = 0;
|
|
7394 for (int y = 0; y < Height; ++y)
|
|
7395 {
|
|
7396 for (int x = 0; x < Width; ++x)
|
|
7397 {
|
|
7398 if ( *v28 )
|
|
7399 {
|
|
7400 v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1));
|
|
7401 if ( v20 >= a7 )
|
|
7402 {
|
|
7403 if ( v20 <= a8 )
|
|
7404 {
|
|
7405 v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
|
|
7406 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
|
|
7407 v21 = 2 * a8 - v21 - a7;
|
|
7408 //v9 = a5;
|
|
7409 //*v10 = a5->pPalette16[v21];
|
|
7410 WritePixel16(clipped_out_x + x, clipped_out_y + y, a5->pPalette16[v21]);
|
|
7411 }
|
|
7412 }
|
|
7413 }
|
|
7414 v28++;
|
|
7415 }
|
|
7416 v28 += a4->uTextureWidth - Width;
|
|
7417 }
|
|
7418
|
|
7419 /*if ( v24 > 0 )
|
|
7420 {
|
|
7421 v23 = v22 - v25;
|
|
7422 do
|
|
7423 {
|
|
7424 for ( i = 0; i < v25; ++v28 )
|
|
7425 {
|
|
7426 if ( *v28 )
|
|
7427 {
|
|
7428 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1));
|
|
7429 if ( v20 >= a7 )
|
|
7430 {
|
|
7431 if ( v20 <= a8 )
|
|
7432 {
|
|
7433 v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
|
|
7434 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
|
|
7435 v21 = 2 * a8 - v21 - a7;
|
|
7436 v9 = a5;
|
|
7437 *v10 = a5->pPalette16[v21];
|
|
7438 }
|
|
7439 }
|
|
7440 }
|
|
7441 ++i;
|
|
7442 ++v10;
|
|
7443 }
|
|
7444 ++v27;
|
|
7445 v10 += this->uTargetSurfacePitch - v25;
|
|
7446 v28 += v23;
|
|
7447 }
|
|
7448 while ( v27 < v24 );
|
|
7449 }*/
|
|
7450
|
|
7451 }
|
|
7452 }
|
|
7453 }
|
|
7454 }
|
|
7455 }
|
|
7456 }
|
|
7457
|
|
7458 //----- (004A6274) --------------------------------------------------------
|
|
7459 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture)
|
|
7460 {
|
|
7461 int uHeight; // ebx@4
|
|
7462 unsigned int v11; // edx@9
|
|
7463 unsigned int v12; // esi@12
|
|
7464 unsigned int v13; // esi@15
|
|
7465 unsigned int v15; // esi@18
|
|
7466 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
|
|
7467 int uWidth; // [sp+1Ch] [bp-4h]@4
|
|
7468
|
|
7469 if ( this->uNumSceneBegins )
|
|
7470 {
|
|
7471 if ( pTexture )
|
|
7472 {
|
|
7473 if ( pTexture->pPalette16 )
|
|
7474 {
|
|
7475 uHeight = pTexture->uTextureHeight;
|
|
7476 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask;
|
|
7477 uWidth = pTexture->uTextureWidth;
|
|
7478
|
|
7479 int clipped_out_x = uX;
|
|
7480 int clipped_out_y = uY;
|
|
7481 if ( this->bClip )
|
|
7482 {
|
|
7483 if ( (signed int)uX < (signed int)this->uClipX )
|
|
7484 {
|
|
7485 v19 += this->uClipX - uX;
|
|
7486 uWidth += uX - this->uClipX;
|
|
7487 clipped_out_x = uClipX;
|
|
7488 }
|
|
7489
|
|
7490 uHeight = pTexture->uTextureHeight;
|
|
7491 if ( (signed int)uY < (signed int)this->uClipY )
|
|
7492 {
|
|
7493 v19 += pTexture->uTextureWidth * (this->uClipY - uY);
|
|
7494 uHeight = uY - this->uClipY + pTexture->uTextureHeight;
|
|
7495 clipped_out_y = uClipY;
|
|
7496 }
|
|
7497 v11 = this->uClipX;
|
|
7498 if ( (signed int)this->uClipX < (signed int)uX )
|
|
7499 v11 = uX;
|
|
7500
|
|
7501 if ( (signed int)(v11 + uWidth) > (signed int)this->uClipZ )
|
|
7502 {
|
|
7503 v12 = this->uClipX;
|
|
7504 if ( (signed int)this->uClipX < (signed int)uX )
|
|
7505 v12 = uX;
|
|
7506 uWidth = this->uClipZ - v12;
|
|
7507 }
|
|
7508 v13 = this->uClipY;
|
|
7509 if ( (signed int)this->uClipY < (signed int)uY )
|
|
7510 v13 = uY;
|
|
7511
|
|
7512 if ( (signed int)(uHeight + v13) > (signed int)this->uClipW )
|
|
7513 {
|
|
7514 v15 = this->uClipY;
|
|
7515 if ( (signed int)this->uClipY < (signed int)uY )
|
|
7516 v15 = uY;
|
|
7517 uHeight = this->uClipW - v15;
|
|
7518 }
|
|
7519 }
|
|
7520
|
|
7521 for (int y = 0; y < uHeight; ++y)
|
|
7522 {
|
|
7523 for (int x = 0; x < uWidth; ++x)
|
|
7524 {
|
|
7525 if ( *v19 )
|
|
7526 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]);
|
|
7527 ++v19;
|
|
7528 }
|
|
7529 v19 += pTexture->uTextureWidth - uWidth;
|
|
7530 }
|
|
7531 /*if ( (signed int)uHeight > 0 )
|
|
7532 {
|
|
7533 uYa = uHeight;
|
|
7534 v16 = v19;
|
|
7535 do
|
|
7536 {
|
|
7537 if ( uWidth > 0 )
|
|
7538 {
|
|
7539 uXa = uWidth;
|
|
7540 do
|
|
7541 {
|
|
7542 if ( *v16 )
|
|
7543 *v6 = pCurrentTexture->pPalette16[*v16];
|
|
7544 ++v6;
|
|
7545 ++v16;
|
|
7546 }
|
|
7547 while ( uXa-- !=1 );
|
|
7548 }
|
|
7549 v16 += v18 - uWidth;
|
|
7550 uFlag = uYa-- == 1;
|
|
7551 v6 += this->uTargetSurfacePitch - uWidth;
|
|
7552 }
|
|
7553 while ( !uFlag );
|
|
7554 }*/
|
|
7555 }
|
|
7556 }
|
|
7557 }
|
|
7558 }
|
|
7559
|
|
7560 //----- (004A612A) --------------------------------------------------------
|
|
7561 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal)
|
|
7562 {
|
|
7563 unsigned int v6; // edx@3
|
|
7564 int v7; // ebx@3
|
|
7565 int v8; // edi@3
|
|
7566 int v10; // eax@5
|
|
7567 signed int v12; // esi@8
|
|
7568 signed int v14; // esi@11
|
|
7569 unsigned int v15; // esi@14
|
|
7570 unsigned int v17; // ecx@17
|
|
7571 int v18; // edx@23
|
|
7572 int v19; // [sp+Ch] [bp-Ch]@3
|
|
7573 int v20; // [sp+10h] [bp-8h]@3
|
|
7574 int uOutXa; // [sp+20h] [bp+8h]@21
|
|
7575 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3
|
|
7576 int *pZBuffer; // [sp+28h] [bp+10h]@3
|
|
7577
|
|
7578 if ( this->uNumSceneBegins )
|
|
7579 {
|
|
7580 if ( pTexture )
|
|
7581 {
|
|
7582 v6 = uOutY;
|
|
7583 v7 = pTexture->uTextureHeight;
|
|
7584 pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY];
|
|
7585 uOutYa = pTexture->pLevelOfDetail0_prolly_alpha_mask;
|
|
7586 v8 = pTexture->uTextureWidth;
|
|
7587 v20 = pTexture->uTextureWidth;
|
|
7588 v19 = pTexture->uTextureWidth;
|
|
7589 if ( this->bClip )
|
|
7590 {
|
|
7591 if ( uOutX < this->uClipX )
|
|
7592 {
|
|
7593 v10 = this->uClipX - uOutX;
|
|
7594 uOutYa += v10;
|
|
7595 v8 += uOutX - this->uClipX;
|
|
7596 v20 = v8;
|
|
7597 pZBuffer += v10;
|
|
7598 }
|
|
7599 if ( (signed int)v6 < (signed int)this->uClipY )
|
|
7600 {
|
|
7601 uOutYa += v19 * (this->uClipY - v6);
|
|
7602 v7 += v6 - this->uClipY;
|
|
7603 pZBuffer += window->GetWidth() * (this->uClipY - v6);
|
|
7604 v8 = v20;
|
|
7605 }
|
|
7606 v12 = this->uClipX;
|
|
7607 if ( this->uClipX < uOutX )
|
|
7608 v12 = uOutX;
|
|
7609 if ( v8 + v12 > (signed int)this->uClipZ )
|
|
7610 {
|
|
7611 v14 = this->uClipX;
|
|
7612 if ( this->uClipX < uOutX )
|
|
7613 v14 = uOutX;
|
|
7614 v8 = this->uClipZ - v14;
|
|
7615 }
|
|
7616 v15 = this->uClipY;
|
|
7617 if ( (signed int)this->uClipY < (signed int)v6 )
|
|
7618 v15 = v6;
|
|
7619 if ( (signed int)(v7 + v15) > (signed int)this->uClipW )
|
|
7620 {
|
|
7621 v17 = this->uClipY;
|
|
7622 if ( (signed int)this->uClipY >= (signed int)v6 )
|
|
7623 v6 = v17;
|
|
7624 v7 = this->uClipW - v6;
|
|
7625 }
|
|
7626 }
|
|
7627 if ( v7 > 0 )
|
|
7628 {
|
|
7629 uOutXa = v7;
|
|
7630 do
|
|
7631 {
|
|
7632 if ( v8 > 0 )
|
|
7633 {
|
|
7634 v18 = v8;
|
|
7635 do
|
|
7636 {
|
|
7637 if ( *uOutYa )
|
|
7638 *pZBuffer = zVal;
|
|
7639 ++pZBuffer;
|
|
7640 ++uOutYa;
|
|
7641 --v18;
|
|
7642 }
|
|
7643 while ( v18 );
|
|
7644 }
|
|
7645 pZBuffer += window->GetWidth() - v8;
|
|
7646 uOutYa += v19 - v8;
|
|
7647 --uOutXa;
|
|
7648 }
|
|
7649 while ( uOutXa );
|
|
7650 }
|
|
7651 }
|
|
7652 }
|
|
7653 }
|
|
7654
|
|
7655 //----- (004A601E) --------------------------------------------------------
|
|
7656 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5)
|
|
7657 {
|
|
7658 signed int v5; // edx@3
|
|
7659 int v6; // ebx@3
|
|
7660 int v7; // esi@3
|
|
7661 void *v8; // esi@3
|
|
7662 signed int v11; // edi@8
|
|
7663 signed int v13; // edi@11
|
|
7664 unsigned int v14; // edi@14
|
|
7665 unsigned int v16; // ecx@17
|
|
7666 int v17; // [sp+18h] [bp+Ch]@3
|
|
7667 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3
|
|
7668
|
|
7669 if ( this->uNumSceneBegins && pTexture )
|
|
7670 {
|
|
7671 v5 = a3;
|
|
7672 v6 = pTexture->uTextureHeight;
|
|
7673 v7 = 5 * a3;
|
|
7674 v17 = pTexture->uTextureHeight;
|
|
7675 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)];
|
|
7676 pTexturea = pTexture->uTextureWidth;
|
|
7677 if ( this->bClip )
|
|
7678 {
|
|
7679 if ( a2 < (signed int)this->uClipX )
|
|
7680 {
|
|
7681 pTexturea += a2 - this->uClipX;
|
|
7682 v8 = (char *)v8 + 4 * (this->uClipX - a2);
|
|
7683 }
|
|
7684 if ( v5 < (signed int)this->uClipY )
|
|
7685 {
|
|
7686 v17 += v5 - this->uClipY;
|
|
7687 v8 = (char *)v8 + 2560 * (this->uClipY - v5);
|
|
7688 }
|
|
7689 v11 = this->uClipX;
|
|
7690 if ( this->uClipX < a2 )
|
|
7691 v11 = a2;
|
|
7692 if ( (signed int)(pTexturea + v11) > (signed int)this->uClipZ )
|
|
7693 {
|
|
7694 v13 = this->uClipX;
|
|
7695 if ( this->uClipX < a2 )
|
|
7696 v13 = a2;
|
|
7697 pTexturea = this->uClipZ - v13;
|
|
7698 }
|
|
7699 v14 = this->uClipY;
|
|
7700 if ( (signed int)this->uClipY < v5 )
|
|
7701 v14 = v5;
|
|
7702 v6 = v17;
|
|
7703 if ( (signed int)(v17 + v14) > (signed int)this->uClipW )
|
|
7704 {
|
|
7705 v16 = this->uClipY;
|
|
7706 if ( (signed int)this->uClipY < v5 )
|
|
7707 v16 = v5;
|
|
7708 v6 = this->uClipW - v16;
|
|
7709 }
|
|
7710 }
|
|
7711 if ( v6 > 0 )
|
|
7712 {
|
|
7713 do
|
|
7714 {
|
|
7715 if ( (signed int)pTexturea > 0 )
|
|
7716 {
|
|
7717 memset32(v8, a5, pTexturea);
|
|
7718 v8 = (char *)v8 + 4 * pTexturea;
|
|
7719 }
|
|
7720 v8 = (char *)v8 + 4 * (window->GetWidth() - pTexturea);
|
|
7721 --v6;
|
|
7722 }
|
|
7723 while ( v6 );
|
|
7724 }
|
|
7725 }
|
|
7726 }
|
|
7727
|
|
7728 //----- (004A5EB2) --------------------------------------------------------
|
|
7729 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4)
|
|
7730 {
|
|
7731 int v5; // ebx@4
|
|
7732 unsigned int v8; // edx@6
|
|
7733 unsigned int v10; // edx@8
|
|
7734 unsigned int v11; // edx@9
|
|
7735 unsigned int v12; // esi@12
|
|
7736 unsigned int v13; // esi@15
|
|
7737 unsigned int v15; // esi@18
|
|
7738 int v18; // [sp+10h] [bp-10h]@4
|
|
7739 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
|
|
7740 int v20; // [sp+1Ch] [bp-4h]@4
|
|
7741
|
|
7742 if ( this->uNumSceneBegins )
|
|
7743 {
|
|
7744 if ( a4 )
|
|
7745 {
|
|
7746 if ( a4->pPalette16 )
|
|
7747 {
|
|
7748 v5 = a4->uTextureHeight;
|
|
7749 //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch];
|
|
7750 v19 = a4->pLevelOfDetail0_prolly_alpha_mask;
|
|
7751 v20 = a4->uTextureWidth;
|
|
7752 v18 = a4->uTextureWidth;
|
|
7753
|
|
7754 int clipped_out_x = uX;
|
|
7755 int clipped_out_y = uY;
|
|
7756 if ( this->bClip )
|
|
7757 {
|
|
7758 if ( (signed int)uX < (signed int)this->uClipX )
|
|
7759 {
|
|
7760 v8 = this->uClipX - uX;
|
|
7761 v19 += v8;
|
|
7762 v20 += uX - this->uClipX;
|
|
7763 clipped_out_x = uClipX;
|
|
7764 }
|
|
7765
|
|
7766 v5 = a4->uTextureHeight;
|
|
7767 if ( (signed int)uY < (signed int)this->uClipY )
|
|
7768 {
|
|
7769 v10 = this->uClipY - uY;
|
|
7770 v19 += v18 * v10;
|
|
7771 v5 = uY - this->uClipY + a4->uTextureHeight;
|
|
7772 //v4 = a4;
|
|
7773 clipped_out_y = uClipY;
|
|
7774 }
|
|
7775
|
|
7776 v11 = this->uClipX;
|
|
7777 if ( (signed int)this->uClipX < (signed int)uX )
|
|
7778 v11 = uX;
|
|
7779
|
|
7780 if ( (signed int)(v11 + v20) > (signed int)this->uClipZ )
|
|
7781 {
|
|
7782 v12 = this->uClipX;
|
|
7783 if ( (signed int)this->uClipX < (signed int)uX )
|
|
7784 v12 = uX;
|
|
7785 v20 = this->uClipZ - v12;
|
|
7786 }
|
|
7787
|
|
7788 v13 = this->uClipY;
|
|
7789 if ( (signed int)this->uClipY < (signed int)uY )
|
|
7790 v13 = uY;
|
|
7791
|
|
7792 if ( (signed int)(v5 + v13) > (signed int)uClipW )
|
|
7793 {
|
|
7794 v15 = this->uClipY;
|
|
7795 if ( (signed int)this->uClipY < (signed int)uY )
|
|
7796 v15 = uY;
|
|
7797 v5 = uClipW - v15;
|
|
7798 }
|
|
7799 }
|
|
7800
|
|
7801 for (int y = 0; y < v5; ++y)
|
|
7802 {
|
|
7803 for (int x = 0; x < v20; ++x)
|
|
7804 {
|
|
7805 if ( a4->pPalette16[*v19] != 0x7FF )// 2047
|
|
7806 WritePixel16(clipped_out_x + x, clipped_out_y + y, a4->pPalette16[*v19]);
|
|
7807 ++v19;
|
|
7808 }
|
|
7809 v19 += v18 - v20;
|
|
7810 }
|
|
7811 /*if ( (signed int)v5 > 0 )
|
|
7812 {
|
|
7813 uYa = v5;
|
|
7814 v16 = v19;
|
|
7815 do
|
|
7816 {
|
|
7817 if ( v20 > 0 )
|
|
7818 {
|
|
7819 uXa = v20;
|
|
7820 do
|
|
7821 {
|
|
7822 *pTarget = v4->pPalette16[*v16];
|
|
7823 ++pTarget;
|
|
7824 ++v16;
|
|
7825 --uXa;
|
|
7826 }
|
|
7827 while ( uXa );
|
|
7828 }
|
|
7829 v16 += v18 - v20;
|
|
7830 v17 = uYa-- == 1;
|
|
7831 pTarget += this->uTargetSurfacePitch - v20;
|
|
7832 }
|
|
7833 while ( !v17 );
|
|
7834 }*/
|
|
7835 }
|
|
7836 }
|
|
7837 }
|
|
7838 }
|
|
7839
|
|
7840 //----- (004667E9) --------------------------------------------------------
|
|
7841 void Render::ChangeBetweenWinFullscreenModes()
|
|
7842 {
|
|
7843 float v0; // ST14_4@17
|
|
7844 int v4; // edx@26
|
|
7845 ObjectDesc *v5; // eax@26
|
|
7846 RGBTexture *v6; // esi@33
|
|
7847 const char *v8; // [sp-4h] [bp-28h]@33
|
|
7848 // struct tagRECT Rect; // [sp+14h] [bp-10h]@15
|
|
7849
|
|
7850 /*if ( !pRenderer->bWindowMode && (dword_6BE364_game_settings_1 & 2) )
|
|
7851 {
|
|
7852 ModalWindow(pGlobalTXT_LocalizationStrings[62], UIMSG_0);// "Might and Magic VII requires your desktop to be in 16bit (32k or 65k) Color mode in order to operate in a window."
|
|
7853 return;
|
|
7854 }*/
|
|
7855 if ( bWindowMode || pRenderD3D->pAvailableDevices->bIsDeviceCompatible )
|
|
7856 {
|
|
7857 if ( pEventTimer->bPaused )
|
|
7858 dword_6BE364_game_settings_1 |= GAME_SETTINGS_0800;
|
|
7859 else
|
|
7860 pEventTimer->Pause();
|
|
7861 if ( pMiscTimer->bPaused )
|
|
7862 dword_6BE364_game_settings_1 |= GAME_SETTINGS_1000;
|
|
7863 else
|
|
7864 pMiscTimer->Pause();
|
|
7865 pMouse->bActive = 0;
|
|
7866 if ( pRenderD3D )
|
|
7867 {
|
|
7868 pBitmaps_LOD->ReleaseHardwareTextures();
|
|
7869 pSprites_LOD->ReleaseAll();
|
|
7870 }
|
|
7871 if ( bWindowMode )
|
|
7872 {
|
|
7873 //SetMenu(hWnd, 0);
|
|
7874 //SetWindowLongA(hWnd, -20, 0);
|
|
7875 //SetWindowLongA(hWnd, -16, 0x10000000u);
|
|
7876 window->SetFullscreenMode();
|
|
7877 pRenderer->InitializeFullscreen();
|
|
7878 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6;
|
|
7879 pGame->pGammaController->Initialize(v0);
|
|
7880 }
|
|
7881 else
|
|
7882 {
|
|
7883 //ClipCursor(0);
|
|
7884 window->SetWindowedMode(window->GetWidth(), window->GetHeight());
|
|
7885 pRenderer->SwitchToWindow();
|
|
7886 }
|
|
7887 if ( pRenderD3D )
|
|
7888 {
|
|
7889 pBitmaps_LOD->_410423_move_textures_to_device();
|
|
7890 pSprites_LOD->MoveSpritesToVideoMemory();
|
|
7891 }
|
|
7892 if (!( pPaletteManager->uNumTargetBBits == uTargetBBits
|
|
7893 && pPaletteManager->uNumTargetGBits == uTargetGBits
|
|
7894 && pPaletteManager->uNumTargetRBits == uTargetRBits ))
|
|
7895 {
|
|
7896 pPaletteManager->SetColorChannelInfo(uTargetRBits, uTargetGBits, uTargetBBits);
|
|
7897 pPaletteManager->RecalculateAll();
|
|
7898 pBitmaps_LOD->SetupPalettes(uTargetRBits, uTargetGBits, uTargetBBits);
|
|
7899 pIcons_LOD->SetupPalettes(uTargetRBits, uTargetGBits, uTargetBBits);
|
|
7900 for (uint i = 0; i < pObjectList->uNumObjects; i++)
|
|
7901 {
|
|
7902 BYTE3(v4) = 0;
|
|
7903 v5 = &pObjectList->pObjects[i];
|
|
7904 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR;
|
|
7905 LOBYTE(v4) = v5->uParticleTrailColorG;
|
|
7906 v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8);
|
|
7907 }
|
|
7908 SetUserInterface(pParty->alignment, true);
|
|
7909 if ( pMediaPlayer->pVideoFrame.pPixels )
|
|
7910 pMediaPlayer->pVideoFrame.Load(pMediaPlayer->pVideoFrameTextureFilename, 1);
|
|
7911 if ( sCurrentMenuID != MENU_CREATEPARTY )
|
|
7912 {
|
|
7913 if ( sCurrentMenuID == MENU_CREDITSPROC )
|
|
7914 dword_A74C88 = 1;
|
|
7915 }
|
|
7916 else
|
|
7917 {
|
|
7918 if ( sCurrentMenuID )
|
|
7919 {
|
|
7920 v6 = &pTexture_PCX;
|
|
7921 pTexture_PCX.Release();
|
|
7922 v8 = "makeme.pcx";
|
|
7923 }
|
|
7924 else
|
|
7925 {
|
|
7926 v6 = &pTexture_PCX;
|
|
7927 pTexture_PCX.Release();
|
|
7928 v8 = "title.pcx";
|
|
7929 if ( sCurrentMenuID )
|
|
7930 v8 = "lsave640.pcx";
|
|
7931 }
|
|
7932 v6->Load(v8, 0);
|
|
7933 }
|
|
7934 }
|
|
7935 viewparams->bRedrawGameUI = 1;
|
|
7936 viewparams->InitGrayPalette();
|
|
7937 pMouse->SetCurrentCursorBitmap();
|
|
7938 /*if ( pRenderer->bWindowMode )
|
|
7939 {
|
|
7940 //MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0);
|
|
7941 CenterWindowAndAdjustSize(hWnd, windowed_mode_width, windowed_mode_height);
|
|
7942 ShowWindow(hWnd, SW_SHOWNORMAL);
|
|
7943 }*/
|
|
7944 pMouse->bActive = true;
|
|
7945 if ( pMovie_Track )
|
|
7946 pMediaPlayer->SelectMovieType();
|
|
7947 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0800)
|
|
7948 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0800;
|
|
7949 else
|
|
7950 pEventTimer->Resume();
|
|
7951 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_1000)
|
|
7952 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_1000;
|
|
7953 else
|
|
7954 pMiscTimer->Resume();
|
|
7955 }
|
|
7956 }
|
|
7957
|
|
7958
|
|
7959 //----- (004524D8) --------------------------------------------------------
|
|
7960 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps)
|
|
7961 {
|
|
7962 void *v13; // eax@13
|
|
7963 int v16; // esi@14
|
|
7964 int v17; // ecx@16
|
|
7965 int v18; // esi@16
|
|
7966 unsigned __int16 *v19; // eax@16
|
|
7967 int v20; // edx@16
|
|
7968 int v21; // ecx@16
|
|
7969 int v22; // eax@16
|
|
7970 int v23; // esi@16
|
|
7971 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13
|
|
7972 int v27; // [sp+28h] [bp-Ch]@14
|
|
7973 int v28; // [sp+2Ch] [bp-8h]@13
|
|
7974 int pDestb; // [sp+3Ch] [bp+8h]@15
|
|
7975
|
|
7976 if (!uNumItems)
|
|
7977 return nullptr;
|
|
7978
|
|
7979 ///////////////////////////////
|
|
7980 //quick search(áûñòðûé ïîèñê)//
|
|
7981 ///////////////////////////////
|
|
7982 uint idx1 = 0,
|
|
7983 idx2 = uNumItems;
|
|
7984 while (true)
|
|
7985 {
|
|
7986 uint i = idx1 + (idx2 - idx1) / 2;
|
|
7987
|
|
7988 int res = _stricmp(pName, pSpriteNames[i]);
|
|
7989 if (!res)
|
|
7990 {
|
|
7991 fseek(pFile, pSpriteOffsets[i], SEEK_SET);
|
|
7992 break;
|
|
7993 }
|
|
7994 else if (res < 0)
|
|
7995 idx2 = idx1 + (idx2 - idx1) / 2;
|
|
7996 else
|
|
7997 idx1 = i + 1;
|
|
7998
|
|
7999 if ( idx1 >= idx2 )
|
|
8000 return false;
|
|
8001 }
|
|
8002
|
|
8003 uint uCompressedSize = 0;
|
|
8004 fread(&uCompressedSize, 4, 1, pFile);
|
|
8005
|
|
8006 HWLTexture* pTex = new HWLTexture;
|
|
8007 fread(&pTex->uBufferWidth, 4, 1, pFile);
|
|
8008 fread(&pTex->uBufferHeight, 4, 1, pFile);
|
|
8009 fread(&pTex->uAreaWidth, 4, 1, pFile);
|
|
8010 fread(&pTex->uAreaHeigth, 4, 1, pFile);
|
|
8011 fread(&pTex->uWidth, 4, 1, pFile);
|
|
8012 fread(&pTex->uHeight, 4, 1, pFile);
|
|
8013 fread(&pTex->uAreaX, 4, 1, pFile);
|
|
8014 fread(&pTex->uAreaY, 4, 1, pFile);
|
|
8015
|
|
8016 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight];
|
|
8017 if (uCompressedSize)
|
|
8018 {
|
|
8019 char* pCompressedData = new char[uCompressedSize];
|
|
8020 fread(pCompressedData, 1, uCompressedSize, pFile);
|
|
8021 uint uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short);
|
|
8022 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize);
|
|
8023 delete [] pCompressedData;
|
|
8024 }
|
|
8025 else
|
|
8026 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile);
|
|
8027
|
|
8028 if ( scale_hwls_to_half )
|
|
8029 {
|
|
8030 __debugbreak();//Ritor1
|
|
8031 pTex->uHeight /= 2;
|
|
8032 pTex->uWidth /= 2;
|
|
8033 v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight];
|
|
8034 v28 = 0;
|
|
8035 v26 = (unsigned __int16 *)v13;
|
|
8036 if ( pTex->uHeight > 0 )
|
|
8037 {
|
|
8038 v16 = pTex->uWidth;
|
|
8039 v27 = 1;
|
|
8040 do
|
|
8041 {
|
|
8042 pDestb = 0;
|
|
8043 if ( v16 > 0 )
|
|
8044 {
|
|
8045 do
|
|
8046 {
|
|
8047 v17 = v16 * v27;
|
|
8048 v18 = v28 * v16;
|
|
8049 v19 = pTex->pPixels;
|
|
8050 v20 = pDestb + 2 * v18;
|
|
8051 v21 = (int)&v19[2 * (pDestb + v17)];
|
|
8052 v22 = (int)&v19[2 * v20];
|
|
8053 LOWORD(v20) = *(unsigned short *)(v21 + 2);
|
|
8054 LOWORD(v21) = *(unsigned short *)v21;
|
|
8055 v23 = pDestb + v18;
|
|
8056 pDestb++;
|
|
8057
|
|
8058 v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20);
|
|
8059 v16 = pTex->uWidth;
|
|
8060 }
|
|
8061 while (pDestb < pTex->uWidth);
|
|
8062 }
|
|
8063 ++v28;
|
|
8064 v27 += 2;
|
|
8065 }
|
|
8066 while ( v28 < (signed int)pTex->uHeight );
|
|
8067 }
|
|
8068 delete [] pTex->pPixels;
|
|
8069 pTex->pPixels = v26;
|
|
8070 }
|
|
8071 return pTex;
|
|
8072 }
|
|
8073 //----- (0045271F) --------------------------------------------------------
|
|
8074 bool RenderHWLContainer::Release()
|
|
8075 {
|
|
8076 __int32 v4; // eax@6
|
|
8077 FILE *v5; // ST24_4@6
|
|
8078 FILE *File; // [sp+4h] [bp-4h]@6
|
|
8079
|
|
8080 if ( this->bDumpDebug)
|
|
8081 {
|
|
8082 File = fopen("logd3d.txt", "w");
|
|
8083 v4 = ftell(this->pFile);
|
|
8084 v5 = this->pFile;
|
|
8085 this->uDataOffset = v4;
|
|
8086 fwrite(&this->uNumItems, 4u, 1u, v5);
|
|
8087 for (uint i = 0; i < this->uNumItems; i++)
|
|
8088 {
|
|
8089 fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile);
|
|
8090 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*)));
|
|
8091 }
|
|
8092 fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile);
|
|
8093 fseek(this->pFile, 4, 0);
|
|
8094 fwrite(&this->uDataOffset, 4u, 1u, this->pFile);
|
|
8095 fclose(this->pFile);
|
|
8096 fclose(File);
|
|
8097 }
|
|
8098 else
|
|
8099 {
|
|
8100 fclose(this->pFile);
|
|
8101 for (uint i = 0; i < this->uNumItems; i++)
|
|
8102 {
|
|
8103 delete[] this->pSpriteNames[i];
|
|
8104 }
|
|
8105 }
|
|
8106 return true;
|
|
8107 }
|
|
8108
|
|
8109 //----- (00452347) --------------------------------------------------------
|
|
8110 RenderHWLContainer::RenderHWLContainer():
|
|
8111 bDumpDebug(false)
|
|
8112 {
|
|
8113 this->pFile = 0;
|
|
8114 uSignature = 0;
|
|
8115 this->uDataOffset = 0;
|
|
8116 memset(&this->uNumItems, 0, 0x61A84u);
|
|
8117 this->uNumItems = 0;
|
|
8118 this->scale_hwls_to_half = false;
|
|
8119 }
|
|
8120
|
|
8121 //----- (0045237F) --------------------------------------------------------
|
|
8122 bool RenderHWLContainer::Load(const wchar_t *pFilename)
|
|
8123 {
|
|
8124 pFile = _wfopen(pFilename, L"rb");
|
|
8125 if (!pFile)
|
|
8126 {
|
|
8127 Log::Warning(L"Failed to open file: %s", pFilename);
|
|
8128 return false;
|
|
8129 }
|
|
8130
|
|
8131 fread(&uSignature, 1, 4, pFile);
|
|
8132 if (uSignature != 'TD3D')
|
|
8133 {
|
|
8134 Log::Warning(L"Invalid format: %s", pFilename);
|
|
8135 return false;
|
|
8136 }
|
|
8137
|
|
8138 fread(&uDataOffset, 4, 1, pFile);
|
|
8139 fseek(pFile, uDataOffset, SEEK_SET);
|
|
8140 fread(&uNumItems, 4, 1, pFile);
|
|
8141
|
|
8142 memset(pSpriteNames, 0, 50000 * sizeof(char *));
|
|
8143 for (uint i = 0; i < uNumItems; ++i)
|
|
8144 {
|
|
8145 pSpriteNames[i] = new char[20];
|
|
8146 fread(pSpriteNames[i], 1, 20, pFile);
|
|
8147 }
|
|
8148 fread(pSpriteOffsets, 4, uNumItems, pFile);
|
|
8149
|
|
8150 return true;
|
|
8151 }
|
|
8152
|
|
8153 //----- (004A1C1E) --------------------------------------------------------
|
|
8154 void Render::DoRenderBillboards_D3D()
|
|
8155 {
|
|
8156 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
|
|
8157 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
8158 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
8159 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
8160
|
|
8161 /*if (pRenderer->uNumBillboardsToDraw)
|
|
8162 {
|
|
8163 auto p = &pRenderer->pBillboardRenderListD3D[0];
|
|
8164 for (int i = 0; i < p->uNumVertices; ++i)
|
|
8165 {
|
|
8166 p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6;
|
|
8167 //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw);
|
|
8168 }
|
|
8169 p->pQuads[0].pos.x = 10;
|
|
8170 p->pQuads[0].pos.y = 10;
|
|
8171
|
|
8172 p->pQuads[1].pos.x = 10;
|
|
8173 p->pQuads[1].pos.y = 200;
|
|
8174
|
|
8175 p->pQuads[2].pos.x = 100;
|
|
8176 p->pQuads[2].pos.y = 200;
|
|
8177
|
|
8178 p->pQuads[3].pos.x = 100;
|
|
8179 p->pQuads[3].pos.y = 10;
|
|
8180
|
|
8181 if (p->uOpacity != RenderBillboardD3D::NoBlend)
|
|
8182 SetBillboardBlendOptions(p->uOpacity);
|
|
8183
|
|
8184 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture);
|
|
8185 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
8186 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
8187 p->pQuads, p->uNumVertices,
|
|
8188 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS));
|
|
8189
|
|
8190 }*/
|
|
8191
|
|
8192 for (int i = uNumBillboardsToDraw - 1; i >= 0; --i)
|
|
8193 {
|
|
8194 if (pBillboardRenderListD3D[i].opacity != RenderBillboardD3D::NoBlend)
|
|
8195 SetBillboardBlendOptions(pBillboardRenderListD3D[i].opacity);
|
|
8196
|
|
8197 pRenderD3D->pDevice->SetTexture(0, pBillboardRenderListD3D[i].pTexture);
|
|
8198 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
8199 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
8200 pBillboardRenderListD3D[i].pQuads, pBillboardRenderListD3D[i].uNumVertices,
|
|
8201 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS));
|
|
8202 }
|
|
8203
|
|
8204 if (bFogEnabled)
|
|
8205 {
|
|
8206 bFogEnabled = false;
|
|
8207 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
8208 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF));
|
|
8209 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
|
|
8210 }
|
|
8211 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
|
|
8212 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
8213 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
8214 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8215 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
8216 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
8217 }
|
|
8218
|
|
8219 //----- (004A1DA8) --------------------------------------------------------
|
|
8220 void Render::SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1)
|
|
8221 {
|
|
8222 switch (a1)
|
|
8223 {
|
|
8224 case RenderBillboardD3D::Transparent:
|
|
8225 {
|
|
8226 if (bFogEnabled)
|
|
8227 {
|
|
8228 bFogEnabled = false;
|
|
8229 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
8230 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF));
|
|
8231 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
|
|
8232 }
|
|
8233
|
|
8234 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA));
|
|
8235 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA));
|
|
8236 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
8237 }
|
|
8238 break;
|
|
8239
|
|
8240 case RenderBillboardD3D::Opaque_1:
|
|
8241 case RenderBillboardD3D::Opaque_2:
|
|
8242 case RenderBillboardD3D::Opaque_3:
|
|
8243 {
|
|
8244 if (bUsingSpecular)
|
|
8245 {
|
|
8246 if (!bFogEnabled)
|
|
8247 {
|
|
8248 bFogEnabled = true;
|
|
8249 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
8250 }
|
|
8251 }
|
|
8252
|
|
8253 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8254 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
|
|
8255 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
8256 }
|
|
8257 break;
|
|
8258
|
|
8259 default:
|
|
8260 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1);
|
|
8261 assert(false);
|
|
8262 break;
|
|
8263 }
|
|
8264 }
|
|
8265 //----- (00424CD7) --------------------------------------------------------
|
|
8266 int ODM_NearClip(unsigned int num_vertices)
|
|
8267 {
|
|
8268 bool current_vertices_flag; // edi@1
|
|
8269 bool next_vertices_flag; // [sp+Ch] [bp-24h]@6
|
|
8270 double t; // st6@10
|
|
8271 bool bFound;
|
|
8272
|
|
8273 bFound = false;
|
|
8274
|
|
8275 if (!num_vertices)
|
|
8276 return 0;
|
|
8277 for (uint i = 0; i < num_vertices; ++i)// åñòü ëè ïîãðàíè÷íûå âåðøèíû
|
|
8278 {
|
|
8279 if ( array_50AC10[i].vWorldViewPosition.x > 8.0 )
|
|
8280 {
|
|
8281 bFound = true;
|
|
8282 break;
|
|
8283 }
|
|
8284 }
|
|
8285 if ( !bFound )
|
|
8286 return 0;
|
|
8287
|
|
8288 memcpy(&array_50AC10[num_vertices], &array_50AC10[0], sizeof(array_50AC10[0]));
|
|
8289 current_vertices_flag = false;
|
|
8290 next_vertices_flag = false;
|
|
8291 if ( array_50AC10[0].vWorldViewPosition.x <= 8.0 )
|
|
8292 current_vertices_flag = true;
|
|
8293 //check for near clip plane(ïðîâåðêà ïî áëèæíåé ãðàíèöå)
|
|
8294 //
|
|
8295 // v3.__________________. v0
|
|
8296 // | |
|
|
8297 // | |
|
|
8298 // | |
|
|
8299 // ----------------------- 8.0(near_clip - 8.0)
|
|
8300 // | |
|
|
8301 // .__________________.
|
|
8302 // v2 v1
|
|
8303
|
|
8304 int out_num_vertices = 0;
|
|
8305 for (uint i = 0; i < num_vertices; ++i)
|
|
8306 {
|
|
8307 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x <= 8.0;//
|
|
8308 if ( current_vertices_flag ^ next_vertices_flag )
|
|
8309 {
|
|
8310 if ( next_vertices_flag )//ñëåäóþùàÿ âåðøèíà çà áëèæíåé ãðàíèöåé
|
|
8311 {
|
|
8312 //t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ)
|
|
8313 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x);
|
|
8314 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0;
|
|
8315 array_507D30[out_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t;
|
|
8316 array_507D30[out_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t;
|
|
8317 array_507D30[out_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t;
|
|
8318 array_507D30[out_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t;
|
|
8319 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0;
|
|
8320 }
|
|
8321 else// òåêóùàÿ âåðøèíà çà áëèæíåé ãðàíèöåé
|
|
8322 {
|
|
8323 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x);
|
|
8324 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0;
|
|
8325 array_507D30[out_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t;
|
|
8326 array_507D30[out_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t;
|
|
8327 array_507D30[out_num_vertices].u = array_50AC10[i].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t;
|
|
8328 array_507D30[out_num_vertices].v = array_50AC10[i].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t;
|
|
8329 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0;
|
|
8330 }
|
|
8331 //array_507D30[out_num_vertices]._rhw = 0x3E000000u;
|
|
8332 ++out_num_vertices;
|
|
8333 }
|
|
8334 if ( !next_vertices_flag )
|
|
8335 {
|
|
8336 memcpy(&array_507D30[out_num_vertices], &array_50AC10[i + 1], sizeof(array_50AC10[i + 1]));
|
|
8337 out_num_vertices++;
|
|
8338 }
|
|
8339 current_vertices_flag = next_vertices_flag;
|
|
8340 }
|
|
8341 return out_num_vertices >= 3 ? out_num_vertices : 0;
|
|
8342 }
|
|
8343
|
|
8344 //----- (00424EE0) --------------------------------------------------------
|
|
8345 int ODM_FarClip(unsigned int uNumVertices)
|
|
8346 {
|
|
8347 bool current_vertices_flag; // [sp+Ch] [bp-28h]@6
|
|
8348 bool next_vertices_flag; // edi@1
|
|
8349 double t; // st6@10
|
|
8350 signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1
|
|
8351 bool bFound;
|
|
8352 //Äîï èíôî "Ïðîãðàììèðîâàíèå òð¸õìåðíûõ èãð äëÿ windows" Ëàìîò ñòð 910
|
|
8353
|
|
8354 bFound = false;
|
|
8355
|
|
8356 memcpy(&array_50AC10[uNumVertices], &array_50AC10[0], sizeof(array_50AC10[uNumVertices]));
|
|
8357 depth_num_vertices = 0;
|
|
8358 current_vertices_flag = false;
|
|
8359 if ( array_50AC10[0].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist )
|
|
8360 current_vertices_flag = true;//íàñòîÿùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè
|
|
8361 if ( (signed int)uNumVertices <= 0 )
|
|
8362 return 0;
|
|
8363 for (uint i = 0; i < uNumVertices; ++i)// åñòü ëè ïîãðàíè÷íûå âåðøèíû
|
|
8364 {
|
|
8365 if ( array_50AC10[i].vWorldViewPosition.x < pODMRenderParams->shading_dist_mist )
|
|
8366 {
|
|
8367 bFound = true;
|
|
8368 break;
|
|
8369 }
|
|
8370 }
|
|
8371 if ( !bFound )
|
|
8372 return 0;
|
|
8373 //check for far clip plane(ïðîâåðêà ïî äàëüíåé ãðàíèöå)
|
|
8374 //
|
|
8375 // v3.__________________. v0
|
|
8376 // | |
|
|
8377 // | |
|
|
8378 // | |
|
|
8379 // ----------------------- 8192.0(far_clip - 0x2000)
|
|
8380 // | |
|
|
8381 // .__________________.
|
|
8382 // v2 v1
|
|
8383
|
|
8384 for ( uint i = 0; i < uNumVertices; ++i )
|
|
8385 {
|
|
8386 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist;
|
|
8387 if ( current_vertices_flag ^ next_vertices_flag )//îäíà èç ãðàíåé çà ãðàíèöåé âèäèìîñòè
|
|
8388 {
|
|
8389 if ( next_vertices_flag )//ñëåäóþùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè(íàñòîÿùàÿ âåðøèíà ìåíüøå ãðàíèöû âèäèìîñòè) - v3
|
|
8390 {
|
|
8391 //t = far_clip - v2.x / v3.x - v2.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ)
|
|
8392 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x);
|
|
8393 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist;
|
|
8394 //New_y = v2.y + (v3.y - v2.y)*t
|
|
8395 array_507D30[depth_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t;
|
|
8396 //New_z = v2.z + (v3.z - v2.z)*t
|
|
8397 array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t;
|
|
8398 array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t;
|
|
8399 array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t;
|
|
8400 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist;
|
|
8401 }
|
|
8402 else//íàñòîÿùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè(ñëåäóþùàÿ âåðøèíà ìåíüøå ãðàíèöû âèäèìîñòè) - v0
|
|
8403 {
|
|
8404 //t = far_clip - v1.x / v0.x - v1.x
|
|
8405 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x);
|
|
8406 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist;
|
|
8407 //New_y = (v0.y - v1.y)*t + v1.y
|
|
8408 array_507D30[depth_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t;
|
|
8409 //New_z = (v0.z - v1.z)*t + v1.z
|
|
8410 array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t;
|
|
8411 array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t;
|
|
8412 array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t;
|
|
8413 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist;
|
|
8414 }
|
|
8415 ++depth_num_vertices;
|
|
8416 }
|
|
8417 if ( !next_vertices_flag )//îáà â ãðàíèöå âèäèìîñòè
|
|
8418 {
|
|
8419 memcpy(&array_507D30[depth_num_vertices], &array_50AC10[i + 1], sizeof(array_507D30[depth_num_vertices]));
|
|
8420 depth_num_vertices++;
|
|
8421 }
|
|
8422 current_vertices_flag = next_vertices_flag;
|
|
8423 }
|
|
8424 return depth_num_vertices >= 3 ? depth_num_vertices : 0;
|
|
8425 }
|
|
8426
|
|
8427 //----- (0047840D) --------------------------------------------------------
|
|
8428 void Render::DrawBuildingsD3D()
|
|
8429 {
|
|
8430 int v9; // ecx@8
|
|
8431 Texture *pFaceTexture; // eax@10
|
|
8432 unsigned int v16; // edi@22
|
|
8433 int v27; // eax@57
|
|
8434 // int vertex_id; // eax@58
|
|
8435 unsigned int v34; // eax@80
|
|
8436 int v40; // [sp-4h] [bp-5Ch]@2
|
|
8437 int v49; // [sp+2Ch] [bp-2Ch]@10
|
|
8438 int v50; // [sp+30h] [bp-28h]@34
|
|
8439 int v51; // [sp+34h] [bp-24h]@35
|
|
8440 int v52; // [sp+38h] [bp-20h]@36
|
|
8441 int v53; // [sp+3Ch] [bp-1Ch]@8
|
|
8442 int uNumVertices; // [sp+4Ch] [bp-Ch]@34
|
|
8443 int unused; // [sp+50h] [bp-8h]@3
|
|
8444
|
|
8445 if ( !pRenderD3D )
|
|
8446 {
|
|
8447 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0);
|
|
8448 }
|
|
8449
|
|
8450 unused = 0;
|
|
8451 if ( (signed int)pOutdoor->uNumBModels > 0 )
|
|
8452 {
|
|
8453 for ( uint model_id = 0; model_id < (unsigned int)pOutdoor->uNumBModels; model_id++ )
|
|
8454 {
|
|
8455 if ( IsBModelVisible(model_id, &unused) )
|
|
8456 {
|
|
8457 pOutdoor->pBModels[model_id].field_40 |= 1;
|
|
8458 if ( pOutdoor->pBModels[model_id].uNumFaces > 0 )
|
|
8459 {
|
|
8460 for ( int face_id = 0; face_id < pOutdoor->pBModels[model_id].uNumFaces; face_id++ )
|
|
8461 {
|
|
8462 if (!pOutdoor->pBModels[model_id].pFaces[face_id].Invisible())
|
|
8463 {
|
|
8464 v53 = 0;
|
|
8465 array_77EC08[pODMRenderParams->uNumPolygons].flags = 0;
|
|
8466 array_77EC08[pODMRenderParams->uNumPolygons].field_32 = 0;
|
|
8467 v9 = pOutdoor->pBModels[model_id].pFaces[face_id].uTextureID;
|
|
8468 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_TEXTURE_FRAME)
|
|
8469 v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed);
|
|
8470 pFaceTexture = pBitmaps_LOD->GetTexture(v9);
|
|
8471 array_77EC08[pODMRenderParams->uNumPolygons].pTexture = pFaceTexture;
|
|
8472 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLUID)
|
|
8473 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 2;
|
|
8474 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_INDOOR_SKY )
|
|
8475 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4;
|
|
8476 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLOW_DIAGONAL )
|
|
8477 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4;
|
|
8478 else
|
|
8479 {
|
|
8480 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLOW_VERTICAL )
|
|
8481 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 8;
|
|
8482 }
|
|
8483 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLOW_HORIZONTAL)
|
|
8484 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 0x2000;
|
|
8485 else
|
|
8486 {
|
|
8487 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_DONT_CACHE_TEXTURE)
|
|
8488 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 0x10;
|
|
8489 }
|
|
8490 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaU;
|
|
8491 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaV;
|
|
8492 v16 = GetTickCount() >> 4;
|
|
8493 if ( pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z && abs(pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >= 59082 )
|
|
8494 {
|
|
8495 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 )
|
|
8496 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1;
|
|
8497 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 )
|
|
8498 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1;
|
|
8499 }
|
|
8500 else
|
|
8501 {
|
|
8502 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 )
|
|
8503 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1;
|
|
8504 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 )
|
|
8505 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1;
|
|
8506 }
|
|
8507 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x10 )
|
|
8508 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1;
|
|
8509 else
|
|
8510 {
|
|
8511 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x20 )
|
|
8512 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1;
|
|
8513 }
|
|
8514 v50 = 0;
|
|
8515 v49 = 0;
|
|
8516 uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices;
|
|
8517 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices > 0 )
|
|
8518 {
|
|
8519 for ( uint vertex_id = 1; vertex_id <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; vertex_id++ )
|
|
8520 {
|
|
8521 array_73D150[vertex_id - 1].vWorldPosition.x = pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[vertex_id - 1]].x;
|
|
8522 array_73D150[vertex_id - 1].vWorldPosition.y = pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[vertex_id - 1]].y;
|
|
8523 array_73D150[vertex_id - 1].vWorldPosition.z = pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[vertex_id - 1]].z;
|
|
8524 array_73D150[vertex_id - 1].u = (array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU + (signed __int16)pOutdoor->pBModels[model_id].pFaces[face_id].pTextureUIDs[vertex_id - 1]) * (1.0 / (double)pFaceTexture->uTextureWidth);
|
|
8525 array_73D150[vertex_id - 1].v = (array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV + (signed __int16)pOutdoor->pBModels[model_id].pFaces[face_id].pTextureVIDs[vertex_id - 1]) * (1.0 / (double)pFaceTexture->uTextureHeight);
|
|
8526 }
|
|
8527 for ( uint i = 1; i <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; i++ )
|
|
8528 {
|
|
8529 if ( pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[0]].z == array_73D150[i - 1].vWorldPosition.z )
|
|
8530 ++v53;
|
|
8531 pGame->pIndoorCameraD3D->ViewTransform(&array_73D150[i - 1], 1);
|
|
8532 if ( array_73D150[i - 1].vWorldViewPosition.x < 8.0 || array_73D150[i - 1].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist )
|
|
8533 {
|
|
8534 if ( array_73D150[i - 1].vWorldViewPosition.x >= 8.0 )
|
|
8535 v49 = 1;
|
|
8536 else
|
|
8537 v50 = 1;
|
|
8538 }
|
|
8539 else
|
|
8540 pGame->pIndoorCameraD3D->Project(&array_73D150[i - 1], 1, 0);
|
|
8541 }
|
|
8542 }
|
|
8543 if ( v53 == pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices )
|
|
8544 LOBYTE(array_77EC08[pODMRenderParams->uNumPolygons].field_32) |= 1;
|
|
8545 array_77EC08[pODMRenderParams->uNumPolygons].pODMFace = &pOutdoor->pBModels[model_id].pFaces[face_id];
|
|
8546 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices;
|
|
8547 array_77EC08[pODMRenderParams->uNumPolygons].field_59 = 5;
|
|
8548 v51 = fixpoint_mul(-pOutdoor->vSunlight.x, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.x);
|
|
8549 v53 = fixpoint_mul(-pOutdoor->vSunlight.y, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.y);
|
|
8550 v52 = fixpoint_mul(-pOutdoor->vSunlight.z, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z);
|
|
8551 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 20 - fixpoint_mul(20, v51 + v53 + v52);
|
|
8552 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level < 0 )
|
|
8553 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 0;
|
|
8554 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level > 31 )
|
|
8555 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 31;
|
|
8556 if ( pODMRenderParams->uNumPolygons >= 1999 + 5000)
|
|
8557 return;
|
|
8558 if ( ODMFace::IsBackfaceNotCulled(array_73D150, &array_77EC08[pODMRenderParams->uNumPolygons]) )
|
|
8559 {
|
|
8560 pOutdoor->pBModels[model_id].pFaces[face_id].bVisible = 1;
|
|
8561 array_77EC08[pODMRenderParams->uNumPolygons].uBModelFaceID = face_id;
|
|
8562 array_77EC08[pODMRenderParams->uNumPolygons].uBModelID = model_id;
|
|
8563 v27 = 8 * (face_id | (model_id << 6));
|
|
8564 LOBYTE(v27) = v27 | 6;
|
|
8565 array_77EC08[pODMRenderParams->uNumPolygons].field_50 = v27;
|
|
8566 for ( int vertex_id = 0; vertex_id < pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; ++vertex_id)
|
|
8567 {
|
|
8568 memcpy(&array_50AC10[vertex_id], &array_73D150[vertex_id], sizeof(array_50AC10[vertex_id]));
|
|
8569 array_50AC10[vertex_id]._rhw = 1.0 / (array_73D150[vertex_id].vWorldViewPosition.x + 0.0000001);
|
|
8570 }
|
|
8571 static stru154 static_RenderBuildingsD3D_stru_73C834;
|
|
8572 /*static bool __init_flag = false;
|
|
8573 if (!__init_flag)
|
|
8574 {
|
|
8575 __init_flag = true;
|
|
8576 static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u;
|
|
8577 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834);
|
|
8578 atexit(loc_4789D4);
|
|
8579 }*/
|
|
8580
|
|
8581 v40 = (int)&pOutdoor->pBModels[model_id].pFaces[face_id];
|
|
8582 pGame->pLightmapBuilder->ApplyLights_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]);
|
|
8583 pDecalBuilder->ApplyDecals_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]);
|
|
8584 pGame->pLightmapBuilder->std__vector_000004_size = 0;
|
|
8585 int v31 = 0;
|
|
8586 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
|
|
8587 {
|
|
8588 v31 = v50 ? 3 : v49 != 0 ? 5 : 0;
|
|
8589 static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(&pOutdoor->pBModels[model_id].pFaces[face_id], &pOutdoor->pBModels[model_id].pVertices);
|
|
8590 if ( pDecalBuilder->uNumDecals > 0 )
|
|
8591 {
|
|
8592 v40 = -1;
|
|
8593 pDecalBuilder->ApplyDecals(31 - array_77EC08[pODMRenderParams->uNumPolygons].dimming_level, 2, &static_RenderBuildingsD3D_stru_73C834,
|
|
8594 pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices, array_50AC10, 0, (char)v31, -1);
|
|
8595 }
|
|
8596 }
|
|
8597 if ( stru_F8AD28.uNumLightsApplied > 0 )
|
|
8598 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, array_50AC10, 0, (char)v31);
|
|
8599 if ( v50 )
|
|
8600 {
|
|
8601 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_NearClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices);
|
|
8602 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices;
|
|
8603 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices);
|
|
8604 }
|
|
8605 if ( v49 )
|
|
8606 {
|
|
8607 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_FarClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices);
|
|
8608 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices;
|
|
8609 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices);
|
|
8610 }
|
|
8611 if ( uNumVertices )
|
|
8612 {
|
|
8613 if ( array_77EC08[pODMRenderParams->uNumPolygons].flags & 2 )
|
|
8614 {
|
|
8615 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x3C )
|
|
8616 v34 = pRenderer->pHDWaterBitmapIDs[0];
|
|
8617 else
|
|
8618 v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
|
|
8619 v40 = (int)pBitmaps_LOD->pHardwareTextures[v34];
|
|
8620 }
|
|
8621 else
|
|
8622 v40 = (int)pBitmaps_LOD->pHardwareTextures[v9];
|
|
8623 pRenderer->DrawPolygon(uNumVertices, &array_77EC08[pODMRenderParams->uNumPolygons], &pOutdoor->pBModels[model_id].pFaces[face_id], (IDirect3DTexture2 *)v40);
|
|
8624 }
|
|
8625 }
|
|
8626 }
|
|
8627 }
|
|
8628 }
|
|
8629 }
|
|
8630 }
|
|
8631 }
|
|
8632 return;
|
|
8633 }
|
|
8634 //----- (00479543) --------------------------------------------------------
|
|
8635 void Render::DrawOutdoorSkyD3D()
|
|
8636 {
|
|
8637 int v9; // eax@4
|
|
8638 int v10; // ebx@4
|
|
8639 int v13; // edi@6
|
|
8640 int v14; // ecx@6
|
|
8641 int v15; // eax@8
|
|
8642 int v16; // eax@12
|
|
8643 signed __int64 v17; // qtt@13
|
|
8644 signed int v18; // ecx@13
|
|
8645 struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1
|
|
8646 int v30; // [sp+134h] [bp-30h]@1
|
|
8647 int v32; // [sp+13Ch] [bp-28h]@6
|
|
8648 int v33; // [sp+140h] [bp-24h]@2
|
|
8649 signed __int64 v34; // [sp+144h] [bp-20h]@1
|
|
8650 int v35; // [sp+148h] [bp-1Ch]@4
|
|
8651 int v36; // [sp+14Ch] [bp-18h]@2
|
|
8652 int v37; // [sp+154h] [bp-10h]@8
|
|
8653 int v38; // [sp+158h] [bp-Ch]@1
|
|
8654 int v39; // [sp+15Ch] [bp-8h]@4
|
|
8655
|
|
8656 v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z)
|
|
8657 / ((double)pODMRenderParams->int_fov_rad + 8192.0)
|
|
8658 + (double)(pViewport->uScreenCenterY));
|
|
8659 v34 = cos((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;//(double)pODMRenderParams->shading_dist_mist, 8192
|
|
8660 v38 = (signed __int64)((double)(pViewport->uScreenCenterY)
|
|
8661 - (double)pODMRenderParams->int_fov_rad
|
|
8662 / (v34 + 0.0000001)
|
|
8663 * (sin((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064)
|
|
8664 * (double)-0x2000//(double)pODMRenderParams->shading_dist_mist
|
|
8665 - (double)pGame->pIndoorCameraD3D->vPartyPos.z));
|
|
8666 pSkyPolygon.Create_48607B(&stru_8019C8);//çàïîëíÿåòñÿ ptr_38
|
|
8667 pSkyPolygon.ptr_38->_48694B_frustum_sky();
|
|
8668 pSkyPolygon.uTileBitmapID = pOutdoor->sSky_TextureID;//179(original 166)
|
|
8669 pSkyPolygon.pTexture = (Texture *)(SLOWORD(pOutdoor->sSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->sSky_TextureID)] : 0);
|
|
8670 if ( pSkyPolygon.pTexture )
|
|
8671 {
|
|
8672 pSkyPolygon.dimming_level = 0;
|
|
8673 pSkyPolygon.uNumVertices = 4;
|
|
8674 //centering(öåíòðóåì)-----------------------------------------------------------------
|
|
8675 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
|
|
8676 pSkyPolygon.v_18.y = 0;
|
|
8677 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16);
|
|
8678
|
|
8679 //sky wiew position(ïîëîæåíèå íåáà íà ýêðàíå)------------------------------------------
|
|
8680 // X
|
|
8681 // 0._____________________________.3
|
|
8682 // |8,8 468,8 |
|
|
8683 // | |
|
|
8684 // | |
|
|
8685 // Y| |
|
|
8686 // | |
|
|
8687 // |8,351 468,351 |
|
|
8688 // 1._____________________________.2
|
|
8689 //
|
|
8690 array_50AC10[0].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8
|
|
8691 array_50AC10[0].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8
|
|
8692
|
|
8693 array_50AC10[1].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8
|
|
8694 array_50AC10[1].vWorldViewProjY = (double)v38;//247
|
|
8695
|
|
8696 array_50AC10[2].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468
|
|
8697 array_50AC10[2].vWorldViewProjY = (double)v38;//247
|
|
8698
|
|
8699 array_50AC10[3].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468
|
|
8700 array_50AC10[3].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8
|
|
8701
|
|
8702 pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168
|
|
8703 pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168
|
|
8704
|
|
8705 pSkyPolygon.field_24 = 0x2000000u;//maybe attributes
|
|
8706 v33 = 65536 / (signed int)(signed __int64)(((double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2) / tan(0.6457717418670654) + 0.5);
|
|
8707 for ( uint i = 0; i < pSkyPolygon.uNumVertices; ++i )
|
|
8708 {
|
|
8709 //rotate skydome(âðàùåíèå êóïîëà íåáà)--------------------------------------
|
|
8710 //  èãðå ïðèíÿòà ñâîÿ ñèñòåìà èçìåðåíèÿ óãëîâ. Ïîëíûé óãîë (180). Çíà÷åíèþ óãëà 0 ñîîòâåòñòâóåò
|
|
8711 // íàïðàâëåíèå íà ñåâåð è/èëè þã (ëèáî íà âîñòîê è/èëè çàïàä), çíà÷åíèþ 65536 åäåíèöàì(0õ10000) ñîîòâåòñòâóåò óãîë 90.
|
|
8712 // äâå ïåðåìåííûå õðàíÿò äàííûå ïî óãëó îáçîðà. field_14 ïî çàïàäó è âîñòîêó. field_20 ïî þãó è ñåâåðó
|
|
8713 // îò -25080 äî 25080
|
|
8714 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5)));
|
|
8715 v35 = v39 + pSkyPolygon.ptr_38->angle_from_north;
|
|
8716
|
|
8717 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.f)));
|
|
8718 v36 = v39 + pSkyPolygon.ptr_38->angle_from_east;
|
|
8719
|
|
8720 v9 = fixpoint_mul(pSkyPolygon.v_18.z, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5)));
|
|
8721 v10 = pSkyPolygon.v_18.x + v9;
|
|
8722 if ( v10 > 0 )
|
|
8723 v10 = 0;
|
|
8724 v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX);
|
|
8725 v34 = -pSkyPolygon.field_24;
|
|
8726 v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0;
|
|
8727 v14 = v33 * (v30 - v32);
|
|
8728 while ( 1 )
|
|
8729 {
|
|
8730 if ( v10 )
|
|
8731 {
|
|
8732 v37 = abs((int)v34 >> 14);
|
|
8733 v15 = abs(v10);
|
|
8734 if ( v37 <= v15 || v32 <= (signed int)pViewport->uViewportTL_Y )
|
|
8735 {
|
|
8736 if ( v10 <= 0 )
|
|
8737 break;
|
|
8738 }
|
|
8739 }
|
|
8740 v16 = fixpoint_mul(pSkyPolygon.v_18.z, v14);
|
|
8741 --v32;
|
|
8742 v14 += v33;
|
|
8743 v10 = pSkyPolygon.v_18.x + v16;
|
|
8744 }
|
|
8745 LODWORD(v17) = LODWORD(v34) << 16;
|
|
8746 HIDWORD(v17) = v34 >> 16;
|
|
8747 v18 = v17 / v10;
|
|
8748 if ( v18 < 0 )
|
|
8749 v18 = pODMRenderParams->shading_dist_mist;
|
|
8750 v37 = v35 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v13);
|
|
8751 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v37, v18) >> 3);
|
|
8752 array_50AC10[i].u = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureWidth * 65536.0);
|
|
8753
|
|
8754 v36 = v36 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v13);
|
|
8755 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v36, v18) >> 3);
|
|
8756 array_50AC10[i].v = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureHeight * 65536.0);
|
|
8757
|
|
8758 array_50AC10[i].vWorldViewPosition.x = (double)0x2000;//pODMRenderParams->shading_dist_mist 8192
|
|
8759 array_50AC10[i]._rhw = 1.0 / (double)(v18 >> 16);
|
|
8760 }
|
|
8761 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
|
|
8762 array_50AC10[0].vWorldViewProjY = (double)v10;
|
|
8763 array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0;
|
|
8764 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0;
|
|
8765 array_50AC10[3].vWorldViewProjY = (double)v10;
|
|
8766 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
|
|
8767 return;
|
|
8768 }
|
|
8769 }
|
|
8770 //----- (004226C2) --------------------------------------------------------
|
|
8771 bool PauseGameDrawing()
|
|
8772 {
|
|
8773 if ( pCurrentScreen != SCREEN_GAME
|
|
8774 && pCurrentScreen != SCREEN_NPC_DIALOGUE
|
|
8775 && pCurrentScreen != SCREEN_CHANGE_LOCATION )
|
|
8776 {
|
|
8777 if (pCurrentScreen == SCREEN_INPUT_BLV)
|
|
8778 return pMovie_Track;//pSmackerMovie != 0;
|
|
8779 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG )
|
|
8780 return true;
|
|
8781 }
|
|
8782 return false;
|
|
8783 }
|
|
8784
|
|
8785
|
|
8786 //----- (0045E03A) --------------------------------------------------------
|
|
8787 unsigned short *Render::MakeScreenshot(signed int width, signed int height)
|
|
8788 {
|
|
8789 unsigned __int16 *for_pixels; // ebx@1
|
|
8790 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6
|
|
8791 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1
|
|
8792 float interval_x; // [sp+84h] [bp-20h]@1
|
|
8793 float interval_y; // [sp+8Ch] [bp-18h]@1
|
|
8794
|
|
8795 interval_x = game_viewport_width / (double)width;
|
|
8796 interval_y = game_viewport_height / (double)height;
|
|
8797
|
|
8798 pPixels = (unsigned __int16 *)malloc(2 * height * width);
|
|
8799 memset(pPixels, 0 , 2 * height * width);
|
|
8800
|
|
8801 for_pixels = pPixels;
|
|
8802
|
|
8803 BeginSceneD3D();
|
|
8804
|
|
8805 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
8806 pIndoor->Draw();
|
|
8807 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
8808 pOutdoor->Draw();
|
|
8809 DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
|
|
8810 memset(&Dst, 0, sizeof(Dst));
|
|
8811 Dst.dwSize = sizeof(Dst);
|
|
8812
|
|
8813 if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) )
|
|
8814 {
|
|
8815 if (uCurrentlyLoadedLevelType == LEVEL_null)
|
|
8816 memset(&for_pixels, 0, sizeof(for_pixels));
|
|
8817 else
|
|
8818 {
|
|
8819 for (uint y = 0; y < (unsigned int)height; ++y)
|
|
8820 {
|
|
8821 for (uint x = 0; x < (unsigned int)width; ++x)
|
|
8822 {
|
|
8823 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32)
|
|
8824 {
|
|
8825 unsigned __int32 *p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * (Dst.lPitch >> 2);
|
|
8826 *for_pixels = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
|
|
8827 }
|
|
8828 else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16)
|
|
8829 {
|
|
8830 unsigned __int16 * p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch;
|
|
8831 *for_pixels = *p;
|
|
8832 }
|
|
8833 else
|
|
8834 assert(false);
|
|
8835 ++for_pixels;
|
|
8836 }
|
|
8837 }
|
|
8838 }
|
|
8839 ErrD3D(pBackBuffer4->Unlock(NULL));
|
|
8840 }
|
|
8841 return pPixels;
|
|
8842 }
|
|
8843 //----- (0045E26C) --------------------------------------------------------
|
|
8844 void Render::SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height)
|
|
8845 {
|
|
8846 auto pixels = MakeScreenshot(width, height);
|
|
8847 SavePCXImage(pFilename, pixels, width, height);
|
|
8848 free(pixels);
|
|
8849 }
|
|
8850
|
|
8851 void Render::PackScreenshot(unsigned int width, unsigned int height, void *data, unsigned int data_size, unsigned int *out_screenshot_size)
|
|
8852 {
|
|
8853 auto pixels = MakeScreenshot(150, 112);
|
|
8854 PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size);
|
|
8855 free(pixels);
|
|
8856 }
|
|
8857
|
|
8858
|
|
8859 //----- (0046A7C8) --------------------------------------------------------
|
|
8860 int Render::_46À6ÀÑ_GetActorsInViewport(int pDepth)
|
|
8861 {
|
|
8862 unsigned int v3; // eax@2 ïðèìåíÿåòñÿ â çàêëå Æàð ïå÷è äëÿ ïîäñ÷¸òà êîë-âà ìîíñòðîâ âèäèìûõ ãðóïïå è çàïîëíåíèÿ ìàññèâà id âèäèìûõ ìîíñòðîâ
|
|
8863 unsigned int v5; // eax@2
|
|
8864 unsigned int v6; // eax@4
|
|
8865 unsigned int v12; // [sp+10h] [bp-14h]@1
|
|
8866 int mon_num; // [sp+1Ch] [bp-8h]@1
|
|
8867 unsigned int a1a; // [sp+20h] [bp-4h]@1
|
|
8868
|
|
8869 mon_num = 0;
|
|
8870 v12 = GetBillboardDrawListSize();
|
|
8871 if ( (signed int)GetBillboardDrawListSize() > 0 )
|
|
8872 {
|
|
8873 for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a )
|
|
8874 {
|
|
8875 v3 = GetParentBillboardID(a1a);
|
|
8876 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid;
|
|
8877 if ( PID_TYPE(v5) == OBJECT_Actor)
|
|
8878 {
|
|
8879 if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(pDepth << 16) )
|
|
8880 {
|
|
8881 v6 = PID_ID(v5);
|
|
8882 if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed
|
|
8883 && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned )
|
|
8884 {
|
|
8885 if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)pDepth, a1a) )
|
|
8886 {
|
|
8887 if ( mon_num < 100 )
|
|
8888 {
|
|
8889 _50BF30_actors_in_viewport_ids[mon_num] = v6;
|
|
8890 mon_num++;
|
|
8891 }
|
|
8892 }
|
|
8893 }
|
|
8894 }
|
|
8895 }
|
|
8896 }
|
|
8897 }
|
|
8898 return mon_num;
|
|
8899 }
|
|
8900
|
|
8901
|
|
8902
|
|
8903
|
|
8904 void Render::BeginLightmaps()
|
|
8905 {
|
|
8906 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
|
|
8907
|
|
8908 if (bUsingSpecular)
|
|
8909 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE);
|
|
8910
|
|
8911 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
8912 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
8913 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03")));
|
|
8914 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8915 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
|
|
8916 }
|
|
8917
|
|
8918 void Render::EndLightmaps()
|
|
8919 {
|
|
8920 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8921 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
8922 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
8923 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
8924
|
|
8925 if (bUsingSpecular)
|
|
8926 {
|
|
8927 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
8928 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor));
|
|
8929 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
|
|
8930 }
|
|
8931 }
|
|
8932
|
|
8933
|
|
8934 void Render::BeginLightmaps2()
|
|
8935 {
|
|
8936 if (bUsingSpecular)
|
|
8937 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
8938
|
|
8939 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
8940 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
8941 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
8942 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
8943
|
|
8944 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03")));
|
|
8945
|
|
8946 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8947 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
|
|
8948 }
|
|
8949
|
|
8950
|
|
8951 void Render::EndLightmaps2()
|
|
8952 {
|
|
8953 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8954 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
8955 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
8956 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
8957 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
8958 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
|
|
8959
|
|
8960 if (bUsingSpecular)
|
|
8961 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
8962 }
|
|
8963
|
|
8964
|
|
8965
|
|
8966 //----- (00437C96) --------------------------------------------------------
|
|
8967 void Render::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff)
|
|
8968 {
|
|
8969 double v6; // st7@2
|
|
8970 //IDirect3DDevice3 *v7; // eax@2
|
|
8971 // HRESULT v8; // eax@2
|
|
8972 std::string v9; // [sp-18h] [bp-60h]@3
|
|
8973 // const char *v10; // [sp-Ch] [bp-54h]@2
|
|
8974 // const char *v11; // [sp-8h] [bp-50h]@2
|
|
8975 // int v12; // [sp-4h] [bp-4Ch]@2
|
|
8976 RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2
|
|
8977
|
|
8978 //if ( pRenderer->pRenderD3D )
|
|
8979 {
|
|
8980 v6 = 0.001 - z_stuff;
|
|
8981 memcpy(v13, pLineBegin, 0x20u);
|
|
8982 memcpy(&v13[1], pLineEnd, sizeof(v13[1]));
|
|
8983 v13[0].pos.z = v6;
|
|
8984 v13[1].pos.z = v6;
|
|
8985 v13[0].diffuse = sDiffuseBegin;
|
|
8986 v13[1].diffuse = sDiffuseEnd;
|
|
8987 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
|
8988 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
|
|
8989 D3DPT_LINELIST,
|
|
8990 452,
|
|
8991 v13,
|
|
8992 2,
|
|
8993 16));
|
|
8994 }
|
|
8995 }
|
|
8996
|
|
8997
|
|
8998 void Render::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices)
|
|
8999 {
|
|
9000 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
|
9001 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST,
|
|
9002 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
9003 (void *)vertices,
|
|
9004 num_vertices,
|
|
9005 D3DDP_DONOTLIGHT));
|
|
9006 }
|
|
9007
|
|
9008
|
|
9009 void Render::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices)
|
|
9010 {
|
|
9011 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
|
|
9012 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false));
|
|
9013 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
9014 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA));
|
|
9015 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA));
|
|
9016
|
|
9017 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
|
9018 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
9019 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
9020 (void *)vertices,
|
|
9021 num_vertices,
|
|
9022 28));
|
|
9023
|
|
9024 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
9025 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
9026 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
9027 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE));
|
|
9028 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
9029 }
|
|
9030
|
|
9031
|
|
9032 void Render::BeginDecals()
|
|
9033 {
|
|
9034 // code chunk from 0049C304
|
|
9035 if (bUsingSpecular)
|
|
9036 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
9037 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
|
|
9038
|
|
9039 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
9040 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
9041 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
9042 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
9043 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
|
|
9044 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
9045
|
|
9046 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04")));
|
|
9047 }
|
|
9048
|
|
9049
|
|
9050 void Render::EndDecals()
|
|
9051 {
|
|
9052 // code chunk from 0049C304
|
|
9053 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
|
|
9054 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
9055 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
9056 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
9057 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
9058
|
|
9059 if (bUsingSpecular)
|
|
9060 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
9061 }
|
|
9062
|
|
9063
|
|
9064
|
|
9065 //----- (0049C095) --------------------------------------------------------
|
|
9066 void Render::DrawDecal(Decal *pDecal, float z_bias)
|
|
9067 {
|
|
9068 signed int v21; // [sp+Ch] [bp-864h]@15
|
|
9069 RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6
|
|
9070
|
|
9071 if (pDecal->uNumVertices < 3)
|
|
9072 {
|
|
9073 Log::Warning(L"Decal has < 3 vertices");
|
|
9074 return;
|
|
9075 }
|
|
9076
|
|
9077 float color_mult;
|
|
9078 if ( pDecal->field_C1C & 1 )
|
|
9079 color_mult = 1.0;
|
|
9080 else
|
|
9081 color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time();
|
|
9082
|
|
9083 for (uint i = 0; i < (unsigned int)pDecal->uNumVertices; ++i)
|
|
9084 {
|
|
9085 uint uTint = Render::GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr);
|
|
9086
|
|
9087 uint uTintR = (uTint >> 16) & 0xFF,
|
|
9088 uTintG = (uTint >> 8) & 0xFF,
|
|
9089 uTintB = uTint & 0xFF;
|
|
9090
|
|
9091 uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF,
|
|
9092 uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF,
|
|
9093 uDecalColorMultB = pDecal->uColorMultiplier & 0xFF;
|
|
9094
|
|
9095 uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f),
|
|
9096 uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f),
|
|
9097 uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f);
|
|
9098
|
|
9099
|
|
9100 float v15;
|
|
9101 if (fabs(z_bias) < 1e-5)
|
|
9102 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0);
|
|
9103 else
|
|
9104 {
|
|
9105 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias;
|
|
9106 if (v15 < 0.000099999997)
|
|
9107 v15 = 0.000099999997;
|
|
9108 }
|
|
9109
|
|
9110 pVerticesD3D[i].pos.z = v15;
|
|
9111
|
|
9112 pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX;
|
|
9113 pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY;
|
|
9114 pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u;
|
|
9115 pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v;
|
|
9116 pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB;
|
|
9117 pVerticesD3D[i].specular = 0;
|
|
9118 pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x;
|
|
9119 }
|
|
9120
|
|
9121 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
9122 v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS;
|
|
9123 else
|
|
9124 v21 = D3DDP_DONOTLIGHT;
|
|
9125
|
|
9126 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
9127 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
9128 pVerticesD3D,
|
|
9129 pDecal->uNumVertices,
|
|
9130 v21));
|
|
9131 }
|
|
9132
|
|
9133
|
|
9134 void Render::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture)
|
|
9135 {
|
|
9136 ErrD3D(pRenderD3D->pDevice->SetTexture(0, texture));
|
|
9137 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
9138 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
9139 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
9140 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
9141 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
|
|
9142 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
9143 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS));
|
|
9144 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
9145 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
9146 (void *)vertices, 4, 28));
|
|
9147 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
9148 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
9149 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
9150 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
9151 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
9152 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS));
|
|
9153 }
|
|
9154
|
|
9155 //----- (00452442) --------------------------------------------------------
|
|
9156 unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4)
|
|
9157 {
|
|
9158 int v4; // ebx@0
|
|
9159 __int16 v5; // ST14_2@1
|
|
9160 __int16 v6; // dx@1
|
|
9161 int v7; // ecx@1
|
|
9162 __int16 v8; // ST10_2@1
|
|
9163 int v9; // edi@1
|
|
9164 unsigned __int16 v10; // dh@1@1
|
|
9165 int v11; // ebx@1
|
|
9166 int v12; // ebx@1
|
|
9167 __int16 a3a; // [sp+1Ch] [bp+8h]@1
|
|
9168
|
|
9169 v5 = a2 >> 2;
|
|
9170 v6 = (unsigned __int16)a4 >> 2;
|
|
9171 v8 = a1 >> 2;
|
|
9172 a3a = (unsigned __int16)a3 >> 2;
|
|
9173 LOWORD(v7) = a3a;
|
|
9174 v9 = v7;
|
|
9175 LOWORD(v4) = ((unsigned __int16)a4 >> 2) & 0xE0;
|
|
9176 LOWORD(v7) = a3a & 0xE0;
|
|
9177 LOWORD(v9) = v9 & 0x1C00;
|
|
9178 v11 = v7 + v4;
|
|
9179 LOWORD(v7) = v5 & 0xE0;
|
|
9180 v12 = v7 + v11;
|
|
9181 LOWORD(v7) = v8 & 0xE0;
|
|
9182 __debugbreak(); // warning C4700: uninitialized local variable 'v10' used
|
|
9183 return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) | (v7 + v12) | ((v8 & 0x1C00)
|
|
9184 + (v5 & 0x1C00)
|
|
9185 + v9
|
|
9186 + (__PAIR__(v10, (unsigned __int16)a4 >> 2) & 0x1C00));
|
|
9187 }
|
|
9188
|
|
9189 //----- (0047C4FC) --------------------------------------------------------
|
|
9190 int __fastcall GetActorTintColor(int max_dimm, int min_dimm, float distance, int a4, RenderBillboard *a5)
|
|
9191 {
|
|
9192 //int v5; // esi@1
|
|
9193 signed int v6; // edx@1
|
|
9194 //signed int result; // eax@2
|
|
9195 int v8; // eax@3
|
|
9196 double v9; // st7@12
|
|
9197 //double v10; // ST0C_8@18
|
|
9198 int v11; // ecx@28
|
|
9199 //signed int v12; // edi@28
|
|
9200 //double v13; // ST0C_8@33
|
|
9201 //double v14; // ST0C_8@34
|
|
9202 double v15; // st7@44
|
|
9203 //double v16; // ST0C_8@44
|
|
9204 //double v17; // ST0C_8@44
|
|
9205 int v18; // ST14_4@44
|
|
9206 //double v19; // ST0C_8@44
|
|
9207 signed int v20; // [sp+10h] [bp-4h]@10
|
|
9208 // float a3a; // [sp+1Ch] [bp+8h]@33
|
|
9209 //float a3b; // [sp+1Ch] [bp+8h]@34
|
|
9210 float a3c; // [sp+1Ch] [bp+8h]@44
|
|
9211 //float a3d; // [sp+1Ch] [bp+8h]@44
|
|
9212 //float a4b; // [sp+20h] [bp+Ch]@18
|
|
9213 //int a4a; // [sp+20h] [bp+Ch]@33
|
|
9214 //float a4c; // [sp+20h] [bp+Ch]@44
|
|
9215 //float a4d; // [sp+20h] [bp+Ch]@44
|
|
9216 int a5a; // [sp+24h] [bp+10h]@44
|
|
9217
|
|
9218 //v5 = a2;
|
|
9219 v6 = 0;
|
|
9220
|
|
9221 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
9222 return 8 * (31 - max_dimm) | ((8 * (31 - max_dimm) | ((31 - max_dimm) << 11)) << 8);
|
|
9223
|
|
9224 if (pParty->armageddon_timer)
|
|
9225 return 0xFFFF0000;
|
|
9226
|
|
9227 v8 = pWeather->bNight;
|
|
9228 if (bUnderwater)
|
|
9229 v8 = 0;
|
|
9230 if (v8)
|
|
9231 {
|
|
9232 v20 = 1;
|
|
9233 if ((signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0)
|
|
9234 v20 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower;
|
|
9235 v9 = (double)v20 * 1024.0;
|
|
9236 if (a4)
|
|
9237 {
|
|
9238 v6 = 216;
|
|
9239 goto LABEL_20;
|
|
9240 }
|
|
9241 if (distance <= v9)
|
|
9242 {
|
|
9243 if (distance > 0.0)
|
|
9244 {
|
|
9245 //a4b = distance * 216.0 / v9;
|
|
9246 //v10 = a4b + 6.7553994e15;
|
|
9247 //v6 = LODWORD(v10);
|
|
9248 v6 = floorf(0.5f + distance * 216.0 / v9);
|
|
9249 if (v6 > 216)
|
|
9250 {
|
|
9251 v6 = 216;
|
|
9252 goto LABEL_20;
|
|
9253 }
|
|
9254 }
|
|
9255 }
|
|
9256 else
|
|
9257 {
|
|
9258 v6 = 216;
|
|
9259 }
|
|
9260 if (distance != 0.0)
|
|
9261 {
|
|
9262 LABEL_20:
|
|
9263 if (a5)
|
|
9264 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3);
|
|
9265 if (v6 > 216)
|
|
9266 v6 = 216;
|
|
9267 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
|
|
9268 }
|
|
9269 //LABEL_19:
|
|
9270 v6 = 216;
|
|
9271 goto LABEL_20;
|
|
9272 }
|
|
9273
|
|
9274
|
|
9275
|
|
9276 if (fabsf(distance) < 1.0e-6f)
|
|
9277 return 0xFFF8F8F8;
|
|
9278
|
|
9279 // dim in measured in 8-steps
|
|
9280 v11 = 8 * (max_dimm - min_dimm);
|
|
9281 //v12 = v11;
|
|
9282 if (v11 >= 0)
|
|
9283 {
|
|
9284 if (v11 > 216)
|
|
9285 v11 = 216;
|
|
9286 }
|
|
9287 else
|
|
9288 v11 = 0;
|
|
9289
|
|
9290 float fog_density_mult = 216.0f;
|
|
9291 if (a4)
|
|
9292 fog_density_mult += distance / (double)pODMRenderParams->shading_dist_shade * 32.0;
|
|
9293
|
|
9294 v6 = v11 + floorf(pOutdoor->fFogDensity * fog_density_mult + 0.5f);
|
|
9295 /*if ( a4 )
|
|
9296 {
|
|
9297 //a3b = pOutdoor->fFogDensity * 216.0;
|
|
9298 //v14 = a3b + 6.7553994e15;
|
|
9299 //a4a = floorf(a3b + 0.5f);//LODWORD(v14);
|
|
9300 }
|
|
9301 else
|
|
9302 {
|
|
9303 //a3a = (distance / (double)pODMRenderParams->shading_dist_shade * 32.0 + 216.0) * pOutdoor->fFogDensity;
|
|
9304 //v13 = a3a + 6.7553994e15;
|
|
9305 //a4a = floorf(a3a + 0.5f);//LODWORD(v13);
|
|
9306 }
|
|
9307 v6 = a4a + v11;*/
|
|
9308 if (a5)
|
|
9309 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3);
|
|
9310 if (v6 > 216)
|
|
9311 v6 = 216;
|
|
9312 if (v6 < v11)
|
|
9313 v6 = v11;
|
|
9314 if (v6 > 8 * pOutdoor->max_terrain_dimming_level)
|
|
9315 v6 = 8 * pOutdoor->max_terrain_dimming_level;
|
|
9316 if (!bUnderwater)
|
|
9317 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
|
|
9318 else
|
|
9319 {
|
|
9320 v15 = (double)(255 - v6) * 0.0039215689;
|
|
9321 a3c = v15;
|
|
9322 //a4c = v15 * 16.0;
|
|
9323 //v16 = a4c + 6.7553994e15;
|
|
9324 a5a = floorf(v15 * 16.0 + 0.5f);//LODWORD(v16);
|
|
9325 //a4d = a3c * 194.0;
|
|
9326 //v17 = a4d + 6.7553994e15;
|
|
9327 v18 = floorf(a3c * 194.0 + 0.5f);//LODWORD(v17);
|
|
9328 //a3d = a3c * 153.0;
|
|
9329 //v19 = a3d + 6.7553994e15;
|
|
9330 return (int)floorf(a3c * 153.0 + 0.5f)/*LODWORD(v19)*/ | ((v18 | (a5a << 8)) << 8);
|
|
9331 }
|
|
9332 }
|
|
9333 // 6BE3C4: using guessed type char bUnderwater;
|
|
9334
|
|
9335 //----- (0043F55F) --------------------------------------------------------
|
|
9336 int __fastcall _43F55F_get_billboard_light_level(RenderBillboard *a1, int uBaseLightLevel)
|
|
9337 {
|
|
9338 signed int v3; // ecx@2
|
|
9339
|
|
9340 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
9341 v3 = pIndoor->pSectors[a1->uIndoorSectorID].uMinAmbientLightLevel;
|
|
9342 else
|
|
9343 {
|
|
9344 if (uBaseLightLevel == -1)
|
|
9345 v3 = a1->dimming_level;
|
|
9346 else
|
|
9347 v3 = uBaseLightLevel;
|
|
9348 }
|
|
9349 return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->world_x, a1->world_y, a1->world_z);
|
|
9350 }
|
|
9351
|
|
9352 //----- (0043F5C8) --------------------------------------------------------
|
|
9353 int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z)
|
|
9354 {
|
|
9355 // int v5; // esi@1
|
|
9356 signed int v6; // edi@1
|
|
9357 int v8; // eax@6
|
|
9358 int v9; // ebx@6
|
|
9359 unsigned int v10; // ecx@6
|
|
9360 unsigned int v11; // edx@9
|
|
9361 unsigned int v12; // edx@11
|
|
9362 signed int v13; // ecx@12
|
|
9363 BLVLightMM7 *v16; // esi@20
|
|
9364 int v17; // ebx@21
|
|
9365 // int v18; // eax@24
|
|
9366 // int v19; // ebx@24
|
|
9367 // unsigned int v20; // ecx@24
|
|
9368 // int v21; // edx@25
|
|
9369 // unsigned int v22; // edx@27
|
|
9370 // unsigned int v23; // edx@29
|
|
9371 signed int v24; // ecx@30
|
|
9372 int v26; // ebx@35
|
|
9373 // int v27; // eax@38
|
|
9374 // int v28; // ebx@38
|
|
9375 // unsigned int v29; // ecx@38
|
|
9376 // int v30; // edx@39
|
|
9377 // unsigned int v31; // edx@41
|
|
9378 // unsigned int v32; // edx@43
|
|
9379 //signed int v33; // ecx@44
|
|
9380 int v37; // [sp+Ch] [bp-18h]@37
|
|
9381 // int v38; // [sp+10h] [bp-14h]@5
|
|
9382 int v39; // [sp+10h] [bp-14h]@23
|
|
9383 int v40; // [sp+10h] [bp-14h]@36
|
|
9384 int v42; // [sp+14h] [bp-10h]@22
|
|
9385 unsigned int v43; // [sp+18h] [bp-Ch]@12
|
|
9386 unsigned int v44; // [sp+18h] [bp-Ch]@30
|
|
9387 unsigned int v45; // [sp+18h] [bp-Ch]@44
|
|
9388
|
|
9389 v6 = uBaseLightLevel;
|
|
9390 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
|
|
9391 {
|
|
9392 MobileLight* p = &pMobileLightsStack->pLights[i];
|
|
9393
|
|
9394 float distX = abs(p->vPosition.x - x);
|
|
9395 if (distX <= p->uRadius)
|
|
9396 {
|
|
9397 float distY = abs(p->vPosition.y - y);
|
|
9398 if (distY <= p->uRadius)
|
|
9399 {
|
|
9400 float distZ = abs(p->vPosition.z - z);
|
|
9401 if (distZ <= p->uRadius)
|
|
9402 {
|
|
9403 v8 = distX;
|
|
9404 v9 = distY;
|
|
9405 v10 = distZ;
|
|
9406 if (distX < distY)
|
|
9407 {
|
|
9408 v8 = distY;
|
|
9409 v9 = distX;
|
|
9410 }
|
|
9411 if (v8 < distZ)
|
|
9412 {
|
|
9413 v11 = v8;
|
|
9414 v8 = distZ;
|
|
9415 v10 = v11;
|
|
9416 }
|
|
9417 if (v9 < (signed int)v10)
|
|
9418 {
|
|
9419 v12 = v10;
|
|
9420 v10 = v9;
|
|
9421 v9 = v12;
|
|
9422 }
|
|
9423 v43 = ((unsigned int)(11 * v9) / 32) + (v10 / 4) + v8;
|
|
9424 v13 = p->uRadius;
|
|
9425 if ((signed int)v43 < v13)
|
|
9426 v6 += ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30;
|
|
9427 }
|
|
9428 }
|
|
9429 }
|
|
9430 }
|
|
9431
|
|
9432 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
9433 {
|
|
9434 BLVSector* pSector = &pIndoor->pSectors[uSectorID];
|
|
9435
|
|
9436 for (uint i = 0; i < pSector->uNumLights; ++i)
|
|
9437 {
|
|
9438 v16 = pIndoor->pLights + pSector->pLights[i];
|
|
9439 if (~v16->uAtributes & 8)
|
|
9440 {
|
|
9441 v17 = abs(v16->vPosition.x - x);
|
|
9442 if (v17 <= v16->uRadius)
|
|
9443 {
|
|
9444 v42 = abs(v16->vPosition.y - y);
|
|
9445 if (v42 <= v16->uRadius)
|
|
9446 {
|
|
9447 v39 = abs(v16->vPosition.z - z);
|
|
9448 if (v39 <= v16->uRadius)
|
|
9449 {
|
|
9450 v44 = int_get_vector_length(v17, v42, v39);
|
|
9451 v24 = v16->uRadius;
|
|
9452 if ((signed int)v44 < v24)
|
|
9453 v6 += ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30;
|
|
9454 }
|
|
9455 }
|
|
9456 }
|
|
9457 }
|
|
9458 }
|
|
9459 }
|
|
9460
|
|
9461 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i)
|
|
9462 {
|
|
9463 //StationaryLight* p = &pStationaryLightsStack->pLights[i];
|
|
9464 v26 = abs(pStationaryLightsStack->pLights[i].vPosition.x - x);
|
|
9465 if (v26 <= pStationaryLightsStack->pLights[i].uRadius)
|
|
9466 {
|
|
9467 v40 = abs(pStationaryLightsStack->pLights[i].vPosition.y - y);
|
|
9468 if (v40 <= pStationaryLightsStack->pLights[i].uRadius)
|
|
9469 {
|
|
9470 v37 = abs(pStationaryLightsStack->pLights[i].vPosition.z - z);
|
|
9471 if (v37 <= pStationaryLightsStack->pLights[i].uRadius)
|
|
9472 {
|
|
9473 v45 = int_get_vector_length(v26, v40, v37);
|
|
9474 //v33 = pStationaryLightsStack->pLights[i].uRadius;
|
|
9475 if ((signed int)v45 < pStationaryLightsStack->pLights[i].uRadius)
|
|
9476 v6 += ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / pStationaryLightsStack->pLights[i].uRadius) >> 16) - 30;
|
|
9477 }
|
|
9478 }
|
|
9479 }
|
|
9480 }
|
|
9481
|
|
9482 if (v6 <= 31)
|
|
9483 {
|
|
9484 if (v6 < 0)
|
|
9485 v6 = 0;
|
|
9486 }
|
|
9487 else
|
|
9488 v6 = 31;
|
|
9489 return v6;
|
|
9490 }
|
|
9491
|
|
9492 //----- (0049D700) --------------------------------------------------------
|
|
9493 unsigned int __fastcall GetMaxMipLevels(unsigned int uDim)
|
|
9494 {
|
|
9495 int v2; // ecx@1
|
|
9496 unsigned int v3; // eax@1
|
|
9497
|
|
9498 v2 = 0;
|
|
9499 v3 = uDim - 1;
|
|
9500 while (v3 & 1)
|
|
9501 {
|
|
9502 v3 >>= 1;
|
|
9503 ++v2;
|
|
9504 }
|
|
9505 return v3 == 0 ? v2 : 0;
|
|
9506 }
|
|
9507
|
|
9508 //----- (0046E44E) --------------------------------------------------------
|
|
9509 int _46E44E_collide_against_faces_and_portals(unsigned int b1)
|
|
9510 {
|
|
9511 BLVSector *pSector; // edi@1
|
|
9512 signed int v2; // ebx@1
|
|
9513 BLVFace *pFace; // esi@2
|
|
9514 __int16 pNextSector; // si@10
|
|
9515 int pArrayNum; // ecx@12
|
|
9516 unsigned __int8 v6; // sf@12
|
|
9517 unsigned __int8 v7; // of@12
|
|
9518 int result; // eax@14
|
|
9519 //int v10; // ecx@15
|
|
9520 int pFloor; // eax@16
|
|
9521 int v15; // eax@24
|
|
9522 int v16; // edx@25
|
|
9523 int v17; // eax@29
|
|
9524 unsigned int v18; // eax@33
|
|
9525 int v21; // eax@35
|
|
9526 int v22; // ecx@36
|
|
9527 int v23; // eax@40
|
|
9528 unsigned int v24; // eax@44
|
|
9529 int a3; // [sp+10h] [bp-48h]@28
|
|
9530 int v26; // [sp+14h] [bp-44h]@15
|
|
9531 int i; // [sp+18h] [bp-40h]@1
|
|
9532 int a10; // [sp+1Ch] [bp-3Ch]@1
|
|
9533 int v29; // [sp+20h] [bp-38h]@14
|
|
9534 int v32; // [sp+2Ch] [bp-2Ch]@15
|
|
9535 int pSectorsArray[10]; // [sp+30h] [bp-28h]@1
|
|
9536
|
|
9537 pSector = &pIndoor->pSectors[stru_721530.uSectorID];
|
|
9538 i = 1;
|
|
9539 a10 = b1;
|
|
9540 pSectorsArray[0] = stru_721530.uSectorID;
|
|
9541 for (v2 = 0; v2 < pSector->uNumPortals; ++v2)
|
|
9542 {
|
|
9543 pFace = &pIndoor->pFaces[pSector->pPortals[v2]];
|
|
9544 if (stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1
|
|
9545 && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1
|
|
9546 && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1
|
|
9547 && abs((pFace->pFacePlane_old.dist
|
|
9548 + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x
|
|
9549 + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y
|
|
9550 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16) <= stru_721530.field_6C + 16)
|
|
9551 {
|
|
9552 pNextSector = pFace->uSectorID == stru_721530.uSectorID ? pFace->uBackSectorID : pFace->uSectorID;//FrontSectorID
|
|
9553 pArrayNum = i++;
|
|
9554 v7 = i < 10;
|
|
9555 v6 = i - 10 < 0;
|
|
9556 pSectorsArray[pArrayNum] = pNextSector;
|
|
9557 if (!(v6 ^ v7))
|
|
9558 break;
|
|
9559 }
|
|
9560 }
|
|
9561 result = 0;
|
|
9562 for (v29 = 0; v29 < i; v29++)
|
|
9563 {
|
|
9564 pSector = &pIndoor->pSectors[pSectorsArray[v29]];
|
|
9565 v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings;
|
|
9566 for (v26 = 0; v26 < v32; v26++)
|
|
9567 {
|
|
9568 pFloor = pSector->pFloors[v26];
|
|
9569 pFace = &pIndoor->pFaces[pSector->pFloors[v26]];
|
|
9570 if (!pFace->Portal()
|
|
9571 && stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1
|
|
9572 && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1
|
|
9573 && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1
|
|
9574 && pFloor != stru_721530.field_84)
|
|
9575 {
|
|
9576 v15 = (pFace->pFacePlane_old.dist + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x
|
|
9577 + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y
|
|
9578 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16;
|
|
9579 if (v15 > 0)
|
|
9580 {
|
|
9581 v16 = (pFace->pFacePlane_old.dist + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x
|
|
9582 + stru_721530.normal2.y * pFace->pFacePlane_old.vNormal.y
|
|
9583 + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z) >> 16;
|
|
9584 if (v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d)
|
|
9585 {
|
|
9586 if (v16 <= v15)
|
|
9587 {
|
|
9588 a3 = stru_721530.field_6C;
|
|
9589 if (sub_47531C(stru_721530.prolly_normal_d, &a3, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
|
|
9590 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10))
|
|
9591 {
|
|
9592 v17 = a3;
|
|
9593 }
|
|
9594 else
|
|
9595 {
|
|
9596 a3 = stru_721530.field_6C + stru_721530.prolly_normal_d;
|
|
9597 if (!sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, pFace))
|
|
9598 goto LABEL_34;
|
|
9599 v17 = a3 - stru_721530.prolly_normal_d;
|
|
9600 a3 -= stru_721530.prolly_normal_d;
|
|
9601 }
|
|
9602 if (v17 < stru_721530.field_7C)
|
|
9603 {
|
|
9604 stru_721530.field_7C = v17;
|
|
9605 v18 = 8 * pSector->pFloors[v26];
|
|
9606 LOBYTE(v18) = v18 | 6;
|
|
9607 stru_721530.uFaceID = v18;
|
|
9608 }
|
|
9609 }
|
|
9610 }
|
|
9611 }
|
|
9612 LABEL_34:
|
|
9613 if (!(stru_721530.field_0 & 1)
|
|
9614 || (v21 = (pFace->pFacePlane_old.dist + stru_721530.position.x * pFace->pFacePlane_old.vNormal.x
|
|
9615 + stru_721530.position.y * pFace->pFacePlane_old.vNormal.y
|
|
9616 + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16, v21 <= 0)
|
|
9617 || (v22 = (pFace->pFacePlane_old.dist + stru_721530.field_4C * pFace->pFacePlane_old.vNormal.x
|
|
9618 + stru_721530.field_50 * pFace->pFacePlane_old.vNormal.y
|
|
9619 + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16, v21 > stru_721530.prolly_normal_d)
|
|
9620 && v22 > stru_721530.prolly_normal_d || v22 > v21)
|
|
9621 continue;
|
|
9622 a3 = stru_721530.field_6C;
|
|
9623 if (sub_47531C(stru_721530.field_8_radius, &a3, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
|
|
9624 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10))
|
|
9625 {
|
|
9626 v23 = a3;
|
|
9627 goto LABEL_43;
|
|
9628 }
|
|
9629 a3 = stru_721530.field_6C + stru_721530.field_8_radius;
|
|
9630 if (sub_475D85(&stru_721530.position, &stru_721530.direction, &a3, pFace))
|
|
9631 {
|
|
9632 v23 = a3 - stru_721530.prolly_normal_d;
|
|
9633 a3 -= stru_721530.prolly_normal_d;
|
|
9634 LABEL_43:
|
|
9635 if (v23 < stru_721530.field_7C)
|
|
9636 {
|
|
9637 stru_721530.field_7C = v23;
|
|
9638 v24 = 8 * pSector->pFloors[v26];
|
|
9639 LOBYTE(v24) = v24 | 6;
|
|
9640 stru_721530.uFaceID = v24;
|
|
9641 }
|
|
9642 }
|
|
9643 }
|
|
9644 }
|
|
9645 result = v29 + 1;
|
|
9646 }
|
|
9647 return result;
|
|
9648 }
|
|
9649 // 46E44E: using guessed type int var_28[10];
|
|
9650
|
|
9651 //----- (0046E889) --------------------------------------------------------
|
|
9652 int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0)
|
|
9653 {
|
|
9654 int result; // eax@1
|
|
9655 //int v3; // ebx@9
|
|
9656 int v8; // eax@19
|
|
9657 int v9; // ecx@20
|
|
9658 int v10; // eax@24
|
|
9659 unsigned int v14; // eax@28
|
|
9660 int v15; // eax@30
|
|
9661 int v16; // ecx@31
|
|
9662 unsigned int v17; // eax@36
|
|
9663 int v21; // eax@42
|
|
9664 unsigned int v22; // eax@43
|
|
9665 //int a11; // [sp+70h] [bp-18h]@1
|
|
9666 //int a10; // [sp+80h] [bp-8h]@1
|
|
9667 int a2; // [sp+84h] [bp-4h]@23
|
|
9668
|
|
9669 //a11 = ecx0;
|
|
9670
|
|
9671 BLVFace face; // [sp+Ch] [bp-7Ch]@1
|
|
9672
|
|
9673 result = 0;
|
|
9674 for (uint i = 0; i < (signed int)pOutdoor->uNumBModels; ++i)
|
|
9675 {
|
|
9676 if (stru_721530.sMaxX <= pOutdoor->pBModels[i].sMaxX && stru_721530.sMinX >= pOutdoor->pBModels[i].sMinX
|
|
9677 && stru_721530.sMaxY <= pOutdoor->pBModels[i].sMaxY && stru_721530.sMinY >= pOutdoor->pBModels[i].sMinY
|
|
9678 && stru_721530.sMaxZ <= pOutdoor->pBModels[i].sMaxZ && stru_721530.sMinZ >= pOutdoor->pBModels[i].sMinZ)
|
|
9679 {
|
|
9680 for (uint j = 0; j < pOutdoor->pBModels[i].uNumFaces; ++j)
|
|
9681 {
|
|
9682 if (stru_721530.sMaxX <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x2 && stru_721530.sMinX >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x1
|
|
9683 && stru_721530.sMaxY <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y2 && stru_721530.sMinY >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y1
|
|
9684 && stru_721530.sMaxZ <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.z2 && stru_721530.sMinZ >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.z1)
|
|
9685 {
|
|
9686 face.pFacePlane_old.vNormal.x = pOutdoor->pBModels[i].pFaces[j].pFacePlane.vNormal.x;
|
|
9687 face.pFacePlane_old.vNormal.y = pOutdoor->pBModels[i].pFaces[j].pFacePlane.vNormal.y;
|
|
9688 face.pFacePlane_old.vNormal.z = pOutdoor->pBModels[i].pFaces[j].pFacePlane.vNormal.z;
|
|
9689
|
|
9690 face.pFacePlane_old.dist = pOutdoor->pBModels[i].pFaces[j].pFacePlane.dist; //incorrect
|
|
9691
|
|
9692 face.uAttributes = pOutdoor->pBModels[i].pFaces[j].uAttributes;
|
|
9693
|
|
9694 face.pBounding.x1 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x1;
|
|
9695 face.pBounding.y1 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y1;
|
|
9696 face.pBounding.z1 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.z1;
|
|
9697
|
|
9698 face.pBounding.x2 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x2;
|
|
9699 face.pBounding.y2 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y2;
|
|
9700 face.pBounding.z2 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.z2;
|
|
9701
|
|
9702 face.zCalc1 = pOutdoor->pBModels[i].pFaces[j].zCalc1;
|
|
9703 face.zCalc2 = pOutdoor->pBModels[i].pFaces[j].zCalc2;
|
|
9704 face.zCalc3 = pOutdoor->pBModels[i].pFaces[j].zCalc3;
|
|
9705
|
|
9706 face.pXInterceptDisplacements = pOutdoor->pBModels[i].pFaces[j].pXInterceptDisplacements;
|
|
9707 face.pYInterceptDisplacements = pOutdoor->pBModels[i].pFaces[j].pYInterceptDisplacements;
|
|
9708 face.pZInterceptDisplacements = pOutdoor->pBModels[i].pFaces[j].pZInterceptDisplacements;
|
|
9709
|
|
9710 face.uPolygonType = (PolygonType)pOutdoor->pBModels[i].pFaces[j].uPolygonType;
|
|
9711
|
|
9712 face.uNumVertices = pOutdoor->pBModels[i].pFaces[j].uNumVertices;
|
|
9713
|
|
9714 face.uBitmapID = pOutdoor->pBModels[i].pFaces[j].uTextureID;
|
|
9715
|
|
9716 face.pVertexIDs = pOutdoor->pBModels[i].pFaces[j].pVertexIDs;
|
|
9717
|
|
9718 if (!face.Ethereal() && !face.Portal())
|
|
9719 {
|
|
9720 v8 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.normal.x
|
|
9721 + face.pFacePlane_old.vNormal.y * stru_721530.normal.y
|
|
9722 + face.pFacePlane_old.vNormal.z * stru_721530.normal.z) >> 16;
|
|
9723 if (v8 > 0)
|
|
9724 {
|
|
9725 v9 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.normal2.x
|
|
9726 + face.pFacePlane_old.vNormal.y * stru_721530.normal2.y
|
|
9727 + face.pFacePlane_old.vNormal.z * stru_721530.normal2.z) >> 16;
|
|
9728 if (v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d)
|
|
9729 {
|
|
9730 if (v9 <= v8)
|
|
9731 {
|
|
9732 a2 = stru_721530.field_6C;
|
|
9733 if (sub_4754BF(stru_721530.prolly_normal_d, &a2, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
|
|
9734 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &face, i, ecx0))
|
|
9735 {
|
|
9736 v10 = a2;
|
|
9737 }
|
|
9738 else
|
|
9739 {
|
|
9740 a2 = stru_721530.prolly_normal_d + stru_721530.field_6C;
|
|
9741 if (!sub_475F30(&a2, &face, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
|
|
9742 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, i))
|
|
9743 goto LABEL_29;
|
|
9744 v10 = a2 - stru_721530.prolly_normal_d;
|
|
9745 a2 -= stru_721530.prolly_normal_d;
|
|
9746 }
|
|
9747 if (v10 < stru_721530.field_7C)
|
|
9748 {
|
|
9749 stru_721530.field_7C = v10;
|
|
9750 v14 = 8 * (j | (i << 6));
|
|
9751 LOBYTE(v14) = v14 | 6;
|
|
9752 stru_721530.uFaceID = v14;
|
|
9753 }
|
|
9754 }
|
|
9755 }
|
|
9756 }
|
|
9757 LABEL_29:
|
|
9758 if (stru_721530.field_0 & 1)
|
|
9759 {
|
|
9760 v15 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.position.x
|
|
9761 + face.pFacePlane_old.vNormal.y * stru_721530.position.y
|
|
9762 + face.pFacePlane_old.vNormal.z * stru_721530.position.z) >> 16;
|
|
9763 if (v15 > 0)
|
|
9764 {
|
|
9765 v16 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.field_4C
|
|
9766 + face.pFacePlane_old.vNormal.y * stru_721530.field_50
|
|
9767 + face.pFacePlane_old.vNormal.z * stru_721530.field_54) >> 16;
|
|
9768 if (v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d)
|
|
9769 {
|
|
9770 if (v16 <= v15)
|
|
9771 {
|
|
9772 a2 = stru_721530.field_6C;
|
|
9773 if (sub_4754BF(stru_721530.field_8_radius, &a2, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
|
|
9774 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &face, i, ecx0))
|
|
9775 {
|
|
9776 if (a2 < stru_721530.field_7C)
|
|
9777 {
|
|
9778 stru_721530.field_7C = a2;
|
|
9779 v17 = 8 * (j | (i << 6));
|
|
9780 LOBYTE(v17) = v17 | 6;
|
|
9781 stru_721530.uFaceID = v17;
|
|
9782 }
|
|
9783 }
|
|
9784 else
|
|
9785 {
|
|
9786 a2 = stru_721530.field_6C + stru_721530.field_8_radius;
|
|
9787 if (sub_475F30(&a2, &face, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
|
|
9788 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, i))
|
|
9789 {
|
|
9790 v21 = a2 - stru_721530.prolly_normal_d;
|
|
9791 a2 -= stru_721530.prolly_normal_d;
|
|
9792 if (a2 < stru_721530.field_7C)
|
|
9793 {
|
|
9794 stru_721530.field_7C = v21;
|
|
9795 v22 = 8 * (j | (i << 6));
|
|
9796 LOBYTE(v22) = v22 | 6;
|
|
9797 stru_721530.uFaceID = v22;
|
|
9798 }
|
|
9799 }
|
|
9800 }
|
|
9801 }
|
|
9802 }
|
|
9803 }
|
|
9804 }
|
|
9805 }
|
|
9806 }
|
|
9807 }
|
|
9808 }
|
|
9809 result = i;
|
|
9810 }
|
|
9811 return result;
|
|
9812 }
|
|
9813
|
|
9814 //----- (0046ED1B) --------------------------------------------------------
|
|
9815 int collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID)
|
|
9816 {
|
|
9817 uint uFaceID = -1;
|
|
9818 int floor_level = BLV_GetFloorLevel(x, y, z, *pSectorID, &uFaceID);
|
|
9819
|
|
9820 if (floor_level != -30000 && floor_level <= z + 50)
|
|
9821 {
|
|
9822 *pFaceID = uFaceID;
|
|
9823 return floor_level;
|
|
9824 }
|
|
9825
|
|
9826 uint uSectorID = pIndoor->GetSector(x, y, z);
|
|
9827 *pSectorID = uSectorID;
|
|
9828
|
|
9829 floor_level = BLV_GetFloorLevel(x, y, z, uSectorID, &uFaceID);
|
|
9830 if (uSectorID && floor_level != -30000)
|
|
9831 *pFaceID = uFaceID;
|
|
9832 else return -30000;
|
|
9833 return floor_level;
|
|
9834 }
|
|
9835
|
|
9836 //----- (0046ED8A) --------------------------------------------------------
|
|
9837 void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this)
|
|
9838 {
|
|
9839 ObjectDesc *object; // edx@4
|
|
9840 int v10; // ecx@12
|
|
9841 int v11; // esi@13
|
|
9842
|
|
9843 for (uint i = 0; i < uNumSpriteObjects; ++i)
|
|
9844 {
|
|
9845 if (pSpriteObjects[i].uObjectDescID)
|
|
9846 {
|
|
9847 object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
|
|
9848 if (!(object->uFlags & OBJECT_DESC_NO_COLLISION))
|
|
9849 {
|
|
9850 if (stru_721530.sMaxX <= pSpriteObjects[i].vPosition.x + object->uRadius && stru_721530.sMinX >= pSpriteObjects[i].vPosition.x - object->uRadius
|
|
9851 && stru_721530.sMaxY <= pSpriteObjects[i].vPosition.y + object->uRadius && stru_721530.sMinY >= pSpriteObjects[i].vPosition.y - object->uRadius
|
|
9852 && stru_721530.sMaxZ <= pSpriteObjects[i].vPosition.z + object->uHeight && stru_721530.sMinZ >= pSpriteObjects[i].vPosition.z)
|
|
9853 {
|
|
9854 if (abs(((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
|
|
9855 - (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16)
|
|
9856 <= object->uHeight + stru_721530.prolly_normal_d)
|
|
9857 {
|
|
9858 v10 = ((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.x
|
|
9859 + (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.y) >> 16;
|
|
9860 if (v10 > 0)
|
|
9861 {
|
|
9862 v11 = stru_721530.normal.z + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16);
|
|
9863 if (v11 >= pSpriteObjects[i].vPosition.z - stru_721530.prolly_normal_d)
|
|
9864 {
|
|
9865 if (v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z)
|
|
9866 {
|
|
9867 if (v10 < stru_721530.field_7C)
|
|
9868 sub_46DEF2(_this, i);
|
|
9869 }
|
|
9870 }
|
|
9871 }
|
|
9872 }
|
|
9873 }
|
|
9874 }
|
|
9875 }
|
|
9876 }
|
|
9877 }
|
|
9878
|
|
9879 //----- (0046EF01) --------------------------------------------------------
|
|
9880 int _46EF01_collision_chech_player(int a1)
|
|
9881 {
|
|
9882 int result; // eax@1
|
|
9883 int v3; // ebx@7
|
|
9884 int v4; // esi@7
|
|
9885 int v5; // edi@8
|
|
9886 int v6; // ecx@9
|
|
9887 int v7; // edi@12
|
|
9888 int v10; // [sp+14h] [bp-8h]@7
|
|
9889 int v11; // [sp+18h] [bp-4h]@7
|
|
9890
|
|
9891 result = pParty->vPosition.x;
|
|
9892 //v9 = pParty->uPartyHeight;
|
|
9893 if (stru_721530.sMaxX <= pParty->vPosition.x + (2 * pParty->field_14_radius) && stru_721530.sMinX >= pParty->vPosition.x - (2 * pParty->field_14_radius)
|
|
9894 && stru_721530.sMaxY <= pParty->vPosition.y + (2 * pParty->field_14_radius) && stru_721530.sMinY >= pParty->vPosition.y - (2 * pParty->field_14_radius)
|
|
9895 && stru_721530.sMaxZ <= pParty->vPosition.z + pParty->uPartyHeight && stru_721530.sMinZ >= pParty->vPosition.z)
|
|
9896 {
|
|
9897 v3 = stru_721530.prolly_normal_d + (2 * pParty->field_14_radius);
|
|
9898 v11 = pParty->vPosition.x - stru_721530.normal.x;
|
|
9899 v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
|
|
9900 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
|
|
9901 v10 = pParty->vPosition.y - stru_721530.normal.y;
|
|
9902 result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
|
|
9903 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16);
|
|
9904 if (result <= stru_721530.prolly_normal_d + (2 * pParty->field_14_radius))
|
|
9905 {
|
|
9906 result = v10 * stru_721530.direction.y;
|
|
9907 v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16;
|
|
9908 if (v5 > 0)
|
|
9909 {
|
|
9910 v6 = fixpoint_mul(stru_721530.direction.z, v5) + stru_721530.normal.z;
|
|
9911 result = pParty->vPosition.z;
|
|
9912 if (v6 >= pParty->vPosition.z)
|
|
9913 {
|
|
9914 result = pParty->uPartyHeight + pParty->vPosition.z;
|
|
9915 if (v6 <= (signed int)(pParty->uPartyHeight + pParty->vPosition.z) || a1)
|
|
9916 {
|
|
9917 result = integer_sqrt(v3 * v3 - v4 * v4);
|
|
9918 v7 = v5 - integer_sqrt(v3 * v3 - v4 * v4);
|
|
9919 if (v7 < 0)
|
|
9920 v7 = 0;
|
|
9921 if (v7 < stru_721530.field_7C)
|
|
9922 {
|
|
9923 stru_721530.field_7C = v7;
|
|
9924 stru_721530.uFaceID = 4;
|
|
9925 }
|
|
9926 }
|
|
9927 }
|
|
9928 }
|
|
9929 }
|
|
9930 }
|
|
9931 return result;
|
|
9932 }
|
|
9933
|
|
9934 //----- (0046E0B2) --------------------------------------------------------
|
|
9935 void _46E0B2_collide_against_decorations()
|
|
9936 {
|
|
9937 BLVSector *sector; // ebp@1
|
|
9938 LevelDecoration *decor; // edi@2
|
|
9939 DecorationDesc *decor_desc; // esi@3
|
|
9940 int v8; // ebx@10
|
|
9941 int v9; // esi@11
|
|
9942 int v11; // eax@12
|
|
9943 int v12; // esi@14
|
|
9944 unsigned int v13; // eax@17
|
|
9945 signed int i; // [sp+4h] [bp-14h]@1
|
|
9946 int v15; // [sp+8h] [bp-10h]@10
|
|
9947 int v16; // [sp+Ch] [bp-Ch]@10
|
|
9948 int v17; // [sp+10h] [bp-8h]@10
|
|
9949
|
|
9950 sector = &pIndoor->pSectors[stru_721530.uSectorID];
|
|
9951 for (i = 0; i < sector->uNumDecorations; ++i)
|
|
9952 {
|
|
9953 decor = &pLevelDecorations[sector->pDecorationIDs[i]];
|
|
9954 if (!(decor->uFlags & LEVEL_DECORATION_INVISIBLE))
|
|
9955 {
|
|
9956 decor_desc = &pDecorationList->pDecorations[decor->uDecorationDescID];
|
|
9957 if (!decor_desc->CanMoveThrough())
|
|
9958 {
|
|
9959 if (stru_721530.sMaxX <= decor->vPosition.x + decor_desc->uRadius && stru_721530.sMinX >= decor->vPosition.x - decor_desc->uRadius
|
|
9960 && stru_721530.sMaxY <= decor->vPosition.y + decor_desc->uRadius && stru_721530.sMinY >= decor->vPosition.y - decor_desc->uRadius
|
|
9961 && stru_721530.sMaxZ <= decor->vPosition.z + decor_desc->uDecorationHeight && stru_721530.sMinZ >= decor->vPosition.z)
|
|
9962 {
|
|
9963 v16 = decor->vPosition.x - stru_721530.normal.x;
|
|
9964 v15 = decor->vPosition.y - stru_721530.normal.y;
|
|
9965 v8 = stru_721530.prolly_normal_d + decor_desc->uRadius;
|
|
9966 v17 = ((decor->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
|
|
9967 - (decor->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
|
|
9968 if (abs(v17) <= stru_721530.prolly_normal_d + decor_desc->uRadius)
|
|
9969 {
|
|
9970 v9 = (v16 * stru_721530.direction.x + v15 * stru_721530.direction.y) >> 16;
|
|
9971 if (v9 > 0)
|
|
9972 {
|
|
9973 v11 = stru_721530.normal.z + fixpoint_mul(stru_721530.direction.z, v9);
|
|
9974 if (v11 >= decor->vPosition.z)
|
|
9975 {
|
|
9976 if (v11 <= decor_desc->uDecorationHeight + decor->vPosition.z)
|
|
9977 {
|
|
9978 v12 = v9 - integer_sqrt(v8 * v8 - v17 * v17);
|
|
9979 if (v12 < 0)
|
|
9980 v12 = 0;
|
|
9981 if (v12 < stru_721530.field_7C)
|
|
9982 {
|
|
9983 stru_721530.field_7C = v12;
|
|
9984 v13 = 8 * sector->pDecorationIDs[i];
|
|
9985 LOBYTE(v13) = v13 | 5;
|
|
9986 stru_721530.uFaceID = v13;
|
|
9987 }
|
|
9988 }
|
|
9989 }
|
|
9990 }
|
|
9991 }
|
|
9992 }
|
|
9993 }
|
|
9994 }
|
|
9995 }
|
|
9996 }
|
|
9997
|
|
9998 //----- (0046F04E) --------------------------------------------------------
|
|
9999 int _46F04E_collide_against_portals()
|
|
10000 {
|
|
10001 unsigned int v1; // eax@1
|
|
10002 BLVFace *face; // eax@3
|
|
10003 int v4; // ecx@9
|
|
10004 int v5; // edx@9
|
|
10005 signed int result; // eax@21
|
|
10006 unsigned int v10; // [sp+8h] [bp-Ch]@1
|
|
10007 int a3; // [sp+Ch] [bp-8h]@13
|
|
10008 int v12; // [sp+10h] [bp-4h]@15
|
|
10009
|
|
10010 v1 = 0xFFFFFFu;
|
|
10011 v10 = 0xFFFFFFu;
|
|
10012 for (uint i = 0; i < pIndoor->pSectors[stru_721530.uSectorID].uNumPortals; ++i)
|
|
10013 {
|
|
10014 if (pIndoor->pSectors[stru_721530.uSectorID].pPortals[i] != stru_721530.field_80)
|
|
10015 {
|
|
10016 face = &pIndoor->pFaces[pIndoor->pSectors[stru_721530.uSectorID].pPortals[i]];
|
|
10017 if (stru_721530.sMaxX <= face->pBounding.x2 && stru_721530.sMinX >= face->pBounding.x1
|
|
10018 && stru_721530.sMaxY <= face->pBounding.y2 && stru_721530.sMinY >= face->pBounding.y1
|
|
10019 && stru_721530.sMaxZ <= face->pBounding.z2 && stru_721530.sMinZ >= face->pBounding.z1)
|
|
10020 {
|
|
10021 v4 = (stru_721530.normal.x * face->pFacePlane_old.vNormal.x + face->pFacePlane_old.dist
|
|
10022 + stru_721530.normal.y * face->pFacePlane_old.vNormal.y
|
|
10023 + stru_721530.normal.z * face->pFacePlane_old.vNormal.z) >> 16;
|
|
10024 v5 = (stru_721530.normal2.z * face->pFacePlane_old.vNormal.z + face->pFacePlane_old.dist
|
|
10025 + stru_721530.normal2.x * face->pFacePlane_old.vNormal.x
|
|
10026 + stru_721530.normal2.y * face->pFacePlane_old.vNormal.y) >> 16;
|
|
10027 if ((v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d)
|
|
10028 && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d)
|
|
10029 && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, face))
|
|
10030 && a3 < (signed int)v10)
|
|
10031 {
|
|
10032 v10 = a3;
|
|
10033 v12 = pIndoor->pSectors[stru_721530.uSectorID].pPortals[i];
|
|
10034 }
|
|
10035 }
|
|
10036 }
|
|
10037 }
|
|
10038 v1 = v10;
|
|
10039 if (stru_721530.field_7C >= (signed int)v1 && (signed int)v1 <= stru_721530.field_6C)
|
|
10040 {
|
|
10041 stru_721530.field_80 = v12;
|
|
10042 if (pIndoor->pFaces[v12].uSectorID == stru_721530.uSectorID)
|
|
10043 stru_721530.uSectorID = pIndoor->pFaces[v12].uBackSectorID;
|
|
10044 else
|
|
10045 stru_721530.uSectorID = pIndoor->pFaces[v12].uSectorID;
|
|
10046 stru_721530.field_7C = 268435455;
|
|
10047 result = 0;
|
|
10048 }
|
|
10049 else
|
|
10050 result = 1;
|
|
10051 return result;
|
|
10052 }
|
|
10053
|
|
10054 //----- (0046DEF2) --------------------------------------------------------
|
|
10055 unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID)
|
|
10056 {
|
|
10057 unsigned int result; // eax@1
|
|
10058
|
|
10059 result = uLayingItemID;
|
|
10060 if (pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID].uFlags & 0x10)
|
|
10061 result = _46BFFA_check_object_intercept(uLayingItemID, a2);
|
|
10062 return result;
|
|
10063 }
|
|
10064
|
|
10065 //----- (0047253E) --------------------------------------------------------
|
|
10066 void UpdateObjects()
|
|
10067 {
|
|
10068 ObjectDesc *object; // eax@5
|
|
10069 int v5; // ecx@6
|
|
10070 signed int v7; // eax@9
|
|
10071 signed int v11; // eax@17
|
|
10072 int v12; // edi@27
|
|
10073 int v18; // [sp+4h] [bp-10h]@27
|
|
10074 int v19; // [sp+8h] [bp-Ch]@27
|
|
10075
|
|
10076 for (uint i = 0; i < uNumSpriteObjects; ++i)
|
|
10077 {
|
|
10078 if (pSpriteObjects[i].uAttributes & OBJECT_40)
|
|
10079 pSpriteObjects[i].uAttributes &= ~OBJECT_40;
|
|
10080 else
|
|
10081 {
|
|
10082 object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
|
|
10083 if (pSpriteObjects[i].AttachedToActor())
|
|
10084 {
|
|
10085 v5 = PID_ID(pSpriteObjects[i].spell_target_pid);
|
|
10086 pSpriteObjects[i].vPosition.x = pActors[v5].vPosition.x;
|
|
10087 pSpriteObjects[i].vPosition.y = pActors[v5].vPosition.y;
|
|
10088 pSpriteObjects[i].vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
|
|
10089 if (!pSpriteObjects[i].uObjectDescID)
|
|
10090 continue;
|
|
10091 pSpriteObjects[i].uSpriteFrameID += pEventTimer->uTimeElapsed;
|
|
10092 if (!(object->uFlags & OBJECT_DESC_TEMPORARY))
|
|
10093 continue;
|
|
10094 if (pSpriteObjects[i].uSpriteFrameID >= 0)
|
|
10095 {
|
|
10096 v7 = object->uLifetime;
|
|
10097 if (pSpriteObjects[i].uAttributes & ITEM_BROKEN)
|
|
10098 v7 = pSpriteObjects[i].field_20;
|
|
10099 if (pSpriteObjects[i].uSpriteFrameID < v7)
|
|
10100 continue;
|
|
10101 }
|
|
10102 SpriteObject::OnInteraction(i);
|
|
10103 continue;
|
|
10104 }
|
|
10105 if (pSpriteObjects[i].uObjectDescID)
|
|
10106 {
|
|
10107 pSpriteObjects[i].uSpriteFrameID += pEventTimer->uTimeElapsed;
|
|
10108 if (object->uFlags & OBJECT_DESC_TEMPORARY)
|
|
10109 {
|
|
10110 if (pSpriteObjects[i].uSpriteFrameID < 0)
|
|
10111 {
|
|
10112 SpriteObject::OnInteraction(i);
|
|
10113 continue;
|
|
10114 }
|
|
10115 v11 = object->uLifetime;
|
|
10116 if (pSpriteObjects[i].uAttributes & ITEM_BROKEN)
|
|
10117 v11 = pSpriteObjects[i].field_20;
|
|
10118 }
|
|
10119 if (!(object->uFlags & OBJECT_DESC_TEMPORARY) || pSpriteObjects[i].uSpriteFrameID < v11)
|
|
10120 {
|
|
10121 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
10122 SpriteObject::UpdateObject_fn0_BLV(i);
|
|
10123 else
|
|
10124 SpriteObject::UpdateObject_fn0_ODM(i);
|
|
10125 if (pParty->bTurnBasedModeOn != 1 || !(pSpriteObjects[i].uSectorID & 4))
|
|
10126 continue;
|
|
10127 v12 = abs(pParty->vPosition.x - pSpriteObjects[i].vPosition.x);
|
|
10128 v18 = abs(pParty->vPosition.y - pSpriteObjects[i].vPosition.y);
|
|
10129 v19 = abs(pParty->vPosition.z - pSpriteObjects[i].vPosition.z);
|
|
10130 if (int_get_vector_length(v12, v18, v19) <= 5120)
|
|
10131 continue;
|
|
10132 SpriteObject::OnInteraction(i);
|
|
10133 continue;
|
|
10134 }
|
|
10135 if (!(object->uFlags & OBJECT_DESC_INTERACTABLE))
|
|
10136 {
|
|
10137 SpriteObject::OnInteraction(i);
|
|
10138 continue;
|
|
10139 }
|
|
10140 _46BFFA_check_object_intercept(i, PID(OBJECT_Item, i));
|
|
10141 }
|
|
10142 }
|
|
10143 }
|
|
10144 }
|
|
10145
|
|
10146 //----- (0047531C) --------------------------------------------------------
|
|
10147 bool sub_47531C(int a1, int *a2, int pos_x, int pos_y, int pos_z, int dir_x, int dir_y, int dir_z, BLVFace *face, int a10)
|
|
10148 {
|
|
10149 int v11; // ST1C_4@3
|
|
10150 int v12; // edi@3
|
|
10151 int v13; // esi@3
|
|
10152 int v14; // edi@4
|
|
10153 signed __int64 v15; // qtt@6
|
|
10154 //__int16 v16; // si@7
|
|
10155 int a7a; // [sp+30h] [bp+18h]@7
|
|
10156 int a9b; // [sp+38h] [bp+20h]@3
|
|
10157 int a9a; // [sp+38h] [bp+20h]@3
|
|
10158 int a10b; // [sp+3Ch] [bp+24h]@3
|
|
10159 signed int a10a; // [sp+3Ch] [bp+24h]@4
|
|
10160 int a10c; // [sp+3Ch] [bp+24h]@5
|
|
10161
|
|
10162 if (a10 && face->Ethereal())
|
|
10163 return 0;
|
|
10164 v11 = fixpoint_mul(dir_x, face->pFacePlane_old.vNormal.x);
|
|
10165 a10b = fixpoint_mul(dir_y, face->pFacePlane_old.vNormal.y);
|
|
10166 a9b = fixpoint_mul(dir_z, face->pFacePlane_old.vNormal.z);
|
|
10167 v12 = v11 + a9b + a10b;
|
|
10168 a9a = v11 + a9b + a10b;
|
|
10169 v13 = (a1 << 16)
|
|
10170 - pos_x * face->pFacePlane_old.vNormal.x
|
|
10171 - pos_y * face->pFacePlane_old.vNormal.y
|
|
10172 - pos_z * face->pFacePlane_old.vNormal.z
|
|
10173 - face->pFacePlane_old.dist;
|
|
10174 if (abs((a1 << 16)
|
|
10175 - pos_x * face->pFacePlane_old.vNormal.x
|
|
10176 - pos_y * face->pFacePlane_old.vNormal.y
|
|
10177 - pos_z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16)
|
|
10178 {
|
|
10179 a10c = abs(v13) >> 14;
|
|
10180 if (a10c > abs(v12))
|
|
10181 return 0;
|
|
10182 LODWORD(v15) = v13 << 16;
|
|
10183 HIDWORD(v15) = v13 >> 16;
|
|
10184 v14 = a1;
|
|
10185 a10a = v15 / a9a;
|
|
10186 }
|
|
10187 else
|
|
10188 {
|
|
10189 a10a = 0;
|
|
10190 v14 = abs(v13) >> 16;
|
|
10191 }
|
|
10192 //v16 = pos_y + ((unsigned int)fixpoint_mul(a10a, dir_y) >> 16);
|
|
10193 LOWORD(a7a) = (short)pos_x + ((unsigned int)fixpoint_mul(a10a, dir_x) >> 16) - fixpoint_mul(v14, face->pFacePlane_old.vNormal.x);
|
|
10194 HIWORD(a7a) = pos_y + ((unsigned int)fixpoint_mul(a10a, dir_y) >> 16) - fixpoint_mul(v14, face->pFacePlane_old.vNormal.y);
|
|
10195 if (!sub_475665(face, a7a, (short)pos_z + ((unsigned int)fixpoint_mul(a10a, dir_z) >> 16) - fixpoint_mul(v14, face->pFacePlane_old.vNormal.z)))
|
|
10196 return 0;
|
|
10197 *a2 = a10a >> 16;
|
|
10198 if (a10a >> 16 < 0)
|
|
10199 *a2 = 0;
|
|
10200 return 1;
|
|
10201 }
|
|
10202
|
|
10203
|
|
10204 //----- (004754BF) --------------------------------------------------------
|
|
10205 bool sub_4754BF(int a1, int *a2, int X, int Y, int Z, int dir_x, int dir_y, int dir_z, BLVFace *face, int a10, int a11)
|
|
10206 {
|
|
10207 int v12; // ST1C_4@3
|
|
10208 int v13; // edi@3
|
|
10209 int v14; // esi@3
|
|
10210 int v15; // edi@4
|
|
10211 signed __int64 v16; // qtt@6
|
|
10212 //__int16 v17; // si@7
|
|
10213 int a7a; // [sp+30h] [bp+18h]@7
|
|
10214 int a1b; // [sp+38h] [bp+20h]@3
|
|
10215 int a1a; // [sp+38h] [bp+20h]@3
|
|
10216 int a11b; // [sp+40h] [bp+28h]@3
|
|
10217 signed int a11a; // [sp+40h] [bp+28h]@4
|
|
10218 int a11c; // [sp+40h] [bp+28h]@5
|
|
10219
|
|
10220 if (a11 && face->Ethereal())
|
|
10221 return false;
|
|
10222 v12 = fixpoint_mul(dir_x, face->pFacePlane_old.vNormal.x);
|
|
10223 a11b = fixpoint_mul(dir_y, face->pFacePlane_old.vNormal.y);
|
|
10224 a1b = fixpoint_mul(dir_z, face->pFacePlane_old.vNormal.z);
|
|
10225 v13 = v12 + a1b + a11b;
|
|
10226 a1a = v12 + a1b + a11b;
|
|
10227 v14 = (a1 << 16)
|
|
10228 - X * face->pFacePlane_old.vNormal.x
|
|
10229 - Y * face->pFacePlane_old.vNormal.y
|
|
10230 - Z * face->pFacePlane_old.vNormal.z
|
|
10231 - face->pFacePlane_old.dist;
|
|
10232 if (abs((a1 << 16)
|
|
10233 - X * face->pFacePlane_old.vNormal.x
|
|
10234 - Y * face->pFacePlane_old.vNormal.y
|
|
10235 - Z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16)
|
|
10236 {
|
|
10237 a11c = abs(v14) >> 14;
|
|
10238 if (a11c > abs(v13))
|
|
10239 return false;
|
|
10240 LODWORD(v16) = v14 << 16;
|
|
10241 HIDWORD(v16) = v14 >> 16;
|
|
10242 v15 = a1;
|
|
10243 a11a = v16 / a1a;
|
|
10244 }
|
|
10245 else
|
|
10246 {
|
|
10247 a11a = 0;
|
|
10248 v15 = abs(v14) >> 16;
|
|
10249 }
|
|
10250 //v17 = Y + ((unsigned int)fixpoint_mul(a11a, dir_y) >> 16);
|
|
10251 LOWORD(a7a) = (short)X + ((unsigned int)fixpoint_mul(a11a, dir_x) >> 16) - fixpoint_mul(v15, face->pFacePlane_old.vNormal.x);
|
|
10252 HIWORD(a7a) = Y + ((unsigned int)fixpoint_mul(a11a, dir_y) >> 16) - fixpoint_mul(v15, face->pFacePlane_old.vNormal.y);
|
|
10253 if (!sub_4759C9(face, a10, a7a, (short)Z + ((unsigned int)fixpoint_mul(a11a, dir_z) >> 16) - fixpoint_mul(v15, face->pFacePlane_old.vNormal.z)))
|
|
10254 return false;
|
|
10255 *a2 = a11a >> 16;
|
|
10256 if (a11a >> 16 < 0)
|
|
10257 *a2 = 0;
|
|
10258 return true;
|
|
10259 }
|
|
10260
|
|
10261 //----- (00475665) --------------------------------------------------------
|
|
10262 int sub_475665(BLVFace *face, int a2, __int16 a3)
|
|
10263 {
|
|
10264 bool v16; // edi@14
|
|
10265 signed int v20; // ebx@18
|
|
10266 int v21; // edi@20
|
|
10267 signed int v22; // ST14_4@22
|
|
10268 signed __int64 v23; // qtt@22
|
|
10269 signed int result; // eax@25
|
|
10270 int v25; // [sp+14h] [bp-10h]@14
|
|
10271 int v26; // [sp+1Ch] [bp-8h]@2
|
|
10272 signed int v27; // [sp+20h] [bp-4h]@2
|
|
10273 signed int v28; // [sp+30h] [bp+Ch]@2
|
|
10274 signed int v29; // [sp+30h] [bp+Ch]@7
|
|
10275 signed int v30; // [sp+30h] [bp+Ch]@11
|
|
10276 signed int v31; // [sp+30h] [bp+Ch]@14
|
|
10277
|
|
10278 if (face->uAttributes & FACE_XY_PLANE)
|
|
10279 {
|
|
10280 v26 = (signed __int16)a2;
|
|
10281 v27 = SHIWORD(a2);
|
|
10282 if (face->uNumVertices)
|
|
10283 {
|
|
10284 for (v28 = 0; v28 < face->uNumVertices; v28++)
|
|
10285 {
|
|
10286 word_720C10_intercepts_xs[2 * v28] = face->pXInterceptDisplacements[v28] + pIndoor->pVertices[face->pVertexIDs[v28]].x;
|
|
10287 word_720B40_intercepts_zs[2 * v28] = face->pYInterceptDisplacements[v28] + pIndoor->pVertices[face->pVertexIDs[v28]].y;
|
|
10288 word_720C10_intercepts_xs[2 * v28 + 1] = face->pXInterceptDisplacements[v28 + 1] + pIndoor->pVertices[face->pVertexIDs[v28 + 1]].x;
|
|
10289 word_720B40_intercepts_zs[2 * v28 + 1] = face->pYInterceptDisplacements[v28 + 1] + pIndoor->pVertices[face->pVertexIDs[v28 + 1]].y;
|
|
10290 }
|
|
10291 }
|
|
10292 }
|
|
10293 else
|
|
10294 {
|
|
10295 if (face->uAttributes & FACE_XZ_PLANE)
|
|
10296 {
|
|
10297 v26 = (signed __int16)a2;
|
|
10298 v27 = a3;
|
|
10299 if (face->uNumVertices)
|
|
10300 {
|
|
10301 for (v29 = 0; v29 < face->uNumVertices; v29++)
|
|
10302 {
|
|
10303 word_720C10_intercepts_xs[2 * v29] = face->pXInterceptDisplacements[v29] + pIndoor->pVertices[face->pVertexIDs[v29]].x;
|
|
10304 word_720B40_intercepts_zs[2 * v29] = face->pZInterceptDisplacements[v29] + pIndoor->pVertices[face->pVertexIDs[v29]].z;
|
|
10305 word_720C10_intercepts_xs[2 * v29 + 1] = face->pXInterceptDisplacements[v29 + 1] + pIndoor->pVertices[face->pVertexIDs[v29 + 1]].x;
|
|
10306 word_720B40_intercepts_zs[2 * v29 + 1] = face->pZInterceptDisplacements[v29 + 1] + pIndoor->pVertices[face->pVertexIDs[v29 + 1]].z;
|
|
10307 }
|
|
10308 }
|
|
10309 }
|
|
10310 else
|
|
10311 {
|
|
10312 v26 = SHIWORD(a2);
|
|
10313 v27 = a3;
|
|
10314 if (face->uNumVertices)
|
|
10315 {
|
|
10316 for (v30 = 0; v30 < face->uNumVertices; v30++)
|
|
10317 {
|
|
10318 word_720C10_intercepts_xs[2 * v30] = face->pYInterceptDisplacements[v30] + pIndoor->pVertices[face->pVertexIDs[v30]].y;
|
|
10319 word_720B40_intercepts_zs[2 * v30] = face->pZInterceptDisplacements[v30] + pIndoor->pVertices[face->pVertexIDs[v30]].z;
|
|
10320 word_720C10_intercepts_xs[2 * v30 + 1] = face->pYInterceptDisplacements[v30 + 1] + pIndoor->pVertices[face->pVertexIDs[v30 + 1]].y;
|
|
10321 word_720B40_intercepts_zs[2 * v30 + 1] = face->pZInterceptDisplacements[v30 + 1] + pIndoor->pVertices[face->pVertexIDs[v30 + 1]].z;
|
|
10322 }
|
|
10323 }
|
|
10324 }
|
|
10325 }
|
|
10326 v31 = 0;
|
|
10327 word_720C10_intercepts_xs[2 * face->uNumVertices] = word_720C10_intercepts_xs[0];
|
|
10328 word_720B40_intercepts_zs[2 * face->uNumVertices] = word_720B40_intercepts_zs[0];
|
|
10329 v16 = word_720B40_intercepts_zs[0] >= v27;
|
|
10330 if (2 * face->uNumVertices <= 0)
|
|
10331 return 0;
|
|
10332 for (v25 = 0; v25 < 2 * face->uNumVertices; ++v25)
|
|
10333 {
|
|
10334 if (v31 >= 2)
|
|
10335 break;
|
|
10336 if (v16 ^ (word_720B40_intercepts_zs[v25 + 1] >= v27))
|
|
10337 {
|
|
10338 if (word_720C10_intercepts_xs[v25 + 1] >= v26)
|
|
10339 v20 = 0;
|
|
10340 else
|
|
10341 v20 = 2;
|
|
10342 v21 = v20 | (word_720C10_intercepts_xs[v25] < v26);
|
|
10343 if (v21 != 3)
|
|
10344 {
|
|
10345 v22 = word_720C10_intercepts_xs[v25 + 1] - word_720C10_intercepts_xs[v25];
|
|
10346 LODWORD(v23) = v22 << 16;
|
|
10347 HIDWORD(v23) = v22 >> 16;
|
|
10348 if (!v21
|
|
10349 || (word_720C10_intercepts_xs[v25] + ((signed int)(((unsigned __int64)(v23
|
|
10350 / (word_720B40_intercepts_zs[v25 + 1] - word_720B40_intercepts_zs[v25])
|
|
10351 * ((v27 - (signed int)word_720B40_intercepts_zs[v25]) << 16)) >> 16)
|
|
10352 + 32768) >> 16) >= v26))
|
|
10353 ++v31;
|
|
10354 }
|
|
10355 }
|
|
10356 v16 = word_720B40_intercepts_zs[v25 + 1] >= v27;
|
|
10357 }
|
|
10358 result = 1;
|
|
10359 if (v31 != 1)
|
|
10360 result = 0;
|
|
10361 return result;
|
|
10362 }
|
|
10363
|
|
10364 //----- (004759C9) --------------------------------------------------------
|
|
10365 bool __fastcall sub_4759C9(BLVFace *face, int a2, int a3, __int16 a4)
|
|
10366 {
|
|
10367 bool v12; // edi@14
|
|
10368 signed int v16; // ebx@18
|
|
10369 int v17; // edi@20
|
|
10370 signed int v18; // ST14_4@22
|
|
10371 signed __int64 v19; // qtt@22
|
|
10372 bool result; // eax@25
|
|
10373 int v21; // [sp+14h] [bp-10h]@14
|
|
10374 signed int v22; // [sp+18h] [bp-Ch]@1
|
|
10375 int v23; // [sp+1Ch] [bp-8h]@2
|
|
10376 signed int v24; // [sp+20h] [bp-4h]@2
|
|
10377 signed int a4d; // [sp+30h] [bp+Ch]@14
|
|
10378
|
|
10379 if (face->uAttributes & FACE_XY_PLANE)
|
|
10380 {
|
|
10381 v23 = (signed __int16)a3;
|
|
10382 v24 = SHIWORD(a3);
|
|
10383 if (face->uNumVertices)
|
|
10384 {
|
|
10385 for (v22 = 0; v22 < face->uNumVertices; ++v22)
|
|
10386 {
|
|
10387 word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pXInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].x);
|
|
10388 word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pYInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].y);
|
|
10389 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pXInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].x);
|
|
10390 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pYInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].y);
|
|
10391 }
|
|
10392 }
|
|
10393 }
|
|
10394 else
|
|
10395 {
|
|
10396 if (face->uAttributes & FACE_XZ_PLANE)
|
|
10397 {
|
|
10398 v23 = (signed __int16)a3;
|
|
10399 v24 = a4;
|
|
10400 if (face->uNumVertices)
|
|
10401 {
|
|
10402 for (v22 = 0; v22 < face->uNumVertices; ++v22)
|
|
10403 {
|
|
10404 word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pXInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].x);
|
|
10405 word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pZInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].z);
|
|
10406 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pXInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].x);
|
|
10407 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pZInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].z);
|
|
10408 }
|
|
10409 }
|
|
10410 }
|
|
10411 else
|
|
10412 {
|
|
10413 v23 = SHIWORD(a3);
|
|
10414 v24 = a4;
|
|
10415 if (face->uNumVertices)
|
|
10416 {
|
|
10417 for (v22 = 0; v22 < face->uNumVertices; ++v22)
|
|
10418 {
|
|
10419 word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pYInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].y);
|
|
10420 word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pZInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].z);
|
|
10421 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pYInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].y);
|
|
10422 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pZInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].z);
|
|
10423 }
|
|
10424 }
|
|
10425 }
|
|
10426 }
|
|
10427 a4d = 0;
|
|
10428 word_720A70_intercepts_xs_plus_xs[2 * face->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0];
|
|
10429 word_7209A0_intercepts_ys_plus_ys[2 * face->uNumVertices] = word_7209A0_intercepts_ys_plus_ys[0];
|
|
10430 v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24;
|
|
10431 if (2 * face->uNumVertices <= 0)
|
|
10432 return 0;
|
|
10433 for (v21 = 0; v21 < 2 * face->uNumVertices; ++v21)
|
|
10434 {
|
|
10435 if (a4d >= 2)
|
|
10436 break;
|
|
10437 if (v12 ^ (word_7209A0_intercepts_ys_plus_ys[v21 + 1] >= v24))
|
|
10438 {
|
|
10439 if (word_720A70_intercepts_xs_plus_xs[v21 + 1] >= v23)
|
|
10440 v16 = 0;
|
|
10441 else
|
|
10442 v16 = 2;
|
|
10443 v17 = v16 | (word_720A70_intercepts_xs_plus_xs[v21] < v23);
|
|
10444 if (v17 != 3)
|
|
10445 {
|
|
10446 v18 = word_720A70_intercepts_xs_plus_xs[v21 + 1] - word_720A70_intercepts_xs_plus_xs[v21];
|
|
10447 LODWORD(v19) = v18 << 16;
|
|
10448 HIDWORD(v19) = v18 >> 16;
|
|
10449 if (!v17
|
|
10450 || (word_720A70_intercepts_xs_plus_xs[v21] + ((signed int)(((unsigned __int64)(v19
|
|
10451 / (word_7209A0_intercepts_ys_plus_ys[v21 + 1] - word_7209A0_intercepts_ys_plus_ys[v21])
|
|
10452 * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v21]) << 16)) >> 16)
|
|
10453 + 0x8000) >> 16) >= v23))
|
|
10454 ++a4d;
|
|
10455 }
|
|
10456 }
|
|
10457 v12 = word_7209A0_intercepts_ys_plus_ys[v21 + 1] >= v24;
|
|
10458 }
|
|
10459 result = 1;
|
|
10460 if (a4d != 1)
|
|
10461 result = 0;
|
|
10462 return result;
|
|
10463 }
|
|
10464
|
|
10465 //----- (00475D85) --------------------------------------------------------
|
|
10466 bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, BLVFace *a4)
|
|
10467 {
|
|
10468 BLVFace *v4; // ebx@1
|
|
10469 int v5; // ST24_4@2
|
|
10470 int v6; // ST28_4@2
|
|
10471 int v7; // edi@2
|
|
10472 int v8; // eax@5
|
|
10473 signed int v9; // esi@5
|
|
10474 signed __int64 v10; // qtt@10
|
|
10475 Vec3_int_ *v11; // esi@11
|
|
10476 int v12; // ST14_4@11
|
|
10477 Vec3_int_ *v14; // [sp+Ch] [bp-18h]@1
|
|
10478 Vec3_int_ *v15; // [sp+14h] [bp-10h]@1
|
|
10479 // int v16; // [sp+18h] [bp-Ch]@2
|
|
10480 int v17; // [sp+20h] [bp-4h]@10
|
|
10481 int a4b; // [sp+30h] [bp+Ch]@2
|
|
10482 int a4c; // [sp+30h] [bp+Ch]@9
|
|
10483 signed int a4a; // [sp+30h] [bp+Ch]@10
|
|
10484
|
|
10485 v4 = a4;
|
|
10486 v15 = a2;
|
|
10487 v14 = a1;
|
|
10488 v5 = fixpoint_mul(a2->x, a4->pFacePlane_old.vNormal.x);
|
|
10489 a4b = fixpoint_mul(a2->y, a4->pFacePlane_old.vNormal.y);
|
|
10490 v6 = fixpoint_mul(a2->z, v4->pFacePlane_old.vNormal.z);
|
|
10491 v7 = v5 + v6 + a4b;
|
|
10492 //(v16 = v5 + v6 + a4b) == 0;
|
|
10493 if (a4->uAttributes & FACE_ETHEREAL || !v7 || v7 > 0 && !v4->Portal())
|
|
10494 return 0;
|
|
10495 v8 = v4->pFacePlane_old.vNormal.z * a1->z;
|
|
10496 v9 = -(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x);
|
|
10497 if (v7 <= 0)
|
|
10498 {
|
|
10499 if (v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x < 0)
|
|
10500 return 0;
|
|
10501 }
|
|
10502 else
|
|
10503 {
|
|
10504 if (v9 < 0)
|
|
10505 return 0;
|
|
10506 }
|
|
10507 a4c = abs(-(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x)) >> 14;
|
|
10508 v11 = v14;
|
|
10509 LODWORD(v10) = v9 << 16;
|
|
10510 HIDWORD(v10) = v9 >> 16;
|
|
10511 a4a = v10 / v7;
|
|
10512 v17 = v10 / v7;
|
|
10513 LOWORD(v12) = LOWORD(v14->x) + (((unsigned int)fixpoint_mul(v17, v15->x) + 0x8000) >> 16);
|
|
10514 HIWORD(v12) = LOWORD(v11->y) + (((unsigned int)fixpoint_mul(v17, v15->y) + 0x8000) >> 16);
|
|
10515 if (a4c > abs(v7) || (v17 > *a3 << 16) || !sub_475665(v4, v12, LOWORD(v11->z) + (((unsigned int)fixpoint_mul(v17, v15->z) + 0x8000) >> 16)))
|
|
10516 return 0;
|
|
10517 *a3 = a4a >> 16;
|
|
10518 return 1;
|
|
10519 }
|
|
10520
|
|
10521 //----- (00475F30) --------------------------------------------------------
|
|
10522 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
|
|
10523 {
|
|
10524 int v10; // ST20_4@2
|
|
10525 int v11; // ST28_4@2
|
|
10526 int v12; // ST24_4@2
|
|
10527 int v13; // zf@2
|
|
10528 int v14; // edi@2
|
|
10529 signed int v16; // esi@5
|
|
10530 int v17; // ST20_4@9
|
|
10531 signed __int64 v18; // qtt@10
|
|
10532 int v19; // ST14_4@11
|
|
10533 int v22; // [sp+1Ch] [bp-8h]@2
|
|
10534 int v23; // [sp+1Ch] [bp-8h]@10
|
|
10535 signed int v24; // [sp+20h] [bp-4h]@10
|
|
10536
|
|
10537 v10 = fixpoint_mul(a6, a2->pFacePlane_old.vNormal.x);
|
|
10538 v11 = fixpoint_mul(a7, a2->pFacePlane_old.vNormal.y);
|
|
10539 v12 = fixpoint_mul(a8, a2->pFacePlane_old.vNormal.z);
|
|
10540 v13 = v10 + v12 + v11;
|
|
10541 v14 = v10 + v12 + v11;
|
|
10542 v22 = v10 + v12 + v11;
|
|
10543 if (a2->Ethereal() || !v13 || v14 > 0 && !a2->Portal())
|
|
10544 return 0;
|
|
10545 v16 = -(a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z);
|
|
10546 if (v14 <= 0)
|
|
10547 {
|
|
10548 if (a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0)
|
|
10549 return 0;
|
|
10550 }
|
|
10551 else
|
|
10552 {
|
|
10553 if (v16 < 0)
|
|
10554 return 0;
|
|
10555 }
|
|
10556 v17 = abs(-(a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14;
|
|
10557 LODWORD(v18) = v16 << 16;
|
|
10558 HIDWORD(v18) = v16 >> 16;
|
|
10559 v24 = v18 / v22;
|
|
10560 v23 = v18 / v22;
|
|
10561 LOWORD(v19) = a3 + (((unsigned int)fixpoint_mul(v23, a6) + 0x8000) >> 16);
|
|
10562 HIWORD(v19) = a4 + (((unsigned int)fixpoint_mul(v23, a7) + 0x8000) >> 16);
|
|
10563 if (v17 > abs(v14) || v23 > *a1 << 16 || !sub_4759C9(a2, a9, v19, a5 + (((unsigned int)fixpoint_mul(v23, a8) + 0x8000) >> 16)))
|
|
10564 return 0;
|
|
10565 *a1 = v24 >> 16;
|
|
10566 return 1;
|
|
10567 }
|
|
10568
|
|
10569 //----- (00479089) --------------------------------------------------------
|
|
10570 bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable)
|
|
10571 {
|
|
10572 int v3; // edi@1
|
|
10573 int v4; // ebx@1
|
|
10574 int v9; // eax@3
|
|
10575 signed int v11; // esi@6
|
|
10576 int v12; // esi@8
|
|
10577 bool result; // eax@9
|
|
10578 int v17; // [sp+1Ch] [bp-10h]@1
|
|
10579 int v19; // [sp+20h] [bp-Ch]@3
|
|
10580 int angle; // [sp+24h] [bp-8h]@1
|
|
10581
|
|
10582 angle = (signed int)(pODMRenderParams->uCameraFovInDegrees << 11) / 360 / 2;
|
|
10583 v3 = pOutdoor->pBModels[uModelID].vBoundingCenter.x - pGame->pIndoorCameraD3D->vPartyPos.x;
|
|
10584 v4 = pOutdoor->pBModels[uModelID].vBoundingCenter.y - pGame->pIndoorCameraD3D->vPartyPos.y;
|
|
10585 stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX);
|
|
10586 v17 = v3 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) + v4 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
|
|
10587 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
10588 v17 = fixpoint_mul(v17, stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX));
|
|
10589 v19 = v4 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) - v3 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
|
|
10590 v9 = int_get_vector_length(abs(v3), abs(v4), 0);
|
|
10591 //v10 = v14 * 188;
|
|
10592 //v22 = v9;
|
|
10593 *reachable = false;
|
|
10594 if (v9 < pOutdoor->pBModels[uModelID].sBoundingRadius + 256)
|
|
10595 *reachable = true;
|
|
10596 if (v19 >= 0)
|
|
10597 v11 = fixpoint_mul(stru_5C6E00->Sin(angle), v17) - fixpoint_mul(stru_5C6E00->Cos(angle), v19);
|
|
10598 else
|
|
10599 v11 = fixpoint_mul(stru_5C6E00->Cos(angle), v19) + fixpoint_mul(stru_5C6E00->Sin(angle), v17);
|
|
10600 v12 = v11 >> 16;
|
|
10601 if (v9 <= pODMRenderParams->shading_dist_mist + 2048)
|
|
10602 {
|
|
10603 //if ( abs(v12) > *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v10) + 512 )
|
|
10604 if (abs(v12) > pOutdoor->pBModels[uModelID].sBoundingRadius + 512)
|
|
10605 {
|
|
10606 result = v12 < 0;
|
|
10607 LOBYTE(result) = v12 >= 0;
|
|
10608 return result;
|
|
10609 }
|
|
10610 else
|
|
10611 return true;
|
|
10612 }
|
|
10613 return false;
|
|
10614 }
|
|
10615
|
|
10616 //----- (00479295) --------------------------------------------------------
|
|
10617 int Polygon::_479295()
|
|
10618 {
|
|
10619 int v3; // ecx@4
|
|
10620 int v4; // eax@4
|
|
10621 int v5; // edx@4
|
|
10622 // int v6; // ST14_4@5
|
|
10623 Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8
|
|
10624 int v11; // [sp+18h] [bp-4h]@4
|
|
10625
|
|
10626 if (!this->pODMFace->pFacePlane.vNormal.z)
|
|
10627 {
|
|
10628 v3 = this->pODMFace->pFacePlane.vNormal.x;
|
|
10629 v4 = -this->pODMFace->pFacePlane.vNormal.y;
|
|
10630 v5 = 0;
|
|
10631 v11 = 65536;
|
|
10632 }
|
|
10633 else if ((this->pODMFace->pFacePlane.vNormal.x || this->pODMFace->pFacePlane.vNormal.y)
|
|
10634 && abs(this->pODMFace->pFacePlane.vNormal.z) < 59082)
|
|
10635 {
|
|
10636 thisa.x = -this->pODMFace->pFacePlane.vNormal.y;
|
|
10637 thisa.y = this->pODMFace->pFacePlane.vNormal.x;
|
|
10638 thisa.z = 0;
|
|
10639 thisa.Normalize_float();
|
|
10640 v4 = thisa.x;
|
|
10641 v3 = thisa.y;
|
|
10642 v5 = 0;
|
|
10643 v11 = 65536;
|
|
10644 }
|
|
10645 else
|
|
10646 {
|
|
10647 v3 = 0;
|
|
10648 v4 = 65536;
|
|
10649 v11 = 0;
|
|
10650 v5 = -65536;
|
|
10651 }
|
|
10652 sTextureDeltaU = this->pODMFace->sTextureDeltaU;
|
|
10653 sTextureDeltaV = this->pODMFace->sTextureDeltaV;
|
|
10654 ptr_38->_48616B_frustum_odm(v4, v3, 0, 0, v5, v11);
|
|
10655 return 1;
|
|
10656 }
|
|
10657
|
|
10658
|
|
10659 unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr)
|
|
10660 {
|
|
10661 #pragma pack(push, 1)
|
|
10662 struct TGAHeader
|
|
10663 {
|
|
10664 unsigned char tgaSkip;
|
|
10665 unsigned char colourmaptype; // type of colour map 0=none, 1=has palette
|
|
10666 unsigned char tgaType; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed
|
|
10667
|
|
10668 short colourmapstart; // first colour map entry in palette
|
|
10669 short colourmaplength; // number of colours in palette
|
|
10670 char colourmapbits; // number of bits per palette entry 15,16,24,32
|
|
10671
|
|
10672 //unsigned char tgaDontCare2[9];
|
|
10673 short xstart; // image x origin
|
|
10674 short ystart; // image y origin
|
|
10675
|
|
10676 unsigned short tgaWidth;
|
|
10677 unsigned short tgaHeight;
|
|
10678 unsigned char tgaBPP;
|
|
10679
|
|
10680 char descriptor; // image descriptor bits: 00vhaaaa
|
|
10681 // h horizontal flip
|
|
10682 // v vertical flip
|
|
10683 // a alpha bits
|
|
10684 };
|
|
10685 #pragma pack(pop)
|
|
10686
|
|
10687 if (out_width)
|
|
10688 *out_width = 0;
|
|
10689 if (out_height)
|
|
10690 *out_height = 0;
|
|
10691
|
|
10692 DWORD w;
|
|
10693 void* file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
|
|
10694 if (file == INVALID_HANDLE_VALUE)
|
|
10695 return nullptr;
|
|
10696
|
|
10697 TGAHeader header;
|
|
10698 ReadFile(file, &header, sizeof(header), &w, nullptr);
|
|
10699 SetFilePointer(file, header.tgaSkip, nullptr, FILE_CURRENT);
|
|
10700
|
|
10701 if (header.tgaBPP != 24 || header.tgaType != 2)
|
|
10702 {
|
|
10703 CloseHandle(file);
|
|
10704 return nullptr;
|
|
10705 }
|
|
10706
|
|
10707 int imgSize = header.tgaWidth * header.tgaHeight * 3;
|
|
10708 unsigned char* pixels = new unsigned char[imgSize];
|
|
10709 ReadFile(file, pixels, imgSize, &w, nullptr);
|
|
10710 CloseHandle(file);
|
|
10711
|
|
10712 if (w != imgSize)
|
|
10713 {
|
|
10714 delete[] pixels;
|
|
10715 return nullptr;
|
|
10716 }
|
|
10717
|
|
10718 if (out_width)
|
|
10719 *out_width = header.tgaWidth;
|
|
10720 if (out_height)
|
|
10721 *out_height = header.tgaHeight;
|
|
10722
|
|
10723 unsigned short* pixels_16bit = new unsigned short[imgSize / 3];
|
|
10724 for (int i = 0; i < imgSize / 3; ++i)
|
|
10725 {
|
|
10726 pixels_16bit[i] = (pixels[i * 3] / 8 & 0x1F) |
|
|
10727 ((pixels[i * 3 + 1] / 4 & 0x3F) << 5) |
|
|
10728 ((pixels[i * 3 + 2] / 8 & 0x1F) << 11);
|
|
10729 }
|
|
10730 delete[] pixels;
|
|
10731 return pixels_16bit;
|
|
10732 }
|
|
10733
|
|
10734 unsigned short *skybox_xn, *skybox_xp,
|
|
10735 *skybox_yn, *skybox_yp,
|
|
10736 *skybox_zn, *skybox_zp;
|
|
10737 int skybox_width, skybox_height;
|
|
10738
|
|
10739 IDirect3DTexture2 *skybox_texture;
|
|
10740 IDirectDrawSurface4 *skybox_surface;
|
|
10741
|
|
10742 bool Skybox_Initialize(const wchar_t *skybox_name)
|
|
10743 {
|
|
10744 wchar_t xn_filename[1024], xp_filename[1024],
|
|
10745 yn_filename[1024], yp_filename[1024],
|
|
10746 zn_filename[1024], zp_filename[1024];
|
|
10747 swprintf(xn_filename, wcslen(L"%s_xn.tga"), L"%s_xn.tga", skybox_name); swprintf(xp_filename, wcslen(L"%s_xp.tga"), L"%s_xp.tga", skybox_name);
|
|
10748 swprintf(yn_filename, wcslen(L"%s_yn.tga"), L"%s_yn.tga", skybox_name); swprintf(yp_filename, wcslen(L"%s_yp.tga"), L"%s_yp.tga", skybox_name);
|
|
10749 swprintf(zn_filename, wcslen(L"%s_zn.tga"), L"%s_zn.tga", skybox_name); swprintf(zp_filename, wcslen(L"%s_zp.tga"), L"%s_zp.tga", skybox_name);
|
|
10750
|
|
10751 int xn_width, xn_height;
|
|
10752 skybox_xn = LoadTgaTexture(xn_filename, &xn_width, &xn_height);
|
|
10753 if (!skybox_xn)
|
|
10754 return false;
|
|
10755
|
|
10756 int xp_width, xp_height;
|
|
10757 skybox_xp = LoadTgaTexture(xp_filename, &xp_width, &xp_height);
|
|
10758 if (!skybox_xp || xp_width != xn_width || xp_height != xn_height)
|
|
10759 {
|
|
10760 delete[] skybox_xn;
|
|
10761 delete[] skybox_xp;
|
|
10762 return false;
|
|
10763 }
|
|
10764
|
|
10765 int yn_width, yn_height;
|
|
10766 skybox_yn = LoadTgaTexture(yn_filename, &yn_width, &yn_height);
|
|
10767 if (!skybox_yn || yn_width != xn_width || yn_height != xn_height)
|
|
10768 {
|
|
10769 delete[] skybox_xn;
|
|
10770 delete[] skybox_xp;
|
|
10771 delete[] skybox_yn;
|
|
10772 return false;
|
|
10773 }
|
|
10774
|
|
10775 int yp_width, yp_height;
|
|
10776 skybox_yp = LoadTgaTexture(yp_filename, &yp_width, &yp_height);
|
|
10777 if (!skybox_yp || yp_width != xn_width || yp_height != xn_height)
|
|
10778 {
|
|
10779 delete[] skybox_xn;
|
|
10780 delete[] skybox_xp;
|
|
10781 delete[] skybox_yn;
|
|
10782 delete[] skybox_yp;
|
|
10783 return false;
|
|
10784 }
|
|
10785
|
|
10786 int zn_width, zn_height;
|
|
10787 skybox_zn = LoadTgaTexture(zn_filename, &zn_width, &zn_height);
|
|
10788 if (!skybox_zn || zn_width != xn_width || zn_height != xn_height)
|
|
10789 {
|
|
10790 delete[] skybox_xn;
|
|
10791 delete[] skybox_xp;
|
|
10792 delete[] skybox_yn;
|
|
10793 delete[] skybox_yp;
|
|
10794 delete[] skybox_zn;
|
|
10795 return false;
|
|
10796 }
|
|
10797
|
|
10798 int zp_width, zp_height;
|
|
10799 skybox_zp = LoadTgaTexture(zp_filename, &zp_width, &zp_height);
|
|
10800 if (!skybox_zp || zp_width != xn_width || zp_height != xn_height)
|
|
10801 {
|
|
10802 delete[] skybox_xn;
|
|
10803 delete[] skybox_xp;
|
|
10804 delete[] skybox_yn;
|
|
10805 delete[] skybox_yp;
|
|
10806 delete[] skybox_zn;
|
|
10807 delete[] skybox_zp;
|
|
10808 return false;
|
|
10809 }
|
|
10810
|
|
10811 skybox_width = xn_width;
|
|
10812 skybox_height = xn_height;
|
|
10813
|
|
10814 __debugbreak();
|
|
10815 //if (!pRenderer->pRenderD3D->CreateTexture(skybox_width, skybox_height, &skybox_surface, &skybox_texture,
|
|
10816 //false, false, pRenderer->uMinDeviceTextureDim))
|
|
10817 return false;
|
|
10818
|
|
10819 return true;
|
|
10820 }
|
|
10821
|
|
10822 struct vector
|
|
10823 {
|
|
10824 float x, y, z;
|
|
10825 };
|
|
10826
|
|
10827 struct matrix
|
|
10828 {
|
|
10829 float m[4][4];
|
|
10830 };
|
|
10831
|
|
10832 void VectorNormalize(vector *v)
|
|
10833 {
|
|
10834 float invmag = 1.0f / sqrtf(v->x * v->x + v->y * v->y + v->z * v->z);
|
|
10835 v->x *= invmag;
|
|
10836 v->y *= invmag;
|
|
10837 v->z *= invmag;
|
|
10838 }
|
|
10839
|
|
10840 void MatrixRotationAxis(matrix *pout, CONST vector *pv, float angle)
|
|
10841 {
|
|
10842 memset(pout, 0, sizeof(matrix));
|
|
10843 pout->m[3][0] = 0;
|
|
10844 pout->m[3][1] = 0;
|
|
10845 pout->m[3][2] = 0;
|
|
10846 pout->m[3][3] = 1;
|
|
10847
|
|
10848 vector v;
|
|
10849 v.x = pv->x; v.y = pv->y; v.z = pv->z;
|
|
10850 VectorNormalize(&v);
|
|
10851
|
|
10852 pout->m[0][0] = (1.0f - cos(angle)) * v.x * v.x + cos(angle);
|
|
10853 pout->m[1][0] = (1.0f - cos(angle)) * v.x * v.y - sin(angle) * v.z;
|
|
10854 pout->m[2][0] = (1.0f - cos(angle)) * v.x * v.z + sin(angle) * v.y;
|
|
10855 pout->m[0][1] = (1.0f - cos(angle)) * v.y * v.x + sin(angle) * v.z;
|
|
10856 pout->m[1][1] = (1.0f - cos(angle)) * v.y * v.y + cos(angle);
|
|
10857 pout->m[2][1] = (1.0f - cos(angle)) * v.y * v.z - sin(angle) * v.x;
|
|
10858 pout->m[0][2] = (1.0f - cos(angle)) * v.z * v.x - sin(angle) * v.y;
|
|
10859 pout->m[1][2] = (1.0f - cos(angle)) * v.z * v.y + sin(angle) * v.x;
|
|
10860 pout->m[2][2] = (1.0f - cos(angle)) * v.z * v.z + cos(angle);
|
|
10861 }
|
|
10862
|
|
10863 void VectorTransform(const matrix *m, const vector *v, vector *out)
|
|
10864 {
|
|
10865 out->x = m->m[0][0] * v->x + m->m[1][0] * v->y + m->m[2][0] * v->z + m->m[3][0];
|
|
10866 out->y = m->m[0][1] * v->x + m->m[1][1] * v->y + m->m[2][1] * v->z + m->m[3][1];
|
|
10867 out->z = m->m[0][2] * v->x + m->m[1][2] * v->y + m->m[2][2] * v->z + m->m[3][2];
|
|
10868 }
|
|
10869
|
|
10870 bool DrawSkyD3D_Skybox()
|
|
10871 {
|
|
10872 static bool initialized = false,
|
|
10873 initialization_failed = false;
|
|
10874 if (initialization_failed)
|
|
10875 return false;
|
|
10876
|
|
10877 static int last_camera_rot_y,
|
|
10878 last_camera_rot_x;
|
|
10879 if (!initialized)
|
|
10880 {
|
|
10881 if (!Skybox_Initialize(L"data/skybox/stars"))
|
|
10882 {
|
|
10883 initialization_failed = true;
|
|
10884 return false;
|
|
10885 }
|
|
10886 initialized = true;
|
|
10887
|
|
10888 last_camera_rot_y = pParty->sRotationY + 1; // force update for the first run
|
|
10889 last_camera_rot_x = pParty->sRotationX + 1;
|
|
10890 }
|
|
10891
|
|
10892 /*
|
|
10893 r(y) =
|
|
10894 cos y 0 sin y 0
|
|
10895 0 1 0 0
|
|
10896 -sin y 0 cos y 0
|
|
10897 0 0 0 1
|
|
10898
|
|
10899 x cos y - z sin y
|
|
10900 y
|
|
10901 x sin y + z cos y
|
|
10902 1
|
|
10903
|
|
10904
|
|
10905
|
|
10906 r(x) = // should be r(right) actually
|
|
10907 1 0 0 0
|
|
10908 0 cos x -sin x 0
|
|
10909 0 sin x cos x 0
|
|
10910 0 0 0 1
|
|
10911
|
|
10912
|
|
10913 x
|
|
10914 y cos x + z sin x
|
|
10915 -y sin x + z cos x
|
|
10916 1
|
|
10917
|
|
10918 */
|
|
10919
|
|
10920 if (last_camera_rot_y == pParty->sRotationY &&
|
|
10921 last_camera_rot_x == pParty->sRotationX)
|
|
10922 {
|
|
10923 draw:
|
|
10924 struct RenderVertexD3D3 v[6];
|
|
10925
|
|
10926 v[0].pos.x = pViewport->uScreen_TL_X;
|
|
10927 v[0].pos.y = pViewport->uScreen_TL_Y;
|
|
10928 v[0].pos.z = 0.99989998;
|
|
10929 v[0].rhw = 1;
|
|
10930 v[0].diffuse = -1;
|
|
10931 v[0].specular = 0;
|
|
10932 v[0].texcoord.x = 0;
|
|
10933 v[0].texcoord.y = 0;
|
|
10934
|
|
10935 v[1].pos.x = pViewport->uScreen_TL_X + pViewport->uScreenWidth;
|
|
10936 v[1].pos.y = pViewport->uScreen_TL_Y + pViewport->uScreenHeight;
|
|
10937 v[1].pos.z = 0.99989998;
|
|
10938 v[1].rhw = 1;
|
|
10939 v[1].diffuse = -1;
|
|
10940 v[1].specular = 0;
|
|
10941 v[1].texcoord.x = (float)pViewport->uScreenWidth / skybox_width;
|
|
10942 v[1].texcoord.y = (float)pViewport->uScreenHeight / skybox_height;
|
|
10943
|
|
10944 v[2].pos.x = pViewport->uScreen_TL_X + pViewport->uScreenWidth;
|
|
10945 v[2].pos.y = pViewport->uScreen_TL_Y;
|
|
10946 v[2].pos.z = 0.99989998;
|
|
10947 v[2].rhw = 1;
|
|
10948 v[2].diffuse = -1;
|
|
10949 v[2].specular = 0;
|
|
10950 v[2].texcoord.x = (float)pViewport->uScreenWidth / skybox_width;
|
|
10951 v[2].texcoord.y = 0;
|
|
10952
|
|
10953 memcpy(&v[3], &v[0], sizeof(*v));
|
|
10954
|
|
10955 v[4].pos.x = pViewport->uScreen_TL_X;
|
|
10956 v[4].pos.y = pViewport->uScreen_TL_Y + pViewport->uScreenHeight;
|
|
10957 v[4].pos.z = 0.99989998;
|
|
10958 v[4].rhw = 1;
|
|
10959 v[4].diffuse = -1;
|
|
10960 v[4].specular = 0;
|
|
10961 v[4].texcoord.x = 0;
|
|
10962 v[4].texcoord.y = (float)pViewport->uScreenHeight / skybox_height;
|
|
10963
|
|
10964 memcpy(&v[5], &v[1], sizeof(*v));
|
|
10965
|
|
10966 __debugbreak();
|
|
10967 /*
|
|
10968 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
|
|
10969 pRenderer->pRenderD3D->pDevice->SetTexture(0, skybox_texture);
|
|
10970 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v, 6, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT);
|
|
10971 */
|
|
10972 return true;
|
|
10973 }
|
|
10974
|
|
10975
|
|
10976 DDSURFACEDESC2 desc;
|
|
10977 desc.dwSize = sizeof(desc);
|
|
10978 if (!pRenderer->LockSurface_DDraw4(skybox_surface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY))
|
|
10979 return false;
|
|
10980
|
|
10981 last_camera_rot_y = pParty->sRotationY;
|
|
10982 last_camera_rot_x = pParty->sRotationX;
|
|
10983
|
|
10984 float aspect = (float)pViewport->uScreenWidth / (float)pViewport->uScreenHeight;
|
|
10985 float fov_x = 3.141592f * (pODMRenderParams->uCameraFovInDegrees + 0) / 360.0f;
|
|
10986 float fov_y = fov_x / aspect;
|
|
10987
|
|
10988 float ray_dx = fov_x / (float)pViewport->uScreenWidth,
|
|
10989 ray_dy = fov_y / (float)pViewport->uScreenHeight;
|
|
10990 float party_angle_x = 2 * 3.141592653589 * pParty->sRotationX / 2048.0,
|
|
10991 party_angle_y = 2 * 3.141592653589 * pParty->sRotationY / 2048.0;
|
|
10992 for (int y = 0; y < pViewport->uScreenHeight; ++y)
|
|
10993 for (int x = 0; x < pViewport->uScreenWidth; ++x)
|
|
10994 {
|
|
10995 float angle_x = party_angle_x - (y - pViewport->uScreenHeight / 2) * ray_dy;
|
|
10996 float angle_y = party_angle_y - (x - pViewport->uScreenWidth / 2) * ray_dx;
|
|
10997
|
|
10998 float _dir_x_ = 1,
|
|
10999 _dir_y_ = 0,
|
|
11000 _dir_z_ = 0;
|
|
11001
|
|
11002 float dir_x_ = _dir_x_ * cosf(angle_y);// - _dir_z_ * sinf(angle_y); // rotation around y
|
|
11003 //float dir_y_ = _dir_y_;
|
|
11004 float dir_z_ = _dir_x_ * sinf(angle_y);// + _dir_z_ * cosf(angle_y);
|
|
11005
|
|
11006 //float dir_x = dir_x_; // rotation around x
|
|
11007 //float dir_y = /*dir_y_ * cosf(angle_x)*/ + dir_z_ * sinf(angle_x);
|
|
11008 //float dir_z = /*-dir_y_ * sinf(angle_x)*/ + dir_z_ * cosf(angle_x);
|
|
11009
|
|
11010 vector right; // rotate around right actually to avoid space distortion
|
|
11011 right.x = /*dir_y * 0*/ -dir_z_ * 1;
|
|
11012 right.y = /*dir_z_ * 0 - dir_x_ * */0;
|
|
11013 right.z = dir_x_ * 1/* - dir_y_ * 0*/;
|
|
11014 //VectorNormalize(&right);
|
|
11015
|
|
11016 matrix rightMatrix;
|
|
11017 MatrixRotationAxis(&rightMatrix, &right, angle_x);
|
|
11018
|
|
11019 vector v1, v2;
|
|
11020 v1.x = dir_x_; v1.y = 0; v1.z = dir_z_;
|
|
11021 VectorTransform(&rightMatrix, &v1, &v2);
|
|
11022
|
|
11023 float dir_x = v2.x,
|
|
11024 dir_y = v2.y,
|
|
11025 dir_z = v2.z;
|
|
11026
|
|
11027 float abs_dir_x = fabsf(dir_x),
|
|
11028 abs_dir_y = fabsf(dir_y),
|
|
11029 abs_dir_z = fabsf(dir_z);
|
|
11030
|
|
11031 unsigned short color = (0x1F << 11) | (0x1F << 5) | (5); //default to orange
|
|
11032 if (abs_dir_x >= abs_dir_y)
|
|
11033 {
|
|
11034 if (abs_dir_x >= abs_dir_z)
|
|
11035 {
|
|
11036 if (dir_x >= 0)
|
|
11037 {
|
|
11038 float instersect_y = dir_y / (2.0f * dir_x); // plane equation for this side is x + 0.5 = 0
|
|
11039 float instersect_z = dir_z / (2.0f * dir_x);
|
|
11040
|
|
11041 float u = 1.0f - (instersect_z + 0.5f),
|
|
11042 v = 1.0f - (instersect_y + 0.5f);
|
|
11043
|
|
11044 int tx = u * (skybox_width - 1),
|
|
11045 ty = v * (skybox_height - 1);
|
|
11046
|
|
11047 color = skybox_xp[ty * skybox_width + tx];
|
|
11048 //color = ty * 0x1F / skybox_height;
|
|
11049 }
|
|
11050 else
|
|
11051 {
|
|
11052 float instersect_y = dir_y / (2.0f * dir_x);
|
|
11053 float instersect_z = dir_z / (2.0f * dir_x);
|
|
11054
|
|
11055 float u = 1.0f - (instersect_z + 0.5f),
|
|
11056 v = instersect_y + 0.5f;
|
|
11057
|
|
11058 int tx = u * (skybox_width - 1),
|
|
11059 ty = v * (skybox_height - 1);
|
|
11060
|
|
11061 color = skybox_xn[ty * skybox_width + tx];
|
|
11062 //color = tx * 0x1F / skybox_height;
|
|
11063 }
|
|
11064 }
|
|
11065 else if (dir_z >= 0)
|
|
11066 goto DIR_ZP;
|
|
11067 else
|
|
11068 goto DIR_ZN;
|
|
11069 }
|
|
11070 else if (abs_dir_y >= abs_dir_z)
|
|
11071 {
|
|
11072 if (dir_y >= 0)
|
|
11073 {
|
|
11074 float instersect_x = dir_x / (2.0f * dir_y);
|
|
11075 float instersect_z = dir_z / (2.0f * dir_y);
|
|
11076
|
|
11077 float u = instersect_x + 0.5f,
|
|
11078 v = instersect_z + 0.5f;
|
|
11079
|
|
11080 int tx = u * (skybox_width - 1),
|
|
11081 ty = v * (skybox_height - 1);
|
|
11082
|
|
11083 color = skybox_yp[ty * skybox_width + tx];
|
|
11084 //color = tx * 0x1F / skybox_height;
|
|
11085 }
|
|
11086 /*else should never be seen i guess
|
|
11087 {
|
|
11088 __debugbreak();
|
|
11089 // -y
|
|
11090 //Log::Warning(L"(%03u, %03u): -y", x, y);
|
|
11091 }*/
|
|
11092 }
|
|
11093 else if (dir_z >= 0)
|
|
11094 {
|
|
11095 DIR_ZP:
|
|
11096 // +z
|
|
11097 float instersect_x = dir_x / (2.0f * dir_z);
|
|
11098 float instersect_y = dir_y / (2.0f * dir_z);
|
|
11099 //float intersect_z = 0.5f;
|
|
11100
|
|
11101 float u = instersect_x + 0.5f,
|
|
11102 v = -instersect_y + 0.5f;
|
|
11103
|
|
11104 int tx = u * (skybox_width - 1),
|
|
11105 ty = v * (skybox_height - 1);
|
|
11106
|
|
11107 color = skybox_zp[ty * skybox_width + tx];
|
|
11108 }
|
|
11109 else
|
|
11110 {
|
|
11111 DIR_ZN:
|
|
11112 // -z
|
|
11113 float instersect_x = -dir_x / (2.0f * dir_z);
|
|
11114 float instersect_y = -dir_y / (2.0f * dir_z);
|
|
11115 //float intersect_z = -0.5f;
|
|
11116
|
|
11117 float u = 1.0f - instersect_x - 0.5f,
|
|
11118 v = -instersect_y + 0.5f;
|
|
11119
|
|
11120 int tx = u * (skybox_width - 1),
|
|
11121 ty = v * (skybox_height - 1);
|
|
11122
|
|
11123 color = skybox_zn[ty * skybox_width + tx];
|
|
11124 }
|
|
11125
|
|
11126 //pRenderer->pTargetSurface[(pViewport->uScreenY + y) * pRenderer->uTargetSurfacePitch + pViewport->uScreenX + x] = color;
|
|
11127 ((unsigned __int16 *)((char *)desc.lpSurface + y * desc.lPitch))[x] = color;
|
|
11128 }
|
|
11129
|
|
11130 ErrD3D((skybox_surface)->Unlock(0));
|
|
11131 goto draw;
|
|
11132 }
|
|
11133
|
|
11134 //----- (00485F53) --------------------------------------------------------
|
|
11135 void sr_485F53(Vec2_int_ *v)
|
|
11136 {
|
|
11137 ++v->y;
|
|
11138 if (v->y > 1000)
|
|
11139 v->y = 0;
|
|
11140 }
|
|
11141
|
|
11142 //----- (0048607B) --------------------------------------------------------
|
|
11143 void Polygon::Create_48607B(stru149 *a2)
|
|
11144 {
|
|
11145 this->pTexture = 0;
|
|
11146 this->ptr_38 = a2;
|
|
11147 }
|
|
11148
|
|
11149 //----- (00486089) --------------------------------------------------------
|
|
11150 void Polygon::_normalize_v_18()
|
|
11151 {
|
|
11152 //double v2; // st7@1
|
|
11153 //double v3; // st6@1
|
|
11154 //double v5; // st5@1
|
|
11155
|
|
11156 // v2 = (double)this->v_18.x;
|
|
11157 //v3 = (double)this->v_18.y;
|
|
11158 // v5 = (double)this->v_18.z;
|
|
11159 float len = sqrt((double)this->v_18.z * (double)this->v_18.z + (double)this->v_18.y * (double)this->v_18.y + (double)this->v_18.x * (double)this->v_18.x);
|
|
11160 if (fabsf(len) < 1e-6f)
|
|
11161 {
|
|
11162 v_18.x = 0;
|
|
11163 v_18.y = 0;
|
|
11164 v_18.z = 65536;
|
|
11165 }
|
|
11166 else
|
|
11167 {
|
|
11168 v_18.x = round_to_int((double)this->v_18.x / len * 65536.0);
|
|
11169 v_18.y = round_to_int((double)this->v_18.y / len * 65536.0);
|
|
11170 v_18.y = round_to_int((double)this->v_18.z / len * 65536.0);
|
|
11171 }
|
|
11172 }
|
|
11173
|
|
11174 //----- (0048616B) --------------------------------------------------------
|
|
11175 void stru149::_48616B_frustum_odm(int a2, int a3, int a4, int a5, int a6, int a7)
|
|
11176 {
|
|
11177 int v7; // ebx@1
|
|
11178 int v9; // edi@1
|
|
11179 int v11; // edx@1
|
|
11180 int v17; // ST0C_4@6
|
|
11181 int v19; // ST0C_4@9
|
|
11182 int v24; // [sp+14h] [bp-14h]@1
|
|
11183 int v25; // [sp+18h] [bp-10h]@1
|
|
11184 int v27; // [sp+24h] [bp-4h]@1
|
|
11185
|
|
11186 v25 = pGame->pIndoorCameraD3D->int_cosine_x;
|
|
11187 v7 = pGame->pIndoorCameraD3D->int_sine_y;
|
|
11188 v27 = pGame->pIndoorCameraD3D->int_sine_x;
|
|
11189 //v8 = -pIndoorCamera->pos.y;
|
|
11190 v9 = pGame->pIndoorCameraD3D->int_cosine_y;
|
|
11191 //v26 = -pIndoorCamera->pos.z;
|
|
11192 v11 = pGame->pIndoorCameraD3D->int_cosine_y * -pGame->pIndoorCameraD3D->vPartyPos.x + pGame->pIndoorCameraD3D->int_sine_y * -pGame->pIndoorCameraD3D->vPartyPos.y;
|
|
11193 v24 = pGame->pIndoorCameraD3D->int_cosine_y * -pGame->pIndoorCameraD3D->vPartyPos.y - pGame->pIndoorCameraD3D->int_sine_y * -pGame->pIndoorCameraD3D->vPartyPos.x;
|
|
11194 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
11195 {
|
|
11196 this->field_0_party_dir_x = fixpoint_mul(v11, pGame->pIndoorCameraD3D->int_cosine_x) +
|
|
11197 fixpoint_mul((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x);
|
|
11198 this->field_4_party_dir_y = v24;
|
|
11199 this->field_8_party_dir_z = fixpoint_mul((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, v25) - fixpoint_mul(v11, v27);
|
|
11200 }
|
|
11201 else
|
|
11202 {
|
|
11203 this->field_0_party_dir_x = v11;
|
|
11204 this->field_4_party_dir_y = v24;
|
|
11205 this->field_8_party_dir_z = (-pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
|
|
11206 }
|
|
11207
|
|
11208 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
11209 {
|
|
11210 v17 = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7);
|
|
11211
|
|
11212 this->angle_from_north = fixpoint_mul(v17, v25) + fixpoint_mul(a4, v27);
|
|
11213 this->angle_from_west = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7);
|
|
11214 this->viewing_angle_from_west_east = fixpoint_mul(a4, v25) - fixpoint_mul(v17, v27);
|
|
11215 }
|
|
11216 else
|
|
11217 {
|
|
11218 this->angle_from_north = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7);
|
|
11219 this->angle_from_west = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7);
|
|
11220 this->viewing_angle_from_west_east = a4;
|
|
11221 }
|
|
11222
|
|
11223 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
11224 {
|
|
11225 v19 = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7);
|
|
11226
|
|
11227 this->angle_from_east = fixpoint_mul(v19, v25) + fixpoint_mul(a7, v27);
|
|
11228 this->angle_from_south = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7);
|
|
11229 this->viewing_angle_from_north_south = fixpoint_mul(a7, v25) - fixpoint_mul(v19, v27);
|
|
11230 }
|
|
11231 else
|
|
11232 {
|
|
11233 this->angle_from_east = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7);
|
|
11234 this->angle_from_south = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7);
|
|
11235 this->viewing_angle_from_north_south = a7;
|
|
11236 }
|
|
11237
|
|
11238 this->angle_from_east = -this->angle_from_east;
|
|
11239 this->angle_from_south = -this->angle_from_south;
|
|
11240 this->viewing_angle_from_north_south = -this->viewing_angle_from_north_south;
|
|
11241
|
|
11242 this->field_24 = fixpoint_dot(this->angle_from_north, this->field_0_party_dir_x,
|
|
11243 this->angle_from_west, this->field_4_party_dir_y,
|
|
11244 this->viewing_angle_from_west_east, this->field_8_party_dir_z);
|
|
11245 this->field_28 = fixpoint_dot(this->angle_from_east, this->field_0_party_dir_x,
|
|
11246 this->angle_from_south, this->field_4_party_dir_y,
|
|
11247 this->viewing_angle_from_north_south, this->field_8_party_dir_z);
|
|
11248 }
|
|
11249
|
|
11250 //----- (0048694B) --------------------------------------------------------
|
|
11251 void stru149::_48694B_frustum_sky()
|
|
11252 {
|
|
11253 this->angle_from_east = -this->angle_from_east;
|
|
11254 this->angle_from_south = -this->angle_from_south;
|
|
11255 this->viewing_angle_from_north_south = -this->viewing_angle_from_north_south;
|
|
11256
|
|
11257 this->field_24 = fixpoint_dot(this->angle_from_north, this->field_0_party_dir_x,
|
|
11258 this->angle_from_west, this->field_4_party_dir_y,
|
|
11259 this->viewing_angle_from_west_east, this->field_8_party_dir_z);
|
|
11260 this->field_28 = fixpoint_dot(this->angle_from_east, this->field_0_party_dir_x,
|
|
11261 this->angle_from_south, this->field_4_party_dir_y,
|
|
11262 this->viewing_angle_from_north_south, this->field_8_party_dir_z);
|
|
11263 }
|
|
11264
|