Mercurial > mm7
annotate Render.cpp @ 152:796b79187c27
Слияние
author | Ritor1 |
---|---|
date | Tue, 12 Feb 2013 15:28:36 +0600 |
parents | d92c78ab54fe 8ab4484c22e0 |
children | 49e74dee4eab |
rev | line source |
---|---|
140 | 1 #include <assert.h> |
2 | |
0 | 3 #include "Render.h" |
4 #include "OutdoorCamera.h" | |
5 #include "IndoorCamera.h" | |
6 #include "Outdoor.h" | |
7 #include "Party.h" | |
8 #include "LOD.h" | |
9 #include "Viewport.h" | |
10 #include "Math.h" | |
11 #include "PaletteManager.h" | |
12 #include "Time.h" | |
13 #include "Game.h" | |
14 #include "LightmapBuilder.h" | |
15 #include "stru220.h" | |
16 #include "ObjectList.h" | |
17 #include "LayingItem.h" | |
18 #include "DecorationList.h" | |
19 #include "Allocator.h" | |
20 #include "OSInfo.h" | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
21 #include "Actor.h" |
0 | 22 #include "Log.h" |
23 | |
24 #include "mm7_data.h" | |
25 | |
26 | |
27 #pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") | |
28 #pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 struct IDirectDrawClipper *pDDrawClipper; | |
37 struct Render *pRenderer; // idb | |
67 | 38 struct RenderVertexD3D3 pVertices[50]; |
0 | 39 int uNumDecorationsDrawnThisFrame; // weak |
40 RenderBillboard pBillboardRenderList[500]; | |
41 unsigned int uNumBillboardsToDraw; | |
42 int uNumSpritesDrawnThisFrame; // weak | |
43 | |
44 | |
45 RenderVertexSoft array_507D30[50]; | |
46 RenderVertexSoft array_508690[50]; | |
47 RenderVertexSoft array_508FF0[50]; | |
48 RenderVertexSoft array_509950[50]; | |
49 RenderVertexSoft array_50A2B0[50]; | |
50 RenderVertexSoft array_50AC10[50]; | |
51 | |
52 RenderVertexSoft array_73D150[20]; | |
53 | |
54 RenderVertexD3D3 arary_77E5C8[50]; | |
55 | |
56 RenderVertexSoft *ptr_801A04; | |
57 RenderVertexSoft *ptr_801A08; | |
58 | |
59 RenderVertexSoft pVerticesSR_801A10[384]; | |
60 RenderVertexSoft pVerticesSR_806210[384]; | |
61 | |
62 | |
63 | |
64 | |
65 | |
66 | |
67 | |
68 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); | |
69 | |
70 | |
71 /* 384 */ | |
72 #pragma pack(push, 1) | |
73 struct PCXHeader_1 | |
74 { | |
75 char manufacturer; | |
76 char version; | |
77 char encoding; | |
78 char bpp; | |
79 __int16 left; | |
80 __int16 up; | |
81 __int16 right; | |
82 __int16 bottom; | |
83 __int16 hdpi; | |
84 __int16 vdpi; | |
85 }; | |
86 #pragma pack(pop) | |
87 | |
88 /* 385 */ | |
89 #pragma pack(push, 1) | |
90 struct PCXHeader_2 | |
91 { | |
92 char reserved; | |
93 char planes; | |
94 __int16 pitch; | |
95 __int16 palette_info; | |
96 }; | |
97 #pragma pack(pop) | |
98 | |
99 | |
100 | |
101 | |
102 | |
103 | |
104 | |
105 | |
106 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
107 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
108 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
109 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
110 | |
111 | |
112 | |
113 | |
114 | |
115 | |
116 | |
117 | |
118 | |
119 | |
120 | |
121 | |
122 //----- (0049E79F) -------------------------------------------------------- | |
123 bool __cdecl CheckTextureStages() | |
124 { | |
125 bool v0; // edi@1 | |
126 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
127 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
128 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
129 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
130 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
131 | |
132 v0 = false; | |
133 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); | |
134 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
135 | |
136 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
137 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u)); | |
138 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2u)); | |
139 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
140 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
141 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
142 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1u)); | |
143 | |
144 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
145 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, 3u)); | |
146 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1u)); | |
147 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7u)); | |
148 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2u)); | |
149 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1u)); | |
150 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2u)); | |
151 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2u)); | |
152 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1u)); | |
153 | |
154 if ( !pRenderer->pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
155 v0 = true; | |
156 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); | |
157 pTexture1->Release(); | |
158 pTexture2->Release(); | |
159 pSurface1->Release(); | |
160 pSurface2->Release(); | |
161 return v0; | |
162 } | |
163 | |
164 | |
165 | |
166 | |
167 | |
168 | |
169 | |
170 | |
171 | |
172 | |
173 | |
174 | |
175 | |
176 //----- (00440CB8) -------------------------------------------------------- | |
177 void Render::DrawBillboardList_BLV() | |
178 { | |
179 __int16 v2; // ax@3 | |
180 int v5; // eax@11 | |
181 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
182 | |
183 soft_billboard.uParentBillboardID = -1; | |
184 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; | |
185 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
186 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
187 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
188 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
189 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
190 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
191 | |
192 pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw; | |
193 | |
194 for (uint i = 0; i < uNumBillboardsToDraw; ++i) | |
195 { | |
196 auto p = pBillboardRenderList + i; | |
197 | |
198 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
199 soft_billboard.uParentBillboardID = i; | |
200 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
201 soft_billboard._screenspace_x_scaler_packedfloat = p->_screenspace_x_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
202 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 203 soft_billboard.sZValue = p->sZValue; |
204 soft_billboard.uFlags = p->field_1E; | |
205 soft_billboard.uTintColor = p->uTintColor; | |
206 v2 = p->uHwSpriteID; | |
207 if ( v2 != -1 ) | |
208 { | |
209 if ( pRenderer->pRenderD3D ) | |
210 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->uPaletteSubindex); | |
211 else | |
212 { | |
213 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->uPaletteSubindex, 1); | |
214 if (p->field_1E & 0x0100) | |
215 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
216 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
217 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1); | |
218 v5 = p->uHwSpriteID; | |
219 if ( v5 >= 0 ) | |
220 pSprites_LOD->pSpriteHeaders[v5]._4ACC38(&soft_billboard, 1); | |
221 } | |
222 } | |
223 } | |
224 } | |
225 | |
226 | |
227 | |
228 | |
229 | |
230 //----- (004A16A5) -------------------------------------------------------- | |
231 bool __cdecl AreRenderSurfacesOk() | |
232 { | |
233 char v0; // zf@4 | |
234 bool result; // eax@8 | |
235 | |
236 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
237 { | |
238 if ( !pRenderer->pBackBuffer4 ) | |
239 goto LABEL_9; | |
240 v0 = pRenderer->pFrontBuffer4 == 0; | |
241 } | |
242 else | |
243 { | |
244 if ( !pRenderer->pBackBuffer2 ) | |
245 goto LABEL_9; | |
246 v0 = pRenderer->pFrontBuffer2 == 0; | |
247 } | |
248 if ( !v0 ) | |
249 { | |
250 LOBYTE(result) = 1; | |
251 return result; | |
252 } | |
253 LABEL_9: | |
254 LOBYTE(result) = 0; | |
255 return result; | |
256 } | |
257 | |
258 | |
259 | |
260 //----- (00487389) -------------------------------------------------------- | |
261 __int16 Render::ExecOutdoorDrawSW() | |
262 { | |
263 unsigned __int16 *v0; // ebx@1 | |
264 unsigned int v1; // esi@1 | |
265 stru148 *v2; // eax@1 | |
266 Span *v3; // edi@6 | |
267 stru148 *v4; // esi@9 | |
268 Texture *v5; // ebp@10 | |
269 int v6; // esi@16 | |
270 unsigned int v7; // edx@16 | |
271 char *v8; // ecx@17 | |
272 unsigned int v9; // edi@22 | |
273 int v10; // eax@26 | |
274 int v11; // eax@27 | |
275 unsigned int v12; // ebp@32 | |
276 Span *v13; // esi@33 | |
277 int v14; // ecx@37 | |
278 int v15; // eax@40 | |
279 Texture *v16; // ebp@51 | |
280 unsigned int v17; // eax@51 | |
281 int v18; // eax@54 | |
282 char v19; // al@56 | |
283 unsigned int v20; // eax@57 | |
284 int v21; // ecx@57 | |
285 unsigned int v22; // eax@57 | |
286 stru149 *v23; // eax@65 | |
287 int v24; // eax@67 | |
288 ODMFace *v25; // eax@78 | |
289 signed int v26; // edx@79 | |
290 signed int v27; // ecx@79 | |
291 unsigned int v28; // eax@106 | |
292 unsigned int v29; // ebp@117 | |
293 Span *v30; // esi@118 | |
294 unsigned int v31; // ST04_4@124 | |
295 int v33; // [sp+18h] [bp-44h]@80 | |
296 signed int v34; // [sp+1Ch] [bp-40h]@3 | |
297 signed int v35; // [sp+20h] [bp-3Ch]@79 | |
298 Span **v36; // [sp+24h] [bp-38h]@4 | |
299 unsigned int v37; // [sp+28h] [bp-34h]@1 | |
300 unsigned __int16 *a1; // [sp+2Ch] [bp-30h]@1 | |
301 int a1a; // [sp+2Ch] [bp-30h]@26 | |
302 unsigned int a1b; // [sp+2Ch] [bp-30h]@116 | |
303 char v41; // [sp+30h] [bp-2Ch]@57 | |
304 | |
305 v0 = pRenderer->pTargetSurface; | |
306 v1 = pOutdoorCamera->numStru148s; | |
307 a1 = pRenderer->pTargetSurface; | |
308 v2 = array_77EC08; | |
309 v37 = pOutdoorCamera->numStru148s; | |
310 if ( !(pParty->uFlags & 2) ) | |
311 { | |
312 v1 = uNumElementsIn80AA28; | |
313 v2 = ptr_80AA28[0]; | |
314 v37 = uNumElementsIn80AA28; | |
315 } | |
316 v34 = 0; | |
317 if ( (signed int)v1 > 0 ) | |
318 { | |
319 v36 = &v2->prolly_head; | |
320 do | |
321 { | |
322 if ( pParty->uFlags & 2 ) | |
323 v3 = *v36; | |
324 else | |
325 v3 = ptr_80AA28[v34]->prolly_head; | |
326 if ( v3 ) | |
327 { | |
328 v4 = v3->pParent; | |
329 if ( v4 ) | |
330 { | |
331 v5 = v4->pTexture; | |
332 if ( v5 ) | |
333 { | |
334 if ( v3->field_8 >= (signed int)pViewport->uViewportX || v3->field_C != pViewport->uViewportX ) | |
335 { | |
336 LOBYTE(v4->field_32) |= 2u; | |
337 v14 = *(int *)&v4->flags; | |
338 if ( v14 & 0x10 && v4->field_59 != 5 ) | |
339 { | |
340 dword_80AA20 = (v4->field_5C - 64) << 25; | |
341 dword_80AA1C = dword_80AA20 + 0x1FF0000; | |
342 dword_80AA14 = (v4->field_5D << 25) + 0x7FFF0000; | |
343 dword_80AA18 = dword_80AA14 - 0x1FF0000; | |
344 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
345 v4->field_5C, | |
346 v4->field_5D - 1) >> 9) & 1; | |
347 if ( *(int *)&v4->flags & 2 || (v15 = *(int *)&v4->flags, BYTE1(v15) & 1) ) | |
348 { | |
349 if ( *(int *)&v4->flags & 2 ) | |
350 { | |
351 while ( 1 ) | |
352 { | |
353 if ( pOutdoorCamera->outdoor_no_wavy_water ) | |
354 sr_sub_48408A_prolly_odm_water_no_waves(v3); | |
355 else | |
356 sr_sub_485407_prolly_odm_water_wavy(v3); | |
357 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
358 if ( v4->prolly_tail == v3 ) | |
359 break; | |
360 v3 = v3->pNext; | |
361 } | |
362 } | |
363 else | |
364 { | |
365 while ( 1 ) | |
366 { | |
367 v16 = v4->pTexture; | |
368 v17 = pBitmaps_LOD->LoadTexture("wtrtyl"); | |
369 v4->pTexture = (Texture *)(v17 != -1 ? (int)&pBitmaps_LOD->pTextures[v17] : 0); | |
370 if ( pOutdoorCamera->outdoor_no_wavy_water ) | |
371 sr_sub_48408A_prolly_odm_water_no_waves(v3); | |
372 else | |
373 sr_sub_485407_prolly_odm_water_wavy(v3); | |
374 v18 = v4->field_5C - 64; | |
375 v4->pTexture = v16; | |
376 dword_80AA20 = v18 << 25; | |
377 dword_80AA1C = (v18 << 25) + 0x1FF0000; | |
378 dword_80AA14 = (v4->field_5D << 25) + 0x7FFF0000; | |
379 dword_80AA18 = dword_80AA14 - 0x1FF0000; | |
380 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
381 v4->field_5C, | |
382 v4->field_5D - 1) >> 9) & 1; | |
383 sr_sub_484442(v3); | |
384 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
385 if ( v4->prolly_tail == v3 ) | |
386 break; | |
387 v3 = v3->pNext; | |
388 } | |
389 } | |
390 } | |
391 else | |
392 { | |
393 while ( sr_sub_48408A_prolly_odm_water_no_waves(v3) ) | |
394 { | |
395 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
396 if ( v4->prolly_tail == v3 ) | |
397 break; | |
398 v3 = v3->pNext; | |
399 } | |
400 } | |
401 } | |
402 else | |
403 { | |
404 v19 = v4->field_59; | |
405 if ( v19 != 5 ) | |
406 { | |
407 if ( v14 & 2 ) | |
408 { | |
409 while ( 1 ) | |
410 { | |
411 v28 = pBitmaps_LOD->LoadTexture("wtrtyla"); | |
412 v4->pTexture = (Texture *)(v28 != -1 ? &pBitmaps_LOD->pTextures[v28] : 0); | |
413 if ( !sr_sub_4847EB(v3) ) | |
414 break; | |
415 v4->pTexture = v5; | |
416 if ( !sr_sub_484442(v3) ) | |
417 break; | |
418 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
419 if ( v4->prolly_tail == v3 ) | |
420 break; | |
421 v3 = v3->pNext; | |
422 v5 = v4->pTexture; | |
423 } | |
424 } | |
425 else | |
426 { | |
427 if ( v19 == 1 ) | |
428 { | |
429 dword_80AA20 = (v4->field_5C - 64) << 25; | |
430 dword_80AA1C = dword_80AA20 + 33488896; | |
431 dword_80AA14 = (v4->field_5D << 25) + 0x7FFF0000; | |
432 dword_80AA18 = dword_80AA14 - 33488896; | |
433 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
434 v4->field_5C, | |
435 v4->field_5D - 1) >> 9) & 1; | |
436 while ( 1 ) | |
437 { | |
438 if ( !sr_sub_4847EB(v3) ) | |
439 sr_sub_48585C_mb_DrawSpan(v3, &pRenderer->pTargetSurface[v3->field_8 + 640 * v3->field_A], 0); | |
440 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
441 if ( v4->prolly_tail == v3 ) | |
442 break; | |
443 v3 = v3->pNext; | |
444 } | |
445 } | |
446 } | |
447 goto LABEL_14; | |
448 } | |
449 v4->ptr_38 = (stru149 *)&v41; | |
450 v4->_479295(); | |
451 v20 = GetTickCount(); | |
452 v21 = *(int *)&v4->flags; | |
453 v22 = v20 >> 3; | |
454 if ( BYTE1(v21) & 4 ) | |
455 { | |
456 v4->sTextureDeltaV -= v22 & v4->pTexture->uHeightMinus1; | |
457 } | |
458 else | |
459 { | |
460 if ( BYTE1(v21) & 8 ) | |
461 v4->sTextureDeltaV += v22 & v4->pTexture->uHeightMinus1; | |
462 } | |
463 if ( BYTE1(v21) & 0x10 ) | |
464 { | |
465 v4->sTextureDeltaU -= v22 & v4->pTexture->uWidthMinus1; | |
466 } | |
467 else | |
468 { | |
469 if ( BYTE1(v21) & 0x20 ) | |
470 v4->sTextureDeltaU += v22 & v4->pTexture->uWidthMinus1; | |
471 } | |
472 v23 = v4->ptr_38; | |
473 v4->field_52 = 32; | |
474 v4->field_5A = 5; | |
475 if ( (double)abs(v23->field_C) > 52428.8 ) | |
476 { | |
477 v4->field_52 = 8; | |
478 v4->field_5A = 3; | |
479 } | |
480 v24 = *(int *)&v4->flags; | |
481 if ( !(v24 & 0x10000) ) | |
482 { | |
483 if ( !(v24 & 2) ) | |
484 { | |
485 v25 = v4->pODMFace; | |
486 if ( v25->uPolygonType == 1 ) | |
487 { | |
488 v26 = v25->pTextureUIDs[0]; | |
489 dword_80AA1C = v26; | |
490 dword_80AA20 = v26; | |
491 v27 = v25->pTextureVIDs[0]; | |
492 dword_80AA14 = v27; | |
493 dword_80AA18 = v27; | |
494 v35 = 1; | |
495 if ( v25->uNumVertices > 1u ) | |
496 { | |
497 v33 = (int)&v25->pTextureVIDs[1]; | |
498 do | |
499 { | |
500 if ( dword_80AA20 > *(short *)(v33 - 40) ) | |
501 dword_80AA20 = *(short *)(v33 - 40); | |
502 if ( v26 < *(short *)(v33 - 40) ) | |
503 { | |
504 v26 = *(short *)(v33 - 40); | |
505 dword_80AA1C = *(short *)(v33 - 40); | |
506 } | |
507 if ( dword_80AA18 > *(short *)v33 ) | |
508 dword_80AA18 = *(short *)v33; | |
509 if ( v27 < *(short *)v33 ) | |
510 { | |
511 v27 = *(short *)v33; | |
512 dword_80AA14 = *(short *)v33; | |
513 } | |
514 ++v35; | |
515 v33 += 2; | |
516 } | |
517 while ( v35 < v25->uNumVertices ); | |
518 v0 = a1; | |
519 } | |
520 dword_80AA20 = (dword_80AA20 + v4->sTextureDeltaU) << 16; | |
521 dword_80AA1C = ((v26 + v4->sTextureDeltaU) << 16) - 65536; | |
522 dword_80AA18 = (dword_80AA18 + v4->sTextureDeltaV) << 16; | |
523 dword_80AA14 = ((v27 + v4->sTextureDeltaV) << 16) - 65536; | |
524 } | |
525 while ( 1 ) | |
526 { | |
527 if ( !sr_sub_482E07(v3, v0) ) | |
528 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
529 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
530 if ( v4->prolly_tail == v3 ) | |
531 break; | |
532 v3 = v3->pNext; | |
533 } | |
534 goto LABEL_14; | |
535 } | |
536 while ( 1 ) | |
537 { | |
538 LABEL_74: | |
539 if ( !sr_sub_4839BD(v3, v0) ) | |
540 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
541 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
542 if ( v4->prolly_tail == v3 ) | |
543 break; | |
544 v3 = v3->pNext; | |
545 } | |
546 goto LABEL_14; | |
547 } | |
548 if ( v24 & 2 ) | |
549 goto LABEL_74; | |
550 while ( 1 ) | |
551 { | |
552 if ( !sr_sub_482A94(v3) ) | |
553 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
554 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
555 if ( v4->prolly_tail == v3 ) | |
556 break; | |
557 v3 = v3->pNext; | |
558 } | |
559 } | |
560 } | |
561 else | |
562 { | |
563 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
564 } | |
565 } | |
566 } | |
567 } | |
568 LABEL_14: | |
569 ++v34; | |
570 LOWORD(v2) = v34; | |
571 v36 += 67; | |
572 } | |
573 while ( v34 < (signed int)v37 ); | |
574 } | |
575 if ( pParty->uFlags & 2 ) | |
576 { | |
577 v6 = pOutdoorCamera->numStru148s; | |
578 v7 = 0; | |
579 uNumElementsIn80AA28 = 0; | |
580 if ( pOutdoorCamera->numStru148s > 0 ) | |
581 { | |
582 v8 = (char *)&array_77EC08[0].flags; | |
583 do | |
584 { | |
585 v2 = *(stru148 **)v8; | |
586 if ( (unsigned int)v2 & 0x20000 ) | |
587 { | |
588 ++v7; | |
589 *(int *)v8 = (unsigned int)v2 & 0xFFFDFFFF; | |
590 LOWORD(v2) = (short)v8 - 48; | |
591 *(&uNumElementsIn80AA28 + v7) = (unsigned int)(v8 - 48); | |
592 } | |
593 v8 += 268; | |
594 --v6; | |
595 } | |
596 while ( v6 ); | |
597 uNumElementsIn80AA28 = v7; | |
598 } | |
599 } | |
600 v9 = pOutdoorCamera->uNumSpans; | |
601 unnamed_6BE060[0] = pOutdoorCamera->uNumSpans; | |
602 if ( pOutdoorCamera->numStru148s >= 1999 | |
603 || (array_77EC08[1999]._48607B(&stru_8019C8), | |
604 array_77EC08[1999].ptr_38->_48694B(), | |
605 v2 = (stru148 *)&pBitmaps_LOD->pTextures[pOutdoor->uMainTile_BitmapID], | |
606 (array_77EC08[1999].pTexture = (Texture *)(pOutdoor->uMainTile_BitmapID != -1 ? (int)v2 : 0)) == 0) ) | |
607 return (signed __int16)v2; | |
608 array_77EC08[1999].field_58 = 23 - (-20 * pOutdoor->vSunlight.z >> 16); | |
609 if ( array_77EC08[1999].field_58 > 20 ) | |
610 array_77EC08[1999].field_58 = 20; | |
611 v10 = stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi); | |
612 array_77EC08[1999].v_18.y = 0; | |
613 array_77EC08[1999].v_18.x = v10; | |
614 array_77EC08[1999].v_18.z = stru_5C6E00->SinCos(pIndoorCamera->sRotationX); | |
615 array_77EC08[1999].field_24 = 2048 - (pIndoorCamera->pos.z << 16); | |
616 a1a = (signed __int64)((double)(pIndoorCamera->pos.z * pOutdoorCamera->int_fov_rad) | |
617 / ((double)pOutdoorCamera->int_fov_rad + 8192.0) | |
618 + (double)pViewport->uScreenCenterY); | |
619 cos((double)pIndoorCamera->sRotationX * 0.0030664064); | |
620 sin((double)pIndoorCamera->sRotationX * 0.0030664064); | |
621 array_77EC08[1999]._48607B(&stru_8019C8); | |
622 array_77EC08[1999].ptr_38->_48694B(); | |
623 v2 = (stru148 *)&pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID]; | |
624 array_77EC08[1999].pTexture = (Texture *)(pOutdoor->uSky_TextureID != -1 ? (int)v2 : 0); | |
625 if ( !(pOutdoor->uSky_TextureID != -1 ? (int)v2 : 0) ) | |
626 return (signed __int16)v2; | |
627 array_77EC08[1999].field_58 = 0; | |
628 v11 = stru_5C6E00->SinCos(pIndoorCamera->sRotationX + 16 - stru_5C6E00->uIntegerHalfPi); | |
629 array_77EC08[1999].v_18.y = 0; | |
630 array_77EC08[1999].v_18.x = -v11; | |
631 array_77EC08[1999].v_18.z = -stru_5C6E00->SinCos(pIndoorCamera->sRotationX + 16); | |
632 LOWORD(v2) = 224 * LOWORD(pMiscTimer->uTotalGameTimeElapsed); | |
633 array_77EC08[1999].field_24 = 0x2000000u; | |
634 array_77EC08[1999].sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
635 array_77EC08[1999].sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
636 if ( day_attrib & 1 | |
637 && (LOWORD(v2) = LOWORD(pParty->uCurrentHour), pParty->uCurrentHour >= 5) | |
638 && pParty->uCurrentHour < 0x15 | |
639 || bUnderwater ) | |
640 { | |
641 v2 = (stru148 *)*(short *)PaletteManager::Get_Mist_or_Red_LUT(array_77EC08[1999].pTexture->palette_id2, 31, 1); | |
642 a1b = (unsigned int)v2; | |
643 if ( (signed int)v9 <= 0 ) | |
644 return (signed __int16)v2; | |
645 v29 = v9; | |
646 while ( 1 ) | |
647 { | |
648 v30 = &pSpans[v29 - 1]; | |
649 v2 = (stru148 *)v30->field_E; | |
650 if ( v2 != (stru148 *)unnamed_6BE060[1] ) | |
651 { | |
652 LOWORD(v2) = LOWORD(pViewport->uViewportX); | |
653 if ( v30->field_8 >= (signed int)pViewport->uViewportX ) | |
654 goto LABEL_124; | |
655 if ( v30->field_C == pViewport->uViewportX ) | |
656 { | |
657 v30->field_E = LOWORD(unnamed_6BE060[1]); | |
658 } | |
659 else | |
660 { | |
661 v30->field_8 = LOWORD(pViewport->uViewportX); | |
662 v30->field_C -= LOWORD(pViewport->uViewportX); | |
663 if ( v30->field_C >= 0 ) | |
664 { | |
665 LABEL_124: | |
666 v31 = v30->field_C; | |
667 v30->pParent = &array_77EC08[1999]; | |
668 fill_pixels_fast( | |
669 a1b, | |
670 &pRenderer->pTargetSurface[v30->field_8 + pRenderer->uTargetSurfacePitch * v30->field_A], | |
671 v31); | |
672 j_memset32(-65536, &pRenderer->pActiveZBuffer[v30->field_8 + 640 * v30->field_A], v30->field_C); | |
673 goto LABEL_125; | |
674 } | |
675 LOWORD(v2) = LOWORD(unnamed_6BE060[1]); | |
676 v30->field_E = LOWORD(unnamed_6BE060[1]); | |
677 } | |
678 } | |
679 LABEL_125: | |
680 --v29; | |
681 --v9; | |
682 if ( !v9 ) | |
683 return (signed __int16)v2; | |
684 } | |
685 } | |
686 if ( (signed int)v9 > 0 ) | |
687 { | |
688 v12 = v9; | |
689 do | |
690 { | |
691 v13 = &pSpans[v12 - 1]; | |
692 v2 = (stru148 *)v13->field_E; | |
693 if ( v2 != (stru148 *)unnamed_6BE060[1] ) | |
694 { | |
695 LOWORD(v2) = LOWORD(pViewport->uViewportX); | |
696 if ( v13->field_8 >= (signed int)pViewport->uViewportX ) | |
697 goto LABEL_109; | |
698 if ( v13->field_C != pViewport->uViewportX ) | |
699 { | |
700 v13->field_8 = LOWORD(pViewport->uViewportX); | |
701 v13->field_C -= LOWORD(pViewport->uViewportX); | |
702 if ( v13->field_C >= 0 ) | |
703 { | |
704 LABEL_109: | |
705 if ( pOutdoorCamera->bNoSky ) | |
706 { | |
707 const_1_0(); | |
708 } | |
709 else | |
710 { | |
711 v13->pParent = &array_77EC08[1999]; | |
712 if ( !Render::DrawSkySW(v13, &array_77EC08[1999], a1a) ) | |
713 j_memset32(-65536, &pRenderer->pActiveZBuffer[v13->field_8 + 640 * v13->field_A], v13->field_C); | |
714 } | |
715 } | |
716 LOWORD(v2) = LOWORD(unnamed_6BE060[1]); | |
717 v13->field_E = LOWORD(unnamed_6BE060[1]); | |
718 goto LABEL_114; | |
719 } | |
720 v13->field_E = LOWORD(unnamed_6BE060[1]); | |
721 } | |
722 LABEL_114: | |
723 --v12; | |
724 --v9; | |
725 } | |
726 while ( v9 ); | |
727 } | |
728 return (signed __int16)v2; | |
729 } | |
730 // 6BE030: using guessed type int day_attrib; | |
731 // 6BE3C4: using guessed type char bUnderwater; | |
732 // 80AA10: using guessed type char byte_80AA10; | |
733 // 80AA14: using guessed type int dword_80AA14; | |
734 // 80AA18: using guessed type int dword_80AA18; | |
735 // 80AA1C: using guessed type int dword_80AA1C; | |
736 // 80AA20: using guessed type int dword_80AA20; | |
737 | |
738 //----- (00485044) -------------------------------------------------------- | |
739 int Render::DrawSkySW(Span *a1, stru148 *a2, int a3) | |
740 { | |
741 stru148 *v3; // esi@1 | |
742 Span *v4; // edi@1 | |
743 float v5; // ST2C_4@1 | |
744 signed int result; // eax@2 | |
745 int v7; // ST40_4@3 | |
746 stru149 *v8; // eax@3 | |
747 int v9; // ebx@3 | |
748 int v10; // ecx@3 | |
749 int v11; // edx@3 | |
750 int v12; // eax@3 | |
751 int v13; // ST28_4@5 | |
752 int v14; // eax@5 | |
753 signed __int64 v15; // qtt@11 | |
754 int v16; // ST28_4@11 | |
755 int v17; // eax@11 | |
756 signed int v18; // ecx@11 | |
757 int v19; // ST40_4@11 | |
758 int v20; // ST3C_4@11 | |
759 int v21; // ST30_4@11 | |
760 void *v22; // eax@11 | |
761 Texture *v23; // esi@11 | |
762 int v24; // ecx@11 | |
763 unsigned int v25; // esi@11 | |
764 int v26; // edi@11 | |
765 unsigned __int16 *v27; // eax@11 | |
766 int *v28; // ebx@12 | |
767 int v29; // edx@13 | |
768 unsigned __int16 v30; // cx@13 | |
769 int v31; // edx@14 | |
770 unsigned __int16 v32; // cx@14 | |
771 unsigned __int8 v33; // sf@15 | |
772 unsigned __int8 v34; // of@15 | |
773 double v35; // [sp+14h] [bp-38h]@1 | |
774 int v36; // [sp+18h] [bp-34h]@3 | |
775 signed int v37; // [sp+18h] [bp-34h]@11 | |
776 int v38; // [sp+1Ch] [bp-30h]@3 | |
777 signed int v39; // [sp+1Ch] [bp-30h]@11 | |
778 int v40; // [sp+20h] [bp-2Ch]@3 | |
779 void *v41; // [sp+20h] [bp-2Ch]@11 | |
780 int v42; // [sp+24h] [bp-28h]@3 | |
781 unsigned __int8 *v43; // [sp+24h] [bp-28h]@11 | |
782 int v44; // [sp+28h] [bp-24h]@11 | |
783 int v45; // [sp+2Ch] [bp-20h]@3 | |
784 signed int v46; // [sp+30h] [bp-1Ch]@3 | |
785 __int16 v47; // [sp+30h] [bp-1Ch]@11 | |
786 signed int v48; // [sp+34h] [bp-18h]@3 | |
787 int v49; // [sp+34h] [bp-18h]@11 | |
788 int v50; // [sp+38h] [bp-14h]@3 | |
789 unsigned __int16 *v51; // [sp+38h] [bp-14h]@11 | |
790 int v52; // [sp+3Ch] [bp-10h]@4 | |
791 int a1a; // [sp+40h] [bp-Ch]@3 | |
792 int v54; // [sp+44h] [bp-8h]@3 | |
793 int v55; // [sp+48h] [bp-4h]@3 | |
794 int v56; // [sp+54h] [bp+8h]@11 | |
795 int *v57; // [sp+54h] [bp+8h]@11 | |
796 | |
797 v3 = a2; | |
798 v4 = a1; | |
799 v5 = (double)(pViewport->uViewportZ - pViewport->uViewportX) * 0.5 / tan(0.6457717418670654) + 0.5; | |
800 v35 = v5 + 6.7553994e15; | |
801 if ( LODWORD(v35) ) | |
802 { | |
803 v55 = 65536 / SLODWORD(v35); | |
804 v7 = 65536 / SLODWORD(v35) * (a3 - v4->field_A); | |
805 v8 = v3->ptr_38; | |
806 v42 = ((unsigned __int64)(v3->ptr_38->field_14 * (signed __int64)v7) >> 16) + v8->field_C; | |
807 v40 = ((unsigned __int64)(v8->field_20 * (signed __int64)v7) >> 16) + v3->ptr_38->field_18; | |
808 v38 = pOutdoorCamera->camera_rotation_y_int_sine; | |
809 HIDWORD(v35) = pOutdoorCamera->camera_rotation_y_int_cosine; | |
810 v45 = v4->field_C; | |
811 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v7) >> 16) + v3->v_18.x; | |
812 v10 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); | |
813 v48 = 0; | |
814 v50 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); | |
815 v46 = -v3->field_24; | |
816 v11 = v4->field_A - 1; | |
817 v54 = v11; | |
818 v12 = 65536 / SLODWORD(v35) * (a3 - v11); | |
819 a1a = 65536 / SLODWORD(v35) * (a3 - v11); | |
820 while ( 1 ) | |
821 { | |
822 v52 = v9; | |
823 if ( v9 ) | |
824 { | |
825 v13 = abs(v46 >> 14); | |
826 v14 = abs(v9); | |
827 v11 = v54; | |
828 v10 = v50; | |
829 if ( v13 <= v14 ) | |
830 break; | |
831 v12 = a1a; | |
832 } | |
833 if ( v11 <= (signed int)pViewport->uViewportY ) | |
834 break; | |
835 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v12) >> 16) + v3->v_18.x; | |
836 --v54; | |
837 a1a += v55; | |
838 v12 = a1a; | |
839 v11 = v54; | |
840 v48 = 1; | |
841 } | |
842 if ( v48 ) | |
843 v52 = ((unsigned __int64)(v3->v_18.z * (signed __int64)(v55 * (a3 + (signed int)v4->field_A - 2 * v11))) >> 16) | |
844 + v3->v_18.x; | |
845 LODWORD(v15) = v46 << 16; | |
846 HIDWORD(v15) = v46 >> 16; | |
847 v16 = v42 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v10) >> 16); | |
848 v17 = v40 + ((unsigned __int64)(v3->ptr_38->field_1C * (signed __int64)v10) >> 16); | |
849 v18 = v15 / v52; | |
850 v43 = v3->pTexture->pLevelOfDetail0; | |
851 v19 = v3->sTextureDeltaU + ((signed int)((unsigned __int64)(v16 * v15 / v52) >> 16) >> 3); | |
852 v56 = v15 / v52; | |
853 v20 = v3->sTextureDeltaV + ((signed int)((unsigned __int64)(v17 * v15 / v52) >> 16) >> 3); | |
854 v21 = (unsigned __int64)(v55 * (signed __int64)v56) >> 16; | |
855 v39 = (signed int)((unsigned __int64)(v21 * (signed __int64)v38) >> 16) >> 3; | |
856 v37 = (signed int)((unsigned __int64)(v21 * (signed __int64)v36) >> 16) >> 3; | |
857 v22 = sr_sub_47C178(v18, v3, 0, 1); | |
858 v23 = v3->pTexture; | |
859 v41 = v22; | |
860 v47 = 16 - v23->uWidthLn2; | |
861 v44 = v23->uTextureWidth - 1; | |
862 v49 = (v23->uTextureHeight << 16) - 65536; | |
863 v24 = v4->field_8; | |
864 v51 = &pRenderer->pTargetSurface[v24 + pRenderer->uTargetSurfacePitch * v4->field_A]; | |
865 v57 = &pRenderer->pActiveZBuffer[v24 + 640 * v4->field_A]; | |
866 v25 = v19; | |
867 v26 = v20; | |
868 v27 = v51; | |
869 if ( !(v45 & 1) ) | |
870 goto LABEL_15; | |
871 --v45; | |
872 v27 = v51 - 1; | |
873 v28 = v57; | |
874 ++v57; | |
875 while ( 1 ) | |
876 { | |
877 *v28 = -65536; | |
878 v31 = v44 & (v25 >> 16); | |
879 v27 += 2; | |
880 v25 += v39; | |
881 v32 = *((short *)v41 + *(&v43[v31] + ((v49 & (unsigned int)v26) >> v47))); | |
882 v26 += v37; | |
883 *(v27 - 1) = v32; | |
884 LABEL_15: | |
885 v34 = __OFSUB__(v45, 2); | |
886 v33 = v45 - 2 < 0; | |
887 v45 -= 2; | |
888 if ( v33 ^ v34 ) | |
889 break; | |
890 v29 = v44 & (v25 >> 16); | |
891 v25 += v39; | |
892 v30 = *((short *)v41 + *(&v43[v29] + ((v49 & (unsigned int)v26) >> v47))); | |
893 v26 += v37; | |
894 v28 = v57; | |
895 *v27 = v30; | |
896 v57 += 2; | |
897 v28[1] = -65536; | |
898 } | |
899 result = 1; | |
900 } | |
901 else | |
902 { | |
903 result = 0; | |
904 } | |
905 return result; | |
906 } | |
907 | |
908 //----- (0047F5C6) -------------------------------------------------------- | |
909 float Render::DrawBezierTerrain() | |
910 { | |
911 //__debugbreak();Ritor1: it's temporarily | |
912 //return 0; | |
913 | |
86 | 914 unsigned int pDirectionIndicator1; // ebx@1 |
915 unsigned int pDirectionIndicator2; // edi@1 | |
0 | 916 unsigned int v2; // eax@1 |
917 int v3; // eax@3 | |
918 int v4; // edi@3 | |
919 int v5; // ebx@3 | |
920 int v6; // esi@3 | |
921 unsigned int v7; // eax@3 | |
922 int v8; // eax@4 | |
923 unsigned int v9; // eax@6 | |
924 int v10; // eax@7 | |
925 int v11; // ebx@9 | |
926 int v12; // edi@9 | |
927 int v13; // eax@21 | |
928 int v14; // eax@31 | |
929 int v15; // edi@33 | |
67 | 930 int v16; // eax@34 |
0 | 931 int v17; // edx@34 |
932 int v18; // ebx@34 | |
933 int v19; // eax@36 | |
934 int v20; // eax@39 | |
935 int v21; // ecx@43 | |
936 char v22; // zf@44 | |
937 int v23; // ecx@47 | |
938 int v24; // edi@52 | |
67 | 939 int v25; // eax@54 |
0 | 940 int v26; // ecx@54 |
941 int v27; // eax@56 | |
942 int v28; // edx@60 | |
943 int v29; // ecx@61 | |
944 int v30; // ecx@64 | |
945 int v31; // ecx@68 | |
946 int v32; // eax@70 | |
947 int v33; // ecx@71 | |
948 int v34; // eax@73 | |
949 int v35; // ecx@77 | |
950 int v36; // ecx@81 | |
951 int v37; // ecx@86 | |
67 | 952 int v38; // eax@88 |
953 int v39; // ecx@88 | |
0 | 954 int v40; // eax@90 |
955 int v41; // edx@94 | |
956 int v42; // ecx@95 | |
957 int v43; // ecx@98 | |
958 int v44; // ecx@102 | |
959 int v45; // eax@104 | |
960 int v46; // eax@107 | |
961 int v47; // ecx@111 | |
962 int v48; // ecx@115 | |
963 int v49; // edi@120 | |
67 | 964 int v50; // eax@122 |
0 | 965 int v51; // ecx@122 |
966 int v52; // eax@124 | |
967 int v53; // edx@128 | |
968 int v54; // ecx@129 | |
969 int v55; // ecx@132 | |
970 int v56; // eax@139 | |
971 int v57; // ecx@140 | |
972 int v58; // eax@142 | |
973 int v59; // ecx@146 | |
974 int v60; // ecx@147 | |
975 int v61; // ecx@150 | |
976 int v62; // ecx@155 | |
67 | 977 int v63; // eax@157 |
978 int v64; // ecx@157 | |
0 | 979 int v65; // eax@159 |
980 int v66; // edx@163 | |
981 int v67; // ecx@164 | |
982 int v68; // ecx@167 | |
983 int v69; // eax@173 | |
984 int v70; // edi@178 | |
985 int v71; // eax@178 | |
986 int v72; // ecx@178 | |
86 | 987 int x; // ebx@180 |
0 | 988 int v74; // eax@182 |
989 int v75; // eax@184 | |
67 | 990 IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 |
86 | 991 int uStartZ; // ecx@184 |
0 | 992 int v79; // ebx@185 |
993 int v127; // esi@185 | |
994 int v86; // edi@196 | |
995 int v87; // eax@196 | |
996 int v88; // ecx@196 | |
997 int v89; // eax@198 | |
998 int v90; // ecx@200 | |
999 int v92; // ebx@203 | |
1000 int v93; // ST08_4@204 | |
1001 int v97; // ST08_4@204 | |
1002 float result; // eax@212 | |
67 | 1003 struct |
1004 { | |
1005 char v102[4]; // [sp+Ch] [bp-68h]@191 | |
0 | 1006 __int16 v103; // [sp+10h] [bp-64h]@190 |
1007 __int16 v104; // [sp+12h] [bp-62h]@190 | |
67 | 1008 } v102; |
77 | 1009 int v105; // [sp+1Ch] [bp-58h]@1 |
0 | 1010 int v106; // [sp+20h] [bp-54h]@3 |
86 | 1011 int uEndZ; // [sp+24h] [bp-50h]@3 |
0 | 1012 int v108; // [sp+28h] [bp-4Ch]@9 |
1013 int v109; // [sp+2Ch] [bp-48h]@9 | |
1014 int v110; // [sp+30h] [bp-44h]@9 | |
1015 int v111; // [sp+34h] [bp-40h]@3 | |
1016 int v112; // [sp+38h] [bp-3Ch]@6 | |
67 | 1017 IndoorCameraD3D *pIndoorCameraD3D_4; // [sp+3Ch] [bp-38h]@9 |
0 | 1018 int v114; // [sp+40h] [bp-34h]@9 |
1019 int v115; // [sp+44h] [bp-30h]@9 | |
1020 int v116; // [sp+48h] [bp-2Ch]@9 | |
1021 int v117; // [sp+4Ch] [bp-28h]@9 | |
1022 int v118; // [sp+50h] [bp-24h]@9 | |
1023 int v119; // [sp+54h] [bp-20h]@1 | |
1024 int v120; // [sp+58h] [bp-1Ch]@1 | |
1025 int i; // [sp+5Ch] [bp-18h]@1 | |
1026 int v122; // [sp+60h] [bp-14h]@1 | |
1027 int v123; // [sp+64h] [bp-10h]@1 | |
67 | 1028 int v124; // [sp+68h] [bp-Ch]@1 |
0 | 1029 int v125; // [sp+6Ch] [bp-8h]@9 |
67 | 1030 int v126; // [sp+70h] [bp-4h]@9 |
1031 | |
96 | 1032 v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2 |
86 | 1033 pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 |
1034 pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512 | |
1035 v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->SinCos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16; | |
1036 v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->SinCos(pDirectionIndicator2 - stru_5C6E00->uIntegerHalfPi)) >> 16; | |
67 | 1037 v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X |
0 | 1038 v119 = pOutdoorCamera->outdoor_grid_band_3 + v123; |
1039 v2 = pOutdoorCamera->uCameraFovInDegrees + 15; | |
67 | 1040 i = v124 - pOutdoorCamera->outdoor_grid_band_3; |
0 | 1041 v122 = v123 - pOutdoorCamera->outdoor_grid_band_3; |
67 | 1042 |
1043 if ( v2 > 90 ) | |
0 | 1044 v2 = 90; |
67 | 1045 v3 = (v2 << 11) / 720; |
86 | 1046 v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3); |
1047 v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1); | |
0 | 1048 v106 = stru_5C6E00->SinCos(v4); |
86 | 1049 uEndZ = stru_5C6E00->SinCos(v4 - stru_5C6E00->uIntegerHalfPi); |
0 | 1050 v111 = stru_5C6E00->SinCos(v5); |
1051 v6 = stru_5C6E00->SinCos(v5 - stru_5C6E00->uIntegerHalfPi); | |
1052 v7 = v4 & stru_5C6E00->uPiMask; | |
67 | 1053 |
1054 if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) | |
0 | 1055 v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7]; |
1056 else | |
1057 v8 = stru_5C6E00->pTanTable[v7]; | |
1058 v112 = abs(v8); | |
1059 v9 = v5 & stru_5C6E00->uPiMask; | |
67 | 1060 if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) |
0 | 1061 v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9]; |
1062 else | |
1063 v10 = stru_5C6E00->pTanTable[v9]; | |
1064 v108 = abs(v10); | |
67 | 1065 v11 = v124; |
0 | 1066 v12 = v123; |
1067 v114 = 0; | |
1068 v115 = 0; | |
67 | 1069 pIndoorCameraD3D_4 = 0; |
0 | 1070 v125 = 0; |
67 | 1071 v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; |
0 | 1072 v126 = v124; |
1073 v118 = v123; | |
86 | 1074 v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; |
1075 uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; | |
0 | 1076 terrain_76E1C8[0] = 65535; |
67 | 1077 //v116 = 1; |
1078 v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; | |
1079 //v117 = 1; | |
0 | 1080 terrain_76E3C8[0] = 65535; |
1081 terrain_76DDC8[0] = 65535; | |
1082 terrain_76DFC8[0] = 65535; | |
67 | 1083 for( v116=1; v116 < 128; v116++) |
1084 { | |
1085 if ( v112 >= 0x10000 ) | |
1086 { | |
1087 int v1, v2; | |
1088 /*v111 = 4294967296i64 / v112; | |
0 | 1089 v114 += v111; |
1090 if ( v114 >= 65536 ) | |
1091 { | |
1092 v11 += v110; | |
1093 v114 = (unsigned __int16)v114; | |
1094 } | |
67 | 1095 v12 += v109;*/ |
0 | 1096 } |
1097 else | |
1098 { | |
1099 v11 += v110; | |
1100 v115 += v112; | |
67 | 1101 if ( v112 + v115 >= 65536 ) |
0 | 1102 { |
1103 v12 += v109; | |
1104 v115 = (unsigned __int16)v115; | |
1105 } | |
1106 } | |
67 | 1107 if ( v11 < i || v11 > v120 || v12 < v122 || v12 > v119 ) |
0 | 1108 break; |
67 | 1109 //v13 = v116++; |
1110 terrain_76E3C8[v116] = v11; | |
1111 terrain_76E1C8[v116] = v12; | |
1112 } | |
1113 | |
1114 for( v117=1; v117 < 128; v117++ ) | |
0 | 1115 { |
1116 if ( v108 >= 65536 ) | |
1117 { | |
1118 v111 = 4294967296i64 / v108; | |
67 | 1119 v114 += v111;// |
1120 if ( v111 + v114 >= 65536 ) | |
1121 { | |
86 | 1122 v126 += uEndZ; |
67 | 1123 v114 = (unsigned __int16)v114;// |
0 | 1124 } |
1125 v118 += v106; | |
1126 } | |
1127 else | |
1128 { | |
1129 v125 += v108; | |
86 | 1130 v126 += uEndZ; |
0 | 1131 if ( v125 >= 65536 ) |
1132 { | |
1133 v118 += v106; | |
1134 v125 = (unsigned __int16)v125; | |
1135 } | |
1136 } | |
67 | 1137 //if ( v117 >= 128 ) |
1138 //break; | |
1139 if ( v126 < i ) | |
0 | 1140 break; |
67 | 1141 if ( v126 > v120 ) |
0 | 1142 break; |
1143 v14 = v118; | |
1144 if ( v118 < v122 ) | |
1145 break; | |
1146 if ( v118 > v119 ) | |
1147 break; | |
67 | 1148 terrain_76DFC8[v117] = v126; |
1149 terrain_76DDC8[v117] = v14; | |
1150 } | |
1151 v16 = 0; | |
1152 v126 = 0; | |
0 | 1153 v17 = v117 - 1; |
1154 v18 = v116 - 1; | |
77 | 1155 switch ( v105 ) |
0 | 1156 { |
1157 case 0: | |
1158 case 7: | |
67 | 1159 { |
0 | 1160 v116 = terrain_76DFC8[v17]; |
1161 if ( v120 > v116 ) | |
1162 { | |
1163 v125 = v120; | |
67 | 1164 memset32(terrain_76D9C8, v119 + 1, 4 * (v120 - v116 + 1)); |
0 | 1165 v19 = v120; |
1166 do | |
67 | 1167 terrain_76DBC8[v126++] = v19--; |
0 | 1168 while ( v19 >= v116 ); |
1169 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 + 127] ) | |
1170 { | |
1171 do | |
67 | 1172 v20 = terrain_76DDC8[v17-- -1]; |
1173 while ( v20 == terrain_76DDC8[v17 -1] ); | |
0 | 1174 } |
1175 v16 = v126; | |
1176 --v17; | |
1177 } | |
1178 if ( v17 < 0 ) | |
1179 v17 = 0; | |
1180 v21 = terrain_76DFC8[v17]; | |
1181 while ( 1 ) | |
1182 { | |
1183 v125 = v21; | |
67 | 1184 if ( v21 < v124 ) |
0 | 1185 break; |
67 | 1186 terrain_76DBC8[v16] = v21; |
0 | 1187 v22 = terrain_76DDC8[v17] == 65535; |
67 | 1188 terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1; |
0 | 1189 if ( v22 ) |
1190 { | |
67 | 1191 terrain_76D9C8[v16] = v123 + 1; |
0 | 1192 break; |
1193 } | |
1194 if ( !v17 ) | |
1195 break; | |
67 | 1196 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 - 1] ) |
0 | 1197 { |
1198 do | |
67 | 1199 v23 = terrain_76DDC8[v17-- -1]; |
1200 while ( v23 == terrain_76DDC8[v17 -1] ); | |
0 | 1201 } |
1202 --v17; | |
1203 v21 = v125 - 1; | |
67 | 1204 ++v16; |
1205 } | |
1206 v16 = 0; | |
0 | 1207 v24 = terrain_76E3C8[v18]; |
67 | 1208 v126 = 0; |
0 | 1209 if ( v120 > v24 ) |
1210 { | |
1211 v125 = v120; | |
67 | 1212 memset32(terrain_76D5C8, v122, 4 * (v120 - v24 + 1)); |
0 | 1213 do |
1214 { | |
1215 v25 = v126; | |
1216 v26 = v125--; | |
67 | 1217 ++v126; |
1218 terrain_76D7C8[v25] = v26; | |
0 | 1219 } |
1220 while ( v125 >= terrain_76E3C8[v18] ); | |
67 | 1221 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) |
0 | 1222 { |
1223 do | |
67 | 1224 v27 = terrain_76E1C8[v18-- -1]; |
1225 while ( v27 == terrain_76E1C8[v18 -1] ); | |
0 | 1226 } |
1227 v16 = v126; | |
1228 --v18; | |
1229 } | |
1230 if ( v18 < 0 ) | |
1231 v18 = 0; | |
1232 v28 = terrain_76E3C8[v18]; | |
67 | 1233 while ( v28 >= v124 ) |
0 | 1234 { |
1235 v29 = terrain_76E1C8[v18]; | |
67 | 1236 terrain_76D7C8[v16] = v28; |
1237 terrain_76D5C8[v16] = v29; | |
0 | 1238 if ( v29 == 65535 ) |
1239 { | |
1240 v31 = v123; | |
67 | 1241 terrain_76D5C8[v16] = v31; |
1242 break; | |
0 | 1243 } |
1244 if ( !v18 ) | |
1245 break; | |
67 | 1246 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) |
0 | 1247 { |
1248 do | |
67 | 1249 v30 = terrain_76E1C8[v18-- -1]; |
1250 while ( v30 == terrain_76E1C8[v18 -1] ); | |
0 | 1251 } |
1252 --v18; | |
1253 --v28; | |
67 | 1254 ++v16; |
0 | 1255 } |
1256 break; | |
67 | 1257 } |
0 | 1258 case 1: |
1259 case 2: | |
67 | 1260 { |
0 | 1261 v116 = terrain_76DDC8[v17]; |
1262 if ( v122 < v116 ) | |
1263 { | |
1264 v106 = v122; | |
67 | 1265 memset32(terrain_76DBC8, v120 + 1, 4 * (v116 - v122 + 1)); |
0 | 1266 v32 = v122; |
1267 do | |
1268 { | |
67 | 1269 v33 = v126++; |
0 | 1270 terrain_76D9C8[v33] = v32++; |
1271 } | |
1272 while ( v32 <= v116 ); | |
67 | 1273 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1274 { |
1275 do | |
67 | 1276 v34 = terrain_76DBC8[v17-- -1]; |
1277 while ( v34 == terrain_76DBC8[v17 -1] ); | |
0 | 1278 } |
1279 v16 = v126; | |
1280 --v17; | |
1281 } | |
1282 if ( v17 < 0 ) | |
1283 v17 = 0; | |
1284 v35 = terrain_76DDC8[v17]; | |
1285 v125 = terrain_76DDC8[v17]; | |
1286 while ( v35 <= v123 ) | |
1287 { | |
1288 v22 = terrain_76DFC8[v17] == 65535; | |
67 | 1289 terrain_76DBC8[v16] = terrain_76DFC8[v17] + 1; |
1290 terrain_76D9C8[v16] = v125; | |
0 | 1291 if ( v22 ) |
1292 { | |
67 | 1293 terrain_76DBC8[v16] = v124 + 1; |
0 | 1294 break; |
1295 } | |
1296 if ( !v17 ) | |
1297 break; | |
67 | 1298 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1299 { |
1300 do | |
67 | 1301 v36 = terrain_76DBC8[v17-- -1]; |
1302 while ( v36 == terrain_76DBC8[v17 -1] ); | |
0 | 1303 } |
1304 --v17; | |
1305 ++v125; | |
1306 v35 = v125; | |
67 | 1307 ++v16; |
1308 } | |
1309 v16 = 0; | |
1310 v126 = 0; | |
0 | 1311 v37 = terrain_76E1C8[v18]; |
1312 if ( v122 < v37 ) | |
1313 { | |
67 | 1314 v114 = v122; |
1315 memset32(terrain_76D7C8, i, 4 * (v37 - v122 + 1)); | |
0 | 1316 do |
1317 { | |
1318 v38 = v126; | |
67 | 1319 v39 = v114; |
1320 ++v126; | |
1321 ++v114; | |
1322 terrain_76D5C8[v38] = v39; | |
1323 } | |
1324 while ( v114 <= terrain_76E1C8[v18] ); | |
1325 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) | |
0 | 1326 { |
1327 do | |
67 | 1328 v40 = terrain_76DFC8[v18-- -1]; |
1329 while ( v40 == terrain_76DFC8[v18 -1] ); | |
0 | 1330 } |
1331 v16 = v126; | |
1332 --v18; | |
1333 } | |
1334 if ( v18 < 0 ) | |
1335 v18 = 0; | |
1336 v41 = terrain_76E1C8[v18]; | |
1337 while ( v41 <= v123 ) | |
1338 { | |
1339 v42 = terrain_76E3C8[v18]; | |
67 | 1340 terrain_76D5C8[v16] = v41; |
1341 terrain_76D7C8[v16] = v42; | |
0 | 1342 if ( v42 == 65535 ) |
1343 { | |
67 | 1344 terrain_76D7C8[v16] = v124; |
1345 break; | |
0 | 1346 } |
1347 if ( !v18 ) | |
1348 break; | |
67 | 1349 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) |
0 | 1350 { |
1351 do | |
67 | 1352 v43 = terrain_76DFC8[v18-- -1]; |
1353 while ( v43 == terrain_76DFC8[v18 -1] ); | |
0 | 1354 } |
1355 --v18; | |
1356 ++v41; | |
67 | 1357 ++v16; |
0 | 1358 } |
1359 break; | |
67 | 1360 } |
0 | 1361 case 5: |
1362 case 6: | |
67 | 1363 { |
0 | 1364 v116 = terrain_76DDC8[v17]; |
1365 if ( v119 > v116 ) | |
1366 { | |
1367 v106 = v119; | |
67 | 1368 memset32(terrain_76DBC8, i, 4 * (v119 - v116 + 1)); |
0 | 1369 v45 = v119; |
1370 do | |
67 | 1371 terrain_76D9C8[v126++] = v45--; |
0 | 1372 while ( v45 >= v116 ); |
67 | 1373 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1374 { |
1375 do | |
67 | 1376 v46 = terrain_76DBC8[v17-- -1]; |
1377 while ( v46 == terrain_76DBC8[v17 -1] ); | |
0 | 1378 } |
1379 v16 = v126; | |
1380 --v17; | |
1381 } | |
1382 if ( v17 < 0 ) | |
1383 v17 = 0; | |
1384 v47 = terrain_76DDC8[v17]; | |
1385 v125 = terrain_76DDC8[v17]; | |
1386 while ( v47 >= v123 ) | |
1387 { | |
1388 v22 = terrain_76DFC8[v17] == 65535; | |
67 | 1389 terrain_76DBC8[v16] = terrain_76DFC8[v17]; |
1390 terrain_76D9C8[v16] = v125; | |
0 | 1391 if ( v22 ) |
1392 { | |
67 | 1393 terrain_76DBC8[v16] = v124; |
0 | 1394 break; |
1395 } | |
1396 if ( !v17 ) | |
1397 break; | |
67 | 1398 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1399 { |
1400 do | |
67 | 1401 v48 = terrain_76DBC8[v17-- -1]; |
1402 while ( v48 == terrain_76DBC8[v17 -1] ); | |
0 | 1403 } |
1404 --v17; | |
1405 --v125; | |
1406 v47 = v125; | |
67 | 1407 ++v16; |
1408 } | |
1409 v16 = 0; | |
0 | 1410 v49 = terrain_76E1C8[v18]; |
67 | 1411 v126 = 0; |
0 | 1412 if ( v119 > v49 ) |
1413 { | |
1414 v125 = v119; | |
67 | 1415 memset32(terrain_76D7C8, v120 + 1, 4 * (v119 - v49 + 1)); |
0 | 1416 do |
1417 { | |
1418 v50 = v126; | |
1419 v51 = v125--; | |
67 | 1420 ++v126; |
1421 terrain_76D5C8[v50] = v51; | |
0 | 1422 } |
1423 while ( v125 >= terrain_76E1C8[v18] ); | |
67 | 1424 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) |
0 | 1425 { |
1426 do | |
67 | 1427 v52 = terrain_76DFC8[v18-- -1]; |
1428 while ( v52 == terrain_76DFC8[v18 -1] ); | |
0 | 1429 } |
1430 v16 = v126; | |
1431 --v18; | |
1432 } | |
1433 if ( v18 < 0 ) | |
1434 v18 = 0; | |
1435 v53 = terrain_76E1C8[v18]; | |
1436 while ( v53 >= v123 ) | |
1437 { | |
1438 v54 = terrain_76E3C8[v18]; | |
67 | 1439 terrain_76D5C8[v16] = v53; |
1440 terrain_76D7C8[v16] = v54 + 1; | |
0 | 1441 if ( v54 == 65535 ) |
1442 { | |
67 | 1443 terrain_76D7C8[v16] = v124 + 1; |
1444 break; | |
0 | 1445 } |
1446 if ( !v18 ) | |
67 | 1447 break; |
1448 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) | |
0 | 1449 { |
1450 do | |
67 | 1451 v55 = terrain_76DFC8[v18-- -1]; |
1452 while ( v55 == terrain_76DFC8[v18 -1] ); | |
0 | 1453 } |
1454 --v18; | |
1455 --v53; | |
67 | 1456 ++v16; |
0 | 1457 } |
1458 break; | |
67 | 1459 } |
0 | 1460 case 3: |
1461 case 4: | |
67 | 1462 { |
0 | 1463 v116 = terrain_76DFC8[v17]; |
1464 if ( i < v116 ) | |
1465 { | |
1466 v106 = i; | |
67 | 1467 memset32(terrain_76D9C8, v122, 4 * (v116 - i + 1)); |
0 | 1468 v56 = i; |
1469 do | |
1470 { | |
67 | 1471 v57 = v126++; |
0 | 1472 terrain_76DBC8[v57] = v56++; |
1473 } | |
1474 while ( v56 <= v116 ); | |
67 | 1475 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) |
0 | 1476 { |
1477 do | |
67 | 1478 v58 = terrain_76DDC8[v17-- -1]; |
1479 while ( v58 == terrain_76DDC8[v17 -1] ); | |
0 | 1480 } |
1481 v16 = v126; | |
1482 --v17; | |
1483 } | |
1484 if ( v17 < 0 ) | |
1485 v17 = 0; | |
1486 v59 = terrain_76DFC8[v17]; | |
1487 while ( 1 ) | |
1488 { | |
1489 v125 = v59; | |
67 | 1490 if ( v59 > v124 ) |
0 | 1491 break; |
67 | 1492 terrain_76DBC8[v16] = v59; |
0 | 1493 v60 = terrain_76DDC8[v17]; |
67 | 1494 terrain_76D9C8[v16] = v60; |
0 | 1495 if ( v60 == 65535 ) |
1496 { | |
67 | 1497 terrain_76D9C8[v16] = v123; |
0 | 1498 break; |
1499 } | |
1500 if ( !v17 ) | |
1501 break; | |
67 | 1502 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) |
0 | 1503 { |
1504 do | |
67 | 1505 v61 = terrain_76DDC8[v17-- -1]; |
1506 while ( v61 == terrain_76DDC8[v17 -1] ); | |
0 | 1507 } |
1508 --v17; | |
1509 v59 = v125 + 1; | |
67 | 1510 ++v16; |
1511 } | |
1512 v16 = 0; | |
1513 v126 = 0; | |
0 | 1514 v62 = terrain_76E3C8[v18]; |
1515 if ( i < v62 ) | |
1516 { | |
67 | 1517 v114 = i; |
1518 memset32(terrain_76D5C8, v119 + 1, 4 * (v62 - i + 1)); | |
0 | 1519 do |
1520 { | |
1521 v63 = v126; | |
67 | 1522 v64 = v114; |
1523 ++v126; | |
1524 ++v114; | |
1525 terrain_76D7C8[v63] = v64; | |
1526 } | |
1527 while ( v114 <= terrain_76E3C8[v18] ); | |
1528 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) | |
0 | 1529 { |
1530 do | |
67 | 1531 v65 = terrain_76E1C8[v18-- -1]; |
1532 while ( v65 == terrain_76E1C8[v18 -1] ); | |
0 | 1533 } |
1534 v16 = v126; | |
1535 --v18; | |
1536 } | |
1537 if ( v18 < 0 ) | |
1538 v18 = 0; | |
1539 v66 = terrain_76E3C8[v18]; | |
67 | 1540 while ( v66 <= v124 ) |
0 | 1541 { |
1542 v67 = terrain_76E1C8[v18]; | |
67 | 1543 terrain_76D7C8[v16] = v66; |
1544 terrain_76D5C8[v16] = v67 + 1; | |
0 | 1545 if ( v67 == 65535 ) |
1546 { | |
1547 v31 = v123 + 1; | |
67 | 1548 terrain_76D5C8[v16] = v31; |
1549 break; | |
0 | 1550 } |
1551 if ( !v18 ) | |
67 | 1552 break; |
1553 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) | |
0 | 1554 { |
1555 do | |
67 | 1556 v68 = terrain_76E1C8[v18-- -1]; |
1557 while ( v68 == terrain_76E1C8[v18 -1] ); | |
0 | 1558 } |
1559 --v18; | |
1560 ++v66; | |
67 | 1561 ++v16; |
0 | 1562 } |
1563 break; | |
67 | 1564 } |
0 | 1565 default: |
1566 break; | |
1567 } | |
67 | 1568 v69 = v16 - 1; |
0 | 1569 ptr_801A08 = pVerticesSR_806210; |
1570 ptr_801A04 = pVerticesSR_801A10; | |
67 | 1571 v126 = v69; |
106 | 1572 if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )// |
0 | 1573 { |
1574 for ( i = v69; i >= 1; --i ) | |
1575 { | |
67 | 1576 //v70 = i; |
86 | 1577 v71 = terrain_76D7C8[i];//88 |
1578 v72 = terrain_76DBC8[i];//0 | |
67 | 1579 if ( v71 < v72 )//swap |
1580 { | |
1581 terrain_76DBC8[i] = v71; | |
1582 terrain_76D7C8[i] = v72; | |
1583 } | |
86 | 1584 x = terrain_76DBC8[i];//0 |
0 | 1585 v111 = 0; |
86 | 1586 if ( x <= 0 ) |
1587 x = -x; | |
67 | 1588 v74 = terrain_76D7C8[i]; |
0 | 1589 if ( v74 <= 0 ) |
1590 v74 = -v74; | |
1591 v75 = v74 + 2; | |
67 | 1592 //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; |
86 | 1593 uEndZ = v75; |
67 | 1594 //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; |
86 | 1595 uStartZ = x - 2; |
1596 if ( x - 2 < v75 ) | |
0 | 1597 { |
1598 v127 = 0; | |
67 | 1599 //v79 = (v73 - 66) << 9; |
1600 //v116 = v77; | |
1601 //pHeight = v79; | |
86 | 1602 v111 = v75 - uStartZ; |
1603 for (int z = uStartZ; z < uEndZ; ++z) | |
1604 { | |
106 | 1605 ptr_801A08[v127].vWorldPosition.x = (-64 + x) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; |
67 | 1606 ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; |
86 | 1607 ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); |
1608 ptr_801A04[v127].vWorldPosition.x = (-64 + x) * 512; | |
67 | 1609 ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; |
86 | 1610 ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); |
0 | 1611 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1612 { | |
67 | 1613 pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); |
1614 pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); | |
1615 pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); | |
1616 pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0); | |
0 | 1617 } |
67 | 1618 //v79 += 512; |
1619 v127 ++; | |
1620 //++v116; | |
1621 //pHeight = v79; | |
106 | 1622 } |
67 | 1623 //while ( v116 < v107 ); |
1624 } | |
106 | 1625 v102.v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); |
67 | 1626 v102.v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); |
106 | 1627 if ( pRenderer->pRenderD3D )//Ritor1: do comment to test |
98 | 1628 Render::RenderTerrainD3D();//Render::DrawTerrainD3D(v111, 0, (int)&v102); |
67 | 1629 else |
1630 Render::DrawTerrainSW(v111, 0, (int)&v102); | |
1631 } | |
1632 } | |
1633 /* else | |
0 | 1634 { |
1635 for ( i = v69; i >= 1; --i ) | |
1636 { | |
1637 v86 = i; | |
1638 v87 = terrain_76D5C8[i]; | |
1639 v88 = terrain_76D9C8[i]; | |
1640 if ( v87 < v88 ) | |
1641 { | |
1642 terrain_76D9C8[v86] = v87; | |
1643 terrain_76D5C8[v86] = v88; | |
1644 } | |
1645 v89 = terrain_76D9C8[v86]; | |
1646 v111 = 0; | |
1647 if ( v89 <= 0 ) | |
1648 v89 = -v89; | |
1649 v90 = terrain_76D5C8[v86]; | |
1650 if ( v90 <= 0 ) | |
1651 v90 = -v90; | |
67 | 1652 pIndoorCameraD3D_4 = pGame->pIndoorCameraD3D; |
0 | 1653 v107 = v90 + 2; |
1654 if ( v89 - 2 < v90 + 2 ) | |
1655 { | |
1656 v86 = 0; | |
1657 v116 = v89 - 2; | |
1658 v92 = (66 - v89) << 9; | |
62 | 1659 pHeight = (66 - v89) << 9; |
0 | 1660 v111 = v90 + 2 - (v89 - 2); |
1661 do | |
1662 { | |
1663 v93 = v116; | |
1664 v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9; | |
1665 *(float *)((char *)&ptr_801A08->vWorldPosition.x + v86) = (double)v106; | |
62 | 1666 *(float *)&pHeight = (double)pHeight; |
1667 *(float *)((char *)&ptr_801A08->vWorldPosition.y + v86) = *(float *)&pHeight; | |
0 | 1668 v106 = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86), v93); |
1669 v97 = v116; | |
1670 *(float *)((char *)&ptr_801A08->vWorldPosition.z + v86) = (double)v106; | |
1671 v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9; | |
1672 *(float *)((char *)&ptr_801A04->vWorldPosition.x + v86) = (double)v106; | |
62 | 1673 *(float *)((char *)&ptr_801A04->vWorldPosition.y + v86) = *(float *)&pHeight; |
1674 pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97); | |
1675 *(float *)((char *)&ptr_801A04->vWorldPosition.z + v86) = (double)pHeight; | |
0 | 1676 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1677 { | |
67 | 1678 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1); |
1679 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1); | |
1680 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0); | |
1681 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0); | |
0 | 1682 } |
1683 v92 -= 512; | |
1684 v86 += 48; | |
1685 ++v116; | |
62 | 1686 pHeight = v92; |
0 | 1687 } |
1688 while ( v116 < v107 ); | |
1689 } | |
1690 v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]); | |
1691 v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]); | |
67 | 1692 if ( pRenderer->pRenderD3D ) |
1693 Render::DrawTerrainD3D(v111, 1, (int)&v102); | |
1694 else | |
1695 Render::DrawTerrainSW(v111, 1, (int)&v102); | |
1696 } | |
1697 }*/ | |
0 | 1698 result = v126; |
1699 pOutdoorCamera->field_40 = v126; | |
1700 return result; | |
1701 } | |
1702 // 47FFC4: inconsistent fpu stack | |
1703 // 4D864C: using guessed type char byte_4D864C; | |
1704 | |
88 | 1705 void Render::RenderTerrainD3D() // New function. It's temporary |
86 | 1706 { |
1707 char result; // al@3 | |
1708 //int v1; // eax@3 | |
1709 //int v2; // ebx@4 | |
1710 //struct ODMFace *v4; // esi@6 | |
1711 int v6; // ecx@8 | |
1712 //int v7; // ecx@8 | |
1713 struct stru148 *v8; // ebx@8 | |
1714 //char v11; // zf@8 | |
1715 struct stru148 *v16; | |
1716 unsigned int v18; // edi@22 | |
1717 //int v20; // edi@34 | |
1718 //int v28; // eax@50 | |
1719 //int v29; // ecx@55 | |
1720 //int v30; // eax@57 | |
1721 int v31; // eax@57 | |
1722 int v35; // edi@63 | |
1723 int v37; // eax@73 | |
1724 int v39; // eax@80 | |
1725 char v40; // [sp-18h] [bp-70h]@2 | |
1726 int v41; // [sp-14h] [bp-6Ch]@2 | |
1727 int v42; // [sp-10h] [bp-68h]@2 | |
1728 int v43; // [sp-Ch] [bp-64h]@2 | |
1729 const char *v44; // [sp-8h] [bp-60h]@2 | |
1730 int v45; // [sp-4h] [bp-5Ch]@2 | |
1731 //float v48; // [sp+14h] [bp-44h]@8 | |
1732 //void *v52; // [sp+24h] [bp-34h]@3 | |
1733 bool v54; // [sp+2Ch] [bp-2Ch]@10 | |
1734 int v55; // [sp+30h] [bp-28h]@34 | |
1735 int v56; | |
1736 int v57; // [sp+38h] [bp-20h]@36 | |
1737 int v58; // [sp+3Ch] [bp-1Ch]@8 | |
1738 int v63; // [sp+50h] [bp-8h]@3 | |
1739 int v64; // [sp+57h] [bp-1h]@2 | |
1740 int v62; | |
121 | 1741 //struct IndoorCameraD3D *pIndoorCameraD3D; |
86 | 1742 |
1743 v63 = 0; | |
1744 // basic optimizations | |
106 | 1745 unsigned int uStartX, uEndX, |
1746 uStartZ, uEndZ; | |
1747 if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024) | |
1748 { | |
1749 uStartX = 0, uEndX = 128; | |
1750 uStartZ = 0, uEndZ = 64 + 16; | |
1751 } | |
1752 else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536) | |
1753 { | |
1754 uStartX = 0, uEndX = 64 + 16; | |
1755 uStartZ = 0, uEndZ = 128; | |
1756 } | |
1757 else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512) | |
1758 { | |
1759 uStartX = 64 - 16, uEndX = 128; | |
1760 uStartZ = 0, uEndZ = 128; | |
1761 } | |
1762 else | |
1763 { | |
1764 uStartX = 0, uEndX = 128; | |
1765 uStartZ = 64 - 16, uEndZ = 128; | |
1766 } | |
147 | 1767 uStartX = 0, uEndX = 128; |
1768 uStartZ = 0, uEndZ = 128; | |
106 | 1769 static RenderVertexSoft pTerrainVertices[128 * 128]; |
1770 for (unsigned int z = uStartZ; z < uEndZ; ++z) | |
1771 { | |
1772 for (unsigned int x = uStartX; x < uEndX; ++x) | |
1773 { | |
1774 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; | |
1775 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512; | |
1776 pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 1777 //pIndoorCameraD3D = pGame->pIndoorCameraD3D; |
1778 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); | |
1779 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 1780 } |
1781 } | |
1782 for (unsigned int z = uStartZ; z < uEndZ - 1; ++z) | |
1783 { | |
1784 for (unsigned int x = uStartX; x < uEndX - 1; ++x) | |
1785 { | |
1786 v8 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
1787 v8->flags = 0; | |
1788 v8->field_32 = 0; | |
1789 //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x]; | |
1790 //struct TileDesc *pTile = pOutdoor->pTerrain->pTileTable->GetTileById(uTileID); | |
1791 v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | |
1792 v6 = v8->uTileBitmapID; | |
1793 v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v6]; | |
1794 if (v8->uTileBitmapID == 0xFFFF) | |
1795 continue; | |
1796 v8->sTextureDeltaU = 0; | |
1797 v8->sTextureDeltaV = 0; | |
1798 memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft)); | |
1799 array_73D150[0].u = 0; | |
1800 array_73D150[0].v = 0; | |
1801 memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1802 array_73D150[1].u = 1; | |
1803 array_73D150[1].v = 0; | |
1804 memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1805 array_73D150[2].u = 1; | |
1806 array_73D150[2].v = 1; | |
1807 memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft)); | |
1808 array_73D150[3].u = 0; | |
1809 array_73D150[3].v = 1; | |
86 | 1810 v55 = 0; |
1811 v54 = false; | |
1812 v58 = 0; | |
1813 if (v58 == 4) // if all y == first y; primitive in xz plane | |
1814 v8->field_32 |= 0x0001; | |
1815 v8->pODMFace = nullptr; | |
1816 v8->uNumVertices = 4; | |
1817 v8->field_59 = 5; | |
1818 v8->field_58 = 0; | |
1819 ++pOutdoorCamera->numStru148s; | |
1820 ++pOutdoorCamera->field_44; | |
106 | 1821 v8->uBModelID = 0; |
1822 v8->uBModelFaceID = 0; | |
1823 v31 = (8 * (0 | (0 << 6))); | |
1824 v8->field_50 = v31 | 6; | |
1825 for (unsigned int k = 0; k < 4; ++k) | |
1826 { | |
1827 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
1828 array_50AC10[k].flt_20 = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); | |
1829 } | |
140 | 1830 |
1831 assert(v6 < 1000); // many random crashes here | |
106 | 1832 pRenderer->DrawTerrainPolygon(v8, pBitmaps_LOD->pHardwareTextures[v6]); |
86 | 1833 --pOutdoorCamera->numStru148s; |
1834 --pOutdoorCamera->field_44; | |
106 | 1835 } |
1836 } | |
1837 } | |
0 | 1838 |
1839 //----- (0048034E) -------------------------------------------------------- | |
67 | 1840 void Render::DrawTerrainD3D(int a1, int a2, int a3) |
0 | 1841 { |
1842 int v3; // esi@1 | |
1843 int v4; // edi@1 | |
1844 int v5; // ebx@2 | |
1845 int v6; // eax@2 | |
1846 int v7; // eax@3 | |
1847 RenderVertexSoft *v8; // edi@3 | |
1848 RenderVertexSoft *v9; // ebx@4 | |
1849 RenderVertexSoft *v10; // ecx@4 | |
1850 float v11; // eax@6 | |
1851 double v12; // ST5C_8@6 | |
1852 double v13; // ST2C_8@6 | |
1853 int v14; // eax@6 | |
1854 double v15; // st7@6 | |
1855 stru148 *v16; // ebx@12 | |
1856 unsigned __int16 v17; // ax@12 | |
1857 int v18; // eax@13 | |
67 | 1858 int v19; // ecx@13 |
1859 int v20; // eax@13 | |
0 | 1860 int v21; // eax@13 |
1861 signed int v22; // eax@13 | |
1862 Vec3_float_ *v23; // eax@15 | |
1863 double v24; // st6@17 | |
1864 double v25; // ST54_8@17 | |
1865 unsigned __int8 v26; // sf@17 | |
1866 unsigned __int8 v27; // of@17 | |
1867 double v28; // st5@19 | |
1868 double v29; // st5@19 | |
1869 double v30; // st5@19 | |
1870 double v31; // st5@19 | |
67 | 1871 struct struct8 *v32; // esi@21 |
1872 double v3a; // st7@32 | |
0 | 1873 int v33; // edi@38 |
1874 unsigned int v34; // ecx@47 | |
1875 char v35; // zf@47 | |
1876 unsigned int v36; // eax@50 | |
1877 int v37; // eax@54 | |
1878 stru148 *v38; // ecx@55 | |
1879 unsigned int v39; // eax@59 | |
1880 stru148 *v40; // ebx@62 | |
86 | 1881 unsigned __int16 pTileBitmapsID; // ax@62 |
0 | 1882 int v42; // eax@63 |
1883 LightmapBuilder *v43; // ecx@63 | |
67 | 1884 int v44; // eax@63 |
0 | 1885 int v45; // eax@63 |
1886 int v46; // eax@63 | |
1887 signed int v47; // eax@63 | |
1888 Vec3_float_ *v48; // eax@65 | |
1889 double v49; // st6@67 | |
1890 double v50; // ST4C_8@67 | |
1891 double v51; // st5@71 | |
1892 double v52; // st5@71 | |
1893 double v53; // st5@71 | |
1894 double v54; // st7@84 | |
1895 unsigned int v55; // ecx@98 | |
1896 unsigned int v56; // eax@101 | |
1897 int v57; // eax@105 | |
1898 unsigned int v58; // eax@109 | |
1899 stru148 *v59; // esi@112 | |
1900 unsigned __int16 v60; // ax@112 | |
67 | 1901 int v61; // eax@113 |
0 | 1902 signed int v62; // eax@113 |
1903 Vec3_float_ *v63; // eax@114 | |
1904 double v64; // st6@116 | |
1905 double v65; // ST3C_8@116 | |
1906 double v66; // st5@120 | |
1907 double v67; // st5@120 | |
1908 double v68; // st5@120 | |
1909 double v69; // st7@133 | |
1910 int v70; // edi@138 | |
86 | 1911 stru148 *v71; // esi@147 |
0 | 1912 unsigned int v72; // ecx@147 |
1913 unsigned int v73; // eax@150 | |
67 | 1914 int v74; // eax@154 |
0 | 1915 unsigned int v75; // eax@158 |
1916 unsigned int v76; // [sp-10h] [bp-E0h]@61 | |
67 | 1917 int v77; // [sp-Ch] [bp-DCh]@61 |
0 | 1918 IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 |
1919 int v79; // [sp-4h] [bp-D4h]@61 | |
1920 int v80; // [sp+0h] [bp-D0h]@59 | |
1921 int v81; // [sp+0h] [bp-D0h]@109 | |
1922 int v82; // [sp+54h] [bp-7Ch]@1 | |
1923 int v83; // [sp+60h] [bp-70h]@1 | |
1924 int v84; // [sp+6Ch] [bp-64h]@1 | |
1925 int v85; // [sp+70h] [bp-60h]@63 | |
1926 int a4; // [sp+74h] [bp-5Ch]@73 | |
1927 float v87; // [sp+78h] [bp-58h]@122 | |
1928 int v88; // [sp+7Ch] [bp-54h]@1 | |
1929 int v89; // [sp+80h] [bp-50h]@6 | |
1930 float v90; // [sp+84h] [bp-4Ch]@1 | |
1931 float v91; // [sp+88h] [bp-48h]@1 | |
1932 float v92; // [sp+8Ch] [bp-44h]@1 | |
67 | 1933 int v93; // [sp+90h] [bp-40h]@2 |
0 | 1934 int X; // [sp+94h] [bp-3Ch]@1 |
1935 float v95; // [sp+98h] [bp-38h]@21 | |
1936 LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 | |
67 | 1937 int v97; // [sp+A0h] [bp-30h]@6 |
0 | 1938 int sX; // [sp+A4h] [bp-2Ch]@6 |
1939 unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 | |
1940 int v100; // [sp+ACh] [bp-24h]@122 | |
1941 int sY; // [sp+B0h] [bp-20h]@6 | |
67 | 1942 RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 |
0 | 1943 unsigned int a5; // [sp+B8h] [bp-18h]@21 |
1944 RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 | |
1945 Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 | |
1946 RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 | |
67 | 1947 RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 |
0 | 1948 char v108; // [sp+CFh] [bp-1h]@36 |
1949 float thisd; // [sp+D8h] [bp+8h]@6 | |
1950 float thise; // [sp+D8h] [bp+8h]@6 | |
1951 float thisf; // [sp+D8h] [bp+8h]@17 | |
1952 IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 | |
1953 float thisg; // [sp+D8h] [bp+8h]@67 | |
1954 IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 | |
1955 float thish; // [sp+D8h] [bp+8h]@116 | |
1956 IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 | |
1957 char this_3; // [sp+DBh] [bp+Bh]@30 | |
1958 char this_3a; // [sp+DBh] [bp+Bh]@82 | |
1959 char this_3b; // [sp+DBh] [bp+Bh]@131 | |
1960 | |
67 | 1961 static stru154 static_sub_0048034E_stru_154; |
1962 static stru154 stru_76D5A8; | |
0 | 1963 v3 = a1; |
67 | 1964 v82 = a2; |
0 | 1965 v83 = *(/*short **/_WORD *)(a3 + 4); |
1966 X = abs(*(/*short **/_WORD *)(a3 + 6)); | |
1967 v4 = 0; | |
1968 v88 = 0; | |
1969 v84 = v3 - 1; | |
67 | 1970 v90 = (float)pOutdoor->vSunlight.x / 65536,0; |
1971 v91 = (float)pOutdoor->vSunlight.y / 65536.0; | |
1972 v92 = (float)pOutdoor->vSunlight.z / 65536.0; | |
0 | 1973 if ( v3 - 1 > 0 ) |
1974 { | |
1975 while ( 1 ) | |
1976 { | |
1977 v5 = abs(X);//v5 = 13108 | |
1978 v6 = abs(v83);//v6 = 13108 | |
1979 --X; | |
67 | 1980 v93 = (int)&stru_76E5C8[(v5 << 7) + v6]; |
1981 /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), | |
0 | 1982 v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), |
1983 ((a8 = v9, | |
1984 pVertices = &pVerticesSR_801A10[1] + v7, | |
1985 v11 = v8->vWorldPosition.x, | |
1986 v101 = v10, | |
1987 v12 = v11 + 6.755399441055744e15, | |
1988 sX = LODWORD(v12), | |
1989 v13 = v8->vWorldPosition.y + 6.755399441055744e15, | |
1990 sY = LODWORD(v13), | |
1991 thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, | |
62 | 1992 v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X |
0 | 1993 v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, |
1994 v89 = v14, | |
1995 thise = v15 * 0.5, | |
62 | 1996 _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z |
0 | 1997 WorldPosToGridCellX(sX), |
1998 WorldPosToGridCellZ(sY), | |
1999 !byte_4D864C) | |
2000 || !(pGame->uFlags & 0x80)) | |
67 | 2001 && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ |
2002 if ( !&stru_76E5C8[(v5 << 7) + v6] ) | |
0 | 2003 goto LABEL_162; |
67 | 2004 v8 = &pVerticesSR_806210[v4]; |
2005 pVertices2 = &pVerticesSR_801A10[v4 + 1]; | |
2006 v102 = v8; | |
2007 if (!v82) | |
2008 { | |
86 | 2009 pVertices = &pVerticesSR_801A10[v4]; |
2010 v101 = &pVerticesSR_806210[v4 + 1]; | |
67 | 2011 } |
2012 else | |
2013 { | |
86 | 2014 pVertices = &pVerticesSR_801A10[v4 + 1]; |
2015 v101 = &pVerticesSR_806210[v4]; | |
2016 } | |
67 | 2017 sX = floorf(v8->vWorldPosition.x + 0.5f); |
2018 sY = floorf(v8->vWorldPosition.z + 0.5f); | |
2019 v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); | |
2020 v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); | |
2021 WorldPosToGridCellX(sX); | |
2022 WorldPosToGridCellZ(sY); | |
2023 if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) | |
86 | 2024 if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y |
2025 || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) | |
67 | 2026 break; |
2027 v16 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2028 v16->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
86 | 2029 if ( v16->uTileBitmapID != -1 ) |
2030 { | |
2031 v19 = v97; | |
2032 v16->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2033 v16->field_32 = 0; | |
2034 v20 = v93; | |
2035 v16->field_59 = 1; | |
2036 v16->field_5D = (char)v19; | |
2037 v16->field_34 = *(_WORD *)(v20 + 2); | |
2038 v21 = v89; | |
2039 v16->field_5C = v89; | |
2040 v22 = pTerrainNormalIndices[2 * (v19 + 128 * v21) + 1]; | |
2041 if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) | |
2042 v23 = 0; | |
2043 else | |
2044 v23 = &pTerrainNormals[v22]; | |
2045 v24 = v92 * v23->y; | |
2046 //v99 = v23; | |
2047 thisf = 20.0 - (-v24 - v91 * v23->z - v90 * v23->x) * 20.0; | |
2048 //v25 = thisf + 6.7553994e15; | |
2049 //v27 = pOutdoorCamera->numStru148s > 1999; | |
2050 //v26 = pOutdoorCamera->numStru148s - 1999 < 0; | |
2051 v16->field_58 = floorf(thisf + 0.5f); | |
2052 if ( pOutdoorCamera->numStru148s >= 1999 ) | |
2053 return; | |
2054 ++pOutdoorCamera->numStru148s; | |
96 | 2055 //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary |
4 | 2056 //goto LABEL_126; |
96 | 2057 //{ |
2058 //--pOutdoorCamera->numStru148s; | |
2059 //goto LABEL_162; | |
2060 //} | |
86 | 2061 memcpy(&array_50AC10[0], v102, 0x30u); |
2062 array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); | |
2063 array_50AC10[0].u = 0.0; | |
2064 array_50AC10[0].v = 0.0; | |
2065 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
2066 array_50AC10[1].flt_20 = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); | |
2067 array_50AC10[1].u = 0.0; | |
2068 array_50AC10[1].v = 1.0; | |
2069 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
2070 array_50AC10[2].flt_20 = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); | |
2071 array_50AC10[2].u = 1.0; | |
2072 array_50AC10[2].v = 1.0; | |
2073 memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); | |
2074 array_50AC10[3].flt_20 = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); | |
2075 array_50AC10[3].u = 1.0; | |
2076 array_50AC10[3].v = 0.0; | |
2077 /*if ( !(byte_76D5C0 & 1) ) | |
2078 { | |
2079 byte_76D5C0 |= 1u; | |
2080 stru154(stru_76D5A8); | |
2081 atexit(loc_481199); | |
2082 }*/ | |
2083 v32 = (struct8 *)array_50AC10; | |
2084 v97 = (int)pGame->pLightmapBuilder; | |
2085 pGame->pLightmapBuilder->StackLights_TerrainFace(v23, &v95, array_50AC10, 4, 1); | |
2086 pDecalBuilder->_49BE8A(v16, *(float *)&v23, (int)&v95, array_50AC10, 4, 1); | |
2087 a5 = 4; | |
2088 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2089 { | |
2090 thisa = pGame->pIndoorCameraD3D; | |
2091 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) | |
2092 goto LABEL_162; | |
2093 thisa->ViewTransform(array_50AC10, a5); | |
2094 thisa->Project(array_50AC10, a5, 0); | |
2095 } | |
2096 this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 | |
2097 || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
2098 v3a = (double)pOutdoorCamera->shading_dist_mist; | |
2099 v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x | |
2100 || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; | |
2101 v33 = 0; | |
2102 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
2103 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
0 | 2104 { |
86 | 2105 if ( this_3 ) |
2106 v33 = 3; | |
2107 else | |
2108 v33 = v108 != 0 ? 5 : 0; | |
2109 static_sub_0048034E_stru_154._49B0C9(v23, v95); | |
2110 if ( pDecalBuilder->uNumDecals > 0 ) | |
2111 pDecalBuilder->ApplyDecals(31 - v16->field_58, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); | |
0 | 2112 } |
86 | 2113 if ( stru_F8AD28.uNumLightsApplied > 0 ) |
2114 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); | |
2115 v34 = a5; | |
2116 //v35 = byte_4D864C == 0; | |
2117 v16->uNumVertices = a5; | |
2118 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) | |
0 | 2119 { |
86 | 2120 if ( this_3 ) |
2121 { | |
2122 v36 = sr_424CD7(v34); | |
2123 v16->uNumVertices = v36; | |
2124 OutdoorCamera::Project(v36); | |
2125 } | |
2126 if ( v108 ) | |
2127 { | |
2128 v36 = sr_424EE0_MakeFanFromTriangle(v34); | |
2129 v16->uNumVertices = v36; | |
2130 OutdoorCamera::Project(v36); | |
2131 } | |
0 | 2132 } |
86 | 2133 //v37 = *(int *)&v16->flags; |
2134 if ( ~v16->flags & 1 ) | |
2135 { | |
2136 if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) | |
2137 { | |
2138 v80 = false; | |
2139 v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; | |
2140 } | |
2141 else | |
2142 { | |
2143 v39 = v16->uTileBitmapID; | |
2144 v80 = true; | |
2145 } | |
2146 //v79 = 0; | |
2147 //v78 = pBitmaps_LOD->pHardwareTextures[v39]; | |
2148 v16->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary | |
2149 v77 = (int)v16; | |
2150 //v76 = v16->uNumVertices; | |
4 | 2151 //LABEL_161: |
86 | 2152 pRenderer->DrawTerrainPolygon(v16, pBitmaps_LOD->pHardwareTextures[v39]);//pRenderer->DrawTerrainPolygon(v16->uNumVertices, v16, pBitmaps_LOD->pHardwareTextures[v39], false, v80); |
2153 goto LABEL_162; | |
2154 } | |
2155 v38 = v16; | |
0 | 2156 LABEL_56: |
86 | 2157 v38->_4811A3(); |
2158 } | |
0 | 2159 LABEL_162: |
86 | 2160 v4 = v88 + 1; |
2161 if ( ++v88 >= v84 ) | |
2162 return; | |
2163 } | |
2164 v40 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2165 v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
2166 if ( v40->uTileBitmapID == -1 ) | |
2167 goto LABEL_162; | |
2168 v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2169 BYTE1(v42) |= 0x80u; | |
2170 v43 = pGame->pLightmapBuilder; | |
2171 *(int *)&v40->flags = v42; | |
2172 v44 = v93; | |
2173 v40->field_59 = 1; | |
2174 v40->field_5D = (char)v43; | |
2175 v40->field_34 = *(_WORD *)(v44 + 2); | |
2176 v45 = v89; | |
2177 v40->field_5C = v89; | |
2178 v46 = 4 * ((char)v43 + (v45 << 7)); | |
2179 v85 = v46; | |
2180 v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; | |
2181 if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) | |
2182 v48 = 0; | |
2183 else | |
2184 v48 = &pTerrainNormals[v47]; | |
2185 v49 = v92 * v48->y; | |
2186 //v99 = v48; | |
2187 thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; | |
2188 v50 = thisg + 6.755399441055744e15; | |
2189 v40->field_58 = LOBYTE(v50); | |
2190 if ( LOBYTE(v50) < 0 ) | |
2191 v40->field_58 = 0; | |
2192 if ( pOutdoorCamera->numStru148s >= 1999 ) | |
0 | 2193 return; |
86 | 2194 ++pOutdoorCamera->numStru148s; |
2195 /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary | |
2196 //goto LABEL_77; | |
2197 { | |
2198 --pOutdoorCamera->numStru148s; | |
2199 goto LABEL_112; | |
2200 }*/ | |
2201 memcpy(&array_50AC10[0], v102, 0x30u); | |
2202 array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); | |
2203 array_50AC10[0].u = 0.0; | |
2204 array_50AC10[0].v = 0.0; | |
2205 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
2206 array_50AC10[1].flt_20 = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; | |
2207 array_50AC10[1].u = 0.0; | |
2208 array_50AC10[1].v = 1.0; | |
2209 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
2210 array_50AC10[2].flt_20 = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; | |
2211 array_50AC10[2].u = 1.0; | |
2212 array_50AC10[2].v = 1.0; | |
2213 static stru154 static_sub_0048034E_stru_76D590; | |
2214 /*static bool __init_flag2 = false; | |
2215 if (!__init_flag2) | |
2216 { | |
2217 __init_flag2 = true; | |
2218 stru154::stru154(&static_sub_0048034E_stru_76D590); | |
2219 }*/ | |
2220 /*if ( !(byte_76D5C0 & 2) ) | |
2221 { | |
2222 byte_76D5C0 |= 2; | |
2223 stru148(stru_76D590); | |
2224 atexit(loc_48118F); | |
2225 }*/ | |
2226 v96 = pGame->pLightmapBuilder; | |
2227 pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); | |
2228 pDecalBuilder->_49BE8A(v40, *(float *)&v48, (int)&a4, array_50AC10, 3, 0); | |
2229 uNumVertices = 3; | |
2230 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2231 { | |
2232 thisb = pGame->pIndoorCameraD3D; | |
2233 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) | |
2234 { | |
2235 //LABEL_77: | |
2236 --pOutdoorCamera->numStru148s; | |
2237 goto LABEL_112; | |
2238 } | |
2239 thisb->ViewTransform(array_50AC10, uNumVertices); | |
2240 thisb->Project(array_50AC10, uNumVertices, 0); | |
2241 } | |
2242 this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
2243 v54 = (double)pOutdoorCamera->shading_dist_mist; | |
2244 v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; | |
2245 pVertices = 0; | |
2246 v96->std__vector_000004_size = 0; | |
2247 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
2248 { | |
2249 if ( this_3a ) | |
2250 pVertices = (RenderVertexSoft *)3; | |
2251 else | |
2252 pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); | |
2253 //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); | |
2254 static_sub_0048034E_stru_76D590._49B0C9(v48, *(float *)&a4); | |
2255 if ( pDecalBuilder->uNumDecals > 0 ) | |
2256 pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); | |
2257 } | |
2258 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
2259 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); | |
2260 v55 = uNumVertices; | |
2261 //v35 = byte_4D864C == 0; | |
2262 v40->uNumVertices = uNumVertices; | |
2263 if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) | |
2264 { | |
2265 if ( this_3a ) | |
2266 { | |
2267 v56 = sr_424CD7(v55); | |
2268 } | |
2269 else | |
2270 { | |
2271 if ( !v108 ) | |
2272 goto LABEL_105; | |
2273 v56 = sr_424EE0_MakeFanFromTriangle(v55); | |
2274 } | |
2275 v40->uNumVertices = v56; | |
2276 OutdoorCamera::Project(v56); | |
2277 } | |
2278 LABEL_105: | |
2279 v57 = *(int *)&v40->flags; | |
2280 if ( BYTE1(v57) & 1 ) | |
2281 { | |
2282 v40->_4811A3(); | |
2283 } | |
2284 else | |
2285 { | |
2286 if ( v57 & 2 && v40->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) | |
2287 { | |
2288 v81 = 0; | |
2289 v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; | |
2290 } | |
2291 else | |
2292 { | |
2293 v58 = v40->uTileBitmapID; | |
2294 v81 = 1; | |
2295 } | |
2296 pRenderer->DrawTerrainPolygon(v40, pBitmaps_LOD->pHardwareTextures[v58]); | |
2297 } | |
2298 LABEL_112: | |
2299 v59 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2300 //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->numStru148s]; | |
2301 v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
2302 if ( v59->uTileBitmapID == -1 ) | |
2303 goto LABEL_162; | |
2304 *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2305 v61 = v93; | |
2306 v59->field_59 = 1; | |
2307 v59->field_34 = *(_WORD *)(v61 + 2); | |
2308 v59->field_5C = v89; | |
2309 v59->field_5D = v97; | |
2310 v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); | |
2311 if ( v62 > (signed int)(uNumTerrainNormals - 1) ) | |
2312 v63 = 0; | |
2313 else | |
2314 v63 = &pTerrainNormals[v62]; | |
2315 v64 = v92 * v63->y; | |
2316 //v99 = v63; | |
2317 thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; | |
2318 v59->field_58 = floorf(thish + 0.5f); | |
2319 if ( v59->field_58 < 0 ) | |
2320 v59->field_58 = 0; | |
2321 if ( pOutdoorCamera->numStru148s >= 1999 ) | |
2322 return; | |
2323 ++pOutdoorCamera->numStru148s; | |
2324 if ( !sub_481FC9(v101, v102, pVertices2, v59) ) | |
2325 { | |
2326 //LABEL_126: | |
4 | 2327 --pOutdoorCamera->numStru148s; |
86 | 2328 goto LABEL_162; |
2329 } | |
2330 memcpy(&array_50AC10[0], v102, 0x30u); | |
2331 array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); | |
2332 array_50AC10[0].u = 0.0; | |
2333 array_50AC10[0].v = 0.0; | |
2334 memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); | |
2335 array_50AC10[1].flt_20 = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; | |
2336 array_50AC10[1].u = 1.0; | |
2337 array_50AC10[1].v = 1.0; | |
2338 memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); | |
2339 array_50AC10[2].flt_20 = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; | |
2340 array_50AC10[2].u = 1.0; | |
2341 array_50AC10[2].v = 0.0; | |
2342 static stru154 static_sub_0048034E_stru_76D578; | |
2343 /*static bool __init_flag1 = false; | |
2344 if (!__init_flag1) | |
2345 { | |
2346 __init_flag1 = true; | |
2347 stru154::stru154(&static_sub_0048034E_stru_76D578); | |
2348 }*/ | |
2349 v96 = pGame->pLightmapBuilder; | |
2350 pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); | |
2351 pDecalBuilder->_49BE8A(v40, *(float *)&v63, (int)&v87, array_50AC10, 3, 1); | |
2352 v100 = 3; | |
2353 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2354 { | |
2355 thisc = pGame->pIndoorCameraD3D; | |
2356 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) | |
2357 //goto LABEL_126; | |
2358 { | |
2359 --pOutdoorCamera->numStru148s; | |
2360 goto LABEL_162; | |
2361 } | |
2362 thisc->ViewTransform(array_50AC10, v100); | |
2363 thisc->Project(array_50AC10, v100, 0); | |
2364 } | |
2365 this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 | |
2366 || v101->vWorldViewPosition.x < 8.0; | |
2367 v69 = (double)pOutdoorCamera->shading_dist_mist; | |
2368 v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; | |
2369 v70 = 0; | |
2370 v96->std__vector_000004_size = 0; | |
2371 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
2372 { | |
2373 if ( this_3b ) | |
2374 v70 = 3; | |
2375 else | |
2376 v70 = v108 != 0 ? 5 : 0; | |
2377 static_sub_0048034E_stru_76D578._49B0C9(v63, v87); | |
2378 if ( pDecalBuilder->uNumDecals > 0 ) | |
2379 pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); | |
2380 } | |
2381 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
2382 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); | |
2383 v71 = v59; | |
2384 v72 = v100; | |
2385 //v35 = byte_4D864C == 0; | |
2386 v59->uNumVertices = v100;//??? | |
2387 if ( !byte_4D864C && pGame->uFlags & 0x80 ) | |
2388 goto LABEL_154; | |
2389 if ( this_3b ) | |
2390 { | |
2391 v73 = sr_424CD7(v72); | |
0 | 2392 } |
2393 else | |
2394 { | |
2395 if ( !v108 ) | |
86 | 2396 { |
2397 LABEL_154: | |
2398 v74 = v71->flags; | |
2399 if ( !(BYTE1(v74) & 1) ) | |
2400 { | |
2401 if ( v74 & 2 && v71->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) | |
2402 { | |
2403 v80 = false; | |
2404 v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; | |
2405 } | |
2406 else | |
2407 { | |
2408 v75 = v71->uTileBitmapID; | |
2409 v80 = true; | |
2410 } | |
2411 //v79 = 0; | |
2412 //v78 = pBitmaps_LOD->pHardwareTextures[v75]; | |
2413 v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary | |
2414 //v77 = (int)v71; | |
2415 //v76 = v71->uNumVertices; | |
2416 //goto LABEL_161; | |
2417 pRenderer->DrawTerrainPolygon(v71, pBitmaps_LOD->pHardwareTextures[v75]);//pRenderer->DrawTerrainPolygon(v76, (stru148 *)v71, v78, v79, v80); | |
2418 goto LABEL_162; | |
2419 } | |
2420 v38 = (stru148 *)v71; | |
2421 goto LABEL_56; | |
2422 } | |
2423 v73 = sr_424EE0_MakeFanFromTriangle(v72); | |
2424 } | |
2425 v71->uNumVertices = v73; | |
2426 OutdoorCamera::Project(v73); | |
0 | 2427 goto LABEL_154; |
86 | 2428 } |
2429 } | |
0 | 2430 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); |
2431 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); | |
2432 // 4D864C: using guessed type char byte_4D864C; | |
2433 // 76D5C0: using guessed type char static_sub_0048034E_byte_76D5C0__init_flag; | |
2434 | |
2435 | |
2436 | |
2437 //----- (00481212) -------------------------------------------------------- | |
2438 void Render::DrawTerrainSW(int a1, int a2, int a3) | |
2439 { | |
2440 int v3; // esi@1 | |
2441 int v4; // ecx@1 | |
2442 int v5; // ST10_4@1 | |
2443 int v6; // edi@1 | |
2444 int v7; // ebx@2 | |
2445 int v8; // eax@2 | |
2446 int v9; // eax@3 | |
2447 RenderVertexSoft *v10; // edi@3 | |
2448 RenderVertexSoft *v11; // ebx@4 | |
2449 RenderVertexSoft *v12; // ecx@4 | |
2450 float v13; // eax@6 | |
2451 int v14; // eax@6 | |
2452 double v15; // st7@6 | |
2453 double v16; // st7@6 | |
2454 stru148 *v17; // ebx@12 | |
2455 unsigned __int16 v18; // ax@12 | |
2456 int v19; // eax@13 | |
2457 float v20; // ecx@13 | |
2458 stru220 *v21; // eax@13 | |
2459 int v22; // eax@13 | |
2460 signed int v23; // eax@13 | |
2461 Vec3_float_ *v24; // eax@15 | |
2462 double v25; // st7@18 | |
2463 double v26; // st5@24 | |
2464 double v27; // st5@24 | |
2465 double v28; // st5@24 | |
2466 double v29; // st5@24 | |
2467 Game *v30; // eax@25 | |
2468 RenderVertexSoft *v31; // edi@29 | |
2469 double v32; // st7@31 | |
2470 int v33; // esi@35 | |
2471 RenderVertexSoft *v34; // edx@36 | |
2472 RenderVertexSoft *v35; // ecx@36 | |
2473 signed int v36; // eax@39 | |
2474 signed int v37; // esi@40 | |
2475 stru148 *v38; // ebx@43 | |
2476 unsigned __int16 v39; // ax@43 | |
2477 int v40; // eax@44 | |
2478 float v41; // ecx@44 | |
2479 stru220 *v42; // eax@44 | |
2480 int v43; // eax@44 | |
2481 int v44; // eax@44 | |
2482 signed int v45; // eax@44 | |
2483 Vec3_float_ *v46; // eax@46 | |
2484 double v47; // st7@49 | |
2485 double v48; // st5@57 | |
2486 double v49; // st5@57 | |
2487 double v50; // st5@57 | |
2488 Game *v51; // eax@58 | |
2489 RenderVertexSoft *v52; // edi@62 | |
2490 double v53; // st7@63 | |
2491 int v54; // esi@66 | |
2492 signed int v55; // eax@69 | |
2493 signed int v56; // esi@71 | |
2494 unsigned __int16 v57; // ax@75 | |
2495 stru220 *v58; // eax@76 | |
2496 signed int v59; // eax@76 | |
2497 Vec3_float_ *v60; // eax@77 | |
2498 double v61; // st7@80 | |
2499 double v62; // st5@88 | |
2500 double v63; // st5@88 | |
2501 double v64; // st5@88 | |
2502 Game *v65; // eax@89 | |
2503 double v66; // st7@94 | |
2504 RenderVertexSoft *v67; // [sp-Ch] [bp-C4h]@36 | |
2505 stru148 *v68; // [sp-8h] [bp-C0h]@36 | |
2506 int v69; // [sp-4h] [bp-BCh]@36 | |
2507 float v70; // [sp+Ch] [bp-ACh]@88 | |
2508 double v71; // [sp+10h] [bp-A8h]@6 | |
2509 double v72; // [sp+18h] [bp-A0h]@82 | |
2510 double v73; // [sp+20h] [bp-98h]@6 | |
2511 double v74; // [sp+28h] [bp-90h]@51 | |
2512 double v75; // [sp+30h] [bp-88h]@6 | |
2513 double v76; // [sp+38h] [bp-80h]@20 | |
2514 double v77; // [sp+40h] [bp-78h]@6 | |
2515 float v78; // [sp+48h] [bp-70h]@57 | |
2516 float v79; // [sp+4Ch] [bp-6Ch]@6 | |
2517 float v80; // [sp+50h] [bp-68h]@6 | |
2518 int v81; // [sp+54h] [bp-64h]@1 | |
2519 int v82; // [sp+58h] [bp-60h]@6 | |
2520 int v83; // [sp+5Ch] [bp-5Ch]@82 | |
2521 int v84; // [sp+60h] [bp-58h]@20 | |
2522 int v85; // [sp+64h] [bp-54h]@1 | |
2523 int v86; // [sp+68h] [bp-50h]@1 | |
2524 int v87; // [sp+6Ch] [bp-4Ch]@51 | |
2525 float v88; // [sp+70h] [bp-48h]@51 | |
2526 int v89; // [sp+74h] [bp-44h]@6 | |
2527 int v90; // [sp+78h] [bp-40h]@1 | |
2528 float a3a; // [sp+7Ch] [bp-3Ch]@24 | |
2529 stru220 *v92; // [sp+80h] [bp-38h]@2 | |
2530 float v93; // [sp+84h] [bp-34h]@44 | |
2531 int v94; // [sp+88h] [bp-30h]@6 | |
2532 float v95; // [sp+8Ch] [bp-2Ch]@1 | |
2533 float v96; // [sp+90h] [bp-28h]@1 | |
2534 float v97; // [sp+94h] [bp-24h]@1 | |
2535 int X; // [sp+98h] [bp-20h]@1 | |
2536 float v99; // [sp+9Ch] [bp-1Ch]@6 | |
2537 int v100; // [sp+A0h] [bp-18h]@6 | |
2538 unsigned __int64 v101; // [sp+A4h] [bp-14h]@6 | |
2539 RenderVertexSoft *v102; // [sp+ACh] [bp-Ch]@6 | |
2540 RenderVertexSoft *v103; // [sp+B0h] [bp-8h]@6 | |
2541 RenderVertexSoft *v104; // [sp+B4h] [bp-4h]@3 | |
2542 float pNormalc; // [sp+C0h] [bp+8h]@6 | |
2543 float pNormald; // [sp+C0h] [bp+8h]@6 | |
2544 Vec3_float_ *pNormal; // [sp+C0h] [bp+8h]@17 | |
2545 Vec3_float_ *pNormala; // [sp+C0h] [bp+8h]@48 | |
2546 Vec3_float_ *pNormalb; // [sp+C0h] [bp+8h]@77 | |
2547 | |
2548 v3 = a1; | |
2549 //v4 = *(short *)(a3 + 4); | |
2550 //v5 = *(short *)(a3 + 6); | |
2551 v85 = a2; | |
2552 v86 = *(_WORD *)(a3 + 4); //v4; | |
2553 X = abs(*(_WORD *)(a3 + 6)); //v5 | |
2554 v6 = 0; | |
2555 v90 = 0; | |
2556 v81 = v3 - 1; | |
2557 v95 = (double)pOutdoor->vSunlight.x * 0.000015258789; | |
2558 v96 = (double)pOutdoor->vSunlight.y * 0.000015258789; | |
2559 v97 = (double)pOutdoor->vSunlight.z * 0.000015258789; | |
2560 if ( v3 - 1 > 0 ) | |
2561 { | |
2562 while ( 1 ) | |
2563 { | |
2564 v7 = abs(X); | |
2565 v8 = abs(v86); | |
2566 --X; | |
2567 v92 = &stru_76E5C8[(v7 << 7) + v8]; | |
2568 if ( !v92->field_0 | |
2569 || ((v9 = v6, v10 = &pVerticesSR_806210[v6], v104 = v10, !v85) ? (v11 = &pVerticesSR_801A10[v9], | |
2570 v12 = &pVerticesSR_806210[v9 + 1]) : (v11 = &pVerticesSR_806210[v9 + 1], v12 = &pVerticesSR_801A10[v9]), | |
2571 ((v103 = &pVerticesSR_801A10[v9 + 1], | |
2572 v13 = v10->vWorldPosition.x, | |
2573 v102 = v12, | |
2574 v80 = v13, | |
2575 v73 = v13 + 6.7553994e15, | |
2576 v101 = __PAIR__((unsigned int)v11, LODWORD(v73)), | |
2577 v79 = v10->vWorldPosition.y, | |
2578 v75 = v79 + 6.7553994e15, | |
2579 v100 = LODWORD(v75), | |
2580 pNormalc = (v12->vWorldPosition.x + v10->vWorldPosition.x) * 0.5, | |
2581 v71 = pNormalc + 6.7553994e15, | |
2582 v89 = LODWORD(v71), | |
2583 v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(pNormalc + 6.7553994e15)), | |
2584 v15 = v11->vWorldPosition.y + v10->vWorldPosition.y, | |
2585 v94 = v14, | |
2586 pNormald = v15 * 0.5, | |
2587 v16 = pNormald + 6.7553994e15, | |
2588 v77 = v16, | |
2589 v82 = LODWORD(v77), | |
2590 LODWORD(v99) = WorldPosToGridCellZ(LODWORD(v16)), | |
2591 WorldPosToGridCellX(v101), | |
2592 WorldPosToGridCellZ(v100), | |
2593 !byte_4D864C) | |
2594 || !(pGame->uFlags & 0x80)) | |
2595 && !sub_481EFA(v10, v11, v102, v103, 1)) ) | |
2596 goto LABEL_105; | |
2597 if ( v10->vWorldPosition.z != v11->vWorldPosition.z | |
2598 || v11->vWorldPosition.z != v103->vWorldPosition.z | |
2599 || v103->vWorldPosition.z != v102->vWorldPosition.z ) | |
2600 break; | |
2601 v17 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2602 v18 = pOutdoor->GetTileTexture(v101, v100); | |
2603 v17->uTileBitmapID = v18; | |
2604 if ( v18 != -1 ) | |
2605 { | |
2606 v19 = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2607 LOWORD(v19) = v19 | 0x8010; | |
2608 v20 = v99; | |
2609 *(int *)&v17->flags = v19; | |
2610 v21 = v92; | |
2611 v17->field_59 = 1; | |
2612 v17->field_5D = LOBYTE(v20); | |
2613 v17->field_34 = v21->distance; | |
2614 v22 = v94; | |
2615 v17->field_5C = v94; | |
2616 v23 = pTerrainNormalIndices[2 * (LODWORD(v20) + (v22 << 7)) + 1]; | |
2617 if ( v23 < 0 || v23 > (signed int)(uNumTerrainNormals - 1) ) | |
2618 v24 = 0; | |
2619 else | |
2620 v24 = &pTerrainNormals[v23]; | |
2621 pNormal = v24; | |
2622 if ( v24 ) | |
2623 { | |
2624 v25 = -(v97 * v24->z + v96 * v24->y + v95 * v24->x); | |
2625 if ( v25 < 0.0 ) | |
2626 v25 = 0.0; | |
2627 v99 = v25 * 31.0; | |
2628 v76 = v99 + 6.7553994e15; | |
2629 v84 = LODWORD(v76); | |
2630 v17->field_58 = 31 - LOBYTE(v76); | |
2631 } | |
2632 else | |
2633 { | |
2634 v17->field_58 = 0; | |
2635 } | |
2636 if ( pOutdoorCamera->numStru148s >= 1999 ) | |
2637 return; | |
2638 ++pOutdoorCamera->numStru148s; | |
2639 if ( !sub_481FC9(v10, (RenderVertexSoft *)HIDWORD(v101), v102, v17) ) | |
2640 goto LABEL_104; | |
2641 v26 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2642 memcpy(array_50AC10, v104, 0x30u); | |
2643 array_50AC10[0].flt_20 = v26; | |
2644 array_50AC10[0].u = 0.0; | |
2645 array_50AC10[0].v = 0.0; | |
2646 v27 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; | |
2647 memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); | |
2648 array_50AC10[1].flt_20 = 1.0 / v27; | |
2649 array_50AC10[1].u = 0.0; | |
2650 array_50AC10[1].v = 1.0; | |
2651 v28 = v103->vWorldViewPosition.x + 0.0000001; | |
2652 memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); | |
2653 array_50AC10[2].flt_20 = 1.0 / v28; | |
2654 array_50AC10[2].u = 1.0; | |
2655 array_50AC10[2].v = 1.0; | |
2656 v29 = v102->vWorldViewPosition.x + 0.0000001; | |
2657 memcpy(&array_50AC10[3], v102, sizeof(array_50AC10[3])); | |
2658 array_50AC10[3].flt_20 = 1.0 / v29; | |
2659 array_50AC10[3].u = 1.0; | |
2660 array_50AC10[3].v = 0.0; | |
2661 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormal, &a3a, array_50AC10, 4u, 1); | |
2662 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2663 { | |
2664 v17->field_108 = 0; | |
2665 } | |
2666 else | |
2667 { | |
2668 v30 = pGame; | |
2669 v17->field_108 = 1; | |
2670 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 4, pNormal); | |
2671 } | |
2672 if ( v104->vWorldViewPosition.x < 8.0 | |
2673 || *(float *)(HIDWORD(v101) + 12) < 8.0 | |
2674 || (v31 = v102, v102->vWorldViewPosition.x < 8.0) | |
2675 || v103->vWorldViewPosition.x < 8.0 ) | |
2676 { | |
2677 v36 = sr_4250FE(4u); | |
2678 } | |
2679 else | |
2680 { | |
2681 v32 = (double)pOutdoorCamera->shading_dist_mist; | |
2682 if ( v32 >= v104->vWorldViewPosition.x | |
2683 && v32 >= *(float *)(HIDWORD(v101) + 12) | |
2684 && v32 >= v102->vWorldViewPosition.x | |
2685 && v32 >= v103->vWorldViewPosition.x ) | |
2686 { | |
2687 v33 = sr_4254D2(4); | |
2688 v17->uNumVertices = v33; | |
2689 if ( !v33 ) | |
2690 goto LABEL_104; | |
2691 v34 = (RenderVertexSoft *)HIDWORD(v101); | |
2692 v35 = v104; | |
2693 v69 = 0; | |
2694 v68 = v17; | |
2695 v67 = v31; | |
2696 goto LABEL_37; | |
2697 } | |
2698 v36 = sr_4252E8(4u); | |
2699 } | |
2700 v37 = v36; | |
2701 if ( !v36 ) | |
2702 goto LABEL_104; | |
2703 LABEL_41: | |
2704 OutdoorCamera::Project(v37); | |
2705 LABEL_102: | |
2706 v33 = sr_4254D2(v37); | |
2707 v17->uNumVertices = v33; | |
2708 if ( !v33 ) | |
2709 goto LABEL_104; | |
2710 v17->_48276F_sr(); | |
2711 goto LABEL_38; | |
2712 } | |
2713 LABEL_105: | |
2714 v6 = v90++ + 1; | |
2715 if ( v90 >= v81 ) | |
2716 return; | |
2717 } | |
2718 v38 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2719 v39 = pOutdoor->GetTileTexture(v101, v100); | |
2720 v38->uTileBitmapID = v39; | |
2721 if ( v39 == -1 ) | |
2722 goto LABEL_105; | |
2723 v40 = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2724 BYTE1(v40) |= 0x80u; | |
2725 v41 = v99; | |
2726 *(int *)&v38->flags = v40; | |
2727 v42 = v92; | |
2728 v38->field_59 = 1; | |
2729 v38->field_5D = LOBYTE(v41); | |
2730 v38->field_34 = v42->distance; | |
2731 v43 = v94; | |
2732 v38->field_5C = v94; | |
2733 v44 = 2 * (LODWORD(v41) + (v43 << 7)); | |
2734 LODWORD(v93) = v44 * 2; | |
2735 v45 = pTerrainNormalIndices[v44 + 1]; | |
2736 if ( v45 < 0 || v45 > (signed int)(uNumTerrainNormals - 1) ) | |
2737 v46 = 0; | |
2738 else | |
2739 v46 = &pTerrainNormals[v45]; | |
2740 pNormala = v46; | |
2741 if ( v46 ) | |
2742 { | |
2743 v47 = -(v97 * v46->z + v96 * v46->y + v95 * v46->x); | |
2744 if ( v47 < 0.0 ) | |
2745 v47 = 0.0; | |
2746 v88 = v47 * 31.0; | |
2747 v74 = v88 + 6.7553994e15; | |
2748 v87 = LODWORD(v74); | |
2749 v38->field_58 = 31 - LOBYTE(v74); | |
2750 } | |
2751 else | |
2752 { | |
2753 v38->field_58 = 0; | |
2754 } | |
2755 if ( v38->field_58 < 0 ) | |
2756 v38->field_58 = 0; | |
2757 if ( pOutdoorCamera->numStru148s >= 1999 ) | |
2758 return; | |
2759 ++pOutdoorCamera->numStru148s; | |
2760 if ( !sub_481FC9((RenderVertexSoft *)HIDWORD(v101), v103, v104, v38) ) | |
2761 goto LABEL_74; | |
2762 v48 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2763 memcpy(array_50AC10, v104, 0x30u); | |
2764 array_50AC10[0].flt_20 = v48; | |
2765 array_50AC10[0].u = 0.0; | |
2766 array_50AC10[0].v = 0.0; | |
2767 v49 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; | |
2768 memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); | |
2769 array_50AC10[1].flt_20 = 1.0 / v49; | |
2770 array_50AC10[1].u = 0.0; | |
2771 array_50AC10[1].v = 1.0; | |
2772 v50 = v103->vWorldViewPosition.x + 0.0000001; | |
2773 memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); | |
2774 array_50AC10[2].flt_20 = 1.0 / v50; | |
2775 array_50AC10[2].u = 1.0; | |
2776 array_50AC10[2].v = 1.0; | |
2777 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormala, &v78, array_50AC10, 3u, 0); | |
2778 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2779 { | |
2780 v38->field_108 = 0; | |
2781 } | |
2782 else | |
2783 { | |
2784 v51 = pGame; | |
2785 v38->field_108 = 1; | |
2786 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormala); | |
2787 } | |
2788 if ( v104->vWorldViewPosition.x < 8.0 | |
2789 || *(float *)(HIDWORD(v101) + 12) < 8.0 | |
2790 || (v52 = v103, v103->vWorldViewPosition.x < 8.0) ) | |
2791 { | |
2792 v55 = sr_4250FE(3u); | |
2793 } | |
2794 else | |
2795 { | |
2796 v53 = (double)pOutdoorCamera->shading_dist_mist; | |
2797 if ( v53 >= v104->vWorldViewPosition.x | |
2798 && v53 >= *(float *)(HIDWORD(v101) + 12) | |
2799 && v53 >= v103->vWorldViewPosition.x ) | |
2800 { | |
2801 v54 = sr_4254D2(3); | |
2802 v38->uNumVertices = v54; | |
2803 if ( v54 ) | |
2804 { | |
2805 sr_sub_4829B9((RenderVertexSoft *)HIDWORD(v101), v52, v104, v38, 0); | |
2806 LABEL_68: | |
2807 sr_sub_481DB2(array_508690, v54, v38); | |
2808 LABEL_75: | |
2809 v17 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2810 v57 = pOutdoor->GetTileTexture(v101, v100); | |
2811 v17->uTileBitmapID = v57; | |
2812 if ( v57 == -1 ) | |
2813 goto LABEL_105; | |
2814 *(int *)&v17->flags = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2815 v58 = v92; | |
2816 v17->field_59 = 1; | |
2817 v17->field_34 = v58->distance; | |
2818 v17->field_5C = v94; | |
2819 v17->field_5D = LOBYTE(v99); | |
2820 v59 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + LODWORD(v93)); | |
2821 if ( v59 > (signed int)(uNumTerrainNormals - 1) ) | |
2822 { | |
2823 pNormalb = 0; | |
2824 v60 = 0; | |
2825 } | |
2826 else | |
2827 { | |
2828 v60 = &pTerrainNormals[v59]; | |
2829 pNormalb = v60; | |
2830 } | |
2831 if ( v60 ) | |
2832 { | |
2833 v61 = -(v97 * v60->z + v96 * v60->y + v95 * v60->x); | |
2834 if ( v61 < 0.0 ) | |
2835 v61 = 0.0; | |
2836 v93 = v61 * 31.0; | |
2837 v72 = v93 + 6.7553994e15; | |
2838 v83 = LODWORD(v72); | |
2839 v17->field_58 = 31 - LOBYTE(v72); | |
2840 } | |
2841 else | |
2842 { | |
2843 v17->field_58 = 0; | |
2844 } | |
2845 if ( v17->field_58 < 0 ) | |
2846 v17->field_58 = 0; | |
2847 if ( pOutdoorCamera->numStru148s >= 1999 ) | |
2848 return; | |
2849 ++pOutdoorCamera->numStru148s; | |
2850 if ( !sub_481FC9(v102, v104, v103, v17) ) | |
2851 { | |
2852 LABEL_104: | |
2853 --pOutdoorCamera->numStru148s; | |
2854 goto LABEL_105; | |
2855 } | |
2856 v62 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2857 memcpy(array_50AC10, v104, 0x30u); | |
2858 array_50AC10[0].flt_20 = v62; | |
2859 array_50AC10[0].u = 0.0; | |
2860 array_50AC10[0].v = 0.0; | |
2861 v63 = v103->vWorldViewPosition.x + 0.0000001; | |
2862 memcpy(&array_50AC10[1], v103, sizeof(array_50AC10[1])); | |
2863 array_50AC10[1].flt_20 = 1.0 / v63; | |
2864 array_50AC10[1].u = 1.0; | |
2865 array_50AC10[1].v = 1.0; | |
2866 v64 = v102->vWorldViewPosition.x + 0.0000001; | |
2867 memcpy(&array_50AC10[2], v102, sizeof(array_50AC10[2])); | |
2868 array_50AC10[2].flt_20 = 1.0 / v64; | |
2869 array_50AC10[2].u = 1.0; | |
2870 array_50AC10[2].v = 0.0; | |
2871 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormalb, &v70, array_50AC10, 3u, 1); | |
2872 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2873 { | |
2874 v17->field_108 = 0; | |
2875 } | |
2876 else | |
2877 { | |
2878 v65 = pGame; | |
2879 v17->field_108 = 1; | |
2880 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormalb); | |
2881 } | |
2882 if ( v104->vWorldViewPosition.x < 8.0 || v103->vWorldViewPosition.x < 8.0 || v102->vWorldViewPosition.x < 8.0 ) | |
2883 { | |
2884 v37 = sr_4250FE(3u); | |
2885 OutdoorCamera::Project(v37); | |
2886 if ( !v37 ) | |
2887 goto LABEL_104; | |
2888 goto LABEL_102; | |
2889 } | |
2890 v66 = (double)pOutdoorCamera->shading_dist_mist; | |
2891 if ( v66 < v104->vWorldViewPosition.x || v66 < v103->vWorldViewPosition.x || v66 < v102->vWorldViewPosition.x ) | |
2892 { | |
2893 v37 = sr_4252E8(3u); | |
2894 if ( !v37 ) | |
2895 goto LABEL_105; | |
2896 goto LABEL_41; | |
2897 } | |
2898 v33 = sr_4254D2(3); | |
2899 v17->uNumVertices = v33; | |
2900 if ( !v33 ) | |
2901 goto LABEL_104; | |
2902 v34 = v104; | |
2903 v35 = v102; | |
2904 v69 = 0; | |
2905 v68 = v17; | |
2906 v67 = v103; | |
2907 LABEL_37: | |
2908 sr_sub_4829B9(v35, v34, v67, v68, v69); | |
2909 LABEL_38: | |
2910 sr_sub_481DB2(array_508690, v33, v17); | |
2911 goto LABEL_105; | |
2912 } | |
2913 goto LABEL_74; | |
2914 } | |
2915 v55 = sr_4252E8(3u); | |
2916 } | |
2917 v56 = v55; | |
2918 if ( v55 ) | |
2919 { | |
2920 OutdoorCamera::Project(v55); | |
2921 v54 = sr_4254D2(v56); | |
2922 v38->uNumVertices = v54; | |
2923 if ( v54 ) | |
2924 { | |
2925 v38->_48276F_sr(); | |
2926 goto LABEL_68; | |
2927 } | |
2928 } | |
2929 LABEL_74: | |
2930 --pOutdoorCamera->numStru148s; | |
2931 goto LABEL_75; | |
2932 } | |
2933 } | |
2934 | |
2935 | |
2936 //----- (0047BACF) -------------------------------------------------------- | |
2937 void Render::TransformBillboardsAndSetPalettesODM() | |
2938 { | |
142 | 2939 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2940 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2941 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2942 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2943 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2944 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2945 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2946 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2947 //int v8; // ebx@4 |
0 | 2948 unsigned __int16 *v9; // eax@7 |
2949 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2950 //DWORD v11; // eax@13 |
0 | 2951 int v12; // eax@13 |
2952 int v13; // eax@14 | |
2953 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
2954 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 2955 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2956 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 2957 int v18; // [sp+60h] [bp-4h]@13 |
2958 | |
2959 billboard.uParentBillboardID = -1; | |
2960 billboard.pTarget = pRenderer->pTargetSurface; | |
2961 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
2962 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
2963 billboard.uViewportX = pViewport->uViewportX; | |
2964 billboard.uViewportY = pViewport->uViewportY; | |
2965 billboard.uViewportZ = pViewport->uViewportZ - 1; | |
2966 billboard.uViewportW = pViewport->uViewportW; | |
2967 pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw; | |
142 | 2968 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2969 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 2970 { |
143 | 2971 auto pBillboard = pBillboardRenderList + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2972 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2973 billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2974 billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2975 billboard.uParentBillboardID = i; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2976 billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2977 billboard.uTintColor = pBillboard->uTintColor; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2978 billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2979 billboard.sZValue = pBillboard->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2980 billboard.uFlags = pBillboard->field_1E; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2981 if (pBillboard->uHwSpriteID != -1) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2982 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2983 if (pRenderer->pRenderD3D) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2984 pRenderer->TransformBillboard(&billboard, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2985 &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2986 pBillboard->uPaletteSubindex, pBillboard); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2987 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2988 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2989 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2990 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2991 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 2992 if ( *(v1 - 10) & 2 ) |
2993 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
2994 else | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2995 v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 2996 v10 = (*(v1 - 9) & 1) == 0; |
2997 billboard.pPalette = v9; | |
2998 if ( !v10 ) | |
2999 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
3000 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
3001 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3002 v12 = stru_5C6E00->SinCos(i * 5 + GetTickCount()); |
0 | 3003 v15 = abs(v12); |
3004 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
3005 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
3006 } | |
3007 v13 = *((short *)v1 - 8); | |
3008 if ( v13 >= 0 ) | |
3009 pSprites_LOD->pSpriteHeaders[v13]._4ACC38(&billboard, 1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3010 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3011 } |
0 | 3012 } |
3013 } | |
3014 | |
3015 | |
3016 //----- (0047AF11) -------------------------------------------------------- | |
3017 void Render::DrawLayingItems_Shooting_Magic_ODM() | |
3018 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3019 //char *v0; // edi@2 |
0 | 3020 ObjectDesc *v1; // ebx@4 |
3021 __int16 v2; // cx@5 | |
3022 RenderBillboard *v3; // esi@10 | |
3023 SpriteFrame *v4; // eax@10 | |
3024 SpriteFrame *v5; // ebx@10 | |
3025 unsigned int v6; // eax@10 | |
3026 int v7; // ecx@10 | |
3027 int v8; // edx@10 | |
3028 int v9; // ecx@10 | |
3029 unsigned __int16 v10; // ax@10 | |
3030 int *v11; // eax@14 | |
3031 int v12; // eax@22 | |
3032 int v13; // ST3C_4@23 | |
3033 int v14; // eax@23 | |
3034 int v15; // ecx@23 | |
3035 int v16; // ebx@23 | |
3036 int v17; // ecx@25 | |
3037 int v18; // eax@25 | |
3038 int v19; // ST40_4@26 | |
3039 int v20; // ecx@26 | |
3040 int v21; // ST44_4@28 | |
3041 int v22; // ST3C_4@29 | |
3042 signed __int64 v23; // qtt@30 | |
3043 int v24; // ebx@30 | |
3044 int v25; // ST3C_4@30 | |
3045 int v26; // eax@31 | |
3046 char v27; // zf@31 | |
3047 SpriteFrame *v28; // [sp+Ch] [bp-34h]@10 | |
3048 __int16 a5; // [sp+10h] [bp-30h]@10 | |
3049 int v30; // [sp+14h] [bp-2Ch]@23 | |
3050 int v31; // [sp+14h] [bp-2Ch]@29 | |
3051 __int16 v32; // [sp+14h] [bp-2Ch]@30 | |
3052 int v33; // [sp+18h] [bp-28h]@23 | |
3053 int v34; // [sp+18h] [bp-28h]@26 | |
3054 int v35; // [sp+18h] [bp-28h]@30 | |
3055 int v36; // [sp+1Ch] [bp-24h]@10 | |
3056 int v37; // [sp+1Ch] [bp-24h]@23 | |
3057 int a6; // [sp+20h] [bp-20h]@10 | |
3058 int a6a; // [sp+20h] [bp-20h]@23 | |
3059 int v40; // [sp+24h] [bp-1Ch]@25 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3060 //signed int v41; // [sp+28h] [bp-18h]@1 |
0 | 3061 int v42; // [sp+2Ch] [bp-14h]@23 |
3062 int y; // [sp+30h] [bp-10h]@10 | |
3063 int x; // [sp+34h] [bp-Ch]@10 | |
3064 int z; // [sp+38h] [bp-8h]@10 | |
3065 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
3066 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3067 //v41 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3068 for (int i = 0; i < uNumLayingItems; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3069 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3070 auto v0 = (char *)&pLayingItems[i].uSectorID; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3071 //v0 = (char *)&pLayingItems[0].uSectorID; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3072 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3073 //{ |
0 | 3074 if ( *((short *)v0 - 13) ) |
3075 { | |
3076 v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
3077 if ( !(v1->uFlags & 1) ) | |
3078 { | |
3079 if ( ((v2 = *((short *)v0 - 14), v2 < 1000) || v2 >= 10000) && (v2 < 500 || v2 >= 600) | |
3080 || pGame->pStru6Instance->_4A81CA((LayingItem *)(v0 - 28)) ) | |
3081 { | |
3082 a5 = *(short *)v0; | |
3083 x = *((int *)v0 - 6); | |
3084 y = *((int *)v0 - 5); | |
3085 z = *((int *)v0 - 4); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3086 v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; |
0 | 3087 v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, *((short *)v0 + 1)); |
3088 v5 = v4; | |
3089 v28 = v4; | |
3090 v36 = v4->uFlags; | |
3091 a6 = v4->uGlowRadius * *((short *)v0 + 3); | |
3092 v6 = stru_5C6E00->Atan2( | |
3093 *((int *)v0 - 6) - pIndoorCamera->pos.x, | |
3094 *((int *)v0 - 5) - pIndoorCamera->pos.y); | |
3095 LOWORD(v7) = *((short *)v0 - 3); | |
3096 v8 = v36; | |
3097 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7; | |
3098 v10 = v5->pHwSpriteIDs[v9]; | |
3099 v3->uHwSpriteID = v10; | |
3100 if ( v36 & 0x20 ) | |
3101 { | |
3102 v8 = v36; | |
3103 z -= (signed int)((unsigned __int64)(v5->scale | |
3104 * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
3105 } | |
3106 v46 = 0; | |
3107 if ( v8 & 2 ) | |
3108 v46 = 2; | |
3109 v11 = (int *)(256 << v9); | |
3110 if ( (256 << v9) & v8 ) | |
3111 v46 |= 4u; | |
3112 if ( v8 & 0x40000 ) | |
3113 v46 |= 0x40u; | |
3114 if ( v8 & 0x20000 ) | |
3115 LOBYTE(v46) = v46 | 0x80; | |
3116 if ( a6 ) | |
3117 { | |
3118 LOBYTE(v11) = byte_4E94D3; | |
3119 pMobileLightsStack->AddLight(x, y, z, a5, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); | |
3120 } | |
3121 v12 = (x - pIndoorCamera->pos.x) << 16; | |
3122 if ( pIndoorCamera->sRotationX ) | |
3123 { | |
3124 v13 = (y - pIndoorCamera->pos.y) << 16; | |
3125 v30 = ((unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | |
3126 + ((unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3127 v37 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3128 a6a = (unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3129 v33 = (z - pIndoorCamera->pos.z) << 16; | |
3130 v14 = (unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3131 v15 = (unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3132 v16 = v15 + v14; | |
3133 v42 = v15 + v14; | |
3134 if ( v15 + v14 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3135 { | |
3136 v17 = a6a - v37; | |
3137 v40 = a6a - v37; | |
3138 v18 = ((unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) | |
3139 - ((unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3140 goto LABEL_29; | |
3141 } | |
3142 } | |
3143 else | |
3144 { | |
3145 v34 = (y - pIndoorCamera->pos.y) << 16; | |
3146 v19 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3147 v20 = (unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3148 v16 = v20 + v19; | |
3149 v42 = v20 + v19; | |
3150 if ( v20 + v19 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3151 { | |
3152 v21 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) | |
3153 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3154 v17 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | |
3155 - v21; | |
3156 v40 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | |
3157 - v21; | |
3158 v18 = (z - pIndoorCamera->pos.z) << 16; | |
3159 LABEL_29: | |
3160 v31 = v18; | |
3161 v22 = abs(v17); | |
3162 if ( abs(v16) >= v22 ) | |
3163 { | |
3164 LODWORD(v23) = 0; | |
3165 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3166 v24 = v23 / v42; | |
3167 v25 = v23 / v42; | |
3168 LODWORD(v23) = 0; | |
3169 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3170 v35 = pViewport->uScreenCenterX | |
3171 - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); | |
3172 v32 = LOWORD(pViewport->uScreenCenterY) | |
3173 - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3174 if (::uNumBillboardsToDraw >= 500) |
0 | 3175 return; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3176 ++::uNumBillboardsToDraw; |
0 | 3177 ++uNumSpritesDrawnThisFrame; |
3178 *(v0 - 2) |= 1u; | |
3179 v3->uPalette = v28->uPaletteIndex; | |
3180 v3->uIndoorSectorID = a5; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3181 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16; |
0 | 3182 v26 = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16; |
3183 v3->pSpriteFrame = v28; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3184 v3->_screenspace_y_scaler_packedfloat = v26; |
0 | 3185 v3->field_1E = v46; |
3186 v3->some_x = x; | |
3187 v3->some_y = y; | |
3188 v3->some_z = z; | |
3189 v3->uScreenSpaceX = v35; | |
3190 v3->uScreenSpaceY = v32; | |
3191 HIWORD(v26) = HIWORD(v42); | |
3192 LOWORD(v26) = 0; | |
3193 v27 = (*(v0 - 2) & 0x20) == 0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3194 v3->sZValue = v26 + (8 * i | OBJECT_Item); |
0 | 3195 v3->uPaletteSubindex = 0; |
3196 v3->uTintColor = 0; | |
3197 if ( !v27 ) | |
3198 { | |
3199 if ( !pRenderer->pRenderD3D ) | |
3200 v3->sZValue = 0; | |
3201 } | |
3202 } | |
3203 goto LABEL_34; | |
3204 } | |
3205 } | |
3206 } | |
3207 } | |
3208 } | |
3209 LABEL_34: | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3210 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3211 //++v41; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3212 //v0 += 112; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3213 //} |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3214 //while ( v41 < (signed int)uNumLayingItems ); |
0 | 3215 } |
3216 } | |
3217 // 4E94D3: using guessed type char byte_4E94D3; | |
3218 // 5187E4: using guessed type int uNumSpritesDrawnThisFrame; | |
3219 | |
3220 | |
3221 //----- (0049D9BC) -------------------------------------------------------- | |
3222 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
3223 { | |
3224 size_t v4; // eax@1 | |
3225 size_t v5; // eax@1 | |
3226 IUnknown *v6; // eax@10 | |
3227 size_t v7; // eax@13 | |
3228 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
3229 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
3230 int v11; // [sp+430h] [bp-CCh]@16 | |
3231 int v12; // [sp+434h] [bp-C8h]@16 | |
3232 int v13; // [sp+438h] [bp-C4h]@16 | |
3233 int v14; // [sp+474h] [bp-88h]@16*/ | |
3234 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
3235 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
3236 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
3237 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
3238 int v19; // [sp+4C8h] [bp-34h]@16 | |
3239 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
3240 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
3241 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
3242 | |
3243 v4 = strlen(lpDriverName); | |
3244 v20.pDriverName = new char[v4 + 1]; | |
3245 v5 = strlen(lpDevDesc); | |
3246 v20.pDeviceDesc = new char[v5 + 1]; | |
3247 strcpy(v20.pDriverName, lpDriverName); | |
3248 strcpy(v20.pDeviceDesc, lpDevDesc); | |
3249 if ( lpGUID ) | |
3250 { | |
3251 v20.pGUID = new GUID; | |
3252 memcpy(v20.pGUID, lpGUID, 0x10u); | |
3253 } | |
3254 else | |
3255 { | |
3256 v20.pGUID = 0; | |
3257 } | |
3258 | |
3259 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
3260 { | |
3261 delete [] v20.pDriverName; | |
3262 delete [] v20.pDeviceDesc; | |
3263 if ( v20.pGUID ) | |
3264 delete v20.pGUID; | |
3265 } | |
3266 else | |
3267 { | |
3268 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
3269 { | |
3270 delete [] v20.pDriverName; | |
3271 delete [] v20.pDeviceDesc; | |
3272 if ( v20.pGUID ) | |
3273 delete v20.pGUID; | |
3274 v6 = (IUnknown *)pDirectDraw; | |
3275 } | |
3276 else | |
3277 { | |
3278 pDirectDraw->Release(); | |
3279 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1u))) | |
3280 { | |
3281 v20.pDDraw4DevDesc = 0; | |
3282 } | |
3283 else | |
3284 { | |
3285 v7 = strlen(ddDevId.szDescription); | |
3286 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
3287 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
3288 } | |
3289 memset(&ddsCaps, 0, 0x10u); | |
3290 if (FAILED(pDirectDraw4->GetAvailableVidMem( | |
3291 &ddsCaps, | |
3292 (LPDWORD)&v20.uVideoMem, | |
3293 (LPDWORD)&uFreeVideoMem))) | |
3294 v20.uVideoMem = 0; | |
3295 memset(&v10, 0, 0x7Cu); | |
3296 v10.dwSize = 124; | |
3297 v10.dwFlags = 6; | |
3298 v10.dwHeight = 640; | |
3299 v10.dwWidth = 480; | |
3300 v10.ddpfPixelFormat.dwSize = 32; | |
3301 | |
3302 v19 = 0; | |
3303 if ( FAILED(pDirectDraw4->EnumDisplayModes( | |
3304 0, | |
3305 0, | |
3306 &v19, | |
3307 (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) | |
3308 || !v19 | |
3309 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
3310 { | |
3311 delete [] v20.pDriverName; | |
3312 delete [] v20.pDeviceDesc; | |
3313 if ( v20.pDDraw4DevDesc ) | |
3314 free(v20.pDDraw4DevDesc); | |
3315 if ( v20.pGUID ) | |
3316 delete v20.pGUID; | |
3317 v6 = (IUnknown *)pDirectDraw4; | |
3318 } | |
3319 else | |
3320 { | |
3321 aux.pInfo = pOut; | |
3322 aux.ptr_4 = &v20; | |
3323 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
3324 delete [] v20.pDriverName; | |
3325 delete [] v20.pDeviceDesc; | |
3326 if ( v20.pDDraw4DevDesc ) | |
3327 free(v20.pDDraw4DevDesc); | |
3328 if ( v20.pGUID ) | |
3329 delete v20.pGUID; | |
3330 pDirectDraw4->Release(); | |
3331 v6 = (IUnknown *)pDirect3D3; | |
3332 pDirectDraw4 = 0; | |
3333 } | |
3334 } | |
3335 v6->Release(); | |
3336 } | |
3337 return 1; | |
3338 } | |
3339 | |
3340 | |
3341 //----- (0049D784) -------------------------------------------------------- | |
3342 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
3343 { | |
3344 int v6; // eax@1 | |
3345 signed int v7; // edi@1 | |
3346 signed int v8; // edi@14 | |
3347 size_t v9; // eax@30 | |
3348 size_t v10; // eax@30 | |
3349 size_t v11; // eax@30 | |
3350 size_t v12; // eax@30 | |
3351 size_t v13; // eax@30 | |
3352 | |
3353 v6 = pHWDesc->dwFlags; | |
3354 v7 = -1; | |
3355 if ( v6 ) | |
3356 { | |
3357 if ( !a6->ptr_4->pGUID ) | |
3358 v7 = 0; | |
3359 if ( v6 && a6->ptr_4->pGUID ) | |
3360 v7 = 1; | |
3361 } | |
3362 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
3363 v7 = 2; | |
3364 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
3365 v7 = 3; | |
3366 if ( v7 != -1 ) | |
3367 { | |
3368 v8 = v7; | |
3369 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
3370 a6->pInfo[v8].uCaps = 0; | |
3371 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
3372 a6->pInfo[v8].uCaps |= 2u; | |
3373 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
3374 a6->pInfo[v8].uCaps |= 4u; | |
3375 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
3376 a6->pInfo[v8].uCaps |= 8u; | |
3377 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
3378 a6->pInfo[v8].uCaps |= 0x10u; | |
3379 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
3380 a6->pInfo[v8].uCaps |= 0x20u; | |
3381 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
3382 a6->pInfo[v8].uCaps |= 0x40u; | |
3383 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
3384 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
3385 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
3386 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
3387 v9 = strlen(lpDeviceName); | |
3388 a6->pInfo[v8].pName = new char[v9 + 1]; | |
3389 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
3390 v10 = strlen(lpDeviceDesc); | |
3391 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
3392 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
3393 a6->pInfo[v8].pGUID = (GUID *)operator new(0x10u); | |
3394 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); | |
3395 v11 = strlen(a6->ptr_4->pDriverName); | |
3396 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
3397 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
3398 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
3399 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
3400 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
3401 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
3402 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
3403 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
3404 if ( a6->ptr_4->pGUID ) | |
3405 { | |
3406 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
3407 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
3408 } | |
3409 else | |
3410 { | |
3411 a6->pInfo[v8].pDirectDrawGUID = 0; | |
3412 } | |
3413 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
3414 } | |
3415 return 1; | |
3416 } | |
3417 | |
3418 | |
3419 //----- (0049D75C) -------------------------------------------------------- | |
3420 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
3421 { | |
3422 HRESULT result; // eax@3 | |
3423 | |
3424 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
3425 { | |
3426 *a2 = 1; | |
3427 result = 0; | |
3428 } | |
3429 else | |
3430 { | |
3431 result = 1; | |
3432 } | |
3433 return result; | |
3434 } | |
3435 | |
3436 | |
3437 | |
3438 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3439 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3440 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3441 //char *v0; // esi@2 |
0 | 3442 DecorationDesc *v1; // ebx@6 |
3443 __int16 v2; // ax@6 | |
3444 double v3; // st7@7 | |
3445 int v4; // eax@9 | |
3446 int v5; // edx@9 | |
3447 unsigned int v6; // edi@9 | |
3448 int v7; // eax@9 | |
3449 SpriteFrame *v8; // eax@9 | |
3450 SpriteFrame *v9; // edi@9 | |
3451 unsigned __int16 *v10; // eax@9 | |
3452 int v11; // ecx@9 | |
3453 int v12; // eax@9 | |
3454 int v13; // ecx@9 | |
3455 int v14; // ecx@20 | |
3456 char v15; // dl@20 | |
3457 signed int v16; // eax@20 | |
3458 int v17; // eax@23 | |
3459 int v18; // ecx@24 | |
3460 int v19; // eax@24 | |
3461 int v20; // ecx@24 | |
3462 int v21; // ebx@26 | |
3463 int v22; // eax@26 | |
3464 int v23; // eax@30 | |
3465 signed __int64 v24; // qtt@31 | |
3466 int v25; // ebx@31 | |
3467 int v26; // ecx@32 | |
3468 RenderBillboard *v27; // eax@37 | |
3469 __int16 v28; // dx@37 | |
3470 __int16 v29; // cx@37 | |
3471 int v30; // ecx@37 | |
3472 int v31; // ebx@37 | |
3473 Particle_ local_0; // [sp+Ch] [bp-98h]@7 | |
3474 int x; // [sp+74h] [bp-30h]@9 | |
3475 int y; // [sp+78h] [bp-2Ch]@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3476 //int v35; // [sp+7Ch] [bp-28h]@1 |
0 | 3477 int v36; // [sp+80h] [bp-24h]@9 |
3478 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 | |
3479 int v38; // [sp+88h] [bp-1Ch]@9 | |
3480 int v39; // [sp+8Ch] [bp-18h]@24 | |
3481 int v40; // [sp+90h] [bp-14h]@24 | |
3482 int v41; // [sp+94h] [bp-10h]@24 | |
3483 int v42; // [sp+98h] [bp-Ch]@9 | |
3484 int a5; // [sp+9Ch] [bp-8h]@9 | |
3485 int b; // [sp+A0h] [bp-4h]@22 | |
3486 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3487 //v35 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3488 //if ( (signed int)uNumLevelDecorations > 0 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3489 //{ |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3490 //v0 = (char *)&pLevelDecorations[0].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3491 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3492 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3493 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3494 auto v0 = (char *)&pLevelDecorations[i].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3495 |
0 | 3496 if ( (!(*(v0 - 6) & 0x40) || ((LevelDecoration *)(v0 - 8))->_47A825()) && !(*(v0 - 6) & 0x20) ) |
3497 { | |
3498 v1 = &pDecorationList->pDecorations[*((short *)v0 - 4)]; | |
3499 v2 = v1->uFlags; | |
3500 if ( (char)v2 >= 0 ) | |
3501 { | |
3502 if ( !(v2 & 0x22) ) | |
3503 { | |
3504 v4 = *((int *)v0 - 1); | |
3505 v5 = *((int *)v0 + 1); | |
3506 v6 = pMiscTimer->uTotalGameTimeElapsed; | |
3507 y = *(int *)v0; | |
3508 x = v4; | |
3509 v36 = v5; | |
3510 v7 = abs(v4 + y); | |
3511 v8 = pSpriteFrameTable->GetFrame(v1->uSpriteID, v6 + v7); | |
3512 v9 = v8; | |
3513 v42 = v8->uFlags; | |
3514 a5 = v8->uGlowRadius; | |
3515 v10 = (unsigned __int16 *)stru_5C6E00->Atan2( | |
3516 *((int *)v0 - 1) - pIndoorCamera->pos.x, | |
3517 *(int *)v0 - pIndoorCamera->pos.y); | |
3518 v11 = *((int *)v0 + 2); | |
3519 v37 = v10; | |
3520 v12 = v42; | |
3521 v38 = 0; | |
3522 v13 = ((signed int)(stru_5C6E00->uIntegerPi | |
3523 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
3524 + v11 | |
3525 - (signed int)v37) >> 8) & 7; | |
3526 v37 = (unsigned __int16 *)v13; | |
3527 if ( v42 & 2 ) | |
3528 v38 = 2; | |
3529 if ( (256 << v13) & v42 ) | |
3530 v38 |= 4u; | |
3531 if ( v12 & 0x40000 ) | |
3532 v38 |= 0x40u; | |
3533 if ( v12 & 0x20000 ) | |
3534 LOBYTE(v38) = v38 | 0x80; | |
3535 if ( a5 ) | |
3536 { | |
3537 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) | |
3538 { | |
3539 v14 = v1->uColoredLightRed; | |
3540 v15 = v1->uColoredLightGreen; | |
3541 v16 = v1->uColoredLightBlue; | |
3542 } | |
3543 else | |
3544 { | |
3545 v16 = 255; | |
3546 v14 = 255; | |
3547 v15 = 255; | |
3548 } | |
3549 b = v16; | |
3550 pStationaryLightsStack->AddLight( | |
3551 x, | |
3552 y, | |
3553 v36 + v1->uDecorationHeight / 2, | |
3554 a5, | |
3555 v14, | |
3556 v15, | |
3557 v16, | |
3558 byte_4E94D0); | |
3559 } | |
3560 v17 = (x - pIndoorCamera->pos.x) << 16; | |
3561 if ( pIndoorCamera->sRotationX ) | |
3562 { | |
3563 v40 = (y - pIndoorCamera->pos.y) << 16; | |
3564 v18 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | |
3565 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3566 v42 = v18; | |
3567 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3568 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3569 v40 = (v36 - pIndoorCamera->pos.z) << 16; | |
3570 v41 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3571 v19 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3572 v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3573 v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3574 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3575 { | |
3576 v21 = a5 - b; | |
3577 v41 = a5 - b; | |
3578 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3579 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3580 v22 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) - a5; | |
3581 LABEL_30: | |
3582 v42 = v22; | |
3583 v40 = 2 * abs(v20); | |
3584 v23 = abs(v21); | |
3585 if ( v40 >= v23 ) | |
3586 { | |
3587 LODWORD(v24) = 0; | |
3588 HIDWORD(v24) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3589 a5 = v24 / v39; | |
3590 v25 = pViewport->uScreenCenterX | |
3591 - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); | |
3592 b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; | |
3593 v41 = v24 / v39; | |
3594 v40 = pViewport->uScreenCenterY | |
3595 - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); | |
3596 v42 = v9->scale; | |
3597 v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; | |
3598 v37 = (unsigned __int16 *)&v9->pHwSpriteIDs[(int)v37]; | |
3599 if ( pRenderer->pRenderD3D ) | |
3600 { | |
3601 v26 = v41; | |
3602 v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; | |
3603 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
3604 } | |
3605 else | |
3606 { | |
3607 v26 = v41; | |
3608 v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; | |
3609 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
3610 } | |
3611 if ( b + v25 >= (signed int)pViewport->uViewportX && v25 - b <= (signed int)pViewport->uViewportZ ) | |
3612 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3613 if (::uNumBillboardsToDraw >= 500) |
0 | 3614 return; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3615 v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; |
0 | 3616 ++uNumDecorationsDrawnThisFrame; |
3617 v27->uHwSpriteID = *v37; | |
3618 v28 = v9->uPaletteIndex; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3619 v27->_screenspace_x_scaler_packedfloat = v26; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3620 v27->_screenspace_y_scaler_packedfloat = v26; |
0 | 3621 v29 = v38; |
3622 v27->uScreenSpaceX = v25; | |
3623 HIBYTE(v29) |= 2u; | |
3624 v27->uPalette = v28; | |
3625 v27->field_1E = v29; | |
3626 v27->some_x = x; | |
3627 v27->some_y = y; | |
3628 v27->some_z = v36; | |
3629 v27->uScreenSpaceY = v40; | |
3630 HIWORD(v30) = HIWORD(v39); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3631 v31 = 8 * i | OBJECT_Decoration; |
0 | 3632 LOWORD(v30) = 0; |
3633 v27->uIndoorSectorID = 0; | |
3634 v27->sZValue = v30 + v31; | |
3635 v27->uPaletteSubindex = 0; | |
3636 v27->pSpriteFrame = v9; | |
3637 v27->uTintColor = 0; | |
3638 } | |
3639 } | |
3640 goto LABEL_38; | |
3641 } | |
3642 } | |
3643 else | |
3644 { | |
3645 v42 = (x - pIndoorCamera->pos.x) << 16; | |
3646 v40 = (y - pIndoorCamera->pos.y) << 16; | |
3647 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3648 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3649 v20 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3650 v39 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3651 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3652 { | |
3653 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3654 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3655 v21 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
3656 v41 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
3657 v22 = (v36 - pIndoorCamera->pos.z) << 16; | |
3658 goto LABEL_30; | |
3659 } | |
3660 } | |
3661 } | |
3662 } | |
3663 else | |
3664 { | |
3665 memset(&local_0, 0, 0x68u); | |
3666 v3 = (double)*((signed int *)v0 - 1); | |
3667 local_0.bFree = 1036; | |
3668 local_0.uDiffuse = 0xFF3C1Eu; | |
3669 local_0.x = v3; | |
3670 local_0.y = (double)*(signed int *)v0; | |
3671 local_0.z = (double)*((signed int *)v0 + 1); | |
3672 local_0.flt_10 = 0.0; | |
3673 local_0.flt_14 = 0.0; | |
3674 local_0.flt_18 = 0.0; | |
3675 local_0.flt_28 = 1.0; | |
3676 local_0.timeToLive = (rand() & 0x80) + 128; | |
3677 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
3678 pGame->pParticleEngine->AddParticle(&local_0); | |
3679 } | |
3680 } | |
3681 LABEL_38: | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3682 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3683 //++v35; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3684 //v0 += 32; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3685 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3686 //while ( v35 < (signed int)uNumLevelDecorations ); |
0 | 3687 } |
3688 // 4E94D0: using guessed type char byte_4E94D0; | |
3689 // 5187EC: using guessed type int uNumDecorationsDrawnThisFrame; | |
3690 | |
3691 | |
3692 //----- (0049D717) -------------------------------------------------------- | |
3693 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
3694 { | |
3695 HRESULT v2; // esi@2 | |
3696 | |
3697 if ( Src->dwFlags & 0x400 | 0x2000 ) | |
3698 { | |
3699 v2 = 0; | |
3700 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
3701 goto LABEL_6; | |
3702 if ( !Dst->dwSize ) | |
3703 { | |
3704 v2 = 1; | |
3705 LABEL_6: | |
3706 memcpy(Dst, Src, 0x20u); | |
3707 return v2; | |
3708 } | |
3709 } | |
3710 return 1; | |
3711 } | |
3712 | |
3713 //----- (0049DC28) -------------------------------------------------------- | |
3714 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
3715 { | |
3716 RenderD3D__DevInfo *v2; // eax@1 | |
3717 | |
3718 v2 = new RenderD3D__DevInfo[4];// 4 items | |
3719 *pOutDevices = v2; | |
3720 memset(v2, 0, 0xA0u); | |
3721 DirectDrawEnumerateA((LPDDENUMCALLBACKA)RenderD3D__DeviceEnumerator, *pOutDevices); | |
3722 } | |
3723 | |
3724 | |
3725 //----- (0049DC58) -------------------------------------------------------- | |
3726 RenderD3D::RenderD3D() | |
3727 { | |
3728 RenderD3D *v1; // esi@1 | |
3729 | |
3730 v1 = this; | |
3731 this->pHost = 0; | |
3732 this->pDirect3D = 0; | |
3733 this->pUnk = 0; | |
3734 this->pBackBuffer = 0; | |
3735 this->pFrontBuffer = 0; | |
3736 this->pZBuffer = 0; | |
3737 this->pDevice = 0; | |
3738 this->pViewport = 0; | |
3739 this->field_40 = 1; | |
3740 this->field_44 = 10; | |
3741 GetAvailableDevices(&this->pAvailableDevices); | |
3742 } | |
3743 | |
3744 //----- (0049DC90) -------------------------------------------------------- | |
3745 void RenderD3D::Release() | |
3746 { | |
3747 RenderD3D *v1; // esi@1 | |
3748 IDirectDraw4 *v2; // eax@2 | |
3749 signed int v3; // edi@4 | |
3750 IDirect3DViewport3 *v4; // eax@22 | |
3751 IUnknown *v5; // eax@24 | |
3752 IDirectDrawSurface4 *v6; // eax@26 | |
3753 IDirect3DDevice3 *v7; // eax@28 | |
3754 IDirect3D3 *v8; // eax@30 | |
3755 IDirectDrawSurface4 *v9; // eax@32 | |
3756 IDirectDrawSurface4 *v10; // eax@34 | |
3757 IDirectDraw4 *v11; // eax@36 | |
3758 | |
3759 v1 = this; | |
3760 if ( !this->bWindowed ) | |
3761 { | |
3762 v2 = this->pHost; | |
3763 if ( v2 ) | |
3764 { | |
3765 v2->RestoreDisplayMode(); | |
3766 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
3767 v1->pHost->FlipToGDISurface(); | |
3768 } | |
3769 } | |
3770 v3 = 0; | |
3771 do | |
3772 { | |
3773 if ( v1->pAvailableDevices[v3].pDriverName ) | |
3774 { | |
3775 free(v1->pAvailableDevices[v3].pDriverName); | |
3776 v1->pAvailableDevices[v3].pDriverName = 0; | |
3777 } | |
3778 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
3779 { | |
3780 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
3781 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
3782 } | |
3783 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
3784 { | |
3785 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
3786 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
3787 } | |
3788 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
3789 { | |
3790 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
3791 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
3792 } | |
3793 if ( v1->pAvailableDevices[v3].pName ) | |
3794 { | |
3795 free(v1->pAvailableDevices[v3].pName); | |
3796 v1->pAvailableDevices[v3].pName = 0; | |
3797 } | |
3798 if ( v1->pAvailableDevices[v3].pDescription ) | |
3799 { | |
3800 free(v1->pAvailableDevices[v3].pDescription); | |
3801 v1->pAvailableDevices[v3].pDescription = 0; | |
3802 } | |
3803 if ( v1->pAvailableDevices[v3].pGUID ) | |
3804 { | |
3805 free(v1->pAvailableDevices[v3].pGUID); | |
3806 v1->pAvailableDevices[v3].pGUID = 0; | |
3807 } | |
3808 ++v3; | |
3809 } | |
3810 while ( v3 < 4 ); | |
3811 if ( v1->pAvailableDevices ) | |
3812 { | |
3813 free(v1->pAvailableDevices); | |
3814 v1->pAvailableDevices = 0; | |
3815 } | |
3816 v4 = v1->pViewport; | |
3817 if ( v4 ) | |
3818 { | |
3819 v4->Release(); | |
3820 v1->pViewport = 0; | |
3821 } | |
3822 v5 = v1->pUnk; | |
3823 if ( v5 ) | |
3824 { | |
3825 v5->Release(); | |
3826 v1->pUnk = 0; | |
3827 } | |
3828 v6 = v1->pZBuffer; | |
3829 if ( v6 ) | |
3830 { | |
3831 v6->Release(); | |
3832 v1->pZBuffer = 0; | |
3833 } | |
3834 v7 = v1->pDevice; | |
3835 if ( v7 ) | |
3836 { | |
3837 v7->Release(); | |
3838 v1->pDevice = 0; | |
3839 } | |
3840 v8 = v1->pDirect3D; | |
3841 if ( v8 ) | |
3842 { | |
3843 v8->Release(); | |
3844 v1->pDirect3D = 0; | |
3845 } | |
3846 v9 = v1->pBackBuffer; | |
3847 if ( v9 ) | |
3848 { | |
3849 v9->Release(); | |
3850 v1->pBackBuffer = 0; | |
3851 } | |
3852 v10 = v1->pFrontBuffer; | |
3853 if ( v10 ) | |
3854 { | |
3855 v10->Release(); | |
3856 v1->pFrontBuffer = 0; | |
3857 } | |
3858 v11 = v1->pHost; | |
3859 if ( v11 ) | |
3860 { | |
3861 v11->Release(); | |
3862 v1->pHost = 0; | |
3863 } | |
3864 } | |
3865 | |
3866 | |
3867 //----- (0049DE14) -------------------------------------------------------- | |
3868 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, HWND hWnd) | |
3869 { | |
3870 //IDirectDraw4 *v8; // eax@12 | |
3871 //IDirectDraw4 *v9; // eax@16 | |
3872 //IDirectDraw4 *v10; // eax@20 | |
3873 //IDirectDraw4 *v13; // eax@35 | |
3874 const char *v23; // [sp-4h] [bp-DCh]@9 | |
3875 const char *v24; // [sp-4h] [bp-DCh]@13 | |
3876 const char *v25; // [sp-4h] [bp-DCh]@19 | |
3877 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
3878 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
3879 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
3880 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
3881 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
3882 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
3883 | |
3884 this->bWindowed = bWindowed; | |
3885 this->hWindow = hWnd; | |
3886 | |
3887 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
3888 { | |
3889 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
3890 return 0; | |
3891 } | |
3892 | |
3893 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
3894 { | |
3895 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
3896 if (lpDD) | |
3897 lpDD->Release(); | |
3898 return 0; | |
3899 } | |
3900 lpDD->Release(); | |
3901 lpDD = 0; | |
3902 | |
3903 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
3904 { | |
3905 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
3906 { | |
3907 v23 = "Init - Failed to set cooperative level.\n"; | |
3908 sprintf(pErrorMessage, v23); | |
3909 LABEL_65: | |
3910 if (pHost) | |
3911 { | |
3912 pHost->Release(); | |
3913 pHost = 0; | |
3914 } | |
3915 return 0; | |
3916 } | |
3917 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
3918 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
3919 ddsd2.dwFlags = DDSD_CAPS; | |
3920 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
3921 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
3922 { | |
3923 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
3924 pHost->GetDisplayMode(&ddsd2); | |
3925 if ( ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) | |
3926 { | |
3927 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
3928 goto LABEL_14; | |
3929 } | |
3930 | |
3931 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
3932 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
3933 ddsd2.dwWidth = 640; | |
3934 ddsd2.dwHeight = 480; | |
3935 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) | |
3936 { | |
3937 v24 = "Init - Failed to create back buffer.\n"; | |
3938 LABEL_14: | |
3939 sprintf(pErrorMessage, v24); | |
3940 if (pFrontBuffer) | |
3941 { | |
3942 pFrontBuffer->Release(); | |
3943 pFrontBuffer = 0; | |
3944 } | |
3945 goto LABEL_65; | |
3946 } | |
3947 if ( pHost->CreateClipper(0, &v30, 0) ) | |
3948 { | |
3949 v25 = "Init - Failed to create clipper.\n"; | |
3950 goto LABEL_45; | |
3951 } | |
3952 v30->SetHWnd(0, hWnd); | |
3953 pFrontBuffer->SetClipper(v30); | |
3954 | |
3955 v30->Release(); | |
3956 v30 = 0; | |
3957 | |
3958 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
3959 | |
3960 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
3961 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
3962 ddsd2.dwWidth = 640; | |
3963 ddsd2.dwHeight = 480; | |
3964 | |
3965 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
3966 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
3967 &ddsd2.ddpfPixelFormat) ) | |
3968 goto LABEL_21; | |
3969 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
3970 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
3971 | |
3972 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
3973 { | |
3974 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
3975 { | |
3976 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
3977 pBackBuffer, | |
3978 &pDevice, | |
3979 0) ) | |
3980 { | |
3981 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
3982 d3dvp2.dvClipWidth = 2.0; | |
3983 d3dvp2.dvClipY = 1.0; | |
3984 d3dvp2.dvClipHeight = 2.0; | |
3985 d3dvp2.dvMaxZ = 1.0; | |
3986 d3dvp2.dvMinZ = 0.0; | |
3987 goto LABEL_54; | |
3988 } | |
3989 LABEL_51: | |
3990 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
3991 if (pDirect3D) | |
3992 { | |
3993 pDirect3D->Release(); | |
3994 pDirect3D = 0; | |
3995 } | |
3996 goto LABEL_59; | |
3997 } | |
3998 LABEL_48: | |
3999 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
4000 if (pZBuffer) | |
4001 { | |
4002 pZBuffer->Release(); | |
4003 pZBuffer = 0; | |
4004 } | |
4005 goto LABEL_61; | |
4006 } | |
4007 goto LABEL_44; | |
4008 } | |
4009 LABEL_36: | |
4010 v23 = "Init - Failed to create front buffer.\n"; | |
4011 sprintf(pErrorMessage, v23); | |
4012 goto LABEL_65; | |
4013 } | |
4014 if ( uDeviceID == 1 ) | |
4015 v26 = 1045; | |
4016 else | |
4017 v26 = 1041; | |
4018 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
4019 { | |
4020 v23 = "Init - Failed to set cooperative level.\n"; | |
4021 sprintf(pErrorMessage, v23); | |
4022 goto LABEL_65; | |
4023 } | |
4024 if (pHost->SetDisplayMode(640u, 480u, 16u, 0, 0) ) | |
4025 { | |
4026 v23 = "Init - Failed to set display mode.\n"; | |
4027 sprintf(pErrorMessage, v23); | |
4028 goto LABEL_65; | |
4029 } | |
4030 | |
4031 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
4032 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
4033 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4034 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
4035 ddsd2.dwBackBufferCount = 1; | |
4036 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
4037 goto LABEL_36; | |
4038 //a3a = &pBackBuffer; | |
4039 //v14 = *v34; | |
4040 memset(&v27, 0, sizeof(DDSCAPS2)); | |
4041 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
4042 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
4043 //hWnda = &pDirect3D; | |
4044 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
4045 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
4046 { | |
4047 v25 = "Init - Failed to get D3D interface.\n"; | |
4048 goto LABEL_45; | |
4049 } | |
4050 | |
4051 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4052 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
4053 ddsd2.dwWidth = 640; | |
4054 ddsd2.dwHeight = 480; | |
4055 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
4056 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
4057 &ddsd2.ddpfPixelFormat) ) | |
4058 { | |
4059 LABEL_21: | |
4060 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
4061 goto LABEL_45; | |
4062 } | |
4063 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
4064 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
4065 //uDeviceIDa = &pZBuffer; | |
4066 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
4067 { | |
4068 LABEL_44: | |
4069 v25 = "Init - Failed to create z-buffer.\n"; | |
4070 LABEL_45: | |
4071 sprintf(pErrorMessage, v25); | |
4072 if (pBackBuffer) | |
4073 { | |
4074 pBackBuffer->Release(); | |
4075 pBackBuffer = 0; | |
4076 } | |
4077 LABEL_63: | |
4078 //v19 = &pFrontBuffer; | |
4079 if (pFrontBuffer) | |
4080 { | |
4081 pFrontBuffer->Release(); | |
4082 pFrontBuffer= 0; | |
4083 } | |
4084 goto LABEL_65; | |
4085 } | |
4086 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
4087 goto LABEL_48; | |
4088 //v33 = &pDevice; | |
4089 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
4090 pBackBuffer, | |
4091 &pDevice, | |
4092 0) ) | |
4093 goto LABEL_51; | |
4094 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
4095 d3dvp2.dvClipWidth = 2.0; | |
4096 d3dvp2.dvClipY = 1.0; | |
4097 d3dvp2.dvClipHeight = 2.0; | |
4098 d3dvp2.dvMaxZ = 1.0; | |
4099 | |
4100 LABEL_54: | |
4101 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
4102 //v17 = *hWnda; | |
4103 d3dvp2.dwWidth = 640; | |
4104 d3dvp2.dwHeight = 480; | |
4105 d3dvp2.dvClipX = -1.0; | |
4106 //v18 = v17->lpVtbl; | |
4107 //v32 = &v4->pViewport; | |
4108 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
4109 { | |
4110 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
4111 if (pDevice) | |
4112 { | |
4113 pDevice->Release(); | |
4114 pDevice = 0; | |
4115 } | |
4116 if (pDirect3D) | |
4117 { | |
4118 pDirect3D->Release(); | |
4119 pDirect3D = 0; | |
4120 } | |
4121 LABEL_59: | |
4122 if (pZBuffer) | |
4123 { | |
4124 pZBuffer->Release(); | |
4125 pZBuffer = 0; | |
4126 } | |
4127 LABEL_61: | |
4128 if (pBackBuffer) | |
4129 { | |
4130 pBackBuffer->Release(); | |
4131 pBackBuffer = 0; | |
4132 } | |
4133 goto LABEL_63; | |
4134 } | |
4135 | |
4136 pDevice->AddViewport(pViewport); | |
4137 pViewport->SetViewport2(&d3dvp2); | |
4138 pDevice->SetCurrentViewport(pViewport); | |
4139 return 1; | |
4140 } | |
4141 | |
4142 | |
4143 //----- (0049E444) -------------------------------------------------------- | |
4144 unsigned int RenderD3D::GetDeviceCaps() | |
4145 { | |
4146 unsigned int v1; // ebx@1 | |
4147 RenderD3D *v2; // edi@1 | |
4148 IDirect3DDevice3 *v3; // eax@1 | |
4149 unsigned int result; // eax@2 | |
4150 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
4151 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
4152 | |
4153 v1 = 0; | |
4154 v2 = this; | |
4155 memset(&halCaps, 0, 0xFCu); | |
4156 halCaps.dwSize = 252; | |
4157 memset(&refCaps, 0, 0xFCu); | |
4158 v3 = v2->pDevice; | |
4159 refCaps.dwSize = 252; | |
4160 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
4161 { | |
4162 result = 1; | |
4163 } | |
4164 else | |
4165 { | |
4166 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
4167 v1 = 2; | |
4168 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 2) ) | |
4169 v1 |= 4u; | |
4170 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 1) ) | |
4171 v1 |= 8u; | |
4172 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
4173 v1 |= 0x10u; | |
4174 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 2) ) | |
4175 v1 |= 0x20u; | |
4176 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 4) ) | |
4177 v1 |= 0x40u; | |
4178 if ( halCaps.dpcTriCaps.dwTextureCaps & 0x20 ) | |
4179 LOBYTE(v1) = v1 | 0x80; | |
4180 result = v1; | |
4181 } | |
4182 return result; | |
4183 } | |
4184 | |
4185 | |
4186 //----- (0049E4FC) -------------------------------------------------------- | |
4187 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
4188 { | |
4189 uint uClearFlags = 0; | |
4190 | |
4191 if (bClearColor) | |
4192 uClearFlags |= D3DCLEAR_TARGET; | |
4193 if (bClearDepth) | |
4194 uClearFlags |= D3DCLEAR_ZBUFFER; | |
4195 | |
4196 D3DRECT rects[] = {{0, 0, 640, 480}}; | |
4197 if (uClearFlags) | |
4198 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
4199 } | |
4200 | |
4201 | |
4202 //----- (0049E54D) -------------------------------------------------------- | |
4203 void RenderD3D::Present(bool bForceBlit) | |
4204 { | |
4205 RECT v5; // [sp+18h] [bp-18h]@1 | |
4206 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
4207 | |
4208 v5.left = 0; | |
4209 v5.top = 0; | |
4210 v5.bottom = 480; | |
4211 v5.right = 640; | |
4212 | |
4213 if (bWindowed || bForceBlit) | |
4214 { | |
4215 RECT rc; | |
4216 GetClientRect(hWindow, &rc); | |
4217 Point.y = 0; | |
4218 Point.x = 0; | |
4219 ClientToScreen(hWindow, &Point); | |
4220 OffsetRect(&rc, Point.x, Point.y); | |
4221 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
4222 } | |
4223 else | |
4224 pFrontBuffer->Flip(0, 1); | |
4225 } | |
4226 | |
4227 | |
4228 //----- (0049E5D4) -------------------------------------------------------- | |
4229 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
4230 { | |
4231 unsigned int v8; // edx@4 | |
4232 unsigned int v9; // ebx@5 | |
4233 unsigned int v10; // eax@5 | |
4234 DWORD v11; // edx@5 | |
4235 //int v12; // edx@7 | |
4236 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
4237 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
4238 | |
4239 //v15 = this; | |
4240 memset(&ddsd2, 0, 0x7Cu); | |
4241 ddsd2.dwSize = 0x7Cu; | |
4242 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4243 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
4244 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
4245 ddsd2.dwHeight = uTextureHeight; | |
4246 ddsd2.dwWidth = uTextureWidth; | |
4247 if ( bMipmaps ) | |
4248 { | |
4249 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
4250 { | |
4251 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
4252 LABEL_8: | |
4253 ddsd2.dwMipMapCount = v8; | |
4254 if ( !v8 ) | |
4255 goto LABEL_12; | |
4256 goto LABEL_11; | |
4257 } | |
4258 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
4259 { | |
4260 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
4261 goto LABEL_8; | |
4262 } | |
4263 v9 = GetMaxMipLevels(uTextureWidth); | |
4264 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
4265 ddsd2.dwMipMapCount = v9 - v10; | |
4266 if ( v9 == v10 ) | |
4267 { | |
4268 ddsd2.dwFlags = 0x1007u; | |
4269 ddsd2.ddsCaps.dwCaps = v11; | |
4270 goto LABEL_12; | |
4271 } | |
4272 } | |
4273 else | |
4274 { | |
4275 ddsd2.dwMipMapCount = 1; | |
4276 } | |
4277 LABEL_11: | |
4278 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
4279 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
4280 LABEL_12: | |
4281 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
4282 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
4283 if (bAlphaChannel) | |
4284 { | |
4285 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
4286 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
4287 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
4288 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
4289 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
4290 } | |
4291 else | |
4292 { | |
4293 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
4294 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
4295 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
4296 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
4297 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
4298 } | |
4299 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
4300 return false; | |
4301 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
4302 { | |
4303 (*pOutSurface)->Release(); | |
4304 *pOutSurface = 0; | |
4305 return false; | |
4306 } | |
4307 return true; | |
4308 } | |
4309 | |
4310 //----- (004A5190) -------------------------------------------------------- | |
4311 void RenderD3D::HandleLostResources() | |
4312 { | |
4313 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
4314 pBitmaps_LOD->_410423_move_textures_to_device(); | |
4315 pSprites_LOD->ReleaseLostHardwareSprites(); | |
4316 } | |
4317 | |
4318 | |
4319 | |
4320 //----- (004A2050) -------------------------------------------------------- | |
4321 void Render::DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) | |
4322 { | |
4323 Render *v5; // edi@1 | |
4324 unsigned int v6; // ebx@1 | |
4325 LightmapBuilder *v7; // esi@3 | |
4326 int v8; // eax@7 | |
4327 ODMFace *v9; // eax@12 | |
4328 char *v10; // esi@12 | |
4329 double v11; // st7@14 | |
4330 double v12; // st7@14 | |
4331 int v13; // eax@14 | |
4332 ODMFace *v14; // ecx@14 | |
4333 double v15; // st7@14 | |
4334 float v16; // ST48_4@15 | |
4335 int v17; // eax@15 | |
4336 char v18; // zf@17 | |
4337 HRESULT v19; // eax@18 | |
4338 HRESULT v20; // eax@18 | |
4339 HRESULT v21; // eax@20 | |
4340 HRESULT v22; // eax@20 | |
4341 unsigned int v23; // ecx@20 | |
4342 char *v24; // eax@21 | |
4343 HRESULT v25; // eax@23 | |
4344 HRESULT v26; // eax@23 | |
4345 HRESULT v27; // eax@24 | |
4346 HRESULT v28; // eax@25 | |
4347 HRESULT v29; // eax@25 | |
4348 HRESULT v30; // eax@25 | |
4349 HRESULT v31; // eax@25 | |
4350 HRESULT v32; // eax@26 | |
4351 unsigned int v33; // ecx@26 | |
4352 char *v34; // eax@27 | |
4353 int v35; // edx@28 | |
4354 HRESULT v36; // eax@29 | |
4355 HRESULT v37; // eax@29 | |
4356 HRESULT v38; // eax@29 | |
4357 HRESULT v39; // eax@29 | |
4358 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
4359 unsigned int v41; // eax@29 | |
4360 HRESULT v42; // eax@30 | |
4361 HRESULT v43; // eax@30 | |
4362 HRESULT v44; // eax@30 | |
4363 char *v45; // esi@34 | |
4364 int v46; // ecx@35 | |
4365 double v47; // st6@35 | |
4366 int v48; // eax@36 | |
4367 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
4368 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
4369 int v51; // [sp+50h] [bp-18h]@0 | |
4370 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
4371 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
4372 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
4373 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
4374 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
4375 int v57; // [sp+60h] [bp-8h]@34 | |
4376 HRESULT a2; // [sp+64h] [bp-4h]@4 | |
4377 | |
4378 v5 = this; | |
4379 v6 = 0; | |
4380 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
4381 { | |
4382 v7 = pGame->pLightmapBuilder; | |
4383 v53 = v7; | |
4384 v54 = v7->std__vector_000004_size; | |
4385 if ( v7->std__vector_000004_size) | |
4386 a2 = -1; | |
4387 pGame->_44EE30(a4, (int)&a2); | |
4388 if ( byte_4D864C && pGame->uFlags & 1 ) | |
4389 { | |
4390 v8 = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
4391 v7->_45D74F_MessWithLight(v8, 0); | |
4392 } | |
4393 else | |
4394 { | |
4395 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
4396 { | |
62 | 4397 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u));// |
0 | 4398 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
4399 if (bUsingSpecular) | |
4400 { | |
4401 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, true)); | |
4402 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2)); | |
4403 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1)); | |
4404 } | |
4405 if ( (signed int)uNumVertices > 0 ) | |
4406 { | |
4407 v45 = (char *)&array_50AC10[0].vWorldViewPosition; | |
4408 v57 = (int)&arary_77E5C8[0].pos.y; | |
4409 v55 = uNumVertices; | |
4410 do | |
4411 { | |
4412 a2 = GetActorTintColor(a3->field_58, 0, *(float *)v45, 0, 0); | |
4413 pGame->_44EE30(a4, (int)&a2); | |
4414 v46 = v57; | |
4415 v47 = *(float *)v45 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
4416 *(int *)(v57 - 4) = *((int *)v45 + 3); | |
4417 *(int *)v57 = *((int *)v45 + 4); | |
4418 *(int *)(v57 + 12) = a2; | |
4419 *(float *)(v57 + 4) = 1.0 - 1.0 / v47; | |
4420 *(float *)(v57 + 8) = 1.0 / (*(float *)v45 + 0.0000001); | |
4421 if ( v5->bUsingSpecular ) | |
4422 { | |
4423 v48 = sub_47C3D7_get_fog_related_stuff(0, 0, *(float *)v45); | |
4424 v46 = v57; | |
4425 } | |
4426 else | |
4427 { | |
4428 v48 = 0; | |
4429 } | |
4430 *(int *)(v46 + 16) = v48; | |
4431 *(int *)(v46 + 20) = *((int *)v45 + 6); | |
4432 *(int *)(v46 + 24) = *((int *)v45 + 7); | |
4433 v45 += 48; | |
4434 v18 = v55-- == 1; | |
4435 v57 = v46 + 32; | |
4436 } | |
4437 while ( !v18 ); | |
4438 } | |
4439 pRenderD3D->pDevice->SetTexture(0, pTexture); | |
4440 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4441 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
4442 arary_77E5C8, | |
4443 uNumVertices, | |
4444 D3DDP_DONOTLIGHT); | |
4445 } | |
4446 else | |
4447 { | |
4448 if ( (signed int)uNumVertices > 0 ) | |
4449 { | |
4450 v9 = (ODMFace *)&arary_77E5C8[0].pos.y; | |
4451 v10 = (char *)&array_50AC10[0].vWorldViewPosition; | |
4452 a4 = (ODMFace *)&arary_77E5C8[0].pos.y; | |
4453 v56 = uNumVertices; | |
4454 while ( 1 ) | |
4455 { | |
4456 v11 = *(float *)v10 * 1000.0; | |
4457 *((int *)v9 - 1) = *((int *)v10 + 3); | |
4458 v12 = v11 / (double)pOutdoorCamera->shading_dist_mist; | |
4459 v9->pFacePlane.vNormal.x = *((int *)v10 + 4); | |
4460 *(float *)&v9->pFacePlane.vNormal.y = 1.0 - 1.0 / v12; | |
4461 *(float *)&v9->pFacePlane.vNormal.z = 1.0 / (*(float *)v10 + 0.0000001); | |
4462 v13 = GetActorTintColor(a3->field_58, 0, *(float *)v10, 0, 0); | |
4463 v14 = a4; | |
4464 v15 = *(float *)v10; | |
4465 a4->pFacePlane.dist = v13; | |
4466 if ( v5->bUsingSpecular ) | |
4467 { | |
4468 v16 = v15; | |
4469 v17 = sub_47C3D7_get_fog_related_stuff(0, 0, v16); | |
4470 v14 = a4; | |
4471 } | |
4472 else | |
4473 { | |
4474 v17 = 0; | |
4475 } | |
4476 v14->zCalc1 = v17; | |
4477 v14->zCalc2 = *((int *)v10 + 6); | |
4478 v14->zCalc3 = *((int *)v10 + 7); | |
4479 v10 += 48; | |
4480 v18 = v56-- == 1; | |
4481 a4 = (ODMFace *)((char *)v14 + 32); | |
4482 if ( v18 ) | |
4483 break; | |
4484 v9 = a4; | |
4485 } | |
4486 } | |
4487 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
4488 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u)); | |
4489 if (bUsingSpecular) | |
4490 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0)); | |
4491 | |
4492 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
4493 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4494 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
4495 arary_77E5C8, | |
4496 uNumVertices, | |
4497 D3DDP_DONOTLIGHT)); | |
4498 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
4499 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
4500 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
4501 v53->_45D74F_MessWithLight(-1, 0); | |
4502 v23 = uNumVertices; | |
4503 if ( (signed int)uNumVertices > 0 ) | |
4504 { | |
4505 v24 = (char *)&arary_77E5C8[0].diffuse; | |
4506 do | |
4507 { | |
4508 *(int *)v24 = a2; | |
4509 v24 += 32; | |
4510 --v23; | |
4511 } | |
4512 while ( v23 ); | |
4513 } | |
4514 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); | |
4515 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u)); | |
4516 if ( !pRenderer->bUsingSpecular ) | |
4517 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
4518 | |
4519 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, true)); | |
4520 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 1)); | |
4521 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3)); | |
4522 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4523 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
4524 arary_77E5C8, | |
4525 uNumVertices, | |
4526 D3DDP_DONOTLIGHT)); | |
4527 if (bUsingSpecular) | |
4528 { | |
4529 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
4530 | |
4531 v33 = uNumVertices; | |
4532 if ( (signed int)uNumVertices > 0 ) | |
4533 { | |
4534 v34 = (char *)&arary_77E5C8[0].specular; | |
4535 do | |
4536 { | |
4537 v35 = *(int *)v34; | |
4538 *(int *)v34 = 0; | |
4539 v34 += 32; | |
4540 --v33; | |
4541 *((int *)v34 - 9) = pRenderer->uFogColor | v35 & 0xFF000000; | |
4542 } | |
4543 while ( v33 ); | |
4544 } | |
4545 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
4546 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 6)); | |
4547 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 5)); | |
4548 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4549 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
4550 arary_77E5C8, | |
4551 uNumVertices, | |
4552 D3DDP_DONOTLIGHT)); | |
4553 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, true)); | |
4554 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; | |
4555 v41 = GetLevelFogColor(); | |
4556 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
4557 v6 = 0; | |
4558 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4559 } | |
4560 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2)); | |
4561 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1)); | |
4562 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); | |
4563 } | |
4564 } | |
4565 } | |
4566 } | |
4567 // 4D864C: using guessed type char byte_4D864C; | |
4568 | |
4569 | |
4570 //----- (0049EB79) -------------------------------------------------------- | |
4571 Render::~Render() | |
4572 { | |
4573 Render *v1; // esi@1 | |
4574 | |
4575 v1 = this; | |
4576 pAllocator->FreeChunk(this->pDefaultZBuffer); | |
4577 v1->pD3DBitmaps.Release(); | |
4578 v1->pD3DSprites.Release(); | |
4579 Release(); | |
4580 v1->bWindowMode = 1; | |
4581 //nullsub_1(); | |
4582 //nullsub_1(); | |
4583 } | |
4584 | |
4585 | |
4586 | |
4587 //----- (0049E756) -------------------------------------------------------- | |
4588 bool Render::IsColorKeySupported(IDirectDraw4 *this_) | |
4589 { | |
4590 DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1 | |
4591 DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1 | |
4592 | |
4593 halCaps.dwSize = 380; | |
4594 refCaps.dwSize = 380; | |
4595 this_->GetCaps(&halCaps, &refCaps); | |
4596 return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2; | |
4597 } | |
4598 | |
4599 //----- (0049E992) -------------------------------------------------------- | |
4600 Render::Render() | |
4601 { | |
4602 Render *v1; // esi@1 | |
4603 int v2; // eax@1 | |
4604 char v3; // zf@1 | |
4605 | |
4606 v1 = this; | |
4607 this->pDirectDraw4 = 0; | |
4608 this->pFrontBuffer4 = 0; | |
4609 this->pBackBuffer4 = 0; | |
4610 this->pColorKeySurface4 = 0; | |
4611 this->pDirectDraw2 = 0; | |
4612 this->pFrontBuffer2 = 0; | |
4613 this->pBackBuffer2 = 0; | |
4614 this->pSomeSurface2 = 0; | |
4615 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); | |
4616 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
4617 v1->bWindowMode = 1; | |
4618 v1->field_40054 = 0; | |
4619 v1->field_10 = 640; | |
4620 v1->field_14 = 480; | |
4621 v1->field_40030 = 0; | |
4622 v1->field_4002C = 0; | |
4623 v1->pActiveZBuffer = 0; | |
4624 v1->pDefaultZBuffer = 0; | |
4625 v1->field_20_clipy = 0; | |
4626 v1->field_1C_clipx = 0; | |
4627 v1->field_24_clipz = 639; | |
4628 v1->field_28_clipw = 479; | |
4629 v1->field_4003C = (int)&unk_4EED80; | |
4630 v1->field_40040 = dword_4EED78; | |
4631 v1->uClipZ = 640; | |
4632 v1->field_40044 = 2; | |
4633 v1->field_40048 = 6; | |
4634 v1->pFrontBuffer4 = 0; | |
4635 v1->pBackBuffer4 = 0; | |
4636 v1->pColorKeySurface4 = 0; | |
4637 v1->pDirectDraw4 = 0; | |
4638 v1->pRenderD3D = 0; | |
4639 v1->uNumSceneBegins = 0; | |
4640 v1->uNumD3DSceneBegins = 0; | |
4641 v1->field_40110 = 0; | |
4642 v1->pTargetSurface = 0; | |
4643 v1->uTargetSurfacePitch = 0; | |
4644 v1->uClipY = 0; | |
4645 v1->uClipX = 0; | |
4646 v1->uClipW = 480; | |
4647 v1->bClip = 1; | |
4648 v1->bColorKeySupported = 0; | |
4649 v1->bRequiredTextureStagesAvailable = 0; | |
4650 v1->bTinting = 1; | |
4651 LOBYTE(v1->field_103668) = 0; | |
4652 v1->field_1036B8 = 0; | |
4653 v1->_gpu_memory_used = 0; | |
4654 uNumBillboardsToDraw = 0; | |
4655 bFogEnabled = false; | |
4656 } | |
4657 | |
4658 bool Render::Initialize(bool bWindowed, uint uDefaultDevice, | |
4659 bool bColoredLights, uint uDetailLevel, uint bTinting) | |
4660 { | |
4661 bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | |
4662 bStartInWindow = bWindowed; | |
4663 | |
4664 uDesiredDirect3DDevice = uDefaultDevice;//ReadWindowsRegistryInt("D3D Device", 1); | |
4665 | |
4666 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
4667 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
4668 | |
4669 this->bTinting = bTinting; | |
4670 | |
4671 auto r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); | |
4672 auto r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
4673 | |
4674 return r1 && r2; | |
4675 } | |
4676 | |
4677 | |
4678 | |
4679 //----- (0049EBF1) -------------------------------------------------------- | |
4680 void Render::_49EBF1() | |
4681 { | |
4682 signed int uNumRedBits; // edx@1 | |
4683 signed int uNuGreenBits; // edi@1 | |
4684 signed int uNumBlueBits; // esi@1 | |
4685 unsigned int v4; // edx@4 | |
4686 unsigned int v5; // edi@4 | |
4687 int v6; // ebx@4 | |
4688 int v7; // edx@4 | |
4689 signed int v8; // [sp+8h] [bp-24h]@1 | |
4690 signed int v9; // [sp+Ch] [bp-20h]@1 | |
4691 signed int v10; // [sp+20h] [bp-Ch]@1 | |
4692 signed int i; // [sp+24h] [bp-8h]@2 | |
4693 signed int v12; // [sp+28h] [bp-4h]@3 | |
4694 | |
4695 v10 = 0; | |
4696 uNumRedBits = 1 << this->uTargetRBits; | |
4697 uNuGreenBits = 1 << this->uTargetGBits; | |
4698 uNumBlueBits = 1 << this->uTargetBBits; | |
4699 v9 = 1 << this->uTargetRBits; | |
4700 v8 = 1 << this->uTargetGBits; | |
4701 if ( uNumRedBits > 0 ) | |
4702 { | |
4703 do | |
4704 { | |
4705 for ( i = 0; i < uNuGreenBits; ++i ) | |
4706 { | |
4707 v12 = 0; | |
4708 if ( uNumBlueBits > 0 ) | |
4709 { | |
4710 do | |
4711 { | |
4712 v4 = this->uTargetBBits; | |
4713 v5 = v4 + this->uTargetGBits; | |
4714 v6 = (v12 >> 1) + (v10 >> 1 << v5) + (i >> 1 << this->uTargetBBits); | |
4715 v7 = (v10 << v5) + v12++ + (i << v4); | |
4716 this->field_2C[v7] = v6; | |
4717 } | |
4718 while ( v12 < uNumBlueBits ); | |
4719 uNumRedBits = v9; | |
4720 uNuGreenBits = v8; | |
4721 } | |
4722 } | |
4723 ++v10; | |
4724 } | |
4725 while ( v10 < uNumRedBits ); | |
4726 } | |
4727 } | |
4728 | |
4729 | |
4730 //----- (0049ECC4) -------------------------------------------------------- | |
4731 void Render::ClearBlack() | |
4732 { | |
4733 if (pRenderD3D) | |
4734 { | |
4735 if (field_40110) | |
4736 pRenderD3D->ClearTarget(true, 0, false, 0.0); | |
4737 } | |
4738 else | |
4739 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
4740 } | |
4741 | |
4742 | |
4743 //----- (0049ED18) -------------------------------------------------------- | |
4744 void Render::PresentBlackScreen() | |
4745 { | |
4746 LONG w; // edx@3 | |
4747 IDirectDrawSurface *v2; // eax@3 | |
4748 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
4749 RECT x; // [sp+68h] [bp-10h]@3 | |
4750 | |
4751 memset(&v3, 0, sizeof(DDBLTFX)); | |
4752 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
4753 pVersion->pVersionInfo.dwMajorVersion >= 5) | |
4754 { | |
4755 x.left = uWindowX; | |
4756 x.right = uWindowX + uWindowHeight; | |
4757 x.top = uWindowY; | |
4758 w = uWindowY + uWindowWidth; | |
4759 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
4760 } | |
4761 else | |
4762 { | |
4763 x.left = uWindowX; | |
4764 x.right = uWindowX + uWindowHeight; | |
4765 x.top = uWindowY; | |
4766 w = uWindowY + uWindowWidth; | |
4767 v2 = (IDirectDrawSurface *)this->pBackBuffer2; | |
4768 } | |
4769 x.bottom = w; | |
4770 v3.dwFillColor = 0; | |
4771 v3.dwSize = 100; | |
4772 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
4773 pRenderer->Present(); | |
4774 } | |
4775 | |
4776 | |
4777 //----- (0049EDB6) -------------------------------------------------------- | |
4778 void Render::SavePCXScreenshot() | |
4779 { | |
4780 Render *v1; // esi@1 | |
4781 __int16 v2; // di@1 | |
4782 int v3; // eax@4 | |
4783 int v4; // ecx@4 | |
4784 int v5; // eax@8 | |
4785 FILE *v6; // edi@10 | |
4786 int v7; // ecx@11 | |
4787 int v8; // eax@11 | |
4788 int v9; // eax@13 | |
4789 int v10; // ecx@15 | |
4790 unsigned __int8 v11; // dl@15 | |
4791 signed int v12; // eax@18 | |
4792 char v13; // zf@27 | |
4793 HRESULT v14; // eax@29 | |
4794 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
4795 __int16 v16; // [sp+44h] [bp-120h]@10 | |
4796 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
4797 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
4798 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
4799 char *v20; // [sp+11Ch] [bp-48h]@14 | |
4800 char *v21; // [sp+120h] [bp-44h]@14 | |
4801 int v24; // [sp+124h] [bp-40h]@11 | |
4802 FILE *File; // [sp+128h] [bp-3Ch]@3 | |
4803 int var38; // [sp+12Ch] [bp-38h]@4 | |
4804 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
4805 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
4806 void *ptr; // [sp+148h] [bp-1Ch]@10 | |
4807 void *v28; // [sp+14Ch] [bp-18h]@8 | |
4808 int v29; // [sp+150h] [bp-14h]@4 | |
4809 int v30; // [sp+154h] [bp-10h]@4 | |
4810 char v31; // [sp+15Ah] [bp-Ah]@25 | |
4811 unsigned __int8 v32; // [sp+15Bh] [bp-9h]@17 | |
4812 int i; // [sp+15Ch] [bp-8h]@10 | |
4813 unsigned __int8 v34; // [sp+163h] [bp-1h]@17 | |
4814 | |
4815 v1 = this; | |
4816 v2 = 0; | |
4817 if ( !this->pRenderD3D || this->field_40110 ) | |
4818 { | |
4819 sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100); | |
4820 File = fopen(Filename, "wb"); | |
4821 if ( File ) | |
4822 { | |
4823 v3 = v1->field_10; | |
4824 v4 = v1->field_14; | |
4825 var38 = v3; | |
4826 v29 = v4; | |
4827 v30 = v3; | |
4828 if ( v3 & 1 ) | |
4829 v30 = v3 + 1; | |
4830 if ( v1->pRenderD3D ) | |
4831 { | |
4832 memset(&Dst, 0, 0x7Cu); | |
4833 Dst.dwSize = 124; | |
4834 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, 1u) ) | |
4835 return; | |
4836 v28 = Dst.lpSurface; | |
4837 v5 = Dst.lPitch >> 1; | |
4838 v2 = 0; | |
4839 } | |
4840 else | |
4841 { | |
4842 pRenderer->BeginScene(); | |
4843 v28 = pRenderer->pTargetSurface; | |
4844 v5 = pRenderer->uTargetSurfacePitch; | |
4845 } | |
4846 i = v5; | |
4847 header1.right = var38 - 1; | |
4848 header1.left = v2; | |
4849 header1.bottom = v29 - 1; | |
4850 header1.up = v2; | |
4851 header2.pitch = v30; | |
4852 memset(color_map, 0, sizeof(color_map)); | |
4853 memset(v15, 0, sizeof(v15)); | |
4854 header2.reserved = 0; | |
4855 header1.manufacturer = 10; | |
4856 v16 = 0; | |
4857 v6 = File; | |
4858 header1.version = 5; | |
4859 header1.encoding = 1; | |
4860 header1.bpp = 8; | |
4861 header1.hdpi = 75; | |
4862 header1.vdpi = 75; | |
4863 header2.planes = 3; | |
4864 header2.palette_info = 1; | |
4865 fwrite(&header1, 1u, 1u, File); | |
4866 fwrite(&header1.version, 1u, 1u, v6); | |
4867 fwrite(&header1.encoding, 1u, 1u, v6); | |
4868 fwrite(&header1.bpp, 1u, 1u, v6); | |
4869 fwrite(&header1.left, 2u, 1u, v6); | |
4870 fwrite(&header1.up, 2u, 1u, v6); | |
4871 fwrite(&header1.right, 2u, 1u, v6); | |
4872 fwrite(&header1.bottom, 2u, 1u, v6); | |
4873 fwrite(&header1.hdpi, 2u, 1u, v6); | |
4874 fwrite(&header1.vdpi, 2u, 1u, v6); | |
4875 fwrite(color_map, 0x30u, 1u, v6); | |
4876 fwrite(&header2, 1u, 1u, v6); | |
4877 fwrite(&header2.planes, 1u, 1u, v6); | |
4878 fwrite(&header2.pitch, 2u, 1u, v6); | |
4879 fwrite(&header2.palette_info, 2u, 1u, v6); | |
4880 fwrite(v15, 0x3Au, 1u, v6); | |
4881 ptr = pAllocator->AllocNamedChunk(0, 3 * var38 + 6, 0); | |
4882 if ( v29 > 0 ) | |
4883 { | |
4884 v7 = v30; | |
4885 File = (FILE *)v29; | |
4886 v29 = 3 * v30; | |
4887 v24 = 2 * i; | |
4888 v8 = (int)v28; | |
4889 while ( 1 ) | |
4890 { | |
4891 i = v8; | |
4892 v9 = 0; | |
4893 if ( var38 > 0 ) | |
4894 { | |
4895 v21 = (char *)ptr + v7; | |
4896 v20 = (char *)ptr + 2 * v30; | |
4897 do | |
4898 { | |
4899 *((char *)ptr + v9) = (signed int)(v1->uTargetRMask & *(short *)i) >> (LOBYTE(v1->uTargetGBits) | |
4900 + LOBYTE(v1->uTargetBBits) | |
4901 + v1->uTargetRBits | |
4902 - 8); | |
4903 v21[v9] = (signed int)(v1->uTargetGMask & *(short *)i) >> (LOBYTE(v1->uTargetBBits) | |
4904 + LOBYTE(v1->uTargetGBits) | |
4905 - 8); | |
4906 v10 = i; | |
4907 v11 = LOBYTE(v1->uTargetBMask); | |
4908 i += 2; | |
4909 v20[v9++] = (*(char *)v10 & v11) << (8 - LOBYTE(v1->uTargetBBits)); | |
4910 } | |
4911 while ( v9 < var38 ); | |
4912 } | |
4913 for ( i = 0; i < v29; i += v34 ) | |
4914 { | |
4915 v34 = 1; | |
4916 v32 = *((char *)ptr + i); | |
4917 do | |
4918 { | |
4919 v12 = i + v34; | |
4920 if ( *((char *)ptr + v12) != v32 ) | |
4921 break; | |
4922 if ( !(v12 % v30) ) | |
4923 break; | |
4924 ++v34; | |
4925 } | |
4926 while ( v34 < 0x3Fu ); | |
4927 if ( i + v34 > v29 ) | |
4928 v34 = 3 * v30 - i; | |
4929 if ( v34 > 1u || v32 >= 0xC0u ) | |
4930 { | |
4931 v31 = v34 | 0xC0; | |
4932 fwrite(&v31, 1u, 1u, v6); | |
4933 } | |
4934 fwrite(&v32, 1u, 1u, v6); | |
4935 } | |
4936 v8 = (int)((char *)v28 + v24); | |
4937 v13 = File == (FILE *)1; | |
4938 File = (FILE *)((char *)File - 1); | |
4939 v28 = (char *)v28 + v24; | |
4940 if ( v13 ) | |
4941 break; | |
4942 v7 = v30; | |
4943 } | |
4944 } | |
4945 if ( v1->pRenderD3D ) | |
4946 { | |
4947 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
4948 } | |
4949 else | |
4950 { | |
4951 pRenderer->EndScene(); | |
4952 } | |
4953 | |
4954 pAllocator->FreeChunk(ptr); | |
4955 fclose(v6); | |
4956 } | |
4957 } | |
4958 } | |
4959 // 4EFA80: using guessed type int dword_4EFA80; | |
4960 | |
4961 | |
4962 //----- (0049F1BC) -------------------------------------------------------- | |
4963 void Render::_49F1BC(const char *a1) | |
4964 { | |
4965 Render *v2; // esi@1 | |
4966 __int16 v3; // di@1 | |
4967 int v4; // eax@4 | |
4968 char *v5; // ecx@4 | |
4969 unsigned int v6; // eax@8 | |
4970 FILE *v7; // edi@10 | |
4971 int v8; // ecx@11 | |
4972 int v9; // eax@11 | |
4973 int v10; // eax@13 | |
4974 const char *v11; // ecx@15 | |
4975 unsigned __int8 v12; // dl@15 | |
4976 signed int v13; // eax@18 | |
4977 char v14; // zf@27 | |
4978 HRESULT v15; // eax@29 | |
4979 char v16; // [sp+Ch] [bp-12Ch]@10 | |
4980 __int16 v17; // [sp+44h] [bp-F4h]@10 | |
4981 int Dst; // [sp+48h] [bp-F0h]@7 | |
4982 int v19; // [sp+58h] [bp-E0h]@8 | |
4983 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
4984 char v21; // [sp+C4h] [bp-74h]@10 | |
4985 unsigned int v22; // [sp+F4h] [bp-44h]@11 | |
4986 char *v23; // [sp+F8h] [bp-40h]@14 | |
4987 int v24; // [sp+FCh] [bp-3Ch]@11 | |
4988 int v25; // [sp+100h] [bp-38h]@4 | |
4989 FILE *File; // [sp+104h] [bp-34h]@3 | |
4990 char Str; // [sp+108h] [bp-30h]@10 | |
4991 char v28; // [sp+109h] [bp-2Fh]@10 | |
4992 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
4993 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
4994 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
4995 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
4996 __int16 v33; // [sp+110h] [bp-28h]@10 | |
4997 __int16 v34; // [sp+112h] [bp-26h]@10 | |
4998 __int16 v35; // [sp+114h] [bp-24h]@10 | |
4999 __int16 v36; // [sp+116h] [bp-22h]@10 | |
5000 char v37; // [sp+118h] [bp-20h]@10 | |
5001 char v38; // [sp+119h] [bp-1Fh]@10 | |
5002 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
5003 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
5004 void *ptr; // [sp+120h] [bp-18h]@10 | |
5005 unsigned __int16 *v42; // [sp+124h] [bp-14h]@8 | |
5006 int v43; // [sp+128h] [bp-10h]@4 | |
5007 char v44; // [sp+12Fh] [bp-9h]@25 | |
5008 char *i; // [sp+130h] [bp-8h]@10 | |
5009 unsigned __int8 v46; // [sp+137h] [bp-1h]@17 | |
5010 | |
5011 v2 = this; | |
5012 v3 = 0; | |
5013 if ( !this->pRenderD3D || this->field_40110 ) | |
5014 { | |
5015 ++dword_4EFA84; | |
5016 File = fopen(a1, "wb"); | |
5017 if ( File ) | |
5018 { | |
5019 v4 = v2->field_10; | |
5020 v5 = (char *)v2->field_14; | |
5021 v25 = v4; | |
5022 a1 = v5; | |
5023 v43 = v4; | |
5024 if ( v4 & 1 ) | |
5025 v43 = v4 + 1; | |
5026 if ( v2->pRenderD3D ) | |
5027 { | |
5028 memset(&Dst, 0, 0x7Cu); | |
5029 Dst = 124; | |
5030 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, 1u) ) | |
5031 return; | |
5032 v42 = v20; | |
5033 v6 = v19 >> 1; | |
5034 v3 = 0; | |
5035 } | |
5036 else | |
5037 { | |
5038 pRenderer->BeginScene(); | |
5039 v42 = pRenderer->pTargetSurface; | |
5040 v6 = pRenderer->uTargetSurfacePitch; | |
5041 } | |
5042 i = (char *)v6; | |
5043 v33 = v25 - 1; | |
5044 v31 = v3; | |
5045 v34 = (short)a1 - 1; | |
5046 v32 = v3; | |
5047 v39 = v43; | |
5048 memset(&v21, 0, 0x30u); | |
5049 memset(&v16, 0, 0x38u); | |
5050 v37 = 0; | |
5051 Str = 10; | |
5052 v17 = 0; | |
5053 v7 = File; | |
5054 v28 = 5; | |
5055 v29 = 1; | |
5056 v30 = 8; | |
5057 v35 = 75; | |
5058 v36 = 75; | |
5059 v38 = 3; | |
5060 v40 = 1; | |
5061 fwrite(&Str, 1u, 1u, File); | |
5062 fwrite(&v28, 1u, 1u, v7); | |
5063 fwrite(&v29, 1u, 1u, v7); | |
5064 fwrite(&v30, 1u, 1u, v7); | |
5065 fwrite(&v31, 2u, 1u, v7); | |
5066 fwrite(&v32, 2u, 1u, v7); | |
5067 fwrite(&v33, 2u, 1u, v7); | |
5068 fwrite(&v34, 2u, 1u, v7); | |
5069 fwrite(&v35, 2u, 1u, v7); | |
5070 fwrite(&v36, 2u, 1u, v7); | |
5071 fwrite(&v21, 0x30u, 1u, v7); | |
5072 fwrite(&v37, 1u, 1u, v7); | |
5073 fwrite(&v38, 1u, 1u, v7); | |
5074 fwrite(&v39, 2u, 1u, v7); | |
5075 fwrite(&v40, 2u, 1u, v7); | |
5076 fwrite(&v16, 0x3Au, 1u, v7); | |
5077 ptr = pAllocator->AllocNamedChunk(0, 3 * v25 + 6, 0); | |
5078 if ( (signed int)a1 > 0 ) | |
5079 { | |
5080 v8 = v43; | |
5081 File = (FILE *)a1; | |
5082 v24 = 3 * v43; | |
5083 v22 = 2 * (int)i; | |
5084 v9 = (int)v42; | |
5085 while ( 1 ) | |
5086 { | |
5087 a1 = (const char *)v9; | |
5088 v10 = 0; | |
5089 if ( v25 > 0 ) | |
5090 { | |
5091 i = (char *)ptr + v8; | |
5092 v23 = (char *)ptr + 2 * v43; | |
5093 do | |
5094 { | |
5095 *((char *)ptr + v10) = (signed int)(v2->uTargetRMask & *(short *)a1) >> (LOBYTE(v2->uTargetGBits) | |
5096 + LOBYTE(v2->uTargetBBits) | |
5097 + v2->uTargetRBits | |
5098 - 8); | |
5099 i[v10] = (signed int)(v2->uTargetGMask & *(short *)a1) >> (LOBYTE(v2->uTargetBBits) | |
5100 + LOBYTE(v2->uTargetGBits) | |
5101 - 8); | |
5102 v11 = a1; | |
5103 v12 = LOBYTE(v2->uTargetBMask); | |
5104 a1 += 2; | |
5105 v23[v10++] = ((unsigned __int8)*v11 & v12) << (8 - LOBYTE(v2->uTargetBBits)); | |
5106 } | |
5107 while ( v10 < v25 ); | |
5108 } | |
5109 for ( i = 0; (signed int)i < v24; i += BYTE3(a1) ) | |
5110 { | |
5111 BYTE3(a1) = 1; | |
5112 v46 = *((char *)ptr + (int)i); | |
5113 do | |
5114 { | |
5115 v13 = (signed int)&i[BYTE3(a1)]; | |
5116 if ( *((char *)ptr + v13) != v46 ) | |
5117 break; | |
5118 if ( !(v13 % v43) ) | |
5119 break; | |
5120 ++BYTE3(a1); | |
5121 } | |
5122 while ( BYTE3(a1) < 0x3Fu ); | |
5123 if ( (signed int)&i[BYTE3(a1)] > v24 ) | |
5124 BYTE3(a1) = 3 * v43 - (char)i; | |
5125 if ( BYTE3(a1) > 1u || v46 >= 0xC0u ) | |
5126 { | |
5127 v44 = BYTE3(a1) | 0xC0; | |
5128 fwrite(&v44, 1u, 1u, v7); | |
5129 } | |
5130 fwrite(&v46, 1u, 1u, v7); | |
5131 } | |
5132 v9 = (int)&v42[v22 / 2]; | |
5133 v14 = File == (FILE *)1; | |
5134 File = (FILE *)((char *)File - 1); | |
5135 v42 = (unsigned __int16 *)((char *)v42 + v22); | |
5136 if ( v14 ) | |
5137 break; | |
5138 v8 = v43; | |
5139 } | |
5140 } | |
5141 if ( v2->pRenderD3D ) | |
5142 { | |
5143 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
5144 } | |
5145 else | |
5146 { | |
5147 pRenderer->EndScene(); | |
5148 } | |
5149 pAllocator->FreeChunk(ptr); | |
5150 fclose(v7); | |
5151 } | |
5152 } | |
5153 } | |
5154 // 4EFA84: using guessed type int dword_4EFA84; | |
5155 | |
5156 | |
5157 | |
5158 //----- (0049F5A2) -------------------------------------------------------- | |
5159 int Render::_49F5A2(int a2, int a3, int a4, void *Dst, int a6, int a7) | |
5160 { | |
5161 Render *v7; // ebx@1 | |
5162 void *v8; // esi@3 | |
5163 void *v9; // esi@3 | |
5164 int v10; // ecx@4 | |
5165 int v11; // eax@4 | |
5166 int v12; // eax@6 | |
5167 int v13; // eax@8 | |
5168 int v14; // ecx@8 | |
5169 signed int v15; // eax@11 | |
5170 char v16; // zf@20 | |
5171 int result; // eax@21 | |
5172 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
5173 // __int16 v19; // [sp+44h] [bp-74h]@3 | |
5174 char v20[48]; // [sp+48h] [bp-70h]@3 | |
5175 char *v21; // [sp+78h] [bp-40h]@7 | |
5176 char *v22; // [sp+7Ch] [bp-3Ch]@7 | |
5177 int v23; // [sp+80h] [bp-38h]@4 | |
5178 int v24; // [sp+84h] [bp-34h]@4 | |
5179 int v25; // [sp+88h] [bp-30h]@4 | |
5180 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
5181 char Src; // [sp+90h] [bp-28h]@3 | |
5182 char v28; // [sp+91h] [bp-27h]@3 | |
5183 char v29; // [sp+92h] [bp-26h]@3 | |
5184 char v30; // [sp+93h] [bp-25h]@3 | |
5185 __int16 v31; // [sp+94h] [bp-24h]@3 | |
5186 __int16 v32; // [sp+96h] [bp-22h]@3 | |
5187 __int16 v33; // [sp+98h] [bp-20h]@3 | |
5188 __int16 v34; // [sp+9Ah] [bp-1Eh]@3 | |
5189 __int16 v35; // [sp+9Ch] [bp-1Ch]@3 | |
5190 __int16 v36; // [sp+9Eh] [bp-1Ah]@3 | |
5191 char v37; // [sp+A0h] [bp-18h]@3 | |
5192 char v38; // [sp+A1h] [bp-17h]@3 | |
5193 __int16 v39; // [sp+A2h] [bp-16h]@3 | |
5194 __int16 v40; // [sp+A4h] [bp-14h]@3 | |
5195 void *ptr; // [sp+A8h] [bp-10h]@3 | |
5196 int v42; // [sp+ACh] [bp-Ch]@1 | |
5197 char v43; // [sp+B3h] [bp-5h]@18 | |
5198 int i; // [sp+B4h] [bp-4h]@6 | |
5199 | |
5200 v7 = this; | |
5201 v42 = a3; | |
5202 if ( a3 & 1 ) | |
5203 v42 = a3 + 1; | |
5204 v31 = 0; | |
5205 v32 = 0; | |
5206 v33 = a3 - 1; | |
5207 v34 = a4 - 1; | |
5208 v39 = v42; | |
5209 memset(&v20, 0, 0x30u); | |
5210 memset(&v18, 0, 0x38u); | |
5211 v8 = Dst; | |
5212 v37 = 0; | |
5213 *(_WORD *)&v18[56] = 0; | |
5214 Src = 10; | |
5215 v28 = 5; | |
5216 v29 = 1; | |
5217 v30 = 8; | |
5218 v35 = 75; | |
5219 v36 = 75; | |
5220 v38 = 3; | |
5221 v40 = 1; | |
5222 memcpy(Dst, &Src, 1u); | |
5223 v8 = (char *)v8 + 1; | |
5224 memcpy(v8, &v28, 1u); | |
5225 v8 = (char *)v8 + 1; | |
5226 memcpy(v8, &v29, 1u); | |
5227 v8 = (char *)v8 + 1; | |
5228 memcpy(v8, &v30, 1u); | |
5229 v8 = (char *)v8 + 1; | |
5230 memcpy(v8, &v31, 2u); | |
5231 v8 = (char *)v8 + 2; | |
5232 memcpy(v8, &v32, 2u); | |
5233 v8 = (char *)v8 + 2; | |
5234 memcpy(v8, &v33, 2u); | |
5235 v8 = (char *)v8 + 2; | |
5236 memcpy(v8, &v34, 2u); | |
5237 v8 = (char *)v8 + 2; | |
5238 memcpy(v8, &v35, 2u); | |
5239 v8 = (char *)v8 + 2; | |
5240 memcpy(v8, &v36, 2u); | |
5241 v8 = (char *)v8 + 2; | |
5242 memcpy(v8, &v20, 0x30u); | |
5243 v8 = (char *)v8 + 48; | |
5244 memcpy(v8, &v37, 1u); | |
5245 v8 = (char *)v8 + 1; | |
5246 memcpy(v8, &v38, 1u); | |
5247 v8 = (char *)v8 + 1; | |
5248 memcpy(v8, &v39, 2u); | |
5249 v8 = (char *)v8 + 2; | |
5250 memcpy(v8, &v40, 2u); | |
5251 v8 = (char *)v8 + 2; | |
5252 memcpy(v8, &v18, 0x3Au); | |
5253 v9 = (char *)v8 + 58; | |
5254 ptr = pAllocator->AllocNamedChunk(0, 3 * a3 + 6, 0); | |
5255 if ( a4 > 0 ) | |
5256 { | |
5257 v10 = v42; | |
5258 v25 = a4; | |
5259 v26 = 3 * v42; | |
5260 v23 = 2 * a3; | |
5261 v11 = a2; | |
5262 v24 = a2; | |
5263 while ( 1 ) | |
5264 { | |
5265 a4 = v11; | |
5266 v12 = 0; | |
5267 i = 0; | |
5268 if ( a3 > 0 ) | |
5269 { | |
5270 v21 = (char *)ptr + v10; | |
5271 v22 = (char *)ptr + 2 * v42; | |
5272 do | |
5273 { | |
5274 *((char *)ptr + v12) = (signed int)(v7->uTargetRMask & *(short *)a4) >> (LOBYTE(v7->uTargetGBits) | |
5275 + LOBYTE(v7->uTargetBBits) | |
5276 + v7->uTargetRBits | |
5277 - 8); | |
5278 v13 = i; | |
5279 v21[i] = (signed int)(v7->uTargetGMask & *(short *)a4) >> (LOBYTE(v7->uTargetBBits) | |
5280 + LOBYTE(v7->uTargetGBits) | |
5281 - 8); | |
5282 v14 = a4; | |
5283 a4 += 2; | |
5284 v22[v13] = (v7->uTargetBMask & *(char *)v14) << (8 - LOBYTE(v7->uTargetBBits)); | |
5285 v12 = v13 + 1; | |
5286 i = v12; | |
5287 } | |
5288 while ( v12 < a3 ); | |
5289 } | |
5290 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
5291 { | |
5292 BYTE3(a4) = 1; | |
5293 BYTE3(a2) = *((char *)ptr + i); | |
5294 do | |
5295 { | |
5296 v15 = i + BYTE3(a4); | |
5297 if ( *((char *)ptr + v15) != BYTE3(a2) ) | |
5298 break; | |
5299 if ( !(v15 % v42) ) | |
5300 break; | |
5301 ++BYTE3(a4); | |
5302 } | |
5303 while ( BYTE3(a4) < 0x3Fu ); | |
5304 if ( i + BYTE3(a4) > v26 ) | |
5305 BYTE3(a4) = 3 * v42 - i; | |
5306 if ( BYTE3(a4) > 1u || BYTE3(a2) >= 0xC0u ) | |
5307 { | |
5308 v43 = BYTE3(a4) | 0xC0; | |
5309 memcpy(v9, &v43, 1u); | |
5310 v9 = (char *)v9 + 1; | |
5311 } | |
5312 memcpy(v9, (char *)&a2 + 3, 1u); | |
5313 i += BYTE3(a4); | |
5314 } | |
5315 v11 = v23 + v24; | |
5316 v16 = v25-- == 1; | |
5317 v24 += v23; | |
5318 if ( v16 ) | |
5319 break; | |
5320 v10 = v42; | |
5321 } | |
5322 } | |
5323 pAllocator->FreeChunk(ptr); | |
5324 result = a7; | |
5325 *(int *)a7 = (char *)v9 - Dst; | |
5326 return result; | |
5327 } | |
5328 | |
5329 | |
5330 //----- (0049F8B5) -------------------------------------------------------- | |
5331 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) | |
5332 { | |
5333 Render *v5; // esi@1 | |
5334 FILE *result; // eax@1 | |
5335 FILE *v7; // edi@4 | |
5336 int v8; // ecx@5 | |
5337 int v9; // eax@5 | |
5338 int v10; // eax@7 | |
5339 int v11; // ecx@9 | |
5340 signed int v12; // eax@12 | |
5341 char v13; // zf@21 | |
5342 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
5343 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
5344 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
5345 int v17; // [sp+70h] [bp-34h]@5 | |
5346 int v18; // [sp+74h] [bp-30h]@5 | |
5347 char *v19; // [sp+78h] [bp-2Ch]@5 | |
5348 int v20; // [sp+7Ch] [bp-28h]@5 | |
5349 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 | |
5350 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
5351 void *ptr; // [sp+98h] [bp-Ch]@4 | |
5352 int v24; // [sp+9Ch] [bp-8h]@2 | |
5353 char *i; // [sp+A0h] [bp-4h]@8 | |
5354 | |
5355 v5 = this; | |
5356 result = fopen(Filename, "wb"); | |
5357 Filename = (const char *)result; | |
5358 if ( result ) | |
5359 { | |
5360 v24 = a4; | |
5361 if ( a4 & 1 ) | |
5362 v24 = a4 + 1; | |
5363 header1.left = 0; | |
5364 header1.up = 0; | |
5365 header1.right = a4 - 1; | |
5366 header1.bottom = a5 - 1; | |
5367 header2.pitch = v24; | |
5368 memset(color_map, 0, sizeof(color_map)); | |
5369 header2.reserved = 0; | |
5370 memset(v14, 0, sizeof(v14)); | |
5371 v15 = 0; | |
5372 header1.manufacturer = 10; | |
5373 header1.version = 5; | |
5374 header1.encoding = 1; | |
5375 header1.bpp = 8; | |
5376 header1.hdpi = 75; | |
5377 header1.vdpi = 75; | |
5378 header2.planes = 3; | |
5379 header2.palette_info = 1; | |
5380 fwrite(&header1, 1u, 1u, (FILE *)Filename); | |
5381 v7 = (FILE *)Filename; | |
5382 fwrite(&header1.version, 1u, 1u, (FILE *)Filename); | |
5383 fwrite(&header1.encoding, 1u, 1u, v7); | |
5384 fwrite(&header1.bpp, 1u, 1u, v7); | |
5385 fwrite(&header1.left, 2u, 1u, v7); | |
5386 fwrite(&header1.up, 2u, 1u, v7); | |
5387 fwrite(&header1.right, 2u, 1u, v7); | |
5388 fwrite(&header1.bottom, 2u, 1u, v7); | |
5389 fwrite(&header1.hdpi, 2u, 1u, v7); | |
5390 fwrite(&header1.vdpi, 2u, 1u, v7); | |
5391 fwrite(color_map, 0x30u, 1u, v7); | |
5392 fwrite(&header2, 1u, 1u, v7); | |
5393 fwrite(&header2.planes, 1u, 1u, v7); | |
5394 fwrite(&header2.pitch, 2u, 1u, v7); | |
5395 fwrite(&header2.palette_info, 2u, 1u, v7); | |
5396 fwrite(v14, 0x3Au, 1u, v7); | |
5397 ptr = pAllocator->AllocNamedChunk(0, 3 * a4 + 6, 0); | |
5398 if ( a5 > 0 ) | |
5399 { | |
5400 v8 = v24; | |
5401 v18 = a5; | |
5402 v20 = 3 * v24; | |
5403 v17 = 2 * a4; | |
5404 v9 = (int)a3; | |
5405 v19 = a3; | |
5406 while ( 1 ) | |
5407 { | |
5408 a5 = v9; | |
5409 v10 = 0; | |
5410 if ( a4 > 0 ) | |
5411 { | |
5412 a3 = (char *)ptr + v8; | |
5413 i = (char *)ptr + 2 * v24; | |
5414 do | |
5415 { | |
5416 *((char *)ptr + v10) = (signed int)(v5->uTargetRMask & *(short *)a5) >> (LOBYTE(v5->uTargetGBits) | |
5417 + LOBYTE(v5->uTargetBBits) | |
5418 + v5->uTargetRBits | |
5419 - 8); | |
5420 a3[v10] = (signed int)(v5->uTargetGMask & *(short *)a5) >> (LOBYTE(v5->uTargetBBits) | |
5421 + LOBYTE(v5->uTargetGBits) | |
5422 - 8); | |
5423 v11 = a5; | |
5424 a5 += 2; | |
5425 i[v10++] = (v5->uTargetBMask & *(char *)v11) << (8 - LOBYTE(v5->uTargetBBits)); | |
5426 } | |
5427 while ( v10 < a4 ); | |
5428 } | |
5429 for ( i = 0; (signed int)i < v20; i += BYTE3(a5) ) | |
5430 { | |
5431 BYTE3(a5) = 1; | |
5432 BYTE3(Filename) = *((char *)ptr + (int)i); | |
5433 do | |
5434 { | |
5435 v12 = (signed int)&i[BYTE3(a5)]; | |
5436 if ( *((char *)ptr + v12) != BYTE3(Filename) ) | |
5437 break; | |
5438 if ( !(v12 % v24) ) | |
5439 break; | |
5440 ++BYTE3(a5); | |
5441 } | |
5442 while ( BYTE3(a5) < 0x3Fu ); | |
5443 if ( (signed int)&i[BYTE3(a5)] > v20 ) | |
5444 BYTE3(a5) = 3 * v24 - (char)i; | |
5445 if ( BYTE3(a5) > 1u || BYTE3(Filename) >= 0xC0u ) | |
5446 { | |
5447 BYTE3(a3) = BYTE3(a5) | 0xC0; | |
5448 fwrite((char *)&a3 + 3, 1u, 1u, v7); | |
5449 } | |
5450 fwrite((char *)&Filename + 3, 1u, 1u, v7); | |
5451 } | |
5452 v9 = (int)&v19[v17]; | |
5453 v13 = v18-- == 1; | |
5454 v19 += v17; | |
5455 if ( v13 ) | |
5456 break; | |
5457 v8 = v24; | |
5458 } | |
5459 } | |
5460 pAllocator->FreeChunk(ptr); | |
5461 result = (FILE *)fclose(v7); | |
5462 } | |
5463 return result; | |
5464 } | |
5465 | |
5466 | |
5467 //----- (0049FBCD) -------------------------------------------------------- | |
5468 void Render::ClearTarget(unsigned int uColor) | |
5469 { | |
5470 if (pRenderD3D) | |
5471 { | |
5472 if (field_40110) | |
5473 pRenderD3D->ClearTarget(true, uColor, false, 0.0); | |
5474 } | |
5475 else | |
5476 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
5477 } | |
5478 | |
5479 | |
5480 | |
5481 //----- (0049FC23) -------------------------------------------------------- | |
5482 void Render::Release2() | |
5483 { | |
5484 Release(); | |
5485 bWindowMode = 1; | |
5486 } | |
5487 | |
5488 | |
5489 //----- (0049FC37) -------------------------------------------------------- | |
5490 void Render::Present() | |
5491 { | |
5492 Render *v1; // esi@1 | |
5493 struct tagRECT Rect; // [sp+8h] [bp-28h]@11 | |
5494 RECT a4; // [sp+18h] [bp-18h]@11 | |
5495 struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
5496 | |
5497 v1 = this; | |
5498 if ( !pRenderer->pRenderD3D || this->field_40110 ) | |
5499 { | |
5500 this->pBeforePresentFunction(); | |
5501 if ( v1->pRenderD3D ) | |
5502 { | |
5503 if ( v1->field_40110 ) | |
5504 { | |
5505 if (pAsyncMouse) | |
5506 pAsyncMouse->_46BAEC(); | |
5507 pRenderD3D->Present(false); | |
5508 if (pAsyncMouse) | |
5509 pAsyncMouse->_46BB0A(); | |
5510 } | |
5511 } | |
5512 else | |
5513 { | |
5514 if ( v1->bWindowMode ) | |
5515 { | |
5516 RestoreFrontBuffer(); | |
5517 GetClientRect(v1->hWnd, &Rect); | |
5518 Point.y = 0; | |
5519 Point.x = 0; | |
5520 ClientToScreen(v1->hWnd, &Point); | |
5521 OffsetRect(&Rect, Point.x, Point.y); | |
5522 a4.top = 0; | |
5523 a4.bottom = 480; | |
5524 a4.left = 0; | |
5525 a4.right = 640; | |
5526 PresentRect(&Rect, &a4); | |
5527 } | |
5528 else | |
5529 { | |
5530 RestoreFrontBuffer(); | |
5531 a4.top = 0; | |
5532 a4.bottom = 480; | |
5533 a4.left = 0; | |
5534 a4.right = 640; | |
5535 BltBackToFontFast(0, 0, &a4); | |
5536 } | |
5537 } | |
5538 } | |
5539 } | |
5540 | |
5541 //----- (0049FD3A) -------------------------------------------------------- | |
5542 void Render::_49FD3A() | |
5543 { | |
5544 Render *v2; // esi@1 | |
5545 IDirectDrawSurface4 *v3; // eax@6 | |
5546 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
5547 RECT v5; // [sp+8h] [bp-10h]@6 | |
5548 | |
5549 auto a1 = this; | |
5550 v2 = a1; | |
5551 if ( a1->pRenderD3D ) | |
5552 { | |
5553 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
5554 pFrontBuffer4->Restore(); | |
5555 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
5556 pBackBuffer4->Restore(); | |
5557 v3 = v2->pBackBuffer4; | |
5558 v4 = v2->pFrontBuffer4; | |
5559 v5.top = 0; | |
5560 v5.bottom = 480; | |
5561 v5.left = 0; | |
5562 v5.right = 640; | |
5563 v3->BltFast(0, 0, v4, &v5, 16u); | |
5564 } | |
5565 } | |
5566 | |
5567 | |
5568 //----- (0049FDBF) -------------------------------------------------------- | |
5569 void Render::CreateZBuffer() | |
5570 { | |
5571 if (!pDefaultZBuffer) | |
5572 { | |
5573 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
5574 pDefaultZBuffer = pActiveZBuffer = (int *)pAllocator->AllocNamedChunk(0, 0x12C000, "Z Buf."); | |
5575 memset32(pActiveZBuffer, 0xFFFF0000u, 0x4B000u); | |
5576 } | |
5577 } | |
5578 | |
5579 | |
5580 //----- (0049FE05) -------------------------------------------------------- | |
5581 void Render::Release() | |
5582 { | |
5583 Render *v1; // esi@1 | |
5584 RenderD3D *v2; // ecx@1 | |
5585 char v3; // zf@4 | |
5586 void *v4; // ebx@6 | |
5587 IDirectDraw *v5; // eax@10 | |
5588 IDirectDrawSurface2 *v6; // eax@11 | |
5589 IDirectDrawSurface2 *v7; // eax@13 | |
5590 IDirectDrawSurface2 *v8; // eax@15 | |
5591 IDirectDraw2 *v9; // eax@17 | |
5592 IDirectDraw4 *v10; // eax@19 | |
5593 IDirectDrawSurface4 *v11; // eax@20 | |
5594 IDirectDrawSurface4 *v12; // eax@22 | |
5595 IDirectDrawSurface4 *v13; // eax@24 | |
5596 IDirectDraw4 *v14; // eax@26 | |
5597 unsigned __int16 **v15; // ebx@28 | |
5598 void **v16; // esi@29 | |
5599 | |
5600 v1 = this; | |
5601 v2 = this->pRenderD3D; | |
5602 if ( v2 ) | |
5603 { | |
5604 if ( v1->field_40110 ) | |
5605 { | |
5606 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
5607 pRenderD3D->Present(0); | |
5608 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
5609 } | |
5610 v1->pColorKeySurface4 = 0; | |
5611 v1->pBackBuffer4 = 0; | |
5612 v3 = v1->pTargetSurface == 0; | |
5613 v1->pFrontBuffer4 = 0; | |
5614 v1->pDirectDraw4 = 0; | |
5615 if ( !v3 ) | |
5616 { | |
5617 free(v1->ptr_400E8); | |
5618 v1->pTargetSurface = 0; | |
5619 v1->ptr_400E8 = 0; | |
5620 } | |
5621 v4 = v1->pRenderD3D; | |
5622 if ( v4 ) | |
5623 { | |
5624 pRenderD3D->Release(); | |
5625 free(v4); | |
5626 } | |
5627 v1->pRenderD3D = 0; | |
5628 } | |
5629 else | |
5630 { | |
5631 if ( bWinNT4_0 == 1 ) | |
5632 { | |
5633 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
5634 if ( !v5 ) | |
5635 return; | |
5636 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
5637 v1->pDirectDraw2->FlipToGDISurface(); | |
5638 v6 = v1->pSomeSurface2; | |
5639 if ( v6 ) | |
5640 { | |
5641 v6->Release(); | |
5642 v1->pSomeSurface2 = 0; | |
5643 } | |
5644 v7 = v1->pBackBuffer2; | |
5645 if ( v7 ) | |
5646 { | |
5647 v7->Release(); | |
5648 v1->pBackBuffer2 = 0; | |
5649 } | |
5650 v8 = v1->pFrontBuffer2; | |
5651 if ( v8 ) | |
5652 { | |
5653 v8->Release(); | |
5654 v1->pFrontBuffer2 = 0; | |
5655 } | |
5656 v9 = v1->pDirectDraw2; | |
5657 if ( v9 ) | |
5658 { | |
5659 v9->Release(); | |
5660 v1->pDirectDraw2 = 0; | |
5661 } | |
5662 } | |
5663 else | |
5664 { | |
5665 v10 = v1->pDirectDraw4; | |
5666 if ( !v10 ) | |
5667 return; | |
5668 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
5669 v1->pDirectDraw4->FlipToGDISurface(); | |
5670 v11 = v1->pColorKeySurface4; | |
5671 if ( v11 ) | |
5672 { | |
5673 v11->Release(); | |
5674 v1->pColorKeySurface4 = 0; | |
5675 } | |
5676 v12 = v1->pBackBuffer4; | |
5677 if ( v12 ) | |
5678 { | |
5679 v12->Release(); | |
5680 v1->pBackBuffer4 = 0; | |
5681 } | |
5682 v13 = v1->pFrontBuffer4; | |
5683 if ( v13 ) | |
5684 { | |
5685 v13->Release(); | |
5686 v1->pFrontBuffer4 = 0; | |
5687 } | |
5688 v14 = v1->pDirectDraw4; | |
5689 if ( v14 ) | |
5690 { | |
5691 v14->Release(); | |
5692 v1->pDirectDraw4 = 0; | |
5693 } | |
5694 } | |
5695 v15 = &v1->pTargetSurface; | |
5696 if ( v1->pTargetSurface ) | |
5697 { | |
5698 v16 = (void **)&v1->ptr_400E8; | |
5699 free(*v16); | |
5700 *v15 = 0; | |
5701 *v16 = 0; | |
5702 } | |
5703 } | |
5704 } | |
5705 | |
5706 //----- (0049FFD7) -------------------------------------------------------- | |
5707 void Render::CreateSomeTexture() | |
5708 { | |
5709 pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); | |
5710 } | |
5711 | |
5712 //----- (0049FFFB) -------------------------------------------------------- | |
5713 bool Render::InitializeFullscreen(HWND hWnd) | |
5714 { | |
5715 //Render *v2; // esi@1 | |
5716 //HWND v3; // ebx@1 | |
5717 //void *v4; // eax@2 | |
5718 //RenderD3D *v5; // eax@3 | |
5719 unsigned int v6; // edx@5 | |
5720 RenderD3D__DevInfo *v7; // ecx@5 | |
5721 bool v8; // eax@6 | |
5722 RenderD3D *v9; // ecx@13 | |
5723 unsigned int v10; // eax@13 | |
5724 RenderD3D *v11; // eax@25 | |
5725 HRESULT v12; // eax@25 | |
5726 int v13; // ecx@25 | |
5727 int v14; // eax@27 | |
5728 signed int v15; // ebx@31 | |
5729 bool v16; // eax@35 | |
5730 char v17; // zf@35 | |
5731 IDirectDraw4 *v18; // eax@38 | |
5732 HRESULT v19; // eax@38 | |
5733 int *v20; // eax@39 | |
5734 int *v22; // eax@42 | |
5735 int v23; // ecx@42 | |
5736 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
5737 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
5738 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
5739 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
5740 void *v28; // [sp+2FCh] [bp-10h]@2 | |
5741 int v29; // [sp+308h] [bp-4h]@2 | |
5742 | |
5743 //v2 = this; | |
5744 this->field_40110 = 0; | |
5745 this->pColorKeySurface4 = 0; | |
5746 this->pBackBuffer4 = 0; | |
5747 this->pFrontBuffer4 = 0; | |
5748 this->pDirectDraw4 = 0; | |
5749 this->bColorKeySupported = 0; | |
5750 Release(); | |
5751 //v3 = hWnd; | |
5752 this->hWnd = hWnd; | |
5753 CreateZBuffer(); | |
5754 if ( bUserDirect3D ) | |
5755 { | |
5756 pRenderD3D = new RenderD3D; | |
5757 v28 = pRenderD3D; | |
5758 v6 = uDesiredDirect3DDevice; | |
5759 v29 = -1; | |
5760 v7 = pRenderD3D->pAvailableDevices; | |
5761 if ( v7[v6].bIsDeviceCompatible ) | |
5762 { | |
5763 v8 = pRenderD3D->CreateDevice(v6, 0, hWnd); | |
5764 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
5765 } | |
5766 else | |
5767 { | |
5768 if ( v7[1].bIsDeviceCompatible ) | |
5769 { | |
5770 v8 = pRenderD3D->CreateDevice(1u, 0, hWnd); | |
5771 uAcquiredDirect3DDevice = 1; | |
5772 } | |
5773 else | |
5774 { | |
5775 if ( !v7->bIsDeviceCompatible ) | |
5776 Abortf("There aren't any D3D devices to create."); | |
5777 v8 = pRenderD3D->CreateDevice(0, 0, hWnd); | |
5778 uAcquiredDirect3DDevice = 0; | |
5779 } | |
5780 } | |
5781 if ( !v8 ) | |
5782 Abortf("D3Drend->Init failed."); | |
5783 v9 = pRenderD3D; | |
5784 pBackBuffer4 = v9->pBackBuffer; | |
5785 pFrontBuffer4 = v9->pFrontBuffer; | |
5786 pDirectDraw4 = v9->pHost; | |
5787 v10 = pRenderD3D->GetDeviceCaps(); | |
5788 if ( v10 & 1 ) | |
5789 { | |
5790 if ( pRenderD3D ) | |
5791 { | |
5792 pRenderD3D->Release(); | |
5793 delete pRenderD3D; | |
5794 } | |
5795 pRenderD3D = 0; | |
5796 pBackBuffer4 = 0; | |
5797 pFrontBuffer4 = 0; | |
5798 pDirectDraw4 = 0; | |
5799 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
5800 } | |
5801 if ( v10 & 0x3E ) | |
5802 { | |
5803 if ( pRenderD3D ) | |
5804 { | |
5805 pRenderD3D->Release(); | |
5806 delete pRenderD3D; | |
5807 } | |
5808 pColorKeySurface4 = 0; | |
5809 pRenderD3D = 0; | |
5810 pBackBuffer4 = 0; | |
5811 pFrontBuffer4 = 0; | |
5812 pDirectDraw4 = 0; | |
5813 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
5814 } | |
5815 if ( (v10 & 0x80u) != 0 ) | |
5816 { | |
5817 if ( pRenderD3D ) | |
5818 { | |
5819 pRenderD3D->Release(); | |
5820 delete pRenderD3D; | |
5821 } | |
5822 pRenderD3D = 0; | |
5823 pBackBuffer4 = 0; | |
5824 pFrontBuffer4 = 0; | |
5825 pDirectDraw4 = 0; | |
5826 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
5827 } | |
5828 LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; | |
5829 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
5830 memset(&halCaps, 0, 0xFCu); | |
5831 halCaps.dwSize = 252; | |
5832 memset(&refCaps, 0, 0xFCu); | |
5833 v11 = pRenderD3D; | |
5834 refCaps.dwSize = 252; | |
5835 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
5836 v13 = halCaps.dwMinTextureWidth; | |
5837 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
5838 v13 = halCaps.dwMinTextureHeight; | |
5839 v14 = halCaps.dwMaxTextureWidth; | |
5840 uMinDeviceTextureDim = v13; | |
5841 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
5842 v14 = halCaps.dwMaxTextureHeight; | |
5843 uMaxDeviceTextureDim = v14; | |
5844 if ( (unsigned int)v13 < 4 ) | |
5845 uMinDeviceTextureDim = 4; | |
5846 CreateSomeTexture(); | |
5847 v15 = 1; | |
5848 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
5849 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
5850 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
5851 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); | |
5852 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
5853 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
5854 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
5855 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
5856 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
5857 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
5858 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
5859 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
5860 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
5861 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
5862 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
5863 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
5864 } | |
5865 else | |
5866 { | |
5867 CreateDirectDraw(); | |
5868 SetDirectDrawCooperationMode(hWnd, 1); | |
5869 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
5870 CreateDirectDrawPrimarySurface(); | |
5871 v15 = 1; | |
5872 } | |
5873 ddpfPrimareSuface.dwSize = 32; | |
5874 GetTargetPixelFormat(&ddpfPrimareSuface); | |
5875 ParseTargetPixelFormat(); | |
5876 _49EBF1(); | |
5877 if ( pRenderD3D ) | |
5878 { | |
5879 v16 = IsColorKeySupported(pDirectDraw4); | |
5880 v17 = uAcquiredDirect3DDevice == v15; | |
5881 bColorKeySupported = v16; | |
5882 if ( !v17 ) | |
5883 bColorKeySupported = 0; | |
5884 if ( bColorKeySupported ) | |
5885 { | |
5886 memset(&ddsd2, 0, 0x7Cu); | |
5887 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
5888 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
5889 v18 = pDirectDraw4; | |
5890 ddsd2.dwSize = 124; | |
5891 ddsd2.dwFlags = 65543; | |
5892 ddsd2.ddsCaps.dwCaps = 2112; | |
5893 ddsd2.dwWidth = 640; | |
5894 ddsd2.dwHeight = 480; | |
5895 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
5896 pBeforePresentFunction = Present_ColorKey; | |
5897 } | |
5898 else | |
5899 { | |
5900 pTargetSurface = 0; | |
5901 ptr_400E8 = 0; | |
5902 v20 = (int *)operator new(0x96020u); | |
5903 ptr_400E8 = v20; | |
5904 if ( !v20 | |
5905 || (memset(&pDesc, 0, 0x7Cu), | |
5906 pDesc.dwSize = 124, | |
5907 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
5908 return 0; | |
5909 pBackBuffer4->Unlock(0); | |
5910 v22 = ptr_400E8 + 4; | |
5911 v23 = (unsigned int)pDesc.lpSurface & 7; | |
5912 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
5913 uTargetSurfacePitch = 640; | |
5914 pBeforePresentFunction = Present_NoColorKey; | |
5915 v15 = 1; | |
5916 pTargetSurface = (unsigned __int16 *)((char *)v22 + 2 * v23); | |
5917 } | |
5918 field_40110 = v15; | |
5919 } | |
5920 else | |
5921 { | |
5922 pBeforePresentFunction = 0;//nullsub_1; | |
5923 } | |
5924 bWindowMode = 0; | |
5925 pParty->uFlags |= 2u; | |
5926 LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; | |
5927 pViewport->_4C02F8(36044); | |
5928 return v15; | |
5929 } | |
5930 // 6BE3A0: using guessed type float flt_6BE3A0; | |
5931 | |
5932 | |
5933 //----- (004A05F3) -------------------------------------------------------- | |
5934 bool Render::SwitchToWindow(HWND hWnd) | |
5935 { | |
5936 //Render *v2; // esi@1 | |
5937 //void *v3; // eax@2 | |
5938 //RenderD3D *v4; // eax@3 | |
5939 //unsigned int v5; // edx@5 | |
5940 //RenderD3D__DevInfo *v6; // ecx@5 | |
5941 bool v7; // eax@7 | |
5942 //RenderD3D *v8; // ecx@12 | |
5943 unsigned int v9; // eax@12 | |
5944 RenderD3D *v10; // eax@24 | |
5945 HRESULT v11; // eax@24 | |
5946 int v12; // eax@24 | |
5947 int v13; // eax@26 | |
5948 bool v14; // eax@32 | |
5949 char v15; // zf@32 | |
5950 IDirectDraw4 *v16; // eax@35 | |
5951 HRESULT v17; // eax@35 | |
5952 int *v18; // eax@36 | |
5953 int *v19; // edx@38 | |
5954 int v20; // eax@38 | |
5955 unsigned int v21; // ecx@38 | |
5956 int v22; // eax@41 | |
5957 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
5958 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
5959 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
5960 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
5961 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
5962 int v29; // [sp+308h] [bp-4h]@2 | |
5963 | |
5964 pParty->uFlags |= 2u; | |
5965 //v2 = this; | |
5966 flt_6BE3A0 = 0.55000001f; | |
5967 pViewport->_4C02F8(36044); | |
5968 field_40110 = 0; | |
5969 Release(); | |
5970 pColorKeySurface4 = 0; | |
5971 pBackBuffer4 = 0; | |
5972 pFrontBuffer4 = 0; | |
5973 pDirectDraw4 = 0; | |
5974 bColorKeySupported = 0; | |
5975 CreateZBuffer(); | |
5976 if ( bUserDirect3D ) | |
5977 { | |
5978 /*v3 = operator new(0x148u); | |
5979 thisa = (RenderD3D *)v3; | |
5980 v29 = 0; | |
5981 if ( v3 ) | |
5982 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
5983 else | |
5984 v4 = 0;*/ | |
5985 pRenderD3D = new RenderD3D; | |
5986 //v4 = pRenderD3D; | |
5987 //v5 = uDesiredDirect3DDevice; | |
5988 v29 = -1; | |
5989 //v6 = pRenderD3D->pAvailableDevices; | |
5990 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
5991 uDesiredDirect3DDevice != 1 ) | |
5992 { | |
5993 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, hWnd); | |
5994 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
5995 } | |
5996 else | |
5997 { | |
5998 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
5999 Abortf("There aren't any D3D devices to init."); | |
6000 v7 = pRenderD3D->CreateDevice(0, 1, hWnd); | |
6001 uAcquiredDirect3DDevice = 0; | |
6002 } | |
6003 if ( !v7 ) | |
6004 Abortf("D3Drend->Init failed."); | |
6005 | |
6006 //v8 = pRenderD3D; | |
6007 pColorKeySurface4 = 0; | |
6008 pBackBuffer4 = pRenderD3D->pBackBuffer; | |
6009 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
6010 pDirectDraw4 = pRenderD3D->pHost; | |
6011 v9 = pRenderD3D->GetDeviceCaps(); | |
6012 if ( v9 & 1 ) | |
6013 { | |
6014 if (pRenderD3D) | |
6015 { | |
6016 pRenderD3D->Release(); | |
6017 delete pRenderD3D; | |
6018 } | |
6019 pRenderD3D = 0; | |
6020 pBackBuffer4 = 0; | |
6021 pFrontBuffer4 = 0; | |
6022 pDirectDraw4 = 0; | |
6023 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
6024 } | |
6025 if ( v9 & 0x3E ) | |
6026 { | |
6027 if (pRenderD3D) | |
6028 { | |
6029 pRenderD3D->Release(); | |
6030 delete pRenderD3D; | |
6031 } | |
6032 pColorKeySurface4 = 0; | |
6033 pRenderD3D = 0; | |
6034 pBackBuffer4 = 0; | |
6035 pFrontBuffer4 = 0; | |
6036 pDirectDraw4 = 0; | |
6037 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
6038 } | |
6039 if ( (v9 & 0x80u) != 0 ) | |
6040 { | |
6041 if (pRenderD3D) | |
6042 { | |
6043 pRenderD3D->Release(); | |
6044 delete pRenderD3D; | |
6045 } | |
6046 pRenderD3D = 0; | |
6047 pBackBuffer4 = 0; | |
6048 pFrontBuffer4 = 0; | |
6049 pDirectDraw4 = 0; | |
6050 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
6051 } | |
6052 LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; | |
6053 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
6054 memset(&halCaps, 0, 0xFCu); | |
6055 halCaps.dwSize = 252; | |
6056 memset(&refCaps, 0, 0xFCu); | |
6057 //v10 = v2->pRenderD3D; | |
6058 refCaps.dwSize = 252; | |
6059 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
6060 v12 = halCaps.dwMinTextureWidth; | |
6061 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
6062 v12 = halCaps.dwMinTextureHeight; | |
6063 uMinDeviceTextureDim = v12; | |
6064 v13 = halCaps.dwMaxTextureWidth; | |
6065 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
6066 v13 = halCaps.dwMaxTextureHeight; | |
6067 uMaxDeviceTextureDim = v13; | |
6068 CreateSomeTexture(); | |
6069 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
6070 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
6071 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
6072 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
6073 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
6074 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
6075 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
6076 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
6077 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
6078 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
6079 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
6080 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
6081 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
6082 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
6083 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
6084 } | |
6085 else | |
6086 { | |
6087 CreateDirectDraw(); | |
6088 SetDirectDrawCooperationMode(hWnd, 0); | |
6089 field_4004C = 1; | |
6090 CreateFrontBuffer(); | |
6091 CreateClipper(hWnd); | |
6092 CreateBackBuffer(); | |
6093 field_40030 = 0; | |
6094 field_18_locked_pitch = 0; | |
6095 } | |
6096 ddpfPrimareSuface.dwSize = 32; | |
6097 GetTargetPixelFormat(&ddpfPrimareSuface); | |
6098 ParseTargetPixelFormat(); | |
6099 _49EBF1(); | |
6100 if ( !pRenderD3D ) | |
6101 { | |
6102 pBeforePresentFunction = 0;//nullsub_1; | |
6103 goto LABEL_47; | |
6104 } | |
6105 v14 = IsColorKeySupported(pDirectDraw4); | |
6106 v15 = uAcquiredDirect3DDevice == 1; | |
6107 bColorKeySupported = v14; | |
6108 if ( !v15 ) | |
6109 bColorKeySupported = 0; | |
6110 if ( bColorKeySupported ) | |
6111 { | |
6112 memset(&ddsd2, 0, 0x7Cu); | |
6113 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
6114 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
6115 v16 = pDirectDraw4; | |
6116 ddsd2.dwSize = 124; | |
6117 ddsd2.dwFlags = 65543; | |
6118 ddsd2.ddsCaps.dwCaps = 2112; | |
6119 ddsd2.dwWidth = 640; | |
6120 ddsd2.dwHeight = 480; | |
6121 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
6122 pBeforePresentFunction = Present_ColorKey; | |
6123 LABEL_45: | |
6124 field_40110 = 1; | |
6125 LABEL_47: | |
6126 bWindowMode = 1; | |
6127 hWnd = hWnd; | |
6128 return 0; | |
6129 } | |
6130 pTargetSurface = 0; | |
6131 ptr_400E8 = 0; | |
6132 v18 = (int *)new char[0x96020]; | |
6133 memset(v18, -1, 0x96020); | |
6134 ptr_400E8 = v18; | |
6135 if ( v18 ) | |
6136 { | |
6137 memset(&pDesc, 0, 0x7Cu); | |
6138 pDesc.dwSize = 124; | |
6139 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, 1u) ) | |
6140 { | |
6141 pRenderer->pBackBuffer4->Unlock(0); | |
6142 v19 = ptr_400E8; | |
6143 v20 = (unsigned int)pDesc.lpSurface & 7; | |
6144 v21 = (unsigned int)ptr_400E8 & 7; | |
6145 if ( v21 == v20 ) | |
6146 { | |
6147 pTargetSurface = (unsigned __int16 *)v19; | |
6148 } | |
6149 else | |
6150 { | |
6151 if ( (signed int)v21 >= v20 ) | |
6152 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
6153 else | |
6154 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
6155 pTargetSurface = (unsigned __int16 *)v22; | |
6156 } | |
6157 uTargetSurfacePitch = 640; | |
6158 pBeforePresentFunction = Present_NoColorKey; | |
6159 goto LABEL_45; | |
6160 } | |
6161 } | |
6162 return 0; | |
6163 } | |
6164 | |
6165 | |
6166 //----- (004A0BEE) -------------------------------------------------------- | |
6167 char Render::Line2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor) | |
6168 { | |
6169 int v6; // edi@1 | |
6170 int v7; // edx@5 | |
6171 unsigned int v8; // ebx@5 | |
6172 int v9; // eax@7 | |
6173 unsigned int v10; // ecx@9 | |
6174 unsigned int v11; // esi@13 | |
6175 int v12; // eax@17 | |
6176 int v13; // eax@21 | |
6177 Render *v14; // edi@21 | |
6178 int v15; // eax@25 | |
6179 int v16; // eax@27 | |
6180 signed int v17; // eax@28 | |
6181 signed int v18; // edi@30 | |
6182 signed __int64 v19; // qax@41 | |
6183 int v20; // edi@41 | |
6184 unsigned int v21; // edi@46 | |
6185 int v22; // esi@47 | |
6186 int v23; // ebx@47 | |
6187 signed int v24; // edx@50 | |
6188 signed int v25; // esi@52 | |
6189 unsigned __int16 *v26; // ecx@52 | |
6190 int v27; // ebx@54 | |
6191 int v28; // edi@55 | |
6192 int v29; // edx@55 | |
6193 int v30; // ebx@60 | |
6194 int v31; // edx@61 | |
6195 int v32; // edi@61 | |
6196 int v34; // [sp+Ch] [bp-10h]@3 | |
6197 Render *v35; // [sp+10h] [bp-Ch]@1 | |
6198 __int64 v36; // [sp+14h] [bp-8h]@1 | |
6199 signed int v37; // [sp+18h] [bp-4h]@28 | |
6200 unsigned int uXa; // [sp+24h] [bp+8h]@49 | |
6201 unsigned int uYa; // [sp+28h] [bp+Ch]@28 | |
6202 int uYb; // [sp+28h] [bp+Ch]@47 | |
6203 int uZa; // [sp+2Ch] [bp+10h]@38 | |
6204 | |
6205 v36 = 0i64; | |
6206 v6 = this->field_1C_clipx; | |
6207 v35 = this; | |
6208 if ( (signed int)uX < v6 ) | |
6209 HIDWORD(v36) = 8; | |
6210 v34 = this->field_24_clipz; | |
6211 if ( (signed int)uX > this->field_24_clipz ) | |
6212 HIDWORD(v36) |= 4u; | |
6213 v7 = this->field_20_clipy; | |
6214 v8 = uY; | |
6215 if ( (signed int)uY < v7 ) | |
6216 HIDWORD(v36) |= 2u; | |
6217 v9 = this->field_28_clipw; | |
6218 if ( (signed int)uY > v9 ) | |
6219 HIDWORD(v36) |= 1u; | |
6220 v10 = uZ; | |
6221 if ( (signed int)uZ < v6 ) | |
6222 LODWORD(v36) = 8; | |
6223 if ( (signed int)uZ > v34 ) | |
6224 LODWORD(v36) = v36 | 4; | |
6225 v11 = uW; | |
6226 if ( (signed int)uW < v7 ) | |
6227 LODWORD(v36) = v36 | 2; | |
6228 if ( (signed int)uW > v9 ) | |
6229 LODWORD(v36) = v36 | 1; | |
6230 LOBYTE(v12) = v36; | |
6231 if ( (unsigned int)v36 & HIDWORD(v36) ) | |
6232 return v12; | |
6233 if ( !v36 ) | |
6234 { | |
6235 LABEL_46: | |
6236 v21 = pRenderer->uTargetSurfacePitch; | |
6237 if ( pRenderer->uTargetSurfacePitch ) | |
6238 { | |
6239 v12 = uX + v8 * pRenderer->uTargetSurfacePitch; | |
6240 v22 = v11 - v8; | |
6241 v23 = v22; | |
6242 uYb = v22; | |
6243 if ( v22 < 0 ) | |
6244 { | |
6245 v23 = -v22; | |
6246 uYb = -v22; | |
6247 v21 = -pRenderer->uTargetSurfacePitch; | |
6248 } | |
6249 uXa = v10 - uX; | |
6250 if ( (uXa & 0x80000000u) == 0 ) | |
6251 { | |
6252 v24 = 1; | |
6253 } | |
6254 else | |
6255 { | |
6256 uXa = -uXa; | |
6257 v24 = -1; | |
6258 } | |
6259 v25 = 0; | |
6260 v26 = v35->pTargetSurface; | |
6261 if ( v26 ) | |
6262 { | |
6263 if ( (signed int)uXa <= v23 ) | |
6264 { | |
6265 v30 = v23 + 1; | |
6266 if ( v30 > 0 ) | |
6267 { | |
6268 v31 = 2 * v24; | |
6269 v32 = 2 * v21; | |
6270 v12 = (int)&v26[v12]; | |
6271 do | |
6272 { | |
6273 v25 += uXa; | |
6274 *(short *)v12 = uColor; | |
6275 v12 += v32; | |
6276 if ( v25 > 0 ) | |
6277 { | |
6278 v25 -= uYb; | |
6279 v12 += v31; | |
6280 } | |
6281 --v30; | |
6282 } | |
6283 while ( v30 ); | |
6284 } | |
6285 } | |
6286 else | |
6287 { | |
6288 v27 = uXa + 1; | |
6289 if ( (signed int)(uXa + 1) > 0 ) | |
6290 { | |
6291 v28 = 2 * v21; | |
6292 v29 = 2 * v24; | |
6293 v12 = (int)&v26[v12]; | |
6294 do | |
6295 { | |
6296 v25 += uYb; | |
6297 *(short *)v12 = uColor; | |
6298 v12 += v29; | |
6299 if ( v25 > (signed int)uXa ) | |
6300 { | |
6301 v25 -= uXa; | |
6302 v12 += v28; | |
6303 } | |
6304 --v27; | |
6305 } | |
6306 while ( v27 ); | |
6307 } | |
6308 } | |
6309 } | |
6310 } | |
6311 return v12; | |
6312 } | |
6313 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 ) | |
6314 { | |
6315 if ( BYTE4(v36) & 8 ) | |
6316 { | |
6317 v13 = (signed int)((uW - uY) * (v6 - uX)) / (signed int)(uZ - uX); | |
6318 v14 = v35; | |
6319 v8 = v13 + uY; | |
6320 uX = v35->field_1C_clipx; | |
6321 goto LABEL_24; | |
6322 } | |
6323 v10 = v6; | |
6324 v11 = (signed int)((uY - uW) * (v6 - uZ)) / (signed int)(uX - uZ) + uW; | |
6325 } | |
6326 v14 = v35; | |
6327 LABEL_24: | |
6328 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) | |
6329 { | |
6330 v15 = v14->field_24_clipz; | |
6331 if ( BYTE4(v36) & 4 ) | |
6332 { | |
6333 v14 = v35; | |
6334 v8 += (signed int)((v11 - v8) * (v15 - uX)) / (signed int)(v10 - uX); | |
6335 uX = v35->field_24_clipz; | |
6336 } | |
6337 else | |
6338 { | |
6339 v16 = (signed int)((v8 - v11) * (v15 - v10)) / (signed int)(uX - v10); | |
6340 v10 = v14->field_24_clipz; | |
6341 v11 += v16; | |
6342 } | |
6343 } | |
6344 v17 = v14->field_20_clipy; | |
6345 v37 = 0; | |
6346 uYa = v14->field_20_clipy; | |
6347 if ( (signed int)v8 < v17 ) | |
6348 v37 = 2; | |
6349 v18 = v14->field_28_clipw; | |
6350 if ( (signed int)v8 > v18 ) | |
6351 v37 |= 1u; | |
6352 if ( (signed int)v11 >= v17 ) | |
6353 v12 = 0; | |
6354 else | |
6355 v12 = 2; | |
6356 if ( (signed int)v11 > v18 ) | |
6357 LOBYTE(v12) = v12 | 1; | |
6358 if ( !(v12 & v37) ) | |
6359 { | |
6360 v12 ^= v37; | |
6361 uZa = v12; | |
6362 if ( v12 & 2 ) | |
6363 { | |
6364 if ( v37 & 2 ) | |
6365 { | |
6366 uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8); | |
6367 LOBYTE(v12) = (char)v35; | |
6368 v8 = v35->field_20_clipy; | |
6369 } | |
6370 else | |
6371 { | |
6372 v19 = (signed int)((uX - v10) * (uYa - v11)); | |
6373 v20 = v8 - v11; | |
6374 v11 = uYa; | |
6375 v12 = v19 / v20; | |
6376 v10 += v12; | |
6377 } | |
6378 } | |
6379 if ( uZa & 1 ) | |
6380 { | |
6381 if ( v37 & 1 ) | |
6382 { | |
6383 uX += (signed int)((v10 - uX) * (v35->field_28_clipw - v8)) / (signed int)(v11 - v8); | |
6384 LOBYTE(v12) = (char)v35; | |
6385 v8 = v35->field_28_clipw; | |
6386 } | |
6387 else | |
6388 { | |
6389 v12 = (signed int)((uX - v10) * (v35->field_28_clipw - v11)) / (signed int)(v8 - v11); | |
6390 v11 = v35->field_28_clipw; | |
6391 v10 += v12; | |
6392 } | |
6393 } | |
6394 goto LABEL_46; | |
6395 } | |
6396 return v12; | |
6397 } | |
6398 | |
6399 | |
6400 | |
6401 //----- (004A0E80) -------------------------------------------------------- | |
6402 void Render::ClearZBuffer(int a2, int a3) | |
6403 { | |
6404 memset32(this->pActiveZBuffer, -65536, 0x4B000u); | |
6405 } | |
6406 | |
6407 | |
6408 | |
6409 //----- (004A0E97) -------------------------------------------------------- | |
6410 void Render::Clip_v2(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) | |
6411 { | |
6412 this->field_1C_clipx = uX; | |
6413 this->field_20_clipy = uY; | |
6414 this->field_24_clipz = uZ; | |
6415 this->field_28_clipw = uW; | |
6416 } | |
6417 | |
6418 | |
6419 //----- (004A0EB6) -------------------------------------------------------- | |
6420 void Render::ParseTargetPixelFormat() | |
6421 { | |
6422 Render *v1; // eax@1 | |
6423 signed int v2; // ecx@1 | |
6424 DWORD uRedMask; // edx@1 | |
6425 unsigned int uGreenMask; // esi@5 | |
6426 signed int v5; // ecx@5 | |
6427 unsigned int uBlueMask; // edx@9 | |
6428 signed int v7; // ecx@9 | |
6429 unsigned int v8; // ecx@13 | |
6430 | |
6431 v1 = this; | |
6432 v2 = 0; | |
6433 uRedMask = v1->ddpfPrimareSuface.dwRBitMask; | |
6434 v1->uTargetBBits = 0; | |
6435 v1->uTargetGBits = 0; | |
6436 v1->uTargetRBits = 0; | |
6437 do | |
6438 { | |
6439 if ( (1 << v2) & uRedMask ) | |
6440 ++v1->uTargetRBits; | |
6441 ++v2; | |
6442 } | |
6443 while ( v2 < 16 ); | |
6444 uGreenMask = v1->ddpfPrimareSuface.dwGBitMask; | |
6445 v5 = 0; | |
6446 do | |
6447 { | |
6448 if ( (1 << v5) & uGreenMask ) | |
6449 ++v1->uTargetGBits; | |
6450 ++v5; | |
6451 } | |
6452 while ( v5 < 16 ); | |
6453 uBlueMask = v1->ddpfPrimareSuface.dwBBitMask; | |
6454 v7 = 0; | |
6455 do | |
6456 { | |
6457 if ( (1 << v7) & uBlueMask ) | |
6458 ++v1->uTargetBBits; | |
6459 ++v7; | |
6460 } | |
6461 while ( v7 < 16 ); | |
6462 v8 = v1->ddpfPrimareSuface.dwRBitMask; | |
6463 v1->uTargetGMask = uGreenMask; | |
6464 v1->uTargetRMask = v8; | |
6465 v1->uTargetBMask = uBlueMask; | |
6466 } | |
6467 | |
6468 //----- (004A0F40) -------------------------------------------------------- | |
6469 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
6470 { | |
6471 IDirectDrawSurface4 *v4; // esi@1 | |
6472 bool result; // eax@1 | |
6473 HRESULT v6; // eax@4 | |
6474 int v7; // [sp-8h] [bp-14h]@10 | |
6475 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
6476 char v9; // [sp+Bh] [bp-1h]@1 | |
6477 | |
6478 v4 = pSurface; | |
6479 v9 = 1; | |
6480 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
6481 if ( result == DDERR_SURFACELOST ) | |
6482 { | |
6483 if (pAsyncMouse) | |
6484 pAsyncMouse->Suspend(); | |
6485 v6 = v4->Restore(); | |
6486 if ( v6 ) | |
6487 { | |
6488 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
6489 { | |
6490 LABEL_20: | |
6491 v9 = 0; | |
6492 result = (bool)memset(pDesc, 0, 4u); | |
6493 goto LABEL_21; | |
6494 } | |
6495 pRenderer->pFrontBuffer4->Restore(); | |
6496 v4->Restore(); | |
6497 } | |
6498 result = v4->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
6499 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
6500 goto LABEL_20; | |
6501 ErrD3D(result); | |
6502 if ( result ) | |
6503 { | |
6504 //v8 = 0; | |
6505 //v7 = 2161; | |
6506 LABEL_19: | |
6507 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
6508 goto LABEL_20; | |
6509 } | |
6510 if ( pRenderer->pRenderD3D ) | |
6511 pRenderD3D->HandleLostResources(); | |
6512 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
6513 if (pAsyncMouse) | |
6514 pAsyncMouse->Resume(); | |
6515 } | |
6516 else | |
6517 { | |
6518 if ( result ) | |
6519 { | |
6520 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
6521 goto LABEL_20; | |
6522 ErrD3D(result); | |
6523 //v8 = 0; | |
6524 //v7 = 2199; | |
6525 //goto LABEL_19; | |
6526 } | |
6527 } | |
6528 LABEL_21: | |
6529 LOBYTE(result) = v9; | |
6530 return result; | |
6531 } | |
6532 | |
6533 | |
6534 //----- (004A1032) -------------------------------------------------------- | |
6535 bool Render::LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags) | |
6536 { | |
6537 IDirectDrawSurface2 *v4; // esi@1 | |
6538 bool v5; // eax@1 | |
6539 HRESULT v6; // eax@2 | |
6540 int v7; // [sp-8h] [bp-10h]@8 | |
6541 unsigned int v8; // [sp-4h] [bp-Ch]@8 | |
6542 | |
6543 v4 = pSurface; | |
6544 v5 = pSurface->Lock( | |
6545 0, | |
6546 pDesc, | |
6547 uLockFlags, | |
6548 0); | |
6549 BYTE3(pSurface) = 1; | |
6550 if ( v5 == DDERR_SURFACELOST ) | |
6551 { | |
6552 v6 = v4->Restore(); | |
6553 if ( !v6 ) | |
6554 goto LABEL_5; | |
6555 if ( v6 == DDERR_IMPLICITLYCREATED ) | |
6556 { | |
6557 pRenderer->pFrontBuffer2->Restore(); | |
6558 v4->Restore(); | |
6559 LABEL_5: | |
6560 v5 = v4->Lock(0, pDesc, 1u, 0) != 0; | |
6561 if ( v5 == DDERR_INVALIDRECT || v5 == DDERR_SURFACEBUSY ) | |
6562 goto LABEL_14; | |
6563 if ( !v5 ) | |
6564 return true; | |
6565 ErrD3D(v5); | |
6566 //v8 = 0; | |
6567 //v7 = 2247; | |
6568 goto LABEL_13; | |
6569 } | |
6570 else | |
6571 { | |
6572 pDesc->dwSize = 0; | |
6573 return false; | |
6574 } | |
6575 } | |
6576 else | |
6577 { | |
6578 if ( !v5 ) | |
6579 return true; | |
6580 if ( v5 != DDERR_INVALIDRECT && v5 != DDERR_SURFACEBUSY ) | |
6581 { | |
6582 //v8 = 0; | |
6583 //v7 = 2269; | |
6584 ErrD3D(v5); | |
6585 pDesc->dwSize = 0; | |
6586 return false; | |
6587 LABEL_13: | |
6588 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, v5, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
6589 goto LABEL_14; | |
6590 } | |
6591 } | |
6592 LABEL_14: | |
6593 return true; | |
6594 } | |
6595 | |
6596 //----- (004A10E4) -------------------------------------------------------- | |
6597 void Render::CreateDirectDraw() | |
6598 { | |
6599 Render *v1; // edi@1 | |
6600 HRESULT v2; // eax@1 | |
6601 HRESULT v3; // eax@5 | |
6602 int v6; // [sp-Ch] [bp-20h]@3 | |
6603 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
6604 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
6605 | |
6606 v1 = this; | |
6607 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
6608 | |
6609 pDirectDraw2 = nullptr; | |
6610 pDirectDraw4 = nullptr; | |
6611 | |
6612 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6613 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); | |
6614 else | |
6615 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); | |
6616 | |
6617 lpDD->Release(); | |
6618 lpDD = nullptr; | |
6619 } | |
6620 | |
6621 //----- (004A1169) -------------------------------------------------------- | |
6622 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
6623 { | |
6624 DWORD flags; // eax@1 | |
6625 IDirectDraw *v4; // ecx@3 | |
6626 HRESULT v5; // eax@5 | |
6627 int v6; // [sp-8h] [bp-8h]@3 | |
6628 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
6629 | |
6630 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
6631 DDSCL_NORMAL; | |
6632 | |
6633 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6634 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); | |
6635 else | |
6636 ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); | |
6637 } | |
6638 | |
6639 //----- (004A11C6) -------------------------------------------------------- | |
6640 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
6641 { | |
6642 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6643 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
6644 else | |
6645 ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
6646 } | |
6647 | |
6648 //----- (004A121C) -------------------------------------------------------- | |
6649 void Render::CreateFrontBuffer() | |
6650 { | |
6651 Render *v1; // esi@1 | |
6652 IDirectDraw *pDD; // eax@3 | |
6653 IDirectDrawSurface **pOutSurf; // esi@3 | |
6654 struct _DDSURFACEDESC *v4; // edx@3 | |
6655 HRESULT v5; // eax@5 | |
6656 int v6; // [sp-8h] [bp-8Ch]@3 | |
6657 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
6658 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
6659 | |
6660 v1 = this; | |
6661 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6662 { | |
6663 memset(&a2, 0, 0x7Cu); | |
6664 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
6665 a2.dwSize = 124; | |
6666 a2.dwFlags = 1; | |
6667 v7 = 0; | |
6668 a2.ddsCaps.dwCaps = 512; | |
6669 v6 = 2357; | |
6670 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
6671 v4 = (struct _DDSURFACEDESC *)&a2; | |
6672 } | |
6673 else | |
6674 { | |
6675 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
6676 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
6677 a2.lPitch = 108; | |
6678 a2.dwBackBufferCount = 1; | |
6679 v7 = 0; | |
6680 a2.dwTextureStage = 512; | |
6681 v6 = 2346; | |
6682 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
6683 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
6684 } | |
6685 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); | |
6686 } | |
6687 | |
6688 //----- (004A12CD) -------------------------------------------------------- | |
6689 void Render::CreateBackBuffer() | |
6690 { | |
6691 Render *v1; // esi@1 | |
6692 IDirectDraw *v2; // eax@3 | |
6693 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
6694 struct _DDSURFACEDESC *v4; // edx@3 | |
6695 HRESULT v5; // eax@5 | |
6696 int v6; // [sp-8h] [bp-8Ch]@3 | |
6697 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
6698 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
6699 | |
6700 v1 = this; | |
6701 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6702 { | |
6703 memset(&a2, 0, 0x7Cu); | |
6704 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
6705 a2.dwSize = 124; | |
6706 a2.dwFlags = 7; | |
6707 v7 = 0; | |
6708 a2.ddsCaps.dwCaps = 2112; | |
6709 a2.dwWidth = 640; | |
6710 a2.dwHeight = 480; | |
6711 v6 = 2387; | |
6712 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
6713 v4 = (struct _DDSURFACEDESC *)&a2; | |
6714 } | |
6715 else | |
6716 { | |
6717 memset(&a2.lPitch, 0, 0x6Cu); | |
6718 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
6719 a2.lPitch = 108; | |
6720 a2.dwBackBufferCount = 7; | |
6721 v7 = 0; | |
6722 a2.dwTextureStage = 2112; | |
6723 a2.dwAlphaBitDepth = 640; | |
6724 a2.dwMipMapCount = 480; | |
6725 v6 = 2374; | |
6726 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
6727 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
6728 } | |
6729 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); | |
6730 } | |
6731 | |
6732 //----- (004A139A) -------------------------------------------------------- | |
6733 void Render::CreateDirectDrawPrimarySurface() | |
6734 { | |
6735 Render *v1; // esi@1 | |
6736 int v2; // ebx@3 | |
6737 IDirectDraw2 *v3; // eax@3 | |
6738 HRESULT v4; // eax@3 | |
6739 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
6740 DDSCAPS2 *v6; // edx@3 | |
6741 IDirectDraw4 *v7; // eax@4 | |
6742 HRESULT v8; // eax@4 | |
6743 int v9; // ST14_4@5 | |
6744 IDirectDrawSurface *v10; // ST10_4@5 | |
6745 HRESULT v11; // eax@5 | |
6746 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
6747 const char *v13; // [sp+0h] [bp-A0h]@0 | |
6748 int v14; // [sp+4h] [bp-9Ch]@0 | |
6749 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
6750 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
6751 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
6752 int a4; // [sp+98h] [bp-8h]@3 | |
6753 | |
6754 v1 = this; | |
6755 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6756 { | |
6757 v2 = 0; | |
6758 this->field_4004C = 1; | |
6759 memset(&ddsd2, 0, 0x7Cu); | |
6760 v7 = v1->pDirectDraw4; | |
6761 ddsd2.dwBackBufferCount = 1; | |
6762 ddsd2.dwSize = 0x7Cu; | |
6763 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
6764 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
6765 ErrD3D(v7->CreateSurface( | |
6766 &ddsd2, | |
6767 &pFrontBuffer4, | |
6768 0)); | |
6769 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
6770 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
6771 } | |
6772 else | |
6773 { | |
6774 v2 = 0; | |
6775 this->field_4004C = 1; | |
6776 | |
6777 DDSURFACEDESC ddsd; | |
6778 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
6779 | |
6780 ddsd.lpSurface = (LPVOID)1; | |
6781 ddsd.lPitch = 108; | |
6782 ddsd.dwBackBufferCount = 33; | |
6783 ddsd.ddsCaps.dwCaps = 8728; | |
6784 ErrD3D(pDirectDraw2->CreateSurface( | |
6785 &ddsd, | |
6786 (IDirectDrawSurface **)&pFrontBuffer2, | |
6787 0)); | |
6788 | |
6789 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
6790 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
6791 } | |
6792 v9 = (int)v6; | |
6793 v10 = pFrontBuffer; // BUG | |
6794 | |
6795 v17.dwCaps = 4; | |
6796 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
6797 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
6798 v1->field_40030 = v2; | |
6799 v1->field_18_locked_pitch = v2; | |
6800 } | |
6801 | |
6802 //----- (004A14F4) -------------------------------------------------------- | |
6803 void Render::CreateClipper(HWND a2) | |
6804 { | |
6805 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6806 { | |
6807 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); | |
6808 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
6809 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
6810 } | |
6811 else | |
6812 { | |
6813 ErrD3D(pDirectDraw2->CreateClipper(0, &pDDrawClipper, 0)); | |
6814 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
6815 } | |
6816 } | |
6817 | |
6818 //----- (004A15D8) -------------------------------------------------------- | |
6819 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
6820 { | |
6821 IDirectDrawSurface *v2; // eax@3 | |
6822 | |
6823 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6824 v2 = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6825 else | |
6826 v2 = (IDirectDrawSurface *)this->pFrontBuffer2; | |
6827 v2->GetPixelFormat(pOut); | |
6828 } | |
6829 | |
6830 //----- (004A1605) -------------------------------------------------------- | |
6831 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
6832 { | |
6833 Render *v3; // esi@1 | |
6834 signed int v4; // eax@3 | |
6835 | |
6836 v3 = this; | |
6837 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6838 { | |
6839 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
6840 memset(&pDesc, 0, 0x7Cu); | |
6841 pDesc.dwSize = 124; | |
6842 LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, 1u); | |
6843 *pOutSurfacePtr = pDesc.lpSurface; | |
6844 v4 = pDesc.lPitch; | |
6845 } | |
6846 else | |
6847 { | |
6848 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
6849 memset(&pDesc.lPitch, 0, 0x6Cu); | |
6850 pDesc.lPitch = 108; | |
6851 LockSurface_DDraw2(v3->pBackBuffer2, &pDesc, 1u); | |
6852 *pOutSurfacePtr = (void *)pDesc.lpSurface; | |
6853 v4 = pDesc.dwReserved; | |
6854 } | |
6855 *pOutPixelsPerRow = v4 >> 1; | |
6856 } | |
6857 | |
6858 //----- (004A169E) -------------------------------------------------------- | |
6859 bool Render::UsingDirect3D() | |
6860 { | |
6861 return bUserDirect3D == 0; | |
6862 } | |
6863 | |
6864 | |
6865 //----- (004A16E1) -------------------------------------------------------- | |
6866 void Render::UnlockBackBuffer() | |
6867 { | |
6868 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6869 ErrD3D(pBackBuffer4->Unlock(0)); | |
6870 else | |
6871 ErrD3D(pBackBuffer2->Unlock(0)); | |
6872 } | |
6873 | |
6874 | |
6875 //----- (004A172E) -------------------------------------------------------- | |
6876 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
6877 { | |
6878 Render *v3; // esi@1 | |
6879 signed int v4; // eax@3 | |
6880 | |
6881 v3 = this; | |
6882 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6883 { | |
6884 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
6885 memset(&pDesc, 0, 0x7Cu); | |
6886 pDesc.dwSize = 124; | |
6887 LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, 1u); | |
6888 *pOutSurface = pDesc.lpSurface; | |
6889 v4 = pDesc.lPitch; | |
6890 } | |
6891 else | |
6892 { | |
6893 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
6894 memset(&pDesc.lPitch, 0, 0x6Cu); | |
6895 pDesc.lPitch = 108; | |
6896 LockSurface_DDraw2(v3->pFrontBuffer2, &pDesc, 1u); | |
6897 *pOutSurface = (void *)pDesc.lpSurface; | |
6898 v4 = pDesc.dwReserved; | |
6899 } | |
6900 *pOutPixelsPerRow = v4 >> 1; | |
6901 } | |
6902 | |
6903 //----- (004A17C7) -------------------------------------------------------- | |
6904 void Render::UnlockFrontBuffer() | |
6905 { | |
6906 IDirectDrawSurface *pFront; // eax@3 | |
6907 HRESULT v2; // eax@5 | |
6908 signed int v3; // [sp-8h] [bp-Ch]@3 | |
6909 int v4; // [sp-4h] [bp-8h]@3 | |
6910 | |
6911 auto a5 = this; | |
6912 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6913 { | |
6914 pFront = (IDirectDrawSurface *)a5->pFrontBuffer4; | |
6915 v4 = 0; | |
6916 v3 = 2615; | |
6917 } | |
6918 else | |
6919 { | |
6920 pFront = (IDirectDrawSurface *)a5->pFrontBuffer2; | |
6921 v4 = 0; | |
6922 v3 = 2611; | |
6923 } | |
6924 ErrD3D(pFront->Unlock(0)); | |
6925 } | |
6926 | |
6927 | |
6928 //----- (004A1814) -------------------------------------------------------- | |
6929 void Render::RestoreFrontBuffer() | |
6930 { | |
6931 IDirectDrawSurface **v1; // esi@2 | |
6932 | |
6933 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
6934 || (v1 = (IDirectDrawSurface **)&this->pFrontBuffer2, pVersion->pVersionInfo.dwMajorVersion >= 5u) ) | |
6935 v1 = (IDirectDrawSurface **)&this->pFrontBuffer4; | |
6936 if ( (*v1)->IsLost() == DDERR_SURFACELOST ) | |
6937 (*v1)->Restore(); | |
6938 } | |
6939 | |
6940 | |
6941 //----- (004A184C) -------------------------------------------------------- | |
6942 HRESULT Render::_4A184C() | |
6943 { | |
6944 IDirectDrawSurface **pBack; // esi@2 | |
6945 HRESULT result; // eax@4 | |
6946 | |
6947 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
6948 || (pBack = (IDirectDrawSurface **)&this->pBackBuffer2, pVersion->pVersionInfo.dwMajorVersion != 4) ) | |
6949 pBack = (IDirectDrawSurface **)&this->pBackBuffer4; | |
6950 result = (*pBack)->IsLost(); | |
6951 if ( result == DDERR_SURFACELOST ) | |
6952 result = (*pBack)->Restore(); | |
6953 return result; | |
6954 } | |
6955 | |
6956 //----- (004A1884) -------------------------------------------------------- | |
6957 void Render::PresentRect(RECT *a2, RECT *a3) | |
6958 { | |
6959 IDirectDrawSurface *pFront; // eax@3 | |
6960 HRESULT v4; // eax@5 | |
6961 IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3 | |
6962 struct tagRECT *v6; // [sp-18h] [bp-18h]@3 | |
6963 DWORD v7; // [sp-14h] [bp-14h]@3 | |
6964 DDBLTFX *v8; // [sp-10h] [bp-10h]@3 | |
6965 const char *v9; // [sp-Ch] [bp-Ch]@3 | |
6966 int v10; // [sp-8h] [bp-8h]@3 | |
6967 unsigned int v11; // [sp-4h] [bp-4h]@3 | |
6968 | |
6969 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6970 { | |
6971 v11 = 0; | |
6972 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6973 v10 = 2657; | |
6974 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
6975 v8 = 0; | |
6976 v7 = DDBLT_WAIT; | |
6977 v6 = a3; | |
6978 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
6979 } | |
6980 else | |
6981 { | |
6982 v11 = 0; | |
6983 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
6984 v10 = 2653; | |
6985 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
6986 v8 = 0; | |
6987 v7 = DDBLT_WAIT; | |
6988 v6 = a3; | |
6989 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
6990 } | |
6991 ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8)); | |
6992 } | |
6993 | |
6994 | |
6995 //----- (004A18F5) -------------------------------------------------------- | |
6996 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
6997 { | |
6998 IDirectDrawSurface *pFront; // eax@3 | |
6999 HRESULT v6; // eax@5 | |
7000 int v7; // [sp-8h] [bp-8h]@3 | |
7001 unsigned int v8; // [sp-4h] [bp-4h]@3 | |
7002 | |
7003 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) | |
7004 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
7005 else | |
7006 ErrD3D(pFrontBuffer2->Blt(pDstRect, (IDirectDrawSurface2 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
7007 } | |
7008 | |
7009 //----- (004A194A) -------------------------------------------------------- | |
7010 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
7011 { | |
7012 IDirectDrawSurface *pFront; // eax@3 | |
7013 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
7014 | |
7015 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
7016 { | |
7017 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
7018 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
7019 } | |
7020 else | |
7021 { | |
7022 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
7023 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
7024 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7025 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 7026 } |
7027 | |
7028 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7029 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7030 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7031 //unsigned int v2; // ebx@1 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7032 //double v4; // st7@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7033 //unsigned int v5; // esi@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7034 //int v6; // ecx@5 |
0 | 7035 unsigned int v7; // edx@6 |
7036 char *v8; // ecx@12 | |
7037 void *v9; // edi@16 | |
7038 unsigned int v10; // eax@16 | |
7039 void *v11; // edi@21 | |
7040 unsigned int v12; // eax@21 | |
7041 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7042 //v2 = uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7043 if (uNumBillboardsToDraw >= 999 ) |
0 | 7044 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7045 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7046 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7047 uNumBillboardsToDraw = 1; |
0 | 7048 return 0; |
7049 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7050 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7051 //v4 = *(float *)&a1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7052 //v5 = pRenderer->uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7053 //v6 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7054 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7055 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7056 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7057 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7058 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7059 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7060 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7061 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7062 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7063 v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].z_order; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7064 if (z > *(float *)v8 ) |
0 | 7065 { |
7066 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
7067 { | |
7068 v7 = pRenderer->uNumBillboardsToDraw; | |
7069 } | |
7070 else | |
7071 { | |
7072 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
7073 { | |
7074 v9 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
7075 v10 = pRenderer->uNumBillboardsToDraw - v7; | |
7076 do | |
7077 { | |
7078 memcpy(v9, (char *)v9 - 156, 0x9Cu); | |
7079 v9 = (char *)v9 - 156; | |
7080 --v10; | |
7081 } | |
7082 while ( v10 ); | |
7083 } | |
7084 ++v7; | |
7085 } | |
7086 LABEL_23: | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7087 uNumBillboardsToDraw++; |
0 | 7088 return v7; |
7089 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7090 if (z <= *(float *)v8 ) |
0 | 7091 { |
7092 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
7093 { | |
7094 v11 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
7095 v12 = pRenderer->uNumBillboardsToDraw - v7; | |
7096 do | |
7097 { | |
7098 memcpy(v11, (char *)v11 - 156, 0x9Cu); | |
7099 v11 = (char *)v11 - 156; | |
7100 --v12; | |
7101 } | |
7102 while ( v12 ); | |
7103 } | |
7104 goto LABEL_23; | |
7105 } | |
7106 return v7; | |
7107 } | |
7108 | |
7109 | |
7110 //----- (004A1E9D) -------------------------------------------------------- | |
7111 unsigned int Render::GetBillboardDrawListSize() | |
7112 { | |
7113 return pRenderer->uNumBillboardsToDraw; | |
7114 } | |
7115 | |
7116 //----- (004A1EA3) -------------------------------------------------------- | |
7117 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
7118 { | |
7119 return pRenderer->pBillboardRenderListD3D[uBillboardID].uParentBillboardID; | |
7120 } | |
7121 | |
7122 //----- (004A1EB6) -------------------------------------------------------- | |
7123 void Render::BeginSceneD3D() | |
7124 { | |
7125 if (!uNumD3DSceneBegins++) | |
7126 { | |
7127 if (pRenderD3D) | |
7128 { | |
7129 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
7130 pRenderer->uNumBillboardsToDraw = 0; | |
7131 pRenderD3D->pDevice->BeginScene(); | |
7132 if (!pRenderD3D->DoesRaiseExceptions()) | |
7133 { | |
7134 MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0); | |
7135 } | |
7136 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
7137 uFogColor = GetLevelFogColor(); | |
7138 else | |
7139 uFogColor = 0; | |
7140 | |
7141 if ( uFogColor & 0xFF000000 ) | |
7142 { | |
7143 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
7144 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
7145 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
7146 bUsingSpecular = true; | |
7147 } | |
7148 else | |
7149 { | |
7150 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
7151 bUsingSpecular = 0; | |
7152 } | |
7153 } | |
7154 else | |
7155 { | |
7156 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
7157 if (pTargetSurface) | |
7158 field_18_locked_pitch = uTargetSurfacePitch; | |
7159 else | |
7160 --uNumD3DSceneBegins; | |
7161 } | |
7162 } | |
7163 } | |
7164 | |
7165 //----- (004A1FE1) -------------------------------------------------------- | |
7166 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
7167 { | |
7168 --uNumD3DSceneBegins; | |
7169 if (uNumD3DSceneBegins) | |
7170 return; | |
7171 | |
7172 if (pRenderD3D) | |
7173 { | |
7174 pGame->draw_debug_outlines(); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7175 DoRenderBillboards_D3D(); //Ritor1: it's temporarily |
0 | 7176 pGame->pStru6Instance->RenderSpecialEffects(); |
7177 pRenderD3D->pDevice->EndScene(); | |
7178 } | |
7179 else | |
7180 pGame->pStru6Instance->RenderSpecialEffects(); | |
7181 } | |
7182 | |
7183 | |
7184 | |
7185 //----- (004A2031) -------------------------------------------------------- | |
7186 unsigned int Render::GetActorTintColor(float a2, int a3, int a4, int a5, RenderBillboard *a6) | |
7187 { | |
7188 return ::GetActorTintColor(a3, a4, a2, a5, a6); | |
7189 } | |
7190 | |
86 | 7191 void Render::DrawTerrainPolygon(stru148 *a3, IDirect3DTexture2 *pTexture)//new function |
7192 { | |
7193 int v5; // ebx@1 | |
7194 int v6; // edi@1 | |
7195 int v8; // eax@7 | |
7196 float v9; // eax@12 | |
7197 float *v10; // esi@12 | |
7198 float v11; // ecx@14 | |
7199 double v12; // st7@14 | |
7200 double v13; // st7@14 | |
7201 double v14; // st7@14 | |
7202 signed int v15; // eax@14 | |
7203 int v16; // eax@15 | |
7204 float v17; // ST48_4@15 | |
7205 char v18; // zf@17 | |
7206 int v19; // eax@18 | |
7207 int v20; // eax@18 | |
7208 int v21; // edx@20 | |
7209 signed int v22; // ecx@20 | |
7210 int v23; // eax@20 | |
7211 const char *v24; // ST4C_4@20 | |
7212 unsigned int v25; // ST50_4@20 | |
7213 int v26; // ST54_4@20 | |
7214 int v27; // eax@20 | |
7215 _UNKNOWN *v28; // eax@21 | |
7216 int v29; // ecx@23 | |
7217 int v30; // eax@23 | |
7218 int v31; // eax@23 | |
7219 int v32; // eax@24 | |
7220 int v33; // eax@25 | |
7221 int v34; // eax@25 | |
7222 int v35; // eax@25 | |
7223 int v36; // eax@25 | |
7224 signed int v37; // ecx@26 | |
7225 int v38; // eax@26 | |
7226 _UNKNOWN *v39; // eax@27 | |
7227 int v40; // edx@28 | |
7228 int v41; // eax@29 | |
7229 int v42; // eax@29 | |
7230 int v43; // eax@29 | |
7231 int v44; // eax@29 | |
7232 unsigned int v46; // eax@29 | |
7233 int v47; // eax@30 | |
7234 int v48; // eax@30 | |
7235 int v49; // eax@30 | |
7236 double v52; // st6@35 | |
7237 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
7238 int v57; // [sp+5Ch] [bp-Ch]@3 | |
7239 signed int v59; // [sp+60h] [bp-8h]@12 | |
7240 int v61; // [sp+64h] [bp-4h]@4 | |
7241 int i; | |
7242 | |
7243 v6 = (int)this; | |
7244 v5 = 0; | |
7245 if (!this->uNumD3DSceneBegins) | |
7246 return; | |
7247 | |
7248 | |
7249 | |
7250 | |
7251 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1); | |
7252 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); | |
7253 if (this->bUsingSpecular) | |
7254 { | |
7255 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1); | |
7256 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2); | |
7257 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1); | |
7258 } | |
7259 | |
7260 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
7261 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
7262 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7263 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); | |
7264 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
7265 pVertices[0].specular = 0; | |
7266 pVertices[0].texcoord.x = array_50AC10[0].u; | |
7267 pVertices[0].texcoord.y = array_50AC10[0].v; | |
7268 | |
7269 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
7270 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
7271 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7272 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); | |
7273 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
7274 pVertices[1].specular = 0; | |
7275 pVertices[1].texcoord.x = array_50AC10[3].u; | |
7276 pVertices[1].texcoord.y = array_50AC10[3].v; | |
7277 | |
7278 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
7279 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
7280 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7281 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); | |
7282 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
7283 pVertices[2].specular = 0; | |
7284 pVertices[2].texcoord.x = array_50AC10[1].u; | |
7285 pVertices[2].texcoord.y = array_50AC10[1].v; | |
7286 | |
7287 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
7288 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
7289 | |
7290 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
7291 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
7292 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7293 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); | |
7294 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
7295 pVertices[5].specular = 0; | |
7296 pVertices[5].texcoord.x = array_50AC10[2].u; | |
7297 pVertices[5].texcoord.y = array_50AC10[2].v; | |
7298 | |
7299 | |
7300 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7301 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
7302 | |
7303 } | |
0 | 7304 //----- (004A26BC) -------------------------------------------------------- |
7305 void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, int a6, int a7) | |
7306 { | |
7307 RenderVertexSoft *pVertices; // esi@0 | |
75 | 7308 int v7; // edi@1 |
0 | 7309 unsigned int v8; // ebx@1 |
7310 LightmapBuilder *v9; // esi@3 | |
7311 unsigned int v10; // edx@3 | |
7312 int v11; // eax@5 | |
7313 int v12; // eax@11 | |
7314 char *v13; // esi@11 | |
7315 double v14; // st7@13 | |
7316 double v15; // st7@13 | |
7317 signed int v16; // eax@13 | |
7318 int v17; // ecx@13 | |
7319 double v18; // st7@13 | |
7320 float v19; // ST78_4@14 | |
7321 int v20; // eax@14 | |
7322 char v21; // zf@16 | |
7323 HRESULT v22; // eax@17 | |
7324 HRESULT v23; // eax@17 | |
7325 HRESULT v24; // eax@19 | |
7326 HRESULT v25; // eax@19 | |
7327 unsigned int v26; // ecx@19 | |
7328 char *v27; // eax@20 | |
7329 HRESULT v28; // eax@22 | |
7330 HRESULT v29; // eax@22 | |
7331 HRESULT v30; // eax@23 | |
7332 HRESULT v31; // eax@24 | |
7333 HRESULT v32; // eax@24 | |
7334 HRESULT v33; // eax@24 | |
7335 HRESULT v34; // eax@24 | |
7336 HRESULT v35; // eax@25 | |
7337 HRESULT v36; // eax@25 | |
7338 unsigned int v37; // ecx@25 | |
7339 char *v38; // eax@26 | |
7340 int v39; // edx@27 | |
7341 HRESULT v40; // eax@28 | |
7342 HRESULT v41; // eax@28 | |
7343 HRESULT v42; // eax@28 | |
7344 HRESULT v43; // eax@28 | |
7345 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
7346 unsigned int v45; // eax@28 | |
7347 HRESULT v46; // eax@29 | |
7348 HRESULT v47; // eax@29 | |
7349 HRESULT v48; // eax@29 | |
7350 IDirect3DDevice3 *v49; // eax@35 | |
7351 //IDirect3DDevice3Vtbl *v50; // ecx@35 | |
7352 int v51; // eax@40 | |
7353 char *v52; // esi@40 | |
7354 double v53; // st7@42 | |
7355 double v54; // st7@42 | |
7356 signed int v55; // eax@42 | |
7357 int v56; // ecx@42 | |
7358 double v57; // st7@42 | |
7359 float v58; // ST7C_4@43 | |
7360 int v59; // eax@43 | |
7361 signed int v60; // [sp+78h] [bp-14h]@31 | |
7362 RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
7363 const char *v62; // [sp+80h] [bp-Ch]@0 | |
7364 const char *v63; // [sp+80h] [bp-Ch]@19 | |
7365 int v64; // [sp+84h] [bp-8h]@0 | |
7366 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
7367 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
7368 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
7369 | |
75 | 7370 v7 = (int)this; |
0 | 7371 v8 = 0; |
75 | 7372 if ( !this->uNumD3DSceneBegins ) |
7373 return; | |
7374 if ( uNumVertices < 3) | |
7375 return; | |
7376 | |
7377 v61 = pVertices; | |
7378 /* v9 = pGame->pLightmapBuilder; | |
0 | 7379 v65 = v9; |
75 | 7380 v10 = v9->std__vector_000004_size;*/ |
0 | 7381 if ( byte_4D864C && pGame->uFlags & 1 ) |
7382 { | |
7383 v11 = GetActorTintColor(a4->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
75 | 7384 pGame->pLightmapBuilder->_45D74F_MessWithLight(v11, 0); |
0 | 7385 } |
7386 else | |
7387 { | |
75 | 7388 if ( a6 || !pGame->pLightmapBuilder->std__vector_000004_size || |
7389 byte_4D864C && pGame->uFlags & 2 ) | |
7390 { | |
7391 if ( (_BYTE)a7 ) | |
0 | 7392 v60 = 3; |
7393 else | |
7394 v60 = 1; | |
75 | 7395 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, v60); |
7396 if ( a6 || this->bUsingSpecular ) | |
7397 { | |
7398 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1); | |
7399 v49 = this->pRenderD3D->pDevice; | |
0 | 7400 //v50 = v49->lpVtbl; |
7401 if ( a6 ) | |
7402 { | |
75 | 7403 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 5); |
7404 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6); | |
0 | 7405 } |
7406 else | |
7407 { | |
75 | 7408 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2); |
7409 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1); | |
7410 __debugbreak;//it's error | |
0 | 7411 } |
7412 | |
7413 } | |
7414 if ( (signed int)uNumVertices > 0 ) | |
7415 { | |
7416 v51 = (int)&arary_77E5C8[0].pos.y; | |
7417 v52 = (char *)&array_50AC10[0].vWorldViewPosition; | |
7418 a7 = (int)&arary_77E5C8[0].pos.y; | |
7419 v66 = uNumVertices; | |
7420 while ( 1 ) | |
7421 { | |
7422 v53 = *(float *)v52 * 1000.0; | |
7423 *(int *)(v51 - 4) = *((int *)v52 + 3); | |
7424 v54 = v53 / (double)pOutdoorCamera->shading_dist_mist; | |
7425 *(int *)v51 = *((int *)v52 + 4); | |
7426 *(float *)(v51 + 4) = 1.0 - 1.0 / v54; | |
7427 *(float *)(v51 + 8) = 1.0 / (*(float *)v52 + 0.0000001); | |
7428 v55 = GetActorTintColor(a4->field_58, 0, *(float *)v52, 0, 0); | |
7429 v56 = a7; | |
7430 v57 = *(float *)v52; | |
7431 *(int *)(a7 + 12) = v55; | |
75 | 7432 if ( this->bUsingSpecular ) |
0 | 7433 { |
7434 v58 = v57; | |
7435 v59 = sub_47C3D7_get_fog_related_stuff(0, 0, v58); | |
7436 v56 = a7; | |
7437 } | |
7438 else | |
7439 { | |
7440 v59 = 0; | |
7441 } | |
7442 *(int *)(v56 + 16) = v59; | |
7443 *(int *)(v56 + 20) = *((int *)v52 + 6); | |
7444 *(int *)(v56 + 24) = *((int *)v52 + 7); | |
7445 v52 += 48; | |
7446 v21 = v66-- == 1; | |
7447 a7 = v56 + 32; | |
7448 if ( v21 ) | |
7449 break; | |
7450 v51 = a7; | |
7451 } | |
7452 } | |
86 | 7453 this->pRenderD3D->pDevice->SetTexture(0, a5); |
7454 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7455 arary_77E5C8, uNumVertices, 16); | |
0 | 7456 if ( a6 ) |
7457 { | |
7458 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0)); | |
7459 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u)); | |
7460 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u)); | |
7461 } | |
7462 } | |
7463 else | |
7464 { | |
7465 if ( (signed int)uNumVertices > 0 ) | |
7466 { | |
7467 v12 = (int)&arary_77E5C8[0].pos.y; | |
7468 v13 = (char *)&array_50AC10[0].vWorldViewPosition; | |
7469 a7 = (int)&arary_77E5C8[0].pos.y; | |
7470 a6a = uNumVertices; | |
7471 while ( 1 ) | |
7472 { | |
7473 v14 = *(float *)v13 * 1000.0; | |
7474 *(int *)(v12 - 4) = *((int *)v13 + 3); | |
7475 v15 = v14 / (double)pOutdoorCamera->shading_dist_mist; | |
7476 *(int *)v12 = *((int *)v13 + 4); | |
7477 *(float *)(v12 + 4) = 1.0 - 1.0 / v15; | |
7478 *(float *)(v12 + 8) = 1.0 / (*(float *)v13 + 0.0000001); | |
7479 v16 = GetActorTintColor(a4->field_58, 0, *(float *)v13, 0, 0); | |
7480 v17 = a7; | |
7481 v18 = *(float *)v13; | |
7482 *(int *)(a7 + 12) = v16; | |
75 | 7483 if ( this->bUsingSpecular ) |
0 | 7484 { |
7485 v19 = v18; | |
7486 v20 = sub_47C3D7_get_fog_related_stuff(0, 0, v19); | |
7487 v17 = a7; | |
7488 } | |
7489 else | |
7490 { | |
7491 v20 = 0; | |
7492 } | |
7493 *(int *)(v17 + 16) = v20; | |
7494 *(int *)(v17 + 20) = *((int *)v13 + 6); | |
7495 *(int *)(v17 + 24) = *((int *)v13 + 7); | |
7496 v13 += 48; | |
7497 v21 = a6a-- == 1; | |
7498 a7 = v17 + 32; | |
7499 if ( v21 ) | |
7500 break; | |
7501 v12 = a7; | |
7502 } | |
7503 } | |
7504 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
7505 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u)); | |
7506 if ( pRenderer->bUsingSpecular ) | |
7507 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0)); | |
7508 | |
7509 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
7510 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7511 D3DPT_TRIANGLEFAN, | |
7512 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7513 arary_77E5C8, | |
7514 uNumVertices, | |
7515 16)); | |
7516 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
7517 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); | |
7518 //(*(void (**)(void))(*(int *)v63 + 88))(); | |
7519 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
7520 v26 = uNumVertices; | |
7521 if ( (signed int)uNumVertices > 0 ) | |
7522 { | |
7523 v27 = (char *)&arary_77E5C8[0].diffuse; | |
7524 do | |
7525 { | |
7526 *(int *)v27 = -1; | |
7527 v27 += 32; | |
7528 --v26; | |
7529 } | |
7530 while ( v26 ); | |
7531 } | |
7532 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); | |
7533 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u)); | |
7534 if ( !pRenderer->bUsingSpecular ) | |
7535 { | |
7536 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
7537 } | |
7538 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u)); | |
7539 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 1u)); | |
7540 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3u)); | |
7541 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7542 D3DPT_TRIANGLEFAN, | |
7543 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7544 arary_77E5C8, | |
7545 uNumVertices, | |
7546 16)); | |
7547 if ( pRenderer->bUsingSpecular ) | |
7548 { | |
7549 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
7550 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
7551 v37 = uNumVertices; | |
7552 if ( (signed int)uNumVertices > 0 ) | |
7553 { | |
7554 v38 = (char *)&arary_77E5C8[0].specular; | |
7555 do | |
7556 { | |
7557 v39 = *(int *)v38; | |
7558 *(int *)v38 = 0; | |
7559 v38 += 32; | |
7560 --v37; | |
7561 *((int *)v38 - 9) = pRenderer->uFogColor | v39 & 0xFF000000; | |
7562 } | |
7563 while ( v37 ); | |
7564 } | |
75 | 7565 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
0 | 7566 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 6u)); |
7567 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 5u)); | |
7568 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7569 D3DPT_TRIANGLEFAN, | |
7570 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7571 arary_77E5C8, | |
7572 uNumVertices, | |
7573 16)); | |
7574 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1)); | |
7575 //v44 = pRenderer->pRenderD3D->pDevice; | |
7576 v45 = GetLevelFogColor(); | |
7577 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
7578 v8 = 0; | |
7579 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
7580 } | |
7581 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2)); | |
7582 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u)); | |
7583 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); | |
7584 } | |
7585 } | |
7586 if ( pIndoorCamera->field_4C & 2 || pBLVRenderParams->uFlags & 2 ) | |
7587 pGame->pIndoorCameraD3D->debug_outline_d3d(arary_77E5C8, uNumVertices, 0xFFFFFFu, 0.0); | |
7588 } | |
75 | 7589 |
0 | 7590 // 4A26BC: could not find valid save-restore pair for esi |
7591 // 4D864C: using guessed type char byte_4D864C; | |
7592 | |
7593 //----- (004A2DA3) -------------------------------------------------------- | |
67 | 7594 void Render::DrawStrip(unsigned int uNumVertices, struct stru148 *a3, IDirect3DTexture2 *pTexture) |
7595 { | |
7596 int v4; // ebx@1 | |
7597 int v7; // eax@7 | |
7598 float v12; // ST3C_4@8 | |
7599 int i; | |
7600 | |
7601 v4 = (int)this; | |
7602 if (!this->uNumD3DSceneBegins) | |
7603 return; | |
7604 | |
7605 if (uNumVertices >= 3) | |
7606 { | |
7607 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1); | |
7608 if (this->bUsingSpecular) | |
7609 { | |
7610 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1); | |
7611 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2); | |
7612 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1); | |
7613 } | |
7614 | |
7615 for (i = 0; i < uNumVertices; ++i) | |
7616 { | |
7617 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
7618 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
7619 pVertices[i].pos.z = 0.99989998; | |
7620 pVertices[i].rhw = array_50AC10[i].flt_20; | |
7621 | |
7622 pVertices[i].diffuse = GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); | |
7623 v7 = 0; | |
7624 if (this->bUsingSpecular) | |
7625 { | |
7626 v12 = array_50AC10[i].vWorldViewPosition.x; | |
7627 v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v12); | |
7628 } | |
7629 pVertices[i].specular = v7; | |
7630 pVertices[i].texcoord.x = array_50AC10[i].u; | |
7631 pVertices[i].texcoord.y = array_50AC10[i].v; | |
7632 } | |
7633 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7634 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); | |
7635 } | |
7636 } | |
7637 //----- (004A2DA3) -------------------------------------------------------- | |
7638 void Render::DrawFan(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *pTexture) | |
7639 { | |
7640 int v4; // ebx@1 | |
7641 int v7; // eax@7 | |
0 | 7642 float v13; // ST3C_4@8 |
67 | 7643 int i; |
7644 | |
7645 v4 = (int)this; | |
7646 if ( !this->uNumD3DSceneBegins ) | |
7647 return; | |
7648 if ( uNumVertices >= 3 ) | |
7649 { | |
7650 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1); | |
7651 if ( this->bUsingSpecular ) | |
7652 { | |
7653 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1); | |
7654 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2); | |
7655 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1); | |
7656 } | |
7657 for (i = 0; i < uNumVertices; ++i) | |
7658 { | |
7659 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
7660 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
7661 pVertices[i].pos.z = 0.99989998; | |
7662 pVertices[i].rhw = array_50AC10[i].flt_20; | |
7663 | |
7664 pVertices[i].diffuse = GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); | |
7665 v7 = 0; | |
7666 if (this->bUsingSpecular) | |
7667 { | |
7668 v13 = array_50AC10[i].vWorldViewPosition.x; | |
7669 v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v13); | |
7670 } | |
7671 pVertices[i].specular = v7; | |
7672 pVertices[i].texcoord.x = array_50AC10[i].u; | |
7673 pVertices[i].texcoord.y = array_50AC10[i].v; | |
7674 } | |
7675 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7676 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7677 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); | |
0 | 7678 } |
7679 } | |
7680 | |
7681 | |
7682 //----- (004A2ED5) -------------------------------------------------------- | |
7683 void Render::_4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex) | |
7684 { | |
7685 signed int v4; // edi@2 | |
7686 int v5; // eax@3 | |
7687 int v6; // edx@5 | |
7688 char *v7; // eax@6 | |
7689 char *v8; // ecx@6 | |
7690 double v9; // st6@7 | |
7691 int v10; // ebx@7 | |
7692 int v11; // ebx@7 | |
7693 | |
7694 if ( this->uNumD3DSceneBegins ) | |
7695 { | |
7696 v4 = a2; | |
7697 if ( a2 >= 3 ) | |
7698 { | |
7699 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u)); | |
7700 v5 = 31 - (a3->field_58 & 0x1F); | |
7701 if ( v5 < pOutdoor->field_CBC_terrain_triangles_shade_type ) | |
7702 v5 = pOutdoor->field_CBC_terrain_triangles_shade_type; | |
7703 v6 = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); | |
7704 if ( a2 > 0 ) | |
7705 { | |
7706 v7 = (char *)&arary_77E5C8[0].pos.y; | |
7707 v8 = (char *)&array_507D30[0].vWorldViewProjY; | |
7708 do | |
7709 { | |
7710 v9 = *((float *)v8 - 4) * 0.061758894; | |
7711 v10 = *((int *)v8 - 1); | |
7712 *((int *)v7 + 4) = 0; | |
7713 *((int *)v7 - 1) = v10; | |
7714 *(int *)v7 = *(int *)v8; | |
7715 *((int *)v7 + 2) = *((int *)v8 + 1); | |
7716 *((int *)v7 + 5) = *((int *)v8 + 2); | |
7717 v11 = *((int *)v8 + 3); | |
7718 *((int *)v7 + 3) = v6; | |
7719 *((int *)v7 + 6) = v11; | |
7720 v8 += 48; | |
7721 v7 += 32; | |
7722 --v4; | |
7723 *((float *)v7 - 7) = 1.0 - 1.0 / v9; | |
7724 } | |
7725 while ( v4 ); | |
7726 } | |
7727 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); | |
7728 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7729 D3DPT_TRIANGLEFAN, | |
7730 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7731 arary_77E5C8, | |
7732 a2, | |
7733 28)); | |
7734 } | |
7735 } | |
7736 } | |
7737 | |
7738 | |
7739 | |
7740 //----- (004A2FC0) -------------------------------------------------------- | |
7741 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
7742 { | |
7743 //Render *v8; // edi@1 | |
7744 //unsigned int v9; // esi@3 | |
7745 char *v12; // ecx@9 | |
7746 char *v13; // eax@9 | |
7747 double v14; // st6@10 | |
7748 int v15; // edx@10 | |
7749 Texture *v16; // edx@10 | |
7750 double v17; // st6@10 | |
7751 //char v18; // zf@10 | |
7752 Texture *v19; // edx@10 | |
7753 Texture *v23; // edx@16 | |
7754 char *v24; // ecx@16 | |
7755 char *v25; // eax@16 | |
7756 double v26; // st6@17 | |
7757 int v27; // esi@17 | |
7758 double v28; // st6@17 | |
7759 unsigned int v33; // ecx@18 | |
7760 char *v34; // eax@19 | |
7761 //Texture *v45; // edx@23 | |
7762 //char *v46; // ecx@23 | |
7763 //char *v47; // eax@23 | |
7764 //double v48; // st6@24 | |
7765 //int v49; // esi@24 | |
7766 //double v50; // st6@24 | |
7767 const char *v53; // [sp-Ch] [bp-20h]@21 | |
7768 //int v54; // [sp-8h] [bp-1Ch]@21 | |
7769 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
7770 const char *v56; // [sp+0h] [bp-14h]@0 | |
7771 int v57; // [sp+4h] [bp-10h]@0 | |
7772 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
7773 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
7774 //int a3a; // [sp+10h] [bp-4h]@4 | |
7775 | |
7776 //v8 = this; | |
7777 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
7778 return; | |
7779 | |
7780 //auto a3 = pFace; | |
7781 //auto a6 = uPackedID; | |
7782 //v59 = pGame->pLightmapBuilder; | |
7783 //v9 = v59->std__vector_000004_size; | |
7784 | |
7785 auto uCorrectedColor = uColor; | |
7786 if (pGame->pLightmapBuilder->std__vector_000004_size) | |
7787 uCorrectedColor = 0xFFFFFFFF; | |
7788 pGame->AlterGamma(pFace, &uCorrectedColor); | |
7789 | |
7790 if (byte_4D864C && pGame->uFlags & 1) | |
7791 { | |
7792 __debugbreak(); | |
7793 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
7794 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); | |
7795 if ( (signed int)uNumVertices > 0 ) | |
7796 { | |
7797 v12 = (char *)&array_507D30[0].vWorldViewPosition; | |
7798 v13 = (char *)&arary_77E5C8[0].pos.y; | |
7799 auto a7 = uNumVertices; | |
7800 uint v18; | |
7801 do | |
7802 { | |
7803 v14 = *(float *)v12 * 0.061758894; | |
7804 v15 = *((int *)v12 + 3); | |
7805 *((int *)v13 + 4) = 0; | |
7806 *((int *)v13 - 1) = v15; | |
7807 *(int *)v13 = *((int *)v12 + 4); | |
7808 *((int *)v13 + 3) = uCorrectedColor; | |
7809 v16 = pTex; | |
7810 v13 += 32; | |
7811 *((float *)v13 - 7) = 1.0 - 1.0 / v14; | |
7812 v17 = 1.0 / *(float *)v12; | |
7813 v12 += 48; | |
7814 v18 = a7-- == 1; | |
7815 *((float *)v13 - 6) = v17; | |
7816 pHwTex = (IDirect3DTexture2 *)v16->uTextureWidth; | |
7817 v19 = pTex; | |
7818 *((float *)v13 - 3) = *((float *)v12 - 6) / (double)(signed int)pHwTex; | |
7819 pHwTex = (IDirect3DTexture2 *)v19->uTextureHeight; | |
7820 *((float *)v13 - 2) = *((float *)v12 - 5) / (double)(signed int)pHwTex; | |
7821 } | |
7822 while ( !v18 ); | |
7823 } | |
7824 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); | |
7825 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
7826 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7827 D3DPT_TRIANGLEFAN, | |
7828 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7829 arary_77E5C8, | |
7830 uNumVertices, | |
7831 28)); | |
7832 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
7833 } | |
7834 else | |
7835 { | |
7836 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
7837 byte_4D864C && pGame->uFlags & 2) | |
7838 { | |
7839 for (uint i = 0; i < uNumVertices; ++i) | |
7840 { | |
7841 arary_77E5C8[i].pos.x = array_507D30[i].vWorldViewProjX; | |
7842 arary_77E5C8[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7843 arary_77E5C8[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
7844 arary_77E5C8[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
7845 arary_77E5C8[i].diffuse = uCorrectedColor; | |
7846 arary_77E5C8[i].specular = 0; | |
7847 arary_77E5C8[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
7848 arary_77E5C8[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
7849 } | |
7850 | |
7851 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); | |
7852 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); | |
7853 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
7854 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7855 arary_77E5C8, | |
7856 uNumVertices, | |
7857 28)); | |
7858 } | |
7859 else | |
7860 { | |
7861 __debugbreak(); | |
7862 if ( (signed int)uNumVertices > 0 ) | |
7863 { | |
7864 v23 = pTex; | |
7865 v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
7866 v25 = (char *)&arary_77E5C8[0].pos.y; | |
7867 pTex = (Texture *)uNumVertices; | |
7868 uint v18; | |
7869 do | |
7870 { | |
7871 v26 = *(float *)v24 * 0.061758894; | |
7872 v27 = *((int *)v24 + 3); | |
7873 *((int *)v25 + 4) = 0; | |
7874 *((int *)v25 - 1) = v27; | |
7875 *(int *)v25 = *((int *)v24 + 4); | |
7876 *((int *)v25 + 3) = uColor; | |
7877 v25 += 32; | |
7878 *((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
7879 v28 = 1.0 / *(float *)v24; | |
7880 v24 += 48; | |
7881 v18 = pTex == (Texture *)1; | |
7882 pTex = (Texture *)((char *)pTex - 1); | |
7883 *((float *)v25 - 6) = v28; | |
7884 //a3 = (BLVFace *)v23->uTextureWidth; | |
7885 *((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; | |
7886 //a3 = (BLVFace *)v23->uTextureHeight; | |
7887 *((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; | |
7888 } | |
7889 while ( !v18 ); | |
7890 } | |
7891 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
7892 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); | |
7893 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
7894 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7895 D3DPT_TRIANGLEFAN, | |
7896 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7897 arary_77E5C8, | |
7898 uNumVertices, | |
7899 28)); | |
7900 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); | |
7901 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
7902 v33 = uNumVertices; | |
7903 if ( (signed int)uNumVertices > 0 ) | |
7904 { | |
7905 v34 = (char *)&arary_77E5C8[0].diffuse; | |
7906 do | |
7907 { | |
7908 *(int *)v34 = uCorrectedColor; | |
7909 v34 += 32; | |
7910 --v33; | |
7911 } | |
7912 while ( v33 ); | |
7913 } | |
7914 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); | |
7915 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); | |
7916 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
7917 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, true)); | |
7918 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 1)); | |
7919 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3)); | |
7920 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7921 D3DPT_TRIANGLEFAN, | |
7922 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
7923 arary_77E5C8, | |
7924 uNumVertices, | |
7925 28)); | |
7926 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2)); | |
7927 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1)); | |
7928 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, false)); | |
7929 } | |
7930 } | |
7931 } | |
7932 // 4D864C: using guessed type char byte_4D864C; | |
7933 | |
7934 | |
7935 //----- (004A43B1) -------------------------------------------------------- | |
7936 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int uPaletteSubindex) | |
7937 { | |
7938 RenderBillboardTransform_local0 *v4; // ebx@2 | |
7939 double v5; // st7@2 | |
7940 float v6; // ST08_4@2 | |
7941 unsigned int v7; // eax@2 | |
7942 int v8; // ecx@2 | |
7943 unsigned int v9; // esi@2 | |
7944 Sprite *v10; // edi@5 | |
7945 signed int v11; // eax@9 | |
7946 signed int v12; // eax@9 | |
7947 double v13; // st7@12 | |
7948 double v14; // st6@12 | |
7949 double v15; // st5@12 | |
7950 double v16; // st4@12 | |
7951 double v17; // st3@12 | |
7952 double v18; // st2@12 | |
7953 int v19; // ecx@14 | |
7954 double v20; // st3@14 | |
7955 int v21; // ecx@16 | |
7956 double v22; // st3@16 | |
7957 IDirect3DTexture2 *v23; // eax@18 | |
7958 signed int v24; // [sp+18h] [bp-18h]@5 | |
7959 signed int v25; // [sp+1Ch] [bp-14h]@5 | |
7960 Render *v26; // [sp+20h] [bp-10h]@1 | |
7961 float v27; // [sp+24h] [bp-Ch]@5 | |
7962 int v28; // [sp+28h] [bp-8h]@2 | |
7963 float v29; // [sp+2Ch] [bp-4h]@5 | |
7964 float pSoftBillboarda; // [sp+38h] [bp+8h]@2 | |
7965 float v31; // [sp+3Ch] [bp+Ch]@5 | |
7966 float v32; // [sp+3Ch] [bp+Ch]@12 | |
7967 float a1; // [sp+40h] [bp+10h]@5 | |
7968 | |
7969 v26 = this; | |
7970 if ( this->uNumD3DSceneBegins ) | |
7971 { | |
7972 v4 = pSoftBillboard; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7973 v5 = (double)pSoftBillboard->zbuffer_depth; |
0 | 7974 pSoftBillboarda = v5; |
7975 v6 = v5; | |
7976 v7 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v6)); | |
7977 v8 = uPaletteSubindex; | |
7978 v9 = v7; | |
7979 v28 = uPaletteSubindex & 0xFF000000; | |
7980 if ( uPaletteSubindex & 0xFF000000 ) | |
7981 pBillboardRenderListD3D[v9].uOpacity = RenderBillboardD3D::Opaque_3; | |
7982 else | |
7983 pBillboardRenderListD3D[v9].uOpacity = RenderBillboardD3D::Transparent; | |
7984 v10 = a3; | |
7985 pBillboardRenderListD3D[v9].field_90 = v4->field_44; | |
7986 pBillboardRenderListD3D[v9].sZValue = v4->sZValue; | |
7987 pBillboardRenderListD3D[v9].uParentBillboardID = v4->uParentBillboardID; | |
7988 v25 = v4->uScreenSpaceX; | |
7989 v24 = v4->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7990 a1 = (v4->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(v4->_screenspace_x_scaler_packedfloat); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7991 v29 = (v4->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(v4->_screenspace_y_scaler_packedfloat); |
0 | 7992 v31 = (double)((v10->uBufferWidth >> 1) - v10->uAreaX); |
7993 v27 = (double)(v10->uBufferHeight - v10->uAreaY); | |
7994 if ( v4->uFlags & 4 ) | |
7995 v31 = v31 * -1.0; | |
7996 if ( v4->uTintColor && v26->bTinting ) | |
7997 { | |
7998 v11 = GetActorTintColor(v8, 0, pSoftBillboarda, 0, 0); | |
7999 v12 = sub_4A19D8(v4->uTintColor, v11); | |
8000 if ( v28 ) | |
8001 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
8002 } | |
8003 else | |
8004 { | |
8005 v12 = GetActorTintColor(v8, 0, pSoftBillboarda, 0, 0); | |
8006 } | |
8007 v13 = (double)v25; | |
8008 pBillboardRenderListD3D[v9].pQuards[0].specular = 0; | |
8009 pBillboardRenderListD3D[v9].pQuards[0].diffuse = v12; | |
8010 pBillboardRenderListD3D[v9].pQuards[0].pos.x = v13 - v31 * a1; | |
8011 v14 = (double)v24; | |
8012 v32 = v14; | |
8013 pBillboardRenderListD3D[v9].pQuards[0].pos.y = v14 - v27 * v29; | |
8014 v15 = 1.0 - 1.0 / (pSoftBillboarda * 0.061758894); | |
8015 pBillboardRenderListD3D[v9].pQuards[0].pos.z = v15; | |
8016 v16 = 1.0 / pSoftBillboarda; | |
8017 pBillboardRenderListD3D[v9].pQuards[0].rhw = 1.0 / pSoftBillboarda; | |
8018 pBillboardRenderListD3D[v9].pQuards[0].texcoord.x = 0.0; | |
8019 pBillboardRenderListD3D[v9].pQuards[0].texcoord.y = 0.0; | |
8020 v17 = (double)((v10->uBufferWidth >> 1) - v10->uAreaX); | |
8021 v18 = (double)(v10->uBufferHeight - v10->uAreaY - v10->uAreaHeight); | |
8022 if ( v4->uFlags & 4 ) | |
8023 v17 = v17 * -1.0; | |
8024 pBillboardRenderListD3D[v9].pQuards[1].specular = 0; | |
8025 pBillboardRenderListD3D[v9].pQuards[1].diffuse = v12; | |
8026 pBillboardRenderListD3D[v9].pQuards[1].pos.x = v13 - v17 * a1; | |
8027 pBillboardRenderListD3D[v9].pQuards[1].pos.y = v32 - v18 * v29; | |
8028 pBillboardRenderListD3D[v9].pQuards[1].pos.z = v15; | |
8029 pBillboardRenderListD3D[v9].pQuards[1].rhw = v16; | |
8030 pBillboardRenderListD3D[v9].pQuards[1].texcoord.x = 0.0; | |
8031 pBillboardRenderListD3D[v9].pQuards[1].texcoord.y = 1.0; | |
8032 v19 = v10->uBufferHeight - v10->uAreaY - v10->uAreaHeight; | |
8033 v20 = (double)(v10->uAreaX + v10->uAreaWidth + (v10->uBufferWidth >> 1) - v10->uBufferWidth); | |
8034 if ( v4->uFlags & 4 ) | |
8035 v20 = v20 * -1.0; | |
8036 pBillboardRenderListD3D[v9].pQuards[2].specular = 0; | |
8037 pBillboardRenderListD3D[v9].pQuards[2].diffuse = v12; | |
8038 pBillboardRenderListD3D[v9].pQuards[2].pos.x = v20 * a1 + v13; | |
8039 pBillboardRenderListD3D[v9].pQuards[2].pos.y = v32 - (double)v19 * v29; | |
8040 pBillboardRenderListD3D[v9].pQuards[2].pos.z = v15; | |
8041 pBillboardRenderListD3D[v9].pQuards[2].rhw = v16; | |
8042 pBillboardRenderListD3D[v9].pQuards[2].texcoord.x = 1.0; | |
8043 pBillboardRenderListD3D[v9].pQuards[2].texcoord.y = 1.0; | |
8044 v21 = v10->uBufferHeight - v10->uAreaY; | |
8045 v22 = (double)(v10->uAreaX + v10->uAreaWidth + (v10->uBufferWidth >> 1) - v10->uBufferWidth); | |
8046 if ( v4->uFlags & 4 ) | |
8047 v22 = v22 * -1.0; | |
8048 pBillboardRenderListD3D[v9].pQuards[3].specular = 0; | |
8049 pBillboardRenderListD3D[v9].pQuards[3].diffuse = v12; | |
8050 pBillboardRenderListD3D[v9].pQuards[3].pos.x = v22 * a1 + v13; | |
8051 pBillboardRenderListD3D[v9].pQuards[3].pos.y = v32 - (double)v21 * v29; | |
8052 pBillboardRenderListD3D[v9].pQuards[3].pos.z = v15; | |
8053 pBillboardRenderListD3D[v9].pQuards[3].rhw = v16; | |
8054 pBillboardRenderListD3D[v9].pQuards[3].texcoord.x = 1.0; | |
8055 pBillboardRenderListD3D[v9].pQuards[3].texcoord.y = 0.0; | |
8056 v23 = v10->pTexture; | |
8057 pBillboardRenderListD3D[v9].uNumVertices = 4; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8058 pBillboardRenderListD3D[v9].z_order = pSoftBillboarda; |
0 | 8059 pBillboardRenderListD3D[v9].pTexture = v23; |
8060 } | |
8061 } | |
8062 | |
8063 | |
8064 | |
8065 //----- (004A354F) -------------------------------------------------------- | |
8066 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
8067 { | |
8068 double v5; // st7@3 | |
8069 float v6; // ST20_4@3 | |
8070 float v7; // ST00_4@3 | |
8071 unsigned int v8; // esi@3 | |
8072 int v9; // eax@3 | |
8073 int v10; // ebx@3 | |
8074 float v11; // ST28_4@3 | |
8075 double v12; // st7@3 | |
8076 float v13; // ST24_4@3 | |
8077 double v14; // st6@3 | |
8078 float v15; // ST1C_4@3 | |
8079 float v16; // ST2C_4@3 | |
8080 float v17; // ST30_4@3 | |
8081 signed int v18; // ST18_4@3 | |
8082 signed int v19; // ST14_4@3 | |
8083 signed int v20; // ST10_4@3 | |
8084 signed int v21; // eax@3 | |
8085 double v22; // st6@3 | |
8086 float v23; // ST2C_4@3 | |
8087 float v24; // ST30_4@3 | |
8088 signed int v25; // ST10_4@3 | |
8089 signed int v26; // ST14_4@3 | |
8090 signed int v27; // ST18_4@3 | |
8091 signed int v28; // eax@3 | |
8092 double v29; // st6@3 | |
8093 float v30; // ecx@3 | |
8094 float v31; // ST2C_4@3 | |
8095 float v32; // ST30_4@3 | |
8096 signed int v33; // ST10_4@3 | |
8097 signed int v34; // ST14_4@3 | |
8098 signed int v35; // ST18_4@3 | |
8099 signed int v36; // eax@3 | |
8100 float v37; // ecx@3 | |
8101 double v38; // st6@3 | |
8102 float v39; // ST2C_4@3 | |
8103 float v40; // ST30_4@3 | |
8104 signed int v41; // ST10_4@3 | |
8105 signed int v42; // ST14_4@3 | |
8106 signed int v43; // ST18_4@3 | |
8107 signed int v44; // eax@3 | |
8108 double v45; // st6@3 | |
8109 float v46; // eax@3 | |
8110 | |
8111 if ( this->uNumD3DSceneBegins ) | |
8112 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8113 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8114 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8115 v5 = (double)a2->zbuffer_depth; |
0 | 8116 v6 = v5; |
8117 v7 = v5; | |
8118 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
8119 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | |
8120 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
8121 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
8122 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
8123 v9 = a2->uScreenSpaceX; | |
8124 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8125 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 8126 v12 = (double)v9; |
8127 v13 = v12; | |
8128 v14 = (double)(v10 - 12); | |
8129 v15 = v14; | |
8130 v16 = (double)(v9 - 12) - v12; | |
8131 v17 = (double)(v10 - 25) - v14; | |
8132 v18 = stru_5C6E00->SinCos(angle); | |
8133 v19 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); | |
8134 v20 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); | |
8135 v21 = stru_5C6E00->SinCos(angle); | |
8136 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 | |
8137 + (double)(v18 >> 16)) | |
8138 * v16 | |
8139 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
8140 + (double)(v19 >> 16)) | |
8141 * v17) | |
8142 * v11 + v13; | |
8143 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 | |
8144 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
8145 - 12.0) | |
8146 * v11 | |
8147 + (double)a2->uScreenSpaceY; | |
8148 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; | |
8149 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; | |
8150 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v22; | |
8151 pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (v6 * 0.061758894); | |
8152 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / v6; | |
8153 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; | |
8154 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; | |
8155 v31 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8156 v32 = (double)a2->uScreenSpaceY - v15; | |
8157 v25 = stru_5C6E00->SinCos(angle); | |
8158 v26 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); | |
8159 v27 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); | |
8160 v28 = stru_5C6E00->SinCos(angle); | |
8161 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 | |
8162 + (double)(v25 >> 16)) | |
8163 * v23 | |
8164 - ((double)(unsigned __int16)v26 * 0.000015259022 | |
8165 + (double)(v26 >> 16)) | |
8166 * v24) | |
8167 * v11 + v13; | |
8168 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v24 | |
8169 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v23 | |
8170 - 12.0) | |
8171 * v11 | |
8172 + (double)a2->uScreenSpaceY; | |
8173 pBillboardRenderListD3D[v8].pQuards[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8174 v30 = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8175 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v29; | |
8176 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; | |
8177 pBillboardRenderListD3D[v8].pQuards[1].rhw = v30; | |
8178 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; | |
8179 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; | |
8180 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
8181 v23 = (double)(a2->uScreenSpaceX - 12) - v13; | |
8182 v24 = (double)a2->uScreenSpaceY - v15; | |
8183 v33 = stru_5C6E00->SinCos(angle); | |
8184 v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); | |
8185 v35 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); | |
8186 v36 = stru_5C6E00->SinCos(angle); | |
8187 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 | |
8188 + (double)(v33 >> 16)) | |
8189 * v31 | |
8190 - ((double)(unsigned __int16)v34 * 0.000015259022 | |
8191 + (double)(v34 >> 16)) | |
8192 * v32) | |
8193 * v11 + v13; | |
8194 v37 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8195 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v32 | |
8196 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v31 | |
8197 - 12.0) | |
8198 * v11 | |
8199 + (double)a2->uScreenSpaceY; | |
8200 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; | |
8201 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v37; | |
8202 pBillboardRenderListD3D[v8].pQuards[2].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8203 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; | |
8204 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v38; | |
8205 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; | |
8206 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
8207 v39 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8208 v40 = (double)(a2->uScreenSpaceY - 25) - v15; | |
8209 v41 = stru_5C6E00->SinCos(angle); | |
8210 v42 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); | |
8211 v43 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); | |
8212 v44 = stru_5C6E00->SinCos(angle); | |
8213 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 | |
8214 + (double)(v41 >> 16)) | |
8215 * v39 | |
8216 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
8217 + (double)(v42 >> 16)) | |
8218 * v40) | |
8219 * v11 + v13; | |
8220 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
8221 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
8222 - 12.0) | |
8223 * v11 | |
8224 + (double)a2->uScreenSpaceY; | |
8225 v46 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8226 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; | |
8227 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v46; | |
8228 pBillboardRenderListD3D[v8].pQuards[3].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8229 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; | |
8230 pBillboardRenderListD3D[v8].pTexture = a3; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8231 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 8232 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8233 pBillboardRenderListD3D[v8].pQuards[3].pos.y = v45; | |
8234 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; | |
8235 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
8236 } | |
8237 } | |
8238 } | |
8239 | |
8240 | |
8241 //----- (004A3AD9) -------------------------------------------------------- | |
8242 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
8243 { | |
8244 double v5; // st7@2 | |
8245 float v6; // ST28_4@2 | |
8246 float v7; // ST00_4@2 | |
8247 unsigned int v8; // esi@2 | |
8248 int v9; // eax@2 | |
8249 int v10; // ebx@2 | |
8250 float v11; // ST34_4@2 | |
8251 double v12; // st7@2 | |
8252 float v13; // ST2C_4@2 | |
8253 double v14; // st6@2 | |
8254 float v15; // ST24_4@2 | |
8255 float v16; // ST38_4@2 | |
8256 float v17; // ST3C_4@2 | |
8257 signed int v18; // ST1C_4@2 | |
8258 int v19; // ST30_4@2 | |
8259 signed int v20; // ST20_4@2 | |
8260 signed int v21; // ST18_4@2 | |
8261 signed int v22; // eax@2 | |
8262 double v23; // st6@2 | |
8263 float v24; // ST20_4@2 | |
8264 float v25; // ST1C_4@2 | |
8265 float v26; // ST38_4@2 | |
8266 float v27; // ST3C_4@2 | |
8267 signed int v28; // ST18_4@2 | |
8268 signed int v29; // ST14_4@2 | |
8269 signed int v30; // ST10_4@2 | |
8270 signed int v31; // eax@2 | |
8271 double v32; // st6@2 | |
8272 float v33; // ST38_4@2 | |
8273 float v34; // ST3C_4@2 | |
8274 signed int v35; // ST10_4@2 | |
8275 signed int v36; // ST14_4@2 | |
8276 signed int v37; // ST18_4@2 | |
8277 signed int v38; // eax@2 | |
8278 double v39; // st6@2 | |
8279 float v40; // ST38_4@2 | |
8280 float v41; // ST3C_4@2 | |
8281 signed int v42; // ST10_4@2 | |
8282 signed int v43; // ST14_4@2 | |
8283 signed int v44; // ST18_4@2 | |
8284 signed int v45; // eax@2 | |
8285 double v46; // st6@2 | |
8286 | |
8287 if ( this->uNumD3DSceneBegins ) | |
8288 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8289 v5 = (double)a2->zbuffer_depth; |
0 | 8290 v6 = v5; |
8291 v7 = v5; | |
8292 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
8293 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | |
8294 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
8295 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
8296 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
8297 v9 = a2->uScreenSpaceX; | |
8298 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8299 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 8300 v12 = (double)v9; |
8301 v13 = v12; | |
8302 v14 = (double)(v10 - 12); | |
8303 v15 = v14; | |
8304 v16 = (double)(v9 - 12) - v12; | |
8305 v17 = (double)(v10 - 25) - v14; | |
8306 v18 = stru_5C6E00->SinCos(angle); | |
8307 v19 = angle - stru_5C6E00->uIntegerHalfPi; | |
8308 v20 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); | |
8309 v21 = stru_5C6E00->SinCos(v19); | |
8310 v22 = stru_5C6E00->SinCos(angle); | |
8311 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 | |
8312 + (double)(v18 >> 16)) | |
8313 * v16 | |
8314 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
8315 + (double)(v20 >> 16)) | |
8316 * v17) | |
8317 * v11 + v13; | |
8318 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
8319 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
8320 - 12.0) | |
8321 * v11 | |
8322 + (double)a2->uScreenSpaceY; | |
8323 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; | |
8324 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; | |
8325 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v23; | |
8326 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
8327 pBillboardRenderListD3D[v8].pQuards[0].pos.z = v24; | |
8328 v25 = 1.0 / v6; | |
8329 pBillboardRenderListD3D[v8].pQuards[0].rhw = v25; | |
8330 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; | |
8331 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; | |
8332 v26 = (double)(a2->uScreenSpaceX - 12) - v13; | |
8333 v27 = (double)a2->uScreenSpaceY - v15; | |
8334 v28 = stru_5C6E00->SinCos(angle); | |
8335 v29 = stru_5C6E00->SinCos(v19); | |
8336 v30 = stru_5C6E00->SinCos(v19); | |
8337 v31 = stru_5C6E00->SinCos(angle); | |
8338 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 | |
8339 + (double)(v28 >> 16)) | |
8340 * v26 | |
8341 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
8342 + (double)(v29 >> 16)) | |
8343 * v27) | |
8344 * v11 + v13; | |
8345 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
8346 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
8347 - 12.0) | |
8348 * v11 | |
8349 + (double)a2->uScreenSpaceY; | |
8350 pBillboardRenderListD3D[v8].pQuards[1].pos.z = v24; | |
8351 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v32; | |
8352 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; | |
8353 pBillboardRenderListD3D[v8].pQuards[1].rhw = v25; | |
8354 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; | |
8355 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; | |
8356 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
8357 v33 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8358 v34 = (double)a2->uScreenSpaceY - v15; | |
8359 v35 = stru_5C6E00->SinCos(angle); | |
8360 v36 = stru_5C6E00->SinCos(v19); | |
8361 v37 = stru_5C6E00->SinCos(v19); | |
8362 v38 = stru_5C6E00->SinCos(angle); | |
8363 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 | |
8364 + (double)(v35 >> 16)) | |
8365 * v33 | |
8366 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
8367 + (double)(v36 >> 16)) | |
8368 * v34) | |
8369 * v11 + v13; | |
8370 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
8371 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
8372 - 12.0) | |
8373 * v11 | |
8374 + (double)a2->uScreenSpaceY; | |
8375 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; | |
8376 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v24; | |
8377 pBillboardRenderListD3D[v8].pQuards[2].rhw = v25; | |
8378 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; | |
8379 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v39; | |
8380 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; | |
8381 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
8382 v40 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8383 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
8384 v42 = stru_5C6E00->SinCos(angle); | |
8385 v43 = stru_5C6E00->SinCos(v19); | |
8386 v44 = stru_5C6E00->SinCos(v19); | |
8387 v45 = stru_5C6E00->SinCos(angle); | |
8388 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 | |
8389 + (double)(v42 >> 16)) | |
8390 * v40 | |
8391 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
8392 + (double)(v43 >> 16)) | |
8393 * v41) | |
8394 * v11 + v13; | |
8395 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
8396 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
8397 - 12.0) | |
8398 * v11 | |
8399 + (double)a2->uScreenSpaceY; | |
8400 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; | |
8401 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v24; | |
8402 pBillboardRenderListD3D[v8].pQuards[3].rhw = v25; | |
8403 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; | |
8404 pBillboardRenderListD3D[v8].pTexture = a3; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8405 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 8406 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8407 pBillboardRenderListD3D[v8].pQuards[3].pos.y = v46; | |
8408 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; | |
8409 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
8410 } | |
8411 } | |
8412 | |
8413 | |
8414 //----- (004A4023) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8415 void Render::TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int paletteSubindex, RenderBillboard *pBillboard) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8416 { |
0 | 8417 unsigned int v8; // esi@2 |
8418 double v14; // st6@14 | |
8419 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8420 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8421 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8422 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8423 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8424 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8425 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8426 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8427 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8428 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8429 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 8430 float v29; // [sp+28h] [bp-8h]@5 |
8431 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8432 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8433 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8434 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8435 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8436 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8437 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8438 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8439 v30 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8440 v29 = (a2->_screenspace_y_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_y_scaler_packedfloat); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8441 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8442 unsigned int diffuse = GetActorTintColor(paletteSubindex, 0, a2->zbuffer_depth, 0, pBillboard); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8443 if (a2->uTintColor & 0x00FFFFFF && bTinting) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8444 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8445 diffuse = sub_4A19D8(a2->uTintColor, diffuse); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8446 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8447 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8448 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8449 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8450 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8451 if (bUsingSpecular) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8452 specular = sub_47C3D7_get_fog_related_stuff(0, 0, a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8453 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8454 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8455 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8456 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8457 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8458 pBillboardRenderListD3D[v8].pQuards[0].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8459 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8460 pBillboardRenderListD3D[v8].pQuards[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8461 pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8462 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8463 pBillboardRenderListD3D[v8].pQuards[0].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8464 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8465 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8466 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8467 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8468 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8469 if ( a2->uFlags & 4 ) |
0 | 8470 v14 = v14 * -1.0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8471 pBillboardRenderListD3D[v8].pQuards[1].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8472 pBillboardRenderListD3D[v8].pQuards[1].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8473 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8474 pBillboardRenderListD3D[v8].pQuards[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8475 pBillboardRenderListD3D[v8].pQuards[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8476 pBillboardRenderListD3D[v8].pQuards[1].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8477 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; |
8478 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8479 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8480 v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8481 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8482 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8483 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8484 pBillboardRenderListD3D[v8].pQuards[2].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8485 pBillboardRenderListD3D[v8].pQuards[2].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8486 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8487 pBillboardRenderListD3D[v8].pQuards[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8488 pBillboardRenderListD3D[v8].pQuards[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8489 pBillboardRenderListD3D[v8].pQuards[2].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8490 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; |
8491 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8492 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8493 v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8494 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8495 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8496 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8497 pBillboardRenderListD3D[v8].pQuards[3].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8498 pBillboardRenderListD3D[v8].pQuards[3].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8499 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8500 pBillboardRenderListD3D[v8].pQuards[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8501 pBillboardRenderListD3D[v8].pQuards[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8502 pBillboardRenderListD3D[v8].pQuards[3].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8503 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; |
8504 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8505 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8506 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8507 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8508 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8509 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8510 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8511 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8512 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8513 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8514 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8515 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8516 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; |
0 | 8517 } |
8518 | |
8519 | |
8520 //----- (004A48E4) -------------------------------------------------------- | |
8521 int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6) | |
8522 { | |
8523 int v6; // ecx@1 | |
8524 int v7; // ebx@1 | |
8525 int v8; // ecx@1 | |
8526 int v9; // edx@1 | |
8527 int v10; // edi@1 | |
8528 unsigned int x; // esi@1 | |
8529 int result; // eax@8 | |
8530 int v13; // [sp+Ch] [bp-10h]@1 | |
8531 int v14; // [sp+10h] [bp-Ch]@1 | |
8532 int v15; // [sp+14h] [bp-8h]@1 | |
8533 int v16; // [sp+18h] [bp-4h]@1 | |
8534 int v17; // [sp+24h] [bp+8h]@1 | |
8535 unsigned int v18; // [sp+28h] [bp+Ch]@1 | |
8536 int v19; // [sp+34h] [bp+18h]@1 | |
8537 | |
8538 v6 = screenSpaceX; | |
8539 v7 = (a6 >> 1) + screenSpaceY; | |
8540 v17 = 0; | |
8541 v15 = 0; | |
8542 v8 = (a6 >> 1) + v6; | |
8543 v14 = (a6 >> 1) * (a6 >> 1); | |
8544 v9 = 2 * (a6 >> 1); | |
8545 v10 = (a6 >> 1) * ((a6 >> 1) - 1); | |
8546 x = v8 - (a6 >> 1); | |
8547 v16 = (a6 >> 1) + screenSpaceY - v8; | |
8548 v19 = a6 >> 1; | |
8549 v13 = v9; | |
8550 v18 = v8; | |
8551 do | |
8552 { | |
8553 sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor); | |
8554 if ( v15 ) | |
8555 sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor); | |
8556 v14 -= v15; | |
8557 if ( v14 <= v10 ) | |
8558 { | |
8559 if ( v19 != v17 ) | |
8560 { | |
8561 sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor); | |
8562 sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor); | |
8563 } | |
8564 --v19; | |
8565 v13 -= 2; | |
8566 ++x; | |
8567 v10 -= v13; | |
8568 } | |
8569 result = v17++; | |
8570 v15 += 2; | |
8571 --v18; | |
8572 } | |
8573 while ( result < v19 ); | |
8574 return result; | |
8575 } | |
8576 | |
8577 //----- (004A49D0) -------------------------------------------------------- | |
8578 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
8579 { | |
8580 int v10; // eax@1 | |
8581 unsigned int v11; // ebx@1 | |
8582 unsigned int v12; // ecx@1 | |
8583 int v13; // edx@2 | |
8584 int v14; // edx@4 | |
8585 unsigned int v15; // edx@6 | |
8586 double v16; // st7@7 | |
8587 double v17; // st7@7 | |
8588 double v18; // st6@7 | |
8589 double v19; // st4@7 | |
8590 double v20; // st4@8 | |
8591 double v21; // st4@10 | |
8592 double v22; // st4@10 | |
8593 double v23; // st4@10 | |
8594 double v24; // st4@10 | |
8595 double v25; // st4@11 | |
8596 double v26; // st4@13 | |
8597 double v27; // st5@13 | |
8598 double v28; // st4@13 | |
8599 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
8600 double v30; // [sp+80h] [bp-14h]@1 | |
8601 int v31; // [sp+88h] [bp-Ch]@1 | |
8602 signed int v32; // [sp+8Ch] [bp-8h]@1 | |
8603 int X; // [sp+90h] [bp-4h]@1 | |
8604 float a3a; // [sp+A4h] [bp+10h]@10 | |
8605 float a4a; // [sp+A8h] [bp+14h]@10 | |
8606 | |
8607 *(float *)&X = dstX - srcX; | |
8608 v30 = *(float *)&X + 6.7553994e15; | |
8609 v31 = LODWORD(v30); | |
8610 *(float *)&v32 = dstY - srcY; | |
8611 v30 = *(float *)&v32 + 6.7553994e15; | |
8612 X = LODWORD(v30); | |
8613 HIDWORD(v30) = abs(COERCE_UNSIGNED_INT64(*(float *)&v32 + 6.7553994e15)); | |
8614 v10 = abs(v31); | |
8615 v32 = v10; | |
8616 v11 = HIDWORD(v30); | |
8617 v12 = 0; | |
8618 if ( v10 < SHIDWORD(v30) ) | |
8619 { | |
8620 v13 = v10; | |
8621 v10 = HIDWORD(v30); | |
8622 v11 = v13; | |
8623 } | |
8624 if ( v10 < 0 ) | |
8625 { | |
8626 v14 = v10; | |
8627 v10 = 0; | |
8628 v12 = v14; | |
8629 } | |
8630 if ( (signed int)v11 < (signed int)v12 ) | |
8631 { | |
8632 v15 = v12; | |
8633 v12 = v11; | |
8634 v11 = v15; | |
8635 } | |
8636 v32 = (11 * v11 >> 5) + (v12 >> 2) + v10; | |
8637 v16 = 1.0 / (double)v32; | |
8638 *(float *)&v31 = (double)v31 * v16; | |
8639 *(float *)&X = (double)X * v16; | |
8640 v17 = *(float *)&X * a4; | |
8641 v29[0].pos.x = srcX + v17; | |
8642 v18 = *(float *)&v31 * a4; | |
8643 v29[0].pos.y = srcY - v18; | |
8644 v19 = a3; | |
8645 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
8646 v20 = v19 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8647 else | |
8648 v20 = v19 * 0.061758894; | |
8649 v29[0].diffuse = -1; | |
8650 v29[0].specular = 0; | |
8651 v29[0].pos.z = 1.0 - 1.0 / v20; | |
8652 v21 = 1.0 / a3; | |
8653 *((float *)&v30 + 1) = v21; | |
8654 v29[0].rhw = v21; | |
8655 v29[0].texcoord.x = 1.0; | |
8656 v29[0].texcoord.y = 0.0; | |
8657 v22 = *(float *)&X * a8; | |
8658 a3a = v22; | |
8659 v29[1].pos.x = v22 + dstX; | |
8660 v23 = *(float *)&v31 * a8; | |
8661 a4a = v23; | |
8662 v29[1].pos.y = dstY - v23; | |
8663 v24 = a7; | |
8664 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
8665 v25 = v24 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8666 else | |
8667 v25 = v24 * 0.061758894; | |
8668 v29[2].diffuse = -1; | |
8669 v29[3].diffuse = -1; | |
8670 *(_QWORD *)&v29[3].pos.z = __PAIR__(HIDWORD(v30), LODWORD(v29[0].pos.z)); | |
8671 v29[1].diffuse = -16711936; | |
8672 v29[1].specular = 0; | |
8673 v29[2].specular = 0; | |
8674 v29[3].specular = 0; | |
8675 v26 = 1.0 - 1.0 / v25; | |
8676 v29[1].pos.z = v26; | |
8677 v27 = v26; | |
8678 v28 = 1.0 / a7; | |
8679 v29[1].rhw = v28; | |
8680 v29[1].texcoord.x = 1.0; | |
8681 v29[1].texcoord.y = 1.0; | |
8682 v29[2].pos.x = dstX - a3a; | |
8683 v29[2].pos.y = a4a + dstY; | |
8684 v29[2].pos.z = v27; | |
8685 v29[2].rhw = v28; | |
8686 v29[2].texcoord.x = 0.0; | |
8687 v29[2].texcoord.y = 1.0; | |
8688 v29[3].pos.x = srcX - v17; | |
8689 v29[3].pos.y = v18 + srcY; | |
8690 v29[3].texcoord.x = 0.0; | |
8691 v29[3].texcoord.y = 0.0; | |
8692 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u)); | |
8693 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u)); | |
8694 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u)); | |
8695 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0)); | |
8696 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0)); | |
8697 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
8698 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); | |
8699 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
8700 D3DPT_TRIANGLEFAN, | |
8701 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8702 v29, | |
8703 4, | |
8704 24)); | |
8705 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0)); | |
8706 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u)); | |
8707 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u)); | |
8708 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u)); | |
8709 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
8710 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u)); | |
8711 } | |
8712 | |
8713 | |
8714 //----- (004A4CC9) -------------------------------------------------------- | |
8715 void Render::_4A4CC9(stru6_stru1_indoor_sw_billboard *a1, int a2) | |
8716 { | |
8717 int v3; // eax@1 | |
8718 int v4; // edx@3 | |
8719 unsigned int v5; // eax@7 | |
8720 int v6; // edi@7 | |
8721 char *v7; // edx@8 | |
8722 char *v8; // ecx@8 | |
8723 char v9; // zf@9 | |
8724 double v10; // st6@9 | |
8725 double v11; // st6@10 | |
8726 int v12; // ebx@13 | |
8727 int v13; // ecx@16 | |
8728 unsigned int v14; // [sp+Ch] [bp-4h]@1 | |
8729 | |
8730 auto _this = this; | |
8731 | |
8732 *(float *)&v14 = 1000000.0; | |
8733 v3 = a1->field_10; | |
8734 if ( v3 >= 3 ) | |
8735 { | |
8736 if ( v3 > 0 ) | |
8737 { | |
8738 _this = (Render *)&a1->field_14[62]; | |
8739 v4 = a1->field_10; | |
8740 do | |
8741 { | |
8742 if ( *(float *)&this->bUserDirect3D < (double)*(float *)&v14 ) | |
8743 v14 = this->bUserDirect3D; | |
8744 _this = (Render *)((char *)_this + 16); | |
8745 --v4; | |
8746 } | |
8747 while ( v4 ); | |
8748 } | |
8749 v5 = Billboard_ProbablyAddToListAndSortByZOrder(v14); | |
8750 v6 = 0; | |
8751 pBillboardRenderListD3D[v5].field_90 = 0; | |
8752 pBillboardRenderListD3D[v5].uParentBillboardID = -1; | |
8753 pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; | |
8754 if ( a1->field_10 > 0 ) | |
8755 { | |
8756 v7 = (char *)&a1->field_14[62]; | |
8757 v8 = (char *)&pBillboardRenderListD3D[v5].pQuards[0].pos.z; | |
8758 do | |
8759 { | |
8760 v9 = uCurrentlyLoadedLevelType == LEVEL_Indoor; | |
8761 *((int *)v8 - 2) = *((int *)v7 - 2); | |
8762 *((int *)v8 - 1) = *((int *)v7 - 1); | |
8763 v10 = *(float *)v7; | |
8764 if ( v9 ) | |
8765 v11 = v10 * 0.061758894; | |
8766 else | |
8767 v11 = v10 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8768 *(float *)v8 = 1.0 - 1.0 / v11; | |
8769 *((float *)v8 + 1) = 1.0 / *(float *)v7; | |
8770 if ( a2 & 0xFF000000 ) | |
8771 v12 = *((int *)v7 + 1); | |
8772 else | |
8773 v12 = a2; | |
8774 *((int *)v8 + 3) = 0; | |
8775 *((int *)v8 + 2) = v12; | |
8776 ++v6; | |
8777 v7 += 16; | |
8778 *((float *)v8 + 4) = 0.0; | |
8779 *((float *)v8 + 5) = 0.0; | |
8780 v8 += 32; | |
8781 } | |
8782 while ( v6 < a1->field_10 ); | |
8783 } | |
8784 v13 = a1->field_10; | |
8785 pBillboardRenderListD3D[v5].pTexture = 0; | |
8786 pBillboardRenderListD3D[v5].uNumVertices = v13; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8787 LODWORD(pBillboardRenderListD3D[v5].z_order) = v14; |
0 | 8788 } |
8789 } | |
8790 | |
8791 | |
8792 //----- (004A4DE1) -------------------------------------------------------- | |
8793 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
8794 { | |
8795 HRESULT v12; // eax@14 | |
8796 unsigned __int16 *v13; // ecx@19 | |
8797 unsigned __int16 *v14; // eax@19 | |
8798 DWORD v15; // edx@20 | |
8799 HRESULT v16; // eax@23 | |
8800 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
8801 | |
8802 auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); | |
8803 if ( pHWLTexture ) | |
8804 { | |
8805 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
8806 if ( !pRenderD3D->CreateTexture( | |
8807 pHWLTexture->uWidth, | |
8808 pHWLTexture->uHeight, | |
8809 pOutSurface, | |
8810 pOutTexture, | |
8811 true, | |
8812 bMipMaps, | |
8813 uMinDeviceTextureDim) ) | |
8814 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); | |
8815 //v10 = *pOutSurface; | |
8816 //v11 = 0; | |
8817 if ( bMipMaps ) | |
8818 { | |
8819 Dst._450DDE(); | |
8820 //v20 = 0; | |
8821 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
8822 | |
8823 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
8824 while ( 1 ) | |
8825 { | |
8826 DDSCAPS2 v19; | |
8827 memset(&v19, 0, sizeof(DDSCAPS2)); | |
8828 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
8829 | |
8830 DDSURFACEDESC2 desc; | |
8831 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
8832 desc.dwSize = sizeof(DDSURFACEDESC2); | |
8833 | |
8834 if ( LockSurface_DDraw4(pNextSurf, &desc, 0x21u) ) | |
8835 { | |
8836 Dst.sub_451007_scale_image_bicubic( | |
8837 pHWLTexture->pPixels, | |
8838 pHWLTexture->uWidth, | |
8839 pHWLTexture->uHeight, | |
8840 pHWLTexture->uWidth, | |
8841 (unsigned short *)desc.lpSurface, | |
8842 desc.dwWidth, | |
8843 desc.dwHeight, | |
8844 desc.lPitch >> 1, | |
8845 0, | |
8846 0); | |
8847 ErrD3D(pNextSurf->Unlock(0)); | |
8848 //bMipMaps = 0x4D86ACu; | |
8849 } | |
8850 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
8851 break; | |
8852 //v10 = (IDirectDrawSurface4 *)pName; | |
8853 //v11 = 0; | |
8854 } | |
8855 //v20 = -1; | |
8856 //nullsub_1(); | |
8857 } | |
8858 else | |
8859 { | |
8860 DDSCAPS2 v19; | |
8861 memset(&v19, 0, sizeof(DDSCAPS2)); | |
8862 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
8863 | |
8864 DDSURFACEDESC2 desc; | |
8865 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
8866 desc.dwSize = sizeof(DDSURFACEDESC2); | |
8867 | |
8868 if ( LockSurface_DDraw4(*pOutSurface, &desc, 0x21u) ) | |
8869 { | |
8870 bMipMaps = 0; | |
8871 v13 = pHWLTexture->pPixels; | |
8872 v14 = (unsigned __int16 *)desc.lpSurface; | |
8873 if ( desc.dwHeight ) | |
8874 { | |
8875 do | |
8876 { | |
8877 v15 = 0; | |
8878 if ( desc.dwWidth ) | |
8879 { | |
8880 do | |
8881 { | |
8882 ++v15; | |
8883 *v14 = *v13; | |
8884 ++v14; | |
8885 ++v13; | |
8886 } | |
8887 while ( v15 < desc.dwWidth ); | |
8888 } | |
8889 ++bMipMaps; | |
8890 v14 += (desc.lPitch >> 1) - desc.dwWidth; | |
8891 } | |
8892 while ( bMipMaps < desc.dwHeight ); | |
8893 } | |
8894 ErrD3D((*pOutSurface)->Unlock(0)); | |
8895 } | |
8896 } | |
8897 delete [] pHWLTexture->pPixels; | |
8898 delete pHWLTexture; | |
8899 return true; | |
8900 } | |
8901 return false; | |
8902 } | |
8903 | |
8904 //----- (004A5048) -------------------------------------------------------- | |
8905 HWLTexture *Render::MoveSpriteToDevice(Sprite *pSprite) | |
8906 { | |
8907 Sprite *v2; // edi@1 | |
8908 Render *v3; // ebx@1 | |
8909 HWLTexture *result; // eax@1 | |
8910 HWLTexture *v5; // esi@1 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8911 //unsigned int v6; // ST18_4@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8912 //RenderD3D *v7; // ecx@2 |
0 | 8913 Sprite *v8; // ebx@4 |
8914 unsigned __int16 *v9; // edx@5 | |
8915 LPVOID v10; // eax@5 | |
8916 signed int v11; // ebx@5 | |
8917 signed int v12; // ecx@6 | |
8918 signed int v13; // edi@7 | |
8919 HRESULT v14; // eax@10 | |
8920 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
8921 | |
8922 v2 = pSprite; | |
8923 v3 = this; | |
8924 result = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); | |
8925 v5 = result; | |
8926 if ( result ) | |
8927 { | |
8928 v3->_gpu_memory_used += 2 * result->uWidth * result->uHeight; | |
8929 v2->uAreaX = result->field_30; | |
8930 v2->uAreaY = result->field_34; | |
8931 v2->uBufferWidth = result->field_18; | |
8932 v2->uBufferHeight = result->field_1C; | |
8933 v2->uAreaWidth = result->field_20; | |
8934 v2->uAreaHeight = result->field_24; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8935 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8936 //v7 = v3->pRenderD3D; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8937 if (!pRenderD3D->CreateTexture(result->uWidth, result->uHeight, &v2->pTextureSurface, &v2->pTexture, 1u, 0, uMinDeviceTextureDim)) |
0 | 8938 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
8939 //pSprite = v2->pTextureSurface; | |
8940 //pSprite = (Sprite *)pSprite->pName; | |
8941 //v8 = pSprite; | |
8942 memset(&Dst, 0, 0x7Cu); | |
8943 Dst.dwSize = 124; | |
8944 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)v2->pTextureSurface, &Dst, 0x21u) ) | |
8945 { | |
8946 v9 = v5->pPixels; | |
8947 v10 = Dst.lpSurface; | |
8948 v11 = 0; | |
8949 if ( (signed int)v5->uHeight > 0 ) | |
8950 { | |
8951 v12 = (signed int)v5->uWidth >> 1; | |
8952 do | |
8953 { | |
8954 v13 = 0; | |
8955 if ( v12 > 0 ) | |
8956 { | |
8957 do | |
8958 { | |
8959 ++v13; | |
8960 *(int *)v10 = *(int *)v9; | |
8961 v9 += 2; | |
8962 v10 = (char *)v10 + 4; | |
8963 } | |
8964 while ( v13 < (signed int)v5->uWidth >> 1 ); | |
8965 } | |
8966 v12 = (signed int)v5->uWidth >> 1; | |
8967 ++v11; | |
8968 v10 = (char *)v10 + 4 * ((Dst.lPitch >> 2) - v12); | |
8969 } | |
8970 while ( v11 < (signed int)v5->uHeight ); | |
8971 } | |
8972 ErrD3D(v2->pTextureSurface->Unlock(0)); | |
8973 } | |
8974 free(v5->pPixels); | |
8975 free(v5); | |
8976 result = (HWLTexture *)1; | |
8977 } | |
8978 return result; | |
8979 } | |
8980 | |
8981 //----- (004A51CB) -------------------------------------------------------- | |
8982 void Render::BeginScene() | |
8983 { | |
8984 Render *v1; // esi@1 | |
8985 unsigned int v2; // eax@1 | |
8986 int v3; // eax@5 | |
8987 unsigned __int16 **v4; // edi@6 | |
8988 char *v5; // ebx@7 | |
8989 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
8990 | |
8991 v1 = this; | |
8992 v2 = this->uNumSceneBegins; | |
8993 this->uNumSceneBegins = v2 + 1; | |
8994 if ( !v2 ) | |
8995 { | |
8996 if ( this->pRenderD3D ) | |
8997 { | |
8998 if ( this->bColorKeySupported ) | |
8999 { | |
9000 memset(&Dst, 0, 0x7Cu); | |
9001 Dst.dwSize = 124; | |
9002 if ( LockSurface_DDraw4(v1->pColorKeySurface4, &Dst, 0x801u) ) | |
9003 { | |
9004 v1->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; | |
9005 v3 = Dst.lPitch >> 1; | |
9006 v1->uTargetSurfacePitch = Dst.lPitch >> 1; | |
9007 LABEL_10: | |
9008 v1->field_18_locked_pitch = v3; | |
9009 goto LABEL_11; | |
9010 } | |
9011 goto LABEL_8; | |
9012 } | |
9013 } | |
9014 else | |
9015 { | |
9016 v4 = &this->pTargetSurface; | |
9017 if ( !this->pTargetSurface ) | |
9018 { | |
9019 v5 = (char *)&this->uTargetSurfacePitch; | |
9020 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
9021 if ( *v4 ) | |
9022 { | |
9023 v3 = *(int *)v5; | |
9024 goto LABEL_10; | |
9025 } | |
9026 LABEL_8: | |
9027 --v1->uNumSceneBegins; | |
9028 return; | |
9029 } | |
9030 } | |
9031 LABEL_11: | |
9032 RestoreFrontBuffer(); | |
9033 } | |
9034 } | |
9035 | |
9036 //----- (004A527D) -------------------------------------------------------- | |
9037 void Render::EndScene() | |
9038 { | |
9039 unsigned int v1; // edx@1 | |
9040 unsigned int v2; // edx@2 | |
9041 HRESULT v3; // eax@5 | |
9042 | |
9043 v1 = this->uNumSceneBegins; | |
9044 if ( v1 ) | |
9045 { | |
9046 v2 = v1 - 1; | |
9047 this->uNumSceneBegins = v2; | |
9048 if ( !v2 ) | |
9049 { | |
9050 if ( this->pRenderD3D ) | |
9051 { | |
9052 if ( this->bColorKeySupported ) | |
9053 { | |
9054 this->pTargetSurface = 0; | |
9055 this->uTargetSurfacePitch = 0; | |
9056 this->field_18_locked_pitch = 0; | |
9057 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
9058 } | |
9059 } | |
9060 else | |
9061 { | |
9062 this->pTargetSurface = 0; | |
9063 this->uTargetSurfacePitch = 0; | |
9064 this->field_18_locked_pitch = 0; | |
9065 UnlockBackBuffer(); | |
9066 } | |
9067 } | |
9068 } | |
9069 } | |
9070 | |
9071 | |
9072 //----- ( ) -------------------------------------------------------- | |
9073 unsigned int Render::_4A52F1(unsigned int this_, float a3) | |
9074 { | |
9075 unsigned int v3; // esi@1 | |
9076 double v4; // st7@2 | |
9077 double v5; // st7@6 | |
9078 double v6; // st6@6 | |
9079 unsigned int v7; // eax@6 | |
9080 double v8; // st5@6 | |
9081 double v9; // st4@6 | |
9082 HRESULT v10; // eax@6 | |
9083 HRESULT v11; // eax@6 | |
9084 unsigned int result; // eax@6 | |
9085 unsigned int v13; // eax@7 | |
9086 unsigned __int16 *v14; // ecx@7 | |
9087 int *v15; // eax@7 | |
9088 unsigned int v16; // ecx@8 | |
9089 __int16 v17; // ax@10 | |
9090 int v18; // esi@10 | |
9091 float v19; // edi@10 | |
9092 void *v20; // esi@10 | |
9093 int v21; // edx@10 | |
9094 int v22; // ecx@11 | |
9095 int v23; // edx@12 | |
9096 __int16 v24; // ax@15 | |
9097 int v25; // esi@15 | |
9098 float v26; // edi@15 | |
9099 char *v27; // esi@15 | |
9100 int v28; // edx@15 | |
9101 int v29; // ecx@16 | |
9102 int v30; // edx@17 | |
9103 int v31; // [sp-Ch] [bp-ACh]@11 | |
9104 int v32; // [sp-Ch] [bp-ACh]@16 | |
9105 const char *v33; // [sp+0h] [bp-A0h]@0 | |
9106 int v34; // [sp+4h] [bp-9Ch]@0 | |
9107 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
9108 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
9109 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
9110 int v38; // [sp+90h] [bp-10h]@7 | |
9111 double v39; // [sp+94h] [bp-Ch]@6 | |
9112 float v40; // [sp+9Ch] [bp-4h]@6 | |
9113 | |
9114 auto ecx0 = this; | |
9115 v3 = 0; | |
9116 if ( ecx0->pRenderD3D ) | |
9117 { | |
9118 v4 = a3; | |
9119 if ( a3 <= 1.0 ) | |
9120 { | |
9121 if ( v4 < 0.0 ) | |
9122 v4 = 0.0; | |
9123 } | |
9124 else | |
9125 { | |
9126 v4 = 1.0; | |
9127 } | |
9128 a3 = v4 * 255.0; | |
9129 v39 = a3 + 6.7553994e15; | |
9130 LODWORD(v40) = LODWORD(v39); | |
9131 v5 = (double)(signed int)pViewport->uViewportX; | |
9132 v36[0].pos.x = v5; | |
9133 v6 = (double)(signed int)pViewport->uViewportY; | |
9134 v7 = this_ | (LODWORD(v39) << 24); | |
9135 this_ = pViewport->uViewportW + 1; | |
9136 v36[0].specular = 0; | |
9137 v36[0].pos.y = v6; | |
9138 v36[0].diffuse = v7; | |
9139 v36[1].diffuse = v7; | |
9140 v36[0].pos.z = 0.0; | |
9141 v36[2].diffuse = v7; | |
9142 v36[3].diffuse = v7; | |
9143 v36[0].rhw = 1.0; | |
9144 v36[1].specular = 0; | |
9145 v36[0].texcoord.x = 0.0; | |
9146 v36[2].specular = 0; | |
9147 v36[3].specular = 0; | |
9148 v36[0].texcoord.y = 0.0; | |
9149 v36[1].pos.x = v5; | |
9150 v8 = (double)(pViewport->uViewportW + 1); | |
9151 v36[1].pos.y = v8; | |
9152 v36[1].pos.z = 0.0; | |
9153 v36[1].rhw = 1.0; | |
9154 v36[1].texcoord.x = 0.0; | |
9155 v36[1].texcoord.y = 0.0; | |
9156 v9 = (double)(signed int)pViewport->uViewportZ; | |
9157 v36[2].pos.x = v9; | |
9158 v36[2].pos.y = v8; | |
9159 v36[2].pos.z = 0.0; | |
9160 v36[2].rhw = 1.0; | |
9161 v36[2].texcoord.x = 0.0; | |
9162 v36[2].texcoord.y = 0.0; | |
9163 v36[3].pos.x = v9; | |
9164 v36[3].pos.y = v6; | |
9165 v36[3].pos.z = 0.0; | |
9166 v36[3].rhw = 1.0; | |
9167 v36[3].texcoord.x = 0.0; | |
9168 v36[3].texcoord.y = 0.0; | |
9169 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
9170 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0)); | |
9171 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u)); | |
9172 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0)); | |
9173 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 5u)); | |
9174 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6u)); | |
9175 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0)); | |
9176 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 8u)); | |
9177 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
9178 D3DPT_TRIANGLEFAN, | |
9179 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9180 v36, | |
9181 4, | |
9182 28)); | |
9183 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2)); | |
9184 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u)); | |
9185 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0)); | |
9186 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
9187 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u)); | |
9188 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
9189 } | |
9190 else | |
9191 { | |
9192 v40 = (1.0 - a3) * 65536.0; | |
9193 v39 = v40 + 6.7553994e15; | |
9194 LODWORD(a3) = LODWORD(v39); | |
9195 v38 = (signed int)(pViewport->uViewportZ - pViewport->uViewportX) >> 1; | |
9196 HIDWORD(v39) = pViewport->uViewportW - pViewport->uViewportY + 1; | |
9197 v13 = pViewport->uViewportX + ecx0->uTargetSurfacePitch - pViewport->uViewportZ; | |
9198 v14 = &ecx0->pTargetSurface[pViewport->uViewportX + pViewport->uViewportY * ecx0->uTargetSurfacePitch]; | |
9199 v37 = 2 * v13; | |
9200 LODWORD(v40) = (int)v14; | |
9201 | |
9202 int __i = 0; | |
9203 v15 = dword_F1B430; | |
9204 do | |
9205 { | |
9206 v16 = v3; | |
9207 v3 += LODWORD(a3); | |
9208 dword_F1B430[__i++] = v16 >> 16; | |
9209 } | |
9210 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
9211 while (__i < 32); | |
9212 | |
9213 if ( pRenderer->uTargetGBits == 6 ) | |
9214 { | |
9215 v17 = _42690D_colors_cvt(this_); | |
9216 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); | |
9217 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); | |
9218 v19 = v40; | |
9219 v20 = off_4EFDB0; | |
9220 v21 = HIDWORD(v39); | |
9221 do | |
9222 { | |
9223 v22 = v38; | |
9224 v31 = v21; | |
9225 do | |
9226 { | |
9227 v23 = (*(int *)((char *)v20 | |
9228 + ((((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; | |
9229 result = this_ | |
9230 + (*((int *)v20 | |
9231 + (((unsigned __int8)(*((char *)v20 | |
9232 + ((((unsigned __int16)(*(short *)((char *)v20 | |
9233 + ((*(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); | |
9234 *(unsigned int *)LODWORD(v19) = result; | |
9235 LODWORD(v19) += 4; | |
9236 --v22; | |
9237 } | |
9238 while ( v22 ); | |
9239 LODWORD(v19) += v37; | |
9240 v21 = v31 - 1; | |
9241 } | |
9242 while ( v31 != 1 ); | |
9243 } | |
9244 else | |
9245 { | |
9246 v24 = _4268E3_smthn_to_a1r5g5b5(this_); | |
9247 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); | |
9248 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
9249 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
9250 v26 = v40; | |
9251 v27 = (char *)off_4EFDB0; | |
9252 v28 = HIDWORD(v39); | |
9253 do | |
9254 { | |
9255 v29 = v38; | |
9256 v32 = v28; | |
9257 do | |
9258 { | |
9259 v30 = 32 | |
9260 * *(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; | |
9261 result = this_ | |
9262 + (*(int *)&v27[4 | |
9263 * (((unsigned __int8)(32 | |
9264 * 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); | |
9265 *(unsigned int *)LODWORD(v26) = result; | |
9266 LODWORD(v26) += 4; | |
9267 --v29; | |
9268 } | |
9269 while ( v29 ); | |
9270 LODWORD(v26) += v37; | |
9271 v28 = v32 - 1; | |
9272 } | |
9273 while ( v32 != 1 ); | |
9274 } | |
9275 } | |
9276 return result; | |
9277 } | |
9278 | |
9279 | |
9280 | |
9281 //----- (004A5B81) -------------------------------------------------------- | |
9282 void Render::Clip(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) | |
9283 { | |
9284 this->bClip = 1; | |
9285 this->uClipY = uY; | |
9286 this->uClipX = uX; | |
9287 this->uClipW = uW; | |
9288 this->uClipZ = uZ; | |
9289 } | |
9290 | |
9291 | |
9292 //----- (004A5BB6) -------------------------------------------------------- | |
9293 void Render::ResetClip() | |
9294 { | |
9295 this->uClipY = 0; | |
9296 this->uClipX = 0; | |
9297 this->bClip = 1; | |
9298 this->uClipW = 480; | |
9299 this->uClipZ = 640; | |
9300 } | |
9301 | |
9302 | |
9303 //----- (004A5BE3) -------------------------------------------------------- | |
9304 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
9305 { | |
9306 int v4; // edi@3 | |
9307 unsigned __int16 *v5; // edx@3 | |
9308 unsigned __int16 *v6; // esi@3 | |
9309 unsigned int v7; // ebx@4 | |
9310 unsigned int v8; // eax@5 | |
9311 unsigned int v9; // ebx@5 | |
9312 unsigned int v10; // eax@6 | |
9313 unsigned int v11; // eax@7 | |
9314 unsigned int v12; // ebx@8 | |
9315 unsigned int v13; // eax@10 | |
9316 unsigned int v14; // edi@11 | |
9317 unsigned int v15; // eax@14 | |
9318 unsigned int v16; // ebx@17 | |
9319 int v17; // eax@23 | |
9320 char v18; // zf@25 | |
9321 int v19; // [sp+10h] [bp-8h]@3 | |
9322 int v20; // [sp+14h] [bp-4h]@3 | |
9323 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
9324 int uOutXb; // [sp+20h] [bp+8h]@21 | |
9325 int v23; // [sp+28h] [bp+10h]@3 | |
9326 | |
9327 if ( this->uNumSceneBegins && a4 ) | |
9328 { | |
9329 v4 = a4->uWidth; | |
9330 v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
9331 v6 = a4->pPixels; | |
9332 v20 = v4; | |
9333 v23 = a4->uHeight; | |
9334 v19 = v4; | |
9335 if ( this->bClip ) | |
9336 { | |
9337 v7 = this->uClipX; | |
9338 if ( (signed int)uOutX < (signed int)v7 ) | |
9339 { | |
9340 v8 = v7 - uOutX; | |
9341 v9 = uOutX - v7; | |
9342 v8 *= 2; | |
9343 v4 += v9; | |
9344 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
9345 v20 += v9; | |
9346 v5 = (unsigned __int16 *)((char *)v5 + v8); | |
9347 } | |
9348 v10 = this->uClipY; | |
9349 if ( (signed int)uOutY < (signed int)v10 ) | |
9350 { | |
9351 v11 = v10 - uOutY; | |
9352 v6 += v19 * v11; | |
9353 v23 += uOutY - this->uClipY; | |
9354 v4 = v20; | |
9355 v5 += this->uTargetSurfacePitch * v11; | |
9356 } | |
9357 v12 = this->uClipX; | |
9358 if ( (signed int)v12 < (signed int)uOutX ) | |
9359 v12 = uOutX; | |
9360 v13 = this->uClipZ; | |
9361 if ( (signed int)(v4 + v12) > (signed int)v13 ) | |
9362 { | |
9363 v14 = this->uClipX; | |
9364 if ( (signed int)v14 < (signed int)uOutX ) | |
9365 v14 = uOutX; | |
9366 v4 = v13 - v14; | |
9367 } | |
9368 v15 = this->uClipY; | |
9369 if ( (signed int)v15 < (signed int)uOutY ) | |
9370 v15 = uOutY; | |
9371 uOutXa = this->uClipW; | |
9372 if ( (signed int)(v15 + v23) > (signed int)uOutXa ) | |
9373 { | |
9374 v16 = this->uClipY; | |
9375 if ( (signed int)v16 < (signed int)uOutY ) | |
9376 v16 = uOutY; | |
9377 v23 = uOutXa - v16; | |
9378 } | |
9379 } | |
9380 if ( v23 > 0 ) | |
9381 { | |
9382 uOutXb = v23; | |
9383 do | |
9384 { | |
9385 if ( v4 > 0 ) | |
9386 { | |
9387 v17 = v4; | |
9388 do | |
9389 { | |
9390 *v5 = *v6; | |
9391 ++v5; | |
9392 ++v6; | |
9393 --v17; | |
9394 } | |
9395 while ( v17 ); | |
9396 } | |
9397 v6 += v19 - v4; | |
9398 v18 = uOutXb-- == 1; | |
9399 v5 += this->uTargetSurfacePitch - v4; | |
9400 } | |
9401 while ( !v18 ); | |
9402 } | |
9403 } | |
9404 } | |
9405 | |
9406 | |
9407 //----- (004A5D33) -------------------------------------------------------- | |
9408 void Render::_4A5D33(unsigned int pX, unsigned int pY, int a4, int a5, RGBTexture *pTexture) | |
9409 { | |
9410 Render *v6; // esi@1 | |
9411 unsigned __int16 *v7; // ebx@3 | |
9412 int v8; // ecx@3 | |
9413 int v9; // edx@3 | |
9414 int v10; // ecx@3 | |
9415 int v11; // edi@3 | |
9416 signed int v12; // eax@4 | |
9417 unsigned int v13; // eax@5 | |
9418 signed int v14; // eax@6 | |
9419 unsigned int v15; // eax@7 | |
9420 unsigned int v16; // edx@8 | |
9421 int v17; // eax@10 | |
9422 unsigned int v18; // ecx@11 | |
9423 unsigned int v19; // ecx@14 | |
9424 int v20; // eax@16 | |
9425 unsigned int v21; // ecx@17 | |
9426 int v22; // eax@21 | |
9427 int v23; // edi@23 | |
9428 int v24; // [sp+Ch] [bp-4h]@3 | |
9429 int a2a; // [sp+18h] [bp+8h]@21 | |
9430 unsigned int teal; // [sp+1Ch] [bp+Ch]@20 | |
9431 int a4a; // [sp+20h] [bp+10h]@3 | |
9432 int a4b; // [sp+20h] [bp+10h]@21 | |
9433 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 | |
9434 | |
9435 v6 = this; | |
9436 if ( this->uNumSceneBegins && pTexture ) | |
9437 { | |
9438 v7 = &this->pTargetSurface[pX + pY * this->uTargetSurfacePitch]; | |
9439 v8 = pTexture->uWidth; | |
9440 v24 = pTexture->uWidth; | |
9441 v9 = a4 + a5 * v8; | |
9442 v10 = v8 - a4; | |
9443 a4a = v10; | |
9444 v11 = pTexture->uHeight - a5; | |
9445 pTexturea = &pTexture->pPixels[v9]; | |
9446 if ( v6->bClip ) | |
9447 { | |
9448 v12 = v6->uClipX; | |
9449 if ( (signed int)pX < v12 ) | |
9450 { | |
9451 v13 = 2 * (v12 - pX); | |
9452 pTexturea = (unsigned __int16 *)((char *)pTexturea + v13); | |
9453 v10 += pX - v6->uClipX; | |
9454 v7 = (unsigned __int16 *)((char *)v7 + v13); | |
9455 a4a = v10; | |
9456 } | |
9457 v14 = v6->uClipY; | |
9458 if ( (signed int)pY < v14 ) | |
9459 { | |
9460 v15 = v14 - pY; | |
9461 pTexturea += v24 * v15; | |
9462 v11 += pY - v6->uClipY; | |
9463 v10 = a4a; | |
9464 v7 += v6->uTargetSurfacePitch * v15; | |
9465 } | |
9466 v16 = v6->uClipX; | |
9467 if ( (signed int)v16 < (signed int)pX ) | |
9468 v16 = pX; | |
9469 v17 = v6->uClipZ; | |
9470 if ( (signed int)(v10 + v16) > v17 ) | |
9471 { | |
9472 v18 = v6->uClipX; | |
9473 if ( (signed int)v18 < (signed int)pX ) | |
9474 v18 = pX; | |
9475 a4a = v17 - v18; | |
9476 } | |
9477 v19 = v6->uClipY; | |
9478 if ( (signed int)v19 < (signed int)pY ) | |
9479 v19 = pY; | |
9480 v20 = v6->uClipW; | |
9481 if ( (signed int)(v11 + v19) > v20 ) | |
9482 { | |
9483 v21 = v6->uClipY; | |
9484 if ( (signed int)v21 < (signed int)pY ) | |
9485 v21 = pY; | |
9486 v11 = v20 - v21; | |
9487 } | |
9488 } | |
9489 teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu); | |
9490 if ( v11 > 0 ) | |
9491 { | |
9492 v22 = a4a; | |
9493 a2a = v11; | |
9494 a4b = 2 * (v24 - a4a); | |
9495 do | |
9496 { | |
9497 if ( v22 > 0 ) | |
9498 { | |
9499 v23 = v22; | |
9500 do | |
9501 { | |
9502 if ( *pTexturea != teal ) | |
9503 *v7 = *pTexturea; | |
9504 ++pTexturea; | |
9505 ++v7; | |
9506 --v23; | |
9507 } | |
9508 while ( v23 ); | |
9509 } | |
9510 v7 += v6->uTargetSurfacePitch - v22; | |
9511 pTexturea = (unsigned __int16 *)((char *)pTexturea + a4b); | |
9512 --a2a; | |
9513 } | |
9514 while ( a2a ); | |
9515 } | |
9516 } | |
9517 } | |
9518 | |
9519 | |
9520 | |
9521 //----- (004A6E7E) -------------------------------------------------------- | |
9522 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) | |
9523 { | |
9524 unsigned __int16 *v4; // eax@4 | |
9525 int v5; // edx@4 | |
9526 unsigned int v6; // edi@4 | |
9527 unsigned int v7; // edx@5 | |
9528 unsigned int v8; // edx@6 | |
9529 unsigned int v9; // edx@7 | |
9530 unsigned int v10; // edx@8 | |
9531 unsigned int v11; // ebx@9 | |
9532 unsigned int v12; // esi@11 | |
9533 unsigned int v13; // edx@12 | |
9534 unsigned int v14; // ebx@15 | |
9535 unsigned int v15; // esi@17 | |
9536 unsigned int v16; // edi@18 | |
9537 char v17; // zf@29 | |
9538 int v18; // [sp+14h] [bp-Ch]@4 | |
9539 int v19; // [sp+18h] [bp-8h]@4 | |
9540 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
9541 int v21; // [sp+28h] [bp+8h]@25 | |
9542 int v22; // [sp+28h] [bp+8h]@34 | |
9543 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
9544 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
9545 | |
9546 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
9547 { | |
9548 v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
9549 v20 = a4->pLevelOfDetail0; | |
9550 v5 = a4->uTextureWidth; | |
9551 v6 = a4->uTextureHeight; | |
9552 v19 = a4->uTextureWidth; | |
9553 v18 = a4->uTextureWidth; | |
9554 if ( this->bClip ) | |
9555 { | |
9556 v7 = this->uClipX; | |
9557 if ( (signed int)a2 < (signed int)v7 ) | |
9558 { | |
9559 v8 = v7 - a2; | |
9560 v20 += v8; | |
9561 v19 += a2 - this->uClipX; | |
9562 v4 += v8; | |
9563 } | |
9564 v9 = this->uClipY; | |
9565 if ( (signed int)a3 < (signed int)v9 ) | |
9566 { | |
9567 v10 = v9 - a3; | |
9568 v20 += v18 * v10; | |
9569 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
9570 v4 += this->uTargetSurfacePitch * v10; | |
9571 } | |
9572 v11 = this->uClipX; | |
9573 v5 = v19; | |
9574 if ( (signed int)v11 < (signed int)a2 ) | |
9575 v11 = a2; | |
9576 v12 = this->uClipZ; | |
9577 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
9578 { | |
9579 v13 = this->uClipX; | |
9580 if ( (signed int)v13 < (signed int)a2 ) | |
9581 v13 = a2; | |
9582 v5 = v12 - v13; | |
9583 } | |
9584 v14 = this->uClipY; | |
9585 if ( (signed int)v14 < (signed int)a3 ) | |
9586 v14 = a3; | |
9587 v15 = this->uClipW; | |
9588 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
9589 { | |
9590 v16 = this->uClipY; | |
9591 if ( (signed int)v16 < (signed int)a3 ) | |
9592 v16 = a3; | |
9593 v6 = v15 - v16; | |
9594 } | |
9595 } | |
9596 if ( pRenderer->uTargetGBits == 5 ) | |
9597 { | |
9598 if ( (signed int)v6 > 0 ) | |
9599 { | |
9600 v23 = v6; | |
9601 do | |
9602 { | |
9603 if ( v5 > 0 ) | |
9604 { | |
9605 v21 = v5; | |
9606 do | |
9607 { | |
9608 if ( *v20 ) | |
9609 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
9610 ++v4; | |
9611 ++v20; | |
9612 --v21; | |
9613 } | |
9614 while ( v21 ); | |
9615 } | |
9616 v20 += v18 - v5; | |
9617 v17 = v23-- == 1; | |
9618 v4 += this->uTargetSurfacePitch - v5; | |
9619 } | |
9620 while ( !v17 ); | |
9621 } | |
9622 } | |
9623 else | |
9624 { | |
9625 if ( (signed int)v6 > 0 ) | |
9626 { | |
9627 v24 = v6; | |
9628 do | |
9629 { | |
9630 if ( v5 > 0 ) | |
9631 { | |
9632 v22 = v5; | |
9633 do | |
9634 { | |
9635 if ( *v20 ) | |
9636 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
9637 ++v4; | |
9638 ++v20; | |
9639 --v22; | |
9640 } | |
9641 while ( v22 ); | |
9642 } | |
9643 v20 += v18 - v5; | |
9644 v17 = v24-- == 1; | |
9645 v4 += this->uTargetSurfacePitch - v5; | |
9646 } | |
9647 while ( !v17 ); | |
9648 } | |
9649 } | |
9650 } | |
9651 } | |
9652 | |
9653 | |
9654 //----- (004A6DF5) -------------------------------------------------------- | |
9655 int Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) | |
9656 { | |
9657 int result; // eax@0 | |
9658 int v8; // ecx@3 | |
9659 unsigned __int16 *v9; // edi@4 | |
9660 unsigned __int16 *v10; // ebx@4 | |
9661 int v11; // esi@4 | |
9662 unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3 | |
9663 unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3 | |
9664 | |
9665 if ( pBitmap ) | |
9666 { | |
9667 if ( pTarget ) | |
9668 { | |
9669 pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y]; | |
9670 pTargeta = &pTarget[a7->x + uTargetPitch * a7->y]; | |
9671 v8 = a7->z - a7->x; | |
9672 result = a7->w - a7->y; | |
9673 if ( result > 0 ) | |
9674 { | |
9675 v9 = pBitmapa; | |
9676 v10 = pTargeta; | |
9677 v11 = a7->w - a7->y; | |
9678 do | |
9679 { | |
9680 if ( v8 > 0 ) | |
9681 { | |
9682 result = v8; | |
9683 do | |
9684 { | |
9685 *v9 = *v10; | |
9686 ++v9; | |
9687 ++v10; | |
9688 --result; | |
9689 } | |
9690 while ( result ); | |
9691 } | |
9692 v9 += uBitmapPitch - v8; | |
9693 v10 += uTargetPitch - v8; | |
9694 --v11; | |
9695 } | |
9696 while ( v11 ); | |
9697 } | |
9698 } | |
9699 } | |
9700 return result; | |
9701 } | |
9702 | |
9703 | |
9704 //----- (004A6D87) -------------------------------------------------------- | |
9705 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
9706 { | |
9707 if (!uNumSceneBegins) | |
9708 return; | |
9709 | |
9710 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
9711 for (uint y = 0; y < uHeight; ++y) | |
9712 { | |
9713 auto pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch]; | |
9714 | |
9715 memset32(pDst, twoColors, uWidth / 2); | |
9716 if (uWidth & 1) | |
9717 pDst[uWidth - 1] = uColor16; | |
9718 } | |
9719 } | |
9720 | |
9721 | |
9722 | |
9723 //----- (004A6C4F) -------------------------------------------------------- | |
9724 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) | |
9725 { | |
9726 unsigned int v9; // edi@2 | |
9727 unsigned int v10; // esi@2 | |
9728 unsigned __int16 *v11; // eax@2 | |
9729 unsigned int v12; // ebx@3 | |
9730 signed int v13; // edx@5 | |
9731 int v14; // edx@6 | |
9732 signed int v15; // ebx@7 | |
9733 unsigned int v16; // edx@9 | |
9734 signed int v17; // edi@10 | |
9735 signed int v18; // ebx@13 | |
9736 unsigned int v19; // edx@15 | |
9737 signed int v20; // esi@16 | |
9738 unsigned int v21; // esi@22 | |
9739 unsigned __int16 v22; // dx@24 | |
9740 char v23; // zf@28 | |
9741 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 | |
9742 unsigned int uOutXa; // [sp+18h] [bp+8h]@20 | |
9743 | |
9744 if ( this->uNumSceneBegins ) | |
9745 { | |
9746 v9 = uCharWidth; | |
9747 v10 = uCharHeight; | |
9748 v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
9749 v24 = pFontPixels; | |
9750 if ( this->bClip ) | |
9751 { | |
9752 v12 = this->uClipX; | |
9753 if ( uOutX < (signed int)v12 ) | |
9754 { | |
9755 v24 = &pFontPixels[v12 - uOutX]; | |
9756 v11 += v12 - uOutX; | |
9757 v9 = uCharWidth + uOutX - v12; | |
9758 } | |
9759 v13 = this->uClipY; | |
9760 if ( uOutY < v13 ) | |
9761 { | |
9762 v14 = v13 - uOutY; | |
9763 v24 += uCharWidth * v14; | |
9764 v10 = uCharHeight + uOutY - this->uClipY; | |
9765 v11 += this->uTargetSurfacePitch * v14; | |
9766 } | |
9767 v15 = this->uClipX; | |
9768 if ( v15 < uOutX ) | |
9769 v15 = uOutX; | |
9770 v16 = this->uClipZ; | |
9771 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
9772 { | |
9773 v17 = this->uClipX; | |
9774 if ( v17 < uOutX ) | |
9775 v17 = uOutX; | |
9776 v9 = v16 - v17; | |
9777 } | |
9778 v18 = this->uClipY; | |
9779 if ( v18 < uOutY ) | |
9780 v18 = uOutY; | |
9781 v19 = this->uClipW; | |
9782 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
9783 { | |
9784 v20 = this->uClipY; | |
9785 if ( v20 < uOutY ) | |
9786 v20 = uOutY; | |
9787 v10 = v19 - v20; | |
9788 } | |
9789 } | |
9790 if ( (signed int)v10 > 0 ) | |
9791 { | |
9792 uOutXa = v10; | |
9793 do | |
9794 { | |
9795 if ( (signed int)v9 > 0 ) | |
9796 { | |
9797 v21 = v9; | |
9798 do | |
9799 { | |
9800 if ( *v24 ) | |
9801 { | |
9802 v22 = uShadowColor; | |
9803 if ( *v24 != 1 ) | |
9804 v22 = uFaceColor; | |
9805 *v11 = v22; | |
9806 } | |
9807 ++v11; | |
9808 ++v24; | |
9809 --v21; | |
9810 } | |
9811 while ( v21 ); | |
9812 } | |
9813 v24 += uCharWidth - v9; | |
9814 v23 = uOutXa-- == 1; | |
9815 v11 += this->uTargetSurfacePitch - v9; | |
9816 } | |
9817 while ( !v23 ); | |
9818 } | |
9819 } | |
9820 } | |
9821 | |
9822 | |
9823 | |
9824 //----- (004A6A68) -------------------------------------------------------- | |
9825 void Render::_4A6A68(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) | |
9826 { | |
9827 Render *v5; // ebx@1 | |
9828 unsigned __int16 v6; // ax@1 | |
9829 | |
9830 v5 = this; | |
9831 | |
9832 Texture tex; // [sp+Ch] [bp-48h]@1 | |
9833 //Texture::Texture(&tex); | |
9834 | |
9835 v6 = a4->uTextureHeight - height; | |
9836 memcpy(&tex, a4, sizeof(tex)); | |
9837 tex.uTextureHeight = v6; | |
9838 if ( (signed __int16)v6 > 0 ) | |
9839 DrawTextureIndexed(a2, a3, &tex); | |
9840 } | |
9841 | |
9842 | |
9843 | |
9844 //----- (004A6AB1) -------------------------------------------------------- | |
9845 void Render::DrawTextPalette(int x, int y, int a4, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8) | |
9846 { | |
9847 int v8; // edi@2 | |
9848 unsigned int v9; // esi@2 | |
9849 unsigned __int16 *v10; // eax@2 | |
9850 unsigned char *v11; // edx@2 | |
9851 unsigned int v12; // ebx@3 | |
9852 signed int v13; // edx@5 | |
9853 int v14; // edx@6 | |
9854 signed int v15; // ebx@7 | |
9855 unsigned int v16; // edx@9 | |
9856 signed int v17; // edi@10 | |
9857 signed int v18; // ebx@13 | |
9858 unsigned int v19; // edx@15 | |
9859 signed int v20; // esi@16 | |
9860 int v21; // ebx@22 | |
9861 char v22; // zf@28 | |
9862 int v23; // ebx@31 | |
9863 unsigned __int16 v24; // si@35 | |
9864 int v25; // [sp+Ch] [bp-4h]@2 | |
9865 int v26; // [sp+1Ch] [bp+Ch]@24 | |
9866 int v27; // [sp+1Ch] [bp+Ch]@33 | |
9867 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
9868 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
9869 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
9870 | |
9871 auto a2 = x; | |
9872 auto a3 = y; | |
9873 auto a6 = uFontHeight; | |
9874 if ( this->uNumSceneBegins ) | |
9875 { | |
9876 v8 = a5; | |
9877 v9 = a6; | |
9878 v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; | |
9879 v11 = (unsigned char *)a4; | |
9880 v25 = a4; | |
9881 if ( this->bClip ) | |
9882 { | |
9883 v12 = this->uClipX; | |
9884 if ( a2 < (signed int)v12 ) | |
9885 { | |
9886 v25 = v12 - a2 + a4; | |
9887 v10 += v12 - a2; | |
9888 v8 = a5 + a2 - v12; | |
9889 } | |
9890 v13 = this->uClipY; | |
9891 if ( a3 < v13 ) | |
9892 { | |
9893 v14 = v13 - a3; | |
9894 v25 += a5 * v14; | |
9895 v9 = a6 + a3 - this->uClipY; | |
9896 v10 += this->uTargetSurfacePitch * v14; | |
9897 } | |
9898 v15 = this->uClipX; | |
9899 if ( v15 < a2 ) | |
9900 v15 = a2; | |
9901 v16 = this->uClipZ; | |
9902 if ( v8 + v15 > (signed int)v16 ) | |
9903 { | |
9904 v17 = this->uClipX; | |
9905 if ( v17 < a2 ) | |
9906 v17 = a2; | |
9907 v8 = v16 - v17; | |
9908 } | |
9909 v18 = this->uClipY; | |
9910 if ( v18 < a3 ) | |
9911 v18 = a3; | |
9912 v19 = this->uClipW; | |
9913 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
9914 { | |
9915 v20 = this->uClipY; | |
9916 if ( v20 < a3 ) | |
9917 v20 = a3; | |
9918 v9 = v19 - v20; | |
9919 } | |
9920 v11 = (unsigned char *)v25; | |
9921 } | |
9922 if ( a8 ) | |
9923 { | |
9924 v28 = pRenderer->uTargetGMask | pRenderer->uTargetBMask; | |
9925 if ( (signed int)v9 > 0 ) | |
9926 { | |
9927 v23 = a5; | |
9928 v30 = v9; | |
9929 do | |
9930 { | |
9931 if ( v8 > 0 ) | |
9932 { | |
9933 v27 = v8; | |
9934 do | |
9935 { | |
9936 if ( *v11 ) | |
9937 v24 = pPalette[*v11]; | |
9938 else | |
9939 v24 = v28; | |
9940 *v10 = v24; | |
9941 ++v10; | |
9942 ++v11; | |
9943 --v27; | |
9944 } | |
9945 while ( v27 ); | |
9946 } | |
9947 v11 += v23 - v8; | |
9948 v22 = v30-- == 1; | |
9949 v10 += this->uTargetSurfacePitch - v8; | |
9950 } | |
9951 while ( !v22 ); | |
9952 } | |
9953 } | |
9954 else | |
9955 { | |
9956 if ( (signed int)v9 > 0 ) | |
9957 { | |
9958 v21 = a5; | |
9959 v29 = v9; | |
9960 do | |
9961 { | |
9962 if ( v8 > 0 ) | |
9963 { | |
9964 v26 = v8; | |
9965 do | |
9966 { | |
9967 if ( *v11 ) | |
9968 *v10 = pPalette[*v11]; | |
9969 ++v10; | |
9970 ++v11; | |
9971 --v26; | |
9972 } | |
9973 while ( v26 ); | |
9974 } | |
9975 v11 += v21 - v8; | |
9976 v22 = v29-- == 1; | |
9977 v10 += this->uTargetSurfacePitch - v8; | |
9978 } | |
9979 while ( !v22 ); | |
9980 } | |
9981 } | |
9982 } | |
9983 } | |
9984 | |
9985 //----- (004A68EF) -------------------------------------------------------- | |
9986 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
9987 { | |
9988 Texture *v4; // edi@2 | |
9989 unsigned int v5; // ebx@4 | |
9990 unsigned __int16 *v6; // eax@4 | |
9991 signed int v7; // edx@5 | |
9992 int v8; // edx@6 | |
9993 signed int v9; // edx@7 | |
9994 int v10; // edx@8 | |
9995 signed int v11; // edx@9 | |
9996 signed int v12; // esi@12 | |
9997 signed int v13; // esi@15 | |
9998 unsigned int v14; // edx@17 | |
9999 signed int v15; // esi@18 | |
10000 unsigned __int8 *v16; // ebx@22 | |
10001 char v17; // zf@28 | |
10002 int v18; // [sp+10h] [bp-10h]@4 | |
10003 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10004 int v20; // [sp+1Ch] [bp-4h]@4 | |
10005 int v21; // [sp+28h] [bp+8h]@24 | |
10006 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
10007 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
10008 | |
10009 if ( this->uNumSceneBegins ) | |
10010 { | |
10011 v4 = pTexture; | |
10012 if ( pTexture ) | |
10013 { | |
10014 if ( pTexture->pPalette16 ) | |
10015 { | |
10016 v5 = pTexture->uTextureHeight; | |
10017 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
10018 v19 = pTexture->pLevelOfDetail0; | |
10019 v20 = pTexture->uTextureWidth; | |
10020 v18 = pTexture->uTextureWidth; | |
10021 if ( this->bClip ) | |
10022 { | |
10023 v7 = this->uClipX; | |
10024 if ( a2 < v7 ) | |
10025 { | |
10026 v8 = v7 - a2; | |
10027 v19 += v8; | |
10028 v20 += a2 - this->uClipX; | |
10029 v6 += v8; | |
10030 } | |
10031 v9 = this->uClipY; | |
10032 v5 = pTexture->uTextureHeight; | |
10033 if ( a3 < v9 ) | |
10034 { | |
10035 v10 = v9 - a3; | |
10036 v19 += v18 * v10; | |
10037 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
10038 v4 = pTexture; | |
10039 v6 += this->uTargetSurfacePitch * v10; | |
10040 } | |
10041 v11 = this->uClipX; | |
10042 if ( v11 < a2 ) | |
10043 v11 = a2; | |
10044 pTexturea = this->uClipZ; | |
10045 if ( v11 + v20 > (signed int)pTexturea ) | |
10046 { | |
10047 v12 = this->uClipX; | |
10048 if ( v12 < a2 ) | |
10049 v12 = a2; | |
10050 v20 = pTexturea - v12; | |
10051 } | |
10052 v13 = this->uClipY; | |
10053 if ( v13 < a3 ) | |
10054 v13 = a3; | |
10055 v14 = this->uClipW; | |
10056 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10057 { | |
10058 v15 = this->uClipY; | |
10059 if ( v15 < a3 ) | |
10060 v15 = a3; | |
10061 v5 = v14 - v15; | |
10062 } | |
10063 } | |
10064 if ( (signed int)v5 > 0 ) | |
10065 { | |
10066 v22 = v5; | |
10067 v16 = v19; | |
10068 do | |
10069 { | |
10070 if ( v20 > 0 ) | |
10071 { | |
10072 v21 = v20; | |
10073 do | |
10074 { | |
10075 if ( *v16 ) | |
10076 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
10077 ++v6; | |
10078 ++v16; | |
10079 --v21; | |
10080 } | |
10081 while ( v21 ); | |
10082 } | |
10083 v16 += v18 - v20; | |
10084 v17 = v22-- == 1; | |
10085 v6 += this->uTargetSurfacePitch - v20; | |
10086 } | |
10087 while ( !v17 ); | |
10088 } | |
10089 } | |
10090 } | |
10091 } | |
10092 } | |
10093 | |
10094 | |
10095 //----- (004A6776) -------------------------------------------------------- | |
10096 void Render::_4A6776(unsigned int a2, unsigned int a3, Texture *a4) | |
10097 { | |
10098 Texture *v4; // edi@2 | |
10099 unsigned int v5; // ebx@4 | |
10100 unsigned __int16 *v6; // eax@4 | |
10101 unsigned int v7; // edx@5 | |
10102 unsigned int v8; // edx@6 | |
10103 unsigned int v9; // edx@7 | |
10104 unsigned int v10; // edx@8 | |
10105 unsigned int v11; // edx@9 | |
10106 unsigned int v12; // esi@12 | |
10107 unsigned int v13; // esi@15 | |
10108 unsigned int v14; // edx@17 | |
10109 unsigned int v15; // esi@18 | |
10110 unsigned __int8 *v16; // ebx@22 | |
10111 char v17; // zf@28 | |
10112 int v18; // [sp+10h] [bp-10h]@4 | |
10113 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10114 int v20; // [sp+1Ch] [bp-4h]@4 | |
10115 int a2a; // [sp+28h] [bp+8h]@24 | |
10116 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
10117 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
10118 | |
10119 if ( this->uNumSceneBegins ) | |
10120 { | |
10121 v4 = a4; | |
10122 if ( a4 ) | |
10123 { | |
10124 if ( a4->pPalette16 ) | |
10125 { | |
10126 v5 = a4->uTextureHeight; | |
10127 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
10128 v19 = a4->pLevelOfDetail0; | |
10129 v20 = a4->uTextureWidth; | |
10130 v18 = a4->uTextureWidth; | |
10131 if ( this->bClip ) | |
10132 { | |
10133 v7 = this->uClipX; | |
10134 if ( (signed int)a2 < (signed int)v7 ) | |
10135 { | |
10136 v8 = v7 - a2; | |
10137 v19 += v8; | |
10138 v20 += a2 - this->uClipX; | |
10139 v6 += v8; | |
10140 } | |
10141 v9 = this->uClipY; | |
10142 v5 = a4->uTextureHeight; | |
10143 if ( (signed int)a3 < (signed int)v9 ) | |
10144 { | |
10145 v10 = v9 - a3; | |
10146 v19 += v18 * v10; | |
10147 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
10148 v4 = a4; | |
10149 v6 += this->uTargetSurfacePitch * v10; | |
10150 } | |
10151 v11 = this->uClipX; | |
10152 if ( (signed int)v11 < (signed int)a2 ) | |
10153 v11 = a2; | |
10154 a4a = this->uClipZ; | |
10155 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
10156 { | |
10157 v12 = this->uClipX; | |
10158 if ( (signed int)v12 < (signed int)a2 ) | |
10159 v12 = a2; | |
10160 v20 = a4a - v12; | |
10161 } | |
10162 v13 = this->uClipY; | |
10163 if ( (signed int)v13 < (signed int)a3 ) | |
10164 v13 = a3; | |
10165 v14 = this->uClipW; | |
10166 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10167 { | |
10168 v15 = this->uClipY; | |
10169 if ( (signed int)v15 < (signed int)a3 ) | |
10170 v15 = a3; | |
10171 v5 = v14 - v15; | |
10172 } | |
10173 } | |
10174 if ( (signed int)v5 > 0 ) | |
10175 { | |
10176 a3a = v5; | |
10177 v16 = v19; | |
10178 do | |
10179 { | |
10180 if ( v20 > 0 ) | |
10181 { | |
10182 a2a = v20; | |
10183 do | |
10184 { | |
10185 if ( *v16 ) | |
10186 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
10187 ++v6; | |
10188 ++v16; | |
10189 --a2a; | |
10190 } | |
10191 while ( a2a ); | |
10192 } | |
10193 v16 += v18 - v20; | |
10194 v17 = a3a-- == 1; | |
10195 v6 += this->uTargetSurfacePitch - v20; | |
10196 } | |
10197 while ( !v17 ); | |
10198 } | |
10199 } | |
10200 } | |
10201 } | |
10202 } | |
10203 | |
10204 //----- (004A65CC) -------------------------------------------------------- | |
10205 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
10206 { | |
10207 unsigned __int16 *v8; // esi@6 | |
10208 unsigned int v9; // edi@6 | |
10209 unsigned int v10; // eax@7 | |
10210 unsigned int v11; // eax@8 | |
10211 unsigned int v12; // eax@9 | |
10212 unsigned int v13; // eax@10 | |
10213 unsigned int v14; // edx@11 | |
10214 unsigned int v15; // eax@13 | |
10215 unsigned int v16; // edx@14 | |
10216 unsigned int v17; // edx@17 | |
10217 unsigned int v18; // eax@19 | |
10218 unsigned int v19; // edx@20 | |
10219 int v20; // eax@27 | |
10220 int v21; // edx@29 | |
10221 int v22; // [sp+Ch] [bp-Ch]@6 | |
10222 int v23; // [sp+Ch] [bp-Ch]@24 | |
10223 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
10224 int xa; // [sp+20h] [bp+8h]@26 | |
10225 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
10226 int v27; // [sp+2Ch] [bp+14h]@6 | |
10227 | |
10228 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
10229 { | |
10230 v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch]; | |
10231 v24 = a4->pLevelOfDetail0; | |
10232 v27 = a4->uTextureWidth; | |
10233 v9 = a4->uTextureHeight; | |
10234 v22 = a4->uTextureWidth; | |
10235 if ( this->bClip ) | |
10236 { | |
10237 v10 = this->uClipX; | |
10238 if ( (signed int)x < (signed int)v10 ) | |
10239 { | |
10240 v11 = v10 - x; | |
10241 v24 += v11; | |
10242 v27 += x - this->uClipX; | |
10243 v8 += v11; | |
10244 } | |
10245 v12 = this->uClipY; | |
10246 if ( (signed int)y < (signed int)v12 ) | |
10247 { | |
10248 v13 = v12 - y; | |
10249 v24 += v22 * v13; | |
10250 v9 = y - this->uClipY + a4->uTextureHeight; | |
10251 v8 += this->uTargetSurfacePitch * v13; | |
10252 } | |
10253 v14 = this->uClipX; | |
10254 if ( (signed int)v14 < (signed int)x ) | |
10255 v14 = x; | |
10256 v15 = this->uClipZ; | |
10257 if ( (signed int)(v27 + v14) > (signed int)v15 ) | |
10258 { | |
10259 v16 = this->uClipX; | |
10260 if ( (signed int)v16 < (signed int)x ) | |
10261 v16 = x; | |
10262 v27 = v15 - v16; | |
10263 } | |
10264 v17 = this->uClipY; | |
10265 if ( (signed int)v17 < (signed int)y ) | |
10266 v17 = y; | |
10267 v18 = this->uClipW; | |
10268 if ( (signed int)(v9 + v17) > (signed int)v18 ) | |
10269 { | |
10270 v19 = this->uClipY; | |
10271 if ( (signed int)v19 < (signed int)y ) | |
10272 v19 = y; | |
10273 v9 = v18 - v19; | |
10274 } | |
10275 } | |
10276 if ( (signed int)v9 > 0 ) | |
10277 { | |
10278 ya = v9; | |
10279 v23 = v22 - v27; | |
10280 do | |
10281 { | |
10282 if ( v27 > 0 ) | |
10283 { | |
10284 xa = v27; | |
10285 do | |
10286 { | |
10287 v20 = *v24; | |
10288 if ( v20 >= a7 && v20 <= a8 ) | |
10289 { | |
10290 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
10291 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
10292 v21 = 2 * a8 - v21 - a7; | |
10293 *v8 = a4->pPalette16[v21]; | |
10294 } | |
10295 ++v8; | |
10296 ++v24; | |
10297 --xa; | |
10298 } | |
10299 while ( xa ); | |
10300 } | |
10301 v8 += this->uTargetSurfacePitch - v27; | |
10302 v24 += v23; | |
10303 --ya; | |
10304 } | |
10305 while ( ya ); | |
10306 } | |
10307 } | |
10308 } | |
10309 | |
10310 | |
10311 //----- (004A63E6) -------------------------------------------------------- | |
10312 void Render::_4A63E6(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
10313 { | |
10314 Texture *v8; // eax@2 | |
10315 Texture *v9; // ebx@4 | |
10316 unsigned __int16 *v10; // esi@6 | |
10317 unsigned int v11; // edi@7 | |
10318 unsigned int v12; // eax@9 | |
10319 unsigned int v13; // eax@10 | |
10320 unsigned int v14; // edx@11 | |
10321 unsigned int v15; // eax@13 | |
10322 unsigned int v16; // edx@14 | |
10323 unsigned int v17; // edx@17 | |
10324 unsigned int v18; // eax@19 | |
10325 unsigned int v19; // edx@20 | |
10326 int v20; // eax@27 | |
10327 int v21; // edx@29 | |
10328 int v22; // [sp+Ch] [bp-Ch]@6 | |
10329 int v23; // [sp+Ch] [bp-Ch]@24 | |
10330 int v24; // [sp+10h] [bp-8h]@6 | |
10331 int v25; // [sp+14h] [bp-4h]@6 | |
10332 int i; // [sp+20h] [bp+8h]@25 | |
10333 int v27; // [sp+24h] [bp+Ch]@23 | |
10334 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
10335 | |
10336 if ( this->uNumSceneBegins ) | |
10337 { | |
10338 v8 = a4; | |
10339 if ( a4 ) | |
10340 { | |
10341 if ( a4->pPalette16 ) | |
10342 { | |
10343 v9 = a5; | |
10344 if ( a5 ) | |
10345 { | |
10346 if ( a5->pPalette16 ) | |
10347 { | |
10348 v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
10349 v28 = a4->pLevelOfDetail0; | |
10350 v25 = v8->uTextureWidth; | |
10351 v24 = v8->uTextureHeight; | |
10352 v22 = v8->uTextureWidth; | |
10353 if ( this->bClip ) | |
10354 { | |
10355 v11 = this->uClipX; | |
10356 if ( (signed int)a2 < (signed int)v11 ) | |
10357 { | |
10358 v28 += v11 - a2; | |
10359 v25 += a2 - v11; | |
10360 v9 = a5; | |
10361 v10 += v11 - a2; | |
10362 } | |
10363 v12 = this->uClipY; | |
10364 if ( (signed int)a3 < (signed int)v12 ) | |
10365 { | |
10366 v13 = v12 - a3; | |
10367 v9 = a5; | |
10368 v28 += v22 * v13; | |
10369 v24 += a3 - this->uClipY; | |
10370 v10 += this->uTargetSurfacePitch * v13; | |
10371 } | |
10372 v14 = this->uClipX; | |
10373 if ( (signed int)v14 < (signed int)a2 ) | |
10374 v14 = a2; | |
10375 v15 = this->uClipZ; | |
10376 if ( (signed int)(v25 + v14) > (signed int)v15 ) | |
10377 { | |
10378 v16 = this->uClipX; | |
10379 if ( (signed int)v16 < (signed int)a2 ) | |
10380 v16 = a2; | |
10381 v25 = v15 - v16; | |
10382 } | |
10383 v17 = this->uClipY; | |
10384 if ( (signed int)v17 < (signed int)a3 ) | |
10385 v17 = a3; | |
10386 v18 = this->uClipW; | |
10387 if ( (signed int)(v24 + v17) > (signed int)v18 ) | |
10388 { | |
10389 v19 = this->uClipY; | |
10390 if ( (signed int)v19 < (signed int)a3 ) | |
10391 v19 = a3; | |
10392 v24 = v18 - v19; | |
10393 } | |
10394 } | |
10395 v27 = 0; | |
10396 if ( v24 > 0 ) | |
10397 { | |
10398 v23 = v22 - v25; | |
10399 do | |
10400 { | |
10401 for ( i = 0; i < v25; ++v28 ) | |
10402 { | |
10403 if ( *v28 ) | |
10404 { | |
10405 v20 = *(&v9->pLevelOfDetail0[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); | |
10406 if ( v20 >= a7 ) | |
10407 { | |
10408 if ( v20 <= a8 ) | |
10409 { | |
10410 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
10411 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
10412 v21 = 2 * a8 - v21 - a7; | |
10413 v9 = a5; | |
10414 *v10 = a5->pPalette16[v21]; | |
10415 } | |
10416 } | |
10417 } | |
10418 ++i; | |
10419 ++v10; | |
10420 } | |
10421 ++v27; | |
10422 v10 += this->uTargetSurfacePitch - v25; | |
10423 v28 += v23; | |
10424 } | |
10425 while ( v27 < v24 ); | |
10426 } | |
10427 } | |
10428 } | |
10429 } | |
10430 } | |
10431 } | |
10432 } | |
10433 | |
10434 | |
10435 //----- (004A6274) -------------------------------------------------------- | |
10436 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
10437 { | |
10438 Texture *pCurrentTexture; // edi@2 | |
10439 int uHeight; // ebx@4 | |
10440 unsigned __int16 *v6; // eax@4 | |
10441 unsigned int v7; // edx@5 | |
10442 unsigned int v8; // edx@6 | |
10443 unsigned int v9; // edx@7 | |
10444 unsigned int v10; // edx@8 | |
10445 unsigned int v11; // edx@9 | |
10446 unsigned int v12; // esi@12 | |
10447 unsigned int v13; // esi@15 | |
10448 unsigned int v14; // edx@17 | |
10449 unsigned int v15; // esi@18 | |
10450 unsigned __int8 *v16; // ebx@22 | |
10451 char uFlag; // zf@28 | |
10452 int v18; // [sp+10h] [bp-10h]@4 | |
10453 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10454 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
10455 int uXa; // [sp+28h] [bp+8h]@24 | |
10456 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
10457 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
10458 | |
10459 if ( this->uNumSceneBegins ) | |
10460 { | |
10461 pCurrentTexture = pTexture; | |
10462 if ( pTexture ) | |
10463 { | |
10464 if ( pTexture->pPalette16 ) | |
10465 { | |
10466 uHeight = pTexture->uTextureHeight; | |
10467 v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
10468 v19 = pTexture->pLevelOfDetail0; | |
10469 uWidth = pTexture->uTextureWidth; | |
10470 v18 = pTexture->uTextureWidth; | |
10471 if ( this->bClip ) | |
10472 { | |
10473 v7 = this->uClipX; | |
10474 if ( (signed int)uX < (signed int)v7 ) | |
10475 { | |
10476 v8 = v7 - uX; | |
10477 v19 += v8; | |
10478 uWidth += uX - this->uClipX; | |
10479 v6 += v8; | |
10480 } | |
10481 v9 = this->uClipY; | |
10482 uHeight = pTexture->uTextureHeight; | |
10483 if ( (signed int)uY < (signed int)v9 ) | |
10484 { | |
10485 v10 = v9 - uY; | |
10486 v19 += v18 * v10; | |
10487 uHeight = uY - this->uClipY + pTexture->uTextureHeight; | |
10488 pCurrentTexture = pTexture; | |
10489 v6 += this->uTargetSurfacePitch * v10; | |
10490 } | |
10491 v11 = this->uClipX; | |
10492 if ( (signed int)v11 < (signed int)uX ) | |
10493 v11 = uX; | |
10494 pTexturea = this->uClipZ; | |
10495 if ( (signed int)(v11 + uWidth) > (signed int)pTexturea ) | |
10496 { | |
10497 v12 = this->uClipX; | |
10498 if ( (signed int)v12 < (signed int)uX ) | |
10499 v12 = uX; | |
10500 uWidth = pTexturea - v12; | |
10501 } | |
10502 v13 = this->uClipY; | |
10503 if ( (signed int)v13 < (signed int)uY ) | |
10504 v13 = uY; | |
10505 v14 = this->uClipW; | |
10506 if ( (signed int)(uHeight + v13) > (signed int)v14 ) | |
10507 { | |
10508 v15 = this->uClipY; | |
10509 if ( (signed int)v15 < (signed int)uY ) | |
10510 v15 = uY; | |
10511 uHeight = v14 - v15; | |
10512 } | |
10513 } | |
10514 if ( (signed int)uHeight > 0 ) | |
10515 { | |
10516 uYa = uHeight; | |
10517 v16 = v19; | |
10518 do | |
10519 { | |
10520 if ( uWidth > 0 ) | |
10521 { | |
10522 uXa = uWidth; | |
10523 do | |
10524 { | |
10525 if ( *v16 ) | |
10526 *v6 = pCurrentTexture->pPalette16[*v16]; | |
10527 ++v6; | |
10528 ++v16; | |
10529 } | |
10530 while ( uXa-- !=1 ); | |
10531 } | |
10532 v16 += v18 - uWidth; | |
10533 uFlag = uYa-- == 1; | |
10534 v6 += this->uTargetSurfacePitch - uWidth; | |
10535 } | |
10536 while ( !uFlag ); | |
10537 } | |
10538 } | |
10539 } | |
10540 } | |
10541 } | |
10542 | |
10543 | |
10544 //----- (004A612A) -------------------------------------------------------- | |
10545 void Render::_4A612A(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) | |
10546 { | |
10547 Texture *v5; // eax@2 | |
10548 unsigned int v6; // edx@3 | |
10549 int v7; // ebx@3 | |
10550 int v8; // edi@3 | |
10551 signed int v9; // eax@4 | |
10552 int v10; // eax@5 | |
10553 unsigned int v11; // esi@6 | |
10554 signed int v12; // esi@8 | |
10555 unsigned int v13; // eax@10 | |
10556 signed int v14; // esi@11 | |
10557 unsigned int v15; // esi@14 | |
10558 unsigned int v16; // eax@16 | |
10559 unsigned int v17; // ecx@17 | |
10560 int v18; // edx@23 | |
10561 int v19; // [sp+Ch] [bp-Ch]@3 | |
10562 int v20; // [sp+10h] [bp-8h]@3 | |
10563 int uOutXa; // [sp+20h] [bp+8h]@21 | |
10564 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
10565 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
10566 | |
10567 if ( this->uNumSceneBegins ) | |
10568 { | |
10569 v5 = pTexture; | |
10570 if ( pTexture ) | |
10571 { | |
10572 v6 = uOutY; | |
10573 v7 = pTexture->uTextureHeight; | |
10574 pZBuffer = &this->pActiveZBuffer[uOutX + 640 * uOutY]; | |
10575 uOutYa = v5->pLevelOfDetail0; | |
10576 v8 = v5->uTextureWidth; | |
10577 v20 = v5->uTextureWidth; | |
10578 v19 = v5->uTextureWidth; | |
10579 if ( this->bClip ) | |
10580 { | |
10581 v9 = this->uClipX; | |
10582 if ( uOutX < v9 ) | |
10583 { | |
10584 v10 = v9 - uOutX; | |
10585 uOutYa += v10; | |
10586 v8 += uOutX - this->uClipX; | |
10587 v20 = v8; | |
10588 pZBuffer += v10; | |
10589 } | |
10590 v11 = this->uClipY; | |
10591 if ( (signed int)v6 < (signed int)v11 ) | |
10592 { | |
10593 uOutYa += v19 * (v11 - v6); | |
10594 v7 += v6 - v11; | |
10595 pZBuffer += 640 * (v11 - v6); | |
10596 v8 = v20; | |
10597 } | |
10598 v12 = this->uClipX; | |
10599 if ( v12 < uOutX ) | |
10600 v12 = uOutX; | |
10601 v13 = this->uClipZ; | |
10602 if ( v8 + v12 > (signed int)v13 ) | |
10603 { | |
10604 v14 = this->uClipX; | |
10605 if ( v14 < uOutX ) | |
10606 v14 = uOutX; | |
10607 v8 = v13 - v14; | |
10608 } | |
10609 v15 = this->uClipY; | |
10610 if ( (signed int)v15 < (signed int)v6 ) | |
10611 v15 = v6; | |
10612 v16 = this->uClipW; | |
10613 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
10614 { | |
10615 v17 = this->uClipY; | |
10616 if ( (signed int)v17 >= (signed int)v6 ) | |
10617 v6 = v17; | |
10618 v7 = v16 - v6; | |
10619 } | |
10620 } | |
10621 if ( v7 > 0 ) | |
10622 { | |
10623 uOutXa = v7; | |
10624 do | |
10625 { | |
10626 if ( v8 > 0 ) | |
10627 { | |
10628 v18 = v8; | |
10629 do | |
10630 { | |
10631 if ( *uOutYa ) | |
10632 *pZBuffer = zVal; | |
10633 ++pZBuffer; | |
10634 ++uOutYa; | |
10635 --v18; | |
10636 } | |
10637 while ( v18 ); | |
10638 } | |
10639 pZBuffer += 640 - v8; | |
10640 uOutYa += v19 - v8; | |
10641 --uOutXa; | |
10642 } | |
10643 while ( uOutXa ); | |
10644 } | |
10645 } | |
10646 } | |
10647 } | |
10648 | |
10649 | |
10650 //----- (004A601E) -------------------------------------------------------- | |
10651 void Render::_4A601E(signed int a2, signed int a3, Texture *pTexture, int a5) | |
10652 { | |
10653 signed int v5; // edx@3 | |
10654 int v6; // ebx@3 | |
10655 int v7; // esi@3 | |
10656 void *v8; // esi@3 | |
10657 unsigned int v9; // eax@4 | |
10658 unsigned int v10; // eax@6 | |
10659 signed int v11; // edi@8 | |
10660 unsigned int v12; // eax@10 | |
10661 signed int v13; // edi@11 | |
10662 unsigned int v14; // edi@14 | |
10663 unsigned int v15; // eax@16 | |
10664 unsigned int v16; // ecx@17 | |
10665 int v17; // [sp+18h] [bp+Ch]@3 | |
10666 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
10667 | |
10668 if ( this->uNumSceneBegins && pTexture ) | |
10669 { | |
10670 v5 = a3; | |
10671 v6 = pTexture->uTextureHeight; | |
10672 v7 = 5 * a3; | |
10673 v17 = pTexture->uTextureHeight; | |
10674 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
10675 pTexturea = pTexture->uTextureWidth; | |
10676 if ( this->bClip ) | |
10677 { | |
10678 v9 = this->uClipX; | |
10679 if ( a2 < (signed int)v9 ) | |
10680 { | |
10681 pTexturea += a2 - v9; | |
10682 v8 = (char *)v8 + 4 * (v9 - a2); | |
10683 } | |
10684 v10 = this->uClipY; | |
10685 if ( v5 < (signed int)v10 ) | |
10686 { | |
10687 v17 += v5 - v10; | |
10688 v8 = (char *)v8 + 2560 * (v10 - v5); | |
10689 } | |
10690 v11 = this->uClipX; | |
10691 if ( v11 < a2 ) | |
10692 v11 = a2; | |
10693 v12 = this->uClipZ; | |
10694 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
10695 { | |
10696 v13 = this->uClipX; | |
10697 if ( v13 < a2 ) | |
10698 v13 = a2; | |
10699 pTexturea = v12 - v13; | |
10700 } | |
10701 v14 = this->uClipY; | |
10702 if ( (signed int)v14 < v5 ) | |
10703 v14 = v5; | |
10704 v6 = v17; | |
10705 v15 = this->uClipW; | |
10706 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
10707 { | |
10708 v16 = this->uClipY; | |
10709 if ( (signed int)v16 < v5 ) | |
10710 v16 = v5; | |
10711 v6 = v15 - v16; | |
10712 } | |
10713 } | |
10714 if ( v6 > 0 ) | |
10715 { | |
10716 do | |
10717 { | |
10718 if ( (signed int)pTexturea > 0 ) | |
10719 { | |
10720 memset32(v8, a5, pTexturea); | |
10721 v8 = (char *)v8 + 4 * pTexturea; | |
10722 } | |
10723 v8 = (char *)v8 + 4 * (640 - pTexturea); | |
10724 --v6; | |
10725 } | |
10726 while ( v6 ); | |
10727 } | |
10728 } | |
10729 } | |
10730 | |
10731 //----- (004A5EB2) -------------------------------------------------------- | |
10732 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
10733 { | |
10734 Texture *v4; // edi@2 | |
10735 unsigned int v5; // ebx@4 | |
10736 unsigned __int16 *pTarget; // eax@4 | |
10737 unsigned int v7; // edx@5 | |
10738 unsigned int v8; // edx@6 | |
10739 unsigned int v9; // edx@7 | |
10740 unsigned int v10; // edx@8 | |
10741 unsigned int v11; // edx@9 | |
10742 unsigned int v12; // esi@12 | |
10743 unsigned int v13; // esi@15 | |
10744 unsigned int v14; // edx@17 | |
10745 unsigned int v15; // esi@18 | |
10746 unsigned __int8 *v16; // edx@22 | |
10747 char v17; // zf@26 | |
10748 int v18; // [sp+10h] [bp-10h]@4 | |
10749 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10750 int v20; // [sp+1Ch] [bp-4h]@4 | |
10751 int uXa; // [sp+28h] [bp+8h]@24 | |
10752 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
10753 unsigned int v23; // [sp+30h] [bp+10h]@11 | |
10754 | |
10755 if ( this->uNumSceneBegins ) | |
10756 { | |
10757 v4 = a4; | |
10758 if ( a4 ) | |
10759 { | |
10760 if ( a4->pPalette16 ) | |
10761 { | |
10762 v5 = a4->uTextureHeight; | |
10763 pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
10764 v19 = a4->pLevelOfDetail0; | |
10765 v20 = a4->uTextureWidth; | |
10766 v18 = a4->uTextureWidth; | |
10767 if ( this->bClip ) | |
10768 { | |
10769 v7 = this->uClipX; | |
10770 if ( (signed int)uX < (signed int)v7 ) | |
10771 { | |
10772 v8 = v7 - uX; | |
10773 v19 += v8; | |
10774 v20 += uX - this->uClipX; | |
10775 pTarget += v8; | |
10776 } | |
10777 v9 = this->uClipY; | |
10778 v5 = a4->uTextureHeight; | |
10779 if ( (signed int)uY < (signed int)v9 ) | |
10780 { | |
10781 v10 = v9 - uY; | |
10782 v19 += v18 * v10; | |
10783 v5 = uY - this->uClipY + a4->uTextureHeight; | |
10784 v4 = a4; | |
10785 pTarget += this->uTargetSurfacePitch * v10; | |
10786 } | |
10787 v11 = this->uClipX; | |
10788 if ( (signed int)v11 < (signed int)uX ) | |
10789 v11 = uX; | |
10790 v23 = this->uClipZ; | |
10791 if ( (signed int)(v11 + v20) > (signed int)v23 ) | |
10792 { | |
10793 v12 = this->uClipX; | |
10794 if ( (signed int)v12 < (signed int)uX ) | |
10795 v12 = uX; | |
10796 v20 = v23 - v12; | |
10797 } | |
10798 v13 = this->uClipY; | |
10799 if ( (signed int)v13 < (signed int)uY ) | |
10800 v13 = uY; | |
10801 v14 = this->uClipW; | |
10802 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10803 { | |
10804 v15 = this->uClipY; | |
10805 if ( (signed int)v15 < (signed int)uY ) | |
10806 v15 = uY; | |
10807 v5 = v14 - v15; | |
10808 } | |
10809 } | |
10810 if ( (signed int)v5 > 0 ) | |
10811 { | |
10812 uYa = v5; | |
10813 v16 = v19; | |
10814 do | |
10815 { | |
10816 if ( v20 > 0 ) | |
10817 { | |
10818 uXa = v20; | |
10819 do | |
10820 { | |
10821 *pTarget = v4->pPalette16[*v16]; | |
10822 ++pTarget; | |
10823 ++v16; | |
10824 --uXa; | |
10825 } | |
10826 while ( uXa ); | |
10827 } | |
10828 v16 += v18 - v20; | |
10829 v17 = uYa-- == 1; | |
10830 pTarget += this->uTargetSurfacePitch - v20; | |
10831 } | |
10832 while ( !v17 ); | |
10833 } | |
10834 } | |
10835 } | |
10836 } | |
10837 } | |
10838 | |
10839 //----- (004667E9) -------------------------------------------------------- | |
10840 void Render::ChangeBetweenWinFullscreenModes() | |
10841 { | |
10842 float v0; // ST14_4@17 | |
10843 int v1; // edx@24 | |
10844 signed int v2; // ecx@24 | |
10845 int v3; // esi@25 | |
10846 int v4; // edx@26 | |
10847 ObjectDesc *v5; // eax@26 | |
10848 RGBTexture *v6; // esi@33 | |
10849 const char *v7; // eax@34 | |
10850 const char *v8; // [sp-4h] [bp-28h]@33 | |
10851 int v9; // [sp+0h] [bp-24h]@33 | |
10852 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
10853 | |
10854 if ( pRenderer->bWindowMode ) | |
10855 goto LABEL_52; | |
10856 if ( dword_6BE364_game_settings_1 & 2 ) | |
10857 { | |
10858 ModalWindow(pGlobalTXT_LocalizationStrings[62], 0);// "Might and Magic VII requires your desktop to be in 16bit (32k or 65k) Color mode in order to operate in a window." | |
10859 return; | |
10860 } | |
10861 if ( !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) | |
10862 { | |
10863 LABEL_52: | |
10864 if ( pEventTimer->bPaused ) | |
10865 BYTE1(dword_6BE364_game_settings_1) |= 8u; | |
10866 else | |
10867 pEventTimer->Pause(); | |
10868 if ( pMiscTimer->bPaused ) | |
10869 BYTE1(dword_6BE364_game_settings_1) |= 0x10u; | |
10870 else | |
10871 pMiscTimer->Pause(); | |
10872 pMouse->bActive = 0; | |
10873 if ( pRenderer->pRenderD3D ) | |
10874 { | |
10875 pBitmaps_LOD->ReleaseHardwareTextures(); | |
10876 pSprites_LOD->ReleaseAll(); | |
10877 } | |
10878 if ( pRenderer->bWindowMode ) | |
10879 { | |
10880 if ( GetWindowRect(hWnd, &Rect) ) | |
10881 { | |
10882 WriteWindowsRegistryInt("window X", Rect.left); | |
10883 WriteWindowsRegistryInt("window Y", Rect.top); | |
10884 uWindowX = Rect.left; | |
10885 uWindowY = Rect.top; | |
10886 } | |
10887 SetMenu(hWnd, 0); | |
10888 SetWindowLongA(hWnd, -20, 0); | |
10889 SetWindowLongA(hWnd, -16, 0x10000000u); | |
10890 pRenderer->InitializeFullscreen(hWnd); | |
10891 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; | |
10892 pGame->pGammaController->Initialize(v0); | |
10893 } | |
10894 else | |
10895 { | |
10896 ClipCursor(0); | |
10897 pRenderer->SwitchToWindow(hWnd); | |
10898 SetWindowLongA(hWnd, -16, uWindowStyle); | |
10899 SetMenu(hWnd, hOSMenu); | |
10900 } | |
10901 if ( pRenderer->pRenderD3D ) | |
10902 { | |
10903 pBitmaps_LOD->_410423_move_textures_to_device(); | |
10904 pSprites_LOD->MoveSpritesToVideoMemory(); | |
10905 } | |
10906 if ( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits | |
10907 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits | |
10908 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits ) | |
10909 goto LABEL_38; | |
10910 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10911 pPaletteManager->RecalculateAll(); | |
10912 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10913 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10914 v2 = 0; | |
10915 if ( (signed int)pObjectList->uNumObjects > 0 ) | |
10916 { | |
10917 v3 = 0; | |
10918 do | |
10919 { | |
10920 BYTE3(v4) = 0; | |
10921 v5 = &pObjectList->pObjects[v3]; | |
10922 ++v3; | |
10923 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; | |
10924 LOBYTE(v4) = v5->uParticleTrailColorG; | |
10925 v1 = v5->uParticleTrailColorB | (v4 << 8); | |
10926 ++v2; | |
10927 v5->uParticleTrailColor = v1; | |
10928 } | |
10929 while ( v2 < (signed int)pObjectList->uNumObjects ); | |
10930 } | |
10931 LOBYTE(v1) = 1; | |
10932 SetUserInterface(pParty->uAlignment, v1); | |
10933 if ( pVideoPlayer->pVideoFrame.pPixels ) | |
10934 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); | |
10935 if ( uCurrentMenuID ) | |
10936 { | |
10937 if ( uCurrentMenuID != 6 ) | |
10938 { | |
10939 if ( uCurrentMenuID == 8 ) | |
10940 dword_A74C88 = 1; | |
10941 goto LABEL_38; | |
10942 } | |
10943 v6 = &pTexture_PCX; | |
10944 pTexture_PCX.Release(); | |
10945 v9 = 0; | |
10946 v8 = "makeme.pcx"; | |
10947 } | |
10948 else | |
10949 { | |
10950 v6 = &pTexture_PCX; | |
10951 pTexture_PCX.Release(); | |
10952 v7 = "title.pcx"; | |
10953 if ( uCurrentMenuID ) | |
10954 v7 = "lsave640.pcx"; | |
10955 v9 = 0; | |
10956 v8 = v7; | |
10957 } | |
10958 v6->Load(v8, v9); | |
10959 LABEL_38: | |
10960 viewparams->bRedrawGameUI = 1; | |
10961 viewparams->_443343(); | |
10962 pMouse->SetCurrentCursorBitmap(); | |
10963 if ( pRenderer->bWindowMode ) | |
10964 { | |
10965 InvalidateRect(0, 0, 0); | |
10966 MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); | |
10967 ShowWindow(hWnd, 1); | |
10968 } | |
10969 pMouse->bActive = 1; | |
10970 if ( pVideoPlayer->AnyMovieLoaded() ) | |
10971 pVideoPlayer->_4BF73A(); | |
10972 if ( BYTE1(dword_6BE364_game_settings_1) & 8 ) | |
10973 BYTE1(dword_6BE364_game_settings_1) &= 0xF7u; | |
10974 else | |
10975 pEventTimer->Resume(); | |
10976 if ( BYTE1(dword_6BE364_game_settings_1) & 0x10 ) | |
10977 BYTE1(dword_6BE364_game_settings_1) &= 0xEFu; | |
10978 else | |
10979 pMiscTimer->Resume(); | |
10980 pAsyncMouse->Release(); | |
10981 CreateAsyncMouse(); | |
10982 if (pAsyncMouse) | |
10983 pAsyncMouse->Clip(); | |
10984 } | |
10985 } | |
10986 // 6BE364: using guessed type int dword_6BE364_game_settings_1; | |
10987 // A74C88: using guessed type int dword_A74C88; | |
10988 | |
10989 | |
10990 //----- (0044EC20) -------------------------------------------------------- | |
10991 bool RenderD3D::DoesRaiseExceptions() | |
10992 { | |
10993 return true; | |
10994 } | |
10995 | |
10996 | |
10997 //----- (0040DBD3) -------------------------------------------------------- | |
10998 void __fastcall Render::SetPixel(Vec2_int_ *pTargetXY, unsigned __int16 uColor) | |
10999 { | |
11000 Vec2_int_ *pTargetXY_; // esi@1 | |
11001 unsigned __int16 v3; // di@1 | |
11002 signed int v4; // ecx@2 | |
11003 signed int v5; // eax@4 | |
11004 | |
11005 pTargetXY_ = pTargetXY; | |
11006 v3 = uColor; | |
11007 pRenderer->BeginScene(); | |
11008 if ( pRenderer->uNumSceneBegins ) | |
11009 { | |
11010 v4 = pTargetXY_->x; | |
11011 if ( pTargetXY_->x >= 0 ) | |
11012 { | |
11013 if ( v4 <= 639 ) | |
11014 { | |
11015 v5 = pTargetXY_->y; | |
11016 if ( v5 >= 0 ) | |
11017 { | |
11018 if ( v5 <= 479 ) | |
11019 pRenderer->pTargetSurface[v4 + pRenderer->uTargetSurfacePitch * v5] = v3; | |
11020 } | |
11021 } | |
11022 } | |
11023 pRenderer->EndScene(); | |
11024 } | |
11025 } | |
11026 | |
11027 | |
11028 //----- (004524D8) -------------------------------------------------------- | |
11029 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
11030 { | |
11031 int v11; // eax@13 | |
11032 int v12; // ecx@13 | |
11033 void *v13; // eax@13 | |
11034 unsigned __int8 v14; // zf@13 | |
11035 unsigned __int8 v15; // sf@13 | |
11036 int v16; // esi@14 | |
11037 int v17; // ecx@16 | |
11038 int v18; // esi@16 | |
11039 unsigned __int16 *v19; // eax@16 | |
11040 int v20; // edx@16 | |
11041 int v21; // ecx@16 | |
11042 int v22; // eax@16 | |
11043 int v23; // esi@16 | |
11044 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
11045 int v27; // [sp+28h] [bp-Ch]@14 | |
11046 int v28; // [sp+2Ch] [bp-8h]@13 | |
11047 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
11048 | |
11049 //v3 = this; | |
11050 //sprintf(Str1, "%s", pName); | |
11051 //v4 = uNumItems; | |
11052 if (!uNumItems) | |
11053 return nullptr; | |
11054 | |
11055 //{ | |
11056 //v5 = 0, pDesta = uNumItems; | |
11057 uint idx1 = 0, | |
11058 idx2 = uNumItems; | |
11059 while (true) | |
11060 { | |
11061 auto i = idx1 + (idx2 - idx1) / 2; | |
11062 | |
11063 auto res = strcmpi(pName, pSpriteNames[i]); | |
11064 if (!res) | |
11065 { | |
11066 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
11067 break; | |
11068 } | |
11069 else if (res < 0) | |
11070 idx2 = idx1 + (idx2 - idx1) / 2; | |
11071 else | |
11072 idx1 = i + 1; | |
11073 | |
11074 if ( idx1 >= idx2 ) | |
11075 return false; | |
11076 } | |
11077 | |
11078 | |
11079 uint uCompressedSize = 0; | |
11080 fread(&uCompressedSize, 4, 1, pFile); | |
11081 | |
11082 auto pTex = new HWLTexture; | |
11083 fread(&pTex->field_18, 4, 1, pFile); | |
11084 fread(&pTex->field_1C, 4, 1, pFile); | |
11085 fread(&pTex->field_20, 4, 1, pFile); | |
11086 fread(&pTex->field_24, 4, 1, pFile); | |
11087 fread(&pTex->uWidth, 4, 1, pFile); | |
11088 fread(&pTex->uHeight, 4, 1, pFile); | |
11089 fread(&pTex->field_30, 4, 1, pFile); | |
11090 fread(&pTex->field_34, 4, 1, pFile); | |
11091 | |
11092 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
11093 if (uCompressedSize) | |
11094 { | |
11095 auto pCompressedData = new char[uCompressedSize]; | |
11096 { | |
11097 fread(pCompressedData, 1, uCompressedSize, pFile); | |
11098 auto uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); | |
11099 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); | |
11100 } | |
11101 delete [] pCompressedData; | |
11102 } | |
11103 else | |
11104 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
11105 | |
11106 if ( field_61A94_scale_hwls_to_half ) | |
11107 { | |
11108 v11 = pTex->uHeight / 2; | |
11109 v12 = pTex->uWidth / 2; | |
11110 pTex->uHeight = v11; | |
11111 pTex->uWidth = v12; | |
11112 v13 = new unsigned __int16[v12 * v11]; | |
11113 v28 = 0; | |
11114 v14 = pTex->uHeight == 0; | |
11115 v15 = (pTex->uHeight & 0x80000000u) != 0; | |
11116 v26 = (unsigned __int16 *)v13; | |
11117 if ( !(v15 | v14) ) | |
11118 { | |
11119 v16 = pTex->uWidth; | |
11120 v27 = 1; | |
11121 do | |
11122 { | |
11123 pDestb = 0; | |
11124 if ( v16 > 0 ) | |
11125 { | |
11126 do | |
11127 { | |
11128 v17 = v16 * v27; | |
11129 v18 = v28 * v16; | |
11130 v19 = pTex->pPixels; | |
11131 v20 = pDestb + 2 * v18; | |
11132 v21 = (int)&v19[2 * (pDestb + v17)]; | |
11133 v22 = (int)&v19[2 * v20]; | |
11134 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
11135 LOWORD(v21) = *(unsigned short *)v21; | |
11136 v23 = pDestb++ + v18; | |
11137 v26[v23] = sub_452442(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
11138 v16 = pTex->uWidth; | |
11139 } | |
11140 while (pDestb < pTex->uWidth); | |
11141 } | |
11142 ++v28; | |
11143 v27 += 2; | |
11144 } | |
11145 while ( v28 < (signed int)pTex->uHeight ); | |
11146 } | |
11147 delete [] pTex->pPixels; | |
11148 pTex->pPixels = v26; | |
11149 } | |
11150 return pTex; | |
11151 //result = pTex; | |
11152 // } | |
11153 // else | |
11154 // { | |
11155 //LABEL_8: | |
11156 // return nullptr; | |
11157 // } | |
11158 } | |
11159 | |
11160 //----- (0045271F) -------------------------------------------------------- | |
11161 bool RenderHWLContainer::Release() | |
11162 { | |
11163 RenderHWLContainer *v1; // esi@1 | |
11164 int v2; // ebx@1 | |
11165 void **v3; // edi@3 | |
11166 __int32 v4; // eax@6 | |
11167 FILE *v5; // ST24_4@6 | |
11168 size_t *v6; // edi@6 | |
11169 int v7; // ebx@7 | |
11170 signed int v9; // [sp+0h] [bp-8h]@6 | |
11171 FILE *File; // [sp+4h] [bp-4h]@6 | |
11172 | |
11173 v1 = this; | |
11174 v2 = 0; | |
11175 if ( this->bDumpDebug ) | |
11176 { | |
11177 File = fopen("logd3d.txt", "w"); | |
11178 v4 = ftell(v1->pFile); | |
11179 v5 = v1->pFile; | |
11180 v6 = &v1->uNumItems; | |
11181 v1->uDataOffset = v4; | |
11182 fwrite(&v1->uNumItems, 4u, 1u, v5); | |
11183 v9 = 0; | |
11184 if ( (signed int)v1->uNumItems > 0 ) | |
11185 { | |
11186 v7 = (int)v1->pSpriteNames; | |
11187 do | |
11188 { | |
11189 fwrite(*(const void **)v7, 1u, 0x14u, v1->pFile); | |
11190 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", *(unsigned int *)v7, *(unsigned int *)(v7 + 200000)); | |
11191 ++v9; | |
11192 v7 += 4; | |
11193 } | |
11194 while ( v9 < (signed int)*v6 ); | |
11195 v2 = 0; | |
11196 } | |
11197 fwrite(v1->pSpriteOffsets, 4u, *v6, v1->pFile); | |
11198 fseek(v1->pFile, 4, v2); | |
11199 fwrite(&v1->uDataOffset, 4u, 1u, v1->pFile); | |
11200 fclose(v1->pFile); | |
11201 fclose(File); | |
11202 } | |
11203 else | |
11204 { | |
11205 fclose(this->pFile); | |
11206 if ( (signed int)v1->uNumItems > 0 ) | |
11207 { | |
11208 v3 = (void **)v1->pSpriteNames; | |
11209 do | |
11210 { | |
11211 free(*v3); | |
11212 ++v2; | |
11213 ++v3; | |
11214 } | |
11215 while ( v2 < (signed int)v1->uNumItems ); | |
11216 } | |
11217 } | |
11218 return 1; | |
11219 } | |
11220 | |
11221 //----- (00452347) -------------------------------------------------------- | |
11222 RenderHWLContainer::RenderHWLContainer(): | |
11223 bDumpDebug(false) | |
11224 { | |
11225 RenderHWLContainer *v1; // esi@1 | |
11226 | |
11227 v1 = this; | |
11228 this->pFile = 0; | |
11229 uSignature = 0; | |
11230 v1->uDataOffset = 0; | |
11231 memset(&v1->uNumItems, 0, 0x61A84u); | |
11232 v1->uNumItems = 0; | |
11233 v1->field_61A94_scale_hwls_to_half = 0; | |
11234 } | |
11235 | |
11236 //----- (0045237F) -------------------------------------------------------- | |
11237 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
11238 { | |
11239 pFile = _wfopen(pFilename, L"rb"); | |
11240 if (!pFile) | |
11241 { | |
11242 Log::Warning(L"Failed to open file: %s", pFilename); | |
11243 return false; | |
11244 } | |
11245 | |
11246 fread(&uSignature, 1, 4, pFile); | |
11247 if (uSignature != 'TD3D') | |
11248 { | |
11249 Log::Warning(L"Invalid format: %s", pFilename); | |
11250 return false; | |
11251 } | |
11252 | |
11253 fread(&uDataOffset, 4, 1, pFile); | |
11254 fseek(pFile, uDataOffset, SEEK_SET); | |
11255 fread(&uNumItems, 4, 1, pFile); | |
11256 | |
11257 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
11258 for (uint i = 0; i < uNumItems; ++i) | |
11259 { | |
11260 pSpriteNames[i] = new char[20]; | |
11261 fread(pSpriteNames[i], 1, 20, pFile); | |
11262 } | |
11263 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
11264 | |
11265 return true; | |
11266 } | |
11267 | |
11268 | |
11269 | |
11270 | |
11271 | |
11272 | |
11273 | |
11274 | |
11275 | |
11276 //----- (004A1C1E) -------------------------------------------------------- | |
11277 void DoRenderBillboards_D3D() | |
11278 { | |
11279 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3u)); | |
11280 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u)); | |
11281 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11282 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11283 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11284 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11285 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11286 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11287 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11288 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11289 p->pQuards[i].pos.z -= p->pQuards[i].pos.z * 0.6; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11290 //p->pQuards[i].rhw = + 0.8 * (1.0f - p->pQuards[i].rhw); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11291 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11292 p->pQuards[0].pos.x = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11293 p->pQuards[0].pos.y = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11294 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11295 p->pQuards[1].pos.x = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11296 p->pQuards[1].pos.y = 200; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11297 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11298 p->pQuards[2].pos.x = 100; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11299 p->pQuards[2].pos.y = 200; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11300 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11301 p->pQuards[3].pos.x = 100; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11302 p->pQuards[3].pos.y = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11303 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11304 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11305 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11306 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11307 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11308 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11309 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11310 p->pQuards, p->uNumVertices, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11311 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11312 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11313 }*/ |
0 | 11314 |
11315 for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i) | |
11316 { | |
101 | 11317 auto p = &pRenderer->pBillboardRenderListD3D[i]; |
0 | 11318 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11319 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
0 | 11320 SetBillboardBlendOptions(p->uOpacity); |
11321 | |
101 | 11322 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11323 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11324 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11325 p->pQuards, p->uNumVertices, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11326 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
0 | 11327 } |
11328 | |
11329 if (pRenderer->bFogEnabled) | |
11330 { | |
11331 pRenderer->bFogEnabled = false; | |
11332 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1)); | |
11333 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
11334 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
11335 } | |
11336 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2)); | |
11337 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1)); | |
11338 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0)); | |
11339 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u)); | |
11340 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u)); | |
11341 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u)); | |
11342 } | |
11343 | |
11344 | |
11345 | |
11346 | |
11347 | |
11348 //----- (004A1DA8) -------------------------------------------------------- | |
11349 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) | |
11350 { | |
11351 switch (a1) | |
11352 { | |
11353 case RenderBillboardD3D::Transparent: | |
11354 { | |
11355 if (pRenderer->bFogEnabled) | |
11356 { | |
11357 pRenderer->bFogEnabled = false; | |
11358 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u)); | |
11359 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); | |
11360 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
11361 } | |
11362 | |
11363 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 5)); | |
11364 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6u)); | |
11365 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1)); | |
11366 } | |
11367 break; | |
11368 | |
11369 case RenderBillboardD3D::Opaque_1: | |
11370 case RenderBillboardD3D::Opaque_2: | |
11371 case RenderBillboardD3D::Opaque_3: | |
11372 { | |
11373 if (pRenderer->bUsingSpecular) | |
11374 { | |
11375 if (!pRenderer->bFogEnabled) | |
11376 { | |
11377 pRenderer->bFogEnabled = true; | |
11378 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0)); | |
11379 } | |
11380 } | |
11381 | |
11382 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2)); | |
11383 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u)); | |
11384 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0)); | |
11385 } | |
11386 break; | |
11387 | |
11388 default: | |
11389 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11390 assert(false); |
0 | 11391 break; |
11392 } | |
11393 } | |
11394 |