Mercurial > mm7
annotate Engine/Graphics/Render.cpp @ 2575:a76d408c5132 tip
DrawTranslucent -> DrawTextureGrayShade
Removed old texture drawing stuff
author | a.parshin |
---|---|
date | Wed, 09 Mar 2016 01:39:52 +0200 |
parents | dd36326a9994 |
children |
rev | line source |
---|---|
2496 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
5 #define _CRT_SECURE_NO_WARNINGS | |
6 | |
2541 | 7 #include "Engine/Engine.h" |
8 | |
9 #include "Engine/ZlibWrapper.h" | |
2496 | 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" |
2567 | 15 #include "Engine/stru6.h" |
2502 | 16 #include "GUI/GUIWindow.h" |
2496 | 17 #include "DecalBuilder.h" |
18 #include "ParticleEngine.h" | |
19 #include "Outdoor.h" | |
2541 | 20 #include "Engine/Party.h" |
21 #include "Engine/LOD.h" | |
2496 | 22 #include "Viewport.h" |
2541 | 23 #include "Engine/OurMath.h" |
2496 | 24 #include "PaletteManager.h" |
2541 | 25 #include "Engine/Timer.h" |
2496 | 26 #include "LightmapBuilder.h" |
2541 | 27 #include "Engine/Objects/ObjectList.h" |
28 #include "Engine/Objects/SpriteObject.h" | |
2496 | 29 #include "DecorationList.h" |
2541 | 30 #include "Engine/Objects/Actor.h" |
2496 | 31 #include "Lights.h" |
2499 | 32 #include "Level/Decoration.h" |
2496 | 33 #include "Vis.h" |
34 #include "Weather.h" | |
2541 | 35 #include "Engine/MMT.h" |
2496 | 36 |
37 | |
38 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") | |
39 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") | |
40 | |
41 struct IDirectDrawClipper *pDDrawClipper; | |
42 struct IRender *pRenderer; // idb | |
43 struct RenderVertexD3D3 pVertices[50]; | |
44 int uNumDecorationsDrawnThisFrame; // weak | |
45 RenderBillboard pBillboardRenderList[500]; | |
46 unsigned int uNumBillboardsToDraw; | |
47 int uNumSpritesDrawnThisFrame; // weak | |
48 | |
49 RenderVertexSoft array_507D30[50]; | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
50 RenderVertexSoft VertexRenderList[50];//array_50AC10 |
2496 | 51 RenderVertexSoft array_73D150[20]; |
52 | |
53 RenderVertexD3D3 d3d_vertex_buffer[50]; | |
54 | |
55 /* 384 */ | |
56 #pragma pack(push, 1) | |
57 struct PCXHeader_1 | |
58 { | |
59 char manufacturer; | |
60 char version; | |
61 char encoding; | |
62 char bpp; | |
63 __int16 left; | |
64 __int16 up; | |
65 __int16 right; | |
66 __int16 bottom; | |
67 __int16 hdpi; | |
68 __int16 vdpi; | |
69 }; | |
70 #pragma pack(pop) | |
71 | |
72 /* 385 */ | |
73 #pragma pack(push, 1) | |
74 struct PCXHeader_2 | |
75 { | |
76 char reserved; | |
77 char planes; | |
78 __int16 pitch; | |
79 __int16 palette_info; | |
80 }; | |
81 #pragma pack(pop) | |
82 | |
83 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
84 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
85 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
86 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
87 | |
88 //----- (0049E79F) -------------------------------------------------------- | |
89 bool Render::CheckTextureStages() | |
90 { | |
91 bool v0; // edi@1 | |
92 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
93 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
94 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
95 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
96 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
97 | |
98 v0 = false; | |
99 pRenderD3D->CreateTexture(64, 64, &pSurface1, &pTexture1, true, false, 32); | |
100 pRenderD3D->CreateTexture(64, 64, &pSurface2, &pTexture2, true, false, 32); | |
101 | |
102 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
103 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
104 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2)); | |
105 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
106 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
107 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
108 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1)); | |
109 | |
110 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
111 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
112 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1)); | |
113 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7)); | |
114 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2)); | |
115 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1)); | |
116 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2)); | |
117 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2)); | |
118 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1)); | |
119 | |
120 if ( !pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
121 v0 = true; | |
122 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1)); | |
123 pTexture1->Release(); | |
124 pTexture2->Release(); | |
125 pSurface1->Release(); | |
126 pSurface2->Release(); | |
127 return v0; | |
128 } | |
129 | |
130 | |
131 //----- (00440CB8) -------------------------------------------------------- | |
132 void Render::DrawBillboardList_BLV() | |
133 { | |
134 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
135 | |
136 soft_billboard.sParentBillboardID = -1; | |
137 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; | |
138 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
139 soft_billboard.uTargetPitch = uTargetSurfacePitch; | |
140 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
141 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
142 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
143 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
144 | |
145 pODMRenderParams->uNumBillboards = ::uNumBillboardsToDraw; | |
146 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) | |
147 { | |
148 RenderBillboard* p = &pBillboardRenderList[i]; | |
149 | |
150 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
151 soft_billboard.sParentBillboardID = i; | |
152 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; | |
153 soft_billboard._screenspace_x_scaler_packedfloat = p->_screenspace_x_scaler_packedfloat; | |
154 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; | |
155 soft_billboard.sZValue = p->sZValue; | |
156 soft_billboard.uFlags = p->field_1E; | |
157 soft_billboard.sTintColor = p->sTintColor; | |
158 if ( p->HwSpriteID != -1 ) | |
159 { | |
160 if ( pRenderD3D ) | |
161 DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[p->HwSpriteID], p->dimming_level); | |
162 else | |
163 { | |
164 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); | |
165 if (p->field_1E & 0x0100) | |
166 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
167 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
168 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1); | |
169 if ( p->HwSpriteID >= 0 ) | |
170 pSprites_LOD->pSpriteHeaders[p->HwSpriteID].DrawSprite_sw(&soft_billboard, 1); | |
171 } | |
172 } | |
173 } | |
174 } | |
175 | |
176 //----- (004A16A5) -------------------------------------------------------- | |
177 bool Render::AreRenderSurfacesOk() | |
178 { | |
179 return pFrontBuffer4 && pBackBuffer4; | |
180 } | |
181 | |
182 | |
183 //----- (004A19D8) -------------------------------------------------------- | |
184 unsigned int BlendColors(unsigned int a1, unsigned int a2) | |
185 { | |
186 /*signed __int64 v2; // ST10_8@1 | |
187 double v3; // st7@1 | |
188 float v4; // ST24_4@1 | |
189 double v5; // ST10_8@1 | |
190 int v6; // ST1C_4@1 | |
191 float v7; // ST24_4@1 | |
192 double v8; // ST10_8@1 | |
193 unsigned __int8 v9; // ST20_1@1 | |
194 float v10; // ST24_4@1 | |
195 double v11; // ST10_8@1 | |
196 float v12; // ST24_4@1 | |
197 double v13; // ST08_8@1*/ | |
198 | |
199 uint alpha = (uint)floorf(0.5f + (a1 >> 24) / 255.0f * | |
200 (a2 >> 24) / 255.0f * 255.0f), | |
201 red = (uint)floorf(0.5f + ((a1 >> 16) & 0xFF) / 255.0f * | |
202 ((a2 >> 16) & 0xFF) / 255.0f * 255.0f), | |
203 green = (uint)floorf(0.5f + ((a1 >> 8) & 0xFF) / 255.0f * | |
204 ((a2 >> 8) & 0xFF) / 255.0f * 255.0f), | |
205 blue = (uint)floorf(0.5f + ((a1 >> 0) & 0xFF) / 255.0f * | |
206 ((a2 >> 0) & 0xFF) / 255.0f * 255.0f); | |
207 return (alpha << 24) | (red << 16) | (green << 8) | blue; | |
208 /*v2 = a1 >> 24; | |
209 v3 = (double)v2 / 255.0f; | |
210 HIDWORD(v2) = 0; | |
211 LODWORD(v2) = a2 >> 24; | |
212 v4 = v3 * (double)v2 / 255.0f * 255.0; | |
213 v5 = v4 + 6.7553994e15; | |
214 v6 = LODWORD(v5); | |
215 v7 = (double)((a1 >> 16) & 0xFFi64) / 255.0f * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0; | |
216 v8 = v7 + 6.7553994e15; | |
217 v9 = LOBYTE(v8); | |
218 v10 = (double)((unsigned __int16)a1 >> 8) / 255.0f * (double)((unsigned __int16)a2 >> 8) / 255.0f * 255.0; | |
219 v11 = v10 + 6.7553994e15; | |
220 v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0; | |
221 v13 = v12 + 6.7553994e15; | |
222 return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/ | |
223 } | |
224 | |
225 void Render::RenderTerrainD3D() // New function | |
226 { | |
227 int v6; // ecx@8 | |
228 struct Polygon *pTilePolygon; // ebx@8 | |
229 float Light_tile_dist; | |
230 | |
231 //warning: the game uses CW culling by default, ccw is incosistent | |
232 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
233 | |
234 static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ | |
235 | |
236 //Ãåíåðàöèÿ ìåñòîïîëîæåíèÿ âåðøèí------------------------------------------------------------------------- | |
237 //ðåø¸òêà âåðøèí äåëèòñÿ íà äâå ÷àñòè îò -64 äî 0 è îò 0 äî 64 | |
238 // | |
239 // -64 X 0 64 | |
240 // --------------- 64 | |
241 // | | | | |
242 // | | | | |
243 // | | | | |
244 // 0|------+------| Z | |
245 // | | | | |
246 // | | | | |
247 // | | | | |
248 // --------------- | |
249 // -64 | |
250 | |
251 int blockScale = 512; | |
252 int heightScale = 32; | |
253 for (unsigned int z = 0; z < 128; ++z) | |
254 { | |
255 for (unsigned int x = 0; x < 128; ++x) | |
256 { | |
257 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale; | |
258 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale; | |
259 pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
2543 | 260 pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); |
261 pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
2496 | 262 } |
263 } | |
264 //-------(Îòñå÷åíèå íåâèäèìîé ÷àñòè êàðòû)------------------------------------------------------------------------------------------ | |
2543 | 265 float direction = (float)(pIndoorCameraD3D->sRotationY / 256);//direction of the camera(íàïðâëåíèå êàìåðû) |
2496 | 266 //0-East(B) |
267 //1-NorthEast(CB) | |
268 //2-North(C) | |
269 //3-WestNorth(CÇ) | |
270 //4-West(Ç) | |
271 //5-SouthWest(ÞÇ) | |
272 //6-South(Þ) | |
273 //7-SouthEast(ÞÂ) | |
274 unsigned int Start_X, End_X, Start_Z, End_Z; | |
275 if ( direction >= 0 && direction < 1.0 )//East(B) - NorthEast(CB) | |
276 { | |
2531 | 277 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 128; |
278 Start_Z = 0, End_Z = 128; | |
2496 | 279 } |
280 else if (direction >= 1.0 && direction < 3.0)//NorthEast(CB) - WestNorth(CÇ) | |
281 { | |
2531 | 282 Start_X = 0, End_X = 128; |
2496 | 283 Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ + 1; |
284 } | |
285 else if (direction >= 3.0 && direction < 5.0)//WestNorth(CÇ) - SouthWest(ÞÇ) | |
286 { | |
287 Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 2; | |
2531 | 288 Start_Z = 0, End_Z = 128; |
2496 | 289 } |
290 else if ( direction >= 5.0 && direction < 7.0 )//SouthWest(ÞÇ) - //SouthEast(ÞÂ) | |
291 { | |
2531 | 292 Start_X = 0, End_X = 128; |
293 Start_Z = pODMRenderParams->uMapGridCellZ - 2, End_Z = 128; | |
2496 | 294 } |
295 else//SouthEast(ÞÂ) - East(B) | |
296 { | |
2531 | 297 Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 128; |
298 Start_Z = 0, End_Z = 128; | |
2496 | 299 } |
300 for (unsigned int z = Start_Z; z < End_Z; ++z) | |
301 { | |
302 for (unsigned int x = Start_X; x < End_X; ++x) | |
303 { | |
304 pTilePolygon = &array_77EC08[pODMRenderParams->uNumPolygons]; | |
305 pTilePolygon->flags = 0; | |
306 pTilePolygon->field_32 = 0; | |
307 pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | |
2574 | 308 pTilePolygon->pTexture = (Texture_MM7 *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID]; |
2496 | 309 if (pTilePolygon->uTileBitmapID == 0xFFFF) |
310 continue; | |
311 | |
312 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); | |
313 pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z); | |
314 pTilePolygon->field_32 = 0; | |
315 pTilePolygon->field_59 = 1; | |
316 pTilePolygon->sTextureDeltaU = 0; | |
317 pTilePolygon->sTextureDeltaV = 0; | |
318 // x,z x+1,z | |
319 // .____________. | |
320 // | | | |
321 // | | | |
322 // | | | |
323 // | | | |
324 // | | | |
325 // .____________. | |
326 // x,z+1 x+1,z+1 | |
327 memcpy(&array_73D150[0], &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));//x, z | |
328 array_73D150[0].u = 0; | |
329 array_73D150[0].v = 0; | |
330 memcpy(&array_73D150[1], &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z | |
331 array_73D150[1].u = 1; | |
332 array_73D150[1].v = 0; | |
333 memcpy(&array_73D150[2], &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z + 1 | |
334 array_73D150[2].u = 1; | |
335 array_73D150[2].v = 1; | |
336 memcpy(&array_73D150[3], &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));//x, z + 1 | |
337 array_73D150[3].u = 0; | |
338 array_73D150[3].v = 1; | |
339 //v58 = 0; | |
340 //if (v58 == 4) // if all y == first y; primitive in xz plane | |
341 //pTile->field_32 |= 0x0001; | |
342 pTilePolygon->pODMFace = nullptr; | |
343 pTilePolygon->uNumVertices = 4; | |
344 pTilePolygon->field_59 = 5; | |
345 | |
2531 | 346 if ( array_73D150[0].vWorldViewPosition.x < 8.0 |
347 && array_73D150[1].vWorldViewPosition.x < 8.0 | |
348 && array_73D150[2].vWorldViewPosition.x < 8.0 | |
349 && array_73D150[3].vWorldViewPosition.x < 8.0 ) | |
350 continue; | |
351 if ( (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x | |
352 && (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x | |
353 && (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x | |
354 && (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x ) | |
355 continue; | |
356 //---------------------------------------------------------------------------- | |
357 | |
358 ++pODMRenderParams->uNumPolygons; | |
359 ++pODMRenderParams->field_44; | |
360 assert(pODMRenderParams->uNumPolygons < 20000); | |
361 | |
362 pTilePolygon->uBModelID = 0; | |
363 pTilePolygon->uBModelFaceID = 0; | |
364 pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; | |
365 for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) | |
366 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
367 memcpy(&VertexRenderList[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
368 VertexRenderList[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
2531 | 369 } |
2570 | 370 |
2496 | 371 //shading (çàòåíåíèå)---------------------------------------------------------------------------- |
372 //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; | |
2531 | 373 uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 1]; |
2496 | 374 assert(norm_idx < uNumTerrainNormals); |
375 | |
376 Vec3_float_* norm = &pTerrainNormals[norm_idx]; | |
377 float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - | |
378 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - | |
379 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); | |
380 pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); | |
381 if ( norm_idx < 0 || norm_idx > uNumTerrainNormals - 1 ) | |
382 norm = 0; | |
383 else | |
384 norm = &pTerrainNormals[norm_idx]; | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
385 if (lights_flag) |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
386 { |
2531 | 387 //MessageBoxA(nullptr, "Ritor1: function StackLights_TerrainFace needed refactoring and result - slows", "", 0); |
388 //__debugbreak(); | |
389 | |
2570 | 390 pEngine->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, VertexRenderList, 4, 1);//Ritor1: slows |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
391 //pDecalBuilder->_49BE8A(pTilePolygon, norm, &Light_tile_dist, VertexRenderList, 4, 1); |
2531 | 392 } |
393 unsigned int a5 = 4; | |
394 | |
2496 | 395 //---------Draw distance(Äàëüíîñòü îòðèñîâêè)------------------------------- |
396 int temp = pODMRenderParams->shading_dist_mist; | |
397 if ( draw_terrain_dist_mist ) | |
398 pODMRenderParams->shading_dist_mist = 0x5000; | |
399 bool neer_clip = array_73D150[0].vWorldViewPosition.x < 8.0 | |
400 || array_73D150[1].vWorldViewPosition.x < 8.0 | |
401 || array_73D150[2].vWorldViewPosition.x < 8.0 | |
402 || array_73D150[3].vWorldViewPosition.x < 8.0; | |
403 bool far_clip = (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x | |
404 || (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x | |
405 || (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x | |
406 || (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x; | |
407 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
408 int uClipFlag = 0; |
2531 | 409 static stru154 static_sub_0048034E_stru_154; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
410 pEngine->pLightmapBuilder->StationaryLightsCount = 0; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
411 if ( Lights.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) |
2531 | 412 { |
413 if ( neer_clip ) | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
414 uClipFlag = 3; |
2531 | 415 else |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
416 uClipFlag = far_clip != 0 ? 5 : 0; |
2531 | 417 static_sub_0048034E_stru_154.ClassifyPolygon(norm, Light_tile_dist); |
418 if ( pDecalBuilder->uNumDecals > 0 ) | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
419 pDecalBuilder->ApplyDecals(31 - pTilePolygon->dimming_level, 4, &static_sub_0048034E_stru_154, a5, VertexRenderList, 0, *(float *)&uClipFlag, -1); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
420 if ( Lights.uNumLightsApplied > 0 ) |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
421 pEngine->pLightmapBuilder->ApplyLights(&Lights, &static_sub_0048034E_stru_154, a5, VertexRenderList, 0, uClipFlag); |
2541 | 422 } |
423 | |
424 if ( !byte_4D864C || ~pEngine->uFlags & 0x80 ) | |
2496 | 425 { |
426 //if ( neer_clip ) //Ritor1: Äà¸ò èñêàæåíèÿ íà ïîäú¸ìå, âîçìîæíî òðåáóåòñÿ ô-öèÿ Áåçüå | |
427 //{ | |
428 // pTilePolygon->uNumVertices = ODM_NearClip(pTilePolygon->uNumVertices); | |
429 // ODM_Project(pTilePolygon->uNumVertices); | |
430 //} | |
431 if ( far_clip ) | |
432 { | |
433 pTilePolygon->uNumVertices = ODM_FarClip(pTilePolygon->uNumVertices); | |
434 ODM_Project(pTilePolygon->uNumVertices); | |
435 } | |
436 } | |
437 pODMRenderParams->shading_dist_mist = temp; | |
438 | |
439 // check the transparency and texture (tiles) mapping (ïðîâåðêà ïðîçðà÷íîñòè è íàëîæåíèå òåêñòóð (òàéëîâ))---------------------- | |
440 bool transparent = false; | |
441 if ( !( pTilePolygon->flags & 1 ) ) // íå ïîääåðæèâàåòñÿ TextureFrameTable | |
442 { | |
443 if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id) | |
444 { | |
445 //transparent = false; | |
446 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
447 } | |
448 else | |
449 { | |
450 v6 = pTilePolygon->uTileBitmapID; | |
451 if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) ) | |
452 transparent = true; | |
453 } | |
454 | |
2570 | 455 assert(v6 < 1000); // many random crashes here |
456 | |
457 // for all shore tiles - draw a tile water under them since they're half-empty | |
458 if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX | |
459 DrawBorderTiles(pTilePolygon); | |
460 | |
461 pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
2496 | 462 } |
463 //else //çäåñü óæå ïîãðàíè÷íûå òàéëû âîäû | |
464 //pTile->DrawBorderTiles(); | |
465 //-------------------------------------------------------------------------------------------------------------------------------- | |
466 | |
2570 | 467 //--pODMRenderParams->uNumPolygons; |
468 //--pODMRenderParams->field_44; | |
2496 | 469 } |
470 } | |
471 } | |
472 | |
473 //----- (004811A3) -------------------------------------------------------- | |
474 void Render::DrawBorderTiles(struct Polygon *poly) | |
475 { | |
476 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false); | |
477 DrawTerrainPolygon(poly->uNumVertices, poly, | |
478 pBitmaps_LOD->pHardwareTextures[pHDWaterBitmapIDs[hd_water_current_frame]], false, true); | |
479 | |
480 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true); | |
481 //DrawTerrainPolygon(poly->uNumVertices, poly, pBitmaps_LOD->pHardwareTextures[poly->uTileBitmapID], true, true); | |
482 } | |
483 | |
484 | |
485 //----- (0047BACF) -------------------------------------------------------- | |
486 void Render::TransformBillboardsAndSetPalettesODM() | |
487 { | |
488 //int v0; // edi@1 | |
489 //char *v1; // esi@2 | |
490 //unsigned int v2; // edx@3 | |
491 //int v3; // eax@3 | |
492 //int v4; // edi@3 | |
493 //int v5; // eax@3 | |
494 //__int16 v6; // di@3 | |
495 //int v7; // eax@3 | |
496 //int v8; // ebx@4 | |
497 // unsigned __int16 *v9; // eax@7 | |
498 // char v10; // zf@9 | |
499 //DWORD v11; // eax@13 | |
500 // int v12; // eax@13 | |
501 // int v13; // eax@14 | |
502 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
503 // int v15; // [sp+54h] [bp-10h]@13 | |
504 //int v16; // [sp+58h] [bp-Ch]@1 | |
505 //int v17; // [sp+5Ch] [bp-8h]@2 | |
506 // int v18; // [sp+60h] [bp-4h]@13 | |
507 | |
508 billboard.sParentBillboardID = -1; | |
509 billboard.pTarget = pRenderer->pTargetSurface; | |
510 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
511 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
512 billboard.uViewportX = pViewport->uViewportTL_X; | |
513 billboard.uViewportY = pViewport->uViewportTL_Y; | |
514 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
515 billboard.uViewportW = pViewport->uViewportBR_Y; | |
516 pODMRenderParams->uNumBillboards = uNumBillboardsToDraw; | |
517 | |
518 for (unsigned int i = 0; i < ::uNumBillboardsToDraw; ++i) | |
519 { | |
520 billboard.uScreenSpaceX = pBillboardRenderList[i].uScreenSpaceX; | |
521 billboard.uScreenSpaceY = pBillboardRenderList[i].uScreenSpaceY; | |
522 billboard.sParentBillboardID = i; | |
523 billboard._screenspace_x_scaler_packedfloat = pBillboardRenderList[i]._screenspace_x_scaler_packedfloat; | |
524 billboard.sTintColor = pBillboardRenderList[i].sTintColor; | |
525 billboard._screenspace_y_scaler_packedfloat = pBillboardRenderList[i]._screenspace_y_scaler_packedfloat; | |
526 billboard.sZValue = pBillboardRenderList[i].sZValue; | |
527 billboard.uFlags = pBillboardRenderList[i].field_1E; | |
528 if (pBillboardRenderList[i].HwSpriteID != -1) | |
529 { | |
530 if (!pRenderD3D) __debugbreak(); // no sw rendering | |
531 //if (pRenderer->pRenderD3D) | |
532 TransformBillboard(&billboard, | |
533 &pSprites_LOD->pHardwareSprites[pBillboardRenderList[i].HwSpriteID], | |
534 pBillboardRenderList[i].dimming_level, &pBillboardRenderList[i]); | |
535 /*else | |
536 { | |
537 assert(false); | |
538 | |
539 auto v1 = (char *)&pBillboard->uScreenSpaceY; | |
540 if ( *(v1 - 10) & 2 ) | |
541 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
542 else | |
543 v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); | |
544 v10 = (*(v1 - 9) & 1) == 0; | |
545 billboard.pPalette = v9; | |
546 if ( !v10 ) | |
547 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
548 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
549 { | |
550 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); | |
551 v15 = abs(v12); | |
552 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
553 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
554 } | |
555 v13 = *((short *)v1 - 8); | |
556 if ( v13 >= 0 ) | |
557 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); | |
558 }*/ | |
559 } | |
560 } | |
561 } | |
562 | |
563 //----- (0047AF11) -------------------------------------------------------- | |
564 void Render::DrawSpriteObjects_ODM() | |
565 { | |
566 SpriteFrame *frame; // eax@10 | |
567 unsigned int v6; // eax@10 | |
568 int v9; // ecx@10 | |
569 int v17; // ecx@25 | |
570 int v18; // eax@25 | |
571 // int v22; // ST3C_4@29 | |
572 signed __int64 v23; // qtt@30 | |
573 int v26; // eax@31 | |
574 // char v27; // zf@31 | |
575 int v30; // [sp+14h] [bp-2Ch]@23 | |
576 int v37; // [sp+1Ch] [bp-24h]@23 | |
577 int a6; // [sp+20h] [bp-20h]@10 | |
578 int v42; // [sp+2Ch] [bp-14h]@23 | |
579 int y; // [sp+30h] [bp-10h]@10 | |
580 int x; // [sp+34h] [bp-Ch]@10 | |
581 int z; // [sp+38h] [bp-8h]@10 | |
582 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
583 | |
584 //v41 = 0; | |
585 for (unsigned int i = 0; i < uNumSpriteObjects; ++i) | |
586 { | |
587 SpriteObject* object = &pSpriteObjects[i]; | |
588 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; | |
589 //v0 = (char *)&pSpriteObjects[0].uSectorID; | |
590 //do | |
591 //{ | |
592 if (!object->uObjectDescID) // item probably pciked up | |
593 continue; | |
594 | |
595 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
596 ObjectDesc* object_desc = &pObjectList->pObjects[object->uObjectDescID]; | |
597 if (object_desc->NoSprite()) | |
598 continue; | |
599 | |
600 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
601 //if ( !(v1->uFlags & 1) ) | |
602 //{ | |
603 //v2 = *((short *)v0 - 14) | |
604 //v2 = object->uType; | |
605 if ( (object->uType < 1000 || object->uType >= 10000) && (object->uType < 500 || object->uType >= 600) | |
2566 | 606 || pEngine->pStru6Instance->RenderAsSprite(object) ) |
2496 | 607 { |
608 //a5 = *(short *)v0; | |
609 x = object->vPosition.x; | |
610 y = object->vPosition.y; | |
611 z = object->vPosition.z; | |
612 frame = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); | |
613 a6 = frame->uGlowRadius * object->field_22_glow_radius_multiplier; | |
2543 | 614 v6 = stru_5C6E00->Atan2(object->vPosition.x - pIndoorCameraD3D->vPartyPos.x, object->vPosition.y - pIndoorCameraD3D->vPartyPos.y); |
2496 | 615 //LOWORD(v7) = object->uFacing; |
616 //v8 = v36; | |
617 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; | |
618 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[v9]; | |
619 if ( frame->uFlags & 0x20 ) | |
620 { | |
621 //v8 = v36; | |
622 z -= fixpoint_mul(frame->scale, pSprites_LOD->pSpriteHeaders[(signed __int16)frame->pHwSpriteIDs[v9]].uHeight) / 2; | |
623 } | |
624 v46 = 0; | |
625 if ( frame->uFlags & 2 ) | |
626 v46 = 2; | |
627 //v11 = (int *)(256 << v9); | |
628 if ( (256 << v9) & frame->uFlags ) | |
629 v46 |= 4; | |
630 if ( frame->uFlags & 0x40000 ) | |
631 v46 |= 0x40; | |
632 if ( frame->uFlags & 0x20000 ) | |
633 LOBYTE(v46) = v46 | 0x80; | |
634 if ( a6 ) | |
635 { | |
636 //LOBYTE(v11) = _4E94D3_light_type; | |
637 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFF, 0xFF, 0xFF, _4E94D3_light_type); | |
638 } | |
2543 | 639 if (pIndoorCameraD3D->sRotationX) |
640 { | |
641 v30 = fixpoint_mul((x - pIndoorCameraD3D->vPartyPos.x) << 16, pIndoorCameraD3D->int_cosine_y) | |
642 + fixpoint_mul((y - pIndoorCameraD3D->vPartyPos.y) << 16, pIndoorCameraD3D->int_sine_y); | |
643 v37 = fixpoint_mul((x - pIndoorCameraD3D->vPartyPos.x) << 16, pIndoorCameraD3D->int_sine_y); | |
644 v42 = fixpoint_mul((z - pIndoorCameraD3D->vPartyPos.z) << 16, pIndoorCameraD3D->int_sine_x) | |
645 + fixpoint_mul(v30, pIndoorCameraD3D->int_cosine_x); | |
2496 | 646 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) |
647 { | |
2543 | 648 v17 = fixpoint_mul((y - pIndoorCameraD3D->vPartyPos.y) << 16, pIndoorCameraD3D->int_cosine_y) - v37; |
649 v18 = fixpoint_mul((z - pIndoorCameraD3D->vPartyPos.z) << 16, pIndoorCameraD3D->int_cosine_x) | |
650 - fixpoint_mul(v30, pIndoorCameraD3D->int_sine_x); | |
2496 | 651 if ( abs(v42) >= abs(v17) ) |
652 { | |
653 LODWORD(v23) = 0; | |
654 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); | |
655 | |
656 object->uAttributes |= 1; | |
657 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; | |
658 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID; | |
659 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
660 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; | |
661 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
662 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46; | |
663 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x; | |
664 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y; | |
665 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z; | |
666 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16); | |
667 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16); | |
668 HIWORD(v26) = HIWORD(v42); | |
669 LOWORD(v26) = 0; | |
670 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i)); | |
671 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
672 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; | |
673 if ( !(object->uAttributes & 0x20) ) | |
674 { | |
675 if ( !pRenderD3D ) | |
676 { | |
677 __debugbreak(); | |
678 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0; | |
679 } | |
680 } | |
681 //if (::uNumBillboardsToDraw >= 500) | |
682 // return; | |
683 assert(::uNumBillboardsToDraw < 500); | |
684 ++::uNumBillboardsToDraw; | |
685 ++uNumSpritesDrawnThisFrame; | |
686 } | |
687 } | |
688 } | |
689 else | |
690 { | |
2543 | 691 v42 = fixpoint_mul((y - pIndoorCameraD3D->vPartyPos.y) << 16, pIndoorCameraD3D->int_sine_y) |
692 + fixpoint_mul((x - pIndoorCameraD3D->vPartyPos.x) << 16, pIndoorCameraD3D->int_cosine_y); | |
2496 | 693 if ( v42 >= 0x40000 && v42 <= pODMRenderParams->shading_dist_mist << 16 ) |
694 { | |
2543 | 695 v17 = fixpoint_mul((y - pIndoorCameraD3D->vPartyPos.y) << 16, pIndoorCameraD3D->int_cosine_y) |
696 - fixpoint_mul(((x - pIndoorCameraD3D->vPartyPos.x) << 16), pIndoorCameraD3D->int_sine_y); | |
697 v18 = (z - pIndoorCameraD3D->vPartyPos.z) << 16; | |
2496 | 698 if ( abs(v42) >= abs(v17) ) |
699 { | |
700 LODWORD(v23) = 0; | |
701 HIDWORD(v23) = SLOWORD(pODMRenderParams->int_fov_rad); | |
702 | |
703 object->uAttributes |= 1; | |
704 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; | |
705 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = object->uSectorID; | |
706 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
707 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; | |
708 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = fixpoint_mul(frame->scale, v23 / v42); | |
709 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v46; | |
710 pBillboardRenderList[::uNumBillboardsToDraw].world_x = x; | |
711 pBillboardRenderList[::uNumBillboardsToDraw].world_y = y; | |
712 pBillboardRenderList[::uNumBillboardsToDraw].world_z = z; | |
713 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v23 / v42, v17) + 0x8000) >> 16); | |
714 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = pViewport->uScreenCenterY - (((unsigned int)fixpoint_mul(v23 / v42, v18) + 0x8000) >> 16); | |
715 HIWORD(v26) = HIWORD(v42); | |
716 LOWORD(v26) = 0; | |
717 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v26 + (PID(OBJECT_Item,i)); | |
718 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
719 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; | |
720 if ( !(object->uAttributes & 0x20) ) | |
721 { | |
722 if ( !pRenderD3D ) | |
723 { | |
724 __debugbreak(); | |
725 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = 0; | |
726 } | |
727 } | |
728 //if (::uNumBillboardsToDraw >= 500) | |
729 // return; | |
730 assert(::uNumBillboardsToDraw < 500); | |
731 ++::uNumBillboardsToDraw; | |
732 ++uNumSpritesDrawnThisFrame; | |
733 } | |
734 } | |
735 } | |
736 } | |
737 } | |
738 } | |
739 | |
740 //----- (0049D9BC) -------------------------------------------------------- | |
741 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
742 { | |
743 size_t v4; // eax@1 | |
744 size_t v5; // eax@1 | |
745 size_t v7; // eax@13 | |
746 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
747 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16*/ | |
748 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
749 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
750 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
751 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
752 int is_there_a_compatible_screen_mode; // [sp+4C8h] [bp-34h]@16 | |
753 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
754 LPDIRECTDRAW pDirectDraw = nullptr; // [sp+4F4h] [bp-8h]@4 | |
755 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
756 | |
757 v4 = strlen(lpDriverName); | |
758 v20.pDriverName = new char[v4 + 1]; | |
759 v5 = strlen(lpDevDesc); | |
760 v20.pDeviceDesc = new char[v5 + 1]; | |
761 strcpy(v20.pDriverName, lpDriverName); | |
762 strcpy(v20.pDeviceDesc, lpDevDesc); | |
763 if ( lpGUID ) | |
764 { | |
765 v20.pGUID = new GUID; | |
766 memcpy(v20.pGUID, lpGUID, 0x10); | |
767 } | |
768 else | |
769 v20.pGUID = 0; | |
770 | |
771 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
772 { | |
773 delete [] v20.pDriverName; | |
774 delete [] v20.pDeviceDesc; | |
775 delete v20.pGUID; | |
776 } | |
777 else | |
778 { | |
779 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
780 { | |
781 delete [] v20.pDriverName; | |
782 delete [] v20.pDeviceDesc; | |
783 delete v20.pGUID; | |
784 pDirectDraw->Release(); | |
785 } | |
786 else | |
787 { | |
788 pDirectDraw->Release(); | |
789 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1))) | |
790 v20.pDDraw4DevDesc = 0; | |
791 else | |
792 { | |
793 v7 = strlen(ddDevId.szDescription); | |
794 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
795 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
796 } | |
797 memset(&ddsCaps, 0, sizeof(ddsCaps)); | |
798 if (FAILED(pDirectDraw4->GetAvailableVidMem(&ddsCaps, (LPDWORD)&v20.uVideoMem, (LPDWORD)&uFreeVideoMem))) | |
799 v20.uVideoMem = 0; | |
800 memset(&v10, 0, sizeof(v10)); | |
801 v10.dwSize = 124; | |
802 v10.dwFlags = 6; | |
803 v10.dwHeight = window->GetWidth(); | |
804 v10.dwWidth = window->GetHeight(); | |
805 v10.ddpfPixelFormat.dwSize = 32; | |
806 | |
807 is_there_a_compatible_screen_mode = false; | |
808 if ( FAILED(pDirectDraw4->EnumDisplayModes(0, 0, &is_there_a_compatible_screen_mode, (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) | |
809 || !is_there_a_compatible_screen_mode | |
810 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
811 { | |
812 delete [] v20.pDriverName; | |
813 delete [] v20.pDeviceDesc; | |
814 //free(v20.pDDraw4DevDesc); | |
815 delete [] v20.pDDraw4DevDesc; | |
816 delete v20.pGUID; | |
817 pDirectDraw4->Release(); | |
818 } | |
819 else | |
820 { | |
821 aux.pInfo = pOut; | |
822 aux.ptr_4 = &v20; | |
823 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
824 delete [] v20.pDriverName; | |
825 delete [] v20.pDeviceDesc; | |
826 delete [] v20.pDDraw4DevDesc; | |
827 delete v20.pGUID; | |
828 pDirectDraw4->Release(); | |
829 pDirectDraw4 = 0; | |
830 pDirect3D3->Release(); | |
831 } | |
832 } | |
833 } | |
834 return 1; | |
835 } | |
836 | |
837 //----- (0049D784) -------------------------------------------------------- | |
838 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
839 { | |
840 signed int v7; // edi@1 | |
841 | |
842 v7 = -1; | |
843 if ( pHWDesc->dwFlags ) | |
844 { | |
845 if ( !a6->ptr_4->pGUID ) | |
846 v7 = 0; | |
847 if ( pHWDesc->dwFlags && a6->ptr_4->pGUID ) | |
848 v7 = 1; | |
849 } | |
850 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
851 v7 = 2; | |
852 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
853 v7 = 3; | |
854 if ( v7 != -1 ) | |
855 { | |
856 a6->pInfo[v7].bIsDeviceCompatible = 1; | |
857 a6->pInfo[v7].uCaps = 0; | |
858 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
859 a6->pInfo[v7].uCaps |= 2; | |
860 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
861 a6->pInfo[v7].uCaps |= 4; | |
862 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
863 a6->pInfo[v7].uCaps |= 8; | |
864 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
865 a6->pInfo[v7].uCaps |= 16; | |
866 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
867 a6->pInfo[v7].uCaps |= 32; | |
868 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
869 a6->pInfo[v7].uCaps |= 64; | |
870 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
871 BYTE1(a6->pInfo[v7].uCaps) |= 1; | |
872 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
873 LOBYTE(a6->pInfo[v7].uCaps) |= 0x80; | |
874 | |
875 a6->pInfo[v7].pName = new char[strlen(lpDeviceName) + 1]; | |
876 strcpy(a6->pInfo[v7].pName, lpDeviceName); | |
877 | |
878 a6->pInfo[v7].pDescription = new char[strlen(lpDeviceDesc) + 1]; | |
879 strcpy(a6->pInfo[v7].pDescription, lpDeviceDesc); | |
880 | |
881 a6->pInfo[v7].pGUID = new GUID; | |
882 memcpy(a6->pInfo[v7].pGUID, lpGUID, 0x10); | |
883 | |
884 a6->pInfo[v7].pDriverName = new char[strlen(a6->ptr_4->pDriverName) + 1]; | |
885 strcpy(a6->pInfo[v7].pDriverName, a6->ptr_4->pDriverName); | |
886 | |
887 a6->pInfo[v7].pDeviceDesc = new char[strlen(a6->ptr_4->pDeviceDesc) + 1]; | |
888 strcpy(a6->pInfo[v7].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
889 | |
890 a6->pInfo[v7].pDDraw4DevDesc = new char[strlen(a6->ptr_4->pDDraw4DevDesc) + 1]; | |
891 strcpy(a6->pInfo[v7].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
892 | |
893 if ( a6->ptr_4->pGUID ) | |
894 { | |
895 a6->pInfo[v7].pDirectDrawGUID = new GUID; | |
896 memcpy(a6->pInfo[v7].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10); | |
897 } | |
898 else | |
899 a6->pInfo[v7].pDirectDrawGUID = 0; | |
900 a6->pInfo[v7].uVideoMem = a6->ptr_4->uVideoMem; | |
901 } | |
902 return 1; | |
903 } | |
904 | |
905 //----- (0049D75C) -------------------------------------------------------- | |
906 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *found_compatible_mode) | |
907 { | |
908 if ( pSurfaceDesc->ddsCaps.dwCaps | DDSCAPS_3DDEVICE /*&& pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16*/ ) | |
909 { | |
910 *found_compatible_mode = 1; | |
911 return S_OK; | |
912 } | |
913 return 1; | |
914 } | |
915 | |
916 //----- (0047A95E) -------------------------------------------------------- | |
917 void Render::PrepareDecorationsRenderList_ODM() | |
918 { | |
919 unsigned int v6; // edi@9 | |
920 int v7; // eax@9 | |
2508 | 921 SpriteFrame *frame; // eax@9 |
2496 | 922 unsigned __int16 *v10; // eax@9 |
923 int v13; // ecx@9 | |
2532 | 924 char r; // ecx@20 |
925 char g; // dl@20 | |
926 char b_; // eax@20 | |
2496 | 927 int v17; // eax@23 |
928 int v18; // ecx@24 | |
929 int v19; // eax@24 | |
930 int v20; // ecx@24 | |
931 int v21; // ebx@26 | |
932 int v22; // eax@26 | |
933 signed __int64 v24; // qtt@31 | |
934 int v25; // ebx@31 | |
935 __int16 v29; // cx@37 | |
936 int v30; // ecx@37 | |
937 int v31; // ebx@37 | |
938 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 | |
939 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 | |
940 int v38; // [sp+88h] [bp-1Ch]@9 | |
941 int v40; // [sp+90h] [bp-14h]@24 | |
942 int v41; // [sp+94h] [bp-10h]@24 | |
943 int v42; // [sp+98h] [bp-Ch]@9 | |
944 int b; // [sp+A0h] [bp-4h]@22 | |
945 | |
946 for (unsigned int i = 0; i < uNumLevelDecorations; ++i) | |
947 { | |
948 //LevelDecoration* decor = &pLevelDecorations[i]; | |
949 if ((!(pLevelDecorations[i].uFlags & LEVEL_DECORATION_OBELISK_CHEST) | |
950 || pLevelDecorations[i].IsObeliskChestActive()) && !(pLevelDecorations[i].uFlags & LEVEL_DECORATION_INVISIBLE)) | |
951 { | |
952 DecorationDesc* decor_desc = &pDecorationList->pDecorations[pLevelDecorations[i].uDecorationDescID]; | |
953 if ( (char)decor_desc->uFlags >= 0 ) | |
954 { | |
955 if ( !(decor_desc->uFlags & 0x22) ) | |
956 { | |
957 v6 = pMiscTimer->uTotalGameTimeElapsed; | |
958 v7 = abs(pLevelDecorations[i].vPosition.x + pLevelDecorations[i].vPosition.y); | |
959 | |
960 #pragma region "New: seasons change" | |
961 extern bool change_seasons; | |
962 if (change_seasons) | |
963 switch (pParty->uCurrentMonth) | |
964 { | |
965 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
966 case 11: case 0: case 1: // winter | |
967 switch (decor_desc->uSpriteID) | |
968 { | |
969 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
970 case 548: // flower10 | |
971 case 547: // flower09 | |
972 case 541: // flower03 | |
973 case 539: continue; // flower01 | |
974 | |
975 case 483: // tree01 | |
976 case 486: // tree04 | |
977 case 492: // tree10 | |
978 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); | |
2508 | 979 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); |
2496 | 980 break; |
981 | |
982 default: | |
2508 | 983 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
2496 | 984 } |
985 break; | |
986 | |
987 case 2: case 3: case 4: // spring | |
988 switch (decor_desc->uSpriteID) | |
989 { | |
990 } | |
2508 | 991 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
2496 | 992 break; |
993 | |
994 case 8: case 9: case 10: // autumn | |
995 switch (decor_desc->uSpriteID) | |
996 { | |
997 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
998 case 548: // flower10 | |
999 case 547: // flower09 | |
1000 case 541: // flower03 | |
1001 case 539: continue; // flower01 | |
1002 | |
1003 case 483: // tree01 | |
1004 case 486: // tree04 | |
1005 case 492: // tree10 | |
1006 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); | |
2508 | 1007 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); |
2496 | 1008 break; |
1009 | |
1010 default: | |
2508 | 1011 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
2496 | 1012 } |
1013 break; | |
1014 | |
1015 case 5: case 6: case 7: // summer | |
1016 //all green by default | |
2508 | 1017 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
2496 | 1018 break; |
1019 | |
1020 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
1021 } | |
1022 else | |
2508 | 1023 frame = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
2496 | 1024 #pragma endregion |
1025 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); | |
1026 | |
2543 | 1027 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(pLevelDecorations[i].vPosition.x - pIndoorCameraD3D->vPartyPos.x, |
1028 pLevelDecorations[i].vPosition.y - pIndoorCameraD3D->vPartyPos.y); | |
2496 | 1029 v38 = 0; |
1030 v13 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + pLevelDecorations[i].field_10_y_rot - (signed int)v10) >> 8) & 7; | |
1031 v37 = (unsigned __int16 *)v13; | |
2508 | 1032 if ( frame->uFlags & 2 ) |
2496 | 1033 v38 = 2; |
2508 | 1034 if ( (256 << v13) & frame->uFlags ) |
2496 | 1035 v38 |= 4; |
2508 | 1036 if ( frame->uFlags & 0x40000 ) |
2496 | 1037 v38 |= 0x40; |
2508 | 1038 if ( frame->uFlags & 0x20000 ) |
2496 | 1039 LOBYTE(v38) = v38 | 0x80; |
2532 | 1040 |
1041 //for light | |
2508 | 1042 if ( frame->uGlowRadius ) |
2496 | 1043 { |
2532 | 1044 r = 255; |
1045 g = 255; | |
1046 b_ = 255; | |
1047 if ( /*pRenderD3D &&*/ bUseColoredLights ) | |
2496 | 1048 { |
2532 | 1049 r = /*255;//*/decor_desc->uColoredLightRed; |
1050 g = /*255;//*/decor_desc->uColoredLightGreen; | |
1051 b_ = /*255;//*/decor_desc->uColoredLightBlue; | |
2496 | 1052 } |
2532 | 1053 pStationaryLightsStack->AddLight(pLevelDecorations[i].vPosition.x, |
1054 pLevelDecorations[i].vPosition.y, | |
1055 pLevelDecorations[i].vPosition.z + decor_desc->uDecorationHeight / 2, | |
1056 frame->uGlowRadius, r, g, b_, _4E94D0_light_type); | |
1057 }//for light | |
1058 | |
2543 | 1059 v17 = (pLevelDecorations[i].vPosition.x - pIndoorCameraD3D->vPartyPos.x) << 16; |
1060 if (pIndoorCameraD3D->sRotationX) | |
2496 | 1061 { |
2543 | 1062 v40 = (pLevelDecorations[i].vPosition.y - pIndoorCameraD3D->vPartyPos.y) << 16; |
1063 v18 = fixpoint_mul(v17, pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pIndoorCameraD3D->int_sine_y); | |
1064 v41 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pIndoorCameraD3D->vPartyPos.z) << 16, pIndoorCameraD3D->int_sine_x); | |
1065 v19 = fixpoint_mul(v18, pIndoorCameraD3D->int_cosine_x); | |
1066 v20 = v19 + fixpoint_mul((pLevelDecorations[i].vPosition.z - pIndoorCameraD3D->vPartyPos.z) << 16, pIndoorCameraD3D->int_sine_x); | |
2496 | 1067 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1068 { | |
2543 | 1069 v21 = fixpoint_mul(v40, pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v17, pIndoorCameraD3D->int_sine_y); |
1070 v22 = fixpoint_mul((pLevelDecorations[i].vPosition.z - pIndoorCameraD3D->vPartyPos.z) << 16, pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(v18, pIndoorCameraD3D->int_sine_x); | |
2496 | 1071 if ( 2 * abs(v20) >= abs(v21) ) |
1072 { | |
1073 LODWORD(v24) = 0; | |
1074 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); | |
1075 v25 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v24 / v20, v21) + 0x8000) >> 16); | |
1076 v40 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(v24 / v20, v22) + 0x8000) >> 16); | |
2508 | 1077 v41 = fixpoint_mul(frame->scale, v24 / v20); |
2496 | 1078 if ( pRenderD3D ) |
2508 | 1079 b = fixpoint_mul(pSprites_LOD->pHardwareSprites[frame->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41); |
2496 | 1080 else |
1081 { | |
1082 __debugbreak(); | |
2508 | 1083 b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[frame->pHwSpriteIDs[(int)v37]].uWidth / 2, v41); |
2496 | 1084 } |
1085 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) | |
1086 { | |
1087 if (::uNumBillboardsToDraw >= 500) | |
1088 return; | |
2508 | 1089 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[(int)v37]; |
2496 | 1090 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41; |
1091 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41; | |
1092 v29 = v38; | |
1093 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25; | |
1094 HIBYTE(v29) |= 2; | |
2508 | 1095 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; |
2496 | 1096 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29; |
1097 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x; | |
1098 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y; | |
1099 pBillboardRenderList[::uNumBillboardsToDraw].world_z = pLevelDecorations[i].vPosition.z; | |
1100 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40; | |
1101 HIWORD(v30) = HIWORD(v20); | |
1102 v31 = PID(OBJECT_Decoration,i); | |
1103 LOWORD(v30) = 0; | |
1104 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0; | |
1105 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31; | |
1106 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
2508 | 1107 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; |
2496 | 1108 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; |
1109 ::uNumBillboardsToDraw++; | |
1110 ++uNumDecorationsDrawnThisFrame; | |
1111 } | |
1112 } | |
1113 continue; | |
1114 } | |
1115 } | |
1116 else | |
1117 { | |
2543 | 1118 v42 = (pLevelDecorations[i].vPosition.x - pIndoorCameraD3D->vPartyPos.x) << 16; |
1119 v40 = (pLevelDecorations[i].vPosition.y - pIndoorCameraD3D->vPartyPos.y) << 16; | |
1120 v20 = fixpoint_mul(v17, pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pIndoorCameraD3D->int_sine_y); | |
2496 | 1121 if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) |
1122 { | |
2543 | 1123 v21 = fixpoint_mul(v40, pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v42, pIndoorCameraD3D->int_sine_y); |
1124 v22 = (pLevelDecorations[i].vPosition.z - pIndoorCameraD3D->vPartyPos.z) << 16; | |
2496 | 1125 v42 = v22; |
1126 if ( 2 * abs(v20) >= abs(v21) ) | |
1127 { | |
1128 LODWORD(v24) = 0; | |
1129 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); | |
1130 v25 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v24 / v20, v21) + 0x8000) >> 16); | |
1131 v40 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(v24 / v20, v42) + 0x8000) >> 16); | |
2508 | 1132 v41 = fixpoint_mul(frame->scale, v24 / v20); |
2496 | 1133 if ( pRenderD3D ) |
2508 | 1134 b = fixpoint_mul(pSprites_LOD->pHardwareSprites[frame->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41); |
2496 | 1135 else |
1136 { | |
1137 __debugbreak(); | |
2508 | 1138 b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[frame->pHwSpriteIDs[(int)v37]].uWidth / 2, v41); |
2496 | 1139 } |
1140 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) | |
1141 { | |
1142 if (::uNumBillboardsToDraw >= 500) | |
1143 return; | |
2508 | 1144 pBillboardRenderList[::uNumBillboardsToDraw].HwSpriteID = frame->pHwSpriteIDs[(int)v37]; |
2496 | 1145 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41; |
1146 pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41; | |
1147 v29 = v38; | |
1148 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25; | |
1149 HIBYTE(v29) |= 2; | |
2508 | 1150 pBillboardRenderList[::uNumBillboardsToDraw].uPalette = frame->uPaletteIndex; |
2496 | 1151 pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29; |
1152 pBillboardRenderList[::uNumBillboardsToDraw].world_x = pLevelDecorations[i].vPosition.x; | |
1153 pBillboardRenderList[::uNumBillboardsToDraw].world_y = pLevelDecorations[i].vPosition.y; | |
1154 pBillboardRenderList[::uNumBillboardsToDraw].world_z = pLevelDecorations[i].vPosition.z; | |
1155 pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40; | |
1156 HIWORD(v30) = HIWORD(v20); | |
1157 v31 = PID(OBJECT_Decoration,i); | |
1158 LOWORD(v30) = 0; | |
1159 pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0; | |
1160 pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31; | |
1161 pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0; | |
2508 | 1162 pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = frame; |
2496 | 1163 pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0; |
1164 ::uNumBillboardsToDraw++; | |
1165 ++uNumDecorationsDrawnThisFrame; | |
1166 } | |
1167 } | |
1168 continue; | |
1169 } | |
1170 } | |
1171 } | |
1172 } | |
1173 else | |
1174 { | |
1175 memset(&local_0, 0, 0x68); | |
1176 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; | |
1177 local_0.uDiffuse = 0xFF3C1E; | |
1178 local_0.x = (double)pLevelDecorations[i].vPosition.x; | |
1179 local_0.y = (double)pLevelDecorations[i].vPosition.y; | |
1180 local_0.z = (double)pLevelDecorations[i].vPosition.z; | |
1181 local_0.r = 0.0; | |
1182 local_0.g = 0.0; | |
1183 local_0.b = 0.0; | |
1184 local_0.flt_28 = 1.0; | |
1185 local_0.timeToLive = (rand() & 0x80) + 128; | |
1186 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
2541 | 1187 pEngine->pParticleEngine->AddParticle(&local_0); |
2496 | 1188 } |
1189 } | |
1190 } | |
1191 } | |
1192 | |
1193 //----- (0049D717) -------------------------------------------------------- | |
1194 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
1195 { | |
1196 if ( Src->dwFlags & (0x400 | 0x2000)) | |
1197 { | |
1198 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
1199 { | |
1200 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); | |
1201 return 0; | |
1202 } | |
1203 if ( !Dst->dwSize ) | |
1204 { | |
1205 memcpy(Dst, Src, sizeof(DDPIXELFORMAT)); | |
1206 return 1; | |
1207 } | |
1208 } | |
1209 return 1; | |
1210 } | |
1211 | |
1212 //----- (0049DC28) -------------------------------------------------------- | |
1213 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
1214 { | |
1215 RenderD3D__DevInfo *v2; // eax@1 | |
1216 | |
1217 v2 = new RenderD3D__DevInfo[4];// 4 items | |
1218 *pOutDevices = v2; | |
1219 memset(v2, 0, sizeof(v2)); | |
1220 DirectDrawEnumerateExA((LPDDENUMCALLBACKEXA)RenderD3D__DeviceEnumerator, *pOutDevices, DDENUM_ATTACHEDSECONDARYDEVICES); | |
1221 } | |
1222 | |
1223 //----- (0049DC58) -------------------------------------------------------- | |
1224 RenderD3D::RenderD3D() | |
1225 { | |
1226 this->pHost = nullptr; | |
1227 this->pDirect3D = nullptr; | |
1228 this->pUnk = nullptr; | |
1229 this->pBackBuffer = nullptr; | |
1230 this->pFrontBuffer = nullptr; | |
1231 this->pZBuffer = nullptr; | |
1232 this->pDevice = nullptr; | |
1233 this->pViewport = nullptr; | |
1234 this->field_40 = 1; | |
1235 this->field_44 = 10; | |
1236 GetAvailableDevices(&this->pAvailableDevices); | |
1237 } | |
1238 | |
1239 //----- (0049DC90) -------------------------------------------------------- | |
1240 void RenderD3D::Release() | |
1241 { | |
1242 if ( !this->bWindowed ) | |
1243 { | |
1244 if ( this->pHost ) | |
1245 { | |
1246 this->pHost->RestoreDisplayMode(); | |
1247 this->pHost->SetCooperativeLevel(this->hWindow, DDSCL_NORMAL); | |
1248 this->pHost->FlipToGDISurface(); | |
1249 } | |
1250 } | |
1251 | |
2555
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1252 for (int i = 0; i < 4; i++) |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1253 { |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1254 if (this->pAvailableDevices[i].pDriverName) |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1255 { |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1256 delete[] this->pAvailableDevices[i].pDriverName; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1257 this->pAvailableDevices[i].pDriverName = nullptr; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1258 } |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1259 |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1260 if (this->pAvailableDevices[i].pDeviceDesc) |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1261 { |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1262 delete[] this->pAvailableDevices[i].pDeviceDesc; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1263 this->pAvailableDevices[i].pDeviceDesc = nullptr; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1264 } |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1265 |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1266 if (this->pAvailableDevices[i].pDDraw4DevDesc) |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1267 { |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1268 delete[] this->pAvailableDevices[i].pDDraw4DevDesc; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1269 this->pAvailableDevices[i].pDDraw4DevDesc = nullptr; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1270 } |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1271 |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1272 if (this->pAvailableDevices[i].pDirectDrawGUID) |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1273 { |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1274 delete this->pAvailableDevices[i].pDirectDrawGUID; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1275 this->pAvailableDevices[i].pDirectDrawGUID = nullptr; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1276 } |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1277 |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1278 if (this->pAvailableDevices[i].pName) |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1279 { |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1280 delete[] this->pAvailableDevices[i].pName; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1281 this->pAvailableDevices[i].pName = nullptr; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1282 } |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1283 |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1284 if (this->pAvailableDevices[i].pDescription) |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1285 { |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1286 delete[] this->pAvailableDevices[i].pDescription; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1287 this->pAvailableDevices[i].pDescription = nullptr; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1288 } |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1289 |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1290 if (this->pAvailableDevices[i].pGUID) |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1291 { |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1292 delete this->pAvailableDevices[i].pGUID; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1293 this->pAvailableDevices[i].pGUID = nullptr; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2544
diff
changeset
|
1294 } |
2496 | 1295 } |
1296 | |
1297 delete[] this->pAvailableDevices; | |
1298 this->pAvailableDevices = NULL; | |
1299 | |
1300 if ( this->pViewport ) | |
1301 { | |
1302 this->pViewport->Release(); | |
1303 this->pViewport = NULL; | |
1304 } | |
1305 | |
1306 if ( this->pUnk ) | |
1307 { | |
1308 this->pUnk->Release(); | |
1309 this->pUnk = NULL; | |
1310 } | |
1311 | |
1312 if ( this->pZBuffer ) | |
1313 { | |
1314 this->pZBuffer->Release(); | |
1315 this->pZBuffer = NULL; | |
1316 } | |
1317 | |
1318 if ( this->pDevice ) | |
1319 { | |
1320 this->pDevice->Release(); | |
1321 this->pDevice = NULL; | |
1322 } | |
1323 | |
1324 if ( this->pDirect3D ) | |
1325 { | |
1326 this->pDirect3D->Release(); | |
1327 this->pDirect3D = NULL; | |
1328 } | |
1329 | |
1330 if ( this->pBackBuffer ) | |
1331 { | |
1332 this->pBackBuffer->Release(); | |
1333 this->pBackBuffer = NULL; | |
1334 } | |
1335 | |
1336 if ( this->pFrontBuffer ) | |
1337 { | |
1338 this->pFrontBuffer->Release(); | |
1339 this->pFrontBuffer = NULL; | |
1340 } | |
1341 | |
1342 if ( this->pHost ) | |
1343 { | |
1344 this->pHost->Release(); | |
1345 this->pHost = NULL; | |
1346 } | |
1347 } | |
1348 | |
1349 //----- (0049DE14) -------------------------------------------------------- | |
1350 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window) | |
1351 { | |
1352 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
1353 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
1354 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
1355 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
1356 IDirectDrawClipper *lpddclipper; // [sp+C4h] [bp-14h]@18 | |
1357 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
1358 | |
1359 auto hWnd = window->GetApiHandle(); | |
1360 int game_width = window->GetWidth(); | |
1361 int game_height = window->GetHeight(); | |
1362 | |
1363 this->bWindowed = bWindowed; | |
1364 this->hWindow = hWnd; | |
1365 | |
1366 //Ñîçäàíèå îáúåêòà DirectDraw | |
1367 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, NULL))) | |
1368 { | |
1369 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
1370 return 0; | |
1371 } | |
1372 | |
1373 //Çàïðîñ èíòåðôåéñà IDirectDraw4 | |
1374 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
1375 { | |
1376 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
1377 if (lpDD) | |
1378 lpDD->Release(); | |
1379 return 0; | |
1380 } | |
1381 lpDD->Release(); | |
1382 lpDD = NULL; | |
1383 | |
1384 //Çàäà¸ì óðîâåíü ñîâìåñòíîãî äîñòóïà äëÿ ïðèëîæåíèÿ DirectDraw â îêîííîì ðåæèìå | |
1385 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
1386 { | |
1387 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
1388 { | |
1389 sprintf(pErrorMessage, "Init - Failed to set cooperative level.\n"); | |
1390 if (pHost) | |
1391 { | |
1392 pHost->Release(); | |
1393 pHost = NULL; | |
1394 } | |
1395 return 0; | |
1396 } | |
1397 | |
1398 // | |
1399 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1400 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1401 ddsd2.dwFlags = DDSD_CAPS; | |
1402 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
1403 //Ñîçäà¸ì ïåðâè÷íóþ ïîâåðõíîñòü | |
1404 if ( FAILED(pHost->CreateSurface(&ddsd2, &pFrontBuffer, NULL)) ) | |
1405 { | |
1406 sprintf(pErrorMessage, "Init - Failed to create front buffer.\n"); | |
1407 if (pHost) | |
1408 { | |
1409 pHost->Release(); | |
1410 pHost = NULL; | |
1411 } | |
1412 return 0; | |
1413 } | |
1414 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1415 pHost->GetDisplayMode(&ddsd2); | |
1416 if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) | |
1417 { | |
1418 sprintf(pErrorMessage, "Init - Desktop isn't in 16 bit mode.\n"); | |
1419 if (pFrontBuffer) | |
1420 { | |
1421 pFrontBuffer->Release(); | |
1422 pFrontBuffer = NULL; | |
1423 } | |
1424 if (pHost) | |
1425 { | |
1426 pHost->Release(); | |
1427 pHost = NULL; | |
1428 } | |
1429 return 0; | |
1430 } | |
1431 | |
1432 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
1433 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
1434 ddsd2.dwWidth = game_width; | |
1435 ddsd2.dwHeight = game_height; | |
1436 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, NULL) ) | |
1437 { | |
1438 sprintf(pErrorMessage, "Init - Failed to create back buffer.\n"); | |
1439 if (pFrontBuffer) | |
1440 { | |
1441 pFrontBuffer->Release(); | |
1442 pFrontBuffer = NULL; | |
1443 } | |
1444 if (pHost) | |
1445 { | |
1446 pHost->Release(); | |
1447 pHost = NULL; | |
1448 } | |
1449 return 0; | |
1450 } | |
1451 //Ñîçäàíèå îòñåêàòåëÿ DirectDraw | |
1452 if ( pHost->CreateClipper(0, &lpddclipper, NULL) ) | |
1453 { | |
1454 sprintf(pErrorMessage, "Init - Failed to create clipper.\n"); | |
1455 if (pBackBuffer) | |
1456 { | |
1457 pBackBuffer->Release(); | |
1458 pBackBuffer = NULL; | |
1459 } | |
1460 if (pFrontBuffer) | |
1461 { | |
1462 pFrontBuffer->Release(); | |
1463 pFrontBuffer= NULL; | |
1464 } | |
1465 if (pHost) | |
1466 { | |
1467 pHost->Release(); | |
1468 pHost = NULL; | |
1469 } | |
1470 return 0; | |
1471 } | |
1472 lpddclipper->SetHWnd(0, hWnd); | |
1473 pFrontBuffer->SetClipper(lpddclipper); | |
1474 | |
1475 lpddclipper->Release(); | |
1476 lpddclipper = NULL; | |
1477 // | |
1478 | |
1479 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1480 | |
1481 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1482 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
1483 ddsd2.dwWidth = game_width; | |
1484 ddsd2.dwHeight = game_height; | |
1485 | |
1486 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1487 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1488 &ddsd2.ddpfPixelFormat) ) | |
1489 { | |
1490 sprintf(pErrorMessage, "Init - Failed to enumerate Z buffer formats.\n"); | |
1491 if (pBackBuffer) | |
1492 { | |
1493 pBackBuffer->Release(); | |
1494 pBackBuffer = NULL; | |
1495 } | |
1496 if (pFrontBuffer) | |
1497 { | |
1498 pFrontBuffer->Release(); | |
1499 pFrontBuffer= NULL; | |
1500 } | |
1501 if (pHost) | |
1502 { | |
1503 pHost->Release(); | |
1504 pHost = NULL; | |
1505 } | |
1506 return 0; | |
1507 } | |
1508 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1509 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
1510 | |
1511 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, NULL) ) | |
1512 { | |
1513 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
1514 { | |
1515 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, pBackBuffer, &pDevice, 0) ) | |
1516 { | |
1517 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1518 d3dvp2.dvClipWidth = 2.0; | |
1519 d3dvp2.dvClipY = 1.0; | |
1520 d3dvp2.dvClipHeight = 2.0; | |
1521 d3dvp2.dvMaxZ = 1.0; | |
1522 d3dvp2.dvMinZ = 0.0; | |
1523 goto LABEL_54; | |
1524 } | |
1525 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
1526 if (pDirect3D) | |
1527 { | |
1528 pDirect3D->Release(); | |
1529 pDirect3D = NULL; | |
1530 } | |
1531 if (pZBuffer) | |
1532 { | |
1533 pZBuffer->Release(); | |
1534 pZBuffer = NULL; | |
1535 } | |
1536 if (pBackBuffer) | |
1537 { | |
1538 pBackBuffer->Release(); | |
1539 pBackBuffer = NULL; | |
1540 } | |
1541 if (pFrontBuffer) | |
1542 { | |
1543 pFrontBuffer->Release(); | |
1544 pFrontBuffer= NULL; | |
1545 } | |
1546 if (pHost) | |
1547 { | |
1548 pHost->Release(); | |
1549 pHost = NULL; | |
1550 } | |
1551 return 0; | |
1552 } | |
1553 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
1554 if (pZBuffer) | |
1555 { | |
1556 pZBuffer->Release(); | |
1557 pZBuffer = NULL; | |
1558 } | |
1559 if (pBackBuffer) | |
1560 { | |
1561 pBackBuffer->Release(); | |
1562 pBackBuffer = NULL; | |
1563 } | |
1564 if (pFrontBuffer) | |
1565 { | |
1566 pFrontBuffer->Release(); | |
1567 pFrontBuffer= NULL; | |
1568 } | |
1569 if (pHost) | |
1570 { | |
1571 pHost->Release(); | |
1572 pHost = NULL; | |
1573 } | |
1574 return 0; | |
1575 } | |
1576 sprintf(pErrorMessage, "Init - Failed to create z-buffer.\n"); | |
1577 if (pBackBuffer) | |
1578 { | |
1579 pBackBuffer->Release(); | |
1580 pBackBuffer = NULL; | |
1581 } | |
1582 if (pFrontBuffer) | |
1583 { | |
1584 pFrontBuffer->Release(); | |
1585 pFrontBuffer= NULL; | |
1586 } | |
1587 if (pHost) | |
1588 { | |
1589 pHost->Release(); | |
1590 pHost = NULL; | |
1591 } | |
1592 return 0; | |
1593 } | |
1594 if ( uDeviceID == 1 ) | |
1595 v26 = 1045; | |
1596 else | |
1597 v26 = 1041; | |
1598 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
1599 { | |
1600 sprintf(pErrorMessage, "Init - Failed to set cooperative level.\n"); | |
1601 if (pHost) | |
1602 { | |
1603 pHost->Release(); | |
1604 pHost = NULL; | |
1605 } | |
1606 return 0; | |
1607 } | |
1608 if (pHost->SetDisplayMode(window->GetWidth(), window->GetHeight(), 16, 0, 0) ) | |
1609 { | |
1610 sprintf(pErrorMessage, "Init - Failed to set display mode.\n"); | |
1611 if (pHost) | |
1612 { | |
1613 pHost->Release(); | |
1614 pHost = NULL; | |
1615 } | |
1616 return 0; | |
1617 } | |
1618 | |
1619 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
1620 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
1621 //Ïîäêëþ÷åíèå ïîëåé ñ äîñòîâåðíûìè äàííûìè | |
1622 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
1623 //Çàïðîñ ñëîæíîé ñòðóêòóðû ñ âîçìîæíîñòüþ ïåðåêëþ÷åíèÿ | |
1624 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
1625 //Ïðèñâîåíèå ïîëþ ñ÷¸ò÷èêà çàäíèõ áóôåðîâ çíà÷åíèÿ 1 | |
1626 ddsd2.dwBackBufferCount = 1; | |
1627 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, NULL) ) | |
1628 { | |
1629 sprintf(pErrorMessage, "Init - Failed to create front buffer.\n"); | |
1630 if (pHost) | |
1631 { | |
1632 pHost->Release(); | |
1633 pHost = NULL; | |
1634 } | |
1635 return 0; | |
1636 } | |
1637 //a3a = &pBackBuffer; | |
1638 //v14 = *v34; | |
1639 memset(&v27, 0, sizeof(DDSCAPS2)); | |
1640 | |
1641 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
1642 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
1643 //hWnda = &pDirect3D; | |
1644 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
1645 | |
1646 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
1647 { | |
1648 sprintf(pErrorMessage, "Init - Failed to get D3D interface.\n"); | |
1649 if (pBackBuffer) | |
1650 { | |
1651 pBackBuffer->Release(); | |
1652 pBackBuffer = NULL; | |
1653 } | |
1654 if (pFrontBuffer) | |
1655 { | |
1656 pFrontBuffer->Release(); | |
1657 pFrontBuffer= NULL; | |
1658 } | |
1659 if (pHost) | |
1660 { | |
1661 pHost->Release(); | |
1662 pHost = NULL; | |
1663 } | |
1664 return 0; | |
1665 } | |
1666 | |
1667 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1668 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
1669 ddsd2.dwWidth = 640; | |
1670 ddsd2.dwHeight = 480; | |
1671 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
1672 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
1673 &ddsd2.ddpfPixelFormat) ) | |
1674 { | |
1675 sprintf(pErrorMessage, "Init - Failed to enumerate Z buffer formats.\n"); | |
1676 if (pBackBuffer) | |
1677 { | |
1678 pBackBuffer->Release(); | |
1679 pBackBuffer = 0; | |
1680 } | |
1681 if (pFrontBuffer) | |
1682 { | |
1683 pFrontBuffer->Release(); | |
1684 pFrontBuffer= 0; | |
1685 } | |
1686 if (pHost) | |
1687 { | |
1688 pHost->Release(); | |
1689 pHost = 0; | |
1690 } | |
1691 return 0; | |
1692 } | |
1693 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
1694 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8; | |
1695 //uDeviceIDa = &pZBuffer; | |
1696 if (pHost->CreateSurface(&ddsd2, &pZBuffer, NULL) ) | |
1697 { | |
1698 sprintf(pErrorMessage, "Init - Failed to create z-buffer.\n"); | |
1699 if (pBackBuffer) | |
1700 { | |
1701 pBackBuffer->Release(); | |
1702 pBackBuffer = 0; | |
1703 } | |
1704 if (pFrontBuffer) | |
1705 { | |
1706 pFrontBuffer->Release(); | |
1707 pFrontBuffer= 0; | |
1708 } | |
1709 if (pHost) | |
1710 { | |
1711 pHost->Release(); | |
1712 pHost = 0; | |
1713 } | |
1714 return 0; | |
1715 } | |
1716 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
1717 { | |
1718 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
1719 if (pZBuffer) | |
1720 { | |
1721 pZBuffer->Release(); | |
1722 pZBuffer = 0; | |
1723 } | |
1724 if (pBackBuffer) | |
1725 { | |
1726 pBackBuffer->Release(); | |
1727 pBackBuffer = 0; | |
1728 } | |
1729 if (pFrontBuffer) | |
1730 { | |
1731 pFrontBuffer->Release(); | |
1732 pFrontBuffer= 0; | |
1733 } | |
1734 if (pHost) | |
1735 { | |
1736 pHost->Release(); | |
1737 pHost = 0; | |
1738 } | |
1739 return 0; | |
1740 } | |
1741 //v33 = &pDevice; | |
1742 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, pBackBuffer, &pDevice, 0) ) | |
1743 { | |
1744 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
1745 if (pDirect3D) | |
1746 { | |
1747 pDirect3D->Release(); | |
1748 pDirect3D = 0; | |
1749 } | |
1750 if (pZBuffer) | |
1751 { | |
1752 pZBuffer->Release(); | |
1753 pZBuffer = 0; | |
1754 } | |
1755 if (pBackBuffer) | |
1756 { | |
1757 pBackBuffer->Release(); | |
1758 pBackBuffer = 0; | |
1759 } | |
1760 if (pFrontBuffer) | |
1761 { | |
1762 pFrontBuffer->Release(); | |
1763 pFrontBuffer= 0; | |
1764 } | |
1765 if (pHost) | |
1766 { | |
1767 pHost->Release(); | |
1768 pHost = 0; | |
1769 } | |
1770 return 0; | |
1771 } | |
1772 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
1773 d3dvp2.dvClipWidth = 2.0; | |
1774 d3dvp2.dvClipY = 1.0; | |
1775 d3dvp2.dvClipHeight = 2.0; | |
1776 d3dvp2.dvMaxZ = 1.0; | |
1777 | |
1778 LABEL_54: | |
1779 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
1780 //v17 = *hWnda; | |
1781 d3dvp2.dwWidth = game_width; | |
1782 d3dvp2.dwHeight = game_height; | |
1783 d3dvp2.dvClipX = -1.0; | |
1784 //v18 = v17->lpVtbl; | |
1785 //v32 = &v4->pViewport; | |
1786 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
1787 { | |
1788 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
1789 if (pDevice) | |
1790 { | |
1791 pDevice->Release(); | |
1792 pDevice = 0; | |
1793 } | |
1794 if (pDirect3D) | |
1795 { | |
1796 pDirect3D->Release(); | |
1797 pDirect3D = 0; | |
1798 } | |
1799 if (pZBuffer) | |
1800 { | |
1801 pZBuffer->Release(); | |
1802 pZBuffer = 0; | |
1803 } | |
1804 if (pBackBuffer) | |
1805 { | |
1806 pBackBuffer->Release(); | |
1807 pBackBuffer = 0; | |
1808 } | |
1809 if (pFrontBuffer) | |
1810 { | |
1811 pFrontBuffer->Release(); | |
1812 pFrontBuffer= 0; | |
1813 } | |
1814 if (pHost) | |
1815 { | |
1816 pHost->Release(); | |
1817 pHost = 0; | |
1818 } | |
1819 return 0; | |
1820 } | |
1821 | |
1822 pDevice->AddViewport(pViewport); | |
1823 pViewport->SetViewport2(&d3dvp2); | |
1824 pDevice->SetCurrentViewport(pViewport); | |
1825 return 1; | |
1826 } | |
1827 | |
1828 //----- (0049E444) -------------------------------------------------------- | |
1829 unsigned int RenderD3D::GetDeviceCaps() | |
1830 { | |
1831 unsigned int v1; // ebx@1 | |
1832 unsigned int result; // eax@2 | |
1833 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
1834 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
1835 | |
1836 v1 = 0; | |
1837 | |
1838 memset(&halCaps, 0, sizeof(halCaps)); | |
1839 halCaps.dwSize = sizeof(halCaps); | |
1840 | |
1841 memset(&refCaps, 0, sizeof(refCaps)); | |
1842 refCaps.dwSize = sizeof(refCaps); | |
1843 | |
1844 if ( this->pDevice->GetCaps(&halCaps, &refCaps) ) | |
1845 result = 1; | |
1846 else | |
1847 { | |
1848 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) ) | |
1849 v1 = 2; | |
1850 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ONE) ) | |
1851 v1 |= 4; | |
1852 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ZERO) ) | |
1853 v1 |= 8; | |
1854 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) ) | |
1855 v1 |= 16; | |
1856 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_ONE) ) | |
1857 v1 |= 32; | |
1858 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) ) | |
1859 v1 |= 64; | |
1860 if ( halCaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY ) | |
1861 v1 |= 128; | |
1862 result = v1; | |
1863 } | |
1864 return result; | |
1865 } | |
1866 | |
1867 //----- (0049E4FC) -------------------------------------------------------- | |
1868 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
1869 { | |
1870 uint uClearFlags = 0; | |
1871 | |
1872 if (bClearColor) | |
1873 uClearFlags |= D3DCLEAR_TARGET; | |
1874 if (bClearDepth) | |
1875 uClearFlags |= D3DCLEAR_ZBUFFER; | |
1876 | |
1877 D3DRECT rects[] = {{0, 0, window->GetWidth(), window->GetHeight()}}; | |
1878 if (uClearFlags) | |
1879 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
1880 } | |
1881 | |
1882 //----- (0049E54D) -------------------------------------------------------- | |
1883 void RenderD3D::Present(bool bForceBlit) | |
1884 { | |
1885 RECT source_rect; // [sp+18h] [bp-18h]@1 | |
1886 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
1887 | |
1888 source_rect.left = 0; | |
1889 source_rect.top = 0; | |
1890 source_rect.bottom = 480;//window->GetHeight(); //Ritor1: ïðîáëåìà ñ êíîïêîé "ðàçâåðíóòü" | |
1891 source_rect.right = 640; //window->GetWidth(); | |
1892 | |
1893 if (bWindowed || bForceBlit) | |
1894 { | |
1895 RECT dest_rect; | |
1896 GetClientRect(hWindow, &dest_rect); | |
1897 Point.y = 0; | |
1898 Point.x = 0; | |
1899 ClientToScreen(hWindow, &Point); | |
1900 OffsetRect(&dest_rect, Point.x, Point.y); | |
1901 pFrontBuffer->Blt(&dest_rect, pBackBuffer, &source_rect, DDBLT_WAIT, NULL); | |
1902 } | |
1903 else | |
1904 pFrontBuffer->Flip(NULL, DDFLIP_WAIT); | |
1905 } | |
1906 | |
1907 //----- (0049E5D4) -------------------------------------------------------- | |
1908 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
1909 { | |
1910 unsigned int v9; // ebx@5 | |
1911 unsigned int v10; // eax@5 | |
1912 DWORD v11; // edx@5 | |
1913 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
1914 | |
1915 memset(&ddsd2, 0, sizeof(ddsd2)); | |
1916 ddsd2.dwSize = sizeof(ddsd2); | |
1917 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
1918 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
1919 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
1920 ddsd2.dwHeight = uTextureHeight; | |
1921 ddsd2.dwWidth = uTextureWidth; | |
1922 if ( bMipmaps ) | |
1923 { | |
1924 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
1925 { | |
1926 ddsd2.dwMipMapCount = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
1927 if ( ddsd2.dwMipMapCount ) | |
1928 { | |
1929 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
1930 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
1931 } | |
1932 goto LABEL_12; | |
1933 } | |
1934 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
1935 { | |
1936 ddsd2.dwMipMapCount = GetMaxMipLevels(uMinDeviceTexDim); | |
1937 if ( ddsd2.dwMipMapCount ) | |
1938 { | |
1939 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
1940 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
1941 } | |
1942 goto LABEL_12; | |
1943 } | |
1944 v9 = GetMaxMipLevels(uTextureWidth); | |
1945 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
1946 ddsd2.dwMipMapCount = v9 - v10; | |
1947 if ( v9 == v10 ) | |
1948 { | |
1949 ddsd2.dwFlags = 0x1007; | |
1950 __debugbreak(); // warning C4700: uninitialized local variable 'v11' used | |
1951 ddsd2.ddsCaps.dwCaps = v11; | |
1952 goto LABEL_12; | |
1953 } | |
1954 } | |
1955 else | |
1956 ddsd2.dwMipMapCount = 1; | |
1957 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
1958 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
1959 LABEL_12: | |
1960 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
1961 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
1962 if (bAlphaChannel) | |
1963 { | |
1964 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
1965 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
1966 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
1967 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1968 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000; | |
1969 } | |
1970 else | |
1971 { | |
1972 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
1973 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
1974 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
1975 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
1976 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
1977 } | |
1978 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, NULL))) | |
1979 return false; | |
1980 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
1981 { | |
1982 (*pOutSurface)->Release(); | |
1983 *pOutSurface = 0; | |
1984 return false; | |
1985 } | |
1986 return true; | |
1987 } | |
1988 | |
1989 //----- (004A5190) -------------------------------------------------------- | |
1990 void RenderD3D::HandleLostResources() | |
1991 { | |
1992 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
1993 pBitmaps_LOD->_410423_move_textures_to_device(); | |
1994 pSprites_LOD->ReleaseLostHardwareSprites(); | |
1995 } | |
1996 | |
1997 //----- (004A2050) -------------------------------------------------------- | |
1998 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) | |
1999 { | |
2000 unsigned int v6; // ebx@1 | |
2001 int v8; // eax@7 | |
2002 unsigned int v41; // eax@29 | |
2003 //unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
2004 signed int a2; // [sp+64h] [bp-4h]@4 | |
2005 | |
2006 v6 = 0; | |
2007 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
2008 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2009 //v54 = pEngine->pLightmapBuilder->StationaryLightsCount; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2010 if ( pEngine->pLightmapBuilder->StationaryLightsCount) |
2496 | 2011 a2 = -1; |
2541 | 2012 pEngine->AlterGamma_ODM(a4, &a2); |
2013 if ( byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_01_lightmap_related) | |
2496 | 2014 { |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2015 v8 = ::GetActorTintColor(a3->dimming_level, 0, VertexRenderList[0].vWorldViewPosition.x, 0, 0); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2016 pEngine->pLightmapBuilder->DrawLightmaps(v8/*, 0*/); |
2496 | 2017 } |
2018 else | |
2019 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2020 if ( !pEngine->pLightmapBuilder->StationaryLightsCount || byte_4D864C && pEngine->uFlags & 2 ) |
2496 | 2021 { |
2022 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
2023 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
2024 if (bUsingSpecular) | |
2025 { | |
2026 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
2027 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
2028 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
2029 } | |
2030 for (uint i = 0; i < uNumVertices; ++i) | |
2031 { | |
2032 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2033 d3d_vertex_buffer[i].pos.x = VertexRenderList[i].vWorldViewProjX; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2034 d3d_vertex_buffer[i].pos.y = VertexRenderList[i].vWorldViewProjY; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2035 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((VertexRenderList[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2036 d3d_vertex_buffer[i].rhw = 1.0 / (VertexRenderList[i].vWorldViewPosition.x + 0.0000001); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2037 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, VertexRenderList[i].vWorldViewPosition.x, 0, 0); |
2541 | 2038 pEngine->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); |
2496 | 2039 |
2040 if ( this->bUsingSpecular ) | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2041 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, VertexRenderList[i].vWorldViewPosition.x); |
2496 | 2042 else |
2043 d3d_vertex_buffer[i].specular = 0; | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2044 d3d_vertex_buffer[i].texcoord.x = VertexRenderList[i].u; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2045 d3d_vertex_buffer[i].texcoord.y = VertexRenderList[i].v; |
2496 | 2046 |
2047 } | |
2048 | |
2049 if (a4->uAttributes & FACE_OUTLINED) | |
2050 { | |
2051 int color; | |
2052 if (GetTickCount() % 300 >= 150) | |
2053 color = 0xFFFF2020; | |
2054 else color = 0xFF901010; | |
2055 | |
2056 for (uint i = 0; i < uNumVertices; ++i) | |
2057 d3d_vertex_buffer[i].diffuse = color; | |
2058 } | |
2059 | |
2060 pRenderD3D->pDevice->SetTexture(0, pTexture); | |
2061 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
2062 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
2063 d3d_vertex_buffer, | |
2064 uNumVertices, | |
2065 D3DDP_DONOTLIGHT); | |
2066 } | |
2067 else | |
2068 { | |
2069 for (uint i = 0; i < uNumVertices; ++i) | |
2070 { | |
2071 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2072 d3d_vertex_buffer[i].pos.x = VertexRenderList[i].vWorldViewProjX; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2073 d3d_vertex_buffer[i].pos.y = VertexRenderList[i].vWorldViewProjY; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2074 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((VertexRenderList[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2075 d3d_vertex_buffer[i].rhw = 1.0 / (VertexRenderList[i].vWorldViewPosition.x + 0.0000001); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2076 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, VertexRenderList[i].vWorldViewPosition.x, 0, 0); |
2496 | 2077 if ( this->bUsingSpecular ) |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2078 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, VertexRenderList[i].vWorldViewPosition.x); |
2496 | 2079 else |
2080 d3d_vertex_buffer[i].specular = 0; | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2081 d3d_vertex_buffer[i].texcoord.x = VertexRenderList[i].u; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2082 d3d_vertex_buffer[i].texcoord.y = VertexRenderList[i].v; |
2496 | 2083 |
2084 } | |
2085 | |
2086 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
2087 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
2088 if (bUsingSpecular) | |
2089 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
2090 | |
2091 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
2092 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
2093 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
2094 d3d_vertex_buffer, | |
2095 uNumVertices, | |
2096 D3DDP_DONOTLIGHT)); | |
2097 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
2098 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
2099 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
2100 pEngine->pLightmapBuilder->DrawLightmaps(-1/*, 0*/); |
2496 | 2101 for (uint i = 0; i < uNumVertices; ++i) |
2102 { | |
2103 d3d_vertex_buffer[i].diffuse = a2; | |
2104 } | |
2105 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); | |
2106 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
2107 if ( !pRenderer->bUsingSpecular ) | |
2108 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
2109 | |
2110 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
2111 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
2112 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
2113 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
2114 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
2115 d3d_vertex_buffer, | |
2116 uNumVertices, | |
2117 D3DDP_DONOTLIGHT)); | |
2118 if (bUsingSpecular) | |
2119 { | |
2120 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
2121 | |
2122 for (uint i = 0; i < uNumVertices; ++i) | |
2123 { | |
2124 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
2125 d3d_vertex_buffer[i].specular = 0; | |
2126 } | |
2127 | |
2128 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
2129 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); | |
2130 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
2131 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
2132 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
2133 d3d_vertex_buffer, | |
2134 uNumVertices, | |
2135 D3DDP_DONOTLIGHT)); | |
2136 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
2137 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; | |
2138 v41 = GetLevelFogColor(); | |
2139 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
2140 v6 = 0; | |
2141 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
2142 } | |
2143 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
2144 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
2145 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); | |
2146 } | |
2147 } | |
2148 } | |
2149 } | |
2150 // 4D864C: using guessed type char byte_4D864C; | |
2151 | |
2152 //----- (0049EB79) -------------------------------------------------------- | |
2153 Render::~Render() | |
2154 { | |
2155 free(this->pDefaultZBuffer); | |
2156 this->pD3DBitmaps.Release(); | |
2157 this->pD3DSprites.Release(); | |
2158 Release(); | |
2159 this->bWindowMode = 1; | |
2160 //nullsub_1(); | |
2161 //nullsub_1(); | |
2162 } | |
2163 | |
2164 | |
2165 //----- (0049E992) -------------------------------------------------------- | |
2526 | 2166 Render::Render(): IRender() |
2496 | 2167 { |
2168 //Render *v1; // esi@1 | |
2169 // int v2; // eax@1 | |
2170 // char v3; // zf@1 | |
2171 | |
2172 //v1 = this; | |
2173 this->pDirectDraw4 = nullptr; | |
2174 this->pFrontBuffer4 = nullptr; | |
2175 this->pBackBuffer4 = nullptr; | |
2176 //this->pColorKeySurface4 = 0; | |
2177 //this->pDirectDraw2 = 0; | |
2178 //this->pFrontBuffer2 = 0; | |
2179 //this->pBackBuffer2 = 0; | |
2180 //this->pSomeSurface2 = 0; | |
2181 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); | |
2182 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
2183 this->bWindowMode = 1; | |
2184 //this->field_40054 = 0; | |
2185 //this->field_10 = 640; | |
2186 //this->field_14 = 480; | |
2187 //this->field_40030 = 0; | |
2188 //this->field_4002C = 0; | |
2189 this->pActiveZBuffer = nullptr; | |
2190 this->pDefaultZBuffer = nullptr; | |
2191 this->raster_clip_y = 0; | |
2192 this->raster_clip_x = 0; | |
2193 this->raster_clip_z = 639; | |
2194 this->raster_clip_w = 479; | |
2195 //this->field_4003C = 0x004EED80; | |
2196 //this->field_40040 = dword_4EED78; | |
2197 this->uClipZ = 640; | |
2198 //this->field_40044 = 2; | |
2199 //this->field_40048 = 6; | |
2200 this->pFrontBuffer4 = nullptr; | |
2201 this->pBackBuffer4 = nullptr; | |
2202 //this->pColorKeySurface4 = 0; | |
2203 this->pDirectDraw4 = nullptr; | |
2204 this->pRenderD3D = 0; | |
2205 this->uNumSceneBegins = 0; | |
2206 this->uNumD3DSceneBegins = 0; | |
2207 this->using_software_screen_buffer = 0; | |
2208 this->pTargetSurface = nullptr; | |
2209 this->uTargetSurfacePitch = 0; | |
2210 this->uClipY = 0; | |
2211 this->uClipX = 0; | |
2212 this->uClipW = 480; | |
2213 this->bClip = 1; | |
2214 //this->bColorKeySupported = 0; | |
2215 this->bRequiredTextureStagesAvailable = 0; | |
2216 this->bTinting = 1; | |
2217 //LOBYTE(this->field_103668) = 0; | |
2218 uNumBillboardsToDraw = 0; | |
2219 bFogEnabled = false; | |
2220 | |
2221 hd_water_tile_id = -1; | |
2222 hd_water_current_frame = 0; | |
2223 } | |
2224 | |
2225 bool Render::Initialize(OSWindow *window/*, bool bColoredLights, uint32_t uDetailLevel, bool bTinting*/) | |
2226 { | |
2227 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | |
2228 | |
2229 this->window = window; | |
2230 //bStartInWindow = true; | |
2231 //windowed_mode_width = windowed_width; | |
2232 //windowed_mode_height = windowed_height; | |
2233 | |
2234 uDesiredDirect3DDevice = ReadWindowsRegistryInt("D3D Device", 0); | |
2235 | |
2236 bUseColoredLights = ReadWindowsRegistryInt("Colored Lights", false); | |
2237 uLevelOfDetail = ReadWindowsRegistryInt("Detail Level", 1); | |
2238 bTinting = ReadWindowsRegistryInt("Tinting", 1) != 0; | |
2239 | |
2240 bool r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); | |
2241 bool r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
2242 | |
2243 return r1 && r2; | |
2244 } | |
2245 | |
2246 | |
2247 //----- (0049ECC4) -------------------------------------------------------- | |
2248 void Render::ClearBlack() | |
2249 { | |
2250 //if (pRenderD3D) | |
2251 { | |
2252 if (using_software_screen_buffer) | |
2253 pRenderD3D->ClearTarget(true, 0, false, 0.0); | |
2254 } | |
2255 //else | |
2256 //memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
2257 } | |
2258 | |
2259 //----- (0049ED18) -------------------------------------------------------- | |
2260 void Render::PresentBlackScreen() | |
2261 { | |
2262 IDirectDrawSurface *lpddsback; // eax@3 | |
2263 DDBLTFX lpDDBltFx; // [sp+4h] [bp-74h]@5 | |
2264 RECT dest_rect; // [sp+68h] [bp-10h]@3 | |
2265 | |
2266 memset(&lpDDBltFx, 0, sizeof(DDBLTFX)); | |
2267 lpDDBltFx.dwSize = sizeof(DDBLTFX); | |
2268 | |
2269 GetWindowRect(window->GetApiHandle(), &dest_rect); | |
2270 lpddsback = (IDirectDrawSurface *)this->pBackBuffer4; | |
2271 | |
2272 lpDDBltFx.dwFillColor = 0; | |
2273 lpddsback->Blt(&dest_rect, NULL, NULL, DDBLT_COLORFILL, &lpDDBltFx); | |
2274 pRenderer->Present(); | |
2275 } | |
2276 | |
2277 //----- (0049EDB6) -------------------------------------------------------- | |
2278 void Render::SavePCXScreenshot() | |
2279 { | |
2280 int v5; // eax@8 | |
2281 FILE *pOutFile; // edi@10 | |
2282 unsigned short *v8; // eax@11 | |
2283 signed int v12; // eax@18 | |
2284 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
2285 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
2286 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
2287 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
2288 char *lineB; // [sp+11Ch] [bp-48h]@14 | |
2289 char *lineG; // [sp+120h] [bp-44h]@14 | |
2290 FILE *File; // [sp+128h] [bp-3Ch]@3 | |
2291 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
2292 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
2293 char *lineRGB; // [sp+148h] [bp-1Ch]@10 | |
2294 void *surface; // [sp+14Ch] [bp-18h]@8 | |
2295 unsigned int image_width; // [sp+150h] [bp-14h]@4 | |
2296 int pitch; // [sp+154h] [bp-10h]@4 | |
2297 char v31; // [sp+15Ah] [bp-Ah]@25 | |
2298 unsigned char pict_byte; // [sp+15Bh] [bp-9h]@17 | |
2299 unsigned short *line_picture_data; // [sp+15Ch] [bp-8h]@10 | |
2300 byte test_byte; // [sp+163h] [bp-1h]@17 | |
2301 | |
2302 int num_r_bits = 5; | |
2303 int num_g_bits = 6; | |
2304 int num_b_bits = 5; | |
2305 | |
2306 int r_mask = 0xF800; | |
2307 int g_mask = 0x7E0; | |
2308 int b_mask = 0x1F; | |
2309 | |
2310 if ( !this->pRenderD3D || this->using_software_screen_buffer ) | |
2311 { | |
2312 sprintf(Filename, "screen%0.2i.pcx", ScreenshotFileNumber++ % 100); | |
2313 File = fopen(Filename, "wb"); | |
2314 if ( File ) | |
2315 { | |
2316 pitch = this->GetRenderWidth(); | |
2317 if ( pitch & 1 ) | |
2318 pitch = pitch + 1; | |
2319 if ( this->pRenderD3D ) | |
2320 { | |
2321 memset(&Dst, 0, sizeof(Dst)); | |
2322 Dst.dwSize = sizeof(Dst); | |
2323 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
2324 return; | |
2325 surface = Dst.lpSurface; | |
2326 v5 = Dst.lPitch / 2; | |
2327 } | |
2328 else | |
2329 { | |
2330 pRenderer->BeginScene(); | |
2331 surface = pRenderer->pTargetSurface; | |
2332 v5 = pRenderer->uTargetSurfacePitch; | |
2333 } | |
2334 header1.right = GetRenderWidth() - 1; | |
2335 header1.left = 0; | |
2336 header1.bottom = this->GetRenderHeight() - 1; | |
2337 header1.up = 0; | |
2338 header2.pitch = pitch; | |
2339 memset(color_map, 0, sizeof(color_map)); | |
2340 memset(v15, 0, sizeof(v15)); | |
2341 header2.reserved = 0; | |
2342 header1.manufacturer = 10; | |
2343 pOutFile = File; | |
2344 header1.version = 5; | |
2345 header1.encoding = 1; | |
2346 header1.bpp = 8; | |
2347 header1.hdpi = 75; | |
2348 header1.vdpi = 75; | |
2349 header2.planes = 3; | |
2350 header2.palette_info = 1; | |
2351 fwrite(&header1, 1, 1, File); | |
2352 fwrite(&header1.version, 1, 1, pOutFile); | |
2353 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2354 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2355 fwrite(&header1.left, 2, 1, pOutFile); | |
2356 fwrite(&header1.up, 2, 1, pOutFile); | |
2357 fwrite(&header1.right, 2, 1, pOutFile); | |
2358 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2359 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2360 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2361 fwrite(color_map, 0x30, 1, pOutFile); | |
2362 fwrite(&header2, 1, 1, pOutFile); | |
2363 fwrite(&header2.planes, 1, 1, pOutFile); | |
2364 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2365 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2366 fwrite(v15, 0x3Au, 1, pOutFile); | |
2367 lineRGB = (char *)malloc(3 * GetRenderWidth() + 6); | |
2368 if ( this->GetRenderHeight() > 0 ) | |
2369 { | |
2370 image_width = 3 * pitch; | |
2371 //v24 = 2 * v5; | |
2372 v8 = (unsigned short *)surface; | |
2373 for ( unsigned int y = 0; y < this->GetRenderHeight(); y++ ) | |
2374 { | |
2375 line_picture_data = v8; | |
2376 if ( GetRenderWidth() > 0 ) | |
2377 { | |
2378 lineG = (char *)lineRGB + pitch; | |
2379 lineB = (char *)lineRGB + 2 * pitch; | |
2380 for ( uint x = 0; x < this->GetRenderWidth(); x++ ) | |
2381 { | |
2382 //int p = *line_picture_data; //0x2818 | |
2383 //int for_rad = (pRenderer->uTargetGBits + pRenderer->uTargetBBits );//16 = 8 + 8 | |
2384 //int value = (pRenderer->uTargetRMask & *line_picture_data);//0 = 0xFF0000 & 0x2818 | |
2385 //int result = (pRenderer->uTargetRMask & *line_picture_data) >> (pRenderer->uTargetGBits + pRenderer->uTargetBBits ); | |
2386 lineRGB[x] = (uTargetRMask & *line_picture_data) >> (uTargetGBits + uTargetBBits );// + pRenderer->uTargetRBits - 8); | |
2387 lineG[x] = (uTargetGMask & *line_picture_data) >> (uTargetBBits);// + pRenderer->uTargetGBits - 8); | |
2388 //int value2 = (pRenderer->uTargetGMask & *line_picture_data); //10240 = 0xFF00 & 0x2818 | |
2389 //int result2 = (pRenderer->uTargetGMask & *line_picture_data) >> (pRenderer->uTargetBBits); | |
2390 lineB[x] = (uTargetBMask & *line_picture_data);// << (8 - pRenderer->uTargetBBits); | |
2391 //int value3 = (pRenderer->uTargetBMask & *line_picture_data);//24 = 0xFF & 0x2818 | |
2392 line_picture_data += 2; | |
2393 } | |
2394 } | |
2395 for ( uint i = 0; i < image_width; i += test_byte ) | |
2396 { | |
2397 pict_byte = lineRGB[i]; | |
2398 for ( test_byte = 1; test_byte < 0x3F; ++test_byte ) | |
2399 { | |
2400 v12 = i + test_byte; | |
2401 if ( lineRGB[v12] != pict_byte ) | |
2402 break; | |
2403 if ( !(v12 % pitch) ) | |
2404 break; | |
2405 } | |
2406 if ( i + test_byte > image_width ) | |
2407 test_byte = 3 * pitch - i; | |
2408 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
2409 { | |
2410 v31 = test_byte | 0xC0; | |
2411 fwrite(&v31, 1, 1, pOutFile); | |
2412 } | |
2413 fwrite(&pict_byte, 1, 1, pOutFile); | |
2414 } | |
2415 v8 += v5; | |
2416 } | |
2417 } | |
2418 if ( this->pRenderD3D ) | |
2419 ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL)); | |
2420 else | |
2421 pRenderer->EndScene(); | |
2422 | |
2423 free(lineRGB); | |
2424 fclose(pOutFile); | |
2425 } | |
2426 } | |
2427 } | |
2428 | |
2429 //----- (0049F1BC) -------------------------------------------------------- | |
2430 void Render::SaveWinnersCertificate(const char *a1) | |
2431 { | |
2432 unsigned int v6; // eax@8 | |
2433 //FILE *v7; // edi@10 | |
2434 // int v8; // ecx@11 | |
2435 unsigned short *v9; // eax@11 | |
2436 int v10; // eax@13 | |
2437 signed int v13; // eax@18 | |
2438 // char v14; // zf@27 | |
2439 // HRESULT v15; // eax@29 | |
2440 char v16[56]; // [sp+Ch] [bp-12Ch]@10 | |
2441 __int16 v17; // [sp+44h] [bp-F4h]@10 | |
2442 DDSURFACEDESC2 Dst; // [sp+48h] [bp-F0h]@7 | |
2443 // int v19; // [sp+58h] [bp-E0h]@8 | |
2444 // unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
2445 char color_map[48]; // [sp+C4h] [bp-74h]@10 | |
2446 // unsigned int v22; // [sp+F4h] [bp-44h]@11 | |
2447 char *lineB; // [sp+F8h] [bp-40h]@14 | |
2448 int image_width; // [sp+FCh] [bp-3Ch]@11 | |
2449 int v25; // [sp+100h] [bp-38h]@4 | |
2450 FILE *File; // [sp+104h] [bp-34h]@3 | |
2451 char Str; // [sp+108h] [bp-30h]@10 | |
2452 char v28; // [sp+109h] [bp-2Fh]@10 | |
2453 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
2454 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
2455 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
2456 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
2457 __int16 v33; // [sp+110h] [bp-28h]@10 | |
2458 __int16 v34; // [sp+112h] [bp-26h]@10 | |
2459 __int16 v35; // [sp+114h] [bp-24h]@10 | |
2460 __int16 v36; // [sp+116h] [bp-22h]@10 | |
2461 char v37; // [sp+118h] [bp-20h]@10 | |
2462 char v38; // [sp+119h] [bp-1Fh]@10 | |
2463 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
2464 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
2465 char *lineRGB; // [sp+120h] [bp-18h]@10 | |
2466 void *surface; // [sp+124h] [bp-14h]@8 | |
2467 int pitch; // [sp+128h] [bp-10h]@4 | |
2468 char v44; // [sp+12Fh] [bp-9h]@25 | |
2469 char *lineG; // [sp+130h] [bp-8h]@10 | |
2470 unsigned char pict_byte; // [sp+137h] [bp-1h]@17 | |
2471 byte test_byte; | |
2472 | |
2473 int num_r_bits = 5; | |
2474 int num_g_bits = 6; | |
2475 int num_b_bits = 5; | |
2476 | |
2477 int r_mask = 0xF800; | |
2478 int g_mask = 0x7E0; | |
2479 int b_mask = 0x1F; | |
2480 | |
2481 if ( !this->pRenderD3D || this->using_software_screen_buffer ) | |
2482 { | |
2483 static int _4EFA84_num_winners_certificates = 0; | |
2484 ++_4EFA84_num_winners_certificates; | |
2485 | |
2486 File = fopen(a1, "wb"); | |
2487 if ( File ) | |
2488 { | |
2489 v25 = this->GetRenderWidth(); | |
2490 pitch = v25; | |
2491 if ( pitch & 1 ) | |
2492 pitch = pitch + 1; | |
2493 if ( this->pRenderD3D ) | |
2494 { | |
2495 memset(&Dst, 0, 0x7C); | |
2496 Dst.dwSize = 124; | |
2497 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) | |
2498 return; | |
2499 surface = Dst.lpSurface; | |
2500 v6 = Dst.lPitch / 2; | |
2501 } | |
2502 else | |
2503 { | |
2504 pRenderer->BeginScene(); | |
2505 surface = pRenderer->pTargetSurface; | |
2506 v6 = pRenderer->uTargetSurfacePitch; | |
2507 } | |
2508 v33 = this->GetRenderWidth() - 1; | |
2509 v31 = 0; | |
2510 v34 = (short)this->GetRenderHeight() - 1; | |
2511 v32 = 0; | |
2512 v39 = pitch; | |
2513 memset(&color_map, 0, sizeof(color_map)); | |
2514 memset(&v16, 0, sizeof(v16)); | |
2515 v37 = 0; | |
2516 Str = 10; | |
2517 v17 = 0; | |
2518 v28 = 5; | |
2519 v29 = 1; | |
2520 v30 = 8; | |
2521 v35 = 75; | |
2522 v36 = 75; | |
2523 v38 = 3; | |
2524 v40 = 1; | |
2525 fwrite(&Str, 1, 1, File); | |
2526 fwrite(&v28, 1, 1, File); | |
2527 fwrite(&v29, 1, 1, File); | |
2528 fwrite(&v30, 1, 1, File); | |
2529 fwrite(&v31, 2, 1, File); | |
2530 fwrite(&v32, 2, 1, File); | |
2531 fwrite(&v33, 2, 1, File); | |
2532 fwrite(&v34, 2, 1, File); | |
2533 fwrite(&v35, 2, 1, File); | |
2534 fwrite(&v36, 2, 1, File); | |
2535 fwrite(&color_map, 0x30, 1, File); | |
2536 fwrite(&v37, 1, 1, File); | |
2537 fwrite(&v38, 1, 1, File); | |
2538 fwrite(&v39, 2, 1, File); | |
2539 fwrite(&v40, 2, 1, File); | |
2540 fwrite(&v16, 0x3A, 1, File); | |
2541 lineRGB = (char *)malloc(3 * (v25 + 2)); | |
2542 if ( (signed int)this->GetRenderHeight() > 0 ) | |
2543 { | |
2544 image_width = 3 * pitch; | |
2545 v9 = (unsigned short *)surface; | |
2546 for ( uint j = 0; j < this->GetRenderHeight(); j++) | |
2547 { | |
2548 a1 = (const char *)v9; | |
2549 if ( v25 > 0 ) | |
2550 { | |
2551 lineG = (char *)lineRGB + pitch; | |
2552 lineB = (char *)lineRGB + 2 * pitch; | |
2553 for ( v10 = 0; v10 < v25; v10++ ) | |
2554 { | |
2555 lineRGB[v10] = (signed int)(r_mask & *(short *)a1) >> (num_g_bits + num_b_bits + num_r_bits - 8); | |
2556 lineG[v10] = (signed int)(g_mask & *(short *)a1) >> (num_b_bits + num_g_bits - 8); | |
2557 lineB[v10] = (b_mask & *(short *)a1) << (8 - num_b_bits); | |
2558 a1 += 2; | |
2559 } | |
2560 } | |
2561 for ( uint i = 0; i < image_width; i += test_byte ) | |
2562 { | |
2563 pict_byte = lineRGB[i]; | |
2564 for ( test_byte = 1; test_byte < 0x3F; test_byte ) | |
2565 { | |
2566 v13 = i + test_byte; | |
2567 if ( lineRGB[v13] != pict_byte ) | |
2568 break; | |
2569 if ( !(v13 % pitch) ) | |
2570 break; | |
2571 } | |
2572 if ( i + test_byte > image_width ) | |
2573 test_byte = 3 * pitch - i; | |
2574 if ( test_byte > 1 || pict_byte >= 0xC0 ) | |
2575 { | |
2576 v44 = test_byte | 0xC0; | |
2577 fwrite(&v44, 1, 1, File); | |
2578 } | |
2579 fwrite(&pict_byte, 1, 1, File); | |
2580 } | |
2581 v9 += pitch; | |
2582 } | |
2583 } | |
2584 if ( this->pRenderD3D ) | |
2585 ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL)); | |
2586 else | |
2587 pRenderer->EndScene(); | |
2588 free(lineRGB); | |
2589 fclose(File); | |
2590 } | |
2591 } | |
2592 } | |
2593 | |
2594 //----- (0049F5A2) -------------------------------------------------------- | |
2595 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) | |
2596 { | |
2597 void *v8; // esi@3 | |
2598 void *v9; // esi@3 | |
2599 unsigned short* v11; // eax@4 | |
2600 // int v13; // eax@8 | |
2601 // int v14; // ecx@8 | |
2602 signed int v15; // eax@11 | |
2603 // char v16; // zf@20 | |
2604 // int result; // eax@21 | |
2605 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
2606 char v20[48]; // [sp+48h] [bp-70h]@3 | |
2607 char *lineG; // [sp+78h] [bp-40h]@7 | |
2608 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
2609 int v23; // [sp+80h] [bp-38h]@4 | |
2610 int v24; // [sp+84h] [bp-34h]@4 | |
2611 int v25; // [sp+88h] [bp-30h]@4 | |
2612 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
2613 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 | |
2614 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
2615 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
2616 int pitch; // [sp+ACh] [bp-Ch]@1 | |
2617 char v43; // [sp+B3h] [bp-5h]@18 | |
2618 int i; // [sp+B4h] [bp-4h]@6 | |
2619 unsigned short* line_picture_data; | |
2620 byte test_byte; | |
2621 unsigned char pict_byte; | |
2622 | |
2623 int num_r_bits = 5; | |
2624 int num_g_bits = 6; | |
2625 int num_b_bits = 5; | |
2626 | |
2627 int r_mask = 0xF800; | |
2628 int g_mask = 0x7E0; | |
2629 int b_mask = 0x1F; | |
2630 | |
2631 pitch = wight; | |
2632 if ( wight & 1 ) | |
2633 pitch = wight + 1; | |
2634 Src.left = 0; | |
2635 Src.up = 0; | |
2636 Src.right = wight - 1; | |
2637 Src.bottom = heidth - 1; | |
2638 v27.pitch = pitch; | |
2639 memset(&v20, 0, 0x30u); | |
2640 memset(&v18, 0, 0x38u); | |
2641 v8 = data_buff; | |
2642 v27.reserved = 0; | |
2643 *(_WORD *)&v18[56] = 0; | |
2644 Src.manufacturer = 10; | |
2645 Src.version = 5; | |
2646 Src.encoding = 1; | |
2647 Src.bpp = 8; | |
2648 Src.hdpi = 75; | |
2649 Src.vdpi = 75; | |
2650 v27.planes = 3; | |
2651 v27.palette_info = 1; | |
2652 memcpy(data_buff, &Src, 1); | |
2653 v8 = (char *)v8 + 1; | |
2654 memcpy(v8, &Src.version, 1); | |
2655 v8 = (char *)v8 + 1; | |
2656 memcpy(v8, &Src.encoding, 1); | |
2657 v8 = (char *)v8 + 1; | |
2658 memcpy(v8, &Src.bpp, 1); | |
2659 v8 = (char *)v8 + 1; | |
2660 memcpy(v8, &Src.left, 2); | |
2661 v8 = (char *)v8 + 2; | |
2662 memcpy(v8, &Src.up, 2); | |
2663 v8 = (char *)v8 + 2; | |
2664 memcpy(v8, &Src.right, 2); | |
2665 v8 = (char *)v8 + 2; | |
2666 memcpy(v8, &Src.bottom, 2); | |
2667 v8 = (char *)v8 + 2; | |
2668 memcpy(v8, &Src.hdpi, 2); | |
2669 v8 = (char *)v8 + 2; | |
2670 memcpy(v8, &Src.vdpi, 2); | |
2671 v8 = (char *)v8 + 2; | |
2672 memcpy(v8, &v20, 0x30u); | |
2673 v8 = (char *)v8 + 48; | |
2674 memcpy(v8, &v27, 1u); | |
2675 v8 = (char *)v8 + 1; | |
2676 memcpy(v8, &v27.planes, 1); | |
2677 v8 = (char *)v8 + 1; | |
2678 memcpy(v8, &v27.pitch, 2); | |
2679 v8 = (char *)v8 + 2; | |
2680 memcpy(v8, &v27.palette_info, 2); | |
2681 v8 = (char *)v8 + 2; | |
2682 memcpy(v8, &v18, 0x3Au); | |
2683 v9 = (char *)v8 + 58; | |
2684 | |
2685 lineRGB = (char*)malloc(3 * (wight + 2)); | |
2686 if ( heidth > 0 ) | |
2687 { | |
2688 v26 = 3 * pitch; | |
2689 v23 = 2 * wight; | |
2690 v11 = picture_data; | |
2691 v24 = (int)picture_data; | |
2692 for ( v25 = heidth; v25; v25-- ) | |
2693 { | |
2694 line_picture_data = v11; | |
2695 if ( wight > 0 ) | |
2696 { | |
2697 lineG = (char *)lineRGB + pitch; | |
2698 lineB = (char *)lineRGB + 2 * pitch; | |
2699 for ( uint i = 0; i < wight; i++ ) | |
2700 { | |
2701 lineRGB[i] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); | |
2702 lineG[i] = (signed int)(g_mask & *line_picture_data) >> ( num_b_bits + num_g_bits- 8); | |
2703 lineB[i] = (b_mask & *line_picture_data) << (8 - num_b_bits); | |
2704 line_picture_data += 1; | |
2705 } | |
2706 } | |
2707 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
2708 { | |
2709 pict_byte = lineRGB[i]; | |
2710 for ( test_byte = 1; test_byte < 63; ++test_byte ) | |
2711 { | |
2712 v15 = i + test_byte; | |
2713 if ( lineRGB[v15] != pict_byte )//Uninitialized memory access | |
2714 break; | |
2715 if ( !(v15 % pitch) ) | |
2716 break; | |
2717 } | |
2718 if ( i + test_byte > v26 ) | |
2719 test_byte = 3 * pitch - i; | |
2720 if ( test_byte > 1 || pict_byte >= 192 ) | |
2721 { | |
2722 v43 = test_byte | 0xC0; | |
2723 memcpy(v9, &v43, 1); | |
2724 v9 = (char *)v9 + 1; | |
2725 } | |
2726 memcpy(v9, &pict_byte, 1); | |
2727 i += test_byte; | |
2728 } | |
2729 v11 += wight; | |
2730 } | |
2731 } | |
2732 free(lineRGB); | |
2733 *(int *)packed_size = (char *)v9 - data_buff; | |
2734 } | |
2735 | |
2736 //----- (0049F8B5) -------------------------------------------------------- | |
2737 void Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) | |
2738 { | |
2739 FILE *result; // eax@1 | |
2740 FILE *pOutFile; // edi@4 | |
2741 unsigned short* v9; // eax@5 | |
2742 // int v10; // eax@7 | |
2743 signed int v12; // eax@12 | |
2744 // char v13; // zf@21 | |
2745 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
2746 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
2747 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
2748 int v18; // [sp+74h] [bp-30h]@5 | |
2749 // char *v19; // [sp+78h] [bp-2Ch]@5 | |
2750 int image_width; // [sp+7Ch] [bp-28h]@5 | |
2751 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 | |
2752 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
2753 char *lineRGB; // [sp+98h] [bp-Ch]@4 | |
2754 int pitch; // [sp+9Ch] [bp-8h]@2 | |
2755 char *lineB; // [sp+A0h] [bp-4h]@8 | |
2756 char *lineG; | |
2757 unsigned short* line_pictute_data; | |
2758 byte test_byte; | |
2759 char v43; | |
2760 | |
2761 int num_r_bits = 5; | |
2762 int num_g_bits = 6; | |
2763 int num_b_bits = 5; | |
2764 | |
2765 int r_mask = 0xF800; | |
2766 int g_mask = 0x7E0; | |
2767 int b_mask = 0x1F; | |
2768 | |
2769 result = fopen(Filename, "wb"); | |
2770 Filename = (const char *)result; | |
2771 if ( result ) | |
2772 { | |
2773 pitch = width; | |
2774 if ( width & 1 ) | |
2775 pitch = width + 1; | |
2776 header1.left = 0; | |
2777 header1.up = 0; | |
2778 header1.right = width - 1; | |
2779 header1.bottom = height - 1; | |
2780 header2.pitch = pitch; | |
2781 memset(color_map, 0, sizeof(color_map)); | |
2782 header2.reserved = 0; | |
2783 memset(v14, 0, sizeof(v14)); | |
2784 v15 = 0; | |
2785 header1.manufacturer = 10; | |
2786 header1.version = 5; | |
2787 header1.encoding = 1; | |
2788 header1.bpp = 8; | |
2789 header1.hdpi = 75; | |
2790 header1.vdpi = 75; | |
2791 header2.planes = 3; | |
2792 header2.palette_info = 1; | |
2793 fwrite(&header1, 1, 1, (FILE *)Filename); | |
2794 pOutFile = (FILE *)Filename; | |
2795 fwrite(&header1.version, 1, 1, (FILE *)Filename); | |
2796 fwrite(&header1.encoding, 1, 1, pOutFile); | |
2797 fwrite(&header1.bpp, 1, 1, pOutFile); | |
2798 fwrite(&header1.left, 2, 1, pOutFile); | |
2799 fwrite(&header1.up, 2, 1, pOutFile); | |
2800 fwrite(&header1.right, 2, 1, pOutFile); | |
2801 fwrite(&header1.bottom, 2, 1, pOutFile); | |
2802 fwrite(&header1.hdpi, 2, 1, pOutFile); | |
2803 fwrite(&header1.vdpi, 2, 1, pOutFile); | |
2804 fwrite(color_map, 0x30u, 1, pOutFile); | |
2805 fwrite(&header2, 1, 1, pOutFile); | |
2806 fwrite(&header2.planes, 1, 1, pOutFile); | |
2807 fwrite(&header2.pitch, 2, 1, pOutFile); | |
2808 fwrite(&header2.palette_info, 2, 1, pOutFile); | |
2809 fwrite(v14, 0x3Au, 1, pOutFile); | |
2810 | |
2811 lineRGB = (char *)malloc(3 * (width + 2)); | |
2812 //Ïðè ñîõðàíåíèè èçîáðàæåíèÿ ïîäðÿä èäóùèå ïèêñåëè îäèíàêîâîãî öâåòà îáúåäèíÿþòñÿ è âìåñòî óêàçàíèÿ öâåòà äëÿ êàæäîãî ïèêñåëÿ | |
2813 //óêàçûâàåòñÿ öâåò ãðóïïû ïèêñåëåé è èõ êîëè÷åñòâî. | |
2814 image_width = 3 * pitch; | |
2815 v9 = picture_data; | |
2816 for ( v18 = 0; v18 < height; v18++ )//ñòîëáåö | |
2817 { | |
2818 line_pictute_data = v9; | |
2819 lineG = (char *)lineRGB + pitch; | |
2820 lineB = (char *)lineRGB + 2 * pitch; | |
2821 | |
2822 for ( int i = 0; i < width; i++ )//ñòðîêà | |
2823 { | |
2824 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); | |
2825 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8); | |
2826 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits); | |
2827 line_pictute_data += 1; | |
2828 } | |
2829 test_byte = 1; | |
2830 for ( int i = 0; (signed int)i < image_width; i += test_byte ) | |
2831 { | |
2832 unsigned char pic_byte = lineRGB[i]; | |
2833 for ( test_byte; test_byte < 63; ++test_byte )// ðàñ÷¸ò êîëè÷åñòâà îäèíàêîâûõ öâåòîâ | |
2834 { | |
2835 v12 = i + test_byte; | |
2836 if ( lineRGB[v12] != pic_byte ) | |
2837 break; | |
2838 if ( !(v12 % pitch) ) | |
2839 break; | |
2840 } | |
2841 if ( i + test_byte > image_width ) | |
2842 test_byte = 3 * pitch - i; | |
2843 if ( test_byte > 1 || pic_byte >= 0xC0 ) | |
2844 { | |
2845 v43 = test_byte | 0xC0;//òåñò-áàéò îáúåäèíåíèÿ | |
2846 fwrite(&v43, 1, 1, pOutFile); | |
2847 } | |
2848 fwrite(&pic_byte, 1, 1, pOutFile); | |
2849 } | |
2850 v9 += width; | |
2851 } | |
2852 free(lineRGB); | |
2853 fclose(pOutFile); | |
2854 } | |
2855 } | |
2856 | |
2857 //----- (0049FBCD) -------------------------------------------------------- | |
2858 void Render::ClearTarget(unsigned int uColor) | |
2859 { | |
2860 //if (pRenderD3D) | |
2861 { | |
2862 if (using_software_screen_buffer) | |
2863 pRenderD3D->ClearTarget(true, uColor, false, 0.0); | |
2864 } | |
2865 //else | |
2866 //memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
2867 } | |
2868 | |
2869 | |
2870 //----- (0049FC37) -------------------------------------------------------- | |
2871 void Render::Present() | |
2872 { | |
2873 //struct tagRECT Rect; // [sp+8h] [bp-28h]@11 | |
2874 //RECT a4; // [sp+18h] [bp-18h]@11 | |
2875 //struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
2876 | |
2877 if ( !pRenderD3D || this->using_software_screen_buffer ) | |
2878 { | |
2879 this->pBeforePresentFunction(); | |
2880 if ( this->pRenderD3D ) | |
2881 { | |
2882 if ( this->using_software_screen_buffer ) | |
2883 pRenderD3D->Present(false); | |
2884 } | |
2885 else | |
2886 __debugbreak(); // no sr | |
2887 /*{ | |
2888 if ( this->bWindowMode ) | |
2889 { | |
2890 RestoreFrontBuffer(); | |
2891 GetClientRect(this->hWnd, &Rect); | |
2892 Point.y = 0; | |
2893 Point.x = 0; | |
2894 ClientToScreen(this->hWnd, &Point); | |
2895 OffsetRect(&Rect, Point.x, Point.y); | |
2896 a4.top = 0; | |
2897 a4.bottom = 480; | |
2898 a4.left = 0; | |
2899 a4.right = 640; | |
2900 PresentRect(&Rect, &a4); | |
2901 } | |
2902 else | |
2903 { | |
2904 RestoreFrontBuffer(); | |
2905 a4.top = 0; | |
2906 a4.bottom = 480; | |
2907 a4.left = 0; | |
2908 a4.right = 640; | |
2909 BltBackToFontFast(0, 0, &a4); | |
2910 } | |
2911 }*/ | |
2912 } | |
2913 } | |
2914 | |
2915 //----- (0049FD3A) -------------------------------------------------------- | |
2916 void Render::_49FD3A_fullscreen() | |
2917 { | |
2918 RECT src_rect; // [sp+8h] [bp-10h]@6 | |
2919 | |
2920 if ( this->pRenderD3D ) | |
2921 { | |
2922 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
2923 pFrontBuffer4->Restore(); | |
2924 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
2925 pBackBuffer4->Restore(); | |
2926 src_rect.top = 0; | |
2927 src_rect.bottom = window->GetHeight(); | |
2928 src_rect.left = 0; | |
2929 src_rect.right = window->GetWidth(); | |
2930 this->pBackBuffer4->BltFast(NULL, NULL, this->pFrontBuffer4, &src_rect, DDBLTFAST_WAIT); | |
2931 } | |
2932 } | |
2933 | |
2934 //----- (0049FDBF) -------------------------------------------------------- | |
2935 void Render::CreateZBuffer() | |
2936 { | |
2937 if (!pDefaultZBuffer) | |
2938 { | |
2939 pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000); | |
2940 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) | |
2941 } | |
2942 } | |
2943 | |
2944 //----- (0049FE05) -------------------------------------------------------- | |
2945 void Render::Release() | |
2946 { | |
2947 //Render *v1; // esi@1 | |
2948 //RenderD3D *v2; // ecx@1 | |
2949 //char v3; // zf@4 | |
2950 //void *v4; // ebx@6 | |
2951 // IDirectDraw *v5; // eax@10 | |
2952 // IDirectDrawSurface2 *v6; // eax@11 | |
2953 // IDirectDrawSurface2 *v7; // eax@13 | |
2954 // IDirectDrawSurface2 *v8; // eax@15 | |
2955 // IDirectDraw2 *v9; // eax@17 | |
2956 // IDirectDraw4 *v10; // eax@19 | |
2957 // IDirectDrawSurface4 *v11; // eax@20 | |
2958 // IDirectDrawSurface4 *v12; // eax@22 | |
2959 // IDirectDrawSurface4 *v13; // eax@24 | |
2960 // IDirectDraw4 *v14; // eax@26 | |
2961 // unsigned __int16 **v15; // ebx@28 | |
2962 // void **v16; // esi@29 | |
2963 | |
2964 // v1 = this; | |
2965 if (pRenderD3D) | |
2966 { | |
2967 if ( this->using_software_screen_buffer ) | |
2968 { | |
2969 pRenderD3D->ClearTarget(true, 0, false, 1.0); | |
2970 pRenderD3D->Present(0); | |
2971 pRenderD3D->ClearTarget(true, 0, false, 1.0); | |
2972 } | |
2973 //this->pColorKeySurface4 = 0; | |
2974 this->pBackBuffer4 = nullptr; | |
2975 this->pFrontBuffer4 = nullptr; | |
2976 this->pDirectDraw4 = nullptr; | |
2977 delete [] this->pTargetSurface_unaligned; | |
2978 this->pTargetSurface = nullptr; | |
2979 this->pTargetSurface_unaligned = nullptr; | |
2980 if (pRenderD3D) | |
2981 { | |
2982 pRenderD3D->Release(); | |
2983 delete pRenderD3D; | |
2984 } | |
2985 pRenderD3D = nullptr; | |
2986 } | |
2987 else | |
2988 ;//__debugbreak(); // no sr | |
2989 /*{ | |
2990 if ( bWinNT4_0 == 1 ) | |
2991 { | |
2992 v5 = (IDirectDraw *)this->pDirectDraw2; | |
2993 if ( !v5 ) | |
2994 return; | |
2995 v5->SetCooperativeLevel(this->hWnd, 8u); | |
2996 this->pDirectDraw2->FlipToGDISurface(); | |
2997 v6 = this->pSomeSurface2; | |
2998 if ( v6 ) | |
2999 { | |
3000 v6->Release(); | |
3001 this->pSomeSurface2 = 0; | |
3002 } | |
3003 v7 = this->pBackBuffer2; | |
3004 if ( v7 ) | |
3005 { | |
3006 v7->Release(); | |
3007 this->pBackBuffer2 = 0; | |
3008 } | |
3009 v8 = this->pFrontBuffer2; | |
3010 if ( v8 ) | |
3011 { | |
3012 v8->Release(); | |
3013 this->pFrontBuffer2 = 0; | |
3014 } | |
3015 v9 = this->pDirectDraw2; | |
3016 if ( v9 ) | |
3017 { | |
3018 v9->Release(); | |
3019 this->pDirectDraw2 = 0; | |
3020 } | |
3021 } | |
3022 else | |
3023 { | |
3024 v10 = this->pDirectDraw4; | |
3025 if ( !v10 ) | |
3026 return; | |
3027 v10->SetCooperativeLevel(this->hWnd, 1032u); | |
3028 this->pDirectDraw4->FlipToGDISurface(); | |
3029 v11 = this->pColorKeySurface4; | |
3030 if ( v11 ) | |
3031 { | |
3032 v11->Release(); | |
3033 this->pColorKeySurface4 = 0; | |
3034 } | |
3035 v12 = this->pBackBuffer4; | |
3036 if ( v12 ) | |
3037 { | |
3038 v12->Release(); | |
3039 this->pBackBuffer4 = 0; | |
3040 } | |
3041 v13 = this->pFrontBuffer4; | |
3042 if ( v13 ) | |
3043 { | |
3044 v13->Release(); | |
3045 this->pFrontBuffer4 = 0; | |
3046 } | |
3047 v14 = this->pDirectDraw4; | |
3048 if ( v14 ) | |
3049 { | |
3050 v14->Release(); | |
3051 this->pDirectDraw4 = 0; | |
3052 } | |
3053 } | |
3054 v15 = &this->pTargetSurface; | |
3055 if ( this->pTargetSurface ) | |
3056 { | |
3057 v16 = (void **)&this->ptr_400E8; | |
3058 free(*v16); | |
3059 *v15 = 0; | |
3060 *v16 = 0; | |
3061 } | |
3062 }*/ | |
3063 } | |
3064 | |
3065 void Present32(unsigned __int32 *src, unsigned int src_pitch, | |
3066 unsigned __int32 *dst, unsigned int dst_pitch) | |
3067 { | |
3068 for (uint y = 0; y < 8; ++y) | |
3069 memcpy(dst + y * dst_pitch, | |
3070 src + y * src_pitch, src_pitch * sizeof(__int32)); | |
3071 | |
3072 for (uint y = 8; y < 352; ++y) | |
3073 { | |
3074 memcpy(dst + y * dst_pitch, | |
3075 src + y * src_pitch, 8 * sizeof(__int32)); | |
3076 memcpy(dst + 8 + game_viewport_width + y * dst_pitch, | |
3077 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32)); | |
3078 } | |
3079 | |
3080 for (uint y = 352; y < 480; ++y) | |
3081 memcpy(dst + y * dst_pitch, | |
3082 src + y * src_pitch, src_pitch * sizeof(__int32)); | |
3083 | |
3084 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | |
3085 { | |
3086 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | |
3087 { | |
3088 //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) | |
3089 if (src[x + y * src_pitch] != 0xFF00FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask)) | |
3090 dst[x + y * dst_pitch] = src[x + y * src_pitch]; | |
3091 } | |
3092 } | |
3093 } | |
3094 | |
3095 //----- (004A597D) -------------------------------------------------------- | |
3096 void Present_NoColorKey() | |
3097 { | |
3098 void *v2; // edi@4 | |
3099 int v9; // eax@10 | |
3100 unsigned int v10; // esi@10 | |
3101 unsigned __int32 v11; // edi@10 | |
3102 unsigned int v13; // ebx@10 | |
3103 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3 | |
3104 int v21; // [sp+8Ch] [bp-18h]@10 | |
3105 __int32 v22; // [sp+90h] [bp-14h]@10 | |
3106 unsigned int v24; // [sp+98h] [bp-Ch]@4 | |
3107 | |
3108 int r_mask = 0xF800; | |
3109 int g_mask = 0x7E0; | |
3110 int b_mask = 0x1F; | |
3111 | |
3112 //if ( !pRenderer->uNumSceneBegins ) | |
3113 { | |
3114 //if ( pRenderer->using_software_screen_buffer ) | |
3115 //{ | |
3116 memset(&Dst, 0, sizeof(Dst)); | |
3117 Dst.dwSize = sizeof(Dst); | |
3118 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
3119 { | |
3120 //v26 = Dst.lpSurface; | |
3121 //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface; | |
3122 v24 = g_mask | b_mask | ((g_mask | b_mask) << 16); | |
3123 //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface; | |
3124 //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch; | |
3125 //v1 = pRenderer->pTargetSurface; | |
3126 v2 = Dst.lpSurface; | |
3127 | |
3128 | |
3129 /*for (uint y = 0; y < 480; ++y) | |
3130 { | |
3131 auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch); | |
3132 for (uint x = 0; x < 640; ++x) | |
3133 pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask; | |
3134 }*/ | |
3135 | |
3136 if (!FORCE_16_BITS) | |
3137 Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4); | |
3138 else | |
3139 { | |
3140 ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface; | |
3141 short* pDst = (__int16 *)Dst.lpSurface; | |
3142 | |
3143 for (uint y = 0; y < 8; ++y) | |
3144 memcpy(pDst + y * Dst.lPitch / 2, | |
3145 | |
3146 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16)); | |
3147 | |
3148 for (uint y = 8; y < 352; ++y) | |
3149 { | |
3150 memcpy(pDst + y * Dst.lPitch / 2, | |
3151 pSrc + y * window->GetWidth(), 8 * sizeof(__int16)); | |
3152 memcpy(pDst + 8 + game_viewport_width/*462*/ + y * Dst.lPitch / 2, | |
3153 pSrc + 8 + game_viewport_width/*462*/ + y * window->GetWidth(), 174/*172*/ * sizeof(__int16)); | |
3154 } | |
3155 | |
3156 for (uint y = 352; y < window->GetHeight(); ++y) | |
3157 memcpy(pDst + y * Dst.lPitch / 2, | |
3158 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16)); | |
3159 | |
3160 | |
3161 ushort* pSrc_x1y1 = pSrc + window->GetWidth() * pViewport->uViewportTL_Y + pViewport->uViewportTL_X; | |
3162 //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)]; | |
3163 short* pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportTL_Y + pViewport->uViewportTL_X; | |
3164 //v23 = (unsigned __int32)((char *)v26 + 4 * (((signed int)pViewport->uViewportX >> 1) + (Dst.lPitch >> 2) * pViewport->uViewportY)); | |
3165 v9 = ((signed int)pViewport->uViewportTL_X >> 1) - ((signed int)pViewport->uViewportBR_X >> 1); | |
3166 //v20 = ((signed int)pViewport->uViewportZ >> 1) - ((signed int)pViewport->uViewportX >> 1); | |
3167 v22 = 4 * ((Dst.lPitch / 4) + v9); | |
3168 v21 = 4 * v9 + 1280; | |
3169 | |
3170 //auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1; | |
3171 //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1); | |
3172 v10 = (int)pSrc_x1y1; | |
3173 v11 = (int)pDst_x1y1; | |
3174 int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2; | |
3175 v13 = v24; | |
3176 | |
3177 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | |
3178 { | |
3179 //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2, | |
3180 // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16)); | |
3181 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | |
3182 { | |
3183 if (pSrc[y * window->GetWidth() + x] != (g_mask | b_mask)) | |
3184 pDst[y * Dst.lPitch / 2 + x] = pSrc[y * window->GetWidth() + x]; | |
3185 } | |
3186 } | |
3187 } | |
3188 | |
3189 ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL)); | |
3190 | |
3191 /* while ( 1 ) | |
3192 { | |
3193 while ( 1 ) | |
3194 { | |
3195 v14 = *(int *)v10; | |
3196 v10 += 4; | |
3197 if ( v14 == v13 ) | |
3198 break; | |
3199 if ( (short)v14 == (short)v13 ) | |
3200 { | |
3201 *(int *)v11 = *(int *)v11 & 0xFFFF | v14 & 0xFFFF0000; | |
3202 v11 += 4; | |
3203 --uHalfWidth; | |
3204 if ( !uHalfWidth ) | |
3205 goto LABEL_21; | |
3206 } | |
3207 else | |
3208 { | |
3209 v15 = __ROL__(v14, 16); | |
3210 if ( (short)v15 == (short)v13 ) | |
3211 { | |
3212 v17 = __ROR__(v15, 16); | |
3213 *(int *)v11 = *(int *)v11 & 0xFFFF0000 | (unsigned __int16)v17; | |
3214 v11 += 4; | |
3215 --uHalfWidth; | |
3216 if ( !uHalfWidth ) | |
3217 goto LABEL_21; | |
3218 } | |
3219 else | |
3220 { | |
3221 v16 = __ROR__(v15, 16); | |
3222 *(int *)v11 = v16; | |
3223 v11 += 4; | |
3224 --uHalfWidth; | |
3225 if ( !uHalfWidth ) | |
3226 goto LABEL_21; | |
3227 } | |
3228 } | |
3229 } | |
3230 v11 += 4; | |
3231 --uHalfWidth; | |
3232 if ( !uHalfWidth ) | |
3233 { | |
3234 LABEL_21: | |
3235 v10 += v21; | |
3236 v11 += v22; | |
3237 uHalfWidth = v20; | |
3238 if ( !--uNumLines ) | |
3239 { | |
3240 ErrD3D(pRenderer->pBackBuffer4->Unlock(NULL)); | |
3241 return; | |
3242 } | |
3243 } | |
3244 }*/ | |
3245 } | |
3246 //} | |
3247 } | |
3248 } | |
3249 | |
3250 | |
3251 //----- (0049FFFB) -------------------------------------------------------- | |
3252 bool Render::InitializeFullscreen() | |
3253 { | |
3254 RenderD3D__DevInfo *v7; // ecx@5 | |
3255 bool v8; // eax@6 | |
3256 unsigned int v10; // eax@13 | |
3257 signed int v15; // ebx@31 | |
3258 int *v22; // eax@42 | |
3259 int v23; // ecx@42 | |
3260 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
3261 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
3262 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
3263 int v29; // [sp+308h] [bp-4h]@2 | |
3264 | |
3265 //__debugbreak(); // Nomad | |
3266 | |
3267 this->using_software_screen_buffer = 0; | |
3268 //this->pColorKeySurface4 = 0; | |
3269 this->pBackBuffer4 = nullptr; | |
3270 this->pFrontBuffer4 = nullptr; | |
3271 this->pDirectDraw4 = nullptr; | |
3272 //this->bColorKeySupported = 0; | |
3273 Release(); | |
3274 //v3 = hWnd; | |
3275 this->window = window; | |
3276 CreateZBuffer(); | |
3277 | |
3278 /*if (!bUserDirect3D) | |
3279 { | |
3280 CreateDirectDraw(); | |
3281 SetDirectDrawCooperationMode(hWnd, 1); | |
3282 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
3283 CreateDirectDrawPrimarySurface(); | |
3284 v15 = 1; | |
3285 } | |
3286 else | |
3287 {*/ | |
3288 pRenderD3D = new RenderD3D; | |
3289 //v28 = pRenderD3D; | |
3290 //v6 = uDesiredDirect3DDevice; | |
3291 v29 = -1; | |
3292 v7 = pRenderD3D->pAvailableDevices; | |
3293 if ( pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible ) | |
3294 v8 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, /*0*/true, window); | |
3295 else | |
3296 { | |
3297 if ( v7[1].bIsDeviceCompatible ) | |
3298 v8 = pRenderD3D->CreateDevice(1, /*0*/true, window); | |
3299 else | |
3300 { | |
3301 if ( !v7->bIsDeviceCompatible ) | |
3302 Error("There aren't any D3D devices to create."); | |
3303 | |
3304 v8 = pRenderD3D->CreateDevice(0, /*0*/true, window); | |
3305 } | |
3306 } | |
3307 if ( !v8 ) | |
3308 Error("D3Drend->Init failed."); | |
3309 | |
3310 //v9 = pRenderD3D; | |
3311 pBackBuffer4 = pRenderD3D->pBackBuffer; | |
3312 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
3313 pDirectDraw4 = pRenderD3D->pHost; | |
3314 v10 = pRenderD3D->GetDeviceCaps(); | |
3315 if ( v10 & 1 ) | |
3316 { | |
3317 if ( pRenderD3D ) | |
3318 { | |
3319 pRenderD3D->Release(); | |
3320 delete pRenderD3D; | |
3321 } | |
3322 pRenderD3D = nullptr; | |
3323 pBackBuffer4 = nullptr; | |
3324 pFrontBuffer4 = nullptr; | |
3325 pDirectDraw4 = nullptr; | |
3326 Error("Direct3D renderer: The device failed to return capabilities."); | |
3327 } | |
3328 if ( v10 & 0x3E ) | |
3329 { | |
3330 if ( pRenderD3D ) | |
3331 { | |
3332 pRenderD3D->Release(); | |
3333 delete pRenderD3D; | |
3334 } | |
3335 //pColorKeySurface4 = 0; | |
3336 pRenderD3D = nullptr; | |
3337 pBackBuffer4 = nullptr; | |
3338 pFrontBuffer4 = nullptr; | |
3339 pDirectDraw4 = nullptr; | |
3340 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
3341 } | |
3342 if ( (v10 & 0x80) != 0 ) | |
3343 { | |
3344 if ( pRenderD3D ) | |
3345 { | |
3346 pRenderD3D->Release(); | |
3347 delete pRenderD3D; | |
3348 } | |
3349 pRenderD3D = nullptr; | |
3350 pBackBuffer4 = nullptr; | |
3351 pFrontBuffer4 = nullptr; | |
3352 pDirectDraw4 = nullptr; | |
3353 Error("Direct3D renderer: The device doesn't support non-square textures."); | |
3354 } | |
3355 //LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; | |
3356 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
3357 | |
3358 memset(&halCaps, 0, sizeof(halCaps)); | |
3359 halCaps.dwSize = sizeof(halCaps); | |
3360 | |
3361 memset(&refCaps, 0, sizeof(refCaps)); | |
3362 refCaps.dwSize = sizeof(refCaps); | |
3363 | |
3364 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
3365 | |
3366 uMinDeviceTextureDim = halCaps.dwMinTextureWidth; | |
3367 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
3368 uMinDeviceTextureDim = halCaps.dwMinTextureHeight; | |
3369 uMinDeviceTextureDim = halCaps.dwMaxTextureWidth; | |
3370 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
3371 uMinDeviceTextureDim = halCaps.dwMaxTextureHeight; | |
3372 if ( (unsigned int)uMinDeviceTextureDim < 4 ) | |
3373 uMinDeviceTextureDim = 4; | |
3374 v15 = 1; | |
3375 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
3376 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
3377 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2)); | |
3378 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); | |
3379 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
3380 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
3381 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); | |
3382 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
3383 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
3384 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3)); | |
3385 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2)); | |
3386 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3387 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2)); | |
3388 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
3389 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3390 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4)); | |
3391 //} | |
3392 ddpfPrimarySuface.dwSize = 32; | |
3393 GetTargetPixelFormat(&ddpfPrimarySuface); | |
3394 ParseTargetPixelFormat(); | |
3395 | |
3396 if (!pRenderD3D) | |
3397 { | |
3398 __debugbreak(); | |
3399 pBeforePresentFunction = 0;//nullsub_1; | |
3400 } | |
3401 //else | |
3402 //{ | |
3403 /*v16 = IsColorKeySupported(pDirectDraw4); | |
3404 v17 = uAcquiredDirect3DDevice == v15; | |
3405 bColorKeySupported = v16; | |
3406 if ( !v17 ) | |
3407 bColorKeySupported = 0; | |
3408 if ( bColorKeySupported ) | |
3409 { | |
3410 memset(&ddsd2, 0, sizeof(ddsd2)); | |
3411 ddsd2.dwSize = sizeof(ddsd2); | |
3412 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3413 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3414 ddsd2.dwFlags = 65543; | |
3415 ddsd2.ddsCaps.dwCaps = 2112; | |
3416 ddsd2.dwWidth = 640; | |
3417 ddsd2.dwHeight = 480; | |
3418 ErrD3D(pDirectDraw4->CreateSurface(&ddsd2, &pColorKeySurface4, NULL)); | |
3419 pBeforePresentFunction = Present_ColorKey; | |
3420 } | |
3421 else*/ | |
3422 { | |
3423 pTargetSurface = nullptr; | |
3424 pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32); | |
3425 if ( !pTargetSurface_unaligned ) | |
3426 return 0; | |
3427 memset(&pDesc, 0, sizeof(pDesc)); | |
3428 pDesc.dwSize = sizeof(pDesc); | |
3429 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15) ) | |
3430 return 0; | |
3431 pBackBuffer4->Unlock(NULL); | |
3432 v22 = (int *)pTargetSurface_unaligned + 4; | |
3433 v23 = (unsigned int)pDesc.lpSurface & 7; | |
3434 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
3435 uTargetSurfacePitch = window->GetWidth(); | |
3436 pBeforePresentFunction = Present_NoColorKey; | |
3437 v15 = 1; | |
3438 pTargetSurface = (unsigned __int32 *)((char *)v22 + 2 * v23); | |
3439 } | |
3440 using_software_screen_buffer = v15; | |
3441 //} | |
3442 bWindowMode = 0; | |
3443 pParty->uFlags |= 2; | |
3444 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); | |
3445 return v15 != 0; | |
3446 } | |
3447 | |
3448 //----- (004A05F3) -------------------------------------------------------- | |
3449 bool Render::SwitchToWindow() | |
3450 { | |
3451 bool v7; // eax@7 | |
3452 unsigned int v9; // eax@12 | |
3453 int v12; // eax@24 | |
3454 int v13; // eax@26 | |
3455 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
3456 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
3457 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
3458 int v29; // [sp+308h] [bp-4h]@2 | |
3459 | |
3460 pParty->uFlags |= PARTY_FLAGS_1_0002; | |
3461 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); | |
3462 using_software_screen_buffer = 0; | |
3463 Release(); | |
3464 //pColorKeySurface4 = 0; | |
3465 pBackBuffer4 = nullptr; | |
3466 pFrontBuffer4 = nullptr; | |
3467 pDirectDraw4 = nullptr; | |
3468 //bColorKeySupported = 0; | |
3469 CreateZBuffer(); | |
3470 /*if (!bUserDirect3D) | |
3471 { | |
3472 CreateDirectDraw(); | |
3473 SetDirectDrawCooperationMode(hWnd, 0); | |
3474 field_4004C = 1; | |
3475 CreateFrontBuffer(); | |
3476 CreateClipper(hWnd); | |
3477 CreateBackBuffer(); | |
3478 field_40030 = 0; | |
3479 field_18_locked_pitch = 0; | |
3480 } | |
3481 else | |
3482 {*/ | |
3483 /*v3 = malloc(0x148u); | |
3484 thisa = (RenderD3D *)v3; | |
3485 v29 = 0; | |
3486 if ( v3 ) | |
3487 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
3488 else | |
3489 v4 = 0;*/ | |
3490 pRenderD3D = new RenderD3D; | |
3491 //v4 = pRenderD3D; | |
3492 //v5 = uDesiredDirect3DDevice; | |
3493 v29 = -1; | |
3494 //v6 = pRenderD3D->pAvailableDevices; | |
3495 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
3496 uDesiredDirect3DDevice != 1 ) | |
3497 { | |
3498 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, true, window); | |
3499 } | |
3500 else | |
3501 { | |
3502 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
3503 Error("There aren't any D3D devices to init."); | |
3504 | |
3505 v7 = pRenderD3D->CreateDevice(0, true, window); | |
3506 } | |
3507 if ( !v7 ) | |
3508 Error("D3Drend->Init failed."); | |
3509 | |
3510 //v8 = pRenderD3D; | |
3511 //pColorKeySurface4 = 0; | |
3512 pBackBuffer4 = pRenderD3D->pBackBuffer; | |
3513 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
3514 pDirectDraw4 = pRenderD3D->pHost; | |
3515 v9 = pRenderD3D->GetDeviceCaps(); | |
3516 if ( v9 & 1 ) | |
3517 { | |
3518 if (pRenderD3D) | |
3519 { | |
3520 pRenderD3D->Release(); | |
3521 delete pRenderD3D; | |
3522 } | |
3523 pRenderD3D = nullptr; | |
3524 pBackBuffer4 = nullptr; | |
3525 pFrontBuffer4 = nullptr; | |
3526 pDirectDraw4 = nullptr; | |
3527 Error("Direct3D renderer: The device failed to return capabilities."); | |
3528 } | |
3529 if ( v9 & 0x3E ) | |
3530 { | |
3531 if (pRenderD3D) | |
3532 { | |
3533 pRenderD3D->Release(); | |
3534 delete pRenderD3D; | |
3535 } | |
3536 //pColorKeySurface4 = 0; | |
3537 pRenderD3D = nullptr; | |
3538 pBackBuffer4 = nullptr; | |
3539 pFrontBuffer4 = nullptr; | |
3540 pDirectDraw4 = nullptr; | |
3541 Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
3542 } | |
3543 if (v9 & 0x80) | |
3544 { | |
3545 if (pRenderD3D) | |
3546 { | |
3547 pRenderD3D->Release(); | |
3548 delete pRenderD3D; | |
3549 } | |
3550 pRenderD3D = nullptr; | |
3551 pBackBuffer4 = nullptr; | |
3552 pFrontBuffer4 = nullptr; | |
3553 pDirectDraw4 = nullptr; | |
3554 Error("Direct3D renderer: The device doesn't support non-square textures."); | |
3555 } | |
3556 //LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; | |
3557 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
3558 | |
3559 memset(&halCaps, 0, sizeof(halCaps)); | |
3560 halCaps.dwSize = sizeof(halCaps); | |
3561 | |
3562 memset(&refCaps, 0, sizeof(refCaps)); | |
3563 refCaps.dwSize = sizeof(refCaps); | |
3564 | |
3565 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
3566 v12 = halCaps.dwMinTextureWidth; | |
3567 if ( (unsigned int)halCaps.dwMinTextureWidth > halCaps.dwMinTextureHeight ) | |
3568 v12 = halCaps.dwMinTextureHeight; | |
3569 uMinDeviceTextureDim = v12; | |
3570 v13 = halCaps.dwMaxTextureWidth; | |
3571 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
3572 v13 = halCaps.dwMaxTextureHeight; | |
3573 uMaxDeviceTextureDim = v13; | |
3574 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1)); | |
3575 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1)); | |
3576 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2)); | |
3577 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
3578 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
3579 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); | |
3580 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2)); | |
3581 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2)); | |
3582 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3)); | |
3583 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2)); | |
3584 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
3585 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2)); | |
3586 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2)); | |
3587 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
3588 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4)); | |
3589 //} | |
3590 | |
3591 ddpfPrimarySuface.dwSize = 32; | |
3592 GetTargetPixelFormat(&ddpfPrimarySuface); | |
3593 ParseTargetPixelFormat(); | |
3594 | |
3595 if ( !pRenderD3D ) | |
3596 { | |
3597 __debugbreak(); | |
3598 //pBeforePresentFunction = 0;//nullsub_1; | |
3599 //goto LABEL_47; | |
3600 } | |
3601 /*v14 = IsColorKeySupported(pDirectDraw4); | |
3602 v15 = uAcquiredDirect3DDevice == 1; | |
3603 bColorKeySupported = v14; | |
3604 if ( !v15 ) | |
3605 bColorKeySupported = 0;*/ | |
3606 //if ( bColorKeySupported ) | |
3607 if (false) | |
3608 { | |
3609 /*memset(&ddsd2, 0, 0x7Cu); | |
3610 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
3611 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
3612 v16 = pDirectDraw4; | |
3613 ddsd2.dwSize = 124; | |
3614 ddsd2.dwFlags = 65543; | |
3615 ddsd2.ddsCaps.dwCaps = 2112; | |
3616 ddsd2.dwWidth = 640; | |
3617 ddsd2.dwHeight = 480; | |
3618 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, NULL)); | |
3619 pBeforePresentFunction = Present_ColorKey;*/ | |
3620 using_software_screen_buffer = 1; | |
3621 //LABEL_47: | |
3622 bWindowMode = 1; | |
3623 //hWnd = hWnd; | |
3624 return 0; | |
3625 } | |
3626 pTargetSurface = 0; | |
3627 pTargetSurface_unaligned = 0; | |
3628 | |
3629 uint num_pixels = window->GetWidth() * window->GetHeight(); | |
3630 pTargetSurface_unaligned = new unsigned int[num_pixels]; | |
3631 | |
3632 if (!pTargetSurface_unaligned) | |
3633 return false; | |
3634 | |
3635 memset(&pDesc, 0, sizeof(pDesc)); | |
3636 pDesc.dwSize = sizeof(pDesc); | |
3637 if (!pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT)) | |
3638 { | |
3639 delete [] pTargetSurface_unaligned; | |
3640 return false; | |
3641 } | |
3642 | |
3643 memset32(pTargetSurface_unaligned, -1, num_pixels); | |
3644 | |
3645 pRenderer->pBackBuffer4->Unlock(NULL); | |
3646 /*v19 = pTargetSurface_unaligned; | |
3647 v20 = (unsigned int)pDesc.lpSurface & 7; | |
3648 v21 = (unsigned int)ptr_400E8 & 7; | |
3649 if ( v21 == v20 ) | |
3650 pTargetSurface = (unsigned __int16 *)v19; | |
3651 else | |
3652 { | |
3653 if ( (signed int)v21 >= v20 ) | |
3654 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
3655 else | |
3656 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
3657 pTargetSurface = (unsigned __int16 *)v22; | |
3658 }*/ | |
3659 pTargetSurface = pTargetSurface_unaligned; | |
3660 uTargetSurfacePitch = window->GetWidth(); | |
3661 pBeforePresentFunction = Present_NoColorKey; | |
3662 using_software_screen_buffer = 1; | |
3663 bWindowMode = 1; | |
3664 return 0; | |
3665 } | |
3666 | |
3667 | |
3668 //----- (0044F2B2) -------------------------------------------------------- | |
3669 bool Render::IsGammaSupported() | |
3670 { | |
3671 // bool result; // eax@3 | |
3672 // HRESULT v1; // eax@4 | |
3673 | |
3674 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
3675 { | |
3676 DDCAPS halCaps; // [sp+0h] [bp-180h]@4 | |
3677 memset(&halCaps, 0, sizeof(DDCAPS)); | |
3678 halCaps.dwSize = sizeof(DDCAPS); | |
3679 | |
3680 ErrD3D(pDirectDraw4->GetCaps(&halCaps, 0)); | |
3681 return (halCaps.dwCaps2 >> 17) & 1; | |
3682 } | |
3683 /*else | |
3684 return false;*/ | |
3685 } | |
3686 | |
3687 //----- (004A0BEE) -------------------------------------------------------- | |
3688 void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor) | |
3689 { | |
3690 signed int lower_bound; // eax@17 | |
3691 // signed int left_bound; | |
3692 unsigned int v21; // edi@46 | |
3693 int v22; // esi@47 | |
3694 int v23; // ebx@47 | |
3695 signed int v24; // edx@50 | |
3696 signed int v25; // esi@52 | |
3697 unsigned __int16 *v26; // ecx@52 | |
3698 int v27; // ebx@54 | |
3699 int v28; // edi@55 | |
3700 int v29; // edx@55 | |
3701 int v30; // ebx@60 | |
3702 int v31; // edx@61 | |
3703 int v32; // edi@61 | |
3704 signed int upper_bound; // [sp+18h] [bp-4h]@28 | |
3705 unsigned int uXa; // [sp+24h] [bp+8h]@49 | |
3706 int uYb; // [sp+28h] [bp+Ch]@47 | |
3707 bool left_border_x = false; | |
3708 bool right_border_x = false; | |
3709 bool left_border_z = false; | |
3710 bool right_border_z = false; | |
3711 bool upper_border_y = false; | |
3712 bool bottom_border_y = false; | |
3713 bool upper_border_w = false; | |
3714 bool bottom_border_w = false; | |
3715 | |
3716 if ( uX < this->raster_clip_x )// x âûõîäèò çà ðàìêè ëåâîé ãðàíèöû | |
3717 left_border_x = true; | |
3718 if ( uX > this->raster_clip_z )// x âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû | |
3719 right_border_x = true; | |
3720 | |
3721 if ( uZ < this->raster_clip_x )// z âûõîäèò çà ðàìêè ëåâîé ãðàíèöû | |
3722 left_border_z = true; | |
3723 if ( uZ > this->raster_clip_z )// z âûõîäèò çà ðàìêè ïðàâîé ãðàíèöû | |
3724 right_border_z = true; | |
3725 | |
3726 if ( uY < this->raster_clip_y )// y âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû | |
3727 upper_border_y = true; | |
3728 if ( uY > this->raster_clip_w )// y âûõîäèò çà ðàìêè íèæíåé ãðàíèöû | |
3729 bottom_border_y = true; | |
3730 | |
3731 if ( uW < this->raster_clip_y )// w âûõîäèò çà ðàìêè âåðõíåé ãðàíèöû | |
3732 upper_border_w = true; | |
3733 if ( uW > this->raster_clip_w )// w âûõîäèò çà ðàìêè íèæíåé ãðàíèöû | |
3734 bottom_border_w = true; | |
3735 | |
3736 if ( (left_border_x && left_border_z) || (right_border_x && right_border_z ) | |
3737 || (upper_border_y && upper_border_w) || (bottom_border_y && bottom_border_w)) | |
3738 return; | |
3739 | |
3740 if ( left_border_x || left_border_z || right_border_x || right_border_z | |
3741 || upper_border_y || upper_border_w || bottom_border_y || bottom_border_w) | |
3742 { | |
3743 if ( left_border_x || left_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left (ëåâàÿ ãðàíèöà) | |
3744 { | |
3745 if ( left_border_x )//left_border = true; õ ìåíüøå ëåâîé ãðàíèöû | |
3746 { | |
3747 uY += (uW - uY) * ((this->raster_clip_x - uX) / (uZ - uX));//t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) | |
3748 uX = this->raster_clip_x; | |
3749 } | |
3750 else if ( left_border_z )//z ìåíüøå ëåâîé ãðàíèöû | |
3751 { | |
3752 uZ = this->raster_clip_x; | |
3753 uW += (uY - uW) * ((this->raster_clip_x - uZ) / (uX - uZ)); | |
3754 } | |
3755 } | |
3756 | |
3757 if ( right_border_x || right_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )//for right (ïðàâàÿ ãðàíèöà) | |
3758 { | |
3759 if ( right_border_x ) //right_border = true; õ áîëüøå ïðàâîé ãðàíèöû | |
3760 { | |
3761 uY += (uY - uW) * ((this->raster_clip_z - uX) / (uZ - uX)); | |
3762 uX = this->raster_clip_z; | |
3763 } | |
3764 else if ( right_border_z )//z áîëüøå ïðàâîé ãðàíèöû | |
3765 { | |
3766 uW += (uW - uY) * ((this->raster_clip_z - uZ) / (uX - uZ)); | |
3767 uZ = this->raster_clip_z; | |
3768 } | |
3769 } | |
3770 | |
3771 upper_bound = 0; | |
3772 if ( uY < this->raster_clip_y ) | |
3773 upper_bound = 2; | |
3774 if ( uY > this->raster_clip_w ) | |
3775 upper_bound |= 1; | |
3776 | |
3777 lower_bound = 0; | |
3778 if ( uW < this->raster_clip_y ) | |
3779 lower_bound = 2; | |
3780 if ( uW > this->raster_clip_w ) | |
3781 lower_bound |= 1; | |
3782 | |
3783 if ( !(lower_bound & upper_bound) )//for up and down(äëÿ âåðõà è íèçà) | |
3784 { | |
3785 lower_bound ^= upper_bound; | |
3786 if ( lower_bound & 2 ) | |
3787 { | |
3788 if ( upper_bound & 2 ) | |
3789 { | |
3790 uX += (uZ - uX) * ((this->raster_clip_y - uY) / (uW - uY)); | |
3791 uY = this->raster_clip_y; | |
3792 } | |
3793 else | |
3794 { | |
3795 uZ += (uX - uZ) * ((this->raster_clip_y - uW) / (uY - uW)); | |
3796 uW = this->raster_clip_y; | |
3797 } | |
3798 } | |
3799 if ( lower_bound & 1 ) | |
3800 { | |
3801 if ( upper_bound & 1 ) | |
3802 { | |
3803 uX += (uZ - uX) * ((this->raster_clip_w - uY) / (uW - uY)); | |
3804 uY = this->raster_clip_w; | |
3805 } | |
3806 else | |
3807 { | |
3808 uZ += (uX - uZ) * ((this->raster_clip_w - uW) / (uY - uW)); | |
3809 uW = this->raster_clip_w; | |
3810 } | |
3811 } | |
3812 } | |
3813 } | |
3814 v21 = pRenderer->uTargetSurfacePitch; | |
3815 if ( pRenderer->uTargetSurfacePitch ) | |
3816 { | |
3817 //v12 = uX + uY * pRenderer->uTargetSurfacePitch; | |
3818 v22 = uW - uY; | |
3819 v23 = v22; | |
3820 uYb = v22; | |
3821 if ( v22 < 0 ) | |
3822 { | |
3823 v23 = -v22; | |
3824 uYb = -v22; | |
3825 v21 = -pRenderer->uTargetSurfacePitch; | |
3826 } | |
3827 uXa = uZ - uX; | |
3828 if ((signed)(uZ - uX) >= 0) | |
3829 v24 = 1; | |
3830 else | |
3831 { | |
3832 uXa = -uXa; | |
3833 v24 = -1; | |
3834 } | |
3835 v25 = 0; | |
3836 | |
3837 v26 = (unsigned __int16 *)this->pTargetSurface; | |
3838 if ( v26 ) | |
3839 { | |
3840 if ( (signed int)uXa <= v23 )//ðèñóåì âåðòèêàëüíóþ ëèíèþ | |
3841 { | |
3842 v30 = v23 + 1; | |
3843 if ( v30 > 0 ) | |
3844 { | |
3845 v31 = 2 * v24; | |
3846 v32 = 2 * v21; | |
3847 //v12 = (int)&v26[v12]; | |
3848 int y = 0; | |
3849 int x = 0; | |
3850 for ( v30; v30; --v30 ) | |
3851 { | |
3852 v25 += uXa; | |
3853 //*(short *)v12 = uColor; | |
3854 //v12 += v32; | |
3855 WritePixel16(uX + x, uY + y, uColor); | |
3856 if ( v32 >= 0 ) | |
3857 y += 1; | |
3858 else | |
3859 y -= 1; | |
3860 if ( v25 > 0 ) | |
3861 { | |
3862 v25 -= uYb; | |
3863 //v12 += v31; | |
3864 if ( v31 >= 0 ) | |
3865 x += 1; | |
3866 else | |
3867 x -= 1; | |
3868 } | |
3869 } | |
3870 } | |
3871 } | |
3872 else//ðèñóåì ãîðèçîíòàëüíóþ ëèíèþ | |
3873 { | |
3874 v27 = uXa + 1; | |
3875 if ( (signed int)(uXa + 1) > 0 ) | |
3876 { | |
3877 v28 = 2 * v21; | |
3878 v29 = 2 * v24; | |
3879 int y = 0; | |
3880 int x = 0; | |
3881 //v12 = (int)&v26[v12]; | |
3882 for ( v27; v27; --v27 ) | |
3883 { | |
3884 v25 += uYb; | |
3885 //*(short *)v12 = uColor; | |
3886 //v12 += v29; | |
3887 WritePixel16(uX + x, uY + y, uColor); | |
3888 if ( v29 >= 0 ) | |
3889 x += 1; | |
3890 else | |
3891 x -= 1; | |
3892 if ( v25 > (signed int)uXa ) | |
3893 { | |
3894 v25 -= uXa; | |
3895 //v12 += v28; | |
3896 if ( v28 >= 0 ) | |
3897 y += 1; | |
3898 else | |
3899 y -= 1; | |
3900 } | |
3901 } | |
3902 } | |
3903 } | |
3904 } | |
3905 } | |
3906 return; | |
3907 } | |
3908 | |
3909 //----- (004A0E80) -------------------------------------------------------- | |
3910 void Render::ClearZBuffer(int a2, int a3) | |
3911 { | |
3912 memset32(this->pActiveZBuffer, -65536, 0x4B000); | |
3913 } | |
3914 | |
3915 //----- (004A0E97) -------------------------------------------------------- | |
3916 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) | |
3917 { | |
3918 this->raster_clip_x = uX; | |
3919 this->raster_clip_y = uY; | |
3920 this->raster_clip_z = uZ; | |
3921 this->raster_clip_w = uW; | |
3922 } | |
3923 | |
3924 //----- (004A0EB6) -------------------------------------------------------- | |
3925 void Render::ParseTargetPixelFormat() | |
3926 { | |
3927 signed int v2; // ecx@1 | |
3928 DWORD uRedMask; // edx@1 | |
3929 unsigned int uGreenMask; // esi@5 | |
3930 signed int v5; // ecx@5 | |
3931 unsigned int uBlueMask; // edx@9 | |
3932 signed int v7; // ecx@9 | |
3933 //unsigned int v8; // ecx@13 | |
3934 | |
3935 v2 = 0; | |
3936 uRedMask = this->ddpfPrimarySuface.dwRBitMask; | |
3937 this->uTargetBBits = 0; | |
3938 this->uTargetGBits = 0; | |
3939 this->uTargetRBits = 0; | |
3940 do | |
3941 { | |
3942 if ( (1 << v2) & uRedMask ) | |
3943 ++this->uTargetRBits; | |
3944 ++v2; | |
3945 } | |
3946 while ( v2 < 32 ); | |
3947 uGreenMask = this->ddpfPrimarySuface.dwGBitMask; | |
3948 v5 = 0; | |
3949 do | |
3950 { | |
3951 if ( (1 << v5) & uGreenMask ) | |
3952 ++this->uTargetGBits; | |
3953 ++v5; | |
3954 } | |
3955 while ( v5 < 32 ); | |
3956 uBlueMask = this->ddpfPrimarySuface.dwBBitMask; | |
3957 v7 = 0; | |
3958 do | |
3959 { | |
3960 if ( (1 << v7) & uBlueMask ) | |
3961 ++this->uTargetBBits; | |
3962 ++v7; | |
3963 } | |
3964 while ( v7 < 32 ); | |
3965 this->uTargetGMask = uGreenMask; | |
3966 this->uTargetRMask = this->ddpfPrimarySuface.dwRBitMask; | |
3967 this->uTargetBMask = uBlueMask; | |
3968 } | |
3969 | |
3970 //----- (004A0F40) -------------------------------------------------------- | |
3971 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
3972 { | |
3973 HRESULT result; // eax@1 | |
3974 HRESULT v6; // eax@4 | |
3975 char v9; // [sp+Bh] [bp-1h]@1 | |
3976 | |
3977 v9 = 1; | |
3978 result = pSurface->Lock(NULL, pDesc, uLockFlags, NULL); | |
3979 /* | |
3980 Êîãäà îáúåêò DirectDrawSurface òåðÿåò ïîâåðõíîñòíóþ ïàìÿòü, ìåòîäû âîçâðàòÿò DDERR_SURFACELOST | |
3981 è íå âûïîëíÿò íèêàêóþ äðóãóþ ôóíêöèþ. Ìåòîä IDirectDrawSurface::Restore ïåðåðàñïðåäåëèò ïîâåðõíîñòíóþ ïàìÿòü | |
3982 è ïîâòîðíî ïðèñîåäèíèò åå ê îáúåêòó DirectDrawSurface. | |
3983 */ | |
3984 if ( result == DDERR_SURFACELOST ) | |
3985 { | |
3986 v6 = pSurface->Restore();//Âîññòàíàâëèâàåò ïîòåðÿííóþ ïîâåðõíîñòü. Ýòî ïðîèñõîäèò, êîãäà ïîâåðõíîñòíàÿ ïàìÿòü, | |
3987 //ñâÿçàííàÿ ñ îáúåêòîì DirectDrawSurface áûëà îñâîáîæäåíà. | |
3988 if ( v6 ) | |
3989 { | |
3990 if ( v6 != DDERR_IMPLICITLYCREATED )//DDERR_IMPLICITLYCREATED - Ïîâåðõíîñòü íå ìîæåò áûòü âîññòàíîâëåíà, | |
3991 //ïîòîìó ÷òî îíà - íåÿâíî ñîçäàííàÿ ïîâåðõíîñòü. | |
3992 { | |
3993 v9 = 0; | |
3994 result = (bool)memset(pDesc, 0, 4); | |
3995 LOBYTE(result) = v9; | |
3996 return 0; | |
3997 } | |
3998 pRenderer->pFrontBuffer4->Restore(); | |
3999 pSurface->Restore(); | |
4000 } | |
4001 result = pSurface->Lock(NULL, pDesc, DDLOCK_WAIT, NULL); | |
4002 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY )//DDERR_SURFACEBUSY - Äîñòóï ê ýòîé ïîâåðõíîñòè îòêàçàí, | |
4003 //ïîòîìó ÷òî ïîâåðõíîñòü áëîêèðîâàíà äðóãîé íèòüþ. DDERR_INVALIDRECT - Îáåñïå÷èâàåìûé ïðÿìîóãîëüíèê íåäîïóñòèì. | |
4004 { | |
4005 v9 = 0; | |
4006 result = (bool)memset(pDesc, 0, 4); | |
4007 LOBYTE(result) = v9; | |
4008 return result; | |
4009 } | |
4010 ErrD3D(result); | |
4011 if ( result ) | |
4012 { | |
4013 //v8 = 0; | |
4014 //v7 = 2161; | |
4015 //LABEL_19: | |
4016 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
4017 v9 = 0; | |
4018 result = (bool)memset(pDesc, 0, 4); | |
4019 LOBYTE(result) = v9; | |
4020 return result; | |
4021 } | |
4022 if ( pRenderD3D ) | |
4023 pRenderD3D->HandleLostResources(); | |
4024 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
4025 } | |
4026 else | |
4027 { | |
4028 if ( result ) | |
4029 { | |
4030 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
4031 { | |
4032 v9 = 0; | |
4033 result = (bool)memset(pDesc, 0, 4); | |
4034 LOBYTE(result) = v9; | |
4035 return result; | |
4036 } | |
4037 ErrD3D(result); | |
4038 //v8 = 0; | |
4039 //v7 = 2199; | |
4040 //goto LABEL_19; | |
4041 } | |
4042 } | |
4043 return true; | |
4044 } | |
4045 | |
4046 | |
4047 //----- (004A10E4) -------------------------------------------------------- | |
4048 void Render::CreateDirectDraw() | |
4049 { | |
4050 //Render *v1; // edi@1 | |
4051 // HRESULT v2; // eax@1 | |
4052 // HRESULT v3; // eax@5 | |
4053 // int v6; // [sp-Ch] [bp-20h]@3 | |
4054 // unsigned int v9; // [sp+0h] [bp-14h]@0 | |
4055 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
4056 | |
4057 //v1 = this; | |
4058 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
4059 | |
4060 pDirectDraw4 = nullptr; | |
4061 | |
4062 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); | |
4063 | |
4064 lpDD->Release(); | |
4065 lpDD = nullptr; | |
4066 } | |
4067 | |
4068 //----- (004A1169) -------------------------------------------------------- | |
4069 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
4070 { | |
4071 DWORD flags; // eax@1 | |
4072 | |
4073 //Óñòàíîâêà âçàèìîäåéñòâèÿ äëÿ ïîëíîýêðàííîãî è îêîííîãî ðåæèìîâ | |
4074 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : DDSCL_NORMAL; | |
4075 | |
4076 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); | |
4077 } | |
4078 | |
4079 //----- (004A11C6) -------------------------------------------------------- | |
4080 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
4081 { | |
4082 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
4083 } | |
4084 | |
4085 //----- (004A121C) -------------------------------------------------------- | |
4086 void Render::CreateFrontBuffer() | |
4087 { | |
4088 //Render *v1; // esi@1 | |
4089 IDirectDraw *pDD; // eax@3 | |
4090 IDirectDrawSurface **pOutSurf; // esi@3 | |
4091 struct _DDSURFACEDESC *v4; // edx@3 | |
4092 //// HRESULT v5; // eax@5 | |
4093 int v6; // [sp-8h] [bp-8Ch]@3 | |
4094 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4095 | |
4096 //v1 = this; | |
4097 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
4098 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4099 { | |
4100 memset(&a2, 0, sizeof(a2)); | |
4101 a2.dwSize = sizeof(a2); | |
4102 | |
4103 pDD = (IDirectDraw *)this->pDirectDraw4; | |
4104 a2.dwFlags = 1; | |
4105 a2.ddsCaps.dwCaps = 512;//DDSCAPS_PRIMARYSURFACE = 0x200 | |
4106 | |
4107 v6 = 2357; | |
4108 pOutSurf = (IDirectDrawSurface **)&this->pFrontBuffer4; | |
4109 v4 = (struct _DDSURFACEDESC *)&a2; | |
4110 } | |
4111 /*else | |
4112 { | |
4113 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
4114 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
4115 a2.lPitch = 108; | |
4116 a2.dwBackBufferCount = 1; | |
4117 a2.dwTextureStage = 512; | |
4118 v6 = 2346; | |
4119 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
4120 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
4121 }*/ | |
4122 ErrD3D(pDD->CreateSurface(v4, pOutSurf, NULL)); | |
4123 } | |
4124 | |
4125 //----- (004A12CD) -------------------------------------------------------- | |
4126 void Render::CreateBackBuffer() | |
4127 { | |
4128 //Render *v1; // esi@1 | |
4129 IDirectDraw *v2; // eax@3 | |
4130 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
4131 struct _DDSURFACEDESC *v4; // edx@3 | |
4132 // HRESULT v5; // eax@5 | |
4133 int v6; // [sp-8h] [bp-8Ch]@3 | |
4134 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
4135 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
4136 | |
4137 //v1 = this; | |
4138 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
4139 // pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4140 { | |
4141 memset(&a2, 0, sizeof(a2)); | |
4142 a2.dwSize = sizeof(a2); | |
4143 | |
4144 v2 = (IDirectDraw *)this->pDirectDraw4; | |
4145 a2.dwFlags = 7; | |
4146 a2.ddsCaps.dwCaps = 2112;//0x840 = DDSCAPS_SYSTEMMEMORY = 0x800 | DDSCAPS_OFFSCREENPLAIN = 0x40 | |
4147 a2.dwWidth = window->GetWidth(); | |
4148 a2.dwHeight = window->GetHeight(); | |
4149 | |
4150 v7 = 0; | |
4151 v6 = 2387; | |
4152 ppBackBuffer = (IDirectDrawSurface **)&this->pBackBuffer4; | |
4153 v4 = (struct _DDSURFACEDESC *)&a2; | |
4154 } | |
4155 /*else | |
4156 { | |
4157 memset(&a2.lPitch, 0, 0x6Cu); | |
4158 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
4159 a2.lPitch = 108; | |
4160 a2.dwBackBufferCount = 7; | |
4161 v7 = 0; | |
4162 a2.dwTextureStage = 2112; | |
4163 a2.dwAlphaBitDepth = 640; | |
4164 a2.dwMipMapCount = 480; | |
4165 v6 = 2374; | |
4166 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4167 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
4168 }*/ | |
4169 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, NULL)); | |
4170 } | |
4171 | |
4172 //----- (004A139A) -------------------------------------------------------- | |
4173 void Render::CreateDirectDrawPrimarySurface() | |
4174 { | |
4175 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
4176 DDSCAPS2 *v6; // edx@3 | |
4177 IDirectDraw4 *v7; // eax@4 | |
4178 int v9; // ST14_4@5 | |
4179 IDirectDrawSurface *v10; // ST10_4@5 | |
4180 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
4181 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
4182 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
4183 | |
4184 //v1 = this; | |
4185 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
4186 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4187 { | |
4188 //v2 = 0; | |
4189 //this->field_4004C = 1; | |
4190 memset(&ddsd2, 0, sizeof(ddsd2)); | |
4191 ddsd2.dwSize = sizeof(ddsd2); | |
4192 | |
4193 ddsd2.dwBackBufferCount = 1; | |
4194 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4195 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
4196 ErrD3D(this->pDirectDraw4->CreateSurface(&ddsd2, &pFrontBuffer4, NULL)); | |
4197 pFrontBuffer = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4198 ppBackBuffer = (IDirectDrawSurface **)&this->pBackBuffer4; | |
4199 } | |
4200 /*else | |
4201 { | |
4202 v2 = 0; | |
4203 this->field_4004C = 1; | |
4204 | |
4205 DDSURFACEDESC ddsd; | |
4206 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
4207 | |
4208 ddsd.lpSurface = (LPVOID)1; | |
4209 ddsd.lPitch = 108; | |
4210 ddsd.dwBackBufferCount = 33; | |
4211 ddsd.ddsCaps.dwCaps = 8728; | |
4212 ErrD3D(pDirectDraw2->CreateSurface(&ddsd, (IDirectDrawSurface **)&pFrontBuffer2, NULL)); | |
4213 | |
4214 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
4215 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
4216 }*/ | |
4217 __debugbreak(); // warning C4700: uninitialized local variable 'v6' used | |
4218 v9 = (int)v6; | |
4219 v10 = pFrontBuffer; // BUG | |
4220 | |
4221 v17.dwCaps = 4; | |
4222 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
4223 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
4224 //v1->field_40030 = v2; | |
4225 //v1->field_18_locked_pitch = v2; | |
4226 } | |
4227 | |
4228 //----- (004A14F4) -------------------------------------------------------- | |
4229 void Render::CreateClipper(HWND a2) | |
4230 { | |
4231 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, NULL)); | |
4232 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
4233 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
4234 } | |
4235 | |
4236 //----- (004A15D8) -------------------------------------------------------- | |
4237 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
4238 { | |
4239 pFrontBuffer4->GetPixelFormat(pOut); | |
4240 } | |
4241 | |
4242 //----- (004A1605) -------------------------------------------------------- | |
4243 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
4244 { | |
4245 signed int v4; // eax@3 | |
4246 | |
4247 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
4248 //pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4249 { | |
4250 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4251 | |
4252 memset(&pDesc, 0, sizeof(pDesc)); | |
4253 pDesc.dwSize = sizeof(pDesc); | |
4254 | |
4255 LockSurface_DDraw4(this->pBackBuffer4, &pDesc, DDLOCK_WAIT); | |
4256 *pOutSurfacePtr = pDesc.lpSurface; | |
4257 v4 = pDesc.lPitch; | |
4258 } | |
4259 /*else | |
4260 { | |
4261 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4262 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4263 pDesc.lPitch = 108; | |
4264 LockSurface_DDraw2(this->pBackBuffer2, &pDesc, 1); | |
4265 *pOutSurfacePtr = (void *)pDesc.lpSurface; | |
4266 v4 = pDesc.dwReserved; | |
4267 }*/ | |
4268 *pOutPixelsPerRow = v4 >> 1; | |
4269 } | |
4270 | |
4271 //----- (004A16E1) -------------------------------------------------------- | |
4272 void Render::UnlockBackBuffer() | |
4273 { | |
4274 ErrD3D(pBackBuffer4->Unlock(NULL)); | |
4275 } | |
4276 | |
4277 //----- (004A172E) -------------------------------------------------------- | |
4278 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
4279 { | |
4280 signed int v4; // eax@3 | |
4281 | |
4282 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4283 { | |
4284 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
4285 | |
4286 memset(&pDesc, 0, sizeof(pDesc)); | |
4287 pDesc.dwSize = sizeof(pDesc); | |
4288 | |
4289 LockSurface_DDraw4(this->pFrontBuffer4, &pDesc, DDLOCK_WAIT); | |
4290 *pOutSurface = pDesc.lpSurface; | |
4291 v4 = pDesc.lPitch; | |
4292 } | |
4293 /*else | |
4294 { | |
4295 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
4296 memset(&pDesc.lPitch, 0, 0x6Cu); | |
4297 pDesc.lPitch = 108; | |
4298 LockSurface_DDraw2(this->pFrontBuffer2, &pDesc, 1); | |
4299 *pOutSurface = (void *)pDesc.lpSurface; | |
4300 v4 = pDesc.dwReserved; | |
4301 }*/ | |
4302 *pOutPixelsPerRow = v4 >> 1; | |
4303 } | |
4304 | |
4305 //----- (004A17C7) -------------------------------------------------------- | |
4306 void Render::UnlockFrontBuffer() | |
4307 { | |
4308 ErrD3D(pFrontBuffer4->Unlock(NULL)); | |
4309 } | |
4310 | |
4311 //----- (004A1814) -------------------------------------------------------- | |
4312 void Render::RestoreFrontBuffer() | |
4313 { | |
4314 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST ) | |
4315 pFrontBuffer4->Restore(); | |
4316 } | |
4317 | |
4318 //----- (004A184C) -------------------------------------------------------- | |
4319 void Render::RestoreBackBuffer() | |
4320 { | |
4321 if ( pBackBuffer4->IsLost() == DDERR_SURFACELOST ) | |
4322 pBackBuffer4->Restore(); | |
4323 } | |
4324 | |
4325 //----- (004A18F5) -------------------------------------------------------- | |
4326 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
4327 { | |
4328 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
4329 } | |
4330 | |
4331 //----- (004A194A) -------------------------------------------------------- | |
4332 void Render::BltBackToFontFast(int a2, int a3, RECT *pSrcRect) | |
4333 { | |
4334 IDirectDrawSurface *pFront; // eax@3 | |
4335 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
4336 | |
4337 //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4338 { | |
4339 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
4340 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
4341 } | |
4342 /*else | |
4343 { | |
4344 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
4345 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
4346 }*/ | |
4347 pFront->BltFast(NULL, NULL, pBack, pSrcRect, DDBLTFAST_WAIT); | |
4348 } | |
4349 | |
4350 //----- (004A1B22) -------------------------------------------------------- | |
4351 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) | |
4352 { | |
4353 unsigned int v7; // edx@6 | |
4354 | |
4355 if (uNumBillboardsToDraw >= 999 ) | |
4356 return 0; | |
4357 if (!uNumBillboardsToDraw) | |
4358 { | |
4359 uNumBillboardsToDraw = 1; | |
4360 return 0; | |
4361 } | |
4362 | |
4363 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch | |
4364 { | |
4365 v7 = left + (right - left) / 2; | |
4366 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) | |
4367 right = v7; | |
4368 else | |
4369 left = v7 + 1; | |
4370 } | |
4371 | |
4372 if (z > pRenderer->pBillboardRenderListD3D[v7].z_order ) | |
4373 { | |
4374 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
4375 v7 = pRenderer->uNumBillboardsToDraw; | |
4376 else | |
4377 { | |
4378 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4379 { | |
4380 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ ) | |
4381 { | |
4382 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i], | |
4383 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - (i + 1)], | |
4384 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i])); | |
4385 } | |
4386 } | |
4387 ++v7; | |
4388 } | |
4389 uNumBillboardsToDraw++; | |
4390 return v7; | |
4391 } | |
4392 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order ) | |
4393 { | |
4394 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
4395 { | |
4396 for ( uint i = 0; i < pRenderer->uNumBillboardsToDraw - v7; i++ ) | |
4397 { | |
4398 memcpy(&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i], | |
4399 &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw -(i + 1)], | |
4400 sizeof(pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - i])); | |
4401 } | |
4402 } | |
4403 uNumBillboardsToDraw++; | |
4404 return v7; | |
4405 } | |
4406 return v7; | |
4407 } | |
4408 | |
4409 //----- (004A1E9D) -------------------------------------------------------- | |
4410 unsigned int Render::GetBillboardDrawListSize() | |
4411 { | |
4412 return pRenderer->uNumBillboardsToDraw; | |
4413 } | |
4414 | |
4415 //----- (004A1EA3) -------------------------------------------------------- | |
4416 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
4417 { | |
4418 return pRenderer->pBillboardRenderListD3D[uBillboardID].sParentBillboardID; | |
4419 } | |
4420 | |
4421 //----- (004A1EB6) -------------------------------------------------------- | |
4422 void Render::BeginSceneD3D() | |
4423 { | |
4424 if (!uNumD3DSceneBegins++) | |
4425 { | |
4426 //if (pRenderD3D) | |
4427 { | |
4428 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
4429 pRenderer->uNumBillboardsToDraw = 0; | |
4430 pRenderD3D->pDevice->BeginScene(); | |
4431 | |
4432 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
4433 uFogColor = GetLevelFogColor(); | |
4434 else | |
4435 uFogColor = 0; | |
4436 | |
4437 if ( uFogColor & 0xFF000000 ) | |
4438 { | |
4439 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
4440 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
4441 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4442 bUsingSpecular = true; | |
4443 } | |
4444 else | |
4445 { | |
4446 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
4447 bUsingSpecular = 0; | |
4448 } | |
4449 } | |
4450 /*else | |
4451 { | |
4452 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
4453 if (pTargetSurface) | |
4454 field_18_locked_pitch = uTargetSurfacePitch; | |
4455 else | |
4456 --uNumD3DSceneBegins; | |
4457 }*/ | |
4458 } | |
4459 } | |
4460 | |
4461 //----- (004A1FE1) -------------------------------------------------------- | |
4462 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
4463 { | |
4464 --uNumD3DSceneBegins; | |
4465 if (uNumD3DSceneBegins) | |
4466 return; | |
4467 | |
4468 if (pRenderD3D) | |
4469 { | |
2541 | 4470 pEngine->draw_debug_outlines(); |
2496 | 4471 DoRenderBillboards_D3D(); |
2541 | 4472 pEngine->pStru6Instance->RenderSpecialEffects(); |
2496 | 4473 pRenderD3D->pDevice->EndScene(); |
4474 } | |
4475 else | |
2541 | 4476 pEngine->pStru6Instance->RenderSpecialEffects(); |
2496 | 4477 } |
4478 | |
4479 //----- (004A2031) -------------------------------------------------------- | |
4480 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) | |
4481 { | |
4482 // __debugbreak(); // should not fire outside decal builder | |
4483 return ::GetActorTintColor(tint, a4, a2, a5, a6); | |
4484 } | |
4485 | |
4486 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function | |
4487 { | |
4488 int v5; // ebx@1 | |
4489 int v6; // edi@1 | |
4490 int v8; // eax@7 | |
4491 float v9; // eax@12 | |
4492 float *v10; // esi@12 | |
4493 float v11; // ecx@14 | |
4494 double v12; // st7@14 | |
4495 double v13; // st7@14 | |
4496 double v14; // st7@14 | |
4497 signed int v15; // eax@14 | |
4498 int v16; // eax@15 | |
4499 float v17; // ST48_4@15 | |
4500 char v18; // zf@17 | |
4501 int v19; // eax@18 | |
4502 int v20; // eax@18 | |
4503 int v21; // edx@20 | |
4504 signed int v22; // ecx@20 | |
4505 int v23; // eax@20 | |
4506 const char *v24; // ST4C_4@20 | |
4507 unsigned int v25; // ST50_4@20 | |
4508 int v26; // ST54_4@20 | |
4509 int v27; // eax@20 | |
4510 _UNKNOWN *v28; // eax@21 | |
4511 int v29; // ecx@23 | |
4512 int v30; // eax@23 | |
4513 int v31; // eax@23 | |
4514 int v32; // eax@24 | |
4515 int v33; // eax@25 | |
4516 int v34; // eax@25 | |
4517 int v35; // eax@25 | |
4518 int v36; // eax@25 | |
4519 signed int v37; // ecx@26 | |
4520 int v38; // eax@26 | |
4521 _UNKNOWN *v39; // eax@27 | |
4522 int v40; // edx@28 | |
4523 int v41; // eax@29 | |
4524 int v42; // eax@29 | |
4525 int v43; // eax@29 | |
4526 int v44; // eax@29 | |
4527 unsigned int v46; // eax@29 | |
4528 int v47; // eax@30 | |
4529 int v48; // eax@30 | |
4530 int v49; // eax@30 | |
4531 double v52; // st6@35 | |
4532 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
4533 int v57; // [sp+5Ch] [bp-Ch]@3 | |
4534 signed int v59; // [sp+60h] [bp-8h]@12 | |
4535 int v61; // [sp+64h] [bp-4h]@4 | |
4536 int i; | |
4537 | |
4538 v6 = (int)this; | |
4539 v5 = 0; | |
4540 if (!this->uNumD3DSceneBegins) | |
4541 return; | |
4542 | |
4543 | |
4544 | |
4545 | |
4546 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); | |
4547 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); | |
4548 if (this->bUsingSpecular) | |
4549 { | |
4550 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
4551 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4552 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
4553 } | |
4554 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4555 pVertices[0].pos.x = VertexRenderList[0].vWorldViewProjX; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4556 pVertices[0].pos.y = VertexRenderList[0].vWorldViewProjY; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4557 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * VertexRenderList[0].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4558 pVertices[0].rhw = 1.0 / (VertexRenderList[0].vWorldViewPosition.x + 0.0000001000000011686097); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4559 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, VertexRenderList[0].vWorldViewPosition.x, 0, 0); |
2496 | 4560 pVertices[0].specular = 0; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4561 pVertices[0].texcoord.x = VertexRenderList[0].u; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4562 pVertices[0].texcoord.y = VertexRenderList[0].v; |
2496 | 4563 |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4564 pVertices[1].pos.x = VertexRenderList[3].vWorldViewProjX; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4565 pVertices[1].pos.y = VertexRenderList[3].vWorldViewProjY; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4566 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * VertexRenderList[3].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4567 pVertices[1].rhw = 1.0 / (VertexRenderList[3].vWorldViewPosition.x + 0.0000001000000011686097); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4568 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, VertexRenderList[3].vWorldViewPosition.x, 0, 0); |
2496 | 4569 pVertices[1].specular = 0; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4570 pVertices[1].texcoord.x = VertexRenderList[3].u; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4571 pVertices[1].texcoord.y = VertexRenderList[3].v; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4572 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4573 pVertices[2].pos.x = VertexRenderList[1].vWorldViewProjX; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4574 pVertices[2].pos.y = VertexRenderList[1].vWorldViewProjY; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4575 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * VertexRenderList[1].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4576 pVertices[2].rhw = 1.0 / (VertexRenderList[1].vWorldViewPosition.x + 0.0000001000000011686097); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4577 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, VertexRenderList[1].vWorldViewPosition.x, 0, 0); |
2496 | 4578 pVertices[2].specular = 0; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4579 pVertices[2].texcoord.x = VertexRenderList[1].u; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4580 pVertices[2].texcoord.y = VertexRenderList[1].v; |
2496 | 4581 |
4582 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
4583 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
4584 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4585 pVertices[5].pos.x = VertexRenderList[2].vWorldViewProjX; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4586 pVertices[5].pos.y = VertexRenderList[2].vWorldViewProjY; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4587 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * VertexRenderList[2].vWorldViewPosition.x / (double)pODMRenderParams->shading_dist_mist); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4588 pVertices[5].rhw = 1.0 / (VertexRenderList[2].vWorldViewPosition.x + 0.0000001000000011686097); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4589 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, VertexRenderList[2].vWorldViewPosition.x, 0, 0); |
2496 | 4590 pVertices[5].specular = 0; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4591 pVertices[5].texcoord.x = VertexRenderList[2].u; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4592 pVertices[5].texcoord.y = VertexRenderList[2].v; |
2496 | 4593 |
4594 | |
4595 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4596 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
4597 | |
4598 }*/ | |
4599 | |
4600 //----- (004A26BC) -------------------------------------------------------- | |
4601 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) | |
4602 { | |
4603 int v11; // eax@5 | |
4604 int v20; // eax@14 | |
4605 unsigned int v45; // eax@28 | |
4606 | |
4607 if (!this->uNumD3DSceneBegins) | |
4608 return; | |
4609 if ( uNumVertices < 3) | |
4610 return; | |
4611 | |
2541 | 4612 if ( byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_01_lightmap_related) |
2496 | 4613 { |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4614 v11 = ::GetActorTintColor(a4->dimming_level, 0, VertexRenderList[0].vWorldViewPosition.x, 0, 0); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4615 pEngine->pLightmapBuilder->DrawLightmaps(v11/*, 0*/); |
2496 | 4616 } |
2570 | 4617 else if (transparent || !pEngine->pLightmapBuilder->StationaryLightsCount || |
4618 byte_4D864C && pEngine->uFlags & GAME_FLAGS_2_SATURATE_LIGHTMAPS ) | |
4619 { | |
2496 | 4620 if (clampAtTextureBorders) |
4621 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
4622 else | |
4623 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); | |
4624 | |
4625 if (transparent || this->bUsingSpecular) | |
4626 { | |
4627 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
4628 if (transparent) | |
4629 { | |
4630 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); | |
4631 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
4632 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
4633 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
4634 } | |
4635 else | |
4636 { | |
4637 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4638 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
4639 } | |
4640 } | |
4641 | |
4642 for (uint i = 0; i < uNumVertices; ++i) | |
4643 { | |
4644 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4645 d3d_vertex_buffer[i].pos.x = VertexRenderList[i].vWorldViewProjX; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4646 d3d_vertex_buffer[i].pos.y = VertexRenderList[i].vWorldViewProjY; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4647 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((VertexRenderList[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4648 d3d_vertex_buffer[i].rhw = 1.0 / (VertexRenderList[i].vWorldViewPosition.x + 0.0000001); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4649 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, VertexRenderList[i].vWorldViewPosition.x, 0, 0); |
2570 | 4650 d3d_vertex_buffer[i].specular = 0; |
4651 if ( this->bUsingSpecular ) | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4652 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, VertexRenderList[i].vWorldViewPosition.x); |
2570 | 4653 |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4654 d3d_vertex_buffer[i].texcoord.x = VertexRenderList[i].u; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4655 d3d_vertex_buffer[i].texcoord.y = VertexRenderList[i].v; |
2496 | 4656 } |
4657 | |
4658 this->pRenderD3D->pDevice->SetTexture(0, a5); | |
2570 | 4659 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, D3DDP_DONOTLIGHT); |
2496 | 4660 if (transparent) |
4661 { | |
4662 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
4663 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4664 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
4665 } | |
2570 | 4666 } |
4667 else if(pEngine->pLightmapBuilder->StationaryLightsCount) | |
4668 { | |
2496 | 4669 for (uint i = 0; i < uNumVertices; ++i) |
4670 { | |
4671 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4672 d3d_vertex_buffer[i].pos.x = VertexRenderList[i].vWorldViewProjX; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4673 d3d_vertex_buffer[i].pos.y = VertexRenderList[i].vWorldViewProjY; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4674 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((VertexRenderList[i].vWorldViewPosition.x * 1000) / (double)pODMRenderParams->shading_dist_mist); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4675 d3d_vertex_buffer[i].rhw = 1.0 / (VertexRenderList[i].vWorldViewPosition.x + 0.0000001); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4676 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, VertexRenderList[i].vWorldViewPosition.x, 0, 0); |
2570 | 4677 d3d_vertex_buffer[i].specular = 0; |
2496 | 4678 if ( this->bUsingSpecular ) |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4679 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_specular(0, 0, VertexRenderList[i].vWorldViewPosition.x); |
2570 | 4680 d3d_vertex_buffer[i].texcoord.x = VertexRenderList[i].u; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4681 d3d_vertex_buffer[i].texcoord.y = VertexRenderList[i].v; |
2496 | 4682 } |
4683 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
4684 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
4685 if (pRenderer->bUsingSpecular) | |
4686 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
4687 | |
4688 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
2570 | 4689 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,//ðèñóåòñÿ òåêñòóðêà ñ ñâåòîì |
2496 | 4690 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
4691 d3d_vertex_buffer, | |
4692 uNumVertices, | |
2570 | 4693 D3DDP_DONOTLIGHT)); |
4694 //ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4695 pEngine->pLightmapBuilder->DrawLightmaps(-1/*, 0*/); |
2496 | 4696 for (uint i = 0; i < uNumVertices; ++i) |
4697 { | |
4698 d3d_vertex_buffer[i].diffuse = -1; | |
4699 } | |
2570 | 4700 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5));//òåêñòóðêà |
2496 | 4701 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
4702 if ( !pRenderer->bUsingSpecular ) | |
4703 { | |
4704 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
4705 } | |
4706 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4707 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4708 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
4709 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4710 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
4711 d3d_vertex_buffer, | |
4712 uNumVertices, | |
2570 | 4713 D3DDP_DONOTLIGHT)); |
2496 | 4714 if ( pRenderer->bUsingSpecular ) |
4715 { | |
4716 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
4717 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
4718 for (uint i = 0; i < uNumVertices; ++i) | |
4719 { | |
4720 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
4721 d3d_vertex_buffer[i].specular = 0; | |
4722 } | |
4723 | |
4724 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem | |
4725 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); | |
4726 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
4727 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4728 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
4729 d3d_vertex_buffer, | |
4730 uNumVertices, | |
2570 | 4731 D3DDP_DONOTLIGHT)); |
2496 | 4732 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
4733 v45 = GetLevelFogColor(); | |
4734 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
2570 | 4735 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, FALSE)); |
2496 | 4736 } |
4737 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4738 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
2570 | 4739 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
4740 //} | |
2496 | 4741 } |
4742 | |
4743 //if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) | |
2570 | 4744 //if (pIndoorCameraD3D->debug_flags & ODM_RENDER_DRAW_TERRAIN_OUTLINES) |
4745 if (debug_terrain_polygin) | |
2543 | 4746 pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
2496 | 4747 } |
4748 // 4A26BC: could not find valid save-restore pair for esi | |
4749 // 4D864C: using guessed type char byte_4D864C; | |
4750 | |
4751 //----- (004A2DA3) -------------------------------------------------------- | |
4752 void Render::DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) | |
4753 { | |
4754 int v7; // eax@7 | |
4755 | |
4756 if ( !this->uNumD3DSceneBegins ) | |
4757 return; | |
4758 if ( uNumVertices >= 3 ) | |
4759 { | |
4760 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); | |
4761 if ( this->bUsingSpecular ) | |
4762 { | |
4763 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
4764 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
4765 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
4766 } | |
4767 for ( uint i = 0; i < uNumVertices; ++i ) | |
4768 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4769 pVertices[i].pos.x = VertexRenderList[i].vWorldViewProjX; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4770 pVertices[i].pos.y = VertexRenderList[i].vWorldViewProjY; |
2496 | 4771 pVertices[i].pos.z = 0.99989998; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4772 pVertices[i].rhw = VertexRenderList[i]._rhw; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4773 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4774 pVertices[i].diffuse = ::GetActorTintColor(31, 0, VertexRenderList[i].vWorldViewPosition.x, 1, 0); |
2496 | 4775 v7 = 0; |
4776 if (this->bUsingSpecular) | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4777 v7 = sub_47C3D7_get_fog_specular(0, 1, VertexRenderList[i].vWorldViewPosition.x); |
2496 | 4778 pVertices[i].specular = v7; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4779 pVertices[i].texcoord.x = VertexRenderList[i].u; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
4780 pVertices[i].texcoord.y = VertexRenderList[i].v; |
2496 | 4781 } |
4782 pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4783 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
4784 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); | |
4785 } | |
4786 } | |
4787 | |
4788 //----- (004A2ED5) -------------------------------------------------------- | |
4789 void Render::DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) | |
4790 { | |
4791 int v5; // eax@3 | |
4792 | |
4793 if ( this->uNumD3DSceneBegins ) | |
4794 { | |
4795 if ( uNumVertices >= 3 ) | |
4796 { | |
4797 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
4798 v5 = 31 - (pSkyPolygon->dimming_level & 0x1F); | |
4799 if ( v5 < pOutdoor->max_terrain_dimming_level ) | |
4800 v5 = pOutdoor->max_terrain_dimming_level; | |
4801 for (uint i = 0; i < (unsigned int)uNumVertices; ++i) | |
4802 { | |
4803 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
4804 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
4805 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
4806 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw; | |
4807 d3d_vertex_buffer[i].diffuse = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); | |
4808 d3d_vertex_buffer[i].specular = 0; | |
4809 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u; | |
4810 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v; | |
4811 } | |
4812 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); | |
4813 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
4814 d3d_vertex_buffer, uNumVertices, 28)); | |
4815 } | |
4816 } | |
4817 } | |
4818 | |
4819 //----- (00479A53) -------------------------------------------------------- | |
4820 void Render::DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID) | |
4821 { | |
4822 BLVFace *pFace; // esi@1 | |
4823 double v5; // st7@3 | |
4824 signed __int64 v6; // qax@3 | |
4825 int v12; // edx@7 | |
4826 int v13; // eax@7 | |
4827 int v17; // edi@9 | |
4828 double v18; // st7@9 | |
4829 signed int v19; // ebx@9 | |
4830 void *v20; // ecx@9 | |
4831 int v21; // ebx@11 | |
4832 int v22; // eax@14 | |
4833 signed __int64 v23; // qtt@16 | |
4834 double v28; // st7@20 | |
4835 double v33; // st6@23 | |
4836 const void *v35; // ecx@31 | |
4837 int v36; // eax@31 | |
4838 const void *v37; // edi@31 | |
4839 signed __int64 v38; // qax@31 | |
4840 int v39; // ecx@31 | |
4841 int v40; // ebx@33 | |
4842 int v41; // eax@36 | |
4843 signed __int64 v42; // qtt@39 | |
4844 int v43; // eax@39 | |
4845 double v48; // st7@41 | |
4846 double v51; // st7@46 | |
4847 struct Polygon pSkyPolygon; // [sp+14h] [bp-160h]@6 | |
4848 unsigned int v63; // [sp+120h] [bp-54h]@7 | |
4849 unsigned int v65; // [sp+128h] [bp-4Ch]@1 | |
4850 unsigned int v66; // [sp+12Ch] [bp-48h]@7 | |
4851 __int64 v69; // [sp+13Ch] [bp-38h]@3 | |
4852 int v70; // [sp+144h] [bp-30h]@3 | |
4853 int X; // [sp+148h] [bp-2Ch]@9 | |
4854 int v72; // [sp+14Ch] [bp-28h]@7 | |
4855 float v73; // [sp+150h] [bp-24h]@16 | |
4856 unsigned int v74; // [sp+154h] [bp-20h]@3 | |
4857 unsigned int v74_; // [sp+154h] [bp-20h]@3 | |
4858 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3 | |
4859 float v76; // [sp+15Ch] [bp-18h]@9 | |
4860 int v77; // [sp+160h] [bp-14h]@9 | |
4861 int v78; // [sp+164h] [bp-10h]@7 | |
4862 void *v79; // [sp+168h] [bp-Ch]@9 | |
4863 float v80; // [sp+16Ch] [bp-8h]@3 | |
4864 const void *v81; // [sp+170h] [bp-4h]@7 | |
4865 | |
4866 pFace = &pIndoor->pFaces[uFaceID]; | |
4867 //for floor and wall(for example Selesta)------------------- | |
4868 if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor) | |
4869 { | |
2543 | 4870 int v69 = (GetTickCount() / 32) - pIndoorCameraD3D->vPartyPos.x; |
4871 int v55 = (GetTickCount() / 32) + pIndoorCameraD3D->vPartyPos.y; | |
2496 | 4872 for (uint i = 0; i < uNumVertices; ++i) |
4873 { | |
4874 array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f; | |
4875 array_507D30[i].v = (v55 + array_507D30[i].v) * 0.25f; | |
4876 } | |
4877 pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0); | |
4878 return; | |
4879 } | |
4880 //--------------------------------------- | |
2543 | 4881 v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pIndoorCameraD3D->vPartyPos.z)//179 |
2496 | 4882 / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0) |
4883 * 65536.0) | |
4884 + (double)pBLVRenderParams->uViewportCenterY); | |
2543 | 4885 v5 = (double)pIndoorCameraD3D->sRotationX * 0.0030664064;//0 |
2496 | 4886 v6 = (signed __int64)((double)pBLVRenderParams->uViewportCenterY//183 |
4887 - (double)pBLVRenderParams->fov_rad_fixpoint | |
4888 / ((cos(v5) * 16192.0 + 0.0000001) | |
4889 * 65535.0) | |
2543 | 4890 * (sin(v5) * -16192.0 - (double)pIndoorCameraD3D->vPartyPos.z)); |
2496 | 4891 |
4892 stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0); | |
4893 pSkyPolygon.Create_48607B(&stru_8019C8); | |
4894 pSkyPolygon.uTileBitmapID = pFace->uBitmapID; | |
4895 | |
4896 pSkyPolygon.pTexture = pBitmaps_LOD->GetTexture(pSkyPolygon.uTileBitmapID); | |
4897 if ( !pSkyPolygon.pTexture ) | |
4898 return; | |
4899 | |
4900 pSkyPolygon.dimming_level = 0; | |
4901 pSkyPolygon.uNumVertices = uNumVertices; | |
4902 | |
2543 | 4903 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pIndoorCameraD3D->sRotationX + 16); |
2496 | 4904 pSkyPolygon.v_18.y = 0; |
2543 | 4905 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pIndoorCameraD3D->sRotationX + 16); |
2496 | 4906 |
4907 memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices])); | |
4908 pSkyPolygon.field_24 = 0x2000000; | |
4909 | |
4910 extern float _calc_fov(int viewport_width, int angle_degree); | |
4911 //v64 = (double)(signed int)(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX) * 0.5; | |
4912 //v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); | |
4913 v72 = 65536.0f / _calc_fov(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX, 74); | |
4914 v12 = pSkyPolygon.pTexture->uWidthMinus1; | |
4915 v13 = pSkyPolygon.pTexture->uHeightMinus1; | |
4916 //v67 = 1.0 / (double)pSkyPolygon.pTexture->uTextureWidth; | |
4917 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; | |
4918 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; | |
4919 v78 = 0; | |
4920 //v81 = 0; | |
4921 float v68 = 1.0 / (double)pSkyPolygon.pTexture->uTextureHeight; | |
4922 if ( (signed int)pSkyPolygon.uNumVertices <= 0 ) | |
4923 return; | |
4924 | |
4925 int _507D30_idx = 0; | |
4926 for ( _507D30_idx; _507D30_idx < pSkyPolygon.uNumVertices; _507D30_idx++ ) | |
4927 { | |
4928 //v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY)); | |
4929 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); | |
4930 v74 = v77 + pSkyPolygon.ptr_38->angle_from_north; | |
4931 | |
4932 v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); | |
4933 v74_ = v77 + pSkyPolygon.ptr_38->angle_from_east; | |
4934 | |
4935 v79 = (void *)(fixpoint_mul(pSkyPolygon.v_18.z, v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY))); | |
4936 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX); | |
4937 v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0; | |
4938 v19 = -pSkyPolygon.field_24; | |
4939 v77 = -pSkyPolygon.field_24; | |
4940 X = (int)((char *)v79 + pSkyPolygon.v_18.x); | |
4941 LODWORD(v76) = (signed __int64)v18; | |
4942 v20 = (void *)(v72 * (v70 - LODWORD(v76))); | |
4943 while ( 1 ) | |
4944 { | |
4945 v79 = v20; | |
4946 if ( !X ) | |
4947 goto LABEL_14; | |
4948 v21 = abs(v19 >> 14); | |
4949 if ( v21 <= abs(X) )//0x800 <= 0x28652 | |
4950 break; | |
4951 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
4952 break; | |
4953 v19 = v77; | |
4954 v20 = v79; | |
4955 LABEL_14: | |
4956 v79 = (void *)fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); | |
4957 v22 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); | |
4958 --LODWORD(v76); | |
4959 v20 = (char *)v20 + v72; | |
4960 X = v22 + pSkyPolygon.v_18.x; | |
4961 v78 = 1; | |
4962 } | |
4963 if ( !v78 ) | |
4964 { | |
4965 LODWORD(v23) = v77 << 16; | |
4966 HIDWORD(v23) = v77 >> 16;//v23 = 0xfffffe0000000000 | |
4967 v79 = (void *)(v23 / X);//X = FFFF9014(-28652) | |
4968 v77 = v17; | |
4969 signed __int64 s = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v17);// s = 0xFFFFFFFF FFFF3EE6 | |
4970 LODWORD(v80) = v66 + ((signed int)fixpoint_mul(SLODWORD(s), v23 / X) >> 4); | |
4971 array_507D30[_507D30_idx].u = ((double)SLODWORD(v80) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); | |
4972 | |
4973 signed __int64 s2 = v74_ + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v17); | |
4974 LODWORD(v80) = v63 + ((signed int)fixpoint_mul(SLODWORD(s2), v23 / X) >> 4); | |
4975 array_507D30[_507D30_idx].v = ((double)SLODWORD(v80) * 0.000015259022) * v68; | |
4976 | |
4977 v77 = fixpoint_mul(SLODWORD(s), v23 / X); | |
4978 LODWORD(v73) = fixpoint_mul(SLODWORD(s2), v23 / X); | |
4979 array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79; | |
4980 | |
4981 //if ( (int)v81 >= pSkyPolygon.uNumVertices ) | |
4982 //{ | |
4983 // pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, | |
4984 // pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
4985 // return; | |
4986 //} | |
4987 continue; | |
4988 } | |
4989 break; | |
4990 } | |
4991 if ( _507D30_idx >= pSkyPolygon.uNumVertices ) | |
4992 { | |
4993 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, | |
4994 pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
4995 return; | |
4996 } | |
4997 LODWORD(v73) = 0; | |
4998 v80 = v76; | |
4999 if ( (signed int)pSkyPolygon.uNumVertices > 0 ) | |
5000 { | |
5001 v28 = (double)SLODWORD(v76); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5002 LODWORD(v76) = (int)(char *)VertexRenderList + 28; |
2496 | 5003 uint i = 0; |
5004 for ( v78 = pSkyPolygon.uNumVertices; v78; --v78 ) | |
5005 { | |
5006 ++LODWORD(v73); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5007 memcpy(&VertexRenderList[i], &array_507D30[i], 0x30u); |
2496 | 5008 LODWORD(v76) += 48; |
5009 if ( v28 < array_507D30[i].vWorldViewProjY | v28 == array_507D30[i].vWorldViewProjY | |
5010 || v28 >= array_507D30[i + 1].vWorldViewProjY ) | |
5011 { | |
5012 if ( v28 >= array_507D30[i].vWorldViewProjY || v28 <= array_507D30[i + 1].vWorldViewProjY ) | |
5013 { | |
5014 i++; | |
5015 continue; | |
5016 } | |
5017 v33 = (array_507D30[i + 1].vWorldViewProjX - array_507D30[i].vWorldViewProjX) * v28 / (array_507D30[i + 1].vWorldViewProjY - array_507D30[i].vWorldViewProjY) | |
5018 + array_507D30[i + 1].vWorldViewProjX; | |
5019 } | |
5020 else | |
5021 { | |
5022 v33 = (array_507D30[i].vWorldViewProjX - array_507D30[i + 1].vWorldViewProjX) * v28 / (array_507D30[i].vWorldViewProjY - array_507D30[i + 1].vWorldViewProjY) | |
5023 + array_507D30[i].vWorldViewProjX; | |
5024 } | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5025 VertexRenderList[i + 1].vWorldViewProjX = v33; |
2496 | 5026 ++LODWORD(v73); |
5027 *(unsigned int *)LODWORD(v76) = v28; | |
5028 LODWORD(v76) += 48; | |
5029 i++; | |
5030 } | |
5031 } | |
5032 if ( SLODWORD(v73) <= 0 ) | |
5033 goto LABEL_40; | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5034 //v34 = (char *)&VertexRenderList[0].vWorldViewProjY; |
2496 | 5035 uint j = 0; |
5036 v65 = v77 >> 14; | |
5037 //HIDWORD(v69) = LODWORD(v73); | |
5038 for ( int t = (int)LODWORD(v73); t > 1; t-- ) | |
5039 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5040 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)VertexRenderList[j].vWorldViewProjY)); |
2496 | 5041 |
5042 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_west_east; | |
5043 //v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v35); | |
5044 v36 = (int)(fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, (int)v35) + pSkyPolygon.ptr_38->angle_from_north); | |
5045 | |
5046 v81 = v35; | |
5047 v74 = v36; | |
5048 //v78 = pSkyPolygon.ptr_38->viewing_angle_from_north_south; | |
5049 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, (int)v35); | |
5050 v78 = (int)v35; | |
5051 v75 = (RenderVertexSoft *)((char *)v81 + pSkyPolygon.ptr_38->angle_from_east); | |
5052 //v81 = (const void *)pSkyPolygon.v_18.z; | |
5053 v78 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v35); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5054 v37 = (const void *)(v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)VertexRenderList[j].vWorldViewProjX)); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5055 v38 = (signed __int64)(VertexRenderList[j].vWorldViewProjY - 1.0); |
2496 | 5056 v81 = 0; |
5057 LODWORD(v76) = v38; | |
5058 v39 = v72 * (v70 - v38); | |
5059 while ( 1 ) | |
5060 { | |
5061 v78 = v39; | |
5062 if ( !X ) | |
5063 goto LABEL_36; | |
5064 v40 = abs(X); | |
5065 if ( abs((signed __int64)v65) <= v40 ) | |
5066 break; | |
5067 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) | |
5068 break; | |
5069 v39 = v78; | |
5070 LABEL_36: | |
5071 v78 = pSkyPolygon.v_18.z; | |
5072 v41 = fixpoint_mul(pSkyPolygon.v_18.z, v39); | |
5073 --LODWORD(v76); | |
5074 v39 += v72; | |
5075 X = v41 + pSkyPolygon.v_18.x; | |
5076 v81 = (const void *)1; | |
5077 } | |
5078 if ( v81 ) | |
5079 { | |
5080 v79 = (void *)pSkyPolygon.v_18.z; | |
5081 v78 = 2 * LODWORD(v76); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5082 v81 = (const void *)fixpoint_mul(pSkyPolygon.v_18.z, (((double)v70 - ((double)(2 * LODWORD(v76)) - VertexRenderList[j].vWorldViewProjY)) |
2496 | 5083 * (double)v72)); |
5084 X = (int)((char *)v81 + pSkyPolygon.v_18.x); | |
5085 } | |
5086 LODWORD(v42) = v77 << 16; | |
5087 HIDWORD(v42) = v77 >> 16; | |
5088 v79 = (void *)(v42 / X); | |
5089 v81 = v37; | |
5090 | |
5091 //v78 = pSkyPolygon.ptr_38->angle_from_west; | |
5092 v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); | |
5093 v43 = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); | |
5094 v74 = (unsigned int)v37; | |
5095 LODWORD(v76) = v43; | |
5096 | |
5097 //v78 = pSkyPolygon.ptr_38->angle_from_south; | |
5098 v75 = (RenderVertexSoft *)((char *)v75 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, (int)v37)); | |
5099 //v74 = fixpoint_mul(v43, v42 / X); | |
5100 v81 = (const void *)fixpoint_mul((int)v75, v42 / X); | |
5101 | |
5102 //v34 += 48; | |
5103 //v78 = v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4); | |
5104 //v44 = HIDWORD(v69)-- == 1; | |
5105 //v45 = (double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022; | |
5106 //v78 = v63 + ((signed int)fixpoint_mul((int)v75, v42 / X) >> 4); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5107 VertexRenderList[j].u = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5108 VertexRenderList[j].v = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * v68; |
2496 | 5109 //v46 = (double)(signed int)v79; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5110 VertexRenderList[j].vWorldViewPosition.x = 0.000015258789 * (double)(signed int)v79; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5111 VertexRenderList[j]._rhw = 65536.0 / (double)(signed int)v79; |
2496 | 5112 ++j; |
5113 } | |
5114 //while ( !v44 ); | |
5115 LABEL_40: | |
5116 uint i = 0; | |
5117 if ( SLODWORD(v73) > 0 ) | |
5118 { | |
5119 v48 = (double)SLODWORD(v80); | |
5120 for ( HIDWORD(v69) = LODWORD(v73); HIDWORD(v69); --HIDWORD(v69) ) | |
5121 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5122 if ( v48 >= VertexRenderList[i].vWorldViewProjY ) |
2496 | 5123 { |
5124 ++i; | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5125 memcpy(&array_507D30[i], &VertexRenderList[i], 0x30u); |
2496 | 5126 } |
5127 } | |
5128 } | |
5129 pSkyPolygon.uNumVertices = i; | |
5130 pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
5131 int pNumVertices = 0; | |
5132 if ( SLODWORD(v73) > 0 ) | |
5133 { | |
5134 v51 = (double)SLODWORD(v80); | |
5135 for ( v80 = v73; v80 != 0.0; --LODWORD(v80) ) | |
5136 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5137 if ( v51 <= VertexRenderList[pNumVertices].vWorldViewProjY ) |
2496 | 5138 { |
5139 ++pNumVertices; | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5140 memcpy(&array_507D30[pNumVertices], &VertexRenderList[pNumVertices], 0x30u); |
2496 | 5141 } |
5142 } | |
5143 } | |
5144 pRenderer->DrawIndoorSkyPolygon(pNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
5145 } | |
5146 | |
5147 //----- (004A2FC0) -------------------------------------------------------- | |
2574 | 5148 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture_MM7 *pTex, int uPackedID, unsigned int uColor, int a8) |
2496 | 5149 { |
5150 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
5151 return; | |
5152 | |
5153 int sCorrectedColor = uColor; | |
2532 | 5154 |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5155 if (pEngine->pLightmapBuilder->StationaryLightsCount) |
2496 | 5156 sCorrectedColor = -1; |
2541 | 5157 pEngine->AlterGamma_BLV(pFace, &sCorrectedColor); |
2496 | 5158 |
5159 if (pFace->uAttributes & FACE_OUTLINED) | |
5160 { | |
5161 if (GetTickCount() % 300 >= 150) | |
5162 uColor = sCorrectedColor = 0xFF20FF20; | |
2532 | 5163 else |
5164 uColor = sCorrectedColor = 0xFF109010; | |
2496 | 5165 } |
5166 | |
2541 | 5167 if (byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_01_lightmap_related) |
2496 | 5168 { |
5169 __debugbreak(); | |
5170 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
5171 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
5172 for (uint i = 0; i < uNumVertices; ++i) | |
5173 { | |
5174 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5175 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5176 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5177 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5178 d3d_vertex_buffer[i].diffuse = sCorrectedColor; | |
5179 d3d_vertex_buffer[i].specular = 0; | |
5180 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5181 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5182 } | |
5183 | |
5184 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
5185 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
2532 | 5186 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
2496 | 5187 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
2532 | 5188 d3d_vertex_buffer, uNumVertices, 28)); |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5189 pEngine->pLightmapBuilder->DrawLightmaps(-1/*, 0*/); |
2496 | 5190 } |
5191 else | |
5192 { | |
2570 | 5193 if (!pEngine->pLightmapBuilder->StationaryLightsCount || byte_4D864C && pEngine->uFlags & GAME_FLAGS_2_SATURATE_LIGHTMAPS) |
2496 | 5194 { |
5195 for (uint i = 0; i < uNumVertices; ++i) | |
5196 { | |
5197 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5198 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5199 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5200 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5201 d3d_vertex_buffer[i].diffuse = sCorrectedColor; | |
5202 d3d_vertex_buffer[i].specular = 0; | |
5203 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5204 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5205 } | |
5206 | |
5207 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
5208 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); | |
5209 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
5210 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
2532 | 5211 d3d_vertex_buffer, uNumVertices, 28)); |
2496 | 5212 } |
5213 else | |
5214 { | |
5215 for (uint i = 0; i < uNumVertices; ++i) | |
5216 { | |
5217 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
5218 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
5219 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
5220 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
5221 d3d_vertex_buffer[i].diffuse = uColor; | |
5222 d3d_vertex_buffer[i].specular = 0; | |
5223 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
5224 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
5225 } | |
2532 | 5226 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
5227 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
5228 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
5229 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
5230 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
5231 d3d_vertex_buffer, uNumVertices, 28)); | |
5232 | |
5233 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
5234 pEngine->pLightmapBuilder->DrawLightmaps(-1/*, 0*/); |
2532 | 5235 |
5236 for (uint i = 0; i < uNumVertices; ++i) | |
5237 d3d_vertex_buffer[i].diffuse = sCorrectedColor; | |
5238 | |
5239 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); | |
5240 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
5241 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
5242 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
5243 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
5244 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
5245 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
5246 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
5247 d3d_vertex_buffer, uNumVertices, 28)); | |
5248 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
5249 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
5250 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
2496 | 5251 } |
5252 } | |
5253 } | |
5254 // 4D864C: using guessed type char byte_4D864C; | |
5255 | |
5256 //----- (004A43B1) -------------------------------------------------------- | |
5257 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) | |
5258 { | |
5259 unsigned int v7; // eax@2 | |
5260 signed int v11; // eax@9 | |
5261 signed int v12; // eax@9 | |
5262 double v15; // st5@12 | |
5263 double v16; // st4@12 | |
5264 double v17; // st3@12 | |
5265 double v18; // st2@12 | |
5266 int v19; // ecx@14 | |
5267 double v20; // st3@14 | |
5268 int v21; // ecx@16 | |
5269 double v22; // st3@16 | |
5270 float v27; // [sp+24h] [bp-Ch]@5 | |
5271 int v28; // [sp+28h] [bp-8h]@2 | |
5272 float v29; // [sp+2Ch] [bp-4h]@5 | |
5273 float v31; // [sp+3Ch] [bp+Ch]@5 | |
5274 float a1; // [sp+40h] [bp+10h]@5 | |
5275 | |
5276 if ( this->uNumD3DSceneBegins ) | |
5277 { | |
5278 //v4 = pSoftBillboard; | |
5279 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
5280 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
5281 //v6 = pSoftBillboard->zbuffer_depth; | |
5282 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
5283 //v8 = dimming_level; | |
5284 //v9 = v7; | |
5285 v28 = dimming_level & 0xFF000000; | |
5286 if ( dimming_level & 0xFF000000 ) | |
5287 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Opaque_3; | |
5288 else | |
5289 pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Transparent; | |
5290 //v10 = a3; | |
5291 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
5292 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
5293 pBillboardRenderListD3D[v7].sParentBillboardID = pSoftBillboard->sParentBillboardID; | |
5294 //v25 = pSoftBillboard->uScreenSpaceX; | |
5295 //v24 = pSoftBillboard->uScreenSpaceY; | |
5296 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
5297 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
5298 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
5299 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
5300 if ( pSoftBillboard->uFlags & 4 ) | |
5301 v31 = v31 * -1.0; | |
5302 if ( pSoftBillboard->sTintColor && this->bTinting ) | |
5303 { | |
5304 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
5305 v12 = BlendColors(pSoftBillboard->sTintColor, v11); | |
5306 if ( v28 ) | |
5307 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
5308 } | |
5309 else | |
5310 { | |
5311 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
5312 } | |
5313 //v13 = (double)v25; | |
5314 pBillboardRenderListD3D[v7].pQuads[0].specular = 0; | |
5315 pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12; | |
5316 pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
5317 //v14 = (double)v24; | |
5318 //v32 = v14; | |
5319 pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; | |
5320 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); | |
5321 pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15; | |
5322 v16 = 1.0 / pSoftBillboard->zbuffer_depth; | |
5323 pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; | |
5324 pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0; | |
5325 pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0; | |
5326 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
5327 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
5328 if ( pSoftBillboard->uFlags & 4 ) | |
5329 v17 = v17 * -1.0; | |
5330 pBillboardRenderListD3D[v7].pQuads[1].specular = 0; | |
5331 pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12; | |
5332 pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
5333 pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
5334 pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15; | |
5335 pBillboardRenderListD3D[v7].pQuads[1].rhw = v16; | |
5336 pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0; | |
5337 pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0; | |
5338 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; | |
5339 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5340 if ( pSoftBillboard->uFlags & 4 ) | |
5341 v20 = v20 * -1.0; | |
5342 pBillboardRenderListD3D[v7].pQuads[2].specular = 0; | |
5343 pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12; | |
5344 pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
5345 pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
5346 pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15; | |
5347 pBillboardRenderListD3D[v7].pQuads[2].rhw = v16; | |
5348 pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0; | |
5349 pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0; | |
5350 v21 = pSprite->uBufferHeight - pSprite->uAreaY; | |
5351 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
5352 if ( pSoftBillboard->uFlags & 4 ) | |
5353 v22 = v22 * -1.0; | |
5354 pBillboardRenderListD3D[v7].pQuads[3].specular = 0; | |
5355 pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12; | |
5356 pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
5357 pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
5358 pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15; | |
5359 pBillboardRenderListD3D[v7].pQuads[3].rhw = v16; | |
5360 pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0; | |
5361 pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0; | |
5362 //v23 = pSprite->pTexture; | |
5363 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
5364 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
5365 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
5366 } | |
5367 } | |
5368 | |
5369 //----- (004A354F) -------------------------------------------------------- | |
5370 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5371 { | |
5372 unsigned int v8; // esi@3 | |
5373 float v11; // ST28_4@3 | |
5374 float v16; // ST2C_4@3 | |
5375 float v17; // ST30_4@3 | |
5376 signed int v18; // ST18_4@3 | |
5377 signed int v19; // ST14_4@3 | |
5378 signed int v20; // ST10_4@3 | |
5379 signed int v21; // eax@3 | |
5380 double v22; // st6@3 | |
5381 float v23; // ST2C_4@3 | |
5382 float v24; // ST30_4@3 | |
5383 signed int v25; // ST10_4@3 | |
5384 signed int v26; // ST14_4@3 | |
5385 signed int v27; // ST18_4@3 | |
5386 signed int v28; // eax@3 | |
5387 double v29; // st6@3 | |
5388 float v30; // ecx@3 | |
5389 float v31; // ST2C_4@3 | |
5390 float v32; // ST30_4@3 | |
5391 signed int v33; // ST10_4@3 | |
5392 signed int v34; // ST14_4@3 | |
5393 signed int v35; // ST18_4@3 | |
5394 signed int v36; // eax@3 | |
5395 float v37; // ecx@3 | |
5396 double v38; // st6@3 | |
5397 float v39; // ST2C_4@3 | |
5398 float v40; // ST30_4@3 | |
5399 signed int v41; // ST10_4@3 | |
5400 signed int v42; // ST14_4@3 | |
5401 signed int v43; // ST18_4@3 | |
5402 signed int v44; // eax@3 | |
5403 double v45; // st6@3 | |
5404 float v46; // eax@3 | |
5405 | |
5406 if ( this->uNumD3DSceneBegins ) | |
5407 { | |
5408 if (a2->zbuffer_depth) | |
5409 { | |
5410 //v5 = (double)a2->zbuffer_depth; | |
5411 //v6 = v5; | |
5412 //v7 = v5; | |
5413 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
5414 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; | |
5415 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
5416 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
5417 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; | |
5418 //v9 = a2->uScreenSpaceX; | |
5419 //v10 = a2->uScreenSpaceY; | |
5420 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); | |
5421 //v12 = (double) a2->uScreenSpaceX; | |
5422 //v13 = v12; | |
5423 //v14 = (double)(a2->uScreenSpaceY - 12); | |
5424 //v15 = v14; | |
5425 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
5426 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
5427 v18 = stru_5C6E00->Cos(angle); | |
5428 v19 = stru_5C6E00->Sin(angle); | |
5429 v20 = stru_5C6E00->Sin(angle); | |
5430 v21 = stru_5C6E00->Cos(angle); | |
5431 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 | |
5432 + (double)(v18 >> 16)) | |
5433 * v16 | |
5434 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
5435 + (double)(v19 >> 16)) | |
5436 * v17) | |
5437 * v11 + (double) a2->uScreenSpaceX; | |
5438 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 | |
5439 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
5440 - 12.0) | |
5441 * v11 | |
5442 + (double)a2->uScreenSpaceY; | |
5443 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; | |
5444 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5445 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22; | |
5446 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); | |
5447 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
5448 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5449 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
5450 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; | |
5451 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
5452 v25 = stru_5C6E00->Cos(angle); | |
5453 v26 = stru_5C6E00->Sin(angle); | |
5454 v27 = stru_5C6E00->Sin(angle); | |
5455 v28 = stru_5C6E00->Cos(angle); | |
5456 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 | |
5457 + (double)(v25 >> 16)) | |
5458 * v31 | |
5459 - ((double)(unsigned __int16)v26 * 0.000015259022 | |
5460 + (double)(v26 >> 16)) | |
5461 * v32) | |
5462 * v11 + (double) a2->uScreenSpaceX; | |
5463 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 | |
5464 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
5465 - 12.0) | |
5466 * v11 | |
5467 + (double)a2->uScreenSpaceY; | |
5468 pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z; | |
5469 v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5470 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29; | |
5471 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5472 pBillboardRenderListD3D[v8].pQuads[1].rhw = v30; | |
5473 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5474 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5475 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
5476 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
5477 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
5478 v33 = stru_5C6E00->Cos(angle); | |
5479 v34 = stru_5C6E00->Sin(angle); | |
5480 v35 = stru_5C6E00->Sin(angle); | |
5481 v36 = stru_5C6E00->Cos(angle); | |
5482 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 | |
5483 + (double)(v33 >> 16)) | |
5484 * v23 | |
5485 - ((double)(unsigned __int16)v34 * 0.000015259022 | |
5486 + (double)(v34 >> 16)) | |
5487 * v24) | |
5488 * v11 + (double) a2->uScreenSpaceX; | |
5489 v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; | |
5490 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 | |
5491 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
5492 - 12.0) | |
5493 * v11 | |
5494 + (double)a2->uScreenSpaceY; | |
5495 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; | |
5496 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37; | |
5497 pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5498 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5499 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38; | |
5500 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5501 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
5502 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; | |
5503 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
5504 v41 = stru_5C6E00->Cos(angle); | |
5505 v42 = stru_5C6E00->Sin(angle); | |
5506 v43 = stru_5C6E00->Sin(angle); | |
5507 v44 = stru_5C6E00->Cos(angle); | |
5508 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 | |
5509 + (double)(v41 >> 16)) | |
5510 * v39 | |
5511 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
5512 + (double)(v42 >> 16)) | |
5513 * v40) | |
5514 * v11 + (double) a2->uScreenSpaceX; | |
5515 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
5516 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
5517 - 12.0) | |
5518 * v11 | |
5519 + (double)a2->uScreenSpaceY; | |
5520 v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; | |
5521 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; | |
5522 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46; | |
5523 pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; | |
5524 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
5525 pBillboardRenderListD3D[v8].pTexture = a3; | |
5526 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; | |
5527 pBillboardRenderListD3D[v8].uNumVertices = 4; | |
5528 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45; | |
5529 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5530 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
5531 } | |
5532 } | |
5533 } | |
5534 | |
5535 //----- (004A3AD9) -------------------------------------------------------- | |
5536 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
5537 { | |
5538 double v5; // st7@2 | |
5539 float v6; // ST28_4@2 | |
5540 float v7; // ST00_4@2 | |
5541 unsigned int v8; // esi@2 | |
5542 //int v9; // eax@2 | |
5543 //int v10; // ebx@2 | |
5544 float v11; // ST34_4@2 | |
5545 double v12; // st7@2 | |
5546 float v13; // ST2C_4@2 | |
5547 double v14; // st6@2 | |
5548 float v15; // ST24_4@2 | |
5549 float v16; // ST38_4@2 | |
5550 float v17; // ST3C_4@2 | |
5551 signed int v18; // ST1C_4@2 | |
5552 int v19; // ST30_4@2 | |
5553 signed int v20; // ST20_4@2 | |
5554 signed int v21; // ST18_4@2 | |
5555 signed int v22; // eax@2 | |
5556 double v23; // st6@2 | |
5557 float v24; // ST20_4@2 | |
5558 float v25; // ST1C_4@2 | |
5559 float v26; // ST38_4@2 | |
5560 float v27; // ST3C_4@2 | |
5561 signed int v28; // ST18_4@2 | |
5562 signed int v29; // ST14_4@2 | |
5563 signed int v30; // ST10_4@2 | |
5564 signed int v31; // eax@2 | |
5565 double v32; // st6@2 | |
5566 float v33; // ST38_4@2 | |
5567 float v34; // ST3C_4@2 | |
5568 signed int v35; // ST10_4@2 | |
5569 signed int v36; // ST14_4@2 | |
5570 signed int v37; // ST18_4@2 | |
5571 signed int v38; // eax@2 | |
5572 double v39; // st6@2 | |
5573 float v40; // ST38_4@2 | |
5574 float v41; // ST3C_4@2 | |
5575 signed int v42; // ST10_4@2 | |
5576 signed int v43; // ST14_4@2 | |
5577 signed int v44; // ST18_4@2 | |
5578 signed int v45; // eax@2 | |
5579 double v46; // st6@2 | |
5580 | |
5581 if ( this->uNumD3DSceneBegins ) | |
5582 { | |
5583 v5 = (double)a2->zbuffer_depth; | |
5584 v6 = v5; | |
5585 v7 = v5; | |
5586 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
5587 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; | |
5588 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
5589 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
5590 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; | |
5591 | |
5592 //v9 = a2->uScreenSpaceX; | |
5593 //v10 = a2->uScreenSpaceY; | |
5594 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); | |
5595 v12 = (double)a2->uScreenSpaceX; | |
5596 v13 = (double)a2->uScreenSpaceX; | |
5597 v14 = (double)(a2->uScreenSpaceY - 12); | |
5598 v15 = v14; | |
5599 v16 = (double)(a2->uScreenSpaceX - 12) - v12; | |
5600 v17 = (double)(a2->uScreenSpaceY - 25) - v14; | |
5601 v18 = stru_5C6E00->Cos(angle); | |
5602 v19 = angle - stru_5C6E00->uIntegerHalfPi; | |
5603 v20 = stru_5C6E00->Sin(angle); | |
5604 v21 = stru_5C6E00->Sin(angle); | |
5605 v22 = stru_5C6E00->Cos(angle); | |
5606 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 | |
5607 + (double)(v18 >> 16)) * v16 | |
5608 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
5609 + (double)(v20 >> 16)) * v17) | |
5610 * v11 + v13; | |
5611 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
5612 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
5613 - 12.0) | |
5614 * v11 | |
5615 + (double)a2->uScreenSpaceY; | |
5616 pBillboardRenderListD3D[v8].pQuads[0].specular = 0; | |
5617 pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; | |
5618 pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23; | |
5619 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pODMRenderParams->shading_dist_mist); | |
5620 pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24; | |
5621 v25 = 1.0 / v6; | |
5622 pBillboardRenderListD3D[v8].pQuads[0].rhw = v25; | |
5623 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5624 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
5625 | |
5626 v26 = (double)(a2->uScreenSpaceX - 12) - v13; | |
5627 v27 = (double)a2->uScreenSpaceY - v15; | |
5628 v28 = stru_5C6E00->Cos(angle); | |
5629 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5630 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5631 v31 = stru_5C6E00->Cos(angle); | |
5632 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 | |
5633 + (double)(v28 >> 16)) * v26 | |
5634 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
5635 + (double)(v29 >> 16)) * v27) | |
5636 * v11 + v13; | |
5637 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
5638 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
5639 - 12.0) | |
5640 * v11 | |
5641 + (double)a2->uScreenSpaceY; | |
5642 pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24; | |
5643 pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32; | |
5644 pBillboardRenderListD3D[v8].pQuads[1].specular = 0; | |
5645 pBillboardRenderListD3D[v8].pQuads[1].rhw = v25; | |
5646 pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; | |
5647 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5648 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
5649 | |
5650 v33 = (double)(a2->uScreenSpaceX + 12) - v13; | |
5651 v34 = (double)a2->uScreenSpaceY - v15; | |
5652 v35 = stru_5C6E00->Cos(angle); | |
5653 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5654 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5655 v38 = stru_5C6E00->Cos(angle); | |
5656 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 | |
5657 + (double)(v35 >> 16)) * v33 | |
5658 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
5659 + (double)(v36 >> 16)) * v34) | |
5660 * v11 + v13; | |
5661 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
5662 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
5663 - 12.0) | |
5664 * v11 | |
5665 + (double)a2->uScreenSpaceY; | |
5666 pBillboardRenderListD3D[v8].pQuads[2].specular = 0; | |
5667 pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24; | |
5668 pBillboardRenderListD3D[v8].pQuads[2].rhw = v25; | |
5669 pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; | |
5670 pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39; | |
5671 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5672 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
5673 | |
5674 v40 = (double)(a2->uScreenSpaceX + 12) - v13; | |
5675 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
5676 v42 = stru_5C6E00->Cos(angle); | |
5677 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5678 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
5679 v45 = stru_5C6E00->Cos(angle); | |
5680 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 | |
5681 + (double)(v42 >> 16)) * v40 | |
5682 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
5683 + (double)(v43 >> 16)) * v41) | |
5684 * v11 + v13; | |
5685 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
5686 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
5687 - 12.0) | |
5688 * v11 | |
5689 + (double)a2->uScreenSpaceY; | |
5690 pBillboardRenderListD3D[v8].pQuads[3].specular = 0; | |
5691 pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24; | |
5692 pBillboardRenderListD3D[v8].pQuads[3].rhw = v25; | |
5693 pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; | |
5694 pBillboardRenderListD3D[v8].pTexture = a3; | |
5695 pBillboardRenderListD3D[v8].z_order = v6; | |
5696 pBillboardRenderListD3D[v8].uNumVertices = 4; | |
5697 pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46; | |
5698 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5699 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
5700 } | |
5701 } | |
5702 | |
5703 //----- (004A4023) -------------------------------------------------------- | |
5704 void Render::TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int dimming_level, RenderBillboard *pBillboard) | |
5705 { | |
5706 unsigned int v8; // esi@2 | |
5707 double v14; // st6@14 | |
5708 double v15; // st5@14 | |
5709 float v29; // [sp+28h] [bp-8h]@5 | |
5710 float v30; // [sp+2Ch] [bp-4h]@5 | |
5711 | |
5712 if (!uNumD3DSceneBegins) | |
5713 return; | |
5714 | |
5715 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
5716 | |
5717 v30 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_x_scaler_packedfloat); | |
5718 v29 = (a2->_screenspace_y_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_y_scaler_packedfloat); | |
5719 | |
5720 unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard); | |
5721 if (a2->sTintColor & 0x00FFFFFF && bTinting) | |
5722 { | |
5723 diffuse = BlendColors(a2->sTintColor, diffuse); | |
5724 if (a2->sTintColor & 0xFF000000) | |
5725 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); | |
5726 } | |
5727 | |
5728 unsigned int specular = 0; | |
5729 if (bUsingSpecular) | |
5730 specular = sub_47C3D7_get_fog_specular(0, 0, a2->zbuffer_depth); | |
5731 | |
5732 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); | |
5733 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); | |
5734 if (a2->uFlags & 4) | |
5735 v14 *= -1.0; | |
5736 pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse; | |
5737 pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5738 pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
5739 pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); | |
5740 pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; | |
5741 pBillboardRenderListD3D[v8].pQuads[0].specular = specular; | |
5742 pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; | |
5743 pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; | |
5744 | |
5745 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); | |
5746 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); | |
5747 if ( a2->uFlags & 4 ) | |
5748 v14 = v14 * -1.0; | |
5749 pBillboardRenderListD3D[v8].pQuads[1].specular = specular; | |
5750 pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse; | |
5751 pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; | |
5752 pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
5753 pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); | |
5754 pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth; | |
5755 pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; | |
5756 pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; | |
5757 | |
5758 v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth); | |
5759 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); | |
5760 if ( a2->uFlags & 4 ) | |
5761 v14 *= -1.0; | |
5762 pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse; | |
5763 pBillboardRenderListD3D[v8].pQuads[2].specular = specular; | |
5764 pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
5765 pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
5766 pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); | |
5767 pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth; | |
5768 pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; | |
5769 pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; | |
5770 | |
5771 v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth); | |
5772 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); | |
5773 if ( a2->uFlags & 4 ) | |
5774 v14 *= -1.0; | |
5775 pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse; | |
5776 pBillboardRenderListD3D[v8].pQuads[3].specular = specular; | |
5777 pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; | |
5778 pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; | |
5779 pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pODMRenderParams->shading_dist_mist); | |
5780 pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth; | |
5781 pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; | |
5782 pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; | |
5783 | |
5784 pBillboardRenderListD3D[v8].uNumVertices = 4; | |
5785 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; | |
5786 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; | |
5787 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
5788 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
5789 pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; | |
5790 | |
5791 if (a2->sTintColor & 0xFF000000) | |
5792 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_3; | |
5793 else | |
5794 pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Transparent; | |
5795 } | |
5796 | |
5797 | |
5798 //----- (004A49D0) -------------------------------------------------------- | |
5799 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
5800 { | |
5801 int absXDifference; // eax@1 | |
5802 int absYDifference; // eax@1 | |
5803 unsigned int smallerabsdiff; // ebx@1 | |
5804 unsigned int largerabsdiff; | |
5805 double v16; // st7@7 | |
5806 double v17; // st7@7 | |
5807 double v18; // st6@7 | |
5808 double v20; // st4@8 | |
5809 double v21; // st4@10 | |
5810 double v22; // st4@10 | |
5811 double v23; // st4@10 | |
5812 double v25; // st4@11 | |
5813 double v26; // st4@13 | |
5814 double v28; // st4@13 | |
5815 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
5816 int xDifference; // [sp+88h] [bp-Ch]@1 | |
5817 signed int v32; // [sp+8Ch] [bp-8h]@1 | |
5818 int yDifference; // [sp+90h] [bp-4h]@1 | |
5819 | |
5820 xDifference = bankersRounding(dstX - srcX); | |
5821 yDifference = bankersRounding(dstY - srcY); | |
5822 absYDifference = abs(yDifference); | |
5823 absXDifference = abs(xDifference); | |
5824 smallerabsdiff = min(absXDifference, absYDifference); | |
5825 largerabsdiff = max(absXDifference, absYDifference); | |
5826 v32 = (11 * smallerabsdiff >> 5) + largerabsdiff; | |
5827 v16 = 1.0 / (double)v32; | |
5828 v17 = (double)yDifference * v16 * a4; | |
5829 v18 = (double)xDifference * v16 * a4; | |
5830 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
5831 { | |
5832 v20 = a3 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; | |
5833 v25 = a7 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; | |
5834 } | |
5835 else | |
5836 { | |
5837 v20 = a3 * 0.061758894; | |
5838 v25 = a7 * 0.061758894; | |
5839 } | |
5840 v21 = 1.0 / a3; | |
5841 v22 = (double)yDifference * v16 * a8; | |
5842 v23 = (double)xDifference * v16 * a8; | |
5843 v26 = 1.0 - 1.0 / v25; | |
5844 v28 = 1.0 / a7; | |
5845 v29[0].pos.x = srcX + v17; | |
5846 v29[0].pos.y = srcY - v18; | |
5847 v29[0].pos.z = 1.0 - 1.0 / v20; | |
5848 v29[0].rhw = v21; | |
5849 v29[0].diffuse = -1; | |
5850 v29[0].specular = 0; | |
5851 v29[0].texcoord.x = 1.0; | |
5852 v29[0].texcoord.y = 0.0; | |
5853 | |
5854 v29[1].pos.x = v22 + dstX; | |
5855 v29[1].pos.y = dstY - v23; | |
5856 v29[1].pos.z = v26; | |
5857 v29[1].rhw = v28; | |
5858 v29[1].diffuse = -16711936; | |
5859 v29[1].specular = 0; | |
5860 v29[1].texcoord.x = 1.0; | |
5861 v29[1].texcoord.y = 1.0; | |
5862 | |
5863 v29[2].pos.x = dstX - v22; | |
5864 v29[2].pos.y = v23 + dstY; | |
5865 v29[2].pos.z = v26; | |
5866 v29[2].rhw = v28; | |
5867 v29[2].diffuse = -1; | |
5868 v29[2].specular = 0; | |
5869 v29[2].texcoord.x = 0.0; | |
5870 v29[2].texcoord.y = 1.0; | |
5871 | |
5872 v29[3].pos.x = srcX - v17; | |
5873 v29[3].pos.y = v18 + srcY; | |
5874 v29[3].pos.z = v29[0].pos.z; | |
5875 v29[3].rhw = v21; | |
5876 v29[3].diffuse = -1; | |
5877 v29[3].specular = 0; | |
5878 v29[3].texcoord.x = 0.0; | |
5879 v29[3].texcoord.y = 0.0; | |
5880 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
5881 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
5882 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
5883 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
5884 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
5885 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
5886 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a9)); | |
5887 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
5888 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v29, 4, 24)); | |
5889 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
5890 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
5891 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
5892 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
5893 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
5894 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
5895 } | |
5896 | |
5897 //----- (004A4CC9) -------------------------------------------------------- | |
5898 void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse) | |
5899 { | |
5900 unsigned int v5; // eax@7 | |
5901 double v10; // st6@9 | |
5902 double v11; // st6@10 | |
5903 int v12; // ebx@13 | |
5904 | |
5905 if (a1->uNumVertices < 3) | |
5906 return; | |
5907 | |
5908 float depth = 1000000.0; | |
5909 for (uint i = 0; i < (unsigned int)a1->uNumVertices; ++i) | |
5910 { | |
5911 if (a1->field_104[i].z < depth) | |
5912 depth = a1->field_104[i * 4].z; | |
5913 } | |
5914 | |
5915 v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); | |
5916 pBillboardRenderListD3D[v5].field_90 = 0; | |
5917 pBillboardRenderListD3D[v5].sParentBillboardID = -1; | |
5918 pBillboardRenderListD3D[v5].opacity = RenderBillboardD3D::Opaque_2; | |
5919 pBillboardRenderListD3D[v5].pTexture = 0; | |
5920 pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; | |
5921 pBillboardRenderListD3D[v5].z_order = depth; | |
5922 | |
5923 for (uint i = 0; i < (unsigned int)a1->uNumVertices; ++i) | |
5924 { | |
5925 pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x; | |
5926 pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y; | |
5927 | |
5928 v10 = a1->field_104[i].z; | |
5929 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
5930 v11 = v10 * 0.061758894; | |
5931 else | |
5932 v11 = v10 * 1000.0 / (double)pODMRenderParams->shading_dist_mist; | |
5933 pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11; | |
5934 pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z; | |
5935 | |
5936 if (diffuse & 0xFF000000) | |
5937 v12 = a1->field_104[i].diffuse; | |
5938 else | |
5939 v12 = diffuse; | |
5940 pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12; | |
5941 pBillboardRenderListD3D[v5].pQuads[i].specular = 0; | |
5942 | |
5943 pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0; | |
5944 pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0; | |
5945 } | |
5946 } | |
5947 | |
5948 //----- (004A4DE1) -------------------------------------------------------- | |
5949 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
5950 { | |
5951 unsigned __int16 *v13; // ecx@19 | |
5952 unsigned __int16 *v14; // eax@19 | |
5953 DWORD v15; // edx@20 | |
5954 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
5955 | |
5956 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); | |
2524 | 5957 if (!pHWLTexture) |
5958 return false; | |
5959 | |
2496 | 5960 bMipMaps = !strncmp(pName, "HDWTR", 5); |
5961 if ( !pRenderD3D->CreateTexture(pHWLTexture->uWidth, pHWLTexture->uHeight, pOutSurface, pOutTexture, true, | |
5962 bMipMaps, uMinDeviceTextureDim) ) | |
5963 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); | |
5964 if (bMipMaps) | |
5965 { | |
5966 Dst._450DDE(); | |
5967 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
5968 | |
5969 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
5970 while ( 1 ) | |
5971 { | |
5972 DDSCAPS2 v19; | |
5973 memset(&v19, 0, sizeof(DDSCAPS2)); | |
5974 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
5975 | |
5976 DDSURFACEDESC2 desc; | |
5977 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
5978 desc.dwSize = sizeof(DDSURFACEDESC2); | |
5979 | |
5980 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) | |
5981 { | |
5982 // linear scaling | |
5983 for (int s = 0; s < desc.dwHeight; ++s) | |
5984 for (int t = 0; t < desc.dwWidth; ++t) | |
5985 { | |
5986 unsigned int resampled_x = t * pHWLTexture->uWidth / desc.dwWidth, | |
5987 resampled_y = s * pHWLTexture->uHeight / desc.dwHeight; | |
5988 unsigned short sample = pHWLTexture->pPixels[resampled_y * pHWLTexture->uWidth + resampled_x]; | |
5989 | |
5990 ((unsigned short *)desc.lpSurface)[s * (desc.lPitch >> 1) + t] = sample; | |
5991 } | |
5992 | |
5993 | |
5994 //bicubic sampling | |
5995 //Dst.sub_451007_scale_image_bicubic(pHWLTexture->pPixels, pHWLTexture->uWidth, pHWLTexture->uHeight, pHWLTexture->uWidth, | |
5996 // (unsigned short *)desc.lpSurface, desc.dwWidth, desc.dwHeight, desc.lPitch >> 1, 0, 0); | |
5997 | |
5998 ErrD3D(pNextSurf->Unlock(NULL)); | |
5999 //bMipMaps = 0x4D86ACu; | |
6000 } | |
6001 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
6002 break; | |
6003 } | |
6004 //v20 = -1; | |
6005 //nullsub_1(); | |
6006 } | |
6007 else | |
6008 { | |
6009 DDSCAPS2 v19; | |
6010 memset(&v19, 0, sizeof(DDSCAPS2)); | |
6011 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
6012 | |
6013 DDSURFACEDESC2 desc; | |
6014 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
6015 desc.dwSize = sizeof(DDSURFACEDESC2); | |
6016 | |
6017 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) | |
6018 { | |
6019 bMipMaps = 0; | |
6020 v13 = pHWLTexture->pPixels; | |
6021 v14 = (unsigned __int16 *)desc.lpSurface; | |
6022 for(uint bMipMaps = 0; bMipMaps < desc.dwHeight; bMipMaps++) | |
6023 { | |
6024 for (v15 = 0; v15 < desc.dwWidth; v15++) | |
6025 { | |
6026 *v14 = *v13; | |
6027 ++v14; | |
6028 ++v13; | |
6029 } | |
6030 v14 += (desc.lPitch >> 1) - desc.dwWidth; | |
6031 } | |
6032 ErrD3D((*pOutSurface)->Unlock(NULL)); | |
6033 } | |
6034 } | |
6035 delete [] pHWLTexture->pPixels; | |
6036 delete pHWLTexture; | |
6037 return true; | |
2524 | 6038 |
2496 | 6039 } |
6040 | |
6041 //----- (004A5048) -------------------------------------------------------- | |
6042 bool Render::MoveSpriteToDevice( Sprite *pSprite ) | |
6043 { | |
6044 HWLTexture *sprite_texture; // eax@1 | |
6045 unsigned __int16 *v9; // edx@5 | |
6046 LPVOID v10; // eax@5 | |
6047 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
6048 | |
6049 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); | |
6050 if ( sprite_texture ) | |
6051 { | |
6052 pSprite->uAreaX = sprite_texture->uAreaX; | |
6053 pSprite->uAreaY = sprite_texture->uAreaY; | |
6054 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
6055 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
6056 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
6057 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
6058 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) | |
6059 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); | |
6060 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); | |
6061 Dst.dwSize = 124; | |
6062 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) | |
6063 { | |
6064 v9 = sprite_texture->pPixels; | |
6065 v10 = Dst.lpSurface; | |
6066 for (uint i=0; i<sprite_texture->uHeight; ++i) | |
6067 { | |
6068 for (uint j=0; j<sprite_texture->uWidth/2; ++j) | |
6069 { | |
6070 *(int *)v10 = *(int *)v9; | |
6071 v9 += 2; | |
6072 v10 = (char *)v10 + 4; | |
6073 } | |
6074 v10 = (char *)v10 + Dst.lPitch-sprite_texture->uWidth*2; | |
6075 } | |
6076 ErrD3D(pSprite->pTextureSurface->Unlock(NULL)); | |
6077 } | |
6078 delete [] sprite_texture->pPixels; | |
6079 delete sprite_texture; | |
6080 return true; | |
6081 } | |
6082 return false; | |
6083 } | |
6084 | |
6085 //----- (004A51CB) -------------------------------------------------------- | |
6086 void Render::BeginScene() | |
6087 { | |
6088 //Render *v1; // esi@1 | |
6089 unsigned int v2; // eax@1 | |
6090 /*int v3; // eax@5 | |
6091 unsigned __int16 **v4; // edi@6 | |
6092 char *v5; // ebx@7*/ | |
6093 // DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
6094 | |
6095 //v1 = this; | |
6096 v2 = this->uNumSceneBegins; | |
6097 this->uNumSceneBegins = v2 + 1; | |
6098 if ( !v2 ) | |
6099 { | |
6100 if ( this->pRenderD3D ) | |
6101 { | |
6102 /*if ( this->bColorKeySupported ) | |
6103 { | |
6104 memset(&Dst, 0, 0x7Cu); | |
6105 Dst.dwSize = 124; | |
6106 if ( LockSurface_DDraw4(this->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) ) | |
6107 { | |
6108 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; | |
6109 this->uTargetSurfacePitch = Dst.lPitch >> 1; | |
6110 this->field_18_locked_pitch = Dst.lPitch >> 1; | |
6111 } | |
6112 --this->uNumSceneBegins; | |
6113 }*/ | |
6114 } | |
6115 else | |
6116 { | |
6117 if ( !this->pTargetSurface ) | |
6118 { | |
6119 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
6120 /*if ( this->pTargetSurface ) | |
6121 { | |
6122 this->field_18_locked_pitch = this->uTargetSurfacePitch; | |
6123 }*/ | |
6124 --this->uNumSceneBegins; | |
6125 } | |
6126 } | |
6127 RestoreFrontBuffer(); | |
6128 } | |
6129 } | |
6130 | |
6131 //----- (004A527D) -------------------------------------------------------- | |
6132 void Render::EndScene() | |
6133 { | |
6134 if ( this->uNumSceneBegins ) | |
6135 { | |
6136 this->uNumSceneBegins--; | |
6137 if ( !this->uNumSceneBegins ) | |
6138 { | |
6139 if ( this->pRenderD3D ) | |
6140 { | |
6141 /*if ( this->bColorKeySupported ) | |
6142 { | |
6143 this->pTargetSurface = 0; | |
6144 this->uTargetSurfacePitch = 0; | |
6145 this->field_18_locked_pitch = 0; | |
6146 ErrD3D(this->pColorKeySurface4->Unlock(NULL)); | |
6147 }*/ | |
6148 } | |
6149 else | |
6150 { | |
6151 this->pTargetSurface = 0; | |
6152 this->uTargetSurfacePitch = 0; | |
6153 //this->field_18_locked_pitch = 0; | |
6154 UnlockBackBuffer(); | |
6155 } | |
6156 } | |
6157 } | |
6158 } | |
6159 | |
6160 //----- (004A52F1) -------------------------------------------------------- | |
6161 void Render::ScreenFade(unsigned int color, float t) | |
6162 { | |
6163 unsigned int v3; // esi@1 | |
6164 unsigned int v7; // eax@6 | |
6165 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
6166 int v40; // [sp+9Ch] [bp-4h]@6 | |
6167 | |
6168 v3 = 0; | |
6169 | |
6170 //{ | |
6171 if (t > 1.0f) | |
6172 t = 1.0f; | |
6173 else if (t < 0.0f) | |
6174 t = 0.0f; | |
6175 | |
6176 v40 = (char)floorf(t * 255.0f + 0.5f); | |
6177 | |
6178 v7 = color | (v40 << 24); | |
6179 | |
6180 v36[0].specular = 0; | |
6181 v36[0].pos.x = pViewport->uViewportTL_X; | |
6182 v36[0].pos.y = (double)pViewport->uViewportTL_Y; | |
6183 v36[0].pos.z = 0.0; | |
6184 v36[0].diffuse = v7; | |
6185 v36[0].rhw = 1.0; | |
6186 v36[0].texcoord.x = 0.0; | |
6187 v36[0].texcoord.y = 0.0; | |
6188 | |
6189 v36[1].specular = 0; | |
6190 v36[1].pos.x = pViewport->uViewportTL_X; | |
6191 v36[1].pos.y = (double)(pViewport->uViewportBR_Y + 1); | |
6192 v36[1].pos.z = 0.0; | |
6193 v36[1].diffuse = v7; | |
6194 v36[1].rhw = 1.0; | |
6195 v36[1].texcoord.x = 0.0; | |
6196 v36[1].texcoord.y = 0.0; | |
6197 | |
6198 v36[2].specular = 0; | |
6199 v36[2].pos.x = (double)pViewport->uViewportBR_X; | |
6200 v36[2].pos.y = (double)(pViewport->uViewportBR_Y + 1); | |
6201 v36[2].pos.z = 0.0; | |
6202 v36[2].diffuse = v7; | |
6203 v36[2].rhw = 1.0; | |
6204 v36[2].texcoord.x = 0.0; | |
6205 v36[2].texcoord.y = 0.0; | |
6206 | |
6207 v36[3].specular = 0; | |
6208 v36[3].pos.x = (double)pViewport->uViewportBR_X; | |
6209 v36[3].pos.y = (double)pViewport->uViewportTL_Y; | |
6210 v36[3].pos.z = 0.0; | |
6211 v36[3].diffuse = v7; | |
6212 v36[3].rhw = 1.0; | |
6213 v36[3].texcoord.x = 0.0; | |
6214 v36[3].texcoord.y = 0.0; | |
6215 | |
6216 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
6217 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
6218 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
6219 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
6220 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
6221 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
6222 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
6223 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
6224 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
6225 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v36, 4, 28)); | |
6226 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
6227 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
6228 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
6229 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
6230 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
6231 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
6232 /*} | |
6233 else | |
6234 { | |
6235 v40 = (1.0 - a3) * 65536.0; | |
6236 v39 = v40 + 6.7553994e15; | |
6237 LODWORD(a3) = LODWORD(v39); | |
6238 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; | |
6239 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
6240 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
6241 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
6242 v37 = 2 * v13; | |
6243 LODWORD(v40) = (int)v14; | |
6244 | |
6245 int __i = 0; | |
6246 v15 = dword_F1B430.data(); | |
6247 do | |
6248 { | |
6249 v16 = v3; | |
6250 v3 += LODWORD(a3); | |
6251 dword_F1B430[__i++] = v16 >> 16; | |
6252 } | |
6253 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
6254 while (__i < 32); | |
6255 | |
6256 if ( pRenderer->uTargetGBits == 6 ) | |
6257 { | |
6258 v17 = sr_42690D_colors_cvt(this_); | |
6259 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); | |
6260 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); | |
6261 v19 = v40; | |
6262 v20 = off_4EFDB0; | |
6263 v21 = HIDWORD(v39); | |
6264 do | |
6265 { | |
6266 v22 = v38; | |
6267 v31 = v21; | |
6268 do | |
6269 { | |
6270 v23 = (*(int *)((char *)v20 | |
6271 + ((((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; | |
6272 result = this_ | |
6273 + (*((int *)v20 | |
6274 + (((unsigned __int8)(*((char *)v20 | |
6275 + ((((unsigned __int16)(*(short *)((char *)v20 | |
6276 + ((*(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); | |
6277 *(unsigned int *)LODWORD(v19) = result; | |
6278 LODWORD(v19) += 4; | |
6279 --v22; | |
6280 } | |
6281 while ( v22 ); | |
6282 LODWORD(v19) += v37; | |
6283 v21 = v31 - 1; | |
6284 } | |
6285 while ( v31 != 1 ); | |
6286 } | |
6287 else | |
6288 { | |
6289 v24 = sr_4268E3_smthn_to_a1r5g5b5(this_); | |
6290 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); | |
6291 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
6292 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
6293 v26 = v40; | |
6294 v27 = (char *)off_4EFDB0; | |
6295 v28 = HIDWORD(v39); | |
6296 do | |
6297 { | |
6298 v29 = v38; | |
6299 v32 = v28; | |
6300 do | |
6301 { | |
6302 v30 = 32 | |
6303 * *(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; | |
6304 result = this_ | |
6305 + (*(int *)&v27[4 | |
6306 * (((unsigned __int8)(32 | |
6307 * 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); | |
6308 *(unsigned int *)LODWORD(v26) = result; | |
6309 LODWORD(v26) += 4; | |
6310 --v29; | |
6311 } | |
6312 while ( v29 ); | |
6313 LODWORD(v26) += v37; | |
6314 v28 = v32 - 1; | |
6315 } | |
6316 while ( v32 != 1 ); | |
6317 } | |
6318 }*/ | |
6319 } | |
6320 | |
6321 //----- (004A5B81) -------------------------------------------------------- | |
2524 | 6322 void Render::SetUIClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
2496 | 6323 { |
6324 this->bClip = 1; | |
6325 this->uClipX = uX; | |
6326 this->uClipY = uY; | |
6327 this->uClipZ = uZ; | |
6328 this->uClipW = uW; | |
6329 } | |
6330 | |
6331 //----- (004A5BB6) -------------------------------------------------------- | |
2524 | 6332 void Render::ResetUIClipRect() |
2496 | 6333 { |
6334 this->bClip = 1; | |
6335 this->uClipX = 0; | |
6336 this->uClipY = 0; | |
6337 this->uClipZ = window->GetWidth(); | |
6338 this->uClipW = 480; | |
6339 } | |
6340 | |
6341 unsigned __int32 Color32(unsigned __int16 color16) | |
6342 { | |
6343 unsigned __int32 c = color16; | |
6344 unsigned int b = (c & 31) * 8; | |
6345 unsigned int g = ((c >> 5) & 63) * 4; | |
6346 unsigned int r = ((c >> 11) & 31) * 8; | |
6347 | |
2523 | 6348 return (r << 16) | (g << 8) | b; |
6349 } | |
6350 | |
6351 unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16) | |
6352 { | |
6353 unsigned __int32 c = color16; | |
6354 unsigned int b = (c & 31) * 8; | |
6355 unsigned int g = ((c >> 5) & 63) * 4; | |
6356 unsigned int r = ((c >> 11) & 31) * 8; | |
6357 | |
6358 return (b << 16) | (g << 8) | r; | |
2496 | 6359 } |
6360 | |
6361 //----- (0040DEF3) -------------------------------------------------------- | |
6362 unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b) | |
6363 { | |
6364 //return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + | |
6365 // LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + | |
6366 // LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8)); | |
6367 return (b >> (8 - 5)) | | |
6368 0x7E0 & (g << (6 + 5 - 8)) | | |
6369 0xF800 & (r << (6 + 5 + 5 - 8)); | |
6370 } | |
6371 | |
2574 | 6372 |
6373 | |
6374 void Render::DrawTextureCustomHeight(float u, float v, class Image *img, int custom_height) | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6375 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6376 unsigned __int16 *v6; // esi@3 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6377 unsigned int v8; // eax@5 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6378 unsigned int v11; // eax@7 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6379 unsigned int v12; // ebx@8 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6380 unsigned int v15; // eax@14 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6381 int v19; // [sp+10h] [bp-8h]@3 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6382 |
2574 | 6383 if (!img) |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6384 return; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6385 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6386 unsigned int uOutX = 640 * u; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6387 unsigned int uOutY = 480 * v; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6388 |
2574 | 6389 int width = img->GetWidth(); |
6390 int height = min(img->GetHeight(), custom_height); | |
6391 v6 = (unsigned __int16 *)img->GetPixels(IMAGE_FORMAT_R5G6B5); | |
6392 | |
6393 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
6394 v19 = width; | |
6395 if (this->bClip) | |
6396 { | |
6397 if ((signed int)uOutX < (signed int)this->uClipX) | |
6398 { | |
6399 v8 = this->uClipX - uOutX; | |
6400 unsigned int v9 = uOutX - this->uClipX; | |
6401 v8 *= 2; | |
6402 width += v9; | |
6403 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
6404 //v5 = (unsigned __int16 *)((char *)v5 + v8); | |
6405 } | |
6406 if ((signed int)uOutY < (signed int)this->uClipY) | |
6407 { | |
6408 v11 = this->uClipY - uOutY; | |
6409 v6 += v19 * v11; | |
6410 height += uOutY - this->uClipY; | |
6411 //v5 += this->uTargetSurfacePitch * v11; | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6412 } |
2574 | 6413 v12 = max(this->uClipX, uOutX); |
6414 if ((signed int)(width + v12) >(signed int)this->uClipZ) | |
6415 { | |
6416 width = this->uClipZ - max(this->uClipX, uOutX); | |
6417 } | |
6418 v15 = max(this->uClipY, uOutY); | |
6419 if ((signed int)(v15 + height) > (signed int)this->uClipW) | |
6420 { | |
6421 height = this->uClipW - max(this->uClipY, uOutY); | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6422 } |
2574 | 6423 } |
6424 | |
6425 for (int y = 0; y < height; y++) | |
6426 { | |
6427 for (int x = 0; x < width; x++) | |
6428 { | |
6429 WritePixel16(uOutX + x, uOutY + y, *v6); | |
6430 //*v5 = *v6; | |
6431 //++v5; | |
6432 ++v6; | |
6433 } | |
6434 v6 += v19 - width; | |
6435 //v5 += this->uTargetSurfacePitch - v4; | |
6436 } | |
6437 } | |
6438 | |
6439 void Render::DrawTextureNew(float u, float v, Image *bmp) | |
6440 { | |
6441 DrawTextureCustomHeight(u, v, bmp, bmp->GetHeight()); | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6442 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6443 |
2496 | 6444 |
6445 //----- (004A5D33) -------------------------------------------------------- | |
6446 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) | |
6447 { | |
6448 //unsigned __int16 *v7; // ebx@3 | |
6449 int full_width; // ecx@3 | |
6450 int full_height; // edi@3 | |
6451 //int v23; // edi@23 | |
6452 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 | |
6453 | |
6454 if ( this->uNumSceneBegins && pTexture ) | |
6455 { | |
6456 /*auto v7 = this->pTargetSurface; | |
6457 if (FORCE_16_BITS) | |
6458 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 2); | |
6459 else | |
6460 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 4);*/ | |
6461 full_width = pTexture->uWidth - move_X; | |
6462 full_height = pTexture->uHeight - move_Y; | |
6463 pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth]; | |
6464 if ( this->bClip ) | |
6465 { | |
6466 if ( pX < this->uClipX )//åñëè êàäð âûõîäèò çà ïðàâóþ ãðàíèöó | |
6467 { | |
6468 pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX))); | |
6469 full_width += pX - this->uClipX; | |
6470 //v7 = (unsigned __int32 *)((char *)v7 + ((FORCE_16_BITS ? 2 : 4) * (this->uClipX - pX))); | |
6471 } | |
6472 if ( pY < this->uClipY )//åñëè êàäð âûõîäèò çà âåðõíþþ ãðàíèöó | |
6473 { | |
6474 pTexturea += pTexture->uWidth * (this->uClipY - pY); | |
6475 full_height += pY - this->uClipY; | |
6476 //v7 = (unsigned __int32 *)((char *)v7 + (FORCE_16_BITS ? 2 : 4) * this->uTargetSurfacePitch * (this->uClipY - pY)); | |
6477 } | |
6478 if ( this->uClipX < pX )//åñëè ïðàâàÿ ãðàíèöà îêíà ìåíüøå õ êîîðäèíàòû êàäðà | |
6479 this->uClipX = pX; | |
6480 if ( this->uClipY < pY )//åñëè âåðõíÿÿ ãðàíèöà îêíà ìåíüøå y êîîðäèíàòû êàäðà | |
6481 this->uClipY = pY; | |
6482 if ( (full_width + this->uClipX) > this->uClipZ )//åñëè øèðèíà êàäðà âûõîäèò çà ïðàâóþ ãðàíèöó | |
6483 { | |
6484 if ( this->uClipX < pX ) | |
6485 this->uClipX = pX; | |
6486 full_width = this->uClipZ - this->uClipX; | |
6487 } | |
6488 if ( (full_height + this->uClipY) > this->uClipW )//åñëè âûñîòà êàäðà âûõîäèò çà íèæíþþ ãðàíèöó | |
6489 { | |
6490 if ( this->uClipY < pY ) | |
6491 this->uClipY = pY; | |
6492 full_height = this->uClipW - this->uClipY; | |
6493 } | |
6494 } | |
6495 | |
6496 for (int y = 0; y < full_height; ++y) | |
6497 { | |
6498 for (int x = 0; x < full_width; ++x) | |
6499 { | |
6500 if ( *pTexturea != Color16(0, 0xFFu, 0xFFu) ) | |
6501 { | |
6502 WritePixel16(pX + x, pY + y, *pTexturea); | |
6503 /*if (FORCE_16_BITS) | |
6504 *(unsigned __int16 *)v7 = *pTexturea; | |
6505 else | |
6506 *(unsigned __int32 *)v7 = r5g6b5_2_r8g8b8(*pTexturea);*/ | |
6507 } | |
6508 ++pTexturea; | |
6509 //++v7; | |
6510 } | |
6511 //v7 += this->uTargetSurfacePitch - full_width; | |
6512 pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width)); | |
6513 } | |
6514 } | |
6515 } | |
6516 | |
6517 //----- (004A6E7E) -------------------------------------------------------- | |
2575 | 6518 void Render::DrawTextureGrayShade(float u, float v, Image *img) |
6519 { | |
6520 DrawMasked(u, v, img, 1, 0x7BEF); | |
2496 | 6521 } |
6522 | |
6523 //----- (004A6DF5) -------------------------------------------------------- | |
6524 void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) | |
6525 { | |
6526 int width; // ecx@3 | |
6527 unsigned __int16 *pixels; // ebx@4 | |
6528 int height; // esi@4 | |
6529 | |
6530 if ( !pBitmap || !pTarget) | |
6531 return; | |
6532 | |
6533 width = a7->z - a7->x; | |
6534 height = a7->w - a7->y; | |
6535 pixels = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y; | |
6536 for ( int y = 0; y < height; ++y ) | |
6537 { | |
6538 for ( int x = 0; x < width; ++x ) | |
6539 { | |
6540 WritePixel16(a7->x + x, a7->y + y, *pixels); | |
6541 ++pixels; | |
6542 } | |
6543 pixels += uTargetPitch - width; | |
6544 } | |
6545 } | |
6546 | |
6547 //----- (004A6D87) -------------------------------------------------------- | |
6548 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
6549 { | |
6550 if (!uNumSceneBegins) | |
6551 return; | |
6552 | |
6553 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
6554 for (uint y = 0; y < uHeight; ++y) | |
6555 { | |
6556 void *pDst = (char *)pTargetSurface + (FORCE_16_BITS ? 2 : 4) * (uX + (y + uY) * uTargetSurfacePitch); | |
6557 | |
6558 memset32(pDst, | |
6559 FORCE_16_BITS ? twoColors : 0xFF000000 | Color32(uColor16), // two colors per int (16bit) or 1 (32bit) | |
6560 uWidth / (FORCE_16_BITS ? 2 : 1)); // two pixels per int (16bit) or 1 (32bit) | |
6561 | |
6562 if (FORCE_16_BITS && uWidth & 1) // we may miss one pixel for 16bit | |
6563 ((unsigned __int16 *)pTargetSurface)[uX + uWidth - 1 + (y + uY) * uTargetSurfacePitch] = uColor16; | |
6564 } | |
6565 } | |
6566 | |
6567 //----- (004A6C4F) -------------------------------------------------------- | |
6568 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, | |
6569 unsigned int uCharHeight, unsigned __int16 *pFontPalette, | |
6570 unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) | |
6571 { | |
6572 unsigned int v9; // edi@2 | |
6573 unsigned int v10; // esi@2 | |
6574 unsigned int v12; // ebx@3 | |
6575 //signed int v13; // edx@5 | |
6576 int v14; // edx@6 | |
6577 signed int v15; // ebx@7 | |
6578 //unsigned int v16; // edx@9 | |
6579 signed int v17; // edi@10 | |
6580 signed int v18; // ebx@13 | |
6581 unsigned int v19; // edx@15 | |
6582 signed int v20; // esi@16 | |
6583 unsigned __int16 v22; // dx@24 | |
6584 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 | |
6585 | |
6586 if (!this->uNumSceneBegins) | |
6587 return; | |
6588 | |
6589 v9 = uCharWidth; | |
6590 v10 = uCharHeight; | |
6591 //v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
6592 v24 = pFontPixels; | |
6593 | |
6594 int clipped_out_x = uOutX, clipped_out_y = uOutY; | |
6595 if ( this->bClip ) | |
6596 { | |
6597 v12 = this->uClipX; | |
6598 if ( uOutX < (signed int)v12 ) | |
6599 { | |
6600 v24 = &pFontPixels[v12 - uOutX]; | |
6601 //v11 += v12 - uOutX; | |
6602 clipped_out_x = uClipX; | |
6603 v9 = uCharWidth + uOutX - v12; | |
6604 } | |
6605 //v13 = this->uClipY; | |
6606 if ( uOutY < this->uClipY ) | |
6607 { | |
6608 v14 = this->uClipY - uOutY; | |
6609 v24 += uCharWidth * v14; | |
6610 v10 = uCharHeight + uOutY - this->uClipY; | |
6611 //v11 += this->uTargetSurfacePitch * v14; | |
6612 clipped_out_y = uClipY; | |
6613 } | |
6614 v15 = this->uClipX; | |
6615 if ( this->uClipX < uOutX ) | |
6616 v15 = uOutX; | |
6617 //v16 = this->uClipZ; | |
6618 if ( (signed int)(v9 + v15) > (signed int)this->uClipZ ) | |
6619 { | |
6620 v17 = this->uClipX; | |
6621 if ( this->uClipX < uOutX ) | |
6622 v17 = uOutX; | |
6623 v9 = this->uClipZ - v17; | |
6624 } | |
6625 v18 = this->uClipY; | |
6626 if ( this->uClipY < uOutY ) | |
6627 v18 = uOutY; | |
6628 v19 = this->uClipW; | |
6629 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
6630 { | |
6631 v20 = this->uClipY; | |
6632 if ( this->uClipY < uOutY ) | |
6633 v20 = uOutY; | |
6634 v10 = v19 - v20; | |
6635 } | |
6636 } | |
6637 | |
6638 for (uint y = 0; y < v10; ++y) | |
6639 { | |
6640 for (uint x = 0; x < v9; ++x) | |
6641 { | |
6642 if (*v24) | |
6643 { | |
6644 v22 = uShadowColor; | |
6645 if ( *v24 != 1 ) | |
6646 v22 = uFaceColor; | |
6647 WritePixel16(clipped_out_x + x, clipped_out_y + y, v22); | |
6648 } | |
6649 ++v24; | |
6650 } | |
6651 v24 += uCharWidth - v9; | |
6652 //v23 = uOutXa-- == 1; | |
6653 //v11 += this->uTargetSurfacePitch - v9; | |
6654 } | |
6655 } | |
6656 | |
2574 | 6657 /* |
2496 | 6658 //----- (004A6A68) -------------------------------------------------------- |
2574 | 6659 void Render::DrawTextureCustomHeight(unsigned int x, unsigned int y, Texture_MM7 *texture, __int16 height) |
6660 { | |
6661 Texture_MM7 tex; // [sp+Ch] [bp-48h]@1 | |
6662 | |
6663 memcpy(&tex, texture, sizeof(tex)); | |
6664 tex.uTextureHeight = texture->uTextureHeight - height; | |
2496 | 6665 if ( (signed __int16)tex.uTextureHeight > 0 ) |
2574 | 6666 DrawTextureTransparentColorKey(x, y, &tex); |
6667 }*/ | |
2496 | 6668 |
6669 //----- (004A6AB1) -------------------------------------------------------- | |
2525 | 6670 void Render::DrawTextAlpha( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, bool present_time_transparency ) |
2496 | 6671 { |
6672 int v8; // edi@2 | |
6673 unsigned int v9; // esi@2 | |
6674 unsigned char *v11; // edx@2 | |
6675 int v14; // edx@6 | |
6676 signed int v15; // ebx@7 | |
6677 signed int v17; // edi@10 | |
6678 signed int v18; // ebx@13 | |
6679 signed int v20; // esi@16 | |
6680 unsigned __int16 v24; // si@35 | |
6681 int v25; // [sp+Ch] [bp-4h]@2 | |
6682 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
6683 | |
6684 int a2 = x; | |
6685 int a3 = y; | |
6686 uint a6 = uFontHeight; | |
6687 if (!this->uNumSceneBegins) | |
6688 return; | |
6689 | |
6690 v8 = a5; | |
6691 v9 = a6; | |
6692 //v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; | |
6693 v11 = (unsigned char *)font_pixels; | |
6694 v25 = (int)font_pixels; | |
6695 int clipped_out_x = x; | |
6696 int clipped_out_y = y; | |
6697 if ( this->bClip ) | |
6698 { | |
6699 if ( a2 < (signed int)this->uClipX ) | |
6700 { | |
6701 v25 = this->uClipX - a2 + (int)font_pixels; | |
6702 //v10 += v12 - a2; | |
6703 v8 = a5 + a2 - this->uClipX; | |
6704 clipped_out_x = uClipX; | |
6705 } | |
6706 if ( a3 < this->uClipY ) | |
6707 { | |
6708 v14 = this->uClipY - a3; | |
6709 v25 += a5 * v14; | |
6710 v9 = a6 + a3 - this->uClipY; | |
6711 //v10 += this->uTargetSurfacePitch * v14; | |
6712 clipped_out_y = uClipY; | |
6713 } | |
6714 v15 = this->uClipX; | |
6715 if ( this->uClipX < a2 ) | |
6716 v15 = a2; | |
6717 if ( v8 + v15 > (signed int)this->uClipZ ) | |
6718 { | |
6719 v17 = this->uClipX; | |
6720 if ( v17 < a2 ) | |
6721 v17 = a2; | |
6722 v8 = this->uClipZ - v17; | |
6723 } | |
6724 v18 = this->uClipY; | |
6725 if ( this->uClipY < a3 ) | |
6726 v18 = a3; | |
6727 if ( (signed int)(v9 + v18) > (signed int)this->uClipW ) | |
6728 { | |
6729 v20 = this->uClipY; | |
6730 if ( this->uClipY < a3 ) | |
6731 v20 = a3; | |
6732 v9 = this->uClipW - v20; | |
6733 } | |
6734 v11 = (unsigned char *)v25; | |
6735 } | |
6736 | |
2525 | 6737 if ( present_time_transparency ) |
6738 { | |
6739 v28 = 0x7FF; // transparent color 16bit pRenderer->uTargetGMask | pRenderer->uTargetBMask; | |
2496 | 6740 for (uint dy = 0; dy < v9; ++dy) |
6741 { | |
6742 for (int dx = 0; dx < v8; ++dx) | |
6743 { | |
6744 if ( *v11 ) | |
6745 v24 = pPalette[*v11]; | |
6746 else | |
6747 v24 = v28; | |
6748 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, v24); | |
6749 //*v10 = v24; | |
6750 //++v10; | |
6751 ++v11; | |
6752 //--v27; | |
6753 | |
6754 } | |
6755 v11 += a5 - v8; | |
6756 } | |
6757 /*if ( (signed int)v9 > 0 ) | |
6758 { | |
6759 v23 = a5; | |
6760 v30 = v9; | |
6761 do | |
6762 { | |
6763 if ( v8 > 0 ) | |
6764 { | |
6765 v27 = v8; | |
6766 do | |
6767 { | |
6768 if ( *v11 ) | |
6769 v24 = pPalette[*v11]; | |
6770 else | |
6771 v24 = v28; | |
6772 *v10 = v24; | |
6773 ++v10; | |
6774 ++v11; | |
6775 --v27; | |
6776 } | |
6777 while ( v27 ); | |
6778 } | |
6779 v11 += v23 - v8; | |
6780 v22 = v30-- == 1; | |
6781 v10 += this->uTargetSurfacePitch - v8; | |
6782 } | |
6783 while ( !v22 ); | |
6784 }*/ | |
6785 } | |
6786 else | |
6787 { | |
6788 for (uint dy = 0; dy < v9; ++dy) | |
6789 { | |
6790 for (int dx = 0; dx < v8; ++dx) | |
6791 { | |
6792 if ( *v11 ) | |
6793 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, pPalette[*v11]); | |
6794 //*v10 = v24; | |
6795 //++v10; | |
6796 ++v11; | |
6797 //--v27; | |
6798 } | |
6799 v11 += a5 - v8; | |
6800 } | |
6801 | |
6802 /*if ( (signed int)v9 > 0 ) | |
6803 { | |
6804 v21 = a5; | |
6805 v29 = v9; | |
6806 do | |
6807 { | |
6808 if ( v8 > 0 ) | |
6809 { | |
6810 v26 = v8; | |
6811 do | |
6812 { | |
6813 if ( *v11 ) | |
6814 *v10 = pPalette[*v11]; | |
6815 ++v10; | |
6816 ++v11; | |
6817 --v26; | |
6818 } | |
6819 while ( v26 ); | |
6820 } | |
6821 v11 += v21 - v8; | |
6822 v22 = v29-- == 1; | |
6823 v10 += this->uTargetSurfacePitch - v8; | |
6824 } | |
6825 while ( !v22 ); | |
6826 }*/ | |
6827 } | |
6828 } | |
6829 | |
6830 //----- (004A68EF) -------------------------------------------------------- | |
2574 | 6831 void Render::DrawTransparentGreenShade(float u, float v, Image *pTexture) |
6832 { | |
2575 | 6833 DrawMasked(u, v, pTexture, 0, 0x07E0); |
2496 | 6834 } |
6835 | |
6836 | |
6837 //----- (004A6776) -------------------------------------------------------- | |
2574 | 6838 void Render::DrawTransparentRedShade(float u, float v, Image *a4) |
6839 { | |
2575 | 6840 DrawMasked(u, v, a4, 0, 0xF800); |
2496 | 6841 } |
6842 | |
6843 //----- (004A68EF) -------------------------------------------------------- | |
2575 | 6844 void Render::DrawMasked(float u, float v, Image *pTexture, unsigned int color_dimming_level, unsigned __int16 mask) |
2496 | 6845 { |
6846 unsigned int v5; // ebx@4 | |
6847 int v10; // edx@8 | |
6848 signed int v11; // edx@9 | |
6849 signed int v12; // esi@12 | |
6850 signed int v13; // esi@15 | |
6851 signed int v15; // esi@18 | |
2574 | 6852 //unsigned __int8 *v16; // ebx@22 |
2496 | 6853 int v18; // [sp+10h] [bp-10h]@4 |
2574 | 6854 //unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 |
2496 | 6855 int v20; // [sp+1Ch] [bp-4h]@4 |
6856 | |
6857 if (!uNumSceneBegins || !pTexture) | |
6858 return; | |
6859 | |
2574 | 6860 //if ( pTexture->pPalette16 ) |
6861 { | |
6862 v5 = pTexture->GetHeight(); | |
2496 | 6863 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; |
2574 | 6864 //v19 = pTexture->paletted_pixels; |
6865 auto pixels = (unsigned __int32 *)pTexture->GetPixels(IMAGE_FORMAT_A8R8G8B8); | |
6866 | |
6867 v18 = v20 = pTexture->GetWidth(); | |
6868 | |
6869 int a2 = u * window->GetWidth(); | |
6870 int a3 = v * window->GetHeight(); | |
6871 | |
2496 | 6872 int clipped_out_x = a2; |
6873 int clipped_out_y = a3; | |
6874 if ( this->bClip ) | |
6875 { | |
6876 if ( a2 < this->uClipX ) | |
6877 { | |
2574 | 6878 pixels += this->uClipX - a2; |
2496 | 6879 v20 += a2 - this->uClipX; |
6880 clipped_out_x = uClipX; | |
6881 } | |
2574 | 6882 v5 = pTexture->GetHeight(); |
2496 | 6883 if ( a3 < this->uClipY ) |
6884 { | |
6885 v10 = this->uClipY - a3; | |
2574 | 6886 pixels += v18 * v10; |
6887 v5 = a3 - this->uClipY + pTexture->GetHeight(); | |
2496 | 6888 clipped_out_y = uClipY; |
6889 } | |
6890 v11 = this->uClipX; | |
6891 if ( this->uClipX < a2 ) | |
6892 v11 = a2; | |
6893 if ( v11 + v20 > (signed int)this->uClipZ ) | |
6894 { | |
6895 v12 = this->uClipX; | |
6896 if ( this->uClipX < a2 ) | |
6897 v12 = a2; | |
6898 v20 = this->uClipZ - v12; | |
6899 } | |
6900 v13 = this->uClipY; | |
6901 if ( this->uClipY < a3 ) | |
6902 v13 = a3; | |
6903 if ( (signed int)(v5 + v13) > (signed int)this->uClipW ) | |
6904 { | |
6905 v15 = this->uClipY; | |
6906 if ( this->uClipY < a3 ) | |
6907 v15 = a3; | |
6908 v5 = this->uClipW - v15; | |
6909 } | |
6910 } | |
6911 | |
2574 | 6912 /*v16 = v19; |
2496 | 6913 for (uint y = 0; y < v5; ++y) |
6914 { | |
6915 for (int x = 0; x < v20; ++x) | |
6916 { | |
6917 if ( *v16 ) | |
6918 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v16] & mask); | |
6919 ++v16; | |
6920 } | |
6921 v16 += v18 - v20; | |
2574 | 6922 }*/ |
6923 | |
6924 for (uint y = 0; y < v5; ++y) | |
6925 { | |
6926 for (int x = 0; x < v20; ++x) | |
6927 { | |
6928 if (*pixels & 0xFF000000) | |
6929 WritePixel16( | |
6930 clipped_out_x + x, | |
6931 clipped_out_y + y, | |
2575 | 6932 (Color16((*pixels >> 16) & 0xFF, (*pixels >> 8) & 0xFF, *pixels & 0xFF) >> color_dimming_level) & mask |
2574 | 6933 ); |
6934 ++pixels; | |
6935 } | |
6936 pixels += v18 - v20; | |
6937 } | |
2496 | 6938 } |
6939 } | |
6940 | |
6941 | |
6942 //----- (004A65CC) -------------------------------------------------------- | |
2574 | 6943 void Render::_4A65CC(unsigned int x, unsigned int y, Texture_MM7 *a4, Texture_MM7 *a5, int a6, int a7, int a8) |
2496 | 6944 { |
6945 unsigned int uHeight; // edi@6 | |
6946 unsigned int v14; // edx@11 | |
6947 unsigned int v16; // edx@14 | |
6948 unsigned int v17; // edx@17 | |
6949 unsigned int v19; // edx@20 | |
6950 int v20; // eax@27 | |
6951 int v21; // edx@29 | |
6952 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
6953 int Width; // [sp+2Ch] [bp+14h]@6 | |
6954 | |
6955 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
6956 { | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
6957 v24 = a4->paletted_pixels; |
2496 | 6958 Width = a4->uTextureWidth; |
6959 uHeight = a4->uTextureHeight; | |
6960 int clipped_out_x = x; | |
6961 int clipped_out_y = y; | |
6962 if ( this->bClip ) | |
6963 { | |
6964 if ( (signed int)x < (signed int)this->uClipX ) | |
6965 { | |
6966 v24 += this->uClipX - x; | |
6967 Width += x - this->uClipX; | |
6968 clipped_out_x = uClipX; | |
6969 } | |
6970 if ( (signed int)y < (signed int)this->uClipY ) | |
6971 { | |
6972 v24 += a4->uTextureWidth * (this->uClipY - y); | |
6973 uHeight = y - this->uClipY + a4->uTextureHeight; | |
6974 clipped_out_y = uClipY; | |
6975 } | |
6976 v14 = this->uClipX; | |
6977 if ( (signed int)this->uClipX < (signed int)x ) | |
6978 v14 = x; | |
6979 if ( (signed int)(Width + v14) > (signed int)this->uClipZ ) | |
6980 { | |
6981 v16 = this->uClipX; | |
6982 if ( (signed int)this->uClipX < (signed int)x ) | |
6983 v16 = x; | |
6984 Width = this->uClipZ - v16; | |
6985 } | |
6986 v17 = this->uClipY; | |
6987 if ( (signed int)this->uClipY < (signed int)y ) | |
6988 v17 = y; | |
6989 if ( (signed int)(uHeight + v17) > (signed int)this->uClipW ) | |
6990 { | |
6991 v19 = this->uClipY; | |
6992 if ( (signed int)this->uClipY < (signed int)y ) | |
6993 v19 = y; | |
6994 uHeight = this->uClipW - v19; | |
6995 } | |
6996 } | |
6997 | |
6998 for (uint dy = 0; dy < uHeight; ++dy) | |
6999 { | |
7000 for (int dx = 0; dx < Width; ++dx) | |
7001 { | |
7002 v20 = *v24; | |
7003 if ( v20 >= a7 && v20 <= a8 ) | |
7004 { | |
7005 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7006 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7007 v21 = 2 * a8 - v21 - a7; | |
7008 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]); | |
7009 } | |
7010 ++v24; | |
7011 } | |
7012 v24 += a4->uTextureWidth - Width; | |
7013 } | |
7014 /*if ( (signed int)v9 > 0 ) | |
7015 { | |
7016 ya = v9; | |
7017 v23 = v22 - v27; | |
7018 do | |
7019 { | |
7020 if ( v27 > 0 ) | |
7021 { | |
7022 xa = v27; | |
7023 do | |
7024 { | |
7025 v20 = *v24; | |
7026 if ( v20 >= a7 && v20 <= a8 ) | |
7027 { | |
7028 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7029 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7030 v21 = 2 * a8 - v21 - a7; | |
7031 *v8 = a4->pPalette16[v21]; | |
7032 } | |
7033 ++v8; | |
7034 ++v24; | |
7035 --xa; | |
7036 } | |
7037 while ( xa ); | |
7038 } | |
7039 v8 += this->uTargetSurfacePitch - v27; | |
7040 v24 += v23; | |
7041 --ya; | |
7042 } | |
7043 while ( ya ); | |
7044 }*/ | |
7045 } | |
7046 } | |
7047 | |
7048 //----- (004A63E6) -------------------------------------------------------- | |
2574 | 7049 void Render::BlendTextures(unsigned int a2, unsigned int a3, Image *a4, Texture_MM7 *a5, int t, int start_opacity, int end_opacity) |
7050 //unsigned int a2, unsigned int a3, Image *a4, Texture_MM7 *a5, int a6, int a7, int a8) | |
2496 | 7051 { |
7052 unsigned int v14; // edx@11 | |
7053 unsigned int v16; // edx@14 | |
7054 unsigned int v17; // edx@17 | |
7055 unsigned int v19; // edx@20 | |
7056 int v20; // eax@27 | |
7057 int v21; // edx@29 | |
7058 int Height; // [sp+10h] [bp-8h]@6 | |
7059 int Width; // [sp+14h] [bp-4h]@6 | |
7060 int v27; // [sp+24h] [bp+Ch]@23 | |
7061 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
7062 | |
2574 | 7063 /*if ( this->uNumSceneBegins ) |
2496 | 7064 { |
7065 if ( a4 ) | |
7066 { | |
7067 if ( a4->pPalette16 ) | |
7068 { | |
7069 if ( a5 ) | |
7070 { | |
7071 if ( a5->pPalette16 ) | |
7072 { | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7073 v28 = a4->paletted_pixels; |
2496 | 7074 Width = a4->uTextureWidth; |
7075 Height = a4->uTextureHeight; | |
7076 int clipped_out_x = a2; | |
7077 int clipped_out_y = a3; | |
7078 if ( this->bClip ) | |
7079 { | |
7080 if ( (signed int)a2 < (signed int)this->uClipX ) | |
7081 { | |
7082 v28 += this->uClipX - a2; | |
7083 Width += a2 - this->uClipX; | |
7084 clipped_out_x = uClipX; | |
7085 } | |
7086 | |
7087 if ( (signed int)a3 < (signed int)this->uClipY ) | |
7088 { | |
7089 v28 += a4->uTextureWidth * (this->uClipY - a3); | |
7090 Height += a3 - this->uClipY; | |
7091 clipped_out_y = uClipY; | |
7092 } | |
7093 | |
7094 v14 = this->uClipX; | |
7095 if ( (signed int)this->uClipX < (signed int)a2 ) | |
7096 v14 = a2; | |
7097 if ( (signed int)(Width + v14) > (signed int)this->uClipZ ) | |
7098 { | |
7099 v16 = this->uClipX; | |
7100 if ( (signed int)this->uClipX < (signed int)a2 ) | |
7101 v16 = a2; | |
7102 Width = this->uClipZ - v16; | |
7103 } | |
7104 | |
7105 v17 = this->uClipY; | |
7106 if ( (signed int)this->uClipY < (signed int)a3 ) | |
7107 v17 = a3; | |
7108 if ( (signed int)(Height + v17) > (signed int)this->uClipW ) | |
7109 { | |
7110 v19 = this->uClipY; | |
7111 if ( (signed int)this->uClipY < (signed int)a3 ) | |
7112 v19 = a3; | |
7113 Height = this->uClipW - v19; | |
7114 } | |
7115 } | |
7116 | |
7117 v27 = 0; | |
7118 for (int y = 0; y < Height; ++y) | |
7119 { | |
7120 for (int x = 0; x < Width; ++x) | |
7121 { | |
7122 if ( *v28 ) | |
7123 { | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7124 v20 = *(&a5->paletted_pixels[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); |
2496 | 7125 if ( v20 >= a7 ) |
7126 { | |
7127 if ( v20 <= a8 ) | |
7128 { | |
7129 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7130 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7131 v21 = 2 * a8 - v21 - a7; | |
7132 //v9 = a5; | |
7133 //*v10 = a5->pPalette16[v21]; | |
7134 WritePixel16(clipped_out_x + x, clipped_out_y + y, a5->pPalette16[v21]); | |
7135 } | |
7136 } | |
7137 } | |
7138 v28++; | |
7139 } | |
7140 v28 += a4->uTextureWidth - Width; | |
7141 } | |
7142 } | |
7143 } | |
7144 } | |
7145 } | |
2574 | 7146 }*/ |
2496 | 7147 } |
7148 | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7149 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7150 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7151 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7152 void Render::DrawTextureAlphaNew(float u, float v, Image *img) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7153 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7154 int uHeight; // ebx@4 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7155 unsigned int v11; // edx@9 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7156 unsigned int v12; // esi@12 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7157 unsigned int v13; // esi@15 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7158 unsigned int v15; // esi@18 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7159 //unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7160 int uWidth; // [sp+1Ch] [bp-4h]@4 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7161 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7162 if (!uNumSceneBegins || !img) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7163 return; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7164 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7165 uHeight = img->GetHeight(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7166 ///v19 = pTexture->paletted_pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7167 uWidth = img->GetWidth(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7168 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7169 auto pixels = (const unsigned __int32 *)img->GetPixels(IMAGE_FORMAT_A8R8G8B8); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7170 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7171 int uX = u * 640.0f; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7172 int uY = v * 480.0f; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7173 int clipped_out_x = uX; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7174 int clipped_out_y = uY; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7175 if (this->bClip) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7176 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7177 if ((signed int)uX < (signed int)this->uClipX) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7178 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7179 pixels += this->uClipX - uX; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7180 uWidth += uX - this->uClipX; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7181 clipped_out_x = uClipX; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7182 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7183 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7184 uHeight = img->GetHeight(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7185 if ((signed int)uY < (signed int)this->uClipY) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7186 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7187 pixels += img->GetWidth() * (this->uClipY - uY); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7188 uHeight = uY - this->uClipY + img->GetHeight(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7189 clipped_out_y = uClipY; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7190 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7191 v11 = this->uClipX; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7192 if ((signed int)this->uClipX < (signed int)uX) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7193 v11 = uX; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7194 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7195 if ((signed int)(v11 + uWidth) >(signed int)this->uClipZ) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7196 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7197 v12 = this->uClipX; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7198 if ((signed int)this->uClipX < (signed int)uX) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7199 v12 = uX; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7200 uWidth = this->uClipZ - v12; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7201 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7202 v13 = this->uClipY; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7203 if ((signed int)this->uClipY < (signed int)uY) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7204 v13 = uY; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7205 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7206 if ((signed int)(uHeight + v13) >(signed int)this->uClipW) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7207 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7208 v15 = this->uClipY; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7209 if ((signed int)this->uClipY < (signed int)uY) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7210 v15 = uY; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7211 uHeight = this->uClipW - v15; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7212 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7213 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7214 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7215 for (int y = 0; y < uHeight; ++y) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7216 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7217 for (int x = 0; x < uWidth; ++x) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7218 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7219 if (*pixels & 0xFF000000) |
2574 | 7220 WritePixel16( |
7221 clipped_out_x + x, | |
7222 clipped_out_y + y, | |
7223 Color16( | |
7224 (*pixels >> 16) & 0xFF, | |
7225 (*pixels >> 8) & 0xFF, | |
7226 *pixels & 0xFF | |
7227 ) | |
7228 ); | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7229 ++pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7230 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7231 pixels += img->GetWidth() - uWidth; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7232 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7233 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7234 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7235 |
2575 | 7236 /* |
2496 | 7237 //----- (004A6274) -------------------------------------------------------- |
2574 | 7238 void Render::DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, Texture_MM7 *pTexture) |
2496 | 7239 { |
7240 int uHeight; // ebx@4 | |
7241 unsigned int v11; // edx@9 | |
7242 unsigned int v12; // esi@12 | |
7243 unsigned int v13; // esi@15 | |
7244 unsigned int v15; // esi@18 | |
7245 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7246 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
7247 | |
7248 if ( this->uNumSceneBegins ) | |
7249 { | |
7250 if ( pTexture ) | |
7251 { | |
7252 if ( pTexture->pPalette16 ) | |
7253 { | |
7254 uHeight = pTexture->uTextureHeight; | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7255 v19 = pTexture->paletted_pixels; |
2496 | 7256 uWidth = pTexture->uTextureWidth; |
7257 | |
7258 int clipped_out_x = uX; | |
7259 int clipped_out_y = uY; | |
7260 if ( this->bClip ) | |
7261 { | |
7262 if ( (signed int)uX < (signed int)this->uClipX ) | |
7263 { | |
7264 v19 += this->uClipX - uX; | |
7265 uWidth += uX - this->uClipX; | |
7266 clipped_out_x = uClipX; | |
7267 } | |
7268 | |
7269 uHeight = pTexture->uTextureHeight; | |
7270 if ( (signed int)uY < (signed int)this->uClipY ) | |
7271 { | |
7272 v19 += pTexture->uTextureWidth * (this->uClipY - uY); | |
7273 uHeight = uY - this->uClipY + pTexture->uTextureHeight; | |
7274 clipped_out_y = uClipY; | |
7275 } | |
7276 v11 = this->uClipX; | |
7277 if ( (signed int)this->uClipX < (signed int)uX ) | |
7278 v11 = uX; | |
7279 | |
7280 if ( (signed int)(v11 + uWidth) > (signed int)this->uClipZ ) | |
7281 { | |
7282 v12 = this->uClipX; | |
7283 if ( (signed int)this->uClipX < (signed int)uX ) | |
7284 v12 = uX; | |
7285 uWidth = this->uClipZ - v12; | |
7286 } | |
7287 v13 = this->uClipY; | |
7288 if ( (signed int)this->uClipY < (signed int)uY ) | |
7289 v13 = uY; | |
7290 | |
7291 if ( (signed int)(uHeight + v13) > (signed int)this->uClipW ) | |
7292 { | |
7293 v15 = this->uClipY; | |
7294 if ( (signed int)this->uClipY < (signed int)uY ) | |
7295 v15 = uY; | |
7296 uHeight = this->uClipW - v15; | |
7297 } | |
7298 } | |
7299 | |
7300 for (int y = 0; y < uHeight; ++y) | |
7301 { | |
7302 for (int x = 0; x < uWidth; ++x) | |
7303 { | |
7304 if ( *v19 ) | |
7305 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]); | |
7306 ++v19; | |
7307 } | |
7308 v19 += pTexture->uTextureWidth - uWidth; | |
7309 } | |
7310 } | |
7311 } | |
7312 } | |
2575 | 7313 }*/ |
7314 | |
2496 | 7315 |
7316 //----- (004A612A) -------------------------------------------------------- | |
2574 | 7317 void Render::ZDrawTextureAlpha(float u, float v, Image *img, int zVal) |
2496 | 7318 { |
7319 unsigned int v6; // edx@3 | |
7320 int v7; // ebx@3 | |
7321 int v8; // edi@3 | |
7322 int v10; // eax@5 | |
7323 signed int v12; // esi@8 | |
7324 signed int v14; // esi@11 | |
7325 unsigned int v15; // esi@14 | |
7326 unsigned int v17; // ecx@17 | |
7327 int v18; // edx@23 | |
7328 int v19; // [sp+Ch] [bp-Ch]@3 | |
7329 int v20; // [sp+10h] [bp-8h]@3 | |
7330 int uOutXa; // [sp+20h] [bp+8h]@21 | |
2574 | 7331 //unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 |
2496 | 7332 int *pZBuffer; // [sp+28h] [bp+10h]@3 |
7333 | |
2574 | 7334 if (!this->uNumSceneBegins || !img) |
7335 return; | |
7336 | |
7337 int uOutX = u * this->window->GetWidth(); | |
7338 int uOutY = v * this->window->GetHeight(); | |
7339 | |
2496 | 7340 v6 = uOutY; |
2574 | 7341 v7 = img->GetHeight(); |
2496 | 7342 pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY]; |
2574 | 7343 //uOutYa = pTexture->paletted_pixels; |
7344 v8 = v20 = v19 = img->GetWidth(); | |
7345 auto pixels = (unsigned __int32 *)img->GetPixels(IMAGE_FORMAT_A8R8G8B8); | |
2496 | 7346 if ( this->bClip ) |
7347 { | |
7348 if ( uOutX < this->uClipX ) | |
7349 { | |
7350 v10 = this->uClipX - uOutX; | |
2574 | 7351 pixels += v10; |
2496 | 7352 v8 += uOutX - this->uClipX; |
7353 v20 = v8; | |
7354 pZBuffer += v10; | |
7355 } | |
7356 if ( (signed int)v6 < (signed int)this->uClipY ) | |
7357 { | |
2574 | 7358 pixels += v19 * (this->uClipY - v6); |
2496 | 7359 v7 += v6 - this->uClipY; |
7360 pZBuffer += window->GetWidth() * (this->uClipY - v6); | |
7361 v8 = v20; | |
7362 } | |
7363 v12 = this->uClipX; | |
7364 if ( this->uClipX < uOutX ) | |
7365 v12 = uOutX; | |
7366 if ( v8 + v12 > (signed int)this->uClipZ ) | |
7367 { | |
7368 v14 = this->uClipX; | |
7369 if ( this->uClipX < uOutX ) | |
7370 v14 = uOutX; | |
7371 v8 = this->uClipZ - v14; | |
7372 } | |
7373 v15 = this->uClipY; | |
7374 if ( (signed int)this->uClipY < (signed int)v6 ) | |
7375 v15 = v6; | |
7376 if ( (signed int)(v7 + v15) > (signed int)this->uClipW ) | |
7377 { | |
7378 v17 = this->uClipY; | |
7379 if ( (signed int)this->uClipY >= (signed int)v6 ) | |
7380 v6 = v17; | |
7381 v7 = this->uClipW - v6; | |
7382 } | |
7383 } | |
2574 | 7384 |
7385 | |
7386 | |
2496 | 7387 if ( v7 > 0 ) |
7388 { | |
7389 uOutXa = v7; | |
7390 do | |
7391 { | |
7392 if ( v8 > 0 ) | |
7393 { | |
7394 v18 = v8; | |
7395 do | |
7396 { | |
2574 | 7397 if ( *pixels & 0xFF000000) |
2496 | 7398 *pZBuffer = zVal; |
7399 ++pZBuffer; | |
2574 | 7400 ++pixels; |
2496 | 7401 --v18; |
7402 } | |
7403 while ( v18 ); | |
7404 } | |
7405 pZBuffer += window->GetWidth() - v8; | |
2574 | 7406 pixels += v19 - v8; |
2496 | 7407 --uOutXa; |
7408 } | |
7409 while ( uOutXa ); | |
7410 } | |
2574 | 7411 |
2496 | 7412 } |
7413 | |
7414 //----- (004A601E) -------------------------------------------------------- | |
2574 | 7415 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Image *pTexture, int a5) |
7416 { | |
7417 /* signed int v5; // edx@3 | |
2496 | 7418 int v6; // ebx@3 |
7419 int v7; // esi@3 | |
7420 void *v8; // esi@3 | |
7421 signed int v11; // edi@8 | |
7422 signed int v13; // edi@11 | |
7423 unsigned int v14; // edi@14 | |
7424 unsigned int v16; // ecx@17 | |
7425 int v17; // [sp+18h] [bp+Ch]@3 | |
7426 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
7427 | |
7428 if ( this->uNumSceneBegins && pTexture ) | |
7429 { | |
7430 v5 = a3; | |
7431 v6 = pTexture->uTextureHeight; | |
7432 v7 = 5 * a3; | |
7433 v17 = pTexture->uTextureHeight; | |
7434 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
7435 pTexturea = pTexture->uTextureWidth; | |
7436 if ( this->bClip ) | |
7437 { | |
7438 if ( a2 < (signed int)this->uClipX ) | |
7439 { | |
7440 pTexturea += a2 - this->uClipX; | |
7441 v8 = (char *)v8 + 4 * (this->uClipX - a2); | |
7442 } | |
7443 if ( v5 < (signed int)this->uClipY ) | |
7444 { | |
7445 v17 += v5 - this->uClipY; | |
7446 v8 = (char *)v8 + 2560 * (this->uClipY - v5); | |
7447 } | |
7448 v11 = this->uClipX; | |
7449 if ( this->uClipX < a2 ) | |
7450 v11 = a2; | |
7451 if ( (signed int)(pTexturea + v11) > (signed int)this->uClipZ ) | |
7452 { | |
7453 v13 = this->uClipX; | |
7454 if ( this->uClipX < a2 ) | |
7455 v13 = a2; | |
7456 pTexturea = this->uClipZ - v13; | |
7457 } | |
7458 v14 = this->uClipY; | |
7459 if ( (signed int)this->uClipY < v5 ) | |
7460 v14 = v5; | |
7461 v6 = v17; | |
7462 if ( (signed int)(v17 + v14) > (signed int)this->uClipW ) | |
7463 { | |
7464 v16 = this->uClipY; | |
7465 if ( (signed int)this->uClipY < v5 ) | |
7466 v16 = v5; | |
7467 v6 = this->uClipW - v16; | |
7468 } | |
7469 } | |
7470 if ( v6 > 0 ) | |
7471 { | |
7472 do | |
7473 { | |
7474 if ( (signed int)pTexturea > 0 ) | |
7475 { | |
7476 memset32(v8, a5, pTexturea); | |
7477 v8 = (char *)v8 + 4 * pTexturea; | |
7478 } | |
7479 v8 = (char *)v8 + 4 * (window->GetWidth() - pTexturea); | |
7480 --v6; | |
7481 } | |
7482 while ( v6 ); | |
7483 } | |
2574 | 7484 }*/ |
2496 | 7485 } |
7486 | |
2573
0c67be4ec900
DrawTextureIndexed renamed to DrawTextureTransparentColorKey
a.parshin
parents:
2572
diff
changeset
|
7487 |
2575 | 7488 /* |
2496 | 7489 //----- (004A5EB2) -------------------------------------------------------- |
2574 | 7490 void Render::DrawTextureTransparentColorKey(signed int x, signed int y, Texture_MM7 *tex) |
2496 | 7491 { |
7492 int v5; // ebx@4 | |
7493 unsigned int v8; // edx@6 | |
7494 unsigned int v10; // edx@8 | |
7495 unsigned int v11; // edx@9 | |
7496 unsigned int v12; // esi@12 | |
7497 unsigned int v13; // esi@15 | |
7498 unsigned int v15; // esi@18 | |
7499 int v18; // [sp+10h] [bp-10h]@4 | |
7500 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7501 int v20; // [sp+1Ch] [bp-4h]@4 | |
7502 | |
7503 if ( this->uNumSceneBegins ) | |
7504 { | |
2536 | 7505 if ( tex ) |
7506 { | |
7507 if ( tex->pPalette16 ) | |
7508 { | |
7509 v5 = tex->uTextureHeight; | |
2496 | 7510 //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2570
diff
changeset
|
7511 v19 = tex->paletted_pixels; |
2536 | 7512 v20 = tex->uTextureWidth; |
7513 v18 = tex->uTextureWidth; | |
7514 | |
7515 int clipped_out_x = x; | |
7516 int clipped_out_y = y; | |
2496 | 7517 if ( this->bClip ) |
7518 { | |
2536 | 7519 if ( (signed int)x < (signed int)this->uClipX ) |
2496 | 7520 { |
2536 | 7521 v8 = this->uClipX - x; |
2496 | 7522 v19 += v8; |
2536 | 7523 v20 += x - this->uClipX; |
2496 | 7524 clipped_out_x = uClipX; |
7525 } | |
7526 | |
2536 | 7527 v5 = tex->uTextureHeight; |
7528 if ( (signed int)y < (signed int)this->uClipY ) | |
2496 | 7529 { |
2536 | 7530 v10 = this->uClipY - y; |
2496 | 7531 v19 += v18 * v10; |
2536 | 7532 v5 = y - this->uClipY + tex->uTextureHeight; |
2496 | 7533 //v4 = a4; |
7534 clipped_out_y = uClipY; | |
7535 } | |
7536 | |
7537 v11 = this->uClipX; | |
2536 | 7538 if ( (signed int)this->uClipX < (signed int)x ) |
7539 v11 = x; | |
2496 | 7540 |
7541 if ( (signed int)(v11 + v20) > (signed int)this->uClipZ ) | |
7542 { | |
7543 v12 = this->uClipX; | |
2536 | 7544 if ( (signed int)this->uClipX < (signed int)x ) |
7545 v12 = x; | |
2496 | 7546 v20 = this->uClipZ - v12; |
7547 } | |
7548 | |
7549 v13 = this->uClipY; | |
2536 | 7550 if ( (signed int)this->uClipY < (signed int)y ) |
7551 v13 = y; | |
2496 | 7552 |
7553 if ( (signed int)(v5 + v13) > (signed int)uClipW ) | |
7554 { | |
7555 v15 = this->uClipY; | |
2536 | 7556 if ( (signed int)this->uClipY < (signed int)y ) |
7557 v15 = y; | |
2496 | 7558 v5 = uClipW - v15; |
7559 } | |
7560 } | |
7561 | |
7562 for (int y = 0; y < v5; ++y) | |
7563 { | |
7564 for (int x = 0; x < v20; ++x) | |
7565 { | |
2536 | 7566 if ( tex->pPalette16[*v19] != 0x7FF )// 2047 |
7567 WritePixel16(clipped_out_x + x, clipped_out_y + y, tex->pPalette16[*v19]); | |
2496 | 7568 ++v19; |
7569 } | |
7570 v19 += v18 - v20; | |
7571 } | |
7572 } | |
7573 } | |
7574 } | |
2575 | 7575 }*/ |
2496 | 7576 |
7577 | |
7578 | |
7579 //----- (004524D8) -------------------------------------------------------- | |
7580 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
7581 { | |
7582 void *v13; // eax@13 | |
7583 int v16; // esi@14 | |
7584 int v17; // ecx@16 | |
7585 int v18; // esi@16 | |
7586 unsigned __int16 *v19; // eax@16 | |
7587 int v20; // edx@16 | |
7588 int v21; // ecx@16 | |
7589 int v22; // eax@16 | |
7590 int v23; // esi@16 | |
7591 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
7592 int v27; // [sp+28h] [bp-Ch]@14 | |
7593 int v28; // [sp+2Ch] [bp-8h]@13 | |
7594 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
7595 | |
7596 if (!uNumItems) | |
7597 return nullptr; | |
7598 | |
7599 /////////////////////////////// | |
7600 //quick search(áûñòðûé ïîèñê)// | |
7601 /////////////////////////////// | |
7602 uint idx1 = 0, | |
7603 idx2 = uNumItems; | |
7604 while (true) | |
7605 { | |
7606 uint i = idx1 + (idx2 - idx1) / 2; | |
7607 | |
7608 int res = _stricmp(pName, pSpriteNames[i]); | |
7609 if (!res) | |
7610 { | |
7611 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
7612 break; | |
7613 } | |
7614 else if (res < 0) | |
7615 idx2 = idx1 + (idx2 - idx1) / 2; | |
7616 else | |
7617 idx1 = i + 1; | |
7618 | |
7619 if ( idx1 >= idx2 ) | |
7620 return false; | |
7621 } | |
7622 | |
7623 uint uCompressedSize = 0; | |
7624 fread(&uCompressedSize, 4, 1, pFile); | |
7625 | |
7626 HWLTexture* pTex = new HWLTexture; | |
7627 fread(&pTex->uBufferWidth, 4, 1, pFile); | |
7628 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
7629 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
7630 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
7631 fread(&pTex->uWidth, 4, 1, pFile); | |
7632 fread(&pTex->uHeight, 4, 1, pFile); | |
7633 fread(&pTex->uAreaX, 4, 1, pFile); | |
7634 fread(&pTex->uAreaY, 4, 1, pFile); | |
7635 | |
7636 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
7637 if (uCompressedSize) | |
7638 { | |
7639 char* pCompressedData = new char[uCompressedSize]; | |
7640 fread(pCompressedData, 1, uCompressedSize, pFile); | |
7641 uint uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); | |
7642 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); | |
7643 delete [] pCompressedData; | |
7644 } | |
7645 else | |
7646 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
7647 | |
7648 if ( scale_hwls_to_half ) | |
7649 { | |
7650 __debugbreak();//Ritor1 | |
7651 pTex->uHeight /= 2; | |
7652 pTex->uWidth /= 2; | |
7653 v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
7654 v28 = 0; | |
7655 v26 = (unsigned __int16 *)v13; | |
7656 if ( pTex->uHeight > 0 ) | |
7657 { | |
7658 v16 = pTex->uWidth; | |
7659 v27 = 1; | |
7660 do | |
7661 { | |
7662 pDestb = 0; | |
7663 if ( v16 > 0 ) | |
7664 { | |
7665 do | |
7666 { | |
7667 v17 = v16 * v27; | |
7668 v18 = v28 * v16; | |
7669 v19 = pTex->pPixels; | |
7670 v20 = pDestb + 2 * v18; | |
7671 v21 = (int)&v19[2 * (pDestb + v17)]; | |
7672 v22 = (int)&v19[2 * v20]; | |
7673 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
7674 LOWORD(v21) = *(unsigned short *)v21; | |
7675 v23 = pDestb + v18; | |
7676 pDestb++; | |
7677 | |
7678 v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
7679 v16 = pTex->uWidth; | |
7680 } | |
7681 while (pDestb < pTex->uWidth); | |
7682 } | |
7683 ++v28; | |
7684 v27 += 2; | |
7685 } | |
7686 while ( v28 < (signed int)pTex->uHeight ); | |
7687 } | |
7688 delete [] pTex->pPixels; | |
7689 pTex->pPixels = v26; | |
7690 } | |
7691 return pTex; | |
7692 } | |
7693 //----- (0045271F) -------------------------------------------------------- | |
7694 bool RenderHWLContainer::Release() | |
7695 { | |
7696 __int32 v4; // eax@6 | |
7697 FILE *v5; // ST24_4@6 | |
7698 FILE *File; // [sp+4h] [bp-4h]@6 | |
7699 | |
7700 if ( this->bDumpDebug) | |
7701 { | |
7702 File = fopen("logd3d.txt", "w"); | |
7703 v4 = ftell(this->pFile); | |
7704 v5 = this->pFile; | |
7705 this->uDataOffset = v4; | |
7706 fwrite(&this->uNumItems, 4u, 1u, v5); | |
7707 for (uint i = 0; i < this->uNumItems; i++) | |
7708 { | |
7709 fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile); | |
7710 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*))); | |
7711 } | |
7712 fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile); | |
7713 fseek(this->pFile, 4, 0); | |
7714 fwrite(&this->uDataOffset, 4u, 1u, this->pFile); | |
7715 fclose(this->pFile); | |
7716 fclose(File); | |
7717 } | |
7718 else | |
7719 { | |
7720 fclose(this->pFile); | |
7721 for (uint i = 0; i < this->uNumItems; i++) | |
7722 { | |
7723 delete[] this->pSpriteNames[i]; | |
7724 } | |
7725 } | |
7726 return true; | |
7727 } | |
7728 | |
7729 //----- (00452347) -------------------------------------------------------- | |
7730 RenderHWLContainer::RenderHWLContainer(): | |
7731 bDumpDebug(false) | |
7732 { | |
7733 this->pFile = 0; | |
7734 uSignature = 0; | |
7735 this->uDataOffset = 0; | |
7736 memset(&this->uNumItems, 0, 0x61A84u); | |
7737 this->uNumItems = 0; | |
7738 this->scale_hwls_to_half = false; | |
7739 } | |
7740 | |
7741 //----- (0045237F) -------------------------------------------------------- | |
7742 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
7743 { | |
7744 pFile = _wfopen(pFilename, L"rb"); | |
7745 if (!pFile) | |
7746 { | |
7747 Log::Warning(L"Failed to open file: %s", pFilename); | |
7748 return false; | |
7749 } | |
7750 | |
7751 fread(&uSignature, 1, 4, pFile); | |
7752 if (uSignature != 'TD3D') | |
7753 { | |
7754 Log::Warning(L"Invalid format: %s", pFilename); | |
7755 return false; | |
7756 } | |
7757 | |
7758 fread(&uDataOffset, 4, 1, pFile); | |
7759 fseek(pFile, uDataOffset, SEEK_SET); | |
7760 fread(&uNumItems, 4, 1, pFile); | |
7761 | |
7762 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
7763 for (uint i = 0; i < uNumItems; ++i) | |
7764 { | |
7765 pSpriteNames[i] = new char[20]; | |
7766 fread(pSpriteNames[i], 1, 20, pFile); | |
7767 } | |
7768 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
7769 | |
7770 return true; | |
7771 } | |
7772 | |
7773 //----- (004A1C1E) -------------------------------------------------------- | |
7774 void Render::DoRenderBillboards_D3D() | |
7775 { | |
7776 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
7777 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
7778 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
7779 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
7780 | |
7781 /*if (pRenderer->uNumBillboardsToDraw) | |
7782 { | |
7783 auto p = &pRenderer->pBillboardRenderListD3D[0]; | |
7784 for (int i = 0; i < p->uNumVertices; ++i) | |
7785 { | |
7786 p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6; | |
7787 //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw); | |
7788 } | |
7789 p->pQuads[0].pos.x = 10; | |
7790 p->pQuads[0].pos.y = 10; | |
7791 | |
7792 p->pQuads[1].pos.x = 10; | |
7793 p->pQuads[1].pos.y = 200; | |
7794 | |
7795 p->pQuads[2].pos.x = 100; | |
7796 p->pQuads[2].pos.y = 200; | |
7797 | |
7798 p->pQuads[3].pos.x = 100; | |
7799 p->pQuads[3].pos.y = 10; | |
7800 | |
7801 if (p->uOpacity != RenderBillboardD3D::NoBlend) | |
7802 SetBillboardBlendOptions(p->uOpacity); | |
7803 | |
7804 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); | |
7805 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
7806 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7807 p->pQuads, p->uNumVertices, | |
7808 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); | |
7809 | |
7810 }*/ | |
7811 | |
7812 for (int i = uNumBillboardsToDraw - 1; i >= 0; --i) | |
7813 { | |
7814 if (pBillboardRenderListD3D[i].opacity != RenderBillboardD3D::NoBlend) | |
7815 SetBillboardBlendOptions(pBillboardRenderListD3D[i].opacity); | |
7816 | |
7817 pRenderD3D->pDevice->SetTexture(0, pBillboardRenderListD3D[i].pTexture); | |
7818 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
7819 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7820 pBillboardRenderListD3D[i].pQuads, pBillboardRenderListD3D[i].uNumVertices, | |
7821 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); | |
7822 } | |
7823 | |
7824 if (bFogEnabled) | |
7825 { | |
7826 bFogEnabled = false; | |
7827 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
7828 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
7829 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
7830 } | |
7831 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
7832 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
7833 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
7834 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
7835 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
7836 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
7837 } | |
7838 | |
7839 //----- (004A1DA8) -------------------------------------------------------- | |
7840 void Render::SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) | |
7841 { | |
7842 switch (a1) | |
7843 { | |
7844 case RenderBillboardD3D::Transparent: | |
7845 { | |
7846 if (bFogEnabled) | |
7847 { | |
7848 bFogEnabled = false; | |
7849 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
7850 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
7851 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
7852 } | |
7853 | |
7854 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
7855 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
7856 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
7857 } | |
7858 break; | |
7859 | |
7860 case RenderBillboardD3D::Opaque_1: | |
7861 case RenderBillboardD3D::Opaque_2: | |
7862 case RenderBillboardD3D::Opaque_3: | |
7863 { | |
7864 if (bUsingSpecular) | |
7865 { | |
7866 if (!bFogEnabled) | |
7867 { | |
7868 bFogEnabled = true; | |
7869 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
7870 } | |
7871 } | |
7872 | |
7873 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
7874 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
7875 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
7876 } | |
7877 break; | |
7878 | |
7879 default: | |
7880 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
7881 assert(false); | |
7882 break; | |
7883 } | |
7884 } | |
7885 //----- (00424CD7) -------------------------------------------------------- | |
7886 int ODM_NearClip(unsigned int num_vertices) | |
7887 { | |
7888 bool current_vertices_flag; // edi@1 | |
7889 bool next_vertices_flag; // [sp+Ch] [bp-24h]@6 | |
7890 double t; // st6@10 | |
7891 bool bFound; | |
7892 | |
7893 bFound = false; | |
7894 | |
7895 if (!num_vertices) | |
7896 return 0; | |
7897 for (uint i = 0; i < num_vertices; ++i)// åñòü ëè ïîãðàíè÷íûå âåðøèíû | |
7898 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7899 if ( VertexRenderList[i].vWorldViewPosition.x > 8.0 ) |
2496 | 7900 { |
7901 bFound = true; | |
7902 break; | |
7903 } | |
7904 } | |
7905 if ( !bFound ) | |
7906 return 0; | |
7907 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7908 memcpy(&VertexRenderList[num_vertices], &VertexRenderList[0], sizeof(VertexRenderList[0])); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7909 next_vertices_flag = false; |
2496 | 7910 current_vertices_flag = false; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7911 if ( VertexRenderList[0].vWorldViewPosition.x <= 8.0 ) |
2496 | 7912 current_vertices_flag = true; |
7913 //check for near clip plane(ïðîâåðêà ïî áëèæíåé ãðàíèöå) | |
7914 // | |
7915 // v3.__________________. v0 | |
7916 // | | | |
7917 // | | | |
7918 // | | | |
7919 // ----------------------- 8.0(near_clip - 8.0) | |
7920 // | | | |
7921 // .__________________. | |
7922 // v2 v1 | |
7923 | |
7924 int out_num_vertices = 0; | |
7925 for (uint i = 0; i < num_vertices; ++i) | |
7926 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7927 next_vertices_flag = VertexRenderList[i + 1].vWorldViewPosition.x <= 8.0;// |
2496 | 7928 if ( current_vertices_flag ^ next_vertices_flag ) |
7929 { | |
7930 if ( next_vertices_flag )//ñëåäóþùàÿ âåðøèíà çà áëèæíåé ãðàíèöåé | |
7931 { | |
7932 //t = near_clip - v0.x / v1.x - v0.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7933 t = (8.0 - VertexRenderList[i].vWorldViewPosition.x) / (VertexRenderList[i + 1].vWorldViewPosition.x - VertexRenderList[i].vWorldViewPosition.x); |
2496 | 7934 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7935 array_507D30[out_num_vertices].vWorldViewPosition.y = VertexRenderList[i].vWorldViewPosition.y + (VertexRenderList[i + 1].vWorldViewPosition.y - VertexRenderList[i].vWorldViewPosition.y) * t; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7936 array_507D30[out_num_vertices].vWorldViewPosition.z = VertexRenderList[i].vWorldViewPosition.z + (VertexRenderList[i + 1].vWorldViewPosition.z - VertexRenderList[i].vWorldViewPosition.z) * t; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7937 array_507D30[out_num_vertices].u = VertexRenderList[i].u + (VertexRenderList[i + 1].u - VertexRenderList[i].u) * t; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7938 array_507D30[out_num_vertices].v = VertexRenderList[i].v + (VertexRenderList[i + 1].v - VertexRenderList[i].v) * t; |
2496 | 7939 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; |
7940 } | |
7941 else// òåêóùàÿ âåðøèíà çà áëèæíåé ãðàíèöåé | |
7942 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7943 t = (8.0 - VertexRenderList[i].vWorldViewPosition.x) / (VertexRenderList[i].vWorldViewPosition.x - VertexRenderList[i + 1].vWorldViewPosition.x); |
2496 | 7944 array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7945 array_507D30[out_num_vertices].vWorldViewPosition.y = VertexRenderList[i].vWorldViewPosition.y + (VertexRenderList[i].vWorldViewPosition.y - VertexRenderList[i + 1].vWorldViewPosition.y) * t; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7946 array_507D30[out_num_vertices].vWorldViewPosition.z = VertexRenderList[i].vWorldViewPosition.z + (VertexRenderList[i].vWorldViewPosition.z - VertexRenderList[i + 1].vWorldViewPosition.z) * t; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7947 array_507D30[out_num_vertices].u = VertexRenderList[i].u + (VertexRenderList[i].u - VertexRenderList[i + 1].u) * t; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7948 array_507D30[out_num_vertices].v = VertexRenderList[i].v + (VertexRenderList[i].v - VertexRenderList[i + 1].v) * t; |
2496 | 7949 array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; |
7950 } | |
7951 //array_507D30[out_num_vertices]._rhw = 0x3E000000u; | |
7952 ++out_num_vertices; | |
7953 } | |
7954 if ( !next_vertices_flag ) | |
7955 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7956 memcpy(&array_507D30[out_num_vertices], &VertexRenderList[i + 1], sizeof(VertexRenderList[i + 1])); |
2496 | 7957 out_num_vertices++; |
7958 } | |
7959 current_vertices_flag = next_vertices_flag; | |
7960 } | |
7961 return out_num_vertices >= 3 ? out_num_vertices : 0; | |
7962 } | |
7963 | |
7964 //----- (00424EE0) -------------------------------------------------------- | |
7965 int ODM_FarClip(unsigned int uNumVertices) | |
7966 { | |
7967 bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 | |
7968 bool next_vertices_flag; // edi@1 | |
7969 double t; // st6@10 | |
7970 signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 | |
7971 bool bFound; | |
7972 //Äîï èíôî "Ïðîãðàììèðîâàíèå òð¸õìåðíûõ èãð äëÿ windows" Ëàìîò ñòð 910 | |
7973 | |
7974 bFound = false; | |
7975 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7976 memcpy(&VertexRenderList[uNumVertices], &VertexRenderList[0], sizeof(VertexRenderList[uNumVertices])); |
2496 | 7977 depth_num_vertices = 0; |
7978 current_vertices_flag = false; | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7979 if ( VertexRenderList[0].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist ) |
2496 | 7980 current_vertices_flag = true;//íàñòîÿùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè |
7981 if ( (signed int)uNumVertices <= 0 ) | |
7982 return 0; | |
7983 for (uint i = 0; i < uNumVertices; ++i)// åñòü ëè ïîãðàíè÷íûå âåðøèíû | |
7984 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
7985 if ( VertexRenderList[i].vWorldViewPosition.x < pODMRenderParams->shading_dist_mist ) |
2496 | 7986 { |
7987 bFound = true; | |
7988 break; | |
7989 } | |
7990 } | |
7991 if ( !bFound ) | |
7992 return 0; | |
7993 //check for far clip plane(ïðîâåðêà ïî äàëüíåé ãðàíèöå) | |
7994 // | |
7995 // v3.__________________. v0 | |
7996 // | | | |
7997 // | | | |
7998 // | | | |
7999 // ----------------------- 8192.0(far_clip - 0x2000) | |
8000 // | | | |
8001 // .__________________. | |
8002 // v2 v1 | |
8003 | |
8004 for ( uint i = 0; i < uNumVertices; ++i ) | |
8005 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8006 next_vertices_flag = VertexRenderList[i + 1].vWorldViewPosition.x >= pODMRenderParams->shading_dist_mist; |
2496 | 8007 if ( current_vertices_flag ^ next_vertices_flag )//îäíà èç ãðàíåé çà ãðàíèöåé âèäèìîñòè |
8008 { | |
8009 if ( next_vertices_flag )//ñëåäóþùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè(íàñòîÿùàÿ âåðøèíà ìåíüøå ãðàíèöû âèäèìîñòè) - v3 | |
8010 { | |
8011 //t = far_clip - v2.x / v3.x - v2.x (ôîðìóëà ïîëó÷åíèÿ òî÷êè ïåðåñå÷åíèÿ îòðåçêà ñ ïëîñêîñòüþ) | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8012 t = (pODMRenderParams->shading_dist_mist - VertexRenderList[i].vWorldViewPosition.x) / (VertexRenderList[i].vWorldViewPosition.x - VertexRenderList[i + 1].vWorldViewPosition.x); |
2496 | 8013 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; |
8014 //New_y = v2.y + (v3.y - v2.y)*t | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8015 array_507D30[depth_num_vertices].vWorldViewPosition.y = VertexRenderList[i].vWorldViewPosition.y + (VertexRenderList[i].vWorldViewPosition.y - VertexRenderList[i + 1].vWorldViewPosition.y) * t; |
2496 | 8016 //New_z = v2.z + (v3.z - v2.z)*t |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8017 array_507D30[depth_num_vertices].vWorldViewPosition.z = VertexRenderList[i].vWorldViewPosition.z + (VertexRenderList[i].vWorldViewPosition.z - VertexRenderList[i + 1].vWorldViewPosition.z) * t; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8018 array_507D30[depth_num_vertices].u = VertexRenderList[i].u + (VertexRenderList[i].u - VertexRenderList[i + 1].u) * t; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8019 array_507D30[depth_num_vertices].v = VertexRenderList[i].v + (VertexRenderList[i].v - VertexRenderList[i + 1].v) * t; |
2496 | 8020 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; |
8021 } | |
8022 else//íàñòîÿùàÿ âåðøèíà áîëüøå ãðàíèöû âèäèìîñòè(ñëåäóþùàÿ âåðøèíà ìåíüøå ãðàíèöû âèäèìîñòè) - v0 | |
8023 { | |
8024 //t = far_clip - v1.x / v0.x - v1.x | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8025 t = (pODMRenderParams->shading_dist_mist - VertexRenderList[i].vWorldViewPosition.x) / (VertexRenderList[i + 1].vWorldViewPosition.x - VertexRenderList[i].vWorldViewPosition.x); |
2496 | 8026 array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; |
8027 //New_y = (v0.y - v1.y)*t + v1.y | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8028 array_507D30[depth_num_vertices].vWorldViewPosition.y = VertexRenderList[i].vWorldViewPosition.y + (VertexRenderList[i + 1].vWorldViewPosition.y - VertexRenderList[i].vWorldViewPosition.y) * t; |
2496 | 8029 //New_z = (v0.z - v1.z)*t + v1.z |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8030 array_507D30[depth_num_vertices].vWorldViewPosition.z = VertexRenderList[i].vWorldViewPosition.z + (VertexRenderList[i + 1].vWorldViewPosition.z - VertexRenderList[i].vWorldViewPosition.z) * t; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8031 array_507D30[depth_num_vertices].u = VertexRenderList[i].u + (VertexRenderList[i + 1].u - VertexRenderList[i].u) * t; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8032 array_507D30[depth_num_vertices].v = VertexRenderList[i].v + (VertexRenderList[i + 1].v - VertexRenderList[i].v) * t; |
2496 | 8033 array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; |
8034 } | |
8035 ++depth_num_vertices; | |
8036 } | |
8037 if ( !next_vertices_flag )//îáà â ãðàíèöå âèäèìîñòè | |
8038 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8039 memcpy(&array_507D30[depth_num_vertices], &VertexRenderList[i + 1], sizeof(array_507D30[depth_num_vertices])); |
2496 | 8040 depth_num_vertices++; |
8041 } | |
8042 current_vertices_flag = next_vertices_flag; | |
8043 } | |
8044 return depth_num_vertices >= 3 ? depth_num_vertices : 0; | |
8045 } | |
8046 | |
8047 //----- (0047840D) -------------------------------------------------------- | |
8048 void Render::DrawBuildingsD3D() | |
8049 { | |
8050 int v9; // ecx@8 | |
2574 | 8051 Texture_MM7 *pFaceTexture; // eax@10 |
2496 | 8052 unsigned int v16; // edi@22 |
8053 int v27; // eax@57 | |
8054 // int vertex_id; // eax@58 | |
8055 unsigned int v34; // eax@80 | |
8056 int v40; // [sp-4h] [bp-5Ch]@2 | |
8057 int v49; // [sp+2Ch] [bp-2Ch]@10 | |
8058 int v50; // [sp+30h] [bp-28h]@34 | |
8059 int v51; // [sp+34h] [bp-24h]@35 | |
8060 int v52; // [sp+38h] [bp-20h]@36 | |
8061 int v53; // [sp+3Ch] [bp-1Ch]@8 | |
8062 int uNumVertices; // [sp+4Ch] [bp-Ch]@34 | |
8063 int unused; // [sp+50h] [bp-8h]@3 | |
8064 | |
8065 if ( !pRenderD3D ) | |
8066 { | |
8067 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); | |
8068 } | |
8069 | |
8070 unused = 0; | |
8071 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
8072 { | |
8073 for ( uint model_id = 0; model_id < (unsigned int)pOutdoor->uNumBModels; model_id++ ) | |
8074 { | |
8075 if ( IsBModelVisible(model_id, &unused) ) | |
8076 { | |
8077 pOutdoor->pBModels[model_id].field_40 |= 1; | |
8078 if ( pOutdoor->pBModels[model_id].uNumFaces > 0 ) | |
8079 { | |
8080 for ( int face_id = 0; face_id < pOutdoor->pBModels[model_id].uNumFaces; face_id++ ) | |
8081 { | |
8082 if (!pOutdoor->pBModels[model_id].pFaces[face_id].Invisible()) | |
8083 { | |
8084 v53 = 0; | |
8085 array_77EC08[pODMRenderParams->uNumPolygons].flags = 0; | |
8086 array_77EC08[pODMRenderParams->uNumPolygons].field_32 = 0; | |
8087 v9 = pOutdoor->pBModels[model_id].pFaces[face_id].uTextureID; | |
8088 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_TEXTURE_FRAME) | |
8089 v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed); | |
8090 pFaceTexture = pBitmaps_LOD->GetTexture(v9); | |
8091 array_77EC08[pODMRenderParams->uNumPolygons].pTexture = pFaceTexture; | |
8092 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLUID) | |
8093 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 2; | |
8094 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_INDOOR_SKY ) | |
8095 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; | |
8096 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLOW_DIAGONAL ) | |
8097 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; | |
8098 else | |
8099 { | |
8100 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLOW_VERTICAL ) | |
8101 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 8; | |
8102 } | |
8103 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLOW_HORIZONTAL) | |
8104 array_77EC08[pODMRenderParams->uNumPolygons].flags |= 0x2000; | |
8105 else | |
8106 { | |
8107 if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_DONT_CACHE_TEXTURE) | |
8108 HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 0x10; | |
8109 } | |
8110 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaU; | |
8111 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaV; | |
8112 v16 = GetTickCount() >> 4; | |
8113 if ( pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z && abs(pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >= 59082 ) | |
8114 { | |
8115 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8116 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8117 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8118 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8119 } | |
8120 else | |
8121 { | |
8122 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) | |
8123 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8124 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) | |
8125 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; | |
8126 } | |
8127 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x10 ) | |
8128 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8129 else | |
8130 { | |
8131 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x20 ) | |
8132 array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; | |
8133 } | |
8134 v50 = 0; | |
8135 v49 = 0; | |
8136 uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8137 if ( pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices > 0 ) | |
8138 { | |
8139 for ( uint vertex_id = 1; vertex_id <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; vertex_id++ ) | |
8140 { | |
8141 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; | |
8142 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; | |
8143 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; | |
8144 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); | |
8145 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); | |
8146 } | |
8147 for ( uint i = 1; i <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; i++ ) | |
8148 { | |
8149 if ( pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[0]].z == array_73D150[i - 1].vWorldPosition.z ) | |
8150 ++v53; | |
2543 | 8151 pIndoorCameraD3D->ViewTransform(&array_73D150[i - 1], 1); |
2496 | 8152 if ( array_73D150[i - 1].vWorldViewPosition.x < 8.0 || array_73D150[i - 1].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist ) |
8153 { | |
8154 if ( array_73D150[i - 1].vWorldViewPosition.x >= 8.0 ) | |
8155 v49 = 1; | |
8156 else | |
8157 v50 = 1; | |
8158 } | |
8159 else | |
2543 | 8160 pIndoorCameraD3D->Project(&array_73D150[i - 1], 1, 0); |
2496 | 8161 } |
8162 } | |
8163 if ( v53 == pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices ) | |
8164 LOBYTE(array_77EC08[pODMRenderParams->uNumPolygons].field_32) |= 1; | |
8165 array_77EC08[pODMRenderParams->uNumPolygons].pODMFace = &pOutdoor->pBModels[model_id].pFaces[face_id]; | |
8166 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; | |
8167 array_77EC08[pODMRenderParams->uNumPolygons].field_59 = 5; | |
8168 v51 = fixpoint_mul(-pOutdoor->vSunlight.x, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.x); | |
8169 v53 = fixpoint_mul(-pOutdoor->vSunlight.y, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.y); | |
8170 v52 = fixpoint_mul(-pOutdoor->vSunlight.z, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z); | |
8171 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 20 - fixpoint_mul(20, v51 + v53 + v52); | |
8172 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level < 0 ) | |
8173 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 0; | |
8174 if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level > 31 ) | |
8175 array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 31; | |
8176 if ( pODMRenderParams->uNumPolygons >= 1999 + 5000) | |
8177 return; | |
8178 if ( ODMFace::IsBackfaceNotCulled(array_73D150, &array_77EC08[pODMRenderParams->uNumPolygons]) ) | |
8179 { | |
8180 pOutdoor->pBModels[model_id].pFaces[face_id].bVisible = 1; | |
8181 array_77EC08[pODMRenderParams->uNumPolygons].uBModelFaceID = face_id; | |
8182 array_77EC08[pODMRenderParams->uNumPolygons].uBModelID = model_id; | |
8183 v27 = 8 * (face_id | (model_id << 6)); | |
8184 LOBYTE(v27) = v27 | 6; | |
8185 array_77EC08[pODMRenderParams->uNumPolygons].field_50 = v27; | |
8186 for ( int vertex_id = 0; vertex_id < pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; ++vertex_id) | |
8187 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8188 memcpy(&VertexRenderList[vertex_id], &array_73D150[vertex_id], sizeof(VertexRenderList[vertex_id])); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8189 VertexRenderList[vertex_id]._rhw = 1.0 / (array_73D150[vertex_id].vWorldViewPosition.x + 0.0000001); |
2496 | 8190 } |
8191 static stru154 static_RenderBuildingsD3D_stru_73C834; | |
8192 /*static bool __init_flag = false; | |
8193 if (!__init_flag) | |
8194 { | |
8195 __init_flag = true; | |
8196 static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u; | |
8197 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834); | |
8198 atexit(loc_4789D4); | |
8199 }*/ | |
8200 | |
8201 v40 = (int)&pOutdoor->pBModels[model_id].pFaces[face_id]; | |
2541 | 8202 pEngine->pLightmapBuilder->ApplyLights_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); |
2496 | 8203 pDecalBuilder->ApplyDecals_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8204 pEngine->pLightmapBuilder->StationaryLightsCount = 0; |
2496 | 8205 int v31 = 0; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8206 if ( Lights.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) |
2496 | 8207 { |
8208 v31 = v50 ? 3 : v49 != 0 ? 5 : 0; | |
8209 static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(&pOutdoor->pBModels[model_id].pFaces[face_id], &pOutdoor->pBModels[model_id].pVertices); | |
8210 if ( pDecalBuilder->uNumDecals > 0 ) | |
8211 { | |
8212 v40 = -1; | |
8213 pDecalBuilder->ApplyDecals(31 - array_77EC08[pODMRenderParams->uNumPolygons].dimming_level, 2, &static_RenderBuildingsD3D_stru_73C834, | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8214 pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices, VertexRenderList, 0, (char)v31, -1); |
2496 | 8215 } |
8216 } | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8217 if ( Lights.uNumLightsApplied > 0 ) |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8218 pEngine->pLightmapBuilder->ApplyLights(&Lights, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, VertexRenderList, 0, (char)v31); |
2496 | 8219 if ( v50 ) |
8220 { | |
8221 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_NearClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); | |
8222 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; | |
8223 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8224 } | |
8225 if ( v49 ) | |
8226 { | |
8227 array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_FarClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); | |
8228 uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; | |
8229 ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); | |
8230 } | |
8231 if ( uNumVertices ) | |
8232 { | |
8233 if ( array_77EC08[pODMRenderParams->uNumPolygons].flags & 2 ) | |
8234 { | |
8235 if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x3C ) | |
8236 v34 = pRenderer->pHDWaterBitmapIDs[0]; | |
8237 else | |
8238 v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
8239 v40 = (int)pBitmaps_LOD->pHardwareTextures[v34]; | |
8240 } | |
8241 else | |
8242 v40 = (int)pBitmaps_LOD->pHardwareTextures[v9]; | |
8243 pRenderer->DrawPolygon(uNumVertices, &array_77EC08[pODMRenderParams->uNumPolygons], &pOutdoor->pBModels[model_id].pFaces[face_id], (IDirect3DTexture2 *)v40); | |
8244 } | |
8245 } | |
8246 } | |
8247 } | |
8248 } | |
8249 } | |
8250 } | |
8251 } | |
8252 return; | |
8253 } | |
8254 //----- (00479543) -------------------------------------------------------- | |
8255 void Render::DrawOutdoorSkyD3D() | |
8256 { | |
8257 int v9; // eax@4 | |
8258 int v10; // ebx@4 | |
8259 int v13; // edi@6 | |
8260 int v14; // ecx@6 | |
8261 int v15; // eax@8 | |
8262 int v16; // eax@12 | |
8263 signed __int64 v17; // qtt@13 | |
8264 signed int v18; // ecx@13 | |
8265 struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1 | |
8266 int v30; // [sp+134h] [bp-30h]@1 | |
8267 int v32; // [sp+13Ch] [bp-28h]@6 | |
8268 int v33; // [sp+140h] [bp-24h]@2 | |
8269 signed __int64 v34; // [sp+144h] [bp-20h]@1 | |
8270 int v35; // [sp+148h] [bp-1Ch]@4 | |
8271 int v36; // [sp+14Ch] [bp-18h]@2 | |
8272 int v37; // [sp+154h] [bp-10h]@8 | |
8273 int v38; // [sp+158h] [bp-Ch]@1 | |
8274 int v39; // [sp+15Ch] [bp-8h]@4 | |
8275 | |
2543 | 8276 v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pIndoorCameraD3D->vPartyPos.z) |
2496 | 8277 / ((double)pODMRenderParams->int_fov_rad + 8192.0) |
8278 + (double)(pViewport->uScreenCenterY)); | |
2543 | 8279 v34 = cos((double)pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;//(double)pODMRenderParams->shading_dist_mist, 8192 |
2496 | 8280 v38 = (signed __int64)((double)(pViewport->uScreenCenterY) |
8281 - (double)pODMRenderParams->int_fov_rad | |
8282 / (v34 + 0.0000001) | |
2543 | 8283 * (sin((double)pIndoorCameraD3D->sRotationX * 0.0030664064) |
2496 | 8284 * (double)-0x2000//(double)pODMRenderParams->shading_dist_mist |
2543 | 8285 - (double)pIndoorCameraD3D->vPartyPos.z)); |
2496 | 8286 pSkyPolygon.Create_48607B(&stru_8019C8);//çàïîëíÿåòñÿ ptr_38 |
8287 pSkyPolygon.ptr_38->_48694B_frustum_sky(); | |
2534 | 8288 |
8289 //if ( pParty->uCurrentHour > 20 || pParty->uCurrentHour < 5 ) | |
8290 //pSkyPolygon.uTileBitmapID = pOutdoor->New_SKY_NIGHT_ID; | |
8291 //else | |
8292 pSkyPolygon.uTileBitmapID = pOutdoor->sSky_TextureID;//179(original 166) | |
2574 | 8293 pSkyPolygon.pTexture = (Texture_MM7 *)(pSkyPolygon.uTileBitmapID != -1 ? (int)&pBitmaps_LOD->pTextures[pSkyPolygon.uTileBitmapID] : 0); |
2496 | 8294 if ( pSkyPolygon.pTexture ) |
8295 { | |
8296 pSkyPolygon.dimming_level = 0; | |
8297 pSkyPolygon.uNumVertices = 4; | |
8298 //centering(öåíòðóåì)----------------------------------------------------------------- | |
2543 | 8299 pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pIndoorCameraD3D->sRotationX + 16); |
2496 | 8300 pSkyPolygon.v_18.y = 0; |
2543 | 8301 pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pIndoorCameraD3D->sRotationX + 16); |
2496 | 8302 |
8303 //sky wiew position(ïîëîæåíèå íåáà íà ýêðàíå)------------------------------------------ | |
8304 // X | |
8305 // 0._____________________________.3 | |
8306 // |8,8 468,8 | | |
8307 // | | | |
8308 // | | | |
8309 // Y| | | |
8310 // | | | |
8311 // |8,351 468,351 | | |
8312 // 1._____________________________.2 | |
8313 // | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8314 VertexRenderList[0].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8315 VertexRenderList[0].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8316 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8317 VertexRenderList[1].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;//8 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8318 VertexRenderList[1].vWorldViewProjY = (double)v38;//247 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8319 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8320 VertexRenderList[2].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8321 VertexRenderList[2].vWorldViewProjY = (double)v38;//247 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8322 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8323 VertexRenderList[3].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;//468 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8324 VertexRenderList[3].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;//8 |
2496 | 8325 |
8326 pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
8327 pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;//7168 | |
8328 | |
2535 | 8329 pSkyPolygon.field_24 = 0x2000000;//maybe attributes |
2496 | 8330 v33 = 65536 / (signed int)(signed __int64)(((double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2) / tan(0.6457717418670654) + 0.5); |
8331 for ( uint i = 0; i < pSkyPolygon.uNumVertices; ++i ) | |
8332 { | |
8333 //rotate skydome(âðàùåíèå êóïîëà íåáà)-------------------------------------- | |
8334 //  èãðå ïðèíÿòà ñâîÿ ñèñòåìà èçìåðåíèÿ óãëîâ. Ïîëíûé óãîë (180). Çíà÷åíèþ óãëà 0 ñîîòâåòñòâóåò | |
8335 // íàïðàâëåíèå íà ñåâåð è/èëè þã (ëèáî íà âîñòîê è/èëè çàïàä), çíà÷åíèþ 65536 åäåíèöàì(0õ10000) ñîîòâåòñòâóåò óãîë 90. | |
8336 // äâå ïåðåìåííûå õðàíÿò äàííûå ïî óãëó îáçîðà. field_14 ïî çàïàäó è âîñòîêó. field_20 ïî þãó è ñåâåðó | |
8337 // îò -25080 äî 25080 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8338 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v33 * (v30 - floor(VertexRenderList[i].vWorldViewProjY + 0.5))); |
2496 | 8339 v35 = v39 + pSkyPolygon.ptr_38->angle_from_north; |
8340 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8341 v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v33 * (v30 - floor(VertexRenderList[i].vWorldViewProjY + 0.f))); |
2496 | 8342 v36 = v39 + pSkyPolygon.ptr_38->angle_from_east; |
8343 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8344 v9 = fixpoint_mul(pSkyPolygon.v_18.z, v33 * (v30 - floor(VertexRenderList[i].vWorldViewProjY + 0.5))); |
2496 | 8345 v10 = pSkyPolygon.v_18.x + v9; |
8346 if ( v10 > 0 ) | |
8347 v10 = 0; | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8348 v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)VertexRenderList[i].vWorldViewProjX); |
2496 | 8349 v34 = -pSkyPolygon.field_24; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8350 v32 = (signed __int64)VertexRenderList[i].vWorldViewProjY - 1.0; |
2496 | 8351 v14 = v33 * (v30 - v32); |
8352 while ( 1 ) | |
8353 { | |
8354 if ( v10 ) | |
8355 { | |
8356 v37 = abs((int)v34 >> 14); | |
8357 v15 = abs(v10); | |
8358 if ( v37 <= v15 || v32 <= (signed int)pViewport->uViewportTL_Y ) | |
8359 { | |
8360 if ( v10 <= 0 ) | |
8361 break; | |
8362 } | |
8363 } | |
8364 v16 = fixpoint_mul(pSkyPolygon.v_18.z, v14); | |
8365 --v32; | |
8366 v14 += v33; | |
8367 v10 = pSkyPolygon.v_18.x + v16; | |
8368 } | |
8369 LODWORD(v17) = LODWORD(v34) << 16; | |
8370 HIDWORD(v17) = v34 >> 16; | |
8371 v18 = v17 / v10; | |
8372 if ( v18 < 0 ) | |
8373 v18 = pODMRenderParams->shading_dist_mist; | |
8374 v37 = v35 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v13); | |
8375 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v37, v18) >> 3); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8376 VertexRenderList[i].u = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureWidth * 65536.0); |
2496 | 8377 |
8378 v36 = v36 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v13); | |
8379 v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v36, v18) >> 3); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8380 VertexRenderList[i].v = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureHeight * 65536.0); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8381 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8382 VertexRenderList[i].vWorldViewPosition.x = (double)0x2000;//pODMRenderParams->shading_dist_mist 8192 |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8383 VertexRenderList[i]._rhw = 1.0 / (double)(v18 >> 16); |
2496 | 8384 } |
8385 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8386 VertexRenderList[0].vWorldViewProjY = (double)v10; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8387 VertexRenderList[1].vWorldViewProjY = VertexRenderList[1].vWorldViewProjY + 30.0; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8388 VertexRenderList[2].vWorldViewProjY = VertexRenderList[2].vWorldViewProjY + 30.0; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2561
diff
changeset
|
8389 VertexRenderList[3].vWorldViewProjY = (double)v10; |
2496 | 8390 pRenderer->DrawOutdoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
8391 return; | |
8392 } | |
8393 } | |
8394 //----- (004226C2) -------------------------------------------------------- | |
8395 bool PauseGameDrawing() | |
8396 { | |
2541 | 8397 if ( current_screen_type != SCREEN_GAME |
8398 && current_screen_type != SCREEN_NPC_DIALOGUE | |
8399 && current_screen_type != SCREEN_CHANGE_LOCATION ) | |
8400 { | |
8401 if (current_screen_type == SCREEN_INPUT_BLV) | |
2496 | 8402 return pMovie_Track;//pSmackerMovie != 0; |
2541 | 8403 if ( current_screen_type != SCREEN_BRANCHLESS_NPC_DIALOG ) |
2496 | 8404 return true; |
8405 } | |
8406 return false; | |
8407 } | |
8408 | |
8409 | |
8410 //----- (0045E03A) -------------------------------------------------------- | |
8411 unsigned short *Render::MakeScreenshot(signed int width, signed int height) | |
8412 { | |
8413 unsigned __int16 *for_pixels; // ebx@1 | |
8414 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 | |
8415 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 | |
8416 float interval_x; // [sp+84h] [bp-20h]@1 | |
8417 float interval_y; // [sp+8Ch] [bp-18h]@1 | |
8418 | |
8419 interval_x = game_viewport_width / (double)width; | |
8420 interval_y = game_viewport_height / (double)height; | |
8421 | |
8422 pPixels = (unsigned __int16 *)malloc(2 * height * width); | |
8423 memset(pPixels, 0 , 2 * height * width); | |
8424 | |
8425 for_pixels = pPixels; | |
8426 | |
8427 BeginSceneD3D(); | |
8428 | |
8429 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
8430 pIndoor->Draw(); | |
8431 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
8432 pOutdoor->Draw(); | |
8433 DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
8434 memset(&Dst, 0, sizeof(Dst)); | |
8435 Dst.dwSize = sizeof(Dst); | |
8436 | |
8437 if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) ) | |
8438 { | |
8439 if (uCurrentlyLoadedLevelType == LEVEL_null) | |
8440 memset(&for_pixels, 0, sizeof(for_pixels)); | |
8441 else | |
8442 { | |
8443 for (uint y = 0; y < (unsigned int)height; ++y) | |
8444 { | |
8445 for (uint x = 0; x < (unsigned int)width; ++x) | |
8446 { | |
8447 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) | |
8448 { | |
8449 unsigned __int32 *p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * (Dst.lPitch >> 2); | |
8450 *for_pixels = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | |
8451 } | |
8452 else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) | |
8453 { | |
8454 unsigned __int16 * p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch; | |
8455 *for_pixels = *p; | |
8456 } | |
8457 else | |
8458 assert(false); | |
8459 ++for_pixels; | |
8460 } | |
8461 } | |
8462 } | |
8463 ErrD3D(pBackBuffer4->Unlock(NULL)); | |
8464 } | |
8465 return pPixels; | |
8466 } | |
8467 //----- (0045E26C) -------------------------------------------------------- | |
8468 void Render::SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height) | |
8469 { | |
8470 auto pixels = MakeScreenshot(width, height); | |
8471 SavePCXImage(pFilename, pixels, width, height); | |
8472 free(pixels); | |
8473 } | |
8474 | |
8475 void Render::PackScreenshot(unsigned int width, unsigned int height, void *data, unsigned int data_size, unsigned int *out_screenshot_size) | |
8476 { | |
8477 auto pixels = MakeScreenshot(150, 112); | |
8478 PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size); | |
8479 free(pixels); | |
8480 } | |
8481 | |
8482 | |
8483 //----- (0046A7C8) -------------------------------------------------------- | |
8484 int Render::_46À6ÀÑ_GetActorsInViewport(int pDepth) | |
8485 { | |
8486 unsigned int v3; // eax@2 ïðèìåíÿåòñÿ â çàêëå Æàð ïå÷è äëÿ ïîäñ÷¸òà êîë-âà ìîíñòðîâ âèäèìûõ ãðóïïå è çàïîëíåíèÿ ìàññèâà id âèäèìûõ ìîíñòðîâ | |
8487 unsigned int v5; // eax@2 | |
8488 unsigned int v6; // eax@4 | |
8489 unsigned int v12; // [sp+10h] [bp-14h]@1 | |
8490 int mon_num; // [sp+1Ch] [bp-8h]@1 | |
8491 unsigned int a1a; // [sp+20h] [bp-4h]@1 | |
8492 | |
8493 mon_num = 0; | |
8494 v12 = GetBillboardDrawListSize(); | |
8495 if ( (signed int)GetBillboardDrawListSize() > 0 ) | |
8496 { | |
8497 for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a ) | |
8498 { | |
8499 v3 = GetParentBillboardID(a1a); | |
8500 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; | |
8501 if ( PID_TYPE(v5) == OBJECT_Actor) | |
8502 { | |
8503 if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(pDepth << 16) ) | |
8504 { | |
8505 v6 = PID_ID(v5); | |
2535 | 8506 if ( pActors[v6].uAIState != Dead |
8507 && pActors[v6].uAIState != Dying | |
8508 && pActors[v6].uAIState != Removed | |
8509 && pActors[v6].uAIState != Disabled | |
8510 && pActors[v6].uAIState != Summoned ) | |
2496 | 8511 { |
2541 | 8512 if ( pEngine->pVisInstance->DoesRayIntersectBillboard((double)pDepth, a1a) ) |
2496 | 8513 { |
8514 if ( mon_num < 100 ) | |
8515 { | |
8516 _50BF30_actors_in_viewport_ids[mon_num] = v6; | |
8517 mon_num++; | |
8518 } | |
8519 } | |
8520 } | |
8521 } | |
8522 } | |
8523 } | |
8524 } | |
8525 return mon_num; | |
8526 } | |
8527 | |
8528 | |
8529 | |
8530 | |
8531 void Render::BeginLightmaps() | |
8532 { | |
8533 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
8534 | |
8535 if (bUsingSpecular) | |
8536 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE); | |
8537 | |
8538 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8539 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
2543 | 8540 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); |
2496 | 8541 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
8542 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8543 } | |
8544 | |
8545 void Render::EndLightmaps() | |
8546 { | |
8547 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8548 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8549 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8550 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
8551 | |
8552 if (bUsingSpecular) | |
8553 { | |
8554 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8555 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor)); | |
8556 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
8557 } | |
8558 } | |
8559 | |
8560 | |
8561 void Render::BeginLightmaps2() | |
8562 { | |
8563 if (bUsingSpecular) | |
8564 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
8565 | |
8566 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
8567 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8568 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8569 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
2543 | 8570 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); |
2496 | 8571 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
8572 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8573 } | |
8574 | |
8575 | |
8576 void Render::EndLightmaps2() | |
8577 { | |
8578 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8579 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8580 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8581 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
8582 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8583 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
8584 | |
8585 if (bUsingSpecular) | |
8586 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8587 } | |
8588 | |
8589 //----- (00437C96) -------------------------------------------------------- | |
8590 void Render::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff) | |
8591 { | |
2570 | 8592 RenderVertexD3D3 vertices[2]; // [sp+8h] [bp-40h]@2 |
8593 | |
8594 memcpy(&vertices[0], pLineBegin, sizeof(vertices[0])); | |
8595 memcpy(&vertices[1], pLineEnd, sizeof(vertices[1])); | |
8596 | |
8597 vertices[0].pos.z = 0.001 - z_stuff; | |
8598 vertices[1].pos.z = 0.001 - z_stuff; | |
8599 | |
8600 vertices[0].diffuse = sDiffuseBegin; | |
8601 vertices[1].diffuse = sDiffuseEnd; | |
8602 | |
8603 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
8604 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST, 452, vertices, 2, D3DDP_DONOTLIGHT)); | |
2496 | 8605 } |
8606 | |
8607 | |
8608 void Render::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
8609 { | |
8610 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
8611 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST, | |
8612 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8613 (void *)vertices, | |
8614 num_vertices, | |
8615 D3DDP_DONOTLIGHT)); | |
8616 } | |
8617 | |
8618 | |
8619 void Render::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices) | |
8620 { | |
8621 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
8622 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false)); | |
8623 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8624 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
8625 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
8626 | |
8627 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
8628 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
8629 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8630 (void *)vertices, | |
8631 num_vertices, | |
8632 28)); | |
8633 | |
8634 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8635 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8636 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8637 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE)); | |
8638 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8639 } | |
8640 | |
8641 | |
8642 void Render::BeginDecals() | |
8643 { | |
8644 // code chunk from 0049C304 | |
8645 if (bUsingSpecular) | |
8646 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
8647 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); | |
8648 | |
8649 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8650 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8651 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
8652 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8653 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8654 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
8655 | |
2543 | 8656 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04"))); |
2496 | 8657 } |
8658 | |
8659 | |
8660 void Render::EndDecals() | |
8661 { | |
8662 // code chunk from 0049C304 | |
8663 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
8664 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8665 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8666 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8667 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8668 | |
8669 if (bUsingSpecular) | |
8670 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); | |
8671 } | |
8672 | |
8673 | |
8674 | |
8675 //----- (0049C095) -------------------------------------------------------- | |
8676 void Render::DrawDecal(Decal *pDecal, float z_bias) | |
8677 { | |
2532 | 8678 signed int dwFlags; // [sp+Ch] [bp-864h]@15 |
2496 | 8679 RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6 |
8680 | |
8681 if (pDecal->uNumVertices < 3) | |
8682 { | |
8683 Log::Warning(L"Decal has < 3 vertices"); | |
8684 return; | |
8685 } | |
8686 | |
8687 float color_mult; | |
8688 if ( pDecal->field_C1C & 1 ) | |
8689 color_mult = 1.0; | |
8690 else | |
8691 color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time(); | |
8692 | |
8693 for (uint i = 0; i < (unsigned int)pDecal->uNumVertices; ++i) | |
8694 { | |
8695 uint uTint = Render::GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr); | |
8696 | |
8697 uint uTintR = (uTint >> 16) & 0xFF, | |
8698 uTintG = (uTint >> 8) & 0xFF, | |
8699 uTintB = uTint & 0xFF; | |
8700 | |
8701 uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF, | |
8702 uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF, | |
8703 uDecalColorMultB = pDecal->uColorMultiplier & 0xFF; | |
8704 | |
8705 uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f), | |
8706 uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f), | |
8707 uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f); | |
8708 | |
8709 float v15; | |
8710 if (fabs(z_bias) < 1e-5) | |
2543 | 8711 v15 = 1.0 - 1.0 / ((1.0f / pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0); |
2532 | 8712 else |
8713 { | |
2543 | 8714 v15 = 1.0 - 1.0 / ((1.0f / pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias; |
2496 | 8715 if (v15 < 0.000099999997) |
8716 v15 = 0.000099999997; | |
2532 | 8717 } |
2496 | 8718 |
8719 pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX; | |
8720 pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY; | |
2532 | 8721 pVerticesD3D[i].pos.z = v15; |
8722 | |
8723 pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x; | |
8724 pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB; | |
8725 pVerticesD3D[i].specular = 0; | |
8726 | |
2496 | 8727 pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u; |
8728 pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v; | |
8729 } | |
8730 | |
8731 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
2532 | 8732 dwFlags = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS; |
2496 | 8733 else |
2532 | 8734 dwFlags = D3DDP_DONOTLIGHT; |
2496 | 8735 |
8736 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
8737 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
2532 | 8738 pVerticesD3D, pDecal->uNumVertices, dwFlags)); |
2496 | 8739 } |
8740 | |
8741 | |
8742 void Render::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture) | |
8743 { | |
8744 ErrD3D(pRenderD3D->pDevice->SetTexture(0, texture)); | |
8745 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
8746 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
8747 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8748 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8749 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8750 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
8751 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
8752 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
8753 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8754 (void *)vertices, 4, 28)); | |
8755 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8756 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8757 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
8758 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8759 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
8760 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
8761 } | |
8762 | |
8763 //----- (00452442) -------------------------------------------------------- | |
8764 unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4) | |
8765 { | |
8766 int v4; // ebx@0 | |
8767 __int16 v5; // ST14_2@1 | |
8768 __int16 v6; // dx@1 | |
8769 int v7; // ecx@1 | |
8770 __int16 v8; // ST10_2@1 | |
8771 int v9; // edi@1 | |
8772 unsigned __int16 v10; // dh@1@1 | |
8773 int v11; // ebx@1 | |
8774 int v12; // ebx@1 | |
8775 __int16 a3a; // [sp+1Ch] [bp+8h]@1 | |
8776 | |
8777 v5 = a2 >> 2; | |
8778 v6 = (unsigned __int16)a4 >> 2; | |
8779 v8 = a1 >> 2; | |
8780 a3a = (unsigned __int16)a3 >> 2; | |
8781 LOWORD(v7) = a3a; | |
8782 v9 = v7; | |
8783 LOWORD(v4) = ((unsigned __int16)a4 >> 2) & 0xE0; | |
8784 LOWORD(v7) = a3a & 0xE0; | |
8785 LOWORD(v9) = v9 & 0x1C00; | |
8786 v11 = v7 + v4; | |
8787 LOWORD(v7) = v5 & 0xE0; | |
8788 v12 = v7 + v11; | |
8789 LOWORD(v7) = v8 & 0xE0; | |
8790 __debugbreak(); // warning C4700: uninitialized local variable 'v10' used | |
8791 return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) | (v7 + v12) | ((v8 & 0x1C00) | |
8792 + (v5 & 0x1C00) | |
8793 + v9 | |
8794 + (__PAIR__(v10, (unsigned __int16)a4 >> 2) & 0x1C00)); | |
8795 } | |
8796 | |
8797 //----- (0047C4FC) -------------------------------------------------------- | |
8798 int __fastcall GetActorTintColor(int max_dimm, int min_dimm, float distance, int a4, RenderBillboard *a5) | |
8799 { | |
8800 signed int v6; // edx@1 | |
8801 int v8; // eax@3 | |
8802 double v9; // st7@12 | |
8803 int v11; // ecx@28 | |
8804 double v15; // st7@44 | |
8805 int v18; // ST14_4@44 | |
8806 signed int v20; // [sp+10h] [bp-4h]@10 | |
8807 float a3c; // [sp+1Ch] [bp+8h]@44 | |
8808 int a5a; // [sp+24h] [bp+10h]@44 | |
8809 | |
8810 //v5 = a2; | |
8811 v6 = 0; | |
8812 | |
8813 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
8814 return 8 * (31 - max_dimm) | ((8 * (31 - max_dimm) | ((31 - max_dimm) << 11)) << 8); | |
8815 | |
8816 if (pParty->armageddon_timer) | |
8817 return 0xFFFF0000; | |
8818 | |
8819 v8 = pWeather->bNight; | |
8820 if (bUnderwater) | |
8821 v8 = 0; | |
8822 if (v8) | |
8823 { | |
8824 v20 = 1; | |
8825 if ((signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0) | |
8826 v20 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower; | |
8827 v9 = (double)v20 * 1024.0; | |
8828 if (a4) | |
8829 { | |
8830 v6 = 216; | |
8831 goto LABEL_20; | |
8832 } | |
8833 if (distance <= v9) | |
8834 { | |
8835 if (distance > 0.0) | |
8836 { | |
8837 //a4b = distance * 216.0 / v9; | |
8838 //v10 = a4b + 6.7553994e15; | |
8839 //v6 = LODWORD(v10); | |
8840 v6 = floorf(0.5f + distance * 216.0 / v9); | |
8841 if (v6 > 216) | |
8842 { | |
8843 v6 = 216; | |
8844 goto LABEL_20; | |
8845 } | |
8846 } | |
8847 } | |
8848 else | |
8849 { | |
8850 v6 = 216; | |
8851 } | |
8852 if (distance != 0.0) | |
8853 { | |
8854 LABEL_20: | |
8855 if (a5) | |
8856 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3); | |
8857 if (v6 > 216) | |
8858 v6 = 216; | |
8859 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8); | |
8860 } | |
8861 //LABEL_19: | |
8862 v6 = 216; | |
8863 goto LABEL_20; | |
8864 } | |
8865 | |
8866 | |
8867 | |
8868 if (fabsf(distance) < 1.0e-6f) | |
8869 return 0xFFF8F8F8; | |
8870 | |
8871 // dim in measured in 8-steps | |
8872 v11 = 8 * (max_dimm - min_dimm); | |
8873 //v12 = v11; | |
8874 if (v11 >= 0) | |
8875 { | |
8876 if (v11 > 216) | |
8877 v11 = 216; | |
8878 } | |
8879 else | |
8880 v11 = 0; | |
8881 | |
8882 float fog_density_mult = 216.0f; | |
8883 if (a4) | |
8884 fog_density_mult += distance / (double)pODMRenderParams->shading_dist_shade * 32.0; | |
8885 | |
8886 v6 = v11 + floorf(pOutdoor->fFogDensity * fog_density_mult + 0.5f); | |
8887 /*if ( a4 ) | |
8888 { | |
8889 //a3b = pOutdoor->fFogDensity * 216.0; | |
8890 //v14 = a3b + 6.7553994e15; | |
8891 //a4a = floorf(a3b + 0.5f);//LODWORD(v14); | |
8892 } | |
8893 else | |
8894 { | |
8895 //a3a = (distance / (double)pODMRenderParams->shading_dist_shade * 32.0 + 216.0) * pOutdoor->fFogDensity; | |
8896 //v13 = a3a + 6.7553994e15; | |
8897 //a4a = floorf(a3a + 0.5f);//LODWORD(v13); | |
8898 } | |
8899 v6 = a4a + v11;*/ | |
8900 if (a5) | |
8901 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3); | |
8902 if (v6 > 216) | |
8903 v6 = 216; | |
8904 if (v6 < v11) | |
8905 v6 = v11; | |
8906 if (v6 > 8 * pOutdoor->max_terrain_dimming_level) | |
8907 v6 = 8 * pOutdoor->max_terrain_dimming_level; | |
8908 if (!bUnderwater) | |
8909 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8); | |
8910 else | |
8911 { | |
8912 v15 = (double)(255 - v6) * 0.0039215689; | |
8913 a3c = v15; | |
8914 //a4c = v15 * 16.0; | |
8915 //v16 = a4c + 6.7553994e15; | |
8916 a5a = floorf(v15 * 16.0 + 0.5f);//LODWORD(v16); | |
8917 //a4d = a3c * 194.0; | |
8918 //v17 = a4d + 6.7553994e15; | |
8919 v18 = floorf(a3c * 194.0 + 0.5f);//LODWORD(v17); | |
8920 //a3d = a3c * 153.0; | |
8921 //v19 = a3d + 6.7553994e15; | |
8922 return (int)floorf(a3c * 153.0 + 0.5f)/*LODWORD(v19)*/ | ((v18 | (a5a << 8)) << 8); | |
8923 } | |
8924 } | |
8925 // 6BE3C4: using guessed type char bUnderwater; | |
8926 | |
8927 //----- (0043F55F) -------------------------------------------------------- | |
8928 int __fastcall _43F55F_get_billboard_light_level(RenderBillboard *a1, int uBaseLightLevel) | |
8929 { | |
8930 signed int v3; // ecx@2 | |
8931 | |
8932 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
8933 v3 = pIndoor->pSectors[a1->uIndoorSectorID].uMinAmbientLightLevel; | |
8934 else | |
8935 { | |
8936 if (uBaseLightLevel == -1) | |
8937 v3 = a1->dimming_level; | |
8938 else | |
8939 v3 = uBaseLightLevel; | |
8940 } | |
8941 return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->world_x, a1->world_y, a1->world_z); | |
8942 } | |
8943 | |
8944 //----- (0043F5C8) -------------------------------------------------------- | |
8945 int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z) | |
8946 { | |
8947 signed int v6; // edi@1 | |
8948 int v8; // eax@6 | |
8949 int v9; // ebx@6 | |
8950 unsigned int v10; // ecx@6 | |
8951 unsigned int v11; // edx@9 | |
8952 unsigned int v12; // edx@11 | |
8953 signed int v13; // ecx@12 | |
8954 BLVLightMM7 *v16; // esi@20 | |
8955 int v17; // ebx@21 | |
8956 signed int v24; // ecx@30 | |
8957 int v26; // ebx@35 | |
8958 int v37; // [sp+Ch] [bp-18h]@37 | |
8959 int v39; // [sp+10h] [bp-14h]@23 | |
8960 int v40; // [sp+10h] [bp-14h]@36 | |
8961 int v42; // [sp+14h] [bp-10h]@22 | |
8962 unsigned int v43; // [sp+18h] [bp-Ch]@12 | |
8963 unsigned int v44; // [sp+18h] [bp-Ch]@30 | |
8964 unsigned int v45; // [sp+18h] [bp-Ch]@44 | |
8965 | |
8966 v6 = uBaseLightLevel; | |
8967 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) | |
8968 { | |
8969 MobileLight* p = &pMobileLightsStack->pLights[i]; | |
8970 | |
8971 float distX = abs(p->vPosition.x - x); | |
8972 if (distX <= p->uRadius) | |
8973 { | |
8974 float distY = abs(p->vPosition.y - y); | |
8975 if (distY <= p->uRadius) | |
8976 { | |
8977 float distZ = abs(p->vPosition.z - z); | |
8978 if (distZ <= p->uRadius) | |
8979 { | |
8980 v8 = distX; | |
8981 v9 = distY; | |
8982 v10 = distZ; | |
8983 if (distX < distY) | |
8984 { | |
8985 v8 = distY; | |
8986 v9 = distX; | |
8987 } | |
8988 if (v8 < distZ) | |
8989 { | |
8990 v11 = v8; | |
8991 v8 = distZ; | |
8992 v10 = v11; | |
8993 } | |
8994 if (v9 < (signed int)v10) | |
8995 { | |
8996 v12 = v10; | |
8997 v10 = v9; | |
8998 v9 = v12; | |
8999 } | |
9000 v43 = ((unsigned int)(11 * v9) / 32) + (v10 / 4) + v8; | |
9001 v13 = p->uRadius; | |
9002 if ((signed int)v43 < v13) | |
9003 v6 += ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30; | |
9004 } | |
9005 } | |
9006 } | |
9007 } | |
9008 | |
9009 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
9010 { | |
9011 BLVSector* pSector = &pIndoor->pSectors[uSectorID]; | |
9012 | |
9013 for (uint i = 0; i < pSector->uNumLights; ++i) | |
9014 { | |
9015 v16 = pIndoor->pLights + pSector->pLights[i]; | |
9016 if (~v16->uAtributes & 8) | |
9017 { | |
9018 v17 = abs(v16->vPosition.x - x); | |
9019 if (v17 <= v16->uRadius) | |
9020 { | |
9021 v42 = abs(v16->vPosition.y - y); | |
9022 if (v42 <= v16->uRadius) | |
9023 { | |
9024 v39 = abs(v16->vPosition.z - z); | |
9025 if (v39 <= v16->uRadius) | |
9026 { | |
9027 v44 = int_get_vector_length(v17, v42, v39); | |
9028 v24 = v16->uRadius; | |
9029 if ((signed int)v44 < v24) | |
9030 v6 += ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30; | |
9031 } | |
9032 } | |
9033 } | |
9034 } | |
9035 } | |
9036 } | |
9037 | |
9038 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) | |
9039 { | |
9040 //StationaryLight* p = &pStationaryLightsStack->pLights[i]; | |
9041 v26 = abs(pStationaryLightsStack->pLights[i].vPosition.x - x); | |
9042 if (v26 <= pStationaryLightsStack->pLights[i].uRadius) | |
9043 { | |
9044 v40 = abs(pStationaryLightsStack->pLights[i].vPosition.y - y); | |
9045 if (v40 <= pStationaryLightsStack->pLights[i].uRadius) | |
9046 { | |
9047 v37 = abs(pStationaryLightsStack->pLights[i].vPosition.z - z); | |
9048 if (v37 <= pStationaryLightsStack->pLights[i].uRadius) | |
9049 { | |
9050 v45 = int_get_vector_length(v26, v40, v37); | |
9051 //v33 = pStationaryLightsStack->pLights[i].uRadius; | |
9052 if ((signed int)v45 < pStationaryLightsStack->pLights[i].uRadius) | |
9053 v6 += ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / pStationaryLightsStack->pLights[i].uRadius) >> 16) - 30; | |
9054 } | |
9055 } | |
9056 } | |
9057 } | |
9058 | |
9059 if (v6 <= 31) | |
9060 { | |
9061 if (v6 < 0) | |
9062 v6 = 0; | |
9063 } | |
9064 else | |
9065 v6 = 31; | |
9066 return v6; | |
9067 } | |
9068 | |
9069 //----- (0049D700) -------------------------------------------------------- | |
9070 unsigned int __fastcall GetMaxMipLevels(unsigned int uDim) | |
9071 { | |
9072 int v2; // ecx@1 | |
9073 unsigned int v3; // eax@1 | |
9074 | |
9075 v2 = 0; | |
9076 v3 = uDim - 1; | |
9077 while (v3 & 1) | |
9078 { | |
9079 v3 >>= 1; | |
9080 ++v2; | |
9081 } | |
9082 return v3 == 0 ? v2 : 0; | |
9083 } | |
9084 | |
9085 //----- (0046E44E) -------------------------------------------------------- | |
9086 int _46E44E_collide_against_faces_and_portals(unsigned int b1) | |
9087 { | |
9088 BLVSector *pSector; // edi@1 | |
9089 signed int v2; // ebx@1 | |
9090 BLVFace *pFace; // esi@2 | |
9091 __int16 pNextSector; // si@10 | |
9092 int pArrayNum; // ecx@12 | |
9093 unsigned __int8 v6; // sf@12 | |
9094 unsigned __int8 v7; // of@12 | |
9095 int result; // eax@14 | |
9096 //int v10; // ecx@15 | |
9097 int pFloor; // eax@16 | |
9098 int v15; // eax@24 | |
9099 int v16; // edx@25 | |
9100 int v17; // eax@29 | |
9101 unsigned int v18; // eax@33 | |
9102 int v21; // eax@35 | |
9103 int v22; // ecx@36 | |
9104 int v23; // eax@40 | |
9105 unsigned int v24; // eax@44 | |
9106 int a3; // [sp+10h] [bp-48h]@28 | |
9107 int v26; // [sp+14h] [bp-44h]@15 | |
9108 int i; // [sp+18h] [bp-40h]@1 | |
9109 int a10; // [sp+1Ch] [bp-3Ch]@1 | |
9110 int v29; // [sp+20h] [bp-38h]@14 | |
9111 int v32; // [sp+2Ch] [bp-2Ch]@15 | |
9112 int pSectorsArray[10]; // [sp+30h] [bp-28h]@1 | |
9113 | |
9114 pSector = &pIndoor->pSectors[stru_721530.uSectorID]; | |
9115 i = 1; | |
9116 a10 = b1; | |
9117 pSectorsArray[0] = stru_721530.uSectorID; | |
9118 for (v2 = 0; v2 < pSector->uNumPortals; ++v2) | |
9119 { | |
9120 pFace = &pIndoor->pFaces[pSector->pPortals[v2]]; | |
9121 if (stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1 | |
9122 && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1 | |
9123 && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1 | |
9124 && abs((pFace->pFacePlane_old.dist | |
9125 + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x | |
9126 + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y | |
9127 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16) <= stru_721530.field_6C + 16) | |
9128 { | |
9129 pNextSector = pFace->uSectorID == stru_721530.uSectorID ? pFace->uBackSectorID : pFace->uSectorID;//FrontSectorID | |
9130 pArrayNum = i++; | |
9131 v7 = i < 10; | |
9132 v6 = i - 10 < 0; | |
9133 pSectorsArray[pArrayNum] = pNextSector; | |
9134 if (!(v6 ^ v7)) | |
9135 break; | |
9136 } | |
9137 } | |
9138 result = 0; | |
9139 for (v29 = 0; v29 < i; v29++) | |
9140 { | |
9141 pSector = &pIndoor->pSectors[pSectorsArray[v29]]; | |
9142 v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings; | |
9143 for (v26 = 0; v26 < v32; v26++) | |
9144 { | |
9145 pFloor = pSector->pFloors[v26]; | |
9146 pFace = &pIndoor->pFaces[pSector->pFloors[v26]]; | |
9147 if (!pFace->Portal() | |
9148 && stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1 | |
9149 && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1 | |
9150 && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1 | |
9151 && pFloor != stru_721530.field_84) | |
9152 { | |
9153 v15 = (pFace->pFacePlane_old.dist + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x | |
9154 + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y | |
9155 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16; | |
9156 if (v15 > 0) | |
9157 { | |
9158 v16 = (pFace->pFacePlane_old.dist + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x | |
9159 + stru_721530.normal2.y * pFace->pFacePlane_old.vNormal.y | |
9160 + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z) >> 16; | |
9161 if (v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d) | |
9162 { | |
9163 if (v16 <= v15) | |
9164 { | |
9165 a3 = stru_721530.field_6C; | |
9166 if (sub_47531C(stru_721530.prolly_normal_d, &a3, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, | |
9167 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10)) | |
9168 { | |
9169 v17 = a3; | |
9170 } | |
9171 else | |
9172 { | |
9173 a3 = stru_721530.field_6C + stru_721530.prolly_normal_d; | |
9174 if (!sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, pFace)) | |
9175 goto LABEL_34; | |
9176 v17 = a3 - stru_721530.prolly_normal_d; | |
9177 a3 -= stru_721530.prolly_normal_d; | |
9178 } | |
9179 if (v17 < stru_721530.field_7C) | |
9180 { | |
9181 stru_721530.field_7C = v17; | |
9182 v18 = 8 * pSector->pFloors[v26]; | |
9183 LOBYTE(v18) = v18 | 6; | |
9184 stru_721530.uFaceID = v18; | |
9185 } | |
9186 } | |
9187 } | |
9188 } | |
9189 LABEL_34: | |
9190 if (!(stru_721530.field_0 & 1) | |
9191 || (v21 = (pFace->pFacePlane_old.dist + stru_721530.position.x * pFace->pFacePlane_old.vNormal.x | |
9192 + stru_721530.position.y * pFace->pFacePlane_old.vNormal.y | |
9193 + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16, v21 <= 0) | |
9194 || (v22 = (pFace->pFacePlane_old.dist + stru_721530.field_4C * pFace->pFacePlane_old.vNormal.x | |
9195 + stru_721530.field_50 * pFace->pFacePlane_old.vNormal.y | |
9196 + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16, v21 > stru_721530.prolly_normal_d) | |
9197 && v22 > stru_721530.prolly_normal_d || v22 > v21) | |
9198 continue; | |
9199 a3 = stru_721530.field_6C; | |
9200 if (sub_47531C(stru_721530.field_8_radius, &a3, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z, | |
9201 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10)) | |
9202 { | |
9203 v23 = a3; | |
9204 goto LABEL_43; | |
9205 } | |
9206 a3 = stru_721530.field_6C + stru_721530.field_8_radius; | |
9207 if (sub_475D85(&stru_721530.position, &stru_721530.direction, &a3, pFace)) | |
9208 { | |
9209 v23 = a3 - stru_721530.prolly_normal_d; | |
9210 a3 -= stru_721530.prolly_normal_d; | |
9211 LABEL_43: | |
9212 if (v23 < stru_721530.field_7C) | |
9213 { | |
9214 stru_721530.field_7C = v23; | |
9215 v24 = 8 * pSector->pFloors[v26]; | |
9216 LOBYTE(v24) = v24 | 6; | |
9217 stru_721530.uFaceID = v24; | |
9218 } | |
9219 } | |
9220 } | |
9221 } | |
9222 result = v29 + 1; | |
9223 } | |
9224 return result; | |
9225 } | |
9226 // 46E44E: using guessed type int var_28[10]; | |
9227 | |
9228 //----- (0046E889) -------------------------------------------------------- | |
9229 int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0) | |
9230 { | |
9231 int result; // eax@1 | |
9232 //int v3; // ebx@9 | |
9233 int v8; // eax@19 | |
9234 int v9; // ecx@20 | |
9235 int v10; // eax@24 | |
9236 unsigned int v14; // eax@28 | |
9237 int v15; // eax@30 | |
9238 int v16; // ecx@31 | |
9239 unsigned int v17; // eax@36 | |
9240 int v21; // eax@42 | |
9241 unsigned int v22; // eax@43 | |
9242 //int a11; // [sp+70h] [bp-18h]@1 | |
9243 //int a10; // [sp+80h] [bp-8h]@1 | |
9244 int a2; // [sp+84h] [bp-4h]@23 | |
9245 | |
9246 //a11 = ecx0; | |
9247 | |
9248 BLVFace face; // [sp+Ch] [bp-7Ch]@1 | |
9249 | |
9250 result = 0; | |
9251 for (uint i = 0; i < (signed int)pOutdoor->uNumBModels; ++i) | |
9252 { | |
9253 if (stru_721530.sMaxX <= pOutdoor->pBModels[i].sMaxX && stru_721530.sMinX >= pOutdoor->pBModels[i].sMinX | |
9254 && stru_721530.sMaxY <= pOutdoor->pBModels[i].sMaxY && stru_721530.sMinY >= pOutdoor->pBModels[i].sMinY | |
9255 && stru_721530.sMaxZ <= pOutdoor->pBModels[i].sMaxZ && stru_721530.sMinZ >= pOutdoor->pBModels[i].sMinZ) | |
9256 { | |
9257 for (uint j = 0; j < pOutdoor->pBModels[i].uNumFaces; ++j) | |
9258 { | |
9259 if (stru_721530.sMaxX <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x2 && stru_721530.sMinX >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x1 | |
9260 && stru_721530.sMaxY <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y2 && stru_721530.sMinY >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y1 | |
9261 && stru_721530.sMaxZ <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.z2 && stru_721530.sMinZ >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.z1) | |
9262 { | |
9263 face.pFacePlane_old.vNormal.x = pOutdoor->pBModels[i].pFaces[j].pFacePlane.vNormal.x; | |
9264 face.pFacePlane_old.vNormal.y = pOutdoor->pBModels[i].pFaces[j].pFacePlane.vNormal.y; | |
9265 face.pFacePlane_old.vNormal.z = pOutdoor->pBModels[i].pFaces[j].pFacePlane.vNormal.z; | |
9266 | |
9267 face.pFacePlane_old.dist = pOutdoor->pBModels[i].pFaces[j].pFacePlane.dist; //incorrect | |
9268 | |
9269 face.uAttributes = pOutdoor->pBModels[i].pFaces[j].uAttributes; | |
9270 | |
9271 face.pBounding.x1 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x1; | |
9272 face.pBounding.y1 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y1; | |
9273 face.pBounding.z1 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.z1; | |
9274 | |
9275 face.pBounding.x2 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x2; | |
9276 face.pBounding.y2 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y2; | |
9277 face.pBounding.z2 = pOutdoor->pBModels[i].pFaces[j].pBoundingBox.z2; | |
9278 | |
9279 face.zCalc1 = pOutdoor->pBModels[i].pFaces[j].zCalc1; | |
9280 face.zCalc2 = pOutdoor->pBModels[i].pFaces[j].zCalc2; | |
9281 face.zCalc3 = pOutdoor->pBModels[i].pFaces[j].zCalc3; | |
9282 | |
9283 face.pXInterceptDisplacements = pOutdoor->pBModels[i].pFaces[j].pXInterceptDisplacements; | |
9284 face.pYInterceptDisplacements = pOutdoor->pBModels[i].pFaces[j].pYInterceptDisplacements; | |
9285 face.pZInterceptDisplacements = pOutdoor->pBModels[i].pFaces[j].pZInterceptDisplacements; | |
9286 | |
9287 face.uPolygonType = (PolygonType)pOutdoor->pBModels[i].pFaces[j].uPolygonType; | |
9288 | |
9289 face.uNumVertices = pOutdoor->pBModels[i].pFaces[j].uNumVertices; | |
9290 | |
9291 face.uBitmapID = pOutdoor->pBModels[i].pFaces[j].uTextureID; | |
9292 | |
9293 face.pVertexIDs = pOutdoor->pBModels[i].pFaces[j].pVertexIDs; | |
9294 | |
9295 if (!face.Ethereal() && !face.Portal()) | |
9296 { | |
9297 v8 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.normal.x | |
9298 + face.pFacePlane_old.vNormal.y * stru_721530.normal.y | |
9299 + face.pFacePlane_old.vNormal.z * stru_721530.normal.z) >> 16; | |
9300 if (v8 > 0) | |
9301 { | |
9302 v9 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.normal2.x | |
9303 + face.pFacePlane_old.vNormal.y * stru_721530.normal2.y | |
9304 + face.pFacePlane_old.vNormal.z * stru_721530.normal2.z) >> 16; | |
9305 if (v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d) | |
9306 { | |
9307 if (v9 <= v8) | |
9308 { | |
9309 a2 = stru_721530.field_6C; | |
9310 if (sub_4754BF(stru_721530.prolly_normal_d, &a2, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, | |
9311 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &face, i, ecx0)) | |
9312 { | |
9313 v10 = a2; | |
9314 } | |
9315 else | |
9316 { | |
9317 a2 = stru_721530.prolly_normal_d + stru_721530.field_6C; | |
9318 if (!sub_475F30(&a2, &face, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, | |
9319 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, i)) | |
9320 goto LABEL_29; | |
9321 v10 = a2 - stru_721530.prolly_normal_d; | |
9322 a2 -= stru_721530.prolly_normal_d; | |
9323 } | |
9324 if (v10 < stru_721530.field_7C) | |
9325 { | |
9326 stru_721530.field_7C = v10; | |
9327 v14 = 8 * (j | (i << 6)); | |
9328 LOBYTE(v14) = v14 | 6; | |
9329 stru_721530.uFaceID = v14; | |
9330 } | |
9331 } | |
9332 } | |
9333 } | |
9334 LABEL_29: | |
9335 if (stru_721530.field_0 & 1) | |
9336 { | |
9337 v15 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.position.x | |
9338 + face.pFacePlane_old.vNormal.y * stru_721530.position.y | |
9339 + face.pFacePlane_old.vNormal.z * stru_721530.position.z) >> 16; | |
9340 if (v15 > 0) | |
9341 { | |
9342 v16 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.field_4C | |
9343 + face.pFacePlane_old.vNormal.y * stru_721530.field_50 | |
9344 + face.pFacePlane_old.vNormal.z * stru_721530.field_54) >> 16; | |
9345 if (v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d) | |
9346 { | |
9347 if (v16 <= v15) | |
9348 { | |
9349 a2 = stru_721530.field_6C; | |
9350 if (sub_4754BF(stru_721530.field_8_radius, &a2, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z, | |
9351 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &face, i, ecx0)) | |
9352 { | |
9353 if (a2 < stru_721530.field_7C) | |
9354 { | |
9355 stru_721530.field_7C = a2; | |
9356 v17 = 8 * (j | (i << 6)); | |
9357 LOBYTE(v17) = v17 | 6; | |
9358 stru_721530.uFaceID = v17; | |
9359 } | |
9360 } | |
9361 else | |
9362 { | |
9363 a2 = stru_721530.field_6C + stru_721530.field_8_radius; | |
9364 if (sub_475F30(&a2, &face, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z, | |
9365 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, i)) | |
9366 { | |
9367 v21 = a2 - stru_721530.prolly_normal_d; | |
9368 a2 -= stru_721530.prolly_normal_d; | |
9369 if (a2 < stru_721530.field_7C) | |
9370 { | |
9371 stru_721530.field_7C = v21; | |
9372 v22 = 8 * (j | (i << 6)); | |
9373 LOBYTE(v22) = v22 | 6; | |
9374 stru_721530.uFaceID = v22; | |
9375 } | |
9376 } | |
9377 } | |
9378 } | |
9379 } | |
9380 } | |
9381 } | |
9382 } | |
9383 } | |
9384 } | |
9385 } | |
9386 result = i; | |
9387 } | |
9388 return result; | |
9389 } | |
9390 | |
9391 //----- (0046ED1B) -------------------------------------------------------- | |
9392 int collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID) | |
9393 { | |
9394 uint uFaceID = -1; | |
9395 int floor_level = BLV_GetFloorLevel(x, y, z, *pSectorID, &uFaceID); | |
9396 | |
9397 if (floor_level != -30000 && floor_level <= z + 50) | |
9398 { | |
9399 *pFaceID = uFaceID; | |
9400 return floor_level; | |
9401 } | |
9402 | |
9403 uint uSectorID = pIndoor->GetSector(x, y, z); | |
9404 *pSectorID = uSectorID; | |
9405 | |
9406 floor_level = BLV_GetFloorLevel(x, y, z, uSectorID, &uFaceID); | |
9407 if (uSectorID && floor_level != -30000) | |
9408 *pFaceID = uFaceID; | |
9409 else return -30000; | |
9410 return floor_level; | |
9411 } | |
9412 | |
9413 //----- (0046ED8A) -------------------------------------------------------- | |
9414 void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this) | |
9415 { | |
9416 ObjectDesc *object; // edx@4 | |
9417 int v10; // ecx@12 | |
9418 int v11; // esi@13 | |
9419 | |
9420 for (uint i = 0; i < uNumSpriteObjects; ++i) | |
9421 { | |
9422 if (pSpriteObjects[i].uObjectDescID) | |
9423 { | |
9424 object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID]; | |
9425 if (!(object->uFlags & OBJECT_DESC_NO_COLLISION)) | |
9426 { | |
9427 if (stru_721530.sMaxX <= pSpriteObjects[i].vPosition.x + object->uRadius && stru_721530.sMinX >= pSpriteObjects[i].vPosition.x - object->uRadius | |
9428 && stru_721530.sMaxY <= pSpriteObjects[i].vPosition.y + object->uRadius && stru_721530.sMinY >= pSpriteObjects[i].vPosition.y - object->uRadius | |
9429 && stru_721530.sMaxZ <= pSpriteObjects[i].vPosition.z + object->uHeight && stru_721530.sMinZ >= pSpriteObjects[i].vPosition.z) | |
9430 { | |
9431 if (abs(((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.y | |
9432 - (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16) | |
9433 <= object->uHeight + stru_721530.prolly_normal_d) | |
9434 { | |
9435 v10 = ((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.x | |
9436 + (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.y) >> 16; | |
9437 if (v10 > 0) | |
9438 { | |
9439 v11 = stru_721530.normal.z + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16); | |
9440 if (v11 >= pSpriteObjects[i].vPosition.z - stru_721530.prolly_normal_d) | |
9441 { | |
9442 if (v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z) | |
9443 { | |
9444 if (v10 < stru_721530.field_7C) | |
9445 sub_46DEF2(_this, i); | |
9446 } | |
9447 } | |
9448 } | |
9449 } | |
9450 } | |
9451 } | |
9452 } | |
9453 } | |
9454 } | |
9455 | |
9456 //----- (0046EF01) -------------------------------------------------------- | |
9457 int _46EF01_collision_chech_player(int a1) | |
9458 { | |
9459 int result; // eax@1 | |
9460 int v3; // ebx@7 | |
9461 int v4; // esi@7 | |
9462 int v5; // edi@8 | |
9463 int v6; // ecx@9 | |
9464 int v7; // edi@12 | |
9465 int v10; // [sp+14h] [bp-8h]@7 | |
9466 int v11; // [sp+18h] [bp-4h]@7 | |
9467 | |
9468 result = pParty->vPosition.x; | |
9469 //v9 = pParty->uPartyHeight; | |
9470 if (stru_721530.sMaxX <= pParty->vPosition.x + (2 * pParty->field_14_radius) && stru_721530.sMinX >= pParty->vPosition.x - (2 * pParty->field_14_radius) | |
9471 && stru_721530.sMaxY <= pParty->vPosition.y + (2 * pParty->field_14_radius) && stru_721530.sMinY >= pParty->vPosition.y - (2 * pParty->field_14_radius) | |
9472 && stru_721530.sMaxZ <= pParty->vPosition.z + pParty->uPartyHeight && stru_721530.sMinZ >= pParty->vPosition.z) | |
9473 { | |
9474 v3 = stru_721530.prolly_normal_d + (2 * pParty->field_14_radius); | |
9475 v11 = pParty->vPosition.x - stru_721530.normal.x; | |
9476 v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y | |
9477 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16; | |
9478 v10 = pParty->vPosition.y - stru_721530.normal.y; | |
9479 result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y | |
9480 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16); | |
9481 if (result <= stru_721530.prolly_normal_d + (2 * pParty->field_14_radius)) | |
9482 { | |
9483 result = v10 * stru_721530.direction.y; | |
9484 v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16; | |
9485 if (v5 > 0) | |
9486 { | |
9487 v6 = fixpoint_mul(stru_721530.direction.z, v5) + stru_721530.normal.z; | |
9488 result = pParty->vPosition.z; | |
9489 if (v6 >= pParty->vPosition.z) | |
9490 { | |
9491 result = pParty->uPartyHeight + pParty->vPosition.z; | |
9492 if (v6 <= (signed int)(pParty->uPartyHeight + pParty->vPosition.z) || a1) | |
9493 { | |
9494 result = integer_sqrt(v3 * v3 - v4 * v4); | |
9495 v7 = v5 - integer_sqrt(v3 * v3 - v4 * v4); | |
9496 if (v7 < 0) | |
9497 v7 = 0; | |
9498 if (v7 < stru_721530.field_7C) | |
9499 { | |
9500 stru_721530.field_7C = v7; | |
9501 stru_721530.uFaceID = 4; | |
9502 } | |
9503 } | |
9504 } | |
9505 } | |
9506 } | |
9507 } | |
9508 return result; | |
9509 } | |
9510 | |
9511 //----- (0046E0B2) -------------------------------------------------------- | |
9512 void _46E0B2_collide_against_decorations() | |
9513 { | |
9514 BLVSector *sector; // ebp@1 | |
9515 LevelDecoration *decor; // edi@2 | |
9516 DecorationDesc *decor_desc; // esi@3 | |
9517 int v8; // ebx@10 | |
9518 int v9; // esi@11 | |
9519 int v11; // eax@12 | |
9520 int v12; // esi@14 | |
9521 unsigned int v13; // eax@17 | |
9522 signed int i; // [sp+4h] [bp-14h]@1 | |
9523 int v15; // [sp+8h] [bp-10h]@10 | |
9524 int v16; // [sp+Ch] [bp-Ch]@10 | |
9525 int v17; // [sp+10h] [bp-8h]@10 | |
9526 | |
9527 sector = &pIndoor->pSectors[stru_721530.uSectorID]; | |
9528 for (i = 0; i < sector->uNumDecorations; ++i) | |
9529 { | |
9530 decor = &pLevelDecorations[sector->pDecorationIDs[i]]; | |
9531 if (!(decor->uFlags & LEVEL_DECORATION_INVISIBLE)) | |
9532 { | |
9533 decor_desc = &pDecorationList->pDecorations[decor->uDecorationDescID]; | |
9534 if (!decor_desc->CanMoveThrough()) | |
9535 { | |
9536 if (stru_721530.sMaxX <= decor->vPosition.x + decor_desc->uRadius && stru_721530.sMinX >= decor->vPosition.x - decor_desc->uRadius | |
9537 && stru_721530.sMaxY <= decor->vPosition.y + decor_desc->uRadius && stru_721530.sMinY >= decor->vPosition.y - decor_desc->uRadius | |
9538 && stru_721530.sMaxZ <= decor->vPosition.z + decor_desc->uDecorationHeight && stru_721530.sMinZ >= decor->vPosition.z) | |
9539 { | |
9540 v16 = decor->vPosition.x - stru_721530.normal.x; | |
9541 v15 = decor->vPosition.y - stru_721530.normal.y; | |
9542 v8 = stru_721530.prolly_normal_d + decor_desc->uRadius; | |
9543 v17 = ((decor->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y | |
9544 - (decor->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16; | |
9545 if (abs(v17) <= stru_721530.prolly_normal_d + decor_desc->uRadius) | |
9546 { | |
9547 v9 = (v16 * stru_721530.direction.x + v15 * stru_721530.direction.y) >> 16; | |
9548 if (v9 > 0) | |
9549 { | |
9550 v11 = stru_721530.normal.z + fixpoint_mul(stru_721530.direction.z, v9); | |
9551 if (v11 >= decor->vPosition.z) | |
9552 { | |
9553 if (v11 <= decor_desc->uDecorationHeight + decor->vPosition.z) | |
9554 { | |
9555 v12 = v9 - integer_sqrt(v8 * v8 - v17 * v17); | |
9556 if (v12 < 0) | |
9557 v12 = 0; | |
9558 if (v12 < stru_721530.field_7C) | |
9559 { | |
9560 stru_721530.field_7C = v12; | |
9561 v13 = 8 * sector->pDecorationIDs[i]; | |
9562 LOBYTE(v13) = v13 | 5; | |
9563 stru_721530.uFaceID = v13; | |
9564 } | |
9565 } | |
9566 } | |
9567 } | |
9568 } | |
9569 } | |
9570 } | |
9571 } | |
9572 } | |
9573 } | |
9574 | |
9575 //----- (0046F04E) -------------------------------------------------------- | |
9576 int _46F04E_collide_against_portals() | |
9577 { | |
9578 unsigned int v1; // eax@1 | |
9579 BLVFace *face; // eax@3 | |
9580 int v4; // ecx@9 | |
9581 int v5; // edx@9 | |
9582 signed int result; // eax@21 | |
9583 unsigned int v10; // [sp+8h] [bp-Ch]@1 | |
9584 int a3; // [sp+Ch] [bp-8h]@13 | |
9585 int v12; // [sp+10h] [bp-4h]@15 | |
9586 | |
2535 | 9587 v1 = 0xFFFFFF; |
9588 v10 = 0xFFFFFF; | |
2496 | 9589 for (uint i = 0; i < pIndoor->pSectors[stru_721530.uSectorID].uNumPortals; ++i) |
9590 { | |
9591 if (pIndoor->pSectors[stru_721530.uSectorID].pPortals[i] != stru_721530.field_80) | |
9592 { | |
9593 face = &pIndoor->pFaces[pIndoor->pSectors[stru_721530.uSectorID].pPortals[i]]; | |
9594 if (stru_721530.sMaxX <= face->pBounding.x2 && stru_721530.sMinX >= face->pBounding.x1 | |
9595 && stru_721530.sMaxY <= face->pBounding.y2 && stru_721530.sMinY >= face->pBounding.y1 | |
9596 && stru_721530.sMaxZ <= face->pBounding.z2 && stru_721530.sMinZ >= face->pBounding.z1) | |
9597 { | |
9598 v4 = (stru_721530.normal.x * face->pFacePlane_old.vNormal.x + face->pFacePlane_old.dist | |
9599 + stru_721530.normal.y * face->pFacePlane_old.vNormal.y | |
9600 + stru_721530.normal.z * face->pFacePlane_old.vNormal.z) >> 16; | |
9601 v5 = (stru_721530.normal2.z * face->pFacePlane_old.vNormal.z + face->pFacePlane_old.dist | |
9602 + stru_721530.normal2.x * face->pFacePlane_old.vNormal.x | |
9603 + stru_721530.normal2.y * face->pFacePlane_old.vNormal.y) >> 16; | |
9604 if ((v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d) | |
9605 && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d) | |
9606 && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, face)) | |
9607 && a3 < (signed int)v10) | |
9608 { | |
9609 v10 = a3; | |
9610 v12 = pIndoor->pSectors[stru_721530.uSectorID].pPortals[i]; | |
9611 } | |
9612 } | |
9613 } | |
9614 } | |
9615 v1 = v10; | |
9616 if (stru_721530.field_7C >= (signed int)v1 && (signed int)v1 <= stru_721530.field_6C) | |
9617 { | |
9618 stru_721530.field_80 = v12; | |
9619 if (pIndoor->pFaces[v12].uSectorID == stru_721530.uSectorID) | |
9620 stru_721530.uSectorID = pIndoor->pFaces[v12].uBackSectorID; | |
9621 else | |
9622 stru_721530.uSectorID = pIndoor->pFaces[v12].uSectorID; | |
2535 | 9623 stru_721530.field_7C = 268435455;//0xFFFFFFF |
2496 | 9624 result = 0; |
9625 } | |
9626 else | |
9627 result = 1; | |
9628 return result; | |
9629 } | |
9630 | |
9631 //----- (0046DEF2) -------------------------------------------------------- | |
9632 unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID) | |
9633 { | |
9634 unsigned int result; // eax@1 | |
9635 | |
9636 result = uLayingItemID; | |
9637 if (pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID].uFlags & 0x10) | |
2566 | 9638 result = _46BFFA_update_spell_fx(uLayingItemID, a2); |
2496 | 9639 return result; |
9640 } | |
9641 | |
9642 //----- (0047253E) -------------------------------------------------------- | |
9643 void UpdateObjects() | |
9644 { | |
9645 ObjectDesc *object; // eax@5 | |
9646 int v5; // ecx@6 | |
9647 signed int v7; // eax@9 | |
9648 signed int v11; // eax@17 | |
9649 int v12; // edi@27 | |
9650 int v18; // [sp+4h] [bp-10h]@27 | |
9651 int v19; // [sp+8h] [bp-Ch]@27 | |
9652 | |
9653 for (uint i = 0; i < uNumSpriteObjects; ++i) | |
9654 { | |
9655 if (pSpriteObjects[i].uAttributes & OBJECT_40) | |
9656 pSpriteObjects[i].uAttributes &= ~OBJECT_40; | |
9657 else | |
9658 { | |
9659 object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID]; | |
9660 if (pSpriteObjects[i].AttachedToActor()) | |
9661 { | |
9662 v5 = PID_ID(pSpriteObjects[i].spell_target_pid); | |
9663 pSpriteObjects[i].vPosition.x = pActors[v5].vPosition.x; | |
9664 pSpriteObjects[i].vPosition.y = pActors[v5].vPosition.y; | |
9665 pSpriteObjects[i].vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight; | |
9666 if (!pSpriteObjects[i].uObjectDescID) | |
9667 continue; | |
9668 pSpriteObjects[i].uSpriteFrameID += pEventTimer->uTimeElapsed; | |
9669 if (!(object->uFlags & OBJECT_DESC_TEMPORARY)) | |
9670 continue; | |
9671 if (pSpriteObjects[i].uSpriteFrameID >= 0) | |
9672 { | |
9673 v7 = object->uLifetime; | |
9674 if (pSpriteObjects[i].uAttributes & ITEM_BROKEN) | |
9675 v7 = pSpriteObjects[i].field_20; | |
9676 if (pSpriteObjects[i].uSpriteFrameID < v7) | |
9677 continue; | |
9678 } | |
9679 SpriteObject::OnInteraction(i); | |
9680 continue; | |
9681 } | |
9682 if (pSpriteObjects[i].uObjectDescID) | |
9683 { | |
9684 pSpriteObjects[i].uSpriteFrameID += pEventTimer->uTimeElapsed; | |
9685 if (object->uFlags & OBJECT_DESC_TEMPORARY) | |
9686 { | |
9687 if (pSpriteObjects[i].uSpriteFrameID < 0) | |
9688 { | |
9689 SpriteObject::OnInteraction(i); | |
9690 continue; | |
9691 } | |
9692 v11 = object->uLifetime; | |
9693 if (pSpriteObjects[i].uAttributes & ITEM_BROKEN) | |
9694 v11 = pSpriteObjects[i].field_20; | |
9695 } | |
9696 if (!(object->uFlags & OBJECT_DESC_TEMPORARY) || pSpriteObjects[i].uSpriteFrameID < v11) | |
9697 { | |
9698 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
9699 SpriteObject::UpdateObject_fn0_BLV(i); | |
9700 else | |
9701 SpriteObject::UpdateObject_fn0_ODM(i); | |
9702 if (pParty->bTurnBasedModeOn != 1 || !(pSpriteObjects[i].uSectorID & 4)) | |
9703 continue; | |
9704 v12 = abs(pParty->vPosition.x - pSpriteObjects[i].vPosition.x); | |
9705 v18 = abs(pParty->vPosition.y - pSpriteObjects[i].vPosition.y); | |
9706 v19 = abs(pParty->vPosition.z - pSpriteObjects[i].vPosition.z); | |
9707 if (int_get_vector_length(v12, v18, v19) <= 5120) | |
9708 continue; | |
9709 SpriteObject::OnInteraction(i); | |
9710 continue; | |
9711 } | |
9712 if (!(object->uFlags & OBJECT_DESC_INTERACTABLE)) | |
9713 { | |
9714 SpriteObject::OnInteraction(i); | |
9715 continue; | |
9716 } | |
2566 | 9717 _46BFFA_update_spell_fx(i, PID(OBJECT_Item, i)); |
2496 | 9718 } |
9719 } | |
9720 } | |
9721 } | |
9722 | |
9723 //----- (0047531C) -------------------------------------------------------- | |
9724 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) | |
9725 { | |
9726 int v11; // ST1C_4@3 | |
9727 int v12; // edi@3 | |
9728 int v13; // esi@3 | |
9729 int v14; // edi@4 | |
9730 signed __int64 v15; // qtt@6 | |
9731 //__int16 v16; // si@7 | |
9732 int a7a; // [sp+30h] [bp+18h]@7 | |
9733 int a9b; // [sp+38h] [bp+20h]@3 | |
9734 int a9a; // [sp+38h] [bp+20h]@3 | |
9735 int a10b; // [sp+3Ch] [bp+24h]@3 | |
9736 signed int a10a; // [sp+3Ch] [bp+24h]@4 | |
9737 int a10c; // [sp+3Ch] [bp+24h]@5 | |
9738 | |
9739 if (a10 && face->Ethereal()) | |
9740 return 0; | |
9741 v11 = fixpoint_mul(dir_x, face->pFacePlane_old.vNormal.x); | |
9742 a10b = fixpoint_mul(dir_y, face->pFacePlane_old.vNormal.y); | |
9743 a9b = fixpoint_mul(dir_z, face->pFacePlane_old.vNormal.z); | |
9744 v12 = v11 + a9b + a10b; | |
9745 a9a = v11 + a9b + a10b; | |
9746 v13 = (a1 << 16) | |
9747 - pos_x * face->pFacePlane_old.vNormal.x | |
9748 - pos_y * face->pFacePlane_old.vNormal.y | |
9749 - pos_z * face->pFacePlane_old.vNormal.z | |
9750 - face->pFacePlane_old.dist; | |
9751 if (abs((a1 << 16) | |
9752 - pos_x * face->pFacePlane_old.vNormal.x | |
9753 - pos_y * face->pFacePlane_old.vNormal.y | |
9754 - pos_z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16) | |
9755 { | |
9756 a10c = abs(v13) >> 14; | |
9757 if (a10c > abs(v12)) | |
9758 return 0; | |
9759 LODWORD(v15) = v13 << 16; | |
9760 HIDWORD(v15) = v13 >> 16; | |
9761 v14 = a1; | |
9762 a10a = v15 / a9a; | |
9763 } | |
9764 else | |
9765 { | |
9766 a10a = 0; | |
9767 v14 = abs(v13) >> 16; | |
9768 } | |
9769 //v16 = pos_y + ((unsigned int)fixpoint_mul(a10a, dir_y) >> 16); | |
9770 LOWORD(a7a) = (short)pos_x + ((unsigned int)fixpoint_mul(a10a, dir_x) >> 16) - fixpoint_mul(v14, face->pFacePlane_old.vNormal.x); | |
9771 HIWORD(a7a) = pos_y + ((unsigned int)fixpoint_mul(a10a, dir_y) >> 16) - fixpoint_mul(v14, face->pFacePlane_old.vNormal.y); | |
9772 if (!sub_475665(face, a7a, (short)pos_z + ((unsigned int)fixpoint_mul(a10a, dir_z) >> 16) - fixpoint_mul(v14, face->pFacePlane_old.vNormal.z))) | |
9773 return 0; | |
9774 *a2 = a10a >> 16; | |
9775 if (a10a >> 16 < 0) | |
9776 *a2 = 0; | |
9777 return 1; | |
9778 } | |
9779 | |
9780 | |
9781 //----- (004754BF) -------------------------------------------------------- | |
9782 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) | |
9783 { | |
9784 int v12; // ST1C_4@3 | |
9785 int v13; // edi@3 | |
9786 int v14; // esi@3 | |
9787 int v15; // edi@4 | |
9788 signed __int64 v16; // qtt@6 | |
9789 //__int16 v17; // si@7 | |
9790 int a7a; // [sp+30h] [bp+18h]@7 | |
9791 int a1b; // [sp+38h] [bp+20h]@3 | |
9792 int a1a; // [sp+38h] [bp+20h]@3 | |
9793 int a11b; // [sp+40h] [bp+28h]@3 | |
9794 signed int a11a; // [sp+40h] [bp+28h]@4 | |
9795 int a11c; // [sp+40h] [bp+28h]@5 | |
9796 | |
9797 if (a11 && face->Ethereal()) | |
9798 return false; | |
9799 v12 = fixpoint_mul(dir_x, face->pFacePlane_old.vNormal.x); | |
9800 a11b = fixpoint_mul(dir_y, face->pFacePlane_old.vNormal.y); | |
9801 a1b = fixpoint_mul(dir_z, face->pFacePlane_old.vNormal.z); | |
9802 v13 = v12 + a1b + a11b; | |
9803 a1a = v12 + a1b + a11b; | |
9804 v14 = (a1 << 16) | |
9805 - X * face->pFacePlane_old.vNormal.x | |
9806 - Y * face->pFacePlane_old.vNormal.y | |
9807 - Z * face->pFacePlane_old.vNormal.z | |
9808 - face->pFacePlane_old.dist; | |
9809 if (abs((a1 << 16) | |
9810 - X * face->pFacePlane_old.vNormal.x | |
9811 - Y * face->pFacePlane_old.vNormal.y | |
9812 - Z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16) | |
9813 { | |
9814 a11c = abs(v14) >> 14; | |
9815 if (a11c > abs(v13)) | |
9816 return false; | |
9817 LODWORD(v16) = v14 << 16; | |
9818 HIDWORD(v16) = v14 >> 16; | |
9819 v15 = a1; | |
9820 a11a = v16 / a1a; | |
9821 } | |
9822 else | |
9823 { | |
9824 a11a = 0; | |
9825 v15 = abs(v14) >> 16; | |
9826 } | |
9827 //v17 = Y + ((unsigned int)fixpoint_mul(a11a, dir_y) >> 16); | |
9828 LOWORD(a7a) = (short)X + ((unsigned int)fixpoint_mul(a11a, dir_x) >> 16) - fixpoint_mul(v15, face->pFacePlane_old.vNormal.x); | |
9829 HIWORD(a7a) = Y + ((unsigned int)fixpoint_mul(a11a, dir_y) >> 16) - fixpoint_mul(v15, face->pFacePlane_old.vNormal.y); | |
9830 if (!sub_4759C9(face, a10, a7a, (short)Z + ((unsigned int)fixpoint_mul(a11a, dir_z) >> 16) - fixpoint_mul(v15, face->pFacePlane_old.vNormal.z))) | |
9831 return false; | |
9832 *a2 = a11a >> 16; | |
9833 if (a11a >> 16 < 0) | |
9834 *a2 = 0; | |
9835 return true; | |
9836 } | |
9837 | |
9838 //----- (00475665) -------------------------------------------------------- | |
9839 int sub_475665(BLVFace *face, int a2, __int16 a3) | |
9840 { | |
9841 bool v16; // edi@14 | |
9842 signed int v20; // ebx@18 | |
9843 int v21; // edi@20 | |
9844 signed int v22; // ST14_4@22 | |
9845 signed __int64 v23; // qtt@22 | |
9846 signed int result; // eax@25 | |
9847 int v25; // [sp+14h] [bp-10h]@14 | |
9848 int v26; // [sp+1Ch] [bp-8h]@2 | |
9849 signed int v27; // [sp+20h] [bp-4h]@2 | |
9850 signed int v28; // [sp+30h] [bp+Ch]@2 | |
9851 signed int v29; // [sp+30h] [bp+Ch]@7 | |
9852 signed int v30; // [sp+30h] [bp+Ch]@11 | |
9853 signed int v31; // [sp+30h] [bp+Ch]@14 | |
9854 | |
9855 if (face->uAttributes & FACE_XY_PLANE) | |
9856 { | |
9857 v26 = (signed __int16)a2; | |
9858 v27 = SHIWORD(a2); | |
9859 if (face->uNumVertices) | |
9860 { | |
9861 for (v28 = 0; v28 < face->uNumVertices; v28++) | |
9862 { | |
9863 word_720C10_intercepts_xs[2 * v28] = face->pXInterceptDisplacements[v28] + pIndoor->pVertices[face->pVertexIDs[v28]].x; | |
9864 word_720B40_intercepts_zs[2 * v28] = face->pYInterceptDisplacements[v28] + pIndoor->pVertices[face->pVertexIDs[v28]].y; | |
9865 word_720C10_intercepts_xs[2 * v28 + 1] = face->pXInterceptDisplacements[v28 + 1] + pIndoor->pVertices[face->pVertexIDs[v28 + 1]].x; | |
9866 word_720B40_intercepts_zs[2 * v28 + 1] = face->pYInterceptDisplacements[v28 + 1] + pIndoor->pVertices[face->pVertexIDs[v28 + 1]].y; | |
9867 } | |
9868 } | |
9869 } | |
9870 else | |
9871 { | |
9872 if (face->uAttributes & FACE_XZ_PLANE) | |
9873 { | |
9874 v26 = (signed __int16)a2; | |
9875 v27 = a3; | |
9876 if (face->uNumVertices) | |
9877 { | |
9878 for (v29 = 0; v29 < face->uNumVertices; v29++) | |
9879 { | |
9880 word_720C10_intercepts_xs[2 * v29] = face->pXInterceptDisplacements[v29] + pIndoor->pVertices[face->pVertexIDs[v29]].x; | |
9881 word_720B40_intercepts_zs[2 * v29] = face->pZInterceptDisplacements[v29] + pIndoor->pVertices[face->pVertexIDs[v29]].z; | |
9882 word_720C10_intercepts_xs[2 * v29 + 1] = face->pXInterceptDisplacements[v29 + 1] + pIndoor->pVertices[face->pVertexIDs[v29 + 1]].x; | |
9883 word_720B40_intercepts_zs[2 * v29 + 1] = face->pZInterceptDisplacements[v29 + 1] + pIndoor->pVertices[face->pVertexIDs[v29 + 1]].z; | |
9884 } | |
9885 } | |
9886 } | |
9887 else | |
9888 { | |
9889 v26 = SHIWORD(a2); | |
9890 v27 = a3; | |
9891 if (face->uNumVertices) | |
9892 { | |
9893 for (v30 = 0; v30 < face->uNumVertices; v30++) | |
9894 { | |
9895 word_720C10_intercepts_xs[2 * v30] = face->pYInterceptDisplacements[v30] + pIndoor->pVertices[face->pVertexIDs[v30]].y; | |
9896 word_720B40_intercepts_zs[2 * v30] = face->pZInterceptDisplacements[v30] + pIndoor->pVertices[face->pVertexIDs[v30]].z; | |
9897 word_720C10_intercepts_xs[2 * v30 + 1] = face->pYInterceptDisplacements[v30 + 1] + pIndoor->pVertices[face->pVertexIDs[v30 + 1]].y; | |
9898 word_720B40_intercepts_zs[2 * v30 + 1] = face->pZInterceptDisplacements[v30 + 1] + pIndoor->pVertices[face->pVertexIDs[v30 + 1]].z; | |
9899 } | |
9900 } | |
9901 } | |
9902 } | |
9903 v31 = 0; | |
9904 word_720C10_intercepts_xs[2 * face->uNumVertices] = word_720C10_intercepts_xs[0]; | |
9905 word_720B40_intercepts_zs[2 * face->uNumVertices] = word_720B40_intercepts_zs[0]; | |
9906 v16 = word_720B40_intercepts_zs[0] >= v27; | |
9907 if (2 * face->uNumVertices <= 0) | |
9908 return 0; | |
9909 for (v25 = 0; v25 < 2 * face->uNumVertices; ++v25) | |
9910 { | |
9911 if (v31 >= 2) | |
9912 break; | |
9913 if (v16 ^ (word_720B40_intercepts_zs[v25 + 1] >= v27)) | |
9914 { | |
9915 if (word_720C10_intercepts_xs[v25 + 1] >= v26) | |
9916 v20 = 0; | |
9917 else | |
9918 v20 = 2; | |
9919 v21 = v20 | (word_720C10_intercepts_xs[v25] < v26); | |
9920 if (v21 != 3) | |
9921 { | |
9922 v22 = word_720C10_intercepts_xs[v25 + 1] - word_720C10_intercepts_xs[v25]; | |
9923 LODWORD(v23) = v22 << 16; | |
9924 HIDWORD(v23) = v22 >> 16; | |
9925 if (!v21 | |
9926 || (word_720C10_intercepts_xs[v25] + ((signed int)(((unsigned __int64)(v23 | |
9927 / (word_720B40_intercepts_zs[v25 + 1] - word_720B40_intercepts_zs[v25]) | |
9928 * ((v27 - (signed int)word_720B40_intercepts_zs[v25]) << 16)) >> 16) | |
9929 + 32768) >> 16) >= v26)) | |
9930 ++v31; | |
9931 } | |
9932 } | |
9933 v16 = word_720B40_intercepts_zs[v25 + 1] >= v27; | |
9934 } | |
9935 result = 1; | |
9936 if (v31 != 1) | |
9937 result = 0; | |
9938 return result; | |
9939 } | |
9940 | |
9941 //----- (004759C9) -------------------------------------------------------- | |
9942 bool __fastcall sub_4759C9(BLVFace *face, int a2, int a3, __int16 a4) | |
9943 { | |
9944 bool v12; // edi@14 | |
9945 signed int v16; // ebx@18 | |
9946 int v17; // edi@20 | |
9947 signed int v18; // ST14_4@22 | |
9948 signed __int64 v19; // qtt@22 | |
9949 bool result; // eax@25 | |
9950 int v21; // [sp+14h] [bp-10h]@14 | |
9951 signed int v22; // [sp+18h] [bp-Ch]@1 | |
9952 int v23; // [sp+1Ch] [bp-8h]@2 | |
9953 signed int v24; // [sp+20h] [bp-4h]@2 | |
9954 signed int a4d; // [sp+30h] [bp+Ch]@14 | |
9955 | |
9956 if (face->uAttributes & FACE_XY_PLANE) | |
9957 { | |
9958 v23 = (signed __int16)a3; | |
9959 v24 = SHIWORD(a3); | |
9960 if (face->uNumVertices) | |
9961 { | |
9962 for (v22 = 0; v22 < face->uNumVertices; ++v22) | |
9963 { | |
9964 word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pXInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].x); | |
9965 word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pYInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].y); | |
9966 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pXInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].x); | |
9967 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pYInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].y); | |
9968 } | |
9969 } | |
9970 } | |
9971 else | |
9972 { | |
9973 if (face->uAttributes & FACE_XZ_PLANE) | |
9974 { | |
9975 v23 = (signed __int16)a3; | |
9976 v24 = a4; | |
9977 if (face->uNumVertices) | |
9978 { | |
9979 for (v22 = 0; v22 < face->uNumVertices; ++v22) | |
9980 { | |
9981 word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pXInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].x); | |
9982 word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pZInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].z); | |
9983 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pXInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].x); | |
9984 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pZInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].z); | |
9985 } | |
9986 } | |
9987 } | |
9988 else | |
9989 { | |
9990 v23 = SHIWORD(a3); | |
9991 v24 = a4; | |
9992 if (face->uNumVertices) | |
9993 { | |
9994 for (v22 = 0; v22 < face->uNumVertices; ++v22) | |
9995 { | |
9996 word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pYInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].y); | |
9997 word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pZInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].z); | |
9998 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pYInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].y); | |
9999 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pZInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].z); | |
10000 } | |
10001 } | |
10002 } | |
10003 } | |
10004 a4d = 0; | |
10005 word_720A70_intercepts_xs_plus_xs[2 * face->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0]; | |
10006 word_7209A0_intercepts_ys_plus_ys[2 * face->uNumVertices] = word_7209A0_intercepts_ys_plus_ys[0]; | |
10007 v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24; | |
10008 if (2 * face->uNumVertices <= 0) | |
10009 return 0; | |
10010 for (v21 = 0; v21 < 2 * face->uNumVertices; ++v21) | |
10011 { | |
10012 if (a4d >= 2) | |
10013 break; | |
10014 if (v12 ^ (word_7209A0_intercepts_ys_plus_ys[v21 + 1] >= v24)) | |
10015 { | |
10016 if (word_720A70_intercepts_xs_plus_xs[v21 + 1] >= v23) | |
10017 v16 = 0; | |
10018 else | |
10019 v16 = 2; | |
10020 v17 = v16 | (word_720A70_intercepts_xs_plus_xs[v21] < v23); | |
10021 if (v17 != 3) | |
10022 { | |
10023 v18 = word_720A70_intercepts_xs_plus_xs[v21 + 1] - word_720A70_intercepts_xs_plus_xs[v21]; | |
10024 LODWORD(v19) = v18 << 16; | |
10025 HIDWORD(v19) = v18 >> 16; | |
10026 if (!v17 | |
10027 || (word_720A70_intercepts_xs_plus_xs[v21] + ((signed int)(((unsigned __int64)(v19 | |
10028 / (word_7209A0_intercepts_ys_plus_ys[v21 + 1] - word_7209A0_intercepts_ys_plus_ys[v21]) | |
10029 * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v21]) << 16)) >> 16) | |
10030 + 0x8000) >> 16) >= v23)) | |
10031 ++a4d; | |
10032 } | |
10033 } | |
10034 v12 = word_7209A0_intercepts_ys_plus_ys[v21 + 1] >= v24; | |
10035 } | |
10036 result = 1; | |
10037 if (a4d != 1) | |
10038 result = 0; | |
10039 return result; | |
10040 } | |
10041 | |
10042 //----- (00475D85) -------------------------------------------------------- | |
10043 bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, BLVFace *a4) | |
10044 { | |
10045 BLVFace *v4; // ebx@1 | |
10046 int v5; // ST24_4@2 | |
10047 int v6; // ST28_4@2 | |
10048 int v7; // edi@2 | |
10049 int v8; // eax@5 | |
10050 signed int v9; // esi@5 | |
10051 signed __int64 v10; // qtt@10 | |
10052 Vec3_int_ *v11; // esi@11 | |
10053 int v12; // ST14_4@11 | |
10054 Vec3_int_ *v14; // [sp+Ch] [bp-18h]@1 | |
10055 Vec3_int_ *v15; // [sp+14h] [bp-10h]@1 | |
10056 // int v16; // [sp+18h] [bp-Ch]@2 | |
10057 int v17; // [sp+20h] [bp-4h]@10 | |
10058 int a4b; // [sp+30h] [bp+Ch]@2 | |
10059 int a4c; // [sp+30h] [bp+Ch]@9 | |
10060 signed int a4a; // [sp+30h] [bp+Ch]@10 | |
10061 | |
10062 v4 = a4; | |
10063 v15 = a2; | |
10064 v14 = a1; | |
10065 v5 = fixpoint_mul(a2->x, a4->pFacePlane_old.vNormal.x); | |
10066 a4b = fixpoint_mul(a2->y, a4->pFacePlane_old.vNormal.y); | |
10067 v6 = fixpoint_mul(a2->z, v4->pFacePlane_old.vNormal.z); | |
10068 v7 = v5 + v6 + a4b; | |
10069 //(v16 = v5 + v6 + a4b) == 0; | |
10070 if (a4->uAttributes & FACE_ETHEREAL || !v7 || v7 > 0 && !v4->Portal()) | |
10071 return 0; | |
10072 v8 = v4->pFacePlane_old.vNormal.z * a1->z; | |
10073 v9 = -(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x); | |
10074 if (v7 <= 0) | |
10075 { | |
10076 if (v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x < 0) | |
10077 return 0; | |
10078 } | |
10079 else | |
10080 { | |
10081 if (v9 < 0) | |
10082 return 0; | |
10083 } | |
10084 a4c = abs(-(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x)) >> 14; | |
10085 v11 = v14; | |
10086 LODWORD(v10) = v9 << 16; | |
10087 HIDWORD(v10) = v9 >> 16; | |
10088 a4a = v10 / v7; | |
10089 v17 = v10 / v7; | |
10090 LOWORD(v12) = LOWORD(v14->x) + (((unsigned int)fixpoint_mul(v17, v15->x) + 0x8000) >> 16); | |
10091 HIWORD(v12) = LOWORD(v11->y) + (((unsigned int)fixpoint_mul(v17, v15->y) + 0x8000) >> 16); | |
10092 if (a4c > abs(v7) || (v17 > *a3 << 16) || !sub_475665(v4, v12, LOWORD(v11->z) + (((unsigned int)fixpoint_mul(v17, v15->z) + 0x8000) >> 16))) | |
10093 return 0; | |
10094 *a3 = a4a >> 16; | |
10095 return 1; | |
10096 } | |
10097 | |
10098 //----- (00475F30) -------------------------------------------------------- | |
10099 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9) | |
10100 { | |
10101 int v10; // ST20_4@2 | |
10102 int v11; // ST28_4@2 | |
10103 int v12; // ST24_4@2 | |
10104 int v13; // zf@2 | |
10105 int v14; // edi@2 | |
10106 signed int v16; // esi@5 | |
10107 int v17; // ST20_4@9 | |
10108 signed __int64 v18; // qtt@10 | |
10109 int v19; // ST14_4@11 | |
10110 int v22; // [sp+1Ch] [bp-8h]@2 | |
10111 int v23; // [sp+1Ch] [bp-8h]@10 | |
10112 signed int v24; // [sp+20h] [bp-4h]@10 | |
10113 | |
10114 v10 = fixpoint_mul(a6, a2->pFacePlane_old.vNormal.x); | |
10115 v11 = fixpoint_mul(a7, a2->pFacePlane_old.vNormal.y); | |
10116 v12 = fixpoint_mul(a8, a2->pFacePlane_old.vNormal.z); | |
10117 v13 = v10 + v12 + v11; | |
10118 v14 = v10 + v12 + v11; | |
10119 v22 = v10 + v12 + v11; | |
10120 if (a2->Ethereal() || !v13 || v14 > 0 && !a2->Portal()) | |
10121 return 0; | |
10122 v16 = -(a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z); | |
10123 if (v14 <= 0) | |
10124 { | |
10125 if (a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0) | |
10126 return 0; | |
10127 } | |
10128 else | |
10129 { | |
10130 if (v16 < 0) | |
10131 return 0; | |
10132 } | |
10133 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; | |
10134 LODWORD(v18) = v16 << 16; | |
10135 HIDWORD(v18) = v16 >> 16; | |
10136 v24 = v18 / v22; | |
10137 v23 = v18 / v22; | |
10138 LOWORD(v19) = a3 + (((unsigned int)fixpoint_mul(v23, a6) + 0x8000) >> 16); | |
10139 HIWORD(v19) = a4 + (((unsigned int)fixpoint_mul(v23, a7) + 0x8000) >> 16); | |
10140 if (v17 > abs(v14) || v23 > *a1 << 16 || !sub_4759C9(a2, a9, v19, a5 + (((unsigned int)fixpoint_mul(v23, a8) + 0x8000) >> 16))) | |
10141 return 0; | |
10142 *a1 = v24 >> 16; | |
10143 return 1; | |
10144 } | |
10145 | |
10146 //----- (00479089) -------------------------------------------------------- | |
10147 bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable) | |
10148 { | |
10149 int v3; // edi@1 | |
10150 int v4; // ebx@1 | |
10151 int v9; // eax@3 | |
10152 signed int v11; // esi@6 | |
10153 int v12; // esi@8 | |
10154 bool result; // eax@9 | |
10155 int v17; // [sp+1Ch] [bp-10h]@1 | |
10156 int v19; // [sp+20h] [bp-Ch]@3 | |
10157 int angle; // [sp+24h] [bp-8h]@1 | |
10158 | |
10159 angle = (signed int)(pODMRenderParams->uCameraFovInDegrees << 11) / 360 / 2; | |
2543 | 10160 v3 = pOutdoor->pBModels[uModelID].vBoundingCenter.x - pIndoorCameraD3D->vPartyPos.x; |
10161 v4 = pOutdoor->pBModels[uModelID].vBoundingCenter.y - pIndoorCameraD3D->vPartyPos.y; | |
10162 stru_5C6E00->Sin(pIndoorCameraD3D->sRotationX); | |
10163 v17 = v3 * stru_5C6E00->Cos(pIndoorCameraD3D->sRotationY) + v4 * stru_5C6E00->Sin(pIndoorCameraD3D->sRotationY); | |
10164 if (pIndoorCameraD3D->sRotationX) | |
10165 v17 = fixpoint_mul(v17, stru_5C6E00->Cos(pIndoorCameraD3D->sRotationX)); | |
10166 v19 = v4 * stru_5C6E00->Cos(pIndoorCameraD3D->sRotationY) - v3 * stru_5C6E00->Sin(pIndoorCameraD3D->sRotationY); | |
2496 | 10167 v9 = int_get_vector_length(abs(v3), abs(v4), 0); |
10168 //v10 = v14 * 188; | |
10169 //v22 = v9; | |
10170 *reachable = false; | |
10171 if (v9 < pOutdoor->pBModels[uModelID].sBoundingRadius + 256) | |
10172 *reachable = true; | |
10173 if (v19 >= 0) | |
10174 v11 = fixpoint_mul(stru_5C6E00->Sin(angle), v17) - fixpoint_mul(stru_5C6E00->Cos(angle), v19); | |
10175 else | |
10176 v11 = fixpoint_mul(stru_5C6E00->Cos(angle), v19) + fixpoint_mul(stru_5C6E00->Sin(angle), v17); | |
10177 v12 = v11 >> 16; | |
10178 if (v9 <= pODMRenderParams->shading_dist_mist + 2048) | |
10179 { | |
10180 //if ( abs(v12) > *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v10) + 512 ) | |
10181 if (abs(v12) > pOutdoor->pBModels[uModelID].sBoundingRadius + 512) | |
10182 { | |
10183 result = v12 < 0; | |
10184 LOBYTE(result) = v12 >= 0; | |
10185 return result; | |
10186 } | |
10187 else | |
10188 return true; | |
10189 } | |
10190 return false; | |
10191 } | |
10192 | |
10193 //----- (00479295) -------------------------------------------------------- | |
10194 int Polygon::_479295() | |
10195 { | |
10196 int v3; // ecx@4 | |
10197 int v4; // eax@4 | |
10198 int v5; // edx@4 | |
10199 // int v6; // ST14_4@5 | |
10200 Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8 | |
10201 int v11; // [sp+18h] [bp-4h]@4 | |
10202 | |
10203 if (!this->pODMFace->pFacePlane.vNormal.z) | |
10204 { | |
10205 v3 = this->pODMFace->pFacePlane.vNormal.x; | |
10206 v4 = -this->pODMFace->pFacePlane.vNormal.y; | |
10207 v5 = 0; | |
10208 v11 = 65536; | |
10209 } | |
10210 else if ((this->pODMFace->pFacePlane.vNormal.x || this->pODMFace->pFacePlane.vNormal.y) | |
10211 && abs(this->pODMFace->pFacePlane.vNormal.z) < 59082) | |
10212 { | |
10213 thisa.x = -this->pODMFace->pFacePlane.vNormal.y; | |
10214 thisa.y = this->pODMFace->pFacePlane.vNormal.x; | |
10215 thisa.z = 0; | |
10216 thisa.Normalize_float(); | |
10217 v4 = thisa.x; | |
10218 v3 = thisa.y; | |
10219 v5 = 0; | |
10220 v11 = 65536; | |
10221 } | |
10222 else | |
10223 { | |
10224 v3 = 0; | |
10225 v4 = 65536; | |
10226 v11 = 0; | |
10227 v5 = -65536; | |
10228 } | |
10229 sTextureDeltaU = this->pODMFace->sTextureDeltaU; | |
10230 sTextureDeltaV = this->pODMFace->sTextureDeltaV; | |
10231 ptr_38->_48616B_frustum_odm(v4, v3, 0, 0, v5, v11); | |
10232 return 1; | |
10233 } | |
10234 | |
10235 | |
10236 unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr) | |
10237 { | |
10238 #pragma pack(push, 1) | |
10239 struct TGAHeader | |
10240 { | |
10241 unsigned char tgaSkip; | |
10242 unsigned char colourmaptype; // type of colour map 0=none, 1=has palette | |
10243 unsigned char tgaType; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed | |
10244 | |
10245 short colourmapstart; // first colour map entry in palette | |
10246 short colourmaplength; // number of colours in palette | |
10247 char colourmapbits; // number of bits per palette entry 15,16,24,32 | |
10248 | |
10249 //unsigned char tgaDontCare2[9]; | |
10250 short xstart; // image x origin | |
10251 short ystart; // image y origin | |
10252 | |
10253 unsigned short tgaWidth; | |
10254 unsigned short tgaHeight; | |
10255 unsigned char tgaBPP; | |
10256 | |
10257 char descriptor; // image descriptor bits: 00vhaaaa | |
10258 // h horizontal flip | |
10259 // v vertical flip | |
10260 // a alpha bits | |
10261 }; | |
10262 #pragma pack(pop) | |
10263 | |
10264 if (out_width) | |
10265 *out_width = 0; | |
10266 if (out_height) | |
10267 *out_height = 0; | |
10268 | |
10269 DWORD w; | |
10270 void* file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); | |
10271 if (file == INVALID_HANDLE_VALUE) | |
10272 return nullptr; | |
10273 | |
10274 TGAHeader header; | |
10275 ReadFile(file, &header, sizeof(header), &w, nullptr); | |
10276 SetFilePointer(file, header.tgaSkip, nullptr, FILE_CURRENT); | |
10277 | |
10278 if (header.tgaBPP != 24 || header.tgaType != 2) | |
10279 { | |
10280 CloseHandle(file); | |
10281 return nullptr; | |
10282 } | |
10283 | |
10284 int imgSize = header.tgaWidth * header.tgaHeight * 3; | |
10285 unsigned char* pixels = new unsigned char[imgSize]; | |
10286 ReadFile(file, pixels, imgSize, &w, nullptr); | |
10287 CloseHandle(file); | |
10288 | |
10289 if (w != imgSize) | |
10290 { | |
10291 delete[] pixels; | |
10292 return nullptr; | |
10293 } | |
10294 | |
10295 if (out_width) | |
10296 *out_width = header.tgaWidth; | |
10297 if (out_height) | |
10298 *out_height = header.tgaHeight; | |
10299 | |
10300 unsigned short* pixels_16bit = new unsigned short[imgSize / 3]; | |
10301 for (int i = 0; i < imgSize / 3; ++i) | |
10302 { | |
10303 pixels_16bit[i] = (pixels[i * 3] / 8 & 0x1F) | | |
10304 ((pixels[i * 3 + 1] / 4 & 0x3F) << 5) | | |
10305 ((pixels[i * 3 + 2] / 8 & 0x1F) << 11); | |
10306 } | |
10307 delete[] pixels; | |
10308 return pixels_16bit; | |
10309 } | |
10310 | |
10311 unsigned short *skybox_xn, *skybox_xp, | |
10312 *skybox_yn, *skybox_yp, | |
10313 *skybox_zn, *skybox_zp; | |
10314 int skybox_width, skybox_height; | |
10315 | |
10316 IDirect3DTexture2 *skybox_texture; | |
10317 IDirectDrawSurface4 *skybox_surface; | |
10318 | |
10319 bool Skybox_Initialize(const wchar_t *skybox_name) | |
10320 { | |
10321 wchar_t xn_filename[1024], xp_filename[1024], | |
10322 yn_filename[1024], yp_filename[1024], | |
10323 zn_filename[1024], zp_filename[1024]; | |
10324 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); | |
10325 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); | |
10326 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); | |
10327 | |
10328 int xn_width, xn_height; | |
10329 skybox_xn = LoadTgaTexture(xn_filename, &xn_width, &xn_height); | |
10330 if (!skybox_xn) | |
10331 return false; | |
10332 | |
10333 int xp_width, xp_height; | |
10334 skybox_xp = LoadTgaTexture(xp_filename, &xp_width, &xp_height); | |
10335 if (!skybox_xp || xp_width != xn_width || xp_height != xn_height) | |
10336 { | |
10337 delete[] skybox_xn; | |
10338 delete[] skybox_xp; | |
10339 return false; | |
10340 } | |
10341 | |
10342 int yn_width, yn_height; | |
10343 skybox_yn = LoadTgaTexture(yn_filename, &yn_width, &yn_height); | |
10344 if (!skybox_yn || yn_width != xn_width || yn_height != xn_height) | |
10345 { | |
10346 delete[] skybox_xn; | |
10347 delete[] skybox_xp; | |
10348 delete[] skybox_yn; | |
10349 return false; | |
10350 } | |
10351 | |
10352 int yp_width, yp_height; | |
10353 skybox_yp = LoadTgaTexture(yp_filename, &yp_width, &yp_height); | |
10354 if (!skybox_yp || yp_width != xn_width || yp_height != xn_height) | |
10355 { | |
10356 delete[] skybox_xn; | |
10357 delete[] skybox_xp; | |
10358 delete[] skybox_yn; | |
10359 delete[] skybox_yp; | |
10360 return false; | |
10361 } | |
10362 | |
10363 int zn_width, zn_height; | |
10364 skybox_zn = LoadTgaTexture(zn_filename, &zn_width, &zn_height); | |
10365 if (!skybox_zn || zn_width != xn_width || zn_height != xn_height) | |
10366 { | |
10367 delete[] skybox_xn; | |
10368 delete[] skybox_xp; | |
10369 delete[] skybox_yn; | |
10370 delete[] skybox_yp; | |
10371 delete[] skybox_zn; | |
10372 return false; | |
10373 } | |
10374 | |
10375 int zp_width, zp_height; | |
10376 skybox_zp = LoadTgaTexture(zp_filename, &zp_width, &zp_height); | |
10377 if (!skybox_zp || zp_width != xn_width || zp_height != xn_height) | |
10378 { | |
10379 delete[] skybox_xn; | |
10380 delete[] skybox_xp; | |
10381 delete[] skybox_yn; | |
10382 delete[] skybox_yp; | |
10383 delete[] skybox_zn; | |
10384 delete[] skybox_zp; | |
10385 return false; | |
10386 } | |
10387 | |
10388 skybox_width = xn_width; | |
10389 skybox_height = xn_height; | |
10390 | |
10391 __debugbreak(); | |
10392 //if (!pRenderer->pRenderD3D->CreateTexture(skybox_width, skybox_height, &skybox_surface, &skybox_texture, | |
10393 //false, false, pRenderer->uMinDeviceTextureDim)) | |
10394 return false; | |
10395 | |
10396 return true; | |
10397 } | |
10398 | |
10399 struct vector | |
10400 { | |
10401 float x, y, z; | |
10402 }; | |
10403 | |
10404 struct matrix | |
10405 { | |
10406 float m[4][4]; | |
10407 }; | |
10408 | |
10409 void VectorNormalize(vector *v) | |
10410 { | |
10411 float invmag = 1.0f / sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); | |
10412 v->x *= invmag; | |
10413 v->y *= invmag; | |
10414 v->z *= invmag; | |
10415 } | |
10416 | |
10417 void MatrixRotationAxis(matrix *pout, CONST vector *pv, float angle) | |
10418 { | |
10419 memset(pout, 0, sizeof(matrix)); | |
10420 pout->m[3][0] = 0; | |
10421 pout->m[3][1] = 0; | |
10422 pout->m[3][2] = 0; | |
10423 pout->m[3][3] = 1; | |
10424 | |
10425 vector v; | |
10426 v.x = pv->x; v.y = pv->y; v.z = pv->z; | |
10427 VectorNormalize(&v); | |
10428 | |
10429 pout->m[0][0] = (1.0f - cos(angle)) * v.x * v.x + cos(angle); | |
10430 pout->m[1][0] = (1.0f - cos(angle)) * v.x * v.y - sin(angle) * v.z; | |
10431 pout->m[2][0] = (1.0f - cos(angle)) * v.x * v.z + sin(angle) * v.y; | |
10432 pout->m[0][1] = (1.0f - cos(angle)) * v.y * v.x + sin(angle) * v.z; | |
10433 pout->m[1][1] = (1.0f - cos(angle)) * v.y * v.y + cos(angle); | |
10434 pout->m[2][1] = (1.0f - cos(angle)) * v.y * v.z - sin(angle) * v.x; | |
10435 pout->m[0][2] = (1.0f - cos(angle)) * v.z * v.x - sin(angle) * v.y; | |
10436 pout->m[1][2] = (1.0f - cos(angle)) * v.z * v.y + sin(angle) * v.x; | |
10437 pout->m[2][2] = (1.0f - cos(angle)) * v.z * v.z + cos(angle); | |
10438 } | |
10439 | |
10440 void VectorTransform(const matrix *m, const vector *v, vector *out) | |
10441 { | |
10442 out->x = m->m[0][0] * v->x + m->m[1][0] * v->y + m->m[2][0] * v->z + m->m[3][0]; | |
10443 out->y = m->m[0][1] * v->x + m->m[1][1] * v->y + m->m[2][1] * v->z + m->m[3][1]; | |
10444 out->z = m->m[0][2] * v->x + m->m[1][2] * v->y + m->m[2][2] * v->z + m->m[3][2]; | |
10445 } | |
10446 | |
10447 bool DrawSkyD3D_Skybox() | |
10448 { | |
10449 static bool initialized = false, | |
10450 initialization_failed = false; | |
10451 if (initialization_failed) | |
10452 return false; | |
10453 | |
10454 static int last_camera_rot_y, | |
10455 last_camera_rot_x; | |
10456 if (!initialized) | |
10457 { | |
10458 if (!Skybox_Initialize(L"data/skybox/stars")) | |
10459 { | |
10460 initialization_failed = true; | |
10461 return false; | |
10462 } | |
10463 initialized = true; | |
10464 | |
10465 last_camera_rot_y = pParty->sRotationY + 1; // force update for the first run | |
10466 last_camera_rot_x = pParty->sRotationX + 1; | |
10467 } | |
10468 | |
10469 /* | |
10470 r(y) = | |
10471 cos y 0 sin y 0 | |
10472 0 1 0 0 | |
10473 -sin y 0 cos y 0 | |
10474 0 0 0 1 | |
10475 | |
10476 x cos y - z sin y | |
10477 y | |
10478 x sin y + z cos y | |
10479 1 | |
10480 | |
10481 | |
10482 | |
10483 r(x) = // should be r(right) actually | |
10484 1 0 0 0 | |
10485 0 cos x -sin x 0 | |
10486 0 sin x cos x 0 | |
10487 0 0 0 1 | |
10488 | |
10489 | |
10490 x | |
10491 y cos x + z sin x | |
10492 -y sin x + z cos x | |
10493 1 | |
10494 | |
10495 */ | |
10496 | |
10497 if (last_camera_rot_y == pParty->sRotationY && | |
10498 last_camera_rot_x == pParty->sRotationX) | |
10499 { | |
10500 draw: | |
10501 struct RenderVertexD3D3 v[6]; | |
10502 | |
10503 v[0].pos.x = pViewport->uScreen_TL_X; | |
10504 v[0].pos.y = pViewport->uScreen_TL_Y; | |
10505 v[0].pos.z = 0.99989998; | |
10506 v[0].rhw = 1; | |
10507 v[0].diffuse = -1; | |
10508 v[0].specular = 0; | |
10509 v[0].texcoord.x = 0; | |
10510 v[0].texcoord.y = 0; | |
10511 | |
10512 v[1].pos.x = pViewport->uScreen_TL_X + pViewport->uScreenWidth; | |
10513 v[1].pos.y = pViewport->uScreen_TL_Y + pViewport->uScreenHeight; | |
10514 v[1].pos.z = 0.99989998; | |
10515 v[1].rhw = 1; | |
10516 v[1].diffuse = -1; | |
10517 v[1].specular = 0; | |
10518 v[1].texcoord.x = (float)pViewport->uScreenWidth / skybox_width; | |
10519 v[1].texcoord.y = (float)pViewport->uScreenHeight / skybox_height; | |
10520 | |
10521 v[2].pos.x = pViewport->uScreen_TL_X + pViewport->uScreenWidth; | |
10522 v[2].pos.y = pViewport->uScreen_TL_Y; | |
10523 v[2].pos.z = 0.99989998; | |
10524 v[2].rhw = 1; | |
10525 v[2].diffuse = -1; | |
10526 v[2].specular = 0; | |
10527 v[2].texcoord.x = (float)pViewport->uScreenWidth / skybox_width; | |
10528 v[2].texcoord.y = 0; | |
10529 | |
10530 memcpy(&v[3], &v[0], sizeof(*v)); | |
10531 | |
10532 v[4].pos.x = pViewport->uScreen_TL_X; | |
10533 v[4].pos.y = pViewport->uScreen_TL_Y + pViewport->uScreenHeight; | |
10534 v[4].pos.z = 0.99989998; | |
10535 v[4].rhw = 1; | |
10536 v[4].diffuse = -1; | |
10537 v[4].specular = 0; | |
10538 v[4].texcoord.x = 0; | |
10539 v[4].texcoord.y = (float)pViewport->uScreenHeight / skybox_height; | |
10540 | |
10541 memcpy(&v[5], &v[1], sizeof(*v)); | |
10542 | |
10543 __debugbreak(); | |
10544 /* | |
10545 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); | |
10546 pRenderer->pRenderD3D->pDevice->SetTexture(0, skybox_texture); | |
10547 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v, 6, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); | |
10548 */ | |
10549 return true; | |
10550 } | |
10551 | |
10552 | |
10553 DDSURFACEDESC2 desc; | |
10554 desc.dwSize = sizeof(desc); | |
10555 if (!pRenderer->LockSurface_DDraw4(skybox_surface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY)) | |
10556 return false; | |
10557 | |
10558 last_camera_rot_y = pParty->sRotationY; | |
10559 last_camera_rot_x = pParty->sRotationX; | |
10560 | |
10561 float aspect = (float)pViewport->uScreenWidth / (float)pViewport->uScreenHeight; | |
10562 float fov_x = 3.141592f * (pODMRenderParams->uCameraFovInDegrees + 0) / 360.0f; | |
10563 float fov_y = fov_x / aspect; | |
10564 | |
10565 float ray_dx = fov_x / (float)pViewport->uScreenWidth, | |
10566 ray_dy = fov_y / (float)pViewport->uScreenHeight; | |
2534 | 10567 float party_angle_x = 2 * pi_double * pParty->sRotationX / 2048.0, |
10568 party_angle_y = 2 * pi_double * pParty->sRotationY / 2048.0; | |
2496 | 10569 for (int y = 0; y < pViewport->uScreenHeight; ++y) |
10570 for (int x = 0; x < pViewport->uScreenWidth; ++x) | |
10571 { | |
10572 float angle_x = party_angle_x - (y - pViewport->uScreenHeight / 2) * ray_dy; | |
10573 float angle_y = party_angle_y - (x - pViewport->uScreenWidth / 2) * ray_dx; | |
10574 | |
10575 float _dir_x_ = 1, | |
10576 _dir_y_ = 0, | |
10577 _dir_z_ = 0; | |
10578 | |
10579 float dir_x_ = _dir_x_ * cosf(angle_y);// - _dir_z_ * sinf(angle_y); // rotation around y | |
10580 //float dir_y_ = _dir_y_; | |
10581 float dir_z_ = _dir_x_ * sinf(angle_y);// + _dir_z_ * cosf(angle_y); | |
10582 | |
10583 //float dir_x = dir_x_; // rotation around x | |
10584 //float dir_y = /*dir_y_ * cosf(angle_x)*/ + dir_z_ * sinf(angle_x); | |
10585 //float dir_z = /*-dir_y_ * sinf(angle_x)*/ + dir_z_ * cosf(angle_x); | |
10586 | |
10587 vector right; // rotate around right actually to avoid space distortion | |
10588 right.x = /*dir_y * 0*/ -dir_z_ * 1; | |
10589 right.y = /*dir_z_ * 0 - dir_x_ * */0; | |
10590 right.z = dir_x_ * 1/* - dir_y_ * 0*/; | |
10591 //VectorNormalize(&right); | |
10592 | |
10593 matrix rightMatrix; | |
10594 MatrixRotationAxis(&rightMatrix, &right, angle_x); | |
10595 | |
10596 vector v1, v2; | |
10597 v1.x = dir_x_; v1.y = 0; v1.z = dir_z_; | |
10598 VectorTransform(&rightMatrix, &v1, &v2); | |
10599 | |
10600 float dir_x = v2.x, | |
10601 dir_y = v2.y, | |
10602 dir_z = v2.z; | |
10603 | |
10604 float abs_dir_x = fabsf(dir_x), | |
10605 abs_dir_y = fabsf(dir_y), | |
10606 abs_dir_z = fabsf(dir_z); | |
10607 | |
10608 unsigned short color = (0x1F << 11) | (0x1F << 5) | (5); //default to orange | |
10609 if (abs_dir_x >= abs_dir_y) | |
10610 { | |
10611 if (abs_dir_x >= abs_dir_z) | |
10612 { | |
10613 if (dir_x >= 0) | |
10614 { | |
10615 float instersect_y = dir_y / (2.0f * dir_x); // plane equation for this side is x + 0.5 = 0 | |
10616 float instersect_z = dir_z / (2.0f * dir_x); | |
10617 | |
10618 float u = 1.0f - (instersect_z + 0.5f), | |
10619 v = 1.0f - (instersect_y + 0.5f); | |
10620 | |
10621 int tx = u * (skybox_width - 1), | |
10622 ty = v * (skybox_height - 1); | |
10623 | |
10624 color = skybox_xp[ty * skybox_width + tx]; | |
10625 //color = ty * 0x1F / skybox_height; | |
10626 } | |
10627 else | |
10628 { | |
10629 float instersect_y = dir_y / (2.0f * dir_x); | |
10630 float instersect_z = dir_z / (2.0f * dir_x); | |
10631 | |
10632 float u = 1.0f - (instersect_z + 0.5f), | |
10633 v = instersect_y + 0.5f; | |
10634 | |
10635 int tx = u * (skybox_width - 1), | |
10636 ty = v * (skybox_height - 1); | |
10637 | |
10638 color = skybox_xn[ty * skybox_width + tx]; | |
10639 //color = tx * 0x1F / skybox_height; | |
10640 } | |
10641 } | |
10642 else if (dir_z >= 0) | |
10643 goto DIR_ZP; | |
10644 else | |
10645 goto DIR_ZN; | |
10646 } | |
10647 else if (abs_dir_y >= abs_dir_z) | |
10648 { | |
10649 if (dir_y >= 0) | |
10650 { | |
10651 float instersect_x = dir_x / (2.0f * dir_y); | |
10652 float instersect_z = dir_z / (2.0f * dir_y); | |
10653 | |
10654 float u = instersect_x + 0.5f, | |
10655 v = instersect_z + 0.5f; | |
10656 | |
10657 int tx = u * (skybox_width - 1), | |
10658 ty = v * (skybox_height - 1); | |
10659 | |
10660 color = skybox_yp[ty * skybox_width + tx]; | |
10661 //color = tx * 0x1F / skybox_height; | |
10662 } | |
10663 /*else should never be seen i guess | |
10664 { | |
10665 __debugbreak(); | |
10666 // -y | |
10667 //Log::Warning(L"(%03u, %03u): -y", x, y); | |
10668 }*/ | |
10669 } | |
10670 else if (dir_z >= 0) | |
10671 { | |
10672 DIR_ZP: | |
10673 // +z | |
10674 float instersect_x = dir_x / (2.0f * dir_z); | |
10675 float instersect_y = dir_y / (2.0f * dir_z); | |
10676 //float intersect_z = 0.5f; | |
10677 | |
10678 float u = instersect_x + 0.5f, | |
10679 v = -instersect_y + 0.5f; | |
10680 | |
10681 int tx = u * (skybox_width - 1), | |
10682 ty = v * (skybox_height - 1); | |
10683 | |
10684 color = skybox_zp[ty * skybox_width + tx]; | |
10685 } | |
10686 else | |
10687 { | |
10688 DIR_ZN: | |
10689 // -z | |
10690 float instersect_x = -dir_x / (2.0f * dir_z); | |
10691 float instersect_y = -dir_y / (2.0f * dir_z); | |
10692 //float intersect_z = -0.5f; | |
10693 | |
10694 float u = 1.0f - instersect_x - 0.5f, | |
10695 v = -instersect_y + 0.5f; | |
10696 | |
10697 int tx = u * (skybox_width - 1), | |
10698 ty = v * (skybox_height - 1); | |
10699 | |
10700 color = skybox_zn[ty * skybox_width + tx]; | |
10701 } | |
10702 | |
10703 //pRenderer->pTargetSurface[(pViewport->uScreenY + y) * pRenderer->uTargetSurfacePitch + pViewport->uScreenX + x] = color; | |
10704 ((unsigned __int16 *)((char *)desc.lpSurface + y * desc.lPitch))[x] = color; | |
10705 } | |
10706 | |
10707 ErrD3D((skybox_surface)->Unlock(0)); | |
10708 goto draw; | |
10709 } | |
10710 | |
10711 //----- (00485F53) -------------------------------------------------------- | |
10712 void sr_485F53(Vec2_int_ *v) | |
10713 { | |
10714 ++v->y; | |
10715 if (v->y > 1000) | |
10716 v->y = 0; | |
10717 } | |
10718 | |
10719 //----- (0048607B) -------------------------------------------------------- | |
10720 void Polygon::Create_48607B(stru149 *a2) | |
10721 { | |
10722 this->pTexture = 0; | |
10723 this->ptr_38 = a2; | |
10724 } | |
10725 | |
10726 //----- (00486089) -------------------------------------------------------- | |
10727 void Polygon::_normalize_v_18() | |
10728 { | |
10729 //double v2; // st7@1 | |
10730 //double v3; // st6@1 | |
10731 //double v5; // st5@1 | |
10732 | |
10733 // v2 = (double)this->v_18.x; | |
10734 //v3 = (double)this->v_18.y; | |
10735 // v5 = (double)this->v_18.z; | |
10736 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); | |
10737 if (fabsf(len) < 1e-6f) | |
10738 { | |
10739 v_18.x = 0; | |
10740 v_18.y = 0; | |
10741 v_18.z = 65536; | |
10742 } | |
10743 else | |
10744 { | |
10745 v_18.x = round_to_int((double)this->v_18.x / len * 65536.0); | |
10746 v_18.y = round_to_int((double)this->v_18.y / len * 65536.0); | |
10747 v_18.y = round_to_int((double)this->v_18.z / len * 65536.0); | |
10748 } | |
10749 } | |
10750 | |
10751 //----- (0048616B) -------------------------------------------------------- | |
10752 void stru149::_48616B_frustum_odm(int a2, int a3, int a4, int a5, int a6, int a7) | |
10753 { | |
10754 int v7; // ebx@1 | |
10755 int v9; // edi@1 | |
10756 int v11; // edx@1 | |
10757 int v17; // ST0C_4@6 | |
10758 int v19; // ST0C_4@9 | |
10759 int v24; // [sp+14h] [bp-14h]@1 | |
10760 int v25; // [sp+18h] [bp-10h]@1 | |
10761 int v27; // [sp+24h] [bp-4h]@1 | |
10762 | |
2543 | 10763 v25 = pIndoorCameraD3D->int_cosine_x; |
10764 v7 = pIndoorCameraD3D->int_sine_y; | |
10765 v27 = pIndoorCameraD3D->int_sine_x; | |
2496 | 10766 //v8 = -pIndoorCamera->pos.y; |
2543 | 10767 v9 = pIndoorCameraD3D->int_cosine_y; |
2496 | 10768 //v26 = -pIndoorCamera->pos.z; |
2543 | 10769 v11 = pIndoorCameraD3D->int_cosine_y * -pIndoorCameraD3D->vPartyPos.x + pIndoorCameraD3D->int_sine_y * -pIndoorCameraD3D->vPartyPos.y; |
10770 v24 = pIndoorCameraD3D->int_cosine_y * -pIndoorCameraD3D->vPartyPos.y - pIndoorCameraD3D->int_sine_y * -pIndoorCameraD3D->vPartyPos.x; | |
10771 if (pIndoorCameraD3D->sRotationX) | |
2496 | 10772 { |
2543 | 10773 this->field_0_party_dir_x = fixpoint_mul(v11, pIndoorCameraD3D->int_cosine_x) + |
10774 fixpoint_mul((-pIndoorCameraD3D->vPartyPos.z) << 16, pIndoorCameraD3D->int_sine_x); | |
2496 | 10775 this->field_4_party_dir_y = v24; |
2543 | 10776 this->field_8_party_dir_z = fixpoint_mul((-pIndoorCameraD3D->vPartyPos.z) << 16, v25) - fixpoint_mul(v11, v27); |
2496 | 10777 } |
10778 else | |
10779 { | |
10780 this->field_0_party_dir_x = v11; | |
10781 this->field_4_party_dir_y = v24; | |
2543 | 10782 this->field_8_party_dir_z = (-pIndoorCameraD3D->vPartyPos.z) << 16; |
2496 | 10783 } |
10784 | |
2543 | 10785 if (pIndoorCameraD3D->sRotationX) |
2496 | 10786 { |
10787 v17 = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7); | |
10788 | |
10789 this->angle_from_north = fixpoint_mul(v17, v25) + fixpoint_mul(a4, v27); | |
10790 this->angle_from_west = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7); | |
10791 this->viewing_angle_from_west_east = fixpoint_mul(a4, v25) - fixpoint_mul(v17, v27); | |
10792 } | |
10793 else | |
10794 { | |
10795 this->angle_from_north = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7); | |
10796 this->angle_from_west = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7); | |
10797 this->viewing_angle_from_west_east = a4; | |
10798 } | |
10799 | |
2543 | 10800 if (pIndoorCameraD3D->sRotationX) |
2496 | 10801 { |
10802 v19 = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7); | |
10803 | |
10804 this->angle_from_east = fixpoint_mul(v19, v25) + fixpoint_mul(a7, v27); | |
10805 this->angle_from_south = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7); | |
10806 this->viewing_angle_from_north_south = fixpoint_mul(a7, v25) - fixpoint_mul(v19, v27); | |
10807 } | |
10808 else | |
10809 { | |
10810 this->angle_from_east = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7); | |
10811 this->angle_from_south = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7); | |
10812 this->viewing_angle_from_north_south = a7; | |
10813 } | |
10814 | |
10815 this->angle_from_east = -this->angle_from_east; | |
10816 this->angle_from_south = -this->angle_from_south; | |
10817 this->viewing_angle_from_north_south = -this->viewing_angle_from_north_south; | |
10818 | |
10819 this->field_24 = fixpoint_dot(this->angle_from_north, this->field_0_party_dir_x, | |
10820 this->angle_from_west, this->field_4_party_dir_y, | |
10821 this->viewing_angle_from_west_east, this->field_8_party_dir_z); | |
10822 this->field_28 = fixpoint_dot(this->angle_from_east, this->field_0_party_dir_x, | |
10823 this->angle_from_south, this->field_4_party_dir_y, | |
10824 this->viewing_angle_from_north_south, this->field_8_party_dir_z); | |
10825 } | |
10826 | |
10827 //----- (0048694B) -------------------------------------------------------- | |
10828 void stru149::_48694B_frustum_sky() | |
10829 { | |
10830 this->angle_from_east = -this->angle_from_east; | |
10831 this->angle_from_south = -this->angle_from_south; | |
10832 this->viewing_angle_from_north_south = -this->viewing_angle_from_north_south; | |
10833 | |
10834 this->field_24 = fixpoint_dot(this->angle_from_north, this->field_0_party_dir_x, | |
10835 this->angle_from_west, this->field_4_party_dir_y, | |
10836 this->viewing_angle_from_west_east, this->field_8_party_dir_z); | |
10837 this->field_28 = fixpoint_dot(this->angle_from_east, this->field_0_party_dir_x, | |
10838 this->angle_from_south, this->field_4_party_dir_y, | |
10839 this->viewing_angle_from_north_south, this->field_8_party_dir_z); | |
10840 } | |
10841 |