Mercurial > mm7
annotate Render.cpp @ 973:ec7568e13b24
Minor code cleaning.
author | Nomad |
---|---|
date | Wed, 08 May 2013 21:37:12 +0200 |
parents | c0d0656aa662 |
children | 062788391c88 c5d8ea1e6ccb |
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" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
17 #include "SpriteObject.h" |
0 | 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" |
179 | 23 #include "TileFrameTable.h" |
189 | 24 #include "texts.h" |
0 | 25 #include "mm7_data.h" |
860 | 26 #include "MM7.h" |
0 | 27 |
28 #pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") | |
29 #pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") | |
30 | |
31 struct IDirectDrawClipper *pDDrawClipper; | |
32 struct Render *pRenderer; // idb | |
67 | 33 struct RenderVertexD3D3 pVertices[50]; |
0 | 34 int uNumDecorationsDrawnThisFrame; // weak |
35 RenderBillboard pBillboardRenderList[500]; | |
36 unsigned int uNumBillboardsToDraw; | |
37 int uNumSpritesDrawnThisFrame; // weak | |
38 | |
39 RenderVertexSoft array_507D30[50]; | |
40 RenderVertexSoft array_508690[50]; | |
41 RenderVertexSoft array_508FF0[50]; | |
42 RenderVertexSoft array_509950[50]; | |
43 RenderVertexSoft array_50A2B0[50]; | |
44 RenderVertexSoft array_50AC10[50]; | |
45 | |
46 RenderVertexSoft array_73D150[20]; | |
47 | |
186 | 48 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 49 |
50 RenderVertexSoft *ptr_801A04; | |
51 RenderVertexSoft *ptr_801A08; | |
52 | |
53 RenderVertexSoft pVerticesSR_801A10[384]; | |
54 RenderVertexSoft pVerticesSR_806210[384]; | |
55 | |
56 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); | |
57 | |
58 /* 384 */ | |
59 #pragma pack(push, 1) | |
60 struct PCXHeader_1 | |
61 { | |
62 char manufacturer; | |
63 char version; | |
64 char encoding; | |
65 char bpp; | |
66 __int16 left; | |
67 __int16 up; | |
68 __int16 right; | |
69 __int16 bottom; | |
70 __int16 hdpi; | |
71 __int16 vdpi; | |
72 }; | |
73 #pragma pack(pop) | |
74 | |
75 /* 385 */ | |
76 #pragma pack(push, 1) | |
77 struct PCXHeader_2 | |
78 { | |
79 char reserved; | |
80 char planes; | |
81 __int16 pitch; | |
82 __int16 palette_info; | |
83 }; | |
84 #pragma pack(pop) | |
85 | |
86 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
87 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
88 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
89 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
90 | |
91 //----- (0049E79F) -------------------------------------------------------- | |
92 bool __cdecl CheckTextureStages() | |
93 { | |
94 bool v0; // edi@1 | |
95 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
96 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
97 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
98 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
99 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
100 | |
101 v0 = false; | |
102 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); | |
103 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
104 | |
105 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
186 | 106 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 107 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2u)); |
108 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
109 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
110 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
111 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1u)); | |
112 | |
113 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
186 | 114 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
0 | 115 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1u)); |
116 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7u)); | |
117 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2u)); | |
118 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1u)); | |
119 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2u)); | |
120 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2u)); | |
121 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1u)); | |
122 | |
123 if ( !pRenderer->pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
124 v0 = true; | |
125 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); | |
126 pTexture1->Release(); | |
127 pTexture2->Release(); | |
128 pSurface1->Release(); | |
129 pSurface2->Release(); | |
130 return v0; | |
131 } | |
132 | |
133 //----- (00440CB8) -------------------------------------------------------- | |
134 void Render::DrawBillboardList_BLV() | |
135 { | |
136 __int16 v2; // ax@3 | |
137 int v5; // eax@11 | |
138 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
139 | |
140 soft_billboard.uParentBillboardID = -1; | |
141 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; | |
142 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
143 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
144 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
145 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
146 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
147 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
148 | |
617 | 149 pOutdoorCamera->uNumBillboards = ::uNumBillboardsToDraw; |
150 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) | |
0 | 151 { |
152 auto p = pBillboardRenderList + i; | |
153 | |
154 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
155 soft_billboard.uParentBillboardID = i; | |
156 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
157 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
|
158 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 159 soft_billboard.sZValue = p->sZValue; |
160 soft_billboard.uFlags = p->field_1E; | |
161 soft_billboard.uTintColor = p->uTintColor; | |
162 v2 = p->uHwSpriteID; | |
163 if ( v2 != -1 ) | |
164 { | |
165 if ( pRenderer->pRenderD3D ) | |
657 | 166 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 167 else |
168 { | |
657 | 169 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 170 if (p->field_1E & 0x0100) |
171 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
172 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
173 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1); | |
174 v5 = p->uHwSpriteID; | |
175 if ( v5 >= 0 ) | |
733 | 176 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 177 } |
178 } | |
179 } | |
180 } | |
181 | |
182 //----- (004A16A5) -------------------------------------------------------- | |
183 bool __cdecl AreRenderSurfacesOk() | |
184 { | |
185 char v0; // zf@4 | |
186 bool result; // eax@8 | |
187 | |
188 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
189 { | |
190 if ( !pRenderer->pBackBuffer4 ) | |
191 goto LABEL_9; | |
192 v0 = pRenderer->pFrontBuffer4 == 0; | |
193 } | |
194 else | |
195 { | |
196 if ( !pRenderer->pBackBuffer2 ) | |
197 goto LABEL_9; | |
198 v0 = pRenderer->pFrontBuffer2 == 0; | |
199 } | |
200 if ( !v0 ) | |
201 { | |
202 LOBYTE(result) = 1; | |
203 return result; | |
204 } | |
205 LABEL_9: | |
206 LOBYTE(result) = 0; | |
207 return result; | |
208 } | |
209 | |
210 //----- (00487389) -------------------------------------------------------- | |
973 | 211 void Render::ExecOutdoorDrawSW() |
0 | 212 { |
213 unsigned __int16 *v0; // ebx@1 | |
214 unsigned int v1; // esi@1 | |
215 stru148 *v2; // eax@1 | |
216 Span *v3; // edi@6 | |
217 stru148 *v4; // esi@9 | |
218 Texture *v5; // ebp@10 | |
219 int v6; // esi@16 | |
220 unsigned int v7; // edx@16 | |
221 char *v8; // ecx@17 | |
222 unsigned int v9; // edi@22 | |
223 int v10; // eax@26 | |
224 int v11; // eax@27 | |
225 unsigned int v12; // ebp@32 | |
226 Span *v13; // esi@33 | |
227 int v14; // ecx@37 | |
228 int v15; // eax@40 | |
229 Texture *v16; // ebp@51 | |
973 | 230 //unsigned int v17; // eax@51 |
0 | 231 int v18; // eax@54 |
232 char v19; // al@56 | |
233 unsigned int v20; // eax@57 | |
234 int v21; // ecx@57 | |
235 unsigned int v22; // eax@57 | |
236 stru149 *v23; // eax@65 | |
237 int v24; // eax@67 | |
238 ODMFace *v25; // eax@78 | |
239 signed int v26; // edx@79 | |
240 signed int v27; // ecx@79 | |
241 unsigned int v28; // eax@106 | |
242 unsigned int v29; // ebp@117 | |
243 Span *v30; // esi@118 | |
244 unsigned int v31; // ST04_4@124 | |
245 int v33; // [sp+18h] [bp-44h]@80 | |
246 signed int v34; // [sp+1Ch] [bp-40h]@3 | |
247 signed int v35; // [sp+20h] [bp-3Ch]@79 | |
248 Span **v36; // [sp+24h] [bp-38h]@4 | |
249 unsigned int v37; // [sp+28h] [bp-34h]@1 | |
250 unsigned __int16 *a1; // [sp+2Ch] [bp-30h]@1 | |
251 int a1a; // [sp+2Ch] [bp-30h]@26 | |
252 unsigned int a1b; // [sp+2Ch] [bp-30h]@116 | |
253 char v41; // [sp+30h] [bp-2Ch]@57 | |
254 | |
255 v0 = pRenderer->pTargetSurface; | |
256 v1 = pOutdoorCamera->numStru148s; | |
257 a1 = pRenderer->pTargetSurface; | |
258 v2 = array_77EC08; | |
259 v37 = pOutdoorCamera->numStru148s; | |
260 if ( !(pParty->uFlags & 2) ) | |
261 { | |
262 v1 = uNumElementsIn80AA28; | |
263 v2 = ptr_80AA28[0]; | |
264 v37 = uNumElementsIn80AA28; | |
265 } | |
266 v34 = 0; | |
267 if ( (signed int)v1 > 0 ) | |
268 { | |
269 v36 = &v2->prolly_head; | |
270 do | |
271 { | |
272 if ( pParty->uFlags & 2 ) | |
273 v3 = *v36; | |
274 else | |
275 v3 = ptr_80AA28[v34]->prolly_head; | |
276 if ( v3 ) | |
277 { | |
278 v4 = v3->pParent; | |
279 if ( v4 ) | |
280 { | |
281 v5 = v4->pTexture; | |
282 if ( v5 ) | |
283 { | |
693 | 284 if ( v3->field_8 >= (signed int)pViewport->uViewportTL_X || v3->field_C != pViewport->uViewportTL_X ) |
0 | 285 { |
286 LOBYTE(v4->field_32) |= 2u; | |
287 v14 = *(int *)&v4->flags; | |
288 if ( v14 & 0x10 && v4->field_59 != 5 ) | |
289 { | |
638 | 290 dword_80AA20 = (v4->terrain_grid_z - 64) << 25; |
0 | 291 dword_80AA1C = dword_80AA20 + 0x1FF0000; |
638 | 292 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 293 dword_80AA18 = dword_80AA14 - 0x1FF0000; |
294 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 295 v4->terrain_grid_z, |
296 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 297 if ( *(int *)&v4->flags & 2 || (v15 = *(int *)&v4->flags, BYTE1(v15) & 1) ) |
298 { | |
299 if ( *(int *)&v4->flags & 2 ) | |
300 { | |
301 while ( 1 ) | |
302 { | |
303 if ( pOutdoorCamera->outdoor_no_wavy_water ) | |
304 sr_sub_48408A_prolly_odm_water_no_waves(v3); | |
305 else | |
306 sr_sub_485407_prolly_odm_water_wavy(v3); | |
307 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
308 if ( v4->prolly_tail == v3 ) | |
309 break; | |
310 v3 = v3->pNext; | |
311 } | |
312 } | |
313 else | |
314 { | |
315 while ( 1 ) | |
316 { | |
317 v16 = v4->pTexture; | |
973 | 318 v4->pTexture = pBitmaps_LOD->LoadTexturePtr("wtrtyl"); |
0 | 319 if ( pOutdoorCamera->outdoor_no_wavy_water ) |
320 sr_sub_48408A_prolly_odm_water_no_waves(v3); | |
321 else | |
322 sr_sub_485407_prolly_odm_water_wavy(v3); | |
638 | 323 v18 = v4->terrain_grid_z - 64; |
0 | 324 v4->pTexture = v16; |
325 dword_80AA20 = v18 << 25; | |
326 dword_80AA1C = (v18 << 25) + 0x1FF0000; | |
638 | 327 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 328 dword_80AA18 = dword_80AA14 - 0x1FF0000; |
329 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 330 v4->terrain_grid_z, |
331 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 332 sr_sub_484442(v3); |
333 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
334 if ( v4->prolly_tail == v3 ) | |
335 break; | |
336 v3 = v3->pNext; | |
337 } | |
338 } | |
339 } | |
340 else | |
341 { | |
342 while ( sr_sub_48408A_prolly_odm_water_no_waves(v3) ) | |
343 { | |
344 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
345 if ( v4->prolly_tail == v3 ) | |
346 break; | |
347 v3 = v3->pNext; | |
348 } | |
349 } | |
350 } | |
351 else | |
352 { | |
353 v19 = v4->field_59; | |
354 if ( v19 != 5 ) | |
355 { | |
356 if ( v14 & 2 ) | |
357 { | |
358 while ( 1 ) | |
359 { | |
360 v28 = pBitmaps_LOD->LoadTexture("wtrtyla"); | |
361 v4->pTexture = (Texture *)(v28 != -1 ? &pBitmaps_LOD->pTextures[v28] : 0); | |
362 if ( !sr_sub_4847EB(v3) ) | |
363 break; | |
364 v4->pTexture = v5; | |
365 if ( !sr_sub_484442(v3) ) | |
366 break; | |
367 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
368 if ( v4->prolly_tail == v3 ) | |
369 break; | |
370 v3 = v3->pNext; | |
371 v5 = v4->pTexture; | |
372 } | |
373 } | |
374 else | |
375 { | |
376 if ( v19 == 1 ) | |
377 { | |
638 | 378 dword_80AA20 = (v4->terrain_grid_z - 64) << 25; |
0 | 379 dword_80AA1C = dword_80AA20 + 33488896; |
638 | 380 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 381 dword_80AA18 = dword_80AA14 - 33488896; |
382 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 383 v4->terrain_grid_z, |
384 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 385 while ( 1 ) |
386 { | |
387 if ( !sr_sub_4847EB(v3) ) | |
388 sr_sub_48585C_mb_DrawSpan(v3, &pRenderer->pTargetSurface[v3->field_8 + 640 * v3->field_A], 0); | |
389 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
390 if ( v4->prolly_tail == v3 ) | |
391 break; | |
392 v3 = v3->pNext; | |
393 } | |
394 } | |
395 } | |
396 goto LABEL_14; | |
397 } | |
398 v4->ptr_38 = (stru149 *)&v41; | |
399 v4->_479295(); | |
400 v20 = GetTickCount(); | |
401 v21 = *(int *)&v4->flags; | |
402 v22 = v20 >> 3; | |
403 if ( BYTE1(v21) & 4 ) | |
404 { | |
405 v4->sTextureDeltaV -= v22 & v4->pTexture->uHeightMinus1; | |
406 } | |
407 else | |
408 { | |
409 if ( BYTE1(v21) & 8 ) | |
410 v4->sTextureDeltaV += v22 & v4->pTexture->uHeightMinus1; | |
411 } | |
412 if ( BYTE1(v21) & 0x10 ) | |
413 { | |
414 v4->sTextureDeltaU -= v22 & v4->pTexture->uWidthMinus1; | |
415 } | |
416 else | |
417 { | |
418 if ( BYTE1(v21) & 0x20 ) | |
419 v4->sTextureDeltaU += v22 & v4->pTexture->uWidthMinus1; | |
420 } | |
421 v23 = v4->ptr_38; | |
422 v4->field_52 = 32; | |
423 v4->field_5A = 5; | |
424 if ( (double)abs(v23->field_C) > 52428.8 ) | |
425 { | |
426 v4->field_52 = 8; | |
427 v4->field_5A = 3; | |
428 } | |
429 v24 = *(int *)&v4->flags; | |
430 if ( !(v24 & 0x10000) ) | |
431 { | |
432 if ( !(v24 & 2) ) | |
433 { | |
434 v25 = v4->pODMFace; | |
435 if ( v25->uPolygonType == 1 ) | |
436 { | |
437 v26 = v25->pTextureUIDs[0]; | |
438 dword_80AA1C = v26; | |
439 dword_80AA20 = v26; | |
440 v27 = v25->pTextureVIDs[0]; | |
441 dword_80AA14 = v27; | |
442 dword_80AA18 = v27; | |
443 v35 = 1; | |
444 if ( v25->uNumVertices > 1u ) | |
445 { | |
446 v33 = (int)&v25->pTextureVIDs[1]; | |
447 do | |
448 { | |
449 if ( dword_80AA20 > *(short *)(v33 - 40) ) | |
450 dword_80AA20 = *(short *)(v33 - 40); | |
451 if ( v26 < *(short *)(v33 - 40) ) | |
452 { | |
453 v26 = *(short *)(v33 - 40); | |
454 dword_80AA1C = *(short *)(v33 - 40); | |
455 } | |
456 if ( dword_80AA18 > *(short *)v33 ) | |
457 dword_80AA18 = *(short *)v33; | |
458 if ( v27 < *(short *)v33 ) | |
459 { | |
460 v27 = *(short *)v33; | |
461 dword_80AA14 = *(short *)v33; | |
462 } | |
463 ++v35; | |
464 v33 += 2; | |
465 } | |
466 while ( v35 < v25->uNumVertices ); | |
467 v0 = a1; | |
468 } | |
469 dword_80AA20 = (dword_80AA20 + v4->sTextureDeltaU) << 16; | |
470 dword_80AA1C = ((v26 + v4->sTextureDeltaU) << 16) - 65536; | |
471 dword_80AA18 = (dword_80AA18 + v4->sTextureDeltaV) << 16; | |
472 dword_80AA14 = ((v27 + v4->sTextureDeltaV) << 16) - 65536; | |
473 } | |
474 while ( 1 ) | |
475 { | |
476 if ( !sr_sub_482E07(v3, v0) ) | |
477 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
478 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
479 if ( v4->prolly_tail == v3 ) | |
480 break; | |
481 v3 = v3->pNext; | |
482 } | |
483 goto LABEL_14; | |
484 } | |
485 while ( 1 ) | |
486 { | |
487 LABEL_74: | |
488 if ( !sr_sub_4839BD(v3, v0) ) | |
489 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
490 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
491 if ( v4->prolly_tail == v3 ) | |
492 break; | |
493 v3 = v3->pNext; | |
494 } | |
495 goto LABEL_14; | |
496 } | |
497 if ( v24 & 2 ) | |
498 goto LABEL_74; | |
499 while ( 1 ) | |
500 { | |
501 if ( !sr_sub_482A94(v3) ) | |
502 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
503 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
504 if ( v4->prolly_tail == v3 ) | |
505 break; | |
506 v3 = v3->pNext; | |
507 } | |
508 } | |
509 } | |
510 else | |
511 { | |
512 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
513 } | |
514 } | |
515 } | |
516 } | |
517 LABEL_14: | |
518 ++v34; | |
519 LOWORD(v2) = v34; | |
520 v36 += 67; | |
521 } | |
522 while ( v34 < (signed int)v37 ); | |
523 } | |
524 if ( pParty->uFlags & 2 ) | |
525 { | |
526 v6 = pOutdoorCamera->numStru148s; | |
527 v7 = 0; | |
528 uNumElementsIn80AA28 = 0; | |
529 if ( pOutdoorCamera->numStru148s > 0 ) | |
530 { | |
531 v8 = (char *)&array_77EC08[0].flags; | |
532 do | |
533 { | |
534 v2 = *(stru148 **)v8; | |
535 if ( (unsigned int)v2 & 0x20000 ) | |
536 { | |
537 ++v7; | |
538 *(int *)v8 = (unsigned int)v2 & 0xFFFDFFFF; | |
539 LOWORD(v2) = (short)v8 - 48; | |
540 *(&uNumElementsIn80AA28 + v7) = (unsigned int)(v8 - 48); | |
541 } | |
542 v8 += 268; | |
543 --v6; | |
544 } | |
545 while ( v6 ); | |
546 uNumElementsIn80AA28 = v7; | |
547 } | |
548 } | |
549 v9 = pOutdoorCamera->uNumSpans; | |
550 unnamed_6BE060[0] = pOutdoorCamera->uNumSpans; | |
973 | 551 if (pOutdoorCamera->numStru148s >= 1999) |
552 return; | |
553 | |
554 array_77EC08[1999]._48607B(&stru_8019C8); | |
555 array_77EC08[1999].ptr_38->_48694B(); | |
556 | |
557 if (pOutdoor->uMainTile_BitmapID == -1) | |
558 { | |
559 array_77EC08[1999].pTexture = nullptr; | |
560 return; | |
561 } | |
562 else | |
563 array_77EC08[1999].pTexture = pBitmaps_LOD->GetTexture(pOutdoor->uMainTile_BitmapID); | |
638 | 564 array_77EC08[1999].dimming_level = 23 - (-20 * pOutdoor->vSunlight.z >> 16); |
565 if ( array_77EC08[1999].dimming_level > 20 ) | |
566 array_77EC08[1999].dimming_level = 20; | |
323 | 567 v10 = stru_5C6E00->Sin(pIndoorCamera->sRotationX); |
0 | 568 array_77EC08[1999].v_18.y = 0; |
569 array_77EC08[1999].v_18.x = v10; | |
323 | 570 array_77EC08[1999].v_18.z = stru_5C6E00->Cos(pIndoorCamera->sRotationX); |
0 | 571 array_77EC08[1999].field_24 = 2048 - (pIndoorCamera->pos.z << 16); |
572 a1a = (signed __int64)((double)(pIndoorCamera->pos.z * pOutdoorCamera->int_fov_rad) | |
573 / ((double)pOutdoorCamera->int_fov_rad + 8192.0) | |
574 + (double)pViewport->uScreenCenterY); | |
575 cos((double)pIndoorCamera->sRotationX * 0.0030664064); | |
576 sin((double)pIndoorCamera->sRotationX * 0.0030664064); | |
577 array_77EC08[1999]._48607B(&stru_8019C8); | |
578 array_77EC08[1999].ptr_38->_48694B(); | |
973 | 579 |
580 if (pOutdoor->uSky_TextureID == -1) | |
581 { | |
582 array_77EC08[1999].pTexture = nullptr; | |
583 return; | |
584 } | |
585 else | |
586 array_77EC08[1999].pTexture = pBitmaps_LOD->GetTexture(pOutdoor->uSky_TextureID); | |
638 | 587 array_77EC08[1999].dimming_level = 0; |
323 | 588 v11 = stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16); |
0 | 589 array_77EC08[1999].v_18.y = 0; |
590 array_77EC08[1999].v_18.x = -v11; | |
323 | 591 array_77EC08[1999].v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16); |
0 | 592 LOWORD(v2) = 224 * LOWORD(pMiscTimer->uTotalGameTimeElapsed); |
593 array_77EC08[1999].field_24 = 0x2000000u; | |
594 array_77EC08[1999].sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
595 array_77EC08[1999].sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
767 | 596 if ( day_attrib & DAY_ATTRIB_FOG |
0 | 597 && (LOWORD(v2) = LOWORD(pParty->uCurrentHour), pParty->uCurrentHour >= 5) |
598 && pParty->uCurrentHour < 0x15 | |
599 || bUnderwater ) | |
600 { | |
601 v2 = (stru148 *)*(short *)PaletteManager::Get_Mist_or_Red_LUT(array_77EC08[1999].pTexture->palette_id2, 31, 1); | |
602 a1b = (unsigned int)v2; | |
603 if ( (signed int)v9 <= 0 ) | |
973 | 604 return; |
0 | 605 v29 = v9; |
606 while ( 1 ) | |
607 { | |
608 v30 = &pSpans[v29 - 1]; | |
609 v2 = (stru148 *)v30->field_E; | |
610 if ( v2 != (stru148 *)unnamed_6BE060[1] ) | |
611 { | |
693 | 612 LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); |
613 if ( v30->field_8 >= (signed int)pViewport->uViewportTL_X ) | |
0 | 614 goto LABEL_124; |
693 | 615 if ( v30->field_C == pViewport->uViewportTL_X ) |
0 | 616 { |
617 v30->field_E = LOWORD(unnamed_6BE060[1]); | |
618 } | |
619 else | |
620 { | |
693 | 621 v30->field_8 = LOWORD(pViewport->uViewportTL_X); |
622 v30->field_C -= LOWORD(pViewport->uViewportTL_X); | |
0 | 623 if ( v30->field_C >= 0 ) |
624 { | |
625 LABEL_124: | |
626 v31 = v30->field_C; | |
627 v30->pParent = &array_77EC08[1999]; | |
628 fill_pixels_fast( | |
629 a1b, | |
630 &pRenderer->pTargetSurface[v30->field_8 + pRenderer->uTargetSurfacePitch * v30->field_A], | |
631 v31); | |
632 j_memset32(-65536, &pRenderer->pActiveZBuffer[v30->field_8 + 640 * v30->field_A], v30->field_C); | |
633 goto LABEL_125; | |
634 } | |
635 LOWORD(v2) = LOWORD(unnamed_6BE060[1]); | |
636 v30->field_E = LOWORD(unnamed_6BE060[1]); | |
637 } | |
638 } | |
639 LABEL_125: | |
640 --v29; | |
641 --v9; | |
642 if ( !v9 ) | |
973 | 643 return; |
0 | 644 } |
645 } | |
646 if ( (signed int)v9 > 0 ) | |
647 { | |
648 v12 = v9; | |
649 do | |
650 { | |
651 v13 = &pSpans[v12 - 1]; | |
652 v2 = (stru148 *)v13->field_E; | |
653 if ( v2 != (stru148 *)unnamed_6BE060[1] ) | |
654 { | |
693 | 655 LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); |
656 if ( v13->field_8 >= (signed int)pViewport->uViewportTL_X ) | |
0 | 657 goto LABEL_109; |
693 | 658 if ( v13->field_C != pViewport->uViewportTL_X ) |
659 { | |
660 v13->field_8 = LOWORD(pViewport->uViewportTL_X); | |
661 v13->field_C -= LOWORD(pViewport->uViewportTL_X); | |
0 | 662 if ( v13->field_C >= 0 ) |
663 { | |
664 LABEL_109: | |
665 if ( pOutdoorCamera->bNoSky ) | |
666 { | |
667 const_1_0(); | |
668 } | |
669 else | |
670 { | |
671 v13->pParent = &array_77EC08[1999]; | |
672 if ( !Render::DrawSkySW(v13, &array_77EC08[1999], a1a) ) | |
673 j_memset32(-65536, &pRenderer->pActiveZBuffer[v13->field_8 + 640 * v13->field_A], v13->field_C); | |
674 } | |
675 } | |
676 LOWORD(v2) = LOWORD(unnamed_6BE060[1]); | |
677 v13->field_E = LOWORD(unnamed_6BE060[1]); | |
678 goto LABEL_114; | |
679 } | |
680 v13->field_E = LOWORD(unnamed_6BE060[1]); | |
681 } | |
682 LABEL_114: | |
683 --v12; | |
684 --v9; | |
685 } | |
686 while ( v9 ); | |
687 } | |
688 } | |
689 | |
690 //----- (00485044) -------------------------------------------------------- | |
691 int Render::DrawSkySW(Span *a1, stru148 *a2, int a3) | |
692 { | |
693 stru148 *v3; // esi@1 | |
694 Span *v4; // edi@1 | |
695 float v5; // ST2C_4@1 | |
696 signed int result; // eax@2 | |
697 int v7; // ST40_4@3 | |
698 stru149 *v8; // eax@3 | |
699 int v9; // ebx@3 | |
700 int v10; // ecx@3 | |
701 int v11; // edx@3 | |
702 int v12; // eax@3 | |
703 int v13; // ST28_4@5 | |
704 int v14; // eax@5 | |
705 signed __int64 v15; // qtt@11 | |
706 int v16; // ST28_4@11 | |
707 int v17; // eax@11 | |
708 signed int v18; // ecx@11 | |
709 int v19; // ST40_4@11 | |
710 int v20; // ST3C_4@11 | |
711 int v21; // ST30_4@11 | |
712 void *v22; // eax@11 | |
713 Texture *v23; // esi@11 | |
714 int v24; // ecx@11 | |
715 unsigned int v25; // esi@11 | |
716 int v26; // edi@11 | |
717 unsigned __int16 *v27; // eax@11 | |
718 int *v28; // ebx@12 | |
719 int v29; // edx@13 | |
720 unsigned __int16 v30; // cx@13 | |
721 int v31; // edx@14 | |
722 unsigned __int16 v32; // cx@14 | |
723 unsigned __int8 v33; // sf@15 | |
724 unsigned __int8 v34; // of@15 | |
725 double v35; // [sp+14h] [bp-38h]@1 | |
726 int v36; // [sp+18h] [bp-34h]@3 | |
727 signed int v37; // [sp+18h] [bp-34h]@11 | |
728 int v38; // [sp+1Ch] [bp-30h]@3 | |
729 signed int v39; // [sp+1Ch] [bp-30h]@11 | |
730 int v40; // [sp+20h] [bp-2Ch]@3 | |
731 void *v41; // [sp+20h] [bp-2Ch]@11 | |
732 int v42; // [sp+24h] [bp-28h]@3 | |
733 unsigned __int8 *v43; // [sp+24h] [bp-28h]@11 | |
734 int v44; // [sp+28h] [bp-24h]@11 | |
735 int v45; // [sp+2Ch] [bp-20h]@3 | |
736 signed int v46; // [sp+30h] [bp-1Ch]@3 | |
737 __int16 v47; // [sp+30h] [bp-1Ch]@11 | |
738 signed int v48; // [sp+34h] [bp-18h]@3 | |
739 int v49; // [sp+34h] [bp-18h]@11 | |
740 int v50; // [sp+38h] [bp-14h]@3 | |
741 unsigned __int16 *v51; // [sp+38h] [bp-14h]@11 | |
742 int v52; // [sp+3Ch] [bp-10h]@4 | |
743 int a1a; // [sp+40h] [bp-Ch]@3 | |
744 int v54; // [sp+44h] [bp-8h]@3 | |
745 int v55; // [sp+48h] [bp-4h]@3 | |
746 int v56; // [sp+54h] [bp+8h]@11 | |
747 int *v57; // [sp+54h] [bp+8h]@11 | |
748 | |
749 v3 = a2; | |
750 v4 = a1; | |
693 | 751 v5 = (double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5 / tan(0.6457717418670654) + 0.5; |
0 | 752 v35 = v5 + 6.7553994e15; |
753 if ( LODWORD(v35) ) | |
754 { | |
755 v55 = 65536 / SLODWORD(v35); | |
756 v7 = 65536 / SLODWORD(v35) * (a3 - v4->field_A); | |
757 v8 = v3->ptr_38; | |
758 v42 = ((unsigned __int64)(v3->ptr_38->field_14 * (signed __int64)v7) >> 16) + v8->field_C; | |
759 v40 = ((unsigned __int64)(v8->field_20 * (signed __int64)v7) >> 16) + v3->ptr_38->field_18; | |
760 v38 = pOutdoorCamera->camera_rotation_y_int_sine; | |
761 HIDWORD(v35) = pOutdoorCamera->camera_rotation_y_int_cosine; | |
762 v45 = v4->field_C; | |
763 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v7) >> 16) + v3->v_18.x; | |
764 v10 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); | |
765 v48 = 0; | |
766 v50 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); | |
767 v46 = -v3->field_24; | |
768 v11 = v4->field_A - 1; | |
769 v54 = v11; | |
770 v12 = 65536 / SLODWORD(v35) * (a3 - v11); | |
771 a1a = 65536 / SLODWORD(v35) * (a3 - v11); | |
772 while ( 1 ) | |
773 { | |
774 v52 = v9; | |
775 if ( v9 ) | |
776 { | |
777 v13 = abs(v46 >> 14); | |
778 v14 = abs(v9); | |
779 v11 = v54; | |
780 v10 = v50; | |
781 if ( v13 <= v14 ) | |
782 break; | |
783 v12 = a1a; | |
784 } | |
693 | 785 if ( v11 <= (signed int)pViewport->uViewportTL_Y ) |
0 | 786 break; |
787 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v12) >> 16) + v3->v_18.x; | |
788 --v54; | |
789 a1a += v55; | |
790 v12 = a1a; | |
791 v11 = v54; | |
792 v48 = 1; | |
793 } | |
794 if ( v48 ) | |
795 v52 = ((unsigned __int64)(v3->v_18.z * (signed __int64)(v55 * (a3 + (signed int)v4->field_A - 2 * v11))) >> 16) | |
796 + v3->v_18.x; | |
797 LODWORD(v15) = v46 << 16; | |
798 HIDWORD(v15) = v46 >> 16; | |
799 v16 = v42 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v10) >> 16); | |
800 v17 = v40 + ((unsigned __int64)(v3->ptr_38->field_1C * (signed __int64)v10) >> 16); | |
801 v18 = v15 / v52; | |
710 | 802 v43 = v3->pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 803 v19 = v3->sTextureDeltaU + ((signed int)((unsigned __int64)(v16 * v15 / v52) >> 16) >> 3); |
804 v56 = v15 / v52; | |
805 v20 = v3->sTextureDeltaV + ((signed int)((unsigned __int64)(v17 * v15 / v52) >> 16) >> 3); | |
806 v21 = (unsigned __int64)(v55 * (signed __int64)v56) >> 16; | |
807 v39 = (signed int)((unsigned __int64)(v21 * (signed __int64)v38) >> 16) >> 3; | |
808 v37 = (signed int)((unsigned __int64)(v21 * (signed __int64)v36) >> 16) >> 3; | |
809 v22 = sr_sub_47C178(v18, v3, 0, 1); | |
810 v23 = v3->pTexture; | |
811 v41 = v22; | |
812 v47 = 16 - v23->uWidthLn2; | |
813 v44 = v23->uTextureWidth - 1; | |
814 v49 = (v23->uTextureHeight << 16) - 65536; | |
815 v24 = v4->field_8; | |
816 v51 = &pRenderer->pTargetSurface[v24 + pRenderer->uTargetSurfacePitch * v4->field_A]; | |
817 v57 = &pRenderer->pActiveZBuffer[v24 + 640 * v4->field_A]; | |
818 v25 = v19; | |
819 v26 = v20; | |
820 v27 = v51; | |
821 if ( !(v45 & 1) ) | |
822 goto LABEL_15; | |
823 --v45; | |
824 v27 = v51 - 1; | |
825 v28 = v57; | |
826 ++v57; | |
827 while ( 1 ) | |
828 { | |
829 *v28 = -65536; | |
830 v31 = v44 & (v25 >> 16); | |
831 v27 += 2; | |
832 v25 += v39; | |
833 v32 = *((short *)v41 + *(&v43[v31] + ((v49 & (unsigned int)v26) >> v47))); | |
834 v26 += v37; | |
835 *(v27 - 1) = v32; | |
836 LABEL_15: | |
837 v34 = __OFSUB__(v45, 2); | |
838 v33 = v45 - 2 < 0; | |
839 v45 -= 2; | |
840 if ( v33 ^ v34 ) | |
841 break; | |
842 v29 = v44 & (v25 >> 16); | |
843 v25 += v39; | |
844 v30 = *((short *)v41 + *(&v43[v29] + ((v49 & (unsigned int)v26) >> v47))); | |
845 v26 += v37; | |
846 v28 = v57; | |
847 *v27 = v30; | |
848 v57 += 2; | |
849 v28[1] = -65536; | |
850 } | |
851 result = 1; | |
852 } | |
853 else | |
854 { | |
855 result = 0; | |
856 } | |
857 return result; | |
858 } | |
859 | |
860 //----- (0047F5C6) -------------------------------------------------------- | |
861 float Render::DrawBezierTerrain() | |
862 { | |
863 //__debugbreak();Ritor1: it's temporarily | |
864 //return 0; | |
865 | |
86 | 866 unsigned int pDirectionIndicator1; // ebx@1 |
867 unsigned int pDirectionIndicator2; // edi@1 | |
0 | 868 unsigned int v2; // eax@1 |
869 int v3; // eax@3 | |
870 int v4; // edi@3 | |
871 int v5; // ebx@3 | |
872 int v6; // esi@3 | |
873 unsigned int v7; // eax@3 | |
874 int v8; // eax@4 | |
875 unsigned int v9; // eax@6 | |
876 int v10; // eax@7 | |
877 int v11; // ebx@9 | |
878 int v12; // edi@9 | |
879 int v13; // eax@21 | |
880 int v14; // eax@31 | |
881 int v15; // edi@33 | |
67 | 882 int v16; // eax@34 |
0 | 883 int v17; // edx@34 |
884 int v18; // ebx@34 | |
885 int v19; // eax@36 | |
886 int v20; // eax@39 | |
887 int v21; // ecx@43 | |
888 char v22; // zf@44 | |
889 int v23; // ecx@47 | |
890 int v24; // edi@52 | |
67 | 891 int v25; // eax@54 |
0 | 892 int v26; // ecx@54 |
893 int v27; // eax@56 | |
894 int v28; // edx@60 | |
895 int v29; // ecx@61 | |
896 int v30; // ecx@64 | |
897 int v31; // ecx@68 | |
898 int v32; // eax@70 | |
899 int v33; // ecx@71 | |
900 int v34; // eax@73 | |
901 int v35; // ecx@77 | |
902 int v36; // ecx@81 | |
903 int v37; // ecx@86 | |
67 | 904 int v38; // eax@88 |
905 int v39; // ecx@88 | |
0 | 906 int v40; // eax@90 |
907 int v41; // edx@94 | |
908 int v42; // ecx@95 | |
909 int v43; // ecx@98 | |
910 int v44; // ecx@102 | |
911 int v45; // eax@104 | |
912 int v46; // eax@107 | |
913 int v47; // ecx@111 | |
914 int v48; // ecx@115 | |
915 int v49; // edi@120 | |
67 | 916 int v50; // eax@122 |
0 | 917 int v51; // ecx@122 |
918 int v52; // eax@124 | |
919 int v53; // edx@128 | |
920 int v54; // ecx@129 | |
921 int v55; // ecx@132 | |
922 int v56; // eax@139 | |
923 int v57; // ecx@140 | |
924 int v58; // eax@142 | |
925 int v59; // ecx@146 | |
926 int v60; // ecx@147 | |
927 int v61; // ecx@150 | |
928 int v62; // ecx@155 | |
67 | 929 int v63; // eax@157 |
930 int v64; // ecx@157 | |
0 | 931 int v65; // eax@159 |
932 int v66; // edx@163 | |
933 int v67; // ecx@164 | |
934 int v68; // ecx@167 | |
935 int v69; // eax@173 | |
936 int v70; // edi@178 | |
937 int v71; // eax@178 | |
938 int v72; // ecx@178 | |
86 | 939 int x; // ebx@180 |
0 | 940 int v74; // eax@182 |
941 int v75; // eax@184 | |
67 | 942 IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 |
86 | 943 int uStartZ; // ecx@184 |
0 | 944 int v79; // ebx@185 |
945 int v127; // esi@185 | |
946 int v86; // edi@196 | |
947 int v87; // eax@196 | |
948 int v88; // ecx@196 | |
949 int v89; // eax@198 | |
950 int v90; // ecx@200 | |
951 int v92; // ebx@203 | |
952 int v93; // ST08_4@204 | |
953 int v97; // ST08_4@204 | |
954 float result; // eax@212 | |
67 | 955 struct |
956 { | |
957 char v102[4]; // [sp+Ch] [bp-68h]@191 | |
0 | 958 __int16 v103; // [sp+10h] [bp-64h]@190 |
959 __int16 v104; // [sp+12h] [bp-62h]@190 | |
67 | 960 } v102; |
77 | 961 int v105; // [sp+1Ch] [bp-58h]@1 |
0 | 962 int v106; // [sp+20h] [bp-54h]@3 |
86 | 963 int uEndZ; // [sp+24h] [bp-50h]@3 |
0 | 964 int v108; // [sp+28h] [bp-4Ch]@9 |
965 int v109; // [sp+2Ch] [bp-48h]@9 | |
966 int v110; // [sp+30h] [bp-44h]@9 | |
967 int v111; // [sp+34h] [bp-40h]@3 | |
968 int v112; // [sp+38h] [bp-3Ch]@6 | |
67 | 969 IndoorCameraD3D *pIndoorCameraD3D_4; // [sp+3Ch] [bp-38h]@9 |
0 | 970 int v114; // [sp+40h] [bp-34h]@9 |
971 int v115; // [sp+44h] [bp-30h]@9 | |
972 int v116; // [sp+48h] [bp-2Ch]@9 | |
973 int v117; // [sp+4Ch] [bp-28h]@9 | |
974 int v118; // [sp+50h] [bp-24h]@9 | |
975 int v119; // [sp+54h] [bp-20h]@1 | |
976 int v120; // [sp+58h] [bp-1Ch]@1 | |
977 int i; // [sp+5Ch] [bp-18h]@1 | |
978 int v122; // [sp+60h] [bp-14h]@1 | |
979 int v123; // [sp+64h] [bp-10h]@1 | |
67 | 980 int v124; // [sp+68h] [bp-Ch]@1 |
0 | 981 int v125; // [sp+6Ch] [bp-8h]@9 |
67 | 982 int v126; // [sp+70h] [bp-4h]@9 |
983 | |
96 | 984 v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2 |
86 | 985 pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 |
986 pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512 | |
323 | 987 v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16; |
988 v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16; | |
67 | 989 v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X |
0 | 990 v119 = pOutdoorCamera->outdoor_grid_band_3 + v123; |
991 v2 = pOutdoorCamera->uCameraFovInDegrees + 15; | |
67 | 992 i = v124 - pOutdoorCamera->outdoor_grid_band_3; |
0 | 993 v122 = v123 - pOutdoorCamera->outdoor_grid_band_3; |
67 | 994 |
995 if ( v2 > 90 ) | |
0 | 996 v2 = 90; |
67 | 997 v3 = (v2 << 11) / 720; |
86 | 998 v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3); |
999 v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1); | |
323 | 1000 v106 = stru_5C6E00->Cos(v4); |
1001 uEndZ = stru_5C6E00->Sin(v4); | |
1002 v111 = stru_5C6E00->Cos(v5); | |
1003 v6 = stru_5C6E00->Sin(v5); | |
0 | 1004 v7 = v4 & stru_5C6E00->uPiMask; |
67 | 1005 |
1006 if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) | |
0 | 1007 v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7]; |
1008 else | |
1009 v8 = stru_5C6E00->pTanTable[v7]; | |
1010 v112 = abs(v8); | |
1011 v9 = v5 & stru_5C6E00->uPiMask; | |
67 | 1012 if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) |
0 | 1013 v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9]; |
1014 else | |
1015 v10 = stru_5C6E00->pTanTable[v9]; | |
1016 v108 = abs(v10); | |
67 | 1017 v11 = v124; |
0 | 1018 v12 = v123; |
1019 v114 = 0; | |
1020 v115 = 0; | |
67 | 1021 pIndoorCameraD3D_4 = 0; |
0 | 1022 v125 = 0; |
67 | 1023 v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; |
0 | 1024 v126 = v124; |
1025 v118 = v123; | |
86 | 1026 v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; |
1027 uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; | |
0 | 1028 terrain_76E1C8[0] = 65535; |
67 | 1029 //v116 = 1; |
1030 v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; | |
1031 //v117 = 1; | |
0 | 1032 terrain_76E3C8[0] = 65535; |
1033 terrain_76DDC8[0] = 65535; | |
1034 terrain_76DFC8[0] = 65535; | |
67 | 1035 for( v116=1; v116 < 128; v116++) |
1036 { | |
1037 if ( v112 >= 0x10000 ) | |
1038 { | |
1039 int v1, v2; | |
1040 /*v111 = 4294967296i64 / v112; | |
0 | 1041 v114 += v111; |
1042 if ( v114 >= 65536 ) | |
1043 { | |
1044 v11 += v110; | |
1045 v114 = (unsigned __int16)v114; | |
1046 } | |
67 | 1047 v12 += v109;*/ |
0 | 1048 } |
1049 else | |
1050 { | |
1051 v11 += v110; | |
1052 v115 += v112; | |
67 | 1053 if ( v112 + v115 >= 65536 ) |
0 | 1054 { |
1055 v12 += v109; | |
1056 v115 = (unsigned __int16)v115; | |
1057 } | |
1058 } | |
67 | 1059 if ( v11 < i || v11 > v120 || v12 < v122 || v12 > v119 ) |
0 | 1060 break; |
67 | 1061 //v13 = v116++; |
1062 terrain_76E3C8[v116] = v11; | |
1063 terrain_76E1C8[v116] = v12; | |
1064 } | |
1065 | |
1066 for( v117=1; v117 < 128; v117++ ) | |
0 | 1067 { |
1068 if ( v108 >= 65536 ) | |
1069 { | |
1070 v111 = 4294967296i64 / v108; | |
67 | 1071 v114 += v111;// |
1072 if ( v111 + v114 >= 65536 ) | |
1073 { | |
86 | 1074 v126 += uEndZ; |
67 | 1075 v114 = (unsigned __int16)v114;// |
0 | 1076 } |
1077 v118 += v106; | |
1078 } | |
1079 else | |
1080 { | |
1081 v125 += v108; | |
86 | 1082 v126 += uEndZ; |
0 | 1083 if ( v125 >= 65536 ) |
1084 { | |
1085 v118 += v106; | |
1086 v125 = (unsigned __int16)v125; | |
1087 } | |
1088 } | |
67 | 1089 //if ( v117 >= 128 ) |
1090 //break; | |
1091 if ( v126 < i ) | |
0 | 1092 break; |
67 | 1093 if ( v126 > v120 ) |
0 | 1094 break; |
1095 v14 = v118; | |
1096 if ( v118 < v122 ) | |
1097 break; | |
1098 if ( v118 > v119 ) | |
1099 break; | |
67 | 1100 terrain_76DFC8[v117] = v126; |
1101 terrain_76DDC8[v117] = v14; | |
1102 } | |
1103 v16 = 0; | |
1104 v126 = 0; | |
0 | 1105 v17 = v117 - 1; |
1106 v18 = v116 - 1; | |
77 | 1107 switch ( v105 ) |
0 | 1108 { |
1109 case 0: | |
1110 case 7: | |
67 | 1111 { |
0 | 1112 v116 = terrain_76DFC8[v17]; |
1113 if ( v120 > v116 ) | |
1114 { | |
1115 v125 = v120; | |
67 | 1116 memset32(terrain_76D9C8, v119 + 1, 4 * (v120 - v116 + 1)); |
0 | 1117 v19 = v120; |
1118 do | |
67 | 1119 terrain_76DBC8[v126++] = v19--; |
0 | 1120 while ( v19 >= v116 ); |
1121 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 + 127] ) | |
1122 { | |
1123 do | |
67 | 1124 v20 = terrain_76DDC8[v17-- -1]; |
1125 while ( v20 == terrain_76DDC8[v17 -1] ); | |
0 | 1126 } |
1127 v16 = v126; | |
1128 --v17; | |
1129 } | |
1130 if ( v17 < 0 ) | |
1131 v17 = 0; | |
1132 v21 = terrain_76DFC8[v17]; | |
1133 while ( 1 ) | |
1134 { | |
1135 v125 = v21; | |
67 | 1136 if ( v21 < v124 ) |
0 | 1137 break; |
67 | 1138 terrain_76DBC8[v16] = v21; |
0 | 1139 v22 = terrain_76DDC8[v17] == 65535; |
67 | 1140 terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1; |
0 | 1141 if ( v22 ) |
1142 { | |
67 | 1143 terrain_76D9C8[v16] = v123 + 1; |
0 | 1144 break; |
1145 } | |
1146 if ( !v17 ) | |
1147 break; | |
67 | 1148 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 - 1] ) |
0 | 1149 { |
1150 do | |
67 | 1151 v23 = terrain_76DDC8[v17-- -1]; |
1152 while ( v23 == terrain_76DDC8[v17 -1] ); | |
0 | 1153 } |
1154 --v17; | |
1155 v21 = v125 - 1; | |
67 | 1156 ++v16; |
1157 } | |
1158 v16 = 0; | |
0 | 1159 v24 = terrain_76E3C8[v18]; |
67 | 1160 v126 = 0; |
0 | 1161 if ( v120 > v24 ) |
1162 { | |
1163 v125 = v120; | |
67 | 1164 memset32(terrain_76D5C8, v122, 4 * (v120 - v24 + 1)); |
0 | 1165 do |
1166 { | |
1167 v25 = v126; | |
1168 v26 = v125--; | |
67 | 1169 ++v126; |
1170 terrain_76D7C8[v25] = v26; | |
0 | 1171 } |
1172 while ( v125 >= terrain_76E3C8[v18] ); | |
67 | 1173 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) |
0 | 1174 { |
1175 do | |
67 | 1176 v27 = terrain_76E1C8[v18-- -1]; |
1177 while ( v27 == terrain_76E1C8[v18 -1] ); | |
0 | 1178 } |
1179 v16 = v126; | |
1180 --v18; | |
1181 } | |
1182 if ( v18 < 0 ) | |
1183 v18 = 0; | |
1184 v28 = terrain_76E3C8[v18]; | |
67 | 1185 while ( v28 >= v124 ) |
0 | 1186 { |
1187 v29 = terrain_76E1C8[v18]; | |
67 | 1188 terrain_76D7C8[v16] = v28; |
1189 terrain_76D5C8[v16] = v29; | |
0 | 1190 if ( v29 == 65535 ) |
1191 { | |
1192 v31 = v123; | |
67 | 1193 terrain_76D5C8[v16] = v31; |
1194 break; | |
0 | 1195 } |
1196 if ( !v18 ) | |
1197 break; | |
67 | 1198 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) |
0 | 1199 { |
1200 do | |
67 | 1201 v30 = terrain_76E1C8[v18-- -1]; |
1202 while ( v30 == terrain_76E1C8[v18 -1] ); | |
0 | 1203 } |
1204 --v18; | |
1205 --v28; | |
67 | 1206 ++v16; |
0 | 1207 } |
1208 break; | |
67 | 1209 } |
0 | 1210 case 1: |
1211 case 2: | |
67 | 1212 { |
0 | 1213 v116 = terrain_76DDC8[v17]; |
1214 if ( v122 < v116 ) | |
1215 { | |
1216 v106 = v122; | |
67 | 1217 memset32(terrain_76DBC8, v120 + 1, 4 * (v116 - v122 + 1)); |
0 | 1218 v32 = v122; |
1219 do | |
1220 { | |
67 | 1221 v33 = v126++; |
0 | 1222 terrain_76D9C8[v33] = v32++; |
1223 } | |
1224 while ( v32 <= v116 ); | |
67 | 1225 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1226 { |
1227 do | |
67 | 1228 v34 = terrain_76DBC8[v17-- -1]; |
1229 while ( v34 == terrain_76DBC8[v17 -1] ); | |
0 | 1230 } |
1231 v16 = v126; | |
1232 --v17; | |
1233 } | |
1234 if ( v17 < 0 ) | |
1235 v17 = 0; | |
1236 v35 = terrain_76DDC8[v17]; | |
1237 v125 = terrain_76DDC8[v17]; | |
1238 while ( v35 <= v123 ) | |
1239 { | |
1240 v22 = terrain_76DFC8[v17] == 65535; | |
67 | 1241 terrain_76DBC8[v16] = terrain_76DFC8[v17] + 1; |
1242 terrain_76D9C8[v16] = v125; | |
0 | 1243 if ( v22 ) |
1244 { | |
67 | 1245 terrain_76DBC8[v16] = v124 + 1; |
0 | 1246 break; |
1247 } | |
1248 if ( !v17 ) | |
1249 break; | |
67 | 1250 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1251 { |
1252 do | |
67 | 1253 v36 = terrain_76DBC8[v17-- -1]; |
1254 while ( v36 == terrain_76DBC8[v17 -1] ); | |
0 | 1255 } |
1256 --v17; | |
1257 ++v125; | |
1258 v35 = v125; | |
67 | 1259 ++v16; |
1260 } | |
1261 v16 = 0; | |
1262 v126 = 0; | |
0 | 1263 v37 = terrain_76E1C8[v18]; |
1264 if ( v122 < v37 ) | |
1265 { | |
67 | 1266 v114 = v122; |
1267 memset32(terrain_76D7C8, i, 4 * (v37 - v122 + 1)); | |
0 | 1268 do |
1269 { | |
1270 v38 = v126; | |
67 | 1271 v39 = v114; |
1272 ++v126; | |
1273 ++v114; | |
1274 terrain_76D5C8[v38] = v39; | |
1275 } | |
1276 while ( v114 <= terrain_76E1C8[v18] ); | |
1277 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) | |
0 | 1278 { |
1279 do | |
67 | 1280 v40 = terrain_76DFC8[v18-- -1]; |
1281 while ( v40 == terrain_76DFC8[v18 -1] ); | |
0 | 1282 } |
1283 v16 = v126; | |
1284 --v18; | |
1285 } | |
1286 if ( v18 < 0 ) | |
1287 v18 = 0; | |
1288 v41 = terrain_76E1C8[v18]; | |
1289 while ( v41 <= v123 ) | |
1290 { | |
1291 v42 = terrain_76E3C8[v18]; | |
67 | 1292 terrain_76D5C8[v16] = v41; |
1293 terrain_76D7C8[v16] = v42; | |
0 | 1294 if ( v42 == 65535 ) |
1295 { | |
67 | 1296 terrain_76D7C8[v16] = v124; |
1297 break; | |
0 | 1298 } |
1299 if ( !v18 ) | |
1300 break; | |
67 | 1301 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) |
0 | 1302 { |
1303 do | |
67 | 1304 v43 = terrain_76DFC8[v18-- -1]; |
1305 while ( v43 == terrain_76DFC8[v18 -1] ); | |
0 | 1306 } |
1307 --v18; | |
1308 ++v41; | |
67 | 1309 ++v16; |
0 | 1310 } |
1311 break; | |
67 | 1312 } |
0 | 1313 case 5: |
1314 case 6: | |
67 | 1315 { |
0 | 1316 v116 = terrain_76DDC8[v17]; |
1317 if ( v119 > v116 ) | |
1318 { | |
1319 v106 = v119; | |
67 | 1320 memset32(terrain_76DBC8, i, 4 * (v119 - v116 + 1)); |
0 | 1321 v45 = v119; |
1322 do | |
67 | 1323 terrain_76D9C8[v126++] = v45--; |
0 | 1324 while ( v45 >= v116 ); |
67 | 1325 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1326 { |
1327 do | |
67 | 1328 v46 = terrain_76DBC8[v17-- -1]; |
1329 while ( v46 == terrain_76DBC8[v17 -1] ); | |
0 | 1330 } |
1331 v16 = v126; | |
1332 --v17; | |
1333 } | |
1334 if ( v17 < 0 ) | |
1335 v17 = 0; | |
1336 v47 = terrain_76DDC8[v17]; | |
1337 v125 = terrain_76DDC8[v17]; | |
1338 while ( v47 >= v123 ) | |
1339 { | |
1340 v22 = terrain_76DFC8[v17] == 65535; | |
67 | 1341 terrain_76DBC8[v16] = terrain_76DFC8[v17]; |
1342 terrain_76D9C8[v16] = v125; | |
0 | 1343 if ( v22 ) |
1344 { | |
67 | 1345 terrain_76DBC8[v16] = v124; |
0 | 1346 break; |
1347 } | |
1348 if ( !v17 ) | |
1349 break; | |
67 | 1350 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1351 { |
1352 do | |
67 | 1353 v48 = terrain_76DBC8[v17-- -1]; |
1354 while ( v48 == terrain_76DBC8[v17 -1] ); | |
0 | 1355 } |
1356 --v17; | |
1357 --v125; | |
1358 v47 = v125; | |
67 | 1359 ++v16; |
1360 } | |
1361 v16 = 0; | |
0 | 1362 v49 = terrain_76E1C8[v18]; |
67 | 1363 v126 = 0; |
0 | 1364 if ( v119 > v49 ) |
1365 { | |
1366 v125 = v119; | |
67 | 1367 memset32(terrain_76D7C8, v120 + 1, 4 * (v119 - v49 + 1)); |
0 | 1368 do |
1369 { | |
1370 v50 = v126; | |
1371 v51 = v125--; | |
67 | 1372 ++v126; |
1373 terrain_76D5C8[v50] = v51; | |
0 | 1374 } |
1375 while ( v125 >= terrain_76E1C8[v18] ); | |
67 | 1376 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) |
0 | 1377 { |
1378 do | |
67 | 1379 v52 = terrain_76DFC8[v18-- -1]; |
1380 while ( v52 == terrain_76DFC8[v18 -1] ); | |
0 | 1381 } |
1382 v16 = v126; | |
1383 --v18; | |
1384 } | |
1385 if ( v18 < 0 ) | |
1386 v18 = 0; | |
1387 v53 = terrain_76E1C8[v18]; | |
1388 while ( v53 >= v123 ) | |
1389 { | |
1390 v54 = terrain_76E3C8[v18]; | |
67 | 1391 terrain_76D5C8[v16] = v53; |
1392 terrain_76D7C8[v16] = v54 + 1; | |
0 | 1393 if ( v54 == 65535 ) |
1394 { | |
67 | 1395 terrain_76D7C8[v16] = v124 + 1; |
1396 break; | |
0 | 1397 } |
1398 if ( !v18 ) | |
67 | 1399 break; |
1400 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) | |
0 | 1401 { |
1402 do | |
67 | 1403 v55 = terrain_76DFC8[v18-- -1]; |
1404 while ( v55 == terrain_76DFC8[v18 -1] ); | |
0 | 1405 } |
1406 --v18; | |
1407 --v53; | |
67 | 1408 ++v16; |
0 | 1409 } |
1410 break; | |
67 | 1411 } |
0 | 1412 case 3: |
1413 case 4: | |
67 | 1414 { |
0 | 1415 v116 = terrain_76DFC8[v17]; |
1416 if ( i < v116 ) | |
1417 { | |
1418 v106 = i; | |
67 | 1419 memset32(terrain_76D9C8, v122, 4 * (v116 - i + 1)); |
0 | 1420 v56 = i; |
1421 do | |
1422 { | |
67 | 1423 v57 = v126++; |
0 | 1424 terrain_76DBC8[v57] = v56++; |
1425 } | |
1426 while ( v56 <= v116 ); | |
67 | 1427 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) |
0 | 1428 { |
1429 do | |
67 | 1430 v58 = terrain_76DDC8[v17-- -1]; |
1431 while ( v58 == terrain_76DDC8[v17 -1] ); | |
0 | 1432 } |
1433 v16 = v126; | |
1434 --v17; | |
1435 } | |
1436 if ( v17 < 0 ) | |
1437 v17 = 0; | |
1438 v59 = terrain_76DFC8[v17]; | |
1439 while ( 1 ) | |
1440 { | |
1441 v125 = v59; | |
67 | 1442 if ( v59 > v124 ) |
0 | 1443 break; |
67 | 1444 terrain_76DBC8[v16] = v59; |
0 | 1445 v60 = terrain_76DDC8[v17]; |
67 | 1446 terrain_76D9C8[v16] = v60; |
0 | 1447 if ( v60 == 65535 ) |
1448 { | |
67 | 1449 terrain_76D9C8[v16] = v123; |
0 | 1450 break; |
1451 } | |
1452 if ( !v17 ) | |
1453 break; | |
67 | 1454 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) |
0 | 1455 { |
1456 do | |
67 | 1457 v61 = terrain_76DDC8[v17-- -1]; |
1458 while ( v61 == terrain_76DDC8[v17 -1] ); | |
0 | 1459 } |
1460 --v17; | |
1461 v59 = v125 + 1; | |
67 | 1462 ++v16; |
1463 } | |
1464 v16 = 0; | |
1465 v126 = 0; | |
0 | 1466 v62 = terrain_76E3C8[v18]; |
1467 if ( i < v62 ) | |
1468 { | |
67 | 1469 v114 = i; |
1470 memset32(terrain_76D5C8, v119 + 1, 4 * (v62 - i + 1)); | |
0 | 1471 do |
1472 { | |
1473 v63 = v126; | |
67 | 1474 v64 = v114; |
1475 ++v126; | |
1476 ++v114; | |
1477 terrain_76D7C8[v63] = v64; | |
1478 } | |
1479 while ( v114 <= terrain_76E3C8[v18] ); | |
1480 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) | |
0 | 1481 { |
1482 do | |
67 | 1483 v65 = terrain_76E1C8[v18-- -1]; |
1484 while ( v65 == terrain_76E1C8[v18 -1] ); | |
0 | 1485 } |
1486 v16 = v126; | |
1487 --v18; | |
1488 } | |
1489 if ( v18 < 0 ) | |
1490 v18 = 0; | |
1491 v66 = terrain_76E3C8[v18]; | |
67 | 1492 while ( v66 <= v124 ) |
0 | 1493 { |
1494 v67 = terrain_76E1C8[v18]; | |
67 | 1495 terrain_76D7C8[v16] = v66; |
1496 terrain_76D5C8[v16] = v67 + 1; | |
0 | 1497 if ( v67 == 65535 ) |
1498 { | |
1499 v31 = v123 + 1; | |
67 | 1500 terrain_76D5C8[v16] = v31; |
1501 break; | |
0 | 1502 } |
1503 if ( !v18 ) | |
67 | 1504 break; |
1505 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) | |
0 | 1506 { |
1507 do | |
67 | 1508 v68 = terrain_76E1C8[v18-- -1]; |
1509 while ( v68 == terrain_76E1C8[v18 -1] ); | |
0 | 1510 } |
1511 --v18; | |
1512 ++v66; | |
67 | 1513 ++v16; |
0 | 1514 } |
1515 break; | |
67 | 1516 } |
0 | 1517 default: |
1518 break; | |
1519 } | |
67 | 1520 v69 = v16 - 1; |
0 | 1521 ptr_801A08 = pVerticesSR_806210; |
1522 ptr_801A04 = pVerticesSR_801A10; | |
67 | 1523 v126 = v69; |
106 | 1524 if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//áëîê |
0 | 1525 { |
1526 for ( i = v69; i >= 1; --i ) | |
1527 { | |
67 | 1528 //v70 = i; |
86 | 1529 v71 = terrain_76D7C8[i];//88 |
1530 v72 = terrain_76DBC8[i];//0 | |
67 | 1531 if ( v71 < v72 )//swap |
1532 { | |
1533 terrain_76DBC8[i] = v71; | |
1534 terrain_76D7C8[i] = v72; | |
1535 } | |
86 | 1536 x = terrain_76DBC8[i];//0 |
0 | 1537 v111 = 0; |
86 | 1538 if ( x <= 0 ) |
1539 x = -x; | |
67 | 1540 v74 = terrain_76D7C8[i]; |
0 | 1541 if ( v74 <= 0 ) |
1542 v74 = -v74; | |
1543 v75 = v74 + 2; | |
67 | 1544 //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; |
86 | 1545 uEndZ = v75; |
67 | 1546 //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; |
86 | 1547 uStartZ = x - 2; |
1548 if ( x - 2 < v75 ) | |
0 | 1549 { |
1550 v127 = 0; | |
67 | 1551 //v79 = (v73 - 66) << 9; |
1552 //v116 = v77; | |
1553 //pHeight = v79; | |
86 | 1554 v111 = v75 - uStartZ; |
1555 for (int z = uStartZ; z < uEndZ; ++z) | |
1556 { | |
106 | 1557 ptr_801A08[v127].vWorldPosition.x = (-64 + x) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; |
67 | 1558 ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; |
86 | 1559 ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); |
1560 ptr_801A04[v127].vWorldPosition.x = (-64 + x) * 512; | |
67 | 1561 ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; |
86 | 1562 ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); |
0 | 1563 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1564 { | |
67 | 1565 pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); |
1566 pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); | |
1567 pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); | |
1568 pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0); | |
0 | 1569 } |
67 | 1570 //v79 += 512; |
1571 v127 ++; | |
1572 //++v116; | |
1573 //pHeight = v79; | |
106 | 1574 } |
67 | 1575 //while ( v116 < v107 ); |
1576 } | |
106 | 1577 v102.v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); |
67 | 1578 v102.v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); |
106 | 1579 if ( pRenderer->pRenderD3D )//Ritor1: do comment to test |
98 | 1580 Render::RenderTerrainD3D();//Render::DrawTerrainD3D(v111, 0, (int)&v102); |
67 | 1581 else |
1582 Render::DrawTerrainSW(v111, 0, (int)&v102); | |
1583 } | |
1584 } | |
1585 /* else | |
0 | 1586 { |
1587 for ( i = v69; i >= 1; --i ) | |
1588 { | |
1589 v86 = i; | |
1590 v87 = terrain_76D5C8[i]; | |
1591 v88 = terrain_76D9C8[i]; | |
1592 if ( v87 < v88 ) | |
1593 { | |
1594 terrain_76D9C8[v86] = v87; | |
1595 terrain_76D5C8[v86] = v88; | |
1596 } | |
1597 v89 = terrain_76D9C8[v86]; | |
1598 v111 = 0; | |
1599 if ( v89 <= 0 ) | |
1600 v89 = -v89; | |
1601 v90 = terrain_76D5C8[v86]; | |
1602 if ( v90 <= 0 ) | |
1603 v90 = -v90; | |
67 | 1604 pIndoorCameraD3D_4 = pGame->pIndoorCameraD3D; |
0 | 1605 v107 = v90 + 2; |
1606 if ( v89 - 2 < v90 + 2 ) | |
1607 { | |
1608 v86 = 0; | |
1609 v116 = v89 - 2; | |
1610 v92 = (66 - v89) << 9; | |
62 | 1611 pHeight = (66 - v89) << 9; |
0 | 1612 v111 = v90 + 2 - (v89 - 2); |
1613 do | |
1614 { | |
1615 v93 = v116; | |
1616 v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9; | |
1617 *(float *)((char *)&ptr_801A08->vWorldPosition.x + v86) = (double)v106; | |
62 | 1618 *(float *)&pHeight = (double)pHeight; |
1619 *(float *)((char *)&ptr_801A08->vWorldPosition.y + v86) = *(float *)&pHeight; | |
0 | 1620 v106 = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86), v93); |
1621 v97 = v116; | |
1622 *(float *)((char *)&ptr_801A08->vWorldPosition.z + v86) = (double)v106; | |
1623 v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9; | |
1624 *(float *)((char *)&ptr_801A04->vWorldPosition.x + v86) = (double)v106; | |
62 | 1625 *(float *)((char *)&ptr_801A04->vWorldPosition.y + v86) = *(float *)&pHeight; |
1626 pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97); | |
1627 *(float *)((char *)&ptr_801A04->vWorldPosition.z + v86) = (double)pHeight; | |
0 | 1628 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1629 { | |
67 | 1630 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1); |
1631 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1); | |
1632 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0); | |
1633 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0); | |
0 | 1634 } |
1635 v92 -= 512; | |
1636 v86 += 48; | |
1637 ++v116; | |
62 | 1638 pHeight = v92; |
0 | 1639 } |
1640 while ( v116 < v107 ); | |
1641 } | |
1642 v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]); | |
1643 v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]); | |
67 | 1644 if ( pRenderer->pRenderD3D ) |
1645 Render::DrawTerrainD3D(v111, 1, (int)&v102); | |
1646 else | |
1647 Render::DrawTerrainSW(v111, 1, (int)&v102); | |
1648 } | |
1649 }*/ | |
0 | 1650 result = v126; |
1651 pOutdoorCamera->field_40 = v126; | |
1652 return result; | |
1653 } | |
1654 // 47FFC4: inconsistent fpu stack | |
1655 // 4D864C: using guessed type char byte_4D864C; | |
1656 | |
88 | 1657 void Render::RenderTerrainD3D() // New function. It's temporary |
86 | 1658 { |
1659 char result; // al@3 | |
1660 //int v1; // eax@3 | |
1661 //int v2; // ebx@4 | |
1662 //struct ODMFace *v4; // esi@6 | |
1663 int v6; // ecx@8 | |
1664 //int v7; // ecx@8 | |
1665 struct stru148 *v8; // ebx@8 | |
179 | 1666 // RenderVertexSoft *v8a; // edi@3 |
86 | 1667 //char v11; // zf@8 |
1668 struct stru148 *v16; | |
1669 unsigned int v18; // edi@22 | |
1670 //int v20; // edi@34 | |
1671 //int v28; // eax@50 | |
1672 //int v29; // ecx@55 | |
1673 //int v30; // eax@57 | |
1674 int v31; // eax@57 | |
1675 int v35; // edi@63 | |
1676 int v37; // eax@73 | |
1677 int v39; // eax@80 | |
1678 char v40; // [sp-18h] [bp-70h]@2 | |
1679 int v41; // [sp-14h] [bp-6Ch]@2 | |
1680 int v42; // [sp-10h] [bp-68h]@2 | |
1681 int v43; // [sp-Ch] [bp-64h]@2 | |
1682 const char *v44; // [sp-8h] [bp-60h]@2 | |
1683 int v45; // [sp-4h] [bp-5Ch]@2 | |
1684 //float v48; // [sp+14h] [bp-44h]@8 | |
1685 //void *v52; // [sp+24h] [bp-34h]@3 | |
1686 bool v54; // [sp+2Ch] [bp-2Ch]@10 | |
1687 int v55; // [sp+30h] [bp-28h]@34 | |
1688 int v56; | |
1689 int v57; // [sp+38h] [bp-20h]@36 | |
1690 int v58; // [sp+3Ch] [bp-1Ch]@8 | |
1691 int v63; // [sp+50h] [bp-8h]@3 | |
1692 int v64; // [sp+57h] [bp-1h]@2 | |
1693 int v62; | |
121 | 1694 //struct IndoorCameraD3D *pIndoorCameraD3D; |
179 | 1695 //RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 |
86 | 1696 |
186 | 1697 |
1698 //warning: the game uses CW culling by default, ccw is incosistent | |
1699 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
1700 | |
1701 | |
86 | 1702 v63 = 0; |
1703 // basic optimizations | |
577 | 1704 unsigned int uStartX, uEndX, uStartZ, uEndZ; |
106 | 1705 if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024) |
1706 { | |
1707 uStartX = 0, uEndX = 128; | |
1708 uStartZ = 0, uEndZ = 64 + 16; | |
1709 } | |
1710 else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536) | |
1711 { | |
1712 uStartX = 0, uEndX = 64 + 16; | |
1713 uStartZ = 0, uEndZ = 128; | |
1714 } | |
1715 else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512) | |
1716 { | |
1717 uStartX = 64 - 16, uEndX = 128; | |
1718 uStartZ = 0, uEndZ = 128; | |
1719 } | |
1720 else | |
1721 { | |
1722 uStartX = 0, uEndX = 128; | |
1723 uStartZ = 64 - 16, uEndZ = 128; | |
1724 } | |
147 | 1725 uStartX = 0, uEndX = 128; |
1726 uStartZ = 0, uEndZ = 128; | |
106 | 1727 static RenderVertexSoft pTerrainVertices[128 * 128]; |
1728 for (unsigned int z = uStartZ; z < uEndZ; ++z) | |
1729 { | |
1730 for (unsigned int x = uStartX; x < uEndX; ++x) | |
1731 { | |
1732 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; | |
1733 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512; | |
1734 pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 1735 //pIndoorCameraD3D = pGame->pIndoorCameraD3D; |
1736 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); | |
1737 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 1738 } |
1739 } | |
186 | 1740 |
106 | 1741 for (unsigned int z = uStartZ; z < uEndZ - 1; ++z) |
1742 { | |
1743 for (unsigned int x = uStartX; x < uEndX - 1; ++x) | |
1744 { | |
1745 v8 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
1746 v8->flags = 0; | |
1747 v8->field_32 = 0; | |
1748 //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x]; | |
179 | 1749 //struct TileDesc *pTile = pTileTable->GetTileById(uTileID); |
106 | 1750 v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); |
179 | 1751 //v6 = v8->uTileBitmapID; |
1752 v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v8->uTileBitmapID]; | |
106 | 1753 if (v8->uTileBitmapID == 0xFFFF) |
1754 continue; | |
186 | 1755 |
179 | 1756 v8->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
1757 v8->field_32 = 0; | |
1758 v8->field_59 = 1; | |
1759 //v8->field_5D = (char)WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8a->vWorldPosition.z) / 2 + 0.5f)); | |
1760 //v8->field_5C = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f));; | |
106 | 1761 v8->sTextureDeltaU = 0; |
1762 v8->sTextureDeltaV = 0; | |
1763 memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft)); | |
1764 array_73D150[0].u = 0; | |
1765 array_73D150[0].v = 0; | |
1766 memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1767 array_73D150[1].u = 1; | |
1768 array_73D150[1].v = 0; | |
1769 memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1770 array_73D150[2].u = 1; | |
1771 array_73D150[2].v = 1; | |
1772 memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft)); | |
1773 array_73D150[3].u = 0; | |
1774 array_73D150[3].v = 1; | |
86 | 1775 v55 = 0; |
1776 v54 = false; | |
1777 v58 = 0; | |
1778 if (v58 == 4) // if all y == first y; primitive in xz plane | |
1779 v8->field_32 |= 0x0001; | |
1780 v8->pODMFace = nullptr; | |
1781 v8->uNumVertices = 4; | |
1782 v8->field_59 = 5; | |
638 | 1783 |
1784 | |
1785 uint norm_idx = pTerrainNormalIndices[2 * (x + 128 * z) + 1]; | |
1786 assert(norm_idx < uNumTerrainNormals); | |
1787 | |
1788 auto norm = pTerrainNormals + norm_idx; | |
1789 float _f = (norm->x * (float)pOutdoor->vSunlight.x / 65536.0 - | |
1790 norm->y * (float)pOutdoor->vSunlight.y / 65536.0 - | |
1791 norm->z * (float)pOutdoor->vSunlight.z / 65536.0); | |
1792 v8->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); | |
1793 | |
86 | 1794 ++pOutdoorCamera->numStru148s; |
1795 ++pOutdoorCamera->field_44; | |
265 | 1796 assert(pOutdoorCamera->numStru148s < 20000); |
1797 | |
106 | 1798 v8->uBModelID = 0; |
1799 v8->uBModelFaceID = 0; | |
1800 v31 = (8 * (0 | (0 << 6))); | |
1801 v8->field_50 = v31 | 6; | |
265 | 1802 for (unsigned int k = 0; k < v8->uNumVertices; ++k) |
106 | 1803 { |
1804 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 1805 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 1806 } |
140 | 1807 |
186 | 1808 bool transparent = false; |
265 | 1809 if ( v8->flags & 2 && v8->uTileBitmapID == pRenderer->hd_water_tile_id) |
179 | 1810 { |
1811 //v80 = false; | |
265 | 1812 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
179 | 1813 } |
1814 else | |
1815 { | |
1816 v6 = v8->uTileBitmapID; | |
186 | 1817 transparent = true; |
179 | 1818 } |
1819 | |
140 | 1820 assert(v6 < 1000); // many random crashes here |
186 | 1821 |
1822 // for all shore tiles - draw a tile water under them since they're half-empty | |
1823 if (!strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX | |
1824 { | |
1825 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE); // no Z writing: the shore tile will be draw in the same place, so taking care about z-fighting | |
265 | 1826 pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]], false, true); |
186 | 1827 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE); |
1828 | |
1829 } | |
1830 | |
1831 pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
1832 | |
1833 | |
86 | 1834 --pOutdoorCamera->numStru148s; |
1835 --pOutdoorCamera->field_44; | |
106 | 1836 } |
1837 } | |
1838 } | |
0 | 1839 |
1840 //----- (0048034E) -------------------------------------------------------- | |
67 | 1841 void Render::DrawTerrainD3D(int a1, int a2, int a3) |
0 | 1842 { |
1843 int v3; // esi@1 | |
1844 int v4; // edi@1 | |
1845 int v5; // ebx@2 | |
1846 int v6; // eax@2 | |
1847 int v7; // eax@3 | |
1848 RenderVertexSoft *v8; // edi@3 | |
1849 RenderVertexSoft *v9; // ebx@4 | |
1850 RenderVertexSoft *v10; // ecx@4 | |
1851 float v11; // eax@6 | |
1852 double v12; // ST5C_8@6 | |
1853 double v13; // ST2C_8@6 | |
1854 int v14; // eax@6 | |
1855 double v15; // st7@6 | |
1856 stru148 *v16; // ebx@12 | |
1857 unsigned __int16 v17; // ax@12 | |
1858 int v18; // eax@13 | |
67 | 1859 int v19; // ecx@13 |
1860 int v20; // eax@13 | |
0 | 1861 int v21; // eax@13 |
1862 signed int v22; // eax@13 | |
1863 Vec3_float_ *v23; // eax@15 | |
1864 double v24; // st6@17 | |
1865 double v25; // ST54_8@17 | |
1866 unsigned __int8 v26; // sf@17 | |
1867 unsigned __int8 v27; // of@17 | |
1868 double v28; // st5@19 | |
1869 double v29; // st5@19 | |
1870 double v30; // st5@19 | |
1871 double v31; // st5@19 | |
67 | 1872 struct struct8 *v32; // esi@21 |
1873 double v3a; // st7@32 | |
0 | 1874 int v33; // edi@38 |
1875 unsigned int v34; // ecx@47 | |
1876 char v35; // zf@47 | |
1877 unsigned int v36; // eax@50 | |
1878 int v37; // eax@54 | |
1879 stru148 *v38; // ecx@55 | |
1880 unsigned int v39; // eax@59 | |
1881 stru148 *v40; // ebx@62 | |
86 | 1882 unsigned __int16 pTileBitmapsID; // ax@62 |
0 | 1883 int v42; // eax@63 |
1884 LightmapBuilder *v43; // ecx@63 | |
67 | 1885 int v44; // eax@63 |
0 | 1886 int v45; // eax@63 |
1887 int v46; // eax@63 | |
1888 signed int v47; // eax@63 | |
1889 Vec3_float_ *v48; // eax@65 | |
1890 double v49; // st6@67 | |
1891 double v50; // ST4C_8@67 | |
1892 double v51; // st5@71 | |
1893 double v52; // st5@71 | |
1894 double v53; // st5@71 | |
1895 double v54; // st7@84 | |
1896 unsigned int v55; // ecx@98 | |
1897 unsigned int v56; // eax@101 | |
1898 int v57; // eax@105 | |
1899 unsigned int v58; // eax@109 | |
1900 stru148 *v59; // esi@112 | |
1901 unsigned __int16 v60; // ax@112 | |
67 | 1902 int v61; // eax@113 |
0 | 1903 signed int v62; // eax@113 |
1904 Vec3_float_ *v63; // eax@114 | |
1905 double v64; // st6@116 | |
1906 double v65; // ST3C_8@116 | |
1907 double v66; // st5@120 | |
1908 double v67; // st5@120 | |
1909 double v68; // st5@120 | |
1910 double v69; // st7@133 | |
1911 int v70; // edi@138 | |
86 | 1912 stru148 *v71; // esi@147 |
0 | 1913 unsigned int v72; // ecx@147 |
1914 unsigned int v73; // eax@150 | |
67 | 1915 int v74; // eax@154 |
0 | 1916 unsigned int v75; // eax@158 |
1917 unsigned int v76; // [sp-10h] [bp-E0h]@61 | |
67 | 1918 int v77; // [sp-Ch] [bp-DCh]@61 |
0 | 1919 IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 |
1920 int v79; // [sp-4h] [bp-D4h]@61 | |
1921 int v80; // [sp+0h] [bp-D0h]@59 | |
1922 int v81; // [sp+0h] [bp-D0h]@109 | |
1923 int v82; // [sp+54h] [bp-7Ch]@1 | |
1924 int v83; // [sp+60h] [bp-70h]@1 | |
1925 int v84; // [sp+6Ch] [bp-64h]@1 | |
1926 int v85; // [sp+70h] [bp-60h]@63 | |
1927 int a4; // [sp+74h] [bp-5Ch]@73 | |
1928 float v87; // [sp+78h] [bp-58h]@122 | |
1929 int v88; // [sp+7Ch] [bp-54h]@1 | |
1930 int v89; // [sp+80h] [bp-50h]@6 | |
1931 float v90; // [sp+84h] [bp-4Ch]@1 | |
1932 float v91; // [sp+88h] [bp-48h]@1 | |
1933 float v92; // [sp+8Ch] [bp-44h]@1 | |
67 | 1934 int v93; // [sp+90h] [bp-40h]@2 |
0 | 1935 int X; // [sp+94h] [bp-3Ch]@1 |
1936 float v95; // [sp+98h] [bp-38h]@21 | |
1937 LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 | |
67 | 1938 int v97; // [sp+A0h] [bp-30h]@6 |
0 | 1939 int sX; // [sp+A4h] [bp-2Ch]@6 |
1940 unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 | |
1941 int v100; // [sp+ACh] [bp-24h]@122 | |
1942 int sY; // [sp+B0h] [bp-20h]@6 | |
67 | 1943 RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 |
0 | 1944 unsigned int a5; // [sp+B8h] [bp-18h]@21 |
1945 RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 | |
1946 Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 | |
1947 RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 | |
67 | 1948 RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 |
0 | 1949 char v108; // [sp+CFh] [bp-1h]@36 |
1950 float thisd; // [sp+D8h] [bp+8h]@6 | |
1951 float thise; // [sp+D8h] [bp+8h]@6 | |
1952 float thisf; // [sp+D8h] [bp+8h]@17 | |
1953 IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 | |
1954 float thisg; // [sp+D8h] [bp+8h]@67 | |
1955 IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 | |
1956 float thish; // [sp+D8h] [bp+8h]@116 | |
1957 IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 | |
1958 char this_3; // [sp+DBh] [bp+Bh]@30 | |
1959 char this_3a; // [sp+DBh] [bp+Bh]@82 | |
1960 char this_3b; // [sp+DBh] [bp+Bh]@131 | |
1961 | |
67 | 1962 static stru154 static_sub_0048034E_stru_154; |
1963 static stru154 stru_76D5A8; | |
0 | 1964 v3 = a1; |
67 | 1965 v82 = a2; |
0 | 1966 v83 = *(/*short **/_WORD *)(a3 + 4); |
1967 X = abs(*(/*short **/_WORD *)(a3 + 6)); | |
1968 v4 = 0; | |
1969 v88 = 0; | |
1970 v84 = v3 - 1; | |
638 | 1971 v90 = (float)pOutdoor->vSunlight.x / 65536.0; |
67 | 1972 v91 = (float)pOutdoor->vSunlight.y / 65536.0; |
1973 v92 = (float)pOutdoor->vSunlight.z / 65536.0; | |
0 | 1974 if ( v3 - 1 > 0 ) |
1975 { | |
1976 while ( 1 ) | |
1977 { | |
1978 v5 = abs(X);//v5 = 13108 | |
1979 v6 = abs(v83);//v6 = 13108 | |
1980 --X; | |
186 | 1981 __debugbreak(); // uncoment & refactor following large if |
67 | 1982 v93 = (int)&stru_76E5C8[(v5 << 7) + v6]; |
1983 /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), | |
0 | 1984 v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), |
1985 ((a8 = v9, | |
1986 pVertices = &pVerticesSR_801A10[1] + v7, | |
1987 v11 = v8->vWorldPosition.x, | |
1988 v101 = v10, | |
1989 v12 = v11 + 6.755399441055744e15, | |
1990 sX = LODWORD(v12), | |
1991 v13 = v8->vWorldPosition.y + 6.755399441055744e15, | |
1992 sY = LODWORD(v13), | |
1993 thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, | |
62 | 1994 v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X |
0 | 1995 v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, |
1996 v89 = v14, | |
1997 thise = v15 * 0.5, | |
62 | 1998 _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z |
0 | 1999 WorldPosToGridCellX(sX), |
2000 WorldPosToGridCellZ(sY), | |
2001 !byte_4D864C) | |
2002 || !(pGame->uFlags & 0x80)) | |
67 | 2003 && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ |
2004 if ( !&stru_76E5C8[(v5 << 7) + v6] ) | |
0 | 2005 goto LABEL_162; |
67 | 2006 v8 = &pVerticesSR_806210[v4]; |
2007 pVertices2 = &pVerticesSR_801A10[v4 + 1]; | |
2008 v102 = v8; | |
2009 if (!v82) | |
2010 { | |
86 | 2011 pVertices = &pVerticesSR_801A10[v4]; |
2012 v101 = &pVerticesSR_806210[v4 + 1]; | |
67 | 2013 } |
2014 else | |
2015 { | |
86 | 2016 pVertices = &pVerticesSR_801A10[v4 + 1]; |
2017 v101 = &pVerticesSR_806210[v4]; | |
2018 } | |
67 | 2019 sX = floorf(v8->vWorldPosition.x + 0.5f); |
2020 sY = floorf(v8->vWorldPosition.z + 0.5f); | |
2021 v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); | |
2022 v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); | |
2023 WorldPosToGridCellX(sX); | |
2024 WorldPosToGridCellZ(sY); | |
2025 if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) | |
86 | 2026 if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y |
2027 || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) | |
67 | 2028 break; |
2029 v16 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2030 v16->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
86 | 2031 if ( v16->uTileBitmapID != -1 ) |
2032 { | |
2033 v19 = v97; | |
2034 v16->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2035 v16->field_32 = 0; | |
2036 v20 = v93; | |
2037 v16->field_59 = 1; | |
638 | 2038 v16->terrain_grid_x = (char)v19; |
86 | 2039 v16->field_34 = *(_WORD *)(v20 + 2); |
2040 v21 = v89; | |
638 | 2041 v16->terrain_grid_z = v89; |
86 | 2042 v22 = pTerrainNormalIndices[2 * (v19 + 128 * v21) + 1]; |
2043 if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) | |
2044 v23 = 0; | |
2045 else | |
2046 v23 = &pTerrainNormals[v22]; | |
638 | 2047 v24 = v92 * v23->z; |
86 | 2048 //v99 = v23; |
638 | 2049 thisf = 20.0 - (-v24 - v91 * v23->y - v90 * v23->x) * 20.0; |
86 | 2050 //v25 = thisf + 6.7553994e15; |
2051 //v27 = pOutdoorCamera->numStru148s > 1999; | |
2052 //v26 = pOutdoorCamera->numStru148s - 1999 < 0; | |
638 | 2053 v16->dimming_level = floorf(thisf + 0.5f); |
86 | 2054 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2055 return; | |
2056 ++pOutdoorCamera->numStru148s; | |
96 | 2057 //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary |
4 | 2058 //goto LABEL_126; |
96 | 2059 //{ |
2060 //--pOutdoorCamera->numStru148s; | |
2061 //goto LABEL_162; | |
2062 //} | |
86 | 2063 memcpy(&array_50AC10[0], v102, 0x30u); |
168 | 2064 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2065 array_50AC10[0].u = 0.0; |
2066 array_50AC10[0].v = 0.0; | |
2067 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
168 | 2068 array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2069 array_50AC10[1].u = 0.0; |
2070 array_50AC10[1].v = 1.0; | |
2071 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
168 | 2072 array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2073 array_50AC10[2].u = 1.0; |
2074 array_50AC10[2].v = 1.0; | |
2075 memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); | |
168 | 2076 array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2077 array_50AC10[3].u = 1.0; |
2078 array_50AC10[3].v = 0.0; | |
2079 /*if ( !(byte_76D5C0 & 1) ) | |
2080 { | |
2081 byte_76D5C0 |= 1u; | |
2082 stru154(stru_76D5A8); | |
2083 atexit(loc_481199); | |
2084 }*/ | |
2085 v32 = (struct8 *)array_50AC10; | |
2086 v97 = (int)pGame->pLightmapBuilder; | |
2087 pGame->pLightmapBuilder->StackLights_TerrainFace(v23, &v95, array_50AC10, 4, 1); | |
2088 pDecalBuilder->_49BE8A(v16, *(float *)&v23, (int)&v95, array_50AC10, 4, 1); | |
2089 a5 = 4; | |
2090 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2091 { | |
2092 thisa = pGame->pIndoorCameraD3D; | |
2093 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) | |
2094 goto LABEL_162; | |
2095 thisa->ViewTransform(array_50AC10, a5); | |
2096 thisa->Project(array_50AC10, a5, 0); | |
2097 } | |
2098 this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 | |
2099 || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
2100 v3a = (double)pOutdoorCamera->shading_dist_mist; | |
2101 v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x | |
2102 || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; | |
2103 v33 = 0; | |
2104 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
2105 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
0 | 2106 { |
86 | 2107 if ( this_3 ) |
2108 v33 = 3; | |
2109 else | |
2110 v33 = v108 != 0 ? 5 : 0; | |
734 | 2111 static_sub_0048034E_stru_154.ClassifyPolygon(v23, v95); |
86 | 2112 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2113 pDecalBuilder->ApplyDecals(31 - v16->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); |
0 | 2114 } |
86 | 2115 if ( stru_F8AD28.uNumLightsApplied > 0 ) |
2116 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); | |
2117 v34 = a5; | |
2118 //v35 = byte_4D864C == 0; | |
2119 v16->uNumVertices = a5; | |
2120 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) | |
0 | 2121 { |
86 | 2122 if ( this_3 ) |
2123 { | |
2124 v36 = sr_424CD7(v34); | |
2125 v16->uNumVertices = v36; | |
2126 OutdoorCamera::Project(v36); | |
2127 } | |
2128 if ( v108 ) | |
2129 { | |
2130 v36 = sr_424EE0_MakeFanFromTriangle(v34); | |
2131 v16->uNumVertices = v36; | |
2132 OutdoorCamera::Project(v36); | |
2133 } | |
0 | 2134 } |
86 | 2135 //v37 = *(int *)&v16->flags; |
2136 if ( ~v16->flags & 1 ) | |
2137 { | |
265 | 2138 if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2139 { |
2140 v80 = false; | |
265 | 2141 v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2142 } |
2143 else | |
2144 { | |
2145 v39 = v16->uTileBitmapID; | |
2146 v80 = true; | |
2147 } | |
2148 //v79 = 0; | |
2149 //v78 = pBitmaps_LOD->pHardwareTextures[v39]; | |
2150 v16->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary | |
2151 v77 = (int)v16; | |
2152 //v76 = v16->uNumVertices; | |
4 | 2153 //LABEL_161: |
186 | 2154 pRenderer->DrawTerrainPolygon(v16->uNumVertices, v16, pBitmaps_LOD->pHardwareTextures[v39], false, v80); |
86 | 2155 goto LABEL_162; |
2156 } | |
2157 v38 = v16; | |
0 | 2158 LABEL_56: |
86 | 2159 v38->_4811A3(); |
2160 } | |
0 | 2161 LABEL_162: |
86 | 2162 v4 = v88 + 1; |
2163 if ( ++v88 >= v84 ) | |
2164 return; | |
2165 } | |
2166 v40 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2167 v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
2168 if ( v40->uTileBitmapID == -1 ) | |
2169 goto LABEL_162; | |
2170 v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2171 BYTE1(v42) |= 0x80u; | |
2172 v43 = pGame->pLightmapBuilder; | |
2173 *(int *)&v40->flags = v42; | |
2174 v44 = v93; | |
2175 v40->field_59 = 1; | |
638 | 2176 v40->terrain_grid_x = (char)v43; |
86 | 2177 v40->field_34 = *(_WORD *)(v44 + 2); |
2178 v45 = v89; | |
638 | 2179 v40->terrain_grid_z = v89; |
86 | 2180 v46 = 4 * ((char)v43 + (v45 << 7)); |
2181 v85 = v46; | |
2182 v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; | |
2183 if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) | |
2184 v48 = 0; | |
2185 else | |
2186 v48 = &pTerrainNormals[v47]; | |
2187 v49 = v92 * v48->y; | |
2188 //v99 = v48; | |
2189 thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; | |
2190 v50 = thisg + 6.755399441055744e15; | |
638 | 2191 v40->dimming_level = LOBYTE(v50); |
86 | 2192 if ( LOBYTE(v50) < 0 ) |
638 | 2193 v40->dimming_level = 0; |
86 | 2194 if ( pOutdoorCamera->numStru148s >= 1999 ) |
0 | 2195 return; |
86 | 2196 ++pOutdoorCamera->numStru148s; |
2197 /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary | |
2198 //goto LABEL_77; | |
2199 { | |
2200 --pOutdoorCamera->numStru148s; | |
2201 goto LABEL_112; | |
2202 }*/ | |
2203 memcpy(&array_50AC10[0], v102, 0x30u); | |
168 | 2204 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2205 array_50AC10[0].u = 0.0; |
2206 array_50AC10[0].v = 0.0; | |
2207 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
168 | 2208 array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2209 array_50AC10[1].u = 0.0; |
2210 array_50AC10[1].v = 1.0; | |
2211 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
168 | 2212 array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2213 array_50AC10[2].u = 1.0; |
2214 array_50AC10[2].v = 1.0; | |
2215 static stru154 static_sub_0048034E_stru_76D590; | |
2216 /*static bool __init_flag2 = false; | |
2217 if (!__init_flag2) | |
2218 { | |
2219 __init_flag2 = true; | |
2220 stru154::stru154(&static_sub_0048034E_stru_76D590); | |
2221 }*/ | |
2222 /*if ( !(byte_76D5C0 & 2) ) | |
2223 { | |
2224 byte_76D5C0 |= 2; | |
2225 stru148(stru_76D590); | |
2226 atexit(loc_48118F); | |
2227 }*/ | |
2228 v96 = pGame->pLightmapBuilder; | |
2229 pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); | |
2230 pDecalBuilder->_49BE8A(v40, *(float *)&v48, (int)&a4, array_50AC10, 3, 0); | |
2231 uNumVertices = 3; | |
2232 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2233 { | |
2234 thisb = pGame->pIndoorCameraD3D; | |
2235 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) | |
2236 { | |
2237 //LABEL_77: | |
2238 --pOutdoorCamera->numStru148s; | |
2239 goto LABEL_112; | |
2240 } | |
2241 thisb->ViewTransform(array_50AC10, uNumVertices); | |
2242 thisb->Project(array_50AC10, uNumVertices, 0); | |
2243 } | |
2244 this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
2245 v54 = (double)pOutdoorCamera->shading_dist_mist; | |
2246 v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; | |
2247 pVertices = 0; | |
2248 v96->std__vector_000004_size = 0; | |
2249 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
2250 { | |
2251 if ( this_3a ) | |
2252 pVertices = (RenderVertexSoft *)3; | |
2253 else | |
2254 pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); | |
2255 //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); | |
734 | 2256 static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); |
86 | 2257 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2258 pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); |
86 | 2259 } |
2260 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
2261 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); | |
2262 v55 = uNumVertices; | |
2263 //v35 = byte_4D864C == 0; | |
2264 v40->uNumVertices = uNumVertices; | |
2265 if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) | |
2266 { | |
2267 if ( this_3a ) | |
2268 { | |
2269 v56 = sr_424CD7(v55); | |
2270 } | |
2271 else | |
2272 { | |
2273 if ( !v108 ) | |
2274 goto LABEL_105; | |
2275 v56 = sr_424EE0_MakeFanFromTriangle(v55); | |
2276 } | |
2277 v40->uNumVertices = v56; | |
2278 OutdoorCamera::Project(v56); | |
2279 } | |
2280 LABEL_105: | |
2281 v57 = *(int *)&v40->flags; | |
2282 if ( BYTE1(v57) & 1 ) | |
2283 { | |
2284 v40->_4811A3(); | |
2285 } | |
2286 else | |
2287 { | |
265 | 2288 if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2289 { |
2290 v81 = 0; | |
265 | 2291 v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2292 } |
2293 else | |
2294 { | |
2295 v58 = v40->uTileBitmapID; | |
2296 v81 = 1; | |
2297 } | |
186 | 2298 pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); |
86 | 2299 } |
2300 LABEL_112: | |
2301 v59 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2302 //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->numStru148s]; | |
2303 v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
2304 if ( v59->uTileBitmapID == -1 ) | |
2305 goto LABEL_162; | |
2306 *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2307 v61 = v93; | |
2308 v59->field_59 = 1; | |
2309 v59->field_34 = *(_WORD *)(v61 + 2); | |
638 | 2310 v59->terrain_grid_z = v89; |
2311 v59->terrain_grid_x = v97; | |
86 | 2312 v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); |
2313 if ( v62 > (signed int)(uNumTerrainNormals - 1) ) | |
2314 v63 = 0; | |
2315 else | |
2316 v63 = &pTerrainNormals[v62]; | |
2317 v64 = v92 * v63->y; | |
2318 //v99 = v63; | |
2319 thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; | |
638 | 2320 v59->dimming_level = floorf(thish + 0.5f); |
2321 if ( v59->dimming_level < 0 ) | |
2322 v59->dimming_level = 0; | |
86 | 2323 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2324 return; | |
2325 ++pOutdoorCamera->numStru148s; | |
2326 if ( !sub_481FC9(v101, v102, pVertices2, v59) ) | |
2327 { | |
2328 //LABEL_126: | |
4 | 2329 --pOutdoorCamera->numStru148s; |
86 | 2330 goto LABEL_162; |
2331 } | |
2332 memcpy(&array_50AC10[0], v102, 0x30u); | |
168 | 2333 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2334 array_50AC10[0].u = 0.0; |
2335 array_50AC10[0].v = 0.0; | |
2336 memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); | |
168 | 2337 array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2338 array_50AC10[1].u = 1.0; |
2339 array_50AC10[1].v = 1.0; | |
2340 memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); | |
168 | 2341 array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2342 array_50AC10[2].u = 1.0; |
2343 array_50AC10[2].v = 0.0; | |
2344 static stru154 static_sub_0048034E_stru_76D578; | |
2345 /*static bool __init_flag1 = false; | |
2346 if (!__init_flag1) | |
2347 { | |
2348 __init_flag1 = true; | |
2349 stru154::stru154(&static_sub_0048034E_stru_76D578); | |
2350 }*/ | |
2351 v96 = pGame->pLightmapBuilder; | |
2352 pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); | |
2353 pDecalBuilder->_49BE8A(v40, *(float *)&v63, (int)&v87, array_50AC10, 3, 1); | |
2354 v100 = 3; | |
2355 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2356 { | |
2357 thisc = pGame->pIndoorCameraD3D; | |
2358 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) | |
2359 //goto LABEL_126; | |
2360 { | |
2361 --pOutdoorCamera->numStru148s; | |
2362 goto LABEL_162; | |
2363 } | |
2364 thisc->ViewTransform(array_50AC10, v100); | |
2365 thisc->Project(array_50AC10, v100, 0); | |
2366 } | |
2367 this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 | |
2368 || v101->vWorldViewPosition.x < 8.0; | |
2369 v69 = (double)pOutdoorCamera->shading_dist_mist; | |
2370 v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; | |
2371 v70 = 0; | |
2372 v96->std__vector_000004_size = 0; | |
2373 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
2374 { | |
2375 if ( this_3b ) | |
2376 v70 = 3; | |
2377 else | |
2378 v70 = v108 != 0 ? 5 : 0; | |
734 | 2379 static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); |
86 | 2380 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2381 pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); |
86 | 2382 } |
2383 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
2384 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); | |
2385 v71 = v59; | |
2386 v72 = v100; | |
2387 //v35 = byte_4D864C == 0; | |
2388 v59->uNumVertices = v100;//??? | |
2389 if ( !byte_4D864C && pGame->uFlags & 0x80 ) | |
2390 goto LABEL_154; | |
2391 if ( this_3b ) | |
2392 { | |
2393 v73 = sr_424CD7(v72); | |
0 | 2394 } |
2395 else | |
2396 { | |
2397 if ( !v108 ) | |
86 | 2398 { |
2399 LABEL_154: | |
2400 v74 = v71->flags; | |
2401 if ( !(BYTE1(v74) & 1) ) | |
2402 { | |
265 | 2403 if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2404 { |
2405 v80 = false; | |
265 | 2406 v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2407 } |
2408 else | |
2409 { | |
2410 v75 = v71->uTileBitmapID; | |
2411 v80 = true; | |
2412 } | |
2413 //v79 = 0; | |
2414 //v78 = pBitmaps_LOD->pHardwareTextures[v75]; | |
2415 v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary | |
2416 //v77 = (int)v71; | |
2417 //v76 = v71->uNumVertices; | |
2418 //goto LABEL_161; | |
186 | 2419 pRenderer->DrawTerrainPolygon(v76, (stru148 *)v71, v78, v79, v80); |
86 | 2420 goto LABEL_162; |
2421 } | |
2422 v38 = (stru148 *)v71; | |
2423 goto LABEL_56; | |
2424 } | |
2425 v73 = sr_424EE0_MakeFanFromTriangle(v72); | |
2426 } | |
2427 v71->uNumVertices = v73; | |
2428 OutdoorCamera::Project(v73); | |
0 | 2429 goto LABEL_154; |
86 | 2430 } |
2431 } | |
0 | 2432 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); |
2433 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); | |
2434 // 4D864C: using guessed type char byte_4D864C; | |
2435 // 76D5C0: using guessed type char static_sub_0048034E_byte_76D5C0__init_flag; | |
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; | |
638 | 2557 v95 = (double)pOutdoor->vSunlight.x / 65536.0; |
2558 v96 = (double)pOutdoor->vSunlight.y / 65536.0; | |
2559 v97 = (double)pOutdoor->vSunlight.z / 65536.0; | |
0 | 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; | |
638 | 2612 v17->terrain_grid_x = LOBYTE(v20); |
0 | 2613 v17->field_34 = v21->distance; |
2614 v22 = v94; | |
638 | 2615 v17->terrain_grid_z = v94; |
0 | 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); | |
638 | 2630 v17->dimming_level = 31 - LOBYTE(v76); |
0 | 2631 } |
2632 else | |
2633 { | |
638 | 2634 v17->dimming_level = 0; |
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); | |
168 | 2643 array_50AC10[0]._rhw = v26; |
0 | 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])); | |
168 | 2648 array_50AC10[1]._rhw = 1.0 / v27; |
0 | 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])); | |
168 | 2653 array_50AC10[2]._rhw = 1.0 / v28; |
0 | 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])); | |
168 | 2658 array_50AC10[3]._rhw = 1.0 / v29; |
0 | 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; | |
638 | 2729 v38->terrain_grid_x = LOBYTE(v41); |
0 | 2730 v38->field_34 = v42->distance; |
2731 v43 = v94; | |
638 | 2732 v38->terrain_grid_z = v94; |
0 | 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); | |
638 | 2749 v38->dimming_level = 31 - LOBYTE(v74); |
0 | 2750 } |
2751 else | |
2752 { | |
638 | 2753 v38->dimming_level = 0; |
2754 } | |
2755 if ( v38->dimming_level < 0 ) | |
2756 v38->dimming_level = 0; | |
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); | |
168 | 2764 array_50AC10[0]._rhw = v48; |
0 | 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])); | |
168 | 2769 array_50AC10[1]._rhw = 1.0 / v49; |
0 | 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])); | |
168 | 2774 array_50AC10[2]._rhw = 1.0 / v50; |
0 | 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; | |
638 | 2818 v17->terrain_grid_z = v94; |
2819 v17->terrain_grid_x = LOBYTE(v99); | |
0 | 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); | |
638 | 2839 v17->dimming_level = 31 - LOBYTE(v72); |
0 | 2840 } |
2841 else | |
2842 { | |
638 | 2843 v17->dimming_level = 0; |
0 | 2844 } |
638 | 2845 if ( v17->dimming_level < 0 ) |
2846 v17->dimming_level = 0; | |
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); | |
168 | 2858 array_50AC10[0]._rhw = v62; |
0 | 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])); | |
168 | 2863 array_50AC10[1]._rhw = 1.0 / v63; |
0 | 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])); | |
168 | 2868 array_50AC10[2]._rhw = 1.0 / v64; |
0 | 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 //----- (0047BACF) -------------------------------------------------------- | |
2936 void Render::TransformBillboardsAndSetPalettesODM() | |
2937 { | |
142 | 2938 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2939 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2940 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2941 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2942 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2943 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2944 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2945 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2946 //int v8; // ebx@4 |
0 | 2947 unsigned __int16 *v9; // eax@7 |
2948 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2949 //DWORD v11; // eax@13 |
0 | 2950 int v12; // eax@13 |
2951 int v13; // eax@14 | |
2952 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
2953 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 2954 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2955 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 2956 int v18; // [sp+60h] [bp-4h]@13 |
2957 | |
2958 billboard.uParentBillboardID = -1; | |
2959 billboard.pTarget = pRenderer->pTargetSurface; | |
2960 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
2961 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 2962 billboard.uViewportX = pViewport->uViewportTL_X; |
2963 billboard.uViewportY = pViewport->uViewportTL_Y; | |
2964 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
2965 billboard.uViewportW = pViewport->uViewportBR_Y; | |
0 | 2966 pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw; |
142 | 2967 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2968 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 2969 { |
143 | 2970 auto pBillboard = pBillboardRenderList + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2971 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2972 billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2973 billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2974 billboard.uParentBillboardID = i; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2975 billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2976 billboard.uTintColor = pBillboard->uTintColor; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2977 billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2978 billboard.sZValue = pBillboard->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2979 billboard.uFlags = pBillboard->field_1E; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2980 if (pBillboard->uHwSpriteID != -1) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2981 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2982 if (pRenderer->pRenderD3D) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2983 pRenderer->TransformBillboard(&billboard, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2984 &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], |
657 | 2985 pBillboard->dimming_level, pBillboard); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2986 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2987 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2988 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2989 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2990 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 2991 if ( *(v1 - 10) & 2 ) |
2992 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
2993 else | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2994 v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 2995 v10 = (*(v1 - 9) & 1) == 0; |
2996 billboard.pPalette = v9; | |
2997 if ( !v10 ) | |
2998 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
2999 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
3000 { | |
323 | 3001 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 3002 v15 = abs(v12); |
3003 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
3004 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
3005 } | |
3006 v13 = *((short *)v1 - 8); | |
3007 if ( v13 >= 0 ) | |
733 | 3008 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3009 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3010 } |
0 | 3011 } |
3012 } | |
3013 | |
3014 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3015 void Render::DrawSpriteObjects_ODM() |
0 | 3016 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3017 //char *v0; // edi@2 |
430 | 3018 //ObjectDesc *v1; // ebx@4 |
0 | 3019 __int16 v2; // cx@5 |
3020 RenderBillboard *v3; // esi@10 | |
3021 SpriteFrame *v4; // eax@10 | |
430 | 3022 //SpriteFrame *v5; // ebx@10 |
0 | 3023 unsigned int v6; // eax@10 |
430 | 3024 //int v7; // ecx@10 |
3025 //int v8; // edx@10 | |
0 | 3026 int v9; // ecx@10 |
3027 unsigned __int16 v10; // ax@10 | |
430 | 3028 //int *v11; // eax@14 |
0 | 3029 int v12; // eax@22 |
3030 int v13; // ST3C_4@23 | |
3031 int v14; // eax@23 | |
3032 int v15; // ecx@23 | |
3033 int v16; // ebx@23 | |
3034 int v17; // ecx@25 | |
3035 int v18; // eax@25 | |
3036 int v19; // ST40_4@26 | |
3037 int v20; // ecx@26 | |
3038 int v21; // ST44_4@28 | |
3039 int v22; // ST3C_4@29 | |
3040 signed __int64 v23; // qtt@30 | |
3041 int v24; // ebx@30 | |
3042 int v25; // ST3C_4@30 | |
3043 int v26; // eax@31 | |
3044 char v27; // zf@31 | |
430 | 3045 //SpriteFrame *v28; // [sp+Ch] [bp-34h]@10 |
3046 //__int16 a5; // [sp+10h] [bp-30h]@10 | |
0 | 3047 int v30; // [sp+14h] [bp-2Ch]@23 |
3048 int v31; // [sp+14h] [bp-2Ch]@29 | |
3049 __int16 v32; // [sp+14h] [bp-2Ch]@30 | |
3050 int v33; // [sp+18h] [bp-28h]@23 | |
3051 int v34; // [sp+18h] [bp-28h]@26 | |
3052 int v35; // [sp+18h] [bp-28h]@30 | |
3053 int v36; // [sp+1Ch] [bp-24h]@10 | |
3054 int v37; // [sp+1Ch] [bp-24h]@23 | |
3055 int a6; // [sp+20h] [bp-20h]@10 | |
3056 int a6a; // [sp+20h] [bp-20h]@23 | |
3057 int v40; // [sp+24h] [bp-1Ch]@25 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3058 //signed int v41; // [sp+28h] [bp-18h]@1 |
0 | 3059 int v42; // [sp+2Ch] [bp-14h]@23 |
3060 int y; // [sp+30h] [bp-10h]@10 | |
3061 int x; // [sp+34h] [bp-Ch]@10 | |
3062 int z; // [sp+38h] [bp-8h]@10 | |
3063 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
3064 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3065 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3066 for (int i = 0; i < uNumSpriteObjects; ++i) |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3067 { |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3068 auto object = pSpriteObjects + i; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3069 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3070 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3071 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3072 //{ |
430 | 3073 if (!object->uObjectDescID) // item probably pciked up |
3074 continue; | |
3075 | |
3076 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
3077 auto object_desc = pObjectList->pObjects + object->uObjectDescID; | |
3078 if (object_desc->NoSprite()) | |
3079 continue; | |
3080 | |
3081 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
3082 //if ( !(v1->uFlags & 1) ) | |
3083 //{ | |
3084 //v2 = *((short *)v0 - 14) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3085 v2 = object->uType; |
430 | 3086 if ( (v2 < 1000 || v2 >= 10000) && (v2 < 500 || v2 >= 600) || pGame->pStru6Instance->_4A81CA(object) ) |
3087 { | |
3088 //a5 = *(short *)v0; | |
3089 x = object->vPosition.x; | |
3090 y = object->vPosition.y; | |
3091 z = object->vPosition.z; | |
3092 v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; | |
3093 v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); | |
3094 //v5 = v4; | |
3095 //v28 = v4; | |
3096 v36 = v4->uFlags; | |
3097 a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier; | |
3098 v6 = stru_5C6E00->Atan2(object->vPosition.x - pIndoorCamera->pos.x, object->vPosition.y - pIndoorCamera->pos.y); | |
3099 //LOWORD(v7) = object->uFacing; | |
3100 //v8 = v36; | |
3101 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; | |
3102 v10 = v4->pHwSpriteIDs[v9]; | |
0 | 3103 v3->uHwSpriteID = v10; |
3104 if ( v36 & 0x20 ) | |
3105 { | |
430 | 3106 //v8 = v36; |
3107 z -= (signed int)((unsigned __int64)(v4->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
0 | 3108 } |
3109 v46 = 0; | |
430 | 3110 if ( v36 & 2 ) |
0 | 3111 v46 = 2; |
430 | 3112 //v11 = (int *)(256 << v9); |
3113 if ( (256 << v9) & v36 ) | |
0 | 3114 v46 |= 4u; |
430 | 3115 if ( v36 & 0x40000 ) |
0 | 3116 v46 |= 0x40u; |
430 | 3117 if ( v36 & 0x20000 ) |
0 | 3118 LOBYTE(v46) = v46 | 0x80; |
3119 if ( a6 ) | |
3120 { | |
430 | 3121 //LOBYTE(v11) = byte_4E94D3; |
3122 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); | |
0 | 3123 } |
3124 v12 = (x - pIndoorCamera->pos.x) << 16; | |
3125 if ( pIndoorCamera->sRotationX ) | |
3126 { | |
3127 v13 = (y - pIndoorCamera->pos.y) << 16; | |
3128 v30 = ((unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | |
3129 + ((unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3130 v37 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3131 a6a = (unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3132 v33 = (z - pIndoorCamera->pos.z) << 16; | |
3133 v14 = (unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3134 v15 = (unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3135 v16 = v15 + v14; | |
3136 v42 = v15 + v14; | |
3137 if ( v15 + v14 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3138 { | |
3139 v17 = a6a - v37; | |
3140 v40 = a6a - v37; | |
3141 v18 = ((unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) | |
3142 - ((unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3143 goto LABEL_29; | |
3144 } | |
3145 } | |
3146 else | |
3147 { | |
3148 v34 = (y - pIndoorCamera->pos.y) << 16; | |
3149 v19 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3150 v20 = (unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3151 v16 = v20 + v19; | |
3152 v42 = v20 + v19; | |
3153 if ( v20 + v19 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3154 { | |
430 | 3155 v21 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; |
3156 v17 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
3157 v40 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
0 | 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); | |
430 | 3170 v35 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); |
3171 v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); | |
3172 | |
3173 //if (::uNumBillboardsToDraw >= 500) | |
3174 // return; | |
3175 assert(::uNumBillboardsToDraw < 500); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3176 ++::uNumBillboardsToDraw; |
0 | 3177 ++uNumSpritesDrawnThisFrame; |
430 | 3178 |
3179 object->uAttributes |= 1; | |
3180 v3->uPalette = v4->uPaletteIndex; | |
3181 v3->uIndoorSectorID = object->uSectorID; | |
3182 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
3183 v26 = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
3184 v3->pSpriteFrame = v4; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3185 v3->_screenspace_y_scaler_packedfloat = v26; |
0 | 3186 v3->field_1E = v46; |
430 | 3187 v3->world_x = x; |
3188 v3->world_y = y; | |
3189 v3->world_z = z; | |
0 | 3190 v3->uScreenSpaceX = v35; |
3191 v3->uScreenSpaceY = v32; | |
3192 HIWORD(v26) = HIWORD(v42); | |
3193 LOWORD(v26) = 0; | |
430 | 3194 v27 = (object->uAttributes & 0x20) == 0; |
862 | 3195 v3->sZValue = v26 + (PID(OBJECT_Item,i)); |
657 | 3196 v3->dimming_level = 0; |
0 | 3197 v3->uTintColor = 0; |
3198 if ( !v27 ) | |
3199 { | |
3200 if ( !pRenderer->pRenderD3D ) | |
3201 v3->sZValue = 0; | |
3202 } | |
3203 } | |
3204 goto LABEL_34; | |
3205 } | |
3206 } | |
3207 } | |
430 | 3208 //} |
0 | 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 //} |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3214 //while ( v41 < (signed int)uNumSpriteObjects ); |
0 | 3215 } |
3216 } | |
3217 // 4E94D3: using guessed type char byte_4E94D3; | |
3218 // 5187E4: using guessed type int uNumSpritesDrawnThisFrame; | |
3219 | |
3220 //----- (0049D9BC) -------------------------------------------------------- | |
3221 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
3222 { | |
3223 size_t v4; // eax@1 | |
3224 size_t v5; // eax@1 | |
3225 IUnknown *v6; // eax@10 | |
3226 size_t v7; // eax@13 | |
3227 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
3228 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
3229 int v11; // [sp+430h] [bp-CCh]@16 | |
3230 int v12; // [sp+434h] [bp-C8h]@16 | |
3231 int v13; // [sp+438h] [bp-C4h]@16 | |
3232 int v14; // [sp+474h] [bp-88h]@16*/ | |
3233 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
3234 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
3235 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
3236 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
3237 int v19; // [sp+4C8h] [bp-34h]@16 | |
3238 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
3239 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
3240 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
3241 | |
3242 v4 = strlen(lpDriverName); | |
3243 v20.pDriverName = new char[v4 + 1]; | |
3244 v5 = strlen(lpDevDesc); | |
3245 v20.pDeviceDesc = new char[v5 + 1]; | |
3246 strcpy(v20.pDriverName, lpDriverName); | |
3247 strcpy(v20.pDeviceDesc, lpDevDesc); | |
3248 if ( lpGUID ) | |
3249 { | |
3250 v20.pGUID = new GUID; | |
3251 memcpy(v20.pGUID, lpGUID, 0x10u); | |
3252 } | |
3253 else | |
3254 { | |
3255 v20.pGUID = 0; | |
3256 } | |
3257 | |
3258 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
3259 { | |
3260 delete [] v20.pDriverName; | |
3261 delete [] v20.pDeviceDesc; | |
3262 if ( v20.pGUID ) | |
3263 delete v20.pGUID; | |
3264 } | |
3265 else | |
3266 { | |
3267 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
3268 { | |
3269 delete [] v20.pDriverName; | |
3270 delete [] v20.pDeviceDesc; | |
3271 if ( v20.pGUID ) | |
3272 delete v20.pGUID; | |
3273 v6 = (IUnknown *)pDirectDraw; | |
3274 } | |
3275 else | |
3276 { | |
3277 pDirectDraw->Release(); | |
3278 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1u))) | |
3279 { | |
3280 v20.pDDraw4DevDesc = 0; | |
3281 } | |
3282 else | |
3283 { | |
3284 v7 = strlen(ddDevId.szDescription); | |
3285 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
3286 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
3287 } | |
3288 memset(&ddsCaps, 0, 0x10u); | |
3289 if (FAILED(pDirectDraw4->GetAvailableVidMem( | |
3290 &ddsCaps, | |
3291 (LPDWORD)&v20.uVideoMem, | |
3292 (LPDWORD)&uFreeVideoMem))) | |
3293 v20.uVideoMem = 0; | |
3294 memset(&v10, 0, 0x7Cu); | |
3295 v10.dwSize = 124; | |
3296 v10.dwFlags = 6; | |
3297 v10.dwHeight = 640; | |
3298 v10.dwWidth = 480; | |
3299 v10.ddpfPixelFormat.dwSize = 32; | |
3300 | |
3301 v19 = 0; | |
3302 if ( FAILED(pDirectDraw4->EnumDisplayModes( | |
3303 0, | |
3304 0, | |
3305 &v19, | |
3306 (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) | |
3307 || !v19 | |
3308 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
3309 { | |
3310 delete [] v20.pDriverName; | |
3311 delete [] v20.pDeviceDesc; | |
3312 if ( v20.pDDraw4DevDesc ) | |
3313 free(v20.pDDraw4DevDesc); | |
3314 if ( v20.pGUID ) | |
3315 delete v20.pGUID; | |
3316 v6 = (IUnknown *)pDirectDraw4; | |
3317 } | |
3318 else | |
3319 { | |
3320 aux.pInfo = pOut; | |
3321 aux.ptr_4 = &v20; | |
3322 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
3323 delete [] v20.pDriverName; | |
3324 delete [] v20.pDeviceDesc; | |
3325 if ( v20.pDDraw4DevDesc ) | |
3326 free(v20.pDDraw4DevDesc); | |
3327 if ( v20.pGUID ) | |
3328 delete v20.pGUID; | |
3329 pDirectDraw4->Release(); | |
3330 v6 = (IUnknown *)pDirect3D3; | |
3331 pDirectDraw4 = 0; | |
3332 } | |
3333 } | |
3334 v6->Release(); | |
3335 } | |
3336 return 1; | |
3337 } | |
3338 | |
3339 //----- (0049D784) -------------------------------------------------------- | |
3340 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
3341 { | |
3342 int v6; // eax@1 | |
3343 signed int v7; // edi@1 | |
3344 signed int v8; // edi@14 | |
3345 size_t v9; // eax@30 | |
3346 size_t v10; // eax@30 | |
3347 size_t v11; // eax@30 | |
3348 size_t v12; // eax@30 | |
3349 size_t v13; // eax@30 | |
3350 | |
3351 v6 = pHWDesc->dwFlags; | |
3352 v7 = -1; | |
3353 if ( v6 ) | |
3354 { | |
3355 if ( !a6->ptr_4->pGUID ) | |
3356 v7 = 0; | |
3357 if ( v6 && a6->ptr_4->pGUID ) | |
3358 v7 = 1; | |
3359 } | |
3360 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
3361 v7 = 2; | |
3362 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
3363 v7 = 3; | |
3364 if ( v7 != -1 ) | |
3365 { | |
3366 v8 = v7; | |
3367 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
3368 a6->pInfo[v8].uCaps = 0; | |
3369 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
3370 a6->pInfo[v8].uCaps |= 2u; | |
3371 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
3372 a6->pInfo[v8].uCaps |= 4u; | |
3373 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
3374 a6->pInfo[v8].uCaps |= 8u; | |
3375 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
3376 a6->pInfo[v8].uCaps |= 0x10u; | |
3377 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
3378 a6->pInfo[v8].uCaps |= 0x20u; | |
3379 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
3380 a6->pInfo[v8].uCaps |= 0x40u; | |
3381 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
3382 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
3383 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
3384 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
3385 v9 = strlen(lpDeviceName); | |
3386 a6->pInfo[v8].pName = new char[v9 + 1]; | |
3387 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
3388 v10 = strlen(lpDeviceDesc); | |
3389 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
3390 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
3391 a6->pInfo[v8].pGUID = (GUID *)operator new(0x10u); | |
3392 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); | |
3393 v11 = strlen(a6->ptr_4->pDriverName); | |
3394 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
3395 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
3396 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
3397 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
3398 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
3399 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
3400 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
3401 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
3402 if ( a6->ptr_4->pGUID ) | |
3403 { | |
3404 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
3405 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
3406 } | |
3407 else | |
3408 { | |
3409 a6->pInfo[v8].pDirectDrawGUID = 0; | |
3410 } | |
3411 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
3412 } | |
3413 return 1; | |
3414 } | |
3415 | |
3416 //----- (0049D75C) -------------------------------------------------------- | |
3417 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
3418 { | |
3419 HRESULT result; // eax@3 | |
3420 | |
3421 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
3422 { | |
3423 *a2 = 1; | |
3424 result = 0; | |
3425 } | |
3426 else | |
3427 { | |
3428 result = 1; | |
3429 } | |
3430 return result; | |
3431 } | |
3432 | |
3433 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3434 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3435 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3436 //char *v0; // esi@2 |
639 | 3437 //DecorationDesc *v1; // ebx@6 |
0 | 3438 __int16 v2; // ax@6 |
3439 double v3; // st7@7 | |
639 | 3440 //int v4; // eax@9 |
3441 //int v5; // edx@9 | |
0 | 3442 unsigned int v6; // edi@9 |
3443 int v7; // eax@9 | |
3444 SpriteFrame *v8; // eax@9 | |
635 | 3445 //SpriteFrame *v9; // edi@9 |
0 | 3446 unsigned __int16 *v10; // eax@9 |
3447 int v11; // ecx@9 | |
3448 int v12; // eax@9 | |
3449 int v13; // ecx@9 | |
3450 int v14; // ecx@20 | |
3451 char v15; // dl@20 | |
3452 signed int v16; // eax@20 | |
3453 int v17; // eax@23 | |
3454 int v18; // ecx@24 | |
3455 int v19; // eax@24 | |
3456 int v20; // ecx@24 | |
3457 int v21; // ebx@26 | |
3458 int v22; // eax@26 | |
3459 int v23; // eax@30 | |
3460 signed __int64 v24; // qtt@31 | |
3461 int v25; // ebx@31 | |
3462 int v26; // ecx@32 | |
3463 RenderBillboard *v27; // eax@37 | |
3464 __int16 v28; // dx@37 | |
3465 __int16 v29; // cx@37 | |
3466 int v30; // ecx@37 | |
3467 int v31; // ebx@37 | |
619 | 3468 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
639 | 3469 //int x; // [sp+74h] [bp-30h]@9 |
3470 //int y; // [sp+78h] [bp-2Ch]@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3471 //int v35; // [sp+7Ch] [bp-28h]@1 |
639 | 3472 //int v36; // [sp+80h] [bp-24h]@9 |
0 | 3473 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
3474 int v38; // [sp+88h] [bp-1Ch]@9 | |
3475 int v39; // [sp+8Ch] [bp-18h]@24 | |
3476 int v40; // [sp+90h] [bp-14h]@24 | |
3477 int v41; // [sp+94h] [bp-10h]@24 | |
3478 int v42; // [sp+98h] [bp-Ch]@9 | |
3479 int a5; // [sp+9Ch] [bp-8h]@9 | |
3480 int b; // [sp+A0h] [bp-4h]@22 | |
3481 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3482 //v35 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3483 //if ( (signed int)uNumLevelDecorations > 0 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3484 //{ |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3485 //v0 = (char *)&pLevelDecorations[0].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3486 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3487 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3488 { |
635 | 3489 auto decor = pLevelDecorations + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3490 auto v0 = (char *)&pLevelDecorations[i].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3491 |
639 | 3492 if ( (!(decor->field_2 & 0x40) || decor->_47A825()) && !(decor->field_2 & 0x20) ) |
3493 { | |
3494 //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID]; | |
3495 auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; | |
3496 v2 = decor_desc->uFlags; | |
0 | 3497 if ( (char)v2 >= 0 ) |
3498 { | |
3499 if ( !(v2 & 0x22) ) | |
3500 { | |
639 | 3501 //v4 = decor->vPosition.x; |
3502 //v5 = decor->vPosition.z; | |
0 | 3503 v6 = pMiscTimer->uTotalGameTimeElapsed; |
639 | 3504 //y = decor->vPosition.y; |
3505 //x = decor->vPosition.x; | |
3506 //v36 = decor->vPosition.z; | |
3507 v7 = abs(decor->vPosition.x + decor->vPosition.y); | |
635 | 3508 |
3509 | |
3510 #pragma region "New: seasons change" | |
3511 extern bool change_seasons; | |
3512 if (change_seasons) | |
3513 switch (pParty->uCurrentMonth) | |
3514 { | |
3515 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
3516 case 11: case 0: case 1: // winter | |
639 | 3517 switch (decor_desc->uSpriteID) |
635 | 3518 { |
3519 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
3520 case 548: // flower10 | |
3521 case 547: // flower09 | |
3522 case 541: // flower03 | |
3523 case 539: continue; // flower01 | |
3524 | |
3525 case 483: // tree01 | |
3526 case 486: // tree04 | |
3527 case 492: // tree10 | |
639 | 3528 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); |
3529 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
635 | 3530 break; |
3531 | |
3532 default: | |
639 | 3533 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3534 } |
3535 break; | |
3536 | |
3537 case 2: case 3: case 4: // spring | |
639 | 3538 switch (decor_desc->uSpriteID) |
635 | 3539 { |
3540 } | |
639 | 3541 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3542 break; |
3543 | |
3544 case 8: case 9: case 10: // autumn | |
639 | 3545 switch (decor_desc->uSpriteID) |
635 | 3546 { |
3547 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
3548 case 548: // flower10 | |
3549 case 547: // flower09 | |
3550 case 541: // flower03 | |
3551 case 539: continue; // flower01 | |
3552 | |
3553 case 483: // tree01 | |
3554 case 486: // tree04 | |
3555 case 492: // tree10 | |
639 | 3556 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); |
3557 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
635 | 3558 break; |
3559 | |
3560 default: | |
639 | 3561 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3562 } |
3563 break; | |
3564 | |
3565 case 5: case 6: case 7: // summer | |
3566 //all green by default | |
639 | 3567 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3568 break; |
3569 | |
3570 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
3571 } | |
637 | 3572 else |
639 | 3573 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3574 #pragma endregion |
639 | 3575 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3576 |
3577 //v9 = v8; | |
0 | 3578 v42 = v8->uFlags; |
3579 a5 = v8->uGlowRadius; | |
639 | 3580 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pIndoorCamera->pos.x, |
3581 decor->vPosition.y - pIndoorCamera->pos.y); | |
0 | 3582 v11 = *((int *)v0 + 2); |
3583 v37 = v10; | |
3584 v12 = v42; | |
3585 v38 = 0; | |
3586 v13 = ((signed int)(stru_5C6E00->uIntegerPi | |
3587 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
3588 + v11 | |
3589 - (signed int)v37) >> 8) & 7; | |
3590 v37 = (unsigned __int16 *)v13; | |
3591 if ( v42 & 2 ) | |
3592 v38 = 2; | |
3593 if ( (256 << v13) & v42 ) | |
3594 v38 |= 4u; | |
3595 if ( v12 & 0x40000 ) | |
3596 v38 |= 0x40u; | |
3597 if ( v12 & 0x20000 ) | |
3598 LOBYTE(v38) = v38 | 0x80; | |
3599 if ( a5 ) | |
3600 { | |
3601 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) | |
3602 { | |
639 | 3603 v14 = decor_desc->uColoredLightRed; |
3604 v15 = decor_desc->uColoredLightGreen; | |
3605 v16 = decor_desc->uColoredLightBlue; | |
0 | 3606 } |
3607 else | |
3608 { | |
3609 v16 = 255; | |
3610 v14 = 255; | |
3611 v15 = 255; | |
3612 } | |
3613 b = v16; | |
3614 pStationaryLightsStack->AddLight( | |
639 | 3615 decor->vPosition.x, |
3616 decor->vPosition.y, | |
3617 decor->vPosition.z + decor_desc->uDecorationHeight / 2, | |
0 | 3618 a5, |
3619 v14, | |
3620 v15, | |
3621 v16, | |
3622 byte_4E94D0); | |
3623 } | |
639 | 3624 v17 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
0 | 3625 if ( pIndoorCamera->sRotationX ) |
3626 { | |
639 | 3627 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; |
0 | 3628 v18 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) |
3629 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3630 v42 = v18; | |
3631 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3632 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
639 | 3633 v40 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 3634 v41 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; |
3635 v19 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3636 v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3637 v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3638 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3639 { | |
3640 v21 = a5 - b; | |
3641 v41 = a5 - b; | |
3642 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3643 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3644 v22 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) - a5; | |
3645 LABEL_30: | |
3646 v42 = v22; | |
3647 v40 = 2 * abs(v20); | |
3648 v23 = abs(v21); | |
3649 if ( v40 >= v23 ) | |
3650 { | |
3651 LODWORD(v24) = 0; | |
3652 HIDWORD(v24) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3653 a5 = v24 / v39; | |
3654 v25 = pViewport->uScreenCenterX | |
3655 - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); | |
3656 b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; | |
3657 v41 = v24 / v39; | |
3658 v40 = pViewport->uScreenCenterY | |
3659 - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); | |
635 | 3660 v42 = v8->scale; |
0 | 3661 v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; |
635 | 3662 v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37]; |
0 | 3663 if ( pRenderer->pRenderD3D ) |
3664 { | |
3665 v26 = v41; | |
3666 v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; | |
3667 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
3668 } | |
3669 else | |
3670 { | |
3671 v26 = v41; | |
3672 v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; | |
3673 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
3674 } | |
693 | 3675 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
0 | 3676 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3677 if (::uNumBillboardsToDraw >= 500) |
0 | 3678 return; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3679 v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; |
0 | 3680 ++uNumDecorationsDrawnThisFrame; |
3681 v27->uHwSpriteID = *v37; | |
635 | 3682 v28 = v8->uPaletteIndex; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3683 v27->_screenspace_x_scaler_packedfloat = v26; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3684 v27->_screenspace_y_scaler_packedfloat = v26; |
0 | 3685 v29 = v38; |
3686 v27->uScreenSpaceX = v25; | |
3687 HIBYTE(v29) |= 2u; | |
3688 v27->uPalette = v28; | |
3689 v27->field_1E = v29; | |
639 | 3690 v27->world_x = decor->vPosition.x; |
3691 v27->world_y = decor->vPosition.y; | |
3692 v27->world_z = decor->vPosition.z; | |
0 | 3693 v27->uScreenSpaceY = v40; |
3694 HIWORD(v30) = HIWORD(v39); | |
862 | 3695 v31 = PID(OBJECT_Decoration,i); |
0 | 3696 LOWORD(v30) = 0; |
3697 v27->uIndoorSectorID = 0; | |
3698 v27->sZValue = v30 + v31; | |
657 | 3699 v27->dimming_level = 0; |
635 | 3700 v27->pSpriteFrame = v8; |
0 | 3701 v27->uTintColor = 0; |
3702 } | |
3703 } | |
3704 goto LABEL_38; | |
3705 } | |
3706 } | |
3707 else | |
3708 { | |
639 | 3709 v42 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
3710 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; | |
0 | 3711 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; |
3712 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3713 v20 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3714 v39 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3715 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3716 { | |
3717 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3718 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3719 v21 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
3720 v41 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
639 | 3721 v22 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 3722 goto LABEL_30; |
3723 } | |
3724 } | |
3725 } | |
3726 } | |
3727 else | |
3728 { | |
3729 memset(&local_0, 0, 0x68u); | |
3730 v3 = (double)*((signed int *)v0 - 1); | |
619 | 3731 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; |
3732 local_0.uDiffuse = 0xFF3C1E; | |
0 | 3733 local_0.x = v3; |
3734 local_0.y = (double)*(signed int *)v0; | |
3735 local_0.z = (double)*((signed int *)v0 + 1); | |
3736 local_0.flt_10 = 0.0; | |
3737 local_0.flt_14 = 0.0; | |
3738 local_0.flt_18 = 0.0; | |
3739 local_0.flt_28 = 1.0; | |
3740 local_0.timeToLive = (rand() & 0x80) + 128; | |
3741 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
3742 pGame->pParticleEngine->AddParticle(&local_0); | |
3743 } | |
3744 } | |
3745 LABEL_38: | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3746 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3747 //++v35; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3748 //v0 += 32; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3749 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3750 //while ( v35 < (signed int)uNumLevelDecorations ); |
0 | 3751 } |
3752 // 4E94D0: using guessed type char byte_4E94D0; | |
3753 // 5187EC: using guessed type int uNumDecorationsDrawnThisFrame; | |
3754 | |
3755 //----- (0049D717) -------------------------------------------------------- | |
3756 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
3757 { | |
3758 HRESULT v2; // esi@2 | |
3759 | |
3760 if ( Src->dwFlags & 0x400 | 0x2000 ) | |
3761 { | |
3762 v2 = 0; | |
3763 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
3764 goto LABEL_6; | |
3765 if ( !Dst->dwSize ) | |
3766 { | |
3767 v2 = 1; | |
3768 LABEL_6: | |
3769 memcpy(Dst, Src, 0x20u); | |
3770 return v2; | |
3771 } | |
3772 } | |
3773 return 1; | |
3774 } | |
3775 | |
3776 //----- (0049DC28) -------------------------------------------------------- | |
3777 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
3778 { | |
3779 RenderD3D__DevInfo *v2; // eax@1 | |
3780 | |
3781 v2 = new RenderD3D__DevInfo[4];// 4 items | |
3782 *pOutDevices = v2; | |
3783 memset(v2, 0, 0xA0u); | |
3784 DirectDrawEnumerateA((LPDDENUMCALLBACKA)RenderD3D__DeviceEnumerator, *pOutDevices); | |
3785 } | |
3786 | |
3787 //----- (0049DC58) -------------------------------------------------------- | |
3788 RenderD3D::RenderD3D() | |
3789 { | |
3790 RenderD3D *v1; // esi@1 | |
3791 | |
3792 v1 = this; | |
3793 this->pHost = 0; | |
3794 this->pDirect3D = 0; | |
3795 this->pUnk = 0; | |
3796 this->pBackBuffer = 0; | |
3797 this->pFrontBuffer = 0; | |
3798 this->pZBuffer = 0; | |
3799 this->pDevice = 0; | |
3800 this->pViewport = 0; | |
3801 this->field_40 = 1; | |
3802 this->field_44 = 10; | |
3803 GetAvailableDevices(&this->pAvailableDevices); | |
3804 } | |
3805 | |
3806 //----- (0049DC90) -------------------------------------------------------- | |
3807 void RenderD3D::Release() | |
3808 { | |
3809 RenderD3D *v1; // esi@1 | |
3810 IDirectDraw4 *v2; // eax@2 | |
3811 signed int v3; // edi@4 | |
3812 IDirect3DViewport3 *v4; // eax@22 | |
3813 IUnknown *v5; // eax@24 | |
3814 IDirectDrawSurface4 *v6; // eax@26 | |
3815 IDirect3DDevice3 *v7; // eax@28 | |
3816 IDirect3D3 *v8; // eax@30 | |
3817 IDirectDrawSurface4 *v9; // eax@32 | |
3818 IDirectDrawSurface4 *v10; // eax@34 | |
3819 IDirectDraw4 *v11; // eax@36 | |
3820 | |
3821 v1 = this; | |
3822 if ( !this->bWindowed ) | |
3823 { | |
3824 v2 = this->pHost; | |
3825 if ( v2 ) | |
3826 { | |
3827 v2->RestoreDisplayMode(); | |
3828 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
3829 v1->pHost->FlipToGDISurface(); | |
3830 } | |
3831 } | |
3832 v3 = 0; | |
3833 do | |
3834 { | |
3835 if ( v1->pAvailableDevices[v3].pDriverName ) | |
3836 { | |
3837 free(v1->pAvailableDevices[v3].pDriverName); | |
3838 v1->pAvailableDevices[v3].pDriverName = 0; | |
3839 } | |
3840 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
3841 { | |
3842 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
3843 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
3844 } | |
3845 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
3846 { | |
3847 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
3848 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
3849 } | |
3850 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
3851 { | |
3852 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
3853 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
3854 } | |
3855 if ( v1->pAvailableDevices[v3].pName ) | |
3856 { | |
3857 free(v1->pAvailableDevices[v3].pName); | |
3858 v1->pAvailableDevices[v3].pName = 0; | |
3859 } | |
3860 if ( v1->pAvailableDevices[v3].pDescription ) | |
3861 { | |
3862 free(v1->pAvailableDevices[v3].pDescription); | |
3863 v1->pAvailableDevices[v3].pDescription = 0; | |
3864 } | |
3865 if ( v1->pAvailableDevices[v3].pGUID ) | |
3866 { | |
3867 free(v1->pAvailableDevices[v3].pGUID); | |
3868 v1->pAvailableDevices[v3].pGUID = 0; | |
3869 } | |
3870 ++v3; | |
3871 } | |
3872 while ( v3 < 4 ); | |
3873 if ( v1->pAvailableDevices ) | |
3874 { | |
3875 free(v1->pAvailableDevices); | |
3876 v1->pAvailableDevices = 0; | |
3877 } | |
3878 v4 = v1->pViewport; | |
3879 if ( v4 ) | |
3880 { | |
3881 v4->Release(); | |
3882 v1->pViewport = 0; | |
3883 } | |
3884 v5 = v1->pUnk; | |
3885 if ( v5 ) | |
3886 { | |
3887 v5->Release(); | |
3888 v1->pUnk = 0; | |
3889 } | |
3890 v6 = v1->pZBuffer; | |
3891 if ( v6 ) | |
3892 { | |
3893 v6->Release(); | |
3894 v1->pZBuffer = 0; | |
3895 } | |
3896 v7 = v1->pDevice; | |
3897 if ( v7 ) | |
3898 { | |
3899 v7->Release(); | |
3900 v1->pDevice = 0; | |
3901 } | |
3902 v8 = v1->pDirect3D; | |
3903 if ( v8 ) | |
3904 { | |
3905 v8->Release(); | |
3906 v1->pDirect3D = 0; | |
3907 } | |
3908 v9 = v1->pBackBuffer; | |
3909 if ( v9 ) | |
3910 { | |
3911 v9->Release(); | |
3912 v1->pBackBuffer = 0; | |
3913 } | |
3914 v10 = v1->pFrontBuffer; | |
3915 if ( v10 ) | |
3916 { | |
3917 v10->Release(); | |
3918 v1->pFrontBuffer = 0; | |
3919 } | |
3920 v11 = v1->pHost; | |
3921 if ( v11 ) | |
3922 { | |
3923 v11->Release(); | |
3924 v1->pHost = 0; | |
3925 } | |
3926 } | |
3927 | |
3928 //----- (0049DE14) -------------------------------------------------------- | |
3929 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, HWND hWnd) | |
3930 { | |
3931 //IDirectDraw4 *v8; // eax@12 | |
3932 //IDirectDraw4 *v9; // eax@16 | |
3933 //IDirectDraw4 *v10; // eax@20 | |
3934 //IDirectDraw4 *v13; // eax@35 | |
3935 const char *v23; // [sp-4h] [bp-DCh]@9 | |
3936 const char *v24; // [sp-4h] [bp-DCh]@13 | |
3937 const char *v25; // [sp-4h] [bp-DCh]@19 | |
3938 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
3939 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
3940 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
3941 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
3942 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
3943 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
3944 | |
3945 this->bWindowed = bWindowed; | |
3946 this->hWindow = hWnd; | |
3947 | |
3948 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
3949 { | |
3950 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
3951 return 0; | |
3952 } | |
3953 | |
3954 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
3955 { | |
3956 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
3957 if (lpDD) | |
3958 lpDD->Release(); | |
3959 return 0; | |
3960 } | |
3961 lpDD->Release(); | |
3962 lpDD = 0; | |
3963 | |
3964 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
3965 { | |
3966 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
3967 { | |
3968 v23 = "Init - Failed to set cooperative level.\n"; | |
3969 sprintf(pErrorMessage, v23); | |
3970 LABEL_65: | |
3971 if (pHost) | |
3972 { | |
3973 pHost->Release(); | |
3974 pHost = 0; | |
3975 } | |
3976 return 0; | |
3977 } | |
3978 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
3979 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
3980 ddsd2.dwFlags = DDSD_CAPS; | |
3981 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
3982 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
3983 { | |
3984 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
3985 pHost->GetDisplayMode(&ddsd2); | |
3986 if ( ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) | |
3987 { | |
3988 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
3989 goto LABEL_14; | |
3990 } | |
3991 | |
3992 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
3993 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
3994 ddsd2.dwWidth = 640; | |
3995 ddsd2.dwHeight = 480; | |
3996 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) | |
3997 { | |
3998 v24 = "Init - Failed to create back buffer.\n"; | |
3999 LABEL_14: | |
4000 sprintf(pErrorMessage, v24); | |
4001 if (pFrontBuffer) | |
4002 { | |
4003 pFrontBuffer->Release(); | |
4004 pFrontBuffer = 0; | |
4005 } | |
4006 goto LABEL_65; | |
4007 } | |
4008 if ( pHost->CreateClipper(0, &v30, 0) ) | |
4009 { | |
4010 v25 = "Init - Failed to create clipper.\n"; | |
4011 goto LABEL_45; | |
4012 } | |
4013 v30->SetHWnd(0, hWnd); | |
4014 pFrontBuffer->SetClipper(v30); | |
4015 | |
4016 v30->Release(); | |
4017 v30 = 0; | |
4018 | |
4019 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
4020 | |
4021 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4022 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
4023 ddsd2.dwWidth = 640; | |
4024 ddsd2.dwHeight = 480; | |
4025 | |
4026 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
4027 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
4028 &ddsd2.ddpfPixelFormat) ) | |
4029 goto LABEL_21; | |
4030 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
4031 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
4032 | |
4033 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
4034 { | |
4035 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
4036 { | |
4037 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
4038 pBackBuffer, | |
4039 &pDevice, | |
4040 0) ) | |
4041 { | |
4042 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
4043 d3dvp2.dvClipWidth = 2.0; | |
4044 d3dvp2.dvClipY = 1.0; | |
4045 d3dvp2.dvClipHeight = 2.0; | |
4046 d3dvp2.dvMaxZ = 1.0; | |
4047 d3dvp2.dvMinZ = 0.0; | |
4048 goto LABEL_54; | |
4049 } | |
4050 LABEL_51: | |
4051 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
4052 if (pDirect3D) | |
4053 { | |
4054 pDirect3D->Release(); | |
4055 pDirect3D = 0; | |
4056 } | |
4057 goto LABEL_59; | |
4058 } | |
4059 LABEL_48: | |
4060 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
4061 if (pZBuffer) | |
4062 { | |
4063 pZBuffer->Release(); | |
4064 pZBuffer = 0; | |
4065 } | |
4066 goto LABEL_61; | |
4067 } | |
4068 goto LABEL_44; | |
4069 } | |
4070 LABEL_36: | |
4071 v23 = "Init - Failed to create front buffer.\n"; | |
4072 sprintf(pErrorMessage, v23); | |
4073 goto LABEL_65; | |
4074 } | |
4075 if ( uDeviceID == 1 ) | |
4076 v26 = 1045; | |
4077 else | |
4078 v26 = 1041; | |
4079 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
4080 { | |
4081 v23 = "Init - Failed to set cooperative level.\n"; | |
4082 sprintf(pErrorMessage, v23); | |
4083 goto LABEL_65; | |
4084 } | |
4085 if (pHost->SetDisplayMode(640u, 480u, 16u, 0, 0) ) | |
4086 { | |
4087 v23 = "Init - Failed to set display mode.\n"; | |
4088 sprintf(pErrorMessage, v23); | |
4089 goto LABEL_65; | |
4090 } | |
4091 | |
4092 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
4093 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
4094 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4095 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
4096 ddsd2.dwBackBufferCount = 1; | |
4097 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
4098 goto LABEL_36; | |
4099 //a3a = &pBackBuffer; | |
4100 //v14 = *v34; | |
4101 memset(&v27, 0, sizeof(DDSCAPS2)); | |
4102 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
4103 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
4104 //hWnda = &pDirect3D; | |
4105 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
4106 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
4107 { | |
4108 v25 = "Init - Failed to get D3D interface.\n"; | |
4109 goto LABEL_45; | |
4110 } | |
4111 | |
4112 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4113 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
4114 ddsd2.dwWidth = 640; | |
4115 ddsd2.dwHeight = 480; | |
4116 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
4117 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
4118 &ddsd2.ddpfPixelFormat) ) | |
4119 { | |
4120 LABEL_21: | |
4121 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
4122 goto LABEL_45; | |
4123 } | |
4124 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
4125 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
4126 //uDeviceIDa = &pZBuffer; | |
4127 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
4128 { | |
4129 LABEL_44: | |
4130 v25 = "Init - Failed to create z-buffer.\n"; | |
4131 LABEL_45: | |
4132 sprintf(pErrorMessage, v25); | |
4133 if (pBackBuffer) | |
4134 { | |
4135 pBackBuffer->Release(); | |
4136 pBackBuffer = 0; | |
4137 } | |
4138 LABEL_63: | |
4139 //v19 = &pFrontBuffer; | |
4140 if (pFrontBuffer) | |
4141 { | |
4142 pFrontBuffer->Release(); | |
4143 pFrontBuffer= 0; | |
4144 } | |
4145 goto LABEL_65; | |
4146 } | |
4147 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
4148 goto LABEL_48; | |
4149 //v33 = &pDevice; | |
4150 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
4151 pBackBuffer, | |
4152 &pDevice, | |
4153 0) ) | |
4154 goto LABEL_51; | |
4155 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
4156 d3dvp2.dvClipWidth = 2.0; | |
4157 d3dvp2.dvClipY = 1.0; | |
4158 d3dvp2.dvClipHeight = 2.0; | |
4159 d3dvp2.dvMaxZ = 1.0; | |
4160 | |
4161 LABEL_54: | |
4162 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
4163 //v17 = *hWnda; | |
4164 d3dvp2.dwWidth = 640; | |
4165 d3dvp2.dwHeight = 480; | |
4166 d3dvp2.dvClipX = -1.0; | |
4167 //v18 = v17->lpVtbl; | |
4168 //v32 = &v4->pViewport; | |
4169 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
4170 { | |
4171 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
4172 if (pDevice) | |
4173 { | |
4174 pDevice->Release(); | |
4175 pDevice = 0; | |
4176 } | |
4177 if (pDirect3D) | |
4178 { | |
4179 pDirect3D->Release(); | |
4180 pDirect3D = 0; | |
4181 } | |
4182 LABEL_59: | |
4183 if (pZBuffer) | |
4184 { | |
4185 pZBuffer->Release(); | |
4186 pZBuffer = 0; | |
4187 } | |
4188 LABEL_61: | |
4189 if (pBackBuffer) | |
4190 { | |
4191 pBackBuffer->Release(); | |
4192 pBackBuffer = 0; | |
4193 } | |
4194 goto LABEL_63; | |
4195 } | |
4196 | |
4197 pDevice->AddViewport(pViewport); | |
4198 pViewport->SetViewport2(&d3dvp2); | |
4199 pDevice->SetCurrentViewport(pViewport); | |
4200 return 1; | |
4201 } | |
4202 | |
4203 //----- (0049E444) -------------------------------------------------------- | |
4204 unsigned int RenderD3D::GetDeviceCaps() | |
4205 { | |
4206 unsigned int v1; // ebx@1 | |
4207 RenderD3D *v2; // edi@1 | |
4208 IDirect3DDevice3 *v3; // eax@1 | |
4209 unsigned int result; // eax@2 | |
4210 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
4211 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
4212 | |
4213 v1 = 0; | |
4214 v2 = this; | |
4215 memset(&halCaps, 0, 0xFCu); | |
4216 halCaps.dwSize = 252; | |
4217 memset(&refCaps, 0, 0xFCu); | |
4218 v3 = v2->pDevice; | |
4219 refCaps.dwSize = 252; | |
4220 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
4221 { | |
4222 result = 1; | |
4223 } | |
4224 else | |
4225 { | |
4226 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
4227 v1 = 2; | |
4228 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 2) ) | |
4229 v1 |= 4u; | |
4230 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 1) ) | |
4231 v1 |= 8u; | |
4232 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
4233 v1 |= 0x10u; | |
4234 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 2) ) | |
4235 v1 |= 0x20u; | |
4236 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 4) ) | |
4237 v1 |= 0x40u; | |
4238 if ( halCaps.dpcTriCaps.dwTextureCaps & 0x20 ) | |
4239 LOBYTE(v1) = v1 | 0x80; | |
4240 result = v1; | |
4241 } | |
4242 return result; | |
4243 } | |
4244 | |
4245 //----- (0049E4FC) -------------------------------------------------------- | |
4246 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
4247 { | |
4248 uint uClearFlags = 0; | |
4249 | |
4250 if (bClearColor) | |
4251 uClearFlags |= D3DCLEAR_TARGET; | |
4252 if (bClearDepth) | |
4253 uClearFlags |= D3DCLEAR_ZBUFFER; | |
4254 | |
4255 D3DRECT rects[] = {{0, 0, 640, 480}}; | |
4256 if (uClearFlags) | |
4257 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
4258 } | |
4259 | |
4260 //----- (0049E54D) -------------------------------------------------------- | |
4261 void RenderD3D::Present(bool bForceBlit) | |
4262 { | |
4263 RECT v5; // [sp+18h] [bp-18h]@1 | |
4264 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
4265 | |
4266 v5.left = 0; | |
4267 v5.top = 0; | |
4268 v5.bottom = 480; | |
4269 v5.right = 640; | |
4270 | |
4271 if (bWindowed || bForceBlit) | |
4272 { | |
4273 RECT rc; | |
4274 GetClientRect(hWindow, &rc); | |
4275 Point.y = 0; | |
4276 Point.x = 0; | |
4277 ClientToScreen(hWindow, &Point); | |
4278 OffsetRect(&rc, Point.x, Point.y); | |
4279 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
4280 } | |
4281 else | |
4282 pFrontBuffer->Flip(0, 1); | |
4283 } | |
4284 | |
4285 //----- (0049E5D4) -------------------------------------------------------- | |
4286 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
4287 { | |
4288 unsigned int v8; // edx@4 | |
4289 unsigned int v9; // ebx@5 | |
4290 unsigned int v10; // eax@5 | |
4291 DWORD v11; // edx@5 | |
4292 //int v12; // edx@7 | |
4293 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
4294 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
4295 | |
4296 //v15 = this; | |
4297 memset(&ddsd2, 0, 0x7Cu); | |
4298 ddsd2.dwSize = 0x7Cu; | |
4299 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4300 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
4301 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
4302 ddsd2.dwHeight = uTextureHeight; | |
4303 ddsd2.dwWidth = uTextureWidth; | |
4304 if ( bMipmaps ) | |
4305 { | |
4306 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
4307 { | |
4308 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
4309 LABEL_8: | |
4310 ddsd2.dwMipMapCount = v8; | |
4311 if ( !v8 ) | |
4312 goto LABEL_12; | |
4313 goto LABEL_11; | |
4314 } | |
4315 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
4316 { | |
4317 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
4318 goto LABEL_8; | |
4319 } | |
4320 v9 = GetMaxMipLevels(uTextureWidth); | |
4321 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
4322 ddsd2.dwMipMapCount = v9 - v10; | |
4323 if ( v9 == v10 ) | |
4324 { | |
4325 ddsd2.dwFlags = 0x1007u; | |
4326 ddsd2.ddsCaps.dwCaps = v11; | |
4327 goto LABEL_12; | |
4328 } | |
4329 } | |
4330 else | |
4331 { | |
4332 ddsd2.dwMipMapCount = 1; | |
4333 } | |
4334 LABEL_11: | |
4335 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
4336 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
4337 LABEL_12: | |
4338 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
4339 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
4340 if (bAlphaChannel) | |
4341 { | |
4342 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
4343 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
4344 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
4345 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
4346 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
4347 } | |
4348 else | |
4349 { | |
4350 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
4351 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
4352 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
4353 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
4354 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
4355 } | |
4356 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
4357 return false; | |
4358 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
4359 { | |
4360 (*pOutSurface)->Release(); | |
4361 *pOutSurface = 0; | |
4362 return false; | |
4363 } | |
4364 return true; | |
4365 } | |
4366 | |
4367 //----- (004A5190) -------------------------------------------------------- | |
4368 void RenderD3D::HandleLostResources() | |
4369 { | |
4370 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
4371 pBitmaps_LOD->_410423_move_textures_to_device(); | |
4372 pSprites_LOD->ReleaseLostHardwareSprites(); | |
4373 } | |
4374 | |
4375 //----- (004A2050) -------------------------------------------------------- | |
4376 void Render::DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) | |
4377 { | |
4378 Render *v5; // edi@1 | |
4379 unsigned int v6; // ebx@1 | |
4380 LightmapBuilder *v7; // esi@3 | |
4381 int v8; // eax@7 | |
4382 ODMFace *v9; // eax@12 | |
4383 char *v10; // esi@12 | |
4384 double v11; // st7@14 | |
4385 double v12; // st7@14 | |
4386 int v13; // eax@14 | |
4387 ODMFace *v14; // ecx@14 | |
4388 double v15; // st7@14 | |
4389 float v16; // ST48_4@15 | |
4390 int v17; // eax@15 | |
4391 char v18; // zf@17 | |
4392 HRESULT v19; // eax@18 | |
4393 HRESULT v20; // eax@18 | |
4394 HRESULT v21; // eax@20 | |
4395 HRESULT v22; // eax@20 | |
4396 unsigned int v23; // ecx@20 | |
4397 char *v24; // eax@21 | |
4398 HRESULT v25; // eax@23 | |
4399 HRESULT v26; // eax@23 | |
4400 HRESULT v27; // eax@24 | |
4401 HRESULT v28; // eax@25 | |
4402 HRESULT v29; // eax@25 | |
4403 HRESULT v30; // eax@25 | |
4404 HRESULT v31; // eax@25 | |
4405 HRESULT v32; // eax@26 | |
4406 unsigned int v33; // ecx@26 | |
4407 char *v34; // eax@27 | |
4408 int v35; // edx@28 | |
4409 HRESULT v36; // eax@29 | |
4410 HRESULT v37; // eax@29 | |
4411 HRESULT v38; // eax@29 | |
4412 HRESULT v39; // eax@29 | |
4413 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
4414 unsigned int v41; // eax@29 | |
4415 HRESULT v42; // eax@30 | |
4416 HRESULT v43; // eax@30 | |
4417 HRESULT v44; // eax@30 | |
4418 char *v45; // esi@34 | |
4419 int v46; // ecx@35 | |
4420 double v47; // st6@35 | |
4421 int v48; // eax@36 | |
4422 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
4423 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
4424 int v51; // [sp+50h] [bp-18h]@0 | |
4425 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
4426 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
4427 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
4428 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
4429 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
4430 int v57; // [sp+60h] [bp-8h]@34 | |
638 | 4431 unsigned int a2; // [sp+64h] [bp-4h]@4 |
0 | 4432 |
4433 v5 = this; | |
4434 v6 = 0; | |
4435 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
4436 { | |
4437 v7 = pGame->pLightmapBuilder; | |
4438 v53 = v7; | |
4439 v54 = v7->std__vector_000004_size; | |
4440 if ( v7->std__vector_000004_size) | |
638 | 4441 a2 = 0xFFFFFFFF; |
4442 pGame->AlterGamma_ODM(a4, &a2); | |
0 | 4443 if ( byte_4D864C && pGame->uFlags & 1 ) |
4444 { | |
638 | 4445 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
0 | 4446 v7->_45D74F_MessWithLight(v8, 0); |
4447 } | |
4448 else | |
4449 { | |
4450 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
4451 { | |
323 | 4452 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4453 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
4454 if (bUsingSpecular) | |
4455 { | |
186 | 4456 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
4457 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4458 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4459 } |
4460 if ( (signed int)uNumVertices > 0 ) | |
4461 { | |
4462 v45 = (char *)&array_50AC10[0].vWorldViewPosition; | |
186 | 4463 v57 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 4464 v55 = uNumVertices; |
4465 do | |
4466 { | |
638 | 4467 a2 = ::GetActorTintColor(a3->dimming_level, 0, *(float *)v45, 0, 0); |
4468 pGame->AlterGamma_ODM(a4, &a2); | |
0 | 4469 v46 = v57; |
4470 v47 = *(float *)v45 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
4471 *(int *)(v57 - 4) = *((int *)v45 + 3); | |
4472 *(int *)v57 = *((int *)v45 + 4); | |
4473 *(int *)(v57 + 12) = a2; | |
4474 *(float *)(v57 + 4) = 1.0 - 1.0 / v47; | |
4475 *(float *)(v57 + 8) = 1.0 / (*(float *)v45 + 0.0000001); | |
4476 if ( v5->bUsingSpecular ) | |
4477 { | |
4478 v48 = sub_47C3D7_get_fog_related_stuff(0, 0, *(float *)v45); | |
4479 v46 = v57; | |
4480 } | |
4481 else | |
4482 { | |
4483 v48 = 0; | |
4484 } | |
4485 *(int *)(v46 + 16) = v48; | |
4486 *(int *)(v46 + 20) = *((int *)v45 + 6); | |
4487 *(int *)(v46 + 24) = *((int *)v45 + 7); | |
4488 v45 += 48; | |
4489 v18 = v55-- == 1; | |
4490 v57 = v46 + 32; | |
4491 } | |
4492 while ( !v18 ); | |
4493 } | |
323 | 4494 |
4495 if (a4->uAttributes & FACE_OUTLINED) | |
4496 { | |
4497 int color; | |
4498 if (GetTickCount() % 300 >= 150) | |
4499 color = 0xFFFF2020; | |
4500 else color = 0xFF901010; | |
4501 | |
4502 for (uint i = 0; i < uNumVertices; ++i) | |
4503 d3d_vertex_buffer[i].diffuse = color; | |
4504 } | |
4505 | |
0 | 4506 pRenderD3D->pDevice->SetTexture(0, pTexture); |
4507 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4508 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 4509 d3d_vertex_buffer, |
0 | 4510 uNumVertices, |
4511 D3DDP_DONOTLIGHT); | |
4512 } | |
4513 else | |
4514 { | |
4515 if ( (signed int)uNumVertices > 0 ) | |
4516 { | |
186 | 4517 v9 = (ODMFace *)&d3d_vertex_buffer[0].pos.y; |
0 | 4518 v10 = (char *)&array_50AC10[0].vWorldViewPosition; |
186 | 4519 a4 = (ODMFace *)&d3d_vertex_buffer[0].pos.y; |
0 | 4520 v56 = uNumVertices; |
4521 while ( 1 ) | |
4522 { | |
4523 v11 = *(float *)v10 * 1000.0; | |
4524 *((int *)v9 - 1) = *((int *)v10 + 3); | |
4525 v12 = v11 / (double)pOutdoorCamera->shading_dist_mist; | |
4526 v9->pFacePlane.vNormal.x = *((int *)v10 + 4); | |
4527 *(float *)&v9->pFacePlane.vNormal.y = 1.0 - 1.0 / v12; | |
4528 *(float *)&v9->pFacePlane.vNormal.z = 1.0 / (*(float *)v10 + 0.0000001); | |
638 | 4529 v13 = GetActorTintColor(a3->dimming_level, 0, *(float *)v10, 0, 0); |
0 | 4530 v14 = a4; |
4531 v15 = *(float *)v10; | |
4532 a4->pFacePlane.dist = v13; | |
4533 if ( v5->bUsingSpecular ) | |
4534 { | |
4535 v16 = v15; | |
4536 v17 = sub_47C3D7_get_fog_related_stuff(0, 0, v16); | |
4537 v14 = a4; | |
4538 } | |
4539 else | |
4540 { | |
4541 v17 = 0; | |
4542 } | |
4543 v14->zCalc1 = v17; | |
4544 v14->zCalc2 = *((int *)v10 + 6); | |
4545 v14->zCalc3 = *((int *)v10 + 7); | |
4546 v10 += 48; | |
4547 v18 = v56-- == 1; | |
4548 a4 = (ODMFace *)((char *)v14 + 32); | |
4549 if ( v18 ) | |
4550 break; | |
4551 v9 = a4; | |
4552 } | |
4553 } | |
186 | 4554 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4555 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 4556 if (bUsingSpecular) |
186 | 4557 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 4558 |
4559 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
4560 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4561 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4562 d3d_vertex_buffer, |
0 | 4563 uNumVertices, |
4564 D3DDP_DONOTLIGHT)); | |
4565 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
4566 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
4567 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
4568 v53->_45D74F_MessWithLight(-1, 0); | |
4569 v23 = uNumVertices; | |
4570 if ( (signed int)uNumVertices > 0 ) | |
4571 { | |
186 | 4572 v24 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 4573 do |
4574 { | |
4575 *(int *)v24 = a2; | |
4576 v24 += 32; | |
4577 --v23; | |
4578 } | |
4579 while ( v23 ); | |
4580 } | |
4581 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); | |
186 | 4582 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4583 if ( !pRenderer->bUsingSpecular ) |
186 | 4584 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4585 | |
4586 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4587 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4588 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 4589 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
4590 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4591 d3d_vertex_buffer, |
0 | 4592 uNumVertices, |
4593 D3DDP_DONOTLIGHT)); | |
4594 if (bUsingSpecular) | |
4595 { | |
186 | 4596 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4597 |
4598 v33 = uNumVertices; | |
4599 if ( (signed int)uNumVertices > 0 ) | |
4600 { | |
186 | 4601 v34 = (char *)&d3d_vertex_buffer[0].specular; |
0 | 4602 do |
4603 { | |
4604 v35 = *(int *)v34; | |
4605 *(int *)v34 = 0; | |
4606 v34 += 32; | |
4607 --v33; | |
4608 *((int *)v34 - 9) = pRenderer->uFogColor | v35 & 0xFF000000; | |
4609 } | |
4610 while ( v33 ); | |
4611 } | |
4612 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
186 | 4613 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4614 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 4615 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
4616 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4617 d3d_vertex_buffer, |
0 | 4618 uNumVertices, |
4619 D3DDP_DONOTLIGHT)); | |
186 | 4620 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4621 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
4622 v41 = GetLevelFogColor(); | |
4623 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
4624 v6 = 0; | |
4625 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4626 } | |
186 | 4627 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4628 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4629 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
4630 } | |
4631 } | |
4632 } | |
4633 } | |
4634 // 4D864C: using guessed type char byte_4D864C; | |
4635 | |
4636 //----- (0049EB79) -------------------------------------------------------- | |
4637 Render::~Render() | |
4638 { | |
4639 Render *v1; // esi@1 | |
4640 | |
4641 v1 = this; | |
4642 pAllocator->FreeChunk(this->pDefaultZBuffer); | |
4643 v1->pD3DBitmaps.Release(); | |
4644 v1->pD3DSprites.Release(); | |
4645 Release(); | |
4646 v1->bWindowMode = 1; | |
4647 //nullsub_1(); | |
4648 //nullsub_1(); | |
4649 } | |
4650 | |
4651 //----- (0049E756) -------------------------------------------------------- | |
4652 bool Render::IsColorKeySupported(IDirectDraw4 *this_) | |
4653 { | |
4654 DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1 | |
4655 DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1 | |
4656 | |
4657 halCaps.dwSize = 380; | |
4658 refCaps.dwSize = 380; | |
4659 this_->GetCaps(&halCaps, &refCaps); | |
4660 return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2; | |
4661 } | |
4662 | |
4663 //----- (0049E992) -------------------------------------------------------- | |
4664 Render::Render() | |
4665 { | |
4666 Render *v1; // esi@1 | |
4667 int v2; // eax@1 | |
4668 char v3; // zf@1 | |
4669 | |
4670 v1 = this; | |
4671 this->pDirectDraw4 = 0; | |
4672 this->pFrontBuffer4 = 0; | |
4673 this->pBackBuffer4 = 0; | |
4674 this->pColorKeySurface4 = 0; | |
4675 this->pDirectDraw2 = 0; | |
4676 this->pFrontBuffer2 = 0; | |
4677 this->pBackBuffer2 = 0; | |
4678 this->pSomeSurface2 = 0; | |
4679 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); | |
4680 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
4681 v1->bWindowMode = 1; | |
4682 v1->field_40054 = 0; | |
4683 v1->field_10 = 640; | |
4684 v1->field_14 = 480; | |
4685 v1->field_40030 = 0; | |
4686 v1->field_4002C = 0; | |
4687 v1->pActiveZBuffer = 0; | |
4688 v1->pDefaultZBuffer = 0; | |
709 | 4689 v1->raster_clip_y = 0; |
4690 v1->raster_clip_x = 0; | |
4691 v1->raster_clip_z = 639; | |
4692 v1->raster_clip_w = 479; | |
0 | 4693 v1->field_4003C = (int)&unk_4EED80; |
4694 v1->field_40040 = dword_4EED78; | |
4695 v1->uClipZ = 640; | |
4696 v1->field_40044 = 2; | |
4697 v1->field_40048 = 6; | |
4698 v1->pFrontBuffer4 = 0; | |
4699 v1->pBackBuffer4 = 0; | |
4700 v1->pColorKeySurface4 = 0; | |
4701 v1->pDirectDraw4 = 0; | |
4702 v1->pRenderD3D = 0; | |
4703 v1->uNumSceneBegins = 0; | |
4704 v1->uNumD3DSceneBegins = 0; | |
4705 v1->field_40110 = 0; | |
4706 v1->pTargetSurface = 0; | |
4707 v1->uTargetSurfacePitch = 0; | |
4708 v1->uClipY = 0; | |
4709 v1->uClipX = 0; | |
4710 v1->uClipW = 480; | |
4711 v1->bClip = 1; | |
4712 v1->bColorKeySupported = 0; | |
4713 v1->bRequiredTextureStagesAvailable = 0; | |
4714 v1->bTinting = 1; | |
4715 LOBYTE(v1->field_103668) = 0; | |
4716 v1->field_1036B8 = 0; | |
4717 v1->_gpu_memory_used = 0; | |
4718 uNumBillboardsToDraw = 0; | |
4719 bFogEnabled = false; | |
265 | 4720 |
4721 hd_water_tile_id = -1; | |
4722 hd_water_current_frame = 0; | |
0 | 4723 } |
4724 | |
781 | 4725 bool Render::Initialize(bool bWindowed, uint uDefaultDevice, bool bColoredLights, uint uDetailLevel, uint bTinting) |
0 | 4726 { |
4727 bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | |
4728 bStartInWindow = bWindowed; | |
4729 | |
4730 uDesiredDirect3DDevice = uDefaultDevice;//ReadWindowsRegistryInt("D3D Device", 1); | |
4731 | |
4732 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
4733 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
4734 | |
4735 this->bTinting = bTinting; | |
4736 | |
4737 auto r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); | |
4738 auto r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
4739 | |
4740 return r1 && r2; | |
4741 } | |
4742 | |
4743 //----- (0049EBF1) -------------------------------------------------------- | |
4744 void Render::_49EBF1() | |
4745 { | |
4746 signed int uNumRedBits; // edx@1 | |
4747 signed int uNuGreenBits; // edi@1 | |
4748 signed int uNumBlueBits; // esi@1 | |
4749 unsigned int v4; // edx@4 | |
4750 unsigned int v5; // edi@4 | |
4751 int v6; // ebx@4 | |
4752 int v7; // edx@4 | |
4753 signed int v8; // [sp+8h] [bp-24h]@1 | |
4754 signed int v9; // [sp+Ch] [bp-20h]@1 | |
4755 signed int v10; // [sp+20h] [bp-Ch]@1 | |
4756 signed int i; // [sp+24h] [bp-8h]@2 | |
4757 signed int v12; // [sp+28h] [bp-4h]@3 | |
4758 | |
4759 v10 = 0; | |
4760 uNumRedBits = 1 << this->uTargetRBits; | |
4761 uNuGreenBits = 1 << this->uTargetGBits; | |
4762 uNumBlueBits = 1 << this->uTargetBBits; | |
4763 v9 = 1 << this->uTargetRBits; | |
4764 v8 = 1 << this->uTargetGBits; | |
4765 if ( uNumRedBits > 0 ) | |
4766 { | |
4767 do | |
4768 { | |
4769 for ( i = 0; i < uNuGreenBits; ++i ) | |
4770 { | |
4771 v12 = 0; | |
4772 if ( uNumBlueBits > 0 ) | |
4773 { | |
4774 do | |
4775 { | |
4776 v4 = this->uTargetBBits; | |
4777 v5 = v4 + this->uTargetGBits; | |
4778 v6 = (v12 >> 1) + (v10 >> 1 << v5) + (i >> 1 << this->uTargetBBits); | |
4779 v7 = (v10 << v5) + v12++ + (i << v4); | |
4780 this->field_2C[v7] = v6; | |
4781 } | |
4782 while ( v12 < uNumBlueBits ); | |
4783 uNumRedBits = v9; | |
4784 uNuGreenBits = v8; | |
4785 } | |
4786 } | |
4787 ++v10; | |
4788 } | |
4789 while ( v10 < uNumRedBits ); | |
4790 } | |
4791 } | |
4792 | |
4793 //----- (0049ECC4) -------------------------------------------------------- | |
4794 void Render::ClearBlack() | |
4795 { | |
4796 if (pRenderD3D) | |
4797 { | |
4798 if (field_40110) | |
4799 pRenderD3D->ClearTarget(true, 0, false, 0.0); | |
4800 } | |
4801 else | |
4802 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
4803 } | |
4804 | |
4805 //----- (0049ED18) -------------------------------------------------------- | |
4806 void Render::PresentBlackScreen() | |
4807 { | |
4808 LONG w; // edx@3 | |
4809 IDirectDrawSurface *v2; // eax@3 | |
4810 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
4811 RECT x; // [sp+68h] [bp-10h]@3 | |
4812 | |
4813 memset(&v3, 0, sizeof(DDBLTFX)); | |
4814 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
4815 pVersion->pVersionInfo.dwMajorVersion >= 5) | |
4816 { | |
4817 x.left = uWindowX; | |
4818 x.right = uWindowX + uWindowHeight; | |
4819 x.top = uWindowY; | |
4820 w = uWindowY + uWindowWidth; | |
4821 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
4822 } | |
4823 else | |
4824 { | |
4825 x.left = uWindowX; | |
4826 x.right = uWindowX + uWindowHeight; | |
4827 x.top = uWindowY; | |
4828 w = uWindowY + uWindowWidth; | |
4829 v2 = (IDirectDrawSurface *)this->pBackBuffer2; | |
4830 } | |
4831 x.bottom = w; | |
4832 v3.dwFillColor = 0; | |
4833 v3.dwSize = 100; | |
4834 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
4835 pRenderer->Present(); | |
4836 } | |
4837 | |
4838 //----- (0049EDB6) -------------------------------------------------------- | |
4839 void Render::SavePCXScreenshot() | |
4840 { | |
4841 Render *v1; // esi@1 | |
4842 __int16 v2; // di@1 | |
4843 int v3; // eax@4 | |
4844 int v4; // ecx@4 | |
4845 int v5; // eax@8 | |
4846 FILE *v6; // edi@10 | |
4847 int v7; // ecx@11 | |
4848 int v8; // eax@11 | |
4849 int v9; // eax@13 | |
4850 int v10; // ecx@15 | |
4851 unsigned __int8 v11; // dl@15 | |
4852 signed int v12; // eax@18 | |
4853 char v13; // zf@27 | |
4854 HRESULT v14; // eax@29 | |
4855 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
4856 __int16 v16; // [sp+44h] [bp-120h]@10 | |
4857 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
4858 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
4859 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
4860 char *v20; // [sp+11Ch] [bp-48h]@14 | |
4861 char *v21; // [sp+120h] [bp-44h]@14 | |
4862 int v24; // [sp+124h] [bp-40h]@11 | |
4863 FILE *File; // [sp+128h] [bp-3Ch]@3 | |
4864 int var38; // [sp+12Ch] [bp-38h]@4 | |
4865 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
4866 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
4867 void *ptr; // [sp+148h] [bp-1Ch]@10 | |
4868 void *v28; // [sp+14Ch] [bp-18h]@8 | |
4869 int v29; // [sp+150h] [bp-14h]@4 | |
4870 int v30; // [sp+154h] [bp-10h]@4 | |
4871 char v31; // [sp+15Ah] [bp-Ah]@25 | |
4872 unsigned __int8 v32; // [sp+15Bh] [bp-9h]@17 | |
4873 int i; // [sp+15Ch] [bp-8h]@10 | |
4874 unsigned __int8 v34; // [sp+163h] [bp-1h]@17 | |
4875 | |
4876 v1 = this; | |
4877 v2 = 0; | |
4878 if ( !this->pRenderD3D || this->field_40110 ) | |
4879 { | |
4880 sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100); | |
4881 File = fopen(Filename, "wb"); | |
4882 if ( File ) | |
4883 { | |
4884 v3 = v1->field_10; | |
4885 v4 = v1->field_14; | |
4886 var38 = v3; | |
4887 v29 = v4; | |
4888 v30 = v3; | |
4889 if ( v3 & 1 ) | |
4890 v30 = v3 + 1; | |
4891 if ( v1->pRenderD3D ) | |
4892 { | |
4893 memset(&Dst, 0, 0x7Cu); | |
4894 Dst.dwSize = 124; | |
168 | 4895 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 4896 return; |
4897 v28 = Dst.lpSurface; | |
4898 v5 = Dst.lPitch >> 1; | |
4899 v2 = 0; | |
4900 } | |
4901 else | |
4902 { | |
4903 pRenderer->BeginScene(); | |
4904 v28 = pRenderer->pTargetSurface; | |
4905 v5 = pRenderer->uTargetSurfacePitch; | |
4906 } | |
4907 i = v5; | |
4908 header1.right = var38 - 1; | |
4909 header1.left = v2; | |
4910 header1.bottom = v29 - 1; | |
4911 header1.up = v2; | |
4912 header2.pitch = v30; | |
4913 memset(color_map, 0, sizeof(color_map)); | |
4914 memset(v15, 0, sizeof(v15)); | |
4915 header2.reserved = 0; | |
4916 header1.manufacturer = 10; | |
4917 v16 = 0; | |
4918 v6 = File; | |
4919 header1.version = 5; | |
4920 header1.encoding = 1; | |
4921 header1.bpp = 8; | |
4922 header1.hdpi = 75; | |
4923 header1.vdpi = 75; | |
4924 header2.planes = 3; | |
4925 header2.palette_info = 1; | |
4926 fwrite(&header1, 1u, 1u, File); | |
4927 fwrite(&header1.version, 1u, 1u, v6); | |
4928 fwrite(&header1.encoding, 1u, 1u, v6); | |
4929 fwrite(&header1.bpp, 1u, 1u, v6); | |
4930 fwrite(&header1.left, 2u, 1u, v6); | |
4931 fwrite(&header1.up, 2u, 1u, v6); | |
4932 fwrite(&header1.right, 2u, 1u, v6); | |
4933 fwrite(&header1.bottom, 2u, 1u, v6); | |
4934 fwrite(&header1.hdpi, 2u, 1u, v6); | |
4935 fwrite(&header1.vdpi, 2u, 1u, v6); | |
4936 fwrite(color_map, 0x30u, 1u, v6); | |
4937 fwrite(&header2, 1u, 1u, v6); | |
4938 fwrite(&header2.planes, 1u, 1u, v6); | |
4939 fwrite(&header2.pitch, 2u, 1u, v6); | |
4940 fwrite(&header2.palette_info, 2u, 1u, v6); | |
4941 fwrite(v15, 0x3Au, 1u, v6); | |
4942 ptr = pAllocator->AllocNamedChunk(0, 3 * var38 + 6, 0); | |
4943 if ( v29 > 0 ) | |
4944 { | |
4945 v7 = v30; | |
4946 File = (FILE *)v29; | |
4947 v29 = 3 * v30; | |
4948 v24 = 2 * i; | |
4949 v8 = (int)v28; | |
4950 while ( 1 ) | |
4951 { | |
4952 i = v8; | |
4953 v9 = 0; | |
4954 if ( var38 > 0 ) | |
4955 { | |
4956 v21 = (char *)ptr + v7; | |
4957 v20 = (char *)ptr + 2 * v30; | |
4958 do | |
4959 { | |
4960 *((char *)ptr + v9) = (signed int)(v1->uTargetRMask & *(short *)i) >> (LOBYTE(v1->uTargetGBits) | |
4961 + LOBYTE(v1->uTargetBBits) | |
4962 + v1->uTargetRBits | |
4963 - 8); | |
4964 v21[v9] = (signed int)(v1->uTargetGMask & *(short *)i) >> (LOBYTE(v1->uTargetBBits) | |
4965 + LOBYTE(v1->uTargetGBits) | |
4966 - 8); | |
4967 v10 = i; | |
4968 v11 = LOBYTE(v1->uTargetBMask); | |
4969 i += 2; | |
4970 v20[v9++] = (*(char *)v10 & v11) << (8 - LOBYTE(v1->uTargetBBits)); | |
4971 } | |
4972 while ( v9 < var38 ); | |
4973 } | |
4974 for ( i = 0; i < v29; i += v34 ) | |
4975 { | |
4976 v34 = 1; | |
4977 v32 = *((char *)ptr + i); | |
4978 do | |
4979 { | |
4980 v12 = i + v34; | |
4981 if ( *((char *)ptr + v12) != v32 ) | |
4982 break; | |
4983 if ( !(v12 % v30) ) | |
4984 break; | |
4985 ++v34; | |
4986 } | |
4987 while ( v34 < 0x3Fu ); | |
4988 if ( i + v34 > v29 ) | |
4989 v34 = 3 * v30 - i; | |
4990 if ( v34 > 1u || v32 >= 0xC0u ) | |
4991 { | |
4992 v31 = v34 | 0xC0; | |
4993 fwrite(&v31, 1u, 1u, v6); | |
4994 } | |
4995 fwrite(&v32, 1u, 1u, v6); | |
4996 } | |
4997 v8 = (int)((char *)v28 + v24); | |
4998 v13 = File == (FILE *)1; | |
4999 File = (FILE *)((char *)File - 1); | |
5000 v28 = (char *)v28 + v24; | |
5001 if ( v13 ) | |
5002 break; | |
5003 v7 = v30; | |
5004 } | |
5005 } | |
5006 if ( v1->pRenderD3D ) | |
5007 { | |
5008 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
5009 } | |
5010 else | |
5011 { | |
5012 pRenderer->EndScene(); | |
5013 } | |
5014 | |
5015 pAllocator->FreeChunk(ptr); | |
5016 fclose(v6); | |
5017 } | |
5018 } | |
5019 } | |
5020 // 4EFA80: using guessed type int dword_4EFA80; | |
5021 | |
5022 //----- (0049F1BC) -------------------------------------------------------- | |
5023 void Render::_49F1BC(const char *a1) | |
5024 { | |
5025 Render *v2; // esi@1 | |
5026 __int16 v3; // di@1 | |
5027 int v4; // eax@4 | |
5028 char *v5; // ecx@4 | |
5029 unsigned int v6; // eax@8 | |
5030 FILE *v7; // edi@10 | |
5031 int v8; // ecx@11 | |
5032 int v9; // eax@11 | |
5033 int v10; // eax@13 | |
5034 const char *v11; // ecx@15 | |
5035 unsigned __int8 v12; // dl@15 | |
5036 signed int v13; // eax@18 | |
5037 char v14; // zf@27 | |
5038 HRESULT v15; // eax@29 | |
5039 char v16; // [sp+Ch] [bp-12Ch]@10 | |
5040 __int16 v17; // [sp+44h] [bp-F4h]@10 | |
5041 int Dst; // [sp+48h] [bp-F0h]@7 | |
5042 int v19; // [sp+58h] [bp-E0h]@8 | |
5043 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
5044 char v21; // [sp+C4h] [bp-74h]@10 | |
5045 unsigned int v22; // [sp+F4h] [bp-44h]@11 | |
5046 char *v23; // [sp+F8h] [bp-40h]@14 | |
5047 int v24; // [sp+FCh] [bp-3Ch]@11 | |
5048 int v25; // [sp+100h] [bp-38h]@4 | |
5049 FILE *File; // [sp+104h] [bp-34h]@3 | |
5050 char Str; // [sp+108h] [bp-30h]@10 | |
5051 char v28; // [sp+109h] [bp-2Fh]@10 | |
5052 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
5053 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
5054 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
5055 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
5056 __int16 v33; // [sp+110h] [bp-28h]@10 | |
5057 __int16 v34; // [sp+112h] [bp-26h]@10 | |
5058 __int16 v35; // [sp+114h] [bp-24h]@10 | |
5059 __int16 v36; // [sp+116h] [bp-22h]@10 | |
5060 char v37; // [sp+118h] [bp-20h]@10 | |
5061 char v38; // [sp+119h] [bp-1Fh]@10 | |
5062 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
5063 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
5064 void *ptr; // [sp+120h] [bp-18h]@10 | |
5065 unsigned __int16 *v42; // [sp+124h] [bp-14h]@8 | |
5066 int v43; // [sp+128h] [bp-10h]@4 | |
5067 char v44; // [sp+12Fh] [bp-9h]@25 | |
5068 char *i; // [sp+130h] [bp-8h]@10 | |
5069 unsigned __int8 v46; // [sp+137h] [bp-1h]@17 | |
5070 | |
5071 v2 = this; | |
5072 v3 = 0; | |
5073 if ( !this->pRenderD3D || this->field_40110 ) | |
5074 { | |
5075 ++dword_4EFA84; | |
5076 File = fopen(a1, "wb"); | |
5077 if ( File ) | |
5078 { | |
5079 v4 = v2->field_10; | |
5080 v5 = (char *)v2->field_14; | |
5081 v25 = v4; | |
5082 a1 = v5; | |
5083 v43 = v4; | |
5084 if ( v4 & 1 ) | |
5085 v43 = v4 + 1; | |
5086 if ( v2->pRenderD3D ) | |
5087 { | |
5088 memset(&Dst, 0, 0x7Cu); | |
5089 Dst = 124; | |
168 | 5090 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 5091 return; |
5092 v42 = v20; | |
5093 v6 = v19 >> 1; | |
5094 v3 = 0; | |
5095 } | |
5096 else | |
5097 { | |
5098 pRenderer->BeginScene(); | |
5099 v42 = pRenderer->pTargetSurface; | |
5100 v6 = pRenderer->uTargetSurfacePitch; | |
5101 } | |
5102 i = (char *)v6; | |
5103 v33 = v25 - 1; | |
5104 v31 = v3; | |
5105 v34 = (short)a1 - 1; | |
5106 v32 = v3; | |
5107 v39 = v43; | |
5108 memset(&v21, 0, 0x30u); | |
5109 memset(&v16, 0, 0x38u); | |
5110 v37 = 0; | |
5111 Str = 10; | |
5112 v17 = 0; | |
5113 v7 = File; | |
5114 v28 = 5; | |
5115 v29 = 1; | |
5116 v30 = 8; | |
5117 v35 = 75; | |
5118 v36 = 75; | |
5119 v38 = 3; | |
5120 v40 = 1; | |
5121 fwrite(&Str, 1u, 1u, File); | |
5122 fwrite(&v28, 1u, 1u, v7); | |
5123 fwrite(&v29, 1u, 1u, v7); | |
5124 fwrite(&v30, 1u, 1u, v7); | |
5125 fwrite(&v31, 2u, 1u, v7); | |
5126 fwrite(&v32, 2u, 1u, v7); | |
5127 fwrite(&v33, 2u, 1u, v7); | |
5128 fwrite(&v34, 2u, 1u, v7); | |
5129 fwrite(&v35, 2u, 1u, v7); | |
5130 fwrite(&v36, 2u, 1u, v7); | |
5131 fwrite(&v21, 0x30u, 1u, v7); | |
5132 fwrite(&v37, 1u, 1u, v7); | |
5133 fwrite(&v38, 1u, 1u, v7); | |
5134 fwrite(&v39, 2u, 1u, v7); | |
5135 fwrite(&v40, 2u, 1u, v7); | |
5136 fwrite(&v16, 0x3Au, 1u, v7); | |
5137 ptr = pAllocator->AllocNamedChunk(0, 3 * v25 + 6, 0); | |
5138 if ( (signed int)a1 > 0 ) | |
5139 { | |
5140 v8 = v43; | |
5141 File = (FILE *)a1; | |
5142 v24 = 3 * v43; | |
5143 v22 = 2 * (int)i; | |
5144 v9 = (int)v42; | |
5145 while ( 1 ) | |
5146 { | |
5147 a1 = (const char *)v9; | |
5148 v10 = 0; | |
5149 if ( v25 > 0 ) | |
5150 { | |
5151 i = (char *)ptr + v8; | |
5152 v23 = (char *)ptr + 2 * v43; | |
5153 do | |
5154 { | |
5155 *((char *)ptr + v10) = (signed int)(v2->uTargetRMask & *(short *)a1) >> (LOBYTE(v2->uTargetGBits) | |
5156 + LOBYTE(v2->uTargetBBits) | |
5157 + v2->uTargetRBits | |
5158 - 8); | |
5159 i[v10] = (signed int)(v2->uTargetGMask & *(short *)a1) >> (LOBYTE(v2->uTargetBBits) | |
5160 + LOBYTE(v2->uTargetGBits) | |
5161 - 8); | |
5162 v11 = a1; | |
5163 v12 = LOBYTE(v2->uTargetBMask); | |
5164 a1 += 2; | |
5165 v23[v10++] = ((unsigned __int8)*v11 & v12) << (8 - LOBYTE(v2->uTargetBBits)); | |
5166 } | |
5167 while ( v10 < v25 ); | |
5168 } | |
5169 for ( i = 0; (signed int)i < v24; i += BYTE3(a1) ) | |
5170 { | |
5171 BYTE3(a1) = 1; | |
5172 v46 = *((char *)ptr + (int)i); | |
5173 do | |
5174 { | |
5175 v13 = (signed int)&i[BYTE3(a1)]; | |
5176 if ( *((char *)ptr + v13) != v46 ) | |
5177 break; | |
5178 if ( !(v13 % v43) ) | |
5179 break; | |
5180 ++BYTE3(a1); | |
5181 } | |
5182 while ( BYTE3(a1) < 0x3Fu ); | |
5183 if ( (signed int)&i[BYTE3(a1)] > v24 ) | |
5184 BYTE3(a1) = 3 * v43 - (char)i; | |
5185 if ( BYTE3(a1) > 1u || v46 >= 0xC0u ) | |
5186 { | |
5187 v44 = BYTE3(a1) | 0xC0; | |
5188 fwrite(&v44, 1u, 1u, v7); | |
5189 } | |
5190 fwrite(&v46, 1u, 1u, v7); | |
5191 } | |
5192 v9 = (int)&v42[v22 / 2]; | |
5193 v14 = File == (FILE *)1; | |
5194 File = (FILE *)((char *)File - 1); | |
5195 v42 = (unsigned __int16 *)((char *)v42 + v22); | |
5196 if ( v14 ) | |
5197 break; | |
5198 v8 = v43; | |
5199 } | |
5200 } | |
5201 if ( v2->pRenderD3D ) | |
5202 { | |
5203 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
5204 } | |
5205 else | |
5206 { | |
5207 pRenderer->EndScene(); | |
5208 } | |
5209 pAllocator->FreeChunk(ptr); | |
5210 fclose(v7); | |
5211 } | |
5212 } | |
5213 } | |
5214 // 4EFA84: using guessed type int dword_4EFA84; | |
5215 | |
5216 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 5217 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
5218 { | |
0 | 5219 Render *v7; // ebx@1 |
5220 void *v8; // esi@3 | |
5221 void *v9; // esi@3 | |
5222 int v10; // ecx@4 | |
810 | 5223 unsigned short* v11; // eax@4 |
0 | 5224 int v12; // eax@6 |
5225 int v13; // eax@8 | |
5226 int v14; // ecx@8 | |
5227 signed int v15; // eax@11 | |
5228 char v16; // zf@20 | |
5229 int result; // eax@21 | |
5230 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
5231 // __int16 v19; // [sp+44h] [bp-74h]@3 | |
5232 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 5233 char *lineG; // [sp+78h] [bp-40h]@7 |
5234 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 5235 int v23; // [sp+80h] [bp-38h]@4 |
5236 int v24; // [sp+84h] [bp-34h]@4 | |
5237 int v25; // [sp+88h] [bp-30h]@4 | |
5238 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 5239 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
5240 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
5241 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
5242 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 5243 char v43; // [sp+B3h] [bp-5h]@18 |
5244 int i; // [sp+B4h] [bp-4h]@6 | |
810 | 5245 unsigned short* line_pictute_data; |
5246 byte test_byte; | |
5247 unsigned char pict_byte; | |
0 | 5248 |
5249 v7 = this; | |
810 | 5250 pitch = wight; |
5251 if ( wight & 1 ) | |
5252 pitch = wight + 1; | |
5253 Src.left = 0; | |
5254 Src.up = 0; | |
5255 Src.right = wight - 1; | |
5256 Src.bottom = heidth - 1; | |
5257 v27.pitch = pitch; | |
0 | 5258 memset(&v20, 0, 0x30u); |
5259 memset(&v18, 0, 0x38u); | |
810 | 5260 v8 = data_buff; |
5261 v27.reserved = 0; | |
0 | 5262 *(_WORD *)&v18[56] = 0; |
810 | 5263 Src.manufacturer = 10; |
5264 Src.version = 5; | |
5265 Src.encoding = 1; | |
5266 Src.bpp = 8; | |
5267 Src.hdpi = 75; | |
5268 Src.vdpi = 75; | |
5269 v27.planes = 3; | |
5270 v27.palette_info = 1; | |
5271 memcpy(data_buff, &Src, 1u); | |
0 | 5272 v8 = (char *)v8 + 1; |
810 | 5273 memcpy(v8, &Src.version, 1u); |
0 | 5274 v8 = (char *)v8 + 1; |
810 | 5275 memcpy(v8, &Src.encoding, 1u); |
0 | 5276 v8 = (char *)v8 + 1; |
810 | 5277 memcpy(v8, &Src.bpp, 1u); |
0 | 5278 v8 = (char *)v8 + 1; |
810 | 5279 memcpy(v8, &Src.left, 2u); |
0 | 5280 v8 = (char *)v8 + 2; |
810 | 5281 memcpy(v8, &Src.up, 2u); |
0 | 5282 v8 = (char *)v8 + 2; |
810 | 5283 memcpy(v8, &Src.right, 2u); |
0 | 5284 v8 = (char *)v8 + 2; |
810 | 5285 memcpy(v8, &Src.bottom, 2u); |
0 | 5286 v8 = (char *)v8 + 2; |
810 | 5287 memcpy(v8, &Src.hdpi, 2u); |
0 | 5288 v8 = (char *)v8 + 2; |
810 | 5289 memcpy(v8, &Src.vdpi, 2u); |
0 | 5290 v8 = (char *)v8 + 2; |
5291 memcpy(v8, &v20, 0x30u); | |
5292 v8 = (char *)v8 + 48; | |
810 | 5293 memcpy(v8, &v27, 1u); |
0 | 5294 v8 = (char *)v8 + 1; |
810 | 5295 memcpy(v8, &v27.planes, 1u); |
0 | 5296 v8 = (char *)v8 + 1; |
810 | 5297 memcpy(v8, &v27.pitch, 2u); |
0 | 5298 v8 = (char *)v8 + 2; |
810 | 5299 memcpy(v8, &v27.palette_info, 2u); |
0 | 5300 v8 = (char *)v8 + 2; |
5301 memcpy(v8, &v18, 0x3Au); | |
5302 v9 = (char *)v8 + 58; | |
810 | 5303 |
5304 lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0); | |
5305 if ( heidth > 0 ) | |
5306 { | |
5307 v10 = pitch; | |
5308 v25 = heidth; | |
5309 v26 = 3 * pitch; | |
5310 v23 = 2 * wight; | |
5311 v11 = picture_data; | |
5312 v24 = (int)picture_data; | |
0 | 5313 while ( 1 ) |
5314 { | |
810 | 5315 line_pictute_data = v11; |
0 | 5316 v12 = 0; |
5317 i = 0; | |
810 | 5318 if ( wight > 0 ) |
5319 { | |
5320 lineG = (char *)lineRGB + pitch; | |
5321 lineB = (char *)lineRGB + 2 * pitch; | |
0 | 5322 do |
5323 { | |
810 | 5324 lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8); |
5325 lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8); | |
5326 lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits); | |
5327 | |
5328 v12++; | |
5329 } | |
5330 while ( v12 < wight ); | |
0 | 5331 } |
5332 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
5333 { | |
810 | 5334 test_byte = 1; |
5335 pict_byte = lineRGB [i]; | |
0 | 5336 do |
5337 { | |
810 | 5338 v15 = i + test_byte; |
5339 if ( *((char *)lineRGB + v15) != pict_byte ) | |
0 | 5340 break; |
810 | 5341 if ( !(v15 % pitch) ) |
0 | 5342 break; |
810 | 5343 ++test_byte; |
5344 } | |
5345 while ( test_byte < 0x3Fu ); | |
5346 if ( i + test_byte > v26 ) | |
5347 test_byte = 3 * pitch - i; | |
5348 if ( test_byte > 1u || pict_byte >= 0xC0u ) | |
5349 { | |
5350 v43 = test_byte | 0xC0; | |
0 | 5351 memcpy(v9, &v43, 1u); |
5352 v9 = (char *)v9 + 1; | |
5353 } | |
810 | 5354 memcpy(v9, &pict_byte, 1u); |
5355 i += test_byte; | |
5356 } | |
5357 v11 +=wight ; | |
0 | 5358 v16 = v25-- == 1; |
810 | 5359 |
0 | 5360 if ( v16 ) |
5361 break; | |
810 | 5362 v10 = pitch; |
5363 } | |
5364 } | |
5365 pAllocator->FreeChunk(lineRGB); | |
5366 *(int *)packed_size = (char *)v9 - data_buff; | |
5367 | |
0 | 5368 } |
5369 | |
5370 //----- (0049F8B5) -------------------------------------------------------- | |
5371 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) | |
5372 { | |
5373 Render *v5; // esi@1 | |
5374 FILE *result; // eax@1 | |
5375 FILE *v7; // edi@4 | |
5376 int v8; // ecx@5 | |
5377 int v9; // eax@5 | |
5378 int v10; // eax@7 | |
5379 int v11; // ecx@9 | |
5380 signed int v12; // eax@12 | |
5381 char v13; // zf@21 | |
5382 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
5383 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
5384 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
5385 int v17; // [sp+70h] [bp-34h]@5 | |
5386 int v18; // [sp+74h] [bp-30h]@5 | |
5387 char *v19; // [sp+78h] [bp-2Ch]@5 | |
5388 int v20; // [sp+7Ch] [bp-28h]@5 | |
5389 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 | |
5390 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
5391 void *ptr; // [sp+98h] [bp-Ch]@4 | |
5392 int v24; // [sp+9Ch] [bp-8h]@2 | |
5393 char *i; // [sp+A0h] [bp-4h]@8 | |
5394 | |
5395 v5 = this; | |
5396 result = fopen(Filename, "wb"); | |
5397 Filename = (const char *)result; | |
5398 if ( result ) | |
5399 { | |
5400 v24 = a4; | |
5401 if ( a4 & 1 ) | |
5402 v24 = a4 + 1; | |
5403 header1.left = 0; | |
5404 header1.up = 0; | |
5405 header1.right = a4 - 1; | |
5406 header1.bottom = a5 - 1; | |
5407 header2.pitch = v24; | |
5408 memset(color_map, 0, sizeof(color_map)); | |
5409 header2.reserved = 0; | |
5410 memset(v14, 0, sizeof(v14)); | |
5411 v15 = 0; | |
5412 header1.manufacturer = 10; | |
5413 header1.version = 5; | |
5414 header1.encoding = 1; | |
5415 header1.bpp = 8; | |
5416 header1.hdpi = 75; | |
5417 header1.vdpi = 75; | |
5418 header2.planes = 3; | |
5419 header2.palette_info = 1; | |
5420 fwrite(&header1, 1u, 1u, (FILE *)Filename); | |
5421 v7 = (FILE *)Filename; | |
5422 fwrite(&header1.version, 1u, 1u, (FILE *)Filename); | |
5423 fwrite(&header1.encoding, 1u, 1u, v7); | |
5424 fwrite(&header1.bpp, 1u, 1u, v7); | |
5425 fwrite(&header1.left, 2u, 1u, v7); | |
5426 fwrite(&header1.up, 2u, 1u, v7); | |
5427 fwrite(&header1.right, 2u, 1u, v7); | |
5428 fwrite(&header1.bottom, 2u, 1u, v7); | |
5429 fwrite(&header1.hdpi, 2u, 1u, v7); | |
5430 fwrite(&header1.vdpi, 2u, 1u, v7); | |
5431 fwrite(color_map, 0x30u, 1u, v7); | |
5432 fwrite(&header2, 1u, 1u, v7); | |
5433 fwrite(&header2.planes, 1u, 1u, v7); | |
5434 fwrite(&header2.pitch, 2u, 1u, v7); | |
5435 fwrite(&header2.palette_info, 2u, 1u, v7); | |
5436 fwrite(v14, 0x3Au, 1u, v7); | |
5437 ptr = pAllocator->AllocNamedChunk(0, 3 * a4 + 6, 0); | |
5438 if ( a5 > 0 ) | |
5439 { | |
5440 v8 = v24; | |
5441 v18 = a5; | |
5442 v20 = 3 * v24; | |
5443 v17 = 2 * a4; | |
5444 v9 = (int)a3; | |
5445 v19 = a3; | |
5446 while ( 1 ) | |
5447 { | |
5448 a5 = v9; | |
5449 v10 = 0; | |
5450 if ( a4 > 0 ) | |
5451 { | |
5452 a3 = (char *)ptr + v8; | |
5453 i = (char *)ptr + 2 * v24; | |
5454 do | |
5455 { | |
5456 *((char *)ptr + v10) = (signed int)(v5->uTargetRMask & *(short *)a5) >> (LOBYTE(v5->uTargetGBits) | |
5457 + LOBYTE(v5->uTargetBBits) | |
5458 + v5->uTargetRBits | |
5459 - 8); | |
5460 a3[v10] = (signed int)(v5->uTargetGMask & *(short *)a5) >> (LOBYTE(v5->uTargetBBits) | |
5461 + LOBYTE(v5->uTargetGBits) | |
5462 - 8); | |
5463 v11 = a5; | |
5464 a5 += 2; | |
5465 i[v10++] = (v5->uTargetBMask & *(char *)v11) << (8 - LOBYTE(v5->uTargetBBits)); | |
5466 } | |
5467 while ( v10 < a4 ); | |
5468 } | |
5469 for ( i = 0; (signed int)i < v20; i += BYTE3(a5) ) | |
5470 { | |
5471 BYTE3(a5) = 1; | |
5472 BYTE3(Filename) = *((char *)ptr + (int)i); | |
5473 do | |
5474 { | |
5475 v12 = (signed int)&i[BYTE3(a5)]; | |
5476 if ( *((char *)ptr + v12) != BYTE3(Filename) ) | |
5477 break; | |
5478 if ( !(v12 % v24) ) | |
5479 break; | |
5480 ++BYTE3(a5); | |
5481 } | |
5482 while ( BYTE3(a5) < 0x3Fu ); | |
5483 if ( (signed int)&i[BYTE3(a5)] > v20 ) | |
5484 BYTE3(a5) = 3 * v24 - (char)i; | |
5485 if ( BYTE3(a5) > 1u || BYTE3(Filename) >= 0xC0u ) | |
5486 { | |
5487 BYTE3(a3) = BYTE3(a5) | 0xC0; | |
5488 fwrite((char *)&a3 + 3, 1u, 1u, v7); | |
5489 } | |
5490 fwrite((char *)&Filename + 3, 1u, 1u, v7); | |
5491 } | |
5492 v9 = (int)&v19[v17]; | |
5493 v13 = v18-- == 1; | |
5494 v19 += v17; | |
5495 if ( v13 ) | |
5496 break; | |
5497 v8 = v24; | |
5498 } | |
5499 } | |
5500 pAllocator->FreeChunk(ptr); | |
5501 result = (FILE *)fclose(v7); | |
5502 } | |
5503 return result; | |
5504 } | |
5505 | |
5506 //----- (0049FBCD) -------------------------------------------------------- | |
5507 void Render::ClearTarget(unsigned int uColor) | |
5508 { | |
5509 if (pRenderD3D) | |
5510 { | |
5511 if (field_40110) | |
5512 pRenderD3D->ClearTarget(true, uColor, false, 0.0); | |
5513 } | |
5514 else | |
5515 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
5516 } | |
5517 | |
5518 //----- (0049FC23) -------------------------------------------------------- | |
5519 void Render::Release2() | |
5520 { | |
5521 Release(); | |
5522 bWindowMode = 1; | |
5523 } | |
5524 | |
5525 //----- (0049FC37) -------------------------------------------------------- | |
5526 void Render::Present() | |
5527 { | |
5528 Render *v1; // esi@1 | |
5529 struct tagRECT Rect; // [sp+8h] [bp-28h]@11 | |
5530 RECT a4; // [sp+18h] [bp-18h]@11 | |
5531 struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
5532 | |
5533 v1 = this; | |
5534 if ( !pRenderer->pRenderD3D || this->field_40110 ) | |
5535 { | |
5536 this->pBeforePresentFunction(); | |
5537 if ( v1->pRenderD3D ) | |
5538 { | |
5539 if ( v1->field_40110 ) | |
5540 { | |
5541 if (pAsyncMouse) | |
5542 pAsyncMouse->_46BAEC(); | |
5543 pRenderD3D->Present(false); | |
5544 if (pAsyncMouse) | |
5545 pAsyncMouse->_46BB0A(); | |
5546 } | |
5547 } | |
5548 else | |
5549 { | |
5550 if ( v1->bWindowMode ) | |
5551 { | |
5552 RestoreFrontBuffer(); | |
5553 GetClientRect(v1->hWnd, &Rect); | |
5554 Point.y = 0; | |
5555 Point.x = 0; | |
5556 ClientToScreen(v1->hWnd, &Point); | |
5557 OffsetRect(&Rect, Point.x, Point.y); | |
5558 a4.top = 0; | |
5559 a4.bottom = 480; | |
5560 a4.left = 0; | |
5561 a4.right = 640; | |
5562 PresentRect(&Rect, &a4); | |
5563 } | |
5564 else | |
5565 { | |
5566 RestoreFrontBuffer(); | |
5567 a4.top = 0; | |
5568 a4.bottom = 480; | |
5569 a4.left = 0; | |
5570 a4.right = 640; | |
5571 BltBackToFontFast(0, 0, &a4); | |
5572 } | |
5573 } | |
5574 } | |
5575 } | |
5576 | |
5577 //----- (0049FD3A) -------------------------------------------------------- | |
5578 void Render::_49FD3A() | |
5579 { | |
5580 Render *v2; // esi@1 | |
5581 IDirectDrawSurface4 *v3; // eax@6 | |
5582 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
5583 RECT v5; // [sp+8h] [bp-10h]@6 | |
5584 | |
5585 auto a1 = this; | |
5586 v2 = a1; | |
5587 if ( a1->pRenderD3D ) | |
5588 { | |
5589 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
5590 pFrontBuffer4->Restore(); | |
5591 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
5592 pBackBuffer4->Restore(); | |
5593 v3 = v2->pBackBuffer4; | |
5594 v4 = v2->pFrontBuffer4; | |
5595 v5.top = 0; | |
5596 v5.bottom = 480; | |
5597 v5.left = 0; | |
5598 v5.right = 640; | |
5599 v3->BltFast(0, 0, v4, &v5, 16u); | |
5600 } | |
5601 } | |
5602 | |
5603 //----- (0049FDBF) -------------------------------------------------------- | |
5604 void Render::CreateZBuffer() | |
5605 { | |
5606 if (!pDefaultZBuffer) | |
5607 { | |
5608 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
5609 pDefaultZBuffer = pActiveZBuffer = (int *)pAllocator->AllocNamedChunk(0, 0x12C000, "Z Buf."); | |
871 | 5610 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 5611 } |
5612 } | |
5613 | |
5614 //----- (0049FE05) -------------------------------------------------------- | |
5615 void Render::Release() | |
5616 { | |
5617 Render *v1; // esi@1 | |
5618 RenderD3D *v2; // ecx@1 | |
5619 char v3; // zf@4 | |
5620 void *v4; // ebx@6 | |
5621 IDirectDraw *v5; // eax@10 | |
5622 IDirectDrawSurface2 *v6; // eax@11 | |
5623 IDirectDrawSurface2 *v7; // eax@13 | |
5624 IDirectDrawSurface2 *v8; // eax@15 | |
5625 IDirectDraw2 *v9; // eax@17 | |
5626 IDirectDraw4 *v10; // eax@19 | |
5627 IDirectDrawSurface4 *v11; // eax@20 | |
5628 IDirectDrawSurface4 *v12; // eax@22 | |
5629 IDirectDrawSurface4 *v13; // eax@24 | |
5630 IDirectDraw4 *v14; // eax@26 | |
5631 unsigned __int16 **v15; // ebx@28 | |
5632 void **v16; // esi@29 | |
5633 | |
5634 v1 = this; | |
5635 v2 = this->pRenderD3D; | |
5636 if ( v2 ) | |
5637 { | |
5638 if ( v1->field_40110 ) | |
5639 { | |
5640 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
5641 pRenderD3D->Present(0); | |
5642 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
5643 } | |
5644 v1->pColorKeySurface4 = 0; | |
5645 v1->pBackBuffer4 = 0; | |
5646 v3 = v1->pTargetSurface == 0; | |
5647 v1->pFrontBuffer4 = 0; | |
5648 v1->pDirectDraw4 = 0; | |
5649 if ( !v3 ) | |
5650 { | |
5651 free(v1->ptr_400E8); | |
5652 v1->pTargetSurface = 0; | |
5653 v1->ptr_400E8 = 0; | |
5654 } | |
5655 v4 = v1->pRenderD3D; | |
5656 if ( v4 ) | |
5657 { | |
5658 pRenderD3D->Release(); | |
5659 free(v4); | |
5660 } | |
5661 v1->pRenderD3D = 0; | |
5662 } | |
5663 else | |
5664 { | |
5665 if ( bWinNT4_0 == 1 ) | |
5666 { | |
5667 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
5668 if ( !v5 ) | |
5669 return; | |
5670 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
5671 v1->pDirectDraw2->FlipToGDISurface(); | |
5672 v6 = v1->pSomeSurface2; | |
5673 if ( v6 ) | |
5674 { | |
5675 v6->Release(); | |
5676 v1->pSomeSurface2 = 0; | |
5677 } | |
5678 v7 = v1->pBackBuffer2; | |
5679 if ( v7 ) | |
5680 { | |
5681 v7->Release(); | |
5682 v1->pBackBuffer2 = 0; | |
5683 } | |
5684 v8 = v1->pFrontBuffer2; | |
5685 if ( v8 ) | |
5686 { | |
5687 v8->Release(); | |
5688 v1->pFrontBuffer2 = 0; | |
5689 } | |
5690 v9 = v1->pDirectDraw2; | |
5691 if ( v9 ) | |
5692 { | |
5693 v9->Release(); | |
5694 v1->pDirectDraw2 = 0; | |
5695 } | |
5696 } | |
5697 else | |
5698 { | |
5699 v10 = v1->pDirectDraw4; | |
5700 if ( !v10 ) | |
5701 return; | |
5702 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
5703 v1->pDirectDraw4->FlipToGDISurface(); | |
5704 v11 = v1->pColorKeySurface4; | |
5705 if ( v11 ) | |
5706 { | |
5707 v11->Release(); | |
5708 v1->pColorKeySurface4 = 0; | |
5709 } | |
5710 v12 = v1->pBackBuffer4; | |
5711 if ( v12 ) | |
5712 { | |
5713 v12->Release(); | |
5714 v1->pBackBuffer4 = 0; | |
5715 } | |
5716 v13 = v1->pFrontBuffer4; | |
5717 if ( v13 ) | |
5718 { | |
5719 v13->Release(); | |
5720 v1->pFrontBuffer4 = 0; | |
5721 } | |
5722 v14 = v1->pDirectDraw4; | |
5723 if ( v14 ) | |
5724 { | |
5725 v14->Release(); | |
5726 v1->pDirectDraw4 = 0; | |
5727 } | |
5728 } | |
5729 v15 = &v1->pTargetSurface; | |
5730 if ( v1->pTargetSurface ) | |
5731 { | |
5732 v16 = (void **)&v1->ptr_400E8; | |
5733 free(*v16); | |
5734 *v15 = 0; | |
5735 *v16 = 0; | |
5736 } | |
5737 } | |
5738 } | |
5739 | |
5740 //----- (0049FFD7) -------------------------------------------------------- | |
5741 void Render::CreateSomeTexture() | |
5742 { | |
5743 pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); | |
5744 } | |
5745 | |
5746 //----- (0049FFFB) -------------------------------------------------------- | |
5747 bool Render::InitializeFullscreen(HWND hWnd) | |
5748 { | |
5749 //Render *v2; // esi@1 | |
5750 //HWND v3; // ebx@1 | |
5751 //void *v4; // eax@2 | |
5752 //RenderD3D *v5; // eax@3 | |
5753 unsigned int v6; // edx@5 | |
5754 RenderD3D__DevInfo *v7; // ecx@5 | |
5755 bool v8; // eax@6 | |
5756 RenderD3D *v9; // ecx@13 | |
5757 unsigned int v10; // eax@13 | |
5758 RenderD3D *v11; // eax@25 | |
5759 HRESULT v12; // eax@25 | |
5760 int v13; // ecx@25 | |
5761 int v14; // eax@27 | |
5762 signed int v15; // ebx@31 | |
5763 bool v16; // eax@35 | |
5764 char v17; // zf@35 | |
5765 IDirectDraw4 *v18; // eax@38 | |
5766 HRESULT v19; // eax@38 | |
5767 int *v20; // eax@39 | |
5768 int *v22; // eax@42 | |
5769 int v23; // ecx@42 | |
5770 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
5771 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
5772 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
5773 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
5774 void *v28; // [sp+2FCh] [bp-10h]@2 | |
5775 int v29; // [sp+308h] [bp-4h]@2 | |
5776 | |
5777 //v2 = this; | |
5778 this->field_40110 = 0; | |
5779 this->pColorKeySurface4 = 0; | |
5780 this->pBackBuffer4 = 0; | |
5781 this->pFrontBuffer4 = 0; | |
5782 this->pDirectDraw4 = 0; | |
5783 this->bColorKeySupported = 0; | |
5784 Release(); | |
5785 //v3 = hWnd; | |
5786 this->hWnd = hWnd; | |
5787 CreateZBuffer(); | |
5788 if ( bUserDirect3D ) | |
5789 { | |
5790 pRenderD3D = new RenderD3D; | |
5791 v28 = pRenderD3D; | |
5792 v6 = uDesiredDirect3DDevice; | |
5793 v29 = -1; | |
5794 v7 = pRenderD3D->pAvailableDevices; | |
5795 if ( v7[v6].bIsDeviceCompatible ) | |
5796 { | |
5797 v8 = pRenderD3D->CreateDevice(v6, 0, hWnd); | |
5798 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
5799 } | |
5800 else | |
5801 { | |
5802 if ( v7[1].bIsDeviceCompatible ) | |
5803 { | |
5804 v8 = pRenderD3D->CreateDevice(1u, 0, hWnd); | |
5805 uAcquiredDirect3DDevice = 1; | |
5806 } | |
5807 else | |
5808 { | |
5809 if ( !v7->bIsDeviceCompatible ) | |
5810 Abortf("There aren't any D3D devices to create."); | |
5811 v8 = pRenderD3D->CreateDevice(0, 0, hWnd); | |
5812 uAcquiredDirect3DDevice = 0; | |
5813 } | |
5814 } | |
5815 if ( !v8 ) | |
5816 Abortf("D3Drend->Init failed."); | |
5817 v9 = pRenderD3D; | |
5818 pBackBuffer4 = v9->pBackBuffer; | |
5819 pFrontBuffer4 = v9->pFrontBuffer; | |
5820 pDirectDraw4 = v9->pHost; | |
5821 v10 = pRenderD3D->GetDeviceCaps(); | |
5822 if ( v10 & 1 ) | |
5823 { | |
5824 if ( pRenderD3D ) | |
5825 { | |
5826 pRenderD3D->Release(); | |
5827 delete pRenderD3D; | |
5828 } | |
5829 pRenderD3D = 0; | |
5830 pBackBuffer4 = 0; | |
5831 pFrontBuffer4 = 0; | |
5832 pDirectDraw4 = 0; | |
5833 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
5834 } | |
5835 if ( v10 & 0x3E ) | |
5836 { | |
5837 if ( pRenderD3D ) | |
5838 { | |
5839 pRenderD3D->Release(); | |
5840 delete pRenderD3D; | |
5841 } | |
5842 pColorKeySurface4 = 0; | |
5843 pRenderD3D = 0; | |
5844 pBackBuffer4 = 0; | |
5845 pFrontBuffer4 = 0; | |
5846 pDirectDraw4 = 0; | |
5847 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
5848 } | |
5849 if ( (v10 & 0x80u) != 0 ) | |
5850 { | |
5851 if ( pRenderD3D ) | |
5852 { | |
5853 pRenderD3D->Release(); | |
5854 delete pRenderD3D; | |
5855 } | |
5856 pRenderD3D = 0; | |
5857 pBackBuffer4 = 0; | |
5858 pFrontBuffer4 = 0; | |
5859 pDirectDraw4 = 0; | |
5860 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
5861 } | |
5862 LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; | |
5863 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
5864 memset(&halCaps, 0, 0xFCu); | |
5865 halCaps.dwSize = 252; | |
5866 memset(&refCaps, 0, 0xFCu); | |
5867 v11 = pRenderD3D; | |
5868 refCaps.dwSize = 252; | |
5869 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
5870 v13 = halCaps.dwMinTextureWidth; | |
5871 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
5872 v13 = halCaps.dwMinTextureHeight; | |
5873 v14 = halCaps.dwMaxTextureWidth; | |
5874 uMinDeviceTextureDim = v13; | |
5875 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
5876 v14 = halCaps.dwMaxTextureHeight; | |
5877 uMaxDeviceTextureDim = v14; | |
5878 if ( (unsigned int)v13 < 4 ) | |
5879 uMinDeviceTextureDim = 4; | |
5880 CreateSomeTexture(); | |
5881 v15 = 1; | |
5882 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
5883 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
5884 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
5885 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); | |
5886 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
5887 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
5888 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
5889 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
5890 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
5891 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
5892 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
5893 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
5894 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
5895 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
5896 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
5897 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
5898 } | |
5899 else | |
5900 { | |
5901 CreateDirectDraw(); | |
5902 SetDirectDrawCooperationMode(hWnd, 1); | |
5903 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
5904 CreateDirectDrawPrimarySurface(); | |
5905 v15 = 1; | |
5906 } | |
5907 ddpfPrimareSuface.dwSize = 32; | |
5908 GetTargetPixelFormat(&ddpfPrimareSuface); | |
5909 ParseTargetPixelFormat(); | |
5910 _49EBF1(); | |
5911 if ( pRenderD3D ) | |
5912 { | |
5913 v16 = IsColorKeySupported(pDirectDraw4); | |
5914 v17 = uAcquiredDirect3DDevice == v15; | |
5915 bColorKeySupported = v16; | |
5916 if ( !v17 ) | |
5917 bColorKeySupported = 0; | |
5918 if ( bColorKeySupported ) | |
5919 { | |
5920 memset(&ddsd2, 0, 0x7Cu); | |
5921 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
5922 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
5923 v18 = pDirectDraw4; | |
5924 ddsd2.dwSize = 124; | |
5925 ddsd2.dwFlags = 65543; | |
5926 ddsd2.ddsCaps.dwCaps = 2112; | |
5927 ddsd2.dwWidth = 640; | |
5928 ddsd2.dwHeight = 480; | |
5929 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
5930 pBeforePresentFunction = Present_ColorKey; | |
5931 } | |
5932 else | |
5933 { | |
5934 pTargetSurface = 0; | |
5935 ptr_400E8 = 0; | |
5936 v20 = (int *)operator new(0x96020u); | |
5937 ptr_400E8 = v20; | |
5938 if ( !v20 | |
5939 || (memset(&pDesc, 0, 0x7Cu), | |
5940 pDesc.dwSize = 124, | |
5941 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
5942 return 0; | |
5943 pBackBuffer4->Unlock(0); | |
5944 v22 = ptr_400E8 + 4; | |
5945 v23 = (unsigned int)pDesc.lpSurface & 7; | |
5946 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
5947 uTargetSurfacePitch = 640; | |
5948 pBeforePresentFunction = Present_NoColorKey; | |
5949 v15 = 1; | |
5950 pTargetSurface = (unsigned __int16 *)((char *)v22 + 2 * v23); | |
5951 } | |
5952 field_40110 = v15; | |
5953 } | |
5954 else | |
5955 { | |
5956 pBeforePresentFunction = 0;//nullsub_1; | |
5957 } | |
5958 bWindowMode = 0; | |
5959 pParty->uFlags |= 2u; | |
5960 LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; | |
5961 pViewport->_4C02F8(36044); | |
5962 return v15; | |
5963 } | |
5964 // 6BE3A0: using guessed type float flt_6BE3A0; | |
5965 | |
5966 //----- (004A05F3) -------------------------------------------------------- | |
5967 bool Render::SwitchToWindow(HWND hWnd) | |
5968 { | |
5969 //Render *v2; // esi@1 | |
5970 //void *v3; // eax@2 | |
5971 //RenderD3D *v4; // eax@3 | |
5972 //unsigned int v5; // edx@5 | |
5973 //RenderD3D__DevInfo *v6; // ecx@5 | |
5974 bool v7; // eax@7 | |
5975 //RenderD3D *v8; // ecx@12 | |
5976 unsigned int v9; // eax@12 | |
5977 RenderD3D *v10; // eax@24 | |
5978 HRESULT v11; // eax@24 | |
5979 int v12; // eax@24 | |
5980 int v13; // eax@26 | |
5981 bool v14; // eax@32 | |
5982 char v15; // zf@32 | |
5983 IDirectDraw4 *v16; // eax@35 | |
5984 HRESULT v17; // eax@35 | |
5985 int *v18; // eax@36 | |
5986 int *v19; // edx@38 | |
5987 int v20; // eax@38 | |
5988 unsigned int v21; // ecx@38 | |
5989 int v22; // eax@41 | |
5990 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
5991 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
5992 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
5993 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
5994 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
5995 int v29; // [sp+308h] [bp-4h]@2 | |
5996 | |
5997 pParty->uFlags |= 2u; | |
5998 //v2 = this; | |
5999 flt_6BE3A0 = 0.55000001f; | |
6000 pViewport->_4C02F8(36044); | |
6001 field_40110 = 0; | |
6002 Release(); | |
6003 pColorKeySurface4 = 0; | |
6004 pBackBuffer4 = 0; | |
6005 pFrontBuffer4 = 0; | |
6006 pDirectDraw4 = 0; | |
6007 bColorKeySupported = 0; | |
6008 CreateZBuffer(); | |
6009 if ( bUserDirect3D ) | |
6010 { | |
6011 /*v3 = operator new(0x148u); | |
6012 thisa = (RenderD3D *)v3; | |
6013 v29 = 0; | |
6014 if ( v3 ) | |
6015 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
6016 else | |
6017 v4 = 0;*/ | |
6018 pRenderD3D = new RenderD3D; | |
6019 //v4 = pRenderD3D; | |
6020 //v5 = uDesiredDirect3DDevice; | |
6021 v29 = -1; | |
6022 //v6 = pRenderD3D->pAvailableDevices; | |
6023 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
6024 uDesiredDirect3DDevice != 1 ) | |
6025 { | |
6026 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, hWnd); | |
6027 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
6028 } | |
6029 else | |
6030 { | |
6031 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
6032 Abortf("There aren't any D3D devices to init."); | |
6033 v7 = pRenderD3D->CreateDevice(0, 1, hWnd); | |
6034 uAcquiredDirect3DDevice = 0; | |
6035 } | |
6036 if ( !v7 ) | |
6037 Abortf("D3Drend->Init failed."); | |
6038 | |
6039 //v8 = pRenderD3D; | |
6040 pColorKeySurface4 = 0; | |
6041 pBackBuffer4 = pRenderD3D->pBackBuffer; | |
6042 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
6043 pDirectDraw4 = pRenderD3D->pHost; | |
6044 v9 = pRenderD3D->GetDeviceCaps(); | |
6045 if ( v9 & 1 ) | |
6046 { | |
6047 if (pRenderD3D) | |
6048 { | |
6049 pRenderD3D->Release(); | |
6050 delete pRenderD3D; | |
6051 } | |
6052 pRenderD3D = 0; | |
6053 pBackBuffer4 = 0; | |
6054 pFrontBuffer4 = 0; | |
6055 pDirectDraw4 = 0; | |
6056 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
6057 } | |
6058 if ( v9 & 0x3E ) | |
6059 { | |
6060 if (pRenderD3D) | |
6061 { | |
6062 pRenderD3D->Release(); | |
6063 delete pRenderD3D; | |
6064 } | |
6065 pColorKeySurface4 = 0; | |
6066 pRenderD3D = 0; | |
6067 pBackBuffer4 = 0; | |
6068 pFrontBuffer4 = 0; | |
6069 pDirectDraw4 = 0; | |
6070 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
6071 } | |
6072 if ( (v9 & 0x80u) != 0 ) | |
6073 { | |
6074 if (pRenderD3D) | |
6075 { | |
6076 pRenderD3D->Release(); | |
6077 delete pRenderD3D; | |
6078 } | |
6079 pRenderD3D = 0; | |
6080 pBackBuffer4 = 0; | |
6081 pFrontBuffer4 = 0; | |
6082 pDirectDraw4 = 0; | |
6083 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
6084 } | |
6085 LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; | |
6086 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
6087 memset(&halCaps, 0, 0xFCu); | |
6088 halCaps.dwSize = 252; | |
6089 memset(&refCaps, 0, 0xFCu); | |
6090 //v10 = v2->pRenderD3D; | |
6091 refCaps.dwSize = 252; | |
6092 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
6093 v12 = halCaps.dwMinTextureWidth; | |
6094 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
6095 v12 = halCaps.dwMinTextureHeight; | |
6096 uMinDeviceTextureDim = v12; | |
6097 v13 = halCaps.dwMaxTextureWidth; | |
6098 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
6099 v13 = halCaps.dwMaxTextureHeight; | |
6100 uMaxDeviceTextureDim = v13; | |
6101 CreateSomeTexture(); | |
6102 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
6103 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
6104 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
6105 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
6106 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
6107 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
6108 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
6109 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
6110 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
6111 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
6112 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
6113 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
6114 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
6115 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
6116 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
6117 } | |
6118 else | |
6119 { | |
6120 CreateDirectDraw(); | |
6121 SetDirectDrawCooperationMode(hWnd, 0); | |
6122 field_4004C = 1; | |
6123 CreateFrontBuffer(); | |
6124 CreateClipper(hWnd); | |
6125 CreateBackBuffer(); | |
6126 field_40030 = 0; | |
6127 field_18_locked_pitch = 0; | |
6128 } | |
6129 ddpfPrimareSuface.dwSize = 32; | |
6130 GetTargetPixelFormat(&ddpfPrimareSuface); | |
6131 ParseTargetPixelFormat(); | |
6132 _49EBF1(); | |
6133 if ( !pRenderD3D ) | |
6134 { | |
6135 pBeforePresentFunction = 0;//nullsub_1; | |
6136 goto LABEL_47; | |
6137 } | |
6138 v14 = IsColorKeySupported(pDirectDraw4); | |
6139 v15 = uAcquiredDirect3DDevice == 1; | |
6140 bColorKeySupported = v14; | |
6141 if ( !v15 ) | |
6142 bColorKeySupported = 0; | |
6143 if ( bColorKeySupported ) | |
6144 { | |
6145 memset(&ddsd2, 0, 0x7Cu); | |
6146 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
6147 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
6148 v16 = pDirectDraw4; | |
6149 ddsd2.dwSize = 124; | |
6150 ddsd2.dwFlags = 65543; | |
6151 ddsd2.ddsCaps.dwCaps = 2112; | |
6152 ddsd2.dwWidth = 640; | |
6153 ddsd2.dwHeight = 480; | |
6154 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
6155 pBeforePresentFunction = Present_ColorKey; | |
6156 LABEL_45: | |
6157 field_40110 = 1; | |
6158 LABEL_47: | |
6159 bWindowMode = 1; | |
6160 hWnd = hWnd; | |
6161 return 0; | |
6162 } | |
6163 pTargetSurface = 0; | |
6164 ptr_400E8 = 0; | |
6165 v18 = (int *)new char[0x96020]; | |
6166 memset(v18, -1, 0x96020); | |
6167 ptr_400E8 = v18; | |
6168 if ( v18 ) | |
6169 { | |
6170 memset(&pDesc, 0, 0x7Cu); | |
6171 pDesc.dwSize = 124; | |
168 | 6172 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT) ) |
0 | 6173 { |
6174 pRenderer->pBackBuffer4->Unlock(0); | |
6175 v19 = ptr_400E8; | |
6176 v20 = (unsigned int)pDesc.lpSurface & 7; | |
6177 v21 = (unsigned int)ptr_400E8 & 7; | |
6178 if ( v21 == v20 ) | |
6179 { | |
6180 pTargetSurface = (unsigned __int16 *)v19; | |
6181 } | |
6182 else | |
6183 { | |
6184 if ( (signed int)v21 >= v20 ) | |
6185 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
6186 else | |
6187 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
6188 pTargetSurface = (unsigned __int16 *)v22; | |
6189 } | |
6190 uTargetSurfacePitch = 640; | |
6191 pBeforePresentFunction = Present_NoColorKey; | |
6192 goto LABEL_45; | |
6193 } | |
6194 } | |
6195 return 0; | |
6196 } | |
6197 | |
6198 //----- (004A0BEE) -------------------------------------------------------- | |
709 | 6199 char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor) |
0 | 6200 { |
6201 int v6; // edi@1 | |
6202 int v7; // edx@5 | |
6203 unsigned int v8; // ebx@5 | |
6204 int v9; // eax@7 | |
6205 unsigned int v10; // ecx@9 | |
6206 unsigned int v11; // esi@13 | |
6207 int v12; // eax@17 | |
6208 int v13; // eax@21 | |
6209 Render *v14; // edi@21 | |
6210 int v15; // eax@25 | |
6211 int v16; // eax@27 | |
6212 signed int v17; // eax@28 | |
6213 signed int v18; // edi@30 | |
6214 signed __int64 v19; // qax@41 | |
6215 int v20; // edi@41 | |
6216 unsigned int v21; // edi@46 | |
6217 int v22; // esi@47 | |
6218 int v23; // ebx@47 | |
6219 signed int v24; // edx@50 | |
6220 signed int v25; // esi@52 | |
6221 unsigned __int16 *v26; // ecx@52 | |
6222 int v27; // ebx@54 | |
6223 int v28; // edi@55 | |
6224 int v29; // edx@55 | |
6225 int v30; // ebx@60 | |
6226 int v31; // edx@61 | |
6227 int v32; // edi@61 | |
6228 int v34; // [sp+Ch] [bp-10h]@3 | |
6229 Render *v35; // [sp+10h] [bp-Ch]@1 | |
6230 __int64 v36; // [sp+14h] [bp-8h]@1 | |
6231 signed int v37; // [sp+18h] [bp-4h]@28 | |
6232 unsigned int uXa; // [sp+24h] [bp+8h]@49 | |
6233 unsigned int uYa; // [sp+28h] [bp+Ch]@28 | |
6234 int uYb; // [sp+28h] [bp+Ch]@47 | |
6235 int uZa; // [sp+2Ch] [bp+10h]@38 | |
6236 | |
6237 v36 = 0i64; | |
709 | 6238 v6 = this->raster_clip_x; |
0 | 6239 v35 = this; |
6240 if ( (signed int)uX < v6 ) | |
6241 HIDWORD(v36) = 8; | |
709 | 6242 v34 = this->raster_clip_z; |
6243 if ( (signed int)uX > this->raster_clip_z ) | |
0 | 6244 HIDWORD(v36) |= 4u; |
709 | 6245 v7 = this->raster_clip_y; |
0 | 6246 v8 = uY; |
6247 if ( (signed int)uY < v7 ) | |
6248 HIDWORD(v36) |= 2u; | |
709 | 6249 v9 = this->raster_clip_w; |
0 | 6250 if ( (signed int)uY > v9 ) |
6251 HIDWORD(v36) |= 1u; | |
6252 v10 = uZ; | |
6253 if ( (signed int)uZ < v6 ) | |
6254 LODWORD(v36) = 8; | |
6255 if ( (signed int)uZ > v34 ) | |
6256 LODWORD(v36) = v36 | 4; | |
6257 v11 = uW; | |
6258 if ( (signed int)uW < v7 ) | |
6259 LODWORD(v36) = v36 | 2; | |
6260 if ( (signed int)uW > v9 ) | |
6261 LODWORD(v36) = v36 | 1; | |
6262 LOBYTE(v12) = v36; | |
6263 if ( (unsigned int)v36 & HIDWORD(v36) ) | |
6264 return v12; | |
6265 if ( !v36 ) | |
6266 { | |
6267 LABEL_46: | |
6268 v21 = pRenderer->uTargetSurfacePitch; | |
6269 if ( pRenderer->uTargetSurfacePitch ) | |
6270 { | |
6271 v12 = uX + v8 * pRenderer->uTargetSurfacePitch; | |
6272 v22 = v11 - v8; | |
6273 v23 = v22; | |
6274 uYb = v22; | |
6275 if ( v22 < 0 ) | |
6276 { | |
6277 v23 = -v22; | |
6278 uYb = -v22; | |
6279 v21 = -pRenderer->uTargetSurfacePitch; | |
6280 } | |
6281 uXa = v10 - uX; | |
6282 if ( (uXa & 0x80000000u) == 0 ) | |
6283 { | |
6284 v24 = 1; | |
6285 } | |
6286 else | |
6287 { | |
6288 uXa = -uXa; | |
6289 v24 = -1; | |
6290 } | |
6291 v25 = 0; | |
6292 v26 = v35->pTargetSurface; | |
6293 if ( v26 ) | |
6294 { | |
6295 if ( (signed int)uXa <= v23 ) | |
6296 { | |
6297 v30 = v23 + 1; | |
6298 if ( v30 > 0 ) | |
6299 { | |
6300 v31 = 2 * v24; | |
6301 v32 = 2 * v21; | |
6302 v12 = (int)&v26[v12]; | |
6303 do | |
6304 { | |
6305 v25 += uXa; | |
6306 *(short *)v12 = uColor; | |
6307 v12 += v32; | |
6308 if ( v25 > 0 ) | |
6309 { | |
6310 v25 -= uYb; | |
6311 v12 += v31; | |
6312 } | |
6313 --v30; | |
6314 } | |
6315 while ( v30 ); | |
6316 } | |
6317 } | |
6318 else | |
6319 { | |
6320 v27 = uXa + 1; | |
6321 if ( (signed int)(uXa + 1) > 0 ) | |
6322 { | |
6323 v28 = 2 * v21; | |
6324 v29 = 2 * v24; | |
6325 v12 = (int)&v26[v12]; | |
6326 do | |
6327 { | |
6328 v25 += uYb; | |
6329 *(short *)v12 = uColor; | |
6330 v12 += v29; | |
6331 if ( v25 > (signed int)uXa ) | |
6332 { | |
6333 v25 -= uXa; | |
6334 v12 += v28; | |
6335 } | |
6336 --v27; | |
6337 } | |
6338 while ( v27 ); | |
6339 } | |
6340 } | |
6341 } | |
6342 } | |
6343 return v12; | |
6344 } | |
6345 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 ) | |
6346 { | |
6347 if ( BYTE4(v36) & 8 ) | |
6348 { | |
6349 v13 = (signed int)((uW - uY) * (v6 - uX)) / (signed int)(uZ - uX); | |
6350 v14 = v35; | |
6351 v8 = v13 + uY; | |
709 | 6352 uX = v35->raster_clip_x; |
0 | 6353 goto LABEL_24; |
6354 } | |
6355 v10 = v6; | |
6356 v11 = (signed int)((uY - uW) * (v6 - uZ)) / (signed int)(uX - uZ) + uW; | |
6357 } | |
6358 v14 = v35; | |
6359 LABEL_24: | |
6360 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) | |
6361 { | |
709 | 6362 v15 = v14->raster_clip_z; |
0 | 6363 if ( BYTE4(v36) & 4 ) |
6364 { | |
6365 v14 = v35; | |
6366 v8 += (signed int)((v11 - v8) * (v15 - uX)) / (signed int)(v10 - uX); | |
709 | 6367 uX = v35->raster_clip_z; |
0 | 6368 } |
6369 else | |
6370 { | |
6371 v16 = (signed int)((v8 - v11) * (v15 - v10)) / (signed int)(uX - v10); | |
709 | 6372 v10 = v14->raster_clip_z; |
0 | 6373 v11 += v16; |
6374 } | |
6375 } | |
709 | 6376 v17 = v14->raster_clip_y; |
0 | 6377 v37 = 0; |
709 | 6378 uYa = v14->raster_clip_y; |
0 | 6379 if ( (signed int)v8 < v17 ) |
6380 v37 = 2; | |
709 | 6381 v18 = v14->raster_clip_w; |
0 | 6382 if ( (signed int)v8 > v18 ) |
6383 v37 |= 1u; | |
6384 if ( (signed int)v11 >= v17 ) | |
6385 v12 = 0; | |
6386 else | |
6387 v12 = 2; | |
6388 if ( (signed int)v11 > v18 ) | |
6389 LOBYTE(v12) = v12 | 1; | |
6390 if ( !(v12 & v37) ) | |
6391 { | |
6392 v12 ^= v37; | |
6393 uZa = v12; | |
6394 if ( v12 & 2 ) | |
6395 { | |
6396 if ( v37 & 2 ) | |
6397 { | |
6398 uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8); | |
6399 LOBYTE(v12) = (char)v35; | |
709 | 6400 v8 = v35->raster_clip_y; |
0 | 6401 } |
6402 else | |
6403 { | |
6404 v19 = (signed int)((uX - v10) * (uYa - v11)); | |
6405 v20 = v8 - v11; | |
6406 v11 = uYa; | |
6407 v12 = v19 / v20; | |
6408 v10 += v12; | |
6409 } | |
6410 } | |
6411 if ( uZa & 1 ) | |
6412 { | |
6413 if ( v37 & 1 ) | |
6414 { | |
709 | 6415 uX += (signed int)((v10 - uX) * (v35->raster_clip_w - v8)) / (signed int)(v11 - v8); |
0 | 6416 LOBYTE(v12) = (char)v35; |
709 | 6417 v8 = v35->raster_clip_w; |
0 | 6418 } |
6419 else | |
6420 { | |
709 | 6421 v12 = (signed int)((uX - v10) * (v35->raster_clip_w - v11)) / (signed int)(v8 - v11); |
6422 v11 = v35->raster_clip_w; | |
0 | 6423 v10 += v12; |
6424 } | |
6425 } | |
6426 goto LABEL_46; | |
6427 } | |
6428 return v12; | |
6429 } | |
6430 | |
6431 //----- (004A0E80) -------------------------------------------------------- | |
6432 void Render::ClearZBuffer(int a2, int a3) | |
6433 { | |
6434 memset32(this->pActiveZBuffer, -65536, 0x4B000u); | |
6435 } | |
6436 | |
6437 //----- (004A0E97) -------------------------------------------------------- | |
709 | 6438 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
6439 { | |
6440 this->raster_clip_x = uX; | |
6441 this->raster_clip_y = uY; | |
6442 this->raster_clip_z = uZ; | |
6443 this->raster_clip_w = uW; | |
0 | 6444 } |
6445 | |
6446 //----- (004A0EB6) -------------------------------------------------------- | |
6447 void Render::ParseTargetPixelFormat() | |
6448 { | |
6449 Render *v1; // eax@1 | |
6450 signed int v2; // ecx@1 | |
6451 DWORD uRedMask; // edx@1 | |
6452 unsigned int uGreenMask; // esi@5 | |
6453 signed int v5; // ecx@5 | |
6454 unsigned int uBlueMask; // edx@9 | |
6455 signed int v7; // ecx@9 | |
6456 unsigned int v8; // ecx@13 | |
6457 | |
6458 v1 = this; | |
6459 v2 = 0; | |
6460 uRedMask = v1->ddpfPrimareSuface.dwRBitMask; | |
6461 v1->uTargetBBits = 0; | |
6462 v1->uTargetGBits = 0; | |
6463 v1->uTargetRBits = 0; | |
6464 do | |
6465 { | |
6466 if ( (1 << v2) & uRedMask ) | |
6467 ++v1->uTargetRBits; | |
6468 ++v2; | |
6469 } | |
6470 while ( v2 < 16 ); | |
6471 uGreenMask = v1->ddpfPrimareSuface.dwGBitMask; | |
6472 v5 = 0; | |
6473 do | |
6474 { | |
6475 if ( (1 << v5) & uGreenMask ) | |
6476 ++v1->uTargetGBits; | |
6477 ++v5; | |
6478 } | |
6479 while ( v5 < 16 ); | |
6480 uBlueMask = v1->ddpfPrimareSuface.dwBBitMask; | |
6481 v7 = 0; | |
6482 do | |
6483 { | |
6484 if ( (1 << v7) & uBlueMask ) | |
6485 ++v1->uTargetBBits; | |
6486 ++v7; | |
6487 } | |
6488 while ( v7 < 16 ); | |
6489 v8 = v1->ddpfPrimareSuface.dwRBitMask; | |
6490 v1->uTargetGMask = uGreenMask; | |
6491 v1->uTargetRMask = v8; | |
6492 v1->uTargetBMask = uBlueMask; | |
6493 } | |
6494 | |
6495 //----- (004A0F40) -------------------------------------------------------- | |
6496 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
6497 { | |
6498 IDirectDrawSurface4 *v4; // esi@1 | |
168 | 6499 HRESULT result; // eax@1 |
0 | 6500 HRESULT v6; // eax@4 |
6501 int v7; // [sp-8h] [bp-14h]@10 | |
6502 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
6503 char v9; // [sp+Bh] [bp-1h]@1 | |
6504 | |
6505 v4 = pSurface; | |
6506 v9 = 1; | |
6507 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
6508 if ( result == DDERR_SURFACELOST ) | |
6509 { | |
6510 if (pAsyncMouse) | |
6511 pAsyncMouse->Suspend(); | |
6512 v6 = v4->Restore(); | |
6513 if ( v6 ) | |
6514 { | |
6515 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
6516 { | |
6517 LABEL_20: | |
6518 v9 = 0; | |
6519 result = (bool)memset(pDesc, 0, 4u); | |
6520 goto LABEL_21; | |
6521 } | |
6522 pRenderer->pFrontBuffer4->Restore(); | |
6523 v4->Restore(); | |
6524 } | |
6525 result = v4->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
6526 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
6527 goto LABEL_20; | |
6528 ErrD3D(result); | |
6529 if ( result ) | |
6530 { | |
6531 //v8 = 0; | |
6532 //v7 = 2161; | |
6533 LABEL_19: | |
6534 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
6535 goto LABEL_20; | |
6536 } | |
6537 if ( pRenderer->pRenderD3D ) | |
6538 pRenderD3D->HandleLostResources(); | |
6539 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
6540 if (pAsyncMouse) | |
6541 pAsyncMouse->Resume(); | |
6542 } | |
6543 else | |
6544 { | |
6545 if ( result ) | |
6546 { | |
6547 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
6548 goto LABEL_20; | |
6549 ErrD3D(result); | |
6550 //v8 = 0; | |
6551 //v7 = 2199; | |
6552 //goto LABEL_19; | |
6553 } | |
6554 } | |
6555 LABEL_21: | |
6556 LOBYTE(result) = v9; | |
6557 return result; | |
6558 } | |
6559 | |
6560 //----- (004A1032) -------------------------------------------------------- | |
6561 bool Render::LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags) | |
6562 { | |
6563 IDirectDrawSurface2 *v4; // esi@1 | |
6564 bool v5; // eax@1 | |
6565 HRESULT v6; // eax@2 | |
6566 int v7; // [sp-8h] [bp-10h]@8 | |
6567 unsigned int v8; // [sp-4h] [bp-Ch]@8 | |
6568 | |
6569 v4 = pSurface; | |
6570 v5 = pSurface->Lock( | |
6571 0, | |
6572 pDesc, | |
6573 uLockFlags, | |
6574 0); | |
6575 BYTE3(pSurface) = 1; | |
6576 if ( v5 == DDERR_SURFACELOST ) | |
6577 { | |
6578 v6 = v4->Restore(); | |
6579 if ( !v6 ) | |
6580 goto LABEL_5; | |
6581 if ( v6 == DDERR_IMPLICITLYCREATED ) | |
6582 { | |
6583 pRenderer->pFrontBuffer2->Restore(); | |
6584 v4->Restore(); | |
6585 LABEL_5: | |
6586 v5 = v4->Lock(0, pDesc, 1u, 0) != 0; | |
6587 if ( v5 == DDERR_INVALIDRECT || v5 == DDERR_SURFACEBUSY ) | |
6588 goto LABEL_14; | |
6589 if ( !v5 ) | |
6590 return true; | |
6591 ErrD3D(v5); | |
6592 //v8 = 0; | |
6593 //v7 = 2247; | |
6594 goto LABEL_13; | |
6595 } | |
6596 else | |
6597 { | |
6598 pDesc->dwSize = 0; | |
6599 return false; | |
6600 } | |
6601 } | |
6602 else | |
6603 { | |
6604 if ( !v5 ) | |
6605 return true; | |
6606 if ( v5 != DDERR_INVALIDRECT && v5 != DDERR_SURFACEBUSY ) | |
6607 { | |
6608 //v8 = 0; | |
6609 //v7 = 2269; | |
6610 ErrD3D(v5); | |
6611 pDesc->dwSize = 0; | |
6612 return false; | |
6613 LABEL_13: | |
6614 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, v5, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
6615 goto LABEL_14; | |
6616 } | |
6617 } | |
6618 LABEL_14: | |
6619 return true; | |
6620 } | |
6621 | |
6622 //----- (004A10E4) -------------------------------------------------------- | |
6623 void Render::CreateDirectDraw() | |
6624 { | |
6625 Render *v1; // edi@1 | |
6626 HRESULT v2; // eax@1 | |
6627 HRESULT v3; // eax@5 | |
6628 int v6; // [sp-Ch] [bp-20h]@3 | |
6629 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
6630 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
6631 | |
6632 v1 = this; | |
6633 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
6634 | |
6635 pDirectDraw2 = nullptr; | |
6636 pDirectDraw4 = nullptr; | |
6637 | |
6638 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6639 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); | |
6640 else | |
6641 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); | |
6642 | |
6643 lpDD->Release(); | |
6644 lpDD = nullptr; | |
6645 } | |
6646 | |
6647 //----- (004A1169) -------------------------------------------------------- | |
6648 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
6649 { | |
6650 DWORD flags; // eax@1 | |
6651 IDirectDraw *v4; // ecx@3 | |
6652 HRESULT v5; // eax@5 | |
6653 int v6; // [sp-8h] [bp-8h]@3 | |
6654 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
6655 | |
6656 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
6657 DDSCL_NORMAL; | |
6658 | |
6659 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6660 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); | |
6661 else | |
6662 ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); | |
6663 } | |
6664 | |
6665 //----- (004A11C6) -------------------------------------------------------- | |
6666 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
6667 { | |
6668 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6669 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
6670 else | |
6671 ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
6672 } | |
6673 | |
6674 //----- (004A121C) -------------------------------------------------------- | |
6675 void Render::CreateFrontBuffer() | |
6676 { | |
6677 Render *v1; // esi@1 | |
6678 IDirectDraw *pDD; // eax@3 | |
6679 IDirectDrawSurface **pOutSurf; // esi@3 | |
6680 struct _DDSURFACEDESC *v4; // edx@3 | |
6681 HRESULT v5; // eax@5 | |
6682 int v6; // [sp-8h] [bp-8Ch]@3 | |
6683 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
6684 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
6685 | |
6686 v1 = this; | |
6687 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6688 { | |
6689 memset(&a2, 0, 0x7Cu); | |
6690 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
6691 a2.dwSize = 124; | |
6692 a2.dwFlags = 1; | |
6693 v7 = 0; | |
6694 a2.ddsCaps.dwCaps = 512; | |
6695 v6 = 2357; | |
6696 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
6697 v4 = (struct _DDSURFACEDESC *)&a2; | |
6698 } | |
6699 else | |
6700 { | |
6701 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
6702 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
6703 a2.lPitch = 108; | |
6704 a2.dwBackBufferCount = 1; | |
6705 v7 = 0; | |
6706 a2.dwTextureStage = 512; | |
6707 v6 = 2346; | |
6708 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
6709 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
6710 } | |
6711 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); | |
6712 } | |
6713 | |
6714 //----- (004A12CD) -------------------------------------------------------- | |
6715 void Render::CreateBackBuffer() | |
6716 { | |
6717 Render *v1; // esi@1 | |
6718 IDirectDraw *v2; // eax@3 | |
6719 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
6720 struct _DDSURFACEDESC *v4; // edx@3 | |
6721 HRESULT v5; // eax@5 | |
6722 int v6; // [sp-8h] [bp-8Ch]@3 | |
6723 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
6724 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
6725 | |
6726 v1 = this; | |
6727 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6728 { | |
6729 memset(&a2, 0, 0x7Cu); | |
6730 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
6731 a2.dwSize = 124; | |
6732 a2.dwFlags = 7; | |
6733 v7 = 0; | |
6734 a2.ddsCaps.dwCaps = 2112; | |
6735 a2.dwWidth = 640; | |
6736 a2.dwHeight = 480; | |
6737 v6 = 2387; | |
6738 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
6739 v4 = (struct _DDSURFACEDESC *)&a2; | |
6740 } | |
6741 else | |
6742 { | |
6743 memset(&a2.lPitch, 0, 0x6Cu); | |
6744 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
6745 a2.lPitch = 108; | |
6746 a2.dwBackBufferCount = 7; | |
6747 v7 = 0; | |
6748 a2.dwTextureStage = 2112; | |
6749 a2.dwAlphaBitDepth = 640; | |
6750 a2.dwMipMapCount = 480; | |
6751 v6 = 2374; | |
6752 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
6753 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
6754 } | |
6755 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); | |
6756 } | |
6757 | |
6758 //----- (004A139A) -------------------------------------------------------- | |
6759 void Render::CreateDirectDrawPrimarySurface() | |
6760 { | |
6761 Render *v1; // esi@1 | |
6762 int v2; // ebx@3 | |
6763 IDirectDraw2 *v3; // eax@3 | |
6764 HRESULT v4; // eax@3 | |
6765 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
6766 DDSCAPS2 *v6; // edx@3 | |
6767 IDirectDraw4 *v7; // eax@4 | |
6768 HRESULT v8; // eax@4 | |
6769 int v9; // ST14_4@5 | |
6770 IDirectDrawSurface *v10; // ST10_4@5 | |
6771 HRESULT v11; // eax@5 | |
6772 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
6773 const char *v13; // [sp+0h] [bp-A0h]@0 | |
6774 int v14; // [sp+4h] [bp-9Ch]@0 | |
6775 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
6776 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
6777 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
6778 int a4; // [sp+98h] [bp-8h]@3 | |
6779 | |
6780 v1 = this; | |
6781 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6782 { | |
6783 v2 = 0; | |
6784 this->field_4004C = 1; | |
6785 memset(&ddsd2, 0, 0x7Cu); | |
6786 v7 = v1->pDirectDraw4; | |
6787 ddsd2.dwBackBufferCount = 1; | |
6788 ddsd2.dwSize = 0x7Cu; | |
6789 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
6790 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
6791 ErrD3D(v7->CreateSurface( | |
6792 &ddsd2, | |
6793 &pFrontBuffer4, | |
6794 0)); | |
6795 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
6796 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
6797 } | |
6798 else | |
6799 { | |
6800 v2 = 0; | |
6801 this->field_4004C = 1; | |
6802 | |
6803 DDSURFACEDESC ddsd; | |
6804 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
6805 | |
6806 ddsd.lpSurface = (LPVOID)1; | |
6807 ddsd.lPitch = 108; | |
6808 ddsd.dwBackBufferCount = 33; | |
6809 ddsd.ddsCaps.dwCaps = 8728; | |
6810 ErrD3D(pDirectDraw2->CreateSurface( | |
6811 &ddsd, | |
6812 (IDirectDrawSurface **)&pFrontBuffer2, | |
6813 0)); | |
6814 | |
6815 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
6816 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
6817 } | |
6818 v9 = (int)v6; | |
6819 v10 = pFrontBuffer; // BUG | |
6820 | |
6821 v17.dwCaps = 4; | |
6822 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
6823 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
6824 v1->field_40030 = v2; | |
6825 v1->field_18_locked_pitch = v2; | |
6826 } | |
6827 | |
6828 //----- (004A14F4) -------------------------------------------------------- | |
6829 void Render::CreateClipper(HWND a2) | |
6830 { | |
6831 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6832 { | |
6833 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); | |
6834 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
6835 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
6836 } | |
6837 else | |
6838 { | |
6839 ErrD3D(pDirectDraw2->CreateClipper(0, &pDDrawClipper, 0)); | |
6840 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
6841 } | |
6842 } | |
6843 | |
6844 //----- (004A15D8) -------------------------------------------------------- | |
6845 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
6846 { | |
6847 IDirectDrawSurface *v2; // eax@3 | |
6848 | |
6849 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6850 v2 = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6851 else | |
6852 v2 = (IDirectDrawSurface *)this->pFrontBuffer2; | |
6853 v2->GetPixelFormat(pOut); | |
6854 } | |
6855 | |
6856 //----- (004A1605) -------------------------------------------------------- | |
6857 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
6858 { | |
6859 Render *v3; // esi@1 | |
6860 signed int v4; // eax@3 | |
6861 | |
6862 v3 = this; | |
6863 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6864 { | |
6865 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
6866 memset(&pDesc, 0, 0x7Cu); | |
6867 pDesc.dwSize = 124; | |
168 | 6868 LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 6869 *pOutSurfacePtr = pDesc.lpSurface; |
6870 v4 = pDesc.lPitch; | |
6871 } | |
6872 else | |
6873 { | |
6874 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
6875 memset(&pDesc.lPitch, 0, 0x6Cu); | |
6876 pDesc.lPitch = 108; | |
6877 LockSurface_DDraw2(v3->pBackBuffer2, &pDesc, 1u); | |
6878 *pOutSurfacePtr = (void *)pDesc.lpSurface; | |
6879 v4 = pDesc.dwReserved; | |
6880 } | |
6881 *pOutPixelsPerRow = v4 >> 1; | |
6882 } | |
6883 | |
6884 //----- (004A169E) -------------------------------------------------------- | |
6885 bool Render::UsingDirect3D() | |
6886 { | |
6887 return bUserDirect3D == 0; | |
6888 } | |
6889 | |
6890 //----- (004A16E1) -------------------------------------------------------- | |
6891 void Render::UnlockBackBuffer() | |
6892 { | |
6893 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6894 ErrD3D(pBackBuffer4->Unlock(0)); | |
6895 else | |
6896 ErrD3D(pBackBuffer2->Unlock(0)); | |
6897 } | |
6898 | |
6899 //----- (004A172E) -------------------------------------------------------- | |
6900 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
6901 { | |
6902 Render *v3; // esi@1 | |
6903 signed int v4; // eax@3 | |
6904 | |
6905 v3 = this; | |
6906 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6907 { | |
6908 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
6909 memset(&pDesc, 0, 0x7Cu); | |
6910 pDesc.dwSize = 124; | |
168 | 6911 LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 6912 *pOutSurface = pDesc.lpSurface; |
6913 v4 = pDesc.lPitch; | |
6914 } | |
6915 else | |
6916 { | |
6917 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
6918 memset(&pDesc.lPitch, 0, 0x6Cu); | |
6919 pDesc.lPitch = 108; | |
6920 LockSurface_DDraw2(v3->pFrontBuffer2, &pDesc, 1u); | |
6921 *pOutSurface = (void *)pDesc.lpSurface; | |
6922 v4 = pDesc.dwReserved; | |
6923 } | |
6924 *pOutPixelsPerRow = v4 >> 1; | |
6925 } | |
6926 | |
6927 //----- (004A17C7) -------------------------------------------------------- | |
6928 void Render::UnlockFrontBuffer() | |
6929 { | |
6930 IDirectDrawSurface *pFront; // eax@3 | |
6931 HRESULT v2; // eax@5 | |
6932 signed int v3; // [sp-8h] [bp-Ch]@3 | |
6933 int v4; // [sp-4h] [bp-8h]@3 | |
6934 | |
6935 auto a5 = this; | |
6936 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6937 { | |
6938 pFront = (IDirectDrawSurface *)a5->pFrontBuffer4; | |
6939 v4 = 0; | |
6940 v3 = 2615; | |
6941 } | |
6942 else | |
6943 { | |
6944 pFront = (IDirectDrawSurface *)a5->pFrontBuffer2; | |
6945 v4 = 0; | |
6946 v3 = 2611; | |
6947 } | |
6948 ErrD3D(pFront->Unlock(0)); | |
6949 } | |
6950 | |
6951 //----- (004A1814) -------------------------------------------------------- | |
6952 void Render::RestoreFrontBuffer() | |
6953 { | |
6954 IDirectDrawSurface **v1; // esi@2 | |
6955 | |
6956 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
6957 || (v1 = (IDirectDrawSurface **)&this->pFrontBuffer2, pVersion->pVersionInfo.dwMajorVersion >= 5u) ) | |
6958 v1 = (IDirectDrawSurface **)&this->pFrontBuffer4; | |
6959 if ( (*v1)->IsLost() == DDERR_SURFACELOST ) | |
6960 (*v1)->Restore(); | |
6961 } | |
6962 | |
6963 //----- (004A184C) -------------------------------------------------------- | |
6964 HRESULT Render::_4A184C() | |
6965 { | |
6966 IDirectDrawSurface **pBack; // esi@2 | |
6967 HRESULT result; // eax@4 | |
6968 | |
6969 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
6970 || (pBack = (IDirectDrawSurface **)&this->pBackBuffer2, pVersion->pVersionInfo.dwMajorVersion != 4) ) | |
6971 pBack = (IDirectDrawSurface **)&this->pBackBuffer4; | |
6972 result = (*pBack)->IsLost(); | |
6973 if ( result == DDERR_SURFACELOST ) | |
6974 result = (*pBack)->Restore(); | |
6975 return result; | |
6976 } | |
6977 | |
6978 //----- (004A1884) -------------------------------------------------------- | |
6979 void Render::PresentRect(RECT *a2, RECT *a3) | |
6980 { | |
6981 IDirectDrawSurface *pFront; // eax@3 | |
6982 HRESULT v4; // eax@5 | |
6983 IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3 | |
6984 struct tagRECT *v6; // [sp-18h] [bp-18h]@3 | |
6985 DWORD v7; // [sp-14h] [bp-14h]@3 | |
6986 DDBLTFX *v8; // [sp-10h] [bp-10h]@3 | |
6987 const char *v9; // [sp-Ch] [bp-Ch]@3 | |
6988 int v10; // [sp-8h] [bp-8h]@3 | |
6989 unsigned int v11; // [sp-4h] [bp-4h]@3 | |
6990 | |
6991 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6992 { | |
6993 v11 = 0; | |
6994 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6995 v10 = 2657; | |
6996 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
6997 v8 = 0; | |
6998 v7 = DDBLT_WAIT; | |
6999 v6 = a3; | |
7000 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
7001 } | |
7002 else | |
7003 { | |
7004 v11 = 0; | |
7005 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
7006 v10 = 2653; | |
7007 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
7008 v8 = 0; | |
7009 v7 = DDBLT_WAIT; | |
7010 v6 = a3; | |
7011 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
7012 } | |
7013 ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8)); | |
7014 } | |
7015 | |
7016 //----- (004A18F5) -------------------------------------------------------- | |
7017 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
7018 { | |
7019 IDirectDrawSurface *pFront; // eax@3 | |
7020 HRESULT v6; // eax@5 | |
7021 int v7; // [sp-8h] [bp-8h]@3 | |
7022 unsigned int v8; // [sp-4h] [bp-4h]@3 | |
7023 | |
7024 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) | |
7025 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
7026 else | |
7027 ErrD3D(pFrontBuffer2->Blt(pDstRect, (IDirectDrawSurface2 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
7028 } | |
7029 | |
7030 //----- (004A194A) -------------------------------------------------------- | |
7031 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
7032 { | |
7033 IDirectDrawSurface *pFront; // eax@3 | |
7034 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
7035 | |
7036 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
7037 { | |
7038 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
7039 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
7040 } | |
7041 else | |
7042 { | |
7043 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
7044 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
7045 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7046 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 7047 } |
7048 | |
7049 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7050 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7051 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7052 //unsigned int v2; // ebx@1 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7053 //double v4; // st7@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7054 //unsigned int v5; // esi@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7055 //int v6; // ecx@5 |
0 | 7056 unsigned int v7; // edx@6 |
7057 char *v8; // ecx@12 | |
7058 void *v9; // edi@16 | |
7059 unsigned int v10; // eax@16 | |
7060 void *v11; // edi@21 | |
7061 unsigned int v12; // eax@21 | |
7062 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7063 //v2 = uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7064 if (uNumBillboardsToDraw >= 999 ) |
0 | 7065 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7066 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7067 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7068 uNumBillboardsToDraw = 1; |
0 | 7069 return 0; |
7070 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7071 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7072 //v4 = *(float *)&a1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7073 //v5 = pRenderer->uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7074 //v6 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7075 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7076 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7077 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7078 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7079 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7080 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7081 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7082 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7083 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7084 v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].z_order; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7085 if (z > *(float *)v8 ) |
0 | 7086 { |
7087 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
7088 { | |
7089 v7 = pRenderer->uNumBillboardsToDraw; | |
7090 } | |
7091 else | |
7092 { | |
7093 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
7094 { | |
7095 v9 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
7096 v10 = pRenderer->uNumBillboardsToDraw - v7; | |
7097 do | |
7098 { | |
7099 memcpy(v9, (char *)v9 - 156, 0x9Cu); | |
7100 v9 = (char *)v9 - 156; | |
7101 --v10; | |
7102 } | |
7103 while ( v10 ); | |
7104 } | |
7105 ++v7; | |
7106 } | |
717 | 7107 //LABEL_23: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7108 uNumBillboardsToDraw++; |
0 | 7109 return v7; |
7110 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7111 if (z <= *(float *)v8 ) |
0 | 7112 { |
7113 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
7114 { | |
7115 v11 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
7116 v12 = pRenderer->uNumBillboardsToDraw - v7; | |
7117 do | |
7118 { | |
7119 memcpy(v11, (char *)v11 - 156, 0x9Cu); | |
7120 v11 = (char *)v11 - 156; | |
7121 --v12; | |
7122 } | |
7123 while ( v12 ); | |
7124 } | |
717 | 7125 //goto LABEL_23; |
7126 uNumBillboardsToDraw++; | |
7127 return v7; | |
0 | 7128 } |
7129 return v7; | |
7130 } | |
7131 | |
7132 //----- (004A1E9D) -------------------------------------------------------- | |
7133 unsigned int Render::GetBillboardDrawListSize() | |
7134 { | |
7135 return pRenderer->uNumBillboardsToDraw; | |
7136 } | |
7137 | |
7138 //----- (004A1EA3) -------------------------------------------------------- | |
7139 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
7140 { | |
7141 return pRenderer->pBillboardRenderListD3D[uBillboardID].uParentBillboardID; | |
7142 } | |
7143 | |
7144 //----- (004A1EB6) -------------------------------------------------------- | |
7145 void Render::BeginSceneD3D() | |
7146 { | |
7147 if (!uNumD3DSceneBegins++) | |
7148 { | |
7149 if (pRenderD3D) | |
7150 { | |
7151 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
7152 pRenderer->uNumBillboardsToDraw = 0; | |
7153 pRenderD3D->pDevice->BeginScene(); | |
7154 if (!pRenderD3D->DoesRaiseExceptions()) | |
7155 { | |
7156 MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0); | |
7157 } | |
7158 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
7159 uFogColor = GetLevelFogColor(); | |
7160 else | |
7161 uFogColor = 0; | |
7162 | |
7163 if ( uFogColor & 0xFF000000 ) | |
7164 { | |
7165 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
7166 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
7167 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
7168 bUsingSpecular = true; | |
7169 } | |
7170 else | |
7171 { | |
7172 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
7173 bUsingSpecular = 0; | |
7174 } | |
7175 } | |
7176 else | |
7177 { | |
7178 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
7179 if (pTargetSurface) | |
7180 field_18_locked_pitch = uTargetSurfacePitch; | |
7181 else | |
7182 --uNumD3DSceneBegins; | |
7183 } | |
7184 } | |
7185 } | |
7186 | |
7187 //----- (004A1FE1) -------------------------------------------------------- | |
7188 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
7189 { | |
7190 --uNumD3DSceneBegins; | |
7191 if (uNumD3DSceneBegins) | |
7192 return; | |
7193 | |
7194 if (pRenderD3D) | |
7195 { | |
7196 pGame->draw_debug_outlines(); | |
161 | 7197 DoRenderBillboards_D3D(); |
0 | 7198 pGame->pStru6Instance->RenderSpecialEffects(); |
7199 pRenderD3D->pDevice->EndScene(); | |
7200 } | |
7201 else | |
7202 pGame->pStru6Instance->RenderSpecialEffects(); | |
7203 } | |
7204 | |
7205 //----- (004A2031) -------------------------------------------------------- | |
349 | 7206 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
7207 { | |
638 | 7208 __debugbreak(); // should not fire outside decal builder |
349 | 7209 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 7210 } |
7211 | |
186 | 7212 /*void Render::DrawTerrainPolygon_new(stru148 *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 7213 { |
7214 int v5; // ebx@1 | |
7215 int v6; // edi@1 | |
7216 int v8; // eax@7 | |
7217 float v9; // eax@12 | |
7218 float *v10; // esi@12 | |
7219 float v11; // ecx@14 | |
7220 double v12; // st7@14 | |
7221 double v13; // st7@14 | |
7222 double v14; // st7@14 | |
7223 signed int v15; // eax@14 | |
7224 int v16; // eax@15 | |
7225 float v17; // ST48_4@15 | |
7226 char v18; // zf@17 | |
7227 int v19; // eax@18 | |
7228 int v20; // eax@18 | |
7229 int v21; // edx@20 | |
7230 signed int v22; // ecx@20 | |
7231 int v23; // eax@20 | |
7232 const char *v24; // ST4C_4@20 | |
7233 unsigned int v25; // ST50_4@20 | |
7234 int v26; // ST54_4@20 | |
7235 int v27; // eax@20 | |
7236 _UNKNOWN *v28; // eax@21 | |
7237 int v29; // ecx@23 | |
7238 int v30; // eax@23 | |
7239 int v31; // eax@23 | |
7240 int v32; // eax@24 | |
7241 int v33; // eax@25 | |
7242 int v34; // eax@25 | |
7243 int v35; // eax@25 | |
7244 int v36; // eax@25 | |
7245 signed int v37; // ecx@26 | |
7246 int v38; // eax@26 | |
7247 _UNKNOWN *v39; // eax@27 | |
7248 int v40; // edx@28 | |
7249 int v41; // eax@29 | |
7250 int v42; // eax@29 | |
7251 int v43; // eax@29 | |
7252 int v44; // eax@29 | |
7253 unsigned int v46; // eax@29 | |
7254 int v47; // eax@30 | |
7255 int v48; // eax@30 | |
7256 int v49; // eax@30 | |
7257 double v52; // st6@35 | |
7258 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
7259 int v57; // [sp+5Ch] [bp-Ch]@3 | |
7260 signed int v59; // [sp+60h] [bp-8h]@12 | |
7261 int v61; // [sp+64h] [bp-4h]@4 | |
7262 int i; | |
7263 | |
7264 v6 = (int)this; | |
7265 v5 = 0; | |
7266 if (!this->uNumD3DSceneBegins) | |
7267 return; | |
7268 | |
7269 | |
7270 | |
7271 | |
186 | 7272 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 7273 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
7274 if (this->bUsingSpecular) | |
7275 { | |
186 | 7276 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
7277 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
7278 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 7279 } |
7280 | |
7281 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
7282 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
7283 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7284 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); | |
7285 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
7286 pVertices[0].specular = 0; | |
7287 pVertices[0].texcoord.x = array_50AC10[0].u; | |
7288 pVertices[0].texcoord.y = array_50AC10[0].v; | |
7289 | |
7290 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
7291 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
7292 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7293 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); | |
7294 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
7295 pVertices[1].specular = 0; | |
7296 pVertices[1].texcoord.x = array_50AC10[3].u; | |
7297 pVertices[1].texcoord.y = array_50AC10[3].v; | |
7298 | |
7299 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
7300 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
7301 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7302 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); | |
7303 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
7304 pVertices[2].specular = 0; | |
7305 pVertices[2].texcoord.x = array_50AC10[1].u; | |
7306 pVertices[2].texcoord.y = array_50AC10[1].v; | |
7307 | |
7308 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
7309 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
7310 | |
7311 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
7312 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
7313 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7314 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); | |
7315 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
7316 pVertices[5].specular = 0; | |
7317 pVertices[5].texcoord.x = array_50AC10[2].u; | |
7318 pVertices[5].texcoord.y = array_50AC10[2].v; | |
7319 | |
7320 | |
7321 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7322 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
7323 | |
186 | 7324 }*/ |
7325 | |
0 | 7326 //----- (004A26BC) -------------------------------------------------------- |
186 | 7327 void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
7328 { | |
7329 //RenderVertexSoft *pVertices; // esi@0 | |
7330 //int v7; // edi@1 | |
0 | 7331 unsigned int v8; // ebx@1 |
7332 LightmapBuilder *v9; // esi@3 | |
7333 unsigned int v10; // edx@3 | |
7334 int v11; // eax@5 | |
7335 int v12; // eax@11 | |
7336 char *v13; // esi@11 | |
7337 double v14; // st7@13 | |
7338 double v15; // st7@13 | |
7339 signed int v16; // eax@13 | |
7340 int v17; // ecx@13 | |
7341 double v18; // st7@13 | |
7342 float v19; // ST78_4@14 | |
7343 int v20; // eax@14 | |
7344 char v21; // zf@16 | |
7345 HRESULT v22; // eax@17 | |
7346 HRESULT v23; // eax@17 | |
7347 HRESULT v24; // eax@19 | |
7348 HRESULT v25; // eax@19 | |
7349 unsigned int v26; // ecx@19 | |
7350 char *v27; // eax@20 | |
7351 HRESULT v28; // eax@22 | |
7352 HRESULT v29; // eax@22 | |
7353 HRESULT v30; // eax@23 | |
7354 HRESULT v31; // eax@24 | |
7355 HRESULT v32; // eax@24 | |
7356 HRESULT v33; // eax@24 | |
7357 HRESULT v34; // eax@24 | |
7358 HRESULT v35; // eax@25 | |
7359 HRESULT v36; // eax@25 | |
7360 unsigned int v37; // ecx@25 | |
7361 char *v38; // eax@26 | |
7362 int v39; // edx@27 | |
7363 HRESULT v40; // eax@28 | |
7364 HRESULT v41; // eax@28 | |
7365 HRESULT v42; // eax@28 | |
7366 HRESULT v43; // eax@28 | |
7367 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
7368 unsigned int v45; // eax@28 | |
7369 HRESULT v46; // eax@29 | |
7370 HRESULT v47; // eax@29 | |
7371 HRESULT v48; // eax@29 | |
186 | 7372 //IDirect3DDevice3 *v49; // eax@35 |
0 | 7373 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
7374 int v51; // eax@40 | |
7375 char *v52; // esi@40 | |
7376 double v53; // st7@42 | |
7377 double v54; // st7@42 | |
7378 signed int v55; // eax@42 | |
7379 int v56; // ecx@42 | |
7380 double v57; // st7@42 | |
7381 float v58; // ST7C_4@43 | |
7382 int v59; // eax@43 | |
186 | 7383 //signed int v60; // [sp+78h] [bp-14h]@31 |
7384 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
0 | 7385 const char *v62; // [sp+80h] [bp-Ch]@0 |
7386 const char *v63; // [sp+80h] [bp-Ch]@19 | |
7387 int v64; // [sp+84h] [bp-8h]@0 | |
7388 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
7389 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
7390 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
186 | 7391 int a7; |
7392 | |
7393 //v7 = (int)this; | |
0 | 7394 v8 = 0; |
186 | 7395 if (!this->uNumD3DSceneBegins) |
75 | 7396 return; |
7397 if ( uNumVertices < 3) | |
7398 return; | |
7399 | |
186 | 7400 //v61 = pVertices; |
7401 | |
75 | 7402 /* v9 = pGame->pLightmapBuilder; |
0 | 7403 v65 = v9; |
75 | 7404 v10 = v9->std__vector_000004_size;*/ |
0 | 7405 if ( byte_4D864C && pGame->uFlags & 1 ) |
7406 { | |
638 | 7407 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
75 | 7408 pGame->pLightmapBuilder->_45D74F_MessWithLight(v11, 0); |
0 | 7409 } |
7410 else | |
7411 { | |
186 | 7412 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 7413 byte_4D864C && pGame->uFlags & 2 ) |
7414 { | |
186 | 7415 if (clampAtTextureBorders) |
7416 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 7417 else |
186 | 7418 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
7419 | |
7420 if (transparent || this->bUsingSpecular) | |
7421 { | |
7422 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
7423 if (transparent) | |
0 | 7424 { |
186 | 7425 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
7426 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
7427 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
7428 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 7429 } |
7430 else | |
7431 { | |
186 | 7432 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
7433 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 7434 } |
186 | 7435 } |
7436 if (uNumVertices > 0) | |
7437 { | |
7438 v51 = (int)&d3d_vertex_buffer[0].pos.y; | |
0 | 7439 v52 = (char *)&array_50AC10[0].vWorldViewPosition; |
186 | 7440 a7 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 7441 v66 = uNumVertices; |
7442 while ( 1 ) | |
7443 { | |
7444 v53 = *(float *)v52 * 1000.0; | |
7445 *(int *)(v51 - 4) = *((int *)v52 + 3); | |
7446 v54 = v53 / (double)pOutdoorCamera->shading_dist_mist; | |
7447 *(int *)v51 = *((int *)v52 + 4); | |
7448 *(float *)(v51 + 4) = 1.0 - 1.0 / v54; | |
7449 *(float *)(v51 + 8) = 1.0 / (*(float *)v52 + 0.0000001); | |
638 | 7450 v55 = ::GetActorTintColor(a4->dimming_level, 0, *(float *)v52, 0, 0); |
0 | 7451 v56 = a7; |
7452 v57 = *(float *)v52; | |
7453 *(int *)(a7 + 12) = v55; | |
75 | 7454 if ( this->bUsingSpecular ) |
0 | 7455 { |
7456 v58 = v57; | |
7457 v59 = sub_47C3D7_get_fog_related_stuff(0, 0, v58); | |
7458 v56 = a7; | |
7459 } | |
7460 else | |
7461 { | |
7462 v59 = 0; | |
7463 } | |
7464 *(int *)(v56 + 16) = v59; | |
7465 *(int *)(v56 + 20) = *((int *)v52 + 6); | |
7466 *(int *)(v56 + 24) = *((int *)v52 + 7); | |
7467 v52 += 48; | |
7468 v21 = v66-- == 1; | |
7469 a7 = v56 + 32; | |
7470 if ( v21 ) | |
7471 break; | |
7472 v51 = a7; | |
7473 } | |
7474 } | |
86 | 7475 this->pRenderD3D->pDevice->SetTexture(0, a5); |
186 | 7476 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
7477 if (transparent) | |
7478 { | |
7479 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
7480 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
7481 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 7482 } |
7483 } | |
7484 else | |
7485 { | |
7486 if ( (signed int)uNumVertices > 0 ) | |
7487 { | |
186 | 7488 v12 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 7489 v13 = (char *)&array_50AC10[0].vWorldViewPosition; |
186 | 7490 a7 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 7491 a6a = uNumVertices; |
7492 while ( 1 ) | |
7493 { | |
7494 v14 = *(float *)v13 * 1000.0; | |
7495 *(int *)(v12 - 4) = *((int *)v13 + 3); | |
7496 v15 = v14 / (double)pOutdoorCamera->shading_dist_mist; | |
7497 *(int *)v12 = *((int *)v13 + 4); | |
7498 *(float *)(v12 + 4) = 1.0 - 1.0 / v15; | |
7499 *(float *)(v12 + 8) = 1.0 / (*(float *)v13 + 0.0000001); | |
638 | 7500 v16 = GetActorTintColor(a4->dimming_level, 0, *(float *)v13, 0, 0); |
0 | 7501 v17 = a7; |
7502 v18 = *(float *)v13; | |
7503 *(int *)(a7 + 12) = v16; | |
75 | 7504 if ( this->bUsingSpecular ) |
0 | 7505 { |
7506 v19 = v18; | |
7507 v20 = sub_47C3D7_get_fog_related_stuff(0, 0, v19); | |
7508 v17 = a7; | |
7509 } | |
7510 else | |
7511 { | |
7512 v20 = 0; | |
7513 } | |
7514 *(int *)(v17 + 16) = v20; | |
7515 *(int *)(v17 + 20) = *((int *)v13 + 6); | |
7516 *(int *)(v17 + 24) = *((int *)v13 + 7); | |
7517 v13 += 48; | |
7518 v21 = a6a-- == 1; | |
7519 a7 = v17 + 32; | |
7520 if ( v21 ) | |
7521 break; | |
7522 v12 = a7; | |
7523 } | |
7524 } | |
186 | 7525 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
7526 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
7527 if (pRenderer->bUsingSpecular) | |
7528 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 7529 |
7530 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 7531 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7532 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7533 d3d_vertex_buffer, |
0 | 7534 uNumVertices, |
7535 16)); | |
7536 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 7537 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 7538 //(*(void (**)(void))(*(int *)v63 + 88))(); |
7539 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
7540 v26 = uNumVertices; | |
7541 if ( (signed int)uNumVertices > 0 ) | |
7542 { | |
186 | 7543 v27 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 7544 do |
7545 { | |
7546 *(int *)v27 = -1; | |
7547 v27 += 32; | |
7548 --v26; | |
7549 } | |
7550 while ( v26 ); | |
7551 } | |
7552 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); | |
186 | 7553 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7554 if ( !pRenderer->bUsingSpecular ) |
7555 { | |
186 | 7556 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
7557 } | |
7558 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
7559 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
7560 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
7561 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7562 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7563 d3d_vertex_buffer, |
0 | 7564 uNumVertices, |
7565 16)); | |
7566 if ( pRenderer->bUsingSpecular ) | |
7567 { | |
186 | 7568 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 7569 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
7570 v37 = uNumVertices; | |
7571 if ( (signed int)uNumVertices > 0 ) | |
7572 { | |
186 | 7573 v38 = (char *)&d3d_vertex_buffer[0].specular; |
0 | 7574 do |
7575 { | |
7576 v39 = *(int *)v38; | |
7577 *(int *)v38 = 0; | |
7578 v38 += 32; | |
7579 --v37; | |
7580 *((int *)v38 - 9) = pRenderer->uFogColor | v39 & 0xFF000000; | |
7581 } | |
7582 while ( v37 ); | |
7583 } | |
75 | 7584 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 7585 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
7586 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
7587 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7588 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7589 d3d_vertex_buffer, |
0 | 7590 uNumVertices, |
7591 16)); | |
186 | 7592 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 7593 //v44 = pRenderer->pRenderD3D->pDevice; |
7594 v45 = GetLevelFogColor(); | |
7595 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
7596 v8 = 0; | |
7597 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
7598 } | |
186 | 7599 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
7600 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 7601 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
7602 } | |
7603 } | |
186 | 7604 |
791 | 7605 if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
186 | 7606 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 7607 } |
7608 // 4A26BC: could not find valid save-restore pair for esi | |
7609 // 4D864C: using guessed type char byte_4D864C; | |
7610 | |
7611 //----- (004A2DA3) -------------------------------------------------------- | |
852 | 7612 void Render::DrawSkyPolygon(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *pTexture) |
7613 { | |
67 | 7614 int v7; // eax@7 |
0 | 7615 float v13; // ST3C_4@8 |
67 | 7616 int i; |
7617 | |
7618 if ( !this->uNumD3DSceneBegins ) | |
7619 return; | |
7620 if ( uNumVertices >= 3 ) | |
7621 { | |
186 | 7622 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 7623 if ( this->bUsingSpecular ) |
7624 { | |
186 | 7625 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
7626 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
7627 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 7628 } |
840 | 7629 for ( i = 0; i < uNumVertices; ++i ) |
67 | 7630 { |
7631 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
7632 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
7633 pVertices[i].pos.z = 0.99989998; | |
168 | 7634 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 7635 |
840 | 7636 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 7637 v7 = 0; |
7638 if (this->bUsingSpecular) | |
7639 { | |
7640 v13 = array_50AC10[i].vWorldViewPosition.x; | |
7641 v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v13); | |
7642 } | |
7643 pVertices[i].specular = v7; | |
7644 pVertices[i].texcoord.x = array_50AC10[i].u; | |
7645 pVertices[i].texcoord.y = array_50AC10[i].v; | |
7646 } | |
7647 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7648 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 7649 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 7650 } |
7651 } | |
7652 | |
7653 //----- (004A2ED5) -------------------------------------------------------- | |
7654 void Render::_4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex) | |
7655 { | |
7656 signed int v4; // edi@2 | |
7657 int v5; // eax@3 | |
7658 int v6; // edx@5 | |
7659 char *v7; // eax@6 | |
7660 char *v8; // ecx@6 | |
7661 double v9; // st6@7 | |
7662 int v10; // ebx@7 | |
7663 int v11; // ebx@7 | |
7664 | |
7665 if ( this->uNumD3DSceneBegins ) | |
7666 { | |
7667 v4 = a2; | |
7668 if ( a2 >= 3 ) | |
7669 { | |
186 | 7670 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
638 | 7671 v5 = 31 - (a3->dimming_level & 0x1F); |
7672 if ( v5 < pOutdoor->max_terrain_dimming_level ) | |
7673 v5 = pOutdoor->max_terrain_dimming_level; | |
0 | 7674 v6 = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); |
7675 if ( a2 > 0 ) | |
7676 { | |
186 | 7677 v7 = (char *)&d3d_vertex_buffer[0].pos.y; |
0 | 7678 v8 = (char *)&array_507D30[0].vWorldViewProjY; |
7679 do | |
7680 { | |
7681 v9 = *((float *)v8 - 4) * 0.061758894; | |
7682 v10 = *((int *)v8 - 1); | |
7683 *((int *)v7 + 4) = 0; | |
7684 *((int *)v7 - 1) = v10; | |
7685 *(int *)v7 = *(int *)v8; | |
7686 *((int *)v7 + 2) = *((int *)v8 + 1); | |
7687 *((int *)v7 + 5) = *((int *)v8 + 2); | |
7688 v11 = *((int *)v8 + 3); | |
7689 *((int *)v7 + 3) = v6; | |
7690 *((int *)v7 + 6) = v11; | |
7691 v8 += 48; | |
7692 v7 += 32; | |
7693 --v4; | |
7694 *((float *)v7 - 7) = 1.0 - 1.0 / v9; | |
7695 } | |
7696 while ( v4 ); | |
7697 } | |
7698 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); | |
186 | 7699 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7700 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7701 d3d_vertex_buffer, |
0 | 7702 a2, |
7703 28)); | |
7704 } | |
7705 } | |
7706 } | |
7707 | |
7708 //----- (004A2FC0) -------------------------------------------------------- | |
7709 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
7710 { | |
7711 //Render *v8; // edi@1 | |
7712 //unsigned int v9; // esi@3 | |
7713 char *v12; // ecx@9 | |
7714 char *v13; // eax@9 | |
7715 double v14; // st6@10 | |
7716 int v15; // edx@10 | |
7717 Texture *v16; // edx@10 | |
7718 double v17; // st6@10 | |
7719 //char v18; // zf@10 | |
7720 Texture *v19; // edx@10 | |
595 | 7721 //Texture *v23; // edx@16 |
7722 //char *v24; // ecx@16 | |
7723 //char *v25; // eax@16 | |
7724 //double v26; // st6@17 | |
7725 //int v27; // esi@17 | |
7726 //double v28; // st6@17 | |
7727 //unsigned int v33; // ecx@18 | |
7728 //char *v34; // eax@19 | |
0 | 7729 //Texture *v45; // edx@23 |
7730 //char *v46; // ecx@23 | |
7731 //char *v47; // eax@23 | |
7732 //double v48; // st6@24 | |
7733 //int v49; // esi@24 | |
7734 //double v50; // st6@24 | |
7735 const char *v53; // [sp-Ch] [bp-20h]@21 | |
7736 //int v54; // [sp-8h] [bp-1Ch]@21 | |
7737 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
7738 const char *v56; // [sp+0h] [bp-14h]@0 | |
7739 int v57; // [sp+4h] [bp-10h]@0 | |
7740 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
7741 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
7742 //int a3a; // [sp+10h] [bp-4h]@4 | |
7743 | |
7744 //v8 = this; | |
7745 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
7746 return; | |
7747 | |
7748 //auto a3 = pFace; | |
7749 //auto a6 = uPackedID; | |
7750 //v59 = pGame->pLightmapBuilder; | |
7751 //v9 = v59->std__vector_000004_size; | |
7752 | |
7753 auto uCorrectedColor = uColor; | |
7754 if (pGame->pLightmapBuilder->std__vector_000004_size) | |
7755 uCorrectedColor = 0xFFFFFFFF; | |
638 | 7756 pGame->AlterGamma_BLV(pFace, &uCorrectedColor); |
0 | 7757 |
792 | 7758 |
7759 if (pFace->uAttributes & FACE_OUTLINED) | |
7760 { | |
7761 int color; | |
7762 if (GetTickCount() % 300 >= 150) | |
7763 uColor = uCorrectedColor = 0xFF20FF20; | |
7764 else uColor = uCorrectedColor = 0xFF109010; | |
7765 } | |
7766 | |
0 | 7767 if (byte_4D864C && pGame->uFlags & 1) |
7768 { | |
7769 __debugbreak(); | |
7770 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 7771 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7772 if ( (signed int)uNumVertices > 0 ) |
7773 { | |
7774 v12 = (char *)&array_507D30[0].vWorldViewPosition; | |
186 | 7775 v13 = (char *)&d3d_vertex_buffer[0].pos.y; |
0 | 7776 auto a7 = uNumVertices; |
7777 uint v18; | |
7778 do | |
7779 { | |
7780 v14 = *(float *)v12 * 0.061758894; | |
7781 v15 = *((int *)v12 + 3); | |
7782 *((int *)v13 + 4) = 0; | |
7783 *((int *)v13 - 1) = v15; | |
7784 *(int *)v13 = *((int *)v12 + 4); | |
7785 *((int *)v13 + 3) = uCorrectedColor; | |
7786 v16 = pTex; | |
7787 v13 += 32; | |
7788 *((float *)v13 - 7) = 1.0 - 1.0 / v14; | |
7789 v17 = 1.0 / *(float *)v12; | |
7790 v12 += 48; | |
7791 v18 = a7-- == 1; | |
7792 *((float *)v13 - 6) = v17; | |
7793 pHwTex = (IDirect3DTexture2 *)v16->uTextureWidth; | |
7794 v19 = pTex; | |
7795 *((float *)v13 - 3) = *((float *)v12 - 6) / (double)(signed int)pHwTex; | |
7796 pHwTex = (IDirect3DTexture2 *)v19->uTextureHeight; | |
7797 *((float *)v13 - 2) = *((float *)v12 - 5) / (double)(signed int)pHwTex; | |
7798 } | |
7799 while ( !v18 ); | |
7800 } | |
186 | 7801 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7802 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
7803 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7804 D3DPT_TRIANGLEFAN, | |
7805 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 7806 d3d_vertex_buffer, |
0 | 7807 uNumVertices, |
7808 28)); | |
7809 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
7810 } | |
7811 else | |
7812 { | |
7813 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
7814 byte_4D864C && pGame->uFlags & 2) | |
7815 { | |
7816 for (uint i = 0; i < uNumVertices; ++i) | |
7817 { | |
186 | 7818 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
7819 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7820 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
7821 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
7822 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
7823 d3d_vertex_buffer[i].specular = 0; | |
7824 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
7825 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
7826 } | |
7827 | |
7828 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 7829 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
7830 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
7831 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 7832 d3d_vertex_buffer, |
0 | 7833 uNumVertices, |
7834 28)); | |
7835 } | |
7836 else | |
7837 { | |
595 | 7838 for (uint i = 0; i < uNumVertices; ++i) |
7839 { | |
7840 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
7841 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7842 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
7843 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
7844 d3d_vertex_buffer[i].diffuse = uColor; | |
7845 d3d_vertex_buffer[i].specular = 0; | |
7846 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
7847 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
7848 } | |
7849 //__debugbreak(); | |
7850 //if ( (signed int)uNumVertices > 0 ) | |
7851 //{ | |
7852 //v23 = pTex; | |
7853 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
7854 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
7855 //pTex = (Texture *)uNumVertices; | |
7856 //uint v18; | |
7857 //do | |
7858 //{ | |
7859 //v26 = *(float *)v24 * 0.061758894; | |
7860 //v27 = *((int *)v24 + 3); | |
7861 //*((int *)v25 + 4) = 0; | |
7862 //*((int *)v25 - 1) = v27; | |
7863 //*(int *)v25 = *((int *)v24 + 4); | |
7864 //*((int *)v25 + 3) = uColor; | |
7865 //v25 += 32; | |
7866 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
7867 //v28 = 1.0 / *(float *)v24; | |
7868 //v24 += 48; | |
7869 //v18 = pTex == (Texture *)1; | |
7870 //pTex = (Texture *)((char *)pTex - 1); | |
7871 //*((float *)v25 - 6) = v28; | |
0 | 7872 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 7873 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 7874 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 7875 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
7876 //} | |
7877 //while ( !v18 ); | |
7878 //} | |
0 | 7879 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 7880 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7881 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 7882 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7883 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7884 d3d_vertex_buffer, |
0 | 7885 uNumVertices, |
7886 28)); | |
595 | 7887 |
7888 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 7889 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); |
595 | 7890 |
7891 for (uint i = 0; i < uNumVertices; ++i) | |
7892 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
7893 /*v33 = uNumVertices; | |
0 | 7894 if ( (signed int)uNumVertices > 0 ) |
7895 { | |
186 | 7896 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 7897 do |
7898 { | |
7899 *(int *)v34 = uCorrectedColor; | |
7900 v34 += 32; | |
7901 --v33; | |
7902 } | |
7903 while ( v33 ); | |
595 | 7904 }*/ |
0 | 7905 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 7906 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
7907 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
7908 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
7909 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
7910 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
7911 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7912 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7913 d3d_vertex_buffer, |
0 | 7914 uNumVertices, |
7915 28)); | |
186 | 7916 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
7917 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
7918 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 7919 } |
7920 } | |
7921 } | |
7922 // 4D864C: using guessed type char byte_4D864C; | |
7923 | |
7924 //----- (004A43B1) -------------------------------------------------------- | |
717 | 7925 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
7926 { | |
7927 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
7928 //double v5; // st7@2 | |
7929 //float v6; // ST08_4@2 | |
0 | 7930 unsigned int v7; // eax@2 |
717 | 7931 //int v8; // ecx@2 |
7932 //unsigned int v9; // esi@2 | |
7933 //Sprite *v10; // edi@5 | |
0 | 7934 signed int v11; // eax@9 |
7935 signed int v12; // eax@9 | |
717 | 7936 //double v13; // st7@12 |
7937 //double v14; // st6@12 | |
0 | 7938 double v15; // st5@12 |
7939 double v16; // st4@12 | |
7940 double v17; // st3@12 | |
7941 double v18; // st2@12 | |
7942 int v19; // ecx@14 | |
7943 double v20; // st3@14 | |
7944 int v21; // ecx@16 | |
7945 double v22; // st3@16 | |
717 | 7946 //IDirect3DTexture2 *v23; // eax@18 |
7947 //signed int v24; // [sp+18h] [bp-18h]@5 | |
7948 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
7949 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 7950 float v27; // [sp+24h] [bp-Ch]@5 |
7951 int v28; // [sp+28h] [bp-8h]@2 | |
7952 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 7953 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 7954 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 7955 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 7956 float a1; // [sp+40h] [bp+10h]@5 |
7957 | |
717 | 7958 //v26 = this; |
0 | 7959 if ( this->uNumD3DSceneBegins ) |
7960 { | |
717 | 7961 //v4 = pSoftBillboard; |
7962 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
7963 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
7964 //v6 = pSoftBillboard->zbuffer_depth; | |
7965 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
7966 //v8 = dimming_level; | |
7967 //v9 = v7; | |
657 | 7968 v28 = dimming_level & 0xFF000000; |
7969 if ( dimming_level & 0xFF000000 ) | |
717 | 7970 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Opaque_3; |
0 | 7971 else |
717 | 7972 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Transparent; |
7973 //v10 = a3; | |
7974 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
7975 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
7976 pBillboardRenderListD3D[v7].uParentBillboardID = pSoftBillboard->uParentBillboardID; | |
7977 //v25 = pSoftBillboard->uScreenSpaceX; | |
7978 //v24 = pSoftBillboard->uScreenSpaceY; | |
7979 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
7980 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
7981 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
7982 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
7983 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 7984 v31 = v31 * -1.0; |
717 | 7985 if ( pSoftBillboard->uTintColor && this->bTinting ) |
7986 { | |
7987 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
737 | 7988 v12 = BlendColors(pSoftBillboard->uTintColor, v11); |
0 | 7989 if ( v28 ) |
7990 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
7991 } | |
7992 else | |
7993 { | |
717 | 7994 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
7995 } | |
7996 //v13 = (double)v25; | |
7997 pBillboardRenderListD3D[v7].pQuards[0].specular = 0; | |
7998 pBillboardRenderListD3D[v7].pQuards[0].diffuse = v12; | |
7999 pBillboardRenderListD3D[v7].pQuards[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
8000 //v14 = (double)v24; | |
8001 //v32 = v14; | |
8002 pBillboardRenderListD3D[v7].pQuards[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; | |
8003 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); | |
8004 pBillboardRenderListD3D[v7].pQuards[0].pos.z = v15; | |
8005 v16 = 1.0 / pSoftBillboard->zbuffer_depth; | |
8006 pBillboardRenderListD3D[v7].pQuards[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; | |
8007 pBillboardRenderListD3D[v7].pQuards[0].texcoord.x = 0.0; | |
8008 pBillboardRenderListD3D[v7].pQuards[0].texcoord.y = 0.0; | |
8009 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
8010 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
8011 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8012 v17 = v17 * -1.0; |
717 | 8013 pBillboardRenderListD3D[v7].pQuards[1].specular = 0; |
8014 pBillboardRenderListD3D[v7].pQuards[1].diffuse = v12; | |
8015 pBillboardRenderListD3D[v7].pQuards[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
8016 pBillboardRenderListD3D[v7].pQuards[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
8017 pBillboardRenderListD3D[v7].pQuards[1].pos.z = v15; | |
8018 pBillboardRenderListD3D[v7].pQuards[1].rhw = v16; | |
8019 pBillboardRenderListD3D[v7].pQuards[1].texcoord.x = 0.0; | |
8020 pBillboardRenderListD3D[v7].pQuards[1].texcoord.y = 1.0; | |
8021 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; | |
8022 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
8023 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8024 v20 = v20 * -1.0; |
717 | 8025 pBillboardRenderListD3D[v7].pQuards[2].specular = 0; |
8026 pBillboardRenderListD3D[v7].pQuards[2].diffuse = v12; | |
8027 pBillboardRenderListD3D[v7].pQuards[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
8028 pBillboardRenderListD3D[v7].pQuards[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
8029 pBillboardRenderListD3D[v7].pQuards[2].pos.z = v15; | |
8030 pBillboardRenderListD3D[v7].pQuards[2].rhw = v16; | |
8031 pBillboardRenderListD3D[v7].pQuards[2].texcoord.x = 1.0; | |
8032 pBillboardRenderListD3D[v7].pQuards[2].texcoord.y = 1.0; | |
8033 v21 = pSprite->uBufferHeight - pSprite->uAreaY; | |
8034 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
8035 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8036 v22 = v22 * -1.0; |
717 | 8037 pBillboardRenderListD3D[v7].pQuards[3].specular = 0; |
8038 pBillboardRenderListD3D[v7].pQuards[3].diffuse = v12; | |
8039 pBillboardRenderListD3D[v7].pQuards[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
8040 pBillboardRenderListD3D[v7].pQuards[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
8041 pBillboardRenderListD3D[v7].pQuards[3].pos.z = v15; | |
8042 pBillboardRenderListD3D[v7].pQuards[3].rhw = v16; | |
8043 pBillboardRenderListD3D[v7].pQuards[3].texcoord.x = 1.0; | |
8044 pBillboardRenderListD3D[v7].pQuards[3].texcoord.y = 0.0; | |
8045 //v23 = pSprite->pTexture; | |
8046 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
8047 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
8048 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 8049 } |
8050 } | |
8051 | |
8052 //----- (004A354F) -------------------------------------------------------- | |
8053 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
8054 { | |
743 | 8055 //double v5; // st7@3 |
8056 //float v6; // ST20_4@3 | |
8057 //float v7; // ST00_4@3 | |
0 | 8058 unsigned int v8; // esi@3 |
743 | 8059 //int v9; // eax@3 |
8060 //int v10; // ebx@3 | |
0 | 8061 float v11; // ST28_4@3 |
743 | 8062 //double v12; // st7@3 |
8063 //float v13; // ST24_4@3 | |
8064 //double v14; // st6@3 | |
8065 //float v15; // ST1C_4@3 | |
0 | 8066 float v16; // ST2C_4@3 |
8067 float v17; // ST30_4@3 | |
8068 signed int v18; // ST18_4@3 | |
8069 signed int v19; // ST14_4@3 | |
8070 signed int v20; // ST10_4@3 | |
8071 signed int v21; // eax@3 | |
8072 double v22; // st6@3 | |
8073 float v23; // ST2C_4@3 | |
8074 float v24; // ST30_4@3 | |
8075 signed int v25; // ST10_4@3 | |
8076 signed int v26; // ST14_4@3 | |
8077 signed int v27; // ST18_4@3 | |
8078 signed int v28; // eax@3 | |
8079 double v29; // st6@3 | |
8080 float v30; // ecx@3 | |
8081 float v31; // ST2C_4@3 | |
8082 float v32; // ST30_4@3 | |
8083 signed int v33; // ST10_4@3 | |
8084 signed int v34; // ST14_4@3 | |
8085 signed int v35; // ST18_4@3 | |
8086 signed int v36; // eax@3 | |
8087 float v37; // ecx@3 | |
8088 double v38; // st6@3 | |
8089 float v39; // ST2C_4@3 | |
8090 float v40; // ST30_4@3 | |
8091 signed int v41; // ST10_4@3 | |
8092 signed int v42; // ST14_4@3 | |
8093 signed int v43; // ST18_4@3 | |
8094 signed int v44; // eax@3 | |
8095 double v45; // st6@3 | |
8096 float v46; // eax@3 | |
8097 | |
8098 if ( this->uNumD3DSceneBegins ) | |
8099 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8100 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8101 { |
743 | 8102 //v5 = (double)a2->zbuffer_depth; |
8103 //v6 = v5; | |
8104 //v7 = v5; | |
8105 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
0 | 8106 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; |
8107 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
8108 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
8109 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
743 | 8110 //v9 = a2->uScreenSpaceX; |
8111 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8112 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 8113 //v12 = (double) a2->uScreenSpaceX; |
8114 //v13 = v12; | |
8115 //v14 = (double)(a2->uScreenSpaceY - 12); | |
8116 //v15 = v14; | |
8117 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
8118 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 8119 v18 = stru_5C6E00->Cos(angle); |
8120 v19 = stru_5C6E00->Sin(angle); | |
8121 v20 = stru_5C6E00->Sin(angle); | |
8122 v21 = stru_5C6E00->Cos(angle); | |
0 | 8123 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
8124 + (double)(v18 >> 16)) | |
8125 * v16 | |
8126 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
8127 + (double)(v19 >> 16)) | |
8128 * v17) | |
743 | 8129 * v11 + (double) a2->uScreenSpaceX; |
0 | 8130 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
8131 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
8132 - 12.0) | |
8133 * v11 | |
8134 + (double)a2->uScreenSpaceY; | |
8135 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; | |
8136 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; | |
8137 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v22; | |
743 | 8138 pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); |
8139 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; | |
0 | 8140 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; |
8141 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; | |
743 | 8142 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
8143 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 8144 v25 = stru_5C6E00->Cos(angle); |
8145 v26 = stru_5C6E00->Sin(angle); | |
8146 v27 = stru_5C6E00->Sin(angle); | |
8147 v28 = stru_5C6E00->Cos(angle); | |
0 | 8148 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
8149 + (double)(v25 >> 16)) | |
740 | 8150 * v31 |
0 | 8151 - ((double)(unsigned __int16)v26 * 0.000015259022 |
8152 + (double)(v26 >> 16)) | |
740 | 8153 * v32) |
743 | 8154 * v11 + (double) a2->uScreenSpaceX; |
740 | 8155 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
8156 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 8157 - 12.0) |
8158 * v11 | |
8159 + (double)a2->uScreenSpaceY; | |
8160 pBillboardRenderListD3D[v8].pQuards[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8161 v30 = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8162 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v29; | |
8163 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; | |
8164 pBillboardRenderListD3D[v8].pQuards[1].rhw = v30; | |
8165 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; | |
8166 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; | |
8167 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
743 | 8168 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
8169 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 8170 v33 = stru_5C6E00->Cos(angle); |
8171 v34 = stru_5C6E00->Sin(angle); | |
8172 v35 = stru_5C6E00->Sin(angle); | |
8173 v36 = stru_5C6E00->Cos(angle); | |
0 | 8174 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
8175 + (double)(v33 >> 16)) | |
740 | 8176 * v23 |
0 | 8177 - ((double)(unsigned __int16)v34 * 0.000015259022 |
8178 + (double)(v34 >> 16)) | |
740 | 8179 * v24) |
743 | 8180 * v11 + (double) a2->uScreenSpaceX; |
0 | 8181 v37 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; |
740 | 8182 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
8183 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 8184 - 12.0) |
8185 * v11 | |
8186 + (double)a2->uScreenSpaceY; | |
8187 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; | |
8188 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v37; | |
8189 pBillboardRenderListD3D[v8].pQuards[2].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8190 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; | |
8191 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v38; | |
8192 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; | |
8193 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
743 | 8194 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
8195 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 8196 v41 = stru_5C6E00->Cos(angle); |
8197 v42 = stru_5C6E00->Sin(angle); | |
8198 v43 = stru_5C6E00->Sin(angle); | |
8199 v44 = stru_5C6E00->Cos(angle); | |
0 | 8200 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
8201 + (double)(v41 >> 16)) | |
8202 * v39 | |
8203 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
8204 + (double)(v42 >> 16)) | |
8205 * v40) | |
743 | 8206 * v11 + (double) a2->uScreenSpaceX; |
0 | 8207 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
8208 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
8209 - 12.0) | |
8210 * v11 | |
8211 + (double)a2->uScreenSpaceY; | |
8212 v46 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8213 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; | |
8214 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v46; | |
8215 pBillboardRenderListD3D[v8].pQuards[3].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8216 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; | |
8217 pBillboardRenderListD3D[v8].pTexture = a3; | |
743 | 8218 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 8219 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8220 pBillboardRenderListD3D[v8].pQuards[3].pos.y = v45; | |
8221 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; | |
8222 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
8223 } | |
8224 } | |
8225 } | |
8226 | |
8227 //----- (004A3AD9) -------------------------------------------------------- | |
8228 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
8229 { | |
8230 double v5; // st7@2 | |
8231 float v6; // ST28_4@2 | |
8232 float v7; // ST00_4@2 | |
8233 unsigned int v8; // esi@2 | |
8234 int v9; // eax@2 | |
8235 int v10; // ebx@2 | |
8236 float v11; // ST34_4@2 | |
8237 double v12; // st7@2 | |
8238 float v13; // ST2C_4@2 | |
8239 double v14; // st6@2 | |
8240 float v15; // ST24_4@2 | |
8241 float v16; // ST38_4@2 | |
8242 float v17; // ST3C_4@2 | |
8243 signed int v18; // ST1C_4@2 | |
8244 int v19; // ST30_4@2 | |
8245 signed int v20; // ST20_4@2 | |
8246 signed int v21; // ST18_4@2 | |
8247 signed int v22; // eax@2 | |
8248 double v23; // st6@2 | |
8249 float v24; // ST20_4@2 | |
8250 float v25; // ST1C_4@2 | |
8251 float v26; // ST38_4@2 | |
8252 float v27; // ST3C_4@2 | |
8253 signed int v28; // ST18_4@2 | |
8254 signed int v29; // ST14_4@2 | |
8255 signed int v30; // ST10_4@2 | |
8256 signed int v31; // eax@2 | |
8257 double v32; // st6@2 | |
8258 float v33; // ST38_4@2 | |
8259 float v34; // ST3C_4@2 | |
8260 signed int v35; // ST10_4@2 | |
8261 signed int v36; // ST14_4@2 | |
8262 signed int v37; // ST18_4@2 | |
8263 signed int v38; // eax@2 | |
8264 double v39; // st6@2 | |
8265 float v40; // ST38_4@2 | |
8266 float v41; // ST3C_4@2 | |
8267 signed int v42; // ST10_4@2 | |
8268 signed int v43; // ST14_4@2 | |
8269 signed int v44; // ST18_4@2 | |
8270 signed int v45; // eax@2 | |
8271 double v46; // st6@2 | |
8272 | |
8273 if ( this->uNumD3DSceneBegins ) | |
8274 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8275 v5 = (double)a2->zbuffer_depth; |
0 | 8276 v6 = v5; |
8277 v7 = v5; | |
8278 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
8279 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | |
8280 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
8281 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
8282 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
8283 v9 = a2->uScreenSpaceX; | |
8284 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8285 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 8286 v12 = (double)v9; |
8287 v13 = v12; | |
8288 v14 = (double)(v10 - 12); | |
8289 v15 = v14; | |
8290 v16 = (double)(v9 - 12) - v12; | |
8291 v17 = (double)(v10 - 25) - v14; | |
323 | 8292 v18 = stru_5C6E00->Cos(angle); |
0 | 8293 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 8294 v20 = stru_5C6E00->Sin(angle); |
8295 v21 = stru_5C6E00->Sin(angle); | |
8296 v22 = stru_5C6E00->Cos(angle); | |
0 | 8297 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
8298 + (double)(v18 >> 16)) | |
8299 * v16 | |
8300 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
8301 + (double)(v20 >> 16)) | |
8302 * v17) | |
8303 * v11 + v13; | |
8304 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
8305 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
8306 - 12.0) | |
8307 * v11 | |
8308 + (double)a2->uScreenSpaceY; | |
8309 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; | |
8310 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; | |
8311 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v23; | |
8312 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
8313 pBillboardRenderListD3D[v8].pQuards[0].pos.z = v24; | |
8314 v25 = 1.0 / v6; | |
8315 pBillboardRenderListD3D[v8].pQuards[0].rhw = v25; | |
8316 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; | |
8317 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; | |
8318 v26 = (double)(a2->uScreenSpaceX - 12) - v13; | |
8319 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 8320 v28 = stru_5C6E00->Cos(angle); |
8321 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8322 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8323 v31 = stru_5C6E00->Cos(angle); | |
0 | 8324 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
8325 + (double)(v28 >> 16)) | |
8326 * v26 | |
8327 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
8328 + (double)(v29 >> 16)) | |
8329 * v27) | |
8330 * v11 + v13; | |
8331 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
8332 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
8333 - 12.0) | |
8334 * v11 | |
8335 + (double)a2->uScreenSpaceY; | |
8336 pBillboardRenderListD3D[v8].pQuards[1].pos.z = v24; | |
8337 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v32; | |
8338 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; | |
8339 pBillboardRenderListD3D[v8].pQuards[1].rhw = v25; | |
8340 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; | |
8341 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; | |
8342 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
8343 v33 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8344 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 8345 v35 = stru_5C6E00->Cos(angle); |
8346 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8347 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8348 v38 = stru_5C6E00->Cos(angle); | |
0 | 8349 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
8350 + (double)(v35 >> 16)) | |
8351 * v33 | |
8352 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
8353 + (double)(v36 >> 16)) | |
8354 * v34) | |
8355 * v11 + v13; | |
8356 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
8357 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
8358 - 12.0) | |
8359 * v11 | |
8360 + (double)a2->uScreenSpaceY; | |
8361 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; | |
8362 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v24; | |
8363 pBillboardRenderListD3D[v8].pQuards[2].rhw = v25; | |
8364 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; | |
8365 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v39; | |
8366 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; | |
8367 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
8368 v40 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8369 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 8370 v42 = stru_5C6E00->Cos(angle); |
8371 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8372 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8373 v45 = stru_5C6E00->Cos(angle); | |
0 | 8374 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
8375 + (double)(v42 >> 16)) | |
8376 * v40 | |
8377 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
8378 + (double)(v43 >> 16)) | |
8379 * v41) | |
8380 * v11 + v13; | |
8381 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
8382 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
8383 - 12.0) | |
8384 * v11 | |
8385 + (double)a2->uScreenSpaceY; | |
8386 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; | |
8387 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v24; | |
8388 pBillboardRenderListD3D[v8].pQuards[3].rhw = v25; | |
8389 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; | |
8390 pBillboardRenderListD3D[v8].pTexture = a3; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8391 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 8392 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8393 pBillboardRenderListD3D[v8].pQuards[3].pos.y = v46; | |
8394 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; | |
8395 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
8396 } | |
8397 } | |
8398 | |
8399 //----- (004A4023) -------------------------------------------------------- | |
657 | 8400 void Render::TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int dimming_level, RenderBillboard *pBillboard) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8401 { |
0 | 8402 unsigned int v8; // esi@2 |
8403 double v14; // st6@14 | |
8404 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8405 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8406 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8407 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8408 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8409 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8410 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8411 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8412 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8413 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8414 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 8415 float v29; // [sp+28h] [bp-8h]@5 |
8416 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8417 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8418 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8419 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8420 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8421 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8422 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8423 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8424 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
|
8425 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
|
8426 |
657 | 8427 unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8428 if (a2->uTintColor & 0x00FFFFFF && bTinting) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8429 { |
737 | 8430 diffuse = BlendColors(a2->uTintColor, diffuse); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8431 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8432 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
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 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8435 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8436 if (bUsingSpecular) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8437 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
|
8438 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8439 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8440 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8441 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8442 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8443 pBillboardRenderListD3D[v8].pQuards[0].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8444 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
|
8445 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
|
8446 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
|
8447 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8448 pBillboardRenderListD3D[v8].pQuards[0].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8449 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8450 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8451 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8452 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8453 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8454 if ( a2->uFlags & 4 ) |
0 | 8455 v14 = v14 * -1.0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8456 pBillboardRenderListD3D[v8].pQuards[1].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8457 pBillboardRenderListD3D[v8].pQuards[1].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8458 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
|
8459 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
|
8460 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
|
8461 pBillboardRenderListD3D[v8].pQuards[1].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8462 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; |
8463 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8464 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8465 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
|
8466 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8467 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8468 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8469 pBillboardRenderListD3D[v8].pQuards[2].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8470 pBillboardRenderListD3D[v8].pQuards[2].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8471 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
|
8472 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
|
8473 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
|
8474 pBillboardRenderListD3D[v8].pQuards[2].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8475 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; |
8476 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8477 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8478 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
|
8479 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8480 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8481 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8482 pBillboardRenderListD3D[v8].pQuards[3].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8483 pBillboardRenderListD3D[v8].pQuards[3].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8484 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
|
8485 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
|
8486 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
|
8487 pBillboardRenderListD3D[v8].pQuards[3].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8488 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; |
8489 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8490 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8491 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8492 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8493 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8494 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8495 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8496 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8497 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8498 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8499 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8500 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8501 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; |
0 | 8502 } |
8503 | |
8504 //----- (004A48E4) -------------------------------------------------------- | |
8505 int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6) | |
8506 { | |
8507 int v6; // ecx@1 | |
8508 int v7; // ebx@1 | |
8509 int v8; // ecx@1 | |
8510 int v9; // edx@1 | |
8511 int v10; // edi@1 | |
8512 unsigned int x; // esi@1 | |
8513 int result; // eax@8 | |
8514 int v13; // [sp+Ch] [bp-10h]@1 | |
8515 int v14; // [sp+10h] [bp-Ch]@1 | |
8516 int v15; // [sp+14h] [bp-8h]@1 | |
8517 int v16; // [sp+18h] [bp-4h]@1 | |
8518 int v17; // [sp+24h] [bp+8h]@1 | |
8519 unsigned int v18; // [sp+28h] [bp+Ch]@1 | |
8520 int v19; // [sp+34h] [bp+18h]@1 | |
8521 | |
8522 v6 = screenSpaceX; | |
8523 v7 = (a6 >> 1) + screenSpaceY; | |
8524 v17 = 0; | |
8525 v15 = 0; | |
8526 v8 = (a6 >> 1) + v6; | |
8527 v14 = (a6 >> 1) * (a6 >> 1); | |
8528 v9 = 2 * (a6 >> 1); | |
8529 v10 = (a6 >> 1) * ((a6 >> 1) - 1); | |
8530 x = v8 - (a6 >> 1); | |
8531 v16 = (a6 >> 1) + screenSpaceY - v8; | |
8532 v19 = a6 >> 1; | |
8533 v13 = v9; | |
8534 v18 = v8; | |
8535 do | |
8536 { | |
8537 sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor); | |
8538 if ( v15 ) | |
8539 sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor); | |
8540 v14 -= v15; | |
8541 if ( v14 <= v10 ) | |
8542 { | |
8543 if ( v19 != v17 ) | |
8544 { | |
8545 sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor); | |
8546 sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor); | |
8547 } | |
8548 --v19; | |
8549 v13 -= 2; | |
8550 ++x; | |
8551 v10 -= v13; | |
8552 } | |
8553 result = v17++; | |
8554 v15 += 2; | |
8555 --v18; | |
8556 } | |
8557 while ( result < v19 ); | |
8558 return result; | |
8559 } | |
8560 | |
8561 //----- (004A49D0) -------------------------------------------------------- | |
8562 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
8563 { | |
8564 int v10; // eax@1 | |
8565 unsigned int v11; // ebx@1 | |
8566 unsigned int v12; // ecx@1 | |
8567 int v13; // edx@2 | |
8568 int v14; // edx@4 | |
8569 unsigned int v15; // edx@6 | |
8570 double v16; // st7@7 | |
8571 double v17; // st7@7 | |
8572 double v18; // st6@7 | |
8573 double v19; // st4@7 | |
8574 double v20; // st4@8 | |
8575 double v21; // st4@10 | |
8576 double v22; // st4@10 | |
8577 double v23; // st4@10 | |
8578 double v24; // st4@10 | |
8579 double v25; // st4@11 | |
8580 double v26; // st4@13 | |
8581 double v27; // st5@13 | |
8582 double v28; // st4@13 | |
8583 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
8584 double v30; // [sp+80h] [bp-14h]@1 | |
8585 int v31; // [sp+88h] [bp-Ch]@1 | |
8586 signed int v32; // [sp+8Ch] [bp-8h]@1 | |
8587 int X; // [sp+90h] [bp-4h]@1 | |
8588 float a3a; // [sp+A4h] [bp+10h]@10 | |
8589 float a4a; // [sp+A8h] [bp+14h]@10 | |
8590 | |
8591 *(float *)&X = dstX - srcX; | |
8592 v30 = *(float *)&X + 6.7553994e15; | |
8593 v31 = LODWORD(v30); | |
8594 *(float *)&v32 = dstY - srcY; | |
8595 v30 = *(float *)&v32 + 6.7553994e15; | |
8596 X = LODWORD(v30); | |
8597 HIDWORD(v30) = abs(COERCE_UNSIGNED_INT64(*(float *)&v32 + 6.7553994e15)); | |
8598 v10 = abs(v31); | |
8599 v32 = v10; | |
8600 v11 = HIDWORD(v30); | |
8601 v12 = 0; | |
8602 if ( v10 < SHIDWORD(v30) ) | |
8603 { | |
8604 v13 = v10; | |
8605 v10 = HIDWORD(v30); | |
8606 v11 = v13; | |
8607 } | |
8608 if ( v10 < 0 ) | |
8609 { | |
8610 v14 = v10; | |
8611 v10 = 0; | |
8612 v12 = v14; | |
8613 } | |
8614 if ( (signed int)v11 < (signed int)v12 ) | |
8615 { | |
8616 v15 = v12; | |
8617 v12 = v11; | |
8618 v11 = v15; | |
8619 } | |
8620 v32 = (11 * v11 >> 5) + (v12 >> 2) + v10; | |
8621 v16 = 1.0 / (double)v32; | |
8622 *(float *)&v31 = (double)v31 * v16; | |
8623 *(float *)&X = (double)X * v16; | |
8624 v17 = *(float *)&X * a4; | |
8625 v29[0].pos.x = srcX + v17; | |
8626 v18 = *(float *)&v31 * a4; | |
8627 v29[0].pos.y = srcY - v18; | |
8628 v19 = a3; | |
8629 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
8630 v20 = v19 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8631 else | |
8632 v20 = v19 * 0.061758894; | |
8633 v29[0].diffuse = -1; | |
8634 v29[0].specular = 0; | |
8635 v29[0].pos.z = 1.0 - 1.0 / v20; | |
8636 v21 = 1.0 / a3; | |
8637 *((float *)&v30 + 1) = v21; | |
8638 v29[0].rhw = v21; | |
8639 v29[0].texcoord.x = 1.0; | |
8640 v29[0].texcoord.y = 0.0; | |
8641 v22 = *(float *)&X * a8; | |
8642 a3a = v22; | |
8643 v29[1].pos.x = v22 + dstX; | |
8644 v23 = *(float *)&v31 * a8; | |
8645 a4a = v23; | |
8646 v29[1].pos.y = dstY - v23; | |
8647 v24 = a7; | |
8648 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
8649 v25 = v24 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8650 else | |
8651 v25 = v24 * 0.061758894; | |
8652 v29[2].diffuse = -1; | |
8653 v29[3].diffuse = -1; | |
8654 *(_QWORD *)&v29[3].pos.z = __PAIR__(HIDWORD(v30), LODWORD(v29[0].pos.z)); | |
8655 v29[1].diffuse = -16711936; | |
8656 v29[1].specular = 0; | |
8657 v29[2].specular = 0; | |
8658 v29[3].specular = 0; | |
8659 v26 = 1.0 - 1.0 / v25; | |
8660 v29[1].pos.z = v26; | |
8661 v27 = v26; | |
8662 v28 = 1.0 / a7; | |
8663 v29[1].rhw = v28; | |
8664 v29[1].texcoord.x = 1.0; | |
8665 v29[1].texcoord.y = 1.0; | |
8666 v29[2].pos.x = dstX - a3a; | |
8667 v29[2].pos.y = a4a + dstY; | |
8668 v29[2].pos.z = v27; | |
8669 v29[2].rhw = v28; | |
8670 v29[2].texcoord.x = 0.0; | |
8671 v29[2].texcoord.y = 1.0; | |
8672 v29[3].pos.x = srcX - v17; | |
8673 v29[3].pos.y = v18 + srcY; | |
8674 v29[3].texcoord.x = 0.0; | |
8675 v29[3].texcoord.y = 0.0; | |
186 | 8676 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
8677 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8678 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8679 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
8680 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8681 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 8682 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
8683 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
8684 D3DPT_TRIANGLEFAN, | |
8685 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8686 v29, | |
8687 4, | |
8688 24)); | |
186 | 8689 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
8690 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8691 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8692 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
8693 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8694 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 8695 } |
8696 | |
8697 //----- (004A4CC9) -------------------------------------------------------- | |
8698 void Render::_4A4CC9(stru6_stru1_indoor_sw_billboard *a1, int a2) | |
8699 { | |
8700 int v3; // eax@1 | |
8701 int v4; // edx@3 | |
8702 unsigned int v5; // eax@7 | |
8703 int v6; // edi@7 | |
8704 char *v7; // edx@8 | |
8705 char *v8; // ecx@8 | |
8706 char v9; // zf@9 | |
8707 double v10; // st6@9 | |
8708 double v11; // st6@10 | |
8709 int v12; // ebx@13 | |
8710 int v13; // ecx@16 | |
8711 unsigned int v14; // [sp+Ch] [bp-4h]@1 | |
8712 | |
8713 auto _this = this; | |
8714 | |
8715 *(float *)&v14 = 1000000.0; | |
8716 v3 = a1->field_10; | |
8717 if ( v3 >= 3 ) | |
8718 { | |
8719 if ( v3 > 0 ) | |
8720 { | |
8721 _this = (Render *)&a1->field_14[62]; | |
8722 v4 = a1->field_10; | |
8723 do | |
8724 { | |
8725 if ( *(float *)&this->bUserDirect3D < (double)*(float *)&v14 ) | |
8726 v14 = this->bUserDirect3D; | |
8727 _this = (Render *)((char *)_this + 16); | |
8728 --v4; | |
8729 } | |
8730 while ( v4 ); | |
8731 } | |
8732 v5 = Billboard_ProbablyAddToListAndSortByZOrder(v14); | |
8733 v6 = 0; | |
8734 pBillboardRenderListD3D[v5].field_90 = 0; | |
8735 pBillboardRenderListD3D[v5].uParentBillboardID = -1; | |
8736 pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; | |
8737 if ( a1->field_10 > 0 ) | |
8738 { | |
8739 v7 = (char *)&a1->field_14[62]; | |
8740 v8 = (char *)&pBillboardRenderListD3D[v5].pQuards[0].pos.z; | |
8741 do | |
8742 { | |
8743 v9 = uCurrentlyLoadedLevelType == LEVEL_Indoor; | |
8744 *((int *)v8 - 2) = *((int *)v7 - 2); | |
8745 *((int *)v8 - 1) = *((int *)v7 - 1); | |
8746 v10 = *(float *)v7; | |
8747 if ( v9 ) | |
8748 v11 = v10 * 0.061758894; | |
8749 else | |
8750 v11 = v10 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8751 *(float *)v8 = 1.0 - 1.0 / v11; | |
8752 *((float *)v8 + 1) = 1.0 / *(float *)v7; | |
8753 if ( a2 & 0xFF000000 ) | |
8754 v12 = *((int *)v7 + 1); | |
8755 else | |
8756 v12 = a2; | |
8757 *((int *)v8 + 3) = 0; | |
8758 *((int *)v8 + 2) = v12; | |
8759 ++v6; | |
8760 v7 += 16; | |
8761 *((float *)v8 + 4) = 0.0; | |
8762 *((float *)v8 + 5) = 0.0; | |
8763 v8 += 32; | |
8764 } | |
8765 while ( v6 < a1->field_10 ); | |
8766 } | |
8767 v13 = a1->field_10; | |
8768 pBillboardRenderListD3D[v5].pTexture = 0; | |
8769 pBillboardRenderListD3D[v5].uNumVertices = v13; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8770 LODWORD(pBillboardRenderListD3D[v5].z_order) = v14; |
0 | 8771 } |
8772 } | |
8773 | |
8774 //----- (004A4DE1) -------------------------------------------------------- | |
8775 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
8776 { | |
8777 HRESULT v12; // eax@14 | |
8778 unsigned __int16 *v13; // ecx@19 | |
8779 unsigned __int16 *v14; // eax@19 | |
8780 DWORD v15; // edx@20 | |
8781 HRESULT v16; // eax@23 | |
8782 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
8783 | |
8784 auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); | |
8785 if ( pHWLTexture ) | |
8786 { | |
8787 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
8788 if ( !pRenderD3D->CreateTexture( | |
8789 pHWLTexture->uWidth, | |
8790 pHWLTexture->uHeight, | |
8791 pOutSurface, | |
8792 pOutTexture, | |
8793 true, | |
8794 bMipMaps, | |
8795 uMinDeviceTextureDim) ) | |
8796 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); | |
8797 //v10 = *pOutSurface; | |
8798 //v11 = 0; | |
8799 if ( bMipMaps ) | |
8800 { | |
8801 Dst._450DDE(); | |
8802 //v20 = 0; | |
8803 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
8804 | |
8805 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
8806 while ( 1 ) | |
8807 { | |
8808 DDSCAPS2 v19; | |
8809 memset(&v19, 0, sizeof(DDSCAPS2)); | |
8810 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
8811 | |
8812 DDSURFACEDESC2 desc; | |
8813 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
8814 desc.dwSize = sizeof(DDSURFACEDESC2); | |
8815 | |
168 | 8816 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 8817 { |
8818 Dst.sub_451007_scale_image_bicubic( | |
8819 pHWLTexture->pPixels, | |
8820 pHWLTexture->uWidth, | |
8821 pHWLTexture->uHeight, | |
8822 pHWLTexture->uWidth, | |
8823 (unsigned short *)desc.lpSurface, | |
8824 desc.dwWidth, | |
8825 desc.dwHeight, | |
8826 desc.lPitch >> 1, | |
8827 0, | |
8828 0); | |
8829 ErrD3D(pNextSurf->Unlock(0)); | |
8830 //bMipMaps = 0x4D86ACu; | |
8831 } | |
8832 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
8833 break; | |
8834 //v10 = (IDirectDrawSurface4 *)pName; | |
8835 //v11 = 0; | |
8836 } | |
8837 //v20 = -1; | |
8838 //nullsub_1(); | |
8839 } | |
8840 else | |
8841 { | |
8842 DDSCAPS2 v19; | |
8843 memset(&v19, 0, sizeof(DDSCAPS2)); | |
8844 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
8845 | |
8846 DDSURFACEDESC2 desc; | |
8847 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
8848 desc.dwSize = sizeof(DDSURFACEDESC2); | |
8849 | |
168 | 8850 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 8851 { |
8852 bMipMaps = 0; | |
8853 v13 = pHWLTexture->pPixels; | |
8854 v14 = (unsigned __int16 *)desc.lpSurface; | |
8855 if ( desc.dwHeight ) | |
8856 { | |
8857 do | |
8858 { | |
8859 v15 = 0; | |
8860 if ( desc.dwWidth ) | |
8861 { | |
8862 do | |
8863 { | |
8864 ++v15; | |
8865 *v14 = *v13; | |
8866 ++v14; | |
8867 ++v13; | |
8868 } | |
8869 while ( v15 < desc.dwWidth ); | |
8870 } | |
8871 ++bMipMaps; | |
8872 v14 += (desc.lPitch >> 1) - desc.dwWidth; | |
8873 } | |
8874 while ( bMipMaps < desc.dwHeight ); | |
8875 } | |
8876 ErrD3D((*pOutSurface)->Unlock(0)); | |
8877 } | |
8878 } | |
8879 delete [] pHWLTexture->pPixels; | |
8880 delete pHWLTexture; | |
8881 return true; | |
8882 } | |
8883 return false; | |
8884 } | |
8885 | |
8886 //----- (004A5048) -------------------------------------------------------- | |
670 | 8887 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
8888 { | |
8889 | |
8890 HWLTexture *sprite_texture; // eax@1 | |
0 | 8891 unsigned __int16 *v9; // edx@5 |
8892 LPVOID v10; // eax@5 | |
8893 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
8894 | |
670 | 8895 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
8896 if ( sprite_texture ) | |
8897 { | |
8898 _gpu_memory_used += 2 * sprite_texture->uWidth * sprite_texture->uHeight; | |
8899 pSprite->uAreaX = sprite_texture->uAreaX; | |
8900 pSprite->uAreaY = sprite_texture->uAreaY; | |
8901 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
8902 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
8903 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
8904 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8905 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8906 //v7 = v3->pRenderD3D; |
670 | 8907 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
0 | 8908 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
8909 //pSprite = v2->pTextureSurface; | |
8910 //pSprite = (Sprite *)pSprite->pName; | |
8911 //v8 = pSprite; | |
670 | 8912 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 8913 Dst.dwSize = 124; |
670 | 8914 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
8915 { | |
8916 v9 = sprite_texture->pPixels; | |
8917 v10 = Dst.lpSurface; | |
8918 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 8919 { |
670 | 8920 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
8921 { | |
0 | 8922 *(int *)v10 = *(int *)v9; |
8923 v9 += 2; | |
8924 v10 = (char *)v10 + 4; | |
670 | 8925 } |
8926 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 8927 } |
670 | 8928 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
8929 } | |
8930 free(sprite_texture->pPixels); | |
8931 free(sprite_texture); | |
8932 return true; | |
8933 } | |
8934 return false; | |
0 | 8935 } |
8936 | |
8937 //----- (004A51CB) -------------------------------------------------------- | |
8938 void Render::BeginScene() | |
8939 { | |
8940 Render *v1; // esi@1 | |
8941 unsigned int v2; // eax@1 | |
8942 int v3; // eax@5 | |
8943 unsigned __int16 **v4; // edi@6 | |
8944 char *v5; // ebx@7 | |
8945 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
8946 | |
8947 v1 = this; | |
8948 v2 = this->uNumSceneBegins; | |
8949 this->uNumSceneBegins = v2 + 1; | |
8950 if ( !v2 ) | |
8951 { | |
8952 if ( this->pRenderD3D ) | |
8953 { | |
8954 if ( this->bColorKeySupported ) | |
8955 { | |
8956 memset(&Dst, 0, 0x7Cu); | |
8957 Dst.dwSize = 124; | |
168 | 8958 if ( LockSurface_DDraw4(v1->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) ) |
0 | 8959 { |
8960 v1->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; | |
8961 v3 = Dst.lPitch >> 1; | |
8962 v1->uTargetSurfacePitch = Dst.lPitch >> 1; | |
8963 LABEL_10: | |
8964 v1->field_18_locked_pitch = v3; | |
8965 goto LABEL_11; | |
8966 } | |
8967 goto LABEL_8; | |
8968 } | |
8969 } | |
8970 else | |
8971 { | |
8972 v4 = &this->pTargetSurface; | |
8973 if ( !this->pTargetSurface ) | |
8974 { | |
8975 v5 = (char *)&this->uTargetSurfacePitch; | |
8976 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
8977 if ( *v4 ) | |
8978 { | |
8979 v3 = *(int *)v5; | |
8980 goto LABEL_10; | |
8981 } | |
8982 LABEL_8: | |
8983 --v1->uNumSceneBegins; | |
8984 return; | |
8985 } | |
8986 } | |
8987 LABEL_11: | |
8988 RestoreFrontBuffer(); | |
8989 } | |
8990 } | |
8991 | |
8992 //----- (004A527D) -------------------------------------------------------- | |
8993 void Render::EndScene() | |
8994 { | |
8995 unsigned int v1; // edx@1 | |
8996 unsigned int v2; // edx@2 | |
8997 HRESULT v3; // eax@5 | |
8998 | |
8999 v1 = this->uNumSceneBegins; | |
9000 if ( v1 ) | |
9001 { | |
9002 v2 = v1 - 1; | |
9003 this->uNumSceneBegins = v2; | |
9004 if ( !v2 ) | |
9005 { | |
9006 if ( this->pRenderD3D ) | |
9007 { | |
9008 if ( this->bColorKeySupported ) | |
9009 { | |
9010 this->pTargetSurface = 0; | |
9011 this->uTargetSurfacePitch = 0; | |
9012 this->field_18_locked_pitch = 0; | |
9013 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
9014 } | |
9015 } | |
9016 else | |
9017 { | |
9018 this->pTargetSurface = 0; | |
9019 this->uTargetSurfacePitch = 0; | |
9020 this->field_18_locked_pitch = 0; | |
9021 UnlockBackBuffer(); | |
9022 } | |
9023 } | |
9024 } | |
9025 } | |
9026 | |
9027 //----- ( ) -------------------------------------------------------- | |
9028 unsigned int Render::_4A52F1(unsigned int this_, float a3) | |
9029 { | |
9030 unsigned int v3; // esi@1 | |
9031 double v4; // st7@2 | |
9032 double v5; // st7@6 | |
9033 double v6; // st6@6 | |
9034 unsigned int v7; // eax@6 | |
9035 double v8; // st5@6 | |
9036 double v9; // st4@6 | |
9037 HRESULT v10; // eax@6 | |
9038 HRESULT v11; // eax@6 | |
9039 unsigned int result; // eax@6 | |
9040 unsigned int v13; // eax@7 | |
9041 unsigned __int16 *v14; // ecx@7 | |
9042 int *v15; // eax@7 | |
9043 unsigned int v16; // ecx@8 | |
9044 __int16 v17; // ax@10 | |
9045 int v18; // esi@10 | |
9046 float v19; // edi@10 | |
9047 void *v20; // esi@10 | |
9048 int v21; // edx@10 | |
9049 int v22; // ecx@11 | |
9050 int v23; // edx@12 | |
9051 __int16 v24; // ax@15 | |
9052 int v25; // esi@15 | |
9053 float v26; // edi@15 | |
9054 char *v27; // esi@15 | |
9055 int v28; // edx@15 | |
9056 int v29; // ecx@16 | |
9057 int v30; // edx@17 | |
9058 int v31; // [sp-Ch] [bp-ACh]@11 | |
9059 int v32; // [sp-Ch] [bp-ACh]@16 | |
9060 const char *v33; // [sp+0h] [bp-A0h]@0 | |
9061 int v34; // [sp+4h] [bp-9Ch]@0 | |
9062 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
9063 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
9064 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
9065 int v38; // [sp+90h] [bp-10h]@7 | |
9066 double v39; // [sp+94h] [bp-Ch]@6 | |
9067 float v40; // [sp+9Ch] [bp-4h]@6 | |
9068 | |
9069 auto ecx0 = this; | |
9070 v3 = 0; | |
9071 if ( ecx0->pRenderD3D ) | |
9072 { | |
9073 v4 = a3; | |
9074 if ( a3 <= 1.0 ) | |
9075 { | |
9076 if ( v4 < 0.0 ) | |
9077 v4 = 0.0; | |
9078 } | |
9079 else | |
9080 { | |
9081 v4 = 1.0; | |
9082 } | |
9083 a3 = v4 * 255.0; | |
9084 v39 = a3 + 6.7553994e15; | |
9085 LODWORD(v40) = LODWORD(v39); | |
693 | 9086 v5 = (double)(signed int)pViewport->uViewportTL_X; |
0 | 9087 v36[0].pos.x = v5; |
693 | 9088 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
0 | 9089 v7 = this_ | (LODWORD(v39) << 24); |
693 | 9090 this_ = pViewport->uViewportBR_Y + 1; |
0 | 9091 v36[0].specular = 0; |
9092 v36[0].pos.y = v6; | |
9093 v36[0].diffuse = v7; | |
9094 v36[1].diffuse = v7; | |
9095 v36[0].pos.z = 0.0; | |
9096 v36[2].diffuse = v7; | |
9097 v36[3].diffuse = v7; | |
9098 v36[0].rhw = 1.0; | |
9099 v36[1].specular = 0; | |
9100 v36[0].texcoord.x = 0.0; | |
9101 v36[2].specular = 0; | |
9102 v36[3].specular = 0; | |
9103 v36[0].texcoord.y = 0.0; | |
9104 v36[1].pos.x = v5; | |
693 | 9105 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 9106 v36[1].pos.y = v8; |
9107 v36[1].pos.z = 0.0; | |
9108 v36[1].rhw = 1.0; | |
9109 v36[1].texcoord.x = 0.0; | |
9110 v36[1].texcoord.y = 0.0; | |
693 | 9111 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 9112 v36[2].pos.x = v9; |
9113 v36[2].pos.y = v8; | |
9114 v36[2].pos.z = 0.0; | |
9115 v36[2].rhw = 1.0; | |
9116 v36[2].texcoord.x = 0.0; | |
9117 v36[2].texcoord.y = 0.0; | |
9118 v36[3].pos.x = v9; | |
9119 v36[3].pos.y = v6; | |
9120 v36[3].pos.z = 0.0; | |
9121 v36[3].rhw = 1.0; | |
9122 v36[3].texcoord.x = 0.0; | |
9123 v36[3].texcoord.y = 0.0; | |
9124 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 9125 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
9126 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9127 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9128 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
9129 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
9130 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9131 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 9132 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
9133 D3DPT_TRIANGLEFAN, | |
9134 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9135 v36, | |
9136 4, | |
9137 28)); | |
186 | 9138 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
9139 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9140 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9141 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9142 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9143 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
0 | 9144 } |
9145 else | |
9146 { | |
9147 v40 = (1.0 - a3) * 65536.0; | |
9148 v39 = v40 + 6.7553994e15; | |
9149 LODWORD(a3) = LODWORD(v39); | |
693 | 9150 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
9151 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
9152 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
9153 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 9154 v37 = 2 * v13; |
9155 LODWORD(v40) = (int)v14; | |
9156 | |
9157 int __i = 0; | |
9158 v15 = dword_F1B430; | |
9159 do | |
9160 { | |
9161 v16 = v3; | |
9162 v3 += LODWORD(a3); | |
9163 dword_F1B430[__i++] = v16 >> 16; | |
9164 } | |
9165 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
9166 while (__i < 32); | |
9167 | |
9168 if ( pRenderer->uTargetGBits == 6 ) | |
9169 { | |
9170 v17 = _42690D_colors_cvt(this_); | |
9171 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); | |
9172 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); | |
9173 v19 = v40; | |
9174 v20 = off_4EFDB0; | |
9175 v21 = HIDWORD(v39); | |
9176 do | |
9177 { | |
9178 v22 = v38; | |
9179 v31 = v21; | |
9180 do | |
9181 { | |
9182 v23 = (*(int *)((char *)v20 | |
9183 + ((((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; | |
9184 result = this_ | |
9185 + (*((int *)v20 | |
9186 + (((unsigned __int8)(*((char *)v20 | |
9187 + ((((unsigned __int16)(*(short *)((char *)v20 | |
9188 + ((*(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); | |
9189 *(unsigned int *)LODWORD(v19) = result; | |
9190 LODWORD(v19) += 4; | |
9191 --v22; | |
9192 } | |
9193 while ( v22 ); | |
9194 LODWORD(v19) += v37; | |
9195 v21 = v31 - 1; | |
9196 } | |
9197 while ( v31 != 1 ); | |
9198 } | |
9199 else | |
9200 { | |
9201 v24 = _4268E3_smthn_to_a1r5g5b5(this_); | |
9202 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); | |
9203 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
9204 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
9205 v26 = v40; | |
9206 v27 = (char *)off_4EFDB0; | |
9207 v28 = HIDWORD(v39); | |
9208 do | |
9209 { | |
9210 v29 = v38; | |
9211 v32 = v28; | |
9212 do | |
9213 { | |
9214 v30 = 32 | |
9215 * *(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; | |
9216 result = this_ | |
9217 + (*(int *)&v27[4 | |
9218 * (((unsigned __int8)(32 | |
9219 * 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); | |
9220 *(unsigned int *)LODWORD(v26) = result; | |
9221 LODWORD(v26) += 4; | |
9222 --v29; | |
9223 } | |
9224 while ( v29 ); | |
9225 LODWORD(v26) += v37; | |
9226 v28 = v32 - 1; | |
9227 } | |
9228 while ( v32 != 1 ); | |
9229 } | |
9230 } | |
9231 return result; | |
9232 } | |
9233 | |
9234 //----- (004A5B81) -------------------------------------------------------- | |
727 | 9235 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 9236 { |
9237 this->bClip = 1; | |
9238 this->uClipY = uY; | |
9239 this->uClipX = uX; | |
9240 this->uClipW = uW; | |
9241 this->uClipZ = uZ; | |
9242 } | |
9243 | |
9244 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 9245 void Render::ResetTextureClipRect() |
0 | 9246 { |
9247 this->uClipY = 0; | |
9248 this->uClipX = 0; | |
9249 this->bClip = 1; | |
9250 this->uClipW = 480; | |
9251 this->uClipZ = 640; | |
9252 } | |
9253 | |
9254 //----- (004A5BE3) -------------------------------------------------------- | |
9255 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
9256 { | |
9257 int v4; // edi@3 | |
9258 unsigned __int16 *v5; // edx@3 | |
9259 unsigned __int16 *v6; // esi@3 | |
9260 unsigned int v7; // ebx@4 | |
9261 unsigned int v8; // eax@5 | |
9262 unsigned int v9; // ebx@5 | |
9263 unsigned int v10; // eax@6 | |
9264 unsigned int v11; // eax@7 | |
9265 unsigned int v12; // ebx@8 | |
9266 unsigned int v13; // eax@10 | |
9267 unsigned int v14; // edi@11 | |
9268 unsigned int v15; // eax@14 | |
9269 unsigned int v16; // ebx@17 | |
9270 int v17; // eax@23 | |
9271 char v18; // zf@25 | |
9272 int v19; // [sp+10h] [bp-8h]@3 | |
9273 int v20; // [sp+14h] [bp-4h]@3 | |
9274 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
9275 int uOutXb; // [sp+20h] [bp+8h]@21 | |
9276 int v23; // [sp+28h] [bp+10h]@3 | |
9277 | |
9278 if ( this->uNumSceneBegins && a4 ) | |
9279 { | |
9280 v4 = a4->uWidth; | |
9281 v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
9282 v6 = a4->pPixels; | |
9283 v20 = v4; | |
9284 v23 = a4->uHeight; | |
9285 v19 = v4; | |
9286 if ( this->bClip ) | |
9287 { | |
9288 v7 = this->uClipX; | |
9289 if ( (signed int)uOutX < (signed int)v7 ) | |
9290 { | |
9291 v8 = v7 - uOutX; | |
9292 v9 = uOutX - v7; | |
9293 v8 *= 2; | |
9294 v4 += v9; | |
9295 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
9296 v20 += v9; | |
9297 v5 = (unsigned __int16 *)((char *)v5 + v8); | |
9298 } | |
9299 v10 = this->uClipY; | |
9300 if ( (signed int)uOutY < (signed int)v10 ) | |
9301 { | |
9302 v11 = v10 - uOutY; | |
9303 v6 += v19 * v11; | |
9304 v23 += uOutY - this->uClipY; | |
9305 v4 = v20; | |
9306 v5 += this->uTargetSurfacePitch * v11; | |
9307 } | |
9308 v12 = this->uClipX; | |
9309 if ( (signed int)v12 < (signed int)uOutX ) | |
9310 v12 = uOutX; | |
9311 v13 = this->uClipZ; | |
9312 if ( (signed int)(v4 + v12) > (signed int)v13 ) | |
9313 { | |
9314 v14 = this->uClipX; | |
9315 if ( (signed int)v14 < (signed int)uOutX ) | |
9316 v14 = uOutX; | |
9317 v4 = v13 - v14; | |
9318 } | |
9319 v15 = this->uClipY; | |
9320 if ( (signed int)v15 < (signed int)uOutY ) | |
9321 v15 = uOutY; | |
9322 uOutXa = this->uClipW; | |
9323 if ( (signed int)(v15 + v23) > (signed int)uOutXa ) | |
9324 { | |
9325 v16 = this->uClipY; | |
9326 if ( (signed int)v16 < (signed int)uOutY ) | |
9327 v16 = uOutY; | |
9328 v23 = uOutXa - v16; | |
9329 } | |
9330 } | |
9331 if ( v23 > 0 ) | |
9332 { | |
9333 uOutXb = v23; | |
9334 do | |
9335 { | |
9336 if ( v4 > 0 ) | |
9337 { | |
9338 v17 = v4; | |
9339 do | |
9340 { | |
9341 *v5 = *v6; | |
9342 ++v5; | |
9343 ++v6; | |
9344 --v17; | |
9345 } | |
9346 while ( v17 ); | |
9347 } | |
9348 v6 += v19 - v4; | |
9349 v18 = uOutXb-- == 1; | |
9350 v5 += this->uTargetSurfacePitch - v4; | |
9351 } | |
9352 while ( !v18 ); | |
9353 } | |
9354 } | |
9355 } | |
9356 | |
9357 //----- (004A5D33) -------------------------------------------------------- | |
9358 void Render::_4A5D33(unsigned int pX, unsigned int pY, int a4, int a5, RGBTexture *pTexture) | |
9359 { | |
9360 Render *v6; // esi@1 | |
9361 unsigned __int16 *v7; // ebx@3 | |
9362 int v8; // ecx@3 | |
9363 int v9; // edx@3 | |
9364 int v10; // ecx@3 | |
9365 int v11; // edi@3 | |
9366 signed int v12; // eax@4 | |
9367 unsigned int v13; // eax@5 | |
9368 signed int v14; // eax@6 | |
9369 unsigned int v15; // eax@7 | |
9370 unsigned int v16; // edx@8 | |
9371 int v17; // eax@10 | |
9372 unsigned int v18; // ecx@11 | |
9373 unsigned int v19; // ecx@14 | |
9374 int v20; // eax@16 | |
9375 unsigned int v21; // ecx@17 | |
9376 int v22; // eax@21 | |
9377 int v23; // edi@23 | |
9378 int v24; // [sp+Ch] [bp-4h]@3 | |
9379 int a2a; // [sp+18h] [bp+8h]@21 | |
9380 unsigned int teal; // [sp+1Ch] [bp+Ch]@20 | |
9381 int a4a; // [sp+20h] [bp+10h]@3 | |
9382 int a4b; // [sp+20h] [bp+10h]@21 | |
9383 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 | |
9384 | |
9385 v6 = this; | |
9386 if ( this->uNumSceneBegins && pTexture ) | |
9387 { | |
9388 v7 = &this->pTargetSurface[pX + pY * this->uTargetSurfacePitch]; | |
9389 v8 = pTexture->uWidth; | |
9390 v24 = pTexture->uWidth; | |
9391 v9 = a4 + a5 * v8; | |
9392 v10 = v8 - a4; | |
9393 a4a = v10; | |
9394 v11 = pTexture->uHeight - a5; | |
9395 pTexturea = &pTexture->pPixels[v9]; | |
9396 if ( v6->bClip ) | |
9397 { | |
9398 v12 = v6->uClipX; | |
9399 if ( (signed int)pX < v12 ) | |
9400 { | |
9401 v13 = 2 * (v12 - pX); | |
9402 pTexturea = (unsigned __int16 *)((char *)pTexturea + v13); | |
9403 v10 += pX - v6->uClipX; | |
9404 v7 = (unsigned __int16 *)((char *)v7 + v13); | |
9405 a4a = v10; | |
9406 } | |
9407 v14 = v6->uClipY; | |
9408 if ( (signed int)pY < v14 ) | |
9409 { | |
9410 v15 = v14 - pY; | |
9411 pTexturea += v24 * v15; | |
9412 v11 += pY - v6->uClipY; | |
9413 v10 = a4a; | |
9414 v7 += v6->uTargetSurfacePitch * v15; | |
9415 } | |
9416 v16 = v6->uClipX; | |
9417 if ( (signed int)v16 < (signed int)pX ) | |
9418 v16 = pX; | |
9419 v17 = v6->uClipZ; | |
9420 if ( (signed int)(v10 + v16) > v17 ) | |
9421 { | |
9422 v18 = v6->uClipX; | |
9423 if ( (signed int)v18 < (signed int)pX ) | |
9424 v18 = pX; | |
9425 a4a = v17 - v18; | |
9426 } | |
9427 v19 = v6->uClipY; | |
9428 if ( (signed int)v19 < (signed int)pY ) | |
9429 v19 = pY; | |
9430 v20 = v6->uClipW; | |
9431 if ( (signed int)(v11 + v19) > v20 ) | |
9432 { | |
9433 v21 = v6->uClipY; | |
9434 if ( (signed int)v21 < (signed int)pY ) | |
9435 v21 = pY; | |
9436 v11 = v20 - v21; | |
9437 } | |
9438 } | |
949 | 9439 teal = TargetColor(0, 0xFFu, 0xFFu); |
0 | 9440 if ( v11 > 0 ) |
9441 { | |
9442 v22 = a4a; | |
9443 a2a = v11; | |
9444 a4b = 2 * (v24 - a4a); | |
9445 do | |
9446 { | |
9447 if ( v22 > 0 ) | |
9448 { | |
9449 v23 = v22; | |
9450 do | |
9451 { | |
9452 if ( *pTexturea != teal ) | |
9453 *v7 = *pTexturea; | |
9454 ++pTexturea; | |
9455 ++v7; | |
9456 --v23; | |
9457 } | |
9458 while ( v23 ); | |
9459 } | |
9460 v7 += v6->uTargetSurfacePitch - v22; | |
9461 pTexturea = (unsigned __int16 *)((char *)pTexturea + a4b); | |
9462 --a2a; | |
9463 } | |
9464 while ( a2a ); | |
9465 } | |
9466 } | |
9467 } | |
9468 | |
9469 //----- (004A6E7E) -------------------------------------------------------- | |
9470 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) | |
9471 { | |
9472 unsigned __int16 *v4; // eax@4 | |
9473 int v5; // edx@4 | |
9474 unsigned int v6; // edi@4 | |
9475 unsigned int v7; // edx@5 | |
9476 unsigned int v8; // edx@6 | |
9477 unsigned int v9; // edx@7 | |
9478 unsigned int v10; // edx@8 | |
9479 unsigned int v11; // ebx@9 | |
9480 unsigned int v12; // esi@11 | |
9481 unsigned int v13; // edx@12 | |
9482 unsigned int v14; // ebx@15 | |
9483 unsigned int v15; // esi@17 | |
9484 unsigned int v16; // edi@18 | |
9485 char v17; // zf@29 | |
9486 int v18; // [sp+14h] [bp-Ch]@4 | |
9487 int v19; // [sp+18h] [bp-8h]@4 | |
9488 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
9489 int v21; // [sp+28h] [bp+8h]@25 | |
9490 int v22; // [sp+28h] [bp+8h]@34 | |
9491 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
9492 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
9493 | |
9494 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
9495 { | |
9496 v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 9497 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 9498 v5 = a4->uTextureWidth; |
9499 v6 = a4->uTextureHeight; | |
9500 v19 = a4->uTextureWidth; | |
9501 v18 = a4->uTextureWidth; | |
9502 if ( this->bClip ) | |
9503 { | |
9504 v7 = this->uClipX; | |
9505 if ( (signed int)a2 < (signed int)v7 ) | |
9506 { | |
9507 v8 = v7 - a2; | |
9508 v20 += v8; | |
9509 v19 += a2 - this->uClipX; | |
9510 v4 += v8; | |
9511 } | |
9512 v9 = this->uClipY; | |
9513 if ( (signed int)a3 < (signed int)v9 ) | |
9514 { | |
9515 v10 = v9 - a3; | |
9516 v20 += v18 * v10; | |
9517 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
9518 v4 += this->uTargetSurfacePitch * v10; | |
9519 } | |
9520 v11 = this->uClipX; | |
9521 v5 = v19; | |
9522 if ( (signed int)v11 < (signed int)a2 ) | |
9523 v11 = a2; | |
9524 v12 = this->uClipZ; | |
9525 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
9526 { | |
9527 v13 = this->uClipX; | |
9528 if ( (signed int)v13 < (signed int)a2 ) | |
9529 v13 = a2; | |
9530 v5 = v12 - v13; | |
9531 } | |
9532 v14 = this->uClipY; | |
9533 if ( (signed int)v14 < (signed int)a3 ) | |
9534 v14 = a3; | |
9535 v15 = this->uClipW; | |
9536 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
9537 { | |
9538 v16 = this->uClipY; | |
9539 if ( (signed int)v16 < (signed int)a3 ) | |
9540 v16 = a3; | |
9541 v6 = v15 - v16; | |
9542 } | |
9543 } | |
9544 if ( pRenderer->uTargetGBits == 5 ) | |
9545 { | |
9546 if ( (signed int)v6 > 0 ) | |
9547 { | |
9548 v23 = v6; | |
9549 do | |
9550 { | |
9551 if ( v5 > 0 ) | |
9552 { | |
9553 v21 = v5; | |
9554 do | |
9555 { | |
9556 if ( *v20 ) | |
9557 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
9558 ++v4; | |
9559 ++v20; | |
9560 --v21; | |
9561 } | |
9562 while ( v21 ); | |
9563 } | |
9564 v20 += v18 - v5; | |
9565 v17 = v23-- == 1; | |
9566 v4 += this->uTargetSurfacePitch - v5; | |
9567 } | |
9568 while ( !v17 ); | |
9569 } | |
9570 } | |
9571 else | |
9572 { | |
9573 if ( (signed int)v6 > 0 ) | |
9574 { | |
9575 v24 = v6; | |
9576 do | |
9577 { | |
9578 if ( v5 > 0 ) | |
9579 { | |
9580 v22 = v5; | |
9581 do | |
9582 { | |
9583 if ( *v20 ) | |
9584 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
9585 ++v4; | |
9586 ++v20; | |
9587 --v22; | |
9588 } | |
9589 while ( v22 ); | |
9590 } | |
9591 v20 += v18 - v5; | |
9592 v17 = v24-- == 1; | |
9593 v4 += this->uTargetSurfacePitch - v5; | |
9594 } | |
9595 while ( !v17 ); | |
9596 } | |
9597 } | |
9598 } | |
9599 } | |
9600 | |
9601 //----- (004A6DF5) -------------------------------------------------------- | |
9602 int Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) | |
9603 { | |
9604 int result; // eax@0 | |
9605 int v8; // ecx@3 | |
9606 unsigned __int16 *v9; // edi@4 | |
9607 unsigned __int16 *v10; // ebx@4 | |
9608 int v11; // esi@4 | |
9609 unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3 | |
9610 unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3 | |
9611 | |
9612 if ( pBitmap ) | |
9613 { | |
9614 if ( pTarget ) | |
9615 { | |
9616 pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y]; | |
9617 pTargeta = &pTarget[a7->x + uTargetPitch * a7->y]; | |
9618 v8 = a7->z - a7->x; | |
9619 result = a7->w - a7->y; | |
9620 if ( result > 0 ) | |
9621 { | |
9622 v9 = pBitmapa; | |
9623 v10 = pTargeta; | |
9624 v11 = a7->w - a7->y; | |
9625 do | |
9626 { | |
9627 if ( v8 > 0 ) | |
9628 { | |
9629 result = v8; | |
9630 do | |
9631 { | |
9632 *v9 = *v10; | |
9633 ++v9; | |
9634 ++v10; | |
9635 --result; | |
9636 } | |
9637 while ( result ); | |
9638 } | |
9639 v9 += uBitmapPitch - v8; | |
9640 v10 += uTargetPitch - v8; | |
9641 --v11; | |
9642 } | |
9643 while ( v11 ); | |
9644 } | |
9645 } | |
9646 } | |
9647 return result; | |
9648 } | |
9649 | |
9650 //----- (004A6D87) -------------------------------------------------------- | |
9651 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
9652 { | |
9653 if (!uNumSceneBegins) | |
9654 return; | |
9655 | |
9656 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
9657 for (uint y = 0; y < uHeight; ++y) | |
9658 { | |
9659 auto pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch]; | |
9660 | |
9661 memset32(pDst, twoColors, uWidth / 2); | |
9662 if (uWidth & 1) | |
9663 pDst[uWidth - 1] = uColor16; | |
9664 } | |
9665 } | |
9666 | |
9667 //----- (004A6C4F) -------------------------------------------------------- | |
9668 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) | |
9669 { | |
9670 unsigned int v9; // edi@2 | |
9671 unsigned int v10; // esi@2 | |
9672 unsigned __int16 *v11; // eax@2 | |
9673 unsigned int v12; // ebx@3 | |
9674 signed int v13; // edx@5 | |
9675 int v14; // edx@6 | |
9676 signed int v15; // ebx@7 | |
9677 unsigned int v16; // edx@9 | |
9678 signed int v17; // edi@10 | |
9679 signed int v18; // ebx@13 | |
9680 unsigned int v19; // edx@15 | |
9681 signed int v20; // esi@16 | |
9682 unsigned int v21; // esi@22 | |
9683 unsigned __int16 v22; // dx@24 | |
9684 char v23; // zf@28 | |
9685 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 | |
9686 unsigned int uOutXa; // [sp+18h] [bp+8h]@20 | |
9687 | |
9688 if ( this->uNumSceneBegins ) | |
9689 { | |
9690 v9 = uCharWidth; | |
9691 v10 = uCharHeight; | |
9692 v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
9693 v24 = pFontPixels; | |
9694 if ( this->bClip ) | |
9695 { | |
9696 v12 = this->uClipX; | |
9697 if ( uOutX < (signed int)v12 ) | |
9698 { | |
9699 v24 = &pFontPixels[v12 - uOutX]; | |
9700 v11 += v12 - uOutX; | |
9701 v9 = uCharWidth + uOutX - v12; | |
9702 } | |
9703 v13 = this->uClipY; | |
9704 if ( uOutY < v13 ) | |
9705 { | |
9706 v14 = v13 - uOutY; | |
9707 v24 += uCharWidth * v14; | |
9708 v10 = uCharHeight + uOutY - this->uClipY; | |
9709 v11 += this->uTargetSurfacePitch * v14; | |
9710 } | |
9711 v15 = this->uClipX; | |
9712 if ( v15 < uOutX ) | |
9713 v15 = uOutX; | |
9714 v16 = this->uClipZ; | |
9715 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
9716 { | |
9717 v17 = this->uClipX; | |
9718 if ( v17 < uOutX ) | |
9719 v17 = uOutX; | |
9720 v9 = v16 - v17; | |
9721 } | |
9722 v18 = this->uClipY; | |
9723 if ( v18 < uOutY ) | |
9724 v18 = uOutY; | |
9725 v19 = this->uClipW; | |
9726 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
9727 { | |
9728 v20 = this->uClipY; | |
9729 if ( v20 < uOutY ) | |
9730 v20 = uOutY; | |
9731 v10 = v19 - v20; | |
9732 } | |
9733 } | |
9734 if ( (signed int)v10 > 0 ) | |
9735 { | |
9736 uOutXa = v10; | |
9737 do | |
9738 { | |
9739 if ( (signed int)v9 > 0 ) | |
9740 { | |
9741 v21 = v9; | |
9742 do | |
9743 { | |
9744 if ( *v24 ) | |
9745 { | |
9746 v22 = uShadowColor; | |
9747 if ( *v24 != 1 ) | |
9748 v22 = uFaceColor; | |
9749 *v11 = v22; | |
9750 } | |
9751 ++v11; | |
9752 ++v24; | |
9753 --v21; | |
9754 } | |
9755 while ( v21 ); | |
9756 } | |
9757 v24 += uCharWidth - v9; | |
9758 v23 = uOutXa-- == 1; | |
9759 v11 += this->uTargetSurfacePitch - v9; | |
9760 } | |
9761 while ( !v23 ); | |
9762 } | |
9763 } | |
9764 } | |
9765 | |
9766 //----- (004A6A68) -------------------------------------------------------- | |
9767 void Render::_4A6A68(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) | |
9768 { | |
9769 Render *v5; // ebx@1 | |
9770 unsigned __int16 v6; // ax@1 | |
9771 | |
9772 v5 = this; | |
9773 | |
9774 Texture tex; // [sp+Ch] [bp-48h]@1 | |
9775 //Texture::Texture(&tex); | |
9776 | |
9777 v6 = a4->uTextureHeight - height; | |
9778 memcpy(&tex, a4, sizeof(tex)); | |
9779 tex.uTextureHeight = v6; | |
9780 if ( (signed __int16)v6 > 0 ) | |
9781 DrawTextureIndexed(a2, a3, &tex); | |
9782 } | |
9783 | |
9784 //----- (004A6AB1) -------------------------------------------------------- | |
9785 void Render::DrawTextPalette(int x, int y, int a4, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8) | |
9786 { | |
9787 int v8; // edi@2 | |
9788 unsigned int v9; // esi@2 | |
9789 unsigned __int16 *v10; // eax@2 | |
9790 unsigned char *v11; // edx@2 | |
9791 unsigned int v12; // ebx@3 | |
9792 signed int v13; // edx@5 | |
9793 int v14; // edx@6 | |
9794 signed int v15; // ebx@7 | |
9795 unsigned int v16; // edx@9 | |
9796 signed int v17; // edi@10 | |
9797 signed int v18; // ebx@13 | |
9798 unsigned int v19; // edx@15 | |
9799 signed int v20; // esi@16 | |
9800 int v21; // ebx@22 | |
9801 char v22; // zf@28 | |
9802 int v23; // ebx@31 | |
9803 unsigned __int16 v24; // si@35 | |
9804 int v25; // [sp+Ch] [bp-4h]@2 | |
9805 int v26; // [sp+1Ch] [bp+Ch]@24 | |
9806 int v27; // [sp+1Ch] [bp+Ch]@33 | |
9807 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
9808 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
9809 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
9810 | |
9811 auto a2 = x; | |
9812 auto a3 = y; | |
9813 auto a6 = uFontHeight; | |
9814 if ( this->uNumSceneBegins ) | |
9815 { | |
9816 v8 = a5; | |
9817 v9 = a6; | |
9818 v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; | |
9819 v11 = (unsigned char *)a4; | |
9820 v25 = a4; | |
9821 if ( this->bClip ) | |
9822 { | |
9823 v12 = this->uClipX; | |
9824 if ( a2 < (signed int)v12 ) | |
9825 { | |
9826 v25 = v12 - a2 + a4; | |
9827 v10 += v12 - a2; | |
9828 v8 = a5 + a2 - v12; | |
9829 } | |
9830 v13 = this->uClipY; | |
9831 if ( a3 < v13 ) | |
9832 { | |
9833 v14 = v13 - a3; | |
9834 v25 += a5 * v14; | |
9835 v9 = a6 + a3 - this->uClipY; | |
9836 v10 += this->uTargetSurfacePitch * v14; | |
9837 } | |
9838 v15 = this->uClipX; | |
9839 if ( v15 < a2 ) | |
9840 v15 = a2; | |
9841 v16 = this->uClipZ; | |
9842 if ( v8 + v15 > (signed int)v16 ) | |
9843 { | |
9844 v17 = this->uClipX; | |
9845 if ( v17 < a2 ) | |
9846 v17 = a2; | |
9847 v8 = v16 - v17; | |
9848 } | |
9849 v18 = this->uClipY; | |
9850 if ( v18 < a3 ) | |
9851 v18 = a3; | |
9852 v19 = this->uClipW; | |
9853 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
9854 { | |
9855 v20 = this->uClipY; | |
9856 if ( v20 < a3 ) | |
9857 v20 = a3; | |
9858 v9 = v19 - v20; | |
9859 } | |
9860 v11 = (unsigned char *)v25; | |
9861 } | |
9862 if ( a8 ) | |
9863 { | |
9864 v28 = pRenderer->uTargetGMask | pRenderer->uTargetBMask; | |
9865 if ( (signed int)v9 > 0 ) | |
9866 { | |
9867 v23 = a5; | |
9868 v30 = v9; | |
9869 do | |
9870 { | |
9871 if ( v8 > 0 ) | |
9872 { | |
9873 v27 = v8; | |
9874 do | |
9875 { | |
9876 if ( *v11 ) | |
9877 v24 = pPalette[*v11]; | |
9878 else | |
9879 v24 = v28; | |
9880 *v10 = v24; | |
9881 ++v10; | |
9882 ++v11; | |
9883 --v27; | |
9884 } | |
9885 while ( v27 ); | |
9886 } | |
9887 v11 += v23 - v8; | |
9888 v22 = v30-- == 1; | |
9889 v10 += this->uTargetSurfacePitch - v8; | |
9890 } | |
9891 while ( !v22 ); | |
9892 } | |
9893 } | |
9894 else | |
9895 { | |
9896 if ( (signed int)v9 > 0 ) | |
9897 { | |
9898 v21 = a5; | |
9899 v29 = v9; | |
9900 do | |
9901 { | |
9902 if ( v8 > 0 ) | |
9903 { | |
9904 v26 = v8; | |
9905 do | |
9906 { | |
9907 if ( *v11 ) | |
9908 *v10 = pPalette[*v11]; | |
9909 ++v10; | |
9910 ++v11; | |
9911 --v26; | |
9912 } | |
9913 while ( v26 ); | |
9914 } | |
9915 v11 += v21 - v8; | |
9916 v22 = v29-- == 1; | |
9917 v10 += this->uTargetSurfacePitch - v8; | |
9918 } | |
9919 while ( !v22 ); | |
9920 } | |
9921 } | |
9922 } | |
9923 } | |
9924 | |
9925 //----- (004A68EF) -------------------------------------------------------- | |
9926 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
9927 { | |
9928 Texture *v4; // edi@2 | |
9929 unsigned int v5; // ebx@4 | |
9930 unsigned __int16 *v6; // eax@4 | |
9931 signed int v7; // edx@5 | |
9932 int v8; // edx@6 | |
9933 signed int v9; // edx@7 | |
9934 int v10; // edx@8 | |
9935 signed int v11; // edx@9 | |
9936 signed int v12; // esi@12 | |
9937 signed int v13; // esi@15 | |
9938 unsigned int v14; // edx@17 | |
9939 signed int v15; // esi@18 | |
9940 unsigned __int8 *v16; // ebx@22 | |
9941 char v17; // zf@28 | |
9942 int v18; // [sp+10h] [bp-10h]@4 | |
9943 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
9944 int v20; // [sp+1Ch] [bp-4h]@4 | |
9945 int v21; // [sp+28h] [bp+8h]@24 | |
9946 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
9947 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
9948 | |
9949 if ( this->uNumSceneBegins ) | |
9950 { | |
9951 v4 = pTexture; | |
9952 if ( pTexture ) | |
9953 { | |
9954 if ( pTexture->pPalette16 ) | |
9955 { | |
9956 v5 = pTexture->uTextureHeight; | |
9957 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 9958 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 9959 v20 = pTexture->uTextureWidth; |
9960 v18 = pTexture->uTextureWidth; | |
9961 if ( this->bClip ) | |
9962 { | |
9963 v7 = this->uClipX; | |
9964 if ( a2 < v7 ) | |
9965 { | |
9966 v8 = v7 - a2; | |
9967 v19 += v8; | |
9968 v20 += a2 - this->uClipX; | |
9969 v6 += v8; | |
9970 } | |
9971 v9 = this->uClipY; | |
9972 v5 = pTexture->uTextureHeight; | |
9973 if ( a3 < v9 ) | |
9974 { | |
9975 v10 = v9 - a3; | |
9976 v19 += v18 * v10; | |
9977 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
9978 v4 = pTexture; | |
9979 v6 += this->uTargetSurfacePitch * v10; | |
9980 } | |
9981 v11 = this->uClipX; | |
9982 if ( v11 < a2 ) | |
9983 v11 = a2; | |
9984 pTexturea = this->uClipZ; | |
9985 if ( v11 + v20 > (signed int)pTexturea ) | |
9986 { | |
9987 v12 = this->uClipX; | |
9988 if ( v12 < a2 ) | |
9989 v12 = a2; | |
9990 v20 = pTexturea - v12; | |
9991 } | |
9992 v13 = this->uClipY; | |
9993 if ( v13 < a3 ) | |
9994 v13 = a3; | |
9995 v14 = this->uClipW; | |
9996 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
9997 { | |
9998 v15 = this->uClipY; | |
9999 if ( v15 < a3 ) | |
10000 v15 = a3; | |
10001 v5 = v14 - v15; | |
10002 } | |
10003 } | |
10004 if ( (signed int)v5 > 0 ) | |
10005 { | |
10006 v22 = v5; | |
10007 v16 = v19; | |
10008 do | |
10009 { | |
10010 if ( v20 > 0 ) | |
10011 { | |
10012 v21 = v20; | |
10013 do | |
10014 { | |
10015 if ( *v16 ) | |
10016 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
10017 ++v6; | |
10018 ++v16; | |
10019 --v21; | |
10020 } | |
10021 while ( v21 ); | |
10022 } | |
10023 v16 += v18 - v20; | |
10024 v17 = v22-- == 1; | |
10025 v6 += this->uTargetSurfacePitch - v20; | |
10026 } | |
10027 while ( !v17 ); | |
10028 } | |
10029 } | |
10030 } | |
10031 } | |
10032 } | |
10033 | |
10034 //----- (004A6776) -------------------------------------------------------- | |
315 | 10035 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 10036 { |
10037 Texture *v4; // edi@2 | |
10038 unsigned int v5; // ebx@4 | |
10039 unsigned __int16 *v6; // eax@4 | |
10040 unsigned int v7; // edx@5 | |
10041 unsigned int v8; // edx@6 | |
10042 unsigned int v9; // edx@7 | |
10043 unsigned int v10; // edx@8 | |
10044 unsigned int v11; // edx@9 | |
10045 unsigned int v12; // esi@12 | |
10046 unsigned int v13; // esi@15 | |
10047 unsigned int v14; // edx@17 | |
10048 unsigned int v15; // esi@18 | |
10049 unsigned __int8 *v16; // ebx@22 | |
10050 char v17; // zf@28 | |
10051 int v18; // [sp+10h] [bp-10h]@4 | |
10052 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10053 int v20; // [sp+1Ch] [bp-4h]@4 | |
10054 int a2a; // [sp+28h] [bp+8h]@24 | |
10055 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
10056 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
10057 | |
10058 if ( this->uNumSceneBegins ) | |
10059 { | |
10060 v4 = a4; | |
10061 if ( a4 ) | |
10062 { | |
10063 if ( a4->pPalette16 ) | |
10064 { | |
10065 v5 = a4->uTextureHeight; | |
10066 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 10067 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10068 v20 = a4->uTextureWidth; |
10069 v18 = a4->uTextureWidth; | |
10070 if ( this->bClip ) | |
10071 { | |
10072 v7 = this->uClipX; | |
10073 if ( (signed int)a2 < (signed int)v7 ) | |
10074 { | |
10075 v8 = v7 - a2; | |
10076 v19 += v8; | |
10077 v20 += a2 - this->uClipX; | |
10078 v6 += v8; | |
10079 } | |
10080 v9 = this->uClipY; | |
10081 v5 = a4->uTextureHeight; | |
10082 if ( (signed int)a3 < (signed int)v9 ) | |
10083 { | |
10084 v10 = v9 - a3; | |
10085 v19 += v18 * v10; | |
10086 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
10087 v4 = a4; | |
10088 v6 += this->uTargetSurfacePitch * v10; | |
10089 } | |
10090 v11 = this->uClipX; | |
10091 if ( (signed int)v11 < (signed int)a2 ) | |
10092 v11 = a2; | |
10093 a4a = this->uClipZ; | |
10094 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
10095 { | |
10096 v12 = this->uClipX; | |
10097 if ( (signed int)v12 < (signed int)a2 ) | |
10098 v12 = a2; | |
10099 v20 = a4a - v12; | |
10100 } | |
10101 v13 = this->uClipY; | |
10102 if ( (signed int)v13 < (signed int)a3 ) | |
10103 v13 = a3; | |
10104 v14 = this->uClipW; | |
10105 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10106 { | |
10107 v15 = this->uClipY; | |
10108 if ( (signed int)v15 < (signed int)a3 ) | |
10109 v15 = a3; | |
10110 v5 = v14 - v15; | |
10111 } | |
10112 } | |
10113 if ( (signed int)v5 > 0 ) | |
10114 { | |
10115 a3a = v5; | |
10116 v16 = v19; | |
10117 do | |
10118 { | |
10119 if ( v20 > 0 ) | |
10120 { | |
10121 a2a = v20; | |
10122 do | |
10123 { | |
10124 if ( *v16 ) | |
10125 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
10126 ++v6; | |
10127 ++v16; | |
10128 --a2a; | |
10129 } | |
10130 while ( a2a ); | |
10131 } | |
10132 v16 += v18 - v20; | |
10133 v17 = a3a-- == 1; | |
10134 v6 += this->uTargetSurfacePitch - v20; | |
10135 } | |
10136 while ( !v17 ); | |
10137 } | |
10138 } | |
10139 } | |
10140 } | |
10141 } | |
10142 | |
10143 //----- (004A65CC) -------------------------------------------------------- | |
10144 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
10145 { | |
10146 unsigned __int16 *v8; // esi@6 | |
10147 unsigned int v9; // edi@6 | |
10148 unsigned int v10; // eax@7 | |
10149 unsigned int v11; // eax@8 | |
10150 unsigned int v12; // eax@9 | |
10151 unsigned int v13; // eax@10 | |
10152 unsigned int v14; // edx@11 | |
10153 unsigned int v15; // eax@13 | |
10154 unsigned int v16; // edx@14 | |
10155 unsigned int v17; // edx@17 | |
10156 unsigned int v18; // eax@19 | |
10157 unsigned int v19; // edx@20 | |
10158 int v20; // eax@27 | |
10159 int v21; // edx@29 | |
10160 int v22; // [sp+Ch] [bp-Ch]@6 | |
10161 int v23; // [sp+Ch] [bp-Ch]@24 | |
10162 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
10163 int xa; // [sp+20h] [bp+8h]@26 | |
10164 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
10165 int v27; // [sp+2Ch] [bp+14h]@6 | |
10166 | |
10167 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
10168 { | |
10169 v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch]; | |
710 | 10170 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10171 v27 = a4->uTextureWidth; |
10172 v9 = a4->uTextureHeight; | |
10173 v22 = a4->uTextureWidth; | |
10174 if ( this->bClip ) | |
10175 { | |
10176 v10 = this->uClipX; | |
10177 if ( (signed int)x < (signed int)v10 ) | |
10178 { | |
10179 v11 = v10 - x; | |
10180 v24 += v11; | |
10181 v27 += x - this->uClipX; | |
10182 v8 += v11; | |
10183 } | |
10184 v12 = this->uClipY; | |
10185 if ( (signed int)y < (signed int)v12 ) | |
10186 { | |
10187 v13 = v12 - y; | |
10188 v24 += v22 * v13; | |
10189 v9 = y - this->uClipY + a4->uTextureHeight; | |
10190 v8 += this->uTargetSurfacePitch * v13; | |
10191 } | |
10192 v14 = this->uClipX; | |
10193 if ( (signed int)v14 < (signed int)x ) | |
10194 v14 = x; | |
10195 v15 = this->uClipZ; | |
10196 if ( (signed int)(v27 + v14) > (signed int)v15 ) | |
10197 { | |
10198 v16 = this->uClipX; | |
10199 if ( (signed int)v16 < (signed int)x ) | |
10200 v16 = x; | |
10201 v27 = v15 - v16; | |
10202 } | |
10203 v17 = this->uClipY; | |
10204 if ( (signed int)v17 < (signed int)y ) | |
10205 v17 = y; | |
10206 v18 = this->uClipW; | |
10207 if ( (signed int)(v9 + v17) > (signed int)v18 ) | |
10208 { | |
10209 v19 = this->uClipY; | |
10210 if ( (signed int)v19 < (signed int)y ) | |
10211 v19 = y; | |
10212 v9 = v18 - v19; | |
10213 } | |
10214 } | |
10215 if ( (signed int)v9 > 0 ) | |
10216 { | |
10217 ya = v9; | |
10218 v23 = v22 - v27; | |
10219 do | |
10220 { | |
10221 if ( v27 > 0 ) | |
10222 { | |
10223 xa = v27; | |
10224 do | |
10225 { | |
10226 v20 = *v24; | |
10227 if ( v20 >= a7 && v20 <= a8 ) | |
10228 { | |
10229 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
10230 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
10231 v21 = 2 * a8 - v21 - a7; | |
10232 *v8 = a4->pPalette16[v21]; | |
10233 } | |
10234 ++v8; | |
10235 ++v24; | |
10236 --xa; | |
10237 } | |
10238 while ( xa ); | |
10239 } | |
10240 v8 += this->uTargetSurfacePitch - v27; | |
10241 v24 += v23; | |
10242 --ya; | |
10243 } | |
10244 while ( ya ); | |
10245 } | |
10246 } | |
10247 } | |
10248 | |
10249 //----- (004A63E6) -------------------------------------------------------- | |
10250 void Render::_4A63E6(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
10251 { | |
10252 Texture *v8; // eax@2 | |
10253 Texture *v9; // ebx@4 | |
10254 unsigned __int16 *v10; // esi@6 | |
10255 unsigned int v11; // edi@7 | |
10256 unsigned int v12; // eax@9 | |
10257 unsigned int v13; // eax@10 | |
10258 unsigned int v14; // edx@11 | |
10259 unsigned int v15; // eax@13 | |
10260 unsigned int v16; // edx@14 | |
10261 unsigned int v17; // edx@17 | |
10262 unsigned int v18; // eax@19 | |
10263 unsigned int v19; // edx@20 | |
10264 int v20; // eax@27 | |
10265 int v21; // edx@29 | |
10266 int v22; // [sp+Ch] [bp-Ch]@6 | |
10267 int v23; // [sp+Ch] [bp-Ch]@24 | |
10268 int v24; // [sp+10h] [bp-8h]@6 | |
10269 int v25; // [sp+14h] [bp-4h]@6 | |
10270 int i; // [sp+20h] [bp+8h]@25 | |
10271 int v27; // [sp+24h] [bp+Ch]@23 | |
10272 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
10273 | |
10274 if ( this->uNumSceneBegins ) | |
10275 { | |
10276 v8 = a4; | |
10277 if ( a4 ) | |
10278 { | |
10279 if ( a4->pPalette16 ) | |
10280 { | |
10281 v9 = a5; | |
10282 if ( a5 ) | |
10283 { | |
10284 if ( a5->pPalette16 ) | |
10285 { | |
10286 v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 10287 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10288 v25 = v8->uTextureWidth; |
10289 v24 = v8->uTextureHeight; | |
10290 v22 = v8->uTextureWidth; | |
10291 if ( this->bClip ) | |
10292 { | |
10293 v11 = this->uClipX; | |
10294 if ( (signed int)a2 < (signed int)v11 ) | |
10295 { | |
10296 v28 += v11 - a2; | |
10297 v25 += a2 - v11; | |
10298 v9 = a5; | |
10299 v10 += v11 - a2; | |
10300 } | |
10301 v12 = this->uClipY; | |
10302 if ( (signed int)a3 < (signed int)v12 ) | |
10303 { | |
10304 v13 = v12 - a3; | |
10305 v9 = a5; | |
10306 v28 += v22 * v13; | |
10307 v24 += a3 - this->uClipY; | |
10308 v10 += this->uTargetSurfacePitch * v13; | |
10309 } | |
10310 v14 = this->uClipX; | |
10311 if ( (signed int)v14 < (signed int)a2 ) | |
10312 v14 = a2; | |
10313 v15 = this->uClipZ; | |
10314 if ( (signed int)(v25 + v14) > (signed int)v15 ) | |
10315 { | |
10316 v16 = this->uClipX; | |
10317 if ( (signed int)v16 < (signed int)a2 ) | |
10318 v16 = a2; | |
10319 v25 = v15 - v16; | |
10320 } | |
10321 v17 = this->uClipY; | |
10322 if ( (signed int)v17 < (signed int)a3 ) | |
10323 v17 = a3; | |
10324 v18 = this->uClipW; | |
10325 if ( (signed int)(v24 + v17) > (signed int)v18 ) | |
10326 { | |
10327 v19 = this->uClipY; | |
10328 if ( (signed int)v19 < (signed int)a3 ) | |
10329 v19 = a3; | |
10330 v24 = v18 - v19; | |
10331 } | |
10332 } | |
10333 v27 = 0; | |
10334 if ( v24 > 0 ) | |
10335 { | |
10336 v23 = v22 - v25; | |
10337 do | |
10338 { | |
10339 for ( i = 0; i < v25; ++v28 ) | |
10340 { | |
10341 if ( *v28 ) | |
10342 { | |
710 | 10343 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 10344 if ( v20 >= a7 ) |
10345 { | |
10346 if ( v20 <= a8 ) | |
10347 { | |
10348 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
10349 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
10350 v21 = 2 * a8 - v21 - a7; | |
10351 v9 = a5; | |
10352 *v10 = a5->pPalette16[v21]; | |
10353 } | |
10354 } | |
10355 } | |
10356 ++i; | |
10357 ++v10; | |
10358 } | |
10359 ++v27; | |
10360 v10 += this->uTargetSurfacePitch - v25; | |
10361 v28 += v23; | |
10362 } | |
10363 while ( v27 < v24 ); | |
10364 } | |
10365 } | |
10366 } | |
10367 } | |
10368 } | |
10369 } | |
10370 } | |
10371 | |
10372 //----- (004A6274) -------------------------------------------------------- | |
10373 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
10374 { | |
10375 Texture *pCurrentTexture; // edi@2 | |
10376 int uHeight; // ebx@4 | |
10377 unsigned __int16 *v6; // eax@4 | |
10378 unsigned int v7; // edx@5 | |
10379 unsigned int v8; // edx@6 | |
10380 unsigned int v9; // edx@7 | |
10381 unsigned int v10; // edx@8 | |
10382 unsigned int v11; // edx@9 | |
10383 unsigned int v12; // esi@12 | |
10384 unsigned int v13; // esi@15 | |
10385 unsigned int v14; // edx@17 | |
10386 unsigned int v15; // esi@18 | |
10387 unsigned __int8 *v16; // ebx@22 | |
10388 char uFlag; // zf@28 | |
10389 int v18; // [sp+10h] [bp-10h]@4 | |
10390 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10391 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
10392 int uXa; // [sp+28h] [bp+8h]@24 | |
10393 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
10394 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
10395 | |
10396 if ( this->uNumSceneBegins ) | |
10397 { | |
10398 pCurrentTexture = pTexture; | |
10399 if ( pTexture ) | |
10400 { | |
10401 if ( pTexture->pPalette16 ) | |
10402 { | |
10403 uHeight = pTexture->uTextureHeight; | |
10404 v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 10405 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10406 uWidth = pTexture->uTextureWidth; |
10407 v18 = pTexture->uTextureWidth; | |
10408 if ( this->bClip ) | |
10409 { | |
10410 v7 = this->uClipX; | |
10411 if ( (signed int)uX < (signed int)v7 ) | |
10412 { | |
10413 v8 = v7 - uX; | |
10414 v19 += v8; | |
10415 uWidth += uX - this->uClipX; | |
10416 v6 += v8; | |
10417 } | |
10418 v9 = this->uClipY; | |
10419 uHeight = pTexture->uTextureHeight; | |
10420 if ( (signed int)uY < (signed int)v9 ) | |
10421 { | |
10422 v10 = v9 - uY; | |
10423 v19 += v18 * v10; | |
10424 uHeight = uY - this->uClipY + pTexture->uTextureHeight; | |
10425 pCurrentTexture = pTexture; | |
10426 v6 += this->uTargetSurfacePitch * v10; | |
10427 } | |
10428 v11 = this->uClipX; | |
10429 if ( (signed int)v11 < (signed int)uX ) | |
10430 v11 = uX; | |
10431 pTexturea = this->uClipZ; | |
10432 if ( (signed int)(v11 + uWidth) > (signed int)pTexturea ) | |
10433 { | |
10434 v12 = this->uClipX; | |
10435 if ( (signed int)v12 < (signed int)uX ) | |
10436 v12 = uX; | |
10437 uWidth = pTexturea - v12; | |
10438 } | |
10439 v13 = this->uClipY; | |
10440 if ( (signed int)v13 < (signed int)uY ) | |
10441 v13 = uY; | |
10442 v14 = this->uClipW; | |
10443 if ( (signed int)(uHeight + v13) > (signed int)v14 ) | |
10444 { | |
10445 v15 = this->uClipY; | |
10446 if ( (signed int)v15 < (signed int)uY ) | |
10447 v15 = uY; | |
10448 uHeight = v14 - v15; | |
10449 } | |
10450 } | |
10451 if ( (signed int)uHeight > 0 ) | |
10452 { | |
10453 uYa = uHeight; | |
10454 v16 = v19; | |
10455 do | |
10456 { | |
10457 if ( uWidth > 0 ) | |
10458 { | |
10459 uXa = uWidth; | |
10460 do | |
10461 { | |
10462 if ( *v16 ) | |
10463 *v6 = pCurrentTexture->pPalette16[*v16]; | |
10464 ++v6; | |
10465 ++v16; | |
10466 } | |
10467 while ( uXa-- !=1 ); | |
10468 } | |
10469 v16 += v18 - uWidth; | |
10470 uFlag = uYa-- == 1; | |
10471 v6 += this->uTargetSurfacePitch - uWidth; | |
10472 } | |
10473 while ( !uFlag ); | |
10474 } | |
10475 } | |
10476 } | |
10477 } | |
10478 } | |
10479 | |
10480 //----- (004A612A) -------------------------------------------------------- | |
710 | 10481 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 10482 { |
10483 Texture *v5; // eax@2 | |
10484 unsigned int v6; // edx@3 | |
10485 int v7; // ebx@3 | |
10486 int v8; // edi@3 | |
10487 signed int v9; // eax@4 | |
10488 int v10; // eax@5 | |
10489 unsigned int v11; // esi@6 | |
10490 signed int v12; // esi@8 | |
10491 unsigned int v13; // eax@10 | |
10492 signed int v14; // esi@11 | |
10493 unsigned int v15; // esi@14 | |
10494 unsigned int v16; // eax@16 | |
10495 unsigned int v17; // ecx@17 | |
10496 int v18; // edx@23 | |
10497 int v19; // [sp+Ch] [bp-Ch]@3 | |
10498 int v20; // [sp+10h] [bp-8h]@3 | |
10499 int uOutXa; // [sp+20h] [bp+8h]@21 | |
10500 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
10501 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
10502 | |
10503 if ( this->uNumSceneBegins ) | |
10504 { | |
10505 v5 = pTexture; | |
10506 if ( pTexture ) | |
10507 { | |
10508 v6 = uOutY; | |
10509 v7 = pTexture->uTextureHeight; | |
10510 pZBuffer = &this->pActiveZBuffer[uOutX + 640 * uOutY]; | |
710 | 10511 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10512 v8 = v5->uTextureWidth; |
10513 v20 = v5->uTextureWidth; | |
10514 v19 = v5->uTextureWidth; | |
10515 if ( this->bClip ) | |
10516 { | |
10517 v9 = this->uClipX; | |
10518 if ( uOutX < v9 ) | |
10519 { | |
10520 v10 = v9 - uOutX; | |
10521 uOutYa += v10; | |
10522 v8 += uOutX - this->uClipX; | |
10523 v20 = v8; | |
10524 pZBuffer += v10; | |
10525 } | |
10526 v11 = this->uClipY; | |
10527 if ( (signed int)v6 < (signed int)v11 ) | |
10528 { | |
10529 uOutYa += v19 * (v11 - v6); | |
10530 v7 += v6 - v11; | |
10531 pZBuffer += 640 * (v11 - v6); | |
10532 v8 = v20; | |
10533 } | |
10534 v12 = this->uClipX; | |
10535 if ( v12 < uOutX ) | |
10536 v12 = uOutX; | |
10537 v13 = this->uClipZ; | |
10538 if ( v8 + v12 > (signed int)v13 ) | |
10539 { | |
10540 v14 = this->uClipX; | |
10541 if ( v14 < uOutX ) | |
10542 v14 = uOutX; | |
10543 v8 = v13 - v14; | |
10544 } | |
10545 v15 = this->uClipY; | |
10546 if ( (signed int)v15 < (signed int)v6 ) | |
10547 v15 = v6; | |
10548 v16 = this->uClipW; | |
10549 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
10550 { | |
10551 v17 = this->uClipY; | |
10552 if ( (signed int)v17 >= (signed int)v6 ) | |
10553 v6 = v17; | |
10554 v7 = v16 - v6; | |
10555 } | |
10556 } | |
10557 if ( v7 > 0 ) | |
10558 { | |
10559 uOutXa = v7; | |
10560 do | |
10561 { | |
10562 if ( v8 > 0 ) | |
10563 { | |
10564 v18 = v8; | |
10565 do | |
10566 { | |
10567 if ( *uOutYa ) | |
10568 *pZBuffer = zVal; | |
10569 ++pZBuffer; | |
10570 ++uOutYa; | |
10571 --v18; | |
10572 } | |
10573 while ( v18 ); | |
10574 } | |
10575 pZBuffer += 640 - v8; | |
10576 uOutYa += v19 - v8; | |
10577 --uOutXa; | |
10578 } | |
10579 while ( uOutXa ); | |
10580 } | |
10581 } | |
10582 } | |
10583 } | |
10584 | |
10585 //----- (004A601E) -------------------------------------------------------- | |
10586 void Render::_4A601E(signed int a2, signed int a3, Texture *pTexture, int a5) | |
10587 { | |
10588 signed int v5; // edx@3 | |
10589 int v6; // ebx@3 | |
10590 int v7; // esi@3 | |
10591 void *v8; // esi@3 | |
10592 unsigned int v9; // eax@4 | |
10593 unsigned int v10; // eax@6 | |
10594 signed int v11; // edi@8 | |
10595 unsigned int v12; // eax@10 | |
10596 signed int v13; // edi@11 | |
10597 unsigned int v14; // edi@14 | |
10598 unsigned int v15; // eax@16 | |
10599 unsigned int v16; // ecx@17 | |
10600 int v17; // [sp+18h] [bp+Ch]@3 | |
10601 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
10602 | |
10603 if ( this->uNumSceneBegins && pTexture ) | |
10604 { | |
10605 v5 = a3; | |
10606 v6 = pTexture->uTextureHeight; | |
10607 v7 = 5 * a3; | |
10608 v17 = pTexture->uTextureHeight; | |
10609 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
10610 pTexturea = pTexture->uTextureWidth; | |
10611 if ( this->bClip ) | |
10612 { | |
10613 v9 = this->uClipX; | |
10614 if ( a2 < (signed int)v9 ) | |
10615 { | |
10616 pTexturea += a2 - v9; | |
10617 v8 = (char *)v8 + 4 * (v9 - a2); | |
10618 } | |
10619 v10 = this->uClipY; | |
10620 if ( v5 < (signed int)v10 ) | |
10621 { | |
10622 v17 += v5 - v10; | |
10623 v8 = (char *)v8 + 2560 * (v10 - v5); | |
10624 } | |
10625 v11 = this->uClipX; | |
10626 if ( v11 < a2 ) | |
10627 v11 = a2; | |
10628 v12 = this->uClipZ; | |
10629 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
10630 { | |
10631 v13 = this->uClipX; | |
10632 if ( v13 < a2 ) | |
10633 v13 = a2; | |
10634 pTexturea = v12 - v13; | |
10635 } | |
10636 v14 = this->uClipY; | |
10637 if ( (signed int)v14 < v5 ) | |
10638 v14 = v5; | |
10639 v6 = v17; | |
10640 v15 = this->uClipW; | |
10641 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
10642 { | |
10643 v16 = this->uClipY; | |
10644 if ( (signed int)v16 < v5 ) | |
10645 v16 = v5; | |
10646 v6 = v15 - v16; | |
10647 } | |
10648 } | |
10649 if ( v6 > 0 ) | |
10650 { | |
10651 do | |
10652 { | |
10653 if ( (signed int)pTexturea > 0 ) | |
10654 { | |
10655 memset32(v8, a5, pTexturea); | |
10656 v8 = (char *)v8 + 4 * pTexturea; | |
10657 } | |
10658 v8 = (char *)v8 + 4 * (640 - pTexturea); | |
10659 --v6; | |
10660 } | |
10661 while ( v6 ); | |
10662 } | |
10663 } | |
10664 } | |
10665 | |
10666 //----- (004A5EB2) -------------------------------------------------------- | |
10667 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
10668 { | |
10669 Texture *v4; // edi@2 | |
10670 unsigned int v5; // ebx@4 | |
10671 unsigned __int16 *pTarget; // eax@4 | |
10672 unsigned int v7; // edx@5 | |
10673 unsigned int v8; // edx@6 | |
10674 unsigned int v9; // edx@7 | |
10675 unsigned int v10; // edx@8 | |
10676 unsigned int v11; // edx@9 | |
10677 unsigned int v12; // esi@12 | |
10678 unsigned int v13; // esi@15 | |
10679 unsigned int v14; // edx@17 | |
10680 unsigned int v15; // esi@18 | |
10681 unsigned __int8 *v16; // edx@22 | |
10682 char v17; // zf@26 | |
10683 int v18; // [sp+10h] [bp-10h]@4 | |
10684 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10685 int v20; // [sp+1Ch] [bp-4h]@4 | |
10686 int uXa; // [sp+28h] [bp+8h]@24 | |
10687 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
10688 unsigned int v23; // [sp+30h] [bp+10h]@11 | |
10689 | |
10690 if ( this->uNumSceneBegins ) | |
10691 { | |
10692 v4 = a4; | |
10693 if ( a4 ) | |
10694 { | |
10695 if ( a4->pPalette16 ) | |
10696 { | |
10697 v5 = a4->uTextureHeight; | |
10698 pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 10699 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10700 v20 = a4->uTextureWidth; |
10701 v18 = a4->uTextureWidth; | |
10702 if ( this->bClip ) | |
10703 { | |
10704 v7 = this->uClipX; | |
10705 if ( (signed int)uX < (signed int)v7 ) | |
10706 { | |
10707 v8 = v7 - uX; | |
10708 v19 += v8; | |
10709 v20 += uX - this->uClipX; | |
10710 pTarget += v8; | |
10711 } | |
10712 v9 = this->uClipY; | |
10713 v5 = a4->uTextureHeight; | |
10714 if ( (signed int)uY < (signed int)v9 ) | |
10715 { | |
10716 v10 = v9 - uY; | |
10717 v19 += v18 * v10; | |
10718 v5 = uY - this->uClipY + a4->uTextureHeight; | |
10719 v4 = a4; | |
10720 pTarget += this->uTargetSurfacePitch * v10; | |
10721 } | |
10722 v11 = this->uClipX; | |
10723 if ( (signed int)v11 < (signed int)uX ) | |
10724 v11 = uX; | |
10725 v23 = this->uClipZ; | |
10726 if ( (signed int)(v11 + v20) > (signed int)v23 ) | |
10727 { | |
10728 v12 = this->uClipX; | |
10729 if ( (signed int)v12 < (signed int)uX ) | |
10730 v12 = uX; | |
10731 v20 = v23 - v12; | |
10732 } | |
10733 v13 = this->uClipY; | |
10734 if ( (signed int)v13 < (signed int)uY ) | |
10735 v13 = uY; | |
10736 v14 = this->uClipW; | |
10737 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10738 { | |
10739 v15 = this->uClipY; | |
10740 if ( (signed int)v15 < (signed int)uY ) | |
10741 v15 = uY; | |
10742 v5 = v14 - v15; | |
10743 } | |
10744 } | |
10745 if ( (signed int)v5 > 0 ) | |
10746 { | |
10747 uYa = v5; | |
10748 v16 = v19; | |
10749 do | |
10750 { | |
10751 if ( v20 > 0 ) | |
10752 { | |
10753 uXa = v20; | |
10754 do | |
10755 { | |
10756 *pTarget = v4->pPalette16[*v16]; | |
10757 ++pTarget; | |
10758 ++v16; | |
10759 --uXa; | |
10760 } | |
10761 while ( uXa ); | |
10762 } | |
10763 v16 += v18 - v20; | |
10764 v17 = uYa-- == 1; | |
10765 pTarget += this->uTargetSurfacePitch - v20; | |
10766 } | |
10767 while ( !v17 ); | |
10768 } | |
10769 } | |
10770 } | |
10771 } | |
10772 } | |
10773 | |
10774 //----- (004667E9) -------------------------------------------------------- | |
10775 void Render::ChangeBetweenWinFullscreenModes() | |
10776 { | |
10777 float v0; // ST14_4@17 | |
10778 int v1; // edx@24 | |
10779 signed int v2; // ecx@24 | |
10780 int v3; // esi@25 | |
10781 int v4; // edx@26 | |
10782 ObjectDesc *v5; // eax@26 | |
10783 RGBTexture *v6; // esi@33 | |
10784 const char *v7; // eax@34 | |
10785 const char *v8; // [sp-4h] [bp-28h]@33 | |
10786 int v9; // [sp+0h] [bp-24h]@33 | |
10787 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
10788 | |
10789 if ( pRenderer->bWindowMode ) | |
10790 goto LABEL_52; | |
10791 if ( dword_6BE364_game_settings_1 & 2 ) | |
10792 { | |
10793 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." | |
10794 return; | |
10795 } | |
10796 if ( !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) | |
10797 { | |
10798 LABEL_52: | |
10799 if ( pEventTimer->bPaused ) | |
10800 BYTE1(dword_6BE364_game_settings_1) |= 8u; | |
10801 else | |
10802 pEventTimer->Pause(); | |
10803 if ( pMiscTimer->bPaused ) | |
10804 BYTE1(dword_6BE364_game_settings_1) |= 0x10u; | |
10805 else | |
10806 pMiscTimer->Pause(); | |
10807 pMouse->bActive = 0; | |
10808 if ( pRenderer->pRenderD3D ) | |
10809 { | |
10810 pBitmaps_LOD->ReleaseHardwareTextures(); | |
10811 pSprites_LOD->ReleaseAll(); | |
10812 } | |
10813 if ( pRenderer->bWindowMode ) | |
10814 { | |
10815 if ( GetWindowRect(hWnd, &Rect) ) | |
10816 { | |
10817 WriteWindowsRegistryInt("window X", Rect.left); | |
10818 WriteWindowsRegistryInt("window Y", Rect.top); | |
10819 uWindowX = Rect.left; | |
10820 uWindowY = Rect.top; | |
10821 } | |
10822 SetMenu(hWnd, 0); | |
10823 SetWindowLongA(hWnd, -20, 0); | |
10824 SetWindowLongA(hWnd, -16, 0x10000000u); | |
10825 pRenderer->InitializeFullscreen(hWnd); | |
10826 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; | |
10827 pGame->pGammaController->Initialize(v0); | |
10828 } | |
10829 else | |
10830 { | |
10831 ClipCursor(0); | |
10832 pRenderer->SwitchToWindow(hWnd); | |
10833 SetWindowLongA(hWnd, -16, uWindowStyle); | |
10834 SetMenu(hWnd, hOSMenu); | |
10835 } | |
10836 if ( pRenderer->pRenderD3D ) | |
10837 { | |
10838 pBitmaps_LOD->_410423_move_textures_to_device(); | |
10839 pSprites_LOD->MoveSpritesToVideoMemory(); | |
10840 } | |
10841 if ( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits | |
10842 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits | |
10843 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits ) | |
10844 goto LABEL_38; | |
10845 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10846 pPaletteManager->RecalculateAll(); | |
10847 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10848 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10849 v2 = 0; | |
10850 if ( (signed int)pObjectList->uNumObjects > 0 ) | |
10851 { | |
10852 v3 = 0; | |
10853 do | |
10854 { | |
10855 BYTE3(v4) = 0; | |
10856 v5 = &pObjectList->pObjects[v3]; | |
10857 ++v3; | |
10858 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; | |
10859 LOBYTE(v4) = v5->uParticleTrailColorG; | |
10860 v1 = v5->uParticleTrailColorB | (v4 << 8); | |
10861 ++v2; | |
10862 v5->uParticleTrailColor = v1; | |
10863 } | |
10864 while ( v2 < (signed int)pObjectList->uNumObjects ); | |
10865 } | |
10866 LOBYTE(v1) = 1; | |
373 | 10867 SetUserInterface(pParty->alignment, v1); |
0 | 10868 if ( pVideoPlayer->pVideoFrame.pPixels ) |
10869 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); | |
10870 if ( uCurrentMenuID ) | |
10871 { | |
10872 if ( uCurrentMenuID != 6 ) | |
10873 { | |
10874 if ( uCurrentMenuID == 8 ) | |
10875 dword_A74C88 = 1; | |
10876 goto LABEL_38; | |
10877 } | |
10878 v6 = &pTexture_PCX; | |
10879 pTexture_PCX.Release(); | |
10880 v9 = 0; | |
10881 v8 = "makeme.pcx"; | |
10882 } | |
10883 else | |
10884 { | |
10885 v6 = &pTexture_PCX; | |
10886 pTexture_PCX.Release(); | |
10887 v7 = "title.pcx"; | |
10888 if ( uCurrentMenuID ) | |
10889 v7 = "lsave640.pcx"; | |
10890 v9 = 0; | |
10891 v8 = v7; | |
10892 } | |
10893 v6->Load(v8, v9); | |
10894 LABEL_38: | |
10895 viewparams->bRedrawGameUI = 1; | |
688 | 10896 viewparams->InitGrayPalette(); |
0 | 10897 pMouse->SetCurrentCursorBitmap(); |
10898 if ( pRenderer->bWindowMode ) | |
10899 { | |
10900 InvalidateRect(0, 0, 0); | |
10901 MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); | |
10902 ShowWindow(hWnd, 1); | |
10903 } | |
10904 pMouse->bActive = 1; | |
10905 if ( pVideoPlayer->AnyMovieLoaded() ) | |
898 | 10906 pVideoPlayer->SelectMovieType(); |
0 | 10907 if ( BYTE1(dword_6BE364_game_settings_1) & 8 ) |
10908 BYTE1(dword_6BE364_game_settings_1) &= 0xF7u; | |
10909 else | |
10910 pEventTimer->Resume(); | |
10911 if ( BYTE1(dword_6BE364_game_settings_1) & 0x10 ) | |
10912 BYTE1(dword_6BE364_game_settings_1) &= 0xEFu; | |
10913 else | |
10914 pMiscTimer->Resume(); | |
10915 pAsyncMouse->Release(); | |
10916 CreateAsyncMouse(); | |
10917 if (pAsyncMouse) | |
10918 pAsyncMouse->Clip(); | |
10919 } | |
10920 } | |
10921 // 6BE364: using guessed type int dword_6BE364_game_settings_1; | |
10922 // A74C88: using guessed type int dword_A74C88; | |
10923 | |
10924 //----- (0044EC20) -------------------------------------------------------- | |
10925 bool RenderD3D::DoesRaiseExceptions() | |
10926 { | |
10927 return true; | |
10928 } | |
10929 | |
10930 //----- (0040DBD3) -------------------------------------------------------- | |
10931 void __fastcall Render::SetPixel(Vec2_int_ *pTargetXY, unsigned __int16 uColor) | |
10932 { | |
10933 Vec2_int_ *pTargetXY_; // esi@1 | |
10934 unsigned __int16 v3; // di@1 | |
10935 signed int v4; // ecx@2 | |
10936 signed int v5; // eax@4 | |
10937 | |
10938 pTargetXY_ = pTargetXY; | |
10939 v3 = uColor; | |
10940 pRenderer->BeginScene(); | |
10941 if ( pRenderer->uNumSceneBegins ) | |
10942 { | |
10943 v4 = pTargetXY_->x; | |
10944 if ( pTargetXY_->x >= 0 ) | |
10945 { | |
10946 if ( v4 <= 639 ) | |
10947 { | |
10948 v5 = pTargetXY_->y; | |
10949 if ( v5 >= 0 ) | |
10950 { | |
10951 if ( v5 <= 479 ) | |
10952 pRenderer->pTargetSurface[v4 + pRenderer->uTargetSurfacePitch * v5] = v3; | |
10953 } | |
10954 } | |
10955 } | |
10956 pRenderer->EndScene(); | |
10957 } | |
10958 } | |
10959 | |
10960 //----- (004524D8) -------------------------------------------------------- | |
10961 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
10962 { | |
10963 int v11; // eax@13 | |
10964 int v12; // ecx@13 | |
10965 void *v13; // eax@13 | |
10966 unsigned __int8 v14; // zf@13 | |
10967 unsigned __int8 v15; // sf@13 | |
10968 int v16; // esi@14 | |
10969 int v17; // ecx@16 | |
10970 int v18; // esi@16 | |
10971 unsigned __int16 *v19; // eax@16 | |
10972 int v20; // edx@16 | |
10973 int v21; // ecx@16 | |
10974 int v22; // eax@16 | |
10975 int v23; // esi@16 | |
10976 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
10977 int v27; // [sp+28h] [bp-Ch]@14 | |
10978 int v28; // [sp+2Ch] [bp-8h]@13 | |
10979 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
10980 | |
10981 //v3 = this; | |
10982 //sprintf(Str1, "%s", pName); | |
10983 //v4 = uNumItems; | |
10984 if (!uNumItems) | |
10985 return nullptr; | |
10986 | |
10987 //{ | |
10988 //v5 = 0, pDesta = uNumItems; | |
10989 uint idx1 = 0, | |
10990 idx2 = uNumItems; | |
10991 while (true) | |
10992 { | |
10993 auto i = idx1 + (idx2 - idx1) / 2; | |
10994 | |
10995 auto res = strcmpi(pName, pSpriteNames[i]); | |
10996 if (!res) | |
10997 { | |
10998 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
10999 break; | |
11000 } | |
11001 else if (res < 0) | |
11002 idx2 = idx1 + (idx2 - idx1) / 2; | |
11003 else | |
11004 idx1 = i + 1; | |
11005 | |
11006 if ( idx1 >= idx2 ) | |
11007 return false; | |
11008 } | |
11009 | |
11010 | |
11011 uint uCompressedSize = 0; | |
11012 fread(&uCompressedSize, 4, 1, pFile); | |
11013 | |
11014 auto pTex = new HWLTexture; | |
670 | 11015 fread(&pTex->uBufferWidth, 4, 1, pFile); |
11016 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
11017 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
11018 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 11019 fread(&pTex->uWidth, 4, 1, pFile); |
11020 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 11021 fread(&pTex->uAreaX, 4, 1, pFile); |
11022 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 11023 |
11024 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
11025 if (uCompressedSize) | |
11026 { | |
11027 auto pCompressedData = new char[uCompressedSize]; | |
11028 { | |
11029 fread(pCompressedData, 1, uCompressedSize, pFile); | |
11030 auto uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); | |
11031 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); | |
11032 } | |
11033 delete [] pCompressedData; | |
11034 } | |
11035 else | |
11036 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
11037 | |
11038 if ( field_61A94_scale_hwls_to_half ) | |
11039 { | |
11040 v11 = pTex->uHeight / 2; | |
11041 v12 = pTex->uWidth / 2; | |
11042 pTex->uHeight = v11; | |
11043 pTex->uWidth = v12; | |
11044 v13 = new unsigned __int16[v12 * v11]; | |
11045 v28 = 0; | |
11046 v14 = pTex->uHeight == 0; | |
11047 v15 = (pTex->uHeight & 0x80000000u) != 0; | |
11048 v26 = (unsigned __int16 *)v13; | |
11049 if ( !(v15 | v14) ) | |
11050 { | |
11051 v16 = pTex->uWidth; | |
11052 v27 = 1; | |
11053 do | |
11054 { | |
11055 pDestb = 0; | |
11056 if ( v16 > 0 ) | |
11057 { | |
11058 do | |
11059 { | |
11060 v17 = v16 * v27; | |
11061 v18 = v28 * v16; | |
11062 v19 = pTex->pPixels; | |
11063 v20 = pDestb + 2 * v18; | |
11064 v21 = (int)&v19[2 * (pDestb + v17)]; | |
11065 v22 = (int)&v19[2 * v20]; | |
11066 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
11067 LOWORD(v21) = *(unsigned short *)v21; | |
11068 v23 = pDestb++ + v18; | |
11069 v26[v23] = sub_452442(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
11070 v16 = pTex->uWidth; | |
11071 } | |
11072 while (pDestb < pTex->uWidth); | |
11073 } | |
11074 ++v28; | |
11075 v27 += 2; | |
11076 } | |
11077 while ( v28 < (signed int)pTex->uHeight ); | |
11078 } | |
11079 delete [] pTex->pPixels; | |
11080 pTex->pPixels = v26; | |
11081 } | |
11082 return pTex; | |
11083 //result = pTex; | |
11084 // } | |
11085 // else | |
11086 // { | |
11087 //LABEL_8: | |
11088 // return nullptr; | |
11089 // } | |
11090 } | |
11091 | |
11092 //----- (0045271F) -------------------------------------------------------- | |
11093 bool RenderHWLContainer::Release() | |
11094 { | |
11095 RenderHWLContainer *v1; // esi@1 | |
11096 int v2; // ebx@1 | |
11097 void **v3; // edi@3 | |
11098 __int32 v4; // eax@6 | |
11099 FILE *v5; // ST24_4@6 | |
11100 size_t *v6; // edi@6 | |
11101 int v7; // ebx@7 | |
11102 signed int v9; // [sp+0h] [bp-8h]@6 | |
11103 FILE *File; // [sp+4h] [bp-4h]@6 | |
11104 | |
11105 v1 = this; | |
11106 v2 = 0; | |
11107 if ( this->bDumpDebug ) | |
11108 { | |
11109 File = fopen("logd3d.txt", "w"); | |
11110 v4 = ftell(v1->pFile); | |
11111 v5 = v1->pFile; | |
11112 v6 = &v1->uNumItems; | |
11113 v1->uDataOffset = v4; | |
11114 fwrite(&v1->uNumItems, 4u, 1u, v5); | |
11115 v9 = 0; | |
11116 if ( (signed int)v1->uNumItems > 0 ) | |
11117 { | |
11118 v7 = (int)v1->pSpriteNames; | |
11119 do | |
11120 { | |
11121 fwrite(*(const void **)v7, 1u, 0x14u, v1->pFile); | |
11122 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", *(unsigned int *)v7, *(unsigned int *)(v7 + 200000)); | |
11123 ++v9; | |
11124 v7 += 4; | |
11125 } | |
11126 while ( v9 < (signed int)*v6 ); | |
11127 v2 = 0; | |
11128 } | |
11129 fwrite(v1->pSpriteOffsets, 4u, *v6, v1->pFile); | |
11130 fseek(v1->pFile, 4, v2); | |
11131 fwrite(&v1->uDataOffset, 4u, 1u, v1->pFile); | |
11132 fclose(v1->pFile); | |
11133 fclose(File); | |
11134 } | |
11135 else | |
11136 { | |
11137 fclose(this->pFile); | |
11138 if ( (signed int)v1->uNumItems > 0 ) | |
11139 { | |
11140 v3 = (void **)v1->pSpriteNames; | |
11141 do | |
11142 { | |
11143 free(*v3); | |
11144 ++v2; | |
11145 ++v3; | |
11146 } | |
11147 while ( v2 < (signed int)v1->uNumItems ); | |
11148 } | |
11149 } | |
11150 return 1; | |
11151 } | |
11152 | |
11153 //----- (00452347) -------------------------------------------------------- | |
11154 RenderHWLContainer::RenderHWLContainer(): | |
11155 bDumpDebug(false) | |
11156 { | |
11157 RenderHWLContainer *v1; // esi@1 | |
11158 | |
11159 v1 = this; | |
11160 this->pFile = 0; | |
11161 uSignature = 0; | |
11162 v1->uDataOffset = 0; | |
11163 memset(&v1->uNumItems, 0, 0x61A84u); | |
11164 v1->uNumItems = 0; | |
11165 v1->field_61A94_scale_hwls_to_half = 0; | |
11166 } | |
11167 | |
11168 //----- (0045237F) -------------------------------------------------------- | |
11169 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
11170 { | |
11171 pFile = _wfopen(pFilename, L"rb"); | |
11172 if (!pFile) | |
11173 { | |
11174 Log::Warning(L"Failed to open file: %s", pFilename); | |
11175 return false; | |
11176 } | |
11177 | |
11178 fread(&uSignature, 1, 4, pFile); | |
11179 if (uSignature != 'TD3D') | |
11180 { | |
11181 Log::Warning(L"Invalid format: %s", pFilename); | |
11182 return false; | |
11183 } | |
11184 | |
11185 fread(&uDataOffset, 4, 1, pFile); | |
11186 fseek(pFile, uDataOffset, SEEK_SET); | |
11187 fread(&uNumItems, 4, 1, pFile); | |
11188 | |
11189 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
11190 for (uint i = 0; i < uNumItems; ++i) | |
11191 { | |
11192 pSpriteNames[i] = new char[20]; | |
11193 fread(pSpriteNames[i], 1, 20, pFile); | |
11194 } | |
11195 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
11196 | |
11197 return true; | |
11198 } | |
11199 | |
11200 //----- (004A1C1E) -------------------------------------------------------- | |
11201 void DoRenderBillboards_D3D() | |
11202 { | |
186 | 11203 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
11204 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
11205 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11206 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11207 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11208 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11209 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11210 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11211 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11212 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11213 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
|
11214 //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
|
11215 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11216 p->pQuards[0].pos.x = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11217 p->pQuards[0].pos.y = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11218 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11219 p->pQuards[1].pos.x = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11220 p->pQuards[1].pos.y = 200; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11221 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11222 p->pQuards[2].pos.x = 100; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11223 p->pQuards[2].pos.y = 200; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11224 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11225 p->pQuards[3].pos.x = 100; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11226 p->pQuards[3].pos.y = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11227 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11228 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11229 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11230 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11231 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11232 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11233 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11234 p->pQuards, p->uNumVertices, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11235 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11236 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11237 }*/ |
0 | 11238 |
11239 for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i) | |
11240 { | |
101 | 11241 auto p = &pRenderer->pBillboardRenderListD3D[i]; |
0 | 11242 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11243 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
0 | 11244 SetBillboardBlendOptions(p->uOpacity); |
11245 | |
101 | 11246 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11247 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11248 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11249 p->pQuards, p->uNumVertices, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11250 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
0 | 11251 } |
11252 | |
11253 if (pRenderer->bFogEnabled) | |
11254 { | |
11255 pRenderer->bFogEnabled = false; | |
186 | 11256 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 11257 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
11258 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
11259 } | |
186 | 11260 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
11261 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
11262 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
11263 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
11264 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
11265 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 11266 } |
11267 | |
11268 //----- (004A1DA8) -------------------------------------------------------- | |
11269 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) | |
11270 { | |
11271 switch (a1) | |
11272 { | |
11273 case RenderBillboardD3D::Transparent: | |
11274 { | |
11275 if (pRenderer->bFogEnabled) | |
11276 { | |
11277 pRenderer->bFogEnabled = false; | |
186 | 11278 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 11279 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
11280 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
11281 } | |
11282 | |
186 | 11283 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); |
11284 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
11285 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 11286 } |
11287 break; | |
11288 | |
11289 case RenderBillboardD3D::Opaque_1: | |
11290 case RenderBillboardD3D::Opaque_2: | |
11291 case RenderBillboardD3D::Opaque_3: | |
11292 { | |
11293 if (pRenderer->bUsingSpecular) | |
11294 { | |
11295 if (!pRenderer->bFogEnabled) | |
11296 { | |
11297 pRenderer->bFogEnabled = true; | |
186 | 11298 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
11299 } | |
11300 } | |
11301 | |
11302 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
11303 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
11304 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 11305 } |
11306 break; | |
11307 | |
11308 default: | |
11309 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11310 assert(false); |
0 | 11311 break; |
11312 } | |
11313 } | |
11314 |