2496
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
|
6
|
2499
|
7 #include "../ZlibWrapper.h"
|
|
8 #include "../ErrorHandling.h"
|
2496
|
9
|
|
10 #include "Render.h"
|
2502
|
11 #include "Media/MediaPlayer.h"
|
2496
|
12 #include "Sprites.h"
|
2502
|
13 #include "IO/Mouse.h"
|
2499
|
14 #include "GammaControl.h"
|
2496
|
15 #include "stru6.h"
|
2502
|
16 #include "GUI/GUIWindow.h"
|
2496
|
17 #include "DecalBuilder.h"
|
|
18 #include "ParticleEngine.h"
|
|
19 #include "Outdoor.h"
|
2499
|
20 #include "../Party.h"
|
|
21 #include "../LOD.h"
|
2496
|
22 #include "Viewport.h"
|
2499
|
23 #include "../OurMath.h"
|
2496
|
24 #include "PaletteManager.h"
|
2499
|
25 #include "../Timer.h"
|
|
26 #include "../Game.h"
|
2496
|
27 #include "LightmapBuilder.h"
|
2499
|
28 #include "../Objects/ObjectList.h"
|
|
29 #include "../Objects/SpriteObject.h"
|
2496
|
30 #include "DecorationList.h"
|
2499
|
31 #include "../Objects/Actor.h"
|
|
32 #include "../Log.h"
|
|
33 #include "../MM7.h"
|
2496
|
34 #include "Lights.h"
|
2499
|
35 #include "Level/Decoration.h"
|
2496
|
36 #include "Vis.h"
|
2499
|
37 #include "../Registry.h"
|
2496
|
38 #include "Weather.h"
|
2499
|
39 #include "../MMT.h"
|
2496
|
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 {
|
2531
|
282 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 128;
|
|
283 Start_Z = 0, End_Z = 128;
|
2496
|
284 }
|
|
285 else if (direction >= 1.0 && direction < 3.0)//NorthEast(CB) - WestNorth(CÇ)
|
|
286 {
|
2531
|
287 Start_X = 0, End_X = 128;
|
2496
|
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;
|
2531
|
293 Start_Z = 0, End_Z = 128;
|
2496
|
294 }
|
|
295 else if ( direction >= 5.0 && direction < 7.0 )//SouthWest(ÞÇ) - //SouthEast(ÞÂ)
|
|
296 {
|
2531
|
297 Start_X = 0, End_X = 128;
|
|
298 Start_Z = pODMRenderParams->uMapGridCellZ - 2, End_Z = 128;
|
2496
|
299 }
|
|
300 else//SouthEast(ÞÂ) - East(B)
|
|
301 {
|
2531
|
302 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 128;
|
|
303 Start_Z = 0, End_Z = 128;
|
2496
|
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
|
2531
|
351 if ( array_73D150[0].vWorldViewPosition.x < 8.0
|
|
352 && array_73D150[1].vWorldViewPosition.x < 8.0
|
|
353 && array_73D150[2].vWorldViewPosition.x < 8.0
|
|
354 && array_73D150[3].vWorldViewPosition.x < 8.0 )
|
|
355 continue;
|
|
356 if ( (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x
|
|
357 && (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x
|
|
358 && (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x
|
|
359 && (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x )
|
|
360 continue;
|
|
361 //----------------------------------------------------------------------------
|
|
362
|
|
363 ++pODMRenderParams->uNumPolygons;
|
|
364 ++pODMRenderParams->field_44;
|
|
365 assert(pODMRenderParams->uNumPolygons < 20000);
|
|
366
|
|
367 pTilePolygon->uBModelID = 0;
|
|
368 pTilePolygon->uBModelFaceID = 0;
|
|
369 pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6;
|
|
370 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k)
|
|
371 {
|
|
372 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft));
|
|
373 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
|
|
374 }
|
2496
|
375 //shading (çàòåíåíèå)----------------------------------------------------------------------------
|
|
376 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1];
|
2531
|
377 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 1];
|
2496
|
378 assert(norm_idx < uNumTerrainNormals);
|
|
379
|
|
380 Vec3_float_* norm = &pTerrainNormals[norm_idx];
|
|
381 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) -
|
|
382 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) -
|
|
383 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0));
|
|
384 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f);
|
|
385 if ( norm_idx < 0 || norm_idx > uNumTerrainNormals - 1 )
|
|
386 norm = 0;
|
|
387 else
|
|
388 norm = &pTerrainNormals[norm_idx];
|
|
389 if (for_refactoring)
|
|
390 {
|
2531
|
391 //MessageBoxA(nullptr, "Ritor1: function StackLights_TerrainFace needed refactoring and result - slows", "", 0);
|
|
392 //__debugbreak();
|
|
393
|
|
394 pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows
|
2496
|
395 //pDecalBuilder->_49BE8A(pTilePolygon, norm, &Light_tile_dist, array_50AC10, 4, 1);
|
2531
|
396 }
|
|
397 unsigned int a5 = 4;
|
|
398
|
2496
|
399 //---------Draw distance(Äàëüíîñòü îòðèñîâêè)-------------------------------
|
|
400 int temp = pODMRenderParams->shading_dist_mist;
|
|
401 if ( draw_terrain_dist_mist )
|
|
402 pODMRenderParams->shading_dist_mist = 0x5000;
|
|
403 bool neer_clip = array_73D150[0].vWorldViewPosition.x < 8.0
|
|
404 || array_73D150[1].vWorldViewPosition.x < 8.0
|
|
405 || array_73D150[2].vWorldViewPosition.x < 8.0
|
|
406 || array_73D150[3].vWorldViewPosition.x < 8.0;
|
|
407 bool far_clip = (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x
|
|
408 || (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x
|
|
409 || (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x
|
|
410 || (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x;
|
|
411
|
2531
|
412 int v33 = 0;
|
|
413 static stru154 static_sub_0048034E_stru_154;
|
|
414 pGame->pLightmapBuilder->std__vector_000004_size = 0;
|
|
415 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
|
|
416 {
|
|
417 if ( neer_clip )
|
|
418 v33 = 3;
|
|
419 else
|
|
420 v33 = far_clip != 0 ? 5 : 0;
|
|
421 static_sub_0048034E_stru_154.ClassifyPolygon(norm, Light_tile_dist);
|
|
422 if ( pDecalBuilder->uNumDecals > 0 )
|
|
423 pDecalBuilder->ApplyDecals(31 - pTilePolygon->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1);
|
|
424 if ( stru_F8AD28.uNumLightsApplied > 0 )
|
|
425 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33);
|
|
426 }
|
2496
|
427
|
|
428 if ( !byte_4D864C || ~pGame->uFlags & 0x80 )
|
|
429 {
|
|
430 //if ( neer_clip ) //Ritor1: Äà¸ò èñêàæåíèÿ íà ïîäú¸ìå, âîçìîæíî òðåáóåòñÿ ô-öèÿ Áåçüå
|
|
431 //{
|
|
432 // pTilePolygon->uNumVertices = ODM_NearClip(pTilePolygon->uNumVertices);
|
|
433 // ODM_Project(pTilePolygon->uNumVertices);
|
|
434 //}
|
|
435 if ( far_clip )
|
|
436 {
|
|
437 pTilePolygon->uNumVertices = ODM_FarClip(pTilePolygon->uNumVertices);
|
|
438 ODM_Project(pTilePolygon->uNumVertices);
|
|
439 }
|
|
440 }
|
|
441 pODMRenderParams->shading_dist_mist = temp;
|
|
442
|
|
443 // check the transparency and texture (tiles) mapping (ïðîâåðêà ïðîçðà÷íîñòè è íàëîæåíèå òåêñòóð (òàéëîâ))----------------------
|
|
444 bool transparent = false;
|
|
445 if ( !( pTilePolygon->flags & 1 ) ) // íå ïîääåðæèâàåòñÿ TextureFrameTable
|
|
446 {
|
|
447 if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id)
|
|
448 {
|
|
449 //transparent = false;
|
|
450 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
|
|
451 }
|
|
452 else
|
|
453 {
|
|
454 v6 = pTilePolygon->uTileBitmapID;
|
|
455 if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) )
|
|
456 transparent = true;
|
|
457 }
|
|
458
|
|
459 assert(v6 < 1000); // many random crashes here
|
|
460
|
|
461 // for all shore tiles - draw a tile water under them since they're half-empty
|
|
462 if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX
|
|
463 DrawBorderTiles(pTilePolygon);
|
|
464
|
|
465 pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true);
|
|
466 }
|
|
467 //else //çäåñü óæå ïîãðàíè÷íûå òàéëû âîäû
|
|
468 //pTile->DrawBorderTiles();
|
|
469 //--------------------------------------------------------------------------------------------------------------------------------
|
|
470
|
|
471 --pODMRenderParams->uNumPolygons;
|
|
472 --pODMRenderParams->field_44;
|
|
473 }
|
|
474 }
|
|
475 }
|
|
476
|
|
477 //----- (004811A3) --------------------------------------------------------
|
|
478 void Render::DrawBorderTiles(struct Polygon *poly)
|
|
479 {
|
|
480 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false);
|
|
481 DrawTerrainPolygon(poly->uNumVertices, poly,
|
|
482 pBitmaps_LOD->pHardwareTextures[pHDWaterBitmapIDs[hd_water_current_frame]], false, true);
|
|
483
|
|
484 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true);
|
|
485 //DrawTerrainPolygon(poly->uNumVertices, poly, pBitmaps_LOD->pHardwareTextures[poly->uTileBitmapID], true, true);
|
|
486 }
|
|
487
|
|
488
|
|
489 //----- (0047BACF) --------------------------------------------------------
|
|
490 void Render::TransformBillboardsAndSetPalettesODM()
|
|
491 {
|
|
492 //int v0; // edi@1
|
|
493 //char *v1; // esi@2
|
|
494 //unsigned int v2; // edx@3
|
|
495 //int v3; // eax@3
|
|
496 //int v4; // edi@3
|
|
497 //int v5; // eax@3
|
|
498 //__int16 v6; // di@3
|
|
499 //int v7; // eax@3
|
|
500 //int v8; // ebx@4
|
|
501 // unsigned __int16 *v9; // eax@7
|
|
502 // char v10; // zf@9
|
|
503 //DWORD v11; // eax@13
|
|
504 // int v12; // eax@13
|
|
505 // int v13; // eax@14
|
|
506 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1
|
|
507 // int v15; // [sp+54h] [bp-10h]@13
|
|
508 //int v16; // [sp+58h] [bp-Ch]@1
|
|
509 //int v17; // [sp+5Ch] [bp-8h]@2
|
|
510 // int v18; // [sp+60h] [bp-4h]@13
|
|
511
|
|
512 billboard.sParentBillboardID = -1;
|
|
513 billboard.pTarget = pRenderer->pTargetSurface;
|
|
514 billboard.pTargetZ = pRenderer->pActiveZBuffer;
|
|
515 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch;
|
|
516 billboard.uViewportX = pViewport->uViewportTL_X;
|
|
517 billboard.uViewportY = pViewport->uViewportTL_Y;
|
|
518 billboard.uViewportZ = pViewport->uViewportBR_X - 1;
|
|
519 billboard.uViewportW = pViewport->uViewportBR_Y;
|
|
520 pODMRenderParams->uNumBillboards = uNumBillboardsToDraw;
|
|
521
|
|
522 for (unsigned int i = 0; i < ::uNumBillboardsToDraw; ++i)
|
|
523 {
|
|
524 billboard.uScreenSpaceX = pBillboardRenderList[i].uScreenSpaceX;
|
|
525 billboard.uScreenSpaceY = pBillboardRenderList[i].uScreenSpaceY;
|
|
526 billboard.sParentBillboardID = i;
|
|
527 billboard._screenspace_x_scaler_packedfloat = pBillboardRenderList[i]._screenspace_x_scaler_packedfloat;
|
|
528 billboard.sTintColor = pBillboardRenderList[i].sTintColor;
|
|
529 billboard._screenspace_y_scaler_packedfloat = pBillboardRenderList[i]._screenspace_y_scaler_packedfloat;
|
|
530 billboard.sZValue = pBillboardRenderList[i].sZValue;
|
|
531 billboard.uFlags = pBillboardRenderList[i].field_1E;
|
|
532 if (pBillboardRenderList[i].HwSpriteID != -1)
|
|
533 {
|
|
534 if (!pRenderD3D) __debugbreak(); // no sw rendering
|
|
535 //if (pRenderer->pRenderD3D)
|
|
536 TransformBillboard(&billboard,
|
|
537 &pSprites_LOD->pHardwareSprites[pBillboardRenderList[i].HwSpriteID],
|
|
538 pBillboardRenderList[i].dimming_level, &pBillboardRenderList[i]);
|
|
539 /*else
|
|
540 {
|
|
541 assert(false);
|
|
542
|
|
543 auto v1 = (char *)&pBillboard->uScreenSpaceY;
|
|
544 if ( *(v1 - 10) & 2 )
|
|
545 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1);
|
|
546 else
|
|
547 v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1));
|
|
548 v10 = (*(v1 - 9) & 1) == 0;
|
|
549 billboard.pPalette = v9;
|
|
550 if ( !v10 )
|
|
551 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)];
|
|
552 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 )
|
|
553 {
|
|
554 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount());
|
|
555 v15 = abs(v12);
|
|
556 v18 = (unsigned __int64)(15i64 * v15) >> 16;
|
|
557 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1);
|
|
558 }
|
|
559 v13 = *((short *)v1 - 8);
|
|
560 if ( v13 >= 0 )
|
|
561 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1);
|
|
562 }*/
|
|
563 }
|
|
564 }
|
|
565 }
|
|
566
|
|
567 //----- (0047AF11) --------------------------------------------------------
|
|
568 void Render::DrawSpriteObjects_ODM()
|
|
569 {
|
|
570 SpriteFrame *frame; // eax@10
|
|
571 unsigned int v6; // eax@10
|
|
572 int v9; // ecx@10
|
|
573 int v17; // ecx@25
|
|
574 int v18; // eax@25
|
|
575 // int v22; // ST3C_4@29
|
|
576 signed __int64 v23; // qtt@30
|
|
577 int v26; // eax@31
|
|
578 // char v27; // zf@31
|
|
579 int v30; // [sp+14h] [bp-2Ch]@23
|
|
580 int v37; // [sp+1Ch] [bp-24h]@23
|
|
581 int a6; // [sp+20h] [bp-20h]@10
|
|
582 int v42; // [sp+2Ch] [bp-14h]@23
|
|
583 int y; // [sp+30h] [bp-10h]@10
|
|
584 int x; // [sp+34h] [bp-Ch]@10
|
|
585 int z; // [sp+38h] [bp-8h]@10
|
|
586 signed __int16 v46; // [sp+3Ch] [bp-4h]@12
|
|
587
|
|
588 //v41 = 0;
|
|
589 for (unsigned int i = 0; i < uNumSpriteObjects; ++i)
|
|
590 {
|
|
591 SpriteObject* object = &pSpriteObjects[i];
|
|
592 //auto v0 = (char *)&pSpriteObjects[i].uSectorID;
|
|
593 //v0 = (char *)&pSpriteObjects[0].uSectorID;
|
|
594 //do
|
|
595 //{
|
|
596 if (!object->uObjectDescID) // item probably pciked up
|
|
597 continue;
|
|
598
|
|
599 assert(object->uObjectDescID < pObjectList->uNumObjects);
|
|
600 ObjectDesc* object_desc = &pObjectList->pObjects[object->uObjectDescID];
|
|
601 if (object_desc->NoSprite())
|
|
602 continue;
|
|
603
|
|
604 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)];
|
|
605 //if ( !(v1->uFlags & 1) )
|
|
606 //{
|
|
607 //v2 = *((short *)v0 - 14)
|
|
608 //v2 = object->uType;
|
|
609 if ( (object->uType < 1000 || object->uType >= 10000) && (object->uType < 500 || object->uType >= 600)
|
|
610 || pGame->pStru6Instance->_4A81CA(object) )
|
|
611 {
|
|
612 //a5 = *(short *)v0;
|
|
613 x = object->vPosition.x;
|
|
614 y = object->vPosition.y;
|
|
615 z = object->vPosition.z;
|
|
616 frame = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID);
|
|
617 a6 = frame->uGlowRadius * object->field_22_glow_radius_multiplier;
|
|
618 v6 = stru_5C6E00->Atan2(object->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y);
|
|
619 //LOWORD(v7) = object->uFacing;
|
|
620 //v8 = v36;
|
|
621 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7;
|
|
622 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[v9];
|
|
623 if ( frame->uFlags & 0x20 )
|
|
624 {
|
|
625 //v8 = v36;
|
|
626 z -= fixpoint_mul(frame->scale, pSprites_LOD->pSpriteHeaders[(signed __int16)frame->pHwSpriteIDs[v9]].uHeight) / 2;
|
|
627 }
|
|
628 v46 = 0;
|
|
629 if ( frame->uFlags & 2 )
|
|
630 v46 = 2;
|
|
631 //v11 = (int *)(256 << v9);
|
|
632 if ( (256 << v9) & frame->uFlags )
|
|
633 v46 |= 4;
|
|
634 if ( frame->uFlags & 0x40000 )
|
|
635 v46 |= 0x40;
|
|
636 if ( frame->uFlags & 0x20000 )
|
|
637 LOBYTE(v46) = v46 | 0x80;
|
|
638 if ( a6 )
|
|
639 {
|
|
640 //LOBYTE(v11) = _4E94D3_light_type;
|
|
641 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFF, 0xFF, 0xFF, _4E94D3_light_type);
|
|
642 }
|
|
643 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
644 {
|
|
645 v30 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y)
|
|
646 + fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y);
|
|
647 v37 = fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_sine_y);
|
|
648 v42 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x)
|
|
649 + fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_cosine_x);
|
|
650 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 )
|
|
651 {
|
|
652 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y) - v37;
|
|
653 v18 = fixpoint_mul((z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x)
|
|
654 - fixpoint_mul(v30, pGame->pIndoorCameraD3D->int_sine_x);
|
|
655 if ( abs(v42) >= abs(v17) )
|
|
656 {
|
|
657 LODWORD(v23) = 0;
|
|
658 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad);
|
|
659
|
|
660 object->uAttributes |= 1;
|
|
661 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex;
|
|
662 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID;
|
|
663 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42);
|
|
664 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame;
|
|
665 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42);
|
|
666 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46;
|
|
667 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x;
|
|
668 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y;
|
|
669 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z;
|
|
670 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16);
|
|
671 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16);
|
|
672 HIWORD(v26) = HIWORD(v42);
|
|
673 LOWORD(v26) = 0;
|
|
674 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i));
|
|
675 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0;
|
|
676 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0;
|
|
677 if ( !(object->uAttributes & 0x20) )
|
|
678 {
|
|
679 if ( !pRenderD3D )
|
|
680 {
|
|
681 __debugbreak();
|
|
682 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0;
|
|
683 }
|
|
684 }
|
|
685 //if (::uNumBillboardsToDraw >= 500)
|
|
686 // return;
|
|
687 assert(::uNumBillboardsToDraw < 500);
|
|
688 ++::uNumBillboardsToDraw;
|
|
689 ++uNumSpritesDrawnThisFrame;
|
|
690 }
|
|
691 }
|
|
692 }
|
|
693 else
|
|
694 {
|
|
695 v42 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_sine_y)
|
|
696 + fixpoint_mul((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16, pGame->pIndoorCameraD3D->int_cosine_y);
|
|
697 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 )
|
|
698 {
|
|
699 v17 = fixpoint_mul((y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16, pGame->pIndoorCameraD3D->int_cosine_y)
|
|
700 - fixpoint_mul(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16), pGame->pIndoorCameraD3D->int_sine_y);
|
|
701 v18 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
|
|
702 if ( abs(v42) >= abs(v17) )
|
|
703 {
|
|
704 LODWORD(v23) = 0;
|
|
705 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad);
|
|
706
|
|
707 object->uAttributes |= 1;
|
|
708 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex;
|
|
709 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID;
|
|
710 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42);
|
|
711 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame;
|
|
712 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42);
|
|
713 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46;
|
|
714 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x;
|
|
715 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y;
|
|
716 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z;
|
|
717 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16);
|
|
718 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16);
|
|
719 HIWORD(v26) = HIWORD(v42);
|
|
720 LOWORD(v26) = 0;
|
|
721 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i));
|
|
722 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0;
|
|
723 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0;
|
|
724 if ( !(object->uAttributes & 0x20) )
|
|
725 {
|
|
726 if ( !pRenderD3D )
|
|
727 {
|
|
728 __debugbreak();
|
|
729 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0;
|
|
730 }
|
|
731 }
|
|
732 //if (::uNumBillboardsToDraw >= 500)
|
|
733 // return;
|
|
734 assert(::uNumBillboardsToDraw < 500);
|
|
735 ++::uNumBillboardsToDraw;
|
|
736 ++uNumSpritesDrawnThisFrame;
|
|
737 }
|
|
738 }
|
|
739 }
|
|
740 }
|
|
741 }
|
|
742 }
|
|
743
|
|
744 //----- (0049D9BC) --------------------------------------------------------
|
|
745 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut)
|
|
746 {
|
|
747 size_t v4; // eax@1
|
|
748 size_t v5; // eax@1
|
|
749 size_t v7; // eax@13
|
|
750 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11
|
|
751 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16*/
|
|
752 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14
|
|
753 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14
|
|
754 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19
|
|
755 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18
|
|
756 int is_there_a_compatible_screen_mode; // [sp+4C8h] [bp-34h]@16
|
|
757 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1
|
|
758 LPDIRECTDRAW pDirectDraw = nullptr; // [sp+4F4h] [bp-8h]@4
|
|
759 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7
|
|
760
|
|
761 v4 = strlen(lpDriverName);
|
|
762 v20.pDriverName = new char[v4 + 1];
|
|
763 v5 = strlen(lpDevDesc);
|
|
764 v20.pDeviceDesc = new char[v5 + 1];
|
|
765 strcpy(v20.pDriverName, lpDriverName);
|
|
766 strcpy(v20.pDeviceDesc, lpDevDesc);
|
|
767 if ( lpGUID )
|
|
768 {
|
|
769 v20.pGUID = new GUID;
|
|
770 memcpy(v20.pGUID, lpGUID, 0x10);
|
|
771 }
|
|
772 else
|
|
773 v20.pGUID = 0;
|
|
774
|
|
775 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0)))
|
|
776 {
|
|
777 delete [] v20.pDriverName;
|
|
778 delete [] v20.pDeviceDesc;
|
|
779 delete v20.pGUID;
|
|
780 }
|
|
781 else
|
|
782 {
|
|
783 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4)))
|
|
784 {
|
|
785 delete [] v20.pDriverName;
|
|
786 delete [] v20.pDeviceDesc;
|
|
787 delete v20.pGUID;
|
|
788 pDirectDraw->Release();
|
|
789 }
|
|
790 else
|
|
791 {
|
|
792 pDirectDraw->Release();
|
|
793 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1)))
|
|
794 v20.pDDraw4DevDesc = 0;
|
|
795 else
|
|
796 {
|
|
797 v7 = strlen(ddDevId.szDescription);
|
|
798 v20.pDDraw4DevDesc = new char[v7 + 1];
|
|
799 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription);
|
|
800 }
|
|
801 memset(&ddsCaps, 0, sizeof(ddsCaps));
|
|
802 if (FAILED(pDirectDraw4->GetAvailableVidMem(&ddsCaps, (LPDWORD)&v20.uVideoMem, (LPDWORD)&uFreeVideoMem)))
|
|
803 v20.uVideoMem = 0;
|
|
804 memset(&v10, 0, sizeof(v10));
|
|
805 v10.dwSize = 124;
|
|
806 v10.dwFlags = 6;
|
|
807 v10.dwHeight = window->GetWidth();
|
|
808 v10.dwWidth = window->GetHeight();
|
|
809 v10.ddpfPixelFormat.dwSize = 32;
|
|
810
|
|
811 is_there_a_compatible_screen_mode = false;
|
|
812 if ( FAILED(pDirectDraw4->EnumDisplayModes(0, 0, &is_there_a_compatible_screen_mode, (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator))
|
|
813 || !is_there_a_compatible_screen_mode
|
|
814 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3)))
|
|
815 {
|
|
816 delete [] v20.pDriverName;
|
|
817 delete [] v20.pDeviceDesc;
|
|
818 //free(v20.pDDraw4DevDesc);
|
|
819 delete [] v20.pDDraw4DevDesc;
|
|
820 delete v20.pGUID;
|
|
821 pDirectDraw4->Release();
|
|
822 }
|
|
823 else
|
|
824 {
|
|
825 aux.pInfo = pOut;
|
|
826 aux.ptr_4 = &v20;
|
|
827 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux);
|
|
828 delete [] v20.pDriverName;
|
|
829 delete [] v20.pDeviceDesc;
|
|
830 delete [] v20.pDDraw4DevDesc;
|
|
831 delete v20.pGUID;
|
|
832 pDirectDraw4->Release();
|
|
833 pDirectDraw4 = 0;
|
|
834 pDirect3D3->Release();
|
|
835 }
|
|
836 }
|
|
837 }
|
|
838 return 1;
|
|
839 }
|
|
840
|
|
841 //----- (0049D784) --------------------------------------------------------
|
|
842 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6)
|
|
843 {
|
|
844 signed int v7; // edi@1
|
|
845
|
|
846 v7 = -1;
|
|
847 if ( pHWDesc->dwFlags )
|
|
848 {
|
|
849 if ( !a6->ptr_4->pGUID )
|
|
850 v7 = 0;
|
|
851 if ( pHWDesc->dwFlags && a6->ptr_4->pGUID )
|
|
852 v7 = 1;
|
|
853 }
|
|
854 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID )
|
|
855 v7 = 2;
|
|
856 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID )
|
|
857 v7 = 3;
|
|
858 if ( v7 != -1 )
|
|
859 {
|
|
860 a6->pInfo[v7].bIsDeviceCompatible = 1;
|
|
861 a6->pInfo[v7].uCaps = 0;
|
|
862 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) )
|
|
863 a6->pInfo[v7].uCaps |= 2;
|
|
864 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) )
|
|
865 a6->pInfo[v7].uCaps |= 4;
|
|
866 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) )
|
|
867 a6->pInfo[v7].uCaps |= 8;
|
|
868 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) )
|
|
869 a6->pInfo[v7].uCaps |= 16;
|
|
870 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) )
|
|
871 a6->pInfo[v7].uCaps |= 32;
|
|
872 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) )
|
|
873 a6->pInfo[v7].uCaps |= 64;
|
|
874 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) )
|
|
875 BYTE1(a6->pInfo[v7].uCaps) |= 1;
|
|
876 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 )
|
|
877 LOBYTE(a6->pInfo[v7].uCaps) |= 0x80;
|
|
878
|
|
879 a6->pInfo[v7].pName = new char[strlen(lpDeviceName) + 1];
|
|
880 strcpy(a6->pInfo[v7].pName, lpDeviceName);
|
|
881
|
|
882 a6->pInfo[v7].pDescription = new char[strlen(lpDeviceDesc) + 1];
|
|
883 strcpy(a6->pInfo[v7].pDescription, lpDeviceDesc);
|
|
884
|
|
885 a6->pInfo[v7].pGUID = new GUID;
|
|
886 memcpy(a6->pInfo[v7].pGUID, lpGUID, 0x10);
|
|
887
|
|
888 a6->pInfo[v7].pDriverName = new char[strlen(a6->ptr_4->pDriverName) + 1];
|
|
889 strcpy(a6->pInfo[v7].pDriverName, a6->ptr_4->pDriverName);
|
|
890
|
|
891 a6->pInfo[v7].pDeviceDesc = new char[strlen(a6->ptr_4->pDeviceDesc) + 1];
|
|
892 strcpy(a6->pInfo[v7].pDeviceDesc, a6->ptr_4->pDeviceDesc);
|
|
893
|
|
894 a6->pInfo[v7].pDDraw4DevDesc = new char[strlen(a6->ptr_4->pDDraw4DevDesc) + 1];
|
|
895 strcpy(a6->pInfo[v7].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc);
|
|
896
|
|
897 if ( a6->ptr_4->pGUID )
|
|
898 {
|
|
899 a6->pInfo[v7].pDirectDrawGUID = new GUID;
|
|
900 memcpy(a6->pInfo[v7].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10);
|
|
901 }
|
|
902 else
|
|
903 a6->pInfo[v7].pDirectDrawGUID = 0;
|
|
904 a6->pInfo[v7].uVideoMem = a6->ptr_4->uVideoMem;
|
|
905 }
|
|
906 return 1;
|
|
907 }
|
|
908
|
|
909 //----- (0049D75C) --------------------------------------------------------
|
|
910 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *found_compatible_mode)
|
|
911 {
|
|
912 if ( pSurfaceDesc->ddsCaps.dwCaps | DDSCAPS_3DDEVICE /*&& pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16*/ )
|
|
913 {
|
|
914 *found_compatible_mode = 1;
|
|
915 return S_OK;
|
|
916 }
|
|
917 return 1;
|
|
918 }
|
|
919
|
|
920 //----- (0047A95E) --------------------------------------------------------
|
|
921 void Render::PrepareDecorationsRenderList_ODM()
|
|
922 {
|
|
923 unsigned int v6; // edi@9
|
|
924 int v7; // eax@9
|
2508
|
925 SpriteFrame *frame; // eax@9
|
2496
|
926 unsigned __int16 *v10; // eax@9
|
|
927 int v13; // ecx@9
|
2532
|
928 char r; // ecx@20
|
|
929 char g; // dl@20
|
|
930 char b_; // eax@20
|
2496
|
931 int v17; // eax@23
|
|
932 int v18; // ecx@24
|
|
933 int v19; // eax@24
|
|
934 int v20; // ecx@24
|
|
935 int v21; // ebx@26
|
|
936 int v22; // eax@26
|
|
937 signed __int64 v24; // qtt@31
|
|
938 int v25; // ebx@31
|
|
939 __int16 v29; // cx@37
|
|
940 int v30; // ecx@37
|
|
941 int v31; // ebx@37
|
|
942 Particle_sw local_0; // [sp+Ch] [bp-98h]@7
|
|
943 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9
|
|
944 int v38; // [sp+88h] [bp-1Ch]@9
|
|
945 int v40; // [sp+90h] [bp-14h]@24
|
|
946 int v41; // [sp+94h] [bp-10h]@24
|
|
947 int v42; // [sp+98h] [bp-Ch]@9
|
|
948 int b; // [sp+A0h] [bp-4h]@22
|
|
949
|
|
950 for (unsigned int i = 0; i < uNumLevelDecorations; ++i)
|
|
951 {
|
|
952 //LevelDecoration* decor = &pLevelDecorations[i];
|
|
953 if ((!(pLevelDecorations[i].uFlags & LEVEL_DECORATION_OBELISK_CHEST)
|
|
954 || pLevelDecorations[i].IsObeliskChestActive()) && !(pLevelDecorations[i].uFlags & LEVEL_DECORATION_INVISIBLE))
|
|
955 {
|
|
956 DecorationDesc* decor_desc = &pDecorationList->pDecorations[pLevelDecorations[i].uDecorationDescID];
|
|
957 if ( (char)decor_desc->uFlags >= 0 )
|
|
958 {
|
|
959 if ( !(decor_desc->uFlags & 0x22) )
|
|
960 {
|
|
961 v6 = pMiscTimer->uTotalGameTimeElapsed;
|
|
962 v7 = abs(pLevelDecorations[i].vPosition.x + pLevelDecorations[i].vPosition.y);
|
|
963
|
|
964 #pragma region "New: seasons change"
|
|
965 extern bool change_seasons;
|
|
966 if (change_seasons)
|
|
967 switch (pParty->uCurrentMonth)
|
|
968 {
|
|
969 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites
|
|
970 case 11: case 0: case 1: // winter
|
|
971 switch (decor_desc->uSpriteID)
|
|
972 {
|
|
973 //case 468: //bush02 grows on swamps, which are evergreeen actually
|
|
974 case 548: // flower10
|
|
975 case 547: // flower09
|
|
976 case 541: // flower03
|
|
977 case 539: continue; // flower01
|
|
978
|
|
979 case 483: // tree01
|
|
980 case 486: // tree04
|
|
981 case 492: // tree10
|
|
982 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2);
|
2508
|
983 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7);
|
2496
|
984 break;
|
|
985
|
|
986 default:
|
2508
|
987 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
|
2496
|
988 }
|
|
989 break;
|
|
990
|
|
991 case 2: case 3: case 4: // spring
|
|
992 switch (decor_desc->uSpriteID)
|
|
993 {
|
|
994 }
|
2508
|
995 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
|
2496
|
996 break;
|
|
997
|
|
998 case 8: case 9: case 10: // autumn
|
|
999 switch (decor_desc->uSpriteID)
|
|
1000 {
|
|
1001 //case 468: //bush02 grows on swamps, which are evergreeen actually
|
|
1002 case 548: // flower10
|
|
1003 case 547: // flower09
|
|
1004 case 541: // flower03
|
|
1005 case 539: continue; // flower01
|
|
1006
|
|
1007 case 483: // tree01
|
|
1008 case 486: // tree04
|
|
1009 case 492: // tree10
|
|
1010 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1);
|
2508
|
1011 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7);
|
2496
|
1012 break;
|
|
1013
|
|
1014 default:
|
2508
|
1015 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
|
2496
|
1016 }
|
|
1017 break;
|
|
1018
|
|
1019 case 5: case 6: case 7: // summer
|
|
1020 //all green by default
|
2508
|
1021 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
|
2496
|
1022 break;
|
|
1023
|
|
1024 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12);
|
|
1025 }
|
|
1026 else
|
2508
|
1027 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
|
2496
|
1028 #pragma endregion
|
|
1029 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
|
|
1030
|
|
1031 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x,
|
|
1032 pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y);
|
|
1033 v38 = 0;
|
|
1034 v13 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + pLevelDecorations[i].field_10_y_rot - (signed int)v10) >> 8) & 7;
|
|
1035 v37 = (unsigned __int16 *)v13;
|
2508
|
1036 if ( frame->uFlags & 2 )
|
2496
|
1037 v38 = 2;
|
2508
|
1038 if ( (256 << v13) & frame->uFlags )
|
2496
|
1039 v38 |= 4;
|
2508
|
1040 if ( frame->uFlags & 0x40000 )
|
2496
|
1041 v38 |= 0x40;
|
2508
|
1042 if ( frame->uFlags & 0x20000 )
|
2496
|
1043 LOBYTE(v38) = v38 | 0x80;
|
2532
|
1044
|
|
1045 //for light
|
2508
|
1046 if ( frame->uGlowRadius )
|
2496
|
1047 {
|
2532
|
1048 r = 255;
|
|
1049 g = 255;
|
|
1050 b_ = 255;
|
|
1051 if ( /*pRenderD3D &&*/ bUseColoredLights )
|
2496
|
1052 {
|
2532
|
1053 r = /*255;//*/decor_desc->uColoredLightRed;
|
|
1054 g = /*255;//*/decor_desc->uColoredLightGreen;
|
|
1055 b_ = /*255;//*/decor_desc->uColoredLightBlue;
|
2496
|
1056 }
|
2532
|
1057 pStationaryLightsStack->AddLight(pLevelDecorations[i].vPosition.x,
|
|
1058 pLevelDecorations[i].vPosition.y,
|
|
1059 pLevelDecorations[i].vPosition.z + decor_desc->uDecorationHeight / 2,
|
|
1060 frame->uGlowRadius, r, g, b_, _4E94D0_light_type);
|
|
1061 }//for light
|
|
1062
|
2496
|
1063 v17 = (pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16;
|
|
1064 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
1065 {
|
|
1066 v40 = (pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16;
|
|
1067 v18 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y);
|
|
1068 v41 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x);
|
|
1069 v19 = fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_cosine_x);
|
|
1070 v20 = v19 + fixpoint_mul((pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x);
|
|
1071 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 )
|
|
1072 {
|
|
1073 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_sine_y);
|
|
1074 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);
|
|
1075 if ( 2 * abs(v20) >= abs(v21) )
|
|
1076 {
|
|
1077 LODWORD(v24) = 0;
|
|
1078 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad);
|
|
1079 v25 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v24 / v20, v21) + 0x8000) >> 16);
|
|
1080 v40 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(v24 / v20, v22) + 0x8000) >> 16);
|
2508
|
1081 v41 = fixpoint_mul(frame->scale, v24 / v20);
|
2496
|
1082 if ( pRenderD3D )
|
2508
|
1083 b = fixpoint_mul(pSprites_LOD->pHardwareSprites[frame->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41);
|
2496
|
1084 else
|
|
1085 {
|
|
1086 __debugbreak();
|
2508
|
1087 b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[frame->pHwSpriteIDs[(int)v37]].uWidth / 2, v41);
|
2496
|
1088 }
|
|
1089 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X )
|
|
1090 {
|
|
1091 if (::uNumBillboardsToDraw >= 500)
|
|
1092 return;
|
2508
|
1093 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[(int)v37];
|
2496
|
1094 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41;
|
|
1095 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41;
|
|
1096 v29 = v38;
|
|
1097 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25;
|
|
1098 HIBYTE(v29) |= 2;
|
2508
|
1099 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex;
|
2496
|
1100 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29;
|
|
1101 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x;
|
|
1102 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y;
|
|
1103 pBillboardRenderList[::uNumBillboardsToDraw].world_z = pLevelDecorations[i].vPosition.z;
|
|
1104 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40;
|
|
1105 HIWORD(v30) = HIWORD(v20);
|
|
1106 v31 = PID(OBJECT_Decoration,i);
|
|
1107 LOWORD(v30) = 0;
|
|
1108 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0;
|
|
1109 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31;
|
|
1110 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0;
|
2508
|
1111 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame;
|
2496
|
1112 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0;
|
|
1113 ::uNumBillboardsToDraw++;
|
|
1114 ++uNumDecorationsDrawnThisFrame;
|
|
1115 }
|
|
1116 }
|
|
1117 continue;
|
|
1118 }
|
|
1119 }
|
|
1120 else
|
|
1121 {
|
|
1122 v42 = (pLevelDecorations[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16;
|
|
1123 v40 = (pLevelDecorations[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16;
|
|
1124 v20 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y);
|
|
1125 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 )
|
|
1126 {
|
|
1127 v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_y);
|
|
1128 v22 = (pLevelDecorations[i].vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
|
|
1129 v42 = v22;
|
|
1130 if ( 2 * abs(v20) >= abs(v21) )
|
|
1131 {
|
|
1132 LODWORD(v24) = 0;
|
|
1133 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad);
|
|
1134 v25 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v24 / v20, v21) + 0x8000) >> 16);
|
|
1135 v40 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(v24 / v20, v42) + 0x8000) >> 16);
|
2508
|
1136 v41 = fixpoint_mul(frame->scale, v24 / v20);
|
2496
|
1137 if ( pRenderD3D )
|
2508
|
1138 b = fixpoint_mul(pSprites_LOD->pHardwareSprites[frame->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41);
|
2496
|
1139 else
|
|
1140 {
|
|
1141 __debugbreak();
|
2508
|
1142 b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[frame->pHwSpriteIDs[(int)v37]].uWidth / 2, v41);
|
2496
|
1143 }
|
|
1144 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X )
|
|
1145 {
|
|
1146 if (::uNumBillboardsToDraw >= 500)
|
|
1147 return;
|
2508
|
1148 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[(int)v37];
|
2496
|
1149 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41;
|
|
1150 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41;
|
|
1151 v29 = v38;
|
|
1152 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25;
|
|
1153 HIBYTE(v29) |= 2;
|
2508
|
1154 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex;
|
2496
|
1155 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29;
|
|
1156 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x;
|
|
1157 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y;
|
|
1158 pBillboardRenderList[::uNumBillboardsToDraw].world_z = pLevelDecorations[i].vPosition.z;
|
|
1159 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40;
|
|
1160 HIWORD(v30) = HIWORD(v20);
|
|
1161 v31 = PID(OBJECT_Decoration,i);
|
|
1162 LOWORD(v30) = 0;
|
|
1163 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0;
|
|
1164 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31;
|
|
1165 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0;
|
2508
|
1166 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame;
|
2496
|
1167 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0;
|
|
1168 ::uNumBillboardsToDraw++;
|
|
1169 ++uNumDecorationsDrawnThisFrame;
|
|
1170 }
|
|
1171 }
|
|
1172 continue;
|
|
1173 }
|
|
1174 }
|
|
1175 }
|
|
1176 }
|
|
1177 else
|
|
1178 {
|
|
1179 memset(&local_0, 0, 0x68);
|
|
1180 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
|
|
1181 local_0.uDiffuse = 0xFF3C1E;
|
|
1182 local_0.x = (double)pLevelDecorations[i].vPosition.x;
|
|
1183 local_0.y = (double)pLevelDecorations[i].vPosition.y;
|
|
1184 local_0.z = (double)pLevelDecorations[i].vPosition.z;
|
|
1185 local_0.r = 0.0;
|
|
1186 local_0.g = 0.0;
|
|
1187 local_0.b = 0.0;
|
|
1188 local_0.flt_28 = 1.0;
|
|
1189 local_0.timeToLive = (rand() & 0x80) + 128;
|
|
1190 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01");
|
|
1191 pGame->pParticleEngine->AddParticle(&local_0);
|
|
1192 }
|
|
1193 }
|
|
1194 }
|
|
1195 }
|
|
1196
|
|
1197 //----- (0049D717) --------------------------------------------------------
|
|
1198 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst)
|
|
1199 {
|
|
1200 if ( Src->dwFlags & (0x400 | 0x2000))
|
|
1201 {
|
|
1202 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask )
|
|
1203 {
|
|
1204 memcpy(Dst, Src, sizeof(DDPIXELFORMAT));
|
|
1205 return 0;
|
|
1206 }
|
|
1207 if ( !Dst->dwSize )
|
|
1208 {
|
|
1209 memcpy(Dst, Src, sizeof(DDPIXELFORMAT));
|
|
1210 return 1;
|
|
1211 }
|
|
1212 }
|
|
1213 return 1;
|
|
1214 }
|
|
1215
|
|
1216 //----- (0049DC28) --------------------------------------------------------
|
|
1217 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices)
|
|
1218 {
|
|
1219 RenderD3D__DevInfo *v2; // eax@1
|
|
1220
|
|
1221 v2 = new RenderD3D__DevInfo[4];// 4 items
|
|
1222 *pOutDevices = v2;
|
|
1223 memset(v2, 0, sizeof(v2));
|
|
1224 DirectDrawEnumerateExA((LPDDENUMCALLBACKEXA)RenderD3D__DeviceEnumerator, *pOutDevices, DDENUM_ATTACHEDSECONDARYDEVICES);
|
|
1225 }
|
|
1226
|
|
1227 //----- (0049DC58) --------------------------------------------------------
|
|
1228 RenderD3D::RenderD3D()
|
|
1229 {
|
|
1230 this->pHost = nullptr;
|
|
1231 this->pDirect3D = nullptr;
|
|
1232 this->pUnk = nullptr;
|
|
1233 this->pBackBuffer = nullptr;
|
|
1234 this->pFrontBuffer = nullptr;
|
|
1235 this->pZBuffer = nullptr;
|
|
1236 this->pDevice = nullptr;
|
|
1237 this->pViewport = nullptr;
|
|
1238 this->field_40 = 1;
|
|
1239 this->field_44 = 10;
|
|
1240 GetAvailableDevices(&this->pAvailableDevices);
|
|
1241 }
|
|
1242
|
|
1243 //----- (0049DC90) --------------------------------------------------------
|
|
1244 void RenderD3D::Release()
|
|
1245 {
|
|
1246 if ( !this->bWindowed )
|
|
1247 {
|
|
1248 if ( this->pHost )
|
|
1249 {
|
|
1250 this->pHost->RestoreDisplayMode();
|
|
1251 this->pHost->SetCooperativeLevel(this->hWindow, DDSCL_NORMAL);
|
|
1252 this->pHost->FlipToGDISurface();
|
|
1253 }
|
|
1254 }
|
|
1255
|
|
1256 for (int i = 0; i < 4; i++)
|
|
1257 {
|
|
1258 delete[] this->pAvailableDevices[i].pDriverName;
|
|
1259 this->pAvailableDevices[i].pDriverName = nullptr;
|
|
1260
|
|
1261 delete[] this->pAvailableDevices[i].pDeviceDesc;
|
|
1262 this->pAvailableDevices[i].pDeviceDesc = nullptr;
|
|
1263
|
|
1264 delete[] this->pAvailableDevices[i].pDDraw4DevDesc;
|
|
1265 this->pAvailableDevices[i].pDDraw4DevDesc = nullptr;
|
|
1266
|
|
1267 delete this->pAvailableDevices[i].pDirectDrawGUID;
|
|
1268 this->pAvailableDevices[i].pDirectDrawGUID = nullptr;
|
|
1269
|
|
1270 delete[] this->pAvailableDevices[i].pName;
|
|
1271 this->pAvailableDevices[i].pName = nullptr;
|
|
1272
|
|
1273 delete[] this->pAvailableDevices[i].pDescription;
|
|
1274 this->pAvailableDevices[i].pDescription = nullptr;
|
|
1275
|
|
1276 delete this->pAvailableDevices[i].pGUID;
|
|
1277 this->pAvailableDevices[i].pGUID = nullptr;
|
|
1278 }
|
|
1279
|
|
1280 delete[] this->pAvailableDevices;
|
|
1281 this->pAvailableDevices = NULL;
|
|
1282
|
|
1283 if ( this->pViewport )
|
|
1284 {
|
|
1285 this->pViewport->Release();
|
|
1286 this->pViewport = NULL;
|
|
1287 }
|
|
1288
|
|
1289 if ( this->pUnk )
|
|
1290 {
|
|
1291 this->pUnk->Release();
|
|
1292 this->pUnk = NULL;
|
|
1293 }
|
|
1294
|
|
1295 if ( this->pZBuffer )
|
|
1296 {
|
|
1297 this->pZBuffer->Release();
|
|
1298 this->pZBuffer = NULL;
|
|
1299 }
|
|
1300
|
|
1301 if ( this->pDevice )
|
|
1302 {
|
|
1303 this->pDevice->Release();
|
|
1304 this->pDevice = NULL;
|
|
1305 }
|
|
1306
|
|
1307 if ( this->pDirect3D )
|
|
1308 {
|
|
1309 this->pDirect3D->Release();
|
|
1310 this->pDirect3D = NULL;
|
|
1311 }
|
|
1312
|
|
1313 if ( this->pBackBuffer )
|
|
1314 {
|
|
1315 this->pBackBuffer->Release();
|
|
1316 this->pBackBuffer = NULL;
|
|
1317 }
|
|
1318
|
|
1319 if ( this->pFrontBuffer )
|
|
1320 {
|
|
1321 this->pFrontBuffer->Release();
|
|
1322 this->pFrontBuffer = NULL;
|
|
1323 }
|
|
1324
|
|
1325 if ( this->pHost )
|
|
1326 {
|
|
1327 this->pHost->Release();
|
|
1328 this->pHost = NULL;
|
|
1329 }
|
|
1330 }
|
|
1331
|
|
1332 //----- (0049DE14) --------------------------------------------------------
|
|
1333 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window)
|
|
1334 {
|
|
1335 DWORD v26; // [sp-4h] [bp-DCh]@30
|
|
1336 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37
|
|
1337 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11
|
|
1338 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28
|
|
1339 IDirectDrawClipper *lpddclipper; // [sp+C4h] [bp-14h]@18
|
|
1340 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1
|
|
1341
|
|
1342 auto hWnd = window->GetApiHandle();
|
|
1343 int game_width = window->GetWidth();
|
|
1344 int game_height = window->GetHeight();
|
|
1345
|
|
1346 this->bWindowed = bWindowed;
|
|
1347 this->hWindow = hWnd;
|
|
1348
|
|
1349 //Ñîçäàíèå îáúåêòà DirectDraw
|
|
1350 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, NULL)))
|
|
1351 {
|
|
1352 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n");
|
|
1353 return 0;
|
|
1354 }
|
|
1355
|
|
1356 //Çàïðîñ èíòåðôåéñà IDirectDraw4
|
|
1357 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost)))
|
|
1358 {
|
|
1359 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n");
|
|
1360 if (lpDD)
|
|
1361 lpDD->Release();
|
|
1362 return 0;
|
|
1363 }
|
|
1364 lpDD->Release();
|
|
1365 lpDD = NULL;
|
|
1366
|
|
1367 //Çàäà¸ì óðîâåíü ñîâìåñòíîãî äîñòóïà äëÿ ïðèëîæåíèÿ DirectDraw â îêîííîì ðåæèìå
|
|
1368 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID)
|
|
1369 {
|
|
1370 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL)))
|
|
1371 {
|
|
1372 sprintf(pErrorMessage, "Init - Failed to set cooperative level.\n");
|
|
1373 if (pHost)
|
|
1374 {
|
|
1375 pHost->Release();
|
|
1376 pHost = NULL;
|
|
1377 }
|
|
1378 return 0;
|
|
1379 }
|
|
1380
|
|
1381 //
|
|
1382 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2));
|
|
1383 ddsd2.dwSize = sizeof(DDSURFACEDESC2);
|
|
1384 ddsd2.dwFlags = DDSD_CAPS;
|
|
1385 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
|
1386 //Ñîçäà¸ì ïåðâè÷íóþ ïîâåðõíîñòü
|
|
1387 if ( FAILED(pHost->CreateSurface(&ddsd2, &pFrontBuffer, NULL)) )
|
|
1388 {
|
|
1389 sprintf(pErrorMessage, "Init - Failed to create front buffer.\n");
|
|
1390 if (pHost)
|
|
1391 {
|
|
1392 pHost->Release();
|
|
1393 pHost = NULL;
|
|
1394 }
|
|
1395 return 0;
|
|
1396 }
|
|
1397 ddsd2.dwSize = sizeof(DDSURFACEDESC2);
|
|
1398 pHost->GetDisplayMode(&ddsd2);
|
|
1399 if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 )
|
|
1400 {
|
|
1401 sprintf(pErrorMessage, "Init - Desktop isn't in 16 bit mode.\n");
|
|
1402 if (pFrontBuffer)
|
|
1403 {
|
|
1404 pFrontBuffer->Release();
|
|
1405 pFrontBuffer = NULL;
|
|
1406 }
|
|
1407 if (pHost)
|
|
1408 {
|
|
1409 pHost->Release();
|
|
1410 pHost = NULL;
|
|
1411 }
|
|
1412 return 0;
|
|
1413 }
|
|
1414
|
|
1415 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
|
|
1416 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
|
|
1417 ddsd2.dwWidth = game_width;
|
|
1418 ddsd2.dwHeight = game_height;
|
|
1419 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, NULL) )
|
|
1420 {
|
|
1421 sprintf(pErrorMessage, "Init - Failed to create back buffer.\n");
|
|
1422 if (pFrontBuffer)
|
|
1423 {
|
|
1424 pFrontBuffer->Release();
|
|
1425 pFrontBuffer = NULL;
|
|
1426 }
|
|
1427 if (pHost)
|
|
1428 {
|
|
1429 pHost->Release();
|
|
1430 pHost = NULL;
|
|
1431 }
|
|
1432 return 0;
|
|
1433 }
|
|
1434 //Ñîçäàíèå îòñåêàòåëÿ DirectDraw
|
|
1435 if ( pHost->CreateClipper(0, &lpddclipper, NULL) )
|
|
1436 {
|
|
1437 sprintf(pErrorMessage, "Init - Failed to create clipper.\n");
|
|
1438 if (pBackBuffer)
|
|
1439 {
|
|
1440 pBackBuffer->Release();
|
|
1441 pBackBuffer = NULL;
|
|
1442 }
|
|
1443 if (pFrontBuffer)
|
|
1444 {
|
|
1445 pFrontBuffer->Release();
|
|
1446 pFrontBuffer= NULL;
|
|
1447 }
|
|
1448 if (pHost)
|
|
1449 {
|
|
1450 pHost->Release();
|
|
1451 pHost = NULL;
|
|
1452 }
|
|
1453 return 0;
|
|
1454 }
|
|
1455 lpddclipper->SetHWnd(0, hWnd);
|
|
1456 pFrontBuffer->SetClipper(lpddclipper);
|
|
1457
|
|
1458 lpddclipper->Release();
|
|
1459 lpddclipper = NULL;
|
|
1460 //
|
|
1461
|
|
1462 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D);
|
|
1463
|
|
1464 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
|
1465 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
|
|
1466 ddsd2.dwWidth = game_width;
|
|
1467 ddsd2.dwHeight = game_height;
|
|
1468
|
|
1469 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID,
|
|
1470 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator,
|
|
1471 &ddsd2.ddpfPixelFormat) )
|
|
1472 {
|
|
1473 sprintf(pErrorMessage, "Init - Failed to enumerate Z buffer formats.\n");
|
|
1474 if (pBackBuffer)
|
|
1475 {
|
|
1476 pBackBuffer->Release();
|
|
1477 pBackBuffer = NULL;
|
|
1478 }
|
|
1479 if (pFrontBuffer)
|
|
1480 {
|
|
1481 pFrontBuffer->Release();
|
|
1482 pFrontBuffer= NULL;
|
|
1483 }
|
|
1484 if (pHost)
|
|
1485 {
|
|
1486 pHost->Release();
|
|
1487 pHost = NULL;
|
|
1488 }
|
|
1489 return 0;
|
|
1490 }
|
|
1491 if ( uDeviceID == 2 || uDeviceID == 3 )
|
|
1492 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
|
|
1493
|
|
1494 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, NULL) )
|
|
1495 {
|
|
1496 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) )
|
|
1497 {
|
|
1498 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, pBackBuffer, &pDevice, 0) )
|
|
1499 {
|
|
1500 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2));
|
|
1501 d3dvp2.dvClipWidth = 2.0;
|
|
1502 d3dvp2.dvClipY = 1.0;
|
|
1503 d3dvp2.dvClipHeight = 2.0;
|
|
1504 d3dvp2.dvMaxZ = 1.0;
|
|
1505 d3dvp2.dvMinZ = 0.0;
|
|
1506 goto LABEL_54;
|
|
1507 }
|
|
1508 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n");
|
|
1509 if (pDirect3D)
|
|
1510 {
|
|
1511 pDirect3D->Release();
|
|
1512 pDirect3D = NULL;
|
|
1513 }
|
|
1514 if (pZBuffer)
|
|
1515 {
|
|
1516 pZBuffer->Release();
|
|
1517 pZBuffer = NULL;
|
|
1518 }
|
|
1519 if (pBackBuffer)
|
|
1520 {
|
|
1521 pBackBuffer->Release();
|
|
1522 pBackBuffer = NULL;
|
|
1523 }
|
|
1524 if (pFrontBuffer)
|
|
1525 {
|
|
1526 pFrontBuffer->Release();
|
|
1527 pFrontBuffer= NULL;
|
|
1528 }
|
|
1529 if (pHost)
|
|
1530 {
|
|
1531 pHost->Release();
|
|
1532 pHost = NULL;
|
|
1533 }
|
|
1534 return 0;
|
|
1535 }
|
|
1536 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n");
|
|
1537 if (pZBuffer)
|
|
1538 {
|
|
1539 pZBuffer->Release();
|
|
1540 pZBuffer = NULL;
|
|
1541 }
|
|
1542 if (pBackBuffer)
|
|
1543 {
|
|
1544 pBackBuffer->Release();
|
|
1545 pBackBuffer = NULL;
|
|
1546 }
|
|
1547 if (pFrontBuffer)
|
|
1548 {
|
|
1549 pFrontBuffer->Release();
|
|
1550 pFrontBuffer= NULL;
|
|
1551 }
|
|
1552 if (pHost)
|
|
1553 {
|
|
1554 pHost->Release();
|
|
1555 pHost = NULL;
|
|
1556 }
|
|
1557 return 0;
|
|
1558 }
|
|
1559 sprintf(pErrorMessage, "Init - Failed to create z-buffer.\n");
|
|
1560 if (pBackBuffer)
|
|
1561 {
|
|
1562 pBackBuffer->Release();
|
|
1563 pBackBuffer = NULL;
|
|
1564 }
|
|
1565 if (pFrontBuffer)
|
|
1566 {
|
|
1567 pFrontBuffer->Release();
|
|
1568 pFrontBuffer= NULL;
|
|
1569 }
|
|
1570 if (pHost)
|
|
1571 {
|
|
1572 pHost->Release();
|
|
1573 pHost = NULL;
|
|
1574 }
|
|
1575 return 0;
|
|
1576 }
|
|
1577 if ( uDeviceID == 1 )
|
|
1578 v26 = 1045;
|
|
1579 else
|
|
1580 v26 = 1041;
|
|
1581 if (pHost->SetCooperativeLevel(hWnd, v26) )
|
|
1582 {
|
|
1583 sprintf(pErrorMessage, "Init - Failed to set cooperative level.\n");
|
|
1584 if (pHost)
|
|
1585 {
|
|
1586 pHost->Release();
|
|
1587 pHost = NULL;
|
|
1588 }
|
|
1589 return 0;
|
|
1590 }
|
|
1591 if (pHost->SetDisplayMode(window->GetWidth(), window->GetHeight(), 16, 0, 0) )
|
|
1592 {
|
|
1593 sprintf(pErrorMessage, "Init - Failed to set display mode.\n");
|
|
1594 if (pHost)
|
|
1595 {
|
|
1596 pHost->Release();
|
|
1597 pHost = NULL;
|
|
1598 }
|
|
1599 return 0;
|
|
1600 }
|
|
1601
|
|
1602 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2));
|
|
1603 ddsd2.dwSize = sizeof(DDSURFACEDESC2);
|
|
1604 //Ïîäêëþ÷åíèå ïîëåé ñ äîñòîâåðíûìè äàííûìè
|
|
1605 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
|
|
1606 //Çàïðîñ ñëîæíîé ñòðóêòóðû ñ âîçìîæíîñòüþ ïåðåêëþ÷åíèÿ
|
|
1607 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
|
|
1608 //Ïðèñâîåíèå ïîëþ ñ÷¸ò÷èêà çàäíèõ áóôåðîâ çíà÷åíèÿ 1
|
|
1609 ddsd2.dwBackBufferCount = 1;
|
|
1610 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, NULL) )
|
|
1611 {
|
|
1612 sprintf(pErrorMessage, "Init - Failed to create front buffer.\n");
|
|
1613 if (pHost)
|
|
1614 {
|
|
1615 pHost->Release();
|
|
1616 pHost = NULL;
|
|
1617 }
|
|
1618 return 0;
|
|
1619 }
|
|
1620 //a3a = &pBackBuffer;
|
|
1621 //v14 = *v34;
|
|
1622 memset(&v27, 0, sizeof(DDSCAPS2));
|
|
1623
|
|
1624 v27.dwCaps = DDSCAPS_BACKBUFFER;
|
|
1625 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer);
|
|
1626 //hWnda = &pDirect3D;
|
|
1627 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D);
|
|
1628
|
|
1629 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer)))
|
|
1630 {
|
|
1631 sprintf(pErrorMessage, "Init - Failed to get D3D interface.\n");
|
|
1632 if (pBackBuffer)
|
|
1633 {
|
|
1634 pBackBuffer->Release();
|
|
1635 pBackBuffer = NULL;
|
|
1636 }
|
|
1637 if (pFrontBuffer)
|
|
1638 {
|
|
1639 pFrontBuffer->Release();
|
|
1640 pFrontBuffer= NULL;
|
|
1641 }
|
|
1642 if (pHost)
|
|
1643 {
|
|
1644 pHost->Release();
|
|
1645 pHost = NULL;
|
|
1646 }
|
|
1647 return 0;
|
|
1648 }
|
|
1649
|
|
1650 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
|
1651 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
|
|
1652 ddsd2.dwWidth = 640;
|
|
1653 ddsd2.dwHeight = 480;
|
|
1654 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID,
|
|
1655 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator,
|
|
1656 &ddsd2.ddpfPixelFormat) )
|
|
1657 {
|
|
1658 sprintf(pErrorMessage, "Init - Failed to enumerate Z buffer formats.\n");
|
|
1659 if (pBackBuffer)
|
|
1660 {
|
|
1661 pBackBuffer->Release();
|
|
1662 pBackBuffer = 0;
|
|
1663 }
|
|
1664 if (pFrontBuffer)
|
|
1665 {
|
|
1666 pFrontBuffer->Release();
|
|
1667 pFrontBuffer= 0;
|
|
1668 }
|
|
1669 if (pHost)
|
|
1670 {
|
|
1671 pHost->Release();
|
|
1672 pHost = 0;
|
|
1673 }
|
|
1674 return 0;
|
|
1675 }
|
|
1676 if ( uDeviceID == 2 || uDeviceID == 3 )
|
|
1677 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8;
|
|
1678 //uDeviceIDa = &pZBuffer;
|
|
1679 if (pHost->CreateSurface(&ddsd2, &pZBuffer, NULL) )
|
|
1680 {
|
|
1681 sprintf(pErrorMessage, "Init - Failed to create z-buffer.\n");
|
|
1682 if (pBackBuffer)
|
|
1683 {
|
|
1684 pBackBuffer->Release();
|
|
1685 pBackBuffer = 0;
|
|
1686 }
|
|
1687 if (pFrontBuffer)
|
|
1688 {
|
|
1689 pFrontBuffer->Release();
|
|
1690 pFrontBuffer= 0;
|
|
1691 }
|
|
1692 if (pHost)
|
|
1693 {
|
|
1694 pHost->Release();
|
|
1695 pHost = 0;
|
|
1696 }
|
|
1697 return 0;
|
|
1698 }
|
|
1699 if (pBackBuffer->AddAttachedSurface(pZBuffer))
|
|
1700 {
|
|
1701 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n");
|
|
1702 if (pZBuffer)
|
|
1703 {
|
|
1704 pZBuffer->Release();
|
|
1705 pZBuffer = 0;
|
|
1706 }
|
|
1707 if (pBackBuffer)
|
|
1708 {
|
|
1709 pBackBuffer->Release();
|
|
1710 pBackBuffer = 0;
|
|
1711 }
|
|
1712 if (pFrontBuffer)
|
|
1713 {
|
|
1714 pFrontBuffer->Release();
|
|
1715 pFrontBuffer= 0;
|
|
1716 }
|
|
1717 if (pHost)
|
|
1718 {
|
|
1719 pHost->Release();
|
|
1720 pHost = 0;
|
|
1721 }
|
|
1722 return 0;
|
|
1723 }
|
|
1724 //v33 = &pDevice;
|
|
1725 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, pBackBuffer, &pDevice, 0) )
|
|
1726 {
|
|
1727 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n");
|
|
1728 if (pDirect3D)
|
|
1729 {
|
|
1730 pDirect3D->Release();
|
|
1731 pDirect3D = 0;
|
|
1732 }
|
|
1733 if (pZBuffer)
|
|
1734 {
|
|
1735 pZBuffer->Release();
|
|
1736 pZBuffer = 0;
|
|
1737 }
|
|
1738 if (pBackBuffer)
|
|
1739 {
|
|
1740 pBackBuffer->Release();
|
|
1741 pBackBuffer = 0;
|
|
1742 }
|
|
1743 if (pFrontBuffer)
|
|
1744 {
|
|
1745 pFrontBuffer->Release();
|
|
1746 pFrontBuffer= 0;
|
|
1747 }
|
|
1748 if (pHost)
|
|
1749 {
|
|
1750 pHost->Release();
|
|
1751 pHost = 0;
|
|
1752 }
|
|
1753 return 0;
|
|
1754 }
|
|
1755 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2));
|
|
1756 d3dvp2.dvClipWidth = 2.0;
|
|
1757 d3dvp2.dvClipY = 1.0;
|
|
1758 d3dvp2.dvClipHeight = 2.0;
|
|
1759 d3dvp2.dvMaxZ = 1.0;
|
|
1760
|
|
1761 LABEL_54:
|
|
1762 d3dvp2.dwSize = sizeof(D3DVIEWPORT2);
|
|
1763 //v17 = *hWnda;
|
|
1764 d3dvp2.dwWidth = game_width;
|
|
1765 d3dvp2.dwHeight = game_height;
|
|
1766 d3dvp2.dvClipX = -1.0;
|
|
1767 //v18 = v17->lpVtbl;
|
|
1768 //v32 = &v4->pViewport;
|
|
1769 if (pDirect3D->CreateViewport(&pViewport, 0))
|
|
1770 {
|
|
1771 sprintf(pErrorMessage, "Init - Failed to create viewport.\n");
|
|
1772 if (pDevice)
|
|
1773 {
|
|
1774 pDevice->Release();
|
|
1775 pDevice = 0;
|
|
1776 }
|
|
1777 if (pDirect3D)
|
|
1778 {
|
|
1779 pDirect3D->Release();
|
|
1780 pDirect3D = 0;
|
|
1781 }
|
|
1782 if (pZBuffer)
|
|
1783 {
|
|
1784 pZBuffer->Release();
|
|
1785 pZBuffer = 0;
|
|
1786 }
|
|
1787 if (pBackBuffer)
|
|
1788 {
|
|
1789 pBackBuffer->Release();
|
|
1790 pBackBuffer = 0;
|
|
1791 }
|
|
1792 if (pFrontBuffer)
|
|
1793 {
|
|
1794 pFrontBuffer->Release();
|
|
1795 pFrontBuffer= 0;
|
|
1796 }
|
|
1797 if (pHost)
|
|
1798 {
|
|
1799 pHost->Release();
|
|
1800 pHost = 0;
|
|
1801 }
|
|
1802 return 0;
|
|
1803 }
|
|
1804
|
|
1805 pDevice->AddViewport(pViewport);
|
|
1806 pViewport->SetViewport2(&d3dvp2);
|
|
1807 pDevice->SetCurrentViewport(pViewport);
|
|
1808 return 1;
|
|
1809 }
|
|
1810
|
|
1811 //----- (0049E444) --------------------------------------------------------
|
|
1812 unsigned int RenderD3D::GetDeviceCaps()
|
|
1813 {
|
|
1814 unsigned int v1; // ebx@1
|
|
1815 unsigned int result; // eax@2
|
|
1816 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1
|
|
1817 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1
|
|
1818
|
|
1819 v1 = 0;
|
|
1820
|
|
1821 memset(&halCaps, 0, sizeof(halCaps));
|
|
1822 halCaps.dwSize = sizeof(halCaps);
|
|
1823
|
|
1824 memset(&refCaps, 0, sizeof(refCaps));
|
|
1825 refCaps.dwSize = sizeof(refCaps);
|
|
1826
|
|
1827 if ( this->pDevice->GetCaps(&halCaps, &refCaps) )
|
|
1828 result = 1;
|
|
1829 else
|
|
1830 {
|
|
1831 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) )
|
|
1832 v1 = 2;
|
|
1833 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ONE) )
|
|
1834 v1 |= 4;
|
|
1835 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ZERO) )
|
|
1836 v1 |= 8;
|
|
1837 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) )
|
|
1838 v1 |= 16;
|
|
1839 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_ONE) )
|
|
1840 v1 |= 32;
|
|
1841 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) )
|
|
1842 v1 |= 64;
|
|
1843 if ( halCaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY )
|
|
1844 v1 |= 128;
|
|
1845 result = v1;
|
|
1846 }
|
|
1847 return result;
|
|
1848 }
|
|
1849
|
|
1850 //----- (0049E4FC) --------------------------------------------------------
|
|
1851 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear)
|
|
1852 {
|
|
1853 uint uClearFlags = 0;
|
|
1854
|
|
1855 if (bClearColor)
|
|
1856 uClearFlags |= D3DCLEAR_TARGET;
|
|
1857 if (bClearDepth)
|
|
1858 uClearFlags |= D3DCLEAR_ZBUFFER;
|
|
1859
|
|
1860 D3DRECT rects[] = {{0, 0, window->GetWidth(), window->GetHeight()}};
|
|
1861 if (uClearFlags)
|
|
1862 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0);
|
|
1863 }
|
|
1864
|
|
1865 //----- (0049E54D) --------------------------------------------------------
|
|
1866 void RenderD3D::Present(bool bForceBlit)
|
|
1867 {
|
|
1868 RECT source_rect; // [sp+18h] [bp-18h]@1
|
|
1869 struct tagPOINT Point; // [sp+28h] [bp-8h]@4
|
|
1870
|
|
1871 source_rect.left = 0;
|
|
1872 source_rect.top = 0;
|
|
1873 source_rect.bottom = 480;//window->GetHeight(); //Ritor1: ïðîáëåìà ñ êíîïêîé "ðàçâåðíóòü"
|
|
1874 source_rect.right = 640; //window->GetWidth();
|
|
1875
|
|
1876 if (bWindowed || bForceBlit)
|
|
1877 {
|
|
1878 RECT dest_rect;
|
|
1879 GetClientRect(hWindow, &dest_rect);
|
|
1880 Point.y = 0;
|
|
1881 Point.x = 0;
|
|
1882 ClientToScreen(hWindow, &Point);
|
|
1883 OffsetRect(&dest_rect, Point.x, Point.y);
|
|
1884 pFrontBuffer->Blt(&dest_rect, pBackBuffer, &source_rect, DDBLT_WAIT, NULL);
|
|
1885 }
|
|
1886 else
|
|
1887 pFrontBuffer->Flip(NULL, DDFLIP_WAIT);
|
|
1888 }
|
|
1889
|
|
1890 //----- (0049E5D4) --------------------------------------------------------
|
|
1891 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim)
|
|
1892 {
|
|
1893 unsigned int v9; // ebx@5
|
|
1894 unsigned int v10; // eax@5
|
|
1895 DWORD v11; // edx@5
|
|
1896 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1
|
|
1897
|
|
1898 memset(&ddsd2, 0, sizeof(ddsd2));
|
|
1899 ddsd2.dwSize = sizeof(ddsd2);
|
|
1900 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
|
1901 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
|
1902 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
|
|
1903 ddsd2.dwHeight = uTextureHeight;
|
|
1904 ddsd2.dwWidth = uTextureWidth;
|
|
1905 if ( bMipmaps )
|
|
1906 {
|
|
1907 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth )
|
|
1908 {
|
|
1909 ddsd2.dwMipMapCount = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim);
|
|
1910 if ( ddsd2.dwMipMapCount )
|
|
1911 {
|
|
1912 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT;
|
|
1913 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
|
|
1914 }
|
|
1915 goto LABEL_12;
|
|
1916 }
|
|
1917 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim )
|
|
1918 {
|
|
1919 ddsd2.dwMipMapCount = GetMaxMipLevels(uMinDeviceTexDim);
|
|
1920 if ( ddsd2.dwMipMapCount )
|
|
1921 {
|
|
1922 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT;
|
|
1923 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
|
|
1924 }
|
|
1925 goto LABEL_12;
|
|
1926 }
|
|
1927 v9 = GetMaxMipLevels(uTextureWidth);
|
|
1928 v10 = GetMaxMipLevels(uMinDeviceTexDim);
|
|
1929 ddsd2.dwMipMapCount = v9 - v10;
|
|
1930 if ( v9 == v10 )
|
|
1931 {
|
|
1932 ddsd2.dwFlags = 0x1007;
|
|
1933 __debugbreak(); // warning C4700: uninitialized local variable 'v11' used
|
|
1934 ddsd2.ddsCaps.dwCaps = v11;
|
|
1935 goto LABEL_12;
|
|
1936 }
|
|
1937 }
|
|
1938 else
|
|
1939 ddsd2.dwMipMapCount = 1;
|
|
1940 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT;
|
|
1941 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
|
|
1942 LABEL_12:
|
|
1943 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16;
|
|
1944 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
|
|
1945 if (bAlphaChannel)
|
|
1946 {
|
|
1947 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
|
|
1948 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00;
|
|
1949 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0;
|
|
1950 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F;
|
|
1951 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000;
|
|
1952 }
|
|
1953 else
|
|
1954 {
|
|
1955 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
|
1956 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800;
|
|
1957 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0;
|
|
1958 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F;
|
|
1959 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0;
|
|
1960 }
|
|
1961 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, NULL)))
|
|
1962 return false;
|
|
1963 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture)))
|
|
1964 {
|
|
1965 (*pOutSurface)->Release();
|
|
1966 *pOutSurface = 0;
|
|
1967 return false;
|
|
1968 }
|
|
1969 return true;
|
|
1970 }
|
|
1971
|
|
1972 //----- (004A5190) --------------------------------------------------------
|
|
1973 void RenderD3D::HandleLostResources()
|
|
1974 {
|
|
1975 pBitmaps_LOD->ReleaseLostHardwareTextures();
|
|
1976 pBitmaps_LOD->_410423_move_textures_to_device();
|
|
1977 pSprites_LOD->ReleaseLostHardwareSprites();
|
|
1978 }
|
|
1979
|
|
1980 //----- (004A2050) --------------------------------------------------------
|
|
1981 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture)
|
|
1982 {
|
|
1983 unsigned int v6; // ebx@1
|
|
1984 int v8; // eax@7
|
|
1985 unsigned int v41; // eax@29
|
|
1986 //unsigned int v54; // [sp+5Ch] [bp-Ch]@3
|
|
1987 signed int a2; // [sp+64h] [bp-4h]@4
|
|
1988
|
|
1989 v6 = 0;
|
|
1990 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 )
|
|
1991 {
|
|
1992 //v54 = pGame->pLightmapBuilder->std__vector_000004_size;
|
|
1993 if ( pGame->pLightmapBuilder->std__vector_000004_size)
|
|
1994 a2 = -1;
|
|
1995 pGame->AlterGamma_ODM(a4, &a2);
|
|
1996 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related)
|
|
1997 {
|
|
1998 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0);
|
|
1999 pGame->pLightmapBuilder->DrawLightmaps(/*v8, 0*/);
|
|
2000 }
|
|
2001 else
|
|
2002 {
|
|
2003 if ( !pGame->pLightmapBuilder->std__vector_000004_size || byte_4D864C && pGame->uFlags & 2 )
|
|
2004 {
|
|
2005 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
2006 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
|
|
2007 if (bUsingSpecular)
|
|
2008 {
|
|
2009 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
2010 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
2011 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
2012 }
|
|
2013 for (uint i = 0; i < uNumVertices; ++i)
|
|
2014 {
|
|
2015
|
|
2016 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX;
|
|
2017 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY;
|
|
2018 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist);
|
|
2019 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001);
|
|
2020 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0);
|
|
2021 pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse);
|
|
2022
|
|
2023 if ( this->bUsingSpecular )
|
|
2024 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x);
|
|
2025 else
|
|
2026 d3d_vertex_buffer[i].specular = 0;
|
|
2027 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u;
|
|
2028 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
|
|
2029
|
|
2030 }
|
|
2031
|
|
2032 if (a4->uAttributes & FACE_OUTLINED)
|
|
2033 {
|
|
2034 int color;
|
|
2035 if (GetTickCount() % 300 >= 150)
|
|
2036 color = 0xFFFF2020;
|
|
2037 else color = 0xFF901010;
|
|
2038
|
|
2039 for (uint i = 0; i < uNumVertices; ++i)
|
|
2040 d3d_vertex_buffer[i].diffuse = color;
|
|
2041 }
|
|
2042
|
|
2043 pRenderD3D->pDevice->SetTexture(0, pTexture);
|
|
2044 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
2045 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
2046 d3d_vertex_buffer,
|
|
2047 uNumVertices,
|
|
2048 D3DDP_DONOTLIGHT);
|
|
2049 }
|
|
2050 else
|
|
2051 {
|
|
2052 for (uint i = 0; i < uNumVertices; ++i)
|
|
2053 {
|
|
2054
|
|
2055 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX;
|
|
2056 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY;
|
|
2057 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist);
|
|
2058 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001);
|
|
2059 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0);
|
|
2060 if ( this->bUsingSpecular )
|
|
2061 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x);
|
|
2062 else
|
|
2063 d3d_vertex_buffer[i].specular = 0;
|
|
2064 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u;
|
|
2065 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
|
|
2066
|
|
2067 }
|
|
2068
|
|
2069 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
2070 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
2071 if (bUsingSpecular)
|
|
2072 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
2073
|
|
2074 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
|
2075 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
2076 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
|
|
2077 d3d_vertex_buffer,
|
|
2078 uNumVertices,
|
|
2079 D3DDP_DONOTLIGHT));
|
|
2080 //v50 = (const char *)v5->pRenderD3D->pDevice;
|
|
2081 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
2082 //(*(void (**)(void))(*(int *)v50 + 88))();
|
|
2083 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/);
|
|
2084 for (uint i = 0; i < uNumVertices; ++i)
|
|
2085 {
|
|
2086 d3d_vertex_buffer[i].diffuse = a2;
|
|
2087 }
|
|
2088 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture));
|
|
2089 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
2090 if ( !pRenderer->bUsingSpecular )
|
|
2091 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
2092
|
|
2093 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
2094 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO));
|
|
2095 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR));
|
|
2096 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
2097 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
|
|
2098 d3d_vertex_buffer,
|
|
2099 uNumVertices,
|
|
2100 D3DDP_DONOTLIGHT));
|
|
2101 if (bUsingSpecular)
|
|
2102 {
|
|
2103 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
2104
|
|
2105 for (uint i = 0; i < uNumVertices; ++i)
|
|
2106 {
|
|
2107 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000;
|
|
2108 d3d_vertex_buffer[i].specular = 0;
|
|
2109 }
|
|
2110
|
|
2111 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
|
2112 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA));
|
|
2113 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA));
|
|
2114 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
2115 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
|
|
2116 d3d_vertex_buffer,
|
|
2117 uNumVertices,
|
|
2118 D3DDP_DONOTLIGHT));
|
|
2119 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
2120 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl;
|
|
2121 v41 = GetLevelFogColor();
|
|
2122 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF);
|
|
2123 v6 = 0;
|
|
2124 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0);
|
|
2125 }
|
|
2126 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
2127 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
2128 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6));
|
|
2129 }
|
|
2130 }
|
|
2131 }
|
|
2132 }
|
|
2133 // 4D864C: using guessed type char byte_4D864C;
|
|
2134
|
|
2135 //----- (0049EB79) --------------------------------------------------------
|
|
2136 Render::~Render()
|
|
2137 {
|
|
2138 free(this->pDefaultZBuffer);
|
|
2139 this->pD3DBitmaps.Release();
|
|
2140 this->pD3DSprites.Release();
|
|
2141 Release();
|
|
2142 this->bWindowMode = 1;
|
|
2143 //nullsub_1();
|
|
2144 //nullsub_1();
|
|
2145 }
|
|
2146
|
|
2147
|
|
2148 //----- (0049E992) --------------------------------------------------------
|
2526
|
2149 Render::Render(): IRender()
|
2496
|
2150 {
|
|
2151 //Render *v1; // esi@1
|
|
2152 // int v2; // eax@1
|
|
2153 // char v3; // zf@1
|
|
2154
|
|
2155 //v1 = this;
|
|
2156 this->pDirectDraw4 = nullptr;
|
|
2157 this->pFrontBuffer4 = nullptr;
|
|
2158 this->pBackBuffer4 = nullptr;
|
|
2159 //this->pColorKeySurface4 = 0;
|
|
2160 //this->pDirectDraw2 = 0;
|
|
2161 //this->pFrontBuffer2 = 0;
|
|
2162 //this->pBackBuffer2 = 0;
|
|
2163 //this->pSomeSurface2 = 0;
|
|
2164 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps);
|
|
2165 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites);
|
|
2166 this->bWindowMode = 1;
|
|
2167 //this->field_40054 = 0;
|
|
2168 //this->field_10 = 640;
|
|
2169 //this->field_14 = 480;
|
|
2170 //this->field_40030 = 0;
|
|
2171 //this->field_4002C = 0;
|
|
2172 this->pActiveZBuffer = nullptr;
|
|
2173 this->pDefaultZBuffer = nullptr;
|
|
2174 this->raster_clip_y = 0;
|
|
2175 this->raster_clip_x = 0;
|
|
2176 this->raster_clip_z = 639;
|
|
2177 this->raster_clip_w = 479;
|
|
2178 //this->field_4003C = 0x004EED80;
|
|
2179 //this->field_40040 = dword_4EED78;
|
|
2180 this->uClipZ = 640;
|
|
2181 //this->field_40044 = 2;
|
|
2182 //this->field_40048 = 6;
|
|
2183 this->pFrontBuffer4 = nullptr;
|
|
2184 this->pBackBuffer4 = nullptr;
|
|
2185 //this->pColorKeySurface4 = 0;
|
|
2186 this->pDirectDraw4 = nullptr;
|
|
2187 this->pRenderD3D = 0;
|
|
2188 this->uNumSceneBegins = 0;
|
|
2189 this->uNumD3DSceneBegins = 0;
|
|
2190 this->using_software_screen_buffer = 0;
|
|
2191 this->pTargetSurface = nullptr;
|
|
2192 this->uTargetSurfacePitch = 0;
|
|
2193 this->uClipY = 0;
|
|
2194 this->uClipX = 0;
|
|
2195 this->uClipW = 480;
|
|
2196 this->bClip = 1;
|
|
2197 //this->bColorKeySupported = 0;
|
|
2198 this->bRequiredTextureStagesAvailable = 0;
|
|
2199 this->bTinting = 1;
|
|
2200 //LOBYTE(this->field_103668) = 0;
|
|
2201 uNumBillboardsToDraw = 0;
|
|
2202 bFogEnabled = false;
|
|
2203
|
|
2204 hd_water_tile_id = -1;
|
|
2205 hd_water_current_frame = 0;
|
|
2206 }
|
|
2207
|
|
2208 bool Render::Initialize(OSWindow *window/*, bool bColoredLights, uint32_t uDetailLevel, bool bTinting*/)
|
|
2209 {
|
|
2210 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0);
|
|
2211
|
|
2212 this->window = window;
|
|
2213 //bStartInWindow = true;
|
|
2214 //windowed_mode_width = windowed_width;
|
|
2215 //windowed_mode_height = windowed_height;
|
|
2216
|
|
2217 uDesiredDirect3DDevice = ReadWindowsRegistryInt("D3D Device", 0);
|
|
2218
|
|
2219 bUseColoredLights = ReadWindowsRegistryInt("Colored Lights", false);
|
|
2220 uLevelOfDetail = ReadWindowsRegistryInt("Detail Level", 1);
|
|
2221 bTinting = ReadWindowsRegistryInt("Tinting", 1) != 0;
|
|
2222
|
|
2223 bool r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl");
|
|
2224 bool r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl");
|
|
2225
|
|
2226 return r1 && r2;
|
|
2227 }
|
|
2228
|
|
2229
|
|
2230 //----- (0049ECC4) --------------------------------------------------------
|
|
2231 void Render::ClearBlack()
|
|
2232 {
|
|
2233 //if (pRenderD3D)
|
|
2234 {
|
|
2235 if (using_software_screen_buffer)
|
|
2236 pRenderD3D->ClearTarget(true, 0, false, 0.0);
|
|
2237 }
|
|
2238 //else
|
|
2239 //memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2));
|
|
2240 }
|
|
2241
|
|
2242 //----- (0049ED18) --------------------------------------------------------
|
|
2243 void Render::PresentBlackScreen()
|
|
2244 {
|
|
2245 IDirectDrawSurface *lpddsback; // eax@3
|
|
2246 DDBLTFX lpDDBltFx; // [sp+4h] [bp-74h]@5
|
|
2247 RECT dest_rect; // [sp+68h] [bp-10h]@3
|
|
2248
|
|
2249 memset(&lpDDBltFx, 0, sizeof(DDBLTFX));
|
|
2250 lpDDBltFx.dwSize = sizeof(DDBLTFX);
|
|
2251
|
|
2252 GetWindowRect(window->GetApiHandle(), &dest_rect);
|
|
2253 lpddsback = (IDirectDrawSurface *)this->pBackBuffer4;
|
|
2254
|
|
2255 lpDDBltFx.dwFillColor = 0;
|
|
2256 lpddsback->Blt(&dest_rect, NULL, NULL, DDBLT_COLORFILL, &lpDDBltFx);
|
|
2257 pRenderer->Present();
|
|
2258 }
|
|
2259
|
|
2260 //----- (0049EDB6) --------------------------------------------------------
|
|
2261 void Render::SavePCXScreenshot()
|
|
2262 {
|
|
2263 int v5; // eax@8
|
|
2264 FILE *pOutFile; // edi@10
|
|
2265 unsigned short *v8; // eax@11
|
|
2266 signed int v12; // eax@18
|
|
2267 char v15[56]; // [sp+Ch] [bp-158h]@10
|
|
2268 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7
|
|
2269 char color_map[48]; // [sp+C4h] [bp-A0h]@10
|
|
2270 char Filename[40]; // [sp+F4h] [bp-70h]@3
|
|
2271 char *lineB; // [sp+11Ch] [bp-48h]@14
|
|
2272 char *lineG; // [sp+120h] [bp-44h]@14
|
|
2273 FILE *File; // [sp+128h] [bp-3Ch]@3
|
|
2274 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10
|
|
2275 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10
|
|
2276 char *lineRGB; // [sp+148h] [bp-1Ch]@10
|
|
2277 void *surface; // [sp+14Ch] [bp-18h]@8
|
|
2278 unsigned int image_width; // [sp+150h] [bp-14h]@4
|
|
2279 int pitch; // [sp+154h] [bp-10h]@4
|
|
2280 char v31; // [sp+15Ah] [bp-Ah]@25
|
|
2281 unsigned char pict_byte; // [sp+15Bh] [bp-9h]@17
|
|
2282 unsigned short *line_picture_data; // [sp+15Ch] [bp-8h]@10
|
|
2283 byte test_byte; // [sp+163h] [bp-1h]@17
|
|
2284
|
|
2285 int num_r_bits = 5;
|
|
2286 int num_g_bits = 6;
|
|
2287 int num_b_bits = 5;
|
|
2288
|
|
2289 int r_mask = 0xF800;
|
|
2290 int g_mask = 0x7E0;
|
|
2291 int b_mask = 0x1F;
|
|
2292
|
|
2293 if ( !this->pRenderD3D || this->using_software_screen_buffer )
|
|
2294 {
|
|
2295 sprintf(Filename, "screen%0.2i.pcx", ScreenshotFileNumber++ % 100);
|
|
2296 File = fopen(Filename, "wb");
|
|
2297 if ( File )
|
|
2298 {
|
|
2299 pitch = this->GetRenderWidth();
|
|
2300 if ( pitch & 1 )
|
|
2301 pitch = pitch + 1;
|
|
2302 if ( this->pRenderD3D )
|
|
2303 {
|
|
2304 memset(&Dst, 0, sizeof(Dst));
|
|
2305 Dst.dwSize = sizeof(Dst);
|
|
2306 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
|
|
2307 return;
|
|
2308 surface = Dst.lpSurface;
|
|
2309 v5 = Dst.lPitch / 2;
|
|
2310 }
|
|
2311 else
|
|
2312 {
|
|
2313 pRenderer->BeginScene();
|
|
2314 surface = pRenderer->pTargetSurface;
|
|
2315 v5 = pRenderer->uTargetSurfacePitch;
|
|
2316 }
|
|
2317 header1.right = GetRenderWidth() - 1;
|
|
2318 header1.left = 0;
|
|
2319 header1.bottom = this->GetRenderHeight() - 1;
|
|
2320 header1.up = 0;
|
|
2321 header2.pitch = pitch;
|
|
2322 memset(color_map, 0, sizeof(color_map));
|
|
2323 memset(v15, 0, sizeof(v15));
|
|
2324 header2.reserved = 0;
|
|
2325 header1.manufacturer = 10;
|
|
2326 pOutFile = File;
|
|
2327 header1.version = 5;
|
|
2328 header1.encoding = 1;
|
|
2329 header1.bpp = 8;
|
|
2330 header1.hdpi = 75;
|
|
2331 header1.vdpi = 75;
|
|
2332 header2.planes = 3;
|
|
2333 header2.palette_info = 1;
|
|
2334 fwrite(&header1, 1, 1, File);
|
|
2335 fwrite(&header1.version, 1, 1, pOutFile);
|
|
2336 fwrite(&header1.encoding, 1, 1, pOutFile);
|
|
2337 fwrite(&header1.bpp, 1, 1, pOutFile);
|
|
2338 fwrite(&header1.left, 2, 1, pOutFile);
|
|
2339 fwrite(&header1.up, 2, 1, pOutFile);
|
|
2340 fwrite(&header1.right, 2, 1, pOutFile);
|
|
2341 fwrite(&header1.bottom, 2, 1, pOutFile);
|
|
2342 fwrite(&header1.hdpi, 2, 1, pOutFile);
|
|
2343 fwrite(&header1.vdpi, 2, 1, pOutFile);
|
|
2344 fwrite(color_map, 0x30, 1, pOutFile);
|
|
2345 fwrite(&header2, 1, 1, pOutFile);
|
|
2346 fwrite(&header2.planes, 1, 1, pOutFile);
|
|
2347 fwrite(&header2.pitch, 2, 1, pOutFile);
|
|
2348 fwrite(&header2.palette_info, 2, 1, pOutFile);
|
|
2349 fwrite(v15, 0x3Au, 1, pOutFile);
|
|
2350 lineRGB = (char *)malloc(3 * GetRenderWidth() + 6);
|
|
2351 if ( this->GetRenderHeight() > 0 )
|
|
2352 {
|
|
2353 image_width = 3 * pitch;
|
|
2354 //v24 = 2 * v5;
|
|
2355 v8 = (unsigned short *)surface;
|
|
2356 for ( unsigned int y = 0; y < this->GetRenderHeight(); y++ )
|
|
2357 {
|
|
2358 line_picture_data = v8;
|
|
2359 if ( GetRenderWidth() > 0 )
|
|
2360 {
|
|
2361 lineG = (char *)lineRGB + pitch;
|
|
2362 lineB = (char *)lineRGB + 2 * pitch;
|
|
2363 for ( uint x = 0; x < this->GetRenderWidth(); x++ )
|
|
2364 {
|
|
2365 //int p = *line_picture_data; //0x2818
|
|
2366 //int for_rad = (pRenderer->uTargetGBits + pRenderer->uTargetBBits );//16 = 8 + 8
|
|
2367 //int value = (pRenderer->uTargetRMask & *line_picture_data);//0 = 0xFF0000 & 0x2818
|
|
2368 //int result = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits );
|
|
2369 lineRGB[x] = (uTargetRMask & *line_picture_data) >> (uTargetGBits + uTargetBBits );// + pRenderer->uTargetRBits - 8);
|
|
2370 lineG[x] = (uTargetGMask & *line_picture_data) >> (uTargetBBits);// + pRenderer->uTargetGBits - 8);
|
|
2371 //int value2 = (pRenderer->uTargetGMask & *line_picture_data); //10240 = 0xFF00 & 0x2818
|
|
2372 //int result2 = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits);
|
|
2373 lineB[x] = (uTargetBMask & *line_picture_data);// << (8 - pRenderer->uTargetBBits);
|
|
2374 //int value3 = (pRenderer->uTargetBMask & *line_picture_data);//24 = 0xFF & 0x2818
|
|
2375 line_picture_data += 2;
|
|
2376 }
|
|
2377 }
|
|
2378 for ( uint i = 0; i < image_width; i += test_byte )
|
|
2379 {
|
|
2380 pict_byte = lineRGB[i];
|
|
2381 for ( test_byte = 1; test_byte < 0x3F; ++test_byte )
|
|
2382 {
|
|
2383 v12 = i + test_byte;
|
|
2384 if ( lineRGB[v12] != pict_byte )
|
|
2385 break;
|
|
2386 if ( !(v12 % pitch) )
|
|
2387 break;
|
|
2388 }
|
|
2389 if ( i + test_byte > image_width )
|
|
2390 test_byte = 3 * pitch - i;
|
|
2391 if ( test_byte > 1 || pict_byte >= 0xC0 )
|
|
2392 {
|
|
2393 v31 = test_byte | 0xC0;
|
|
2394 fwrite(&v31, 1, 1, pOutFile);
|
|
2395 }
|
|
2396 fwrite(&pict_byte, 1, 1, pOutFile);
|
|
2397 }
|
|
2398 v8 += v5;
|
|
2399 }
|
|
2400 }
|
|
2401 if ( this->pRenderD3D )
|
|
2402 ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL));
|
|
2403 else
|
|
2404 pRenderer->EndScene();
|
|
2405
|
|
2406 free(lineRGB);
|
|
2407 fclose(pOutFile);
|
|
2408 }
|
|
2409 }
|
|
2410 }
|
|
2411
|
|
2412 //----- (0049F1BC) --------------------------------------------------------
|
|
2413 void Render::SaveWinnersCertificate(const char *a1)
|
|
2414 {
|
|
2415 unsigned int v6; // eax@8
|
|
2416 //FILE *v7; // edi@10
|
|
2417 // int v8; // ecx@11
|
|
2418 unsigned short *v9; // eax@11
|
|
2419 int v10; // eax@13
|
|
2420 signed int v13; // eax@18
|
|
2421 // char v14; // zf@27
|
|
2422 // HRESULT v15; // eax@29
|
|
2423 char v16[56]; // [sp+Ch] [bp-12Ch]@10
|
|
2424 __int16 v17; // [sp+44h] [bp-F4h]@10
|
|
2425 DDSURFACEDESC2 Dst; // [sp+48h] [bp-F0h]@7
|
|
2426 // int v19; // [sp+58h] [bp-E0h]@8
|
|
2427 // unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8
|
|
2428 char color_map[48]; // [sp+C4h] [bp-74h]@10
|
|
2429 // unsigned int v22; // [sp+F4h] [bp-44h]@11
|
|
2430 char *lineB; // [sp+F8h] [bp-40h]@14
|
|
2431 int image_width; // [sp+FCh] [bp-3Ch]@11
|
|
2432 int v25; // [sp+100h] [bp-38h]@4
|
|
2433 FILE *File; // [sp+104h] [bp-34h]@3
|
|
2434 char Str; // [sp+108h] [bp-30h]@10
|
|
2435 char v28; // [sp+109h] [bp-2Fh]@10
|
|
2436 char v29; // [sp+10Ah] [bp-2Eh]@10
|
|
2437 char v30; // [sp+10Bh] [bp-2Dh]@10
|
|
2438 __int16 v31; // [sp+10Ch] [bp-2Ch]@10
|
|
2439 __int16 v32; // [sp+10Eh] [bp-2Ah]@10
|
|
2440 __int16 v33; // [sp+110h] [bp-28h]@10
|
|
2441 __int16 v34; // [sp+112h] [bp-26h]@10
|
|
2442 __int16 v35; // [sp+114h] [bp-24h]@10
|
|
2443 __int16 v36; // [sp+116h] [bp-22h]@10
|
|
2444 char v37; // [sp+118h] [bp-20h]@10
|
|
2445 char v38; // [sp+119h] [bp-1Fh]@10
|
|
2446 __int16 v39; // [sp+11Ah] [bp-1Eh]@10
|
|
2447 __int16 v40; // [sp+11Ch] [bp-1Ch]@10
|
|
2448 char *lineRGB; // [sp+120h] [bp-18h]@10
|
|
2449 void *surface; // [sp+124h] [bp-14h]@8
|
|
2450 int pitch; // [sp+128h] [bp-10h]@4
|
|
2451 char v44; // [sp+12Fh] [bp-9h]@25
|
|
2452 char *lineG; // [sp+130h] [bp-8h]@10
|
|
2453 unsigned char pict_byte; // [sp+137h] [bp-1h]@17
|
|
2454 byte test_byte;
|
|
2455
|
|
2456 int num_r_bits = 5;
|
|
2457 int num_g_bits = 6;
|
|
2458 int num_b_bits = 5;
|
|
2459
|
|
2460 int r_mask = 0xF800;
|
|
2461 int g_mask = 0x7E0;
|
|
2462 int b_mask = 0x1F;
|
|
2463
|
|
2464 if ( !this->pRenderD3D || this->using_software_screen_buffer )
|
|
2465 {
|
|
2466 static int _4EFA84_num_winners_certificates = 0;
|
|
2467 ++_4EFA84_num_winners_certificates;
|
|
2468
|
|
2469 File = fopen(a1, "wb");
|
|
2470 if ( File )
|
|
2471 {
|
|
2472 v25 = this->GetRenderWidth();
|
|
2473 pitch = v25;
|
|
2474 if ( pitch & 1 )
|
|
2475 pitch = pitch + 1;
|
|
2476 if ( this->pRenderD3D )
|
|
2477 {
|
|
2478 memset(&Dst, 0, 0x7C);
|
|
2479 Dst.dwSize = 124;
|
|
2480 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) )
|
|
2481 return;
|
|
2482 surface = Dst.lpSurface;
|
|
2483 v6 = Dst.lPitch / 2;
|
|
2484 }
|
|
2485 else
|
|
2486 {
|
|
2487 pRenderer->BeginScene();
|
|
2488 surface = pRenderer->pTargetSurface;
|
|
2489 v6 = pRenderer->uTargetSurfacePitch;
|
|
2490 }
|
|
2491 v33 = this->GetRenderWidth() - 1;
|
|
2492 v31 = 0;
|
|
2493 v34 = (short)this->GetRenderHeight() - 1;
|
|
2494 v32 = 0;
|
|
2495 v39 = pitch;
|
|
2496 memset(&color_map, 0, sizeof(color_map));
|
|
2497 memset(&v16, 0, sizeof(v16));
|
|
2498 v37 = 0;
|
|
2499 Str = 10;
|
|
2500 v17 = 0;
|
|
2501 v28 = 5;
|
|
2502 v29 = 1;
|
|
2503 v30 = 8;
|
|
2504 v35 = 75;
|
|
2505 v36 = 75;
|
|
2506 v38 = 3;
|
|
2507 v40 = 1;
|
|
2508 fwrite(&Str, 1, 1, File);
|
|
2509 fwrite(&v28, 1, 1, File);
|
|
2510 fwrite(&v29, 1, 1, File);
|
|
2511 fwrite(&v30, 1, 1, File);
|
|
2512 fwrite(&v31, 2, 1, File);
|
|
2513 fwrite(&v32, 2, 1, File);
|
|
2514 fwrite(&v33, 2, 1, File);
|
|
2515 fwrite(&v34, 2, 1, File);
|
|
2516 fwrite(&v35, 2, 1, File);
|
|
2517 fwrite(&v36, 2, 1, File);
|
|
2518 fwrite(&color_map, 0x30, 1, File);
|
|
2519 fwrite(&v37, 1, 1, File);
|
|
2520 fwrite(&v38, 1, 1, File);
|
|
2521 fwrite(&v39, 2, 1, File);
|
|
2522 fwrite(&v40, 2, 1, File);
|
|
2523 fwrite(&v16, 0x3A, 1, File);
|
|
2524 lineRGB = (char *)malloc(3 * (v25 + 2));
|
|
2525 if ( (signed int)this->GetRenderHeight() > 0 )
|
|
2526 {
|
|
2527 image_width = 3 * pitch;
|
|
2528 v9 = (unsigned short *)surface;
|
|
2529 for ( uint j = 0; j < this->GetRenderHeight(); j++)
|
|
2530 {
|
|
2531 a1 = (const char *)v9;
|
|
2532 if ( v25 > 0 )
|
|
2533 {
|
|
2534 lineG = (char *)lineRGB + pitch;
|
|
2535 lineB = (char *)lineRGB + 2 * pitch;
|
|
2536 for ( v10 = 0; v10 < v25; v10++ )
|
|
2537 {
|
|
2538 lineRGB[v10] = (signed int)(r_mask & *(short *)a1) >> (num_g_bits + num_b_bits + num_r_bits - 8);
|
|
2539 lineG[v10] = (signed int)(g_mask & *(short *)a1) >> (num_b_bits + num_g_bits - 8);
|
|
2540 lineB[v10] = (b_mask & *(short *)a1) << (8 - num_b_bits);
|
|
2541 a1 += 2;
|
|
2542 }
|
|
2543 }
|
|
2544 for ( uint i = 0; i < image_width; i += test_byte )
|
|
2545 {
|
|
2546 pict_byte = lineRGB[i];
|
|
2547 for ( test_byte = 1; test_byte < 0x3F; test_byte )
|
|
2548 {
|
|
2549 v13 = i + test_byte;
|
|
2550 if ( lineRGB[v13] != pict_byte )
|
|
2551 break;
|
|
2552 if ( !(v13 % pitch) )
|
|
2553 break;
|
|
2554 }
|
|
2555 if ( i + test_byte > image_width )
|
|
2556 test_byte = 3 * pitch - i;
|
|
2557 if ( test_byte > 1 || pict_byte >= 0xC0 )
|
|
2558 {
|
|
2559 v44 = test_byte | 0xC0;
|
|
2560 fwrite(&v44, 1, 1, File);
|
|
2561 }
|
|
2562 fwrite(&pict_byte, 1, 1, File);
|
|
2563 }
|
|
2564 v9 += pitch;
|
|
2565 }
|
|
2566 }
|
|
2567 if ( this->pRenderD3D )
|
|
2568 ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL));
|
|
2569 else
|
|
2570 pRenderer->EndScene();
|
|
2571 free(lineRGB);
|
|
2572 fclose(File);
|
|
2573 }
|
|
2574 }
|
|
2575 }
|
|
2576
|
|
2577 //----- (0049F5A2) --------------------------------------------------------
|
|
2578 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size )
|
|
2579 {
|
|
2580 void *v8; // esi@3
|
|
2581 void *v9; // esi@3
|
|
2582 unsigned short* v11; // eax@4
|
|
2583 // int v13; // eax@8
|
|
2584 // int v14; // ecx@8
|
|
2585 signed int v15; // eax@11
|
|
2586 // char v16; // zf@20
|
|
2587 // int result; // eax@21
|
|
2588 char v18[58]; // [sp+Ch] [bp-ACh]@3
|
|
2589 char v20[48]; // [sp+48h] [bp-70h]@3
|
|
2590 char *lineG; // [sp+78h] [bp-40h]@7
|
|
2591 char *lineB; // [sp+7Ch] [bp-3Ch]@7
|
|
2592 int v23; // [sp+80h] [bp-38h]@4
|
|
2593 int v24; // [sp+84h] [bp-34h]@4
|
|
2594 int v25; // [sp+88h] [bp-30h]@4
|
|
2595 int v26; // [sp+8Ch] [bp-2Ch]@4
|
|
2596 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3
|
|
2597 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3
|
|
2598 char *lineRGB; // [sp+A8h] [bp-10h]@3
|
|
2599 int pitch; // [sp+ACh] [bp-Ch]@1
|
|
2600 char v43; // [sp+B3h] [bp-5h]@18
|
|
2601 int i; // [sp+B4h] [bp-4h]@6
|
|
2602 unsigned short* line_picture_data;
|
|
2603 byte test_byte;
|
|
2604 unsigned char pict_byte;
|
|
2605
|
|
2606 int num_r_bits = 5;
|
|
2607 int num_g_bits = 6;
|
|
2608 int num_b_bits = 5;
|
|
2609
|
|
2610 int r_mask = 0xF800;
|
|
2611 int g_mask = 0x7E0;
|
|
2612 int b_mask = 0x1F;
|
|
2613
|
|
2614 pitch = wight;
|
|
2615 if ( wight & 1 )
|
|
2616 pitch = wight + 1;
|
|
2617 Src.left = 0;
|
|
2618 Src.up = 0;
|
|
2619 Src.right = wight - 1;
|
|
2620 Src.bottom = heidth - 1;
|
|
2621 v27.pitch = pitch;
|
|
2622 memset(&v20, 0, 0x30u);
|
|
2623 memset(&v18, 0, 0x38u);
|
|
2624 v8 = data_buff;
|
|
2625 v27.reserved = 0;
|
|
2626 *(_WORD *)&v18[56] = 0;
|
|
2627 Src.manufacturer = 10;
|
|
2628 Src.version = 5;
|
|
2629 Src.encoding = 1;
|
|
2630 Src.bpp = 8;
|
|
2631 Src.hdpi = 75;
|
|
2632 Src.vdpi = 75;
|
|
2633 v27.planes = 3;
|
|
2634 v27.palette_info = 1;
|
|
2635 memcpy(data_buff, &Src, 1);
|
|
2636 v8 = (char *)v8 + 1;
|
|
2637 memcpy(v8, &Src.version, 1);
|
|
2638 v8 = (char *)v8 + 1;
|
|
2639 memcpy(v8, &Src.encoding, 1);
|
|
2640 v8 = (char *)v8 + 1;
|
|
2641 memcpy(v8, &Src.bpp, 1);
|
|
2642 v8 = (char *)v8 + 1;
|
|
2643 memcpy(v8, &Src.left, 2);
|
|
2644 v8 = (char *)v8 + 2;
|
|
2645 memcpy(v8, &Src.up, 2);
|
|
2646 v8 = (char *)v8 + 2;
|
|
2647 memcpy(v8, &Src.right, 2);
|
|
2648 v8 = (char *)v8 + 2;
|
|
2649 memcpy(v8, &Src.bottom, 2);
|
|
2650 v8 = (char *)v8 + 2;
|
|
2651 memcpy(v8, &Src.hdpi, 2);
|
|
2652 v8 = (char *)v8 + 2;
|
|
2653 memcpy(v8, &Src.vdpi, 2);
|
|
2654 v8 = (char *)v8 + 2;
|
|
2655 memcpy(v8, &v20, 0x30u);
|
|
2656 v8 = (char *)v8 + 48;
|
|
2657 memcpy(v8, &v27, 1u);
|
|
2658 v8 = (char *)v8 + 1;
|
|
2659 memcpy(v8, &v27.planes, 1);
|
|
2660 v8 = (char *)v8 + 1;
|
|
2661 memcpy(v8, &v27.pitch, 2);
|
|
2662 v8 = (char *)v8 + 2;
|
|
2663 memcpy(v8, &v27.palette_info, 2);
|
|
2664 v8 = (char *)v8 + 2;
|
|
2665 memcpy(v8, &v18, 0x3Au);
|
|
2666 v9 = (char *)v8 + 58;
|
|
2667
|
|
2668 lineRGB = (char*)malloc(3 * (wight + 2));
|
|
2669 if ( heidth > 0 )
|
|
2670 {
|
|
2671 v26 = 3 * pitch;
|
|
2672 v23 = 2 * wight;
|
|
2673 v11 = picture_data;
|
|
2674 v24 = (int)picture_data;
|
|
2675 for ( v25 = heidth; v25; v25-- )
|
|
2676 {
|
|
2677 line_picture_data = v11;
|
|
2678 if ( wight > 0 )
|
|
2679 {
|
|
2680 lineG = (char *)lineRGB + pitch;
|
|
2681 lineB = (char *)lineRGB + 2 * pitch;
|
|
2682 for ( uint i = 0; i < wight; i++ )
|
|
2683 {
|
|
2684 lineRGB[i] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8);
|
|
2685 lineG[i] = (signed int)(g_mask & *line_picture_data) >> ( num_b_bits + num_g_bits- 8);
|
|
2686 lineB[i] = (b_mask & *line_picture_data) << (8 - num_b_bits);
|
|
2687 line_picture_data += 1;
|
|
2688 }
|
|
2689 }
|
|
2690 for ( i = 0; i < v26; v9 = (char *)v9 + 1 )
|
|
2691 {
|
|
2692 pict_byte = lineRGB[i];
|
|
2693 for ( test_byte = 1; test_byte < 63; ++test_byte )
|
|
2694 {
|
|
2695 v15 = i + test_byte;
|
|
2696 if ( lineRGB[v15] != pict_byte )//Uninitialized memory access
|
|
2697 break;
|
|
2698 if ( !(v15 % pitch) )
|
|
2699 break;
|
|
2700 }
|
|
2701 if ( i + test_byte > v26 )
|
|
2702 test_byte = 3 * pitch - i;
|
|
2703 if ( test_byte > 1 || pict_byte >= 192 )
|
|
2704 {
|
|
2705 v43 = test_byte | 0xC0;
|
|
2706 memcpy(v9, &v43, 1);
|
|
2707 v9 = (char *)v9 + 1;
|
|
2708 }
|
|
2709 memcpy(v9, &pict_byte, 1);
|
|
2710 i += test_byte;
|
|
2711 }
|
|
2712 v11 += wight;
|
|
2713 }
|
|
2714 }
|
|
2715 free(lineRGB);
|
|
2716 *(int *)packed_size = (char *)v9 - data_buff;
|
|
2717 }
|
|
2718
|
|
2719 //----- (0049F8B5) --------------------------------------------------------
|
|
2720 void Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height)
|
|
2721 {
|
|
2722 FILE *result; // eax@1
|
|
2723 FILE *pOutFile; // edi@4
|
|
2724 unsigned short* v9; // eax@5
|
|
2725 // int v10; // eax@7
|
|
2726 signed int v12; // eax@12
|
|
2727 // char v13; // zf@21
|
|
2728 char v14[56]; // [sp+4h] [bp-A0h]@4
|
|
2729 __int16 v15; // [sp+3Ch] [bp-68h]@4
|
|
2730 char color_map[48]; // [sp+40h] [bp-64h]@4
|
|
2731 int v18; // [sp+74h] [bp-30h]@5
|
|
2732 // char *v19; // [sp+78h] [bp-2Ch]@5
|
|
2733 int image_width; // [sp+7Ch] [bp-28h]@5
|
|
2734 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4
|
|
2735 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4
|
|
2736 char *lineRGB; // [sp+98h] [bp-Ch]@4
|
|
2737 int pitch; // [sp+9Ch] [bp-8h]@2
|
|
2738 char *lineB; // [sp+A0h] [bp-4h]@8
|
|
2739 char *lineG;
|
|
2740 unsigned short* line_pictute_data;
|
|
2741 byte test_byte;
|
|
2742 char v43;
|
|
2743
|
|
2744 int num_r_bits = 5;
|
|
2745 int num_g_bits = 6;
|
|
2746 int num_b_bits = 5;
|
|
2747
|
|
2748 int r_mask = 0xF800;
|
|
2749 int g_mask = 0x7E0;
|
|
2750 int b_mask = 0x1F;
|
|
2751
|
|
2752 result = fopen(Filename, "wb");
|
|
2753 Filename = (const char *)result;
|
|
2754 if ( result )
|
|
2755 {
|
|
2756 pitch = width;
|
|
2757 if ( width & 1 )
|
|
2758 pitch = width + 1;
|
|
2759 header1.left = 0;
|
|
2760 header1.up = 0;
|
|
2761 header1.right = width - 1;
|
|
2762 header1.bottom = height - 1;
|
|
2763 header2.pitch = pitch;
|
|
2764 memset(color_map, 0, sizeof(color_map));
|
|
2765 header2.reserved = 0;
|
|
2766 memset(v14, 0, sizeof(v14));
|
|
2767 v15 = 0;
|
|
2768 header1.manufacturer = 10;
|
|
2769 header1.version = 5;
|
|
2770 header1.encoding = 1;
|
|
2771 header1.bpp = 8;
|
|
2772 header1.hdpi = 75;
|
|
2773 header1.vdpi = 75;
|
|
2774 header2.planes = 3;
|
|
2775 header2.palette_info = 1;
|
|
2776 fwrite(&header1, 1, 1, (FILE *)Filename);
|
|
2777 pOutFile = (FILE *)Filename;
|
|
2778 fwrite(&header1.version, 1, 1, (FILE *)Filename);
|
|
2779 fwrite(&header1.encoding, 1, 1, pOutFile);
|
|
2780 fwrite(&header1.bpp, 1, 1, pOutFile);
|
|
2781 fwrite(&header1.left, 2, 1, pOutFile);
|
|
2782 fwrite(&header1.up, 2, 1, pOutFile);
|
|
2783 fwrite(&header1.right, 2, 1, pOutFile);
|
|
2784 fwrite(&header1.bottom, 2, 1, pOutFile);
|
|
2785 fwrite(&header1.hdpi, 2, 1, pOutFile);
|
|
2786 fwrite(&header1.vdpi, 2, 1, pOutFile);
|
|
2787 fwrite(color_map, 0x30u, 1, pOutFile);
|
|
2788 fwrite(&header2, 1, 1, pOutFile);
|
|
2789 fwrite(&header2.planes, 1, 1, pOutFile);
|
|
2790 fwrite(&header2.pitch, 2, 1, pOutFile);
|
|
2791 fwrite(&header2.palette_info, 2, 1, pOutFile);
|
|
2792 fwrite(v14, 0x3Au, 1, pOutFile);
|
|
2793
|
|
2794 lineRGB = (char *)malloc(3 * (width + 2));
|
|
2795 //Ïðè ñîõðàíåíèè èçîáðàæåíèÿ ïîäðÿä èäóùèå ïèêñåëè îäèíàêîâîãî öâåòà îáúåäèíÿþòñÿ è âìåñòî óêàçàíèÿ öâåòà äëÿ êàæäîãî ïèêñåëÿ
|
|
2796 //óêàçûâàåòñÿ öâåò ãðóïïû ïèêñåëåé è èõ êîëè÷åñòâî.
|
|
2797 image_width = 3 * pitch;
|
|
2798 v9 = picture_data;
|
|
2799 for ( v18 = 0; v18 < height; v18++ )//ñòîëáåö
|
|
2800 {
|
|
2801 line_pictute_data = v9;
|
|
2802 lineG = (char *)lineRGB + pitch;
|
|
2803 lineB = (char *)lineRGB + 2 * pitch;
|
|
2804
|
|
2805 for ( int i = 0; i < width; i++ )//ñòðîêà
|
|
2806 {
|
|
2807 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8);
|
|
2808 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8);
|
|
2809 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits);
|
|
2810 line_pictute_data += 1;
|
|
2811 }
|
|
2812 test_byte = 1;
|
|
2813 for ( int i = 0; (signed int)i < image_width; i += test_byte )
|
|
2814 {
|
|
2815 unsigned char pic_byte = lineRGB[i];
|
|
2816 for ( test_byte; test_byte < 63; ++test_byte )// ðàñ÷¸ò êîëè÷åñòâà îäèíàêîâûõ öâåòîâ
|
|
2817 {
|
|
2818 v12 = i + test_byte;
|
|
2819 if ( lineRGB[v12] != pic_byte )
|
|
2820 break;
|
|
2821 if ( !(v12 % pitch) )
|
|
2822 break;
|
|
2823 }
|
|
2824 if ( i + test_byte > image_width )
|
|
2825 test_byte = 3 * pitch - i;
|
|
2826 if ( test_byte > 1 || pic_byte >= 0xC0 )
|
|
2827 {
|
|
2828 v43 = test_byte | 0xC0;//òåñò-áàéò îáúåäèíåíèÿ
|
|
2829 fwrite(&v43, 1, 1, pOutFile);
|
|
2830 }
|
|
2831 fwrite(&pic_byte, 1, 1, pOutFile);
|
|
2832 }
|
|
2833 v9 += width;
|
|
2834 }
|
|
2835 free(lineRGB);
|
|
2836 fclose(pOutFile);
|
|
2837 }
|
|
2838 }
|
|
2839
|
|
2840 //----- (0049FBCD) --------------------------------------------------------
|
|
2841 void Render::ClearTarget(unsigned int uColor)
|
|
2842 {
|
|
2843 //if (pRenderD3D)
|
|
2844 {
|
|
2845 if (using_software_screen_buffer)
|
|
2846 pRenderD3D->ClearTarget(true, uColor, false, 0.0);
|
|
2847 }
|
|
2848 //else
|
|
2849 //memset32(pTargetSurface, uColor, field_10 * field_14 / 2);
|
|
2850 }
|
|
2851
|
|
2852
|
|
2853 //----- (0049FC37) --------------------------------------------------------
|
|
2854 void Render::Present()
|
|
2855 {
|
|
2856 //struct tagRECT Rect; // [sp+8h] [bp-28h]@11
|
|
2857 //RECT a4; // [sp+18h] [bp-18h]@11
|
|
2858 //struct tagPOINT Point; // [sp+28h] [bp-8h]@11
|
|
2859
|
|
2860 if ( !pRenderD3D || this->using_software_screen_buffer )
|
|
2861 {
|
|
2862 this->pBeforePresentFunction();
|
|
2863 if ( this->pRenderD3D )
|
|
2864 {
|
|
2865 if ( this->using_software_screen_buffer )
|
|
2866 pRenderD3D->Present(false);
|
|
2867 }
|
|
2868 else
|
|
2869 __debugbreak(); // no sr
|
|
2870 /*{
|
|
2871 if ( this->bWindowMode )
|
|
2872 {
|
|
2873 RestoreFrontBuffer();
|
|
2874 GetClientRect(this->hWnd, &Rect);
|
|
2875 Point.y = 0;
|
|
2876 Point.x = 0;
|
|
2877 ClientToScreen(this->hWnd, &Point);
|
|
2878 OffsetRect(&Rect, Point.x, Point.y);
|
|
2879 a4.top = 0;
|
|
2880 a4.bottom = 480;
|
|
2881 a4.left = 0;
|
|
2882 a4.right = 640;
|
|
2883 PresentRect(&Rect, &a4);
|
|
2884 }
|
|
2885 else
|
|
2886 {
|
|
2887 RestoreFrontBuffer();
|
|
2888 a4.top = 0;
|
|
2889 a4.bottom = 480;
|
|
2890 a4.left = 0;
|
|
2891 a4.right = 640;
|
|
2892 BltBackToFontFast(0, 0, &a4);
|
|
2893 }
|
|
2894 }*/
|
|
2895 }
|
|
2896 }
|
|
2897
|
|
2898 //----- (0049FD3A) --------------------------------------------------------
|
|
2899 void Render::_49FD3A_fullscreen()
|
|
2900 {
|
|
2901 RECT src_rect; // [sp+8h] [bp-10h]@6
|
|
2902
|
|
2903 if ( this->pRenderD3D )
|
|
2904 {
|
|
2905 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST)
|
|
2906 pFrontBuffer4->Restore();
|
|
2907 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST)
|
|
2908 pBackBuffer4->Restore();
|
|
2909 src_rect.top = 0;
|
|
2910 src_rect.bottom = window->GetHeight();
|
|
2911 src_rect.left = 0;
|
|
2912 src_rect.right = window->GetWidth();
|
|
2913 this->pBackBuffer4->BltFast(NULL, NULL, this->pFrontBuffer4, &src_rect, DDBLTFAST_WAIT);
|
|
2914 }
|
|
2915 }
|
|
2916
|
|
2917 //----- (0049FDBF) --------------------------------------------------------
|
|
2918 void Render::CreateZBuffer()
|
|
2919 {
|
|
2920 if (!pDefaultZBuffer)
|
|
2921 {
|
|
2922 pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000);
|
|
2923 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B)
|
|
2924 }
|
|
2925 }
|
|
2926
|
|
2927 //----- (0049FE05) --------------------------------------------------------
|
|
2928 void Render::Release()
|
|
2929 {
|
|
2930 //Render *v1; // esi@1
|
|
2931 //RenderD3D *v2; // ecx@1
|
|
2932 //char v3; // zf@4
|
|
2933 //void *v4; // ebx@6
|
|
2934 // IDirectDraw *v5; // eax@10
|
|
2935 // IDirectDrawSurface2 *v6; // eax@11
|
|
2936 // IDirectDrawSurface2 *v7; // eax@13
|
|
2937 // IDirectDrawSurface2 *v8; // eax@15
|
|
2938 // IDirectDraw2 *v9; // eax@17
|
|
2939 // IDirectDraw4 *v10; // eax@19
|
|
2940 // IDirectDrawSurface4 *v11; // eax@20
|
|
2941 // IDirectDrawSurface4 *v12; // eax@22
|
|
2942 // IDirectDrawSurface4 *v13; // eax@24
|
|
2943 // IDirectDraw4 *v14; // eax@26
|
|
2944 // unsigned __int16 **v15; // ebx@28
|
|
2945 // void **v16; // esi@29
|
|
2946
|
|
2947 // v1 = this;
|
|
2948 if (pRenderD3D)
|
|
2949 {
|
|
2950 if ( this->using_software_screen_buffer )
|
|
2951 {
|
|
2952 pRenderD3D->ClearTarget(true, 0, false, 1.0);
|
|
2953 pRenderD3D->Present(0);
|
|
2954 pRenderD3D->ClearTarget(true, 0, false, 1.0);
|
|
2955 }
|
|
2956 //this->pColorKeySurface4 = 0;
|
|
2957 this->pBackBuffer4 = nullptr;
|
|
2958 this->pFrontBuffer4 = nullptr;
|
|
2959 this->pDirectDraw4 = nullptr;
|
|
2960 delete [] this->pTargetSurface_unaligned;
|
|
2961 this->pTargetSurface = nullptr;
|
|
2962 this->pTargetSurface_unaligned = nullptr;
|
|
2963 if (pRenderD3D)
|
|
2964 {
|
|
2965 pRenderD3D->Release();
|
|
2966 delete pRenderD3D;
|
|
2967 }
|
|
2968 pRenderD3D = nullptr;
|
|
2969 }
|
|
2970 else
|
|
2971 ;//__debugbreak(); // no sr
|
|
2972 /*{
|
|
2973 if ( bWinNT4_0 == 1 )
|
|
2974 {
|
|
2975 v5 = (IDirectDraw *)this->pDirectDraw2;
|
|
2976 if ( !v5 )
|
|
2977 return;
|
|
2978 v5->SetCooperativeLevel(this->hWnd, 8u);
|
|
2979 this->pDirectDraw2->FlipToGDISurface();
|
|
2980 v6 = this->pSomeSurface2;
|
|
2981 if ( v6 )
|
|
2982 {
|
|
2983 v6->Release();
|
|
2984 this->pSomeSurface2 = 0;
|
|
2985 }
|
|
2986 v7 = this->pBackBuffer2;
|
|
2987 if ( v7 )
|
|
2988 {
|
|
2989 v7->Release();
|
|
2990 this->pBackBuffer2 = 0;
|
|
2991 }
|
|
2992 v8 = this->pFrontBuffer2;
|
|
2993 if ( v8 )
|
|
2994 {
|
|
2995 v8->Release();
|
|
2996 this->pFrontBuffer2 = 0;
|
|
2997 }
|
|
2998 v9 = this->pDirectDraw2;
|
|
2999 if ( v9 )
|
|
3000 {
|
|
3001 v9->Release();
|
|
3002 this->pDirectDraw2 = 0;
|
|
3003 }
|
|
3004 }
|
|
3005 else
|
|
3006 {
|
|
3007 v10 = this->pDirectDraw4;
|
|
3008 if ( !v10 )
|
|
3009 return;
|
|
3010 v10->SetCooperativeLevel(this->hWnd, 1032u);
|
|
3011 this->pDirectDraw4->FlipToGDISurface();
|
|
3012 v11 = this->pColorKeySurface4;
|
|
3013 if ( v11 )
|
|
3014 {
|
|
3015 v11->Release();
|
|
3016 this->pColorKeySurface4 = 0;
|
|
3017 }
|
|
3018 v12 = this->pBackBuffer4;
|
|
3019 if ( v12 )
|
|
3020 {
|
|
3021 v12->Release();
|
|
3022 this->pBackBuffer4 = 0;
|
|
3023 }
|
|
3024 v13 = this->pFrontBuffer4;
|
|
3025 if ( v13 )
|
|
3026 {
|
|
3027 v13->Release();
|
|
3028 this->pFrontBuffer4 = 0;
|
|
3029 }
|
|
3030 v14 = this->pDirectDraw4;
|
|
3031 if ( v14 )
|
|
3032 {
|
|
3033 v14->Release();
|
|
3034 this->pDirectDraw4 = 0;
|
|
3035 }
|
|
3036 }
|
|
3037 v15 = &this->pTargetSurface;
|
|
3038 if ( this->pTargetSurface )
|
|
3039 {
|
|
3040 v16 = (void **)&this->ptr_400E8;
|
|
3041 free(*v16);
|
|
3042 *v15 = 0;
|
|
3043 *v16 = 0;
|
|
3044 }
|
|
3045 }*/
|
|
3046 }
|
|
3047
|
|
3048 void Present32(unsigned __int32 *src, unsigned int src_pitch,
|
|
3049 unsigned __int32 *dst, unsigned int dst_pitch)
|
|
3050 {
|
|
3051 for (uint y = 0; y < 8; ++y)
|
|
3052 memcpy(dst + y * dst_pitch,
|
|
3053 src + y * src_pitch, src_pitch * sizeof(__int32));
|
|
3054
|
|
3055 for (uint y = 8; y < 352; ++y)
|
|
3056 {
|
|
3057 memcpy(dst + y * dst_pitch,
|
|
3058 src + y * src_pitch, 8 * sizeof(__int32));
|
|
3059 memcpy(dst + 8 + game_viewport_width + y * dst_pitch,
|
|
3060 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32));
|
|
3061 }
|
|
3062
|
|
3063 for (uint y = 352; y < 480; ++y)
|
|
3064 memcpy(dst + y * dst_pitch,
|
|
3065 src + y * src_pitch, src_pitch * sizeof(__int32));
|
|
3066
|
|
3067 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
|
|
3068 {
|
|
3069 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x)
|
|
3070 {
|
|
3071 //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask))
|
|
3072 if (src[x + y * src_pitch] != 0xFF00FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask))
|
|
3073 dst[x + y * dst_pitch] = src[x + y * src_pitch];
|
|
3074 }
|
|
3075 }
|
|
3076 }
|
|
3077
|
|
3078 //----- (004A597D) --------------------------------------------------------
|
|
3079 void Present_NoColorKey()
|
|
3080 {
|
|
3081 void *v2; // edi@4
|
|
3082 int v9; // eax@10
|
|
3083 unsigned int v10; // esi@10
|
|
3084 unsigned __int32 v11; // edi@10
|
|
3085 unsigned int v13; // ebx@10
|
|
3086 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3
|
|
3087 int v21; // [sp+8Ch] [bp-18h]@10
|
|
3088 __int32 v22; // [sp+90h] [bp-14h]@10
|
|
3089 unsigned int v24; // [sp+98h] [bp-Ch]@4
|
|
3090
|
|
3091 int r_mask = 0xF800;
|
|
3092 int g_mask = 0x7E0;
|
|
3093 int b_mask = 0x1F;
|
|
3094
|
|
3095 //if ( !pRenderer->uNumSceneBegins )
|
|
3096 {
|
|
3097 //if ( pRenderer->using_software_screen_buffer )
|
|
3098 //{
|
|
3099 memset(&Dst, 0, sizeof(Dst));
|
|
3100 Dst.dwSize = sizeof(Dst);
|
|
3101 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
|
|
3102 {
|
|
3103 //v26 = Dst.lpSurface;
|
|
3104 //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface;
|
|
3105 v24 = g_mask | b_mask | ((g_mask | b_mask) << 16);
|
|
3106 //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface;
|
|
3107 //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch;
|
|
3108 //v1 = pRenderer->pTargetSurface;
|
|
3109 v2 = Dst.lpSurface;
|
|
3110
|
|
3111
|
|
3112 /*for (uint y = 0; y < 480; ++y)
|
|
3113 {
|
|
3114 auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch);
|
|
3115 for (uint x = 0; x < 640; ++x)
|
|
3116 pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask;
|
|
3117 }*/
|
|
3118
|
|
3119 if (!FORCE_16_BITS)
|
|
3120 Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4);
|
|
3121 else
|
|
3122 {
|
|
3123 ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface;
|
|
3124 short* pDst = (__int16 *)Dst.lpSurface;
|
|
3125
|
|
3126 for (uint y = 0; y < 8; ++y)
|
|
3127 memcpy(pDst + y * Dst.lPitch / 2,
|
|
3128
|
|
3129 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16));
|
|
3130
|
|
3131 for (uint y = 8; y < 352; ++y)
|
|
3132 {
|
|
3133 memcpy(pDst + y * Dst.lPitch / 2,
|
|
3134 pSrc + y * window->GetWidth(), 8 * sizeof(__int16));
|
|
3135 memcpy(pDst + 8 + game_viewport_width/*462*/ + y * Dst.lPitch / 2,
|
|
3136 pSrc + 8 + game_viewport_width/*462*/ + y * window->GetWidth(), 174/*172*/ * sizeof(__int16));
|
|
3137 }
|
|
3138
|
|
3139 for (uint y = 352; y < window->GetHeight(); ++y)
|
|
3140 memcpy(pDst + y * Dst.lPitch / 2,
|
|
3141 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16));
|
|
3142
|
|
3143
|
|
3144 ushort* pSrc_x1y1 = pSrc + window->GetWidth() * pViewport->uViewportTL_Y + pViewport->uViewportTL_X;
|
|
3145 //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)];
|
|
3146 short* pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportTL_Y + pViewport->uViewportTL_X;
|
|
3147 //v23 = (unsigned __int32)((char *)v26 + 4 * (((signed int)pViewport->uViewportX >> 1) + (Dst.lPitch >> 2) * pViewport->uViewportY));
|
|
3148 v9 = ((signed int)pViewport->uViewportTL_X >> 1) - ((signed int)pViewport->uViewportBR_X >> 1);
|
|
3149 //v20 = ((signed int)pViewport->uViewportZ >> 1) - ((signed int)pViewport->uViewportX >> 1);
|
|
3150 v22 = 4 * ((Dst.lPitch / 4) + v9);
|
|
3151 v21 = 4 * v9 + 1280;
|
|
3152
|
|
3153 //auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1;
|
|
3154 //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1);
|
|
3155 v10 = (int)pSrc_x1y1;
|
|
3156 v11 = (int)pDst_x1y1;
|
|
3157 int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;
|
|
3158 v13 = v24;
|
|
3159
|
|
3160 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
|
|
3161 {
|
|
3162 //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2,
|
|
3163 // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16));
|
|
3164 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x)
|
|
3165 {
|
|
3166 if (pSrc[y * window->GetWidth() + x] != (g_mask | b_mask))
|
|
3167 pDst[y * Dst.lPitch / 2 + x] = pSrc[y * window->GetWidth() + x];
|
|
3168 }
|
|
3169 }
|
|
3170 }
|
|
3171
|
|
3172 ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL));
|
|
3173
|
|
3174 /* while ( 1 )
|
|
3175 {
|
|
3176 while ( 1 )
|
|
3177 {
|
|
3178 v14 = *(int *)v10;
|
|
3179 v10 += 4;
|
|
3180 if ( v14 == v13 )
|
|
3181 break;
|
|
3182 if ( (short)v14 == (short)v13 )
|
|
3183 {
|
|
3184 *(int *)v11 = *(int *)v11 & 0xFFFF | v14 & 0xFFFF0000;
|
|
3185 v11 += 4;
|
|
3186 --uHalfWidth;
|
|
3187 if ( !uHalfWidth )
|
|
3188 goto LABEL_21;
|
|
3189 }
|
|
3190 else
|
|
3191 {
|
|
3192 v15 = __ROL__(v14, 16);
|
|
3193 if ( (short)v15 == (short)v13 )
|
|
3194 {
|
|
3195 v17 = __ROR__(v15, 16);
|
|
3196 *(int *)v11 = *(int *)v11 & 0xFFFF0000 | (unsigned __int16)v17;
|
|
3197 v11 += 4;
|
|
3198 --uHalfWidth;
|
|
3199 if ( !uHalfWidth )
|
|
3200 goto LABEL_21;
|
|
3201 }
|
|
3202 else
|
|
3203 {
|
|
3204 v16 = __ROR__(v15, 16);
|
|
3205 *(int *)v11 = v16;
|
|
3206 v11 += 4;
|
|
3207 --uHalfWidth;
|
|
3208 if ( !uHalfWidth )
|
|
3209 goto LABEL_21;
|
|
3210 }
|
|
3211 }
|
|
3212 }
|
|
3213 v11 += 4;
|
|
3214 --uHalfWidth;
|
|
3215 if ( !uHalfWidth )
|
|
3216 {
|
|
3217 LABEL_21:
|
|
3218 v10 += v21;
|
|
3219 v11 += v22;
|
|
3220 uHalfWidth = v20;
|
|
3221 if ( !--uNumLines )
|
|
3222 {
|
|
3223 ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL));
|
|
3224 return;
|
|
3225 }
|
|
3226 }
|
|
3227 }*/
|
|
3228 }
|
|
3229 //}
|
|
3230 }
|
|
3231 }
|
|
3232
|
|
3233
|
|
3234 //----- (0049FFFB) --------------------------------------------------------
|
|
3235 bool Render::InitializeFullscreen()
|
|
3236 {
|
|
3237 RenderD3D__DevInfo *v7; // ecx@5
|
|
3238 bool v8; // eax@6
|
|
3239 unsigned int v10; // eax@13
|
|
3240 signed int v15; // ebx@31
|
|
3241 int *v22; // eax@42
|
|
3242 int v23; // ecx@42
|
|
3243 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25
|
|
3244 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40
|
|
3245 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25
|
|
3246 int v29; // [sp+308h] [bp-4h]@2
|
|
3247
|
|
3248 //__debugbreak(); // Nomad
|
|
3249
|
|
3250 this->using_software_screen_buffer = 0;
|
|
3251 //this->pColorKeySurface4 = 0;
|
|
3252 this->pBackBuffer4 = nullptr;
|
|
3253 this->pFrontBuffer4 = nullptr;
|
|
3254 this->pDirectDraw4 = nullptr;
|
|
3255 //this->bColorKeySupported = 0;
|
|
3256 Release();
|
|
3257 //v3 = hWnd;
|
|
3258 this->window = window;
|
|
3259 CreateZBuffer();
|
|
3260
|
|
3261 /*if (!bUserDirect3D)
|
|
3262 {
|
|
3263 CreateDirectDraw();
|
|
3264 SetDirectDrawCooperationMode(hWnd, 1);
|
|
3265 SetDirectDrawDisplayMode(640u, 480u, 16u);
|
|
3266 CreateDirectDrawPrimarySurface();
|
|
3267 v15 = 1;
|
|
3268 }
|
|
3269 else
|
|
3270 {*/
|
|
3271 pRenderD3D = new RenderD3D;
|
|
3272 //v28 = pRenderD3D;
|
|
3273 //v6 = uDesiredDirect3DDevice;
|
|
3274 v29 = -1;
|
|
3275 v7 = pRenderD3D->pAvailableDevices;
|
|
3276 if ( pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible )
|
|
3277 v8 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, /*0*/true, window);
|
|
3278 else
|
|
3279 {
|
|
3280 if ( v7[1].bIsDeviceCompatible )
|
|
3281 v8 = pRenderD3D->CreateDevice(1, /*0*/true, window);
|
|
3282 else
|
|
3283 {
|
|
3284 if ( !v7->bIsDeviceCompatible )
|
|
3285 Error("There aren't any D3D devices to create.");
|
|
3286
|
|
3287 v8 = pRenderD3D->CreateDevice(0, /*0*/true, window);
|
|
3288 }
|
|
3289 }
|
|
3290 if ( !v8 )
|
|
3291 Error("D3Drend->Init failed.");
|
|
3292
|
|
3293 //v9 = pRenderD3D;
|
|
3294 pBackBuffer4 = pRenderD3D->pBackBuffer;
|
|
3295 pFrontBuffer4 = pRenderD3D->pFrontBuffer;
|
|
3296 pDirectDraw4 = pRenderD3D->pHost;
|
|
3297 v10 = pRenderD3D->GetDeviceCaps();
|
|
3298 if ( v10 & 1 )
|
|
3299 {
|
|
3300 if ( pRenderD3D )
|
|
3301 {
|
|
3302 pRenderD3D->Release();
|
|
3303 delete pRenderD3D;
|
|
3304 }
|
|
3305 pRenderD3D = nullptr;
|
|
3306 pBackBuffer4 = nullptr;
|
|
3307 pFrontBuffer4 = nullptr;
|
|
3308 pDirectDraw4 = nullptr;
|
|
3309 Error("Direct3D renderer: The device failed to return capabilities.");
|
|
3310 }
|
|
3311 if ( v10 & 0x3E )
|
|
3312 {
|
|
3313 if ( pRenderD3D )
|
|
3314 {
|
|
3315 pRenderD3D->Release();
|
|
3316 delete pRenderD3D;
|
|
3317 }
|
|
3318 //pColorKeySurface4 = 0;
|
|
3319 pRenderD3D = nullptr;
|
|
3320 pBackBuffer4 = nullptr;
|
|
3321 pFrontBuffer4 = nullptr;
|
|
3322 pDirectDraw4 = nullptr;
|
|
3323 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes.");
|
|
3324 }
|
|
3325 if ( (v10 & 0x80) != 0 )
|
|
3326 {
|
|
3327 if ( pRenderD3D )
|
|
3328 {
|
|
3329 pRenderD3D->Release();
|
|
3330 delete pRenderD3D;
|
|
3331 }
|
|
3332 pRenderD3D = nullptr;
|
|
3333 pBackBuffer4 = nullptr;
|
|
3334 pFrontBuffer4 = nullptr;
|
|
3335 pDirectDraw4 = nullptr;
|
|
3336 Error("Direct3D renderer: The device doesn't support non-square textures.");
|
|
3337 }
|
|
3338 //LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1;
|
|
3339 bRequiredTextureStagesAvailable = CheckTextureStages();
|
|
3340
|
|
3341 memset(&halCaps, 0, sizeof(halCaps));
|
|
3342 halCaps.dwSize = sizeof(halCaps);
|
|
3343
|
|
3344 memset(&refCaps, 0, sizeof(refCaps));
|
|
3345 refCaps.dwSize = sizeof(refCaps);
|
|
3346
|
|
3347 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps));
|
|
3348
|
|
3349 uMinDeviceTextureDim = halCaps.dwMinTextureWidth;
|
|
3350 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight )
|
|
3351 uMinDeviceTextureDim = halCaps.dwMinTextureHeight;
|
|
3352 uMinDeviceTextureDim = halCaps.dwMaxTextureWidth;
|
|
3353 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight )
|
|
3354 uMinDeviceTextureDim = halCaps.dwMaxTextureHeight;
|
|
3355 if ( (unsigned int)uMinDeviceTextureDim < 4 )
|
|
3356 uMinDeviceTextureDim = 4;
|
|
3357 v15 = 1;
|
|
3358 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true));
|
|
3359 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true));
|
|
3360 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2));
|
|
3361 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false));
|
|
3362 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false));
|
|
3363 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false));
|
|
3364 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
|
|
3365 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2));
|
|
3366 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2));
|
|
3367 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3));
|
|
3368 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2));
|
|
3369 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0));
|
|
3370 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2));
|
|
3371 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2));
|
|
3372 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0));
|
|
3373 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4));
|
|
3374 //}
|
|
3375 ddpfPrimarySuface.dwSize = 32;
|
|
3376 GetTargetPixelFormat(&ddpfPrimarySuface);
|
|
3377 ParseTargetPixelFormat();
|
|
3378
|
|
3379 if (!pRenderD3D)
|
|
3380 {
|
|
3381 __debugbreak();
|
|
3382 pBeforePresentFunction = 0;//nullsub_1;
|
|
3383 }
|
|
3384 //else
|
|
3385 //{
|
|
3386 /*v16 = IsColorKeySupported(pDirectDraw4);
|
|
3387 v17 = uAcquiredDirect3DDevice == v15;
|
|
3388 bColorKeySupported = v16;
|
|
3389 if ( !v17 )
|
|
3390 bColorKeySupported = 0;
|
|
3391 if ( bColorKeySupported )
|
|
3392 {
|
|
3393 memset(&ddsd2, 0, sizeof(ddsd2));
|
|
3394 ddsd2.dwSize = sizeof(ddsd2);
|
|
3395 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask;
|
|
3396 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue;
|
|
3397 ddsd2.dwFlags = 65543;
|
|
3398 ddsd2.ddsCaps.dwCaps = 2112;
|
|
3399 ddsd2.dwWidth = 640;
|
|
3400 ddsd2.dwHeight = 480;
|
|
3401 ErrD3D(pDirectDraw4->CreateSurface(&ddsd2, &pColorKeySurface4, NULL));
|
|
3402 pBeforePresentFunction = Present_ColorKey;
|
|
3403 }
|
|
3404 else*/
|
|
3405 {
|
|
3406 pTargetSurface = nullptr;
|
|
3407 pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32);
|
|
3408 if ( !pTargetSurface_unaligned )
|
|
3409 return 0;
|
|
3410 memset(&pDesc, 0, sizeof(pDesc));
|
|
3411 pDesc.dwSize = sizeof(pDesc);
|
|
3412 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15) )
|
|
3413 return 0;
|
|
3414 pBackBuffer4->Unlock(NULL);
|
|
3415 v22 = (int *)pTargetSurface_unaligned + 4;
|
|
3416 v23 = (unsigned int)pDesc.lpSurface & 7;
|
|
3417 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8;
|
|
3418 uTargetSurfacePitch = window->GetWidth();
|
|
3419 pBeforePresentFunction = Present_NoColorKey;
|
|
3420 v15 = 1;
|
|
3421 pTargetSurface = (unsigned __int32 *)((char *)v22 + 2 * v23);
|
|
3422 }
|
|
3423 using_software_screen_buffer = v15;
|
|
3424 //}
|
|
3425 bWindowMode = 0;
|
|
3426 pParty->uFlags |= 2;
|
|
3427 pViewport->SetFOV(flt_6BE3A0 * 65536.0f);
|
|
3428 return v15 != 0;
|
|
3429 }
|
|
3430
|
|
3431 //----- (004A05F3) --------------------------------------------------------
|
|
3432 bool Render::SwitchToWindow()
|
|
3433 {
|
|
3434 bool v7; // eax@7
|
|
3435 unsigned int v9; // eax@12
|
|
3436 int v12; // eax@24
|
|
3437 int v13; // eax@26
|
|
3438 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24
|
|
3439 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37
|
|
3440 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24
|
|
3441 int v29; // [sp+308h] [bp-4h]@2
|
|
3442
|
|
3443 pParty->uFlags |= PARTY_FLAGS_1_0002;
|
|
3444 pViewport->SetFOV(flt_6BE3A0 * 65536.0f);
|
|
3445 using_software_screen_buffer = 0;
|
|
3446 Release();
|
|
3447 //pColorKeySurface4 = 0;
|
|
3448 pBackBuffer4 = nullptr;
|
|
3449 pFrontBuffer4 = nullptr;
|
|
3450 pDirectDraw4 = nullptr;
|
|
3451 //bColorKeySupported = 0;
|
|
3452 CreateZBuffer();
|
|
3453 /*if (!bUserDirect3D)
|
|
3454 {
|
|
3455 CreateDirectDraw();
|
|
3456 SetDirectDrawCooperationMode(hWnd, 0);
|
|
3457 field_4004C = 1;
|
|
3458 CreateFrontBuffer();
|
|
3459 CreateClipper(hWnd);
|
|
3460 CreateBackBuffer();
|
|
3461 field_40030 = 0;
|
|
3462 field_18_locked_pitch = 0;
|
|
3463 }
|
|
3464 else
|
|
3465 {*/
|
|
3466 /*v3 = malloc(0x148u);
|
|
3467 thisa = (RenderD3D *)v3;
|
|
3468 v29 = 0;
|
|
3469 if ( v3 )
|
|
3470 v4 = RenderD3D::RenderD3D((RenderD3D *)v3);
|
|
3471 else
|
|
3472 v4 = 0;*/
|
|
3473 pRenderD3D = new RenderD3D;
|
|
3474 //v4 = pRenderD3D;
|
|
3475 //v5 = uDesiredDirect3DDevice;
|
|
3476 v29 = -1;
|
|
3477 //v6 = pRenderD3D->pAvailableDevices;
|
|
3478 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible &&
|
|
3479 uDesiredDirect3DDevice != 1 )
|
|
3480 {
|
|
3481 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, true, window);
|
|
3482 }
|
|
3483 else
|
|
3484 {
|
|
3485 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible )
|
|
3486 Error("There aren't any D3D devices to init.");
|
|
3487
|
|
3488 v7 = pRenderD3D->CreateDevice(0, true, window);
|
|
3489 }
|
|
3490 if ( !v7 )
|
|
3491 Error("D3Drend->Init failed.");
|
|
3492
|
|
3493 //v8 = pRenderD3D;
|
|
3494 //pColorKeySurface4 = 0;
|
|
3495 pBackBuffer4 = pRenderD3D->pBackBuffer;
|
|
3496 pFrontBuffer4 = pRenderD3D->pFrontBuffer;
|
|
3497 pDirectDraw4 = pRenderD3D->pHost;
|
|
3498 v9 = pRenderD3D->GetDeviceCaps();
|
|
3499 if ( v9 & 1 )
|
|
3500 {
|
|
3501 if (pRenderD3D)
|
|
3502 {
|
|
3503 pRenderD3D->Release();
|
|
3504 delete pRenderD3D;
|
|
3505 }
|
|
3506 pRenderD3D = nullptr;
|
|
3507 pBackBuffer4 = nullptr;
|
|
3508 pFrontBuffer4 = nullptr;
|
|
3509 pDirectDraw4 = nullptr;
|
|
3510 Error("Direct3D renderer: The device failed to return capabilities.");
|
|
3511 }
|
|
3512 if ( v9 & 0x3E )
|
|
3513 {
|
|
3514 if (pRenderD3D)
|
|
3515 {
|
|
3516 pRenderD3D->Release();
|
|
3517 delete pRenderD3D;
|
|
3518 }
|
|
3519 //pColorKeySurface4 = 0;
|
|
3520 pRenderD3D = nullptr;
|
|
3521 pBackBuffer4 = nullptr;
|
|
3522 pFrontBuffer4 = nullptr;
|
|
3523 pDirectDraw4 = nullptr;
|
|
3524 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes.");
|
|
3525 }
|
|
3526 if (v9 & 0x80)
|
|
3527 {
|
|
3528 if (pRenderD3D)
|
|
3529 {
|
|
3530 pRenderD3D->Release();
|
|
3531 delete pRenderD3D;
|
|
3532 }
|
|
3533 pRenderD3D = nullptr;
|
|
3534 pBackBuffer4 = nullptr;
|
|
3535 pFrontBuffer4 = nullptr;
|
|
3536 pDirectDraw4 = nullptr;
|
|
3537 Error("Direct3D renderer: The device doesn't support non-square textures.");
|
|
3538 }
|
|
3539 //LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1;
|
|
3540 bRequiredTextureStagesAvailable = CheckTextureStages();
|
|
3541
|
|
3542 memset(&halCaps, 0, sizeof(halCaps));
|
|
3543 halCaps.dwSize = sizeof(halCaps);
|
|
3544
|
|
3545 memset(&refCaps, 0, sizeof(refCaps));
|
|
3546 refCaps.dwSize = sizeof(refCaps);
|
|
3547
|
|
3548 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps));
|
|
3549 v12 = halCaps.dwMinTextureWidth;
|
|
3550 if ( (unsigned int)halCaps.dwMinTextureWidth > halCaps.dwMinTextureHeight )
|
|
3551 v12 = halCaps.dwMinTextureHeight;
|
|
3552 uMinDeviceTextureDim = v12;
|
|
3553 v13 = halCaps.dwMaxTextureWidth;
|
|
3554 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight )
|
|
3555 v13 = halCaps.dwMaxTextureHeight;
|
|
3556 uMaxDeviceTextureDim = v13;
|
|
3557 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1));
|
|
3558 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1));
|
|
3559 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2));
|
|
3560 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0));
|
|
3561 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0));
|
|
3562 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
|
|
3563 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2));
|
|
3564 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2));
|
|
3565 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3));
|
|
3566 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2));
|
|
3567 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0));
|
|
3568 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2));
|
|
3569 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2));
|
|
3570 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0));
|
|
3571 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4));
|
|
3572 //}
|
|
3573
|
|
3574 ddpfPrimarySuface.dwSize = 32;
|
|
3575 GetTargetPixelFormat(&ddpfPrimarySuface);
|
|
3576 ParseTargetPixelFormat();
|
|
3577
|
|
3578 if ( !pRenderD3D )
|
|
3579 {
|
|
3580 __debugbreak();
|
|
3581 //pBeforePresentFunction = 0;//nullsub_1;
|
|
3582 //goto LABEL_47;
|
|
3583 }
|
|
3584 /*v14 = IsColorKeySupported(pDirectDraw4);
|
|
3585 v15 = uAcquiredDirect3DDevice == 1;
|
|
3586 bColorKeySupported = v14;
|
|
3587 if ( !v15 )
|
|
3588 bColorKeySupported = 0;*/
|
|
3589 //if ( bColorKeySupported )
|
|
3590 if (false)
|
|
3591 {
|
|
3592 /*memset(&ddsd2, 0, 0x7Cu);
|
|
3593 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask;
|
|
3594 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue;
|
|
3595 v16 = pDirectDraw4;
|
|
3596 ddsd2.dwSize = 124;
|
|
3597 ddsd2.dwFlags = 65543;
|
|
3598 ddsd2.ddsCaps.dwCaps = 2112;
|
|
3599 ddsd2.dwWidth = 640;
|
|
3600 ddsd2.dwHeight = 480;
|
|
3601 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, NULL));
|
|
3602 pBeforePresentFunction = Present_ColorKey;*/
|
|
3603 using_software_screen_buffer = 1;
|
|
3604 //LABEL_47:
|
|
3605 bWindowMode = 1;
|
|
3606 //hWnd = hWnd;
|
|
3607 return 0;
|
|
3608 }
|
|
3609 pTargetSurface = 0;
|
|
3610 pTargetSurface_unaligned = 0;
|
|
3611
|
|
3612 uint num_pixels = window->GetWidth() * window->GetHeight();
|
|
3613 pTargetSurface_unaligned = new unsigned int[num_pixels];
|
|
3614
|
|
3615 if (!pTargetSurface_unaligned)
|
|
3616 return false;
|
|
3617
|
|
3618 memset(&pDesc, 0, sizeof(pDesc));
|
|
3619 pDesc.dwSize = sizeof(pDesc);
|
|
3620 if (!pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT))
|
|
3621 {
|
|
3622 delete [] pTargetSurface_unaligned;
|
|
3623 return false;
|
|
3624 }
|
|
3625
|
|
3626 memset32(pTargetSurface_unaligned, -1, num_pixels);
|
|
3627
|
|
3628 pRenderer->pBackBuffer4->Unlock(NULL);
|
|
3629 /*v19 = pTargetSurface_unaligned;
|
|
3630 v20 = (unsigned int)pDesc.lpSurface & 7;
|
|
3631 v21 = (unsigned int)ptr_400E8 & 7;
|
|
3632 if ( v21 == v20 )
|
|
3633 pTargetSurface = (unsigned __int16 *)v19;
|
|
3634 else
|
|
3635 {
|
|
3636 if ( (signed int)v21 >= v20 )
|
|
3637 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16);
|
|
3638 else
|
|
3639 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16);
|
|
3640 pTargetSurface = (unsigned __int16 *)v22;
|
|
3641 }*/
|
|
3642 pTargetSurface = pTargetSurface_unaligned;
|
|
3643 uTargetSurfacePitch = window->GetWidth();
|
|
3644 pBeforePresentFunction = Present_NoColorKey;
|
|
3645 using_software_screen_buffer = 1;
|
|
3646 bWindowMode = 1;
|
|
3647 return 0;
|
|
3648 }
|
|
3649
|
|
3650
|
|
3651 //----- (0044F2B2) --------------------------------------------------------
|
|
3652 bool Render::IsGammaSupported()
|
|
3653 {
|
|
3654 // bool result; // eax@3
|
|
3655 // HRESULT v1; // eax@4
|
|
3656
|
|
3657 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
3658 {
|
|
3659 DDCAPS halCaps; // [sp+0h] [bp-180h]@4
|
|
3660 memset(&halCaps, 0, sizeof(DDCAPS));
|
|
3661 halCaps.dwSize = sizeof(DDCAPS);
|
|
3662
|
|
3663 ErrD3D(pDirectDraw4->GetCaps(&halCaps, 0));
|
|
3664 return (halCaps.dwCaps2 >> 17) & 1;
|
|
3665 }
|
|
3666 /*else
|
|
3667 return false;*/
|
|
3668 }
|
|
3669
|
|
3670 //----- (004A0BEE) --------------------------------------------------------
|
|
3671 void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor)
|
|
3672 {
|
|
3673 signed int lower_bound; // eax@17
|
|
3674 // signed int left_bound;
|
|
3675 unsigned int v21; // edi@46
|
|
3676 int v22; // esi@47
|
|
3677 int v23; // ebx@47
|
|
3678 signed int v24; // edx@50
|
|
3679 signed int v25; // esi@52
|
|
3680 unsigned __int16 *v26; // ecx@52
|
|
3681 int v27; // ebx@54
|
|
3682 int v28; // edi@55
|
|
3683 int v29; // edx@55
|
|
3684 int v30; // ebx@60
|
|
3685 int v31; // edx@61
|
|
3686 int v32; // edi@61
|
|
3687 signed int upper_bound; // [sp+18h] [bp-4h]@28
|
|
3688 unsigned int uXa; // [sp+24h] [bp+8h]@49
|
|
3689 int uYb; // [sp+28h] [bp+Ch]@47
|
|
3690 bool left_border_x = false;
|
|
3691 bool right_border_x = false;
|
|
3692 bool left_border_z = false;
|
|
3693 bool right_border_z = false;
|
|
3694 bool upper_border_y = false;
|
|
3695 bool bottom_border_y = false;
|
|
3696 bool upper_border_w = false;
|
|
3697 bool bottom_border_w = false;
|
|
3698
|
|
3699 if ( uX < this->raster_clip_x )// x âûõîäèò çà ðàìêè ëåâîé ãðàíèöû
|
|
3700 left_border_x = true;
|
|
3701 if ( uX > this->raster_clip_z )// x âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû
|
|
3702 right_border_x = true;
|
|
3703
|
|
3704 if ( uZ < this->raster_clip_x )// z âûõîäèò çà ðàìêè ëåâîé ãðàíèöû
|
|
3705 left_border_z = true;
|
|
3706 if ( uZ > this->raster_clip_z )// z âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû
|
|
3707 right_border_z = true;
|
|
3708
|
|
3709 if ( uY < this->raster_clip_y )// y âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû
|
|
3710 upper_border_y = true;
|
|
3711 if ( uY > this->raster_clip_w )// y âûõîäèò çà ðàìêè íèæíåé ãðàíèöû
|
|
3712 bottom_border_y = true;
|
|
3713
|
|
3714 if ( uW < this->raster_clip_y )// w âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû
|
|
3715 upper_border_w = true;
|
|
3716 if ( uW > this->raster_clip_w )// w âûõîäèò çà ðàìêè íèæíåé ãðàíèöû
|
|
3717 bottom_border_w = true;
|
|
3718
|
|
3719 if ( (left_border_x && left_border_z) || (right_border_x && right_border_z )
|
|
3720 || (upper_border_y && upper_border_w) || (bottom_border_y && bottom_border_w))
|
|
3721 return;
|
|
3722
|
|
3723 if ( left_border_x || left_border_z || right_border_x || right_border_z
|
|
3724 || upper_border_y || upper_border_w || bottom_border_y || bottom_border_w)
|
|
3725 {
|
|
3726 if ( left_border_x || left_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left (ëåâàÿ ãðàíèöà)
|
|
3727 {
|
|
3728 if ( left_border_x )//left_border = true; õ ìåíüøå ëåâîé ãðàíèöû
|
|
3729 {
|
|
3730 uY += (uW - uY) * ((this->raster_clip_x - uX) / (uZ - uX));//t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ)
|
|
3731 uX = this->raster_clip_x;
|
|
3732 }
|
|
3733 else if ( left_border_z )//z ìåíüøå ëåâîé ãðàíèöû
|
|
3734 {
|
|
3735 uZ = this->raster_clip_x;
|
|
3736 uW += (uY - uW) * ((this->raster_clip_x - uZ) / (uX - uZ));
|
|
3737 }
|
|
3738 }
|
|
3739
|
|
3740 if ( right_border_x || right_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )//for right (ïðàâàÿ ãðàíèöà)
|
|
3741 {
|
|
3742 if ( right_border_x ) //right_border = true; õ áîëüøå ïðàâîé ãðàíèöû
|
|
3743 {
|
|
3744 uY += (uY - uW) * ((this->raster_clip_z - uX) / (uZ - uX));
|
|
3745 uX = this->raster_clip_z;
|
|
3746 }
|
|
3747 else if ( right_border_z )//z áîëüøå ïðàâîé ãðàíèöû
|
|
3748 {
|
|
3749 uW += (uW - uY) * ((this->raster_clip_z - uZ) / (uX - uZ));
|
|
3750 uZ = this->raster_clip_z;
|
|
3751 }
|
|
3752 }
|
|
3753
|
|
3754 upper_bound = 0;
|
|
3755 if ( uY < this->raster_clip_y )
|
|
3756 upper_bound = 2;
|
|
3757 if ( uY > this->raster_clip_w )
|
|
3758 upper_bound |= 1;
|
|
3759
|
|
3760 lower_bound = 0;
|
|
3761 if ( uW < this->raster_clip_y )
|
|
3762 lower_bound = 2;
|
|
3763 if ( uW > this->raster_clip_w )
|
|
3764 lower_bound |= 1;
|
|
3765
|
|
3766 if ( !(lower_bound & upper_bound) )//for up and down(äëÿ âåðõà è íèçà)
|
|
3767 {
|
|
3768 lower_bound ^= upper_bound;
|
|
3769 if ( lower_bound & 2 )
|
|
3770 {
|
|
3771 if ( upper_bound & 2 )
|
|
3772 {
|
|
3773 uX += (uZ - uX) * ((this->raster_clip_y - uY) / (uW - uY));
|
|
3774 uY = this->raster_clip_y;
|
|
3775 }
|
|
3776 else
|
|
3777 {
|
|
3778 uZ += (uX - uZ) * ((this->raster_clip_y - uW) / (uY - uW));
|
|
3779 uW = this->raster_clip_y;
|
|
3780 }
|
|
3781 }
|
|
3782 if ( lower_bound & 1 )
|
|
3783 {
|
|
3784 if ( upper_bound & 1 )
|
|
3785 {
|
|
3786 uX += (uZ - uX) * ((this->raster_clip_w - uY) / (uW - uY));
|
|
3787 uY = this->raster_clip_w;
|
|
3788 }
|
|
3789 else
|
|
3790 {
|
|
3791 uZ += (uX - uZ) * ((this->raster_clip_w - uW) / (uY - uW));
|
|
3792 uW = this->raster_clip_w;
|
|
3793 }
|
|
3794 }
|
|
3795 }
|
|
3796 }
|
|
3797 v21 = pRenderer->uTargetSurfacePitch;
|
|
3798 if ( pRenderer->uTargetSurfacePitch )
|
|
3799 {
|
|
3800 //v12 = uX + uY * pRenderer->uTargetSurfacePitch;
|
|
3801 v22 = uW - uY;
|
|
3802 v23 = v22;
|
|
3803 uYb = v22;
|
|
3804 if ( v22 < 0 )
|
|
3805 {
|
|
3806 v23 = -v22;
|
|
3807 uYb = -v22;
|
|
3808 v21 = -pRenderer->uTargetSurfacePitch;
|
|
3809 }
|
|
3810 uXa = uZ - uX;
|
|
3811 if ((signed)(uZ - uX) >= 0)
|
|
3812 v24 = 1;
|
|
3813 else
|
|
3814 {
|
|
3815 uXa = -uXa;
|
|
3816 v24 = -1;
|
|
3817 }
|
|
3818 v25 = 0;
|
|
3819
|
|
3820 v26 = (unsigned __int16 *)this->pTargetSurface;
|
|
3821 if ( v26 )
|
|
3822 {
|
|
3823 if ( (signed int)uXa <= v23 )//ðèñóåì âåðòèêàëüíóþ ëèíèþ
|
|
3824 {
|
|
3825 v30 = v23 + 1;
|
|
3826 if ( v30 > 0 )
|
|
3827 {
|
|
3828 v31 = 2 * v24;
|
|
3829 v32 = 2 * v21;
|
|
3830 //v12 = (int)&v26[v12];
|
|
3831 int y = 0;
|
|
3832 int x = 0;
|
|
3833 for ( v30; v30; --v30 )
|
|
3834 {
|
|
3835 v25 += uXa;
|
|
3836 //*(short *)v12 = uColor;
|
|
3837 //v12 += v32;
|
|
3838 WritePixel16(uX + x, uY + y, uColor);
|
|
3839 if ( v32 >= 0 )
|
|
3840 y += 1;
|
|
3841 else
|
|
3842 y -= 1;
|
|
3843 if ( v25 > 0 )
|
|
3844 {
|
|
3845 v25 -= uYb;
|
|
3846 //v12 += v31;
|
|
3847 if ( v31 >= 0 )
|
|
3848 x += 1;
|
|
3849 else
|
|
3850 x -= 1;
|
|
3851 }
|
|
3852 }
|
|
3853 }
|
|
3854 }
|
|
3855 else//ðèñóåì ãîðèçîíòàëüíóþ ëèíèþ
|
|
3856 {
|
|
3857 v27 = uXa + 1;
|
|
3858 if ( (signed int)(uXa + 1) > 0 )
|
|
3859 {
|
|
3860 v28 = 2 * v21;
|
|
3861 v29 = 2 * v24;
|
|
3862 int y = 0;
|
|
3863 int x = 0;
|
|
3864 //v12 = (int)&v26[v12];
|
|
3865 for ( v27; v27; --v27 )
|
|
3866 {
|
|
3867 v25 += uYb;
|
|
3868 //*(short *)v12 = uColor;
|
|
3869 //v12 += v29;
|
|
3870 WritePixel16(uX + x, uY + y, uColor);
|
|
3871 if ( v29 >= 0 )
|
|
3872 x += 1;
|
|
3873 else
|
|
3874 x -= 1;
|
|
3875 if ( v25 > (signed int)uXa )
|
|
3876 {
|
|
3877 v25 -= uXa;
|
|
3878 //v12 += v28;
|
|
3879 if ( v28 >= 0 )
|
|
3880 y += 1;
|
|
3881 else
|
|
3882 y -= 1;
|
|
3883 }
|
|
3884 }
|
|
3885 }
|
|
3886 }
|
|
3887 }
|
|
3888 }
|
|
3889 return;
|
|
3890 }
|
|
3891
|
|
3892 //----- (004A0E80) --------------------------------------------------------
|
|
3893 void Render::ClearZBuffer(int a2, int a3)
|
|
3894 {
|
|
3895 memset32(this->pActiveZBuffer, -65536, 0x4B000);
|
|
3896 }
|
|
3897
|
|
3898 //----- (004A0E97) --------------------------------------------------------
|
|
3899 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
|
|
3900 {
|
|
3901 this->raster_clip_x = uX;
|
|
3902 this->raster_clip_y = uY;
|
|
3903 this->raster_clip_z = uZ;
|
|
3904 this->raster_clip_w = uW;
|
|
3905 }
|
|
3906
|
|
3907 //----- (004A0EB6) --------------------------------------------------------
|
|
3908 void Render::ParseTargetPixelFormat()
|
|
3909 {
|
|
3910 signed int v2; // ecx@1
|
|
3911 DWORD uRedMask; // edx@1
|
|
3912 unsigned int uGreenMask; // esi@5
|
|
3913 signed int v5; // ecx@5
|
|
3914 unsigned int uBlueMask; // edx@9
|
|
3915 signed int v7; // ecx@9
|
|
3916 //unsigned int v8; // ecx@13
|
|
3917
|
|
3918 v2 = 0;
|
|
3919 uRedMask = this->ddpfPrimarySuface.dwRBitMask;
|
|
3920 this->uTargetBBits = 0;
|
|
3921 this->uTargetGBits = 0;
|
|
3922 this->uTargetRBits = 0;
|
|
3923 do
|
|
3924 {
|
|
3925 if ( (1 << v2) & uRedMask )
|
|
3926 ++this->uTargetRBits;
|
|
3927 ++v2;
|
|
3928 }
|
|
3929 while ( v2 < 32 );
|
|
3930 uGreenMask = this->ddpfPrimarySuface.dwGBitMask;
|
|
3931 v5 = 0;
|
|
3932 do
|
|
3933 {
|
|
3934 if ( (1 << v5) & uGreenMask )
|
|
3935 ++this->uTargetGBits;
|
|
3936 ++v5;
|
|
3937 }
|
|
3938 while ( v5 < 32 );
|
|
3939 uBlueMask = this->ddpfPrimarySuface.dwBBitMask;
|
|
3940 v7 = 0;
|
|
3941 do
|
|
3942 {
|
|
3943 if ( (1 << v7) & uBlueMask )
|
|
3944 ++this->uTargetBBits;
|
|
3945 ++v7;
|
|
3946 }
|
|
3947 while ( v7 < 32 );
|
|
3948 this->uTargetGMask = uGreenMask;
|
|
3949 this->uTargetRMask = this->ddpfPrimarySuface.dwRBitMask;
|
|
3950 this->uTargetBMask = uBlueMask;
|
|
3951 }
|
|
3952
|
|
3953 //----- (004A0F40) --------------------------------------------------------
|
|
3954 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags)
|
|
3955 {
|
|
3956 HRESULT result; // eax@1
|
|
3957 HRESULT v6; // eax@4
|
|
3958 char v9; // [sp+Bh] [bp-1h]@1
|
|
3959
|
|
3960 v9 = 1;
|
|
3961 result = pSurface->Lock(NULL, pDesc, uLockFlags, NULL);
|
|
3962 /*
|
|
3963 Êîãäà îáúåêò DirectDrawSurface òåðÿåò ïîâåðõíîñòíóþ ïàìÿòü, ìåòîäû âîçâðàòÿò DDERR_SURFACELOST
|
|
3964 è íå âûïîëíÿò íèêàêóþ äðóãóþ ôóíêöèþ. Ìåòîä IDirectDrawSurface::Restore ïåðåðàñïðåäåëèò ïîâåðõíîñòíóþ ïàìÿòü
|
|
3965 è ïîâòîðíî ïðèñîåäèíèò åå ê îáúåêòó DirectDrawSurface.
|
|
3966 */
|
|
3967 if ( result == DDERR_SURFACELOST )
|
|
3968 {
|
|
3969 v6 = pSurface->Restore();//Âîññòàíàâëèâàåò ïîòåðÿííóþ ïîâåðõíîñòü. Ýòî ïðîèñõîäèò, êîãäà ïîâåðõíîñòíàÿ ïàìÿòü,
|
|
3970 //ñâÿçàííàÿ ñ îáúåêòîì DirectDrawSurface áûëà îñâîáîæäåíà.
|
|
3971 if ( v6 )
|
|
3972 {
|
|
3973 if ( v6 != DDERR_IMPLICITLYCREATED )//DDERR_IMPLICITLYCREATED - Ïîâåðõíîñòü íå ìîæåò áûòü âîññòàíîâëåíà,
|
|
3974 //ïîòîìó ÷òî îíà - íåÿâíî ñîçäàííàÿ ïîâåðõíîñòü.
|
|
3975 {
|
|
3976 v9 = 0;
|
|
3977 result = (bool)memset(pDesc, 0, 4);
|
|
3978 LOBYTE(result) = v9;
|
|
3979 return 0;
|
|
3980 }
|
|
3981 pRenderer->pFrontBuffer4->Restore();
|
|
3982 pSurface->Restore();
|
|
3983 }
|
|
3984 result = pSurface->Lock(NULL, pDesc, DDLOCK_WAIT, NULL);
|
|
3985 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY )//DDERR_SURFACEBUSY - Äîñòóï ê ýòîé ïîâåðõíîñòè îòêàçàí,
|
|
3986 //ïîòîìó ÷òî ïîâåðõíîñòü áëîêèðîâàíà äðóãîé íèòüþ. DDERR_INVALIDRECT - Îáåñïå÷èâàåìûé ïðÿìîóãîëüíèê íåäîïóñòèì.
|
|
3987 {
|
|
3988 v9 = 0;
|
|
3989 result = (bool)memset(pDesc, 0, 4);
|
|
3990 LOBYTE(result) = v9;
|
|
3991 return result;
|
|
3992 }
|
|
3993 ErrD3D(result);
|
|
3994 if ( result )
|
|
3995 {
|
|
3996 //v8 = 0;
|
|
3997 //v7 = 2161;
|
|
3998 //LABEL_19:
|
|
3999 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8);
|
|
4000 v9 = 0;
|
|
4001 result = (bool)memset(pDesc, 0, 4);
|
|
4002 LOBYTE(result) = v9;
|
|
4003 return result;
|
|
4004 }
|
|
4005 if ( pRenderD3D )
|
|
4006 pRenderD3D->HandleLostResources();
|
|
4007 result = pRenderer->pDirectDraw4->RestoreAllSurfaces();
|
|
4008 }
|
|
4009 else
|
|
4010 {
|
|
4011 if ( result )
|
|
4012 {
|
|
4013 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY )
|
|
4014 {
|
|
4015 v9 = 0;
|
|
4016 result = (bool)memset(pDesc, 0, 4);
|
|
4017 LOBYTE(result) = v9;
|
|
4018 return result;
|
|
4019 }
|
|
4020 ErrD3D(result);
|
|
4021 //v8 = 0;
|
|
4022 //v7 = 2199;
|
|
4023 //goto LABEL_19;
|
|
4024 }
|
|
4025 }
|
|
4026 return true;
|
|
4027 }
|
|
4028
|
|
4029
|
|
4030 //----- (004A10E4) --------------------------------------------------------
|
|
4031 void Render::CreateDirectDraw()
|
|
4032 {
|
|
4033 //Render *v1; // edi@1
|
|
4034 // HRESULT v2; // eax@1
|
|
4035 // HRESULT v3; // eax@5
|
|
4036 // int v6; // [sp-Ch] [bp-20h]@3
|
|
4037 // unsigned int v9; // [sp+0h] [bp-14h]@0
|
|
4038 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1
|
|
4039
|
|
4040 //v1 = this;
|
|
4041 ErrD3D(DirectDrawCreate(0, &lpDD, 0));
|
|
4042
|
|
4043 pDirectDraw4 = nullptr;
|
|
4044
|
|
4045 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4));
|
|
4046
|
|
4047 lpDD->Release();
|
|
4048 lpDD = nullptr;
|
|
4049 }
|
|
4050
|
|
4051 //----- (004A1169) --------------------------------------------------------
|
|
4052 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen)
|
|
4053 {
|
|
4054 DWORD flags; // eax@1
|
|
4055
|
|
4056 //Óñòàíîâêà âçàèìîäåéñòâèÿ äëÿ ïîëíîýêðàííîãî è îêîííîãî ðåæèìîâ
|
|
4057 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : DDSCL_NORMAL;
|
|
4058
|
|
4059 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED));
|
|
4060 }
|
|
4061
|
|
4062 //----- (004A11C6) --------------------------------------------------------
|
|
4063 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP)
|
|
4064 {
|
|
4065 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0));
|
|
4066 }
|
|
4067
|
|
4068 //----- (004A121C) --------------------------------------------------------
|
|
4069 void Render::CreateFrontBuffer()
|
|
4070 {
|
|
4071 //Render *v1; // esi@1
|
|
4072 IDirectDraw *pDD; // eax@3
|
|
4073 IDirectDrawSurface **pOutSurf; // esi@3
|
|
4074 struct _DDSURFACEDESC *v4; // edx@3
|
|
4075 //// HRESULT v5; // eax@5
|
|
4076 int v6; // [sp-8h] [bp-8Ch]@3
|
|
4077 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3
|
|
4078
|
|
4079 //v1 = this;
|
|
4080 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
|
|
4081 //pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
4082 {
|
|
4083 memset(&a2, 0, sizeof(a2));
|
|
4084 a2.dwSize = sizeof(a2);
|
|
4085
|
|
4086 pDD = (IDirectDraw *)this->pDirectDraw4;
|
|
4087 a2.dwFlags = 1;
|
|
4088 a2.ddsCaps.dwCaps = 512;//DDSCAPS_PRIMARYSURFACE = 0x200
|
|
4089
|
|
4090 v6 = 2357;
|
|
4091 pOutSurf = (IDirectDrawSurface **)&this->pFrontBuffer4;
|
|
4092 v4 = (struct _DDSURFACEDESC *)&a2;
|
|
4093 }
|
|
4094 /*else
|
|
4095 {
|
|
4096 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here
|
|
4097 pDD = (IDirectDraw *)v1->pDirectDraw2;
|
|
4098 a2.lPitch = 108;
|
|
4099 a2.dwBackBufferCount = 1;
|
|
4100 a2.dwTextureStage = 512;
|
|
4101 v6 = 2346;
|
|
4102 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2;
|
|
4103 v4 = (struct _DDSURFACEDESC *)&a2.lPitch;
|
|
4104 }*/
|
|
4105 ErrD3D(pDD->CreateSurface(v4, pOutSurf, NULL));
|
|
4106 }
|
|
4107
|
|
4108 //----- (004A12CD) --------------------------------------------------------
|
|
4109 void Render::CreateBackBuffer()
|
|
4110 {
|
|
4111 //Render *v1; // esi@1
|
|
4112 IDirectDraw *v2; // eax@3
|
|
4113 IDirectDrawSurface **ppBackBuffer; // esi@3
|
|
4114 struct _DDSURFACEDESC *v4; // edx@3
|
|
4115 // HRESULT v5; // eax@5
|
|
4116 int v6; // [sp-8h] [bp-8Ch]@3
|
|
4117 unsigned int v7; // [sp-4h] [bp-88h]@3
|
|
4118 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3
|
|
4119
|
|
4120 //v1 = this;
|
|
4121 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
|
|
4122 // pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
4123 {
|
|
4124 memset(&a2, 0, sizeof(a2));
|
|
4125 a2.dwSize = sizeof(a2);
|
|
4126
|
|
4127 v2 = (IDirectDraw *)this->pDirectDraw4;
|
|
4128 a2.dwFlags = 7;
|
|
4129 a2.ddsCaps.dwCaps = 2112;//0x840 = DDSCAPS_SYSTEMMEMORY = 0x800 | DDSCAPS_OFFSCREENPLAIN = 0x40
|
|
4130 a2.dwWidth = window->GetWidth();
|
|
4131 a2.dwHeight = window->GetHeight();
|
|
4132
|
|
4133 v7 = 0;
|
|
4134 v6 = 2387;
|
|
4135 ppBackBuffer = (IDirectDrawSurface **)&this->pBackBuffer4;
|
|
4136 v4 = (struct _DDSURFACEDESC *)&a2;
|
|
4137 }
|
|
4138 /*else
|
|
4139 {
|
|
4140 memset(&a2.lPitch, 0, 0x6Cu);
|
|
4141 v2 = (IDirectDraw *)v1->pDirectDraw2;
|
|
4142 a2.lPitch = 108;
|
|
4143 a2.dwBackBufferCount = 7;
|
|
4144 v7 = 0;
|
|
4145 a2.dwTextureStage = 2112;
|
|
4146 a2.dwAlphaBitDepth = 640;
|
|
4147 a2.dwMipMapCount = 480;
|
|
4148 v6 = 2374;
|
|
4149 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2;
|
|
4150 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2
|
|
4151 }*/
|
|
4152 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, NULL));
|
|
4153 }
|
|
4154
|
|
4155 //----- (004A139A) --------------------------------------------------------
|
|
4156 void Render::CreateDirectDrawPrimarySurface()
|
|
4157 {
|
|
4158 IDirectDrawSurface *pFrontBuffer; // eax@3
|
|
4159 DDSCAPS2 *v6; // edx@3
|
|
4160 IDirectDraw4 *v7; // eax@4
|
|
4161 int v9; // ST14_4@5
|
|
4162 IDirectDrawSurface *v10; // ST10_4@5
|
|
4163 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3
|
|
4164 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3
|
|
4165 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4
|
|
4166
|
|
4167 //v1 = this;
|
|
4168 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
|
|
4169 //pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
4170 {
|
|
4171 //v2 = 0;
|
|
4172 //this->field_4004C = 1;
|
|
4173 memset(&ddsd2, 0, sizeof(ddsd2));
|
|
4174 ddsd2.dwSize = sizeof(ddsd2);
|
|
4175
|
|
4176 ddsd2.dwBackBufferCount = 1;
|
|
4177 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
|
|
4178 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE;
|
|
4179 ErrD3D(this->pDirectDraw4->CreateSurface(&ddsd2, &pFrontBuffer4, NULL));
|
|
4180 pFrontBuffer = (IDirectDrawSurface *)this->pFrontBuffer4;
|
|
4181 ppBackBuffer = (IDirectDrawSurface **)&this->pBackBuffer4;
|
|
4182 }
|
|
4183 /*else
|
|
4184 {
|
|
4185 v2 = 0;
|
|
4186 this->field_4004C = 1;
|
|
4187
|
|
4188 DDSURFACEDESC ddsd;
|
|
4189 memset(&ddsd, 0, sizeof(DDSURFACEDESC));
|
|
4190
|
|
4191 ddsd.lpSurface = (LPVOID)1;
|
|
4192 ddsd.lPitch = 108;
|
|
4193 ddsd.dwBackBufferCount = 33;
|
|
4194 ddsd.ddsCaps.dwCaps = 8728;
|
|
4195 ErrD3D(pDirectDraw2->CreateSurface(&ddsd, (IDirectDrawSurface **)&pFrontBuffer2, NULL));
|
|
4196
|
|
4197 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2;
|
|
4198 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2;
|
|
4199 }*/
|
|
4200 __debugbreak(); // warning C4700: uninitialized local variable 'v6' used
|
|
4201 v9 = (int)v6;
|
|
4202 v10 = pFrontBuffer; // BUG
|
|
4203
|
|
4204 v17.dwCaps = 4;
|
|
4205 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer);
|
|
4206 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer);
|
|
4207 //v1->field_40030 = v2;
|
|
4208 //v1->field_18_locked_pitch = v2;
|
|
4209 }
|
|
4210
|
|
4211 //----- (004A14F4) --------------------------------------------------------
|
|
4212 void Render::CreateClipper(HWND a2)
|
|
4213 {
|
|
4214 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, NULL));
|
|
4215 ErrD3D(pDDrawClipper->SetHWnd(0, a2));
|
|
4216 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper));
|
|
4217 }
|
|
4218
|
|
4219 //----- (004A15D8) --------------------------------------------------------
|
|
4220 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut)
|
|
4221 {
|
|
4222 pFrontBuffer4->GetPixelFormat(pOut);
|
|
4223 }
|
|
4224
|
|
4225 //----- (004A1605) --------------------------------------------------------
|
|
4226 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow)
|
|
4227 {
|
|
4228 signed int v4; // eax@3
|
|
4229
|
|
4230 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
|
|
4231 //pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
4232 {
|
|
4233 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3
|
|
4234
|
|
4235 memset(&pDesc, 0, sizeof(pDesc));
|
|
4236 pDesc.dwSize = sizeof(pDesc);
|
|
4237
|
|
4238 LockSurface_DDraw4(this->pBackBuffer4, &pDesc, DDLOCK_WAIT);
|
|
4239 *pOutSurfacePtr = pDesc.lpSurface;
|
|
4240 v4 = pDesc.lPitch;
|
|
4241 }
|
|
4242 /*else
|
|
4243 {
|
|
4244 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3
|
|
4245 memset(&pDesc.lPitch, 0, 0x6Cu);
|
|
4246 pDesc.lPitch = 108;
|
|
4247 LockSurface_DDraw2(this->pBackBuffer2, &pDesc, 1);
|
|
4248 *pOutSurfacePtr = (void *)pDesc.lpSurface;
|
|
4249 v4 = pDesc.dwReserved;
|
|
4250 }*/
|
|
4251 *pOutPixelsPerRow = v4 >> 1;
|
|
4252 }
|
|
4253
|
|
4254 //----- (004A16E1) --------------------------------------------------------
|
|
4255 void Render::UnlockBackBuffer()
|
|
4256 {
|
|
4257 ErrD3D(pBackBuffer4->Unlock(NULL));
|
|
4258 }
|
|
4259
|
|
4260 //----- (004A172E) --------------------------------------------------------
|
|
4261 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow)
|
|
4262 {
|
|
4263 signed int v4; // eax@3
|
|
4264
|
|
4265 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
4266 {
|
|
4267 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3
|
|
4268
|
|
4269 memset(&pDesc, 0, sizeof(pDesc));
|
|
4270 pDesc.dwSize = sizeof(pDesc);
|
|
4271
|
|
4272 LockSurface_DDraw4(this->pFrontBuffer4, &pDesc, DDLOCK_WAIT);
|
|
4273 *pOutSurface = pDesc.lpSurface;
|
|
4274 v4 = pDesc.lPitch;
|
|
4275 }
|
|
4276 /*else
|
|
4277 {
|
|
4278 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3
|
|
4279 memset(&pDesc.lPitch, 0, 0x6Cu);
|
|
4280 pDesc.lPitch = 108;
|
|
4281 LockSurface_DDraw2(this->pFrontBuffer2, &pDesc, 1);
|
|
4282 *pOutSurface = (void *)pDesc.lpSurface;
|
|
4283 v4 = pDesc.dwReserved;
|
|
4284 }*/
|
|
4285 *pOutPixelsPerRow = v4 >> 1;
|
|
4286 }
|
|
4287
|
|
4288 //----- (004A17C7) --------------------------------------------------------
|
|
4289 void Render::UnlockFrontBuffer()
|
|
4290 {
|
|
4291 ErrD3D(pFrontBuffer4->Unlock(NULL));
|
|
4292 }
|
|
4293
|
|
4294 //----- (004A1814) --------------------------------------------------------
|
|
4295 void Render::RestoreFrontBuffer()
|
|
4296 {
|
|
4297 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST )
|
|
4298 pFrontBuffer4->Restore();
|
|
4299 }
|
|
4300
|
|
4301 //----- (004A184C) --------------------------------------------------------
|
|
4302 void Render::RestoreBackBuffer()
|
|
4303 {
|
|
4304 if ( pBackBuffer4->IsLost() == DDERR_SURFACELOST )
|
|
4305 pBackBuffer4->Restore();
|
|
4306 }
|
|
4307
|
|
4308 //----- (004A18F5) --------------------------------------------------------
|
|
4309 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags)
|
|
4310 {
|
|
4311 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr));
|
|
4312 }
|
|
4313
|
|
4314 //----- (004A194A) --------------------------------------------------------
|
|
4315 void Render::BltBackToFontFast(int a2, int a3, RECT *pSrcRect)
|
|
4316 {
|
|
4317 IDirectDrawSurface *pFront; // eax@3
|
|
4318 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3
|
|
4319
|
|
4320 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
4321 {
|
|
4322 pFront = (IDirectDrawSurface *)this->pFrontBuffer4;
|
|
4323 pBack = (IDirectDrawSurface *)this->pBackBuffer4;
|
|
4324 }
|
|
4325 /*else
|
|
4326 {
|
|
4327 pFront = (IDirectDrawSurface *)this->pFrontBuffer2;
|
|
4328 pBack = (IDirectDrawSurface *)this->pBackBuffer2;
|
|
4329 }*/
|
|
4330 pFront->BltFast(NULL, NULL, pBack, pSrcRect, DDBLTFAST_WAIT);
|
|
4331 }
|
|
4332
|
|
4333 //----- (004A1B22) --------------------------------------------------------
|
|
4334 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z)
|
|
4335 {
|
|
4336 unsigned int v7; // edx@6
|
|
4337
|
|
4338 if (uNumBillboardsToDraw >= 999 )
|
|
4339 return 0;
|
|
4340 if (!uNumBillboardsToDraw)
|
|
4341 {
|
|
4342 uNumBillboardsToDraw = 1;
|
|
4343 return 0;
|
|
4344 }
|
|
4345
|
|
4346 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch
|
|
4347 {
|
|
4348 v7 = left + (right - left) / 2;
|
|
4349 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order)
|
|
4350 right = v7;
|
|
4351 else
|
|
4352 left = v7 + 1;
|
|
4353 }
|
|
4354
|
|
4355 if (z > pRenderer->pBillboardRenderListD3D[v7].z_order )
|
|
4356 {
|
|
4357 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 )
|
|
4358 v7 = pRenderer->uNumBillboardsToDraw;
|
|
4359 else
|
|
4360 {
|
|
4361 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 )
|
|
4362 {
|
|
4363 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ )
|
|
4364 {
|
|
4365 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i],
|
|
4366 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - (i + 1)],
|
|
4367 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i]));
|
|
4368 }
|
|
4369 }
|
|
4370 ++v7;
|
|
4371 }
|
|
4372 uNumBillboardsToDraw++;
|
|
4373 return v7;
|
|
4374 }
|
|
4375 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order )
|
|
4376 {
|
|
4377 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 )
|
|
4378 {
|
|
4379 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ )
|
|
4380 {
|
|
4381 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i],
|
|
4382 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw -(i + 1)],
|
|
4383 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i]));
|
|
4384 }
|
|
4385 }
|
|
4386 uNumBillboardsToDraw++;
|
|
4387 return v7;
|
|
4388 }
|
|
4389 return v7;
|
|
4390 }
|
|
4391
|
|
4392 //----- (004A1E9D) --------------------------------------------------------
|
|
4393 unsigned int Render::GetBillboardDrawListSize()
|
|
4394 {
|
|
4395 return pRenderer->uNumBillboardsToDraw;
|
|
4396 }
|
|
4397
|
|
4398 //----- (004A1EA3) --------------------------------------------------------
|
|
4399 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID)
|
|
4400 {
|
|
4401 return pRenderer->pBillboardRenderListD3D[uBillboardID].sParentBillboardID;
|
|
4402 }
|
|
4403
|
|
4404 //----- (004A1EB6) --------------------------------------------------------
|
|
4405 void Render::BeginSceneD3D()
|
|
4406 {
|
|
4407 if (!uNumD3DSceneBegins++)
|
|
4408 {
|
|
4409 //if (pRenderD3D)
|
|
4410 {
|
|
4411 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0);
|
|
4412 pRenderer->uNumBillboardsToDraw = 0;
|
|
4413 pRenderD3D->pDevice->BeginScene();
|
|
4414
|
|
4415 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
|
|
4416 uFogColor = GetLevelFogColor();
|
|
4417 else
|
|
4418 uFogColor = 0;
|
|
4419
|
|
4420 if ( uFogColor & 0xFF000000 )
|
|
4421 {
|
|
4422 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1);
|
|
4423 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF);
|
|
4424 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0);
|
|
4425 bUsingSpecular = true;
|
|
4426 }
|
|
4427 else
|
|
4428 {
|
|
4429 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0);
|
|
4430 bUsingSpecular = 0;
|
|
4431 }
|
|
4432 }
|
|
4433 /*else
|
|
4434 {
|
|
4435 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch);
|
|
4436 if (pTargetSurface)
|
|
4437 field_18_locked_pitch = uTargetSurfacePitch;
|
|
4438 else
|
|
4439 --uNumD3DSceneBegins;
|
|
4440 }*/
|
|
4441 }
|
|
4442 }
|
|
4443
|
|
4444 //----- (004A1FE1) --------------------------------------------------------
|
|
4445 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene()
|
|
4446 {
|
|
4447 --uNumD3DSceneBegins;
|
|
4448 if (uNumD3DSceneBegins)
|
|
4449 return;
|
|
4450
|
|
4451 if (pRenderD3D)
|
|
4452 {
|
|
4453 pGame->draw_debug_outlines();
|
|
4454 DoRenderBillboards_D3D();
|
|
4455 pGame->pStru6Instance->RenderSpecialEffects();
|
|
4456 pRenderD3D->pDevice->EndScene();
|
|
4457 }
|
|
4458 else
|
|
4459 pGame->pStru6Instance->RenderSpecialEffects();
|
|
4460 }
|
|
4461
|
|
4462 //----- (004A2031) --------------------------------------------------------
|
|
4463 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6)
|
|
4464 {
|
|
4465 // __debugbreak(); // should not fire outside decal builder
|
|
4466 return ::GetActorTintColor(tint, a4, a2, a5, a6);
|
|
4467 }
|
|
4468
|
|
4469 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function
|
|
4470 {
|
|
4471 int v5; // ebx@1
|
|
4472 int v6; // edi@1
|
|
4473 int v8; // eax@7
|
|
4474 float v9; // eax@12
|
|
4475 float *v10; // esi@12
|
|
4476 float v11; // ecx@14
|
|
4477 double v12; // st7@14
|
|
4478 double v13; // st7@14
|
|
4479 double v14; // st7@14
|
|
4480 signed int v15; // eax@14
|
|
4481 int v16; // eax@15
|
|
4482 float v17; // ST48_4@15
|
|
4483 char v18; // zf@17
|
|
4484 int v19; // eax@18
|
|
4485 int v20; // eax@18
|
|
4486 int v21; // edx@20
|
|
4487 signed int v22; // ecx@20
|
|
4488 int v23; // eax@20
|
|
4489 const char *v24; // ST4C_4@20
|
|
4490 unsigned int v25; // ST50_4@20
|
|
4491 int v26; // ST54_4@20
|
|
4492 int v27; // eax@20
|
|
4493 _UNKNOWN *v28; // eax@21
|
|
4494 int v29; // ecx@23
|
|
4495 int v30; // eax@23
|
|
4496 int v31; // eax@23
|
|
4497 int v32; // eax@24
|
|
4498 int v33; // eax@25
|
|
4499 int v34; // eax@25
|
|
4500 int v35; // eax@25
|
|
4501 int v36; // eax@25
|
|
4502 signed int v37; // ecx@26
|
|
4503 int v38; // eax@26
|
|
4504 _UNKNOWN *v39; // eax@27
|
|
4505 int v40; // edx@28
|
|
4506 int v41; // eax@29
|
|
4507 int v42; // eax@29
|
|
4508 int v43; // eax@29
|
|
4509 int v44; // eax@29
|
|
4510 unsigned int v46; // eax@29
|
|
4511 int v47; // eax@30
|
|
4512 int v48; // eax@30
|
|
4513 int v49; // eax@30
|
|
4514 double v52; // st6@35
|
|
4515 const char *v55; // [sp+4Ch] [bp-1Ch]@20
|
|
4516 int v57; // [sp+5Ch] [bp-Ch]@3
|
|
4517 signed int v59; // [sp+60h] [bp-8h]@12
|
|
4518 int v61; // [sp+64h] [bp-4h]@4
|
|
4519 int i;
|
|
4520
|
|
4521 v6 = (int)this;
|
|
4522 v5 = 0;
|
|
4523 if (!this->uNumD3DSceneBegins)
|
|
4524 return;
|
|
4525
|
|
4526
|
|
4527
|
|
4528
|
|
4529 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
|
|
4530 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
|
|
4531 if (this->bUsingSpecular)
|
|
4532 {
|
|
4533 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
|
|
4534 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
|
|
4535 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
|
|
4536 }
|
|
4537
|
|
4538 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX;
|
|
4539 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY;
|
|
4540 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist);
|
|
4541 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097);
|
|
4542 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0);
|
|
4543 pVertices[0].specular = 0;
|
|
4544 pVertices[0].texcoord.x = array_50AC10[0].u;
|
|
4545 pVertices[0].texcoord.y = array_50AC10[0].v;
|
|
4546
|
|
4547 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX;
|
|
4548 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY;
|
|
4549 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist);
|
|
4550 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097);
|
|
4551 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0);
|
|
4552 pVertices[1].specular = 0;
|
|
4553 pVertices[1].texcoord.x = array_50AC10[3].u;
|
|
4554 pVertices[1].texcoord.y = array_50AC10[3].v;
|
|
4555
|
|
4556 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX;
|
|
4557 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY;
|
|
4558 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist);
|
|
4559 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097);
|
|
4560 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0);
|
|
4561 pVertices[2].specular = 0;
|
|
4562 pVertices[2].texcoord.x = array_50AC10[1].u;
|
|
4563 pVertices[2].texcoord.y = array_50AC10[1].v;
|
|
4564
|
|
4565 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3));
|
|
4566 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3));
|
|
4567
|
|
4568 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX;
|
|
4569 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY;
|
|
4570 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist);
|
|
4571 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097);
|
|
4572 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0);
|
|
4573 pVertices[5].specular = 0;
|
|
4574 pVertices[5].texcoord.x = array_50AC10[2].u;
|
|
4575 pVertices[5].texcoord.y = array_50AC10[2].v;
|
|
4576
|
|
4577
|
|
4578 this->pRenderD3D->pDevice->SetTexture(0, pTexture);
|
|
4579 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT);
|
|
4580
|
|
4581 }*/
|
|
4582
|
|
4583 //----- (004A26BC) --------------------------------------------------------
|
|
4584 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders)
|
|
4585 {
|
|
4586 unsigned int v8; // ebx@1
|
|
4587 int v11; // eax@5
|
|
4588 int v20; // eax@14
|
|
4589 unsigned int v45; // eax@28
|
|
4590
|
|
4591 v8 = 0;
|
|
4592 if (!this->uNumD3DSceneBegins)
|
|
4593 return;
|
|
4594 if ( uNumVertices < 3)
|
|
4595 return;
|
|
4596
|
|
4597 //v61 = pVertices;
|
|
4598
|
|
4599 /* v9 = pGame->pLightmapBuilder;
|
|
4600 v65 = v9;
|
|
4601 v10 = v9->std__vector_000004_size;*/
|
|
4602 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related)
|
|
4603 {
|
|
4604 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0);
|
|
4605 pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/);
|
|
4606 }
|
|
4607 else
|
|
4608 {
|
|
4609 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size ||
|
|
4610 byte_4D864C && pGame->uFlags & 2 )
|
|
4611 {
|
|
4612 if (clampAtTextureBorders)
|
|
4613 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
|
|
4614 else
|
|
4615 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
|
|
4616
|
|
4617 if (transparent || this->bUsingSpecular)
|
|
4618 {
|
|
4619 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
|
|
4620 if (transparent)
|
|
4621 {
|
|
4622 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
|
|
4623 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
|
4624 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO);
|
|
4625 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
|
|
4626 }
|
|
4627 else
|
|
4628 {
|
|
4629 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
|
|
4630 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
|
|
4631 }
|
|
4632 }
|
|
4633
|
|
4634 for (uint i = 0; i < uNumVertices; ++i)
|
|
4635 {
|
|
4636
|
|
4637 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX;
|
|
4638 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY;
|
|
4639 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist);
|
|
4640 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001);
|
|
4641 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0);
|
|
4642 if ( this->bUsingSpecular )
|
|
4643 {
|
|
4644 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x);
|
|
4645 }
|
|
4646 else
|
|
4647 {
|
|
4648 d3d_vertex_buffer[i].specular = 0;
|
|
4649 }
|
|
4650 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u;
|
|
4651 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
|
|
4652 }
|
|
4653
|
|
4654 this->pRenderD3D->pDevice->SetTexture(0, a5);
|
|
4655 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16);
|
|
4656 if (transparent)
|
|
4657 {
|
|
4658 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
4659 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
4660 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
4661 }
|
|
4662 }
|
|
4663 else
|
|
4664 {
|
|
4665 for (uint i = 0; i < uNumVertices; ++i)
|
|
4666 {
|
|
4667
|
|
4668 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX;
|
|
4669 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY;
|
|
4670 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist);
|
|
4671 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001);
|
|
4672 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0);
|
|
4673 if ( this->bUsingSpecular )
|
|
4674 {
|
|
4675 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, array_50AC10[i].vWorldViewPosition.x);
|
|
4676 }
|
|
4677 else
|
|
4678 {
|
|
4679 d3d_vertex_buffer[i].specular = 0;
|
|
4680 }
|
2531
|
4681 //__debugbreak(); // warning C4700: uninitialized local variable 'v20' used
|
|
4682 //d3d_vertex_buffer[i].specular = v20;
|
2496
|
4683 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u;
|
|
4684 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
|
|
4685 }
|
|
4686 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
4687 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
4688 if (pRenderer->bUsingSpecular)
|
|
4689 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
4690
|
|
4691 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));
|
|
4692 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
4693 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
4694 d3d_vertex_buffer,
|
|
4695 uNumVertices,
|
|
4696 16));
|
|
4697 //v63 = (const char *)v7->pRenderD3D->pDevice;
|
|
4698 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
4699 //(*(void (**)(void))(*(int *)v63 + 88))();
|
|
4700 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/);
|
|
4701 for (uint i = 0; i < uNumVertices; ++i)
|
|
4702 {
|
|
4703 d3d_vertex_buffer[i].diffuse = -1;
|
|
4704 }
|
|
4705 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5));
|
|
4706 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
4707 if ( !pRenderer->bUsingSpecular )
|
|
4708 {
|
|
4709 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
4710 }
|
|
4711 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
4712 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO));
|
|
4713 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR));
|
|
4714 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
4715 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
4716 d3d_vertex_buffer,
|
|
4717 uNumVertices,
|
|
4718 16));
|
|
4719 if ( pRenderer->bUsingSpecular )
|
|
4720 {
|
|
4721 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
4722 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));
|
|
4723 for (uint i = 0; i < uNumVertices; ++i)
|
|
4724 {
|
|
4725 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000;
|
|
4726 d3d_vertex_buffer[i].specular = 0;
|
|
4727 }
|
|
4728
|
|
4729 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem
|
|
4730 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA));
|
|
4731 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA));
|
|
4732 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
4733 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
4734 d3d_vertex_buffer,
|
|
4735 uNumVertices,
|
|
4736 16));
|
|
4737 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
4738 //v44 = pRenderer->pRenderD3D->pDevice;
|
|
4739 v45 = GetLevelFogColor();
|
|
4740 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF));
|
|
4741 v8 = 0;
|
|
4742 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
|
|
4743 }
|
|
4744 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
4745 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
4746 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8));
|
|
4747 }
|
|
4748 }
|
|
4749
|
|
4750 //if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES)
|
|
4751 if (pGame->pIndoorCameraD3D->debug_flags & ODM_RENDER_DRAW_TERRAIN_OUTLINES)
|
|
4752 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0);
|
|
4753 }
|
|
4754 // 4A26BC: could not find valid save-restore pair for esi
|
|
4755 // 4D864C: using guessed type char byte_4D864C;
|
|
4756
|
|
4757 //----- (004A2DA3) --------------------------------------------------------
|
|
4758 void Render::DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture)
|
|
4759 {
|
|
4760 int v7; // eax@7
|
|
4761
|
|
4762 if ( !this->uNumD3DSceneBegins )
|
|
4763 return;
|
|
4764 if ( uNumVertices >= 3 )
|
|
4765 {
|
|
4766 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
|
|
4767 if ( this->bUsingSpecular )
|
|
4768 {
|
|
4769 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
|
|
4770 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
|
|
4771 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
|
|
4772 }
|
|
4773 for ( uint i = 0; i < uNumVertices; ++i )
|
|
4774 {
|
|
4775 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX;
|
|
4776 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY;
|
|
4777 pVertices[i].pos.z = 0.99989998;
|
|
4778 pVertices[i].rhw = array_50AC10[i]._rhw;
|
|
4779
|
|
4780 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0);
|
|
4781 v7 = 0;
|
|
4782 if (this->bUsingSpecular)
|
|
4783 v7 = sub_47C3D7_get_fog_specular(0, 1, array_50AC10[i].vWorldViewPosition.x);
|
|
4784 pVertices[i].specular = v7;
|
|
4785 pVertices[i].texcoord.x = array_50AC10[i].u;
|
|
4786 pVertices[i].texcoord.y = array_50AC10[i].v;
|
|
4787 }
|
|
4788 pRenderD3D->pDevice->SetTexture(0, pTexture);
|
|
4789 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
4790 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT);
|
|
4791 }
|
|
4792 }
|
|
4793
|
|
4794 //----- (004A2ED5) --------------------------------------------------------
|
|
4795 void Render::DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture)
|
|
4796 {
|
|
4797 int v5; // eax@3
|
|
4798
|
|
4799 if ( this->uNumD3DSceneBegins )
|
|
4800 {
|
|
4801 if ( uNumVertices >= 3 )
|
|
4802 {
|
|
4803 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
4804 v5 = 31 - (pSkyPolygon->dimming_level & 0x1F);
|
|
4805 if ( v5 < pOutdoor->max_terrain_dimming_level )
|
|
4806 v5 = pOutdoor->max_terrain_dimming_level;
|
|
4807 for (uint i = 0; i < (unsigned int)uNumVertices; ++i)
|
|
4808 {
|
|
4809 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
|
|
4810 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
|
|
4811 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
|
|
4812 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw;
|
|
4813 d3d_vertex_buffer[i].diffuse = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8);
|
|
4814 d3d_vertex_buffer[i].specular = 0;
|
|
4815 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u;
|
|
4816 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v;
|
|
4817 }
|
|
4818 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture));
|
|
4819 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
4820 d3d_vertex_buffer, uNumVertices, 28));
|
|
4821 }
|
|
4822 }
|
|
4823 }
|
|
4824
|
|
4825 //----- (00479A53) --------------------------------------------------------
|
|
4826 void Render::DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID)
|
|
4827 {
|
|
4828 BLVFace *pFace; // esi@1
|
|
4829 double v5; // st7@3
|
|
4830 signed __int64 v6; // qax@3
|
|
4831 int v12; // edx@7
|
|
4832 int v13; // eax@7
|
|
4833 int v17; // edi@9
|
|
4834 double v18; // st7@9
|
|
4835 signed int v19; // ebx@9
|
|
4836 void *v20; // ecx@9
|
|
4837 int v21; // ebx@11
|
|
4838 int v22; // eax@14
|
|
4839 signed __int64 v23; // qtt@16
|
|
4840 double v28; // st7@20
|
|
4841 double v33; // st6@23
|
|
4842 const void *v35; // ecx@31
|
|
4843 int v36; // eax@31
|
|
4844 const void *v37; // edi@31
|
|
4845 signed __int64 v38; // qax@31
|
|
4846 int v39; // ecx@31
|
|
4847 int v40; // ebx@33
|
|
4848 int v41; // eax@36
|
|
4849 signed __int64 v42; // qtt@39
|
|
4850 int v43; // eax@39
|
|
4851 double v48; // st7@41
|
|
4852 double v51; // st7@46
|
|
4853 struct Polygon pSkyPolygon; // [sp+14h] [bp-160h]@6
|
|
4854 unsigned int v63; // [sp+120h] [bp-54h]@7
|
|
4855 unsigned int v65; // [sp+128h] [bp-4Ch]@1
|
|
4856 unsigned int v66; // [sp+12Ch] [bp-48h]@7
|
|
4857 __int64 v69; // [sp+13Ch] [bp-38h]@3
|
|
4858 int v70; // [sp+144h] [bp-30h]@3
|
|
4859 int X; // [sp+148h] [bp-2Ch]@9
|
|
4860 int v72; // [sp+14Ch] [bp-28h]@7
|
|
4861 float v73; // [sp+150h] [bp-24h]@16
|
|
4862 unsigned int v74; // [sp+154h] [bp-20h]@3
|
|
4863 unsigned int v74_; // [sp+154h] [bp-20h]@3
|
|
4864 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3
|
|
4865 float v76; // [sp+15Ch] [bp-18h]@9
|
|
4866 int v77; // [sp+160h] [bp-14h]@9
|
|
4867 int v78; // [sp+164h] [bp-10h]@7
|
|
4868 void *v79; // [sp+168h] [bp-Ch]@9
|
|
4869 float v80; // [sp+16Ch] [bp-8h]@3
|
|
4870 const void *v81; // [sp+170h] [bp-4h]@7
|
|
4871
|
|
4872 pFace = &pIndoor->pFaces[uFaceID];
|
|
4873 //for floor and wall(for example Selesta)-------------------
|
|
4874 if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor)
|
|
4875 {
|
|
4876 int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x;
|
|
4877 int v55 = (GetTickCount() / 32) + pGame->pIndoorCameraD3D->vPartyPos.y;
|
|
4878 for (uint i = 0; i < uNumVertices; ++i)
|
|
4879 {
|
|
4880 array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f;
|
|
4881 array_507D30[i].v = (v55 + array_507D30[i].v) * 0.25f;
|
|
4882 }
|
|
4883 pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0);
|
|
4884 return;
|
|
4885 }
|
|
4886 //---------------------------------------
|
|
4887 v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)//179
|
|
4888 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0)
|
|
4889 * 65536.0)
|
|
4890 + (double)pBLVRenderParams->uViewportCenterY);
|
|
4891 v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;//0
|
|
4892 v6 = (signed __int64)((double)pBLVRenderParams->uViewportCenterY//183
|
|
4893 - (double)pBLVRenderParams->fov_rad_fixpoint
|
|
4894 / ((cos(v5) * 16192.0 + 0.0000001)
|
|
4895 * 65535.0)
|
|
4896 * (sin(v5) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z));
|
|
4897
|
|
4898 stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0);
|
|
4899 pSkyPolygon.Create_48607B(&stru_8019C8);
|
|
4900 pSkyPolygon.uTileBitmapID = pFace->uBitmapID;
|
|
4901
|
|
4902 pSkyPolygon.pTexture = pBitmaps_LOD->GetTexture(pSkyPolygon.uTileBitmapID);
|
|
4903 if ( !pSkyPolygon.pTexture )
|
|
4904 return;
|
|
4905
|
|
4906 pSkyPolygon.dimming_level = 0;
|
|
4907 pSkyPolygon.uNumVertices = uNumVertices;
|
|
4908
|
|
4909 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
|
|
4910 pSkyPolygon.v_18.y = 0;
|
|
4911 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16);
|
|
4912
|
|
4913 memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices]));
|
|
4914 pSkyPolygon.field_24 = 0x2000000;
|
|
4915
|
|
4916 extern float _calc_fov(int viewport_width, int angle_degree);
|
|
4917 //v64 = (double)(signed int)(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX) * 0.5;
|
|
4918 //v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5);
|
|
4919 v72 = 65536.0f / _calc_fov(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX, 74);
|
|
4920 v12 = pSkyPolygon.pTexture->uWidthMinus1;
|
|
4921 v13 = pSkyPolygon.pTexture->uHeightMinus1;
|
|
4922 //v67 = 1.0 / (double)pSkyPolygon.pTexture->uTextureWidth;
|
|
4923 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13;
|
|
4924 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12;
|
|
4925 v78 = 0;
|
|
4926 //v81 = 0;
|
|
4927 float v68 = 1.0 / (double)pSkyPolygon.pTexture->uTextureHeight;
|
|
4928 if ( (signed int)pSkyPolygon.uNumVertices <= 0 )
|
|
4929 return;
|
|
4930
|
|
4931 int _507D30_idx = 0;
|
|
4932 for ( _507D30_idx; _507D30_idx < pSkyPolygon.uNumVertices; _507D30_idx++ )
|
|
4933 {
|
|
4934 //v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY));
|
|
4935 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY));
|
|
4936 v74 = v77 + pSkyPolygon.ptr_38->angle_from_north;
|
|
4937
|
|
4938 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY));
|
|
4939 v74_ = v77 + pSkyPolygon.ptr_38->angle_from_east;
|
|
4940
|
|
4941 v79 = (void *)(fixpoint_mul(pSkyPolygon.v_18.z, v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY)));
|
|
4942 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX);
|
|
4943 v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0;
|
|
4944 v19 = -pSkyPolygon.field_24;
|
|
4945 v77 = -pSkyPolygon.field_24;
|
|
4946 X = (int)((char *)v79 + pSkyPolygon.v_18.x);
|
|
4947 LODWORD(v76) = (signed __int64)v18;
|
|
4948 v20 = (void *)(v72 * (v70 - LODWORD(v76)));
|
|
4949 while ( 1 )
|
|
4950 {
|
|
4951 v79 = v20;
|
|
4952 if ( !X )
|
|
4953 goto LABEL_14;
|
|
4954 v21 = abs(v19 >> 14);
|
|
4955 if ( v21 <= abs(X) )//0x800 <= 0x28652
|
|
4956 break;
|
|
4957 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y )
|
|
4958 break;
|
|
4959 v19 = v77;
|
|
4960 v20 = v79;
|
|
4961 LABEL_14:
|
|
4962 v79 = (void *)fixpoint_mul(pSkyPolygon.v_18.z, (int)v20);
|
|
4963 v22 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v20);
|
|
4964 --LODWORD(v76);
|
|
4965 v20 = (char *)v20 + v72;
|
|
4966 X = v22 + pSkyPolygon.v_18.x;
|
|
4967 v78 = 1;
|
|
4968 }
|
|
4969 if ( !v78 )
|
|
4970 {
|
|
4971 LODWORD(v23) = v77 << 16;
|
|
4972 HIDWORD(v23) = v77 >> 16;//v23 = 0xfffffe0000000000
|
|
4973 v79 = (void *)(v23 / X);//X = FFFF9014(-28652)
|
|
4974 v77 = v17;
|
|
4975 signed __int64 s = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v17);// s = 0xFFFFFFFF FFFF3EE6
|
|
4976 LODWORD(v80) = v66 + ((signed int)fixpoint_mul(SLODWORD(s), v23 / X) >> 4);
|
|
4977 array_507D30[_507D30_idx].u = ((double)SLODWORD(v80) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth);
|
|
4978
|
|
4979 signed __int64 s2 = v74_ + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v17);
|
|
4980 LODWORD(v80) = v63 + ((signed int)fixpoint_mul(SLODWORD(s2), v23 / X) >> 4);
|
|
4981 array_507D30[_507D30_idx].v = ((double)SLODWORD(v80) * 0.000015259022) * v68;
|
|
4982
|
|
4983 v77 = fixpoint_mul(SLODWORD(s), v23 / X);
|
|
4984 LODWORD(v73) = fixpoint_mul(SLODWORD(s2), v23 / X);
|
|
4985 array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79;
|
|
4986
|
|
4987 //if ( (int)v81 >= pSkyPolygon.uNumVertices )
|
|
4988 //{
|
|
4989 // pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon,
|
|
4990 // pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
|
|
4991 // return;
|
|
4992 //}
|
|
4993 continue;
|
|
4994 }
|
|
4995 break;
|
|
4996 }
|
|
4997 if ( _507D30_idx >= pSkyPolygon.uNumVertices )
|
|
4998 {
|
|
4999 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon,
|
|
5000 pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
|
|
5001 return;
|
|
5002 }
|
|
5003 LODWORD(v73) = 0;
|
|
5004 v80 = v76;
|
|
5005 if ( (signed int)pSkyPolygon.uNumVertices > 0 )
|
|
5006 {
|
|
5007 v28 = (double)SLODWORD(v76);
|
|
5008 LODWORD(v76) = (int)(char *)array_50AC10 + 28;
|
|
5009 uint i = 0;
|
|
5010 for ( v78 = pSkyPolygon.uNumVertices; v78; --v78 )
|
|
5011 {
|
|
5012 ++LODWORD(v73);
|
|
5013 memcpy(&array_50AC10[i], &array_507D30[i], 0x30u);
|
|
5014 LODWORD(v76) += 48;
|
|
5015 if ( v28 < array_507D30[i].vWorldViewProjY | v28 == array_507D30[i].vWorldViewProjY
|
|
5016 || v28 >= array_507D30[i + 1].vWorldViewProjY )
|
|
5017 {
|
|
5018 if ( v28 >= array_507D30[i].vWorldViewProjY || v28 <= array_507D30[i + 1].vWorldViewProjY )
|
|
5019 {
|
|
5020 i++;
|
|
5021 continue;
|
|
5022 }
|
|
5023 v33 = (array_507D30[i + 1].vWorldViewProjX - array_507D30[i].vWorldViewProjX) * v28 / (array_507D30[i + 1].vWorldViewProjY - array_507D30[i].vWorldViewProjY)
|
|
5024 + array_507D30[i + 1].vWorldViewProjX;
|
|
5025 }
|
|
5026 else
|
|
5027 {
|
|
5028 v33 = (array_507D30[i].vWorldViewProjX - array_507D30[i + 1].vWorldViewProjX) * v28 / (array_507D30[i].vWorldViewProjY - array_507D30[i + 1].vWorldViewProjY)
|
|
5029 + array_507D30[i].vWorldViewProjX;
|
|
5030 }
|
|
5031 array_50AC10[i + 1].vWorldViewProjX = v33;
|
|
5032 ++LODWORD(v73);
|
|
5033 *(unsigned int *)LODWORD(v76) = v28;
|
|
5034 LODWORD(v76) += 48;
|
|
5035 i++;
|
|
5036 }
|
|
5037 }
|
|
5038 if ( SLODWORD(v73) <= 0 )
|
|
5039 goto LABEL_40;
|
|
5040 //v34 = (char *)&array_50AC10[0].vWorldViewProjY;
|
|
5041 uint j = 0;
|
|
5042 v65 = v77 >> 14;
|
|
5043 //HIDWORD(v69) = LODWORD(v73);
|
|
5044 for ( int t = (int)LODWORD(v73); t > 1; t-- )
|
|
5045 {
|
|
5046 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjY));
|
|
5047
|
|
5048 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_west_east;
|
|
5049 //v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v35);
|
|
5050 v36 = (int)(fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, (int)v35) + pSkyPolygon.ptr_38->angle_from_north);
|
|
5051
|
|
5052 v81 = v35;
|
|
5053 v74 = v36;
|
|
5054 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_north_south;
|
|
5055 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, (int)v35);
|
|
5056 v78 = (int)v35;
|
|
5057 v75 = (RenderVertexSoft *)((char *)v81 + pSkyPolygon.ptr_38->angle_from_east);
|
|
5058 //v81 = (const void *)pSkyPolygon.v_18.z;
|
|
5059 v78 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v35);
|
|
5060 v37 = (const void *)(v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjX));
|
|
5061 v38 = (signed __int64)(array_50AC10[j].vWorldViewProjY - 1.0);
|
|
5062 v81 = 0;
|
|
5063 LODWORD(v76) = v38;
|
|
5064 v39 = v72 * (v70 - v38);
|
|
5065 while ( 1 )
|
|
5066 {
|
|
5067 v78 = v39;
|
|
5068 if ( !X )
|
|
5069 goto LABEL_36;
|
|
5070 v40 = abs(X);
|
|
5071 if ( abs((signed __int64)v65) <= v40 )
|
|
5072 break;
|
|
5073 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y )
|
|
5074 break;
|
|
5075 v39 = v78;
|
|
5076 LABEL_36:
|
|
5077 v78 = pSkyPolygon.v_18.z;
|
|
5078 v41 = fixpoint_mul(pSkyPolygon.v_18.z, v39);
|
|
5079 --LODWORD(v76);
|
|
5080 v39 += v72;
|
|
5081 X = v41 + pSkyPolygon.v_18.x;
|
|
5082 v81 = (const void *)1;
|
|
5083 }
|
|
5084 if ( v81 )
|
|
5085 {
|
|
5086 v79 = (void *)pSkyPolygon.v_18.z;
|
|
5087 v78 = 2 * LODWORD(v76);
|
|
5088 v81 = (const void *)fixpoint_mul(pSkyPolygon.v_18.z, (((double)v70 - ((double)(2 * LODWORD(v76)) - array_50AC10[j].vWorldViewProjY))
|
|
5089 * (double)v72));
|
|
5090 X = (int)((char *)v81 + pSkyPolygon.v_18.x);
|
|
5091 }
|
|
5092 LODWORD(v42) = v77 << 16;
|
|
5093 HIDWORD(v42) = v77 >> 16;
|
|
5094 v79 = (void *)(v42 / X);
|
|
5095 v81 = v37;
|
|
5096
|
|
5097 //v78 = pSkyPolygon.ptr_38->angle_from_west;
|
|
5098 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37);
|
|
5099 v43 = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37);
|
|
5100 v74 = (unsigned int)v37;
|
|
5101 LODWORD(v76) = v43;
|
|
5102
|
|
5103 //v78 = pSkyPolygon.ptr_38->angle_from_south;
|
|
5104 v75 = (RenderVertexSoft *)((char *)v75 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, (int)v37));
|
|
5105 //v74 = fixpoint_mul(v43, v42 / X);
|
|
5106 v81 = (const void *)fixpoint_mul((int)v75, v42 / X);
|
|
5107
|
|
5108 //v34 += 48;
|
|
5109 //v78 = v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4);
|
|
5110 //v44 = HIDWORD(v69)-- == 1;
|
|
5111 //v45 = (double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022;
|
|
5112 //v78 = v63 + ((signed int)fixpoint_mul((int)v75, v42 / X) >> 4);
|
|
5113 array_50AC10[j].u = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth);
|
|
5114 array_50AC10[j].v = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * v68;
|
|
5115 //v46 = (double)(signed int)v79;
|
|
5116 array_50AC10[j].vWorldViewPosition.x = 0.000015258789 * (double)(signed int)v79;
|
|
5117 array_50AC10[j]._rhw = 65536.0 / (double)(signed int)v79;
|
|
5118 ++j;
|
|
5119 }
|
|
5120 //while ( !v44 );
|
|
5121 LABEL_40:
|
|
5122 uint i = 0;
|
|
5123 if ( SLODWORD(v73) > 0 )
|
|
5124 {
|
|
5125 v48 = (double)SLODWORD(v80);
|
|
5126 for ( HIDWORD(v69) = LODWORD(v73); HIDWORD(v69); --HIDWORD(v69) )
|
|
5127 {
|
|
5128 if ( v48 >= array_50AC10[i].vWorldViewProjY )
|
|
5129 {
|
|
5130 ++i;
|
|
5131 memcpy(&array_507D30[i], &array_50AC10[i], 0x30u);
|
|
5132 }
|
|
5133 }
|
|
5134 }
|
|
5135 pSkyPolygon.uNumVertices = i;
|
|
5136 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
|
|
5137 int pNumVertices = 0;
|
|
5138 if ( SLODWORD(v73) > 0 )
|
|
5139 {
|
|
5140 v51 = (double)SLODWORD(v80);
|
|
5141 for ( v80 = v73; v80 != 0.0; --LODWORD(v80) )
|
|
5142 {
|
|
5143 if ( v51 <= array_50AC10[pNumVertices].vWorldViewProjY )
|
|
5144 {
|
|
5145 ++pNumVertices;
|
|
5146 memcpy(&array_507D30[pNumVertices], &array_50AC10[pNumVertices], 0x30u);
|
|
5147 }
|
|
5148 }
|
|
5149 }
|
|
5150 pRenderer->DrawIndoorSkyPolygon(pNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
|
|
5151 }
|
|
5152
|
|
5153 //----- (004A2FC0) --------------------------------------------------------
|
|
5154 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8)
|
|
5155 {
|
|
5156 if (!uNumD3DSceneBegins || uNumVertices < 3)
|
|
5157 return;
|
|
5158
|
|
5159 int sCorrectedColor = uColor;
|
2532
|
5160
|
2496
|
5161 if (pGame->pLightmapBuilder->std__vector_000004_size)
|
|
5162 sCorrectedColor = -1;
|
|
5163 pGame->AlterGamma_BLV(pFace, &sCorrectedColor);
|
|
5164
|
|
5165 if (pFace->uAttributes & FACE_OUTLINED)
|
|
5166 {
|
|
5167 if (GetTickCount() % 300 >= 150)
|
|
5168 uColor = sCorrectedColor = 0xFF20FF20;
|
2532
|
5169 else
|
|
5170 uColor = sCorrectedColor = 0xFF109010;
|
2496
|
5171 }
|
|
5172
|
|
5173 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related)
|
|
5174 {
|
|
5175 __debugbreak();
|
|
5176 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
|
|
5177 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
5178 for (uint i = 0; i < uNumVertices; ++i)
|
|
5179 {
|
|
5180 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
|
|
5181 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
|
|
5182 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
|
|
5183 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x;
|
|
5184 d3d_vertex_buffer[i].diffuse = sCorrectedColor;
|
|
5185 d3d_vertex_buffer[i].specular = 0;
|
|
5186 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth;
|
|
5187 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight;
|
|
5188 }
|
|
5189
|
|
5190 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
5191 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
2532
|
5192 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
2496
|
5193 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
2532
|
5194 d3d_vertex_buffer, uNumVertices, 28));
|
2496
|
5195 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/);
|
|
5196 }
|
|
5197 else
|
|
5198 {
|
2532
|
5199 if (!pGame->pLightmapBuilder->std__vector_000004_size || byte_4D864C && pGame->uFlags & 2)
|
2496
|
5200 {
|
|
5201 for (uint i = 0; i < uNumVertices; ++i)
|
|
5202 {
|
|
5203 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
|
|
5204 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
|
|
5205 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
|
|
5206 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x;
|
|
5207 d3d_vertex_buffer[i].diffuse = sCorrectedColor;
|
|
5208 d3d_vertex_buffer[i].specular = 0;
|
|
5209 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth;
|
|
5210 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight;
|
|
5211 }
|
|
5212
|
|
5213 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
5214 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex));
|
|
5215 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
5216 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
2532
|
5217 d3d_vertex_buffer, uNumVertices, 28));
|
2496
|
5218 }
|
|
5219 else
|
|
5220 {
|
|
5221 for (uint i = 0; i < uNumVertices; ++i)
|
|
5222 {
|
|
5223 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
|
|
5224 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
|
|
5225 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
|
|
5226 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x;
|
|
5227 d3d_vertex_buffer[i].diffuse = uColor;
|
|
5228 d3d_vertex_buffer[i].specular = 0;
|
|
5229 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth;
|
|
5230 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight;
|
|
5231 }
|
2532
|
5232 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
5233 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
5234 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
|
5235 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
5236 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
5237 d3d_vertex_buffer, uNumVertices, 28));
|
|
5238
|
|
5239 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
5240 pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/);
|
|
5241
|
|
5242 for (uint i = 0; i < uNumVertices; ++i)
|
|
5243 d3d_vertex_buffer[i].diffuse = sCorrectedColor;
|
|
5244
|
|
5245 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex));
|
|
5246 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
|
|
5247 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
5248 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
5249 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO));
|
|
5250 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR));
|
|
5251 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
5252 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
5253 d3d_vertex_buffer, uNumVertices, 28));
|
|
5254 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
5255 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
5256 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
2496
|
5257 }
|
|
5258 }
|
|
5259 }
|
|
5260 // 4D864C: using guessed type char byte_4D864C;
|
|
5261
|
|
5262 //----- (004A43B1) --------------------------------------------------------
|
|
5263 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level)
|
|
5264 {
|
|
5265 unsigned int v7; // eax@2
|
|
5266 signed int v11; // eax@9
|
|
5267 signed int v12; // eax@9
|
|
5268 double v15; // st5@12
|
|
5269 double v16; // st4@12
|
|
5270 double v17; // st3@12
|
|
5271 double v18; // st2@12
|
|
5272 int v19; // ecx@14
|
|
5273 double v20; // st3@14
|
|
5274 int v21; // ecx@16
|
|
5275 double v22; // st3@16
|
|
5276 float v27; // [sp+24h] [bp-Ch]@5
|
|
5277 int v28; // [sp+28h] [bp-8h]@2
|
|
5278 float v29; // [sp+2Ch] [bp-4h]@5
|
|
5279 float v31; // [sp+3Ch] [bp+Ch]@5
|
|
5280 float a1; // [sp+40h] [bp+10h]@5
|
|
5281
|
|
5282 if ( this->uNumD3DSceneBegins )
|
|
5283 {
|
|
5284 //v4 = pSoftBillboard;
|
|
5285 //v5 = (double)pSoftBillboard->zbuffer_depth;
|
|
5286 //pSoftBillboarda = pSoftBillboard->zbuffer_depth;
|
|
5287 //v6 = pSoftBillboard->zbuffer_depth;
|
|
5288 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth);
|
|
5289 //v8 = dimming_level;
|
|
5290 //v9 = v7;
|
|
5291 v28 = dimming_level & 0xFF000000;
|
|
5292 if ( dimming_level & 0xFF000000 )
|
|
5293 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Opaque_3;
|
|
5294 else
|
|
5295 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Transparent;
|
|
5296 //v10 = a3;
|
|
5297 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44;
|
|
5298 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue;
|
|
5299 pBillboardRenderListD3D[v7].sParentBillboardID = pSoftBillboard->sParentBillboardID;
|
|
5300 //v25 = pSoftBillboard->uScreenSpaceX;
|
|
5301 //v24 = pSoftBillboard->uScreenSpaceY;
|
|
5302 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat);
|
|
5303 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat);
|
|
5304 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX);
|
|
5305 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY);
|
|
5306 if ( pSoftBillboard->uFlags & 4 )
|
|
5307 v31 = v31 * -1.0;
|
|
5308 if ( pSoftBillboard->sTintColor && this->bTinting )
|
|
5309 {
|
|
5310 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0);
|
|
5311 v12 = BlendColors(pSoftBillboard->sTintColor, v11);
|
|
5312 if ( v28 )
|
|
5313 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1);
|
|
5314 }
|
|
5315 else
|
|
5316 {
|
|
5317 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0);
|
|
5318 }
|
|
5319 //v13 = (double)v25;
|
|
5320 pBillboardRenderListD3D[v7].pQuads[0].specular = 0;
|
|
5321 pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12;
|
|
5322 pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1;
|
|
5323 //v14 = (double)v24;
|
|
5324 //v32 = v14;
|
|
5325 pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29;
|
|
5326 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894);
|
|
5327 pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15;
|
|
5328 v16 = 1.0 / pSoftBillboard->zbuffer_depth;
|
|
5329 pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth;
|
|
5330 pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0;
|
|
5331 pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0;
|
|
5332 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX);
|
|
5333 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight);
|
|
5334 if ( pSoftBillboard->uFlags & 4 )
|
|
5335 v17 = v17 * -1.0;
|
|
5336 pBillboardRenderListD3D[v7].pQuads[1].specular = 0;
|
|
5337 pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12;
|
|
5338 pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1;
|
|
5339 pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29;
|
|
5340 pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15;
|
|
5341 pBillboardRenderListD3D[v7].pQuads[1].rhw = v16;
|
|
5342 pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0;
|
|
5343 pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0;
|
|
5344 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight;
|
|
5345 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth);
|
|
5346 if ( pSoftBillboard->uFlags & 4 )
|
|
5347 v20 = v20 * -1.0;
|
|
5348 pBillboardRenderListD3D[v7].pQuads[2].specular = 0;
|
|
5349 pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12;
|
|
5350 pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX;
|
|
5351 pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29;
|
|
5352 pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15;
|
|
5353 pBillboardRenderListD3D[v7].pQuads[2].rhw = v16;
|
|
5354 pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0;
|
|
5355 pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0;
|
|
5356 v21 = pSprite->uBufferHeight - pSprite->uAreaY;
|
|
5357 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth);
|
|
5358 if ( pSoftBillboard->uFlags & 4 )
|
|
5359 v22 = v22 * -1.0;
|
|
5360 pBillboardRenderListD3D[v7].pQuads[3].specular = 0;
|
|
5361 pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12;
|
|
5362 pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX;
|
|
5363 pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29;
|
|
5364 pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15;
|
|
5365 pBillboardRenderListD3D[v7].pQuads[3].rhw = v16;
|
|
5366 pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0;
|
|
5367 pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0;
|
|
5368 //v23 = pSprite->pTexture;
|
|
5369 pBillboardRenderListD3D[v7].uNumVertices = 4;
|
|
5370 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth;
|
|
5371 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture;
|
|
5372 }
|
|
5373 }
|
|
5374
|
|
5375 //----- (004A354F) --------------------------------------------------------
|
|
5376 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle)
|
|
5377 {
|
|
5378 unsigned int v8; // esi@3
|
|
5379 float v11; // ST28_4@3
|
|
5380 float v16; // ST2C_4@3
|
|
5381 float v17; // ST30_4@3
|
|
5382 signed int v18; // ST18_4@3
|
|
5383 signed int v19; // ST14_4@3
|
|
5384 signed int v20; // ST10_4@3
|
|
5385 signed int v21; // eax@3
|
|
5386 double v22; // st6@3
|
|
5387 float v23; // ST2C_4@3
|
|
5388 float v24; // ST30_4@3
|
|
5389 signed int v25; // ST10_4@3
|
|
5390 signed int v26; // ST14_4@3
|
|
5391 signed int v27; // ST18_4@3
|
|
5392 signed int v28; // eax@3
|
|
5393 double v29; // st6@3
|
|
5394 float v30; // ecx@3
|
|
5395 float v31; // ST2C_4@3
|
|
5396 float v32; // ST30_4@3
|
|
5397 signed int v33; // ST10_4@3
|
|
5398 signed int v34; // ST14_4@3
|
|
5399 signed int v35; // ST18_4@3
|
|
5400 signed int v36; // eax@3
|
|
5401 float v37; // ecx@3
|
|
5402 double v38; // st6@3
|
|
5403 float v39; // ST2C_4@3
|
|
5404 float v40; // ST30_4@3
|
|
5405 signed int v41; // ST10_4@3
|
|
5406 signed int v42; // ST14_4@3
|
|
5407 signed int v43; // ST18_4@3
|
|
5408 signed int v44; // eax@3
|
|
5409 double v45; // st6@3
|
|
5410 float v46; // eax@3
|
|
5411
|
|
5412 if ( this->uNumD3DSceneBegins )
|
|
5413 {
|
|
5414 if (a2->zbuffer_depth)
|
|
5415 {
|
|
5416 //v5 = (double)a2->zbuffer_depth;
|
|
5417 //v6 = v5;
|
|
5418 //v7 = v5;
|
|
5419 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth);
|
|
5420 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1;
|
|
5421 pBillboardRenderListD3D[v8].field_90 = a2->field_44;
|
|
5422 pBillboardRenderListD3D[v8].sZValue = a2->sZValue;
|
|
5423 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID;
|
|
5424 //v9 = a2->uScreenSpaceX;
|
|
5425 //v10 = a2->uScreenSpaceY;
|
|
5426 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat);
|
|
5427 //v12 = (double) a2->uScreenSpaceX;
|
|
5428 //v13 = v12;
|
|
5429 //v14 = (double)(a2->uScreenSpaceY - 12);
|
|
5430 //v15 = v14;
|
|
5431 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX;
|
|
5432 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12);
|
|
5433 v18 = stru_5C6E00->Cos(angle);
|
|
5434 v19 = stru_5C6E00->Sin(angle);
|
|
5435 v20 = stru_5C6E00->Sin(angle);
|
|
5436 v21 = stru_5C6E00->Cos(angle);
|
|
5437 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022
|
|
5438 + (double)(v18 >> 16))
|
|
5439 * v16
|
|
5440 - ((double)(unsigned __int16)v19 * 0.000015259022
|
|
5441 + (double)(v19 >> 16))
|
|
5442 * v17)
|
|
5443 * v11 + (double) a2->uScreenSpaceX;
|
|
5444 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17
|
|
5445 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16
|
|
5446 - 12.0)
|
|
5447 * v11
|
|
5448 + (double)a2->uScreenSpaceY;
|
|
5449 pBillboardRenderListD3D[v8].pQuads[0].specular = 0;
|
|
5450 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse;
|
|
5451 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22;
|
|
5452 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894);
|
|
5453 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth;
|
|
5454 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0;
|
|
5455 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0;
|
|
5456 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX;
|
|
5457 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12);
|
|
5458 v25 = stru_5C6E00->Cos(angle);
|
|
5459 v26 = stru_5C6E00->Sin(angle);
|
|
5460 v27 = stru_5C6E00->Sin(angle);
|
|
5461 v28 = stru_5C6E00->Cos(angle);
|
|
5462 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022
|
|
5463 + (double)(v25 >> 16))
|
|
5464 * v31
|
|
5465 - ((double)(unsigned __int16)v26 * 0.000015259022
|
|
5466 + (double)(v26 >> 16))
|
|
5467 * v32)
|
|
5468 * v11 + (double) a2->uScreenSpaceX;
|
|
5469 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32
|
|
5470 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31
|
|
5471 - 12.0)
|
|
5472 * v11
|
|
5473 + (double)a2->uScreenSpaceY;
|
|
5474 pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z;
|
|
5475 v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw;
|
|
5476 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29;
|
|
5477 pBillboardRenderListD3D[v8].pQuads[1].specular = 0;
|
|
5478 pBillboardRenderListD3D[v8].pQuads[1].rhw = v30;
|
|
5479 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse;
|
|
5480 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0;
|
|
5481 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0;
|
|
5482 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX;
|
|
5483 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12);
|
|
5484 v33 = stru_5C6E00->Cos(angle);
|
|
5485 v34 = stru_5C6E00->Sin(angle);
|
|
5486 v35 = stru_5C6E00->Sin(angle);
|
|
5487 v36 = stru_5C6E00->Cos(angle);
|
|
5488 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022
|
|
5489 + (double)(v33 >> 16))
|
|
5490 * v23
|
|
5491 - ((double)(unsigned __int16)v34 * 0.000015259022
|
|
5492 + (double)(v34 >> 16))
|
|
5493 * v24)
|
|
5494 * v11 + (double) a2->uScreenSpaceX;
|
|
5495 v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z;
|
|
5496 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24
|
|
5497 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23
|
|
5498 - 12.0)
|
|
5499 * v11
|
|
5500 + (double)a2->uScreenSpaceY;
|
|
5501 pBillboardRenderListD3D[v8].pQuads[2].specular = 0;
|
|
5502 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37;
|
|
5503 pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw;
|
|
5504 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse;
|
|
5505 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38;
|
|
5506 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0;
|
|
5507 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0;
|
|
5508 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX;
|
|
5509 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12);
|
|
5510 v41 = stru_5C6E00->Cos(angle);
|
|
5511 v42 = stru_5C6E00->Sin(angle);
|
|
5512 v43 = stru_5C6E00->Sin(angle);
|
|
5513 v44 = stru_5C6E00->Cos(angle);
|
|
5514 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022
|
|
5515 + (double)(v41 >> 16))
|
|
5516 * v39
|
|
5517 - ((double)(unsigned __int16)v42 * 0.000015259022
|
|
5518 + (double)(v42 >> 16))
|
|
5519 * v40)
|
|
5520 * v11 + (double) a2->uScreenSpaceX;
|
|
5521 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40
|
|
5522 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39
|
|
5523 - 12.0)
|
|
5524 * v11
|
|
5525 + (double)a2->uScreenSpaceY;
|
|
5526 v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z;
|
|
5527 pBillboardRenderListD3D[v8].pQuads[3].specular = 0;
|
|
5528 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46;
|
|
5529 pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw;
|
|
5530 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse;
|
|
5531 pBillboardRenderListD3D[v8].pTexture = a3;
|
|
5532 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth;
|
|
5533 pBillboardRenderListD3D[v8].uNumVertices = 4;
|
|
5534 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45;
|
|
5535 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0;
|
|
5536 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0;
|
|
5537 }
|
|
5538 }
|
|
5539 }
|
|
5540
|
|
5541 //----- (004A3AD9) --------------------------------------------------------
|
|
5542 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle)
|
|
5543 {
|
|
5544 double v5; // st7@2
|
|
5545 float v6; // ST28_4@2
|
|
5546 float v7; // ST00_4@2
|
|
5547 unsigned int v8; // esi@2
|
|
5548 //int v9; // eax@2
|
|
5549 //int v10; // ebx@2
|
|
5550 float v11; // ST34_4@2
|
|
5551 double v12; // st7@2
|
|
5552 float v13; // ST2C_4@2
|
|
5553 double v14; // st6@2
|
|
5554 float v15; // ST24_4@2
|
|
5555 float v16; // ST38_4@2
|
|
5556 float v17; // ST3C_4@2
|
|
5557 signed int v18; // ST1C_4@2
|
|
5558 int v19; // ST30_4@2
|
|
5559 signed int v20; // ST20_4@2
|
|
5560 signed int v21; // ST18_4@2
|
|
5561 signed int v22; // eax@2
|
|
5562 double v23; // st6@2
|
|
5563 float v24; // ST20_4@2
|
|
5564 float v25; // ST1C_4@2
|
|
5565 float v26; // ST38_4@2
|
|
5566 float v27; // ST3C_4@2
|
|
5567 signed int v28; // ST18_4@2
|
|
5568 signed int v29; // ST14_4@2
|
|
5569 signed int v30; // ST10_4@2
|
|
5570 signed int v31; // eax@2
|
|
5571 double v32; // st6@2
|
|
5572 float v33; // ST38_4@2
|
|
5573 float v34; // ST3C_4@2
|
|
5574 signed int v35; // ST10_4@2
|
|
5575 signed int v36; // ST14_4@2
|
|
5576 signed int v37; // ST18_4@2
|
|
5577 signed int v38; // eax@2
|
|
5578 double v39; // st6@2
|
|
5579 float v40; // ST38_4@2
|
|
5580 float v41; // ST3C_4@2
|
|
5581 signed int v42; // ST10_4@2
|
|
5582 signed int v43; // ST14_4@2
|
|
5583 signed int v44; // ST18_4@2
|
|
5584 signed int v45; // eax@2
|
|
5585 double v46; // st6@2
|
|
5586
|
|
5587 if ( this->uNumD3DSceneBegins )
|
|
5588 {
|
|
5589 v5 = (double)a2->zbuffer_depth;
|
|
5590 v6 = v5;
|
|
5591 v7 = v5;
|
|
5592 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7));
|
|
5593 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1;
|
|
5594 pBillboardRenderListD3D[v8].field_90 = a2->field_44;
|
|
5595 pBillboardRenderListD3D[v8].sZValue = a2->sZValue;
|
|
5596 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID;
|
|
5597
|
|
5598 //v9 = a2->uScreenSpaceX;
|
|
5599 //v10 = a2->uScreenSpaceY;
|
|
5600 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat);
|
|
5601 v12 = (double)a2->uScreenSpaceX;
|
|
5602 v13 = (double)a2->uScreenSpaceX;
|
|
5603 v14 = (double)(a2->uScreenSpaceY - 12);
|
|
5604 v15 = v14;
|
|
5605 v16 = (double)(a2->uScreenSpaceX - 12) - v12;
|
|
5606 v17 = (double)(a2->uScreenSpaceY - 25) - v14;
|
|
5607 v18 = stru_5C6E00->Cos(angle);
|
|
5608 v19 = angle - stru_5C6E00->uIntegerHalfPi;
|
|
5609 v20 = stru_5C6E00->Sin(angle);
|
|
5610 v21 = stru_5C6E00->Sin(angle);
|
|
5611 v22 = stru_5C6E00->Cos(angle);
|
|
5612 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022
|
|
5613 + (double)(v18 >> 16)) * v16
|
|
5614 - ((double)(unsigned __int16)v20 * 0.000015259022
|
|
5615 + (double)(v20 >> 16)) * v17)
|
|
5616 * v11 + v13;
|
|
5617 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17
|
|
5618 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16
|
|
5619 - 12.0)
|
|
5620 * v11
|
|
5621 + (double)a2->uScreenSpaceY;
|
|
5622 pBillboardRenderListD3D[v8].pQuads[0].specular = 0;
|
|
5623 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse;
|
|
5624 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23;
|
|
5625 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pODMRenderParams->shading_dist_mist);
|
|
5626 pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24;
|
|
5627 v25 = 1.0 / v6;
|
|
5628 pBillboardRenderListD3D[v8].pQuads[0].rhw = v25;
|
|
5629 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0;
|
|
5630 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0;
|
|
5631
|
|
5632 v26 = (double)(a2->uScreenSpaceX - 12) - v13;
|
|
5633 v27 = (double)a2->uScreenSpaceY - v15;
|
|
5634 v28 = stru_5C6E00->Cos(angle);
|
|
5635 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi);
|
|
5636 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi);
|
|
5637 v31 = stru_5C6E00->Cos(angle);
|
|
5638 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022
|
|
5639 + (double)(v28 >> 16)) * v26
|
|
5640 - ((double)(unsigned __int16)v29 * 0.000015259022
|
|
5641 + (double)(v29 >> 16)) * v27)
|
|
5642 * v11 + v13;
|
|
5643 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27
|
|
5644 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26
|
|
5645 - 12.0)
|
|
5646 * v11
|
|
5647 + (double)a2->uScreenSpaceY;
|
|
5648 pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24;
|
|
5649 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32;
|
|
5650 pBillboardRenderListD3D[v8].pQuads[1].specular = 0;
|
|
5651 pBillboardRenderListD3D[v8].pQuads[1].rhw = v25;
|
|
5652 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse;
|
|
5653 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0;
|
|
5654 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0;
|
|
5655
|
|
5656 v33 = (double)(a2->uScreenSpaceX + 12) - v13;
|
|
5657 v34 = (double)a2->uScreenSpaceY - v15;
|
|
5658 v35 = stru_5C6E00->Cos(angle);
|
|
5659 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi);
|
|
5660 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi);
|
|
5661 v38 = stru_5C6E00->Cos(angle);
|
|
5662 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022
|
|
5663 + (double)(v35 >> 16)) * v33
|
|
5664 - ((double)(unsigned __int16)v36 * 0.000015259022
|
|
5665 + (double)(v36 >> 16)) * v34)
|
|
5666 * v11 + v13;
|
|
5667 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34
|
|
5668 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33
|
|
5669 - 12.0)
|
|
5670 * v11
|
|
5671 + (double)a2->uScreenSpaceY;
|
|
5672 pBillboardRenderListD3D[v8].pQuads[2].specular = 0;
|
|
5673 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24;
|
|
5674 pBillboardRenderListD3D[v8].pQuads[2].rhw = v25;
|
|
5675 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse;
|
|
5676 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39;
|
|
5677 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0;
|
|
5678 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0;
|
|
5679
|
|
5680 v40 = (double)(a2->uScreenSpaceX + 12) - v13;
|
|
5681 v41 = (double)(a2->uScreenSpaceY - 25) - v15;
|
|
5682 v42 = stru_5C6E00->Cos(angle);
|
|
5683 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi);
|
|
5684 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi);
|
|
5685 v45 = stru_5C6E00->Cos(angle);
|
|
5686 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022
|
|
5687 + (double)(v42 >> 16)) * v40
|
|
5688 - ((double)(unsigned __int16)v43 * 0.000015259022
|
|
5689 + (double)(v43 >> 16)) * v41)
|
|
5690 * v11 + v13;
|
|
5691 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41
|
|
5692 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40
|
|
5693 - 12.0)
|
|
5694 * v11
|
|
5695 + (double)a2->uScreenSpaceY;
|
|
5696 pBillboardRenderListD3D[v8].pQuads[3].specular = 0;
|
|
5697 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24;
|
|
5698 pBillboardRenderListD3D[v8].pQuads[3].rhw = v25;
|
|
5699 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse;
|
|
5700 pBillboardRenderListD3D[v8].pTexture = a3;
|
|
5701 pBillboardRenderListD3D[v8].z_order = v6;
|
|
5702 pBillboardRenderListD3D[v8].uNumVertices = 4;
|
|
5703 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46;
|
|
5704 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0;
|
|
5705 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0;
|
|
5706 }
|
|
5707 }
|
|
5708
|
|
5709 //----- (004A4023) --------------------------------------------------------
|
|
5710 void Render::TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int dimming_level, RenderBillboard *pBillboard)
|
|
5711 {
|
|
5712 unsigned int v8; // esi@2
|
|
5713 double v14; // st6@14
|
|
5714 double v15; // st5@14
|
|
5715 float v29; // [sp+28h] [bp-8h]@5
|
|
5716 float v30; // [sp+2Ch] [bp-4h]@5
|
|
5717
|
|
5718 if (!uNumD3DSceneBegins)
|
|
5719 return;
|
|
5720
|
|
5721 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth);
|
|
5722
|
|
5723 v30 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_x_scaler_packedfloat);
|
|
5724 v29 = (a2->_screenspace_y_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_y_scaler_packedfloat);
|
|
5725
|
|
5726 unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard);
|
|
5727 if (a2->sTintColor & 0x00FFFFFF && bTinting)
|
|
5728 {
|
|
5729 diffuse = BlendColors(a2->sTintColor, diffuse);
|
|
5730 if (a2->sTintColor & 0xFF000000)
|
|
5731 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1);
|
|
5732 }
|
|
5733
|
|
5734 unsigned int specular = 0;
|
|
5735 if (bUsingSpecular)
|
|
5736 specular = sub_47C3D7_get_fog_specular(0, 0, a2->zbuffer_depth);
|
|
5737
|
|
5738 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX);
|
|
5739 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY);
|
|
5740 if (a2->uFlags & 4)
|
|
5741 v14 *= -1.0;
|
|
5742 pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse;
|
|
5743 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30;
|
|
5744 pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29;
|
|
5745 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist);
|
|
5746 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth;
|
|
5747 pBillboardRenderListD3D[v8].pQuads[0].specular = specular;
|
|
5748 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0;
|
|
5749 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0;
|
|
5750
|
|
5751 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX);
|
|
5752 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY);
|
|
5753 if ( a2->uFlags & 4 )
|
|
5754 v14 = v14 * -1.0;
|
|
5755 pBillboardRenderListD3D[v8].pQuads[1].specular = specular;
|
|
5756 pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse;
|
|
5757 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30;
|
|
5758 pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29;
|
|
5759 pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist);
|
|
5760 pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth;
|
|
5761 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0;
|
|
5762 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0;
|
|
5763
|
|
5764 v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth);
|
|
5765 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY);
|
|
5766 if ( a2->uFlags & 4 )
|
|
5767 v14 *= -1.0;
|
|
5768 pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse;
|
|
5769 pBillboardRenderListD3D[v8].pQuads[2].specular = specular;
|
|
5770 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30;
|
|
5771 pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29;
|
|
5772 pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist);
|
|
5773 pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth;
|
|
5774 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0;
|
|
5775 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0;
|
|
5776
|
|
5777 v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth);
|
|
5778 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY);
|
|
5779 if ( a2->uFlags & 4 )
|
|
5780 v14 *= -1.0;
|
|
5781 pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse;
|
|
5782 pBillboardRenderListD3D[v8].pQuads[3].specular = specular;
|
|
5783 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30;
|
|
5784 pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29;
|
|
5785 pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist);
|
|
5786 pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth;
|
|
5787 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0;
|
|
5788 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0;
|
|
5789
|
|
5790 pBillboardRenderListD3D[v8].uNumVertices = 4;
|
|
5791 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture;
|
|
5792 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth;
|
|
5793 pBillboardRenderListD3D[v8].field_90 = a2->field_44;
|
|
5794 pBillboardRenderListD3D[v8].sZValue = a2->sZValue;
|
|
5795 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID;
|
|
5796
|
|
5797 if (a2->sTintColor & 0xFF000000)
|
|
5798 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_3;
|
|
5799 else
|
|
5800 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Transparent;
|
|
5801 }
|
|
5802
|
|
5803
|
|
5804 //----- (004A49D0) --------------------------------------------------------
|
|
5805 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9)
|
|
5806 {
|
|
5807 int absXDifference; // eax@1
|
|
5808 int absYDifference; // eax@1
|
|
5809 unsigned int smallerabsdiff; // ebx@1
|
|
5810 unsigned int largerabsdiff;
|
|
5811 double v16; // st7@7
|
|
5812 double v17; // st7@7
|
|
5813 double v18; // st6@7
|
|
5814 double v20; // st4@8
|
|
5815 double v21; // st4@10
|
|
5816 double v22; // st4@10
|
|
5817 double v23; // st4@10
|
|
5818 double v25; // st4@11
|
|
5819 double v26; // st4@13
|
|
5820 double v28; // st4@13
|
|
5821 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7
|
|
5822 int xDifference; // [sp+88h] [bp-Ch]@1
|
|
5823 signed int v32; // [sp+8Ch] [bp-8h]@1
|
|
5824 int yDifference; // [sp+90h] [bp-4h]@1
|
|
5825
|
|
5826 xDifference = bankersRounding(dstX - srcX);
|
|
5827 yDifference = bankersRounding(dstY - srcY);
|
|
5828 absYDifference = abs(yDifference);
|
|
5829 absXDifference = abs(xDifference);
|
|
5830 smallerabsdiff = min(absXDifference, absYDifference);
|
|
5831 largerabsdiff = max(absXDifference, absYDifference);
|
|
5832 v32 = (11 * smallerabsdiff >> 5) + largerabsdiff;
|
|
5833 v16 = 1.0 / (double)v32;
|
|
5834 v17 = (double)yDifference * v16 * a4;
|
|
5835 v18 = (double)xDifference * v16 * a4;
|
|
5836 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
|
|
5837 {
|
|
5838 v20 = a3 * 1000.0 / (double)pODMRenderParams->shading_dist_mist;
|
|
5839 v25 = a7 * 1000.0 / (double)pODMRenderParams->shading_dist_mist;
|
|
5840 }
|
|
5841 else
|
|
5842 {
|
|
5843 v20 = a3 * 0.061758894;
|
|
5844 v25 = a7 * 0.061758894;
|
|
5845 }
|
|
5846 v21 = 1.0 / a3;
|
|
5847 v22 = (double)yDifference * v16 * a8;
|
|
5848 v23 = (double)xDifference * v16 * a8;
|
|
5849 v26 = 1.0 - 1.0 / v25;
|
|
5850 v28 = 1.0 / a7;
|
|
5851 v29[0].pos.x = srcX + v17;
|
|
5852 v29[0].pos.y = srcY - v18;
|
|
5853 v29[0].pos.z = 1.0 - 1.0 / v20;
|
|
5854 v29[0].rhw = v21;
|
|
5855 v29[0].diffuse = -1;
|
|
5856 v29[0].specular = 0;
|
|
5857 v29[0].texcoord.x = 1.0;
|
|
5858 v29[0].texcoord.y = 0.0;
|
|
5859
|
|
5860 v29[1].pos.x = v22 + dstX;
|
|
5861 v29[1].pos.y = dstY - v23;
|
|
5862 v29[1].pos.z = v26;
|
|
5863 v29[1].rhw = v28;
|
|
5864 v29[1].diffuse = -16711936;
|
|
5865 v29[1].specular = 0;
|
|
5866 v29[1].texcoord.x = 1.0;
|
|
5867 v29[1].texcoord.y = 1.0;
|
|
5868
|
|
5869 v29[2].pos.x = dstX - v22;
|
|
5870 v29[2].pos.y = v23 + dstY;
|
|
5871 v29[2].pos.z = v26;
|
|
5872 v29[2].rhw = v28;
|
|
5873 v29[2].diffuse = -1;
|
|
5874 v29[2].specular = 0;
|
|
5875 v29[2].texcoord.x = 0.0;
|
|
5876 v29[2].texcoord.y = 1.0;
|
|
5877
|
|
5878 v29[3].pos.x = srcX - v17;
|
|
5879 v29[3].pos.y = v18 + srcY;
|
|
5880 v29[3].pos.z = v29[0].pos.z;
|
|
5881 v29[3].rhw = v21;
|
|
5882 v29[3].diffuse = -1;
|
|
5883 v29[3].specular = 0;
|
|
5884 v29[3].texcoord.x = 0.0;
|
|
5885 v29[3].texcoord.y = 0.0;
|
|
5886 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
5887 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
5888 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
|
|
5889 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
5890 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
5891 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
5892 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a9));
|
|
5893 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
5894 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v29, 4, 24));
|
|
5895 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
5896 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
5897 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
5898 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
5899 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
5900 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
|
|
5901 }
|
|
5902
|
|
5903 //----- (004A4CC9) --------------------------------------------------------
|
|
5904 void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse)
|
|
5905 {
|
|
5906 unsigned int v5; // eax@7
|
|
5907 double v10; // st6@9
|
|
5908 double v11; // st6@10
|
|
5909 int v12; // ebx@13
|
|
5910
|
|
5911 if (a1->uNumVertices < 3)
|
|
5912 return;
|
|
5913
|
|
5914 float depth = 1000000.0;
|
|
5915 for (uint i = 0; i < (unsigned int)a1->uNumVertices; ++i)
|
|
5916 {
|
|
5917 if (a1->field_104[i].z < depth)
|
|
5918 depth = a1->field_104[i * 4].z;
|
|
5919 }
|
|
5920
|
|
5921 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth);
|
|
5922 pBillboardRenderListD3D[v5].field_90 = 0;
|
|
5923 pBillboardRenderListD3D[v5].sParentBillboardID = -1;
|
|
5924 pBillboardRenderListD3D[v5].opacity = RenderBillboardD3D::Opaque_2;
|
|
5925 pBillboardRenderListD3D[v5].pTexture = 0;
|
|
5926 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices;
|
|
5927 pBillboardRenderListD3D[v5].z_order = depth;
|
|
5928
|
|
5929 for (uint i = 0; i < (unsigned int)a1->uNumVertices; ++i)
|
|
5930 {
|
|
5931 pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x;
|
|
5932 pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y;
|
|
5933
|
|
5934 v10 = a1->field_104[i].z;
|
|
5935 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
5936 v11 = v10 * 0.061758894;
|
|
5937 else
|
|
5938 v11 = v10 * 1000.0 / (double)pODMRenderParams->shading_dist_mist;
|
|
5939 pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11;
|
|
5940 pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z;
|
|
5941
|
|
5942 if (diffuse & 0xFF000000)
|
|
5943 v12 = a1->field_104[i].diffuse;
|
|
5944 else
|
|
5945 v12 = diffuse;
|
|
5946 pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12;
|
|
5947 pBillboardRenderListD3D[v5].pQuads[i].specular = 0;
|
|
5948
|
|
5949 pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0;
|
|
5950 pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0;
|
|
5951 }
|
|
5952 }
|
|
5953
|
|
5954 //----- (004A4DE1) --------------------------------------------------------
|
|
5955 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture)
|
|
5956 {
|
|
5957 unsigned __int16 *v13; // ecx@19
|
|
5958 unsigned __int16 *v14; // eax@19
|
|
5959 DWORD v15; // edx@20
|
|
5960 stru350 Dst; // [sp+Ch] [bp-F8h]@12
|
|
5961
|
|
5962 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps);
|
2524
|
5963 if (!pHWLTexture)
|
|
5964 return false;
|
|
5965
|
2496
|
5966 bMipMaps = !strncmp(pName, "HDWTR", 5);
|
|
5967 if ( !pRenderD3D->CreateTexture(pHWLTexture->uWidth, pHWLTexture->uHeight, pOutSurface, pOutTexture, true,
|
|
5968 bMipMaps, uMinDeviceTextureDim) )
|
|
5969 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0);
|
|
5970 if (bMipMaps)
|
|
5971 {
|
|
5972 Dst._450DDE();
|
|
5973 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC);
|
|
5974
|
|
5975 IDirectDrawSurface4 *pNextSurf = *pOutSurface;
|
|
5976 while ( 1 )
|
|
5977 {
|
|
5978 DDSCAPS2 v19;
|
|
5979 memset(&v19, 0, sizeof(DDSCAPS2));
|
|
5980 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP;
|
|
5981
|
|
5982 DDSURFACEDESC2 desc;
|
|
5983 memset(&desc, 0, sizeof(DDSURFACEDESC2));
|
|
5984 desc.dwSize = sizeof(DDSURFACEDESC2);
|
|
5985
|
|
5986 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) )
|
|
5987 {
|
|
5988 // linear scaling
|
|
5989 for (int s = 0; s < desc.dwHeight; ++s)
|
|
5990 for (int t = 0; t < desc.dwWidth; ++t)
|
|
5991 {
|
|
5992 unsigned int resampled_x = t * pHWLTexture->uWidth / desc.dwWidth,
|
|
5993 resampled_y = s * pHWLTexture->uHeight / desc.dwHeight;
|
|
5994 unsigned short sample = pHWLTexture->pPixels[resampled_y * pHWLTexture->uWidth + resampled_x];
|
|
5995
|
|
5996 ((unsigned short *)desc.lpSurface)[s * (desc.lPitch >> 1) + t] = sample;
|
|
5997 }
|
|
5998
|
|
5999
|
|
6000 //bicubic sampling
|
|
6001 //Dst.sub_451007_scale_image_bicubic(pHWLTexture->pPixels, pHWLTexture->uWidth, pHWLTexture->uHeight, pHWLTexture->uWidth,
|
|
6002 // (unsigned short *)desc.lpSurface, desc.dwWidth, desc.dwHeight, desc.lPitch >> 1, 0, 0);
|
|
6003
|
|
6004 ErrD3D(pNextSurf->Unlock(NULL));
|
|
6005 //bMipMaps = 0x4D86ACu;
|
|
6006 }
|
|
6007 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf)))
|
|
6008 break;
|
|
6009 }
|
|
6010 //v20 = -1;
|
|
6011 //nullsub_1();
|
|
6012 }
|
|
6013 else
|
|
6014 {
|
|
6015 DDSCAPS2 v19;
|
|
6016 memset(&v19, 0, sizeof(DDSCAPS2));
|
|
6017 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP;
|
|
6018
|
|
6019 DDSURFACEDESC2 desc;
|
|
6020 memset(&desc, 0, sizeof(DDSURFACEDESC2));
|
|
6021 desc.dwSize = sizeof(DDSURFACEDESC2);
|
|
6022
|
|
6023 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) )
|
|
6024 {
|
|
6025 bMipMaps = 0;
|
|
6026 v13 = pHWLTexture->pPixels;
|
|
6027 v14 = (unsigned __int16 *)desc.lpSurface;
|
|
6028 for(uint bMipMaps = 0; bMipMaps < desc.dwHeight; bMipMaps++)
|
|
6029 {
|
|
6030 for (v15 = 0; v15 < desc.dwWidth; v15++)
|
|
6031 {
|
|
6032 *v14 = *v13;
|
|
6033 ++v14;
|
|
6034 ++v13;
|
|
6035 }
|
|
6036 v14 += (desc.lPitch >> 1) - desc.dwWidth;
|
|
6037 }
|
|
6038 ErrD3D((*pOutSurface)->Unlock(NULL));
|
|
6039 }
|
|
6040 }
|
|
6041 delete [] pHWLTexture->pPixels;
|
|
6042 delete pHWLTexture;
|
|
6043 return true;
|
2524
|
6044
|
2496
|
6045 }
|
|
6046
|
|
6047 //----- (004A5048) --------------------------------------------------------
|
|
6048 bool Render::MoveSpriteToDevice( Sprite *pSprite )
|
|
6049 {
|
|
6050 HWLTexture *sprite_texture; // eax@1
|
|
6051 unsigned __int16 *v9; // edx@5
|
|
6052 LPVOID v10; // eax@5
|
|
6053 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4
|
|
6054
|
|
6055 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID);
|
|
6056 if ( sprite_texture )
|
|
6057 {
|
|
6058 pSprite->uAreaX = sprite_texture->uAreaX;
|
|
6059 pSprite->uAreaY = sprite_texture->uAreaY;
|
|
6060 pSprite->uBufferWidth = sprite_texture->uBufferWidth;
|
|
6061 pSprite->uBufferHeight = sprite_texture->uBufferHeight;
|
|
6062 pSprite->uAreaWidth = sprite_texture->uAreaWidth;
|
|
6063 pSprite->uAreaHeight = sprite_texture->uAreaHeigth;
|
|
6064 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim))
|
|
6065 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0);
|
|
6066 memset(&Dst, 0, sizeof(DDSURFACEDESC2));
|
|
6067 Dst.dwSize = 124;
|
|
6068 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) )
|
|
6069 {
|
|
6070 v9 = sprite_texture->pPixels;
|
|
6071 v10 = Dst.lpSurface;
|
|
6072 for (uint i=0; i<sprite_texture->uHeight; ++i)
|
|
6073 {
|
|
6074 for (uint j=0; j<sprite_texture->uWidth/2; ++j)
|
|
6075 {
|
|
6076 *(int *)v10 = *(int *)v9;
|
|
6077 v9 += 2;
|
|
6078 v10 = (char *)v10 + 4;
|
|
6079 }
|
|
6080 v10 = (char *)v10 + Dst.lPitch-sprite_texture->uWidth*2;
|
|
6081 }
|
|
6082 ErrD3D(pSprite->pTextureSurface->Unlock(NULL));
|
|
6083 }
|
|
6084 delete [] sprite_texture->pPixels;
|
|
6085 delete sprite_texture;
|
|
6086 return true;
|
|
6087 }
|
|
6088 return false;
|
|
6089 }
|
|
6090
|
|
6091 //----- (004A51CB) --------------------------------------------------------
|
|
6092 void Render::BeginScene()
|
|
6093 {
|
|
6094 //Render *v1; // esi@1
|
|
6095 unsigned int v2; // eax@1
|
|
6096 /*int v3; // eax@5
|
|
6097 unsigned __int16 **v4; // edi@6
|
|
6098 char *v5; // ebx@7*/
|
|
6099 // DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4
|
|
6100
|
|
6101 //v1 = this;
|
|
6102 v2 = this->uNumSceneBegins;
|
|
6103 this->uNumSceneBegins = v2 + 1;
|
|
6104 if ( !v2 )
|
|
6105 {
|
|
6106 if ( this->pRenderD3D )
|
|
6107 {
|
|
6108 /*if ( this->bColorKeySupported )
|
|
6109 {
|
|
6110 memset(&Dst, 0, 0x7Cu);
|
|
6111 Dst.dwSize = 124;
|
|
6112 if ( LockSurface_DDraw4(this->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) )
|
|
6113 {
|
|
6114 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface;
|
|
6115 this->uTargetSurfacePitch = Dst.lPitch >> 1;
|
|
6116 this->field_18_locked_pitch = Dst.lPitch >> 1;
|
|
6117 }
|
|
6118 --this->uNumSceneBegins;
|
|
6119 }*/
|
|
6120 }
|
|
6121 else
|
|
6122 {
|
|
6123 if ( !this->pTargetSurface )
|
|
6124 {
|
|
6125 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch);
|
|
6126 /*if ( this->pTargetSurface )
|
|
6127 {
|
|
6128 this->field_18_locked_pitch = this->uTargetSurfacePitch;
|
|
6129 }*/
|
|
6130 --this->uNumSceneBegins;
|
|
6131 }
|
|
6132 }
|
|
6133 RestoreFrontBuffer();
|
|
6134 }
|
|
6135 }
|
|
6136
|
|
6137 //----- (004A527D) --------------------------------------------------------
|
|
6138 void Render::EndScene()
|
|
6139 {
|
|
6140 if ( this->uNumSceneBegins )
|
|
6141 {
|
|
6142 this->uNumSceneBegins--;
|
|
6143 if ( !this->uNumSceneBegins )
|
|
6144 {
|
|
6145 if ( this->pRenderD3D )
|
|
6146 {
|
|
6147 /*if ( this->bColorKeySupported )
|
|
6148 {
|
|
6149 this->pTargetSurface = 0;
|
|
6150 this->uTargetSurfacePitch = 0;
|
|
6151 this->field_18_locked_pitch = 0;
|
|
6152 ErrD3D(this->pColorKeySurface4->Unlock(NULL));
|
|
6153 }*/
|
|
6154 }
|
|
6155 else
|
|
6156 {
|
|
6157 this->pTargetSurface = 0;
|
|
6158 this->uTargetSurfacePitch = 0;
|
|
6159 //this->field_18_locked_pitch = 0;
|
|
6160 UnlockBackBuffer();
|
|
6161 }
|
|
6162 }
|
|
6163 }
|
|
6164 }
|
|
6165
|
|
6166 //----- (004A52F1) --------------------------------------------------------
|
|
6167 void Render::ScreenFade(unsigned int color, float t)
|
|
6168 {
|
|
6169 unsigned int v3; // esi@1
|
|
6170 unsigned int v7; // eax@6
|
|
6171 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6
|
|
6172 int v40; // [sp+9Ch] [bp-4h]@6
|
|
6173
|
|
6174 v3 = 0;
|
|
6175
|
|
6176 //{
|
|
6177 if (t > 1.0f)
|
|
6178 t = 1.0f;
|
|
6179 else if (t < 0.0f)
|
|
6180 t = 0.0f;
|
|
6181
|
|
6182 v40 = (char)floorf(t * 255.0f + 0.5f);
|
|
6183
|
|
6184 v7 = color | (v40 << 24);
|
|
6185
|
|
6186 v36[0].specular = 0;
|
|
6187 v36[0].pos.x = pViewport->uViewportTL_X;
|
|
6188 v36[0].pos.y = (double)pViewport->uViewportTL_Y;
|
|
6189 v36[0].pos.z = 0.0;
|
|
6190 v36[0].diffuse = v7;
|
|
6191 v36[0].rhw = 1.0;
|
|
6192 v36[0].texcoord.x = 0.0;
|
|
6193 v36[0].texcoord.y = 0.0;
|
|
6194
|
|
6195 v36[1].specular = 0;
|
|
6196 v36[1].pos.x = pViewport->uViewportTL_X;
|
|
6197 v36[1].pos.y = (double)(pViewport->uViewportBR_Y + 1);
|
|
6198 v36[1].pos.z = 0.0;
|
|
6199 v36[1].diffuse = v7;
|
|
6200 v36[1].rhw = 1.0;
|
|
6201 v36[1].texcoord.x = 0.0;
|
|
6202 v36[1].texcoord.y = 0.0;
|
|
6203
|
|
6204 v36[2].specular = 0;
|
|
6205 v36[2].pos.x = (double)pViewport->uViewportBR_X;
|
|
6206 v36[2].pos.y = (double)(pViewport->uViewportBR_Y + 1);
|
|
6207 v36[2].pos.z = 0.0;
|
|
6208 v36[2].diffuse = v7;
|
|
6209 v36[2].rhw = 1.0;
|
|
6210 v36[2].texcoord.x = 0.0;
|
|
6211 v36[2].texcoord.y = 0.0;
|
|
6212
|
|
6213 v36[3].specular = 0;
|
|
6214 v36[3].pos.x = (double)pViewport->uViewportBR_X;
|
|
6215 v36[3].pos.y = (double)pViewport->uViewportTL_Y;
|
|
6216 v36[3].pos.z = 0.0;
|
|
6217 v36[3].diffuse = v7;
|
|
6218 v36[3].rhw = 1.0;
|
|
6219 v36[3].texcoord.x = 0.0;
|
|
6220 v36[3].texcoord.y = 0.0;
|
|
6221
|
|
6222 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));
|
|
6223 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
6224 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
6225 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
6226 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA));
|
|
6227 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA));
|
|
6228 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
6229 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS));
|
|
6230 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
6231 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v36, 4, 28));
|
|
6232 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
6233 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
6234 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
6235 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
6236 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
6237 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS));
|
|
6238 /*}
|
|
6239 else
|
|
6240 {
|
|
6241 v40 = (1.0 - a3) * 65536.0;
|
|
6242 v39 = v40 + 6.7553994e15;
|
|
6243 LODWORD(a3) = LODWORD(v39);
|
|
6244 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1;
|
|
6245 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1;
|
|
6246 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X;
|
|
6247 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch];
|
|
6248 v37 = 2 * v13;
|
|
6249 LODWORD(v40) = (int)v14;
|
|
6250
|
|
6251 int __i = 0;
|
|
6252 v15 = dword_F1B430.data();
|
|
6253 do
|
|
6254 {
|
|
6255 v16 = v3;
|
|
6256 v3 += LODWORD(a3);
|
|
6257 dword_F1B430[__i++] = v16 >> 16;
|
|
6258 }
|
|
6259 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen );
|
|
6260 while (__i < 32);
|
|
6261
|
|
6262 if ( pRenderer->uTargetGBits == 6 )
|
|
6263 {
|
|
6264 v17 = sr_42690D_colors_cvt(this_);
|
|
6265 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F);
|
|
6266 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);
|
|
6267 v19 = v40;
|
|
6268 v20 = off_4EFDB0;
|
|
6269 v21 = HIDWORD(v39);
|
|
6270 do
|
|
6271 {
|
|
6272 v22 = v38;
|
|
6273 v31 = v21;
|
|
6274 do
|
|
6275 {
|
|
6276 v23 = (*(int *)((char *)v20
|
|
6277 + ((((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;
|
|
6278 result = this_
|
|
6279 + (*((int *)v20
|
|
6280 + (((unsigned __int8)(*((char *)v20
|
|
6281 + ((((unsigned __int16)(*(short *)((char *)v20
|
|
6282 + ((*(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);
|
|
6283 *(unsigned int *)LODWORD(v19) = result;
|
|
6284 LODWORD(v19) += 4;
|
|
6285 --v22;
|
|
6286 }
|
|
6287 while ( v22 );
|
|
6288 LODWORD(v19) += v37;
|
|
6289 v21 = v31 - 1;
|
|
6290 }
|
|
6291 while ( v31 != 1 );
|
|
6292 }
|
|
6293 else
|
|
6294 {
|
|
6295 v24 = sr_4268E3_smthn_to_a1r5g5b5(this_);
|
|
6296 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F);
|
|
6297 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3))
|
|
6298 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16);
|
|
6299 v26 = v40;
|
|
6300 v27 = (char *)off_4EFDB0;
|
|
6301 v28 = HIDWORD(v39);
|
|
6302 do
|
|
6303 {
|
|
6304 v29 = v38;
|
|
6305 v32 = v28;
|
|
6306 do
|
|
6307 {
|
|
6308 v30 = 32
|
|
6309 * *(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;
|
|
6310 result = this_
|
|
6311 + (*(int *)&v27[4
|
|
6312 * (((unsigned __int8)(32
|
|
6313 * 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);
|
|
6314 *(unsigned int *)LODWORD(v26) = result;
|
|
6315 LODWORD(v26) += 4;
|
|
6316 --v29;
|
|
6317 }
|
|
6318 while ( v29 );
|
|
6319 LODWORD(v26) += v37;
|
|
6320 v28 = v32 - 1;
|
|
6321 }
|
|
6322 while ( v32 != 1 );
|
|
6323 }
|
|
6324 }*/
|
|
6325 }
|
|
6326
|
|
6327 //----- (004A5B81) --------------------------------------------------------
|
2524
|
6328 void Render::SetUIClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
|
2496
|
6329 {
|
|
6330 this->bClip = 1;
|
|
6331 this->uClipX = uX;
|
|
6332 this->uClipY = uY;
|
|
6333 this->uClipZ = uZ;
|
|
6334 this->uClipW = uW;
|
|
6335 }
|
|
6336
|
|
6337 //----- (004A5BB6) --------------------------------------------------------
|
2524
|
6338 void Render::ResetUIClipRect()
|
2496
|
6339 {
|
|
6340 this->bClip = 1;
|
|
6341 this->uClipX = 0;
|
|
6342 this->uClipY = 0;
|
|
6343 this->uClipZ = window->GetWidth();
|
|
6344 this->uClipW = 480;
|
|
6345 }
|
|
6346
|
|
6347 unsigned __int32 Color32(unsigned __int16 color16)
|
|
6348 {
|
|
6349 unsigned __int32 c = color16;
|
|
6350 unsigned int b = (c & 31) * 8;
|
|
6351 unsigned int g = ((c >> 5) & 63) * 4;
|
|
6352 unsigned int r = ((c >> 11) & 31) * 8;
|
|
6353
|
2523
|
6354 return (r << 16) | (g << 8) | b;
|
|
6355 }
|
|
6356
|
|
6357 unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16)
|
|
6358 {
|
|
6359 unsigned __int32 c = color16;
|
|
6360 unsigned int b = (c & 31) * 8;
|
|
6361 unsigned int g = ((c >> 5) & 63) * 4;
|
|
6362 unsigned int r = ((c >> 11) & 31) * 8;
|
|
6363
|
|
6364 return (b << 16) | (g << 8) | r;
|
2496
|
6365 }
|
|
6366
|
|
6367 //----- (0040DEF3) --------------------------------------------------------
|
|
6368 unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b)
|
|
6369 {
|
|
6370 //return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) +
|
|
6371 // LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) +
|
|
6372 // LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
|
|
6373 return (b >> (8 - 5)) |
|
|
6374 0x7E0 & (g << (6 + 5 - 8)) |
|
|
6375 0xF800 & (r << (6 + 5 + 5 - 8));
|
|
6376 }
|
|
6377
|
2518
|
6378 void Render::DrawTextureNew(float u, float v, Texture *a4)
|
|
6379 {
|
|
6380 __debugbreak();
|
|
6381 }
|
|
6382
|
|
6383 void Render::DrawTextureNew(float u, float v, RGBTexture *a4)
|
|
6384 {
|
|
6385 DrawTextureRGB(640 * u, 480 * v, a4);
|
|
6386 }
|
2496
|
6387
|
|
6388 //----- (004A5BE3) --------------------------------------------------------
|
|
6389 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4)
|
|
6390 {
|
|
6391 int v4; // edi@3
|
|
6392 unsigned __int16 *v6; // esi@3
|
|
6393 unsigned int v8; // eax@5
|
|
6394 unsigned int v9; // ebx@5
|
|
6395 unsigned int v11; // eax@7
|
|
6396 unsigned int v12; // ebx@8
|
|
6397 unsigned int v15; // eax@14
|
|
6398 int v19; // [sp+10h] [bp-8h]@3
|
|
6399 int v23; // [sp+28h] [bp+10h]@3
|
|
6400
|
|
6401 if ( this->uNumSceneBegins && a4 )
|
|
6402 {
|
|
6403 v4 = a4->uWidth;
|
|
6404 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
|
|
6405 v6 = a4->pPixels;
|
|
6406 v23 = a4->uHeight;
|
|
6407 v19 = v4;
|
|
6408 if ( this->bClip )
|
|
6409 {
|
|
6410 if ( (signed int)uOutX < (signed int)this->uClipX )
|
|
6411 {
|
|
6412 v8 = this->uClipX - uOutX;
|
|
6413 v9 = uOutX - this->uClipX;
|
|
6414 v8 *= 2;
|
|
6415 v4 += v9;
|
|
6416 v6 = (unsigned __int16 *)((char *)v6 + v8);
|
|
6417 //v5 = (unsigned __int16 *)((char *)v5 + v8);
|
|
6418 }
|
|
6419 if ( (signed int)uOutY < (signed int)this->uClipY )
|
|
6420 {
|
|
6421 v11 = this->uClipY - uOutY;
|
|
6422 v6 += v19 * v11;
|
|
6423 v23 += uOutY - this->uClipY;
|
|
6424 //v5 += this->uTargetSurfacePitch * v11;
|
|
6425 }
|
|
6426 v12 = max(this->uClipX, uOutX);
|
|
6427 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ )
|
|
6428 {
|
|
6429 v4 = this->uClipZ - max(this->uClipX, uOutX);
|
|
6430 }
|
|
6431 v15 = max(this->uClipY, uOutY);
|
|
6432 if ( (signed int)(v15 + v23) > (signed int)this->uClipW )
|
|
6433 {
|
|
6434 v23 = this->uClipW - max(this->uClipY, uOutY);
|
|
6435 }
|
|
6436 }
|
|
6437
|
|
6438 for (int y = 0; y < v23; y++)
|
|
6439 {
|
|
6440 for (int x = 0; x < v4; x++)
|
|
6441 {
|
|
6442 WritePixel16(uOutX + x, uOutY + y, *v6);
|
|
6443 //*v5 = *v6;
|
|
6444 //++v5;
|
|
6445 ++v6;
|
|
6446 }
|
|
6447 v6 += v19 - v4;
|
|
6448 //v5 += this->uTargetSurfacePitch - v4;
|
|
6449 }
|
|
6450 }
|
|
6451 }
|
|
6452
|
|
6453 //----- (004A5D33) --------------------------------------------------------
|
|
6454 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture)
|
|
6455 {
|
|
6456 //unsigned __int16 *v7; // ebx@3
|
|
6457 int full_width; // ecx@3
|
|
6458 int full_height; // edi@3
|
|
6459 //int v23; // edi@23
|
|
6460 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3
|
|
6461
|
|
6462 if ( this->uNumSceneBegins && pTexture )
|
|
6463 {
|
|
6464 /*auto v7 = this->pTargetSurface;
|
|
6465 if (FORCE_16_BITS)
|
|
6466 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 2);
|
|
6467 else
|
|
6468 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 4);*/
|
|
6469 full_width = pTexture->uWidth - move_X;
|
|
6470 full_height = pTexture->uHeight - move_Y;
|
|
6471 pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth];
|
|
6472 if ( this->bClip )
|
|
6473 {
|
|
6474 if ( pX < this->uClipX )//åñëè êàäð âûõîäèò çà ïðàâóþ ãðàíèöó
|
|
6475 {
|
|
6476 pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX)));
|
|
6477 full_width += pX - this->uClipX;
|
|
6478 //v7 = (unsigned __int32 *)((char *)v7 + ((FORCE_16_BITS ? 2 : 4) * (this->uClipX - pX)));
|
|
6479 }
|
|
6480 if ( pY < this->uClipY )//åñëè êàäð âûõîäèò çà âåðõíþþ ãðàíèöó
|
|
6481 {
|
|
6482 pTexturea += pTexture->uWidth * (this->uClipY - pY);
|
|
6483 full_height += pY - this->uClipY;
|
|
6484 //v7 = (unsigned __int32 *)((char *)v7 + (FORCE_16_BITS ? 2 : 4) * this->uTargetSurfacePitch * (this->uClipY - pY));
|
|
6485 }
|
|
6486 if ( this->uClipX < pX )//åñëè ïðàâàÿ ãðàíèöà îêíà ìåíüøå õ êîîðäèíàòû êàäðà
|
|
6487 this->uClipX = pX;
|
|
6488 if ( this->uClipY < pY )//åñëè âåðõíÿÿ ãðàíèöà îêíà ìåíüøå y êîîðäèíàòû êàäðà
|
|
6489 this->uClipY = pY;
|
|
6490 if ( (full_width + this->uClipX) > this->uClipZ )//åñëè øèðèíà êàäðà âûõîäèò çà ïðàâóþ ãðàíèöó
|
|
6491 {
|
|
6492 if ( this->uClipX < pX )
|
|
6493 this->uClipX = pX;
|
|
6494 full_width = this->uClipZ - this->uClipX;
|
|
6495 }
|
|
6496 if ( (full_height + this->uClipY) > this->uClipW )//åñëè âûñîòà êàäðà âûõîäèò çà íèæíþþ ãðàíèöó
|
|
6497 {
|
|
6498 if ( this->uClipY < pY )
|
|
6499 this->uClipY = pY;
|
|
6500 full_height = this->uClipW - this->uClipY;
|
|
6501 }
|
|
6502 }
|
|
6503
|
|
6504 for (int y = 0; y < full_height; ++y)
|
|
6505 {
|
|
6506 for (int x = 0; x < full_width; ++x)
|
|
6507 {
|
|
6508 if ( *pTexturea != Color16(0, 0xFFu, 0xFFu) )
|
|
6509 {
|
|
6510 WritePixel16(pX + x, pY + y, *pTexturea);
|
|
6511 /*if (FORCE_16_BITS)
|
|
6512 *(unsigned __int16 *)v7 = *pTexturea;
|
|
6513 else
|
|
6514 *(unsigned __int32 *)v7 = r5g6b5_2_r8g8b8(*pTexturea);*/
|
|
6515 }
|
|
6516 ++pTexturea;
|
|
6517 //++v7;
|
|
6518 }
|
|
6519 //v7 += this->uTargetSurfacePitch - full_width;
|
|
6520 pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width));
|
|
6521 }
|
|
6522 }
|
|
6523 }
|
|
6524
|
|
6525 //----- (004A6E7E) --------------------------------------------------------
|
|
6526 void Render::DrawTranslucent(unsigned int a2, unsigned int a3, Texture *a4)
|
|
6527 {
|
|
6528 int v5; // edx@4
|
|
6529 unsigned int v6; // edi@4
|
|
6530 unsigned int v7; // edx@5
|
|
6531 unsigned int v8; // edx@6
|
|
6532 unsigned int v9; // edx@7
|
|
6533 unsigned int v10; // edx@8
|
|
6534 unsigned int v11; // ebx@9
|
|
6535 unsigned int v12; // esi@11
|
|
6536 unsigned int v13; // edx@12
|
|
6537 unsigned int v14; // ebx@15
|
|
6538 unsigned int v15; // esi@17
|
|
6539 unsigned int v16; // edi@18
|
|
6540 int v18; // [sp+14h] [bp-Ch]@4
|
|
6541 int v19; // [sp+18h] [bp-8h]@4
|
|
6542 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4
|
|
6543
|
|
6544 if ( this->uNumSceneBegins && a4 && a4->pPalette16 )
|
|
6545 {
|
|
6546 //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
|
|
6547 v20 = a4->pLevelOfDetail0_prolly_alpha_mask;
|
|
6548 v5 = a4->uTextureWidth;
|
|
6549 v6 = a4->uTextureHeight;
|
|
6550 v19 = a4->uTextureWidth;
|
|
6551 v18 = a4->uTextureWidth;
|
|
6552 int clipped_out_x = a2;
|
|
6553 int clipped_out_y = a3;
|
|
6554 if ( this->bClip )
|
|
6555 {
|
|
6556 v7 = this->uClipX;
|
|
6557 if ( (signed int)a2 < (signed int)v7 )
|
|
6558 {
|
|
6559 v8 = v7 - a2;
|
|
6560 v20 += v8;
|
|
6561 v19 += a2 - this->uClipX;
|
|
6562 //v4 += v8;
|
|
6563 clipped_out_x = uClipX;
|
|
6564 }
|
|
6565 v9 = this->uClipY;
|
|
6566 if ( (signed int)a3 < (signed int)v9 )
|
|
6567 {
|
|
6568 v10 = v9 - a3;
|
|
6569 v20 += v18 * v10;
|
|
6570 v6 = a3 - this->uClipY + a4->uTextureHeight;
|
|
6571 //v4 += this->uTargetSurfacePitch * v10;
|
|
6572 clipped_out_y = uClipY;
|
|
6573 }
|
|
6574 v11 = this->uClipX;
|
|
6575 v5 = v19;
|
|
6576 if ( (signed int)v11 < (signed int)a2 )
|
|
6577 v11 = a2;
|
|
6578 v12 = this->uClipZ;
|
|
6579 if ( (signed int)(v19 + v11) > (signed int)v12 )
|
|
6580 {
|
|
6581 v13 = this->uClipX;
|
|
6582 if ( (signed int)v13 < (signed int)a2 )
|
|
6583 v13 = a2;
|
|
6584 v5 = v12 - v13;
|
|
6585 }
|
|
6586 v14 = this->uClipY;
|
|
6587 if ( (signed int)v14 < (signed int)a3 )
|
|
6588 v14 = a3;
|
|
6589 v15 = this->uClipW;
|
|
6590 if ( (signed int)(v6 + v14) > (signed int)v15 )
|
|
6591 {
|
|
6592 v16 = this->uClipY;
|
|
6593 if ( (signed int)v16 < (signed int)a3 )
|
|
6594 v16 = a3;
|
|
6595 v6 = v15 - v16;
|
|
6596 }
|
|
6597 }
|
|
6598
|
|
6599 for (uint y = 0; y < v6; ++y)
|
|
6600 {
|
|
6601 for (int x = 0; x < v5; ++x)
|
|
6602 {
|
|
6603 if ( *v20 )
|
|
6604 WritePixel16(clipped_out_x + x, clipped_out_y + y, ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF);
|
|
6605 ++v20;
|
|
6606 }
|
|
6607 v20 += v18 - v5;
|
|
6608 }
|
|
6609
|
|
6610 /*if ( pRenderer->uTargetGBits == 5 )
|
|
6611 {
|
|
6612 if ( (signed int)v6 > 0 )
|
|
6613 {
|
|
6614 v23 = v6;
|
|
6615 do
|
|
6616 {
|
|
6617 if ( v5 > 0 )
|
|
6618 {
|
|
6619 v21 = v5;
|
|
6620 do
|
|
6621 {
|
|
6622 if ( *v20 )
|
|
6623 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF;
|
|
6624 ++v4;
|
|
6625 ++v20;
|
|
6626 --v21;
|
|
6627 }
|
|
6628 while ( v21 );
|
|
6629 }
|
|
6630 v20 += v18 - v5;
|
|
6631 v17 = v23-- == 1;
|
|
6632 v4 += this->uTargetSurfacePitch - v5;
|
|
6633 }
|
|
6634 while ( !v17 );
|
|
6635 }
|
|
6636 }
|
|
6637 else
|
|
6638 {
|
|
6639 if ( (signed int)v6 > 0 )
|
|
6640 {
|
|
6641 v24 = v6;
|
|
6642 do
|
|
6643 {
|
|
6644 if ( v5 > 0 )
|
|
6645 {
|
|
6646 v22 = v5;
|
|
6647 do
|
|
6648 {
|
|
6649 if ( *v20 )
|
|
6650 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF;
|
|
6651 ++v4;
|
|
6652 ++v20;
|
|
6653 --v22;
|
|
6654 }
|
|
6655 while ( v22 );
|
|
6656 }
|
|
6657 v20 += v18 - v5;
|
|
6658 v17 = v24-- == 1;
|
|
6659 v4 += this->uTargetSurfacePitch - v5;
|
|
6660 }
|
|
6661 while ( !v17 );
|
|
6662 }
|
|
6663 }*/
|
|
6664 }
|
|
6665 }
|
|
6666
|
|
6667 //----- (004A6DF5) --------------------------------------------------------
|
|
6668 void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7)
|
|
6669 {
|
|
6670 int width; // ecx@3
|
|
6671 unsigned __int16 *pixels; // ebx@4
|
|
6672 int height; // esi@4
|
|
6673
|
|
6674 if ( !pBitmap || !pTarget)
|
|
6675 return;
|
|
6676
|
|
6677 width = a7->z - a7->x;
|
|
6678 height = a7->w - a7->y;
|
|
6679 pixels = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y;
|
|
6680 for ( int y = 0; y < height; ++y )
|
|
6681 {
|
|
6682 for ( int x = 0; x < width; ++x )
|
|
6683 {
|
|
6684 WritePixel16(a7->x + x, a7->y + y, *pixels);
|
|
6685 ++pixels;
|
|
6686 }
|
|
6687 pixels += uTargetPitch - width;
|
|
6688 }
|
|
6689 }
|
|
6690
|
|
6691 //----- (004A6D87) --------------------------------------------------------
|
|
6692 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16)
|
|
6693 {
|
|
6694 if (!uNumSceneBegins)
|
|
6695 return;
|
|
6696
|
|
6697 unsigned __int32 twoColors = (uColor16 << 16) | uColor16;
|
|
6698 for (uint y = 0; y < uHeight; ++y)
|
|
6699 {
|
|
6700 void *pDst = (char *)pTargetSurface + (FORCE_16_BITS ? 2 : 4) * (uX + (y + uY) * uTargetSurfacePitch);
|
|
6701
|
|
6702 memset32(pDst,
|
|
6703 FORCE_16_BITS ? twoColors : 0xFF000000 | Color32(uColor16), // two colors per int (16bit) or 1 (32bit)
|
|
6704 uWidth / (FORCE_16_BITS ? 2 : 1)); // two pixels per int (16bit) or 1 (32bit)
|
|
6705
|
|
6706 if (FORCE_16_BITS && uWidth & 1) // we may miss one pixel for 16bit
|
|
6707 ((unsigned __int16 *)pTargetSurface)[uX + uWidth - 1 + (y + uY) * uTargetSurfacePitch] = uColor16;
|
|
6708 }
|
|
6709 }
|
|
6710
|
|
6711 //----- (004A6C4F) --------------------------------------------------------
|
|
6712 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth,
|
|
6713 unsigned int uCharHeight, unsigned __int16 *pFontPalette,
|
|
6714 unsigned __int16 uFaceColor, unsigned __int16 uShadowColor)
|
|
6715 {
|
|
6716 unsigned int v9; // edi@2
|
|
6717 unsigned int v10; // esi@2
|
|
6718 unsigned int v12; // ebx@3
|
|
6719 //signed int v13; // edx@5
|
|
6720 int v14; // edx@6
|
|
6721 signed int v15; // ebx@7
|
|
6722 //unsigned int v16; // edx@9
|
|
6723 signed int v17; // edi@10
|
|
6724 signed int v18; // ebx@13
|
|
6725 unsigned int v19; // edx@15
|
|
6726 signed int v20; // esi@16
|
|
6727 unsigned __int16 v22; // dx@24
|
|
6728 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2
|
|
6729
|
|
6730 if (!this->uNumSceneBegins)
|
|
6731 return;
|
|
6732
|
|
6733 v9 = uCharWidth;
|
|
6734 v10 = uCharHeight;
|
|
6735 //v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
|
|
6736 v24 = pFontPixels;
|
|
6737
|
|
6738 int clipped_out_x = uOutX, clipped_out_y = uOutY;
|
|
6739 if ( this->bClip )
|
|
6740 {
|
|
6741 v12 = this->uClipX;
|
|
6742 if ( uOutX < (signed int)v12 )
|
|
6743 {
|
|
6744 v24 = &pFontPixels[v12 - uOutX];
|
|
6745 //v11 += v12 - uOutX;
|
|
6746 clipped_out_x = uClipX;
|
|
6747 v9 = uCharWidth + uOutX - v12;
|
|
6748 }
|
|
6749 //v13 = this->uClipY;
|
|
6750 if ( uOutY < this->uClipY )
|
|
6751 {
|
|
6752 v14 = this->uClipY - uOutY;
|
|
6753 v24 += uCharWidth * v14;
|
|
6754 v10 = uCharHeight + uOutY - this->uClipY;
|
|
6755 //v11 += this->uTargetSurfacePitch * v14;
|
|
6756 clipped_out_y = uClipY;
|
|
6757 }
|
|
6758 v15 = this->uClipX;
|
|
6759 if ( this->uClipX < uOutX )
|
|
6760 v15 = uOutX;
|
|
6761 //v16 = this->uClipZ;
|
|
6762 if ( (signed int)(v9 + v15) > (signed int)this->uClipZ )
|
|
6763 {
|
|
6764 v17 = this->uClipX;
|
|
6765 if ( this->uClipX < uOutX )
|
|
6766 v17 = uOutX;
|
|
6767 v9 = this->uClipZ - v17;
|
|
6768 }
|
|
6769 v18 = this->uClipY;
|
|
6770 if ( this->uClipY < uOutY )
|
|
6771 v18 = uOutY;
|
|
6772 v19 = this->uClipW;
|
|
6773 if ( (signed int)(v10 + v18) > (signed int)v19 )
|
|
6774 {
|
|
6775 v20 = this->uClipY;
|
|
6776 if ( this->uClipY < uOutY )
|
|
6777 v20 = uOutY;
|
|
6778 v10 = v19 - v20;
|
|
6779 }
|
|
6780 }
|
|
6781
|
|
6782 for (uint y = 0; y < v10; ++y)
|
|
6783 {
|
|
6784 for (uint x = 0; x < v9; ++x)
|
|
6785 {
|
|
6786 if (*v24)
|
|
6787 {
|
|
6788 v22 = uShadowColor;
|
|
6789 if ( *v24 != 1 )
|
|
6790 v22 = uFaceColor;
|
|
6791 WritePixel16(clipped_out_x + x, clipped_out_y + y, v22);
|
|
6792 }
|
|
6793 ++v24;
|
|
6794 }
|
|
6795 v24 += uCharWidth - v9;
|
|
6796 //v23 = uOutXa-- == 1;
|
|
6797 //v11 += this->uTargetSurfacePitch - v9;
|
|
6798 }
|
|
6799 }
|
|
6800
|
|
6801 //----- (004A6A68) --------------------------------------------------------
|
|
6802 void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height)
|
|
6803 {
|
|
6804 Texture tex; // [sp+Ch] [bp-48h]@1
|
|
6805
|
|
6806 memcpy(&tex, a4, sizeof(tex));
|
|
6807 tex.uTextureHeight = a4->uTextureHeight - height;
|
|
6808 if ( (signed __int16)tex.uTextureHeight > 0 )
|
|
6809 DrawTextureIndexed(a2, a3, &tex);
|
|
6810 }
|
|
6811
|
|
6812 //----- (004A6AB1) --------------------------------------------------------
|
2525
|
6813 void Render::DrawTextAlpha( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, bool present_time_transparency )
|
2496
|
6814 {
|
|
6815 int v8; // edi@2
|
|
6816 unsigned int v9; // esi@2
|
|
6817 unsigned char *v11; // edx@2
|
|
6818 int v14; // edx@6
|
|
6819 signed int v15; // ebx@7
|
|
6820 signed int v17; // edi@10
|
|
6821 signed int v18; // ebx@13
|
|
6822 signed int v20; // esi@16
|
|
6823 unsigned __int16 v24; // si@35
|
|
6824 int v25; // [sp+Ch] [bp-4h]@2
|
|
6825 unsigned int v28; // [sp+20h] [bp+10h]@30
|
|
6826
|
|
6827 int a2 = x;
|
|
6828 int a3 = y;
|
|
6829 uint a6 = uFontHeight;
|
|
6830 if (!this->uNumSceneBegins)
|
|
6831 return;
|
|
6832
|
|
6833 v8 = a5;
|
|
6834 v9 = a6;
|
|
6835 //v10 = &pTargetSurface[x + y * uTargetSurfacePitch];
|
|
6836 v11 = (unsigned char *)font_pixels;
|
|
6837 v25 = (int)font_pixels;
|
|
6838 int clipped_out_x = x;
|
|
6839 int clipped_out_y = y;
|
|
6840 if ( this->bClip )
|
|
6841 {
|
|
6842 if ( a2 < (signed int)this->uClipX )
|
|
6843 {
|
|
6844 v25 = this->uClipX - a2 + (int)font_pixels;
|
|
6845 //v10 += v12 - a2;
|
|
6846 v8 = a5 + a2 - this->uClipX;
|
|
6847 clipped_out_x = uClipX;
|
|
6848 }
|
|
6849 if ( a3 < this->uClipY )
|
|
6850 {
|
|
6851 v14 = this->uClipY - a3;
|
|
6852 v25 += a5 * v14;
|
|
6853 v9 = a6 + a3 - this->uClipY;
|
|
6854 //v10 += this->uTargetSurfacePitch * v14;
|
|
6855 clipped_out_y = uClipY;
|
|
6856 }
|
|
6857 v15 = this->uClipX;
|
|
6858 if ( this->uClipX < a2 )
|
|
6859 v15 = a2;
|
|
6860 if ( v8 + v15 > (signed int)this->uClipZ )
|
|
6861 {
|
|
6862 v17 = this->uClipX;
|
|
6863 if ( v17 < a2 )
|
|
6864 v17 = a2;
|
|
6865 v8 = this->uClipZ - v17;
|
|
6866 }
|
|
6867 v18 = this->uClipY;
|
|
6868 if ( this->uClipY < a3 )
|
|
6869 v18 = a3;
|
|
6870 if ( (signed int)(v9 + v18) > (signed int)this->uClipW )
|
|
6871 {
|
|
6872 v20 = this->uClipY;
|
|
6873 if ( this->uClipY < a3 )
|
|
6874 v20 = a3;
|
|
6875 v9 = this->uClipW - v20;
|
|
6876 }
|
|
6877 v11 = (unsigned char *)v25;
|
|
6878 }
|
|
6879
|
2525
|
6880 if ( present_time_transparency )
|
|
6881 {
|
|
6882 v28 = 0x7FF; // transparent color 16bit pRenderer->uTargetGMask | pRenderer->uTargetBMask;
|
2496
|
6883 for (uint dy = 0; dy < v9; ++dy)
|
|
6884 {
|
|
6885 for (int dx = 0; dx < v8; ++dx)
|
|
6886 {
|
|
6887 if ( *v11 )
|
|
6888 v24 = pPalette[*v11];
|
|
6889 else
|
|
6890 v24 = v28;
|
|
6891 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, v24);
|
|
6892 //*v10 = v24;
|
|
6893 //++v10;
|
|
6894 ++v11;
|
|
6895 //--v27;
|
|
6896
|
|
6897 }
|
|
6898 v11 += a5 - v8;
|
|
6899 }
|
|
6900 /*if ( (signed int)v9 > 0 )
|
|
6901 {
|
|
6902 v23 = a5;
|
|
6903 v30 = v9;
|
|
6904 do
|
|
6905 {
|
|
6906 if ( v8 > 0 )
|
|
6907 {
|
|
6908 v27 = v8;
|
|
6909 do
|
|
6910 {
|
|
6911 if ( *v11 )
|
|
6912 v24 = pPalette[*v11];
|
|
6913 else
|
|
6914 v24 = v28;
|
|
6915 *v10 = v24;
|
|
6916 ++v10;
|
|
6917 ++v11;
|
|
6918 --v27;
|
|
6919 }
|
|
6920 while ( v27 );
|
|
6921 }
|
|
6922 v11 += v23 - v8;
|
|
6923 v22 = v30-- == 1;
|
|
6924 v10 += this->uTargetSurfacePitch - v8;
|
|
6925 }
|
|
6926 while ( !v22 );
|
|
6927 }*/
|
|
6928 }
|
|
6929 else
|
|
6930 {
|
|
6931 for (uint dy = 0; dy < v9; ++dy)
|
|
6932 {
|
|
6933 for (int dx = 0; dx < v8; ++dx)
|
|
6934 {
|
|
6935 if ( *v11 )
|
|
6936 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, pPalette[*v11]);
|
|
6937 //*v10 = v24;
|
|
6938 //++v10;
|
|
6939 ++v11;
|
|
6940 //--v27;
|
|
6941 }
|
|
6942 v11 += a5 - v8;
|
|
6943 }
|
|
6944
|
|
6945 /*if ( (signed int)v9 > 0 )
|
|
6946 {
|
|
6947 v21 = a5;
|
|
6948 v29 = v9;
|
|
6949 do
|
|
6950 {
|
|
6951 if ( v8 > 0 )
|
|
6952 {
|
|
6953 v26 = v8;
|
|
6954 do
|
|
6955 {
|
|
6956 if ( *v11 )
|
|
6957 *v10 = pPalette[*v11];
|
|
6958 ++v10;
|
|
6959 ++v11;
|
|
6960 --v26;
|
|
6961 }
|
|
6962 while ( v26 );
|
|
6963 }
|
|
6964 v11 += v21 - v8;
|
|
6965 v22 = v29-- == 1;
|
|
6966 v10 += this->uTargetSurfacePitch - v8;
|
|
6967 }
|
|
6968 while ( !v22 );
|
|
6969 }*/
|
|
6970 }
|
|
6971 }
|
|
6972
|
|
6973 //----- (004A68EF) --------------------------------------------------------
|
|
6974 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture)
|
|
6975 {
|
|
6976 DrawMasked(a2, a3, pTexture, 0x07E0);
|
|
6977 }
|
|
6978
|
|
6979
|
|
6980 //----- (004A6776) --------------------------------------------------------
|
|
6981 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4)
|
|
6982 {
|
|
6983 DrawMasked(a2, a3, a4, 0xF800);
|
|
6984 /*Texture *v4; // edi@2
|
|
6985 unsigned int v5; // ebx@4
|
|
6986 unsigned __int16 *v6; // eax@4
|
|
6987 unsigned int v7; // edx@5
|
|
6988 unsigned int v8; // edx@6
|
|
6989 unsigned int v9; // edx@7
|
|
6990 unsigned int v10; // edx@8
|
|
6991 unsigned int v11; // edx@9
|
|
6992 unsigned int v12; // esi@12
|
|
6993 unsigned int v13; // esi@15
|
|
6994 unsigned int v14; // edx@17
|
|
6995 unsigned int v15; // esi@18
|
|
6996 unsigned __int8 *v16; // ebx@22
|
|
6997 char v17; // zf@28
|
|
6998 int v18; // [sp+10h] [bp-10h]@4
|
|
6999 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
|
|
7000 int v20; // [sp+1Ch] [bp-4h]@4
|
|
7001 int a2a; // [sp+28h] [bp+8h]@24
|
|
7002 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22
|
|
7003 unsigned int a4a; // [sp+30h] [bp+10h]@11
|
|
7004
|
|
7005 if ( this->uNumSceneBegins )
|
|
7006 {
|
|
7007 v4 = a4;
|
|
7008 if ( a4 )
|
|
7009 {
|
|
7010 if ( a4->pPalette16 )
|
|
7011 {
|
|
7012 v5 = a4->uTextureHeight;
|
|
7013 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
|
|
7014 v19 = a4->pLevelOfDetail0_prolly_alpha_mask;
|
|
7015 v20 = a4->uTextureWidth;
|
|
7016 v18 = a4->uTextureWidth;
|
|
7017 if ( this->bClip )
|
|
7018 {
|
|
7019 v7 = this->uClipX;
|
|
7020 if ( (signed int)a2 < (signed int)v7 )
|
|
7021 {
|
|
7022 v8 = v7 - a2;
|
|
7023 v19 += v8;
|
|
7024 v20 += a2 - this->uClipX;
|
|
7025 v6 += v8;
|
|
7026 }
|
|
7027 v9 = this->uClipY;
|
|
7028 v5 = a4->uTextureHeight;
|
|
7029 if ( (signed int)a3 < (signed int)v9 )
|
|
7030 {
|
|
7031 v10 = v9 - a3;
|
|
7032 v19 += v18 * v10;
|
|
7033 v5 = a3 - this->uClipY + a4->uTextureHeight;
|
|
7034 v4 = a4;
|
|
7035 v6 += this->uTargetSurfacePitch * v10;
|
|
7036 }
|
|
7037 v11 = this->uClipX;
|
|
7038 if ( (signed int)v11 < (signed int)a2 )
|
|
7039 v11 = a2;
|
|
7040 a4a = this->uClipZ;
|
|
7041 if ( (signed int)(v11 + v20) > (signed int)a4a )
|
|
7042 {
|
|
7043 v12 = this->uClipX;
|
|
7044 if ( (signed int)v12 < (signed int)a2 )
|
|
7045 v12 = a2;
|
|
7046 v20 = a4a - v12;
|
|
7047 }
|
|
7048 v13 = this->uClipY;
|
|
7049 if ( (signed int)v13 < (signed int)a3 )
|
|
7050 v13 = a3;
|
|
7051 v14 = this->uClipW;
|
|
7052 if ( (signed int)(v5 + v13) > (signed int)v14 )
|
|
7053 {
|
|
7054 v15 = this->uClipY;
|
|
7055 if ( (signed int)v15 < (signed int)a3 )
|
|
7056 v15 = a3;
|
|
7057 v5 = v14 - v15;
|
|
7058 }
|
|
7059 }
|
|
7060 if ( (signed int)v5 > 0 )
|
|
7061 {
|
|
7062 a3a = v5;
|
|
7063 v16 = v19;
|
|
7064 do
|
|
7065 {
|
|
7066 if ( v20 > 0 )
|
|
7067 {
|
|
7068 a2a = v20;
|
|
7069 do
|
|
7070 {
|
|
7071 if ( *v16 )
|
|
7072 *v6 = this->uTargetRMask & v4->pPalette16[*v16];
|
|
7073 ++v6;
|
|
7074 ++v16;
|
|
7075 --a2a;
|
|
7076 }
|
|
7077 while ( a2a );
|
|
7078 }
|
|
7079 v16 += v18 - v20;
|
|
7080 v17 = a3a-- == 1;
|
|
7081 v6 += this->uTargetSurfacePitch - v20;
|
|
7082 }
|
|
7083 while ( !v17 );
|
|
7084 }
|
|
7085 }
|
|
7086 }
|
|
7087 }*/
|
|
7088 }
|
|
7089
|
|
7090 //----- (004A68EF) --------------------------------------------------------
|
|
7091 void Render::DrawMasked(signed int a2, signed int a3, Texture *pTexture, unsigned __int16 mask)
|
|
7092 {
|
|
7093 unsigned int v5; // ebx@4
|
|
7094 int v10; // edx@8
|
|
7095 signed int v11; // edx@9
|
|
7096 signed int v12; // esi@12
|
|
7097 signed int v13; // esi@15
|
|
7098 signed int v15; // esi@18
|
|
7099 unsigned __int8 *v16; // ebx@22
|
|
7100 int v18; // [sp+10h] [bp-10h]@4
|
|
7101 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
|
|
7102 int v20; // [sp+1Ch] [bp-4h]@4
|
|
7103
|
|
7104 if (!uNumSceneBegins || !pTexture)
|
|
7105 return;
|
|
7106
|
|
7107 if ( pTexture->pPalette16 )
|
|
7108 {
|
|
7109 v5 = pTexture->uTextureHeight;
|
|
7110 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
|
|
7111 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask;
|
|
7112 v20 = pTexture->uTextureWidth;
|
|
7113 v18 = pTexture->uTextureWidth;
|
|
7114 int clipped_out_x = a2;
|
|
7115 int clipped_out_y = a3;
|
|
7116 if ( this->bClip )
|
|
7117 {
|
|
7118 if ( a2 < this->uClipX )
|
|
7119 {
|
|
7120 v19 += this->uClipX - a2;
|
|
7121 v20 += a2 - this->uClipX;
|
|
7122 clipped_out_x = uClipX;
|
|
7123 }
|
|
7124 v5 = pTexture->uTextureHeight;
|
|
7125 if ( a3 < this->uClipY )
|
|
7126 {
|
|
7127 v10 = this->uClipY - a3;
|
|
7128 v19 += v18 * v10;
|
|
7129 v5 = a3 - this->uClipY + pTexture->uTextureHeight;
|
|
7130 clipped_out_y = uClipY;
|
|
7131 }
|
|
7132 v11 = this->uClipX;
|
|
7133 if ( this->uClipX < a2 )
|
|
7134 v11 = a2;
|
|
7135 if ( v11 + v20 > (signed int)this->uClipZ )
|
|
7136 {
|
|
7137 v12 = this->uClipX;
|
|
7138 if ( this->uClipX < a2 )
|
|
7139 v12 = a2;
|
|
7140 v20 = this->uClipZ - v12;
|
|
7141 }
|
|
7142 v13 = this->uClipY;
|
|
7143 if ( this->uClipY < a3 )
|
|
7144 v13 = a3;
|
|
7145 if ( (signed int)(v5 + v13) > (signed int)this->uClipW )
|
|
7146 {
|
|
7147 v15 = this->uClipY;
|
|
7148 if ( this->uClipY < a3 )
|
|
7149 v15 = a3;
|
|
7150 v5 = this->uClipW - v15;
|
|
7151 }
|
|
7152 }
|
|
7153
|
|
7154 v16 = v19;
|
|
7155 for (uint y = 0; y < v5; ++y)
|
|
7156 {
|
|
7157 for (int x = 0; x < v20; ++x)
|
|
7158 {
|
|
7159 if ( *v16 )
|
|
7160 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v16] & mask);
|
|
7161 ++v16;
|
|
7162 }
|
|
7163 v16 += v18 - v20;
|
|
7164 }
|
|
7165
|
|
7166 /*if ( (signed int)v5 > 0 )
|
|
7167 {
|
|
7168 v22 = v5;
|
|
7169 v16 = v19;
|
|
7170 do
|
|
7171 {
|
|
7172 if ( v20 > 0 )
|
|
7173 {
|
|
7174 v21 = v20;
|
|
7175 do
|
|
7176 {
|
|
7177 if ( *v16 )
|
|
7178 *v6 = this->uTargetGMask & v4->pPalette16[*v16];
|
|
7179 ++v6;
|
|
7180 ++v16;
|
|
7181 --v21;
|
|
7182 }
|
|
7183 while ( v21 );
|
|
7184 }
|
|
7185 v16 += v18 - v20;
|
|
7186 v17 = v22-- == 1;
|
|
7187 v6 += this->uTargetSurfacePitch - v20;
|
|
7188 }
|
|
7189 while ( !v17 );
|
|
7190 }*/
|
|
7191 }
|
|
7192 }
|
|
7193
|
|
7194
|
|
7195 //----- (004A65CC) --------------------------------------------------------
|
|
7196 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8)
|
|
7197 {
|
|
7198 unsigned int uHeight; // edi@6
|
|
7199 unsigned int v14; // edx@11
|
|
7200 unsigned int v16; // edx@14
|
|
7201 unsigned int v17; // edx@17
|
|
7202 unsigned int v19; // edx@20
|
|
7203 int v20; // eax@27
|
|
7204 int v21; // edx@29
|
|
7205 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6
|
|
7206 int Width; // [sp+2Ch] [bp+14h]@6
|
|
7207
|
|
7208 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 )
|
|
7209 {
|
|
7210 v24 = a4->pLevelOfDetail0_prolly_alpha_mask;
|
|
7211 Width = a4->uTextureWidth;
|
|
7212 uHeight = a4->uTextureHeight;
|
|
7213 int clipped_out_x = x;
|
|
7214 int clipped_out_y = y;
|
|
7215 if ( this->bClip )
|
|
7216 {
|
|
7217 if ( (signed int)x < (signed int)this->uClipX )
|
|
7218 {
|
|
7219 v24 += this->uClipX - x;
|
|
7220 Width += x - this->uClipX;
|
|
7221 clipped_out_x = uClipX;
|
|
7222 }
|
|
7223 if ( (signed int)y < (signed int)this->uClipY )
|
|
7224 {
|
|
7225 v24 += a4->uTextureWidth * (this->uClipY - y);
|
|
7226 uHeight = y - this->uClipY + a4->uTextureHeight;
|
|
7227 clipped_out_y = uClipY;
|
|
7228 }
|
|
7229 v14 = this->uClipX;
|
|
7230 if ( (signed int)this->uClipX < (signed int)x )
|
|
7231 v14 = x;
|
|
7232 if ( (signed int)(Width + v14) > (signed int)this->uClipZ )
|
|
7233 {
|
|
7234 v16 = this->uClipX;
|
|
7235 if ( (signed int)this->uClipX < (signed int)x )
|
|
7236 v16 = x;
|
|
7237 Width = this->uClipZ - v16;
|
|
7238 }
|
|
7239 v17 = this->uClipY;
|
|
7240 if ( (signed int)this->uClipY < (signed int)y )
|
|
7241 v17 = y;
|
|
7242 if ( (signed int)(uHeight + v17) > (signed int)this->uClipW )
|
|
7243 {
|
|
7244 v19 = this->uClipY;
|
|
7245 if ( (signed int)this->uClipY < (signed int)y )
|
|
7246 v19 = y;
|
|
7247 uHeight = this->uClipW - v19;
|
|
7248 }
|
|
7249 }
|
|
7250
|
|
7251 for (uint dy = 0; dy < uHeight; ++dy)
|
|
7252 {
|
|
7253 for (int dx = 0; dx < Width; ++dx)
|
|
7254 {
|
|
7255 v20 = *v24;
|
|
7256 if ( v20 >= a7 && v20 <= a8 )
|
|
7257 {
|
|
7258 v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
|
|
7259 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
|
|
7260 v21 = 2 * a8 - v21 - a7;
|
|
7261 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]);
|
|
7262 }
|
|
7263 ++v24;
|
|
7264 }
|
|
7265 v24 += a4->uTextureWidth - Width;
|
|
7266 }
|
|
7267 /*if ( (signed int)v9 > 0 )
|
|
7268 {
|
|
7269 ya = v9;
|
|
7270 v23 = v22 - v27;
|
|
7271 do
|
|
7272 {
|
|
7273 if ( v27 > 0 )
|
|
7274 {
|
|
7275 xa = v27;
|
|
7276 do
|
|
7277 {
|
|
7278 v20 = *v24;
|
|
7279 if ( v20 >= a7 && v20 <= a8 )
|
|
7280 {
|
|
7281 v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
|
|
7282 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
|
|
7283 v21 = 2 * a8 - v21 - a7;
|
|
7284 *v8 = a4->pPalette16[v21];
|
|
7285 }
|
|
7286 ++v8;
|
|
7287 ++v24;
|
|
7288 --xa;
|
|
7289 }
|
|
7290 while ( xa );
|
|
7291 }
|
|
7292 v8 += this->uTargetSurfacePitch - v27;
|
|
7293 v24 += v23;
|
|
7294 --ya;
|
|
7295 }
|
|
7296 while ( ya );
|
|
7297 }*/
|
|
7298 }
|
|
7299 }
|
|
7300
|
|
7301 //----- (004A63E6) --------------------------------------------------------
|
|
7302 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8)
|
|
7303 {
|
|
7304 unsigned int v14; // edx@11
|
|
7305 unsigned int v16; // edx@14
|
|
7306 unsigned int v17; // edx@17
|
|
7307 unsigned int v19; // edx@20
|
|
7308 int v20; // eax@27
|
|
7309 int v21; // edx@29
|
|
7310 int Height; // [sp+10h] [bp-8h]@6
|
|
7311 int Width; // [sp+14h] [bp-4h]@6
|
|
7312 int v27; // [sp+24h] [bp+Ch]@23
|
|
7313 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6
|
|
7314
|
|
7315 if ( this->uNumSceneBegins )
|
|
7316 {
|
|
7317 if ( a4 )
|
|
7318 {
|
|
7319 if ( a4->pPalette16 )
|
|
7320 {
|
|
7321 if ( a5 )
|
|
7322 {
|
|
7323 if ( a5->pPalette16 )
|
|
7324 {
|
|
7325 v28 = a4->pLevelOfDetail0_prolly_alpha_mask;
|
|
7326 Width = a4->uTextureWidth;
|
|
7327 Height = a4->uTextureHeight;
|
|
7328 int clipped_out_x = a2;
|
|
7329 int clipped_out_y = a3;
|
|
7330 if ( this->bClip )
|
|
7331 {
|
|
7332 if ( (signed int)a2 < (signed int)this->uClipX )
|
|
7333 {
|
|
7334 v28 += this->uClipX - a2;
|
|
7335 Width += a2 - this->uClipX;
|
|
7336 clipped_out_x = uClipX;
|
|
7337 }
|
|
7338
|
|
7339 if ( (signed int)a3 < (signed int)this->uClipY )
|
|
7340 {
|
|
7341 v28 += a4->uTextureWidth * (this->uClipY - a3);
|
|
7342 Height += a3 - this->uClipY;
|
|
7343 clipped_out_y = uClipY;
|
|
7344 }
|
|
7345
|
|
7346 v14 = this->uClipX;
|
|
7347 if ( (signed int)this->uClipX < (signed int)a2 )
|
|
7348 v14 = a2;
|
|
7349 if ( (signed int)(Width + v14) > (signed int)this->uClipZ )
|
|
7350 {
|
|
7351 v16 = this->uClipX;
|
|
7352 if ( (signed int)this->uClipX < (signed int)a2 )
|
|
7353 v16 = a2;
|
|
7354 Width = this->uClipZ - v16;
|
|
7355 }
|
|
7356
|
|
7357 v17 = this->uClipY;
|
|
7358 if ( (signed int)this->uClipY < (signed int)a3 )
|
|
7359 v17 = a3;
|
|
7360 if ( (signed int)(Height + v17) > (signed int)this->uClipW )
|
|
7361 {
|
|
7362 v19 = this->uClipY;
|
|
7363 if ( (signed int)this->uClipY < (signed int)a3 )
|
|
7364 v19 = a3;
|
|
7365 Height = this->uClipW - v19;
|
|
7366 }
|
|
7367 }
|
|
7368
|
|
7369 v27 = 0;
|
|
7370 for (int y = 0; y < Height; ++y)
|
|
7371 {
|
|
7372 for (int x = 0; x < Width; ++x)
|
|
7373 {
|
|
7374 if ( *v28 )
|
|
7375 {
|
|
7376 v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1));
|
|
7377 if ( v20 >= a7 )
|
|
7378 {
|
|
7379 if ( v20 <= a8 )
|
|
7380 {
|
|
7381 v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
|
|
7382 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
|
|
7383 v21 = 2 * a8 - v21 - a7;
|
|
7384 //v9 = a5;
|
|
7385 //*v10 = a5->pPalette16[v21];
|
|
7386 WritePixel16(clipped_out_x + x, clipped_out_y + y, a5->pPalette16[v21]);
|
|
7387 }
|
|
7388 }
|
|
7389 }
|
|
7390 v28++;
|
|
7391 }
|
|
7392 v28 += a4->uTextureWidth - Width;
|
|
7393 }
|
|
7394
|
|
7395 /*if ( v24 > 0 )
|
|
7396 {
|
|
7397 v23 = v22 - v25;
|
|
7398 do
|
|
7399 {
|
|
7400 for ( i = 0; i < v25; ++v28 )
|
|
7401 {
|
|
7402 if ( *v28 )
|
|
7403 {
|
|
7404 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1));
|
|
7405 if ( v20 >= a7 )
|
|
7406 {
|
|
7407 if ( v20 <= a8 )
|
|
7408 {
|
|
7409 v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
|
|
7410 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
|
|
7411 v21 = 2 * a8 - v21 - a7;
|
|
7412 v9 = a5;
|
|
7413 *v10 = a5->pPalette16[v21];
|
|
7414 }
|
|
7415 }
|
|
7416 }
|
|
7417 ++i;
|
|
7418 ++v10;
|
|
7419 }
|
|
7420 ++v27;
|
|
7421 v10 += this->uTargetSurfacePitch - v25;
|
|
7422 v28 += v23;
|
|
7423 }
|
|
7424 while ( v27 < v24 );
|
|
7425 }*/
|
|
7426
|
|
7427 }
|
|
7428 }
|
|
7429 }
|
|
7430 }
|
|
7431 }
|
|
7432 }
|
|
7433
|
|
7434 //----- (004A6274) --------------------------------------------------------
|
2524
|
7435 void Render::DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, Texture *pTexture)
|
2496
|
7436 {
|
|
7437 int uHeight; // ebx@4
|
|
7438 unsigned int v11; // edx@9
|
|
7439 unsigned int v12; // esi@12
|
|
7440 unsigned int v13; // esi@15
|
|
7441 unsigned int v15; // esi@18
|
|
7442 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
|
|
7443 int uWidth; // [sp+1Ch] [bp-4h]@4
|
|
7444
|
|
7445 if ( this->uNumSceneBegins )
|
|
7446 {
|
|
7447 if ( pTexture )
|
|
7448 {
|
|
7449 if ( pTexture->pPalette16 )
|
|
7450 {
|
|
7451 uHeight = pTexture->uTextureHeight;
|
|
7452 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask;
|
|
7453 uWidth = pTexture->uTextureWidth;
|
|
7454
|
|
7455 int clipped_out_x = uX;
|
|
7456 int clipped_out_y = uY;
|
|
7457 if ( this->bClip )
|
|
7458 {
|
|
7459 if ( (signed int)uX < (signed int)this->uClipX )
|
|
7460 {
|
|
7461 v19 += this->uClipX - uX;
|
|
7462 uWidth += uX - this->uClipX;
|
|
7463 clipped_out_x = uClipX;
|
|
7464 }
|
|
7465
|
|
7466 uHeight = pTexture->uTextureHeight;
|
|
7467 if ( (signed int)uY < (signed int)this->uClipY )
|
|
7468 {
|
|
7469 v19 += pTexture->uTextureWidth * (this->uClipY - uY);
|
|
7470 uHeight = uY - this->uClipY + pTexture->uTextureHeight;
|
|
7471 clipped_out_y = uClipY;
|
|
7472 }
|
|
7473 v11 = this->uClipX;
|
|
7474 if ( (signed int)this->uClipX < (signed int)uX )
|
|
7475 v11 = uX;
|
|
7476
|
|
7477 if ( (signed int)(v11 + uWidth) > (signed int)this->uClipZ )
|
|
7478 {
|
|
7479 v12 = this->uClipX;
|
|
7480 if ( (signed int)this->uClipX < (signed int)uX )
|
|
7481 v12 = uX;
|
|
7482 uWidth = this->uClipZ - v12;
|
|
7483 }
|
|
7484 v13 = this->uClipY;
|
|
7485 if ( (signed int)this->uClipY < (signed int)uY )
|
|
7486 v13 = uY;
|
|
7487
|
|
7488 if ( (signed int)(uHeight + v13) > (signed int)this->uClipW )
|
|
7489 {
|
|
7490 v15 = this->uClipY;
|
|
7491 if ( (signed int)this->uClipY < (signed int)uY )
|
|
7492 v15 = uY;
|
|
7493 uHeight = this->uClipW - v15;
|
|
7494 }
|
|
7495 }
|
|
7496
|
|
7497 for (int y = 0; y < uHeight; ++y)
|
|
7498 {
|
|
7499 for (int x = 0; x < uWidth; ++x)
|
|
7500 {
|
|
7501 if ( *v19 )
|
|
7502 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]);
|
|
7503 ++v19;
|
|
7504 }
|
|
7505 v19 += pTexture->uTextureWidth - uWidth;
|
|
7506 }
|
|
7507 /*if ( (signed int)uHeight > 0 )
|
|
7508 {
|
|
7509 uYa = uHeight;
|
|
7510 v16 = v19;
|
|
7511 do
|
|
7512 {
|
|
7513 if ( uWidth > 0 )
|
|
7514 {
|
|
7515 uXa = uWidth;
|
|
7516 do
|
|
7517 {
|
|
7518 if ( *v16 )
|
|
7519 *v6 = pCurrentTexture->pPalette16[*v16];
|
|
7520 ++v6;
|
|
7521 ++v16;
|
|
7522 }
|
|
7523 while ( uXa-- !=1 );
|
|
7524 }
|
|
7525 v16 += v18 - uWidth;
|
|
7526 uFlag = uYa-- == 1;
|
|
7527 v6 += this->uTargetSurfacePitch - uWidth;
|
|
7528 }
|
|
7529 while ( !uFlag );
|
|
7530 }*/
|
|
7531 }
|
|
7532 }
|
|
7533 }
|
|
7534 }
|
|
7535
|
|
7536 //----- (004A612A) --------------------------------------------------------
|
|
7537 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal)
|
|
7538 {
|
|
7539 unsigned int v6; // edx@3
|
|
7540 int v7; // ebx@3
|
|
7541 int v8; // edi@3
|
|
7542 int v10; // eax@5
|
|
7543 signed int v12; // esi@8
|
|
7544 signed int v14; // esi@11
|
|
7545 unsigned int v15; // esi@14
|
|
7546 unsigned int v17; // ecx@17
|
|
7547 int v18; // edx@23
|
|
7548 int v19; // [sp+Ch] [bp-Ch]@3
|
|
7549 int v20; // [sp+10h] [bp-8h]@3
|
|
7550 int uOutXa; // [sp+20h] [bp+8h]@21
|
|
7551 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3
|
|
7552 int *pZBuffer; // [sp+28h] [bp+10h]@3
|
|
7553
|
|
7554 if ( this->uNumSceneBegins )
|
|
7555 {
|
|
7556 if ( pTexture )
|
|
7557 {
|
|
7558 v6 = uOutY;
|
|
7559 v7 = pTexture->uTextureHeight;
|
|
7560 pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY];
|
|
7561 uOutYa = pTexture->pLevelOfDetail0_prolly_alpha_mask;
|
|
7562 v8 = pTexture->uTextureWidth;
|
|
7563 v20 = pTexture->uTextureWidth;
|
|
7564 v19 = pTexture->uTextureWidth;
|
|
7565 if ( this->bClip )
|
|
7566 {
|
|
7567 if ( uOutX < this->uClipX )
|
|
7568 {
|
|
7569 v10 = this->uClipX - uOutX;
|
|
7570 uOutYa += v10;
|
|
7571 v8 += uOutX - this->uClipX;
|
|
7572 v20 = v8;
|
|
7573 pZBuffer += v10;
|
|
7574 }
|
|
7575 if ( (signed int)v6 < (signed int)this->uClipY )
|
|
7576 {
|
|
7577 uOutYa += v19 * (this->uClipY - v6);
|
|
7578 v7 += v6 - this->uClipY;
|
|
7579 pZBuffer += window->GetWidth() * (this->uClipY - v6);
|
|
7580 v8 = v20;
|
|
7581 }
|
|
7582 v12 = this->uClipX;
|
|
7583 if ( this->uClipX < uOutX )
|
|
7584 v12 = uOutX;
|
|
7585 if ( v8 + v12 > (signed int)this->uClipZ )
|
|
7586 {
|
|
7587 v14 = this->uClipX;
|
|
7588 if ( this->uClipX < uOutX )
|
|
7589 v14 = uOutX;
|
|
7590 v8 = this->uClipZ - v14;
|
|
7591 }
|
|
7592 v15 = this->uClipY;
|
|
7593 if ( (signed int)this->uClipY < (signed int)v6 )
|
|
7594 v15 = v6;
|
|
7595 if ( (signed int)(v7 + v15) > (signed int)this->uClipW )
|
|
7596 {
|
|
7597 v17 = this->uClipY;
|
|
7598 if ( (signed int)this->uClipY >= (signed int)v6 )
|
|
7599 v6 = v17;
|
|
7600 v7 = this->uClipW - v6;
|
|
7601 }
|
|
7602 }
|
|
7603 if ( v7 > 0 )
|
|
7604 {
|
|
7605 uOutXa = v7;
|
|
7606 do
|
|
7607 {
|
|
7608 if ( v8 > 0 )
|
|
7609 {
|
|
7610 v18 = v8;
|
|
7611 do
|
|
7612 {
|
|
7613 if ( *uOutYa )
|
|
7614 *pZBuffer = zVal;
|
|
7615 ++pZBuffer;
|
|
7616 ++uOutYa;
|
|
7617 --v18;
|
|
7618 }
|
|
7619 while ( v18 );
|
|
7620 }
|
|
7621 pZBuffer += window->GetWidth() - v8;
|
|
7622 uOutYa += v19 - v8;
|
|
7623 --uOutXa;
|
|
7624 }
|
|
7625 while ( uOutXa );
|
|
7626 }
|
|
7627 }
|
|
7628 }
|
|
7629 }
|
|
7630
|
|
7631 //----- (004A601E) --------------------------------------------------------
|
|
7632 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5)
|
|
7633 {
|
|
7634 signed int v5; // edx@3
|
|
7635 int v6; // ebx@3
|
|
7636 int v7; // esi@3
|
|
7637 void *v8; // esi@3
|
|
7638 signed int v11; // edi@8
|
|
7639 signed int v13; // edi@11
|
|
7640 unsigned int v14; // edi@14
|
|
7641 unsigned int v16; // ecx@17
|
|
7642 int v17; // [sp+18h] [bp+Ch]@3
|
|
7643 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3
|
|
7644
|
|
7645 if ( this->uNumSceneBegins && pTexture )
|
|
7646 {
|
|
7647 v5 = a3;
|
|
7648 v6 = pTexture->uTextureHeight;
|
|
7649 v7 = 5 * a3;
|
|
7650 v17 = pTexture->uTextureHeight;
|
|
7651 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)];
|
|
7652 pTexturea = pTexture->uTextureWidth;
|
|
7653 if ( this->bClip )
|
|
7654 {
|
|
7655 if ( a2 < (signed int)this->uClipX )
|
|
7656 {
|
|
7657 pTexturea += a2 - this->uClipX;
|
|
7658 v8 = (char *)v8 + 4 * (this->uClipX - a2);
|
|
7659 }
|
|
7660 if ( v5 < (signed int)this->uClipY )
|
|
7661 {
|
|
7662 v17 += v5 - this->uClipY;
|
|
7663 v8 = (char *)v8 + 2560 * (this->uClipY - v5);
|
|
7664 }
|
|
7665 v11 = this->uClipX;
|
|
7666 if ( this->uClipX < a2 )
|
|
7667 v11 = a2;
|
|
7668 if ( (signed int)(pTexturea + v11) > (signed int)this->uClipZ )
|
|
7669 {
|
|
7670 v13 = this->uClipX;
|
|
7671 if ( this->uClipX < a2 )
|
|
7672 v13 = a2;
|
|
7673 pTexturea = this->uClipZ - v13;
|
|
7674 }
|
|
7675 v14 = this->uClipY;
|
|
7676 if ( (signed int)this->uClipY < v5 )
|
|
7677 v14 = v5;
|
|
7678 v6 = v17;
|
|
7679 if ( (signed int)(v17 + v14) > (signed int)this->uClipW )
|
|
7680 {
|
|
7681 v16 = this->uClipY;
|
|
7682 if ( (signed int)this->uClipY < v5 )
|
|
7683 v16 = v5;
|
|
7684 v6 = this->uClipW - v16;
|
|
7685 }
|
|
7686 }
|
|
7687 if ( v6 > 0 )
|
|
7688 {
|
|
7689 do
|
|
7690 {
|
|
7691 if ( (signed int)pTexturea > 0 )
|
|
7692 {
|
|
7693 memset32(v8, a5, pTexturea);
|
|
7694 v8 = (char *)v8 + 4 * pTexturea;
|
|
7695 }
|
|
7696 v8 = (char *)v8 + 4 * (window->GetWidth() - pTexturea);
|
|
7697 --v6;
|
|
7698 }
|
|
7699 while ( v6 );
|
|
7700 }
|
|
7701 }
|
|
7702 }
|
|
7703
|
|
7704 //----- (004A5EB2) --------------------------------------------------------
|
2536
|
7705 void Render::DrawTextureIndexed(signed int x, signed int y, Texture *tex)
|
2496
|
7706 {
|
|
7707 int v5; // ebx@4
|
|
7708 unsigned int v8; // edx@6
|
|
7709 unsigned int v10; // edx@8
|
|
7710 unsigned int v11; // edx@9
|
|
7711 unsigned int v12; // esi@12
|
|
7712 unsigned int v13; // esi@15
|
|
7713 unsigned int v15; // esi@18
|
|
7714 int v18; // [sp+10h] [bp-10h]@4
|
|
7715 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
|
|
7716 int v20; // [sp+1Ch] [bp-4h]@4
|
|
7717
|
|
7718 if ( this->uNumSceneBegins )
|
|
7719 {
|
2536
|
7720 if ( tex )
|
|
7721 {
|
|
7722 if ( tex->pPalette16 )
|
|
7723 {
|
|
7724 v5 = tex->uTextureHeight;
|
2496
|
7725 //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch];
|
2536
|
7726 v19 = tex->pLevelOfDetail0_prolly_alpha_mask;
|
|
7727 v20 = tex->uTextureWidth;
|
|
7728 v18 = tex->uTextureWidth;
|
|
7729
|
|
7730 int clipped_out_x = x;
|
|
7731 int clipped_out_y = y;
|
2496
|
7732 if ( this->bClip )
|
|
7733 {
|
2536
|
7734 if ( (signed int)x < (signed int)this->uClipX )
|
2496
|
7735 {
|
2536
|
7736 v8 = this->uClipX - x;
|
2496
|
7737 v19 += v8;
|
2536
|
7738 v20 += x - this->uClipX;
|
2496
|
7739 clipped_out_x = uClipX;
|
|
7740 }
|
|
7741
|
2536
|
7742 v5 = tex->uTextureHeight;
|
|
7743 if ( (signed int)y < (signed int)this->uClipY )
|
2496
|
7744 {
|
2536
|
7745 v10 = this->uClipY - y;
|
2496
|
7746 v19 += v18 * v10;
|
2536
|
7747 v5 = y - this->uClipY + tex->uTextureHeight;
|
2496
|
7748 //v4 = a4;
|
|
7749 clipped_out_y = uClipY;
|
|
7750 }
|
|
7751
|
|
7752 v11 = this->uClipX;
|
2536
|
7753 if ( (signed int)this->uClipX < (signed int)x )
|
|
7754 v11 = x;
|
2496
|
7755
|
|
7756 if ( (signed int)(v11 + v20) > (signed int)this->uClipZ )
|
|
7757 {
|
|
7758 v12 = this->uClipX;
|
2536
|
7759 if ( (signed int)this->uClipX < (signed int)x )
|
|
7760 v12 = x;
|
2496
|
7761 v20 = this->uClipZ - v12;
|
|
7762 }
|
|
7763
|
|
7764 v13 = this->uClipY;
|
2536
|
7765 if ( (signed int)this->uClipY < (signed int)y )
|
|
7766 v13 = y;
|
2496
|
7767
|
|
7768 if ( (signed int)(v5 + v13) > (signed int)uClipW )
|
|
7769 {
|
|
7770 v15 = this->uClipY;
|
2536
|
7771 if ( (signed int)this->uClipY < (signed int)y )
|
|
7772 v15 = y;
|
2496
|
7773 v5 = uClipW - v15;
|
|
7774 }
|
|
7775 }
|
|
7776
|
|
7777 for (int y = 0; y < v5; ++y)
|
|
7778 {
|
|
7779 for (int x = 0; x < v20; ++x)
|
|
7780 {
|
2536
|
7781 if ( tex->pPalette16[*v19] != 0x7FF )// 2047
|
|
7782 WritePixel16(clipped_out_x + x, clipped_out_y + y, tex->pPalette16[*v19]);
|
2496
|
7783 ++v19;
|
|
7784 }
|
|
7785 v19 += v18 - v20;
|
|
7786 }
|
|
7787 /*if ( (signed int)v5 > 0 )
|
|
7788 {
|
|
7789 uYa = v5;
|
|
7790 v16 = v19;
|
|
7791 do
|
|
7792 {
|
|
7793 if ( v20 > 0 )
|
|
7794 {
|
|
7795 uXa = v20;
|
|
7796 do
|
|
7797 {
|
|
7798 *pTarget = v4->pPalette16[*v16];
|
|
7799 ++pTarget;
|
|
7800 ++v16;
|
|
7801 --uXa;
|
|
7802 }
|
|
7803 while ( uXa );
|
|
7804 }
|
|
7805 v16 += v18 - v20;
|
|
7806 v17 = uYa-- == 1;
|
|
7807 pTarget += this->uTargetSurfacePitch - v20;
|
|
7808 }
|
|
7809 while ( !v17 );
|
|
7810 }*/
|
|
7811 }
|
|
7812 }
|
|
7813 }
|
|
7814 }
|
|
7815
|
|
7816 //----- (004667E9) --------------------------------------------------------
|
|
7817 void Render::ChangeBetweenWinFullscreenModes()
|
|
7818 {
|
|
7819 float v0; // ST14_4@17
|
|
7820 int v4; // edx@26
|
|
7821 ObjectDesc *v5; // eax@26
|
|
7822 RGBTexture *v6; // esi@33
|
|
7823 const char *v8; // [sp-4h] [bp-28h]@33
|
|
7824 // struct tagRECT Rect; // [sp+14h] [bp-10h]@15
|
|
7825
|
|
7826 /*if ( !pRenderer->bWindowMode && (dword_6BE364_game_settings_1 & 2) )
|
|
7827 {
|
|
7828 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."
|
|
7829 return;
|
|
7830 }*/
|
|
7831 if ( bWindowMode || pRenderD3D->pAvailableDevices->bIsDeviceCompatible )
|
|
7832 {
|
|
7833 if ( pEventTimer->bPaused )
|
|
7834 dword_6BE364_game_settings_1 |= GAME_SETTINGS_0800;
|
|
7835 else
|
|
7836 pEventTimer->Pause();
|
|
7837 if ( pMiscTimer->bPaused )
|
|
7838 dword_6BE364_game_settings_1 |= GAME_SETTINGS_1000;
|
|
7839 else
|
|
7840 pMiscTimer->Pause();
|
|
7841 pMouse->bActive = 0;
|
|
7842 if ( pRenderD3D )
|
|
7843 {
|
|
7844 pBitmaps_LOD->ReleaseHardwareTextures();
|
|
7845 pSprites_LOD->ReleaseAll();
|
|
7846 }
|
|
7847 if ( bWindowMode )
|
|
7848 {
|
|
7849 //SetMenu(hWnd, 0);
|
|
7850 //SetWindowLongA(hWnd, -20, 0);
|
|
7851 //SetWindowLongA(hWnd, -16, 0x10000000u);
|
|
7852 window->SetFullscreenMode();
|
|
7853 pRenderer->InitializeFullscreen();
|
|
7854 }
|
|
7855 else
|
|
7856 {
|
|
7857 //ClipCursor(0);
|
|
7858 window->SetWindowedMode(window->GetWidth(), window->GetHeight());
|
|
7859 pRenderer->SwitchToWindow();
|
|
7860 }
|
|
7861 if ( pRenderD3D )
|
|
7862 {
|
|
7863 pBitmaps_LOD->_410423_move_textures_to_device();
|
|
7864 pSprites_LOD->MoveSpritesToVideoMemory();
|
|
7865 }
|
|
7866 if (!( pPaletteManager->uNumTargetBBits == uTargetBBits
|
|
7867 && pPaletteManager->uNumTargetGBits == uTargetGBits
|
|
7868 && pPaletteManager->uNumTargetRBits == uTargetRBits ))
|
|
7869 {
|
|
7870 pPaletteManager->SetColorChannelInfo(uTargetRBits, uTargetGBits, uTargetBBits);
|
|
7871 pPaletteManager->RecalculateAll();
|
|
7872 pBitmaps_LOD->SetupPalettes(uTargetRBits, uTargetGBits, uTargetBBits);
|
|
7873 pIcons_LOD->SetupPalettes(uTargetRBits, uTargetGBits, uTargetBBits);
|
|
7874 for (uint i = 0; i < pObjectList->uNumObjects; i++)
|
|
7875 {
|
|
7876 BYTE3(v4) = 0;
|
|
7877 v5 = &pObjectList->pObjects[i];
|
|
7878 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR;
|
|
7879 LOBYTE(v4) = v5->uParticleTrailColorG;
|
|
7880 v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8);
|
|
7881 }
|
|
7882 SetUserInterface(pParty->alignment, true);
|
|
7883 if ( pMediaPlayer->pVideoFrame.pPixels )
|
|
7884 pMediaPlayer->pVideoFrame.Load(pMediaPlayer->pVideoFrameTextureFilename, 1);
|
|
7885 if ( sCurrentMenuID != MENU_CREATEPARTY )
|
|
7886 {
|
|
7887 if ( sCurrentMenuID == MENU_CREDITSPROC )
|
|
7888 dword_A74C88 = 1;
|
|
7889 }
|
|
7890 else
|
|
7891 {
|
|
7892 if ( sCurrentMenuID )
|
|
7893 {
|
|
7894 v6 = &pTexture_PCX;
|
|
7895 pTexture_PCX.Release();
|
|
7896 v8 = "makeme.pcx";
|
|
7897 }
|
|
7898 else
|
|
7899 {
|
|
7900 v6 = &pTexture_PCX;
|
|
7901 pTexture_PCX.Release();
|
|
7902 v8 = "title.pcx";
|
|
7903 if ( sCurrentMenuID )
|
|
7904 v8 = "lsave640.pcx";
|
|
7905 }
|
|
7906 v6->Load(v8, 0);
|
|
7907 }
|
|
7908 }
|
|
7909 viewparams->bRedrawGameUI = 1;
|
|
7910 viewparams->InitGrayPalette();
|
|
7911 pMouse->SetCurrentCursorBitmap();
|
|
7912 /*if ( pRenderer->bWindowMode )
|
|
7913 {
|
|
7914 //MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0);
|
|
7915 CenterWindowAndAdjustSize(hWnd, windowed_mode_width, windowed_mode_height);
|
|
7916 ShowWindow(hWnd, SW_SHOWNORMAL);
|
|
7917 }*/
|
|
7918 pMouse->bActive = true;
|
|
7919 if ( pMovie_Track )
|
|
7920 pMediaPlayer->SelectMovieType();
|
|
7921 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0800)
|
|
7922 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0800;
|
|
7923 else
|
|
7924 pEventTimer->Resume();
|
|
7925 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_1000)
|
|
7926 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_1000;
|
|
7927 else
|
|
7928 pMiscTimer->Resume();
|
|
7929 }
|
|
7930 }
|
|
7931
|
|
7932
|
|
7933 //----- (004524D8) --------------------------------------------------------
|
|
7934 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps)
|
|
7935 {
|
|
7936 void *v13; // eax@13
|
|
7937 int v16; // esi@14
|
|
7938 int v17; // ecx@16
|
|
7939 int v18; // esi@16
|
|
7940 unsigned __int16 *v19; // eax@16
|
|
7941 int v20; // edx@16
|
|
7942 int v21; // ecx@16
|
|
7943 int v22; // eax@16
|
|
7944 int v23; // esi@16
|
|
7945 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13
|
|
7946 int v27; // [sp+28h] [bp-Ch]@14
|
|
7947 int v28; // [sp+2Ch] [bp-8h]@13
|
|
7948 int pDestb; // [sp+3Ch] [bp+8h]@15
|
|
7949
|
|
7950 if (!uNumItems)
|
|
7951 return nullptr;
|
|
7952
|
|
7953 ///////////////////////////////
|
|
7954 //quick search(áûñòðûé ïîèñê)//
|
|
7955 ///////////////////////////////
|
|
7956 uint idx1 = 0,
|
|
7957 idx2 = uNumItems;
|
|
7958 while (true)
|
|
7959 {
|
|
7960 uint i = idx1 + (idx2 - idx1) / 2;
|
|
7961
|
|
7962 int res = _stricmp(pName, pSpriteNames[i]);
|
|
7963 if (!res)
|
|
7964 {
|
|
7965 fseek(pFile, pSpriteOffsets[i], SEEK_SET);
|
|
7966 break;
|
|
7967 }
|
|
7968 else if (res < 0)
|
|
7969 idx2 = idx1 + (idx2 - idx1) / 2;
|
|
7970 else
|
|
7971 idx1 = i + 1;
|
|
7972
|
|
7973 if ( idx1 >= idx2 )
|
|
7974 return false;
|
|
7975 }
|
|
7976
|
|
7977 uint uCompressedSize = 0;
|
|
7978 fread(&uCompressedSize, 4, 1, pFile);
|
|
7979
|
|
7980 HWLTexture* pTex = new HWLTexture;
|
|
7981 fread(&pTex->uBufferWidth, 4, 1, pFile);
|
|
7982 fread(&pTex->uBufferHeight, 4, 1, pFile);
|
|
7983 fread(&pTex->uAreaWidth, 4, 1, pFile);
|
|
7984 fread(&pTex->uAreaHeigth, 4, 1, pFile);
|
|
7985 fread(&pTex->uWidth, 4, 1, pFile);
|
|
7986 fread(&pTex->uHeight, 4, 1, pFile);
|
|
7987 fread(&pTex->uAreaX, 4, 1, pFile);
|
|
7988 fread(&pTex->uAreaY, 4, 1, pFile);
|
|
7989
|
|
7990 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight];
|
|
7991 if (uCompressedSize)
|
|
7992 {
|
|
7993 char* pCompressedData = new char[uCompressedSize];
|
|
7994 fread(pCompressedData, 1, uCompressedSize, pFile);
|
|
7995 uint uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short);
|
|
7996 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize);
|
|
7997 delete [] pCompressedData;
|
|
7998 }
|
|
7999 else
|
|
8000 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile);
|
|
8001
|
|
8002 if ( scale_hwls_to_half )
|
|
8003 {
|
|
8004 __debugbreak();//Ritor1
|
|
8005 pTex->uHeight /= 2;
|
|
8006 pTex->uWidth /= 2;
|
|
8007 v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight];
|
|
8008 v28 = 0;
|
|
8009 v26 = (unsigned __int16 *)v13;
|
|
8010 if ( pTex->uHeight > 0 )
|
|
8011 {
|
|
8012 v16 = pTex->uWidth;
|
|
8013 v27 = 1;
|
|
8014 do
|
|
8015 {
|
|
8016 pDestb = 0;
|
|
8017 if ( v16 > 0 )
|
|
8018 {
|
|
8019 do
|
|
8020 {
|
|
8021 v17 = v16 * v27;
|
|
8022 v18 = v28 * v16;
|
|
8023 v19 = pTex->pPixels;
|
|
8024 v20 = pDestb + 2 * v18;
|
|
8025 v21 = (int)&v19[2 * (pDestb + v17)];
|
|
8026 v22 = (int)&v19[2 * v20];
|
|
8027 LOWORD(v20) = *(unsigned short *)(v21 + 2);
|
|
8028 LOWORD(v21) = *(unsigned short *)v21;
|
|
8029 v23 = pDestb + v18;
|
|
8030 pDestb++;
|
|
8031
|
|
8032 v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20);
|
|
8033 v16 = pTex->uWidth;
|
|
8034 }
|
|
8035 while (pDestb < pTex->uWidth);
|
|
8036 }
|
|
8037 ++v28;
|
|
8038 v27 += 2;
|
|
8039 }
|
|
8040 while ( v28 < (signed int)pTex->uHeight );
|
|
8041 }
|
|
8042 delete [] pTex->pPixels;
|
|
8043 pTex->pPixels = v26;
|
|
8044 }
|
|
8045 return pTex;
|
|
8046 }
|
|
8047 //----- (0045271F) --------------------------------------------------------
|
|
8048 bool RenderHWLContainer::Release()
|
|
8049 {
|
|
8050 __int32 v4; // eax@6
|
|
8051 FILE *v5; // ST24_4@6
|
|
8052 FILE *File; // [sp+4h] [bp-4h]@6
|
|
8053
|
|
8054 if ( this->bDumpDebug)
|
|
8055 {
|
|
8056 File = fopen("logd3d.txt", "w");
|
|
8057 v4 = ftell(this->pFile);
|
|
8058 v5 = this->pFile;
|
|
8059 this->uDataOffset = v4;
|
|
8060 fwrite(&this->uNumItems, 4u, 1u, v5);
|
|
8061 for (uint i = 0; i < this->uNumItems; i++)
|
|
8062 {
|
|
8063 fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile);
|
|
8064 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*)));
|
|
8065 }
|
|
8066 fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile);
|
|
8067 fseek(this->pFile, 4, 0);
|
|
8068 fwrite(&this->uDataOffset, 4u, 1u, this->pFile);
|
|
8069 fclose(this->pFile);
|
|
8070 fclose(File);
|
|
8071 }
|
|
8072 else
|
|
8073 {
|
|
8074 fclose(this->pFile);
|
|
8075 for (uint i = 0; i < this->uNumItems; i++)
|
|
8076 {
|
|
8077 delete[] this->pSpriteNames[i];
|
|
8078 }
|
|
8079 }
|
|
8080 return true;
|
|
8081 }
|
|
8082
|
|
8083 //----- (00452347) --------------------------------------------------------
|
|
8084 RenderHWLContainer::RenderHWLContainer():
|
|
8085 bDumpDebug(false)
|
|
8086 {
|
|
8087 this->pFile = 0;
|
|
8088 uSignature = 0;
|
|
8089 this->uDataOffset = 0;
|
|
8090 memset(&this->uNumItems, 0, 0x61A84u);
|
|
8091 this->uNumItems = 0;
|
|
8092 this->scale_hwls_to_half = false;
|
|
8093 }
|
|
8094
|
|
8095 //----- (0045237F) --------------------------------------------------------
|
|
8096 bool RenderHWLContainer::Load(const wchar_t *pFilename)
|
|
8097 {
|
|
8098 pFile = _wfopen(pFilename, L"rb");
|
|
8099 if (!pFile)
|
|
8100 {
|
|
8101 Log::Warning(L"Failed to open file: %s", pFilename);
|
|
8102 return false;
|
|
8103 }
|
|
8104
|
|
8105 fread(&uSignature, 1, 4, pFile);
|
|
8106 if (uSignature != 'TD3D')
|
|
8107 {
|
|
8108 Log::Warning(L"Invalid format: %s", pFilename);
|
|
8109 return false;
|
|
8110 }
|
|
8111
|
|
8112 fread(&uDataOffset, 4, 1, pFile);
|
|
8113 fseek(pFile, uDataOffset, SEEK_SET);
|
|
8114 fread(&uNumItems, 4, 1, pFile);
|
|
8115
|
|
8116 memset(pSpriteNames, 0, 50000 * sizeof(char *));
|
|
8117 for (uint i = 0; i < uNumItems; ++i)
|
|
8118 {
|
|
8119 pSpriteNames[i] = new char[20];
|
|
8120 fread(pSpriteNames[i], 1, 20, pFile);
|
|
8121 }
|
|
8122 fread(pSpriteOffsets, 4, uNumItems, pFile);
|
|
8123
|
|
8124 return true;
|
|
8125 }
|
|
8126
|
|
8127 //----- (004A1C1E) --------------------------------------------------------
|
|
8128 void Render::DoRenderBillboards_D3D()
|
|
8129 {
|
|
8130 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
|
|
8131 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
8132 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
8133 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
8134
|
|
8135 /*if (pRenderer->uNumBillboardsToDraw)
|
|
8136 {
|
|
8137 auto p = &pRenderer->pBillboardRenderListD3D[0];
|
|
8138 for (int i = 0; i < p->uNumVertices; ++i)
|
|
8139 {
|
|
8140 p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6;
|
|
8141 //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw);
|
|
8142 }
|
|
8143 p->pQuads[0].pos.x = 10;
|
|
8144 p->pQuads[0].pos.y = 10;
|
|
8145
|
|
8146 p->pQuads[1].pos.x = 10;
|
|
8147 p->pQuads[1].pos.y = 200;
|
|
8148
|
|
8149 p->pQuads[2].pos.x = 100;
|
|
8150 p->pQuads[2].pos.y = 200;
|
|
8151
|
|
8152 p->pQuads[3].pos.x = 100;
|
|
8153 p->pQuads[3].pos.y = 10;
|
|
8154
|
|
8155 if (p->uOpacity != RenderBillboardD3D::NoBlend)
|
|
8156 SetBillboardBlendOptions(p->uOpacity);
|
|
8157
|
|
8158 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture);
|
|
8159 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
8160 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
8161 p->pQuads, p->uNumVertices,
|
|
8162 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS));
|
|
8163
|
|
8164 }*/
|
|
8165
|
|
8166 for (int i = uNumBillboardsToDraw - 1; i >= 0; --i)
|
|
8167 {
|
|
8168 if (pBillboardRenderListD3D[i].opacity != RenderBillboardD3D::NoBlend)
|
|
8169 SetBillboardBlendOptions(pBillboardRenderListD3D[i].opacity);
|
|
8170
|
|
8171 pRenderD3D->pDevice->SetTexture(0, pBillboardRenderListD3D[i].pTexture);
|
|
8172 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
8173 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
8174 pBillboardRenderListD3D[i].pQuads, pBillboardRenderListD3D[i].uNumVertices,
|
|
8175 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS));
|
|
8176 }
|
|
8177
|
|
8178 if (bFogEnabled)
|
|
8179 {
|
|
8180 bFogEnabled = false;
|
|
8181 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
8182 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF));
|
|
8183 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
|
|
8184 }
|
|
8185 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
|
|
8186 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
8187 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
8188 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8189 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
8190 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
8191 }
|
|
8192
|
|
8193 //----- (004A1DA8) --------------------------------------------------------
|
|
8194 void Render::SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1)
|
|
8195 {
|
|
8196 switch (a1)
|
|
8197 {
|
|
8198 case RenderBillboardD3D::Transparent:
|
|
8199 {
|
|
8200 if (bFogEnabled)
|
|
8201 {
|
|
8202 bFogEnabled = false;
|
|
8203 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
8204 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF));
|
|
8205 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
|
|
8206 }
|
|
8207
|
|
8208 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA));
|
|
8209 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA));
|
|
8210 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
8211 }
|
|
8212 break;
|
|
8213
|
|
8214 case RenderBillboardD3D::Opaque_1:
|
|
8215 case RenderBillboardD3D::Opaque_2:
|
|
8216 case RenderBillboardD3D::Opaque_3:
|
|
8217 {
|
|
8218 if (bUsingSpecular)
|
|
8219 {
|
|
8220 if (!bFogEnabled)
|
|
8221 {
|
|
8222 bFogEnabled = true;
|
|
8223 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
8224 }
|
|
8225 }
|
|
8226
|
|
8227 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8228 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
|
|
8229 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
8230 }
|
|
8231 break;
|
|
8232
|
|
8233 default:
|
|
8234 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1);
|
|
8235 assert(false);
|
|
8236 break;
|
|
8237 }
|
|
8238 }
|
|
8239 //----- (00424CD7) --------------------------------------------------------
|
|
8240 int ODM_NearClip(unsigned int num_vertices)
|
|
8241 {
|
|
8242 bool current_vertices_flag; // edi@1
|
|
8243 bool next_vertices_flag; // [sp+Ch] [bp-24h]@6
|
|
8244 double t; // st6@10
|
|
8245 bool bFound;
|
|
8246
|
|
8247 bFound = false;
|
|
8248
|
|
8249 if (!num_vertices)
|
|
8250 return 0;
|
|
8251 for (uint i = 0; i < num_vertices; ++i)// åñòü ëè ïîãðàíè÷íûå âåðøèíû
|
|
8252 {
|
|
8253 if ( array_50AC10[i].vWorldViewPosition.x > 8.0 )
|
|
8254 {
|
|
8255 bFound = true;
|
|
8256 break;
|
|
8257 }
|
|
8258 }
|
|
8259 if ( !bFound )
|
|
8260 return 0;
|
|
8261
|
|
8262 memcpy(&array_50AC10[num_vertices], &array_50AC10[0], sizeof(array_50AC10[0]));
|
|
8263 current_vertices_flag = false;
|
|
8264 next_vertices_flag = false;
|
|
8265 if ( array_50AC10[0].vWorldViewPosition.x <= 8.0 )
|
|
8266 current_vertices_flag = true;
|
|
8267 //check for near clip plane(ïðîâåðêà ïî áëèæíåé ãðàíèöå)
|
|
8268 //
|
|
8269 // v3.__________________. v0
|
|
8270 // | |
|
|
8271 // | |
|
|
8272 // | |
|
|
8273 // ----------------------- 8.0(near_clip - 8.0)
|
|
8274 // | |
|
|
8275 // .__________________.
|
|
8276 // v2 v1
|
|
8277
|
|
8278 int out_num_vertices = 0;
|
|
8279 for (uint i = 0; i < num_vertices; ++i)
|
|
8280 {
|
|
8281 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x <= 8.0;//
|
|
8282 if ( current_vertices_flag ^ next_vertices_flag )
|
|
8283 {
|
|
8284 if ( next_vertices_flag )//ñëåäóþùàÿ âåðøèíà çà áëèæíåé ãðàíèöåé
|
|
8285 {
|
|
8286 //t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ)
|
|
8287 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x);
|
|
8288 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0;
|
|
8289 array_507D30[out_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t;
|
|
8290 array_507D30[out_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t;
|
|
8291 array_507D30[out_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t;
|
|
8292 array_507D30[out_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t;
|
|
8293 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0;
|
|
8294 }
|
|
8295 else// òåêóùàÿ âåðøèíà çà áëèæíåé ãðàíèöåé
|
|
8296 {
|
|
8297 t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x);
|
|
8298 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0;
|
|
8299 array_507D30[out_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t;
|
|
8300 array_507D30[out_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t;
|
|
8301 array_507D30[out_num_vertices].u = array_50AC10[i].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t;
|
|
8302 array_507D30[out_num_vertices].v = array_50AC10[i].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t;
|
|
8303 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0;
|
|
8304 }
|
|
8305 //array_507D30[out_num_vertices]._rhw = 0x3E000000u;
|
|
8306 ++out_num_vertices;
|
|
8307 }
|
|
8308 if ( !next_vertices_flag )
|
|
8309 {
|
|
8310 memcpy(&array_507D30[out_num_vertices], &array_50AC10[i + 1], sizeof(array_50AC10[i + 1]));
|
|
8311 out_num_vertices++;
|
|
8312 }
|
|
8313 current_vertices_flag = next_vertices_flag;
|
|
8314 }
|
|
8315 return out_num_vertices >= 3 ? out_num_vertices : 0;
|
|
8316 }
|
|
8317
|
|
8318 //----- (00424EE0) --------------------------------------------------------
|
|
8319 int ODM_FarClip(unsigned int uNumVertices)
|
|
8320 {
|
|
8321 bool current_vertices_flag; // [sp+Ch] [bp-28h]@6
|
|
8322 bool next_vertices_flag; // edi@1
|
|
8323 double t; // st6@10
|
|
8324 signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1
|
|
8325 bool bFound;
|
|
8326 //Äîï èíôî "Ïðîãðàììèðîâàíèå òð¸õìåðíûõ èãð äëÿ windows" Ëàìîò ñòð 910
|
|
8327
|
|
8328 bFound = false;
|
|
8329
|
|
8330 memcpy(&array_50AC10[uNumVertices], &array_50AC10[0], sizeof(array_50AC10[uNumVertices]));
|
|
8331 depth_num_vertices = 0;
|
|
8332 current_vertices_flag = false;
|
|
8333 if ( array_50AC10[0].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist )
|
|
8334 current_vertices_flag = true;//íàñòîÿùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè
|
|
8335 if ( (signed int)uNumVertices <= 0 )
|
|
8336 return 0;
|
|
8337 for (uint i = 0; i < uNumVertices; ++i)// åñòü ëè ïîãðàíè÷íûå âåðøèíû
|
|
8338 {
|
|
8339 if ( array_50AC10[i].vWorldViewPosition.x < pODMRenderParams->shading_dist_mist )
|
|
8340 {
|
|
8341 bFound = true;
|
|
8342 break;
|
|
8343 }
|
|
8344 }
|
|
8345 if ( !bFound )
|
|
8346 return 0;
|
|
8347 //check for far clip plane(ïðîâåðêà ïî äàëüíåé ãðàíèöå)
|
|
8348 //
|
|
8349 // v3.__________________. v0
|
|
8350 // | |
|
|
8351 // | |
|
|
8352 // | |
|
|
8353 // ----------------------- 8192.0(far_clip - 0x2000)
|
|
8354 // | |
|
|
8355 // .__________________.
|
|
8356 // v2 v1
|
|
8357
|
|
8358 for ( uint i = 0; i < uNumVertices; ++i )
|
|
8359 {
|
|
8360 next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist;
|
|
8361 if ( current_vertices_flag ^ next_vertices_flag )//îäíà èç ãðàíåé çà ãðàíèöåé âèäèìîñòè
|
|
8362 {
|
|
8363 if ( next_vertices_flag )//ñëåäóþùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè(íàñòîÿùàÿ âåðøèíà ìåíüøå ãðàíèöû âèäèìîñòè) - v3
|
|
8364 {
|
|
8365 //t = far_clip - v2.x / v3.x - v2.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ)
|
|
8366 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x);
|
|
8367 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist;
|
|
8368 //New_y = v2.y + (v3.y - v2.y)*t
|
|
8369 array_507D30[depth_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t;
|
|
8370 //New_z = v2.z + (v3.z - v2.z)*t
|
|
8371 array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t;
|
|
8372 array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t;
|
|
8373 array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t;
|
|
8374 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist;
|
|
8375 }
|
|
8376 else//íàñòîÿùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè(ñëåäóþùàÿ âåðøèíà ìåíüøå ãðàíèöû âèäèìîñòè) - v0
|
|
8377 {
|
|
8378 //t = far_clip - v1.x / v0.x - v1.x
|
|
8379 t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x);
|
|
8380 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist;
|
|
8381 //New_y = (v0.y - v1.y)*t + v1.y
|
|
8382 array_507D30[depth_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t;
|
|
8383 //New_z = (v0.z - v1.z)*t + v1.z
|
|
8384 array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t;
|
|
8385 array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t;
|
|
8386 array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t;
|
|
8387 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist;
|
|
8388 }
|
|
8389 ++depth_num_vertices;
|
|
8390 }
|
|
8391 if ( !next_vertices_flag )//îáà â ãðàíèöå âèäèìîñòè
|
|
8392 {
|
|
8393 memcpy(&array_507D30[depth_num_vertices], &array_50AC10[i + 1], sizeof(array_507D30[depth_num_vertices]));
|
|
8394 depth_num_vertices++;
|
|
8395 }
|
|
8396 current_vertices_flag = next_vertices_flag;
|
|
8397 }
|
|
8398 return depth_num_vertices >= 3 ? depth_num_vertices : 0;
|
|
8399 }
|
|
8400
|
|
8401 //----- (0047840D) --------------------------------------------------------
|
|
8402 void Render::DrawBuildingsD3D()
|
|
8403 {
|
|
8404 int v9; // ecx@8
|
|
8405 Texture *pFaceTexture; // eax@10
|
|
8406 unsigned int v16; // edi@22
|
|
8407 int v27; // eax@57
|
|
8408 // int vertex_id; // eax@58
|
|
8409 unsigned int v34; // eax@80
|
|
8410 int v40; // [sp-4h] [bp-5Ch]@2
|
|
8411 int v49; // [sp+2Ch] [bp-2Ch]@10
|
|
8412 int v50; // [sp+30h] [bp-28h]@34
|
|
8413 int v51; // [sp+34h] [bp-24h]@35
|
|
8414 int v52; // [sp+38h] [bp-20h]@36
|
|
8415 int v53; // [sp+3Ch] [bp-1Ch]@8
|
|
8416 int uNumVertices; // [sp+4Ch] [bp-Ch]@34
|
|
8417 int unused; // [sp+50h] [bp-8h]@3
|
|
8418
|
|
8419 if ( !pRenderD3D )
|
|
8420 {
|
|
8421 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0);
|
|
8422 }
|
|
8423
|
|
8424 unused = 0;
|
|
8425 if ( (signed int)pOutdoor->uNumBModels > 0 )
|
|
8426 {
|
|
8427 for ( uint model_id = 0; model_id < (unsigned int)pOutdoor->uNumBModels; model_id++ )
|
|
8428 {
|
|
8429 if ( IsBModelVisible(model_id, &unused) )
|
|
8430 {
|
|
8431 pOutdoor->pBModels[model_id].field_40 |= 1;
|
|
8432 if ( pOutdoor->pBModels[model_id].uNumFaces > 0 )
|
|
8433 {
|
|
8434 for ( int face_id = 0; face_id < pOutdoor->pBModels[model_id].uNumFaces; face_id++ )
|
|
8435 {
|
|
8436 if (!pOutdoor->pBModels[model_id].pFaces[face_id].Invisible())
|
|
8437 {
|
|
8438 v53 = 0;
|
|
8439 array_77EC08[pODMRenderParams->uNumPolygons].flags = 0;
|
|
8440 array_77EC08[pODMRenderParams->uNumPolygons].field_32 = 0;
|
|
8441 v9 = pOutdoor->pBModels[model_id].pFaces[face_id].uTextureID;
|
|
8442 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_TEXTURE_FRAME)
|
|
8443 v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed);
|
|
8444 pFaceTexture = pBitmaps_LOD->GetTexture(v9);
|
|
8445 array_77EC08[pODMRenderParams->uNumPolygons].pTexture = pFaceTexture;
|
|
8446 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLUID)
|
|
8447 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 2;
|
|
8448 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_INDOOR_SKY )
|
|
8449 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4;
|
|
8450 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLOW_DIAGONAL )
|
|
8451 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4;
|
|
8452 else
|
|
8453 {
|
|
8454 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLOW_VERTICAL )
|
|
8455 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 8;
|
|
8456 }
|
|
8457 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLOW_HORIZONTAL)
|
|
8458 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 0x2000;
|
|
8459 else
|
|
8460 {
|
|
8461 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_DONT_CACHE_TEXTURE)
|
|
8462 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 0x10;
|
|
8463 }
|
|
8464 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaU;
|
|
8465 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaV;
|
|
8466 v16 = GetTickCount() >> 4;
|
|
8467 if ( pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z && abs(pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >= 59082 )
|
|
8468 {
|
|
8469 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 )
|
|
8470 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1;
|
|
8471 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 )
|
|
8472 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1;
|
|
8473 }
|
|
8474 else
|
|
8475 {
|
|
8476 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 )
|
|
8477 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1;
|
|
8478 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 )
|
|
8479 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1;
|
|
8480 }
|
|
8481 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x10 )
|
|
8482 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1;
|
|
8483 else
|
|
8484 {
|
|
8485 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x20 )
|
|
8486 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1;
|
|
8487 }
|
|
8488 v50 = 0;
|
|
8489 v49 = 0;
|
|
8490 uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices;
|
|
8491 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices > 0 )
|
|
8492 {
|
|
8493 for ( uint vertex_id = 1; vertex_id <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; vertex_id++ )
|
|
8494 {
|
|
8495 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;
|
|
8496 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;
|
|
8497 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;
|
|
8498 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);
|
|
8499 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);
|
|
8500 }
|
|
8501 for ( uint i = 1; i <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; i++ )
|
|
8502 {
|
|
8503 if ( pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[0]].z == array_73D150[i - 1].vWorldPosition.z )
|
|
8504 ++v53;
|
|
8505 pGame->pIndoorCameraD3D->ViewTransform(&array_73D150[i - 1], 1);
|
|
8506 if ( array_73D150[i - 1].vWorldViewPosition.x < 8.0 || array_73D150[i - 1].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist )
|
|
8507 {
|
|
8508 if ( array_73D150[i - 1].vWorldViewPosition.x >= 8.0 )
|
|
8509 v49 = 1;
|
|
8510 else
|
|
8511 v50 = 1;
|
|
8512 }
|
|
8513 else
|
|
8514 pGame->pIndoorCameraD3D->Project(&array_73D150[i - 1], 1, 0);
|
|
8515 }
|
|
8516 }
|
|
8517 if ( v53 == pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices )
|
|
8518 LOBYTE(array_77EC08[pODMRenderParams->uNumPolygons].field_32) |= 1;
|
|
8519 array_77EC08[pODMRenderParams->uNumPolygons].pODMFace = &pOutdoor->pBModels[model_id].pFaces[face_id];
|
|
8520 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices;
|
|
8521 array_77EC08[pODMRenderParams->uNumPolygons].field_59 = 5;
|
|
8522 v51 = fixpoint_mul(-pOutdoor->vSunlight.x, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.x);
|
|
8523 v53 = fixpoint_mul(-pOutdoor->vSunlight.y, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.y);
|
|
8524 v52 = fixpoint_mul(-pOutdoor->vSunlight.z, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z);
|
|
8525 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 20 - fixpoint_mul(20, v51 + v53 + v52);
|
|
8526 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level < 0 )
|
|
8527 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 0;
|
|
8528 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level > 31 )
|
|
8529 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 31;
|
|
8530 if ( pODMRenderParams->uNumPolygons >= 1999 + 5000)
|
|
8531 return;
|
|
8532 if ( ODMFace::IsBackfaceNotCulled(array_73D150, &array_77EC08[pODMRenderParams->uNumPolygons]) )
|
|
8533 {
|
|
8534 pOutdoor->pBModels[model_id].pFaces[face_id].bVisible = 1;
|
|
8535 array_77EC08[pODMRenderParams->uNumPolygons].uBModelFaceID = face_id;
|
|
8536 array_77EC08[pODMRenderParams->uNumPolygons].uBModelID = model_id;
|
|
8537 v27 = 8 * (face_id | (model_id << 6));
|
|
8538 LOBYTE(v27) = v27 | 6;
|
|
8539 array_77EC08[pODMRenderParams->uNumPolygons].field_50 = v27;
|
|
8540 for ( int vertex_id = 0; vertex_id < pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; ++vertex_id)
|
|
8541 {
|
|
8542 memcpy(&array_50AC10[vertex_id], &array_73D150[vertex_id], sizeof(array_50AC10[vertex_id]));
|
|
8543 array_50AC10[vertex_id]._rhw = 1.0 / (array_73D150[vertex_id].vWorldViewPosition.x + 0.0000001);
|
|
8544 }
|
|
8545 static stru154 static_RenderBuildingsD3D_stru_73C834;
|
|
8546 /*static bool __init_flag = false;
|
|
8547 if (!__init_flag)
|
|
8548 {
|
|
8549 __init_flag = true;
|
|
8550 static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u;
|
|
8551 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834);
|
|
8552 atexit(loc_4789D4);
|
|
8553 }*/
|
|
8554
|
|
8555 v40 = (int)&pOutdoor->pBModels[model_id].pFaces[face_id];
|
|
8556 pGame->pLightmapBuilder->ApplyLights_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]);
|
|
8557 pDecalBuilder->ApplyDecals_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]);
|
|
8558 pGame->pLightmapBuilder->std__vector_000004_size = 0;
|
|
8559 int v31 = 0;
|
|
8560 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
|
|
8561 {
|
|
8562 v31 = v50 ? 3 : v49 != 0 ? 5 : 0;
|
|
8563 static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(&pOutdoor->pBModels[model_id].pFaces[face_id], &pOutdoor->pBModels[model_id].pVertices);
|
|
8564 if ( pDecalBuilder->uNumDecals > 0 )
|
|
8565 {
|
|
8566 v40 = -1;
|
|
8567 pDecalBuilder->ApplyDecals(31 - array_77EC08[pODMRenderParams->uNumPolygons].dimming_level, 2, &static_RenderBuildingsD3D_stru_73C834,
|
|
8568 pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices, array_50AC10, 0, (char)v31, -1);
|
|
8569 }
|
|
8570 }
|
|
8571 if ( stru_F8AD28.uNumLightsApplied > 0 )
|
|
8572 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, array_50AC10, 0, (char)v31);
|
|
8573 if ( v50 )
|
|
8574 {
|
|
8575 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_NearClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices);
|
|
8576 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices;
|
|
8577 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices);
|
|
8578 }
|
|
8579 if ( v49 )
|
|
8580 {
|
|
8581 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_FarClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices);
|
|
8582 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices;
|
|
8583 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices);
|
|
8584 }
|
|
8585 if ( uNumVertices )
|
|
8586 {
|
|
8587 if ( array_77EC08[pODMRenderParams->uNumPolygons].flags & 2 )
|
|
8588 {
|
|
8589 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x3C )
|
|
8590 v34 = pRenderer->pHDWaterBitmapIDs[0];
|
|
8591 else
|
|
8592 v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
|
|
8593 v40 = (int)pBitmaps_LOD->pHardwareTextures[v34];
|
|
8594 }
|
|
8595 else
|
|
8596 v40 = (int)pBitmaps_LOD->pHardwareTextures[v9];
|
|
8597 pRenderer->DrawPolygon(uNumVertices, &array_77EC08[pODMRenderParams->uNumPolygons], &pOutdoor->pBModels[model_id].pFaces[face_id], (IDirect3DTexture2 *)v40);
|
|
8598 }
|
|
8599 }
|
|
8600 }
|
|
8601 }
|
|
8602 }
|
|
8603 }
|
|
8604 }
|
|
8605 }
|
|
8606 return;
|
|
8607 }
|
|
8608 //----- (00479543) --------------------------------------------------------
|
|
8609 void Render::DrawOutdoorSkyD3D()
|
|
8610 {
|
|
8611 int v9; // eax@4
|
|
8612 int v10; // ebx@4
|
|
8613 int v13; // edi@6
|
|
8614 int v14; // ecx@6
|
|
8615 int v15; // eax@8
|
|
8616 int v16; // eax@12
|
|
8617 signed __int64 v17; // qtt@13
|
|
8618 signed int v18; // ecx@13
|
|
8619 struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1
|
|
8620 int v30; // [sp+134h] [bp-30h]@1
|
|
8621 int v32; // [sp+13Ch] [bp-28h]@6
|
|
8622 int v33; // [sp+140h] [bp-24h]@2
|
|
8623 signed __int64 v34; // [sp+144h] [bp-20h]@1
|
|
8624 int v35; // [sp+148h] [bp-1Ch]@4
|
|
8625 int v36; // [sp+14Ch] [bp-18h]@2
|
|
8626 int v37; // [sp+154h] [bp-10h]@8
|
|
8627 int v38; // [sp+158h] [bp-Ch]@1
|
|
8628 int v39; // [sp+15Ch] [bp-8h]@4
|
|
8629
|
|
8630 v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z)
|
|
8631 / ((double)pODMRenderParams->int_fov_rad + 8192.0)
|
|
8632 + (double)(pViewport->uScreenCenterY));
|
|
8633 v34 = cos((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;//(double)pODMRenderParams->shading_dist_mist, 8192
|
|
8634 v38 = (signed __int64)((double)(pViewport->uScreenCenterY)
|
|
8635 - (double)pODMRenderParams->int_fov_rad
|
|
8636 / (v34 + 0.0000001)
|
|
8637 * (sin((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064)
|
|
8638 * (double)-0x2000//(double)pODMRenderParams->shading_dist_mist
|
|
8639 - (double)pGame->pIndoorCameraD3D->vPartyPos.z));
|
|
8640 pSkyPolygon.Create_48607B(&stru_8019C8);//çàïîëíÿåòñÿ ptr_38
|
|
8641 pSkyPolygon.ptr_38->_48694B_frustum_sky();
|
2534
|
8642
|
|
8643 //if ( pParty->uCurrentHour > 20 || pParty->uCurrentHour < 5 )
|
|
8644 //pSkyPolygon.uTileBitmapID = pOutdoor->New_SKY_NIGHT_ID;
|
|
8645 //else
|
|
8646 pSkyPolygon.uTileBitmapID = pOutdoor->sSky_TextureID;//179(original 166)
|
|
8647 pSkyPolygon.pTexture = (Texture *)(pSkyPolygon.uTileBitmapID != -1 ? (int)&pBitmaps_LOD->pTextures[pSkyPolygon.uTileBitmapID] : 0);
|
2496
|
8648 if ( pSkyPolygon.pTexture )
|
|
8649 {
|
|
8650 pSkyPolygon.dimming_level = 0;
|
|
8651 pSkyPolygon.uNumVertices = 4;
|
|
8652 //centering(öåíòðóåì)-----------------------------------------------------------------
|
|
8653 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
|
|
8654 pSkyPolygon.v_18.y = 0;
|
|
8655 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16);
|
|
8656
|
|
8657 //sky wiew position(ïîëîæåíèå íåáà íà ýêðàíå)------------------------------------------
|
|
8658 // X
|
|
8659 // 0._____________________________.3
|
|
8660 // |8,8 468,8 |
|
|
8661 // | |
|
|
8662 // | |
|
|
8663 // Y| |
|
|
8664 // | |
|
|
8665 // |8,351 468,351 |
|
|
8666 // 1._____________________________.2
|
|
8667 //
|
|
8668 array_50AC10[0].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8
|
|
8669 array_50AC10[0].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8
|
|
8670
|
|
8671 array_50AC10[1].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8
|
|
8672 array_50AC10[1].vWorldViewProjY = (double)v38;//247
|
|
8673
|
|
8674 array_50AC10[2].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468
|
|
8675 array_50AC10[2].vWorldViewProjY = (double)v38;//247
|
|
8676
|
|
8677 array_50AC10[3].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468
|
|
8678 array_50AC10[3].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8
|
|
8679
|
|
8680 pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168
|
|
8681 pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168
|
|
8682
|
2535
|
8683 pSkyPolygon.field_24 = 0x2000000;//maybe attributes
|
2496
|
8684 v33 = 65536 / (signed int)(signed __int64)(((double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2) / tan(0.6457717418670654) + 0.5);
|
|
8685 for ( uint i = 0; i < pSkyPolygon.uNumVertices; ++i )
|
|
8686 {
|
|
8687 //rotate skydome(âðàùåíèå êóïîëà íåáà)--------------------------------------
|
|
8688 //  èãðå ïðèíÿòà ñâîÿ ñèñòåìà èçìåðåíèÿ óãëîâ. Ïîëíûé óãîë (180). Çíà÷åíèþ óãëà 0 ñîîòâåòñòâóåò
|
|
8689 // íàïðàâëåíèå íà ñåâåð è/èëè þã (ëèáî íà âîñòîê è/èëè çàïàä), çíà÷åíèþ 65536 åäåíèöàì(0õ10000) ñîîòâåòñòâóåò óãîë 90.
|
|
8690 // äâå ïåðåìåííûå õðàíÿò äàííûå ïî óãëó îáçîðà. field_14 ïî çàïàäó è âîñòîêó. field_20 ïî þãó è ñåâåðó
|
|
8691 // îò -25080 äî 25080
|
|
8692 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5)));
|
|
8693 v35 = v39 + pSkyPolygon.ptr_38->angle_from_north;
|
|
8694
|
|
8695 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.f)));
|
|
8696 v36 = v39 + pSkyPolygon.ptr_38->angle_from_east;
|
|
8697
|
|
8698 v9 = fixpoint_mul(pSkyPolygon.v_18.z, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5)));
|
|
8699 v10 = pSkyPolygon.v_18.x + v9;
|
|
8700 if ( v10 > 0 )
|
|
8701 v10 = 0;
|
|
8702 v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX);
|
|
8703 v34 = -pSkyPolygon.field_24;
|
|
8704 v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0;
|
|
8705 v14 = v33 * (v30 - v32);
|
|
8706 while ( 1 )
|
|
8707 {
|
|
8708 if ( v10 )
|
|
8709 {
|
|
8710 v37 = abs((int)v34 >> 14);
|
|
8711 v15 = abs(v10);
|
|
8712 if ( v37 <= v15 || v32 <= (signed int)pViewport->uViewportTL_Y )
|
|
8713 {
|
|
8714 if ( v10 <= 0 )
|
|
8715 break;
|
|
8716 }
|
|
8717 }
|
|
8718 v16 = fixpoint_mul(pSkyPolygon.v_18.z, v14);
|
|
8719 --v32;
|
|
8720 v14 += v33;
|
|
8721 v10 = pSkyPolygon.v_18.x + v16;
|
|
8722 }
|
|
8723 LODWORD(v17) = LODWORD(v34) << 16;
|
|
8724 HIDWORD(v17) = v34 >> 16;
|
|
8725 v18 = v17 / v10;
|
|
8726 if ( v18 < 0 )
|
|
8727 v18 = pODMRenderParams->shading_dist_mist;
|
|
8728 v37 = v35 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v13);
|
|
8729 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v37, v18) >> 3);
|
|
8730 array_50AC10[i].u = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureWidth * 65536.0);
|
|
8731
|
|
8732 v36 = v36 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v13);
|
|
8733 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v36, v18) >> 3);
|
|
8734 array_50AC10[i].v = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureHeight * 65536.0);
|
|
8735
|
|
8736 array_50AC10[i].vWorldViewPosition.x = (double)0x2000;//pODMRenderParams->shading_dist_mist 8192
|
|
8737 array_50AC10[i]._rhw = 1.0 / (double)(v18 >> 16);
|
|
8738 }
|
|
8739 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
|
|
8740 array_50AC10[0].vWorldViewProjY = (double)v10;
|
|
8741 array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0;
|
|
8742 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0;
|
|
8743 array_50AC10[3].vWorldViewProjY = (double)v10;
|
|
8744 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
|
|
8745 return;
|
|
8746 }
|
|
8747 }
|
|
8748 //----- (004226C2) --------------------------------------------------------
|
|
8749 bool PauseGameDrawing()
|
|
8750 {
|
|
8751 if ( pCurrentScreen != SCREEN_GAME
|
|
8752 && pCurrentScreen != SCREEN_NPC_DIALOGUE
|
|
8753 && pCurrentScreen != SCREEN_CHANGE_LOCATION )
|
|
8754 {
|
|
8755 if (pCurrentScreen == SCREEN_INPUT_BLV)
|
|
8756 return pMovie_Track;//pSmackerMovie != 0;
|
|
8757 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG )
|
|
8758 return true;
|
|
8759 }
|
|
8760 return false;
|
|
8761 }
|
|
8762
|
|
8763
|
|
8764 //----- (0045E03A) --------------------------------------------------------
|
|
8765 unsigned short *Render::MakeScreenshot(signed int width, signed int height)
|
|
8766 {
|
|
8767 unsigned __int16 *for_pixels; // ebx@1
|
|
8768 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6
|
|
8769 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1
|
|
8770 float interval_x; // [sp+84h] [bp-20h]@1
|
|
8771 float interval_y; // [sp+8Ch] [bp-18h]@1
|
|
8772
|
|
8773 interval_x = game_viewport_width / (double)width;
|
|
8774 interval_y = game_viewport_height / (double)height;
|
|
8775
|
|
8776 pPixels = (unsigned __int16 *)malloc(2 * height * width);
|
|
8777 memset(pPixels, 0 , 2 * height * width);
|
|
8778
|
|
8779 for_pixels = pPixels;
|
|
8780
|
|
8781 BeginSceneD3D();
|
|
8782
|
|
8783 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
8784 pIndoor->Draw();
|
|
8785 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
8786 pOutdoor->Draw();
|
|
8787 DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
|
|
8788 memset(&Dst, 0, sizeof(Dst));
|
|
8789 Dst.dwSize = sizeof(Dst);
|
|
8790
|
|
8791 if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) )
|
|
8792 {
|
|
8793 if (uCurrentlyLoadedLevelType == LEVEL_null)
|
|
8794 memset(&for_pixels, 0, sizeof(for_pixels));
|
|
8795 else
|
|
8796 {
|
|
8797 for (uint y = 0; y < (unsigned int)height; ++y)
|
|
8798 {
|
|
8799 for (uint x = 0; x < (unsigned int)width; ++x)
|
|
8800 {
|
|
8801 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32)
|
|
8802 {
|
|
8803 unsigned __int32 *p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * (Dst.lPitch >> 2);
|
|
8804 *for_pixels = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
|
|
8805 }
|
|
8806 else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16)
|
|
8807 {
|
|
8808 unsigned __int16 * p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch;
|
|
8809 *for_pixels = *p;
|
|
8810 }
|
|
8811 else
|
|
8812 assert(false);
|
|
8813 ++for_pixels;
|
|
8814 }
|
|
8815 }
|
|
8816 }
|
|
8817 ErrD3D(pBackBuffer4->Unlock(NULL));
|
|
8818 }
|
|
8819 return pPixels;
|
|
8820 }
|
|
8821 //----- (0045E26C) --------------------------------------------------------
|
|
8822 void Render::SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height)
|
|
8823 {
|
|
8824 auto pixels = MakeScreenshot(width, height);
|
|
8825 SavePCXImage(pFilename, pixels, width, height);
|
|
8826 free(pixels);
|
|
8827 }
|
|
8828
|
|
8829 void Render::PackScreenshot(unsigned int width, unsigned int height, void *data, unsigned int data_size, unsigned int *out_screenshot_size)
|
|
8830 {
|
|
8831 auto pixels = MakeScreenshot(150, 112);
|
|
8832 PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size);
|
|
8833 free(pixels);
|
|
8834 }
|
|
8835
|
|
8836
|
|
8837 //----- (0046A7C8) --------------------------------------------------------
|
|
8838 int Render::_46À6ÀÑ_GetActorsInViewport(int pDepth)
|
|
8839 {
|
|
8840 unsigned int v3; // eax@2 ïðèìåíÿåòñÿ â çàêëå Æàð ïå÷è äëÿ ïîäñ÷¸òà êîë-âà ìîíñòðîâ âèäèìûõ ãðóïïå è çàïîëíåíèÿ ìàññèâà id âèäèìûõ ìîíñòðîâ
|
|
8841 unsigned int v5; // eax@2
|
|
8842 unsigned int v6; // eax@4
|
|
8843 unsigned int v12; // [sp+10h] [bp-14h]@1
|
|
8844 int mon_num; // [sp+1Ch] [bp-8h]@1
|
|
8845 unsigned int a1a; // [sp+20h] [bp-4h]@1
|
|
8846
|
|
8847 mon_num = 0;
|
|
8848 v12 = GetBillboardDrawListSize();
|
|
8849 if ( (signed int)GetBillboardDrawListSize() > 0 )
|
|
8850 {
|
|
8851 for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a )
|
|
8852 {
|
|
8853 v3 = GetParentBillboardID(a1a);
|
|
8854 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid;
|
|
8855 if ( PID_TYPE(v5) == OBJECT_Actor)
|
|
8856 {
|
|
8857 if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(pDepth << 16) )
|
|
8858 {
|
|
8859 v6 = PID_ID(v5);
|
2535
|
8860 if ( pActors[v6].uAIState != Dead
|
|
8861 && pActors[v6].uAIState != Dying
|
|
8862 && pActors[v6].uAIState != Removed
|
|
8863 && pActors[v6].uAIState != Disabled
|
|
8864 && pActors[v6].uAIState != Summoned )
|
2496
|
8865 {
|
|
8866 if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)pDepth, a1a) )
|
|
8867 {
|
|
8868 if ( mon_num < 100 )
|
|
8869 {
|
|
8870 _50BF30_actors_in_viewport_ids[mon_num] = v6;
|
|
8871 mon_num++;
|
|
8872 }
|
|
8873 }
|
|
8874 }
|
|
8875 }
|
|
8876 }
|
|
8877 }
|
|
8878 }
|
|
8879 return mon_num;
|
|
8880 }
|
|
8881
|
|
8882
|
|
8883
|
|
8884
|
|
8885 void Render::BeginLightmaps()
|
|
8886 {
|
|
8887 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
|
|
8888
|
|
8889 if (bUsingSpecular)
|
|
8890 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE);
|
|
8891
|
|
8892 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
8893 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
8894 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03")));
|
|
8895 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8896 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
|
|
8897 }
|
|
8898
|
|
8899 void Render::EndLightmaps()
|
|
8900 {
|
|
8901 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8902 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
8903 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
8904 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
8905
|
|
8906 if (bUsingSpecular)
|
|
8907 {
|
|
8908 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
8909 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor));
|
|
8910 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
|
|
8911 }
|
|
8912 }
|
|
8913
|
|
8914
|
|
8915 void Render::BeginLightmaps2()
|
|
8916 {
|
|
8917 if (bUsingSpecular)
|
|
8918 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
8919
|
|
8920 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
8921 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
8922 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
8923 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
8924 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03")));
|
|
8925 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8926 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
|
|
8927 }
|
|
8928
|
|
8929
|
|
8930 void Render::EndLightmaps2()
|
|
8931 {
|
|
8932 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8933 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
8934 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
8935 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
8936 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
8937 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
|
|
8938
|
|
8939 if (bUsingSpecular)
|
|
8940 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
8941 }
|
|
8942
|
|
8943
|
|
8944
|
|
8945 //----- (00437C96) --------------------------------------------------------
|
|
8946 void Render::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff)
|
|
8947 {
|
|
8948 double v6; // st7@2
|
|
8949 std::string v9; // [sp-18h] [bp-60h]@3
|
|
8950 RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2
|
|
8951
|
|
8952 //if ( pRenderer->pRenderD3D )
|
|
8953 {
|
|
8954 v6 = 0.001 - z_stuff;
|
|
8955 memcpy(v13, pLineBegin, 0x20u);
|
|
8956 memcpy(&v13[1], pLineEnd, sizeof(v13[1]));
|
|
8957 v13[0].pos.z = v6;
|
|
8958 v13[1].pos.z = v6;
|
|
8959 v13[0].diffuse = sDiffuseBegin;
|
|
8960 v13[1].diffuse = sDiffuseEnd;
|
|
8961 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
2535
|
8962 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST, 452, v13, 2, 16));
|
2496
|
8963 }
|
|
8964 }
|
|
8965
|
|
8966
|
|
8967 void Render::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices)
|
|
8968 {
|
|
8969 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
|
8970 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST,
|
|
8971 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
8972 (void *)vertices,
|
|
8973 num_vertices,
|
|
8974 D3DDP_DONOTLIGHT));
|
|
8975 }
|
|
8976
|
|
8977
|
|
8978 void Render::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices)
|
|
8979 {
|
|
8980 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
|
|
8981 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false));
|
|
8982 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
8983 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA));
|
|
8984 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA));
|
|
8985
|
|
8986 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
|
|
8987 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
8988 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
8989 (void *)vertices,
|
|
8990 num_vertices,
|
|
8991 28));
|
|
8992
|
|
8993 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
8994 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
8995 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
8996 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE));
|
|
8997 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
8998 }
|
|
8999
|
|
9000
|
|
9001 void Render::BeginDecals()
|
|
9002 {
|
|
9003 // code chunk from 0049C304
|
|
9004 if (bUsingSpecular)
|
|
9005 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
9006 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
|
|
9007
|
|
9008 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
9009 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
9010 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
|
|
9011 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
9012 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
|
|
9013 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
9014
|
|
9015 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04")));
|
|
9016 }
|
|
9017
|
|
9018
|
|
9019 void Render::EndDecals()
|
|
9020 {
|
|
9021 // code chunk from 0049C304
|
|
9022 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
|
|
9023 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
9024 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
9025 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
9026 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
9027
|
|
9028 if (bUsingSpecular)
|
|
9029 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
|
|
9030 }
|
|
9031
|
|
9032
|
|
9033
|
|
9034 //----- (0049C095) --------------------------------------------------------
|
|
9035 void Render::DrawDecal(Decal *pDecal, float z_bias)
|
|
9036 {
|
2532
|
9037 signed int dwFlags; // [sp+Ch] [bp-864h]@15
|
2496
|
9038 RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6
|
|
9039
|
|
9040 if (pDecal->uNumVertices < 3)
|
|
9041 {
|
|
9042 Log::Warning(L"Decal has < 3 vertices");
|
|
9043 return;
|
|
9044 }
|
|
9045
|
|
9046 float color_mult;
|
|
9047 if ( pDecal->field_C1C & 1 )
|
|
9048 color_mult = 1.0;
|
|
9049 else
|
|
9050 color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time();
|
|
9051
|
|
9052 for (uint i = 0; i < (unsigned int)pDecal->uNumVertices; ++i)
|
|
9053 {
|
|
9054 uint uTint = Render::GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr);
|
|
9055
|
|
9056 uint uTintR = (uTint >> 16) & 0xFF,
|
|
9057 uTintG = (uTint >> 8) & 0xFF,
|
|
9058 uTintB = uTint & 0xFF;
|
|
9059
|
|
9060 uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF,
|
|
9061 uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF,
|
|
9062 uDecalColorMultB = pDecal->uColorMultiplier & 0xFF;
|
|
9063
|
|
9064 uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f),
|
|
9065 uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f),
|
|
9066 uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f);
|
|
9067
|
|
9068 float v15;
|
|
9069 if (fabs(z_bias) < 1e-5)
|
|
9070 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0);
|
2532
|
9071 else
|
|
9072 {
|
2496
|
9073 v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias;
|
|
9074 if (v15 < 0.000099999997)
|
|
9075 v15 = 0.000099999997;
|
2532
|
9076 }
|
2496
|
9077
|
|
9078 pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX;
|
|
9079 pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY;
|
2532
|
9080 pVerticesD3D[i].pos.z = v15;
|
|
9081
|
|
9082 pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x;
|
|
9083 pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB;
|
|
9084 pVerticesD3D[i].specular = 0;
|
|
9085
|
2496
|
9086 pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u;
|
|
9087 pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v;
|
|
9088 }
|
|
9089
|
|
9090 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
2532
|
9091 dwFlags = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS;
|
2496
|
9092 else
|
2532
|
9093 dwFlags = D3DDP_DONOTLIGHT;
|
2496
|
9094
|
|
9095 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
9096 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
2532
|
9097 pVerticesD3D, pDecal->uNumVertices, dwFlags));
|
2496
|
9098 }
|
|
9099
|
|
9100
|
|
9101 void Render::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture)
|
|
9102 {
|
|
9103 ErrD3D(pRenderD3D->pDevice->SetTexture(0, texture));
|
|
9104 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
|
|
9105 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
|
|
9106 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
|
|
9107 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
9108 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
|
|
9109 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
|
|
9110 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS));
|
|
9111 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
9112 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
|
|
9113 (void *)vertices, 4, 28));
|
|
9114 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
|
|
9115 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
|
|
9116 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
|
|
9117 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
|
|
9118 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
|
|
9119 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS));
|
|
9120 }
|
|
9121
|
|
9122 //----- (00452442) --------------------------------------------------------
|
|
9123 unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4)
|
|
9124 {
|
|
9125 int v4; // ebx@0
|
|
9126 __int16 v5; // ST14_2@1
|
|
9127 __int16 v6; // dx@1
|
|
9128 int v7; // ecx@1
|
|
9129 __int16 v8; // ST10_2@1
|
|
9130 int v9; // edi@1
|
|
9131 unsigned __int16 v10; // dh@1@1
|
|
9132 int v11; // ebx@1
|
|
9133 int v12; // ebx@1
|
|
9134 __int16 a3a; // [sp+1Ch] [bp+8h]@1
|
|
9135
|
|
9136 v5 = a2 >> 2;
|
|
9137 v6 = (unsigned __int16)a4 >> 2;
|
|
9138 v8 = a1 >> 2;
|
|
9139 a3a = (unsigned __int16)a3 >> 2;
|
|
9140 LOWORD(v7) = a3a;
|
|
9141 v9 = v7;
|
|
9142 LOWORD(v4) = ((unsigned __int16)a4 >> 2) & 0xE0;
|
|
9143 LOWORD(v7) = a3a & 0xE0;
|
|
9144 LOWORD(v9) = v9 & 0x1C00;
|
|
9145 v11 = v7 + v4;
|
|
9146 LOWORD(v7) = v5 & 0xE0;
|
|
9147 v12 = v7 + v11;
|
|
9148 LOWORD(v7) = v8 & 0xE0;
|
|
9149 __debugbreak(); // warning C4700: uninitialized local variable 'v10' used
|
|
9150 return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) | (v7 + v12) | ((v8 & 0x1C00)
|
|
9151 + (v5 & 0x1C00)
|
|
9152 + v9
|
|
9153 + (__PAIR__(v10, (unsigned __int16)a4 >> 2) & 0x1C00));
|
|
9154 }
|
|
9155
|
|
9156 //----- (0047C4FC) --------------------------------------------------------
|
|
9157 int __fastcall GetActorTintColor(int max_dimm, int min_dimm, float distance, int a4, RenderBillboard *a5)
|
|
9158 {
|
|
9159 signed int v6; // edx@1
|
|
9160 int v8; // eax@3
|
|
9161 double v9; // st7@12
|
|
9162 int v11; // ecx@28
|
|
9163 double v15; // st7@44
|
|
9164 int v18; // ST14_4@44
|
|
9165 signed int v20; // [sp+10h] [bp-4h]@10
|
|
9166 float a3c; // [sp+1Ch] [bp+8h]@44
|
|
9167 int a5a; // [sp+24h] [bp+10h]@44
|
|
9168
|
|
9169 //v5 = a2;
|
|
9170 v6 = 0;
|
|
9171
|
|
9172 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
9173 return 8 * (31 - max_dimm) | ((8 * (31 - max_dimm) | ((31 - max_dimm) << 11)) << 8);
|
|
9174
|
|
9175 if (pParty->armageddon_timer)
|
|
9176 return 0xFFFF0000;
|
|
9177
|
|
9178 v8 = pWeather->bNight;
|
|
9179 if (bUnderwater)
|
|
9180 v8 = 0;
|
|
9181 if (v8)
|
|
9182 {
|
|
9183 v20 = 1;
|
|
9184 if ((signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0)
|
|
9185 v20 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower;
|
|
9186 v9 = (double)v20 * 1024.0;
|
|
9187 if (a4)
|
|
9188 {
|
|
9189 v6 = 216;
|
|
9190 goto LABEL_20;
|
|
9191 }
|
|
9192 if (distance <= v9)
|
|
9193 {
|
|
9194 if (distance > 0.0)
|
|
9195 {
|
|
9196 //a4b = distance * 216.0 / v9;
|
|
9197 //v10 = a4b + 6.7553994e15;
|
|
9198 //v6 = LODWORD(v10);
|
|
9199 v6 = floorf(0.5f + distance * 216.0 / v9);
|
|
9200 if (v6 > 216)
|
|
9201 {
|
|
9202 v6 = 216;
|
|
9203 goto LABEL_20;
|
|
9204 }
|
|
9205 }
|
|
9206 }
|
|
9207 else
|
|
9208 {
|
|
9209 v6 = 216;
|
|
9210 }
|
|
9211 if (distance != 0.0)
|
|
9212 {
|
|
9213 LABEL_20:
|
|
9214 if (a5)
|
|
9215 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3);
|
|
9216 if (v6 > 216)
|
|
9217 v6 = 216;
|
|
9218 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
|
|
9219 }
|
|
9220 //LABEL_19:
|
|
9221 v6 = 216;
|
|
9222 goto LABEL_20;
|
|
9223 }
|
|
9224
|
|
9225
|
|
9226
|
|
9227 if (fabsf(distance) < 1.0e-6f)
|
|
9228 return 0xFFF8F8F8;
|
|
9229
|
|
9230 // dim in measured in 8-steps
|
|
9231 v11 = 8 * (max_dimm - min_dimm);
|
|
9232 //v12 = v11;
|
|
9233 if (v11 >= 0)
|
|
9234 {
|
|
9235 if (v11 > 216)
|
|
9236 v11 = 216;
|
|
9237 }
|
|
9238 else
|
|
9239 v11 = 0;
|
|
9240
|
|
9241 float fog_density_mult = 216.0f;
|
|
9242 if (a4)
|
|
9243 fog_density_mult += distance / (double)pODMRenderParams->shading_dist_shade * 32.0;
|
|
9244
|
|
9245 v6 = v11 + floorf(pOutdoor->fFogDensity * fog_density_mult + 0.5f);
|
|
9246 /*if ( a4 )
|
|
9247 {
|
|
9248 //a3b = pOutdoor->fFogDensity * 216.0;
|
|
9249 //v14 = a3b + 6.7553994e15;
|
|
9250 //a4a = floorf(a3b + 0.5f);//LODWORD(v14);
|
|
9251 }
|
|
9252 else
|
|
9253 {
|
|
9254 //a3a = (distance / (double)pODMRenderParams->shading_dist_shade * 32.0 + 216.0) * pOutdoor->fFogDensity;
|
|
9255 //v13 = a3a + 6.7553994e15;
|
|
9256 //a4a = floorf(a3a + 0.5f);//LODWORD(v13);
|
|
9257 }
|
|
9258 v6 = a4a + v11;*/
|
|
9259 if (a5)
|
|
9260 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3);
|
|
9261 if (v6 > 216)
|
|
9262 v6 = 216;
|
|
9263 if (v6 < v11)
|
|
9264 v6 = v11;
|
|
9265 if (v6 > 8 * pOutdoor->max_terrain_dimming_level)
|
|
9266 v6 = 8 * pOutdoor->max_terrain_dimming_level;
|
|
9267 if (!bUnderwater)
|
|
9268 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
|
|
9269 else
|
|
9270 {
|
|
9271 v15 = (double)(255 - v6) * 0.0039215689;
|
|
9272 a3c = v15;
|
|
9273 //a4c = v15 * 16.0;
|
|
9274 //v16 = a4c + 6.7553994e15;
|
|
9275 a5a = floorf(v15 * 16.0 + 0.5f);//LODWORD(v16);
|
|
9276 //a4d = a3c * 194.0;
|
|
9277 //v17 = a4d + 6.7553994e15;
|
|
9278 v18 = floorf(a3c * 194.0 + 0.5f);//LODWORD(v17);
|
|
9279 //a3d = a3c * 153.0;
|
|
9280 //v19 = a3d + 6.7553994e15;
|
|
9281 return (int)floorf(a3c * 153.0 + 0.5f)/*LODWORD(v19)*/ | ((v18 | (a5a << 8)) << 8);
|
|
9282 }
|
|
9283 }
|
|
9284 // 6BE3C4: using guessed type char bUnderwater;
|
|
9285
|
|
9286 //----- (0043F55F) --------------------------------------------------------
|
|
9287 int __fastcall _43F55F_get_billboard_light_level(RenderBillboard *a1, int uBaseLightLevel)
|
|
9288 {
|
|
9289 signed int v3; // ecx@2
|
|
9290
|
|
9291 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
9292 v3 = pIndoor->pSectors[a1->uIndoorSectorID].uMinAmbientLightLevel;
|
|
9293 else
|
|
9294 {
|
|
9295 if (uBaseLightLevel == -1)
|
|
9296 v3 = a1->dimming_level;
|
|
9297 else
|
|
9298 v3 = uBaseLightLevel;
|
|
9299 }
|
|
9300 return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->world_x, a1->world_y, a1->world_z);
|
|
9301 }
|
|
9302
|
|
9303 //----- (0043F5C8) --------------------------------------------------------
|
|
9304 int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z)
|
|
9305 {
|
|
9306 signed int v6; // edi@1
|
|
9307 int v8; // eax@6
|
|
9308 int v9; // ebx@6
|
|
9309 unsigned int v10; // ecx@6
|
|
9310 unsigned int v11; // edx@9
|
|
9311 unsigned int v12; // edx@11
|
|
9312 signed int v13; // ecx@12
|
|
9313 BLVLightMM7 *v16; // esi@20
|
|
9314 int v17; // ebx@21
|
|
9315 signed int v24; // ecx@30
|
|
9316 int v26; // ebx@35
|
|
9317 int v37; // [sp+Ch] [bp-18h]@37
|
|
9318 int v39; // [sp+10h] [bp-14h]@23
|
|
9319 int v40; // [sp+10h] [bp-14h]@36
|
|
9320 int v42; // [sp+14h] [bp-10h]@22
|
|
9321 unsigned int v43; // [sp+18h] [bp-Ch]@12
|
|
9322 unsigned int v44; // [sp+18h] [bp-Ch]@30
|
|
9323 unsigned int v45; // [sp+18h] [bp-Ch]@44
|
|
9324
|
|
9325 v6 = uBaseLightLevel;
|
|
9326 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
|
|
9327 {
|
|
9328 MobileLight* p = &pMobileLightsStack->pLights[i];
|
|
9329
|
|
9330 float distX = abs(p->vPosition.x - x);
|
|
9331 if (distX <= p->uRadius)
|
|
9332 {
|
|
9333 float distY = abs(p->vPosition.y - y);
|
|
9334 if (distY <= p->uRadius)
|
|
9335 {
|
|
9336 float distZ = abs(p->vPosition.z - z);
|
|
9337 if (distZ <= p->uRadius)
|
|
9338 {
|
|
9339 v8 = distX;
|
|
9340 v9 = distY;
|
|
9341 v10 = distZ;
|
|
9342 if (distX < distY)
|
|
9343 {
|
|
9344 v8 = distY;
|
|
9345 v9 = distX;
|
|
9346 }
|
|
9347 if (v8 < distZ)
|
|
9348 {
|
|
9349 v11 = v8;
|
|
9350 v8 = distZ;
|
|
9351 v10 = v11;
|
|
9352 }
|
|
9353 if (v9 < (signed int)v10)
|
|
9354 {
|
|
9355 v12 = v10;
|
|
9356 v10 = v9;
|
|
9357 v9 = v12;
|
|
9358 }
|
|
9359 v43 = ((unsigned int)(11 * v9) / 32) + (v10 / 4) + v8;
|
|
9360 v13 = p->uRadius;
|
|
9361 if ((signed int)v43 < v13)
|
|
9362 v6 += ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30;
|
|
9363 }
|
|
9364 }
|
|
9365 }
|
|
9366 }
|
|
9367
|
|
9368 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
9369 {
|
|
9370 BLVSector* pSector = &pIndoor->pSectors[uSectorID];
|
|
9371
|
|
9372 for (uint i = 0; i < pSector->uNumLights; ++i)
|
|
9373 {
|
|
9374 v16 = pIndoor->pLights + pSector->pLights[i];
|
|
9375 if (~v16->uAtributes & 8)
|
|
9376 {
|
|
9377 v17 = abs(v16->vPosition.x - x);
|
|
9378 if (v17 <= v16->uRadius)
|
|
9379 {
|
|
9380 v42 = abs(v16->vPosition.y - y);
|
|
9381 if (v42 <= v16->uRadius)
|
|
9382 {
|
|
9383 v39 = abs(v16->vPosition.z - z);
|
|
9384 if (v39 <= v16->uRadius)
|
|
9385 {
|
|
9386 v44 = int_get_vector_length(v17, v42, v39);
|
|
9387 v24 = v16->uRadius;
|
|
9388 if ((signed int)v44 < v24)
|
|
9389 v6 += ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30;
|
|
9390 }
|
|
9391 }
|
|
9392 }
|
|
9393 }
|
|
9394 }
|
|
9395 }
|
|
9396
|
|
9397 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i)
|
|
9398 {
|
|
9399 //StationaryLight* p = &pStationaryLightsStack->pLights[i];
|
|
9400 v26 = abs(pStationaryLightsStack->pLights[i].vPosition.x - x);
|
|
9401 if (v26 <= pStationaryLightsStack->pLights[i].uRadius)
|
|
9402 {
|
|
9403 v40 = abs(pStationaryLightsStack->pLights[i].vPosition.y - y);
|
|
9404 if (v40 <= pStationaryLightsStack->pLights[i].uRadius)
|
|
9405 {
|
|
9406 v37 = abs(pStationaryLightsStack->pLights[i].vPosition.z - z);
|
|
9407 if (v37 <= pStationaryLightsStack->pLights[i].uRadius)
|
|
9408 {
|
|
9409 v45 = int_get_vector_length(v26, v40, v37);
|
|
9410 //v33 = pStationaryLightsStack->pLights[i].uRadius;
|
|
9411 if ((signed int)v45 < pStationaryLightsStack->pLights[i].uRadius)
|
|
9412 v6 += ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / pStationaryLightsStack->pLights[i].uRadius) >> 16) - 30;
|
|
9413 }
|
|
9414 }
|
|
9415 }
|
|
9416 }
|
|
9417
|
|
9418 if (v6 <= 31)
|
|
9419 {
|
|
9420 if (v6 < 0)
|
|
9421 v6 = 0;
|
|
9422 }
|
|
9423 else
|
|
9424 v6 = 31;
|
|
9425 return v6;
|
|
9426 }
|
|
9427
|
|
9428 //----- (0049D700) --------------------------------------------------------
|
|
9429 unsigned int __fastcall GetMaxMipLevels(unsigned int uDim)
|
|
9430 {
|
|
9431 int v2; // ecx@1
|
|
9432 unsigned int v3; // eax@1
|
|
9433
|
|
9434 v2 = 0;
|
|
9435 v3 = uDim - 1;
|
|
9436 while (v3 & 1)
|
|
9437 {
|
|
9438 v3 >>= 1;
|
|
9439 ++v2;
|
|
9440 }
|
|
9441 return v3 == 0 ? v2 : 0;
|
|
9442 }
|
|
9443
|
|
9444 //----- (0046E44E) --------------------------------------------------------
|
|
9445 int _46E44E_collide_against_faces_and_portals(unsigned int b1)
|
|
9446 {
|
|
9447 BLVSector *pSector; // edi@1
|
|
9448 signed int v2; // ebx@1
|
|
9449 BLVFace *pFace; // esi@2
|
|
9450 __int16 pNextSector; // si@10
|
|
9451 int pArrayNum; // ecx@12
|
|
9452 unsigned __int8 v6; // sf@12
|
|
9453 unsigned __int8 v7; // of@12
|
|
9454 int result; // eax@14
|
|
9455 //int v10; // ecx@15
|
|
9456 int pFloor; // eax@16
|
|
9457 int v15; // eax@24
|
|
9458 int v16; // edx@25
|
|
9459 int v17; // eax@29
|
|
9460 unsigned int v18; // eax@33
|
|
9461 int v21; // eax@35
|
|
9462 int v22; // ecx@36
|
|
9463 int v23; // eax@40
|
|
9464 unsigned int v24; // eax@44
|
|
9465 int a3; // [sp+10h] [bp-48h]@28
|
|
9466 int v26; // [sp+14h] [bp-44h]@15
|
|
9467 int i; // [sp+18h] [bp-40h]@1
|
|
9468 int a10; // [sp+1Ch] [bp-3Ch]@1
|
|
9469 int v29; // [sp+20h] [bp-38h]@14
|
|
9470 int v32; // [sp+2Ch] [bp-2Ch]@15
|
|
9471 int pSectorsArray[10]; // [sp+30h] [bp-28h]@1
|
|
9472
|
|
9473 pSector = &pIndoor->pSectors[stru_721530.uSectorID];
|
|
9474 i = 1;
|
|
9475 a10 = b1;
|
|
9476 pSectorsArray[0] = stru_721530.uSectorID;
|
|
9477 for (v2 = 0; v2 < pSector->uNumPortals; ++v2)
|
|
9478 {
|
|
9479 pFace = &pIndoor->pFaces[pSector->pPortals[v2]];
|
|
9480 if (stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1
|
|
9481 && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1
|
|
9482 && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1
|
|
9483 && abs((pFace->pFacePlane_old.dist
|
|
9484 + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x
|
|
9485 + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y
|
|
9486 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16) <= stru_721530.field_6C + 16)
|
|
9487 {
|
|
9488 pNextSector = pFace->uSectorID == stru_721530.uSectorID ? pFace->uBackSectorID : pFace->uSectorID;//FrontSectorID
|
|
9489 pArrayNum = i++;
|
|
9490 v7 = i < 10;
|
|
9491 v6 = i - 10 < 0;
|
|
9492 pSectorsArray[pArrayNum] = pNextSector;
|
|
9493 if (!(v6 ^ v7))
|
|
9494 break;
|
|
9495 }
|
|
9496 }
|
|
9497 result = 0;
|
|
9498 for (v29 = 0; v29 < i; v29++)
|
|
9499 {
|
|
9500 pSector = &pIndoor->pSectors[pSectorsArray[v29]];
|
|
9501 v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings;
|
|
9502 for (v26 = 0; v26 < v32; v26++)
|
|
9503 {
|
|
9504 pFloor = pSector->pFloors[v26];
|
|
9505 pFace = &pIndoor->pFaces[pSector->pFloors[v26]];
|
|
9506 if (!pFace->Portal()
|
|
9507 && stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1
|
|
9508 && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1
|
|
9509 && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1
|
|
9510 && pFloor != stru_721530.field_84)
|
|
9511 {
|
|
9512 v15 = (pFace->pFacePlane_old.dist + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x
|
|
9513 + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y
|
|
9514 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16;
|
|
9515 if (v15 > 0)
|
|
9516 {
|
|
9517 v16 = (pFace->pFacePlane_old.dist + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x
|
|
9518 + stru_721530.normal2.y * pFace->pFacePlane_old.vNormal.y
|
|
9519 + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z) >> 16;
|
|
9520 if (v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d)
|
|
9521 {
|
|
9522 if (v16 <= v15)
|
|
9523 {
|
|
9524 a3 = stru_721530.field_6C;
|
|
9525 if (sub_47531C(stru_721530.prolly_normal_d, &a3, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
|
|
9526 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10))
|
|
9527 {
|
|
9528 v17 = a3;
|
|
9529 }
|
|
9530 else
|
|
9531 {
|
|
9532 a3 = stru_721530.field_6C + stru_721530.prolly_normal_d;
|
|
9533 if (!sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, pFace))
|
|
9534 goto LABEL_34;
|
|
9535 v17 = a3 - stru_721530.prolly_normal_d;
|
|
9536 a3 -= stru_721530.prolly_normal_d;
|
|
9537 }
|
|
9538 if (v17 < stru_721530.field_7C)
|
|
9539 {
|
|
9540 stru_721530.field_7C = v17;
|
|
9541 v18 = 8 * pSector->pFloors[v26];
|
|
9542 LOBYTE(v18) = v18 | 6;
|
|
9543 stru_721530.uFaceID = v18;
|
|
9544 }
|
|
9545 }
|
|
9546 }
|
|
9547 }
|
|
9548 LABEL_34:
|
|
9549 if (!(stru_721530.field_0 & 1)
|
|
9550 || (v21 = (pFace->pFacePlane_old.dist + stru_721530.position.x * pFace->pFacePlane_old.vNormal.x
|
|
9551 + stru_721530.position.y * pFace->pFacePlane_old.vNormal.y
|
|
9552 + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16, v21 <= 0)
|
|
9553 || (v22 = (pFace->pFacePlane_old.dist + stru_721530.field_4C * pFace->pFacePlane_old.vNormal.x
|
|
9554 + stru_721530.field_50 * pFace->pFacePlane_old.vNormal.y
|
|
9555 + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16, v21 > stru_721530.prolly_normal_d)
|
|
9556 && v22 > stru_721530.prolly_normal_d || v22 > v21)
|
|
9557 continue;
|
|
9558 a3 = stru_721530.field_6C;
|
|
9559 if (sub_47531C(stru_721530.field_8_radius, &a3, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
|
|
9560 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10))
|
|
9561 {
|
|
9562 v23 = a3;
|
|
9563 goto LABEL_43;
|
|
9564 }
|
|
9565 a3 = stru_721530.field_6C + stru_721530.field_8_radius;
|
|
9566 if (sub_475D85(&stru_721530.position, &stru_721530.direction, &a3, pFace))
|
|
9567 {
|
|
9568 v23 = a3 - stru_721530.prolly_normal_d;
|
|
9569 a3 -= stru_721530.prolly_normal_d;
|
|
9570 LABEL_43:
|
|
9571 if (v23 < stru_721530.field_7C)
|
|
9572 {
|
|
9573 stru_721530.field_7C = v23;
|
|
9574 v24 = 8 * pSector->pFloors[v26];
|
|
9575 LOBYTE(v24) = v24 | 6;
|
|
9576 stru_721530.uFaceID = v24;
|
|
9577 }
|
|
9578 }
|
|
9579 }
|
|
9580 }
|
|
9581 result = v29 + 1;
|
|
9582 }
|
|
9583 return result;
|
|
9584 }
|
|
9585 // 46E44E: using guessed type int var_28[10];
|
|
9586
|
|
9587 //----- (0046E889) --------------------------------------------------------
|
|
9588 int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0)
|
|
9589 {
|
|
9590 int result; // eax@1
|
|
9591 //int v3; // ebx@9
|
|
9592 int v8; // eax@19
|
|
9593 int v9; // ecx@20
|
|
9594 int v10; // eax@24
|
|
9595 unsigned int v14; // eax@28
|
|
9596 int v15; // eax@30
|
|
9597 int v16; // ecx@31
|
|
9598 unsigned int v17; // eax@36
|
|
9599 int v21; // eax@42
|
|
9600 unsigned int v22; // eax@43
|
|
9601 //int a11; // [sp+70h] [bp-18h]@1
|
|
9602 //int a10; // [sp+80h] [bp-8h]@1
|
|
9603 int a2; // [sp+84h] [bp-4h]@23
|
|
9604
|
|
9605 //a11 = ecx0;
|
|
9606
|
|
9607 BLVFace face; // [sp+Ch] [bp-7Ch]@1
|
|
9608
|
|
9609 result = 0;
|
|
9610 for (uint i = 0; i < (signed int)pOutdoor->uNumBModels; ++i)
|
|
9611 {
|
|
9612 if (stru_721530.sMaxX <= pOutdoor->pBModels[i].sMaxX && stru_721530.sMinX >= pOutdoor->pBModels[i].sMinX
|
|
9613 && stru_721530.sMaxY <= pOutdoor->pBModels[i].sMaxY && stru_721530.sMinY >= pOutdoor->pBModels[i].sMinY
|
|
9614 && stru_721530.sMaxZ <= pOutdoor->pBModels[i].sMaxZ && stru_721530.sMinZ >= pOutdoor->pBModels[i].sMinZ)
|
|
9615 {
|
|
9616 for (uint j = 0; j < pOutdoor->pBModels[i].uNumFaces; ++j)
|
|
9617 {
|
|
9618 if (stru_721530.sMaxX <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x2 && stru_721530.sMinX >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x1
|
|
9619 && stru_721530.sMaxY <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y2 && stru_721530.sMinY >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y1
|
|
9620 && stru_721530.sMaxZ <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.z2 && stru_721530.sMinZ >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.z1)
|
|
9621 {
|
|
9622 face.pFacePlane_old.vNormal.x = pOutdoor->pBModels[i].pFaces[j].pFacePlane.vNormal.x;
|
|
9623 face.pFacePlane_old.vNormal.y = pOutdoor->pBModels[i].pFaces[j].pFacePlane.vNormal.y;
|
|
9624 face.pFacePlane_old.vNormal.z = pOutdoor->pBModels[i].pFaces[j].pFacePlane.vNormal.z;
|
|
9625
|
|
9626 face.pFacePlane_old.dist = pOutdoor->pBModels[i].pFaces[j].pFacePlane.dist; //incorrect
|
|
9627
|
|
9628 face.uAttributes = pOutdoor->pBModels[i].pFaces[j].uAttributes;
|
|
9629
|
|
9630 face.pBounding.x1 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x1;
|
|
9631 face.pBounding.y1 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y1;
|
|
9632 face.pBounding.z1 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.z1;
|
|
9633
|
|
9634 face.pBounding.x2 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x2;
|
|
9635 face.pBounding.y2 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y2;
|
|
9636 face.pBounding.z2 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.z2;
|
|
9637
|
|
9638 face.zCalc1 = pOutdoor->pBModels[i].pFaces[j].zCalc1;
|
|
9639 face.zCalc2 = pOutdoor->pBModels[i].pFaces[j].zCalc2;
|
|
9640 face.zCalc3 = pOutdoor->pBModels[i].pFaces[j].zCalc3;
|
|
9641
|
|
9642 face.pXInterceptDisplacements = pOutdoor->pBModels[i].pFaces[j].pXInterceptDisplacements;
|
|
9643 face.pYInterceptDisplacements = pOutdoor->pBModels[i].pFaces[j].pYInterceptDisplacements;
|
|
9644 face.pZInterceptDisplacements = pOutdoor->pBModels[i].pFaces[j].pZInterceptDisplacements;
|
|
9645
|
|
9646 face.uPolygonType = (PolygonType)pOutdoor->pBModels[i].pFaces[j].uPolygonType;
|
|
9647
|
|
9648 face.uNumVertices = pOutdoor->pBModels[i].pFaces[j].uNumVertices;
|
|
9649
|
|
9650 face.uBitmapID = pOutdoor->pBModels[i].pFaces[j].uTextureID;
|
|
9651
|
|
9652 face.pVertexIDs = pOutdoor->pBModels[i].pFaces[j].pVertexIDs;
|
|
9653
|
|
9654 if (!face.Ethereal() && !face.Portal())
|
|
9655 {
|
|
9656 v8 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.normal.x
|
|
9657 + face.pFacePlane_old.vNormal.y * stru_721530.normal.y
|
|
9658 + face.pFacePlane_old.vNormal.z * stru_721530.normal.z) >> 16;
|
|
9659 if (v8 > 0)
|
|
9660 {
|
|
9661 v9 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.normal2.x
|
|
9662 + face.pFacePlane_old.vNormal.y * stru_721530.normal2.y
|
|
9663 + face.pFacePlane_old.vNormal.z * stru_721530.normal2.z) >> 16;
|
|
9664 if (v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d)
|
|
9665 {
|
|
9666 if (v9 <= v8)
|
|
9667 {
|
|
9668 a2 = stru_721530.field_6C;
|
|
9669 if (sub_4754BF(stru_721530.prolly_normal_d, &a2, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
|
|
9670 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &face, i, ecx0))
|
|
9671 {
|
|
9672 v10 = a2;
|
|
9673 }
|
|
9674 else
|
|
9675 {
|
|
9676 a2 = stru_721530.prolly_normal_d + stru_721530.field_6C;
|
|
9677 if (!sub_475F30(&a2, &face, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
|
|
9678 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, i))
|
|
9679 goto LABEL_29;
|
|
9680 v10 = a2 - stru_721530.prolly_normal_d;
|
|
9681 a2 -= stru_721530.prolly_normal_d;
|
|
9682 }
|
|
9683 if (v10 < stru_721530.field_7C)
|
|
9684 {
|
|
9685 stru_721530.field_7C = v10;
|
|
9686 v14 = 8 * (j | (i << 6));
|
|
9687 LOBYTE(v14) = v14 | 6;
|
|
9688 stru_721530.uFaceID = v14;
|
|
9689 }
|
|
9690 }
|
|
9691 }
|
|
9692 }
|
|
9693 LABEL_29:
|
|
9694 if (stru_721530.field_0 & 1)
|
|
9695 {
|
|
9696 v15 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.position.x
|
|
9697 + face.pFacePlane_old.vNormal.y * stru_721530.position.y
|
|
9698 + face.pFacePlane_old.vNormal.z * stru_721530.position.z) >> 16;
|
|
9699 if (v15 > 0)
|
|
9700 {
|
|
9701 v16 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.field_4C
|
|
9702 + face.pFacePlane_old.vNormal.y * stru_721530.field_50
|
|
9703 + face.pFacePlane_old.vNormal.z * stru_721530.field_54) >> 16;
|
|
9704 if (v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d)
|
|
9705 {
|
|
9706 if (v16 <= v15)
|
|
9707 {
|
|
9708 a2 = stru_721530.field_6C;
|
|
9709 if (sub_4754BF(stru_721530.field_8_radius, &a2, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
|
|
9710 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &face, i, ecx0))
|
|
9711 {
|
|
9712 if (a2 < stru_721530.field_7C)
|
|
9713 {
|
|
9714 stru_721530.field_7C = a2;
|
|
9715 v17 = 8 * (j | (i << 6));
|
|
9716 LOBYTE(v17) = v17 | 6;
|
|
9717 stru_721530.uFaceID = v17;
|
|
9718 }
|
|
9719 }
|
|
9720 else
|
|
9721 {
|
|
9722 a2 = stru_721530.field_6C + stru_721530.field_8_radius;
|
|
9723 if (sub_475F30(&a2, &face, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
|
|
9724 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, i))
|
|
9725 {
|
|
9726 v21 = a2 - stru_721530.prolly_normal_d;
|
|
9727 a2 -= stru_721530.prolly_normal_d;
|
|
9728 if (a2 < stru_721530.field_7C)
|
|
9729 {
|
|
9730 stru_721530.field_7C = v21;
|
|
9731 v22 = 8 * (j | (i << 6));
|
|
9732 LOBYTE(v22) = v22 | 6;
|
|
9733 stru_721530.uFaceID = v22;
|
|
9734 }
|
|
9735 }
|
|
9736 }
|
|
9737 }
|
|
9738 }
|
|
9739 }
|
|
9740 }
|
|
9741 }
|
|
9742 }
|
|
9743 }
|
|
9744 }
|
|
9745 result = i;
|
|
9746 }
|
|
9747 return result;
|
|
9748 }
|
|
9749
|
|
9750 //----- (0046ED1B) --------------------------------------------------------
|
|
9751 int collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID)
|
|
9752 {
|
|
9753 uint uFaceID = -1;
|
|
9754 int floor_level = BLV_GetFloorLevel(x, y, z, *pSectorID, &uFaceID);
|
|
9755
|
|
9756 if (floor_level != -30000 && floor_level <= z + 50)
|
|
9757 {
|
|
9758 *pFaceID = uFaceID;
|
|
9759 return floor_level;
|
|
9760 }
|
|
9761
|
|
9762 uint uSectorID = pIndoor->GetSector(x, y, z);
|
|
9763 *pSectorID = uSectorID;
|
|
9764
|
|
9765 floor_level = BLV_GetFloorLevel(x, y, z, uSectorID, &uFaceID);
|
|
9766 if (uSectorID && floor_level != -30000)
|
|
9767 *pFaceID = uFaceID;
|
|
9768 else return -30000;
|
|
9769 return floor_level;
|
|
9770 }
|
|
9771
|
|
9772 //----- (0046ED8A) --------------------------------------------------------
|
|
9773 void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this)
|
|
9774 {
|
|
9775 ObjectDesc *object; // edx@4
|
|
9776 int v10; // ecx@12
|
|
9777 int v11; // esi@13
|
|
9778
|
|
9779 for (uint i = 0; i < uNumSpriteObjects; ++i)
|
|
9780 {
|
|
9781 if (pSpriteObjects[i].uObjectDescID)
|
|
9782 {
|
|
9783 object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
|
|
9784 if (!(object->uFlags & OBJECT_DESC_NO_COLLISION))
|
|
9785 {
|
|
9786 if (stru_721530.sMaxX <= pSpriteObjects[i].vPosition.x + object->uRadius && stru_721530.sMinX >= pSpriteObjects[i].vPosition.x - object->uRadius
|
|
9787 && stru_721530.sMaxY <= pSpriteObjects[i].vPosition.y + object->uRadius && stru_721530.sMinY >= pSpriteObjects[i].vPosition.y - object->uRadius
|
|
9788 && stru_721530.sMaxZ <= pSpriteObjects[i].vPosition.z + object->uHeight && stru_721530.sMinZ >= pSpriteObjects[i].vPosition.z)
|
|
9789 {
|
|
9790 if (abs(((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
|
|
9791 - (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16)
|
|
9792 <= object->uHeight + stru_721530.prolly_normal_d)
|
|
9793 {
|
|
9794 v10 = ((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.x
|
|
9795 + (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.y) >> 16;
|
|
9796 if (v10 > 0)
|
|
9797 {
|
|
9798 v11 = stru_721530.normal.z + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16);
|
|
9799 if (v11 >= pSpriteObjects[i].vPosition.z - stru_721530.prolly_normal_d)
|
|
9800 {
|
|
9801 if (v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z)
|
|
9802 {
|
|
9803 if (v10 < stru_721530.field_7C)
|
|
9804 sub_46DEF2(_this, i);
|
|
9805 }
|
|
9806 }
|
|
9807 }
|
|
9808 }
|
|
9809 }
|
|
9810 }
|
|
9811 }
|
|
9812 }
|
|
9813 }
|
|
9814
|
|
9815 //----- (0046EF01) --------------------------------------------------------
|
|
9816 int _46EF01_collision_chech_player(int a1)
|
|
9817 {
|
|
9818 int result; // eax@1
|
|
9819 int v3; // ebx@7
|
|
9820 int v4; // esi@7
|
|
9821 int v5; // edi@8
|
|
9822 int v6; // ecx@9
|
|
9823 int v7; // edi@12
|
|
9824 int v10; // [sp+14h] [bp-8h]@7
|
|
9825 int v11; // [sp+18h] [bp-4h]@7
|
|
9826
|
|
9827 result = pParty->vPosition.x;
|
|
9828 //v9 = pParty->uPartyHeight;
|
|
9829 if (stru_721530.sMaxX <= pParty->vPosition.x + (2 * pParty->field_14_radius) && stru_721530.sMinX >= pParty->vPosition.x - (2 * pParty->field_14_radius)
|
|
9830 && stru_721530.sMaxY <= pParty->vPosition.y + (2 * pParty->field_14_radius) && stru_721530.sMinY >= pParty->vPosition.y - (2 * pParty->field_14_radius)
|
|
9831 && stru_721530.sMaxZ <= pParty->vPosition.z + pParty->uPartyHeight && stru_721530.sMinZ >= pParty->vPosition.z)
|
|
9832 {
|
|
9833 v3 = stru_721530.prolly_normal_d + (2 * pParty->field_14_radius);
|
|
9834 v11 = pParty->vPosition.x - stru_721530.normal.x;
|
|
9835 v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
|
|
9836 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
|
|
9837 v10 = pParty->vPosition.y - stru_721530.normal.y;
|
|
9838 result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
|
|
9839 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16);
|
|
9840 if (result <= stru_721530.prolly_normal_d + (2 * pParty->field_14_radius))
|
|
9841 {
|
|
9842 result = v10 * stru_721530.direction.y;
|
|
9843 v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16;
|
|
9844 if (v5 > 0)
|
|
9845 {
|
|
9846 v6 = fixpoint_mul(stru_721530.direction.z, v5) + stru_721530.normal.z;
|
|
9847 result = pParty->vPosition.z;
|
|
9848 if (v6 >= pParty->vPosition.z)
|
|
9849 {
|
|
9850 result = pParty->uPartyHeight + pParty->vPosition.z;
|
|
9851 if (v6 <= (signed int)(pParty->uPartyHeight + pParty->vPosition.z) || a1)
|
|
9852 {
|
|
9853 result = integer_sqrt(v3 * v3 - v4 * v4);
|
|
9854 v7 = v5 - integer_sqrt(v3 * v3 - v4 * v4);
|
|
9855 if (v7 < 0)
|
|
9856 v7 = 0;
|
|
9857 if (v7 < stru_721530.field_7C)
|
|
9858 {
|
|
9859 stru_721530.field_7C = v7;
|
|
9860 stru_721530.uFaceID = 4;
|
|
9861 }
|
|
9862 }
|
|
9863 }
|
|
9864 }
|
|
9865 }
|
|
9866 }
|
|
9867 return result;
|
|
9868 }
|
|
9869
|
|
9870 //----- (0046E0B2) --------------------------------------------------------
|
|
9871 void _46E0B2_collide_against_decorations()
|
|
9872 {
|
|
9873 BLVSector *sector; // ebp@1
|
|
9874 LevelDecoration *decor; // edi@2
|
|
9875 DecorationDesc *decor_desc; // esi@3
|
|
9876 int v8; // ebx@10
|
|
9877 int v9; // esi@11
|
|
9878 int v11; // eax@12
|
|
9879 int v12; // esi@14
|
|
9880 unsigned int v13; // eax@17
|
|
9881 signed int i; // [sp+4h] [bp-14h]@1
|
|
9882 int v15; // [sp+8h] [bp-10h]@10
|
|
9883 int v16; // [sp+Ch] [bp-Ch]@10
|
|
9884 int v17; // [sp+10h] [bp-8h]@10
|
|
9885
|
|
9886 sector = &pIndoor->pSectors[stru_721530.uSectorID];
|
|
9887 for (i = 0; i < sector->uNumDecorations; ++i)
|
|
9888 {
|
|
9889 decor = &pLevelDecorations[sector->pDecorationIDs[i]];
|
|
9890 if (!(decor->uFlags & LEVEL_DECORATION_INVISIBLE))
|
|
9891 {
|
|
9892 decor_desc = &pDecorationList->pDecorations[decor->uDecorationDescID];
|
|
9893 if (!decor_desc->CanMoveThrough())
|
|
9894 {
|
|
9895 if (stru_721530.sMaxX <= decor->vPosition.x + decor_desc->uRadius && stru_721530.sMinX >= decor->vPosition.x - decor_desc->uRadius
|
|
9896 && stru_721530.sMaxY <= decor->vPosition.y + decor_desc->uRadius && stru_721530.sMinY >= decor->vPosition.y - decor_desc->uRadius
|
|
9897 && stru_721530.sMaxZ <= decor->vPosition.z + decor_desc->uDecorationHeight && stru_721530.sMinZ >= decor->vPosition.z)
|
|
9898 {
|
|
9899 v16 = decor->vPosition.x - stru_721530.normal.x;
|
|
9900 v15 = decor->vPosition.y - stru_721530.normal.y;
|
|
9901 v8 = stru_721530.prolly_normal_d + decor_desc->uRadius;
|
|
9902 v17 = ((decor->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
|
|
9903 - (decor->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
|
|
9904 if (abs(v17) <= stru_721530.prolly_normal_d + decor_desc->uRadius)
|
|
9905 {
|
|
9906 v9 = (v16 * stru_721530.direction.x + v15 * stru_721530.direction.y) >> 16;
|
|
9907 if (v9 > 0)
|
|
9908 {
|
|
9909 v11 = stru_721530.normal.z + fixpoint_mul(stru_721530.direction.z, v9);
|
|
9910 if (v11 >= decor->vPosition.z)
|
|
9911 {
|
|
9912 if (v11 <= decor_desc->uDecorationHeight + decor->vPosition.z)
|
|
9913 {
|
|
9914 v12 = v9 - integer_sqrt(v8 * v8 - v17 * v17);
|
|
9915 if (v12 < 0)
|
|
9916 v12 = 0;
|
|
9917 if (v12 < stru_721530.field_7C)
|
|
9918 {
|
|
9919 stru_721530.field_7C = v12;
|
|
9920 v13 = 8 * sector->pDecorationIDs[i];
|
|
9921 LOBYTE(v13) = v13 | 5;
|
|
9922 stru_721530.uFaceID = v13;
|
|
9923 }
|
|
9924 }
|
|
9925 }
|
|
9926 }
|
|
9927 }
|
|
9928 }
|
|
9929 }
|
|
9930 }
|
|
9931 }
|
|
9932 }
|
|
9933
|
|
9934 //----- (0046F04E) --------------------------------------------------------
|
|
9935 int _46F04E_collide_against_portals()
|
|
9936 {
|
|
9937 unsigned int v1; // eax@1
|
|
9938 BLVFace *face; // eax@3
|
|
9939 int v4; // ecx@9
|
|
9940 int v5; // edx@9
|
|
9941 signed int result; // eax@21
|
|
9942 unsigned int v10; // [sp+8h] [bp-Ch]@1
|
|
9943 int a3; // [sp+Ch] [bp-8h]@13
|
|
9944 int v12; // [sp+10h] [bp-4h]@15
|
|
9945
|
2535
|
9946 v1 = 0xFFFFFF;
|
|
9947 v10 = 0xFFFFFF;
|
2496
|
9948 for (uint i = 0; i < pIndoor->pSectors[stru_721530.uSectorID].uNumPortals; ++i)
|
|
9949 {
|
|
9950 if (pIndoor->pSectors[stru_721530.uSectorID].pPortals[i] != stru_721530.field_80)
|
|
9951 {
|
|
9952 face = &pIndoor->pFaces[pIndoor->pSectors[stru_721530.uSectorID].pPortals[i]];
|
|
9953 if (stru_721530.sMaxX <= face->pBounding.x2 && stru_721530.sMinX >= face->pBounding.x1
|
|
9954 && stru_721530.sMaxY <= face->pBounding.y2 && stru_721530.sMinY >= face->pBounding.y1
|
|
9955 && stru_721530.sMaxZ <= face->pBounding.z2 && stru_721530.sMinZ >= face->pBounding.z1)
|
|
9956 {
|
|
9957 v4 = (stru_721530.normal.x * face->pFacePlane_old.vNormal.x + face->pFacePlane_old.dist
|
|
9958 + stru_721530.normal.y * face->pFacePlane_old.vNormal.y
|
|
9959 + stru_721530.normal.z * face->pFacePlane_old.vNormal.z) >> 16;
|
|
9960 v5 = (stru_721530.normal2.z * face->pFacePlane_old.vNormal.z + face->pFacePlane_old.dist
|
|
9961 + stru_721530.normal2.x * face->pFacePlane_old.vNormal.x
|
|
9962 + stru_721530.normal2.y * face->pFacePlane_old.vNormal.y) >> 16;
|
|
9963 if ((v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d)
|
|
9964 && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d)
|
|
9965 && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, face))
|
|
9966 && a3 < (signed int)v10)
|
|
9967 {
|
|
9968 v10 = a3;
|
|
9969 v12 = pIndoor->pSectors[stru_721530.uSectorID].pPortals[i];
|
|
9970 }
|
|
9971 }
|
|
9972 }
|
|
9973 }
|
|
9974 v1 = v10;
|
|
9975 if (stru_721530.field_7C >= (signed int)v1 && (signed int)v1 <= stru_721530.field_6C)
|
|
9976 {
|
|
9977 stru_721530.field_80 = v12;
|
|
9978 if (pIndoor->pFaces[v12].uSectorID == stru_721530.uSectorID)
|
|
9979 stru_721530.uSectorID = pIndoor->pFaces[v12].uBackSectorID;
|
|
9980 else
|
|
9981 stru_721530.uSectorID = pIndoor->pFaces[v12].uSectorID;
|
2535
|
9982 stru_721530.field_7C = 268435455;//0xFFFFFFF
|
2496
|
9983 result = 0;
|
|
9984 }
|
|
9985 else
|
|
9986 result = 1;
|
|
9987 return result;
|
|
9988 }
|
|
9989
|
|
9990 //----- (0046DEF2) --------------------------------------------------------
|
|
9991 unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID)
|
|
9992 {
|
|
9993 unsigned int result; // eax@1
|
|
9994
|
|
9995 result = uLayingItemID;
|
|
9996 if (pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID].uFlags & 0x10)
|
|
9997 result = _46BFFA_check_object_intercept(uLayingItemID, a2);
|
|
9998 return result;
|
|
9999 }
|
|
10000
|
|
10001 //----- (0047253E) --------------------------------------------------------
|
|
10002 void UpdateObjects()
|
|
10003 {
|
|
10004 ObjectDesc *object; // eax@5
|
|
10005 int v5; // ecx@6
|
|
10006 signed int v7; // eax@9
|
|
10007 signed int v11; // eax@17
|
|
10008 int v12; // edi@27
|
|
10009 int v18; // [sp+4h] [bp-10h]@27
|
|
10010 int v19; // [sp+8h] [bp-Ch]@27
|
|
10011
|
|
10012 for (uint i = 0; i < uNumSpriteObjects; ++i)
|
|
10013 {
|
|
10014 if (pSpriteObjects[i].uAttributes & OBJECT_40)
|
|
10015 pSpriteObjects[i].uAttributes &= ~OBJECT_40;
|
|
10016 else
|
|
10017 {
|
|
10018 object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
|
|
10019 if (pSpriteObjects[i].AttachedToActor())
|
|
10020 {
|
|
10021 v5 = PID_ID(pSpriteObjects[i].spell_target_pid);
|
|
10022 pSpriteObjects[i].vPosition.x = pActors[v5].vPosition.x;
|
|
10023 pSpriteObjects[i].vPosition.y = pActors[v5].vPosition.y;
|
|
10024 pSpriteObjects[i].vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
|
|
10025 if (!pSpriteObjects[i].uObjectDescID)
|
|
10026 continue;
|
|
10027 pSpriteObjects[i].uSpriteFrameID += pEventTimer->uTimeElapsed;
|
|
10028 if (!(object->uFlags & OBJECT_DESC_TEMPORARY))
|
|
10029 continue;
|
|
10030 if (pSpriteObjects[i].uSpriteFrameID >= 0)
|
|
10031 {
|
|
10032 v7 = object->uLifetime;
|
|
10033 if (pSpriteObjects[i].uAttributes & ITEM_BROKEN)
|
|
10034 v7 = pSpriteObjects[i].field_20;
|
|
10035 if (pSpriteObjects[i].uSpriteFrameID < v7)
|
|
10036 continue;
|
|
10037 }
|
|
10038 SpriteObject::OnInteraction(i);
|
|
10039 continue;
|
|
10040 }
|
|
10041 if (pSpriteObjects[i].uObjectDescID)
|
|
10042 {
|
|
10043 pSpriteObjects[i].uSpriteFrameID += pEventTimer->uTimeElapsed;
|
|
10044 if (object->uFlags & OBJECT_DESC_TEMPORARY)
|
|
10045 {
|
|
10046 if (pSpriteObjects[i].uSpriteFrameID < 0)
|
|
10047 {
|
|
10048 SpriteObject::OnInteraction(i);
|
|
10049 continue;
|
|
10050 }
|
|
10051 v11 = object->uLifetime;
|
|
10052 if (pSpriteObjects[i].uAttributes & ITEM_BROKEN)
|
|
10053 v11 = pSpriteObjects[i].field_20;
|
|
10054 }
|
|
10055 if (!(object->uFlags & OBJECT_DESC_TEMPORARY) || pSpriteObjects[i].uSpriteFrameID < v11)
|
|
10056 {
|
|
10057 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
10058 SpriteObject::UpdateObject_fn0_BLV(i);
|
|
10059 else
|
|
10060 SpriteObject::UpdateObject_fn0_ODM(i);
|
|
10061 if (pParty->bTurnBasedModeOn != 1 || !(pSpriteObjects[i].uSectorID & 4))
|
|
10062 continue;
|
|
10063 v12 = abs(pParty->vPosition.x - pSpriteObjects[i].vPosition.x);
|
|
10064 v18 = abs(pParty->vPosition.y - pSpriteObjects[i].vPosition.y);
|
|
10065 v19 = abs(pParty->vPosition.z - pSpriteObjects[i].vPosition.z);
|
|
10066 if (int_get_vector_length(v12, v18, v19) <= 5120)
|
|
10067 continue;
|
|
10068 SpriteObject::OnInteraction(i);
|
|
10069 continue;
|
|
10070 }
|
|
10071 if (!(object->uFlags & OBJECT_DESC_INTERACTABLE))
|
|
10072 {
|
|
10073 SpriteObject::OnInteraction(i);
|
|
10074 continue;
|
|
10075 }
|
|
10076 _46BFFA_check_object_intercept(i, PID(OBJECT_Item, i));
|
|
10077 }
|
|
10078 }
|
|
10079 }
|
|
10080 }
|
|
10081
|
|
10082 //----- (0047531C) --------------------------------------------------------
|
|
10083 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)
|
|
10084 {
|
|
10085 int v11; // ST1C_4@3
|
|
10086 int v12; // edi@3
|
|
10087 int v13; // esi@3
|
|
10088 int v14; // edi@4
|
|
10089 signed __int64 v15; // qtt@6
|
|
10090 //__int16 v16; // si@7
|
|
10091 int a7a; // [sp+30h] [bp+18h]@7
|
|
10092 int a9b; // [sp+38h] [bp+20h]@3
|
|
10093 int a9a; // [sp+38h] [bp+20h]@3
|
|
10094 int a10b; // [sp+3Ch] [bp+24h]@3
|
|
10095 signed int a10a; // [sp+3Ch] [bp+24h]@4
|
|
10096 int a10c; // [sp+3Ch] [bp+24h]@5
|
|
10097
|
|
10098 if (a10 && face->Ethereal())
|
|
10099 return 0;
|
|
10100 v11 = fixpoint_mul(dir_x, face->pFacePlane_old.vNormal.x);
|
|
10101 a10b = fixpoint_mul(dir_y, face->pFacePlane_old.vNormal.y);
|
|
10102 a9b = fixpoint_mul(dir_z, face->pFacePlane_old.vNormal.z);
|
|
10103 v12 = v11 + a9b + a10b;
|
|
10104 a9a = v11 + a9b + a10b;
|
|
10105 v13 = (a1 << 16)
|
|
10106 - pos_x * face->pFacePlane_old.vNormal.x
|
|
10107 - pos_y * face->pFacePlane_old.vNormal.y
|
|
10108 - pos_z * face->pFacePlane_old.vNormal.z
|
|
10109 - face->pFacePlane_old.dist;
|
|
10110 if (abs((a1 << 16)
|
|
10111 - pos_x * face->pFacePlane_old.vNormal.x
|
|
10112 - pos_y * face->pFacePlane_old.vNormal.y
|
|
10113 - pos_z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16)
|
|
10114 {
|
|
10115 a10c = abs(v13) >> 14;
|
|
10116 if (a10c > abs(v12))
|
|
10117 return 0;
|
|
10118 LODWORD(v15) = v13 << 16;
|
|
10119 HIDWORD(v15) = v13 >> 16;
|
|
10120 v14 = a1;
|
|
10121 a10a = v15 / a9a;
|
|
10122 }
|
|
10123 else
|
|
10124 {
|
|
10125 a10a = 0;
|
|
10126 v14 = abs(v13) >> 16;
|
|
10127 }
|
|
10128 //v16 = pos_y + ((unsigned int)fixpoint_mul(a10a, dir_y) >> 16);
|
|
10129 LOWORD(a7a) = (short)pos_x + ((unsigned int)fixpoint_mul(a10a, dir_x) >> 16) - fixpoint_mul(v14, face->pFacePlane_old.vNormal.x);
|
|
10130 HIWORD(a7a) = pos_y + ((unsigned int)fixpoint_mul(a10a, dir_y) >> 16) - fixpoint_mul(v14, face->pFacePlane_old.vNormal.y);
|
|
10131 if (!sub_475665(face, a7a, (short)pos_z + ((unsigned int)fixpoint_mul(a10a, dir_z) >> 16) - fixpoint_mul(v14, face->pFacePlane_old.vNormal.z)))
|
|
10132 return 0;
|
|
10133 *a2 = a10a >> 16;
|
|
10134 if (a10a >> 16 < 0)
|
|
10135 *a2 = 0;
|
|
10136 return 1;
|
|
10137 }
|
|
10138
|
|
10139
|
|
10140 //----- (004754BF) --------------------------------------------------------
|
|
10141 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)
|
|
10142 {
|
|
10143 int v12; // ST1C_4@3
|
|
10144 int v13; // edi@3
|
|
10145 int v14; // esi@3
|
|
10146 int v15; // edi@4
|
|
10147 signed __int64 v16; // qtt@6
|
|
10148 //__int16 v17; // si@7
|
|
10149 int a7a; // [sp+30h] [bp+18h]@7
|
|
10150 int a1b; // [sp+38h] [bp+20h]@3
|
|
10151 int a1a; // [sp+38h] [bp+20h]@3
|
|
10152 int a11b; // [sp+40h] [bp+28h]@3
|
|
10153 signed int a11a; // [sp+40h] [bp+28h]@4
|
|
10154 int a11c; // [sp+40h] [bp+28h]@5
|
|
10155
|
|
10156 if (a11 && face->Ethereal())
|
|
10157 return false;
|
|
10158 v12 = fixpoint_mul(dir_x, face->pFacePlane_old.vNormal.x);
|
|
10159 a11b = fixpoint_mul(dir_y, face->pFacePlane_old.vNormal.y);
|
|
10160 a1b = fixpoint_mul(dir_z, face->pFacePlane_old.vNormal.z);
|
|
10161 v13 = v12 + a1b + a11b;
|
|
10162 a1a = v12 + a1b + a11b;
|
|
10163 v14 = (a1 << 16)
|
|
10164 - X * face->pFacePlane_old.vNormal.x
|
|
10165 - Y * face->pFacePlane_old.vNormal.y
|
|
10166 - Z * face->pFacePlane_old.vNormal.z
|
|
10167 - face->pFacePlane_old.dist;
|
|
10168 if (abs((a1 << 16)
|
|
10169 - X * face->pFacePlane_old.vNormal.x
|
|
10170 - Y * face->pFacePlane_old.vNormal.y
|
|
10171 - Z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16)
|
|
10172 {
|
|
10173 a11c = abs(v14) >> 14;
|
|
10174 if (a11c > abs(v13))
|
|
10175 return false;
|
|
10176 LODWORD(v16) = v14 << 16;
|
|
10177 HIDWORD(v16) = v14 >> 16;
|
|
10178 v15 = a1;
|
|
10179 a11a = v16 / a1a;
|
|
10180 }
|
|
10181 else
|
|
10182 {
|
|
10183 a11a = 0;
|
|
10184 v15 = abs(v14) >> 16;
|
|
10185 }
|
|
10186 //v17 = Y + ((unsigned int)fixpoint_mul(a11a, dir_y) >> 16);
|
|
10187 LOWORD(a7a) = (short)X + ((unsigned int)fixpoint_mul(a11a, dir_x) >> 16) - fixpoint_mul(v15, face->pFacePlane_old.vNormal.x);
|
|
10188 HIWORD(a7a) = Y + ((unsigned int)fixpoint_mul(a11a, dir_y) >> 16) - fixpoint_mul(v15, face->pFacePlane_old.vNormal.y);
|
|
10189 if (!sub_4759C9(face, a10, a7a, (short)Z + ((unsigned int)fixpoint_mul(a11a, dir_z) >> 16) - fixpoint_mul(v15, face->pFacePlane_old.vNormal.z)))
|
|
10190 return false;
|
|
10191 *a2 = a11a >> 16;
|
|
10192 if (a11a >> 16 < 0)
|
|
10193 *a2 = 0;
|
|
10194 return true;
|
|
10195 }
|
|
10196
|
|
10197 //----- (00475665) --------------------------------------------------------
|
|
10198 int sub_475665(BLVFace *face, int a2, __int16 a3)
|
|
10199 {
|
|
10200 bool v16; // edi@14
|
|
10201 signed int v20; // ebx@18
|
|
10202 int v21; // edi@20
|
|
10203 signed int v22; // ST14_4@22
|
|
10204 signed __int64 v23; // qtt@22
|
|
10205 signed int result; // eax@25
|
|
10206 int v25; // [sp+14h] [bp-10h]@14
|
|
10207 int v26; // [sp+1Ch] [bp-8h]@2
|
|
10208 signed int v27; // [sp+20h] [bp-4h]@2
|
|
10209 signed int v28; // [sp+30h] [bp+Ch]@2
|
|
10210 signed int v29; // [sp+30h] [bp+Ch]@7
|
|
10211 signed int v30; // [sp+30h] [bp+Ch]@11
|
|
10212 signed int v31; // [sp+30h] [bp+Ch]@14
|
|
10213
|
|
10214 if (face->uAttributes & FACE_XY_PLANE)
|
|
10215 {
|
|
10216 v26 = (signed __int16)a2;
|
|
10217 v27 = SHIWORD(a2);
|
|
10218 if (face->uNumVertices)
|
|
10219 {
|
|
10220 for (v28 = 0; v28 < face->uNumVertices; v28++)
|
|
10221 {
|
|
10222 word_720C10_intercepts_xs[2 * v28] = face->pXInterceptDisplacements[v28] + pIndoor->pVertices[face->pVertexIDs[v28]].x;
|
|
10223 word_720B40_intercepts_zs[2 * v28] = face->pYInterceptDisplacements[v28] + pIndoor->pVertices[face->pVertexIDs[v28]].y;
|
|
10224 word_720C10_intercepts_xs[2 * v28 + 1] = face->pXInterceptDisplacements[v28 + 1] + pIndoor->pVertices[face->pVertexIDs[v28 + 1]].x;
|
|
10225 word_720B40_intercepts_zs[2 * v28 + 1] = face->pYInterceptDisplacements[v28 + 1] + pIndoor->pVertices[face->pVertexIDs[v28 + 1]].y;
|
|
10226 }
|
|
10227 }
|
|
10228 }
|
|
10229 else
|
|
10230 {
|
|
10231 if (face->uAttributes & FACE_XZ_PLANE)
|
|
10232 {
|
|
10233 v26 = (signed __int16)a2;
|
|
10234 v27 = a3;
|
|
10235 if (face->uNumVertices)
|
|
10236 {
|
|
10237 for (v29 = 0; v29 < face->uNumVertices; v29++)
|
|
10238 {
|
|
10239 word_720C10_intercepts_xs[2 * v29] = face->pXInterceptDisplacements[v29] + pIndoor->pVertices[face->pVertexIDs[v29]].x;
|
|
10240 word_720B40_intercepts_zs[2 * v29] = face->pZInterceptDisplacements[v29] + pIndoor->pVertices[face->pVertexIDs[v29]].z;
|
|
10241 word_720C10_intercepts_xs[2 * v29 + 1] = face->pXInterceptDisplacements[v29 + 1] + pIndoor->pVertices[face->pVertexIDs[v29 + 1]].x;
|
|
10242 word_720B40_intercepts_zs[2 * v29 + 1] = face->pZInterceptDisplacements[v29 + 1] + pIndoor->pVertices[face->pVertexIDs[v29 + 1]].z;
|
|
10243 }
|
|
10244 }
|
|
10245 }
|
|
10246 else
|
|
10247 {
|
|
10248 v26 = SHIWORD(a2);
|
|
10249 v27 = a3;
|
|
10250 if (face->uNumVertices)
|
|
10251 {
|
|
10252 for (v30 = 0; v30 < face->uNumVertices; v30++)
|
|
10253 {
|
|
10254 word_720C10_intercepts_xs[2 * v30] = face->pYInterceptDisplacements[v30] + pIndoor->pVertices[face->pVertexIDs[v30]].y;
|
|
10255 word_720B40_intercepts_zs[2 * v30] = face->pZInterceptDisplacements[v30] + pIndoor->pVertices[face->pVertexIDs[v30]].z;
|
|
10256 word_720C10_intercepts_xs[2 * v30 + 1] = face->pYInterceptDisplacements[v30 + 1] + pIndoor->pVertices[face->pVertexIDs[v30 + 1]].y;
|
|
10257 word_720B40_intercepts_zs[2 * v30 + 1] = face->pZInterceptDisplacements[v30 + 1] + pIndoor->pVertices[face->pVertexIDs[v30 + 1]].z;
|
|
10258 }
|
|
10259 }
|
|
10260 }
|
|
10261 }
|
|
10262 v31 = 0;
|
|
10263 word_720C10_intercepts_xs[2 * face->uNumVertices] = word_720C10_intercepts_xs[0];
|
|
10264 word_720B40_intercepts_zs[2 * face->uNumVertices] = word_720B40_intercepts_zs[0];
|
|
10265 v16 = word_720B40_intercepts_zs[0] >= v27;
|
|
10266 if (2 * face->uNumVertices <= 0)
|
|
10267 return 0;
|
|
10268 for (v25 = 0; v25 < 2 * face->uNumVertices; ++v25)
|
|
10269 {
|
|
10270 if (v31 >= 2)
|
|
10271 break;
|
|
10272 if (v16 ^ (word_720B40_intercepts_zs[v25 + 1] >= v27))
|
|
10273 {
|
|
10274 if (word_720C10_intercepts_xs[v25 + 1] >= v26)
|
|
10275 v20 = 0;
|
|
10276 else
|
|
10277 v20 = 2;
|
|
10278 v21 = v20 | (word_720C10_intercepts_xs[v25] < v26);
|
|
10279 if (v21 != 3)
|
|
10280 {
|
|
10281 v22 = word_720C10_intercepts_xs[v25 + 1] - word_720C10_intercepts_xs[v25];
|
|
10282 LODWORD(v23) = v22 << 16;
|
|
10283 HIDWORD(v23) = v22 >> 16;
|
|
10284 if (!v21
|
|
10285 || (word_720C10_intercepts_xs[v25] + ((signed int)(((unsigned __int64)(v23
|
|
10286 / (word_720B40_intercepts_zs[v25 + 1] - word_720B40_intercepts_zs[v25])
|
|
10287 * ((v27 - (signed int)word_720B40_intercepts_zs[v25]) << 16)) >> 16)
|
|
10288 + 32768) >> 16) >= v26))
|
|
10289 ++v31;
|
|
10290 }
|
|
10291 }
|
|
10292 v16 = word_720B40_intercepts_zs[v25 + 1] >= v27;
|
|
10293 }
|
|
10294 result = 1;
|
|
10295 if (v31 != 1)
|
|
10296 result = 0;
|
|
10297 return result;
|
|
10298 }
|
|
10299
|
|
10300 //----- (004759C9) --------------------------------------------------------
|
|
10301 bool __fastcall sub_4759C9(BLVFace *face, int a2, int a3, __int16 a4)
|
|
10302 {
|
|
10303 bool v12; // edi@14
|
|
10304 signed int v16; // ebx@18
|
|
10305 int v17; // edi@20
|
|
10306 signed int v18; // ST14_4@22
|
|
10307 signed __int64 v19; // qtt@22
|
|
10308 bool result; // eax@25
|
|
10309 int v21; // [sp+14h] [bp-10h]@14
|
|
10310 signed int v22; // [sp+18h] [bp-Ch]@1
|
|
10311 int v23; // [sp+1Ch] [bp-8h]@2
|
|
10312 signed int v24; // [sp+20h] [bp-4h]@2
|
|
10313 signed int a4d; // [sp+30h] [bp+Ch]@14
|
|
10314
|
|
10315 if (face->uAttributes & FACE_XY_PLANE)
|
|
10316 {
|
|
10317 v23 = (signed __int16)a3;
|
|
10318 v24 = SHIWORD(a3);
|
|
10319 if (face->uNumVertices)
|
|
10320 {
|
|
10321 for (v22 = 0; v22 < face->uNumVertices; ++v22)
|
|
10322 {
|
|
10323 word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pXInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].x);
|
|
10324 word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pYInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].y);
|
|
10325 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pXInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].x);
|
|
10326 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pYInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].y);
|
|
10327 }
|
|
10328 }
|
|
10329 }
|
|
10330 else
|
|
10331 {
|
|
10332 if (face->uAttributes & FACE_XZ_PLANE)
|
|
10333 {
|
|
10334 v23 = (signed __int16)a3;
|
|
10335 v24 = a4;
|
|
10336 if (face->uNumVertices)
|
|
10337 {
|
|
10338 for (v22 = 0; v22 < face->uNumVertices; ++v22)
|
|
10339 {
|
|
10340 word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pXInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].x);
|
|
10341 word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pZInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].z);
|
|
10342 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pXInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].x);
|
|
10343 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pZInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].z);
|
|
10344 }
|
|
10345 }
|
|
10346 }
|
|
10347 else
|
|
10348 {
|
|
10349 v23 = SHIWORD(a3);
|
|
10350 v24 = a4;
|
|
10351 if (face->uNumVertices)
|
|
10352 {
|
|
10353 for (v22 = 0; v22 < face->uNumVertices; ++v22)
|
|
10354 {
|
|
10355 word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pYInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].y);
|
|
10356 word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pZInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].z);
|
|
10357 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pYInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].y);
|
|
10358 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pZInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].z);
|
|
10359 }
|
|
10360 }
|
|
10361 }
|
|
10362 }
|
|
10363 a4d = 0;
|
|
10364 word_720A70_intercepts_xs_plus_xs[2 * face->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0];
|
|
10365 word_7209A0_intercepts_ys_plus_ys[2 * face->uNumVertices] = word_7209A0_intercepts_ys_plus_ys[0];
|
|
10366 v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24;
|
|
10367 if (2 * face->uNumVertices <= 0)
|
|
10368 return 0;
|
|
10369 for (v21 = 0; v21 < 2 * face->uNumVertices; ++v21)
|
|
10370 {
|
|
10371 if (a4d >= 2)
|
|
10372 break;
|
|
10373 if (v12 ^ (word_7209A0_intercepts_ys_plus_ys[v21 + 1] >= v24))
|
|
10374 {
|
|
10375 if (word_720A70_intercepts_xs_plus_xs[v21 + 1] >= v23)
|
|
10376 v16 = 0;
|
|
10377 else
|
|
10378 v16 = 2;
|
|
10379 v17 = v16 | (word_720A70_intercepts_xs_plus_xs[v21] < v23);
|
|
10380 if (v17 != 3)
|
|
10381 {
|
|
10382 v18 = word_720A70_intercepts_xs_plus_xs[v21 + 1] - word_720A70_intercepts_xs_plus_xs[v21];
|
|
10383 LODWORD(v19) = v18 << 16;
|
|
10384 HIDWORD(v19) = v18 >> 16;
|
|
10385 if (!v17
|
|
10386 || (word_720A70_intercepts_xs_plus_xs[v21] + ((signed int)(((unsigned __int64)(v19
|
|
10387 / (word_7209A0_intercepts_ys_plus_ys[v21 + 1] - word_7209A0_intercepts_ys_plus_ys[v21])
|
|
10388 * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v21]) << 16)) >> 16)
|
|
10389 + 0x8000) >> 16) >= v23))
|
|
10390 ++a4d;
|
|
10391 }
|
|
10392 }
|
|
10393 v12 = word_7209A0_intercepts_ys_plus_ys[v21 + 1] >= v24;
|
|
10394 }
|
|
10395 result = 1;
|
|
10396 if (a4d != 1)
|
|
10397 result = 0;
|
|
10398 return result;
|
|
10399 }
|
|
10400
|
|
10401 //----- (00475D85) --------------------------------------------------------
|
|
10402 bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, BLVFace *a4)
|
|
10403 {
|
|
10404 BLVFace *v4; // ebx@1
|
|
10405 int v5; // ST24_4@2
|
|
10406 int v6; // ST28_4@2
|
|
10407 int v7; // edi@2
|
|
10408 int v8; // eax@5
|
|
10409 signed int v9; // esi@5
|
|
10410 signed __int64 v10; // qtt@10
|
|
10411 Vec3_int_ *v11; // esi@11
|
|
10412 int v12; // ST14_4@11
|
|
10413 Vec3_int_ *v14; // [sp+Ch] [bp-18h]@1
|
|
10414 Vec3_int_ *v15; // [sp+14h] [bp-10h]@1
|
|
10415 // int v16; // [sp+18h] [bp-Ch]@2
|
|
10416 int v17; // [sp+20h] [bp-4h]@10
|
|
10417 int a4b; // [sp+30h] [bp+Ch]@2
|
|
10418 int a4c; // [sp+30h] [bp+Ch]@9
|
|
10419 signed int a4a; // [sp+30h] [bp+Ch]@10
|
|
10420
|
|
10421 v4 = a4;
|
|
10422 v15 = a2;
|
|
10423 v14 = a1;
|
|
10424 v5 = fixpoint_mul(a2->x, a4->pFacePlane_old.vNormal.x);
|
|
10425 a4b = fixpoint_mul(a2->y, a4->pFacePlane_old.vNormal.y);
|
|
10426 v6 = fixpoint_mul(a2->z, v4->pFacePlane_old.vNormal.z);
|
|
10427 v7 = v5 + v6 + a4b;
|
|
10428 //(v16 = v5 + v6 + a4b) == 0;
|
|
10429 if (a4->uAttributes & FACE_ETHEREAL || !v7 || v7 > 0 && !v4->Portal())
|
|
10430 return 0;
|
|
10431 v8 = v4->pFacePlane_old.vNormal.z * a1->z;
|
|
10432 v9 = -(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x);
|
|
10433 if (v7 <= 0)
|
|
10434 {
|
|
10435 if (v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x < 0)
|
|
10436 return 0;
|
|
10437 }
|
|
10438 else
|
|
10439 {
|
|
10440 if (v9 < 0)
|
|
10441 return 0;
|
|
10442 }
|
|
10443 a4c = abs(-(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x)) >> 14;
|
|
10444 v11 = v14;
|
|
10445 LODWORD(v10) = v9 << 16;
|
|
10446 HIDWORD(v10) = v9 >> 16;
|
|
10447 a4a = v10 / v7;
|
|
10448 v17 = v10 / v7;
|
|
10449 LOWORD(v12) = LOWORD(v14->x) + (((unsigned int)fixpoint_mul(v17, v15->x) + 0x8000) >> 16);
|
|
10450 HIWORD(v12) = LOWORD(v11->y) + (((unsigned int)fixpoint_mul(v17, v15->y) + 0x8000) >> 16);
|
|
10451 if (a4c > abs(v7) || (v17 > *a3 << 16) || !sub_475665(v4, v12, LOWORD(v11->z) + (((unsigned int)fixpoint_mul(v17, v15->z) + 0x8000) >> 16)))
|
|
10452 return 0;
|
|
10453 *a3 = a4a >> 16;
|
|
10454 return 1;
|
|
10455 }
|
|
10456
|
|
10457 //----- (00475F30) --------------------------------------------------------
|
|
10458 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
|
|
10459 {
|
|
10460 int v10; // ST20_4@2
|
|
10461 int v11; // ST28_4@2
|
|
10462 int v12; // ST24_4@2
|
|
10463 int v13; // zf@2
|
|
10464 int v14; // edi@2
|
|
10465 signed int v16; // esi@5
|
|
10466 int v17; // ST20_4@9
|
|
10467 signed __int64 v18; // qtt@10
|
|
10468 int v19; // ST14_4@11
|
|
10469 int v22; // [sp+1Ch] [bp-8h]@2
|
|
10470 int v23; // [sp+1Ch] [bp-8h]@10
|
|
10471 signed int v24; // [sp+20h] [bp-4h]@10
|
|
10472
|
|
10473 v10 = fixpoint_mul(a6, a2->pFacePlane_old.vNormal.x);
|
|
10474 v11 = fixpoint_mul(a7, a2->pFacePlane_old.vNormal.y);
|
|
10475 v12 = fixpoint_mul(a8, a2->pFacePlane_old.vNormal.z);
|
|
10476 v13 = v10 + v12 + v11;
|
|
10477 v14 = v10 + v12 + v11;
|
|
10478 v22 = v10 + v12 + v11;
|
|
10479 if (a2->Ethereal() || !v13 || v14 > 0 && !a2->Portal())
|
|
10480 return 0;
|
|
10481 v16 = -(a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z);
|
|
10482 if (v14 <= 0)
|
|
10483 {
|
|
10484 if (a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0)
|
|
10485 return 0;
|
|
10486 }
|
|
10487 else
|
|
10488 {
|
|
10489 if (v16 < 0)
|
|
10490 return 0;
|
|
10491 }
|
|
10492 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;
|
|
10493 LODWORD(v18) = v16 << 16;
|
|
10494 HIDWORD(v18) = v16 >> 16;
|
|
10495 v24 = v18 / v22;
|
|
10496 v23 = v18 / v22;
|
|
10497 LOWORD(v19) = a3 + (((unsigned int)fixpoint_mul(v23, a6) + 0x8000) >> 16);
|
|
10498 HIWORD(v19) = a4 + (((unsigned int)fixpoint_mul(v23, a7) + 0x8000) >> 16);
|
|
10499 if (v17 > abs(v14) || v23 > *a1 << 16 || !sub_4759C9(a2, a9, v19, a5 + (((unsigned int)fixpoint_mul(v23, a8) + 0x8000) >> 16)))
|
|
10500 return 0;
|
|
10501 *a1 = v24 >> 16;
|
|
10502 return 1;
|
|
10503 }
|
|
10504
|
|
10505 //----- (00479089) --------------------------------------------------------
|
|
10506 bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable)
|
|
10507 {
|
|
10508 int v3; // edi@1
|
|
10509 int v4; // ebx@1
|
|
10510 int v9; // eax@3
|
|
10511 signed int v11; // esi@6
|
|
10512 int v12; // esi@8
|
|
10513 bool result; // eax@9
|
|
10514 int v17; // [sp+1Ch] [bp-10h]@1
|
|
10515 int v19; // [sp+20h] [bp-Ch]@3
|
|
10516 int angle; // [sp+24h] [bp-8h]@1
|
|
10517
|
|
10518 angle = (signed int)(pODMRenderParams->uCameraFovInDegrees << 11) / 360 / 2;
|
|
10519 v3 = pOutdoor->pBModels[uModelID].vBoundingCenter.x - pGame->pIndoorCameraD3D->vPartyPos.x;
|
|
10520 v4 = pOutdoor->pBModels[uModelID].vBoundingCenter.y - pGame->pIndoorCameraD3D->vPartyPos.y;
|
|
10521 stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX);
|
|
10522 v17 = v3 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) + v4 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
|
|
10523 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
10524 v17 = fixpoint_mul(v17, stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX));
|
|
10525 v19 = v4 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) - v3 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
|
|
10526 v9 = int_get_vector_length(abs(v3), abs(v4), 0);
|
|
10527 //v10 = v14 * 188;
|
|
10528 //v22 = v9;
|
|
10529 *reachable = false;
|
|
10530 if (v9 < pOutdoor->pBModels[uModelID].sBoundingRadius + 256)
|
|
10531 *reachable = true;
|
|
10532 if (v19 >= 0)
|
|
10533 v11 = fixpoint_mul(stru_5C6E00->Sin(angle), v17) - fixpoint_mul(stru_5C6E00->Cos(angle), v19);
|
|
10534 else
|
|
10535 v11 = fixpoint_mul(stru_5C6E00->Cos(angle), v19) + fixpoint_mul(stru_5C6E00->Sin(angle), v17);
|
|
10536 v12 = v11 >> 16;
|
|
10537 if (v9 <= pODMRenderParams->shading_dist_mist + 2048)
|
|
10538 {
|
|
10539 //if ( abs(v12) > *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v10) + 512 )
|
|
10540 if (abs(v12) > pOutdoor->pBModels[uModelID].sBoundingRadius + 512)
|
|
10541 {
|
|
10542 result = v12 < 0;
|
|
10543 LOBYTE(result) = v12 >= 0;
|
|
10544 return result;
|
|
10545 }
|
|
10546 else
|
|
10547 return true;
|
|
10548 }
|
|
10549 return false;
|
|
10550 }
|
|
10551
|
|
10552 //----- (00479295) --------------------------------------------------------
|
|
10553 int Polygon::_479295()
|
|
10554 {
|
|
10555 int v3; // ecx@4
|
|
10556 int v4; // eax@4
|
|
10557 int v5; // edx@4
|
|
10558 // int v6; // ST14_4@5
|
|
10559 Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8
|
|
10560 int v11; // [sp+18h] [bp-4h]@4
|
|
10561
|
|
10562 if (!this->pODMFace->pFacePlane.vNormal.z)
|
|
10563 {
|
|
10564 v3 = this->pODMFace->pFacePlane.vNormal.x;
|
|
10565 v4 = -this->pODMFace->pFacePlane.vNormal.y;
|
|
10566 v5 = 0;
|
|
10567 v11 = 65536;
|
|
10568 }
|
|
10569 else if ((this->pODMFace->pFacePlane.vNormal.x || this->pODMFace->pFacePlane.vNormal.y)
|
|
10570 && abs(this->pODMFace->pFacePlane.vNormal.z) < 59082)
|
|
10571 {
|
|
10572 thisa.x = -this->pODMFace->pFacePlane.vNormal.y;
|
|
10573 thisa.y = this->pODMFace->pFacePlane.vNormal.x;
|
|
10574 thisa.z = 0;
|
|
10575 thisa.Normalize_float();
|
|
10576 v4 = thisa.x;
|
|
10577 v3 = thisa.y;
|
|
10578 v5 = 0;
|
|
10579 v11 = 65536;
|
|
10580 }
|
|
10581 else
|
|
10582 {
|
|
10583 v3 = 0;
|
|
10584 v4 = 65536;
|
|
10585 v11 = 0;
|
|
10586 v5 = -65536;
|
|
10587 }
|
|
10588 sTextureDeltaU = this->pODMFace->sTextureDeltaU;
|
|
10589 sTextureDeltaV = this->pODMFace->sTextureDeltaV;
|
|
10590 ptr_38->_48616B_frustum_odm(v4, v3, 0, 0, v5, v11);
|
|
10591 return 1;
|
|
10592 }
|
|
10593
|
|
10594
|
|
10595 unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr)
|
|
10596 {
|
|
10597 #pragma pack(push, 1)
|
|
10598 struct TGAHeader
|
|
10599 {
|
|
10600 unsigned char tgaSkip;
|
|
10601 unsigned char colourmaptype; // type of colour map 0=none, 1=has palette
|
|
10602 unsigned char tgaType; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed
|
|
10603
|
|
10604 short colourmapstart; // first colour map entry in palette
|
|
10605 short colourmaplength; // number of colours in palette
|
|
10606 char colourmapbits; // number of bits per palette entry 15,16,24,32
|
|
10607
|
|
10608 //unsigned char tgaDontCare2[9];
|
|
10609 short xstart; // image x origin
|
|
10610 short ystart; // image y origin
|
|
10611
|
|
10612 unsigned short tgaWidth;
|
|
10613 unsigned short tgaHeight;
|
|
10614 unsigned char tgaBPP;
|
|
10615
|
|
10616 char descriptor; // image descriptor bits: 00vhaaaa
|
|
10617 // h horizontal flip
|
|
10618 // v vertical flip
|
|
10619 // a alpha bits
|
|
10620 };
|
|
10621 #pragma pack(pop)
|
|
10622
|
|
10623 if (out_width)
|
|
10624 *out_width = 0;
|
|
10625 if (out_height)
|
|
10626 *out_height = 0;
|
|
10627
|
|
10628 DWORD w;
|
|
10629 void* file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
|
|
10630 if (file == INVALID_HANDLE_VALUE)
|
|
10631 return nullptr;
|
|
10632
|
|
10633 TGAHeader header;
|
|
10634 ReadFile(file, &header, sizeof(header), &w, nullptr);
|
|
10635 SetFilePointer(file, header.tgaSkip, nullptr, FILE_CURRENT);
|
|
10636
|
|
10637 if (header.tgaBPP != 24 || header.tgaType != 2)
|
|
10638 {
|
|
10639 CloseHandle(file);
|
|
10640 return nullptr;
|
|
10641 }
|
|
10642
|
|
10643 int imgSize = header.tgaWidth * header.tgaHeight * 3;
|
|
10644 unsigned char* pixels = new unsigned char[imgSize];
|
|
10645 ReadFile(file, pixels, imgSize, &w, nullptr);
|
|
10646 CloseHandle(file);
|
|
10647
|
|
10648 if (w != imgSize)
|
|
10649 {
|
|
10650 delete[] pixels;
|
|
10651 return nullptr;
|
|
10652 }
|
|
10653
|
|
10654 if (out_width)
|
|
10655 *out_width = header.tgaWidth;
|
|
10656 if (out_height)
|
|
10657 *out_height = header.tgaHeight;
|
|
10658
|
|
10659 unsigned short* pixels_16bit = new unsigned short[imgSize / 3];
|
|
10660 for (int i = 0; i < imgSize / 3; ++i)
|
|
10661 {
|
|
10662 pixels_16bit[i] = (pixels[i * 3] / 8 & 0x1F) |
|
|
10663 ((pixels[i * 3 + 1] / 4 & 0x3F) << 5) |
|
|
10664 ((pixels[i * 3 + 2] / 8 & 0x1F) << 11);
|
|
10665 }
|
|
10666 delete[] pixels;
|
|
10667 return pixels_16bit;
|
|
10668 }
|
|
10669
|
|
10670 unsigned short *skybox_xn, *skybox_xp,
|
|
10671 *skybox_yn, *skybox_yp,
|
|
10672 *skybox_zn, *skybox_zp;
|
|
10673 int skybox_width, skybox_height;
|
|
10674
|
|
10675 IDirect3DTexture2 *skybox_texture;
|
|
10676 IDirectDrawSurface4 *skybox_surface;
|
|
10677
|
|
10678 bool Skybox_Initialize(const wchar_t *skybox_name)
|
|
10679 {
|
|
10680 wchar_t xn_filename[1024], xp_filename[1024],
|
|
10681 yn_filename[1024], yp_filename[1024],
|
|
10682 zn_filename[1024], zp_filename[1024];
|
|
10683 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);
|
|
10684 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);
|
|
10685 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);
|
|
10686
|
|
10687 int xn_width, xn_height;
|
|
10688 skybox_xn = LoadTgaTexture(xn_filename, &xn_width, &xn_height);
|
|
10689 if (!skybox_xn)
|
|
10690 return false;
|
|
10691
|
|
10692 int xp_width, xp_height;
|
|
10693 skybox_xp = LoadTgaTexture(xp_filename, &xp_width, &xp_height);
|
|
10694 if (!skybox_xp || xp_width != xn_width || xp_height != xn_height)
|
|
10695 {
|
|
10696 delete[] skybox_xn;
|
|
10697 delete[] skybox_xp;
|
|
10698 return false;
|
|
10699 }
|
|
10700
|
|
10701 int yn_width, yn_height;
|
|
10702 skybox_yn = LoadTgaTexture(yn_filename, &yn_width, &yn_height);
|
|
10703 if (!skybox_yn || yn_width != xn_width || yn_height != xn_height)
|
|
10704 {
|
|
10705 delete[] skybox_xn;
|
|
10706 delete[] skybox_xp;
|
|
10707 delete[] skybox_yn;
|
|
10708 return false;
|
|
10709 }
|
|
10710
|
|
10711 int yp_width, yp_height;
|
|
10712 skybox_yp = LoadTgaTexture(yp_filename, &yp_width, &yp_height);
|
|
10713 if (!skybox_yp || yp_width != xn_width || yp_height != xn_height)
|
|
10714 {
|
|
10715 delete[] skybox_xn;
|
|
10716 delete[] skybox_xp;
|
|
10717 delete[] skybox_yn;
|
|
10718 delete[] skybox_yp;
|
|
10719 return false;
|
|
10720 }
|
|
10721
|
|
10722 int zn_width, zn_height;
|
|
10723 skybox_zn = LoadTgaTexture(zn_filename, &zn_width, &zn_height);
|
|
10724 if (!skybox_zn || zn_width != xn_width || zn_height != xn_height)
|
|
10725 {
|
|
10726 delete[] skybox_xn;
|
|
10727 delete[] skybox_xp;
|
|
10728 delete[] skybox_yn;
|
|
10729 delete[] skybox_yp;
|
|
10730 delete[] skybox_zn;
|
|
10731 return false;
|
|
10732 }
|
|
10733
|
|
10734 int zp_width, zp_height;
|
|
10735 skybox_zp = LoadTgaTexture(zp_filename, &zp_width, &zp_height);
|
|
10736 if (!skybox_zp || zp_width != xn_width || zp_height != xn_height)
|
|
10737 {
|
|
10738 delete[] skybox_xn;
|
|
10739 delete[] skybox_xp;
|
|
10740 delete[] skybox_yn;
|
|
10741 delete[] skybox_yp;
|
|
10742 delete[] skybox_zn;
|
|
10743 delete[] skybox_zp;
|
|
10744 return false;
|
|
10745 }
|
|
10746
|
|
10747 skybox_width = xn_width;
|
|
10748 skybox_height = xn_height;
|
|
10749
|
|
10750 __debugbreak();
|
|
10751 //if (!pRenderer->pRenderD3D->CreateTexture(skybox_width, skybox_height, &skybox_surface, &skybox_texture,
|
|
10752 //false, false, pRenderer->uMinDeviceTextureDim))
|
|
10753 return false;
|
|
10754
|
|
10755 return true;
|
|
10756 }
|
|
10757
|
|
10758 struct vector
|
|
10759 {
|
|
10760 float x, y, z;
|
|
10761 };
|
|
10762
|
|
10763 struct matrix
|
|
10764 {
|
|
10765 float m[4][4];
|
|
10766 };
|
|
10767
|
|
10768 void VectorNormalize(vector *v)
|
|
10769 {
|
|
10770 float invmag = 1.0f / sqrtf(v->x * v->x + v->y * v->y + v->z * v->z);
|
|
10771 v->x *= invmag;
|
|
10772 v->y *= invmag;
|
|
10773 v->z *= invmag;
|
|
10774 }
|
|
10775
|
|
10776 void MatrixRotationAxis(matrix *pout, CONST vector *pv, float angle)
|
|
10777 {
|
|
10778 memset(pout, 0, sizeof(matrix));
|
|
10779 pout->m[3][0] = 0;
|
|
10780 pout->m[3][1] = 0;
|
|
10781 pout->m[3][2] = 0;
|
|
10782 pout->m[3][3] = 1;
|
|
10783
|
|
10784 vector v;
|
|
10785 v.x = pv->x; v.y = pv->y; v.z = pv->z;
|
|
10786 VectorNormalize(&v);
|
|
10787
|
|
10788 pout->m[0][0] = (1.0f - cos(angle)) * v.x * v.x + cos(angle);
|
|
10789 pout->m[1][0] = (1.0f - cos(angle)) * v.x * v.y - sin(angle) * v.z;
|
|
10790 pout->m[2][0] = (1.0f - cos(angle)) * v.x * v.z + sin(angle) * v.y;
|
|
10791 pout->m[0][1] = (1.0f - cos(angle)) * v.y * v.x + sin(angle) * v.z;
|
|
10792 pout->m[1][1] = (1.0f - cos(angle)) * v.y * v.y + cos(angle);
|
|
10793 pout->m[2][1] = (1.0f - cos(angle)) * v.y * v.z - sin(angle) * v.x;
|
|
10794 pout->m[0][2] = (1.0f - cos(angle)) * v.z * v.x - sin(angle) * v.y;
|
|
10795 pout->m[1][2] = (1.0f - cos(angle)) * v.z * v.y + sin(angle) * v.x;
|
|
10796 pout->m[2][2] = (1.0f - cos(angle)) * v.z * v.z + cos(angle);
|
|
10797 }
|
|
10798
|
|
10799 void VectorTransform(const matrix *m, const vector *v, vector *out)
|
|
10800 {
|
|
10801 out->x = m->m[0][0] * v->x + m->m[1][0] * v->y + m->m[2][0] * v->z + m->m[3][0];
|
|
10802 out->y = m->m[0][1] * v->x + m->m[1][1] * v->y + m->m[2][1] * v->z + m->m[3][1];
|
|
10803 out->z = m->m[0][2] * v->x + m->m[1][2] * v->y + m->m[2][2] * v->z + m->m[3][2];
|
|
10804 }
|
|
10805
|
|
10806 bool DrawSkyD3D_Skybox()
|
|
10807 {
|
|
10808 static bool initialized = false,
|
|
10809 initialization_failed = false;
|
|
10810 if (initialization_failed)
|
|
10811 return false;
|
|
10812
|
|
10813 static int last_camera_rot_y,
|
|
10814 last_camera_rot_x;
|
|
10815 if (!initialized)
|
|
10816 {
|
|
10817 if (!Skybox_Initialize(L"data/skybox/stars"))
|
|
10818 {
|
|
10819 initialization_failed = true;
|
|
10820 return false;
|
|
10821 }
|
|
10822 initialized = true;
|
|
10823
|
|
10824 last_camera_rot_y = pParty->sRotationY + 1; // force update for the first run
|
|
10825 last_camera_rot_x = pParty->sRotationX + 1;
|
|
10826 }
|
|
10827
|
|
10828 /*
|
|
10829 r(y) =
|
|
10830 cos y 0 sin y 0
|
|
10831 0 1 0 0
|
|
10832 -sin y 0 cos y 0
|
|
10833 0 0 0 1
|
|
10834
|
|
10835 x cos y - z sin y
|
|
10836 y
|
|
10837 x sin y + z cos y
|
|
10838 1
|
|
10839
|
|
10840
|
|
10841
|
|
10842 r(x) = // should be r(right) actually
|
|
10843 1 0 0 0
|
|
10844 0 cos x -sin x 0
|
|
10845 0 sin x cos x 0
|
|
10846 0 0 0 1
|
|
10847
|
|
10848
|
|
10849 x
|
|
10850 y cos x + z sin x
|
|
10851 -y sin x + z cos x
|
|
10852 1
|
|
10853
|
|
10854 */
|
|
10855
|
|
10856 if (last_camera_rot_y == pParty->sRotationY &&
|
|
10857 last_camera_rot_x == pParty->sRotationX)
|
|
10858 {
|
|
10859 draw:
|
|
10860 struct RenderVertexD3D3 v[6];
|
|
10861
|
|
10862 v[0].pos.x = pViewport->uScreen_TL_X;
|
|
10863 v[0].pos.y = pViewport->uScreen_TL_Y;
|
|
10864 v[0].pos.z = 0.99989998;
|
|
10865 v[0].rhw = 1;
|
|
10866 v[0].diffuse = -1;
|
|
10867 v[0].specular = 0;
|
|
10868 v[0].texcoord.x = 0;
|
|
10869 v[0].texcoord.y = 0;
|
|
10870
|
|
10871 v[1].pos.x = pViewport->uScreen_TL_X + pViewport->uScreenWidth;
|
|
10872 v[1].pos.y = pViewport->uScreen_TL_Y + pViewport->uScreenHeight;
|
|
10873 v[1].pos.z = 0.99989998;
|
|
10874 v[1].rhw = 1;
|
|
10875 v[1].diffuse = -1;
|
|
10876 v[1].specular = 0;
|
|
10877 v[1].texcoord.x = (float)pViewport->uScreenWidth / skybox_width;
|
|
10878 v[1].texcoord.y = (float)pViewport->uScreenHeight / skybox_height;
|
|
10879
|
|
10880 v[2].pos.x = pViewport->uScreen_TL_X + pViewport->uScreenWidth;
|
|
10881 v[2].pos.y = pViewport->uScreen_TL_Y;
|
|
10882 v[2].pos.z = 0.99989998;
|
|
10883 v[2].rhw = 1;
|
|
10884 v[2].diffuse = -1;
|
|
10885 v[2].specular = 0;
|
|
10886 v[2].texcoord.x = (float)pViewport->uScreenWidth / skybox_width;
|
|
10887 v[2].texcoord.y = 0;
|
|
10888
|
|
10889 memcpy(&v[3], &v[0], sizeof(*v));
|
|
10890
|
|
10891 v[4].pos.x = pViewport->uScreen_TL_X;
|
|
10892 v[4].pos.y = pViewport->uScreen_TL_Y + pViewport->uScreenHeight;
|
|
10893 v[4].pos.z = 0.99989998;
|
|
10894 v[4].rhw = 1;
|
|
10895 v[4].diffuse = -1;
|
|
10896 v[4].specular = 0;
|
|
10897 v[4].texcoord.x = 0;
|
|
10898 v[4].texcoord.y = (float)pViewport->uScreenHeight / skybox_height;
|
|
10899
|
|
10900 memcpy(&v[5], &v[1], sizeof(*v));
|
|
10901
|
|
10902 __debugbreak();
|
|
10903 /*
|
|
10904 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
|
|
10905 pRenderer->pRenderD3D->pDevice->SetTexture(0, skybox_texture);
|
|
10906 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v, 6, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT);
|
|
10907 */
|
|
10908 return true;
|
|
10909 }
|
|
10910
|
|
10911
|
|
10912 DDSURFACEDESC2 desc;
|
|
10913 desc.dwSize = sizeof(desc);
|
|
10914 if (!pRenderer->LockSurface_DDraw4(skybox_surface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY))
|
|
10915 return false;
|
|
10916
|
|
10917 last_camera_rot_y = pParty->sRotationY;
|
|
10918 last_camera_rot_x = pParty->sRotationX;
|
|
10919
|
|
10920 float aspect = (float)pViewport->uScreenWidth / (float)pViewport->uScreenHeight;
|
|
10921 float fov_x = 3.141592f * (pODMRenderParams->uCameraFovInDegrees + 0) / 360.0f;
|
|
10922 float fov_y = fov_x / aspect;
|
|
10923
|
|
10924 float ray_dx = fov_x / (float)pViewport->uScreenWidth,
|
|
10925 ray_dy = fov_y / (float)pViewport->uScreenHeight;
|
2534
|
10926 float party_angle_x = 2 * pi_double * pParty->sRotationX / 2048.0,
|
|
10927 party_angle_y = 2 * pi_double * pParty->sRotationY / 2048.0;
|
2496
|
10928 for (int y = 0; y < pViewport->uScreenHeight; ++y)
|
|
10929 for (int x = 0; x < pViewport->uScreenWidth; ++x)
|
|
10930 {
|
|
10931 float angle_x = party_angle_x - (y - pViewport->uScreenHeight / 2) * ray_dy;
|
|
10932 float angle_y = party_angle_y - (x - pViewport->uScreenWidth / 2) * ray_dx;
|
|
10933
|
|
10934 float _dir_x_ = 1,
|
|
10935 _dir_y_ = 0,
|
|
10936 _dir_z_ = 0;
|
|
10937
|
|
10938 float dir_x_ = _dir_x_ * cosf(angle_y);// - _dir_z_ * sinf(angle_y); // rotation around y
|
|
10939 //float dir_y_ = _dir_y_;
|
|
10940 float dir_z_ = _dir_x_ * sinf(angle_y);// + _dir_z_ * cosf(angle_y);
|
|
10941
|
|
10942 //float dir_x = dir_x_; // rotation around x
|
|
10943 //float dir_y = /*dir_y_ * cosf(angle_x)*/ + dir_z_ * sinf(angle_x);
|
|
10944 //float dir_z = /*-dir_y_ * sinf(angle_x)*/ + dir_z_ * cosf(angle_x);
|
|
10945
|
|
10946 vector right; // rotate around right actually to avoid space distortion
|
|
10947 right.x = /*dir_y * 0*/ -dir_z_ * 1;
|
|
10948 right.y = /*dir_z_ * 0 - dir_x_ * */0;
|
|
10949 right.z = dir_x_ * 1/* - dir_y_ * 0*/;
|
|
10950 //VectorNormalize(&right);
|
|
10951
|
|
10952 matrix rightMatrix;
|
|
10953 MatrixRotationAxis(&rightMatrix, &right, angle_x);
|
|
10954
|
|
10955 vector v1, v2;
|
|
10956 v1.x = dir_x_; v1.y = 0; v1.z = dir_z_;
|
|
10957 VectorTransform(&rightMatrix, &v1, &v2);
|
|
10958
|
|
10959 float dir_x = v2.x,
|
|
10960 dir_y = v2.y,
|
|
10961 dir_z = v2.z;
|
|
10962
|
|
10963 float abs_dir_x = fabsf(dir_x),
|
|
10964 abs_dir_y = fabsf(dir_y),
|
|
10965 abs_dir_z = fabsf(dir_z);
|
|
10966
|
|
10967 unsigned short color = (0x1F << 11) | (0x1F << 5) | (5); //default to orange
|
|
10968 if (abs_dir_x >= abs_dir_y)
|
|
10969 {
|
|
10970 if (abs_dir_x >= abs_dir_z)
|
|
10971 {
|
|
10972 if (dir_x >= 0)
|
|
10973 {
|
|
10974 float instersect_y = dir_y / (2.0f * dir_x); // plane equation for this side is x + 0.5 = 0
|
|
10975 float instersect_z = dir_z / (2.0f * dir_x);
|
|
10976
|
|
10977 float u = 1.0f - (instersect_z + 0.5f),
|
|
10978 v = 1.0f - (instersect_y + 0.5f);
|
|
10979
|
|
10980 int tx = u * (skybox_width - 1),
|
|
10981 ty = v * (skybox_height - 1);
|
|
10982
|
|
10983 color = skybox_xp[ty * skybox_width + tx];
|
|
10984 //color = ty * 0x1F / skybox_height;
|
|
10985 }
|
|
10986 else
|
|
10987 {
|
|
10988 float instersect_y = dir_y / (2.0f * dir_x);
|
|
10989 float instersect_z = dir_z / (2.0f * dir_x);
|
|
10990
|
|
10991 float u = 1.0f - (instersect_z + 0.5f),
|
|
10992 v = instersect_y + 0.5f;
|
|
10993
|
|
10994 int tx = u * (skybox_width - 1),
|
|
10995 ty = v * (skybox_height - 1);
|
|
10996
|
|
10997 color = skybox_xn[ty * skybox_width + tx];
|
|
10998 //color = tx * 0x1F / skybox_height;
|
|
10999 }
|
|
11000 }
|
|
11001 else if (dir_z >= 0)
|
|
11002 goto DIR_ZP;
|
|
11003 else
|
|
11004 goto DIR_ZN;
|
|
11005 }
|
|
11006 else if (abs_dir_y >= abs_dir_z)
|
|
11007 {
|
|
11008 if (dir_y >= 0)
|
|
11009 {
|
|
11010 float instersect_x = dir_x / (2.0f * dir_y);
|
|
11011 float instersect_z = dir_z / (2.0f * dir_y);
|
|
11012
|
|
11013 float u = instersect_x + 0.5f,
|
|
11014 v = instersect_z + 0.5f;
|
|
11015
|
|
11016 int tx = u * (skybox_width - 1),
|
|
11017 ty = v * (skybox_height - 1);
|
|
11018
|
|
11019 color = skybox_yp[ty * skybox_width + tx];
|
|
11020 //color = tx * 0x1F / skybox_height;
|
|
11021 }
|
|
11022 /*else should never be seen i guess
|
|
11023 {
|
|
11024 __debugbreak();
|
|
11025 // -y
|
|
11026 //Log::Warning(L"(%03u, %03u): -y", x, y);
|
|
11027 }*/
|
|
11028 }
|
|
11029 else if (dir_z >= 0)
|
|
11030 {
|
|
11031 DIR_ZP:
|
|
11032 // +z
|
|
11033 float instersect_x = dir_x / (2.0f * dir_z);
|
|
11034 float instersect_y = dir_y / (2.0f * dir_z);
|
|
11035 //float intersect_z = 0.5f;
|
|
11036
|
|
11037 float u = instersect_x + 0.5f,
|
|
11038 v = -instersect_y + 0.5f;
|
|
11039
|
|
11040 int tx = u * (skybox_width - 1),
|
|
11041 ty = v * (skybox_height - 1);
|
|
11042
|
|
11043 color = skybox_zp[ty * skybox_width + tx];
|
|
11044 }
|
|
11045 else
|
|
11046 {
|
|
11047 DIR_ZN:
|
|
11048 // -z
|
|
11049 float instersect_x = -dir_x / (2.0f * dir_z);
|
|
11050 float instersect_y = -dir_y / (2.0f * dir_z);
|
|
11051 //float intersect_z = -0.5f;
|
|
11052
|
|
11053 float u = 1.0f - instersect_x - 0.5f,
|
|
11054 v = -instersect_y + 0.5f;
|
|
11055
|
|
11056 int tx = u * (skybox_width - 1),
|
|
11057 ty = v * (skybox_height - 1);
|
|
11058
|
|
11059 color = skybox_zn[ty * skybox_width + tx];
|
|
11060 }
|
|
11061
|
|
11062 //pRenderer->pTargetSurface[(pViewport->uScreenY + y) * pRenderer->uTargetSurfacePitch + pViewport->uScreenX + x] = color;
|
|
11063 ((unsigned __int16 *)((char *)desc.lpSurface + y * desc.lPitch))[x] = color;
|
|
11064 }
|
|
11065
|
|
11066 ErrD3D((skybox_surface)->Unlock(0));
|
|
11067 goto draw;
|
|
11068 }
|
|
11069
|
|
11070 //----- (00485F53) --------------------------------------------------------
|
|
11071 void sr_485F53(Vec2_int_ *v)
|
|
11072 {
|
|
11073 ++v->y;
|
|
11074 if (v->y > 1000)
|
|
11075 v->y = 0;
|
|
11076 }
|
|
11077
|
|
11078 //----- (0048607B) --------------------------------------------------------
|
|
11079 void Polygon::Create_48607B(stru149 *a2)
|
|
11080 {
|
|
11081 this->pTexture = 0;
|
|
11082 this->ptr_38 = a2;
|
|
11083 }
|
|
11084
|
|
11085 //----- (00486089) --------------------------------------------------------
|
|
11086 void Polygon::_normalize_v_18()
|
|
11087 {
|
|
11088 //double v2; // st7@1
|
|
11089 //double v3; // st6@1
|
|
11090 //double v5; // st5@1
|
|
11091
|
|
11092 // v2 = (double)this->v_18.x;
|
|
11093 //v3 = (double)this->v_18.y;
|
|
11094 // v5 = (double)this->v_18.z;
|
|
11095 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);
|
|
11096 if (fabsf(len) < 1e-6f)
|
|
11097 {
|
|
11098 v_18.x = 0;
|
|
11099 v_18.y = 0;
|
|
11100 v_18.z = 65536;
|
|
11101 }
|
|
11102 else
|
|
11103 {
|
|
11104 v_18.x = round_to_int((double)this->v_18.x / len * 65536.0);
|
|
11105 v_18.y = round_to_int((double)this->v_18.y / len * 65536.0);
|
|
11106 v_18.y = round_to_int((double)this->v_18.z / len * 65536.0);
|
|
11107 }
|
|
11108 }
|
|
11109
|
|
11110 //----- (0048616B) --------------------------------------------------------
|
|
11111 void stru149::_48616B_frustum_odm(int a2, int a3, int a4, int a5, int a6, int a7)
|
|
11112 {
|
|
11113 int v7; // ebx@1
|
|
11114 int v9; // edi@1
|
|
11115 int v11; // edx@1
|
|
11116 int v17; // ST0C_4@6
|
|
11117 int v19; // ST0C_4@9
|
|
11118 int v24; // [sp+14h] [bp-14h]@1
|
|
11119 int v25; // [sp+18h] [bp-10h]@1
|
|
11120 int v27; // [sp+24h] [bp-4h]@1
|
|
11121
|
|
11122 v25 = pGame->pIndoorCameraD3D->int_cosine_x;
|
|
11123 v7 = pGame->pIndoorCameraD3D->int_sine_y;
|
|
11124 v27 = pGame->pIndoorCameraD3D->int_sine_x;
|
|
11125 //v8 = -pIndoorCamera->pos.y;
|
|
11126 v9 = pGame->pIndoorCameraD3D->int_cosine_y;
|
|
11127 //v26 = -pIndoorCamera->pos.z;
|
|
11128 v11 = pGame->pIndoorCameraD3D->int_cosine_y * -pGame->pIndoorCameraD3D->vPartyPos.x + pGame->pIndoorCameraD3D->int_sine_y * -pGame->pIndoorCameraD3D->vPartyPos.y;
|
|
11129 v24 = pGame->pIndoorCameraD3D->int_cosine_y * -pGame->pIndoorCameraD3D->vPartyPos.y - pGame->pIndoorCameraD3D->int_sine_y * -pGame->pIndoorCameraD3D->vPartyPos.x;
|
|
11130 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
11131 {
|
|
11132 this->field_0_party_dir_x = fixpoint_mul(v11, pGame->pIndoorCameraD3D->int_cosine_x) +
|
|
11133 fixpoint_mul((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x);
|
|
11134 this->field_4_party_dir_y = v24;
|
|
11135 this->field_8_party_dir_z = fixpoint_mul((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, v25) - fixpoint_mul(v11, v27);
|
|
11136 }
|
|
11137 else
|
|
11138 {
|
|
11139 this->field_0_party_dir_x = v11;
|
|
11140 this->field_4_party_dir_y = v24;
|
|
11141 this->field_8_party_dir_z = (-pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
|
|
11142 }
|
|
11143
|
|
11144 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
11145 {
|
|
11146 v17 = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7);
|
|
11147
|
|
11148 this->angle_from_north = fixpoint_mul(v17, v25) + fixpoint_mul(a4, v27);
|
|
11149 this->angle_from_west = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7);
|
|
11150 this->viewing_angle_from_west_east = fixpoint_mul(a4, v25) - fixpoint_mul(v17, v27);
|
|
11151 }
|
|
11152 else
|
|
11153 {
|
|
11154 this->angle_from_north = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7);
|
|
11155 this->angle_from_west = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7);
|
|
11156 this->viewing_angle_from_west_east = a4;
|
|
11157 }
|
|
11158
|
|
11159 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
11160 {
|
|
11161 v19 = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7);
|
|
11162
|
|
11163 this->angle_from_east = fixpoint_mul(v19, v25) + fixpoint_mul(a7, v27);
|
|
11164 this->angle_from_south = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7);
|
|
11165 this->viewing_angle_from_north_south = fixpoint_mul(a7, v25) - fixpoint_mul(v19, v27);
|
|
11166 }
|
|
11167 else
|
|
11168 {
|
|
11169 this->angle_from_east = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7);
|
|
11170 this->angle_from_south = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7);
|
|
11171 this->viewing_angle_from_north_south = a7;
|
|
11172 }
|
|
11173
|
|
11174 this->angle_from_east = -this->angle_from_east;
|
|
11175 this->angle_from_south = -this->angle_from_south;
|
|
11176 this->viewing_angle_from_north_south = -this->viewing_angle_from_north_south;
|
|
11177
|
|
11178 this->field_24 = fixpoint_dot(this->angle_from_north, this->field_0_party_dir_x,
|
|
11179 this->angle_from_west, this->field_4_party_dir_y,
|
|
11180 this->viewing_angle_from_west_east, this->field_8_party_dir_z);
|
|
11181 this->field_28 = fixpoint_dot(this->angle_from_east, this->field_0_party_dir_x,
|
|
11182 this->angle_from_south, this->field_4_party_dir_y,
|
|
11183 this->viewing_angle_from_north_south, this->field_8_party_dir_z);
|
|
11184 }
|
|
11185
|
|
11186 //----- (0048694B) --------------------------------------------------------
|
|
11187 void stru149::_48694B_frustum_sky()
|
|
11188 {
|
|
11189 this->angle_from_east = -this->angle_from_east;
|
|
11190 this->angle_from_south = -this->angle_from_south;
|
|
11191 this->viewing_angle_from_north_south = -this->viewing_angle_from_north_south;
|
|
11192
|
|
11193 this->field_24 = fixpoint_dot(this->angle_from_north, this->field_0_party_dir_x,
|
|
11194 this->angle_from_west, this->field_4_party_dir_y,
|
|
11195 this->viewing_angle_from_west_east, this->field_8_party_dir_z);
|
|
11196 this->field_28 = fixpoint_dot(this->angle_from_east, this->field_0_party_dir_x,
|
|
11197 this->angle_from_south, this->field_4_party_dir_y,
|
|
11198 this->viewing_angle_from_north_south, this->field_8_party_dir_z);
|
|
11199 }
|
|
11200
|