Mercurial > mm7
annotate Render.cpp @ 872:2db21a810d48
Merge
author | Nomad |
---|---|
date | Mon, 01 Apr 2013 13:39:39 +0200 |
parents | 710cf848ad24 f4394e320312 |
children | 10fa7dad1391 |
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) -------------------------------------------------------- | |
211 __int16 Render::ExecOutdoorDrawSW() | |
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 | |
230 unsigned int v17; // eax@51 | |
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; | |
318 v17 = pBitmaps_LOD->LoadTexture("wtrtyl"); | |
319 v4->pTexture = (Texture *)(v17 != -1 ? (int)&pBitmaps_LOD->pTextures[v17] : 0); | |
320 if ( pOutdoorCamera->outdoor_no_wavy_water ) | |
321 sr_sub_48408A_prolly_odm_water_no_waves(v3); | |
322 else | |
323 sr_sub_485407_prolly_odm_water_wavy(v3); | |
638 | 324 v18 = v4->terrain_grid_z - 64; |
0 | 325 v4->pTexture = v16; |
326 dword_80AA20 = v18 << 25; | |
327 dword_80AA1C = (v18 << 25) + 0x1FF0000; | |
638 | 328 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 329 dword_80AA18 = dword_80AA14 - 0x1FF0000; |
330 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 331 v4->terrain_grid_z, |
332 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 333 sr_sub_484442(v3); |
334 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
335 if ( v4->prolly_tail == v3 ) | |
336 break; | |
337 v3 = v3->pNext; | |
338 } | |
339 } | |
340 } | |
341 else | |
342 { | |
343 while ( sr_sub_48408A_prolly_odm_water_no_waves(v3) ) | |
344 { | |
345 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
346 if ( v4->prolly_tail == v3 ) | |
347 break; | |
348 v3 = v3->pNext; | |
349 } | |
350 } | |
351 } | |
352 else | |
353 { | |
354 v19 = v4->field_59; | |
355 if ( v19 != 5 ) | |
356 { | |
357 if ( v14 & 2 ) | |
358 { | |
359 while ( 1 ) | |
360 { | |
361 v28 = pBitmaps_LOD->LoadTexture("wtrtyla"); | |
362 v4->pTexture = (Texture *)(v28 != -1 ? &pBitmaps_LOD->pTextures[v28] : 0); | |
363 if ( !sr_sub_4847EB(v3) ) | |
364 break; | |
365 v4->pTexture = v5; | |
366 if ( !sr_sub_484442(v3) ) | |
367 break; | |
368 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
369 if ( v4->prolly_tail == v3 ) | |
370 break; | |
371 v3 = v3->pNext; | |
372 v5 = v4->pTexture; | |
373 } | |
374 } | |
375 else | |
376 { | |
377 if ( v19 == 1 ) | |
378 { | |
638 | 379 dword_80AA20 = (v4->terrain_grid_z - 64) << 25; |
0 | 380 dword_80AA1C = dword_80AA20 + 33488896; |
638 | 381 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 382 dword_80AA18 = dword_80AA14 - 33488896; |
383 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 384 v4->terrain_grid_z, |
385 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 386 while ( 1 ) |
387 { | |
388 if ( !sr_sub_4847EB(v3) ) | |
389 sr_sub_48585C_mb_DrawSpan(v3, &pRenderer->pTargetSurface[v3->field_8 + 640 * v3->field_A], 0); | |
390 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
391 if ( v4->prolly_tail == v3 ) | |
392 break; | |
393 v3 = v3->pNext; | |
394 } | |
395 } | |
396 } | |
397 goto LABEL_14; | |
398 } | |
399 v4->ptr_38 = (stru149 *)&v41; | |
400 v4->_479295(); | |
401 v20 = GetTickCount(); | |
402 v21 = *(int *)&v4->flags; | |
403 v22 = v20 >> 3; | |
404 if ( BYTE1(v21) & 4 ) | |
405 { | |
406 v4->sTextureDeltaV -= v22 & v4->pTexture->uHeightMinus1; | |
407 } | |
408 else | |
409 { | |
410 if ( BYTE1(v21) & 8 ) | |
411 v4->sTextureDeltaV += v22 & v4->pTexture->uHeightMinus1; | |
412 } | |
413 if ( BYTE1(v21) & 0x10 ) | |
414 { | |
415 v4->sTextureDeltaU -= v22 & v4->pTexture->uWidthMinus1; | |
416 } | |
417 else | |
418 { | |
419 if ( BYTE1(v21) & 0x20 ) | |
420 v4->sTextureDeltaU += v22 & v4->pTexture->uWidthMinus1; | |
421 } | |
422 v23 = v4->ptr_38; | |
423 v4->field_52 = 32; | |
424 v4->field_5A = 5; | |
425 if ( (double)abs(v23->field_C) > 52428.8 ) | |
426 { | |
427 v4->field_52 = 8; | |
428 v4->field_5A = 3; | |
429 } | |
430 v24 = *(int *)&v4->flags; | |
431 if ( !(v24 & 0x10000) ) | |
432 { | |
433 if ( !(v24 & 2) ) | |
434 { | |
435 v25 = v4->pODMFace; | |
436 if ( v25->uPolygonType == 1 ) | |
437 { | |
438 v26 = v25->pTextureUIDs[0]; | |
439 dword_80AA1C = v26; | |
440 dword_80AA20 = v26; | |
441 v27 = v25->pTextureVIDs[0]; | |
442 dword_80AA14 = v27; | |
443 dword_80AA18 = v27; | |
444 v35 = 1; | |
445 if ( v25->uNumVertices > 1u ) | |
446 { | |
447 v33 = (int)&v25->pTextureVIDs[1]; | |
448 do | |
449 { | |
450 if ( dword_80AA20 > *(short *)(v33 - 40) ) | |
451 dword_80AA20 = *(short *)(v33 - 40); | |
452 if ( v26 < *(short *)(v33 - 40) ) | |
453 { | |
454 v26 = *(short *)(v33 - 40); | |
455 dword_80AA1C = *(short *)(v33 - 40); | |
456 } | |
457 if ( dword_80AA18 > *(short *)v33 ) | |
458 dword_80AA18 = *(short *)v33; | |
459 if ( v27 < *(short *)v33 ) | |
460 { | |
461 v27 = *(short *)v33; | |
462 dword_80AA14 = *(short *)v33; | |
463 } | |
464 ++v35; | |
465 v33 += 2; | |
466 } | |
467 while ( v35 < v25->uNumVertices ); | |
468 v0 = a1; | |
469 } | |
470 dword_80AA20 = (dword_80AA20 + v4->sTextureDeltaU) << 16; | |
471 dword_80AA1C = ((v26 + v4->sTextureDeltaU) << 16) - 65536; | |
472 dword_80AA18 = (dword_80AA18 + v4->sTextureDeltaV) << 16; | |
473 dword_80AA14 = ((v27 + v4->sTextureDeltaV) << 16) - 65536; | |
474 } | |
475 while ( 1 ) | |
476 { | |
477 if ( !sr_sub_482E07(v3, v0) ) | |
478 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
479 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
480 if ( v4->prolly_tail == v3 ) | |
481 break; | |
482 v3 = v3->pNext; | |
483 } | |
484 goto LABEL_14; | |
485 } | |
486 while ( 1 ) | |
487 { | |
488 LABEL_74: | |
489 if ( !sr_sub_4839BD(v3, v0) ) | |
490 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
491 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
492 if ( v4->prolly_tail == v3 ) | |
493 break; | |
494 v3 = v3->pNext; | |
495 } | |
496 goto LABEL_14; | |
497 } | |
498 if ( v24 & 2 ) | |
499 goto LABEL_74; | |
500 while ( 1 ) | |
501 { | |
502 if ( !sr_sub_482A94(v3) ) | |
503 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
504 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
505 if ( v4->prolly_tail == v3 ) | |
506 break; | |
507 v3 = v3->pNext; | |
508 } | |
509 } | |
510 } | |
511 else | |
512 { | |
513 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
514 } | |
515 } | |
516 } | |
517 } | |
518 LABEL_14: | |
519 ++v34; | |
520 LOWORD(v2) = v34; | |
521 v36 += 67; | |
522 } | |
523 while ( v34 < (signed int)v37 ); | |
524 } | |
525 if ( pParty->uFlags & 2 ) | |
526 { | |
527 v6 = pOutdoorCamera->numStru148s; | |
528 v7 = 0; | |
529 uNumElementsIn80AA28 = 0; | |
530 if ( pOutdoorCamera->numStru148s > 0 ) | |
531 { | |
532 v8 = (char *)&array_77EC08[0].flags; | |
533 do | |
534 { | |
535 v2 = *(stru148 **)v8; | |
536 if ( (unsigned int)v2 & 0x20000 ) | |
537 { | |
538 ++v7; | |
539 *(int *)v8 = (unsigned int)v2 & 0xFFFDFFFF; | |
540 LOWORD(v2) = (short)v8 - 48; | |
541 *(&uNumElementsIn80AA28 + v7) = (unsigned int)(v8 - 48); | |
542 } | |
543 v8 += 268; | |
544 --v6; | |
545 } | |
546 while ( v6 ); | |
547 uNumElementsIn80AA28 = v7; | |
548 } | |
549 } | |
550 v9 = pOutdoorCamera->uNumSpans; | |
551 unnamed_6BE060[0] = pOutdoorCamera->uNumSpans; | |
552 if ( pOutdoorCamera->numStru148s >= 1999 | |
553 || (array_77EC08[1999]._48607B(&stru_8019C8), | |
554 array_77EC08[1999].ptr_38->_48694B(), | |
555 v2 = (stru148 *)&pBitmaps_LOD->pTextures[pOutdoor->uMainTile_BitmapID], | |
556 (array_77EC08[1999].pTexture = (Texture *)(pOutdoor->uMainTile_BitmapID != -1 ? (int)v2 : 0)) == 0) ) | |
557 return (signed __int16)v2; | |
638 | 558 array_77EC08[1999].dimming_level = 23 - (-20 * pOutdoor->vSunlight.z >> 16); |
559 if ( array_77EC08[1999].dimming_level > 20 ) | |
560 array_77EC08[1999].dimming_level = 20; | |
323 | 561 v10 = stru_5C6E00->Sin(pIndoorCamera->sRotationX); |
0 | 562 array_77EC08[1999].v_18.y = 0; |
563 array_77EC08[1999].v_18.x = v10; | |
323 | 564 array_77EC08[1999].v_18.z = stru_5C6E00->Cos(pIndoorCamera->sRotationX); |
0 | 565 array_77EC08[1999].field_24 = 2048 - (pIndoorCamera->pos.z << 16); |
566 a1a = (signed __int64)((double)(pIndoorCamera->pos.z * pOutdoorCamera->int_fov_rad) | |
567 / ((double)pOutdoorCamera->int_fov_rad + 8192.0) | |
568 + (double)pViewport->uScreenCenterY); | |
569 cos((double)pIndoorCamera->sRotationX * 0.0030664064); | |
570 sin((double)pIndoorCamera->sRotationX * 0.0030664064); | |
571 array_77EC08[1999]._48607B(&stru_8019C8); | |
572 array_77EC08[1999].ptr_38->_48694B(); | |
573 v2 = (stru148 *)&pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID]; | |
574 array_77EC08[1999].pTexture = (Texture *)(pOutdoor->uSky_TextureID != -1 ? (int)v2 : 0); | |
575 if ( !(pOutdoor->uSky_TextureID != -1 ? (int)v2 : 0) ) | |
576 return (signed __int16)v2; | |
638 | 577 array_77EC08[1999].dimming_level = 0; |
323 | 578 v11 = stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16); |
0 | 579 array_77EC08[1999].v_18.y = 0; |
580 array_77EC08[1999].v_18.x = -v11; | |
323 | 581 array_77EC08[1999].v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16); |
0 | 582 LOWORD(v2) = 224 * LOWORD(pMiscTimer->uTotalGameTimeElapsed); |
583 array_77EC08[1999].field_24 = 0x2000000u; | |
584 array_77EC08[1999].sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
585 array_77EC08[1999].sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
767 | 586 if ( day_attrib & DAY_ATTRIB_FOG |
0 | 587 && (LOWORD(v2) = LOWORD(pParty->uCurrentHour), pParty->uCurrentHour >= 5) |
588 && pParty->uCurrentHour < 0x15 | |
589 || bUnderwater ) | |
590 { | |
591 v2 = (stru148 *)*(short *)PaletteManager::Get_Mist_or_Red_LUT(array_77EC08[1999].pTexture->palette_id2, 31, 1); | |
592 a1b = (unsigned int)v2; | |
593 if ( (signed int)v9 <= 0 ) | |
594 return (signed __int16)v2; | |
595 v29 = v9; | |
596 while ( 1 ) | |
597 { | |
598 v30 = &pSpans[v29 - 1]; | |
599 v2 = (stru148 *)v30->field_E; | |
600 if ( v2 != (stru148 *)unnamed_6BE060[1] ) | |
601 { | |
693 | 602 LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); |
603 if ( v30->field_8 >= (signed int)pViewport->uViewportTL_X ) | |
0 | 604 goto LABEL_124; |
693 | 605 if ( v30->field_C == pViewport->uViewportTL_X ) |
0 | 606 { |
607 v30->field_E = LOWORD(unnamed_6BE060[1]); | |
608 } | |
609 else | |
610 { | |
693 | 611 v30->field_8 = LOWORD(pViewport->uViewportTL_X); |
612 v30->field_C -= LOWORD(pViewport->uViewportTL_X); | |
0 | 613 if ( v30->field_C >= 0 ) |
614 { | |
615 LABEL_124: | |
616 v31 = v30->field_C; | |
617 v30->pParent = &array_77EC08[1999]; | |
618 fill_pixels_fast( | |
619 a1b, | |
620 &pRenderer->pTargetSurface[v30->field_8 + pRenderer->uTargetSurfacePitch * v30->field_A], | |
621 v31); | |
622 j_memset32(-65536, &pRenderer->pActiveZBuffer[v30->field_8 + 640 * v30->field_A], v30->field_C); | |
623 goto LABEL_125; | |
624 } | |
625 LOWORD(v2) = LOWORD(unnamed_6BE060[1]); | |
626 v30->field_E = LOWORD(unnamed_6BE060[1]); | |
627 } | |
628 } | |
629 LABEL_125: | |
630 --v29; | |
631 --v9; | |
632 if ( !v9 ) | |
633 return (signed __int16)v2; | |
634 } | |
635 } | |
636 if ( (signed int)v9 > 0 ) | |
637 { | |
638 v12 = v9; | |
639 do | |
640 { | |
641 v13 = &pSpans[v12 - 1]; | |
642 v2 = (stru148 *)v13->field_E; | |
643 if ( v2 != (stru148 *)unnamed_6BE060[1] ) | |
644 { | |
693 | 645 LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); |
646 if ( v13->field_8 >= (signed int)pViewport->uViewportTL_X ) | |
0 | 647 goto LABEL_109; |
693 | 648 if ( v13->field_C != pViewport->uViewportTL_X ) |
649 { | |
650 v13->field_8 = LOWORD(pViewport->uViewportTL_X); | |
651 v13->field_C -= LOWORD(pViewport->uViewportTL_X); | |
0 | 652 if ( v13->field_C >= 0 ) |
653 { | |
654 LABEL_109: | |
655 if ( pOutdoorCamera->bNoSky ) | |
656 { | |
657 const_1_0(); | |
658 } | |
659 else | |
660 { | |
661 v13->pParent = &array_77EC08[1999]; | |
662 if ( !Render::DrawSkySW(v13, &array_77EC08[1999], a1a) ) | |
663 j_memset32(-65536, &pRenderer->pActiveZBuffer[v13->field_8 + 640 * v13->field_A], v13->field_C); | |
664 } | |
665 } | |
666 LOWORD(v2) = LOWORD(unnamed_6BE060[1]); | |
667 v13->field_E = LOWORD(unnamed_6BE060[1]); | |
668 goto LABEL_114; | |
669 } | |
670 v13->field_E = LOWORD(unnamed_6BE060[1]); | |
671 } | |
672 LABEL_114: | |
673 --v12; | |
674 --v9; | |
675 } | |
676 while ( v9 ); | |
677 } | |
678 return (signed __int16)v2; | |
679 } | |
680 | |
681 //----- (00485044) -------------------------------------------------------- | |
682 int Render::DrawSkySW(Span *a1, stru148 *a2, int a3) | |
683 { | |
684 stru148 *v3; // esi@1 | |
685 Span *v4; // edi@1 | |
686 float v5; // ST2C_4@1 | |
687 signed int result; // eax@2 | |
688 int v7; // ST40_4@3 | |
689 stru149 *v8; // eax@3 | |
690 int v9; // ebx@3 | |
691 int v10; // ecx@3 | |
692 int v11; // edx@3 | |
693 int v12; // eax@3 | |
694 int v13; // ST28_4@5 | |
695 int v14; // eax@5 | |
696 signed __int64 v15; // qtt@11 | |
697 int v16; // ST28_4@11 | |
698 int v17; // eax@11 | |
699 signed int v18; // ecx@11 | |
700 int v19; // ST40_4@11 | |
701 int v20; // ST3C_4@11 | |
702 int v21; // ST30_4@11 | |
703 void *v22; // eax@11 | |
704 Texture *v23; // esi@11 | |
705 int v24; // ecx@11 | |
706 unsigned int v25; // esi@11 | |
707 int v26; // edi@11 | |
708 unsigned __int16 *v27; // eax@11 | |
709 int *v28; // ebx@12 | |
710 int v29; // edx@13 | |
711 unsigned __int16 v30; // cx@13 | |
712 int v31; // edx@14 | |
713 unsigned __int16 v32; // cx@14 | |
714 unsigned __int8 v33; // sf@15 | |
715 unsigned __int8 v34; // of@15 | |
716 double v35; // [sp+14h] [bp-38h]@1 | |
717 int v36; // [sp+18h] [bp-34h]@3 | |
718 signed int v37; // [sp+18h] [bp-34h]@11 | |
719 int v38; // [sp+1Ch] [bp-30h]@3 | |
720 signed int v39; // [sp+1Ch] [bp-30h]@11 | |
721 int v40; // [sp+20h] [bp-2Ch]@3 | |
722 void *v41; // [sp+20h] [bp-2Ch]@11 | |
723 int v42; // [sp+24h] [bp-28h]@3 | |
724 unsigned __int8 *v43; // [sp+24h] [bp-28h]@11 | |
725 int v44; // [sp+28h] [bp-24h]@11 | |
726 int v45; // [sp+2Ch] [bp-20h]@3 | |
727 signed int v46; // [sp+30h] [bp-1Ch]@3 | |
728 __int16 v47; // [sp+30h] [bp-1Ch]@11 | |
729 signed int v48; // [sp+34h] [bp-18h]@3 | |
730 int v49; // [sp+34h] [bp-18h]@11 | |
731 int v50; // [sp+38h] [bp-14h]@3 | |
732 unsigned __int16 *v51; // [sp+38h] [bp-14h]@11 | |
733 int v52; // [sp+3Ch] [bp-10h]@4 | |
734 int a1a; // [sp+40h] [bp-Ch]@3 | |
735 int v54; // [sp+44h] [bp-8h]@3 | |
736 int v55; // [sp+48h] [bp-4h]@3 | |
737 int v56; // [sp+54h] [bp+8h]@11 | |
738 int *v57; // [sp+54h] [bp+8h]@11 | |
739 | |
740 v3 = a2; | |
741 v4 = a1; | |
693 | 742 v5 = (double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5 / tan(0.6457717418670654) + 0.5; |
0 | 743 v35 = v5 + 6.7553994e15; |
744 if ( LODWORD(v35) ) | |
745 { | |
746 v55 = 65536 / SLODWORD(v35); | |
747 v7 = 65536 / SLODWORD(v35) * (a3 - v4->field_A); | |
748 v8 = v3->ptr_38; | |
749 v42 = ((unsigned __int64)(v3->ptr_38->field_14 * (signed __int64)v7) >> 16) + v8->field_C; | |
750 v40 = ((unsigned __int64)(v8->field_20 * (signed __int64)v7) >> 16) + v3->ptr_38->field_18; | |
751 v38 = pOutdoorCamera->camera_rotation_y_int_sine; | |
752 HIDWORD(v35) = pOutdoorCamera->camera_rotation_y_int_cosine; | |
753 v45 = v4->field_C; | |
754 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v7) >> 16) + v3->v_18.x; | |
755 v10 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); | |
756 v48 = 0; | |
757 v50 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); | |
758 v46 = -v3->field_24; | |
759 v11 = v4->field_A - 1; | |
760 v54 = v11; | |
761 v12 = 65536 / SLODWORD(v35) * (a3 - v11); | |
762 a1a = 65536 / SLODWORD(v35) * (a3 - v11); | |
763 while ( 1 ) | |
764 { | |
765 v52 = v9; | |
766 if ( v9 ) | |
767 { | |
768 v13 = abs(v46 >> 14); | |
769 v14 = abs(v9); | |
770 v11 = v54; | |
771 v10 = v50; | |
772 if ( v13 <= v14 ) | |
773 break; | |
774 v12 = a1a; | |
775 } | |
693 | 776 if ( v11 <= (signed int)pViewport->uViewportTL_Y ) |
0 | 777 break; |
778 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v12) >> 16) + v3->v_18.x; | |
779 --v54; | |
780 a1a += v55; | |
781 v12 = a1a; | |
782 v11 = v54; | |
783 v48 = 1; | |
784 } | |
785 if ( v48 ) | |
786 v52 = ((unsigned __int64)(v3->v_18.z * (signed __int64)(v55 * (a3 + (signed int)v4->field_A - 2 * v11))) >> 16) | |
787 + v3->v_18.x; | |
788 LODWORD(v15) = v46 << 16; | |
789 HIDWORD(v15) = v46 >> 16; | |
790 v16 = v42 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v10) >> 16); | |
791 v17 = v40 + ((unsigned __int64)(v3->ptr_38->field_1C * (signed __int64)v10) >> 16); | |
792 v18 = v15 / v52; | |
710 | 793 v43 = v3->pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 794 v19 = v3->sTextureDeltaU + ((signed int)((unsigned __int64)(v16 * v15 / v52) >> 16) >> 3); |
795 v56 = v15 / v52; | |
796 v20 = v3->sTextureDeltaV + ((signed int)((unsigned __int64)(v17 * v15 / v52) >> 16) >> 3); | |
797 v21 = (unsigned __int64)(v55 * (signed __int64)v56) >> 16; | |
798 v39 = (signed int)((unsigned __int64)(v21 * (signed __int64)v38) >> 16) >> 3; | |
799 v37 = (signed int)((unsigned __int64)(v21 * (signed __int64)v36) >> 16) >> 3; | |
800 v22 = sr_sub_47C178(v18, v3, 0, 1); | |
801 v23 = v3->pTexture; | |
802 v41 = v22; | |
803 v47 = 16 - v23->uWidthLn2; | |
804 v44 = v23->uTextureWidth - 1; | |
805 v49 = (v23->uTextureHeight << 16) - 65536; | |
806 v24 = v4->field_8; | |
807 v51 = &pRenderer->pTargetSurface[v24 + pRenderer->uTargetSurfacePitch * v4->field_A]; | |
808 v57 = &pRenderer->pActiveZBuffer[v24 + 640 * v4->field_A]; | |
809 v25 = v19; | |
810 v26 = v20; | |
811 v27 = v51; | |
812 if ( !(v45 & 1) ) | |
813 goto LABEL_15; | |
814 --v45; | |
815 v27 = v51 - 1; | |
816 v28 = v57; | |
817 ++v57; | |
818 while ( 1 ) | |
819 { | |
820 *v28 = -65536; | |
821 v31 = v44 & (v25 >> 16); | |
822 v27 += 2; | |
823 v25 += v39; | |
824 v32 = *((short *)v41 + *(&v43[v31] + ((v49 & (unsigned int)v26) >> v47))); | |
825 v26 += v37; | |
826 *(v27 - 1) = v32; | |
827 LABEL_15: | |
828 v34 = __OFSUB__(v45, 2); | |
829 v33 = v45 - 2 < 0; | |
830 v45 -= 2; | |
831 if ( v33 ^ v34 ) | |
832 break; | |
833 v29 = v44 & (v25 >> 16); | |
834 v25 += v39; | |
835 v30 = *((short *)v41 + *(&v43[v29] + ((v49 & (unsigned int)v26) >> v47))); | |
836 v26 += v37; | |
837 v28 = v57; | |
838 *v27 = v30; | |
839 v57 += 2; | |
840 v28[1] = -65536; | |
841 } | |
842 result = 1; | |
843 } | |
844 else | |
845 { | |
846 result = 0; | |
847 } | |
848 return result; | |
849 } | |
850 | |
851 //----- (0047F5C6) -------------------------------------------------------- | |
852 float Render::DrawBezierTerrain() | |
853 { | |
854 //__debugbreak();Ritor1: it's temporarily | |
855 //return 0; | |
856 | |
86 | 857 unsigned int pDirectionIndicator1; // ebx@1 |
858 unsigned int pDirectionIndicator2; // edi@1 | |
0 | 859 unsigned int v2; // eax@1 |
860 int v3; // eax@3 | |
861 int v4; // edi@3 | |
862 int v5; // ebx@3 | |
863 int v6; // esi@3 | |
864 unsigned int v7; // eax@3 | |
865 int v8; // eax@4 | |
866 unsigned int v9; // eax@6 | |
867 int v10; // eax@7 | |
868 int v11; // ebx@9 | |
869 int v12; // edi@9 | |
870 int v13; // eax@21 | |
871 int v14; // eax@31 | |
872 int v15; // edi@33 | |
67 | 873 int v16; // eax@34 |
0 | 874 int v17; // edx@34 |
875 int v18; // ebx@34 | |
876 int v19; // eax@36 | |
877 int v20; // eax@39 | |
878 int v21; // ecx@43 | |
879 char v22; // zf@44 | |
880 int v23; // ecx@47 | |
881 int v24; // edi@52 | |
67 | 882 int v25; // eax@54 |
0 | 883 int v26; // ecx@54 |
884 int v27; // eax@56 | |
885 int v28; // edx@60 | |
886 int v29; // ecx@61 | |
887 int v30; // ecx@64 | |
888 int v31; // ecx@68 | |
889 int v32; // eax@70 | |
890 int v33; // ecx@71 | |
891 int v34; // eax@73 | |
892 int v35; // ecx@77 | |
893 int v36; // ecx@81 | |
894 int v37; // ecx@86 | |
67 | 895 int v38; // eax@88 |
896 int v39; // ecx@88 | |
0 | 897 int v40; // eax@90 |
898 int v41; // edx@94 | |
899 int v42; // ecx@95 | |
900 int v43; // ecx@98 | |
901 int v44; // ecx@102 | |
902 int v45; // eax@104 | |
903 int v46; // eax@107 | |
904 int v47; // ecx@111 | |
905 int v48; // ecx@115 | |
906 int v49; // edi@120 | |
67 | 907 int v50; // eax@122 |
0 | 908 int v51; // ecx@122 |
909 int v52; // eax@124 | |
910 int v53; // edx@128 | |
911 int v54; // ecx@129 | |
912 int v55; // ecx@132 | |
913 int v56; // eax@139 | |
914 int v57; // ecx@140 | |
915 int v58; // eax@142 | |
916 int v59; // ecx@146 | |
917 int v60; // ecx@147 | |
918 int v61; // ecx@150 | |
919 int v62; // ecx@155 | |
67 | 920 int v63; // eax@157 |
921 int v64; // ecx@157 | |
0 | 922 int v65; // eax@159 |
923 int v66; // edx@163 | |
924 int v67; // ecx@164 | |
925 int v68; // ecx@167 | |
926 int v69; // eax@173 | |
927 int v70; // edi@178 | |
928 int v71; // eax@178 | |
929 int v72; // ecx@178 | |
86 | 930 int x; // ebx@180 |
0 | 931 int v74; // eax@182 |
932 int v75; // eax@184 | |
67 | 933 IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 |
86 | 934 int uStartZ; // ecx@184 |
0 | 935 int v79; // ebx@185 |
936 int v127; // esi@185 | |
937 int v86; // edi@196 | |
938 int v87; // eax@196 | |
939 int v88; // ecx@196 | |
940 int v89; // eax@198 | |
941 int v90; // ecx@200 | |
942 int v92; // ebx@203 | |
943 int v93; // ST08_4@204 | |
944 int v97; // ST08_4@204 | |
945 float result; // eax@212 | |
67 | 946 struct |
947 { | |
948 char v102[4]; // [sp+Ch] [bp-68h]@191 | |
0 | 949 __int16 v103; // [sp+10h] [bp-64h]@190 |
950 __int16 v104; // [sp+12h] [bp-62h]@190 | |
67 | 951 } v102; |
77 | 952 int v105; // [sp+1Ch] [bp-58h]@1 |
0 | 953 int v106; // [sp+20h] [bp-54h]@3 |
86 | 954 int uEndZ; // [sp+24h] [bp-50h]@3 |
0 | 955 int v108; // [sp+28h] [bp-4Ch]@9 |
956 int v109; // [sp+2Ch] [bp-48h]@9 | |
957 int v110; // [sp+30h] [bp-44h]@9 | |
958 int v111; // [sp+34h] [bp-40h]@3 | |
959 int v112; // [sp+38h] [bp-3Ch]@6 | |
67 | 960 IndoorCameraD3D *pIndoorCameraD3D_4; // [sp+3Ch] [bp-38h]@9 |
0 | 961 int v114; // [sp+40h] [bp-34h]@9 |
962 int v115; // [sp+44h] [bp-30h]@9 | |
963 int v116; // [sp+48h] [bp-2Ch]@9 | |
964 int v117; // [sp+4Ch] [bp-28h]@9 | |
965 int v118; // [sp+50h] [bp-24h]@9 | |
966 int v119; // [sp+54h] [bp-20h]@1 | |
967 int v120; // [sp+58h] [bp-1Ch]@1 | |
968 int i; // [sp+5Ch] [bp-18h]@1 | |
969 int v122; // [sp+60h] [bp-14h]@1 | |
970 int v123; // [sp+64h] [bp-10h]@1 | |
67 | 971 int v124; // [sp+68h] [bp-Ch]@1 |
0 | 972 int v125; // [sp+6Ch] [bp-8h]@9 |
67 | 973 int v126; // [sp+70h] [bp-4h]@9 |
974 | |
96 | 975 v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2 |
86 | 976 pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 |
977 pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512 | |
323 | 978 v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16; |
979 v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16; | |
67 | 980 v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X |
0 | 981 v119 = pOutdoorCamera->outdoor_grid_band_3 + v123; |
982 v2 = pOutdoorCamera->uCameraFovInDegrees + 15; | |
67 | 983 i = v124 - pOutdoorCamera->outdoor_grid_band_3; |
0 | 984 v122 = v123 - pOutdoorCamera->outdoor_grid_band_3; |
67 | 985 |
986 if ( v2 > 90 ) | |
0 | 987 v2 = 90; |
67 | 988 v3 = (v2 << 11) / 720; |
86 | 989 v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3); |
990 v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1); | |
323 | 991 v106 = stru_5C6E00->Cos(v4); |
992 uEndZ = stru_5C6E00->Sin(v4); | |
993 v111 = stru_5C6E00->Cos(v5); | |
994 v6 = stru_5C6E00->Sin(v5); | |
0 | 995 v7 = v4 & stru_5C6E00->uPiMask; |
67 | 996 |
997 if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) | |
0 | 998 v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7]; |
999 else | |
1000 v8 = stru_5C6E00->pTanTable[v7]; | |
1001 v112 = abs(v8); | |
1002 v9 = v5 & stru_5C6E00->uPiMask; | |
67 | 1003 if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) |
0 | 1004 v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9]; |
1005 else | |
1006 v10 = stru_5C6E00->pTanTable[v9]; | |
1007 v108 = abs(v10); | |
67 | 1008 v11 = v124; |
0 | 1009 v12 = v123; |
1010 v114 = 0; | |
1011 v115 = 0; | |
67 | 1012 pIndoorCameraD3D_4 = 0; |
0 | 1013 v125 = 0; |
67 | 1014 v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; |
0 | 1015 v126 = v124; |
1016 v118 = v123; | |
86 | 1017 v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; |
1018 uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; | |
0 | 1019 terrain_76E1C8[0] = 65535; |
67 | 1020 //v116 = 1; |
1021 v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; | |
1022 //v117 = 1; | |
0 | 1023 terrain_76E3C8[0] = 65535; |
1024 terrain_76DDC8[0] = 65535; | |
1025 terrain_76DFC8[0] = 65535; | |
67 | 1026 for( v116=1; v116 < 128; v116++) |
1027 { | |
1028 if ( v112 >= 0x10000 ) | |
1029 { | |
1030 int v1, v2; | |
1031 /*v111 = 4294967296i64 / v112; | |
0 | 1032 v114 += v111; |
1033 if ( v114 >= 65536 ) | |
1034 { | |
1035 v11 += v110; | |
1036 v114 = (unsigned __int16)v114; | |
1037 } | |
67 | 1038 v12 += v109;*/ |
0 | 1039 } |
1040 else | |
1041 { | |
1042 v11 += v110; | |
1043 v115 += v112; | |
67 | 1044 if ( v112 + v115 >= 65536 ) |
0 | 1045 { |
1046 v12 += v109; | |
1047 v115 = (unsigned __int16)v115; | |
1048 } | |
1049 } | |
67 | 1050 if ( v11 < i || v11 > v120 || v12 < v122 || v12 > v119 ) |
0 | 1051 break; |
67 | 1052 //v13 = v116++; |
1053 terrain_76E3C8[v116] = v11; | |
1054 terrain_76E1C8[v116] = v12; | |
1055 } | |
1056 | |
1057 for( v117=1; v117 < 128; v117++ ) | |
0 | 1058 { |
1059 if ( v108 >= 65536 ) | |
1060 { | |
1061 v111 = 4294967296i64 / v108; | |
67 | 1062 v114 += v111;// |
1063 if ( v111 + v114 >= 65536 ) | |
1064 { | |
86 | 1065 v126 += uEndZ; |
67 | 1066 v114 = (unsigned __int16)v114;// |
0 | 1067 } |
1068 v118 += v106; | |
1069 } | |
1070 else | |
1071 { | |
1072 v125 += v108; | |
86 | 1073 v126 += uEndZ; |
0 | 1074 if ( v125 >= 65536 ) |
1075 { | |
1076 v118 += v106; | |
1077 v125 = (unsigned __int16)v125; | |
1078 } | |
1079 } | |
67 | 1080 //if ( v117 >= 128 ) |
1081 //break; | |
1082 if ( v126 < i ) | |
0 | 1083 break; |
67 | 1084 if ( v126 > v120 ) |
0 | 1085 break; |
1086 v14 = v118; | |
1087 if ( v118 < v122 ) | |
1088 break; | |
1089 if ( v118 > v119 ) | |
1090 break; | |
67 | 1091 terrain_76DFC8[v117] = v126; |
1092 terrain_76DDC8[v117] = v14; | |
1093 } | |
1094 v16 = 0; | |
1095 v126 = 0; | |
0 | 1096 v17 = v117 - 1; |
1097 v18 = v116 - 1; | |
77 | 1098 switch ( v105 ) |
0 | 1099 { |
1100 case 0: | |
1101 case 7: | |
67 | 1102 { |
0 | 1103 v116 = terrain_76DFC8[v17]; |
1104 if ( v120 > v116 ) | |
1105 { | |
1106 v125 = v120; | |
67 | 1107 memset32(terrain_76D9C8, v119 + 1, 4 * (v120 - v116 + 1)); |
0 | 1108 v19 = v120; |
1109 do | |
67 | 1110 terrain_76DBC8[v126++] = v19--; |
0 | 1111 while ( v19 >= v116 ); |
1112 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 + 127] ) | |
1113 { | |
1114 do | |
67 | 1115 v20 = terrain_76DDC8[v17-- -1]; |
1116 while ( v20 == terrain_76DDC8[v17 -1] ); | |
0 | 1117 } |
1118 v16 = v126; | |
1119 --v17; | |
1120 } | |
1121 if ( v17 < 0 ) | |
1122 v17 = 0; | |
1123 v21 = terrain_76DFC8[v17]; | |
1124 while ( 1 ) | |
1125 { | |
1126 v125 = v21; | |
67 | 1127 if ( v21 < v124 ) |
0 | 1128 break; |
67 | 1129 terrain_76DBC8[v16] = v21; |
0 | 1130 v22 = terrain_76DDC8[v17] == 65535; |
67 | 1131 terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1; |
0 | 1132 if ( v22 ) |
1133 { | |
67 | 1134 terrain_76D9C8[v16] = v123 + 1; |
0 | 1135 break; |
1136 } | |
1137 if ( !v17 ) | |
1138 break; | |
67 | 1139 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 - 1] ) |
0 | 1140 { |
1141 do | |
67 | 1142 v23 = terrain_76DDC8[v17-- -1]; |
1143 while ( v23 == terrain_76DDC8[v17 -1] ); | |
0 | 1144 } |
1145 --v17; | |
1146 v21 = v125 - 1; | |
67 | 1147 ++v16; |
1148 } | |
1149 v16 = 0; | |
0 | 1150 v24 = terrain_76E3C8[v18]; |
67 | 1151 v126 = 0; |
0 | 1152 if ( v120 > v24 ) |
1153 { | |
1154 v125 = v120; | |
67 | 1155 memset32(terrain_76D5C8, v122, 4 * (v120 - v24 + 1)); |
0 | 1156 do |
1157 { | |
1158 v25 = v126; | |
1159 v26 = v125--; | |
67 | 1160 ++v126; |
1161 terrain_76D7C8[v25] = v26; | |
0 | 1162 } |
1163 while ( v125 >= terrain_76E3C8[v18] ); | |
67 | 1164 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) |
0 | 1165 { |
1166 do | |
67 | 1167 v27 = terrain_76E1C8[v18-- -1]; |
1168 while ( v27 == terrain_76E1C8[v18 -1] ); | |
0 | 1169 } |
1170 v16 = v126; | |
1171 --v18; | |
1172 } | |
1173 if ( v18 < 0 ) | |
1174 v18 = 0; | |
1175 v28 = terrain_76E3C8[v18]; | |
67 | 1176 while ( v28 >= v124 ) |
0 | 1177 { |
1178 v29 = terrain_76E1C8[v18]; | |
67 | 1179 terrain_76D7C8[v16] = v28; |
1180 terrain_76D5C8[v16] = v29; | |
0 | 1181 if ( v29 == 65535 ) |
1182 { | |
1183 v31 = v123; | |
67 | 1184 terrain_76D5C8[v16] = v31; |
1185 break; | |
0 | 1186 } |
1187 if ( !v18 ) | |
1188 break; | |
67 | 1189 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) |
0 | 1190 { |
1191 do | |
67 | 1192 v30 = terrain_76E1C8[v18-- -1]; |
1193 while ( v30 == terrain_76E1C8[v18 -1] ); | |
0 | 1194 } |
1195 --v18; | |
1196 --v28; | |
67 | 1197 ++v16; |
0 | 1198 } |
1199 break; | |
67 | 1200 } |
0 | 1201 case 1: |
1202 case 2: | |
67 | 1203 { |
0 | 1204 v116 = terrain_76DDC8[v17]; |
1205 if ( v122 < v116 ) | |
1206 { | |
1207 v106 = v122; | |
67 | 1208 memset32(terrain_76DBC8, v120 + 1, 4 * (v116 - v122 + 1)); |
0 | 1209 v32 = v122; |
1210 do | |
1211 { | |
67 | 1212 v33 = v126++; |
0 | 1213 terrain_76D9C8[v33] = v32++; |
1214 } | |
1215 while ( v32 <= v116 ); | |
67 | 1216 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1217 { |
1218 do | |
67 | 1219 v34 = terrain_76DBC8[v17-- -1]; |
1220 while ( v34 == terrain_76DBC8[v17 -1] ); | |
0 | 1221 } |
1222 v16 = v126; | |
1223 --v17; | |
1224 } | |
1225 if ( v17 < 0 ) | |
1226 v17 = 0; | |
1227 v35 = terrain_76DDC8[v17]; | |
1228 v125 = terrain_76DDC8[v17]; | |
1229 while ( v35 <= v123 ) | |
1230 { | |
1231 v22 = terrain_76DFC8[v17] == 65535; | |
67 | 1232 terrain_76DBC8[v16] = terrain_76DFC8[v17] + 1; |
1233 terrain_76D9C8[v16] = v125; | |
0 | 1234 if ( v22 ) |
1235 { | |
67 | 1236 terrain_76DBC8[v16] = v124 + 1; |
0 | 1237 break; |
1238 } | |
1239 if ( !v17 ) | |
1240 break; | |
67 | 1241 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1242 { |
1243 do | |
67 | 1244 v36 = terrain_76DBC8[v17-- -1]; |
1245 while ( v36 == terrain_76DBC8[v17 -1] ); | |
0 | 1246 } |
1247 --v17; | |
1248 ++v125; | |
1249 v35 = v125; | |
67 | 1250 ++v16; |
1251 } | |
1252 v16 = 0; | |
1253 v126 = 0; | |
0 | 1254 v37 = terrain_76E1C8[v18]; |
1255 if ( v122 < v37 ) | |
1256 { | |
67 | 1257 v114 = v122; |
1258 memset32(terrain_76D7C8, i, 4 * (v37 - v122 + 1)); | |
0 | 1259 do |
1260 { | |
1261 v38 = v126; | |
67 | 1262 v39 = v114; |
1263 ++v126; | |
1264 ++v114; | |
1265 terrain_76D5C8[v38] = v39; | |
1266 } | |
1267 while ( v114 <= terrain_76E1C8[v18] ); | |
1268 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) | |
0 | 1269 { |
1270 do | |
67 | 1271 v40 = terrain_76DFC8[v18-- -1]; |
1272 while ( v40 == terrain_76DFC8[v18 -1] ); | |
0 | 1273 } |
1274 v16 = v126; | |
1275 --v18; | |
1276 } | |
1277 if ( v18 < 0 ) | |
1278 v18 = 0; | |
1279 v41 = terrain_76E1C8[v18]; | |
1280 while ( v41 <= v123 ) | |
1281 { | |
1282 v42 = terrain_76E3C8[v18]; | |
67 | 1283 terrain_76D5C8[v16] = v41; |
1284 terrain_76D7C8[v16] = v42; | |
0 | 1285 if ( v42 == 65535 ) |
1286 { | |
67 | 1287 terrain_76D7C8[v16] = v124; |
1288 break; | |
0 | 1289 } |
1290 if ( !v18 ) | |
1291 break; | |
67 | 1292 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) |
0 | 1293 { |
1294 do | |
67 | 1295 v43 = terrain_76DFC8[v18-- -1]; |
1296 while ( v43 == terrain_76DFC8[v18 -1] ); | |
0 | 1297 } |
1298 --v18; | |
1299 ++v41; | |
67 | 1300 ++v16; |
0 | 1301 } |
1302 break; | |
67 | 1303 } |
0 | 1304 case 5: |
1305 case 6: | |
67 | 1306 { |
0 | 1307 v116 = terrain_76DDC8[v17]; |
1308 if ( v119 > v116 ) | |
1309 { | |
1310 v106 = v119; | |
67 | 1311 memset32(terrain_76DBC8, i, 4 * (v119 - v116 + 1)); |
0 | 1312 v45 = v119; |
1313 do | |
67 | 1314 terrain_76D9C8[v126++] = v45--; |
0 | 1315 while ( v45 >= v116 ); |
67 | 1316 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1317 { |
1318 do | |
67 | 1319 v46 = terrain_76DBC8[v17-- -1]; |
1320 while ( v46 == terrain_76DBC8[v17 -1] ); | |
0 | 1321 } |
1322 v16 = v126; | |
1323 --v17; | |
1324 } | |
1325 if ( v17 < 0 ) | |
1326 v17 = 0; | |
1327 v47 = terrain_76DDC8[v17]; | |
1328 v125 = terrain_76DDC8[v17]; | |
1329 while ( v47 >= v123 ) | |
1330 { | |
1331 v22 = terrain_76DFC8[v17] == 65535; | |
67 | 1332 terrain_76DBC8[v16] = terrain_76DFC8[v17]; |
1333 terrain_76D9C8[v16] = v125; | |
0 | 1334 if ( v22 ) |
1335 { | |
67 | 1336 terrain_76DBC8[v16] = v124; |
0 | 1337 break; |
1338 } | |
1339 if ( !v17 ) | |
1340 break; | |
67 | 1341 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1342 { |
1343 do | |
67 | 1344 v48 = terrain_76DBC8[v17-- -1]; |
1345 while ( v48 == terrain_76DBC8[v17 -1] ); | |
0 | 1346 } |
1347 --v17; | |
1348 --v125; | |
1349 v47 = v125; | |
67 | 1350 ++v16; |
1351 } | |
1352 v16 = 0; | |
0 | 1353 v49 = terrain_76E1C8[v18]; |
67 | 1354 v126 = 0; |
0 | 1355 if ( v119 > v49 ) |
1356 { | |
1357 v125 = v119; | |
67 | 1358 memset32(terrain_76D7C8, v120 + 1, 4 * (v119 - v49 + 1)); |
0 | 1359 do |
1360 { | |
1361 v50 = v126; | |
1362 v51 = v125--; | |
67 | 1363 ++v126; |
1364 terrain_76D5C8[v50] = v51; | |
0 | 1365 } |
1366 while ( v125 >= terrain_76E1C8[v18] ); | |
67 | 1367 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) |
0 | 1368 { |
1369 do | |
67 | 1370 v52 = terrain_76DFC8[v18-- -1]; |
1371 while ( v52 == terrain_76DFC8[v18 -1] ); | |
0 | 1372 } |
1373 v16 = v126; | |
1374 --v18; | |
1375 } | |
1376 if ( v18 < 0 ) | |
1377 v18 = 0; | |
1378 v53 = terrain_76E1C8[v18]; | |
1379 while ( v53 >= v123 ) | |
1380 { | |
1381 v54 = terrain_76E3C8[v18]; | |
67 | 1382 terrain_76D5C8[v16] = v53; |
1383 terrain_76D7C8[v16] = v54 + 1; | |
0 | 1384 if ( v54 == 65535 ) |
1385 { | |
67 | 1386 terrain_76D7C8[v16] = v124 + 1; |
1387 break; | |
0 | 1388 } |
1389 if ( !v18 ) | |
67 | 1390 break; |
1391 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) | |
0 | 1392 { |
1393 do | |
67 | 1394 v55 = terrain_76DFC8[v18-- -1]; |
1395 while ( v55 == terrain_76DFC8[v18 -1] ); | |
0 | 1396 } |
1397 --v18; | |
1398 --v53; | |
67 | 1399 ++v16; |
0 | 1400 } |
1401 break; | |
67 | 1402 } |
0 | 1403 case 3: |
1404 case 4: | |
67 | 1405 { |
0 | 1406 v116 = terrain_76DFC8[v17]; |
1407 if ( i < v116 ) | |
1408 { | |
1409 v106 = i; | |
67 | 1410 memset32(terrain_76D9C8, v122, 4 * (v116 - i + 1)); |
0 | 1411 v56 = i; |
1412 do | |
1413 { | |
67 | 1414 v57 = v126++; |
0 | 1415 terrain_76DBC8[v57] = v56++; |
1416 } | |
1417 while ( v56 <= v116 ); | |
67 | 1418 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) |
0 | 1419 { |
1420 do | |
67 | 1421 v58 = terrain_76DDC8[v17-- -1]; |
1422 while ( v58 == terrain_76DDC8[v17 -1] ); | |
0 | 1423 } |
1424 v16 = v126; | |
1425 --v17; | |
1426 } | |
1427 if ( v17 < 0 ) | |
1428 v17 = 0; | |
1429 v59 = terrain_76DFC8[v17]; | |
1430 while ( 1 ) | |
1431 { | |
1432 v125 = v59; | |
67 | 1433 if ( v59 > v124 ) |
0 | 1434 break; |
67 | 1435 terrain_76DBC8[v16] = v59; |
0 | 1436 v60 = terrain_76DDC8[v17]; |
67 | 1437 terrain_76D9C8[v16] = v60; |
0 | 1438 if ( v60 == 65535 ) |
1439 { | |
67 | 1440 terrain_76D9C8[v16] = v123; |
0 | 1441 break; |
1442 } | |
1443 if ( !v17 ) | |
1444 break; | |
67 | 1445 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) |
0 | 1446 { |
1447 do | |
67 | 1448 v61 = terrain_76DDC8[v17-- -1]; |
1449 while ( v61 == terrain_76DDC8[v17 -1] ); | |
0 | 1450 } |
1451 --v17; | |
1452 v59 = v125 + 1; | |
67 | 1453 ++v16; |
1454 } | |
1455 v16 = 0; | |
1456 v126 = 0; | |
0 | 1457 v62 = terrain_76E3C8[v18]; |
1458 if ( i < v62 ) | |
1459 { | |
67 | 1460 v114 = i; |
1461 memset32(terrain_76D5C8, v119 + 1, 4 * (v62 - i + 1)); | |
0 | 1462 do |
1463 { | |
1464 v63 = v126; | |
67 | 1465 v64 = v114; |
1466 ++v126; | |
1467 ++v114; | |
1468 terrain_76D7C8[v63] = v64; | |
1469 } | |
1470 while ( v114 <= terrain_76E3C8[v18] ); | |
1471 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) | |
0 | 1472 { |
1473 do | |
67 | 1474 v65 = terrain_76E1C8[v18-- -1]; |
1475 while ( v65 == terrain_76E1C8[v18 -1] ); | |
0 | 1476 } |
1477 v16 = v126; | |
1478 --v18; | |
1479 } | |
1480 if ( v18 < 0 ) | |
1481 v18 = 0; | |
1482 v66 = terrain_76E3C8[v18]; | |
67 | 1483 while ( v66 <= v124 ) |
0 | 1484 { |
1485 v67 = terrain_76E1C8[v18]; | |
67 | 1486 terrain_76D7C8[v16] = v66; |
1487 terrain_76D5C8[v16] = v67 + 1; | |
0 | 1488 if ( v67 == 65535 ) |
1489 { | |
1490 v31 = v123 + 1; | |
67 | 1491 terrain_76D5C8[v16] = v31; |
1492 break; | |
0 | 1493 } |
1494 if ( !v18 ) | |
67 | 1495 break; |
1496 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) | |
0 | 1497 { |
1498 do | |
67 | 1499 v68 = terrain_76E1C8[v18-- -1]; |
1500 while ( v68 == terrain_76E1C8[v18 -1] ); | |
0 | 1501 } |
1502 --v18; | |
1503 ++v66; | |
67 | 1504 ++v16; |
0 | 1505 } |
1506 break; | |
67 | 1507 } |
0 | 1508 default: |
1509 break; | |
1510 } | |
67 | 1511 v69 = v16 - 1; |
0 | 1512 ptr_801A08 = pVerticesSR_806210; |
1513 ptr_801A04 = pVerticesSR_801A10; | |
67 | 1514 v126 = v69; |
106 | 1515 if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//áëîê |
0 | 1516 { |
1517 for ( i = v69; i >= 1; --i ) | |
1518 { | |
67 | 1519 //v70 = i; |
86 | 1520 v71 = terrain_76D7C8[i];//88 |
1521 v72 = terrain_76DBC8[i];//0 | |
67 | 1522 if ( v71 < v72 )//swap |
1523 { | |
1524 terrain_76DBC8[i] = v71; | |
1525 terrain_76D7C8[i] = v72; | |
1526 } | |
86 | 1527 x = terrain_76DBC8[i];//0 |
0 | 1528 v111 = 0; |
86 | 1529 if ( x <= 0 ) |
1530 x = -x; | |
67 | 1531 v74 = terrain_76D7C8[i]; |
0 | 1532 if ( v74 <= 0 ) |
1533 v74 = -v74; | |
1534 v75 = v74 + 2; | |
67 | 1535 //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; |
86 | 1536 uEndZ = v75; |
67 | 1537 //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; |
86 | 1538 uStartZ = x - 2; |
1539 if ( x - 2 < v75 ) | |
0 | 1540 { |
1541 v127 = 0; | |
67 | 1542 //v79 = (v73 - 66) << 9; |
1543 //v116 = v77; | |
1544 //pHeight = v79; | |
86 | 1545 v111 = v75 - uStartZ; |
1546 for (int z = uStartZ; z < uEndZ; ++z) | |
1547 { | |
106 | 1548 ptr_801A08[v127].vWorldPosition.x = (-64 + x) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; |
67 | 1549 ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; |
86 | 1550 ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); |
1551 ptr_801A04[v127].vWorldPosition.x = (-64 + x) * 512; | |
67 | 1552 ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; |
86 | 1553 ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); |
0 | 1554 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1555 { | |
67 | 1556 pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); |
1557 pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); | |
1558 pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); | |
1559 pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0); | |
0 | 1560 } |
67 | 1561 //v79 += 512; |
1562 v127 ++; | |
1563 //++v116; | |
1564 //pHeight = v79; | |
106 | 1565 } |
67 | 1566 //while ( v116 < v107 ); |
1567 } | |
106 | 1568 v102.v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); |
67 | 1569 v102.v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); |
106 | 1570 if ( pRenderer->pRenderD3D )//Ritor1: do comment to test |
98 | 1571 Render::RenderTerrainD3D();//Render::DrawTerrainD3D(v111, 0, (int)&v102); |
67 | 1572 else |
1573 Render::DrawTerrainSW(v111, 0, (int)&v102); | |
1574 } | |
1575 } | |
1576 /* else | |
0 | 1577 { |
1578 for ( i = v69; i >= 1; --i ) | |
1579 { | |
1580 v86 = i; | |
1581 v87 = terrain_76D5C8[i]; | |
1582 v88 = terrain_76D9C8[i]; | |
1583 if ( v87 < v88 ) | |
1584 { | |
1585 terrain_76D9C8[v86] = v87; | |
1586 terrain_76D5C8[v86] = v88; | |
1587 } | |
1588 v89 = terrain_76D9C8[v86]; | |
1589 v111 = 0; | |
1590 if ( v89 <= 0 ) | |
1591 v89 = -v89; | |
1592 v90 = terrain_76D5C8[v86]; | |
1593 if ( v90 <= 0 ) | |
1594 v90 = -v90; | |
67 | 1595 pIndoorCameraD3D_4 = pGame->pIndoorCameraD3D; |
0 | 1596 v107 = v90 + 2; |
1597 if ( v89 - 2 < v90 + 2 ) | |
1598 { | |
1599 v86 = 0; | |
1600 v116 = v89 - 2; | |
1601 v92 = (66 - v89) << 9; | |
62 | 1602 pHeight = (66 - v89) << 9; |
0 | 1603 v111 = v90 + 2 - (v89 - 2); |
1604 do | |
1605 { | |
1606 v93 = v116; | |
1607 v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9; | |
1608 *(float *)((char *)&ptr_801A08->vWorldPosition.x + v86) = (double)v106; | |
62 | 1609 *(float *)&pHeight = (double)pHeight; |
1610 *(float *)((char *)&ptr_801A08->vWorldPosition.y + v86) = *(float *)&pHeight; | |
0 | 1611 v106 = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86), v93); |
1612 v97 = v116; | |
1613 *(float *)((char *)&ptr_801A08->vWorldPosition.z + v86) = (double)v106; | |
1614 v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9; | |
1615 *(float *)((char *)&ptr_801A04->vWorldPosition.x + v86) = (double)v106; | |
62 | 1616 *(float *)((char *)&ptr_801A04->vWorldPosition.y + v86) = *(float *)&pHeight; |
1617 pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97); | |
1618 *(float *)((char *)&ptr_801A04->vWorldPosition.z + v86) = (double)pHeight; | |
0 | 1619 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1620 { | |
67 | 1621 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1); |
1622 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1); | |
1623 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0); | |
1624 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0); | |
0 | 1625 } |
1626 v92 -= 512; | |
1627 v86 += 48; | |
1628 ++v116; | |
62 | 1629 pHeight = v92; |
0 | 1630 } |
1631 while ( v116 < v107 ); | |
1632 } | |
1633 v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]); | |
1634 v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]); | |
67 | 1635 if ( pRenderer->pRenderD3D ) |
1636 Render::DrawTerrainD3D(v111, 1, (int)&v102); | |
1637 else | |
1638 Render::DrawTerrainSW(v111, 1, (int)&v102); | |
1639 } | |
1640 }*/ | |
0 | 1641 result = v126; |
1642 pOutdoorCamera->field_40 = v126; | |
1643 return result; | |
1644 } | |
1645 // 47FFC4: inconsistent fpu stack | |
1646 // 4D864C: using guessed type char byte_4D864C; | |
1647 | |
88 | 1648 void Render::RenderTerrainD3D() // New function. It's temporary |
86 | 1649 { |
1650 char result; // al@3 | |
1651 //int v1; // eax@3 | |
1652 //int v2; // ebx@4 | |
1653 //struct ODMFace *v4; // esi@6 | |
1654 int v6; // ecx@8 | |
1655 //int v7; // ecx@8 | |
1656 struct stru148 *v8; // ebx@8 | |
179 | 1657 // RenderVertexSoft *v8a; // edi@3 |
86 | 1658 //char v11; // zf@8 |
1659 struct stru148 *v16; | |
1660 unsigned int v18; // edi@22 | |
1661 //int v20; // edi@34 | |
1662 //int v28; // eax@50 | |
1663 //int v29; // ecx@55 | |
1664 //int v30; // eax@57 | |
1665 int v31; // eax@57 | |
1666 int v35; // edi@63 | |
1667 int v37; // eax@73 | |
1668 int v39; // eax@80 | |
1669 char v40; // [sp-18h] [bp-70h]@2 | |
1670 int v41; // [sp-14h] [bp-6Ch]@2 | |
1671 int v42; // [sp-10h] [bp-68h]@2 | |
1672 int v43; // [sp-Ch] [bp-64h]@2 | |
1673 const char *v44; // [sp-8h] [bp-60h]@2 | |
1674 int v45; // [sp-4h] [bp-5Ch]@2 | |
1675 //float v48; // [sp+14h] [bp-44h]@8 | |
1676 //void *v52; // [sp+24h] [bp-34h]@3 | |
1677 bool v54; // [sp+2Ch] [bp-2Ch]@10 | |
1678 int v55; // [sp+30h] [bp-28h]@34 | |
1679 int v56; | |
1680 int v57; // [sp+38h] [bp-20h]@36 | |
1681 int v58; // [sp+3Ch] [bp-1Ch]@8 | |
1682 int v63; // [sp+50h] [bp-8h]@3 | |
1683 int v64; // [sp+57h] [bp-1h]@2 | |
1684 int v62; | |
121 | 1685 //struct IndoorCameraD3D *pIndoorCameraD3D; |
179 | 1686 //RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 |
86 | 1687 |
186 | 1688 |
1689 //warning: the game uses CW culling by default, ccw is incosistent | |
1690 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
1691 | |
1692 | |
86 | 1693 v63 = 0; |
1694 // basic optimizations | |
577 | 1695 unsigned int uStartX, uEndX, uStartZ, uEndZ; |
106 | 1696 if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024) |
1697 { | |
1698 uStartX = 0, uEndX = 128; | |
1699 uStartZ = 0, uEndZ = 64 + 16; | |
1700 } | |
1701 else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536) | |
1702 { | |
1703 uStartX = 0, uEndX = 64 + 16; | |
1704 uStartZ = 0, uEndZ = 128; | |
1705 } | |
1706 else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512) | |
1707 { | |
1708 uStartX = 64 - 16, uEndX = 128; | |
1709 uStartZ = 0, uEndZ = 128; | |
1710 } | |
1711 else | |
1712 { | |
1713 uStartX = 0, uEndX = 128; | |
1714 uStartZ = 64 - 16, uEndZ = 128; | |
1715 } | |
147 | 1716 uStartX = 0, uEndX = 128; |
1717 uStartZ = 0, uEndZ = 128; | |
106 | 1718 static RenderVertexSoft pTerrainVertices[128 * 128]; |
1719 for (unsigned int z = uStartZ; z < uEndZ; ++z) | |
1720 { | |
1721 for (unsigned int x = uStartX; x < uEndX; ++x) | |
1722 { | |
1723 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; | |
1724 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512; | |
1725 pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 1726 //pIndoorCameraD3D = pGame->pIndoorCameraD3D; |
1727 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); | |
1728 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 1729 } |
1730 } | |
186 | 1731 |
106 | 1732 for (unsigned int z = uStartZ; z < uEndZ - 1; ++z) |
1733 { | |
1734 for (unsigned int x = uStartX; x < uEndX - 1; ++x) | |
1735 { | |
1736 v8 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
1737 v8->flags = 0; | |
1738 v8->field_32 = 0; | |
1739 //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x]; | |
179 | 1740 //struct TileDesc *pTile = pTileTable->GetTileById(uTileID); |
106 | 1741 v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); |
179 | 1742 //v6 = v8->uTileBitmapID; |
1743 v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v8->uTileBitmapID]; | |
106 | 1744 if (v8->uTileBitmapID == 0xFFFF) |
1745 continue; | |
186 | 1746 |
179 | 1747 v8->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
1748 v8->field_32 = 0; | |
1749 v8->field_59 = 1; | |
1750 //v8->field_5D = (char)WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8a->vWorldPosition.z) / 2 + 0.5f)); | |
1751 //v8->field_5C = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f));; | |
106 | 1752 v8->sTextureDeltaU = 0; |
1753 v8->sTextureDeltaV = 0; | |
1754 memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft)); | |
1755 array_73D150[0].u = 0; | |
1756 array_73D150[0].v = 0; | |
1757 memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1758 array_73D150[1].u = 1; | |
1759 array_73D150[1].v = 0; | |
1760 memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1761 array_73D150[2].u = 1; | |
1762 array_73D150[2].v = 1; | |
1763 memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft)); | |
1764 array_73D150[3].u = 0; | |
1765 array_73D150[3].v = 1; | |
86 | 1766 v55 = 0; |
1767 v54 = false; | |
1768 v58 = 0; | |
1769 if (v58 == 4) // if all y == first y; primitive in xz plane | |
1770 v8->field_32 |= 0x0001; | |
1771 v8->pODMFace = nullptr; | |
1772 v8->uNumVertices = 4; | |
1773 v8->field_59 = 5; | |
638 | 1774 |
1775 | |
1776 uint norm_idx = pTerrainNormalIndices[2 * (x + 128 * z) + 1]; | |
1777 assert(norm_idx < uNumTerrainNormals); | |
1778 | |
1779 auto norm = pTerrainNormals + norm_idx; | |
1780 float _f = (norm->x * (float)pOutdoor->vSunlight.x / 65536.0 - | |
1781 norm->y * (float)pOutdoor->vSunlight.y / 65536.0 - | |
1782 norm->z * (float)pOutdoor->vSunlight.z / 65536.0); | |
1783 v8->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); | |
1784 | |
86 | 1785 ++pOutdoorCamera->numStru148s; |
1786 ++pOutdoorCamera->field_44; | |
265 | 1787 assert(pOutdoorCamera->numStru148s < 20000); |
1788 | |
106 | 1789 v8->uBModelID = 0; |
1790 v8->uBModelFaceID = 0; | |
1791 v31 = (8 * (0 | (0 << 6))); | |
1792 v8->field_50 = v31 | 6; | |
265 | 1793 for (unsigned int k = 0; k < v8->uNumVertices; ++k) |
106 | 1794 { |
1795 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 1796 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 1797 } |
140 | 1798 |
186 | 1799 bool transparent = false; |
265 | 1800 if ( v8->flags & 2 && v8->uTileBitmapID == pRenderer->hd_water_tile_id) |
179 | 1801 { |
1802 //v80 = false; | |
265 | 1803 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
179 | 1804 } |
1805 else | |
1806 { | |
1807 v6 = v8->uTileBitmapID; | |
186 | 1808 transparent = true; |
179 | 1809 } |
1810 | |
140 | 1811 assert(v6 < 1000); // many random crashes here |
186 | 1812 |
1813 // for all shore tiles - draw a tile water under them since they're half-empty | |
1814 if (!strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX | |
1815 { | |
1816 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 | 1817 pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]], false, true); |
186 | 1818 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE); |
1819 | |
1820 } | |
1821 | |
1822 pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
1823 | |
1824 | |
86 | 1825 --pOutdoorCamera->numStru148s; |
1826 --pOutdoorCamera->field_44; | |
106 | 1827 } |
1828 } | |
1829 } | |
0 | 1830 |
1831 //----- (0048034E) -------------------------------------------------------- | |
67 | 1832 void Render::DrawTerrainD3D(int a1, int a2, int a3) |
0 | 1833 { |
1834 int v3; // esi@1 | |
1835 int v4; // edi@1 | |
1836 int v5; // ebx@2 | |
1837 int v6; // eax@2 | |
1838 int v7; // eax@3 | |
1839 RenderVertexSoft *v8; // edi@3 | |
1840 RenderVertexSoft *v9; // ebx@4 | |
1841 RenderVertexSoft *v10; // ecx@4 | |
1842 float v11; // eax@6 | |
1843 double v12; // ST5C_8@6 | |
1844 double v13; // ST2C_8@6 | |
1845 int v14; // eax@6 | |
1846 double v15; // st7@6 | |
1847 stru148 *v16; // ebx@12 | |
1848 unsigned __int16 v17; // ax@12 | |
1849 int v18; // eax@13 | |
67 | 1850 int v19; // ecx@13 |
1851 int v20; // eax@13 | |
0 | 1852 int v21; // eax@13 |
1853 signed int v22; // eax@13 | |
1854 Vec3_float_ *v23; // eax@15 | |
1855 double v24; // st6@17 | |
1856 double v25; // ST54_8@17 | |
1857 unsigned __int8 v26; // sf@17 | |
1858 unsigned __int8 v27; // of@17 | |
1859 double v28; // st5@19 | |
1860 double v29; // st5@19 | |
1861 double v30; // st5@19 | |
1862 double v31; // st5@19 | |
67 | 1863 struct struct8 *v32; // esi@21 |
1864 double v3a; // st7@32 | |
0 | 1865 int v33; // edi@38 |
1866 unsigned int v34; // ecx@47 | |
1867 char v35; // zf@47 | |
1868 unsigned int v36; // eax@50 | |
1869 int v37; // eax@54 | |
1870 stru148 *v38; // ecx@55 | |
1871 unsigned int v39; // eax@59 | |
1872 stru148 *v40; // ebx@62 | |
86 | 1873 unsigned __int16 pTileBitmapsID; // ax@62 |
0 | 1874 int v42; // eax@63 |
1875 LightmapBuilder *v43; // ecx@63 | |
67 | 1876 int v44; // eax@63 |
0 | 1877 int v45; // eax@63 |
1878 int v46; // eax@63 | |
1879 signed int v47; // eax@63 | |
1880 Vec3_float_ *v48; // eax@65 | |
1881 double v49; // st6@67 | |
1882 double v50; // ST4C_8@67 | |
1883 double v51; // st5@71 | |
1884 double v52; // st5@71 | |
1885 double v53; // st5@71 | |
1886 double v54; // st7@84 | |
1887 unsigned int v55; // ecx@98 | |
1888 unsigned int v56; // eax@101 | |
1889 int v57; // eax@105 | |
1890 unsigned int v58; // eax@109 | |
1891 stru148 *v59; // esi@112 | |
1892 unsigned __int16 v60; // ax@112 | |
67 | 1893 int v61; // eax@113 |
0 | 1894 signed int v62; // eax@113 |
1895 Vec3_float_ *v63; // eax@114 | |
1896 double v64; // st6@116 | |
1897 double v65; // ST3C_8@116 | |
1898 double v66; // st5@120 | |
1899 double v67; // st5@120 | |
1900 double v68; // st5@120 | |
1901 double v69; // st7@133 | |
1902 int v70; // edi@138 | |
86 | 1903 stru148 *v71; // esi@147 |
0 | 1904 unsigned int v72; // ecx@147 |
1905 unsigned int v73; // eax@150 | |
67 | 1906 int v74; // eax@154 |
0 | 1907 unsigned int v75; // eax@158 |
1908 unsigned int v76; // [sp-10h] [bp-E0h]@61 | |
67 | 1909 int v77; // [sp-Ch] [bp-DCh]@61 |
0 | 1910 IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 |
1911 int v79; // [sp-4h] [bp-D4h]@61 | |
1912 int v80; // [sp+0h] [bp-D0h]@59 | |
1913 int v81; // [sp+0h] [bp-D0h]@109 | |
1914 int v82; // [sp+54h] [bp-7Ch]@1 | |
1915 int v83; // [sp+60h] [bp-70h]@1 | |
1916 int v84; // [sp+6Ch] [bp-64h]@1 | |
1917 int v85; // [sp+70h] [bp-60h]@63 | |
1918 int a4; // [sp+74h] [bp-5Ch]@73 | |
1919 float v87; // [sp+78h] [bp-58h]@122 | |
1920 int v88; // [sp+7Ch] [bp-54h]@1 | |
1921 int v89; // [sp+80h] [bp-50h]@6 | |
1922 float v90; // [sp+84h] [bp-4Ch]@1 | |
1923 float v91; // [sp+88h] [bp-48h]@1 | |
1924 float v92; // [sp+8Ch] [bp-44h]@1 | |
67 | 1925 int v93; // [sp+90h] [bp-40h]@2 |
0 | 1926 int X; // [sp+94h] [bp-3Ch]@1 |
1927 float v95; // [sp+98h] [bp-38h]@21 | |
1928 LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 | |
67 | 1929 int v97; // [sp+A0h] [bp-30h]@6 |
0 | 1930 int sX; // [sp+A4h] [bp-2Ch]@6 |
1931 unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 | |
1932 int v100; // [sp+ACh] [bp-24h]@122 | |
1933 int sY; // [sp+B0h] [bp-20h]@6 | |
67 | 1934 RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 |
0 | 1935 unsigned int a5; // [sp+B8h] [bp-18h]@21 |
1936 RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 | |
1937 Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 | |
1938 RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 | |
67 | 1939 RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 |
0 | 1940 char v108; // [sp+CFh] [bp-1h]@36 |
1941 float thisd; // [sp+D8h] [bp+8h]@6 | |
1942 float thise; // [sp+D8h] [bp+8h]@6 | |
1943 float thisf; // [sp+D8h] [bp+8h]@17 | |
1944 IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 | |
1945 float thisg; // [sp+D8h] [bp+8h]@67 | |
1946 IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 | |
1947 float thish; // [sp+D8h] [bp+8h]@116 | |
1948 IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 | |
1949 char this_3; // [sp+DBh] [bp+Bh]@30 | |
1950 char this_3a; // [sp+DBh] [bp+Bh]@82 | |
1951 char this_3b; // [sp+DBh] [bp+Bh]@131 | |
1952 | |
67 | 1953 static stru154 static_sub_0048034E_stru_154; |
1954 static stru154 stru_76D5A8; | |
0 | 1955 v3 = a1; |
67 | 1956 v82 = a2; |
0 | 1957 v83 = *(/*short **/_WORD *)(a3 + 4); |
1958 X = abs(*(/*short **/_WORD *)(a3 + 6)); | |
1959 v4 = 0; | |
1960 v88 = 0; | |
1961 v84 = v3 - 1; | |
638 | 1962 v90 = (float)pOutdoor->vSunlight.x / 65536.0; |
67 | 1963 v91 = (float)pOutdoor->vSunlight.y / 65536.0; |
1964 v92 = (float)pOutdoor->vSunlight.z / 65536.0; | |
0 | 1965 if ( v3 - 1 > 0 ) |
1966 { | |
1967 while ( 1 ) | |
1968 { | |
1969 v5 = abs(X);//v5 = 13108 | |
1970 v6 = abs(v83);//v6 = 13108 | |
1971 --X; | |
186 | 1972 __debugbreak(); // uncoment & refactor following large if |
67 | 1973 v93 = (int)&stru_76E5C8[(v5 << 7) + v6]; |
1974 /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), | |
0 | 1975 v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), |
1976 ((a8 = v9, | |
1977 pVertices = &pVerticesSR_801A10[1] + v7, | |
1978 v11 = v8->vWorldPosition.x, | |
1979 v101 = v10, | |
1980 v12 = v11 + 6.755399441055744e15, | |
1981 sX = LODWORD(v12), | |
1982 v13 = v8->vWorldPosition.y + 6.755399441055744e15, | |
1983 sY = LODWORD(v13), | |
1984 thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, | |
62 | 1985 v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X |
0 | 1986 v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, |
1987 v89 = v14, | |
1988 thise = v15 * 0.5, | |
62 | 1989 _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z |
0 | 1990 WorldPosToGridCellX(sX), |
1991 WorldPosToGridCellZ(sY), | |
1992 !byte_4D864C) | |
1993 || !(pGame->uFlags & 0x80)) | |
67 | 1994 && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ |
1995 if ( !&stru_76E5C8[(v5 << 7) + v6] ) | |
0 | 1996 goto LABEL_162; |
67 | 1997 v8 = &pVerticesSR_806210[v4]; |
1998 pVertices2 = &pVerticesSR_801A10[v4 + 1]; | |
1999 v102 = v8; | |
2000 if (!v82) | |
2001 { | |
86 | 2002 pVertices = &pVerticesSR_801A10[v4]; |
2003 v101 = &pVerticesSR_806210[v4 + 1]; | |
67 | 2004 } |
2005 else | |
2006 { | |
86 | 2007 pVertices = &pVerticesSR_801A10[v4 + 1]; |
2008 v101 = &pVerticesSR_806210[v4]; | |
2009 } | |
67 | 2010 sX = floorf(v8->vWorldPosition.x + 0.5f); |
2011 sY = floorf(v8->vWorldPosition.z + 0.5f); | |
2012 v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); | |
2013 v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); | |
2014 WorldPosToGridCellX(sX); | |
2015 WorldPosToGridCellZ(sY); | |
2016 if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) | |
86 | 2017 if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y |
2018 || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) | |
67 | 2019 break; |
2020 v16 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2021 v16->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
86 | 2022 if ( v16->uTileBitmapID != -1 ) |
2023 { | |
2024 v19 = v97; | |
2025 v16->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2026 v16->field_32 = 0; | |
2027 v20 = v93; | |
2028 v16->field_59 = 1; | |
638 | 2029 v16->terrain_grid_x = (char)v19; |
86 | 2030 v16->field_34 = *(_WORD *)(v20 + 2); |
2031 v21 = v89; | |
638 | 2032 v16->terrain_grid_z = v89; |
86 | 2033 v22 = pTerrainNormalIndices[2 * (v19 + 128 * v21) + 1]; |
2034 if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) | |
2035 v23 = 0; | |
2036 else | |
2037 v23 = &pTerrainNormals[v22]; | |
638 | 2038 v24 = v92 * v23->z; |
86 | 2039 //v99 = v23; |
638 | 2040 thisf = 20.0 - (-v24 - v91 * v23->y - v90 * v23->x) * 20.0; |
86 | 2041 //v25 = thisf + 6.7553994e15; |
2042 //v27 = pOutdoorCamera->numStru148s > 1999; | |
2043 //v26 = pOutdoorCamera->numStru148s - 1999 < 0; | |
638 | 2044 v16->dimming_level = floorf(thisf + 0.5f); |
86 | 2045 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2046 return; | |
2047 ++pOutdoorCamera->numStru148s; | |
96 | 2048 //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary |
4 | 2049 //goto LABEL_126; |
96 | 2050 //{ |
2051 //--pOutdoorCamera->numStru148s; | |
2052 //goto LABEL_162; | |
2053 //} | |
86 | 2054 memcpy(&array_50AC10[0], v102, 0x30u); |
168 | 2055 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2056 array_50AC10[0].u = 0.0; |
2057 array_50AC10[0].v = 0.0; | |
2058 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
168 | 2059 array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2060 array_50AC10[1].u = 0.0; |
2061 array_50AC10[1].v = 1.0; | |
2062 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
168 | 2063 array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2064 array_50AC10[2].u = 1.0; |
2065 array_50AC10[2].v = 1.0; | |
2066 memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); | |
168 | 2067 array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2068 array_50AC10[3].u = 1.0; |
2069 array_50AC10[3].v = 0.0; | |
2070 /*if ( !(byte_76D5C0 & 1) ) | |
2071 { | |
2072 byte_76D5C0 |= 1u; | |
2073 stru154(stru_76D5A8); | |
2074 atexit(loc_481199); | |
2075 }*/ | |
2076 v32 = (struct8 *)array_50AC10; | |
2077 v97 = (int)pGame->pLightmapBuilder; | |
2078 pGame->pLightmapBuilder->StackLights_TerrainFace(v23, &v95, array_50AC10, 4, 1); | |
2079 pDecalBuilder->_49BE8A(v16, *(float *)&v23, (int)&v95, array_50AC10, 4, 1); | |
2080 a5 = 4; | |
2081 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2082 { | |
2083 thisa = pGame->pIndoorCameraD3D; | |
2084 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) | |
2085 goto LABEL_162; | |
2086 thisa->ViewTransform(array_50AC10, a5); | |
2087 thisa->Project(array_50AC10, a5, 0); | |
2088 } | |
2089 this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 | |
2090 || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
2091 v3a = (double)pOutdoorCamera->shading_dist_mist; | |
2092 v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x | |
2093 || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; | |
2094 v33 = 0; | |
2095 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
2096 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
0 | 2097 { |
86 | 2098 if ( this_3 ) |
2099 v33 = 3; | |
2100 else | |
2101 v33 = v108 != 0 ? 5 : 0; | |
734 | 2102 static_sub_0048034E_stru_154.ClassifyPolygon(v23, v95); |
86 | 2103 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2104 pDecalBuilder->ApplyDecals(31 - v16->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); |
0 | 2105 } |
86 | 2106 if ( stru_F8AD28.uNumLightsApplied > 0 ) |
2107 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); | |
2108 v34 = a5; | |
2109 //v35 = byte_4D864C == 0; | |
2110 v16->uNumVertices = a5; | |
2111 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) | |
0 | 2112 { |
86 | 2113 if ( this_3 ) |
2114 { | |
2115 v36 = sr_424CD7(v34); | |
2116 v16->uNumVertices = v36; | |
2117 OutdoorCamera::Project(v36); | |
2118 } | |
2119 if ( v108 ) | |
2120 { | |
2121 v36 = sr_424EE0_MakeFanFromTriangle(v34); | |
2122 v16->uNumVertices = v36; | |
2123 OutdoorCamera::Project(v36); | |
2124 } | |
0 | 2125 } |
86 | 2126 //v37 = *(int *)&v16->flags; |
2127 if ( ~v16->flags & 1 ) | |
2128 { | |
265 | 2129 if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2130 { |
2131 v80 = false; | |
265 | 2132 v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2133 } |
2134 else | |
2135 { | |
2136 v39 = v16->uTileBitmapID; | |
2137 v80 = true; | |
2138 } | |
2139 //v79 = 0; | |
2140 //v78 = pBitmaps_LOD->pHardwareTextures[v39]; | |
2141 v16->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary | |
2142 v77 = (int)v16; | |
2143 //v76 = v16->uNumVertices; | |
4 | 2144 //LABEL_161: |
186 | 2145 pRenderer->DrawTerrainPolygon(v16->uNumVertices, v16, pBitmaps_LOD->pHardwareTextures[v39], false, v80); |
86 | 2146 goto LABEL_162; |
2147 } | |
2148 v38 = v16; | |
0 | 2149 LABEL_56: |
86 | 2150 v38->_4811A3(); |
2151 } | |
0 | 2152 LABEL_162: |
86 | 2153 v4 = v88 + 1; |
2154 if ( ++v88 >= v84 ) | |
2155 return; | |
2156 } | |
2157 v40 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2158 v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
2159 if ( v40->uTileBitmapID == -1 ) | |
2160 goto LABEL_162; | |
2161 v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2162 BYTE1(v42) |= 0x80u; | |
2163 v43 = pGame->pLightmapBuilder; | |
2164 *(int *)&v40->flags = v42; | |
2165 v44 = v93; | |
2166 v40->field_59 = 1; | |
638 | 2167 v40->terrain_grid_x = (char)v43; |
86 | 2168 v40->field_34 = *(_WORD *)(v44 + 2); |
2169 v45 = v89; | |
638 | 2170 v40->terrain_grid_z = v89; |
86 | 2171 v46 = 4 * ((char)v43 + (v45 << 7)); |
2172 v85 = v46; | |
2173 v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; | |
2174 if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) | |
2175 v48 = 0; | |
2176 else | |
2177 v48 = &pTerrainNormals[v47]; | |
2178 v49 = v92 * v48->y; | |
2179 //v99 = v48; | |
2180 thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; | |
2181 v50 = thisg + 6.755399441055744e15; | |
638 | 2182 v40->dimming_level = LOBYTE(v50); |
86 | 2183 if ( LOBYTE(v50) < 0 ) |
638 | 2184 v40->dimming_level = 0; |
86 | 2185 if ( pOutdoorCamera->numStru148s >= 1999 ) |
0 | 2186 return; |
86 | 2187 ++pOutdoorCamera->numStru148s; |
2188 /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary | |
2189 //goto LABEL_77; | |
2190 { | |
2191 --pOutdoorCamera->numStru148s; | |
2192 goto LABEL_112; | |
2193 }*/ | |
2194 memcpy(&array_50AC10[0], v102, 0x30u); | |
168 | 2195 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2196 array_50AC10[0].u = 0.0; |
2197 array_50AC10[0].v = 0.0; | |
2198 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
168 | 2199 array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2200 array_50AC10[1].u = 0.0; |
2201 array_50AC10[1].v = 1.0; | |
2202 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
168 | 2203 array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2204 array_50AC10[2].u = 1.0; |
2205 array_50AC10[2].v = 1.0; | |
2206 static stru154 static_sub_0048034E_stru_76D590; | |
2207 /*static bool __init_flag2 = false; | |
2208 if (!__init_flag2) | |
2209 { | |
2210 __init_flag2 = true; | |
2211 stru154::stru154(&static_sub_0048034E_stru_76D590); | |
2212 }*/ | |
2213 /*if ( !(byte_76D5C0 & 2) ) | |
2214 { | |
2215 byte_76D5C0 |= 2; | |
2216 stru148(stru_76D590); | |
2217 atexit(loc_48118F); | |
2218 }*/ | |
2219 v96 = pGame->pLightmapBuilder; | |
2220 pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); | |
2221 pDecalBuilder->_49BE8A(v40, *(float *)&v48, (int)&a4, array_50AC10, 3, 0); | |
2222 uNumVertices = 3; | |
2223 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2224 { | |
2225 thisb = pGame->pIndoorCameraD3D; | |
2226 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) | |
2227 { | |
2228 //LABEL_77: | |
2229 --pOutdoorCamera->numStru148s; | |
2230 goto LABEL_112; | |
2231 } | |
2232 thisb->ViewTransform(array_50AC10, uNumVertices); | |
2233 thisb->Project(array_50AC10, uNumVertices, 0); | |
2234 } | |
2235 this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
2236 v54 = (double)pOutdoorCamera->shading_dist_mist; | |
2237 v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; | |
2238 pVertices = 0; | |
2239 v96->std__vector_000004_size = 0; | |
2240 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
2241 { | |
2242 if ( this_3a ) | |
2243 pVertices = (RenderVertexSoft *)3; | |
2244 else | |
2245 pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); | |
2246 //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); | |
734 | 2247 static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); |
86 | 2248 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2249 pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); |
86 | 2250 } |
2251 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
2252 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); | |
2253 v55 = uNumVertices; | |
2254 //v35 = byte_4D864C == 0; | |
2255 v40->uNumVertices = uNumVertices; | |
2256 if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) | |
2257 { | |
2258 if ( this_3a ) | |
2259 { | |
2260 v56 = sr_424CD7(v55); | |
2261 } | |
2262 else | |
2263 { | |
2264 if ( !v108 ) | |
2265 goto LABEL_105; | |
2266 v56 = sr_424EE0_MakeFanFromTriangle(v55); | |
2267 } | |
2268 v40->uNumVertices = v56; | |
2269 OutdoorCamera::Project(v56); | |
2270 } | |
2271 LABEL_105: | |
2272 v57 = *(int *)&v40->flags; | |
2273 if ( BYTE1(v57) & 1 ) | |
2274 { | |
2275 v40->_4811A3(); | |
2276 } | |
2277 else | |
2278 { | |
265 | 2279 if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2280 { |
2281 v81 = 0; | |
265 | 2282 v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2283 } |
2284 else | |
2285 { | |
2286 v58 = v40->uTileBitmapID; | |
2287 v81 = 1; | |
2288 } | |
186 | 2289 pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); |
86 | 2290 } |
2291 LABEL_112: | |
2292 v59 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2293 //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->numStru148s]; | |
2294 v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
2295 if ( v59->uTileBitmapID == -1 ) | |
2296 goto LABEL_162; | |
2297 *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2298 v61 = v93; | |
2299 v59->field_59 = 1; | |
2300 v59->field_34 = *(_WORD *)(v61 + 2); | |
638 | 2301 v59->terrain_grid_z = v89; |
2302 v59->terrain_grid_x = v97; | |
86 | 2303 v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); |
2304 if ( v62 > (signed int)(uNumTerrainNormals - 1) ) | |
2305 v63 = 0; | |
2306 else | |
2307 v63 = &pTerrainNormals[v62]; | |
2308 v64 = v92 * v63->y; | |
2309 //v99 = v63; | |
2310 thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; | |
638 | 2311 v59->dimming_level = floorf(thish + 0.5f); |
2312 if ( v59->dimming_level < 0 ) | |
2313 v59->dimming_level = 0; | |
86 | 2314 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2315 return; | |
2316 ++pOutdoorCamera->numStru148s; | |
2317 if ( !sub_481FC9(v101, v102, pVertices2, v59) ) | |
2318 { | |
2319 //LABEL_126: | |
4 | 2320 --pOutdoorCamera->numStru148s; |
86 | 2321 goto LABEL_162; |
2322 } | |
2323 memcpy(&array_50AC10[0], v102, 0x30u); | |
168 | 2324 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2325 array_50AC10[0].u = 0.0; |
2326 array_50AC10[0].v = 0.0; | |
2327 memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); | |
168 | 2328 array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2329 array_50AC10[1].u = 1.0; |
2330 array_50AC10[1].v = 1.0; | |
2331 memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); | |
168 | 2332 array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2333 array_50AC10[2].u = 1.0; |
2334 array_50AC10[2].v = 0.0; | |
2335 static stru154 static_sub_0048034E_stru_76D578; | |
2336 /*static bool __init_flag1 = false; | |
2337 if (!__init_flag1) | |
2338 { | |
2339 __init_flag1 = true; | |
2340 stru154::stru154(&static_sub_0048034E_stru_76D578); | |
2341 }*/ | |
2342 v96 = pGame->pLightmapBuilder; | |
2343 pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); | |
2344 pDecalBuilder->_49BE8A(v40, *(float *)&v63, (int)&v87, array_50AC10, 3, 1); | |
2345 v100 = 3; | |
2346 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2347 { | |
2348 thisc = pGame->pIndoorCameraD3D; | |
2349 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) | |
2350 //goto LABEL_126; | |
2351 { | |
2352 --pOutdoorCamera->numStru148s; | |
2353 goto LABEL_162; | |
2354 } | |
2355 thisc->ViewTransform(array_50AC10, v100); | |
2356 thisc->Project(array_50AC10, v100, 0); | |
2357 } | |
2358 this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 | |
2359 || v101->vWorldViewPosition.x < 8.0; | |
2360 v69 = (double)pOutdoorCamera->shading_dist_mist; | |
2361 v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; | |
2362 v70 = 0; | |
2363 v96->std__vector_000004_size = 0; | |
2364 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
2365 { | |
2366 if ( this_3b ) | |
2367 v70 = 3; | |
2368 else | |
2369 v70 = v108 != 0 ? 5 : 0; | |
734 | 2370 static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); |
86 | 2371 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2372 pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); |
86 | 2373 } |
2374 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
2375 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); | |
2376 v71 = v59; | |
2377 v72 = v100; | |
2378 //v35 = byte_4D864C == 0; | |
2379 v59->uNumVertices = v100;//??? | |
2380 if ( !byte_4D864C && pGame->uFlags & 0x80 ) | |
2381 goto LABEL_154; | |
2382 if ( this_3b ) | |
2383 { | |
2384 v73 = sr_424CD7(v72); | |
0 | 2385 } |
2386 else | |
2387 { | |
2388 if ( !v108 ) | |
86 | 2389 { |
2390 LABEL_154: | |
2391 v74 = v71->flags; | |
2392 if ( !(BYTE1(v74) & 1) ) | |
2393 { | |
265 | 2394 if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2395 { |
2396 v80 = false; | |
265 | 2397 v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2398 } |
2399 else | |
2400 { | |
2401 v75 = v71->uTileBitmapID; | |
2402 v80 = true; | |
2403 } | |
2404 //v79 = 0; | |
2405 //v78 = pBitmaps_LOD->pHardwareTextures[v75]; | |
2406 v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary | |
2407 //v77 = (int)v71; | |
2408 //v76 = v71->uNumVertices; | |
2409 //goto LABEL_161; | |
186 | 2410 pRenderer->DrawTerrainPolygon(v76, (stru148 *)v71, v78, v79, v80); |
86 | 2411 goto LABEL_162; |
2412 } | |
2413 v38 = (stru148 *)v71; | |
2414 goto LABEL_56; | |
2415 } | |
2416 v73 = sr_424EE0_MakeFanFromTriangle(v72); | |
2417 } | |
2418 v71->uNumVertices = v73; | |
2419 OutdoorCamera::Project(v73); | |
0 | 2420 goto LABEL_154; |
86 | 2421 } |
2422 } | |
0 | 2423 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); |
2424 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); | |
2425 // 4D864C: using guessed type char byte_4D864C; | |
2426 // 76D5C0: using guessed type char static_sub_0048034E_byte_76D5C0__init_flag; | |
2427 | |
2428 //----- (00481212) -------------------------------------------------------- | |
2429 void Render::DrawTerrainSW(int a1, int a2, int a3) | |
2430 { | |
2431 int v3; // esi@1 | |
2432 int v4; // ecx@1 | |
2433 int v5; // ST10_4@1 | |
2434 int v6; // edi@1 | |
2435 int v7; // ebx@2 | |
2436 int v8; // eax@2 | |
2437 int v9; // eax@3 | |
2438 RenderVertexSoft *v10; // edi@3 | |
2439 RenderVertexSoft *v11; // ebx@4 | |
2440 RenderVertexSoft *v12; // ecx@4 | |
2441 float v13; // eax@6 | |
2442 int v14; // eax@6 | |
2443 double v15; // st7@6 | |
2444 double v16; // st7@6 | |
2445 stru148 *v17; // ebx@12 | |
2446 unsigned __int16 v18; // ax@12 | |
2447 int v19; // eax@13 | |
2448 float v20; // ecx@13 | |
2449 stru220 *v21; // eax@13 | |
2450 int v22; // eax@13 | |
2451 signed int v23; // eax@13 | |
2452 Vec3_float_ *v24; // eax@15 | |
2453 double v25; // st7@18 | |
2454 double v26; // st5@24 | |
2455 double v27; // st5@24 | |
2456 double v28; // st5@24 | |
2457 double v29; // st5@24 | |
2458 Game *v30; // eax@25 | |
2459 RenderVertexSoft *v31; // edi@29 | |
2460 double v32; // st7@31 | |
2461 int v33; // esi@35 | |
2462 RenderVertexSoft *v34; // edx@36 | |
2463 RenderVertexSoft *v35; // ecx@36 | |
2464 signed int v36; // eax@39 | |
2465 signed int v37; // esi@40 | |
2466 stru148 *v38; // ebx@43 | |
2467 unsigned __int16 v39; // ax@43 | |
2468 int v40; // eax@44 | |
2469 float v41; // ecx@44 | |
2470 stru220 *v42; // eax@44 | |
2471 int v43; // eax@44 | |
2472 int v44; // eax@44 | |
2473 signed int v45; // eax@44 | |
2474 Vec3_float_ *v46; // eax@46 | |
2475 double v47; // st7@49 | |
2476 double v48; // st5@57 | |
2477 double v49; // st5@57 | |
2478 double v50; // st5@57 | |
2479 Game *v51; // eax@58 | |
2480 RenderVertexSoft *v52; // edi@62 | |
2481 double v53; // st7@63 | |
2482 int v54; // esi@66 | |
2483 signed int v55; // eax@69 | |
2484 signed int v56; // esi@71 | |
2485 unsigned __int16 v57; // ax@75 | |
2486 stru220 *v58; // eax@76 | |
2487 signed int v59; // eax@76 | |
2488 Vec3_float_ *v60; // eax@77 | |
2489 double v61; // st7@80 | |
2490 double v62; // st5@88 | |
2491 double v63; // st5@88 | |
2492 double v64; // st5@88 | |
2493 Game *v65; // eax@89 | |
2494 double v66; // st7@94 | |
2495 RenderVertexSoft *v67; // [sp-Ch] [bp-C4h]@36 | |
2496 stru148 *v68; // [sp-8h] [bp-C0h]@36 | |
2497 int v69; // [sp-4h] [bp-BCh]@36 | |
2498 float v70; // [sp+Ch] [bp-ACh]@88 | |
2499 double v71; // [sp+10h] [bp-A8h]@6 | |
2500 double v72; // [sp+18h] [bp-A0h]@82 | |
2501 double v73; // [sp+20h] [bp-98h]@6 | |
2502 double v74; // [sp+28h] [bp-90h]@51 | |
2503 double v75; // [sp+30h] [bp-88h]@6 | |
2504 double v76; // [sp+38h] [bp-80h]@20 | |
2505 double v77; // [sp+40h] [bp-78h]@6 | |
2506 float v78; // [sp+48h] [bp-70h]@57 | |
2507 float v79; // [sp+4Ch] [bp-6Ch]@6 | |
2508 float v80; // [sp+50h] [bp-68h]@6 | |
2509 int v81; // [sp+54h] [bp-64h]@1 | |
2510 int v82; // [sp+58h] [bp-60h]@6 | |
2511 int v83; // [sp+5Ch] [bp-5Ch]@82 | |
2512 int v84; // [sp+60h] [bp-58h]@20 | |
2513 int v85; // [sp+64h] [bp-54h]@1 | |
2514 int v86; // [sp+68h] [bp-50h]@1 | |
2515 int v87; // [sp+6Ch] [bp-4Ch]@51 | |
2516 float v88; // [sp+70h] [bp-48h]@51 | |
2517 int v89; // [sp+74h] [bp-44h]@6 | |
2518 int v90; // [sp+78h] [bp-40h]@1 | |
2519 float a3a; // [sp+7Ch] [bp-3Ch]@24 | |
2520 stru220 *v92; // [sp+80h] [bp-38h]@2 | |
2521 float v93; // [sp+84h] [bp-34h]@44 | |
2522 int v94; // [sp+88h] [bp-30h]@6 | |
2523 float v95; // [sp+8Ch] [bp-2Ch]@1 | |
2524 float v96; // [sp+90h] [bp-28h]@1 | |
2525 float v97; // [sp+94h] [bp-24h]@1 | |
2526 int X; // [sp+98h] [bp-20h]@1 | |
2527 float v99; // [sp+9Ch] [bp-1Ch]@6 | |
2528 int v100; // [sp+A0h] [bp-18h]@6 | |
2529 unsigned __int64 v101; // [sp+A4h] [bp-14h]@6 | |
2530 RenderVertexSoft *v102; // [sp+ACh] [bp-Ch]@6 | |
2531 RenderVertexSoft *v103; // [sp+B0h] [bp-8h]@6 | |
2532 RenderVertexSoft *v104; // [sp+B4h] [bp-4h]@3 | |
2533 float pNormalc; // [sp+C0h] [bp+8h]@6 | |
2534 float pNormald; // [sp+C0h] [bp+8h]@6 | |
2535 Vec3_float_ *pNormal; // [sp+C0h] [bp+8h]@17 | |
2536 Vec3_float_ *pNormala; // [sp+C0h] [bp+8h]@48 | |
2537 Vec3_float_ *pNormalb; // [sp+C0h] [bp+8h]@77 | |
2538 | |
2539 v3 = a1; | |
2540 //v4 = *(short *)(a3 + 4); | |
2541 //v5 = *(short *)(a3 + 6); | |
2542 v85 = a2; | |
2543 v86 = *(_WORD *)(a3 + 4); //v4; | |
2544 X = abs(*(_WORD *)(a3 + 6)); //v5 | |
2545 v6 = 0; | |
2546 v90 = 0; | |
2547 v81 = v3 - 1; | |
638 | 2548 v95 = (double)pOutdoor->vSunlight.x / 65536.0; |
2549 v96 = (double)pOutdoor->vSunlight.y / 65536.0; | |
2550 v97 = (double)pOutdoor->vSunlight.z / 65536.0; | |
0 | 2551 if ( v3 - 1 > 0 ) |
2552 { | |
2553 while ( 1 ) | |
2554 { | |
2555 v7 = abs(X); | |
2556 v8 = abs(v86); | |
2557 --X; | |
2558 v92 = &stru_76E5C8[(v7 << 7) + v8]; | |
2559 if ( !v92->field_0 | |
2560 || ((v9 = v6, v10 = &pVerticesSR_806210[v6], v104 = v10, !v85) ? (v11 = &pVerticesSR_801A10[v9], | |
2561 v12 = &pVerticesSR_806210[v9 + 1]) : (v11 = &pVerticesSR_806210[v9 + 1], v12 = &pVerticesSR_801A10[v9]), | |
2562 ((v103 = &pVerticesSR_801A10[v9 + 1], | |
2563 v13 = v10->vWorldPosition.x, | |
2564 v102 = v12, | |
2565 v80 = v13, | |
2566 v73 = v13 + 6.7553994e15, | |
2567 v101 = __PAIR__((unsigned int)v11, LODWORD(v73)), | |
2568 v79 = v10->vWorldPosition.y, | |
2569 v75 = v79 + 6.7553994e15, | |
2570 v100 = LODWORD(v75), | |
2571 pNormalc = (v12->vWorldPosition.x + v10->vWorldPosition.x) * 0.5, | |
2572 v71 = pNormalc + 6.7553994e15, | |
2573 v89 = LODWORD(v71), | |
2574 v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(pNormalc + 6.7553994e15)), | |
2575 v15 = v11->vWorldPosition.y + v10->vWorldPosition.y, | |
2576 v94 = v14, | |
2577 pNormald = v15 * 0.5, | |
2578 v16 = pNormald + 6.7553994e15, | |
2579 v77 = v16, | |
2580 v82 = LODWORD(v77), | |
2581 LODWORD(v99) = WorldPosToGridCellZ(LODWORD(v16)), | |
2582 WorldPosToGridCellX(v101), | |
2583 WorldPosToGridCellZ(v100), | |
2584 !byte_4D864C) | |
2585 || !(pGame->uFlags & 0x80)) | |
2586 && !sub_481EFA(v10, v11, v102, v103, 1)) ) | |
2587 goto LABEL_105; | |
2588 if ( v10->vWorldPosition.z != v11->vWorldPosition.z | |
2589 || v11->vWorldPosition.z != v103->vWorldPosition.z | |
2590 || v103->vWorldPosition.z != v102->vWorldPosition.z ) | |
2591 break; | |
2592 v17 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2593 v18 = pOutdoor->GetTileTexture(v101, v100); | |
2594 v17->uTileBitmapID = v18; | |
2595 if ( v18 != -1 ) | |
2596 { | |
2597 v19 = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2598 LOWORD(v19) = v19 | 0x8010; | |
2599 v20 = v99; | |
2600 *(int *)&v17->flags = v19; | |
2601 v21 = v92; | |
2602 v17->field_59 = 1; | |
638 | 2603 v17->terrain_grid_x = LOBYTE(v20); |
0 | 2604 v17->field_34 = v21->distance; |
2605 v22 = v94; | |
638 | 2606 v17->terrain_grid_z = v94; |
0 | 2607 v23 = pTerrainNormalIndices[2 * (LODWORD(v20) + (v22 << 7)) + 1]; |
2608 if ( v23 < 0 || v23 > (signed int)(uNumTerrainNormals - 1) ) | |
2609 v24 = 0; | |
2610 else | |
2611 v24 = &pTerrainNormals[v23]; | |
2612 pNormal = v24; | |
2613 if ( v24 ) | |
2614 { | |
2615 v25 = -(v97 * v24->z + v96 * v24->y + v95 * v24->x); | |
2616 if ( v25 < 0.0 ) | |
2617 v25 = 0.0; | |
2618 v99 = v25 * 31.0; | |
2619 v76 = v99 + 6.7553994e15; | |
2620 v84 = LODWORD(v76); | |
638 | 2621 v17->dimming_level = 31 - LOBYTE(v76); |
0 | 2622 } |
2623 else | |
2624 { | |
638 | 2625 v17->dimming_level = 0; |
0 | 2626 } |
2627 if ( pOutdoorCamera->numStru148s >= 1999 ) | |
2628 return; | |
2629 ++pOutdoorCamera->numStru148s; | |
2630 if ( !sub_481FC9(v10, (RenderVertexSoft *)HIDWORD(v101), v102, v17) ) | |
2631 goto LABEL_104; | |
2632 v26 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2633 memcpy(array_50AC10, v104, 0x30u); | |
168 | 2634 array_50AC10[0]._rhw = v26; |
0 | 2635 array_50AC10[0].u = 0.0; |
2636 array_50AC10[0].v = 0.0; | |
2637 v27 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; | |
2638 memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); | |
168 | 2639 array_50AC10[1]._rhw = 1.0 / v27; |
0 | 2640 array_50AC10[1].u = 0.0; |
2641 array_50AC10[1].v = 1.0; | |
2642 v28 = v103->vWorldViewPosition.x + 0.0000001; | |
2643 memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); | |
168 | 2644 array_50AC10[2]._rhw = 1.0 / v28; |
0 | 2645 array_50AC10[2].u = 1.0; |
2646 array_50AC10[2].v = 1.0; | |
2647 v29 = v102->vWorldViewPosition.x + 0.0000001; | |
2648 memcpy(&array_50AC10[3], v102, sizeof(array_50AC10[3])); | |
168 | 2649 array_50AC10[3]._rhw = 1.0 / v29; |
0 | 2650 array_50AC10[3].u = 1.0; |
2651 array_50AC10[3].v = 0.0; | |
2652 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormal, &a3a, array_50AC10, 4u, 1); | |
2653 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2654 { | |
2655 v17->field_108 = 0; | |
2656 } | |
2657 else | |
2658 { | |
2659 v30 = pGame; | |
2660 v17->field_108 = 1; | |
2661 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 4, pNormal); | |
2662 } | |
2663 if ( v104->vWorldViewPosition.x < 8.0 | |
2664 || *(float *)(HIDWORD(v101) + 12) < 8.0 | |
2665 || (v31 = v102, v102->vWorldViewPosition.x < 8.0) | |
2666 || v103->vWorldViewPosition.x < 8.0 ) | |
2667 { | |
2668 v36 = sr_4250FE(4u); | |
2669 } | |
2670 else | |
2671 { | |
2672 v32 = (double)pOutdoorCamera->shading_dist_mist; | |
2673 if ( v32 >= v104->vWorldViewPosition.x | |
2674 && v32 >= *(float *)(HIDWORD(v101) + 12) | |
2675 && v32 >= v102->vWorldViewPosition.x | |
2676 && v32 >= v103->vWorldViewPosition.x ) | |
2677 { | |
2678 v33 = sr_4254D2(4); | |
2679 v17->uNumVertices = v33; | |
2680 if ( !v33 ) | |
2681 goto LABEL_104; | |
2682 v34 = (RenderVertexSoft *)HIDWORD(v101); | |
2683 v35 = v104; | |
2684 v69 = 0; | |
2685 v68 = v17; | |
2686 v67 = v31; | |
2687 goto LABEL_37; | |
2688 } | |
2689 v36 = sr_4252E8(4u); | |
2690 } | |
2691 v37 = v36; | |
2692 if ( !v36 ) | |
2693 goto LABEL_104; | |
2694 LABEL_41: | |
2695 OutdoorCamera::Project(v37); | |
2696 LABEL_102: | |
2697 v33 = sr_4254D2(v37); | |
2698 v17->uNumVertices = v33; | |
2699 if ( !v33 ) | |
2700 goto LABEL_104; | |
2701 v17->_48276F_sr(); | |
2702 goto LABEL_38; | |
2703 } | |
2704 LABEL_105: | |
2705 v6 = v90++ + 1; | |
2706 if ( v90 >= v81 ) | |
2707 return; | |
2708 } | |
2709 v38 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2710 v39 = pOutdoor->GetTileTexture(v101, v100); | |
2711 v38->uTileBitmapID = v39; | |
2712 if ( v39 == -1 ) | |
2713 goto LABEL_105; | |
2714 v40 = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2715 BYTE1(v40) |= 0x80u; | |
2716 v41 = v99; | |
2717 *(int *)&v38->flags = v40; | |
2718 v42 = v92; | |
2719 v38->field_59 = 1; | |
638 | 2720 v38->terrain_grid_x = LOBYTE(v41); |
0 | 2721 v38->field_34 = v42->distance; |
2722 v43 = v94; | |
638 | 2723 v38->terrain_grid_z = v94; |
0 | 2724 v44 = 2 * (LODWORD(v41) + (v43 << 7)); |
2725 LODWORD(v93) = v44 * 2; | |
2726 v45 = pTerrainNormalIndices[v44 + 1]; | |
2727 if ( v45 < 0 || v45 > (signed int)(uNumTerrainNormals - 1) ) | |
2728 v46 = 0; | |
2729 else | |
2730 v46 = &pTerrainNormals[v45]; | |
2731 pNormala = v46; | |
2732 if ( v46 ) | |
2733 { | |
2734 v47 = -(v97 * v46->z + v96 * v46->y + v95 * v46->x); | |
2735 if ( v47 < 0.0 ) | |
2736 v47 = 0.0; | |
2737 v88 = v47 * 31.0; | |
2738 v74 = v88 + 6.7553994e15; | |
2739 v87 = LODWORD(v74); | |
638 | 2740 v38->dimming_level = 31 - LOBYTE(v74); |
0 | 2741 } |
2742 else | |
2743 { | |
638 | 2744 v38->dimming_level = 0; |
2745 } | |
2746 if ( v38->dimming_level < 0 ) | |
2747 v38->dimming_level = 0; | |
0 | 2748 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2749 return; | |
2750 ++pOutdoorCamera->numStru148s; | |
2751 if ( !sub_481FC9((RenderVertexSoft *)HIDWORD(v101), v103, v104, v38) ) | |
2752 goto LABEL_74; | |
2753 v48 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2754 memcpy(array_50AC10, v104, 0x30u); | |
168 | 2755 array_50AC10[0]._rhw = v48; |
0 | 2756 array_50AC10[0].u = 0.0; |
2757 array_50AC10[0].v = 0.0; | |
2758 v49 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; | |
2759 memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); | |
168 | 2760 array_50AC10[1]._rhw = 1.0 / v49; |
0 | 2761 array_50AC10[1].u = 0.0; |
2762 array_50AC10[1].v = 1.0; | |
2763 v50 = v103->vWorldViewPosition.x + 0.0000001; | |
2764 memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); | |
168 | 2765 array_50AC10[2]._rhw = 1.0 / v50; |
0 | 2766 array_50AC10[2].u = 1.0; |
2767 array_50AC10[2].v = 1.0; | |
2768 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormala, &v78, array_50AC10, 3u, 0); | |
2769 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2770 { | |
2771 v38->field_108 = 0; | |
2772 } | |
2773 else | |
2774 { | |
2775 v51 = pGame; | |
2776 v38->field_108 = 1; | |
2777 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormala); | |
2778 } | |
2779 if ( v104->vWorldViewPosition.x < 8.0 | |
2780 || *(float *)(HIDWORD(v101) + 12) < 8.0 | |
2781 || (v52 = v103, v103->vWorldViewPosition.x < 8.0) ) | |
2782 { | |
2783 v55 = sr_4250FE(3u); | |
2784 } | |
2785 else | |
2786 { | |
2787 v53 = (double)pOutdoorCamera->shading_dist_mist; | |
2788 if ( v53 >= v104->vWorldViewPosition.x | |
2789 && v53 >= *(float *)(HIDWORD(v101) + 12) | |
2790 && v53 >= v103->vWorldViewPosition.x ) | |
2791 { | |
2792 v54 = sr_4254D2(3); | |
2793 v38->uNumVertices = v54; | |
2794 if ( v54 ) | |
2795 { | |
2796 sr_sub_4829B9((RenderVertexSoft *)HIDWORD(v101), v52, v104, v38, 0); | |
2797 LABEL_68: | |
2798 sr_sub_481DB2(array_508690, v54, v38); | |
2799 LABEL_75: | |
2800 v17 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2801 v57 = pOutdoor->GetTileTexture(v101, v100); | |
2802 v17->uTileBitmapID = v57; | |
2803 if ( v57 == -1 ) | |
2804 goto LABEL_105; | |
2805 *(int *)&v17->flags = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2806 v58 = v92; | |
2807 v17->field_59 = 1; | |
2808 v17->field_34 = v58->distance; | |
638 | 2809 v17->terrain_grid_z = v94; |
2810 v17->terrain_grid_x = LOBYTE(v99); | |
0 | 2811 v59 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + LODWORD(v93)); |
2812 if ( v59 > (signed int)(uNumTerrainNormals - 1) ) | |
2813 { | |
2814 pNormalb = 0; | |
2815 v60 = 0; | |
2816 } | |
2817 else | |
2818 { | |
2819 v60 = &pTerrainNormals[v59]; | |
2820 pNormalb = v60; | |
2821 } | |
2822 if ( v60 ) | |
2823 { | |
2824 v61 = -(v97 * v60->z + v96 * v60->y + v95 * v60->x); | |
2825 if ( v61 < 0.0 ) | |
2826 v61 = 0.0; | |
2827 v93 = v61 * 31.0; | |
2828 v72 = v93 + 6.7553994e15; | |
2829 v83 = LODWORD(v72); | |
638 | 2830 v17->dimming_level = 31 - LOBYTE(v72); |
0 | 2831 } |
2832 else | |
2833 { | |
638 | 2834 v17->dimming_level = 0; |
0 | 2835 } |
638 | 2836 if ( v17->dimming_level < 0 ) |
2837 v17->dimming_level = 0; | |
0 | 2838 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2839 return; | |
2840 ++pOutdoorCamera->numStru148s; | |
2841 if ( !sub_481FC9(v102, v104, v103, v17) ) | |
2842 { | |
2843 LABEL_104: | |
2844 --pOutdoorCamera->numStru148s; | |
2845 goto LABEL_105; | |
2846 } | |
2847 v62 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2848 memcpy(array_50AC10, v104, 0x30u); | |
168 | 2849 array_50AC10[0]._rhw = v62; |
0 | 2850 array_50AC10[0].u = 0.0; |
2851 array_50AC10[0].v = 0.0; | |
2852 v63 = v103->vWorldViewPosition.x + 0.0000001; | |
2853 memcpy(&array_50AC10[1], v103, sizeof(array_50AC10[1])); | |
168 | 2854 array_50AC10[1]._rhw = 1.0 / v63; |
0 | 2855 array_50AC10[1].u = 1.0; |
2856 array_50AC10[1].v = 1.0; | |
2857 v64 = v102->vWorldViewPosition.x + 0.0000001; | |
2858 memcpy(&array_50AC10[2], v102, sizeof(array_50AC10[2])); | |
168 | 2859 array_50AC10[2]._rhw = 1.0 / v64; |
0 | 2860 array_50AC10[2].u = 1.0; |
2861 array_50AC10[2].v = 0.0; | |
2862 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormalb, &v70, array_50AC10, 3u, 1); | |
2863 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2864 { | |
2865 v17->field_108 = 0; | |
2866 } | |
2867 else | |
2868 { | |
2869 v65 = pGame; | |
2870 v17->field_108 = 1; | |
2871 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormalb); | |
2872 } | |
2873 if ( v104->vWorldViewPosition.x < 8.0 || v103->vWorldViewPosition.x < 8.0 || v102->vWorldViewPosition.x < 8.0 ) | |
2874 { | |
2875 v37 = sr_4250FE(3u); | |
2876 OutdoorCamera::Project(v37); | |
2877 if ( !v37 ) | |
2878 goto LABEL_104; | |
2879 goto LABEL_102; | |
2880 } | |
2881 v66 = (double)pOutdoorCamera->shading_dist_mist; | |
2882 if ( v66 < v104->vWorldViewPosition.x || v66 < v103->vWorldViewPosition.x || v66 < v102->vWorldViewPosition.x ) | |
2883 { | |
2884 v37 = sr_4252E8(3u); | |
2885 if ( !v37 ) | |
2886 goto LABEL_105; | |
2887 goto LABEL_41; | |
2888 } | |
2889 v33 = sr_4254D2(3); | |
2890 v17->uNumVertices = v33; | |
2891 if ( !v33 ) | |
2892 goto LABEL_104; | |
2893 v34 = v104; | |
2894 v35 = v102; | |
2895 v69 = 0; | |
2896 v68 = v17; | |
2897 v67 = v103; | |
2898 LABEL_37: | |
2899 sr_sub_4829B9(v35, v34, v67, v68, v69); | |
2900 LABEL_38: | |
2901 sr_sub_481DB2(array_508690, v33, v17); | |
2902 goto LABEL_105; | |
2903 } | |
2904 goto LABEL_74; | |
2905 } | |
2906 v55 = sr_4252E8(3u); | |
2907 } | |
2908 v56 = v55; | |
2909 if ( v55 ) | |
2910 { | |
2911 OutdoorCamera::Project(v55); | |
2912 v54 = sr_4254D2(v56); | |
2913 v38->uNumVertices = v54; | |
2914 if ( v54 ) | |
2915 { | |
2916 v38->_48276F_sr(); | |
2917 goto LABEL_68; | |
2918 } | |
2919 } | |
2920 LABEL_74: | |
2921 --pOutdoorCamera->numStru148s; | |
2922 goto LABEL_75; | |
2923 } | |
2924 } | |
2925 | |
2926 //----- (0047BACF) -------------------------------------------------------- | |
2927 void Render::TransformBillboardsAndSetPalettesODM() | |
2928 { | |
142 | 2929 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2930 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2931 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2932 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2933 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2934 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2935 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2936 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2937 //int v8; // ebx@4 |
0 | 2938 unsigned __int16 *v9; // eax@7 |
2939 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2940 //DWORD v11; // eax@13 |
0 | 2941 int v12; // eax@13 |
2942 int v13; // eax@14 | |
2943 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
2944 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 2945 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2946 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 2947 int v18; // [sp+60h] [bp-4h]@13 |
2948 | |
2949 billboard.uParentBillboardID = -1; | |
2950 billboard.pTarget = pRenderer->pTargetSurface; | |
2951 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
2952 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 2953 billboard.uViewportX = pViewport->uViewportTL_X; |
2954 billboard.uViewportY = pViewport->uViewportTL_Y; | |
2955 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
2956 billboard.uViewportW = pViewport->uViewportBR_Y; | |
0 | 2957 pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw; |
142 | 2958 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2959 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 2960 { |
143 | 2961 auto pBillboard = pBillboardRenderList + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2962 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2963 billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2964 billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2965 billboard.uParentBillboardID = i; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2966 billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2967 billboard.uTintColor = pBillboard->uTintColor; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2968 billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2969 billboard.sZValue = pBillboard->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2970 billboard.uFlags = pBillboard->field_1E; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2971 if (pBillboard->uHwSpriteID != -1) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2972 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2973 if (pRenderer->pRenderD3D) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2974 pRenderer->TransformBillboard(&billboard, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2975 &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], |
657 | 2976 pBillboard->dimming_level, pBillboard); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2977 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2978 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2979 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2980 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2981 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 2982 if ( *(v1 - 10) & 2 ) |
2983 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
2984 else | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2985 v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 2986 v10 = (*(v1 - 9) & 1) == 0; |
2987 billboard.pPalette = v9; | |
2988 if ( !v10 ) | |
2989 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
2990 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
2991 { | |
323 | 2992 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 2993 v15 = abs(v12); |
2994 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
2995 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
2996 } | |
2997 v13 = *((short *)v1 - 8); | |
2998 if ( v13 >= 0 ) | |
733 | 2999 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3000 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3001 } |
0 | 3002 } |
3003 } | |
3004 | |
3005 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3006 void Render::DrawSpriteObjects_ODM() |
0 | 3007 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3008 //char *v0; // edi@2 |
430 | 3009 //ObjectDesc *v1; // ebx@4 |
0 | 3010 __int16 v2; // cx@5 |
3011 RenderBillboard *v3; // esi@10 | |
3012 SpriteFrame *v4; // eax@10 | |
430 | 3013 //SpriteFrame *v5; // ebx@10 |
0 | 3014 unsigned int v6; // eax@10 |
430 | 3015 //int v7; // ecx@10 |
3016 //int v8; // edx@10 | |
0 | 3017 int v9; // ecx@10 |
3018 unsigned __int16 v10; // ax@10 | |
430 | 3019 //int *v11; // eax@14 |
0 | 3020 int v12; // eax@22 |
3021 int v13; // ST3C_4@23 | |
3022 int v14; // eax@23 | |
3023 int v15; // ecx@23 | |
3024 int v16; // ebx@23 | |
3025 int v17; // ecx@25 | |
3026 int v18; // eax@25 | |
3027 int v19; // ST40_4@26 | |
3028 int v20; // ecx@26 | |
3029 int v21; // ST44_4@28 | |
3030 int v22; // ST3C_4@29 | |
3031 signed __int64 v23; // qtt@30 | |
3032 int v24; // ebx@30 | |
3033 int v25; // ST3C_4@30 | |
3034 int v26; // eax@31 | |
3035 char v27; // zf@31 | |
430 | 3036 //SpriteFrame *v28; // [sp+Ch] [bp-34h]@10 |
3037 //__int16 a5; // [sp+10h] [bp-30h]@10 | |
0 | 3038 int v30; // [sp+14h] [bp-2Ch]@23 |
3039 int v31; // [sp+14h] [bp-2Ch]@29 | |
3040 __int16 v32; // [sp+14h] [bp-2Ch]@30 | |
3041 int v33; // [sp+18h] [bp-28h]@23 | |
3042 int v34; // [sp+18h] [bp-28h]@26 | |
3043 int v35; // [sp+18h] [bp-28h]@30 | |
3044 int v36; // [sp+1Ch] [bp-24h]@10 | |
3045 int v37; // [sp+1Ch] [bp-24h]@23 | |
3046 int a6; // [sp+20h] [bp-20h]@10 | |
3047 int a6a; // [sp+20h] [bp-20h]@23 | |
3048 int v40; // [sp+24h] [bp-1Ch]@25 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3049 //signed int v41; // [sp+28h] [bp-18h]@1 |
0 | 3050 int v42; // [sp+2Ch] [bp-14h]@23 |
3051 int y; // [sp+30h] [bp-10h]@10 | |
3052 int x; // [sp+34h] [bp-Ch]@10 | |
3053 int z; // [sp+38h] [bp-8h]@10 | |
3054 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
3055 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3056 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3057 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
|
3058 { |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3059 auto object = pSpriteObjects + i; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3060 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3061 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3062 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3063 //{ |
430 | 3064 if (!object->uObjectDescID) // item probably pciked up |
3065 continue; | |
3066 | |
3067 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
3068 auto object_desc = pObjectList->pObjects + object->uObjectDescID; | |
3069 if (object_desc->NoSprite()) | |
3070 continue; | |
3071 | |
3072 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
3073 //if ( !(v1->uFlags & 1) ) | |
3074 //{ | |
3075 //v2 = *((short *)v0 - 14) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3076 v2 = object->uType; |
430 | 3077 if ( (v2 < 1000 || v2 >= 10000) && (v2 < 500 || v2 >= 600) || pGame->pStru6Instance->_4A81CA(object) ) |
3078 { | |
3079 //a5 = *(short *)v0; | |
3080 x = object->vPosition.x; | |
3081 y = object->vPosition.y; | |
3082 z = object->vPosition.z; | |
3083 v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; | |
3084 v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); | |
3085 //v5 = v4; | |
3086 //v28 = v4; | |
3087 v36 = v4->uFlags; | |
3088 a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier; | |
3089 v6 = stru_5C6E00->Atan2(object->vPosition.x - pIndoorCamera->pos.x, object->vPosition.y - pIndoorCamera->pos.y); | |
3090 //LOWORD(v7) = object->uFacing; | |
3091 //v8 = v36; | |
3092 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; | |
3093 v10 = v4->pHwSpriteIDs[v9]; | |
0 | 3094 v3->uHwSpriteID = v10; |
3095 if ( v36 & 0x20 ) | |
3096 { | |
430 | 3097 //v8 = v36; |
3098 z -= (signed int)((unsigned __int64)(v4->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
0 | 3099 } |
3100 v46 = 0; | |
430 | 3101 if ( v36 & 2 ) |
0 | 3102 v46 = 2; |
430 | 3103 //v11 = (int *)(256 << v9); |
3104 if ( (256 << v9) & v36 ) | |
0 | 3105 v46 |= 4u; |
430 | 3106 if ( v36 & 0x40000 ) |
0 | 3107 v46 |= 0x40u; |
430 | 3108 if ( v36 & 0x20000 ) |
0 | 3109 LOBYTE(v46) = v46 | 0x80; |
3110 if ( a6 ) | |
3111 { | |
430 | 3112 //LOBYTE(v11) = byte_4E94D3; |
3113 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); | |
0 | 3114 } |
3115 v12 = (x - pIndoorCamera->pos.x) << 16; | |
3116 if ( pIndoorCamera->sRotationX ) | |
3117 { | |
3118 v13 = (y - pIndoorCamera->pos.y) << 16; | |
3119 v30 = ((unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | |
3120 + ((unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3121 v37 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3122 a6a = (unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3123 v33 = (z - pIndoorCamera->pos.z) << 16; | |
3124 v14 = (unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3125 v15 = (unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3126 v16 = v15 + v14; | |
3127 v42 = v15 + v14; | |
3128 if ( v15 + v14 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3129 { | |
3130 v17 = a6a - v37; | |
3131 v40 = a6a - v37; | |
3132 v18 = ((unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) | |
3133 - ((unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3134 goto LABEL_29; | |
3135 } | |
3136 } | |
3137 else | |
3138 { | |
3139 v34 = (y - pIndoorCamera->pos.y) << 16; | |
3140 v19 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3141 v20 = (unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3142 v16 = v20 + v19; | |
3143 v42 = v20 + v19; | |
3144 if ( v20 + v19 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3145 { | |
430 | 3146 v21 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; |
3147 v17 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
3148 v40 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
0 | 3149 v18 = (z - pIndoorCamera->pos.z) << 16; |
3150 LABEL_29: | |
3151 v31 = v18; | |
3152 v22 = abs(v17); | |
3153 if ( abs(v16) >= v22 ) | |
3154 { | |
3155 LODWORD(v23) = 0; | |
3156 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3157 v24 = v23 / v42; | |
3158 v25 = v23 / v42; | |
3159 LODWORD(v23) = 0; | |
3160 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
430 | 3161 v35 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); |
3162 v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); | |
3163 | |
3164 //if (::uNumBillboardsToDraw >= 500) | |
3165 // return; | |
3166 assert(::uNumBillboardsToDraw < 500); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3167 ++::uNumBillboardsToDraw; |
0 | 3168 ++uNumSpritesDrawnThisFrame; |
430 | 3169 |
3170 object->uAttributes |= 1; | |
3171 v3->uPalette = v4->uPaletteIndex; | |
3172 v3->uIndoorSectorID = object->uSectorID; | |
3173 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
3174 v26 = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
3175 v3->pSpriteFrame = v4; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3176 v3->_screenspace_y_scaler_packedfloat = v26; |
0 | 3177 v3->field_1E = v46; |
430 | 3178 v3->world_x = x; |
3179 v3->world_y = y; | |
3180 v3->world_z = z; | |
0 | 3181 v3->uScreenSpaceX = v35; |
3182 v3->uScreenSpaceY = v32; | |
3183 HIWORD(v26) = HIWORD(v42); | |
3184 LOWORD(v26) = 0; | |
430 | 3185 v27 = (object->uAttributes & 0x20) == 0; |
862 | 3186 v3->sZValue = v26 + (PID(OBJECT_Item,i)); |
657 | 3187 v3->dimming_level = 0; |
0 | 3188 v3->uTintColor = 0; |
3189 if ( !v27 ) | |
3190 { | |
3191 if ( !pRenderer->pRenderD3D ) | |
3192 v3->sZValue = 0; | |
3193 } | |
3194 } | |
3195 goto LABEL_34; | |
3196 } | |
3197 } | |
3198 } | |
430 | 3199 //} |
0 | 3200 LABEL_34: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3201 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3202 //++v41; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3203 //v0 += 112; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3204 //} |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3205 //while ( v41 < (signed int)uNumSpriteObjects ); |
0 | 3206 } |
3207 } | |
3208 // 4E94D3: using guessed type char byte_4E94D3; | |
3209 // 5187E4: using guessed type int uNumSpritesDrawnThisFrame; | |
3210 | |
3211 //----- (0049D9BC) -------------------------------------------------------- | |
3212 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
3213 { | |
3214 size_t v4; // eax@1 | |
3215 size_t v5; // eax@1 | |
3216 IUnknown *v6; // eax@10 | |
3217 size_t v7; // eax@13 | |
3218 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
3219 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
3220 int v11; // [sp+430h] [bp-CCh]@16 | |
3221 int v12; // [sp+434h] [bp-C8h]@16 | |
3222 int v13; // [sp+438h] [bp-C4h]@16 | |
3223 int v14; // [sp+474h] [bp-88h]@16*/ | |
3224 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
3225 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
3226 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
3227 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
3228 int v19; // [sp+4C8h] [bp-34h]@16 | |
3229 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
3230 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
3231 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
3232 | |
3233 v4 = strlen(lpDriverName); | |
3234 v20.pDriverName = new char[v4 + 1]; | |
3235 v5 = strlen(lpDevDesc); | |
3236 v20.pDeviceDesc = new char[v5 + 1]; | |
3237 strcpy(v20.pDriverName, lpDriverName); | |
3238 strcpy(v20.pDeviceDesc, lpDevDesc); | |
3239 if ( lpGUID ) | |
3240 { | |
3241 v20.pGUID = new GUID; | |
3242 memcpy(v20.pGUID, lpGUID, 0x10u); | |
3243 } | |
3244 else | |
3245 { | |
3246 v20.pGUID = 0; | |
3247 } | |
3248 | |
3249 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
3250 { | |
3251 delete [] v20.pDriverName; | |
3252 delete [] v20.pDeviceDesc; | |
3253 if ( v20.pGUID ) | |
3254 delete v20.pGUID; | |
3255 } | |
3256 else | |
3257 { | |
3258 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
3259 { | |
3260 delete [] v20.pDriverName; | |
3261 delete [] v20.pDeviceDesc; | |
3262 if ( v20.pGUID ) | |
3263 delete v20.pGUID; | |
3264 v6 = (IUnknown *)pDirectDraw; | |
3265 } | |
3266 else | |
3267 { | |
3268 pDirectDraw->Release(); | |
3269 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1u))) | |
3270 { | |
3271 v20.pDDraw4DevDesc = 0; | |
3272 } | |
3273 else | |
3274 { | |
3275 v7 = strlen(ddDevId.szDescription); | |
3276 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
3277 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
3278 } | |
3279 memset(&ddsCaps, 0, 0x10u); | |
3280 if (FAILED(pDirectDraw4->GetAvailableVidMem( | |
3281 &ddsCaps, | |
3282 (LPDWORD)&v20.uVideoMem, | |
3283 (LPDWORD)&uFreeVideoMem))) | |
3284 v20.uVideoMem = 0; | |
3285 memset(&v10, 0, 0x7Cu); | |
3286 v10.dwSize = 124; | |
3287 v10.dwFlags = 6; | |
3288 v10.dwHeight = 640; | |
3289 v10.dwWidth = 480; | |
3290 v10.ddpfPixelFormat.dwSize = 32; | |
3291 | |
3292 v19 = 0; | |
3293 if ( FAILED(pDirectDraw4->EnumDisplayModes( | |
3294 0, | |
3295 0, | |
3296 &v19, | |
3297 (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) | |
3298 || !v19 | |
3299 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
3300 { | |
3301 delete [] v20.pDriverName; | |
3302 delete [] v20.pDeviceDesc; | |
3303 if ( v20.pDDraw4DevDesc ) | |
3304 free(v20.pDDraw4DevDesc); | |
3305 if ( v20.pGUID ) | |
3306 delete v20.pGUID; | |
3307 v6 = (IUnknown *)pDirectDraw4; | |
3308 } | |
3309 else | |
3310 { | |
3311 aux.pInfo = pOut; | |
3312 aux.ptr_4 = &v20; | |
3313 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
3314 delete [] v20.pDriverName; | |
3315 delete [] v20.pDeviceDesc; | |
3316 if ( v20.pDDraw4DevDesc ) | |
3317 free(v20.pDDraw4DevDesc); | |
3318 if ( v20.pGUID ) | |
3319 delete v20.pGUID; | |
3320 pDirectDraw4->Release(); | |
3321 v6 = (IUnknown *)pDirect3D3; | |
3322 pDirectDraw4 = 0; | |
3323 } | |
3324 } | |
3325 v6->Release(); | |
3326 } | |
3327 return 1; | |
3328 } | |
3329 | |
3330 //----- (0049D784) -------------------------------------------------------- | |
3331 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
3332 { | |
3333 int v6; // eax@1 | |
3334 signed int v7; // edi@1 | |
3335 signed int v8; // edi@14 | |
3336 size_t v9; // eax@30 | |
3337 size_t v10; // eax@30 | |
3338 size_t v11; // eax@30 | |
3339 size_t v12; // eax@30 | |
3340 size_t v13; // eax@30 | |
3341 | |
3342 v6 = pHWDesc->dwFlags; | |
3343 v7 = -1; | |
3344 if ( v6 ) | |
3345 { | |
3346 if ( !a6->ptr_4->pGUID ) | |
3347 v7 = 0; | |
3348 if ( v6 && a6->ptr_4->pGUID ) | |
3349 v7 = 1; | |
3350 } | |
3351 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
3352 v7 = 2; | |
3353 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
3354 v7 = 3; | |
3355 if ( v7 != -1 ) | |
3356 { | |
3357 v8 = v7; | |
3358 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
3359 a6->pInfo[v8].uCaps = 0; | |
3360 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
3361 a6->pInfo[v8].uCaps |= 2u; | |
3362 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
3363 a6->pInfo[v8].uCaps |= 4u; | |
3364 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
3365 a6->pInfo[v8].uCaps |= 8u; | |
3366 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
3367 a6->pInfo[v8].uCaps |= 0x10u; | |
3368 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
3369 a6->pInfo[v8].uCaps |= 0x20u; | |
3370 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
3371 a6->pInfo[v8].uCaps |= 0x40u; | |
3372 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
3373 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
3374 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
3375 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
3376 v9 = strlen(lpDeviceName); | |
3377 a6->pInfo[v8].pName = new char[v9 + 1]; | |
3378 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
3379 v10 = strlen(lpDeviceDesc); | |
3380 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
3381 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
3382 a6->pInfo[v8].pGUID = (GUID *)operator new(0x10u); | |
3383 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); | |
3384 v11 = strlen(a6->ptr_4->pDriverName); | |
3385 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
3386 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
3387 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
3388 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
3389 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
3390 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
3391 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
3392 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
3393 if ( a6->ptr_4->pGUID ) | |
3394 { | |
3395 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
3396 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
3397 } | |
3398 else | |
3399 { | |
3400 a6->pInfo[v8].pDirectDrawGUID = 0; | |
3401 } | |
3402 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
3403 } | |
3404 return 1; | |
3405 } | |
3406 | |
3407 //----- (0049D75C) -------------------------------------------------------- | |
3408 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
3409 { | |
3410 HRESULT result; // eax@3 | |
3411 | |
3412 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
3413 { | |
3414 *a2 = 1; | |
3415 result = 0; | |
3416 } | |
3417 else | |
3418 { | |
3419 result = 1; | |
3420 } | |
3421 return result; | |
3422 } | |
3423 | |
3424 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3425 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3426 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3427 //char *v0; // esi@2 |
639 | 3428 //DecorationDesc *v1; // ebx@6 |
0 | 3429 __int16 v2; // ax@6 |
3430 double v3; // st7@7 | |
639 | 3431 //int v4; // eax@9 |
3432 //int v5; // edx@9 | |
0 | 3433 unsigned int v6; // edi@9 |
3434 int v7; // eax@9 | |
3435 SpriteFrame *v8; // eax@9 | |
635 | 3436 //SpriteFrame *v9; // edi@9 |
0 | 3437 unsigned __int16 *v10; // eax@9 |
3438 int v11; // ecx@9 | |
3439 int v12; // eax@9 | |
3440 int v13; // ecx@9 | |
3441 int v14; // ecx@20 | |
3442 char v15; // dl@20 | |
3443 signed int v16; // eax@20 | |
3444 int v17; // eax@23 | |
3445 int v18; // ecx@24 | |
3446 int v19; // eax@24 | |
3447 int v20; // ecx@24 | |
3448 int v21; // ebx@26 | |
3449 int v22; // eax@26 | |
3450 int v23; // eax@30 | |
3451 signed __int64 v24; // qtt@31 | |
3452 int v25; // ebx@31 | |
3453 int v26; // ecx@32 | |
3454 RenderBillboard *v27; // eax@37 | |
3455 __int16 v28; // dx@37 | |
3456 __int16 v29; // cx@37 | |
3457 int v30; // ecx@37 | |
3458 int v31; // ebx@37 | |
619 | 3459 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
639 | 3460 //int x; // [sp+74h] [bp-30h]@9 |
3461 //int y; // [sp+78h] [bp-2Ch]@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3462 //int v35; // [sp+7Ch] [bp-28h]@1 |
639 | 3463 //int v36; // [sp+80h] [bp-24h]@9 |
0 | 3464 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
3465 int v38; // [sp+88h] [bp-1Ch]@9 | |
3466 int v39; // [sp+8Ch] [bp-18h]@24 | |
3467 int v40; // [sp+90h] [bp-14h]@24 | |
3468 int v41; // [sp+94h] [bp-10h]@24 | |
3469 int v42; // [sp+98h] [bp-Ch]@9 | |
3470 int a5; // [sp+9Ch] [bp-8h]@9 | |
3471 int b; // [sp+A0h] [bp-4h]@22 | |
3472 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3473 //v35 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3474 //if ( (signed int)uNumLevelDecorations > 0 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3475 //{ |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3476 //v0 = (char *)&pLevelDecorations[0].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3477 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3478 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3479 { |
635 | 3480 auto decor = pLevelDecorations + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3481 auto v0 = (char *)&pLevelDecorations[i].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3482 |
639 | 3483 if ( (!(decor->field_2 & 0x40) || decor->_47A825()) && !(decor->field_2 & 0x20) ) |
3484 { | |
3485 //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID]; | |
3486 auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; | |
3487 v2 = decor_desc->uFlags; | |
0 | 3488 if ( (char)v2 >= 0 ) |
3489 { | |
3490 if ( !(v2 & 0x22) ) | |
3491 { | |
639 | 3492 //v4 = decor->vPosition.x; |
3493 //v5 = decor->vPosition.z; | |
0 | 3494 v6 = pMiscTimer->uTotalGameTimeElapsed; |
639 | 3495 //y = decor->vPosition.y; |
3496 //x = decor->vPosition.x; | |
3497 //v36 = decor->vPosition.z; | |
3498 v7 = abs(decor->vPosition.x + decor->vPosition.y); | |
635 | 3499 |
3500 | |
3501 #pragma region "New: seasons change" | |
3502 extern bool change_seasons; | |
3503 if (change_seasons) | |
3504 switch (pParty->uCurrentMonth) | |
3505 { | |
3506 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
3507 case 11: case 0: case 1: // winter | |
639 | 3508 switch (decor_desc->uSpriteID) |
635 | 3509 { |
3510 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
3511 case 548: // flower10 | |
3512 case 547: // flower09 | |
3513 case 541: // flower03 | |
3514 case 539: continue; // flower01 | |
3515 | |
3516 case 483: // tree01 | |
3517 case 486: // tree04 | |
3518 case 492: // tree10 | |
639 | 3519 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); |
3520 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
635 | 3521 break; |
3522 | |
3523 default: | |
639 | 3524 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3525 } |
3526 break; | |
3527 | |
3528 case 2: case 3: case 4: // spring | |
639 | 3529 switch (decor_desc->uSpriteID) |
635 | 3530 { |
3531 } | |
639 | 3532 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3533 break; |
3534 | |
3535 case 8: case 9: case 10: // autumn | |
639 | 3536 switch (decor_desc->uSpriteID) |
635 | 3537 { |
3538 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
3539 case 548: // flower10 | |
3540 case 547: // flower09 | |
3541 case 541: // flower03 | |
3542 case 539: continue; // flower01 | |
3543 | |
3544 case 483: // tree01 | |
3545 case 486: // tree04 | |
3546 case 492: // tree10 | |
639 | 3547 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); |
3548 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
635 | 3549 break; |
3550 | |
3551 default: | |
639 | 3552 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3553 } |
3554 break; | |
3555 | |
3556 case 5: case 6: case 7: // summer | |
3557 //all green by default | |
639 | 3558 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3559 break; |
3560 | |
3561 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
3562 } | |
637 | 3563 else |
639 | 3564 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3565 #pragma endregion |
639 | 3566 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3567 |
3568 //v9 = v8; | |
0 | 3569 v42 = v8->uFlags; |
3570 a5 = v8->uGlowRadius; | |
639 | 3571 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pIndoorCamera->pos.x, |
3572 decor->vPosition.y - pIndoorCamera->pos.y); | |
0 | 3573 v11 = *((int *)v0 + 2); |
3574 v37 = v10; | |
3575 v12 = v42; | |
3576 v38 = 0; | |
3577 v13 = ((signed int)(stru_5C6E00->uIntegerPi | |
3578 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
3579 + v11 | |
3580 - (signed int)v37) >> 8) & 7; | |
3581 v37 = (unsigned __int16 *)v13; | |
3582 if ( v42 & 2 ) | |
3583 v38 = 2; | |
3584 if ( (256 << v13) & v42 ) | |
3585 v38 |= 4u; | |
3586 if ( v12 & 0x40000 ) | |
3587 v38 |= 0x40u; | |
3588 if ( v12 & 0x20000 ) | |
3589 LOBYTE(v38) = v38 | 0x80; | |
3590 if ( a5 ) | |
3591 { | |
3592 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) | |
3593 { | |
639 | 3594 v14 = decor_desc->uColoredLightRed; |
3595 v15 = decor_desc->uColoredLightGreen; | |
3596 v16 = decor_desc->uColoredLightBlue; | |
0 | 3597 } |
3598 else | |
3599 { | |
3600 v16 = 255; | |
3601 v14 = 255; | |
3602 v15 = 255; | |
3603 } | |
3604 b = v16; | |
3605 pStationaryLightsStack->AddLight( | |
639 | 3606 decor->vPosition.x, |
3607 decor->vPosition.y, | |
3608 decor->vPosition.z + decor_desc->uDecorationHeight / 2, | |
0 | 3609 a5, |
3610 v14, | |
3611 v15, | |
3612 v16, | |
3613 byte_4E94D0); | |
3614 } | |
639 | 3615 v17 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
0 | 3616 if ( pIndoorCamera->sRotationX ) |
3617 { | |
639 | 3618 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; |
0 | 3619 v18 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) |
3620 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3621 v42 = v18; | |
3622 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3623 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
639 | 3624 v40 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 3625 v41 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; |
3626 v19 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3627 v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3628 v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3629 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3630 { | |
3631 v21 = a5 - b; | |
3632 v41 = a5 - b; | |
3633 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3634 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3635 v22 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) - a5; | |
3636 LABEL_30: | |
3637 v42 = v22; | |
3638 v40 = 2 * abs(v20); | |
3639 v23 = abs(v21); | |
3640 if ( v40 >= v23 ) | |
3641 { | |
3642 LODWORD(v24) = 0; | |
3643 HIDWORD(v24) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3644 a5 = v24 / v39; | |
3645 v25 = pViewport->uScreenCenterX | |
3646 - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); | |
3647 b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; | |
3648 v41 = v24 / v39; | |
3649 v40 = pViewport->uScreenCenterY | |
3650 - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); | |
635 | 3651 v42 = v8->scale; |
0 | 3652 v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; |
635 | 3653 v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37]; |
0 | 3654 if ( pRenderer->pRenderD3D ) |
3655 { | |
3656 v26 = v41; | |
3657 v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; | |
3658 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
3659 } | |
3660 else | |
3661 { | |
3662 v26 = v41; | |
3663 v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; | |
3664 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
3665 } | |
693 | 3666 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
0 | 3667 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3668 if (::uNumBillboardsToDraw >= 500) |
0 | 3669 return; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3670 v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; |
0 | 3671 ++uNumDecorationsDrawnThisFrame; |
3672 v27->uHwSpriteID = *v37; | |
635 | 3673 v28 = v8->uPaletteIndex; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3674 v27->_screenspace_x_scaler_packedfloat = v26; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3675 v27->_screenspace_y_scaler_packedfloat = v26; |
0 | 3676 v29 = v38; |
3677 v27->uScreenSpaceX = v25; | |
3678 HIBYTE(v29) |= 2u; | |
3679 v27->uPalette = v28; | |
3680 v27->field_1E = v29; | |
639 | 3681 v27->world_x = decor->vPosition.x; |
3682 v27->world_y = decor->vPosition.y; | |
3683 v27->world_z = decor->vPosition.z; | |
0 | 3684 v27->uScreenSpaceY = v40; |
3685 HIWORD(v30) = HIWORD(v39); | |
862 | 3686 v31 = PID(OBJECT_Decoration,i); |
0 | 3687 LOWORD(v30) = 0; |
3688 v27->uIndoorSectorID = 0; | |
3689 v27->sZValue = v30 + v31; | |
657 | 3690 v27->dimming_level = 0; |
635 | 3691 v27->pSpriteFrame = v8; |
0 | 3692 v27->uTintColor = 0; |
3693 } | |
3694 } | |
3695 goto LABEL_38; | |
3696 } | |
3697 } | |
3698 else | |
3699 { | |
639 | 3700 v42 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
3701 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; | |
0 | 3702 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; |
3703 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3704 v20 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3705 v39 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3706 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3707 { | |
3708 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3709 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3710 v21 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
3711 v41 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
639 | 3712 v22 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 3713 goto LABEL_30; |
3714 } | |
3715 } | |
3716 } | |
3717 } | |
3718 else | |
3719 { | |
3720 memset(&local_0, 0, 0x68u); | |
3721 v3 = (double)*((signed int *)v0 - 1); | |
619 | 3722 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; |
3723 local_0.uDiffuse = 0xFF3C1E; | |
0 | 3724 local_0.x = v3; |
3725 local_0.y = (double)*(signed int *)v0; | |
3726 local_0.z = (double)*((signed int *)v0 + 1); | |
3727 local_0.flt_10 = 0.0; | |
3728 local_0.flt_14 = 0.0; | |
3729 local_0.flt_18 = 0.0; | |
3730 local_0.flt_28 = 1.0; | |
3731 local_0.timeToLive = (rand() & 0x80) + 128; | |
3732 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
3733 pGame->pParticleEngine->AddParticle(&local_0); | |
3734 } | |
3735 } | |
3736 LABEL_38: | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3737 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3738 //++v35; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3739 //v0 += 32; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3740 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3741 //while ( v35 < (signed int)uNumLevelDecorations ); |
0 | 3742 } |
3743 // 4E94D0: using guessed type char byte_4E94D0; | |
3744 // 5187EC: using guessed type int uNumDecorationsDrawnThisFrame; | |
3745 | |
3746 //----- (0049D717) -------------------------------------------------------- | |
3747 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
3748 { | |
3749 HRESULT v2; // esi@2 | |
3750 | |
3751 if ( Src->dwFlags & 0x400 | 0x2000 ) | |
3752 { | |
3753 v2 = 0; | |
3754 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
3755 goto LABEL_6; | |
3756 if ( !Dst->dwSize ) | |
3757 { | |
3758 v2 = 1; | |
3759 LABEL_6: | |
3760 memcpy(Dst, Src, 0x20u); | |
3761 return v2; | |
3762 } | |
3763 } | |
3764 return 1; | |
3765 } | |
3766 | |
3767 //----- (0049DC28) -------------------------------------------------------- | |
3768 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
3769 { | |
3770 RenderD3D__DevInfo *v2; // eax@1 | |
3771 | |
3772 v2 = new RenderD3D__DevInfo[4];// 4 items | |
3773 *pOutDevices = v2; | |
3774 memset(v2, 0, 0xA0u); | |
3775 DirectDrawEnumerateA((LPDDENUMCALLBACKA)RenderD3D__DeviceEnumerator, *pOutDevices); | |
3776 } | |
3777 | |
3778 //----- (0049DC58) -------------------------------------------------------- | |
3779 RenderD3D::RenderD3D() | |
3780 { | |
3781 RenderD3D *v1; // esi@1 | |
3782 | |
3783 v1 = this; | |
3784 this->pHost = 0; | |
3785 this->pDirect3D = 0; | |
3786 this->pUnk = 0; | |
3787 this->pBackBuffer = 0; | |
3788 this->pFrontBuffer = 0; | |
3789 this->pZBuffer = 0; | |
3790 this->pDevice = 0; | |
3791 this->pViewport = 0; | |
3792 this->field_40 = 1; | |
3793 this->field_44 = 10; | |
3794 GetAvailableDevices(&this->pAvailableDevices); | |
3795 } | |
3796 | |
3797 //----- (0049DC90) -------------------------------------------------------- | |
3798 void RenderD3D::Release() | |
3799 { | |
3800 RenderD3D *v1; // esi@1 | |
3801 IDirectDraw4 *v2; // eax@2 | |
3802 signed int v3; // edi@4 | |
3803 IDirect3DViewport3 *v4; // eax@22 | |
3804 IUnknown *v5; // eax@24 | |
3805 IDirectDrawSurface4 *v6; // eax@26 | |
3806 IDirect3DDevice3 *v7; // eax@28 | |
3807 IDirect3D3 *v8; // eax@30 | |
3808 IDirectDrawSurface4 *v9; // eax@32 | |
3809 IDirectDrawSurface4 *v10; // eax@34 | |
3810 IDirectDraw4 *v11; // eax@36 | |
3811 | |
3812 v1 = this; | |
3813 if ( !this->bWindowed ) | |
3814 { | |
3815 v2 = this->pHost; | |
3816 if ( v2 ) | |
3817 { | |
3818 v2->RestoreDisplayMode(); | |
3819 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
3820 v1->pHost->FlipToGDISurface(); | |
3821 } | |
3822 } | |
3823 v3 = 0; | |
3824 do | |
3825 { | |
3826 if ( v1->pAvailableDevices[v3].pDriverName ) | |
3827 { | |
3828 free(v1->pAvailableDevices[v3].pDriverName); | |
3829 v1->pAvailableDevices[v3].pDriverName = 0; | |
3830 } | |
3831 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
3832 { | |
3833 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
3834 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
3835 } | |
3836 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
3837 { | |
3838 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
3839 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
3840 } | |
3841 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
3842 { | |
3843 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
3844 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
3845 } | |
3846 if ( v1->pAvailableDevices[v3].pName ) | |
3847 { | |
3848 free(v1->pAvailableDevices[v3].pName); | |
3849 v1->pAvailableDevices[v3].pName = 0; | |
3850 } | |
3851 if ( v1->pAvailableDevices[v3].pDescription ) | |
3852 { | |
3853 free(v1->pAvailableDevices[v3].pDescription); | |
3854 v1->pAvailableDevices[v3].pDescription = 0; | |
3855 } | |
3856 if ( v1->pAvailableDevices[v3].pGUID ) | |
3857 { | |
3858 free(v1->pAvailableDevices[v3].pGUID); | |
3859 v1->pAvailableDevices[v3].pGUID = 0; | |
3860 } | |
3861 ++v3; | |
3862 } | |
3863 while ( v3 < 4 ); | |
3864 if ( v1->pAvailableDevices ) | |
3865 { | |
3866 free(v1->pAvailableDevices); | |
3867 v1->pAvailableDevices = 0; | |
3868 } | |
3869 v4 = v1->pViewport; | |
3870 if ( v4 ) | |
3871 { | |
3872 v4->Release(); | |
3873 v1->pViewport = 0; | |
3874 } | |
3875 v5 = v1->pUnk; | |
3876 if ( v5 ) | |
3877 { | |
3878 v5->Release(); | |
3879 v1->pUnk = 0; | |
3880 } | |
3881 v6 = v1->pZBuffer; | |
3882 if ( v6 ) | |
3883 { | |
3884 v6->Release(); | |
3885 v1->pZBuffer = 0; | |
3886 } | |
3887 v7 = v1->pDevice; | |
3888 if ( v7 ) | |
3889 { | |
3890 v7->Release(); | |
3891 v1->pDevice = 0; | |
3892 } | |
3893 v8 = v1->pDirect3D; | |
3894 if ( v8 ) | |
3895 { | |
3896 v8->Release(); | |
3897 v1->pDirect3D = 0; | |
3898 } | |
3899 v9 = v1->pBackBuffer; | |
3900 if ( v9 ) | |
3901 { | |
3902 v9->Release(); | |
3903 v1->pBackBuffer = 0; | |
3904 } | |
3905 v10 = v1->pFrontBuffer; | |
3906 if ( v10 ) | |
3907 { | |
3908 v10->Release(); | |
3909 v1->pFrontBuffer = 0; | |
3910 } | |
3911 v11 = v1->pHost; | |
3912 if ( v11 ) | |
3913 { | |
3914 v11->Release(); | |
3915 v1->pHost = 0; | |
3916 } | |
3917 } | |
3918 | |
3919 //----- (0049DE14) -------------------------------------------------------- | |
3920 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, HWND hWnd) | |
3921 { | |
3922 //IDirectDraw4 *v8; // eax@12 | |
3923 //IDirectDraw4 *v9; // eax@16 | |
3924 //IDirectDraw4 *v10; // eax@20 | |
3925 //IDirectDraw4 *v13; // eax@35 | |
3926 const char *v23; // [sp-4h] [bp-DCh]@9 | |
3927 const char *v24; // [sp-4h] [bp-DCh]@13 | |
3928 const char *v25; // [sp-4h] [bp-DCh]@19 | |
3929 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
3930 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
3931 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
3932 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
3933 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
3934 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
3935 | |
3936 this->bWindowed = bWindowed; | |
3937 this->hWindow = hWnd; | |
3938 | |
3939 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
3940 { | |
3941 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
3942 return 0; | |
3943 } | |
3944 | |
3945 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
3946 { | |
3947 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
3948 if (lpDD) | |
3949 lpDD->Release(); | |
3950 return 0; | |
3951 } | |
3952 lpDD->Release(); | |
3953 lpDD = 0; | |
3954 | |
3955 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
3956 { | |
3957 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
3958 { | |
3959 v23 = "Init - Failed to set cooperative level.\n"; | |
3960 sprintf(pErrorMessage, v23); | |
3961 LABEL_65: | |
3962 if (pHost) | |
3963 { | |
3964 pHost->Release(); | |
3965 pHost = 0; | |
3966 } | |
3967 return 0; | |
3968 } | |
3969 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
3970 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
3971 ddsd2.dwFlags = DDSD_CAPS; | |
3972 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
3973 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
3974 { | |
3975 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
3976 pHost->GetDisplayMode(&ddsd2); | |
3977 if ( ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) | |
3978 { | |
3979 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
3980 goto LABEL_14; | |
3981 } | |
3982 | |
3983 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
3984 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
3985 ddsd2.dwWidth = 640; | |
3986 ddsd2.dwHeight = 480; | |
3987 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) | |
3988 { | |
3989 v24 = "Init - Failed to create back buffer.\n"; | |
3990 LABEL_14: | |
3991 sprintf(pErrorMessage, v24); | |
3992 if (pFrontBuffer) | |
3993 { | |
3994 pFrontBuffer->Release(); | |
3995 pFrontBuffer = 0; | |
3996 } | |
3997 goto LABEL_65; | |
3998 } | |
3999 if ( pHost->CreateClipper(0, &v30, 0) ) | |
4000 { | |
4001 v25 = "Init - Failed to create clipper.\n"; | |
4002 goto LABEL_45; | |
4003 } | |
4004 v30->SetHWnd(0, hWnd); | |
4005 pFrontBuffer->SetClipper(v30); | |
4006 | |
4007 v30->Release(); | |
4008 v30 = 0; | |
4009 | |
4010 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
4011 | |
4012 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4013 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
4014 ddsd2.dwWidth = 640; | |
4015 ddsd2.dwHeight = 480; | |
4016 | |
4017 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
4018 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
4019 &ddsd2.ddpfPixelFormat) ) | |
4020 goto LABEL_21; | |
4021 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
4022 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
4023 | |
4024 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
4025 { | |
4026 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
4027 { | |
4028 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
4029 pBackBuffer, | |
4030 &pDevice, | |
4031 0) ) | |
4032 { | |
4033 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
4034 d3dvp2.dvClipWidth = 2.0; | |
4035 d3dvp2.dvClipY = 1.0; | |
4036 d3dvp2.dvClipHeight = 2.0; | |
4037 d3dvp2.dvMaxZ = 1.0; | |
4038 d3dvp2.dvMinZ = 0.0; | |
4039 goto LABEL_54; | |
4040 } | |
4041 LABEL_51: | |
4042 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
4043 if (pDirect3D) | |
4044 { | |
4045 pDirect3D->Release(); | |
4046 pDirect3D = 0; | |
4047 } | |
4048 goto LABEL_59; | |
4049 } | |
4050 LABEL_48: | |
4051 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
4052 if (pZBuffer) | |
4053 { | |
4054 pZBuffer->Release(); | |
4055 pZBuffer = 0; | |
4056 } | |
4057 goto LABEL_61; | |
4058 } | |
4059 goto LABEL_44; | |
4060 } | |
4061 LABEL_36: | |
4062 v23 = "Init - Failed to create front buffer.\n"; | |
4063 sprintf(pErrorMessage, v23); | |
4064 goto LABEL_65; | |
4065 } | |
4066 if ( uDeviceID == 1 ) | |
4067 v26 = 1045; | |
4068 else | |
4069 v26 = 1041; | |
4070 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
4071 { | |
4072 v23 = "Init - Failed to set cooperative level.\n"; | |
4073 sprintf(pErrorMessage, v23); | |
4074 goto LABEL_65; | |
4075 } | |
4076 if (pHost->SetDisplayMode(640u, 480u, 16u, 0, 0) ) | |
4077 { | |
4078 v23 = "Init - Failed to set display mode.\n"; | |
4079 sprintf(pErrorMessage, v23); | |
4080 goto LABEL_65; | |
4081 } | |
4082 | |
4083 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
4084 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
4085 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4086 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
4087 ddsd2.dwBackBufferCount = 1; | |
4088 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
4089 goto LABEL_36; | |
4090 //a3a = &pBackBuffer; | |
4091 //v14 = *v34; | |
4092 memset(&v27, 0, sizeof(DDSCAPS2)); | |
4093 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
4094 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
4095 //hWnda = &pDirect3D; | |
4096 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
4097 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
4098 { | |
4099 v25 = "Init - Failed to get D3D interface.\n"; | |
4100 goto LABEL_45; | |
4101 } | |
4102 | |
4103 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4104 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
4105 ddsd2.dwWidth = 640; | |
4106 ddsd2.dwHeight = 480; | |
4107 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
4108 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
4109 &ddsd2.ddpfPixelFormat) ) | |
4110 { | |
4111 LABEL_21: | |
4112 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
4113 goto LABEL_45; | |
4114 } | |
4115 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
4116 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
4117 //uDeviceIDa = &pZBuffer; | |
4118 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
4119 { | |
4120 LABEL_44: | |
4121 v25 = "Init - Failed to create z-buffer.\n"; | |
4122 LABEL_45: | |
4123 sprintf(pErrorMessage, v25); | |
4124 if (pBackBuffer) | |
4125 { | |
4126 pBackBuffer->Release(); | |
4127 pBackBuffer = 0; | |
4128 } | |
4129 LABEL_63: | |
4130 //v19 = &pFrontBuffer; | |
4131 if (pFrontBuffer) | |
4132 { | |
4133 pFrontBuffer->Release(); | |
4134 pFrontBuffer= 0; | |
4135 } | |
4136 goto LABEL_65; | |
4137 } | |
4138 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
4139 goto LABEL_48; | |
4140 //v33 = &pDevice; | |
4141 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
4142 pBackBuffer, | |
4143 &pDevice, | |
4144 0) ) | |
4145 goto LABEL_51; | |
4146 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
4147 d3dvp2.dvClipWidth = 2.0; | |
4148 d3dvp2.dvClipY = 1.0; | |
4149 d3dvp2.dvClipHeight = 2.0; | |
4150 d3dvp2.dvMaxZ = 1.0; | |
4151 | |
4152 LABEL_54: | |
4153 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
4154 //v17 = *hWnda; | |
4155 d3dvp2.dwWidth = 640; | |
4156 d3dvp2.dwHeight = 480; | |
4157 d3dvp2.dvClipX = -1.0; | |
4158 //v18 = v17->lpVtbl; | |
4159 //v32 = &v4->pViewport; | |
4160 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
4161 { | |
4162 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
4163 if (pDevice) | |
4164 { | |
4165 pDevice->Release(); | |
4166 pDevice = 0; | |
4167 } | |
4168 if (pDirect3D) | |
4169 { | |
4170 pDirect3D->Release(); | |
4171 pDirect3D = 0; | |
4172 } | |
4173 LABEL_59: | |
4174 if (pZBuffer) | |
4175 { | |
4176 pZBuffer->Release(); | |
4177 pZBuffer = 0; | |
4178 } | |
4179 LABEL_61: | |
4180 if (pBackBuffer) | |
4181 { | |
4182 pBackBuffer->Release(); | |
4183 pBackBuffer = 0; | |
4184 } | |
4185 goto LABEL_63; | |
4186 } | |
4187 | |
4188 pDevice->AddViewport(pViewport); | |
4189 pViewport->SetViewport2(&d3dvp2); | |
4190 pDevice->SetCurrentViewport(pViewport); | |
4191 return 1; | |
4192 } | |
4193 | |
4194 //----- (0049E444) -------------------------------------------------------- | |
4195 unsigned int RenderD3D::GetDeviceCaps() | |
4196 { | |
4197 unsigned int v1; // ebx@1 | |
4198 RenderD3D *v2; // edi@1 | |
4199 IDirect3DDevice3 *v3; // eax@1 | |
4200 unsigned int result; // eax@2 | |
4201 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
4202 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
4203 | |
4204 v1 = 0; | |
4205 v2 = this; | |
4206 memset(&halCaps, 0, 0xFCu); | |
4207 halCaps.dwSize = 252; | |
4208 memset(&refCaps, 0, 0xFCu); | |
4209 v3 = v2->pDevice; | |
4210 refCaps.dwSize = 252; | |
4211 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
4212 { | |
4213 result = 1; | |
4214 } | |
4215 else | |
4216 { | |
4217 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
4218 v1 = 2; | |
4219 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 2) ) | |
4220 v1 |= 4u; | |
4221 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 1) ) | |
4222 v1 |= 8u; | |
4223 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
4224 v1 |= 0x10u; | |
4225 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 2) ) | |
4226 v1 |= 0x20u; | |
4227 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 4) ) | |
4228 v1 |= 0x40u; | |
4229 if ( halCaps.dpcTriCaps.dwTextureCaps & 0x20 ) | |
4230 LOBYTE(v1) = v1 | 0x80; | |
4231 result = v1; | |
4232 } | |
4233 return result; | |
4234 } | |
4235 | |
4236 //----- (0049E4FC) -------------------------------------------------------- | |
4237 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
4238 { | |
4239 uint uClearFlags = 0; | |
4240 | |
4241 if (bClearColor) | |
4242 uClearFlags |= D3DCLEAR_TARGET; | |
4243 if (bClearDepth) | |
4244 uClearFlags |= D3DCLEAR_ZBUFFER; | |
4245 | |
4246 D3DRECT rects[] = {{0, 0, 640, 480}}; | |
4247 if (uClearFlags) | |
4248 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
4249 } | |
4250 | |
4251 //----- (0049E54D) -------------------------------------------------------- | |
4252 void RenderD3D::Present(bool bForceBlit) | |
4253 { | |
4254 RECT v5; // [sp+18h] [bp-18h]@1 | |
4255 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
4256 | |
4257 v5.left = 0; | |
4258 v5.top = 0; | |
4259 v5.bottom = 480; | |
4260 v5.right = 640; | |
4261 | |
4262 if (bWindowed || bForceBlit) | |
4263 { | |
4264 RECT rc; | |
4265 GetClientRect(hWindow, &rc); | |
4266 Point.y = 0; | |
4267 Point.x = 0; | |
4268 ClientToScreen(hWindow, &Point); | |
4269 OffsetRect(&rc, Point.x, Point.y); | |
4270 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
4271 } | |
4272 else | |
4273 pFrontBuffer->Flip(0, 1); | |
4274 } | |
4275 | |
4276 //----- (0049E5D4) -------------------------------------------------------- | |
4277 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
4278 { | |
4279 unsigned int v8; // edx@4 | |
4280 unsigned int v9; // ebx@5 | |
4281 unsigned int v10; // eax@5 | |
4282 DWORD v11; // edx@5 | |
4283 //int v12; // edx@7 | |
4284 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
4285 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
4286 | |
4287 //v15 = this; | |
4288 memset(&ddsd2, 0, 0x7Cu); | |
4289 ddsd2.dwSize = 0x7Cu; | |
4290 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4291 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
4292 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
4293 ddsd2.dwHeight = uTextureHeight; | |
4294 ddsd2.dwWidth = uTextureWidth; | |
4295 if ( bMipmaps ) | |
4296 { | |
4297 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
4298 { | |
4299 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
4300 LABEL_8: | |
4301 ddsd2.dwMipMapCount = v8; | |
4302 if ( !v8 ) | |
4303 goto LABEL_12; | |
4304 goto LABEL_11; | |
4305 } | |
4306 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
4307 { | |
4308 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
4309 goto LABEL_8; | |
4310 } | |
4311 v9 = GetMaxMipLevels(uTextureWidth); | |
4312 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
4313 ddsd2.dwMipMapCount = v9 - v10; | |
4314 if ( v9 == v10 ) | |
4315 { | |
4316 ddsd2.dwFlags = 0x1007u; | |
4317 ddsd2.ddsCaps.dwCaps = v11; | |
4318 goto LABEL_12; | |
4319 } | |
4320 } | |
4321 else | |
4322 { | |
4323 ddsd2.dwMipMapCount = 1; | |
4324 } | |
4325 LABEL_11: | |
4326 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
4327 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
4328 LABEL_12: | |
4329 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
4330 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
4331 if (bAlphaChannel) | |
4332 { | |
4333 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
4334 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
4335 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
4336 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
4337 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
4338 } | |
4339 else | |
4340 { | |
4341 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
4342 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
4343 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
4344 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
4345 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
4346 } | |
4347 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
4348 return false; | |
4349 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
4350 { | |
4351 (*pOutSurface)->Release(); | |
4352 *pOutSurface = 0; | |
4353 return false; | |
4354 } | |
4355 return true; | |
4356 } | |
4357 | |
4358 //----- (004A5190) -------------------------------------------------------- | |
4359 void RenderD3D::HandleLostResources() | |
4360 { | |
4361 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
4362 pBitmaps_LOD->_410423_move_textures_to_device(); | |
4363 pSprites_LOD->ReleaseLostHardwareSprites(); | |
4364 } | |
4365 | |
4366 //----- (004A2050) -------------------------------------------------------- | |
4367 void Render::DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) | |
4368 { | |
4369 Render *v5; // edi@1 | |
4370 unsigned int v6; // ebx@1 | |
4371 LightmapBuilder *v7; // esi@3 | |
4372 int v8; // eax@7 | |
4373 ODMFace *v9; // eax@12 | |
4374 char *v10; // esi@12 | |
4375 double v11; // st7@14 | |
4376 double v12; // st7@14 | |
4377 int v13; // eax@14 | |
4378 ODMFace *v14; // ecx@14 | |
4379 double v15; // st7@14 | |
4380 float v16; // ST48_4@15 | |
4381 int v17; // eax@15 | |
4382 char v18; // zf@17 | |
4383 HRESULT v19; // eax@18 | |
4384 HRESULT v20; // eax@18 | |
4385 HRESULT v21; // eax@20 | |
4386 HRESULT v22; // eax@20 | |
4387 unsigned int v23; // ecx@20 | |
4388 char *v24; // eax@21 | |
4389 HRESULT v25; // eax@23 | |
4390 HRESULT v26; // eax@23 | |
4391 HRESULT v27; // eax@24 | |
4392 HRESULT v28; // eax@25 | |
4393 HRESULT v29; // eax@25 | |
4394 HRESULT v30; // eax@25 | |
4395 HRESULT v31; // eax@25 | |
4396 HRESULT v32; // eax@26 | |
4397 unsigned int v33; // ecx@26 | |
4398 char *v34; // eax@27 | |
4399 int v35; // edx@28 | |
4400 HRESULT v36; // eax@29 | |
4401 HRESULT v37; // eax@29 | |
4402 HRESULT v38; // eax@29 | |
4403 HRESULT v39; // eax@29 | |
4404 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
4405 unsigned int v41; // eax@29 | |
4406 HRESULT v42; // eax@30 | |
4407 HRESULT v43; // eax@30 | |
4408 HRESULT v44; // eax@30 | |
4409 char *v45; // esi@34 | |
4410 int v46; // ecx@35 | |
4411 double v47; // st6@35 | |
4412 int v48; // eax@36 | |
4413 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
4414 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
4415 int v51; // [sp+50h] [bp-18h]@0 | |
4416 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
4417 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
4418 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
4419 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
4420 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
4421 int v57; // [sp+60h] [bp-8h]@34 | |
638 | 4422 unsigned int a2; // [sp+64h] [bp-4h]@4 |
0 | 4423 |
4424 v5 = this; | |
4425 v6 = 0; | |
4426 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
4427 { | |
4428 v7 = pGame->pLightmapBuilder; | |
4429 v53 = v7; | |
4430 v54 = v7->std__vector_000004_size; | |
4431 if ( v7->std__vector_000004_size) | |
638 | 4432 a2 = 0xFFFFFFFF; |
4433 pGame->AlterGamma_ODM(a4, &a2); | |
0 | 4434 if ( byte_4D864C && pGame->uFlags & 1 ) |
4435 { | |
638 | 4436 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
0 | 4437 v7->_45D74F_MessWithLight(v8, 0); |
4438 } | |
4439 else | |
4440 { | |
4441 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
4442 { | |
323 | 4443 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4444 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
4445 if (bUsingSpecular) | |
4446 { | |
186 | 4447 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
4448 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4449 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4450 } |
4451 if ( (signed int)uNumVertices > 0 ) | |
4452 { | |
4453 v45 = (char *)&array_50AC10[0].vWorldViewPosition; | |
186 | 4454 v57 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 4455 v55 = uNumVertices; |
4456 do | |
4457 { | |
638 | 4458 a2 = ::GetActorTintColor(a3->dimming_level, 0, *(float *)v45, 0, 0); |
4459 pGame->AlterGamma_ODM(a4, &a2); | |
0 | 4460 v46 = v57; |
4461 v47 = *(float *)v45 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
4462 *(int *)(v57 - 4) = *((int *)v45 + 3); | |
4463 *(int *)v57 = *((int *)v45 + 4); | |
4464 *(int *)(v57 + 12) = a2; | |
4465 *(float *)(v57 + 4) = 1.0 - 1.0 / v47; | |
4466 *(float *)(v57 + 8) = 1.0 / (*(float *)v45 + 0.0000001); | |
4467 if ( v5->bUsingSpecular ) | |
4468 { | |
4469 v48 = sub_47C3D7_get_fog_related_stuff(0, 0, *(float *)v45); | |
4470 v46 = v57; | |
4471 } | |
4472 else | |
4473 { | |
4474 v48 = 0; | |
4475 } | |
4476 *(int *)(v46 + 16) = v48; | |
4477 *(int *)(v46 + 20) = *((int *)v45 + 6); | |
4478 *(int *)(v46 + 24) = *((int *)v45 + 7); | |
4479 v45 += 48; | |
4480 v18 = v55-- == 1; | |
4481 v57 = v46 + 32; | |
4482 } | |
4483 while ( !v18 ); | |
4484 } | |
323 | 4485 |
4486 if (a4->uAttributes & FACE_OUTLINED) | |
4487 { | |
4488 int color; | |
4489 if (GetTickCount() % 300 >= 150) | |
4490 color = 0xFFFF2020; | |
4491 else color = 0xFF901010; | |
4492 | |
4493 for (uint i = 0; i < uNumVertices; ++i) | |
4494 d3d_vertex_buffer[i].diffuse = color; | |
4495 } | |
4496 | |
0 | 4497 pRenderD3D->pDevice->SetTexture(0, pTexture); |
4498 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4499 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 4500 d3d_vertex_buffer, |
0 | 4501 uNumVertices, |
4502 D3DDP_DONOTLIGHT); | |
4503 } | |
4504 else | |
4505 { | |
4506 if ( (signed int)uNumVertices > 0 ) | |
4507 { | |
186 | 4508 v9 = (ODMFace *)&d3d_vertex_buffer[0].pos.y; |
0 | 4509 v10 = (char *)&array_50AC10[0].vWorldViewPosition; |
186 | 4510 a4 = (ODMFace *)&d3d_vertex_buffer[0].pos.y; |
0 | 4511 v56 = uNumVertices; |
4512 while ( 1 ) | |
4513 { | |
4514 v11 = *(float *)v10 * 1000.0; | |
4515 *((int *)v9 - 1) = *((int *)v10 + 3); | |
4516 v12 = v11 / (double)pOutdoorCamera->shading_dist_mist; | |
4517 v9->pFacePlane.vNormal.x = *((int *)v10 + 4); | |
4518 *(float *)&v9->pFacePlane.vNormal.y = 1.0 - 1.0 / v12; | |
4519 *(float *)&v9->pFacePlane.vNormal.z = 1.0 / (*(float *)v10 + 0.0000001); | |
638 | 4520 v13 = GetActorTintColor(a3->dimming_level, 0, *(float *)v10, 0, 0); |
0 | 4521 v14 = a4; |
4522 v15 = *(float *)v10; | |
4523 a4->pFacePlane.dist = v13; | |
4524 if ( v5->bUsingSpecular ) | |
4525 { | |
4526 v16 = v15; | |
4527 v17 = sub_47C3D7_get_fog_related_stuff(0, 0, v16); | |
4528 v14 = a4; | |
4529 } | |
4530 else | |
4531 { | |
4532 v17 = 0; | |
4533 } | |
4534 v14->zCalc1 = v17; | |
4535 v14->zCalc2 = *((int *)v10 + 6); | |
4536 v14->zCalc3 = *((int *)v10 + 7); | |
4537 v10 += 48; | |
4538 v18 = v56-- == 1; | |
4539 a4 = (ODMFace *)((char *)v14 + 32); | |
4540 if ( v18 ) | |
4541 break; | |
4542 v9 = a4; | |
4543 } | |
4544 } | |
186 | 4545 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4546 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 4547 if (bUsingSpecular) |
186 | 4548 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 4549 |
4550 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
4551 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4552 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4553 d3d_vertex_buffer, |
0 | 4554 uNumVertices, |
4555 D3DDP_DONOTLIGHT)); | |
4556 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
4557 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
4558 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
4559 v53->_45D74F_MessWithLight(-1, 0); | |
4560 v23 = uNumVertices; | |
4561 if ( (signed int)uNumVertices > 0 ) | |
4562 { | |
186 | 4563 v24 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 4564 do |
4565 { | |
4566 *(int *)v24 = a2; | |
4567 v24 += 32; | |
4568 --v23; | |
4569 } | |
4570 while ( v23 ); | |
4571 } | |
4572 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); | |
186 | 4573 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4574 if ( !pRenderer->bUsingSpecular ) |
186 | 4575 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4576 | |
4577 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4578 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4579 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 4580 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
4581 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4582 d3d_vertex_buffer, |
0 | 4583 uNumVertices, |
4584 D3DDP_DONOTLIGHT)); | |
4585 if (bUsingSpecular) | |
4586 { | |
186 | 4587 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4588 |
4589 v33 = uNumVertices; | |
4590 if ( (signed int)uNumVertices > 0 ) | |
4591 { | |
186 | 4592 v34 = (char *)&d3d_vertex_buffer[0].specular; |
0 | 4593 do |
4594 { | |
4595 v35 = *(int *)v34; | |
4596 *(int *)v34 = 0; | |
4597 v34 += 32; | |
4598 --v33; | |
4599 *((int *)v34 - 9) = pRenderer->uFogColor | v35 & 0xFF000000; | |
4600 } | |
4601 while ( v33 ); | |
4602 } | |
4603 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
186 | 4604 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4605 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 4606 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
4607 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4608 d3d_vertex_buffer, |
0 | 4609 uNumVertices, |
4610 D3DDP_DONOTLIGHT)); | |
186 | 4611 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4612 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
4613 v41 = GetLevelFogColor(); | |
4614 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
4615 v6 = 0; | |
4616 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4617 } | |
186 | 4618 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4619 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4620 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
4621 } | |
4622 } | |
4623 } | |
4624 } | |
4625 // 4D864C: using guessed type char byte_4D864C; | |
4626 | |
4627 //----- (0049EB79) -------------------------------------------------------- | |
4628 Render::~Render() | |
4629 { | |
4630 Render *v1; // esi@1 | |
4631 | |
4632 v1 = this; | |
4633 pAllocator->FreeChunk(this->pDefaultZBuffer); | |
4634 v1->pD3DBitmaps.Release(); | |
4635 v1->pD3DSprites.Release(); | |
4636 Release(); | |
4637 v1->bWindowMode = 1; | |
4638 //nullsub_1(); | |
4639 //nullsub_1(); | |
4640 } | |
4641 | |
4642 //----- (0049E756) -------------------------------------------------------- | |
4643 bool Render::IsColorKeySupported(IDirectDraw4 *this_) | |
4644 { | |
4645 DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1 | |
4646 DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1 | |
4647 | |
4648 halCaps.dwSize = 380; | |
4649 refCaps.dwSize = 380; | |
4650 this_->GetCaps(&halCaps, &refCaps); | |
4651 return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2; | |
4652 } | |
4653 | |
4654 //----- (0049E992) -------------------------------------------------------- | |
4655 Render::Render() | |
4656 { | |
4657 Render *v1; // esi@1 | |
4658 int v2; // eax@1 | |
4659 char v3; // zf@1 | |
4660 | |
4661 v1 = this; | |
4662 this->pDirectDraw4 = 0; | |
4663 this->pFrontBuffer4 = 0; | |
4664 this->pBackBuffer4 = 0; | |
4665 this->pColorKeySurface4 = 0; | |
4666 this->pDirectDraw2 = 0; | |
4667 this->pFrontBuffer2 = 0; | |
4668 this->pBackBuffer2 = 0; | |
4669 this->pSomeSurface2 = 0; | |
4670 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); | |
4671 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
4672 v1->bWindowMode = 1; | |
4673 v1->field_40054 = 0; | |
4674 v1->field_10 = 640; | |
4675 v1->field_14 = 480; | |
4676 v1->field_40030 = 0; | |
4677 v1->field_4002C = 0; | |
4678 v1->pActiveZBuffer = 0; | |
4679 v1->pDefaultZBuffer = 0; | |
709 | 4680 v1->raster_clip_y = 0; |
4681 v1->raster_clip_x = 0; | |
4682 v1->raster_clip_z = 639; | |
4683 v1->raster_clip_w = 479; | |
0 | 4684 v1->field_4003C = (int)&unk_4EED80; |
4685 v1->field_40040 = dword_4EED78; | |
4686 v1->uClipZ = 640; | |
4687 v1->field_40044 = 2; | |
4688 v1->field_40048 = 6; | |
4689 v1->pFrontBuffer4 = 0; | |
4690 v1->pBackBuffer4 = 0; | |
4691 v1->pColorKeySurface4 = 0; | |
4692 v1->pDirectDraw4 = 0; | |
4693 v1->pRenderD3D = 0; | |
4694 v1->uNumSceneBegins = 0; | |
4695 v1->uNumD3DSceneBegins = 0; | |
4696 v1->field_40110 = 0; | |
4697 v1->pTargetSurface = 0; | |
4698 v1->uTargetSurfacePitch = 0; | |
4699 v1->uClipY = 0; | |
4700 v1->uClipX = 0; | |
4701 v1->uClipW = 480; | |
4702 v1->bClip = 1; | |
4703 v1->bColorKeySupported = 0; | |
4704 v1->bRequiredTextureStagesAvailable = 0; | |
4705 v1->bTinting = 1; | |
4706 LOBYTE(v1->field_103668) = 0; | |
4707 v1->field_1036B8 = 0; | |
4708 v1->_gpu_memory_used = 0; | |
4709 uNumBillboardsToDraw = 0; | |
4710 bFogEnabled = false; | |
265 | 4711 |
4712 hd_water_tile_id = -1; | |
4713 hd_water_current_frame = 0; | |
0 | 4714 } |
4715 | |
781 | 4716 bool Render::Initialize(bool bWindowed, uint uDefaultDevice, bool bColoredLights, uint uDetailLevel, uint bTinting) |
0 | 4717 { |
4718 bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | |
4719 bStartInWindow = bWindowed; | |
4720 | |
4721 uDesiredDirect3DDevice = uDefaultDevice;//ReadWindowsRegistryInt("D3D Device", 1); | |
4722 | |
4723 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
4724 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
4725 | |
4726 this->bTinting = bTinting; | |
4727 | |
4728 auto r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); | |
4729 auto r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
4730 | |
4731 return r1 && r2; | |
4732 } | |
4733 | |
4734 //----- (0049EBF1) -------------------------------------------------------- | |
4735 void Render::_49EBF1() | |
4736 { | |
4737 signed int uNumRedBits; // edx@1 | |
4738 signed int uNuGreenBits; // edi@1 | |
4739 signed int uNumBlueBits; // esi@1 | |
4740 unsigned int v4; // edx@4 | |
4741 unsigned int v5; // edi@4 | |
4742 int v6; // ebx@4 | |
4743 int v7; // edx@4 | |
4744 signed int v8; // [sp+8h] [bp-24h]@1 | |
4745 signed int v9; // [sp+Ch] [bp-20h]@1 | |
4746 signed int v10; // [sp+20h] [bp-Ch]@1 | |
4747 signed int i; // [sp+24h] [bp-8h]@2 | |
4748 signed int v12; // [sp+28h] [bp-4h]@3 | |
4749 | |
4750 v10 = 0; | |
4751 uNumRedBits = 1 << this->uTargetRBits; | |
4752 uNuGreenBits = 1 << this->uTargetGBits; | |
4753 uNumBlueBits = 1 << this->uTargetBBits; | |
4754 v9 = 1 << this->uTargetRBits; | |
4755 v8 = 1 << this->uTargetGBits; | |
4756 if ( uNumRedBits > 0 ) | |
4757 { | |
4758 do | |
4759 { | |
4760 for ( i = 0; i < uNuGreenBits; ++i ) | |
4761 { | |
4762 v12 = 0; | |
4763 if ( uNumBlueBits > 0 ) | |
4764 { | |
4765 do | |
4766 { | |
4767 v4 = this->uTargetBBits; | |
4768 v5 = v4 + this->uTargetGBits; | |
4769 v6 = (v12 >> 1) + (v10 >> 1 << v5) + (i >> 1 << this->uTargetBBits); | |
4770 v7 = (v10 << v5) + v12++ + (i << v4); | |
4771 this->field_2C[v7] = v6; | |
4772 } | |
4773 while ( v12 < uNumBlueBits ); | |
4774 uNumRedBits = v9; | |
4775 uNuGreenBits = v8; | |
4776 } | |
4777 } | |
4778 ++v10; | |
4779 } | |
4780 while ( v10 < uNumRedBits ); | |
4781 } | |
4782 } | |
4783 | |
4784 //----- (0049ECC4) -------------------------------------------------------- | |
4785 void Render::ClearBlack() | |
4786 { | |
4787 if (pRenderD3D) | |
4788 { | |
4789 if (field_40110) | |
4790 pRenderD3D->ClearTarget(true, 0, false, 0.0); | |
4791 } | |
4792 else | |
4793 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
4794 } | |
4795 | |
4796 //----- (0049ED18) -------------------------------------------------------- | |
4797 void Render::PresentBlackScreen() | |
4798 { | |
4799 LONG w; // edx@3 | |
4800 IDirectDrawSurface *v2; // eax@3 | |
4801 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
4802 RECT x; // [sp+68h] [bp-10h]@3 | |
4803 | |
4804 memset(&v3, 0, sizeof(DDBLTFX)); | |
4805 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
4806 pVersion->pVersionInfo.dwMajorVersion >= 5) | |
4807 { | |
4808 x.left = uWindowX; | |
4809 x.right = uWindowX + uWindowHeight; | |
4810 x.top = uWindowY; | |
4811 w = uWindowY + uWindowWidth; | |
4812 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
4813 } | |
4814 else | |
4815 { | |
4816 x.left = uWindowX; | |
4817 x.right = uWindowX + uWindowHeight; | |
4818 x.top = uWindowY; | |
4819 w = uWindowY + uWindowWidth; | |
4820 v2 = (IDirectDrawSurface *)this->pBackBuffer2; | |
4821 } | |
4822 x.bottom = w; | |
4823 v3.dwFillColor = 0; | |
4824 v3.dwSize = 100; | |
4825 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
4826 pRenderer->Present(); | |
4827 } | |
4828 | |
4829 //----- (0049EDB6) -------------------------------------------------------- | |
4830 void Render::SavePCXScreenshot() | |
4831 { | |
4832 Render *v1; // esi@1 | |
4833 __int16 v2; // di@1 | |
4834 int v3; // eax@4 | |
4835 int v4; // ecx@4 | |
4836 int v5; // eax@8 | |
4837 FILE *v6; // edi@10 | |
4838 int v7; // ecx@11 | |
4839 int v8; // eax@11 | |
4840 int v9; // eax@13 | |
4841 int v10; // ecx@15 | |
4842 unsigned __int8 v11; // dl@15 | |
4843 signed int v12; // eax@18 | |
4844 char v13; // zf@27 | |
4845 HRESULT v14; // eax@29 | |
4846 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
4847 __int16 v16; // [sp+44h] [bp-120h]@10 | |
4848 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
4849 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
4850 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
4851 char *v20; // [sp+11Ch] [bp-48h]@14 | |
4852 char *v21; // [sp+120h] [bp-44h]@14 | |
4853 int v24; // [sp+124h] [bp-40h]@11 | |
4854 FILE *File; // [sp+128h] [bp-3Ch]@3 | |
4855 int var38; // [sp+12Ch] [bp-38h]@4 | |
4856 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
4857 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
4858 void *ptr; // [sp+148h] [bp-1Ch]@10 | |
4859 void *v28; // [sp+14Ch] [bp-18h]@8 | |
4860 int v29; // [sp+150h] [bp-14h]@4 | |
4861 int v30; // [sp+154h] [bp-10h]@4 | |
4862 char v31; // [sp+15Ah] [bp-Ah]@25 | |
4863 unsigned __int8 v32; // [sp+15Bh] [bp-9h]@17 | |
4864 int i; // [sp+15Ch] [bp-8h]@10 | |
4865 unsigned __int8 v34; // [sp+163h] [bp-1h]@17 | |
4866 | |
4867 v1 = this; | |
4868 v2 = 0; | |
4869 if ( !this->pRenderD3D || this->field_40110 ) | |
4870 { | |
4871 sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100); | |
4872 File = fopen(Filename, "wb"); | |
4873 if ( File ) | |
4874 { | |
4875 v3 = v1->field_10; | |
4876 v4 = v1->field_14; | |
4877 var38 = v3; | |
4878 v29 = v4; | |
4879 v30 = v3; | |
4880 if ( v3 & 1 ) | |
4881 v30 = v3 + 1; | |
4882 if ( v1->pRenderD3D ) | |
4883 { | |
4884 memset(&Dst, 0, 0x7Cu); | |
4885 Dst.dwSize = 124; | |
168 | 4886 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 4887 return; |
4888 v28 = Dst.lpSurface; | |
4889 v5 = Dst.lPitch >> 1; | |
4890 v2 = 0; | |
4891 } | |
4892 else | |
4893 { | |
4894 pRenderer->BeginScene(); | |
4895 v28 = pRenderer->pTargetSurface; | |
4896 v5 = pRenderer->uTargetSurfacePitch; | |
4897 } | |
4898 i = v5; | |
4899 header1.right = var38 - 1; | |
4900 header1.left = v2; | |
4901 header1.bottom = v29 - 1; | |
4902 header1.up = v2; | |
4903 header2.pitch = v30; | |
4904 memset(color_map, 0, sizeof(color_map)); | |
4905 memset(v15, 0, sizeof(v15)); | |
4906 header2.reserved = 0; | |
4907 header1.manufacturer = 10; | |
4908 v16 = 0; | |
4909 v6 = File; | |
4910 header1.version = 5; | |
4911 header1.encoding = 1; | |
4912 header1.bpp = 8; | |
4913 header1.hdpi = 75; | |
4914 header1.vdpi = 75; | |
4915 header2.planes = 3; | |
4916 header2.palette_info = 1; | |
4917 fwrite(&header1, 1u, 1u, File); | |
4918 fwrite(&header1.version, 1u, 1u, v6); | |
4919 fwrite(&header1.encoding, 1u, 1u, v6); | |
4920 fwrite(&header1.bpp, 1u, 1u, v6); | |
4921 fwrite(&header1.left, 2u, 1u, v6); | |
4922 fwrite(&header1.up, 2u, 1u, v6); | |
4923 fwrite(&header1.right, 2u, 1u, v6); | |
4924 fwrite(&header1.bottom, 2u, 1u, v6); | |
4925 fwrite(&header1.hdpi, 2u, 1u, v6); | |
4926 fwrite(&header1.vdpi, 2u, 1u, v6); | |
4927 fwrite(color_map, 0x30u, 1u, v6); | |
4928 fwrite(&header2, 1u, 1u, v6); | |
4929 fwrite(&header2.planes, 1u, 1u, v6); | |
4930 fwrite(&header2.pitch, 2u, 1u, v6); | |
4931 fwrite(&header2.palette_info, 2u, 1u, v6); | |
4932 fwrite(v15, 0x3Au, 1u, v6); | |
4933 ptr = pAllocator->AllocNamedChunk(0, 3 * var38 + 6, 0); | |
4934 if ( v29 > 0 ) | |
4935 { | |
4936 v7 = v30; | |
4937 File = (FILE *)v29; | |
4938 v29 = 3 * v30; | |
4939 v24 = 2 * i; | |
4940 v8 = (int)v28; | |
4941 while ( 1 ) | |
4942 { | |
4943 i = v8; | |
4944 v9 = 0; | |
4945 if ( var38 > 0 ) | |
4946 { | |
4947 v21 = (char *)ptr + v7; | |
4948 v20 = (char *)ptr + 2 * v30; | |
4949 do | |
4950 { | |
4951 *((char *)ptr + v9) = (signed int)(v1->uTargetRMask & *(short *)i) >> (LOBYTE(v1->uTargetGBits) | |
4952 + LOBYTE(v1->uTargetBBits) | |
4953 + v1->uTargetRBits | |
4954 - 8); | |
4955 v21[v9] = (signed int)(v1->uTargetGMask & *(short *)i) >> (LOBYTE(v1->uTargetBBits) | |
4956 + LOBYTE(v1->uTargetGBits) | |
4957 - 8); | |
4958 v10 = i; | |
4959 v11 = LOBYTE(v1->uTargetBMask); | |
4960 i += 2; | |
4961 v20[v9++] = (*(char *)v10 & v11) << (8 - LOBYTE(v1->uTargetBBits)); | |
4962 } | |
4963 while ( v9 < var38 ); | |
4964 } | |
4965 for ( i = 0; i < v29; i += v34 ) | |
4966 { | |
4967 v34 = 1; | |
4968 v32 = *((char *)ptr + i); | |
4969 do | |
4970 { | |
4971 v12 = i + v34; | |
4972 if ( *((char *)ptr + v12) != v32 ) | |
4973 break; | |
4974 if ( !(v12 % v30) ) | |
4975 break; | |
4976 ++v34; | |
4977 } | |
4978 while ( v34 < 0x3Fu ); | |
4979 if ( i + v34 > v29 ) | |
4980 v34 = 3 * v30 - i; | |
4981 if ( v34 > 1u || v32 >= 0xC0u ) | |
4982 { | |
4983 v31 = v34 | 0xC0; | |
4984 fwrite(&v31, 1u, 1u, v6); | |
4985 } | |
4986 fwrite(&v32, 1u, 1u, v6); | |
4987 } | |
4988 v8 = (int)((char *)v28 + v24); | |
4989 v13 = File == (FILE *)1; | |
4990 File = (FILE *)((char *)File - 1); | |
4991 v28 = (char *)v28 + v24; | |
4992 if ( v13 ) | |
4993 break; | |
4994 v7 = v30; | |
4995 } | |
4996 } | |
4997 if ( v1->pRenderD3D ) | |
4998 { | |
4999 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
5000 } | |
5001 else | |
5002 { | |
5003 pRenderer->EndScene(); | |
5004 } | |
5005 | |
5006 pAllocator->FreeChunk(ptr); | |
5007 fclose(v6); | |
5008 } | |
5009 } | |
5010 } | |
5011 // 4EFA80: using guessed type int dword_4EFA80; | |
5012 | |
5013 //----- (0049F1BC) -------------------------------------------------------- | |
5014 void Render::_49F1BC(const char *a1) | |
5015 { | |
5016 Render *v2; // esi@1 | |
5017 __int16 v3; // di@1 | |
5018 int v4; // eax@4 | |
5019 char *v5; // ecx@4 | |
5020 unsigned int v6; // eax@8 | |
5021 FILE *v7; // edi@10 | |
5022 int v8; // ecx@11 | |
5023 int v9; // eax@11 | |
5024 int v10; // eax@13 | |
5025 const char *v11; // ecx@15 | |
5026 unsigned __int8 v12; // dl@15 | |
5027 signed int v13; // eax@18 | |
5028 char v14; // zf@27 | |
5029 HRESULT v15; // eax@29 | |
5030 char v16; // [sp+Ch] [bp-12Ch]@10 | |
5031 __int16 v17; // [sp+44h] [bp-F4h]@10 | |
5032 int Dst; // [sp+48h] [bp-F0h]@7 | |
5033 int v19; // [sp+58h] [bp-E0h]@8 | |
5034 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
5035 char v21; // [sp+C4h] [bp-74h]@10 | |
5036 unsigned int v22; // [sp+F4h] [bp-44h]@11 | |
5037 char *v23; // [sp+F8h] [bp-40h]@14 | |
5038 int v24; // [sp+FCh] [bp-3Ch]@11 | |
5039 int v25; // [sp+100h] [bp-38h]@4 | |
5040 FILE *File; // [sp+104h] [bp-34h]@3 | |
5041 char Str; // [sp+108h] [bp-30h]@10 | |
5042 char v28; // [sp+109h] [bp-2Fh]@10 | |
5043 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
5044 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
5045 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
5046 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
5047 __int16 v33; // [sp+110h] [bp-28h]@10 | |
5048 __int16 v34; // [sp+112h] [bp-26h]@10 | |
5049 __int16 v35; // [sp+114h] [bp-24h]@10 | |
5050 __int16 v36; // [sp+116h] [bp-22h]@10 | |
5051 char v37; // [sp+118h] [bp-20h]@10 | |
5052 char v38; // [sp+119h] [bp-1Fh]@10 | |
5053 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
5054 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
5055 void *ptr; // [sp+120h] [bp-18h]@10 | |
5056 unsigned __int16 *v42; // [sp+124h] [bp-14h]@8 | |
5057 int v43; // [sp+128h] [bp-10h]@4 | |
5058 char v44; // [sp+12Fh] [bp-9h]@25 | |
5059 char *i; // [sp+130h] [bp-8h]@10 | |
5060 unsigned __int8 v46; // [sp+137h] [bp-1h]@17 | |
5061 | |
5062 v2 = this; | |
5063 v3 = 0; | |
5064 if ( !this->pRenderD3D || this->field_40110 ) | |
5065 { | |
5066 ++dword_4EFA84; | |
5067 File = fopen(a1, "wb"); | |
5068 if ( File ) | |
5069 { | |
5070 v4 = v2->field_10; | |
5071 v5 = (char *)v2->field_14; | |
5072 v25 = v4; | |
5073 a1 = v5; | |
5074 v43 = v4; | |
5075 if ( v4 & 1 ) | |
5076 v43 = v4 + 1; | |
5077 if ( v2->pRenderD3D ) | |
5078 { | |
5079 memset(&Dst, 0, 0x7Cu); | |
5080 Dst = 124; | |
168 | 5081 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 5082 return; |
5083 v42 = v20; | |
5084 v6 = v19 >> 1; | |
5085 v3 = 0; | |
5086 } | |
5087 else | |
5088 { | |
5089 pRenderer->BeginScene(); | |
5090 v42 = pRenderer->pTargetSurface; | |
5091 v6 = pRenderer->uTargetSurfacePitch; | |
5092 } | |
5093 i = (char *)v6; | |
5094 v33 = v25 - 1; | |
5095 v31 = v3; | |
5096 v34 = (short)a1 - 1; | |
5097 v32 = v3; | |
5098 v39 = v43; | |
5099 memset(&v21, 0, 0x30u); | |
5100 memset(&v16, 0, 0x38u); | |
5101 v37 = 0; | |
5102 Str = 10; | |
5103 v17 = 0; | |
5104 v7 = File; | |
5105 v28 = 5; | |
5106 v29 = 1; | |
5107 v30 = 8; | |
5108 v35 = 75; | |
5109 v36 = 75; | |
5110 v38 = 3; | |
5111 v40 = 1; | |
5112 fwrite(&Str, 1u, 1u, File); | |
5113 fwrite(&v28, 1u, 1u, v7); | |
5114 fwrite(&v29, 1u, 1u, v7); | |
5115 fwrite(&v30, 1u, 1u, v7); | |
5116 fwrite(&v31, 2u, 1u, v7); | |
5117 fwrite(&v32, 2u, 1u, v7); | |
5118 fwrite(&v33, 2u, 1u, v7); | |
5119 fwrite(&v34, 2u, 1u, v7); | |
5120 fwrite(&v35, 2u, 1u, v7); | |
5121 fwrite(&v36, 2u, 1u, v7); | |
5122 fwrite(&v21, 0x30u, 1u, v7); | |
5123 fwrite(&v37, 1u, 1u, v7); | |
5124 fwrite(&v38, 1u, 1u, v7); | |
5125 fwrite(&v39, 2u, 1u, v7); | |
5126 fwrite(&v40, 2u, 1u, v7); | |
5127 fwrite(&v16, 0x3Au, 1u, v7); | |
5128 ptr = pAllocator->AllocNamedChunk(0, 3 * v25 + 6, 0); | |
5129 if ( (signed int)a1 > 0 ) | |
5130 { | |
5131 v8 = v43; | |
5132 File = (FILE *)a1; | |
5133 v24 = 3 * v43; | |
5134 v22 = 2 * (int)i; | |
5135 v9 = (int)v42; | |
5136 while ( 1 ) | |
5137 { | |
5138 a1 = (const char *)v9; | |
5139 v10 = 0; | |
5140 if ( v25 > 0 ) | |
5141 { | |
5142 i = (char *)ptr + v8; | |
5143 v23 = (char *)ptr + 2 * v43; | |
5144 do | |
5145 { | |
5146 *((char *)ptr + v10) = (signed int)(v2->uTargetRMask & *(short *)a1) >> (LOBYTE(v2->uTargetGBits) | |
5147 + LOBYTE(v2->uTargetBBits) | |
5148 + v2->uTargetRBits | |
5149 - 8); | |
5150 i[v10] = (signed int)(v2->uTargetGMask & *(short *)a1) >> (LOBYTE(v2->uTargetBBits) | |
5151 + LOBYTE(v2->uTargetGBits) | |
5152 - 8); | |
5153 v11 = a1; | |
5154 v12 = LOBYTE(v2->uTargetBMask); | |
5155 a1 += 2; | |
5156 v23[v10++] = ((unsigned __int8)*v11 & v12) << (8 - LOBYTE(v2->uTargetBBits)); | |
5157 } | |
5158 while ( v10 < v25 ); | |
5159 } | |
5160 for ( i = 0; (signed int)i < v24; i += BYTE3(a1) ) | |
5161 { | |
5162 BYTE3(a1) = 1; | |
5163 v46 = *((char *)ptr + (int)i); | |
5164 do | |
5165 { | |
5166 v13 = (signed int)&i[BYTE3(a1)]; | |
5167 if ( *((char *)ptr + v13) != v46 ) | |
5168 break; | |
5169 if ( !(v13 % v43) ) | |
5170 break; | |
5171 ++BYTE3(a1); | |
5172 } | |
5173 while ( BYTE3(a1) < 0x3Fu ); | |
5174 if ( (signed int)&i[BYTE3(a1)] > v24 ) | |
5175 BYTE3(a1) = 3 * v43 - (char)i; | |
5176 if ( BYTE3(a1) > 1u || v46 >= 0xC0u ) | |
5177 { | |
5178 v44 = BYTE3(a1) | 0xC0; | |
5179 fwrite(&v44, 1u, 1u, v7); | |
5180 } | |
5181 fwrite(&v46, 1u, 1u, v7); | |
5182 } | |
5183 v9 = (int)&v42[v22 / 2]; | |
5184 v14 = File == (FILE *)1; | |
5185 File = (FILE *)((char *)File - 1); | |
5186 v42 = (unsigned __int16 *)((char *)v42 + v22); | |
5187 if ( v14 ) | |
5188 break; | |
5189 v8 = v43; | |
5190 } | |
5191 } | |
5192 if ( v2->pRenderD3D ) | |
5193 { | |
5194 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
5195 } | |
5196 else | |
5197 { | |
5198 pRenderer->EndScene(); | |
5199 } | |
5200 pAllocator->FreeChunk(ptr); | |
5201 fclose(v7); | |
5202 } | |
5203 } | |
5204 } | |
5205 // 4EFA84: using guessed type int dword_4EFA84; | |
5206 | |
5207 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 5208 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
5209 { | |
0 | 5210 Render *v7; // ebx@1 |
5211 void *v8; // esi@3 | |
5212 void *v9; // esi@3 | |
5213 int v10; // ecx@4 | |
810 | 5214 unsigned short* v11; // eax@4 |
0 | 5215 int v12; // eax@6 |
5216 int v13; // eax@8 | |
5217 int v14; // ecx@8 | |
5218 signed int v15; // eax@11 | |
5219 char v16; // zf@20 | |
5220 int result; // eax@21 | |
5221 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
5222 // __int16 v19; // [sp+44h] [bp-74h]@3 | |
5223 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 5224 char *lineG; // [sp+78h] [bp-40h]@7 |
5225 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 5226 int v23; // [sp+80h] [bp-38h]@4 |
5227 int v24; // [sp+84h] [bp-34h]@4 | |
5228 int v25; // [sp+88h] [bp-30h]@4 | |
5229 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 5230 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
5231 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
5232 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
5233 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 5234 char v43; // [sp+B3h] [bp-5h]@18 |
5235 int i; // [sp+B4h] [bp-4h]@6 | |
810 | 5236 unsigned short* line_pictute_data; |
5237 byte test_byte; | |
5238 unsigned char pict_byte; | |
0 | 5239 |
5240 v7 = this; | |
810 | 5241 pitch = wight; |
5242 if ( wight & 1 ) | |
5243 pitch = wight + 1; | |
5244 Src.left = 0; | |
5245 Src.up = 0; | |
5246 Src.right = wight - 1; | |
5247 Src.bottom = heidth - 1; | |
5248 v27.pitch = pitch; | |
0 | 5249 memset(&v20, 0, 0x30u); |
5250 memset(&v18, 0, 0x38u); | |
810 | 5251 v8 = data_buff; |
5252 v27.reserved = 0; | |
0 | 5253 *(_WORD *)&v18[56] = 0; |
810 | 5254 Src.manufacturer = 10; |
5255 Src.version = 5; | |
5256 Src.encoding = 1; | |
5257 Src.bpp = 8; | |
5258 Src.hdpi = 75; | |
5259 Src.vdpi = 75; | |
5260 v27.planes = 3; | |
5261 v27.palette_info = 1; | |
5262 memcpy(data_buff, &Src, 1u); | |
0 | 5263 v8 = (char *)v8 + 1; |
810 | 5264 memcpy(v8, &Src.version, 1u); |
0 | 5265 v8 = (char *)v8 + 1; |
810 | 5266 memcpy(v8, &Src.encoding, 1u); |
0 | 5267 v8 = (char *)v8 + 1; |
810 | 5268 memcpy(v8, &Src.bpp, 1u); |
0 | 5269 v8 = (char *)v8 + 1; |
810 | 5270 memcpy(v8, &Src.left, 2u); |
0 | 5271 v8 = (char *)v8 + 2; |
810 | 5272 memcpy(v8, &Src.up, 2u); |
0 | 5273 v8 = (char *)v8 + 2; |
810 | 5274 memcpy(v8, &Src.right, 2u); |
0 | 5275 v8 = (char *)v8 + 2; |
810 | 5276 memcpy(v8, &Src.bottom, 2u); |
0 | 5277 v8 = (char *)v8 + 2; |
810 | 5278 memcpy(v8, &Src.hdpi, 2u); |
0 | 5279 v8 = (char *)v8 + 2; |
810 | 5280 memcpy(v8, &Src.vdpi, 2u); |
0 | 5281 v8 = (char *)v8 + 2; |
5282 memcpy(v8, &v20, 0x30u); | |
5283 v8 = (char *)v8 + 48; | |
810 | 5284 memcpy(v8, &v27, 1u); |
0 | 5285 v8 = (char *)v8 + 1; |
810 | 5286 memcpy(v8, &v27.planes, 1u); |
0 | 5287 v8 = (char *)v8 + 1; |
810 | 5288 memcpy(v8, &v27.pitch, 2u); |
0 | 5289 v8 = (char *)v8 + 2; |
810 | 5290 memcpy(v8, &v27.palette_info, 2u); |
0 | 5291 v8 = (char *)v8 + 2; |
5292 memcpy(v8, &v18, 0x3Au); | |
5293 v9 = (char *)v8 + 58; | |
810 | 5294 |
5295 lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0); | |
5296 if ( heidth > 0 ) | |
5297 { | |
5298 v10 = pitch; | |
5299 v25 = heidth; | |
5300 v26 = 3 * pitch; | |
5301 v23 = 2 * wight; | |
5302 v11 = picture_data; | |
5303 v24 = (int)picture_data; | |
0 | 5304 while ( 1 ) |
5305 { | |
810 | 5306 line_pictute_data = v11; |
0 | 5307 v12 = 0; |
5308 i = 0; | |
810 | 5309 if ( wight > 0 ) |
5310 { | |
5311 lineG = (char *)lineRGB + pitch; | |
5312 lineB = (char *)lineRGB + 2 * pitch; | |
0 | 5313 do |
5314 { | |
810 | 5315 lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8); |
5316 lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8); | |
5317 lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits); | |
5318 | |
5319 v12++; | |
5320 } | |
5321 while ( v12 < wight ); | |
0 | 5322 } |
5323 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
5324 { | |
810 | 5325 test_byte = 1; |
5326 pict_byte = lineRGB [i]; | |
0 | 5327 do |
5328 { | |
810 | 5329 v15 = i + test_byte; |
5330 if ( *((char *)lineRGB + v15) != pict_byte ) | |
0 | 5331 break; |
810 | 5332 if ( !(v15 % pitch) ) |
0 | 5333 break; |
810 | 5334 ++test_byte; |
5335 } | |
5336 while ( test_byte < 0x3Fu ); | |
5337 if ( i + test_byte > v26 ) | |
5338 test_byte = 3 * pitch - i; | |
5339 if ( test_byte > 1u || pict_byte >= 0xC0u ) | |
5340 { | |
5341 v43 = test_byte | 0xC0; | |
0 | 5342 memcpy(v9, &v43, 1u); |
5343 v9 = (char *)v9 + 1; | |
5344 } | |
810 | 5345 memcpy(v9, &pict_byte, 1u); |
5346 i += test_byte; | |
5347 } | |
5348 v11 +=wight ; | |
0 | 5349 v16 = v25-- == 1; |
810 | 5350 |
0 | 5351 if ( v16 ) |
5352 break; | |
810 | 5353 v10 = pitch; |
5354 } | |
5355 } | |
5356 pAllocator->FreeChunk(lineRGB); | |
5357 *(int *)packed_size = (char *)v9 - data_buff; | |
5358 | |
0 | 5359 } |
5360 | |
5361 //----- (0049F8B5) -------------------------------------------------------- | |
5362 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) | |
5363 { | |
5364 Render *v5; // esi@1 | |
5365 FILE *result; // eax@1 | |
5366 FILE *v7; // edi@4 | |
5367 int v8; // ecx@5 | |
5368 int v9; // eax@5 | |
5369 int v10; // eax@7 | |
5370 int v11; // ecx@9 | |
5371 signed int v12; // eax@12 | |
5372 char v13; // zf@21 | |
5373 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
5374 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
5375 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
5376 int v17; // [sp+70h] [bp-34h]@5 | |
5377 int v18; // [sp+74h] [bp-30h]@5 | |
5378 char *v19; // [sp+78h] [bp-2Ch]@5 | |
5379 int v20; // [sp+7Ch] [bp-28h]@5 | |
5380 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 | |
5381 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
5382 void *ptr; // [sp+98h] [bp-Ch]@4 | |
5383 int v24; // [sp+9Ch] [bp-8h]@2 | |
5384 char *i; // [sp+A0h] [bp-4h]@8 | |
5385 | |
5386 v5 = this; | |
5387 result = fopen(Filename, "wb"); | |
5388 Filename = (const char *)result; | |
5389 if ( result ) | |
5390 { | |
5391 v24 = a4; | |
5392 if ( a4 & 1 ) | |
5393 v24 = a4 + 1; | |
5394 header1.left = 0; | |
5395 header1.up = 0; | |
5396 header1.right = a4 - 1; | |
5397 header1.bottom = a5 - 1; | |
5398 header2.pitch = v24; | |
5399 memset(color_map, 0, sizeof(color_map)); | |
5400 header2.reserved = 0; | |
5401 memset(v14, 0, sizeof(v14)); | |
5402 v15 = 0; | |
5403 header1.manufacturer = 10; | |
5404 header1.version = 5; | |
5405 header1.encoding = 1; | |
5406 header1.bpp = 8; | |
5407 header1.hdpi = 75; | |
5408 header1.vdpi = 75; | |
5409 header2.planes = 3; | |
5410 header2.palette_info = 1; | |
5411 fwrite(&header1, 1u, 1u, (FILE *)Filename); | |
5412 v7 = (FILE *)Filename; | |
5413 fwrite(&header1.version, 1u, 1u, (FILE *)Filename); | |
5414 fwrite(&header1.encoding, 1u, 1u, v7); | |
5415 fwrite(&header1.bpp, 1u, 1u, v7); | |
5416 fwrite(&header1.left, 2u, 1u, v7); | |
5417 fwrite(&header1.up, 2u, 1u, v7); | |
5418 fwrite(&header1.right, 2u, 1u, v7); | |
5419 fwrite(&header1.bottom, 2u, 1u, v7); | |
5420 fwrite(&header1.hdpi, 2u, 1u, v7); | |
5421 fwrite(&header1.vdpi, 2u, 1u, v7); | |
5422 fwrite(color_map, 0x30u, 1u, v7); | |
5423 fwrite(&header2, 1u, 1u, v7); | |
5424 fwrite(&header2.planes, 1u, 1u, v7); | |
5425 fwrite(&header2.pitch, 2u, 1u, v7); | |
5426 fwrite(&header2.palette_info, 2u, 1u, v7); | |
5427 fwrite(v14, 0x3Au, 1u, v7); | |
5428 ptr = pAllocator->AllocNamedChunk(0, 3 * a4 + 6, 0); | |
5429 if ( a5 > 0 ) | |
5430 { | |
5431 v8 = v24; | |
5432 v18 = a5; | |
5433 v20 = 3 * v24; | |
5434 v17 = 2 * a4; | |
5435 v9 = (int)a3; | |
5436 v19 = a3; | |
5437 while ( 1 ) | |
5438 { | |
5439 a5 = v9; | |
5440 v10 = 0; | |
5441 if ( a4 > 0 ) | |
5442 { | |
5443 a3 = (char *)ptr + v8; | |
5444 i = (char *)ptr + 2 * v24; | |
5445 do | |
5446 { | |
5447 *((char *)ptr + v10) = (signed int)(v5->uTargetRMask & *(short *)a5) >> (LOBYTE(v5->uTargetGBits) | |
5448 + LOBYTE(v5->uTargetBBits) | |
5449 + v5->uTargetRBits | |
5450 - 8); | |
5451 a3[v10] = (signed int)(v5->uTargetGMask & *(short *)a5) >> (LOBYTE(v5->uTargetBBits) | |
5452 + LOBYTE(v5->uTargetGBits) | |
5453 - 8); | |
5454 v11 = a5; | |
5455 a5 += 2; | |
5456 i[v10++] = (v5->uTargetBMask & *(char *)v11) << (8 - LOBYTE(v5->uTargetBBits)); | |
5457 } | |
5458 while ( v10 < a4 ); | |
5459 } | |
5460 for ( i = 0; (signed int)i < v20; i += BYTE3(a5) ) | |
5461 { | |
5462 BYTE3(a5) = 1; | |
5463 BYTE3(Filename) = *((char *)ptr + (int)i); | |
5464 do | |
5465 { | |
5466 v12 = (signed int)&i[BYTE3(a5)]; | |
5467 if ( *((char *)ptr + v12) != BYTE3(Filename) ) | |
5468 break; | |
5469 if ( !(v12 % v24) ) | |
5470 break; | |
5471 ++BYTE3(a5); | |
5472 } | |
5473 while ( BYTE3(a5) < 0x3Fu ); | |
5474 if ( (signed int)&i[BYTE3(a5)] > v20 ) | |
5475 BYTE3(a5) = 3 * v24 - (char)i; | |
5476 if ( BYTE3(a5) > 1u || BYTE3(Filename) >= 0xC0u ) | |
5477 { | |
5478 BYTE3(a3) = BYTE3(a5) | 0xC0; | |
5479 fwrite((char *)&a3 + 3, 1u, 1u, v7); | |
5480 } | |
5481 fwrite((char *)&Filename + 3, 1u, 1u, v7); | |
5482 } | |
5483 v9 = (int)&v19[v17]; | |
5484 v13 = v18-- == 1; | |
5485 v19 += v17; | |
5486 if ( v13 ) | |
5487 break; | |
5488 v8 = v24; | |
5489 } | |
5490 } | |
5491 pAllocator->FreeChunk(ptr); | |
5492 result = (FILE *)fclose(v7); | |
5493 } | |
5494 return result; | |
5495 } | |
5496 | |
5497 //----- (0049FBCD) -------------------------------------------------------- | |
5498 void Render::ClearTarget(unsigned int uColor) | |
5499 { | |
5500 if (pRenderD3D) | |
5501 { | |
5502 if (field_40110) | |
5503 pRenderD3D->ClearTarget(true, uColor, false, 0.0); | |
5504 } | |
5505 else | |
5506 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
5507 } | |
5508 | |
5509 //----- (0049FC23) -------------------------------------------------------- | |
5510 void Render::Release2() | |
5511 { | |
5512 Release(); | |
5513 bWindowMode = 1; | |
5514 } | |
5515 | |
5516 //----- (0049FC37) -------------------------------------------------------- | |
5517 void Render::Present() | |
5518 { | |
5519 Render *v1; // esi@1 | |
5520 struct tagRECT Rect; // [sp+8h] [bp-28h]@11 | |
5521 RECT a4; // [sp+18h] [bp-18h]@11 | |
5522 struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
5523 | |
5524 v1 = this; | |
5525 if ( !pRenderer->pRenderD3D || this->field_40110 ) | |
5526 { | |
5527 this->pBeforePresentFunction(); | |
5528 if ( v1->pRenderD3D ) | |
5529 { | |
5530 if ( v1->field_40110 ) | |
5531 { | |
5532 if (pAsyncMouse) | |
5533 pAsyncMouse->_46BAEC(); | |
5534 pRenderD3D->Present(false); | |
5535 if (pAsyncMouse) | |
5536 pAsyncMouse->_46BB0A(); | |
5537 } | |
5538 } | |
5539 else | |
5540 { | |
5541 if ( v1->bWindowMode ) | |
5542 { | |
5543 RestoreFrontBuffer(); | |
5544 GetClientRect(v1->hWnd, &Rect); | |
5545 Point.y = 0; | |
5546 Point.x = 0; | |
5547 ClientToScreen(v1->hWnd, &Point); | |
5548 OffsetRect(&Rect, Point.x, Point.y); | |
5549 a4.top = 0; | |
5550 a4.bottom = 480; | |
5551 a4.left = 0; | |
5552 a4.right = 640; | |
5553 PresentRect(&Rect, &a4); | |
5554 } | |
5555 else | |
5556 { | |
5557 RestoreFrontBuffer(); | |
5558 a4.top = 0; | |
5559 a4.bottom = 480; | |
5560 a4.left = 0; | |
5561 a4.right = 640; | |
5562 BltBackToFontFast(0, 0, &a4); | |
5563 } | |
5564 } | |
5565 } | |
5566 } | |
5567 | |
5568 //----- (0049FD3A) -------------------------------------------------------- | |
5569 void Render::_49FD3A() | |
5570 { | |
5571 Render *v2; // esi@1 | |
5572 IDirectDrawSurface4 *v3; // eax@6 | |
5573 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
5574 RECT v5; // [sp+8h] [bp-10h]@6 | |
5575 | |
5576 auto a1 = this; | |
5577 v2 = a1; | |
5578 if ( a1->pRenderD3D ) | |
5579 { | |
5580 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
5581 pFrontBuffer4->Restore(); | |
5582 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
5583 pBackBuffer4->Restore(); | |
5584 v3 = v2->pBackBuffer4; | |
5585 v4 = v2->pFrontBuffer4; | |
5586 v5.top = 0; | |
5587 v5.bottom = 480; | |
5588 v5.left = 0; | |
5589 v5.right = 640; | |
5590 v3->BltFast(0, 0, v4, &v5, 16u); | |
5591 } | |
5592 } | |
5593 | |
5594 //----- (0049FDBF) -------------------------------------------------------- | |
5595 void Render::CreateZBuffer() | |
5596 { | |
5597 if (!pDefaultZBuffer) | |
5598 { | |
5599 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
5600 pDefaultZBuffer = pActiveZBuffer = (int *)pAllocator->AllocNamedChunk(0, 0x12C000, "Z Buf."); | |
871 | 5601 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 5602 } |
5603 } | |
5604 | |
5605 //----- (0049FE05) -------------------------------------------------------- | |
5606 void Render::Release() | |
5607 { | |
5608 Render *v1; // esi@1 | |
5609 RenderD3D *v2; // ecx@1 | |
5610 char v3; // zf@4 | |
5611 void *v4; // ebx@6 | |
5612 IDirectDraw *v5; // eax@10 | |
5613 IDirectDrawSurface2 *v6; // eax@11 | |
5614 IDirectDrawSurface2 *v7; // eax@13 | |
5615 IDirectDrawSurface2 *v8; // eax@15 | |
5616 IDirectDraw2 *v9; // eax@17 | |
5617 IDirectDraw4 *v10; // eax@19 | |
5618 IDirectDrawSurface4 *v11; // eax@20 | |
5619 IDirectDrawSurface4 *v12; // eax@22 | |
5620 IDirectDrawSurface4 *v13; // eax@24 | |
5621 IDirectDraw4 *v14; // eax@26 | |
5622 unsigned __int16 **v15; // ebx@28 | |
5623 void **v16; // esi@29 | |
5624 | |
5625 v1 = this; | |
5626 v2 = this->pRenderD3D; | |
5627 if ( v2 ) | |
5628 { | |
5629 if ( v1->field_40110 ) | |
5630 { | |
5631 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
5632 pRenderD3D->Present(0); | |
5633 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
5634 } | |
5635 v1->pColorKeySurface4 = 0; | |
5636 v1->pBackBuffer4 = 0; | |
5637 v3 = v1->pTargetSurface == 0; | |
5638 v1->pFrontBuffer4 = 0; | |
5639 v1->pDirectDraw4 = 0; | |
5640 if ( !v3 ) | |
5641 { | |
5642 free(v1->ptr_400E8); | |
5643 v1->pTargetSurface = 0; | |
5644 v1->ptr_400E8 = 0; | |
5645 } | |
5646 v4 = v1->pRenderD3D; | |
5647 if ( v4 ) | |
5648 { | |
5649 pRenderD3D->Release(); | |
5650 free(v4); | |
5651 } | |
5652 v1->pRenderD3D = 0; | |
5653 } | |
5654 else | |
5655 { | |
5656 if ( bWinNT4_0 == 1 ) | |
5657 { | |
5658 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
5659 if ( !v5 ) | |
5660 return; | |
5661 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
5662 v1->pDirectDraw2->FlipToGDISurface(); | |
5663 v6 = v1->pSomeSurface2; | |
5664 if ( v6 ) | |
5665 { | |
5666 v6->Release(); | |
5667 v1->pSomeSurface2 = 0; | |
5668 } | |
5669 v7 = v1->pBackBuffer2; | |
5670 if ( v7 ) | |
5671 { | |
5672 v7->Release(); | |
5673 v1->pBackBuffer2 = 0; | |
5674 } | |
5675 v8 = v1->pFrontBuffer2; | |
5676 if ( v8 ) | |
5677 { | |
5678 v8->Release(); | |
5679 v1->pFrontBuffer2 = 0; | |
5680 } | |
5681 v9 = v1->pDirectDraw2; | |
5682 if ( v9 ) | |
5683 { | |
5684 v9->Release(); | |
5685 v1->pDirectDraw2 = 0; | |
5686 } | |
5687 } | |
5688 else | |
5689 { | |
5690 v10 = v1->pDirectDraw4; | |
5691 if ( !v10 ) | |
5692 return; | |
5693 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
5694 v1->pDirectDraw4->FlipToGDISurface(); | |
5695 v11 = v1->pColorKeySurface4; | |
5696 if ( v11 ) | |
5697 { | |
5698 v11->Release(); | |
5699 v1->pColorKeySurface4 = 0; | |
5700 } | |
5701 v12 = v1->pBackBuffer4; | |
5702 if ( v12 ) | |
5703 { | |
5704 v12->Release(); | |
5705 v1->pBackBuffer4 = 0; | |
5706 } | |
5707 v13 = v1->pFrontBuffer4; | |
5708 if ( v13 ) | |
5709 { | |
5710 v13->Release(); | |
5711 v1->pFrontBuffer4 = 0; | |
5712 } | |
5713 v14 = v1->pDirectDraw4; | |
5714 if ( v14 ) | |
5715 { | |
5716 v14->Release(); | |
5717 v1->pDirectDraw4 = 0; | |
5718 } | |
5719 } | |
5720 v15 = &v1->pTargetSurface; | |
5721 if ( v1->pTargetSurface ) | |
5722 { | |
5723 v16 = (void **)&v1->ptr_400E8; | |
5724 free(*v16); | |
5725 *v15 = 0; | |
5726 *v16 = 0; | |
5727 } | |
5728 } | |
5729 } | |
5730 | |
5731 //----- (0049FFD7) -------------------------------------------------------- | |
5732 void Render::CreateSomeTexture() | |
5733 { | |
5734 pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); | |
5735 } | |
5736 | |
5737 //----- (0049FFFB) -------------------------------------------------------- | |
5738 bool Render::InitializeFullscreen(HWND hWnd) | |
5739 { | |
5740 //Render *v2; // esi@1 | |
5741 //HWND v3; // ebx@1 | |
5742 //void *v4; // eax@2 | |
5743 //RenderD3D *v5; // eax@3 | |
5744 unsigned int v6; // edx@5 | |
5745 RenderD3D__DevInfo *v7; // ecx@5 | |
5746 bool v8; // eax@6 | |
5747 RenderD3D *v9; // ecx@13 | |
5748 unsigned int v10; // eax@13 | |
5749 RenderD3D *v11; // eax@25 | |
5750 HRESULT v12; // eax@25 | |
5751 int v13; // ecx@25 | |
5752 int v14; // eax@27 | |
5753 signed int v15; // ebx@31 | |
5754 bool v16; // eax@35 | |
5755 char v17; // zf@35 | |
5756 IDirectDraw4 *v18; // eax@38 | |
5757 HRESULT v19; // eax@38 | |
5758 int *v20; // eax@39 | |
5759 int *v22; // eax@42 | |
5760 int v23; // ecx@42 | |
5761 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
5762 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
5763 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
5764 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
5765 void *v28; // [sp+2FCh] [bp-10h]@2 | |
5766 int v29; // [sp+308h] [bp-4h]@2 | |
5767 | |
5768 //v2 = this; | |
5769 this->field_40110 = 0; | |
5770 this->pColorKeySurface4 = 0; | |
5771 this->pBackBuffer4 = 0; | |
5772 this->pFrontBuffer4 = 0; | |
5773 this->pDirectDraw4 = 0; | |
5774 this->bColorKeySupported = 0; | |
5775 Release(); | |
5776 //v3 = hWnd; | |
5777 this->hWnd = hWnd; | |
5778 CreateZBuffer(); | |
5779 if ( bUserDirect3D ) | |
5780 { | |
5781 pRenderD3D = new RenderD3D; | |
5782 v28 = pRenderD3D; | |
5783 v6 = uDesiredDirect3DDevice; | |
5784 v29 = -1; | |
5785 v7 = pRenderD3D->pAvailableDevices; | |
5786 if ( v7[v6].bIsDeviceCompatible ) | |
5787 { | |
5788 v8 = pRenderD3D->CreateDevice(v6, 0, hWnd); | |
5789 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
5790 } | |
5791 else | |
5792 { | |
5793 if ( v7[1].bIsDeviceCompatible ) | |
5794 { | |
5795 v8 = pRenderD3D->CreateDevice(1u, 0, hWnd); | |
5796 uAcquiredDirect3DDevice = 1; | |
5797 } | |
5798 else | |
5799 { | |
5800 if ( !v7->bIsDeviceCompatible ) | |
5801 Abortf("There aren't any D3D devices to create."); | |
5802 v8 = pRenderD3D->CreateDevice(0, 0, hWnd); | |
5803 uAcquiredDirect3DDevice = 0; | |
5804 } | |
5805 } | |
5806 if ( !v8 ) | |
5807 Abortf("D3Drend->Init failed."); | |
5808 v9 = pRenderD3D; | |
5809 pBackBuffer4 = v9->pBackBuffer; | |
5810 pFrontBuffer4 = v9->pFrontBuffer; | |
5811 pDirectDraw4 = v9->pHost; | |
5812 v10 = pRenderD3D->GetDeviceCaps(); | |
5813 if ( v10 & 1 ) | |
5814 { | |
5815 if ( pRenderD3D ) | |
5816 { | |
5817 pRenderD3D->Release(); | |
5818 delete pRenderD3D; | |
5819 } | |
5820 pRenderD3D = 0; | |
5821 pBackBuffer4 = 0; | |
5822 pFrontBuffer4 = 0; | |
5823 pDirectDraw4 = 0; | |
5824 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
5825 } | |
5826 if ( v10 & 0x3E ) | |
5827 { | |
5828 if ( pRenderD3D ) | |
5829 { | |
5830 pRenderD3D->Release(); | |
5831 delete pRenderD3D; | |
5832 } | |
5833 pColorKeySurface4 = 0; | |
5834 pRenderD3D = 0; | |
5835 pBackBuffer4 = 0; | |
5836 pFrontBuffer4 = 0; | |
5837 pDirectDraw4 = 0; | |
5838 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
5839 } | |
5840 if ( (v10 & 0x80u) != 0 ) | |
5841 { | |
5842 if ( pRenderD3D ) | |
5843 { | |
5844 pRenderD3D->Release(); | |
5845 delete pRenderD3D; | |
5846 } | |
5847 pRenderD3D = 0; | |
5848 pBackBuffer4 = 0; | |
5849 pFrontBuffer4 = 0; | |
5850 pDirectDraw4 = 0; | |
5851 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
5852 } | |
5853 LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; | |
5854 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
5855 memset(&halCaps, 0, 0xFCu); | |
5856 halCaps.dwSize = 252; | |
5857 memset(&refCaps, 0, 0xFCu); | |
5858 v11 = pRenderD3D; | |
5859 refCaps.dwSize = 252; | |
5860 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
5861 v13 = halCaps.dwMinTextureWidth; | |
5862 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
5863 v13 = halCaps.dwMinTextureHeight; | |
5864 v14 = halCaps.dwMaxTextureWidth; | |
5865 uMinDeviceTextureDim = v13; | |
5866 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
5867 v14 = halCaps.dwMaxTextureHeight; | |
5868 uMaxDeviceTextureDim = v14; | |
5869 if ( (unsigned int)v13 < 4 ) | |
5870 uMinDeviceTextureDim = 4; | |
5871 CreateSomeTexture(); | |
5872 v15 = 1; | |
5873 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
5874 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
5875 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
5876 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); | |
5877 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
5878 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
5879 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
5880 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
5881 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
5882 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
5883 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
5884 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
5885 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
5886 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
5887 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
5888 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
5889 } | |
5890 else | |
5891 { | |
5892 CreateDirectDraw(); | |
5893 SetDirectDrawCooperationMode(hWnd, 1); | |
5894 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
5895 CreateDirectDrawPrimarySurface(); | |
5896 v15 = 1; | |
5897 } | |
5898 ddpfPrimareSuface.dwSize = 32; | |
5899 GetTargetPixelFormat(&ddpfPrimareSuface); | |
5900 ParseTargetPixelFormat(); | |
5901 _49EBF1(); | |
5902 if ( pRenderD3D ) | |
5903 { | |
5904 v16 = IsColorKeySupported(pDirectDraw4); | |
5905 v17 = uAcquiredDirect3DDevice == v15; | |
5906 bColorKeySupported = v16; | |
5907 if ( !v17 ) | |
5908 bColorKeySupported = 0; | |
5909 if ( bColorKeySupported ) | |
5910 { | |
5911 memset(&ddsd2, 0, 0x7Cu); | |
5912 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
5913 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
5914 v18 = pDirectDraw4; | |
5915 ddsd2.dwSize = 124; | |
5916 ddsd2.dwFlags = 65543; | |
5917 ddsd2.ddsCaps.dwCaps = 2112; | |
5918 ddsd2.dwWidth = 640; | |
5919 ddsd2.dwHeight = 480; | |
5920 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
5921 pBeforePresentFunction = Present_ColorKey; | |
5922 } | |
5923 else | |
5924 { | |
5925 pTargetSurface = 0; | |
5926 ptr_400E8 = 0; | |
5927 v20 = (int *)operator new(0x96020u); | |
5928 ptr_400E8 = v20; | |
5929 if ( !v20 | |
5930 || (memset(&pDesc, 0, 0x7Cu), | |
5931 pDesc.dwSize = 124, | |
5932 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
5933 return 0; | |
5934 pBackBuffer4->Unlock(0); | |
5935 v22 = ptr_400E8 + 4; | |
5936 v23 = (unsigned int)pDesc.lpSurface & 7; | |
5937 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
5938 uTargetSurfacePitch = 640; | |
5939 pBeforePresentFunction = Present_NoColorKey; | |
5940 v15 = 1; | |
5941 pTargetSurface = (unsigned __int16 *)((char *)v22 + 2 * v23); | |
5942 } | |
5943 field_40110 = v15; | |
5944 } | |
5945 else | |
5946 { | |
5947 pBeforePresentFunction = 0;//nullsub_1; | |
5948 } | |
5949 bWindowMode = 0; | |
5950 pParty->uFlags |= 2u; | |
5951 LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; | |
5952 pViewport->_4C02F8(36044); | |
5953 return v15; | |
5954 } | |
5955 // 6BE3A0: using guessed type float flt_6BE3A0; | |
5956 | |
5957 //----- (004A05F3) -------------------------------------------------------- | |
5958 bool Render::SwitchToWindow(HWND hWnd) | |
5959 { | |
5960 //Render *v2; // esi@1 | |
5961 //void *v3; // eax@2 | |
5962 //RenderD3D *v4; // eax@3 | |
5963 //unsigned int v5; // edx@5 | |
5964 //RenderD3D__DevInfo *v6; // ecx@5 | |
5965 bool v7; // eax@7 | |
5966 //RenderD3D *v8; // ecx@12 | |
5967 unsigned int v9; // eax@12 | |
5968 RenderD3D *v10; // eax@24 | |
5969 HRESULT v11; // eax@24 | |
5970 int v12; // eax@24 | |
5971 int v13; // eax@26 | |
5972 bool v14; // eax@32 | |
5973 char v15; // zf@32 | |
5974 IDirectDraw4 *v16; // eax@35 | |
5975 HRESULT v17; // eax@35 | |
5976 int *v18; // eax@36 | |
5977 int *v19; // edx@38 | |
5978 int v20; // eax@38 | |
5979 unsigned int v21; // ecx@38 | |
5980 int v22; // eax@41 | |
5981 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
5982 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
5983 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
5984 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
5985 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
5986 int v29; // [sp+308h] [bp-4h]@2 | |
5987 | |
5988 pParty->uFlags |= 2u; | |
5989 //v2 = this; | |
5990 flt_6BE3A0 = 0.55000001f; | |
5991 pViewport->_4C02F8(36044); | |
5992 field_40110 = 0; | |
5993 Release(); | |
5994 pColorKeySurface4 = 0; | |
5995 pBackBuffer4 = 0; | |
5996 pFrontBuffer4 = 0; | |
5997 pDirectDraw4 = 0; | |
5998 bColorKeySupported = 0; | |
5999 CreateZBuffer(); | |
6000 if ( bUserDirect3D ) | |
6001 { | |
6002 /*v3 = operator new(0x148u); | |
6003 thisa = (RenderD3D *)v3; | |
6004 v29 = 0; | |
6005 if ( v3 ) | |
6006 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
6007 else | |
6008 v4 = 0;*/ | |
6009 pRenderD3D = new RenderD3D; | |
6010 //v4 = pRenderD3D; | |
6011 //v5 = uDesiredDirect3DDevice; | |
6012 v29 = -1; | |
6013 //v6 = pRenderD3D->pAvailableDevices; | |
6014 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
6015 uDesiredDirect3DDevice != 1 ) | |
6016 { | |
6017 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, hWnd); | |
6018 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
6019 } | |
6020 else | |
6021 { | |
6022 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
6023 Abortf("There aren't any D3D devices to init."); | |
6024 v7 = pRenderD3D->CreateDevice(0, 1, hWnd); | |
6025 uAcquiredDirect3DDevice = 0; | |
6026 } | |
6027 if ( !v7 ) | |
6028 Abortf("D3Drend->Init failed."); | |
6029 | |
6030 //v8 = pRenderD3D; | |
6031 pColorKeySurface4 = 0; | |
6032 pBackBuffer4 = pRenderD3D->pBackBuffer; | |
6033 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
6034 pDirectDraw4 = pRenderD3D->pHost; | |
6035 v9 = pRenderD3D->GetDeviceCaps(); | |
6036 if ( v9 & 1 ) | |
6037 { | |
6038 if (pRenderD3D) | |
6039 { | |
6040 pRenderD3D->Release(); | |
6041 delete pRenderD3D; | |
6042 } | |
6043 pRenderD3D = 0; | |
6044 pBackBuffer4 = 0; | |
6045 pFrontBuffer4 = 0; | |
6046 pDirectDraw4 = 0; | |
6047 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
6048 } | |
6049 if ( v9 & 0x3E ) | |
6050 { | |
6051 if (pRenderD3D) | |
6052 { | |
6053 pRenderD3D->Release(); | |
6054 delete pRenderD3D; | |
6055 } | |
6056 pColorKeySurface4 = 0; | |
6057 pRenderD3D = 0; | |
6058 pBackBuffer4 = 0; | |
6059 pFrontBuffer4 = 0; | |
6060 pDirectDraw4 = 0; | |
6061 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
6062 } | |
6063 if ( (v9 & 0x80u) != 0 ) | |
6064 { | |
6065 if (pRenderD3D) | |
6066 { | |
6067 pRenderD3D->Release(); | |
6068 delete pRenderD3D; | |
6069 } | |
6070 pRenderD3D = 0; | |
6071 pBackBuffer4 = 0; | |
6072 pFrontBuffer4 = 0; | |
6073 pDirectDraw4 = 0; | |
6074 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
6075 } | |
6076 LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; | |
6077 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
6078 memset(&halCaps, 0, 0xFCu); | |
6079 halCaps.dwSize = 252; | |
6080 memset(&refCaps, 0, 0xFCu); | |
6081 //v10 = v2->pRenderD3D; | |
6082 refCaps.dwSize = 252; | |
6083 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
6084 v12 = halCaps.dwMinTextureWidth; | |
6085 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
6086 v12 = halCaps.dwMinTextureHeight; | |
6087 uMinDeviceTextureDim = v12; | |
6088 v13 = halCaps.dwMaxTextureWidth; | |
6089 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
6090 v13 = halCaps.dwMaxTextureHeight; | |
6091 uMaxDeviceTextureDim = v13; | |
6092 CreateSomeTexture(); | |
6093 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
6094 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
6095 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
6096 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
6097 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
6098 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
6099 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
6100 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
6101 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
6102 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
6103 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
6104 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
6105 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
6106 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
6107 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
6108 } | |
6109 else | |
6110 { | |
6111 CreateDirectDraw(); | |
6112 SetDirectDrawCooperationMode(hWnd, 0); | |
6113 field_4004C = 1; | |
6114 CreateFrontBuffer(); | |
6115 CreateClipper(hWnd); | |
6116 CreateBackBuffer(); | |
6117 field_40030 = 0; | |
6118 field_18_locked_pitch = 0; | |
6119 } | |
6120 ddpfPrimareSuface.dwSize = 32; | |
6121 GetTargetPixelFormat(&ddpfPrimareSuface); | |
6122 ParseTargetPixelFormat(); | |
6123 _49EBF1(); | |
6124 if ( !pRenderD3D ) | |
6125 { | |
6126 pBeforePresentFunction = 0;//nullsub_1; | |
6127 goto LABEL_47; | |
6128 } | |
6129 v14 = IsColorKeySupported(pDirectDraw4); | |
6130 v15 = uAcquiredDirect3DDevice == 1; | |
6131 bColorKeySupported = v14; | |
6132 if ( !v15 ) | |
6133 bColorKeySupported = 0; | |
6134 if ( bColorKeySupported ) | |
6135 { | |
6136 memset(&ddsd2, 0, 0x7Cu); | |
6137 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
6138 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
6139 v16 = pDirectDraw4; | |
6140 ddsd2.dwSize = 124; | |
6141 ddsd2.dwFlags = 65543; | |
6142 ddsd2.ddsCaps.dwCaps = 2112; | |
6143 ddsd2.dwWidth = 640; | |
6144 ddsd2.dwHeight = 480; | |
6145 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
6146 pBeforePresentFunction = Present_ColorKey; | |
6147 LABEL_45: | |
6148 field_40110 = 1; | |
6149 LABEL_47: | |
6150 bWindowMode = 1; | |
6151 hWnd = hWnd; | |
6152 return 0; | |
6153 } | |
6154 pTargetSurface = 0; | |
6155 ptr_400E8 = 0; | |
6156 v18 = (int *)new char[0x96020]; | |
6157 memset(v18, -1, 0x96020); | |
6158 ptr_400E8 = v18; | |
6159 if ( v18 ) | |
6160 { | |
6161 memset(&pDesc, 0, 0x7Cu); | |
6162 pDesc.dwSize = 124; | |
168 | 6163 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT) ) |
0 | 6164 { |
6165 pRenderer->pBackBuffer4->Unlock(0); | |
6166 v19 = ptr_400E8; | |
6167 v20 = (unsigned int)pDesc.lpSurface & 7; | |
6168 v21 = (unsigned int)ptr_400E8 & 7; | |
6169 if ( v21 == v20 ) | |
6170 { | |
6171 pTargetSurface = (unsigned __int16 *)v19; | |
6172 } | |
6173 else | |
6174 { | |
6175 if ( (signed int)v21 >= v20 ) | |
6176 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
6177 else | |
6178 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
6179 pTargetSurface = (unsigned __int16 *)v22; | |
6180 } | |
6181 uTargetSurfacePitch = 640; | |
6182 pBeforePresentFunction = Present_NoColorKey; | |
6183 goto LABEL_45; | |
6184 } | |
6185 } | |
6186 return 0; | |
6187 } | |
6188 | |
6189 //----- (004A0BEE) -------------------------------------------------------- | |
709 | 6190 char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor) |
0 | 6191 { |
6192 int v6; // edi@1 | |
6193 int v7; // edx@5 | |
6194 unsigned int v8; // ebx@5 | |
6195 int v9; // eax@7 | |
6196 unsigned int v10; // ecx@9 | |
6197 unsigned int v11; // esi@13 | |
6198 int v12; // eax@17 | |
6199 int v13; // eax@21 | |
6200 Render *v14; // edi@21 | |
6201 int v15; // eax@25 | |
6202 int v16; // eax@27 | |
6203 signed int v17; // eax@28 | |
6204 signed int v18; // edi@30 | |
6205 signed __int64 v19; // qax@41 | |
6206 int v20; // edi@41 | |
6207 unsigned int v21; // edi@46 | |
6208 int v22; // esi@47 | |
6209 int v23; // ebx@47 | |
6210 signed int v24; // edx@50 | |
6211 signed int v25; // esi@52 | |
6212 unsigned __int16 *v26; // ecx@52 | |
6213 int v27; // ebx@54 | |
6214 int v28; // edi@55 | |
6215 int v29; // edx@55 | |
6216 int v30; // ebx@60 | |
6217 int v31; // edx@61 | |
6218 int v32; // edi@61 | |
6219 int v34; // [sp+Ch] [bp-10h]@3 | |
6220 Render *v35; // [sp+10h] [bp-Ch]@1 | |
6221 __int64 v36; // [sp+14h] [bp-8h]@1 | |
6222 signed int v37; // [sp+18h] [bp-4h]@28 | |
6223 unsigned int uXa; // [sp+24h] [bp+8h]@49 | |
6224 unsigned int uYa; // [sp+28h] [bp+Ch]@28 | |
6225 int uYb; // [sp+28h] [bp+Ch]@47 | |
6226 int uZa; // [sp+2Ch] [bp+10h]@38 | |
6227 | |
6228 v36 = 0i64; | |
709 | 6229 v6 = this->raster_clip_x; |
0 | 6230 v35 = this; |
6231 if ( (signed int)uX < v6 ) | |
6232 HIDWORD(v36) = 8; | |
709 | 6233 v34 = this->raster_clip_z; |
6234 if ( (signed int)uX > this->raster_clip_z ) | |
0 | 6235 HIDWORD(v36) |= 4u; |
709 | 6236 v7 = this->raster_clip_y; |
0 | 6237 v8 = uY; |
6238 if ( (signed int)uY < v7 ) | |
6239 HIDWORD(v36) |= 2u; | |
709 | 6240 v9 = this->raster_clip_w; |
0 | 6241 if ( (signed int)uY > v9 ) |
6242 HIDWORD(v36) |= 1u; | |
6243 v10 = uZ; | |
6244 if ( (signed int)uZ < v6 ) | |
6245 LODWORD(v36) = 8; | |
6246 if ( (signed int)uZ > v34 ) | |
6247 LODWORD(v36) = v36 | 4; | |
6248 v11 = uW; | |
6249 if ( (signed int)uW < v7 ) | |
6250 LODWORD(v36) = v36 | 2; | |
6251 if ( (signed int)uW > v9 ) | |
6252 LODWORD(v36) = v36 | 1; | |
6253 LOBYTE(v12) = v36; | |
6254 if ( (unsigned int)v36 & HIDWORD(v36) ) | |
6255 return v12; | |
6256 if ( !v36 ) | |
6257 { | |
6258 LABEL_46: | |
6259 v21 = pRenderer->uTargetSurfacePitch; | |
6260 if ( pRenderer->uTargetSurfacePitch ) | |
6261 { | |
6262 v12 = uX + v8 * pRenderer->uTargetSurfacePitch; | |
6263 v22 = v11 - v8; | |
6264 v23 = v22; | |
6265 uYb = v22; | |
6266 if ( v22 < 0 ) | |
6267 { | |
6268 v23 = -v22; | |
6269 uYb = -v22; | |
6270 v21 = -pRenderer->uTargetSurfacePitch; | |
6271 } | |
6272 uXa = v10 - uX; | |
6273 if ( (uXa & 0x80000000u) == 0 ) | |
6274 { | |
6275 v24 = 1; | |
6276 } | |
6277 else | |
6278 { | |
6279 uXa = -uXa; | |
6280 v24 = -1; | |
6281 } | |
6282 v25 = 0; | |
6283 v26 = v35->pTargetSurface; | |
6284 if ( v26 ) | |
6285 { | |
6286 if ( (signed int)uXa <= v23 ) | |
6287 { | |
6288 v30 = v23 + 1; | |
6289 if ( v30 > 0 ) | |
6290 { | |
6291 v31 = 2 * v24; | |
6292 v32 = 2 * v21; | |
6293 v12 = (int)&v26[v12]; | |
6294 do | |
6295 { | |
6296 v25 += uXa; | |
6297 *(short *)v12 = uColor; | |
6298 v12 += v32; | |
6299 if ( v25 > 0 ) | |
6300 { | |
6301 v25 -= uYb; | |
6302 v12 += v31; | |
6303 } | |
6304 --v30; | |
6305 } | |
6306 while ( v30 ); | |
6307 } | |
6308 } | |
6309 else | |
6310 { | |
6311 v27 = uXa + 1; | |
6312 if ( (signed int)(uXa + 1) > 0 ) | |
6313 { | |
6314 v28 = 2 * v21; | |
6315 v29 = 2 * v24; | |
6316 v12 = (int)&v26[v12]; | |
6317 do | |
6318 { | |
6319 v25 += uYb; | |
6320 *(short *)v12 = uColor; | |
6321 v12 += v29; | |
6322 if ( v25 > (signed int)uXa ) | |
6323 { | |
6324 v25 -= uXa; | |
6325 v12 += v28; | |
6326 } | |
6327 --v27; | |
6328 } | |
6329 while ( v27 ); | |
6330 } | |
6331 } | |
6332 } | |
6333 } | |
6334 return v12; | |
6335 } | |
6336 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 ) | |
6337 { | |
6338 if ( BYTE4(v36) & 8 ) | |
6339 { | |
6340 v13 = (signed int)((uW - uY) * (v6 - uX)) / (signed int)(uZ - uX); | |
6341 v14 = v35; | |
6342 v8 = v13 + uY; | |
709 | 6343 uX = v35->raster_clip_x; |
0 | 6344 goto LABEL_24; |
6345 } | |
6346 v10 = v6; | |
6347 v11 = (signed int)((uY - uW) * (v6 - uZ)) / (signed int)(uX - uZ) + uW; | |
6348 } | |
6349 v14 = v35; | |
6350 LABEL_24: | |
6351 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) | |
6352 { | |
709 | 6353 v15 = v14->raster_clip_z; |
0 | 6354 if ( BYTE4(v36) & 4 ) |
6355 { | |
6356 v14 = v35; | |
6357 v8 += (signed int)((v11 - v8) * (v15 - uX)) / (signed int)(v10 - uX); | |
709 | 6358 uX = v35->raster_clip_z; |
0 | 6359 } |
6360 else | |
6361 { | |
6362 v16 = (signed int)((v8 - v11) * (v15 - v10)) / (signed int)(uX - v10); | |
709 | 6363 v10 = v14->raster_clip_z; |
0 | 6364 v11 += v16; |
6365 } | |
6366 } | |
709 | 6367 v17 = v14->raster_clip_y; |
0 | 6368 v37 = 0; |
709 | 6369 uYa = v14->raster_clip_y; |
0 | 6370 if ( (signed int)v8 < v17 ) |
6371 v37 = 2; | |
709 | 6372 v18 = v14->raster_clip_w; |
0 | 6373 if ( (signed int)v8 > v18 ) |
6374 v37 |= 1u; | |
6375 if ( (signed int)v11 >= v17 ) | |
6376 v12 = 0; | |
6377 else | |
6378 v12 = 2; | |
6379 if ( (signed int)v11 > v18 ) | |
6380 LOBYTE(v12) = v12 | 1; | |
6381 if ( !(v12 & v37) ) | |
6382 { | |
6383 v12 ^= v37; | |
6384 uZa = v12; | |
6385 if ( v12 & 2 ) | |
6386 { | |
6387 if ( v37 & 2 ) | |
6388 { | |
6389 uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8); | |
6390 LOBYTE(v12) = (char)v35; | |
709 | 6391 v8 = v35->raster_clip_y; |
0 | 6392 } |
6393 else | |
6394 { | |
6395 v19 = (signed int)((uX - v10) * (uYa - v11)); | |
6396 v20 = v8 - v11; | |
6397 v11 = uYa; | |
6398 v12 = v19 / v20; | |
6399 v10 += v12; | |
6400 } | |
6401 } | |
6402 if ( uZa & 1 ) | |
6403 { | |
6404 if ( v37 & 1 ) | |
6405 { | |
709 | 6406 uX += (signed int)((v10 - uX) * (v35->raster_clip_w - v8)) / (signed int)(v11 - v8); |
0 | 6407 LOBYTE(v12) = (char)v35; |
709 | 6408 v8 = v35->raster_clip_w; |
0 | 6409 } |
6410 else | |
6411 { | |
709 | 6412 v12 = (signed int)((uX - v10) * (v35->raster_clip_w - v11)) / (signed int)(v8 - v11); |
6413 v11 = v35->raster_clip_w; | |
0 | 6414 v10 += v12; |
6415 } | |
6416 } | |
6417 goto LABEL_46; | |
6418 } | |
6419 return v12; | |
6420 } | |
6421 | |
6422 //----- (004A0E80) -------------------------------------------------------- | |
6423 void Render::ClearZBuffer(int a2, int a3) | |
6424 { | |
6425 memset32(this->pActiveZBuffer, -65536, 0x4B000u); | |
6426 } | |
6427 | |
6428 //----- (004A0E97) -------------------------------------------------------- | |
709 | 6429 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
6430 { | |
6431 this->raster_clip_x = uX; | |
6432 this->raster_clip_y = uY; | |
6433 this->raster_clip_z = uZ; | |
6434 this->raster_clip_w = uW; | |
0 | 6435 } |
6436 | |
6437 //----- (004A0EB6) -------------------------------------------------------- | |
6438 void Render::ParseTargetPixelFormat() | |
6439 { | |
6440 Render *v1; // eax@1 | |
6441 signed int v2; // ecx@1 | |
6442 DWORD uRedMask; // edx@1 | |
6443 unsigned int uGreenMask; // esi@5 | |
6444 signed int v5; // ecx@5 | |
6445 unsigned int uBlueMask; // edx@9 | |
6446 signed int v7; // ecx@9 | |
6447 unsigned int v8; // ecx@13 | |
6448 | |
6449 v1 = this; | |
6450 v2 = 0; | |
6451 uRedMask = v1->ddpfPrimareSuface.dwRBitMask; | |
6452 v1->uTargetBBits = 0; | |
6453 v1->uTargetGBits = 0; | |
6454 v1->uTargetRBits = 0; | |
6455 do | |
6456 { | |
6457 if ( (1 << v2) & uRedMask ) | |
6458 ++v1->uTargetRBits; | |
6459 ++v2; | |
6460 } | |
6461 while ( v2 < 16 ); | |
6462 uGreenMask = v1->ddpfPrimareSuface.dwGBitMask; | |
6463 v5 = 0; | |
6464 do | |
6465 { | |
6466 if ( (1 << v5) & uGreenMask ) | |
6467 ++v1->uTargetGBits; | |
6468 ++v5; | |
6469 } | |
6470 while ( v5 < 16 ); | |
6471 uBlueMask = v1->ddpfPrimareSuface.dwBBitMask; | |
6472 v7 = 0; | |
6473 do | |
6474 { | |
6475 if ( (1 << v7) & uBlueMask ) | |
6476 ++v1->uTargetBBits; | |
6477 ++v7; | |
6478 } | |
6479 while ( v7 < 16 ); | |
6480 v8 = v1->ddpfPrimareSuface.dwRBitMask; | |
6481 v1->uTargetGMask = uGreenMask; | |
6482 v1->uTargetRMask = v8; | |
6483 v1->uTargetBMask = uBlueMask; | |
6484 } | |
6485 | |
6486 //----- (004A0F40) -------------------------------------------------------- | |
6487 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
6488 { | |
6489 IDirectDrawSurface4 *v4; // esi@1 | |
168 | 6490 HRESULT result; // eax@1 |
0 | 6491 HRESULT v6; // eax@4 |
6492 int v7; // [sp-8h] [bp-14h]@10 | |
6493 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
6494 char v9; // [sp+Bh] [bp-1h]@1 | |
6495 | |
6496 v4 = pSurface; | |
6497 v9 = 1; | |
6498 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
6499 if ( result == DDERR_SURFACELOST ) | |
6500 { | |
6501 if (pAsyncMouse) | |
6502 pAsyncMouse->Suspend(); | |
6503 v6 = v4->Restore(); | |
6504 if ( v6 ) | |
6505 { | |
6506 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
6507 { | |
6508 LABEL_20: | |
6509 v9 = 0; | |
6510 result = (bool)memset(pDesc, 0, 4u); | |
6511 goto LABEL_21; | |
6512 } | |
6513 pRenderer->pFrontBuffer4->Restore(); | |
6514 v4->Restore(); | |
6515 } | |
6516 result = v4->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
6517 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
6518 goto LABEL_20; | |
6519 ErrD3D(result); | |
6520 if ( result ) | |
6521 { | |
6522 //v8 = 0; | |
6523 //v7 = 2161; | |
6524 LABEL_19: | |
6525 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
6526 goto LABEL_20; | |
6527 } | |
6528 if ( pRenderer->pRenderD3D ) | |
6529 pRenderD3D->HandleLostResources(); | |
6530 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
6531 if (pAsyncMouse) | |
6532 pAsyncMouse->Resume(); | |
6533 } | |
6534 else | |
6535 { | |
6536 if ( result ) | |
6537 { | |
6538 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
6539 goto LABEL_20; | |
6540 ErrD3D(result); | |
6541 //v8 = 0; | |
6542 //v7 = 2199; | |
6543 //goto LABEL_19; | |
6544 } | |
6545 } | |
6546 LABEL_21: | |
6547 LOBYTE(result) = v9; | |
6548 return result; | |
6549 } | |
6550 | |
6551 //----- (004A1032) -------------------------------------------------------- | |
6552 bool Render::LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags) | |
6553 { | |
6554 IDirectDrawSurface2 *v4; // esi@1 | |
6555 bool v5; // eax@1 | |
6556 HRESULT v6; // eax@2 | |
6557 int v7; // [sp-8h] [bp-10h]@8 | |
6558 unsigned int v8; // [sp-4h] [bp-Ch]@8 | |
6559 | |
6560 v4 = pSurface; | |
6561 v5 = pSurface->Lock( | |
6562 0, | |
6563 pDesc, | |
6564 uLockFlags, | |
6565 0); | |
6566 BYTE3(pSurface) = 1; | |
6567 if ( v5 == DDERR_SURFACELOST ) | |
6568 { | |
6569 v6 = v4->Restore(); | |
6570 if ( !v6 ) | |
6571 goto LABEL_5; | |
6572 if ( v6 == DDERR_IMPLICITLYCREATED ) | |
6573 { | |
6574 pRenderer->pFrontBuffer2->Restore(); | |
6575 v4->Restore(); | |
6576 LABEL_5: | |
6577 v5 = v4->Lock(0, pDesc, 1u, 0) != 0; | |
6578 if ( v5 == DDERR_INVALIDRECT || v5 == DDERR_SURFACEBUSY ) | |
6579 goto LABEL_14; | |
6580 if ( !v5 ) | |
6581 return true; | |
6582 ErrD3D(v5); | |
6583 //v8 = 0; | |
6584 //v7 = 2247; | |
6585 goto LABEL_13; | |
6586 } | |
6587 else | |
6588 { | |
6589 pDesc->dwSize = 0; | |
6590 return false; | |
6591 } | |
6592 } | |
6593 else | |
6594 { | |
6595 if ( !v5 ) | |
6596 return true; | |
6597 if ( v5 != DDERR_INVALIDRECT && v5 != DDERR_SURFACEBUSY ) | |
6598 { | |
6599 //v8 = 0; | |
6600 //v7 = 2269; | |
6601 ErrD3D(v5); | |
6602 pDesc->dwSize = 0; | |
6603 return false; | |
6604 LABEL_13: | |
6605 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, v5, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
6606 goto LABEL_14; | |
6607 } | |
6608 } | |
6609 LABEL_14: | |
6610 return true; | |
6611 } | |
6612 | |
6613 //----- (004A10E4) -------------------------------------------------------- | |
6614 void Render::CreateDirectDraw() | |
6615 { | |
6616 Render *v1; // edi@1 | |
6617 HRESULT v2; // eax@1 | |
6618 HRESULT v3; // eax@5 | |
6619 int v6; // [sp-Ch] [bp-20h]@3 | |
6620 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
6621 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
6622 | |
6623 v1 = this; | |
6624 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
6625 | |
6626 pDirectDraw2 = nullptr; | |
6627 pDirectDraw4 = nullptr; | |
6628 | |
6629 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6630 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); | |
6631 else | |
6632 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); | |
6633 | |
6634 lpDD->Release(); | |
6635 lpDD = nullptr; | |
6636 } | |
6637 | |
6638 //----- (004A1169) -------------------------------------------------------- | |
6639 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
6640 { | |
6641 DWORD flags; // eax@1 | |
6642 IDirectDraw *v4; // ecx@3 | |
6643 HRESULT v5; // eax@5 | |
6644 int v6; // [sp-8h] [bp-8h]@3 | |
6645 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
6646 | |
6647 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
6648 DDSCL_NORMAL; | |
6649 | |
6650 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6651 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); | |
6652 else | |
6653 ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); | |
6654 } | |
6655 | |
6656 //----- (004A11C6) -------------------------------------------------------- | |
6657 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
6658 { | |
6659 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6660 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
6661 else | |
6662 ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
6663 } | |
6664 | |
6665 //----- (004A121C) -------------------------------------------------------- | |
6666 void Render::CreateFrontBuffer() | |
6667 { | |
6668 Render *v1; // esi@1 | |
6669 IDirectDraw *pDD; // eax@3 | |
6670 IDirectDrawSurface **pOutSurf; // esi@3 | |
6671 struct _DDSURFACEDESC *v4; // edx@3 | |
6672 HRESULT v5; // eax@5 | |
6673 int v6; // [sp-8h] [bp-8Ch]@3 | |
6674 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
6675 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
6676 | |
6677 v1 = this; | |
6678 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6679 { | |
6680 memset(&a2, 0, 0x7Cu); | |
6681 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
6682 a2.dwSize = 124; | |
6683 a2.dwFlags = 1; | |
6684 v7 = 0; | |
6685 a2.ddsCaps.dwCaps = 512; | |
6686 v6 = 2357; | |
6687 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
6688 v4 = (struct _DDSURFACEDESC *)&a2; | |
6689 } | |
6690 else | |
6691 { | |
6692 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
6693 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
6694 a2.lPitch = 108; | |
6695 a2.dwBackBufferCount = 1; | |
6696 v7 = 0; | |
6697 a2.dwTextureStage = 512; | |
6698 v6 = 2346; | |
6699 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
6700 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
6701 } | |
6702 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); | |
6703 } | |
6704 | |
6705 //----- (004A12CD) -------------------------------------------------------- | |
6706 void Render::CreateBackBuffer() | |
6707 { | |
6708 Render *v1; // esi@1 | |
6709 IDirectDraw *v2; // eax@3 | |
6710 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
6711 struct _DDSURFACEDESC *v4; // edx@3 | |
6712 HRESULT v5; // eax@5 | |
6713 int v6; // [sp-8h] [bp-8Ch]@3 | |
6714 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
6715 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
6716 | |
6717 v1 = this; | |
6718 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6719 { | |
6720 memset(&a2, 0, 0x7Cu); | |
6721 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
6722 a2.dwSize = 124; | |
6723 a2.dwFlags = 7; | |
6724 v7 = 0; | |
6725 a2.ddsCaps.dwCaps = 2112; | |
6726 a2.dwWidth = 640; | |
6727 a2.dwHeight = 480; | |
6728 v6 = 2387; | |
6729 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
6730 v4 = (struct _DDSURFACEDESC *)&a2; | |
6731 } | |
6732 else | |
6733 { | |
6734 memset(&a2.lPitch, 0, 0x6Cu); | |
6735 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
6736 a2.lPitch = 108; | |
6737 a2.dwBackBufferCount = 7; | |
6738 v7 = 0; | |
6739 a2.dwTextureStage = 2112; | |
6740 a2.dwAlphaBitDepth = 640; | |
6741 a2.dwMipMapCount = 480; | |
6742 v6 = 2374; | |
6743 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
6744 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
6745 } | |
6746 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); | |
6747 } | |
6748 | |
6749 //----- (004A139A) -------------------------------------------------------- | |
6750 void Render::CreateDirectDrawPrimarySurface() | |
6751 { | |
6752 Render *v1; // esi@1 | |
6753 int v2; // ebx@3 | |
6754 IDirectDraw2 *v3; // eax@3 | |
6755 HRESULT v4; // eax@3 | |
6756 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
6757 DDSCAPS2 *v6; // edx@3 | |
6758 IDirectDraw4 *v7; // eax@4 | |
6759 HRESULT v8; // eax@4 | |
6760 int v9; // ST14_4@5 | |
6761 IDirectDrawSurface *v10; // ST10_4@5 | |
6762 HRESULT v11; // eax@5 | |
6763 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
6764 const char *v13; // [sp+0h] [bp-A0h]@0 | |
6765 int v14; // [sp+4h] [bp-9Ch]@0 | |
6766 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
6767 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
6768 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
6769 int a4; // [sp+98h] [bp-8h]@3 | |
6770 | |
6771 v1 = this; | |
6772 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6773 { | |
6774 v2 = 0; | |
6775 this->field_4004C = 1; | |
6776 memset(&ddsd2, 0, 0x7Cu); | |
6777 v7 = v1->pDirectDraw4; | |
6778 ddsd2.dwBackBufferCount = 1; | |
6779 ddsd2.dwSize = 0x7Cu; | |
6780 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
6781 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
6782 ErrD3D(v7->CreateSurface( | |
6783 &ddsd2, | |
6784 &pFrontBuffer4, | |
6785 0)); | |
6786 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
6787 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
6788 } | |
6789 else | |
6790 { | |
6791 v2 = 0; | |
6792 this->field_4004C = 1; | |
6793 | |
6794 DDSURFACEDESC ddsd; | |
6795 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
6796 | |
6797 ddsd.lpSurface = (LPVOID)1; | |
6798 ddsd.lPitch = 108; | |
6799 ddsd.dwBackBufferCount = 33; | |
6800 ddsd.ddsCaps.dwCaps = 8728; | |
6801 ErrD3D(pDirectDraw2->CreateSurface( | |
6802 &ddsd, | |
6803 (IDirectDrawSurface **)&pFrontBuffer2, | |
6804 0)); | |
6805 | |
6806 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
6807 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
6808 } | |
6809 v9 = (int)v6; | |
6810 v10 = pFrontBuffer; // BUG | |
6811 | |
6812 v17.dwCaps = 4; | |
6813 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
6814 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
6815 v1->field_40030 = v2; | |
6816 v1->field_18_locked_pitch = v2; | |
6817 } | |
6818 | |
6819 //----- (004A14F4) -------------------------------------------------------- | |
6820 void Render::CreateClipper(HWND a2) | |
6821 { | |
6822 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6823 { | |
6824 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); | |
6825 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
6826 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
6827 } | |
6828 else | |
6829 { | |
6830 ErrD3D(pDirectDraw2->CreateClipper(0, &pDDrawClipper, 0)); | |
6831 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
6832 } | |
6833 } | |
6834 | |
6835 //----- (004A15D8) -------------------------------------------------------- | |
6836 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
6837 { | |
6838 IDirectDrawSurface *v2; // eax@3 | |
6839 | |
6840 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6841 v2 = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6842 else | |
6843 v2 = (IDirectDrawSurface *)this->pFrontBuffer2; | |
6844 v2->GetPixelFormat(pOut); | |
6845 } | |
6846 | |
6847 //----- (004A1605) -------------------------------------------------------- | |
6848 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
6849 { | |
6850 Render *v3; // esi@1 | |
6851 signed int v4; // eax@3 | |
6852 | |
6853 v3 = this; | |
6854 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6855 { | |
6856 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
6857 memset(&pDesc, 0, 0x7Cu); | |
6858 pDesc.dwSize = 124; | |
168 | 6859 LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 6860 *pOutSurfacePtr = pDesc.lpSurface; |
6861 v4 = pDesc.lPitch; | |
6862 } | |
6863 else | |
6864 { | |
6865 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
6866 memset(&pDesc.lPitch, 0, 0x6Cu); | |
6867 pDesc.lPitch = 108; | |
6868 LockSurface_DDraw2(v3->pBackBuffer2, &pDesc, 1u); | |
6869 *pOutSurfacePtr = (void *)pDesc.lpSurface; | |
6870 v4 = pDesc.dwReserved; | |
6871 } | |
6872 *pOutPixelsPerRow = v4 >> 1; | |
6873 } | |
6874 | |
6875 //----- (004A169E) -------------------------------------------------------- | |
6876 bool Render::UsingDirect3D() | |
6877 { | |
6878 return bUserDirect3D == 0; | |
6879 } | |
6880 | |
6881 //----- (004A16E1) -------------------------------------------------------- | |
6882 void Render::UnlockBackBuffer() | |
6883 { | |
6884 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6885 ErrD3D(pBackBuffer4->Unlock(0)); | |
6886 else | |
6887 ErrD3D(pBackBuffer2->Unlock(0)); | |
6888 } | |
6889 | |
6890 //----- (004A172E) -------------------------------------------------------- | |
6891 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
6892 { | |
6893 Render *v3; // esi@1 | |
6894 signed int v4; // eax@3 | |
6895 | |
6896 v3 = this; | |
6897 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6898 { | |
6899 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
6900 memset(&pDesc, 0, 0x7Cu); | |
6901 pDesc.dwSize = 124; | |
168 | 6902 LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 6903 *pOutSurface = pDesc.lpSurface; |
6904 v4 = pDesc.lPitch; | |
6905 } | |
6906 else | |
6907 { | |
6908 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
6909 memset(&pDesc.lPitch, 0, 0x6Cu); | |
6910 pDesc.lPitch = 108; | |
6911 LockSurface_DDraw2(v3->pFrontBuffer2, &pDesc, 1u); | |
6912 *pOutSurface = (void *)pDesc.lpSurface; | |
6913 v4 = pDesc.dwReserved; | |
6914 } | |
6915 *pOutPixelsPerRow = v4 >> 1; | |
6916 } | |
6917 | |
6918 //----- (004A17C7) -------------------------------------------------------- | |
6919 void Render::UnlockFrontBuffer() | |
6920 { | |
6921 IDirectDrawSurface *pFront; // eax@3 | |
6922 HRESULT v2; // eax@5 | |
6923 signed int v3; // [sp-8h] [bp-Ch]@3 | |
6924 int v4; // [sp-4h] [bp-8h]@3 | |
6925 | |
6926 auto a5 = this; | |
6927 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6928 { | |
6929 pFront = (IDirectDrawSurface *)a5->pFrontBuffer4; | |
6930 v4 = 0; | |
6931 v3 = 2615; | |
6932 } | |
6933 else | |
6934 { | |
6935 pFront = (IDirectDrawSurface *)a5->pFrontBuffer2; | |
6936 v4 = 0; | |
6937 v3 = 2611; | |
6938 } | |
6939 ErrD3D(pFront->Unlock(0)); | |
6940 } | |
6941 | |
6942 //----- (004A1814) -------------------------------------------------------- | |
6943 void Render::RestoreFrontBuffer() | |
6944 { | |
6945 IDirectDrawSurface **v1; // esi@2 | |
6946 | |
6947 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
6948 || (v1 = (IDirectDrawSurface **)&this->pFrontBuffer2, pVersion->pVersionInfo.dwMajorVersion >= 5u) ) | |
6949 v1 = (IDirectDrawSurface **)&this->pFrontBuffer4; | |
6950 if ( (*v1)->IsLost() == DDERR_SURFACELOST ) | |
6951 (*v1)->Restore(); | |
6952 } | |
6953 | |
6954 //----- (004A184C) -------------------------------------------------------- | |
6955 HRESULT Render::_4A184C() | |
6956 { | |
6957 IDirectDrawSurface **pBack; // esi@2 | |
6958 HRESULT result; // eax@4 | |
6959 | |
6960 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
6961 || (pBack = (IDirectDrawSurface **)&this->pBackBuffer2, pVersion->pVersionInfo.dwMajorVersion != 4) ) | |
6962 pBack = (IDirectDrawSurface **)&this->pBackBuffer4; | |
6963 result = (*pBack)->IsLost(); | |
6964 if ( result == DDERR_SURFACELOST ) | |
6965 result = (*pBack)->Restore(); | |
6966 return result; | |
6967 } | |
6968 | |
6969 //----- (004A1884) -------------------------------------------------------- | |
6970 void Render::PresentRect(RECT *a2, RECT *a3) | |
6971 { | |
6972 IDirectDrawSurface *pFront; // eax@3 | |
6973 HRESULT v4; // eax@5 | |
6974 IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3 | |
6975 struct tagRECT *v6; // [sp-18h] [bp-18h]@3 | |
6976 DWORD v7; // [sp-14h] [bp-14h]@3 | |
6977 DDBLTFX *v8; // [sp-10h] [bp-10h]@3 | |
6978 const char *v9; // [sp-Ch] [bp-Ch]@3 | |
6979 int v10; // [sp-8h] [bp-8h]@3 | |
6980 unsigned int v11; // [sp-4h] [bp-4h]@3 | |
6981 | |
6982 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6983 { | |
6984 v11 = 0; | |
6985 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6986 v10 = 2657; | |
6987 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
6988 v8 = 0; | |
6989 v7 = DDBLT_WAIT; | |
6990 v6 = a3; | |
6991 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
6992 } | |
6993 else | |
6994 { | |
6995 v11 = 0; | |
6996 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
6997 v10 = 2653; | |
6998 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
6999 v8 = 0; | |
7000 v7 = DDBLT_WAIT; | |
7001 v6 = a3; | |
7002 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
7003 } | |
7004 ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8)); | |
7005 } | |
7006 | |
7007 //----- (004A18F5) -------------------------------------------------------- | |
7008 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
7009 { | |
7010 IDirectDrawSurface *pFront; // eax@3 | |
7011 HRESULT v6; // eax@5 | |
7012 int v7; // [sp-8h] [bp-8h]@3 | |
7013 unsigned int v8; // [sp-4h] [bp-4h]@3 | |
7014 | |
7015 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) | |
7016 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
7017 else | |
7018 ErrD3D(pFrontBuffer2->Blt(pDstRect, (IDirectDrawSurface2 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
7019 } | |
7020 | |
7021 //----- (004A194A) -------------------------------------------------------- | |
7022 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
7023 { | |
7024 IDirectDrawSurface *pFront; // eax@3 | |
7025 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
7026 | |
7027 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
7028 { | |
7029 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
7030 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
7031 } | |
7032 else | |
7033 { | |
7034 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
7035 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
7036 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7037 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 7038 } |
7039 | |
7040 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7041 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7042 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7043 //unsigned int v2; // ebx@1 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7044 //double v4; // st7@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7045 //unsigned int v5; // esi@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7046 //int v6; // ecx@5 |
0 | 7047 unsigned int v7; // edx@6 |
7048 char *v8; // ecx@12 | |
7049 void *v9; // edi@16 | |
7050 unsigned int v10; // eax@16 | |
7051 void *v11; // edi@21 | |
7052 unsigned int v12; // eax@21 | |
7053 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7054 //v2 = uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7055 if (uNumBillboardsToDraw >= 999 ) |
0 | 7056 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7057 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7058 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7059 uNumBillboardsToDraw = 1; |
0 | 7060 return 0; |
7061 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7062 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7063 //v4 = *(float *)&a1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7064 //v5 = pRenderer->uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7065 //v6 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7066 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
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 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7069 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7070 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7071 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7072 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7073 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7074 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7075 v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].z_order; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7076 if (z > *(float *)v8 ) |
0 | 7077 { |
7078 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
7079 { | |
7080 v7 = pRenderer->uNumBillboardsToDraw; | |
7081 } | |
7082 else | |
7083 { | |
7084 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
7085 { | |
7086 v9 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
7087 v10 = pRenderer->uNumBillboardsToDraw - v7; | |
7088 do | |
7089 { | |
7090 memcpy(v9, (char *)v9 - 156, 0x9Cu); | |
7091 v9 = (char *)v9 - 156; | |
7092 --v10; | |
7093 } | |
7094 while ( v10 ); | |
7095 } | |
7096 ++v7; | |
7097 } | |
717 | 7098 //LABEL_23: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7099 uNumBillboardsToDraw++; |
0 | 7100 return v7; |
7101 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7102 if (z <= *(float *)v8 ) |
0 | 7103 { |
7104 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
7105 { | |
7106 v11 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
7107 v12 = pRenderer->uNumBillboardsToDraw - v7; | |
7108 do | |
7109 { | |
7110 memcpy(v11, (char *)v11 - 156, 0x9Cu); | |
7111 v11 = (char *)v11 - 156; | |
7112 --v12; | |
7113 } | |
7114 while ( v12 ); | |
7115 } | |
717 | 7116 //goto LABEL_23; |
7117 uNumBillboardsToDraw++; | |
7118 return v7; | |
0 | 7119 } |
7120 return v7; | |
7121 } | |
7122 | |
7123 //----- (004A1E9D) -------------------------------------------------------- | |
7124 unsigned int Render::GetBillboardDrawListSize() | |
7125 { | |
7126 return pRenderer->uNumBillboardsToDraw; | |
7127 } | |
7128 | |
7129 //----- (004A1EA3) -------------------------------------------------------- | |
7130 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
7131 { | |
7132 return pRenderer->pBillboardRenderListD3D[uBillboardID].uParentBillboardID; | |
7133 } | |
7134 | |
7135 //----- (004A1EB6) -------------------------------------------------------- | |
7136 void Render::BeginSceneD3D() | |
7137 { | |
7138 if (!uNumD3DSceneBegins++) | |
7139 { | |
7140 if (pRenderD3D) | |
7141 { | |
7142 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
7143 pRenderer->uNumBillboardsToDraw = 0; | |
7144 pRenderD3D->pDevice->BeginScene(); | |
7145 if (!pRenderD3D->DoesRaiseExceptions()) | |
7146 { | |
7147 MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0); | |
7148 } | |
7149 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
7150 uFogColor = GetLevelFogColor(); | |
7151 else | |
7152 uFogColor = 0; | |
7153 | |
7154 if ( uFogColor & 0xFF000000 ) | |
7155 { | |
7156 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
7157 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
7158 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
7159 bUsingSpecular = true; | |
7160 } | |
7161 else | |
7162 { | |
7163 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
7164 bUsingSpecular = 0; | |
7165 } | |
7166 } | |
7167 else | |
7168 { | |
7169 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
7170 if (pTargetSurface) | |
7171 field_18_locked_pitch = uTargetSurfacePitch; | |
7172 else | |
7173 --uNumD3DSceneBegins; | |
7174 } | |
7175 } | |
7176 } | |
7177 | |
7178 //----- (004A1FE1) -------------------------------------------------------- | |
7179 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
7180 { | |
7181 --uNumD3DSceneBegins; | |
7182 if (uNumD3DSceneBegins) | |
7183 return; | |
7184 | |
7185 if (pRenderD3D) | |
7186 { | |
7187 pGame->draw_debug_outlines(); | |
161 | 7188 DoRenderBillboards_D3D(); |
0 | 7189 pGame->pStru6Instance->RenderSpecialEffects(); |
7190 pRenderD3D->pDevice->EndScene(); | |
7191 } | |
7192 else | |
7193 pGame->pStru6Instance->RenderSpecialEffects(); | |
7194 } | |
7195 | |
7196 //----- (004A2031) -------------------------------------------------------- | |
349 | 7197 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
7198 { | |
638 | 7199 __debugbreak(); // should not fire outside decal builder |
349 | 7200 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 7201 } |
7202 | |
186 | 7203 /*void Render::DrawTerrainPolygon_new(stru148 *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 7204 { |
7205 int v5; // ebx@1 | |
7206 int v6; // edi@1 | |
7207 int v8; // eax@7 | |
7208 float v9; // eax@12 | |
7209 float *v10; // esi@12 | |
7210 float v11; // ecx@14 | |
7211 double v12; // st7@14 | |
7212 double v13; // st7@14 | |
7213 double v14; // st7@14 | |
7214 signed int v15; // eax@14 | |
7215 int v16; // eax@15 | |
7216 float v17; // ST48_4@15 | |
7217 char v18; // zf@17 | |
7218 int v19; // eax@18 | |
7219 int v20; // eax@18 | |
7220 int v21; // edx@20 | |
7221 signed int v22; // ecx@20 | |
7222 int v23; // eax@20 | |
7223 const char *v24; // ST4C_4@20 | |
7224 unsigned int v25; // ST50_4@20 | |
7225 int v26; // ST54_4@20 | |
7226 int v27; // eax@20 | |
7227 _UNKNOWN *v28; // eax@21 | |
7228 int v29; // ecx@23 | |
7229 int v30; // eax@23 | |
7230 int v31; // eax@23 | |
7231 int v32; // eax@24 | |
7232 int v33; // eax@25 | |
7233 int v34; // eax@25 | |
7234 int v35; // eax@25 | |
7235 int v36; // eax@25 | |
7236 signed int v37; // ecx@26 | |
7237 int v38; // eax@26 | |
7238 _UNKNOWN *v39; // eax@27 | |
7239 int v40; // edx@28 | |
7240 int v41; // eax@29 | |
7241 int v42; // eax@29 | |
7242 int v43; // eax@29 | |
7243 int v44; // eax@29 | |
7244 unsigned int v46; // eax@29 | |
7245 int v47; // eax@30 | |
7246 int v48; // eax@30 | |
7247 int v49; // eax@30 | |
7248 double v52; // st6@35 | |
7249 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
7250 int v57; // [sp+5Ch] [bp-Ch]@3 | |
7251 signed int v59; // [sp+60h] [bp-8h]@12 | |
7252 int v61; // [sp+64h] [bp-4h]@4 | |
7253 int i; | |
7254 | |
7255 v6 = (int)this; | |
7256 v5 = 0; | |
7257 if (!this->uNumD3DSceneBegins) | |
7258 return; | |
7259 | |
7260 | |
7261 | |
7262 | |
186 | 7263 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 7264 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
7265 if (this->bUsingSpecular) | |
7266 { | |
186 | 7267 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
7268 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
7269 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 7270 } |
7271 | |
7272 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
7273 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
7274 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7275 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); | |
7276 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
7277 pVertices[0].specular = 0; | |
7278 pVertices[0].texcoord.x = array_50AC10[0].u; | |
7279 pVertices[0].texcoord.y = array_50AC10[0].v; | |
7280 | |
7281 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
7282 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
7283 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7284 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); | |
7285 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
7286 pVertices[1].specular = 0; | |
7287 pVertices[1].texcoord.x = array_50AC10[3].u; | |
7288 pVertices[1].texcoord.y = array_50AC10[3].v; | |
7289 | |
7290 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
7291 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
7292 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7293 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); | |
7294 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
7295 pVertices[2].specular = 0; | |
7296 pVertices[2].texcoord.x = array_50AC10[1].u; | |
7297 pVertices[2].texcoord.y = array_50AC10[1].v; | |
7298 | |
7299 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
7300 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
7301 | |
7302 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
7303 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
7304 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7305 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); | |
7306 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
7307 pVertices[5].specular = 0; | |
7308 pVertices[5].texcoord.x = array_50AC10[2].u; | |
7309 pVertices[5].texcoord.y = array_50AC10[2].v; | |
7310 | |
7311 | |
7312 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7313 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
7314 | |
186 | 7315 }*/ |
7316 | |
0 | 7317 //----- (004A26BC) -------------------------------------------------------- |
186 | 7318 void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
7319 { | |
7320 //RenderVertexSoft *pVertices; // esi@0 | |
7321 //int v7; // edi@1 | |
0 | 7322 unsigned int v8; // ebx@1 |
7323 LightmapBuilder *v9; // esi@3 | |
7324 unsigned int v10; // edx@3 | |
7325 int v11; // eax@5 | |
7326 int v12; // eax@11 | |
7327 char *v13; // esi@11 | |
7328 double v14; // st7@13 | |
7329 double v15; // st7@13 | |
7330 signed int v16; // eax@13 | |
7331 int v17; // ecx@13 | |
7332 double v18; // st7@13 | |
7333 float v19; // ST78_4@14 | |
7334 int v20; // eax@14 | |
7335 char v21; // zf@16 | |
7336 HRESULT v22; // eax@17 | |
7337 HRESULT v23; // eax@17 | |
7338 HRESULT v24; // eax@19 | |
7339 HRESULT v25; // eax@19 | |
7340 unsigned int v26; // ecx@19 | |
7341 char *v27; // eax@20 | |
7342 HRESULT v28; // eax@22 | |
7343 HRESULT v29; // eax@22 | |
7344 HRESULT v30; // eax@23 | |
7345 HRESULT v31; // eax@24 | |
7346 HRESULT v32; // eax@24 | |
7347 HRESULT v33; // eax@24 | |
7348 HRESULT v34; // eax@24 | |
7349 HRESULT v35; // eax@25 | |
7350 HRESULT v36; // eax@25 | |
7351 unsigned int v37; // ecx@25 | |
7352 char *v38; // eax@26 | |
7353 int v39; // edx@27 | |
7354 HRESULT v40; // eax@28 | |
7355 HRESULT v41; // eax@28 | |
7356 HRESULT v42; // eax@28 | |
7357 HRESULT v43; // eax@28 | |
7358 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
7359 unsigned int v45; // eax@28 | |
7360 HRESULT v46; // eax@29 | |
7361 HRESULT v47; // eax@29 | |
7362 HRESULT v48; // eax@29 | |
186 | 7363 //IDirect3DDevice3 *v49; // eax@35 |
0 | 7364 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
7365 int v51; // eax@40 | |
7366 char *v52; // esi@40 | |
7367 double v53; // st7@42 | |
7368 double v54; // st7@42 | |
7369 signed int v55; // eax@42 | |
7370 int v56; // ecx@42 | |
7371 double v57; // st7@42 | |
7372 float v58; // ST7C_4@43 | |
7373 int v59; // eax@43 | |
186 | 7374 //signed int v60; // [sp+78h] [bp-14h]@31 |
7375 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
0 | 7376 const char *v62; // [sp+80h] [bp-Ch]@0 |
7377 const char *v63; // [sp+80h] [bp-Ch]@19 | |
7378 int v64; // [sp+84h] [bp-8h]@0 | |
7379 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
7380 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
7381 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
186 | 7382 int a7; |
7383 | |
7384 //v7 = (int)this; | |
0 | 7385 v8 = 0; |
186 | 7386 if (!this->uNumD3DSceneBegins) |
75 | 7387 return; |
7388 if ( uNumVertices < 3) | |
7389 return; | |
7390 | |
186 | 7391 //v61 = pVertices; |
7392 | |
75 | 7393 /* v9 = pGame->pLightmapBuilder; |
0 | 7394 v65 = v9; |
75 | 7395 v10 = v9->std__vector_000004_size;*/ |
0 | 7396 if ( byte_4D864C && pGame->uFlags & 1 ) |
7397 { | |
638 | 7398 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
75 | 7399 pGame->pLightmapBuilder->_45D74F_MessWithLight(v11, 0); |
0 | 7400 } |
7401 else | |
7402 { | |
186 | 7403 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 7404 byte_4D864C && pGame->uFlags & 2 ) |
7405 { | |
186 | 7406 if (clampAtTextureBorders) |
7407 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 7408 else |
186 | 7409 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
7410 | |
7411 if (transparent || this->bUsingSpecular) | |
7412 { | |
7413 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
7414 if (transparent) | |
0 | 7415 { |
186 | 7416 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
7417 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
7418 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
7419 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 7420 } |
7421 else | |
7422 { | |
186 | 7423 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
7424 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 7425 } |
186 | 7426 } |
7427 if (uNumVertices > 0) | |
7428 { | |
7429 v51 = (int)&d3d_vertex_buffer[0].pos.y; | |
0 | 7430 v52 = (char *)&array_50AC10[0].vWorldViewPosition; |
186 | 7431 a7 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 7432 v66 = uNumVertices; |
7433 while ( 1 ) | |
7434 { | |
7435 v53 = *(float *)v52 * 1000.0; | |
7436 *(int *)(v51 - 4) = *((int *)v52 + 3); | |
7437 v54 = v53 / (double)pOutdoorCamera->shading_dist_mist; | |
7438 *(int *)v51 = *((int *)v52 + 4); | |
7439 *(float *)(v51 + 4) = 1.0 - 1.0 / v54; | |
7440 *(float *)(v51 + 8) = 1.0 / (*(float *)v52 + 0.0000001); | |
638 | 7441 v55 = ::GetActorTintColor(a4->dimming_level, 0, *(float *)v52, 0, 0); |
0 | 7442 v56 = a7; |
7443 v57 = *(float *)v52; | |
7444 *(int *)(a7 + 12) = v55; | |
75 | 7445 if ( this->bUsingSpecular ) |
0 | 7446 { |
7447 v58 = v57; | |
7448 v59 = sub_47C3D7_get_fog_related_stuff(0, 0, v58); | |
7449 v56 = a7; | |
7450 } | |
7451 else | |
7452 { | |
7453 v59 = 0; | |
7454 } | |
7455 *(int *)(v56 + 16) = v59; | |
7456 *(int *)(v56 + 20) = *((int *)v52 + 6); | |
7457 *(int *)(v56 + 24) = *((int *)v52 + 7); | |
7458 v52 += 48; | |
7459 v21 = v66-- == 1; | |
7460 a7 = v56 + 32; | |
7461 if ( v21 ) | |
7462 break; | |
7463 v51 = a7; | |
7464 } | |
7465 } | |
86 | 7466 this->pRenderD3D->pDevice->SetTexture(0, a5); |
186 | 7467 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
7468 if (transparent) | |
7469 { | |
7470 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
7471 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
7472 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 7473 } |
7474 } | |
7475 else | |
7476 { | |
7477 if ( (signed int)uNumVertices > 0 ) | |
7478 { | |
186 | 7479 v12 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 7480 v13 = (char *)&array_50AC10[0].vWorldViewPosition; |
186 | 7481 a7 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 7482 a6a = uNumVertices; |
7483 while ( 1 ) | |
7484 { | |
7485 v14 = *(float *)v13 * 1000.0; | |
7486 *(int *)(v12 - 4) = *((int *)v13 + 3); | |
7487 v15 = v14 / (double)pOutdoorCamera->shading_dist_mist; | |
7488 *(int *)v12 = *((int *)v13 + 4); | |
7489 *(float *)(v12 + 4) = 1.0 - 1.0 / v15; | |
7490 *(float *)(v12 + 8) = 1.0 / (*(float *)v13 + 0.0000001); | |
638 | 7491 v16 = GetActorTintColor(a4->dimming_level, 0, *(float *)v13, 0, 0); |
0 | 7492 v17 = a7; |
7493 v18 = *(float *)v13; | |
7494 *(int *)(a7 + 12) = v16; | |
75 | 7495 if ( this->bUsingSpecular ) |
0 | 7496 { |
7497 v19 = v18; | |
7498 v20 = sub_47C3D7_get_fog_related_stuff(0, 0, v19); | |
7499 v17 = a7; | |
7500 } | |
7501 else | |
7502 { | |
7503 v20 = 0; | |
7504 } | |
7505 *(int *)(v17 + 16) = v20; | |
7506 *(int *)(v17 + 20) = *((int *)v13 + 6); | |
7507 *(int *)(v17 + 24) = *((int *)v13 + 7); | |
7508 v13 += 48; | |
7509 v21 = a6a-- == 1; | |
7510 a7 = v17 + 32; | |
7511 if ( v21 ) | |
7512 break; | |
7513 v12 = a7; | |
7514 } | |
7515 } | |
186 | 7516 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
7517 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
7518 if (pRenderer->bUsingSpecular) | |
7519 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 7520 |
7521 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 7522 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7523 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7524 d3d_vertex_buffer, |
0 | 7525 uNumVertices, |
7526 16)); | |
7527 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 7528 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 7529 //(*(void (**)(void))(*(int *)v63 + 88))(); |
7530 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
7531 v26 = uNumVertices; | |
7532 if ( (signed int)uNumVertices > 0 ) | |
7533 { | |
186 | 7534 v27 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 7535 do |
7536 { | |
7537 *(int *)v27 = -1; | |
7538 v27 += 32; | |
7539 --v26; | |
7540 } | |
7541 while ( v26 ); | |
7542 } | |
7543 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); | |
186 | 7544 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7545 if ( !pRenderer->bUsingSpecular ) |
7546 { | |
186 | 7547 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
7548 } | |
7549 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
7550 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
7551 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
7552 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7553 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7554 d3d_vertex_buffer, |
0 | 7555 uNumVertices, |
7556 16)); | |
7557 if ( pRenderer->bUsingSpecular ) | |
7558 { | |
186 | 7559 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 7560 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
7561 v37 = uNumVertices; | |
7562 if ( (signed int)uNumVertices > 0 ) | |
7563 { | |
186 | 7564 v38 = (char *)&d3d_vertex_buffer[0].specular; |
0 | 7565 do |
7566 { | |
7567 v39 = *(int *)v38; | |
7568 *(int *)v38 = 0; | |
7569 v38 += 32; | |
7570 --v37; | |
7571 *((int *)v38 - 9) = pRenderer->uFogColor | v39 & 0xFF000000; | |
7572 } | |
7573 while ( v37 ); | |
7574 } | |
75 | 7575 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 7576 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
7577 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
7578 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7579 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7580 d3d_vertex_buffer, |
0 | 7581 uNumVertices, |
7582 16)); | |
186 | 7583 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 7584 //v44 = pRenderer->pRenderD3D->pDevice; |
7585 v45 = GetLevelFogColor(); | |
7586 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
7587 v8 = 0; | |
7588 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
7589 } | |
186 | 7590 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
7591 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 7592 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
7593 } | |
7594 } | |
186 | 7595 |
791 | 7596 if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
186 | 7597 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 7598 } |
7599 // 4A26BC: could not find valid save-restore pair for esi | |
7600 // 4D864C: using guessed type char byte_4D864C; | |
7601 | |
7602 //----- (004A2DA3) -------------------------------------------------------- | |
852 | 7603 void Render::DrawSkyPolygon(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *pTexture) |
7604 { | |
67 | 7605 int v7; // eax@7 |
0 | 7606 float v13; // ST3C_4@8 |
67 | 7607 int i; |
7608 | |
7609 if ( !this->uNumD3DSceneBegins ) | |
7610 return; | |
7611 if ( uNumVertices >= 3 ) | |
7612 { | |
186 | 7613 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 7614 if ( this->bUsingSpecular ) |
7615 { | |
186 | 7616 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
7617 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
7618 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 7619 } |
840 | 7620 for ( i = 0; i < uNumVertices; ++i ) |
67 | 7621 { |
7622 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
7623 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
7624 pVertices[i].pos.z = 0.99989998; | |
168 | 7625 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 7626 |
840 | 7627 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 7628 v7 = 0; |
7629 if (this->bUsingSpecular) | |
7630 { | |
7631 v13 = array_50AC10[i].vWorldViewPosition.x; | |
7632 v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v13); | |
7633 } | |
7634 pVertices[i].specular = v7; | |
7635 pVertices[i].texcoord.x = array_50AC10[i].u; | |
7636 pVertices[i].texcoord.y = array_50AC10[i].v; | |
7637 } | |
7638 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7639 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 7640 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 7641 } |
7642 } | |
7643 | |
7644 //----- (004A2ED5) -------------------------------------------------------- | |
7645 void Render::_4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex) | |
7646 { | |
7647 signed int v4; // edi@2 | |
7648 int v5; // eax@3 | |
7649 int v6; // edx@5 | |
7650 char *v7; // eax@6 | |
7651 char *v8; // ecx@6 | |
7652 double v9; // st6@7 | |
7653 int v10; // ebx@7 | |
7654 int v11; // ebx@7 | |
7655 | |
7656 if ( this->uNumD3DSceneBegins ) | |
7657 { | |
7658 v4 = a2; | |
7659 if ( a2 >= 3 ) | |
7660 { | |
186 | 7661 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
638 | 7662 v5 = 31 - (a3->dimming_level & 0x1F); |
7663 if ( v5 < pOutdoor->max_terrain_dimming_level ) | |
7664 v5 = pOutdoor->max_terrain_dimming_level; | |
0 | 7665 v6 = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); |
7666 if ( a2 > 0 ) | |
7667 { | |
186 | 7668 v7 = (char *)&d3d_vertex_buffer[0].pos.y; |
0 | 7669 v8 = (char *)&array_507D30[0].vWorldViewProjY; |
7670 do | |
7671 { | |
7672 v9 = *((float *)v8 - 4) * 0.061758894; | |
7673 v10 = *((int *)v8 - 1); | |
7674 *((int *)v7 + 4) = 0; | |
7675 *((int *)v7 - 1) = v10; | |
7676 *(int *)v7 = *(int *)v8; | |
7677 *((int *)v7 + 2) = *((int *)v8 + 1); | |
7678 *((int *)v7 + 5) = *((int *)v8 + 2); | |
7679 v11 = *((int *)v8 + 3); | |
7680 *((int *)v7 + 3) = v6; | |
7681 *((int *)v7 + 6) = v11; | |
7682 v8 += 48; | |
7683 v7 += 32; | |
7684 --v4; | |
7685 *((float *)v7 - 7) = 1.0 - 1.0 / v9; | |
7686 } | |
7687 while ( v4 ); | |
7688 } | |
7689 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); | |
186 | 7690 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7691 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7692 d3d_vertex_buffer, |
0 | 7693 a2, |
7694 28)); | |
7695 } | |
7696 } | |
7697 } | |
7698 | |
7699 //----- (004A2FC0) -------------------------------------------------------- | |
7700 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
7701 { | |
7702 //Render *v8; // edi@1 | |
7703 //unsigned int v9; // esi@3 | |
7704 char *v12; // ecx@9 | |
7705 char *v13; // eax@9 | |
7706 double v14; // st6@10 | |
7707 int v15; // edx@10 | |
7708 Texture *v16; // edx@10 | |
7709 double v17; // st6@10 | |
7710 //char v18; // zf@10 | |
7711 Texture *v19; // edx@10 | |
595 | 7712 //Texture *v23; // edx@16 |
7713 //char *v24; // ecx@16 | |
7714 //char *v25; // eax@16 | |
7715 //double v26; // st6@17 | |
7716 //int v27; // esi@17 | |
7717 //double v28; // st6@17 | |
7718 //unsigned int v33; // ecx@18 | |
7719 //char *v34; // eax@19 | |
0 | 7720 //Texture *v45; // edx@23 |
7721 //char *v46; // ecx@23 | |
7722 //char *v47; // eax@23 | |
7723 //double v48; // st6@24 | |
7724 //int v49; // esi@24 | |
7725 //double v50; // st6@24 | |
7726 const char *v53; // [sp-Ch] [bp-20h]@21 | |
7727 //int v54; // [sp-8h] [bp-1Ch]@21 | |
7728 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
7729 const char *v56; // [sp+0h] [bp-14h]@0 | |
7730 int v57; // [sp+4h] [bp-10h]@0 | |
7731 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
7732 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
7733 //int a3a; // [sp+10h] [bp-4h]@4 | |
7734 | |
7735 //v8 = this; | |
7736 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
7737 return; | |
7738 | |
7739 //auto a3 = pFace; | |
7740 //auto a6 = uPackedID; | |
7741 //v59 = pGame->pLightmapBuilder; | |
7742 //v9 = v59->std__vector_000004_size; | |
7743 | |
7744 auto uCorrectedColor = uColor; | |
7745 if (pGame->pLightmapBuilder->std__vector_000004_size) | |
7746 uCorrectedColor = 0xFFFFFFFF; | |
638 | 7747 pGame->AlterGamma_BLV(pFace, &uCorrectedColor); |
0 | 7748 |
792 | 7749 |
7750 if (pFace->uAttributes & FACE_OUTLINED) | |
7751 { | |
7752 int color; | |
7753 if (GetTickCount() % 300 >= 150) | |
7754 uColor = uCorrectedColor = 0xFF20FF20; | |
7755 else uColor = uCorrectedColor = 0xFF109010; | |
7756 } | |
7757 | |
0 | 7758 if (byte_4D864C && pGame->uFlags & 1) |
7759 { | |
7760 __debugbreak(); | |
7761 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 7762 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7763 if ( (signed int)uNumVertices > 0 ) |
7764 { | |
7765 v12 = (char *)&array_507D30[0].vWorldViewPosition; | |
186 | 7766 v13 = (char *)&d3d_vertex_buffer[0].pos.y; |
0 | 7767 auto a7 = uNumVertices; |
7768 uint v18; | |
7769 do | |
7770 { | |
7771 v14 = *(float *)v12 * 0.061758894; | |
7772 v15 = *((int *)v12 + 3); | |
7773 *((int *)v13 + 4) = 0; | |
7774 *((int *)v13 - 1) = v15; | |
7775 *(int *)v13 = *((int *)v12 + 4); | |
7776 *((int *)v13 + 3) = uCorrectedColor; | |
7777 v16 = pTex; | |
7778 v13 += 32; | |
7779 *((float *)v13 - 7) = 1.0 - 1.0 / v14; | |
7780 v17 = 1.0 / *(float *)v12; | |
7781 v12 += 48; | |
7782 v18 = a7-- == 1; | |
7783 *((float *)v13 - 6) = v17; | |
7784 pHwTex = (IDirect3DTexture2 *)v16->uTextureWidth; | |
7785 v19 = pTex; | |
7786 *((float *)v13 - 3) = *((float *)v12 - 6) / (double)(signed int)pHwTex; | |
7787 pHwTex = (IDirect3DTexture2 *)v19->uTextureHeight; | |
7788 *((float *)v13 - 2) = *((float *)v12 - 5) / (double)(signed int)pHwTex; | |
7789 } | |
7790 while ( !v18 ); | |
7791 } | |
186 | 7792 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7793 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
7794 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7795 D3DPT_TRIANGLEFAN, | |
7796 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 7797 d3d_vertex_buffer, |
0 | 7798 uNumVertices, |
7799 28)); | |
7800 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
7801 } | |
7802 else | |
7803 { | |
7804 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
7805 byte_4D864C && pGame->uFlags & 2) | |
7806 { | |
7807 for (uint i = 0; i < uNumVertices; ++i) | |
7808 { | |
186 | 7809 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
7810 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7811 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
7812 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
7813 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
7814 d3d_vertex_buffer[i].specular = 0; | |
7815 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
7816 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
7817 } | |
7818 | |
7819 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 7820 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
7821 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
7822 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 7823 d3d_vertex_buffer, |
0 | 7824 uNumVertices, |
7825 28)); | |
7826 } | |
7827 else | |
7828 { | |
595 | 7829 for (uint i = 0; i < uNumVertices; ++i) |
7830 { | |
7831 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
7832 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7833 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
7834 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
7835 d3d_vertex_buffer[i].diffuse = uColor; | |
7836 d3d_vertex_buffer[i].specular = 0; | |
7837 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
7838 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
7839 } | |
7840 //__debugbreak(); | |
7841 //if ( (signed int)uNumVertices > 0 ) | |
7842 //{ | |
7843 //v23 = pTex; | |
7844 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
7845 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
7846 //pTex = (Texture *)uNumVertices; | |
7847 //uint v18; | |
7848 //do | |
7849 //{ | |
7850 //v26 = *(float *)v24 * 0.061758894; | |
7851 //v27 = *((int *)v24 + 3); | |
7852 //*((int *)v25 + 4) = 0; | |
7853 //*((int *)v25 - 1) = v27; | |
7854 //*(int *)v25 = *((int *)v24 + 4); | |
7855 //*((int *)v25 + 3) = uColor; | |
7856 //v25 += 32; | |
7857 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
7858 //v28 = 1.0 / *(float *)v24; | |
7859 //v24 += 48; | |
7860 //v18 = pTex == (Texture *)1; | |
7861 //pTex = (Texture *)((char *)pTex - 1); | |
7862 //*((float *)v25 - 6) = v28; | |
0 | 7863 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 7864 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 7865 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 7866 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
7867 //} | |
7868 //while ( !v18 ); | |
7869 //} | |
0 | 7870 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 7871 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7872 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 7873 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7874 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7875 d3d_vertex_buffer, |
0 | 7876 uNumVertices, |
7877 28)); | |
595 | 7878 |
7879 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 7880 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); |
595 | 7881 |
7882 for (uint i = 0; i < uNumVertices; ++i) | |
7883 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
7884 /*v33 = uNumVertices; | |
0 | 7885 if ( (signed int)uNumVertices > 0 ) |
7886 { | |
186 | 7887 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 7888 do |
7889 { | |
7890 *(int *)v34 = uCorrectedColor; | |
7891 v34 += 32; | |
7892 --v33; | |
7893 } | |
7894 while ( v33 ); | |
595 | 7895 }*/ |
0 | 7896 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 7897 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
7898 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
7899 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
7900 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
7901 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
7902 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7903 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7904 d3d_vertex_buffer, |
0 | 7905 uNumVertices, |
7906 28)); | |
186 | 7907 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
7908 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
7909 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 7910 } |
7911 } | |
7912 } | |
7913 // 4D864C: using guessed type char byte_4D864C; | |
7914 | |
7915 //----- (004A43B1) -------------------------------------------------------- | |
717 | 7916 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
7917 { | |
7918 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
7919 //double v5; // st7@2 | |
7920 //float v6; // ST08_4@2 | |
0 | 7921 unsigned int v7; // eax@2 |
717 | 7922 //int v8; // ecx@2 |
7923 //unsigned int v9; // esi@2 | |
7924 //Sprite *v10; // edi@5 | |
0 | 7925 signed int v11; // eax@9 |
7926 signed int v12; // eax@9 | |
717 | 7927 //double v13; // st7@12 |
7928 //double v14; // st6@12 | |
0 | 7929 double v15; // st5@12 |
7930 double v16; // st4@12 | |
7931 double v17; // st3@12 | |
7932 double v18; // st2@12 | |
7933 int v19; // ecx@14 | |
7934 double v20; // st3@14 | |
7935 int v21; // ecx@16 | |
7936 double v22; // st3@16 | |
717 | 7937 //IDirect3DTexture2 *v23; // eax@18 |
7938 //signed int v24; // [sp+18h] [bp-18h]@5 | |
7939 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
7940 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 7941 float v27; // [sp+24h] [bp-Ch]@5 |
7942 int v28; // [sp+28h] [bp-8h]@2 | |
7943 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 7944 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 7945 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 7946 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 7947 float a1; // [sp+40h] [bp+10h]@5 |
7948 | |
717 | 7949 //v26 = this; |
0 | 7950 if ( this->uNumD3DSceneBegins ) |
7951 { | |
717 | 7952 //v4 = pSoftBillboard; |
7953 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
7954 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
7955 //v6 = pSoftBillboard->zbuffer_depth; | |
7956 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
7957 //v8 = dimming_level; | |
7958 //v9 = v7; | |
657 | 7959 v28 = dimming_level & 0xFF000000; |
7960 if ( dimming_level & 0xFF000000 ) | |
717 | 7961 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Opaque_3; |
0 | 7962 else |
717 | 7963 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Transparent; |
7964 //v10 = a3; | |
7965 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
7966 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
7967 pBillboardRenderListD3D[v7].uParentBillboardID = pSoftBillboard->uParentBillboardID; | |
7968 //v25 = pSoftBillboard->uScreenSpaceX; | |
7969 //v24 = pSoftBillboard->uScreenSpaceY; | |
7970 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
7971 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
7972 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
7973 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
7974 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 7975 v31 = v31 * -1.0; |
717 | 7976 if ( pSoftBillboard->uTintColor && this->bTinting ) |
7977 { | |
7978 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
737 | 7979 v12 = BlendColors(pSoftBillboard->uTintColor, v11); |
0 | 7980 if ( v28 ) |
7981 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
7982 } | |
7983 else | |
7984 { | |
717 | 7985 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
7986 } | |
7987 //v13 = (double)v25; | |
7988 pBillboardRenderListD3D[v7].pQuards[0].specular = 0; | |
7989 pBillboardRenderListD3D[v7].pQuards[0].diffuse = v12; | |
7990 pBillboardRenderListD3D[v7].pQuards[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
7991 //v14 = (double)v24; | |
7992 //v32 = v14; | |
7993 pBillboardRenderListD3D[v7].pQuards[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; | |
7994 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); | |
7995 pBillboardRenderListD3D[v7].pQuards[0].pos.z = v15; | |
7996 v16 = 1.0 / pSoftBillboard->zbuffer_depth; | |
7997 pBillboardRenderListD3D[v7].pQuards[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; | |
7998 pBillboardRenderListD3D[v7].pQuards[0].texcoord.x = 0.0; | |
7999 pBillboardRenderListD3D[v7].pQuards[0].texcoord.y = 0.0; | |
8000 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
8001 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
8002 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8003 v17 = v17 * -1.0; |
717 | 8004 pBillboardRenderListD3D[v7].pQuards[1].specular = 0; |
8005 pBillboardRenderListD3D[v7].pQuards[1].diffuse = v12; | |
8006 pBillboardRenderListD3D[v7].pQuards[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
8007 pBillboardRenderListD3D[v7].pQuards[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
8008 pBillboardRenderListD3D[v7].pQuards[1].pos.z = v15; | |
8009 pBillboardRenderListD3D[v7].pQuards[1].rhw = v16; | |
8010 pBillboardRenderListD3D[v7].pQuards[1].texcoord.x = 0.0; | |
8011 pBillboardRenderListD3D[v7].pQuards[1].texcoord.y = 1.0; | |
8012 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; | |
8013 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
8014 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8015 v20 = v20 * -1.0; |
717 | 8016 pBillboardRenderListD3D[v7].pQuards[2].specular = 0; |
8017 pBillboardRenderListD3D[v7].pQuards[2].diffuse = v12; | |
8018 pBillboardRenderListD3D[v7].pQuards[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
8019 pBillboardRenderListD3D[v7].pQuards[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
8020 pBillboardRenderListD3D[v7].pQuards[2].pos.z = v15; | |
8021 pBillboardRenderListD3D[v7].pQuards[2].rhw = v16; | |
8022 pBillboardRenderListD3D[v7].pQuards[2].texcoord.x = 1.0; | |
8023 pBillboardRenderListD3D[v7].pQuards[2].texcoord.y = 1.0; | |
8024 v21 = pSprite->uBufferHeight - pSprite->uAreaY; | |
8025 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
8026 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8027 v22 = v22 * -1.0; |
717 | 8028 pBillboardRenderListD3D[v7].pQuards[3].specular = 0; |
8029 pBillboardRenderListD3D[v7].pQuards[3].diffuse = v12; | |
8030 pBillboardRenderListD3D[v7].pQuards[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
8031 pBillboardRenderListD3D[v7].pQuards[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
8032 pBillboardRenderListD3D[v7].pQuards[3].pos.z = v15; | |
8033 pBillboardRenderListD3D[v7].pQuards[3].rhw = v16; | |
8034 pBillboardRenderListD3D[v7].pQuards[3].texcoord.x = 1.0; | |
8035 pBillboardRenderListD3D[v7].pQuards[3].texcoord.y = 0.0; | |
8036 //v23 = pSprite->pTexture; | |
8037 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
8038 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
8039 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 8040 } |
8041 } | |
8042 | |
8043 //----- (004A354F) -------------------------------------------------------- | |
8044 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
8045 { | |
743 | 8046 //double v5; // st7@3 |
8047 //float v6; // ST20_4@3 | |
8048 //float v7; // ST00_4@3 | |
0 | 8049 unsigned int v8; // esi@3 |
743 | 8050 //int v9; // eax@3 |
8051 //int v10; // ebx@3 | |
0 | 8052 float v11; // ST28_4@3 |
743 | 8053 //double v12; // st7@3 |
8054 //float v13; // ST24_4@3 | |
8055 //double v14; // st6@3 | |
8056 //float v15; // ST1C_4@3 | |
0 | 8057 float v16; // ST2C_4@3 |
8058 float v17; // ST30_4@3 | |
8059 signed int v18; // ST18_4@3 | |
8060 signed int v19; // ST14_4@3 | |
8061 signed int v20; // ST10_4@3 | |
8062 signed int v21; // eax@3 | |
8063 double v22; // st6@3 | |
8064 float v23; // ST2C_4@3 | |
8065 float v24; // ST30_4@3 | |
8066 signed int v25; // ST10_4@3 | |
8067 signed int v26; // ST14_4@3 | |
8068 signed int v27; // ST18_4@3 | |
8069 signed int v28; // eax@3 | |
8070 double v29; // st6@3 | |
8071 float v30; // ecx@3 | |
8072 float v31; // ST2C_4@3 | |
8073 float v32; // ST30_4@3 | |
8074 signed int v33; // ST10_4@3 | |
8075 signed int v34; // ST14_4@3 | |
8076 signed int v35; // ST18_4@3 | |
8077 signed int v36; // eax@3 | |
8078 float v37; // ecx@3 | |
8079 double v38; // st6@3 | |
8080 float v39; // ST2C_4@3 | |
8081 float v40; // ST30_4@3 | |
8082 signed int v41; // ST10_4@3 | |
8083 signed int v42; // ST14_4@3 | |
8084 signed int v43; // ST18_4@3 | |
8085 signed int v44; // eax@3 | |
8086 double v45; // st6@3 | |
8087 float v46; // eax@3 | |
8088 | |
8089 if ( this->uNumD3DSceneBegins ) | |
8090 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8091 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8092 { |
743 | 8093 //v5 = (double)a2->zbuffer_depth; |
8094 //v6 = v5; | |
8095 //v7 = v5; | |
8096 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
0 | 8097 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; |
8098 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
8099 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
8100 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
743 | 8101 //v9 = a2->uScreenSpaceX; |
8102 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8103 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 8104 //v12 = (double) a2->uScreenSpaceX; |
8105 //v13 = v12; | |
8106 //v14 = (double)(a2->uScreenSpaceY - 12); | |
8107 //v15 = v14; | |
8108 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
8109 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 8110 v18 = stru_5C6E00->Cos(angle); |
8111 v19 = stru_5C6E00->Sin(angle); | |
8112 v20 = stru_5C6E00->Sin(angle); | |
8113 v21 = stru_5C6E00->Cos(angle); | |
0 | 8114 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
8115 + (double)(v18 >> 16)) | |
8116 * v16 | |
8117 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
8118 + (double)(v19 >> 16)) | |
8119 * v17) | |
743 | 8120 * v11 + (double) a2->uScreenSpaceX; |
0 | 8121 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
8122 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
8123 - 12.0) | |
8124 * v11 | |
8125 + (double)a2->uScreenSpaceY; | |
8126 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; | |
8127 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; | |
8128 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v22; | |
743 | 8129 pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); |
8130 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; | |
0 | 8131 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; |
8132 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; | |
743 | 8133 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
8134 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 8135 v25 = stru_5C6E00->Cos(angle); |
8136 v26 = stru_5C6E00->Sin(angle); | |
8137 v27 = stru_5C6E00->Sin(angle); | |
8138 v28 = stru_5C6E00->Cos(angle); | |
0 | 8139 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
8140 + (double)(v25 >> 16)) | |
740 | 8141 * v31 |
0 | 8142 - ((double)(unsigned __int16)v26 * 0.000015259022 |
8143 + (double)(v26 >> 16)) | |
740 | 8144 * v32) |
743 | 8145 * v11 + (double) a2->uScreenSpaceX; |
740 | 8146 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
8147 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 8148 - 12.0) |
8149 * v11 | |
8150 + (double)a2->uScreenSpaceY; | |
8151 pBillboardRenderListD3D[v8].pQuards[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8152 v30 = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8153 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v29; | |
8154 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; | |
8155 pBillboardRenderListD3D[v8].pQuards[1].rhw = v30; | |
8156 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; | |
8157 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; | |
8158 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
743 | 8159 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
8160 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 8161 v33 = stru_5C6E00->Cos(angle); |
8162 v34 = stru_5C6E00->Sin(angle); | |
8163 v35 = stru_5C6E00->Sin(angle); | |
8164 v36 = stru_5C6E00->Cos(angle); | |
0 | 8165 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
8166 + (double)(v33 >> 16)) | |
740 | 8167 * v23 |
0 | 8168 - ((double)(unsigned __int16)v34 * 0.000015259022 |
8169 + (double)(v34 >> 16)) | |
740 | 8170 * v24) |
743 | 8171 * v11 + (double) a2->uScreenSpaceX; |
0 | 8172 v37 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; |
740 | 8173 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
8174 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 8175 - 12.0) |
8176 * v11 | |
8177 + (double)a2->uScreenSpaceY; | |
8178 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; | |
8179 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v37; | |
8180 pBillboardRenderListD3D[v8].pQuards[2].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8181 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; | |
8182 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v38; | |
8183 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; | |
8184 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
743 | 8185 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
8186 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 8187 v41 = stru_5C6E00->Cos(angle); |
8188 v42 = stru_5C6E00->Sin(angle); | |
8189 v43 = stru_5C6E00->Sin(angle); | |
8190 v44 = stru_5C6E00->Cos(angle); | |
0 | 8191 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
8192 + (double)(v41 >> 16)) | |
8193 * v39 | |
8194 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
8195 + (double)(v42 >> 16)) | |
8196 * v40) | |
743 | 8197 * v11 + (double) a2->uScreenSpaceX; |
0 | 8198 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
8199 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
8200 - 12.0) | |
8201 * v11 | |
8202 + (double)a2->uScreenSpaceY; | |
8203 v46 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8204 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; | |
8205 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v46; | |
8206 pBillboardRenderListD3D[v8].pQuards[3].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8207 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; | |
8208 pBillboardRenderListD3D[v8].pTexture = a3; | |
743 | 8209 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 8210 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8211 pBillboardRenderListD3D[v8].pQuards[3].pos.y = v45; | |
8212 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; | |
8213 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
8214 } | |
8215 } | |
8216 } | |
8217 | |
8218 //----- (004A3AD9) -------------------------------------------------------- | |
8219 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
8220 { | |
8221 double v5; // st7@2 | |
8222 float v6; // ST28_4@2 | |
8223 float v7; // ST00_4@2 | |
8224 unsigned int v8; // esi@2 | |
8225 int v9; // eax@2 | |
8226 int v10; // ebx@2 | |
8227 float v11; // ST34_4@2 | |
8228 double v12; // st7@2 | |
8229 float v13; // ST2C_4@2 | |
8230 double v14; // st6@2 | |
8231 float v15; // ST24_4@2 | |
8232 float v16; // ST38_4@2 | |
8233 float v17; // ST3C_4@2 | |
8234 signed int v18; // ST1C_4@2 | |
8235 int v19; // ST30_4@2 | |
8236 signed int v20; // ST20_4@2 | |
8237 signed int v21; // ST18_4@2 | |
8238 signed int v22; // eax@2 | |
8239 double v23; // st6@2 | |
8240 float v24; // ST20_4@2 | |
8241 float v25; // ST1C_4@2 | |
8242 float v26; // ST38_4@2 | |
8243 float v27; // ST3C_4@2 | |
8244 signed int v28; // ST18_4@2 | |
8245 signed int v29; // ST14_4@2 | |
8246 signed int v30; // ST10_4@2 | |
8247 signed int v31; // eax@2 | |
8248 double v32; // st6@2 | |
8249 float v33; // ST38_4@2 | |
8250 float v34; // ST3C_4@2 | |
8251 signed int v35; // ST10_4@2 | |
8252 signed int v36; // ST14_4@2 | |
8253 signed int v37; // ST18_4@2 | |
8254 signed int v38; // eax@2 | |
8255 double v39; // st6@2 | |
8256 float v40; // ST38_4@2 | |
8257 float v41; // ST3C_4@2 | |
8258 signed int v42; // ST10_4@2 | |
8259 signed int v43; // ST14_4@2 | |
8260 signed int v44; // ST18_4@2 | |
8261 signed int v45; // eax@2 | |
8262 double v46; // st6@2 | |
8263 | |
8264 if ( this->uNumD3DSceneBegins ) | |
8265 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8266 v5 = (double)a2->zbuffer_depth; |
0 | 8267 v6 = v5; |
8268 v7 = v5; | |
8269 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
8270 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | |
8271 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
8272 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
8273 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
8274 v9 = a2->uScreenSpaceX; | |
8275 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8276 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 8277 v12 = (double)v9; |
8278 v13 = v12; | |
8279 v14 = (double)(v10 - 12); | |
8280 v15 = v14; | |
8281 v16 = (double)(v9 - 12) - v12; | |
8282 v17 = (double)(v10 - 25) - v14; | |
323 | 8283 v18 = stru_5C6E00->Cos(angle); |
0 | 8284 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 8285 v20 = stru_5C6E00->Sin(angle); |
8286 v21 = stru_5C6E00->Sin(angle); | |
8287 v22 = stru_5C6E00->Cos(angle); | |
0 | 8288 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
8289 + (double)(v18 >> 16)) | |
8290 * v16 | |
8291 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
8292 + (double)(v20 >> 16)) | |
8293 * v17) | |
8294 * v11 + v13; | |
8295 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
8296 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
8297 - 12.0) | |
8298 * v11 | |
8299 + (double)a2->uScreenSpaceY; | |
8300 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; | |
8301 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; | |
8302 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v23; | |
8303 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
8304 pBillboardRenderListD3D[v8].pQuards[0].pos.z = v24; | |
8305 v25 = 1.0 / v6; | |
8306 pBillboardRenderListD3D[v8].pQuards[0].rhw = v25; | |
8307 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; | |
8308 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; | |
8309 v26 = (double)(a2->uScreenSpaceX - 12) - v13; | |
8310 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 8311 v28 = stru_5C6E00->Cos(angle); |
8312 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8313 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8314 v31 = stru_5C6E00->Cos(angle); | |
0 | 8315 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
8316 + (double)(v28 >> 16)) | |
8317 * v26 | |
8318 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
8319 + (double)(v29 >> 16)) | |
8320 * v27) | |
8321 * v11 + v13; | |
8322 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
8323 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
8324 - 12.0) | |
8325 * v11 | |
8326 + (double)a2->uScreenSpaceY; | |
8327 pBillboardRenderListD3D[v8].pQuards[1].pos.z = v24; | |
8328 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v32; | |
8329 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; | |
8330 pBillboardRenderListD3D[v8].pQuards[1].rhw = v25; | |
8331 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; | |
8332 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; | |
8333 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
8334 v33 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8335 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 8336 v35 = stru_5C6E00->Cos(angle); |
8337 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8338 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8339 v38 = stru_5C6E00->Cos(angle); | |
0 | 8340 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
8341 + (double)(v35 >> 16)) | |
8342 * v33 | |
8343 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
8344 + (double)(v36 >> 16)) | |
8345 * v34) | |
8346 * v11 + v13; | |
8347 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
8348 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
8349 - 12.0) | |
8350 * v11 | |
8351 + (double)a2->uScreenSpaceY; | |
8352 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; | |
8353 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v24; | |
8354 pBillboardRenderListD3D[v8].pQuards[2].rhw = v25; | |
8355 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; | |
8356 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v39; | |
8357 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; | |
8358 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
8359 v40 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8360 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 8361 v42 = stru_5C6E00->Cos(angle); |
8362 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8363 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8364 v45 = stru_5C6E00->Cos(angle); | |
0 | 8365 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
8366 + (double)(v42 >> 16)) | |
8367 * v40 | |
8368 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
8369 + (double)(v43 >> 16)) | |
8370 * v41) | |
8371 * v11 + v13; | |
8372 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
8373 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
8374 - 12.0) | |
8375 * v11 | |
8376 + (double)a2->uScreenSpaceY; | |
8377 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; | |
8378 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v24; | |
8379 pBillboardRenderListD3D[v8].pQuards[3].rhw = v25; | |
8380 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; | |
8381 pBillboardRenderListD3D[v8].pTexture = a3; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8382 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 8383 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8384 pBillboardRenderListD3D[v8].pQuards[3].pos.y = v46; | |
8385 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; | |
8386 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
8387 } | |
8388 } | |
8389 | |
8390 //----- (004A4023) -------------------------------------------------------- | |
657 | 8391 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
|
8392 { |
0 | 8393 unsigned int v8; // esi@2 |
8394 double v14; // st6@14 | |
8395 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8396 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8397 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8398 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8399 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8400 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8401 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8402 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8403 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8404 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8405 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 8406 float v29; // [sp+28h] [bp-8h]@5 |
8407 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8408 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8409 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8410 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8411 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8412 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8413 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8414 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8415 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
|
8416 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
|
8417 |
657 | 8418 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
|
8419 if (a2->uTintColor & 0x00FFFFFF && bTinting) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8420 { |
737 | 8421 diffuse = BlendColors(a2->uTintColor, diffuse); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8422 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8423 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8424 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8425 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8426 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8427 if (bUsingSpecular) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8428 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
|
8429 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8430 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8431 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8432 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8433 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8434 pBillboardRenderListD3D[v8].pQuards[0].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8435 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
|
8436 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
|
8437 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
|
8438 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8439 pBillboardRenderListD3D[v8].pQuards[0].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8440 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8441 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8442 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8443 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8444 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8445 if ( a2->uFlags & 4 ) |
0 | 8446 v14 = v14 * -1.0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8447 pBillboardRenderListD3D[v8].pQuards[1].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8448 pBillboardRenderListD3D[v8].pQuards[1].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8449 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
|
8450 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
|
8451 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
|
8452 pBillboardRenderListD3D[v8].pQuards[1].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8453 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; |
8454 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8455 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8456 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
|
8457 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8458 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8459 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8460 pBillboardRenderListD3D[v8].pQuards[2].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8461 pBillboardRenderListD3D[v8].pQuards[2].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8462 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
|
8463 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
|
8464 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
|
8465 pBillboardRenderListD3D[v8].pQuards[2].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8466 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; |
8467 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8468 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8469 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
|
8470 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8471 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8472 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8473 pBillboardRenderListD3D[v8].pQuards[3].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8474 pBillboardRenderListD3D[v8].pQuards[3].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8475 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
|
8476 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
|
8477 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
|
8478 pBillboardRenderListD3D[v8].pQuards[3].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8479 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; |
8480 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8481 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8482 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8483 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8484 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8485 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8486 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8487 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8488 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8489 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8490 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8491 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8492 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; |
0 | 8493 } |
8494 | |
8495 //----- (004A48E4) -------------------------------------------------------- | |
8496 int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6) | |
8497 { | |
8498 int v6; // ecx@1 | |
8499 int v7; // ebx@1 | |
8500 int v8; // ecx@1 | |
8501 int v9; // edx@1 | |
8502 int v10; // edi@1 | |
8503 unsigned int x; // esi@1 | |
8504 int result; // eax@8 | |
8505 int v13; // [sp+Ch] [bp-10h]@1 | |
8506 int v14; // [sp+10h] [bp-Ch]@1 | |
8507 int v15; // [sp+14h] [bp-8h]@1 | |
8508 int v16; // [sp+18h] [bp-4h]@1 | |
8509 int v17; // [sp+24h] [bp+8h]@1 | |
8510 unsigned int v18; // [sp+28h] [bp+Ch]@1 | |
8511 int v19; // [sp+34h] [bp+18h]@1 | |
8512 | |
8513 v6 = screenSpaceX; | |
8514 v7 = (a6 >> 1) + screenSpaceY; | |
8515 v17 = 0; | |
8516 v15 = 0; | |
8517 v8 = (a6 >> 1) + v6; | |
8518 v14 = (a6 >> 1) * (a6 >> 1); | |
8519 v9 = 2 * (a6 >> 1); | |
8520 v10 = (a6 >> 1) * ((a6 >> 1) - 1); | |
8521 x = v8 - (a6 >> 1); | |
8522 v16 = (a6 >> 1) + screenSpaceY - v8; | |
8523 v19 = a6 >> 1; | |
8524 v13 = v9; | |
8525 v18 = v8; | |
8526 do | |
8527 { | |
8528 sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor); | |
8529 if ( v15 ) | |
8530 sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor); | |
8531 v14 -= v15; | |
8532 if ( v14 <= v10 ) | |
8533 { | |
8534 if ( v19 != v17 ) | |
8535 { | |
8536 sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor); | |
8537 sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor); | |
8538 } | |
8539 --v19; | |
8540 v13 -= 2; | |
8541 ++x; | |
8542 v10 -= v13; | |
8543 } | |
8544 result = v17++; | |
8545 v15 += 2; | |
8546 --v18; | |
8547 } | |
8548 while ( result < v19 ); | |
8549 return result; | |
8550 } | |
8551 | |
8552 //----- (004A49D0) -------------------------------------------------------- | |
8553 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
8554 { | |
8555 int v10; // eax@1 | |
8556 unsigned int v11; // ebx@1 | |
8557 unsigned int v12; // ecx@1 | |
8558 int v13; // edx@2 | |
8559 int v14; // edx@4 | |
8560 unsigned int v15; // edx@6 | |
8561 double v16; // st7@7 | |
8562 double v17; // st7@7 | |
8563 double v18; // st6@7 | |
8564 double v19; // st4@7 | |
8565 double v20; // st4@8 | |
8566 double v21; // st4@10 | |
8567 double v22; // st4@10 | |
8568 double v23; // st4@10 | |
8569 double v24; // st4@10 | |
8570 double v25; // st4@11 | |
8571 double v26; // st4@13 | |
8572 double v27; // st5@13 | |
8573 double v28; // st4@13 | |
8574 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
8575 double v30; // [sp+80h] [bp-14h]@1 | |
8576 int v31; // [sp+88h] [bp-Ch]@1 | |
8577 signed int v32; // [sp+8Ch] [bp-8h]@1 | |
8578 int X; // [sp+90h] [bp-4h]@1 | |
8579 float a3a; // [sp+A4h] [bp+10h]@10 | |
8580 float a4a; // [sp+A8h] [bp+14h]@10 | |
8581 | |
8582 *(float *)&X = dstX - srcX; | |
8583 v30 = *(float *)&X + 6.7553994e15; | |
8584 v31 = LODWORD(v30); | |
8585 *(float *)&v32 = dstY - srcY; | |
8586 v30 = *(float *)&v32 + 6.7553994e15; | |
8587 X = LODWORD(v30); | |
8588 HIDWORD(v30) = abs(COERCE_UNSIGNED_INT64(*(float *)&v32 + 6.7553994e15)); | |
8589 v10 = abs(v31); | |
8590 v32 = v10; | |
8591 v11 = HIDWORD(v30); | |
8592 v12 = 0; | |
8593 if ( v10 < SHIDWORD(v30) ) | |
8594 { | |
8595 v13 = v10; | |
8596 v10 = HIDWORD(v30); | |
8597 v11 = v13; | |
8598 } | |
8599 if ( v10 < 0 ) | |
8600 { | |
8601 v14 = v10; | |
8602 v10 = 0; | |
8603 v12 = v14; | |
8604 } | |
8605 if ( (signed int)v11 < (signed int)v12 ) | |
8606 { | |
8607 v15 = v12; | |
8608 v12 = v11; | |
8609 v11 = v15; | |
8610 } | |
8611 v32 = (11 * v11 >> 5) + (v12 >> 2) + v10; | |
8612 v16 = 1.0 / (double)v32; | |
8613 *(float *)&v31 = (double)v31 * v16; | |
8614 *(float *)&X = (double)X * v16; | |
8615 v17 = *(float *)&X * a4; | |
8616 v29[0].pos.x = srcX + v17; | |
8617 v18 = *(float *)&v31 * a4; | |
8618 v29[0].pos.y = srcY - v18; | |
8619 v19 = a3; | |
8620 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
8621 v20 = v19 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8622 else | |
8623 v20 = v19 * 0.061758894; | |
8624 v29[0].diffuse = -1; | |
8625 v29[0].specular = 0; | |
8626 v29[0].pos.z = 1.0 - 1.0 / v20; | |
8627 v21 = 1.0 / a3; | |
8628 *((float *)&v30 + 1) = v21; | |
8629 v29[0].rhw = v21; | |
8630 v29[0].texcoord.x = 1.0; | |
8631 v29[0].texcoord.y = 0.0; | |
8632 v22 = *(float *)&X * a8; | |
8633 a3a = v22; | |
8634 v29[1].pos.x = v22 + dstX; | |
8635 v23 = *(float *)&v31 * a8; | |
8636 a4a = v23; | |
8637 v29[1].pos.y = dstY - v23; | |
8638 v24 = a7; | |
8639 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
8640 v25 = v24 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8641 else | |
8642 v25 = v24 * 0.061758894; | |
8643 v29[2].diffuse = -1; | |
8644 v29[3].diffuse = -1; | |
8645 *(_QWORD *)&v29[3].pos.z = __PAIR__(HIDWORD(v30), LODWORD(v29[0].pos.z)); | |
8646 v29[1].diffuse = -16711936; | |
8647 v29[1].specular = 0; | |
8648 v29[2].specular = 0; | |
8649 v29[3].specular = 0; | |
8650 v26 = 1.0 - 1.0 / v25; | |
8651 v29[1].pos.z = v26; | |
8652 v27 = v26; | |
8653 v28 = 1.0 / a7; | |
8654 v29[1].rhw = v28; | |
8655 v29[1].texcoord.x = 1.0; | |
8656 v29[1].texcoord.y = 1.0; | |
8657 v29[2].pos.x = dstX - a3a; | |
8658 v29[2].pos.y = a4a + dstY; | |
8659 v29[2].pos.z = v27; | |
8660 v29[2].rhw = v28; | |
8661 v29[2].texcoord.x = 0.0; | |
8662 v29[2].texcoord.y = 1.0; | |
8663 v29[3].pos.x = srcX - v17; | |
8664 v29[3].pos.y = v18 + srcY; | |
8665 v29[3].texcoord.x = 0.0; | |
8666 v29[3].texcoord.y = 0.0; | |
186 | 8667 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
8668 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8669 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8670 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
8671 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8672 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 8673 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
8674 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
8675 D3DPT_TRIANGLEFAN, | |
8676 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8677 v29, | |
8678 4, | |
8679 24)); | |
186 | 8680 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
8681 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8682 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8683 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
8684 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8685 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 8686 } |
8687 | |
8688 //----- (004A4CC9) -------------------------------------------------------- | |
8689 void Render::_4A4CC9(stru6_stru1_indoor_sw_billboard *a1, int a2) | |
8690 { | |
8691 int v3; // eax@1 | |
8692 int v4; // edx@3 | |
8693 unsigned int v5; // eax@7 | |
8694 int v6; // edi@7 | |
8695 char *v7; // edx@8 | |
8696 char *v8; // ecx@8 | |
8697 char v9; // zf@9 | |
8698 double v10; // st6@9 | |
8699 double v11; // st6@10 | |
8700 int v12; // ebx@13 | |
8701 int v13; // ecx@16 | |
8702 unsigned int v14; // [sp+Ch] [bp-4h]@1 | |
8703 | |
8704 auto _this = this; | |
8705 | |
8706 *(float *)&v14 = 1000000.0; | |
8707 v3 = a1->field_10; | |
8708 if ( v3 >= 3 ) | |
8709 { | |
8710 if ( v3 > 0 ) | |
8711 { | |
8712 _this = (Render *)&a1->field_14[62]; | |
8713 v4 = a1->field_10; | |
8714 do | |
8715 { | |
8716 if ( *(float *)&this->bUserDirect3D < (double)*(float *)&v14 ) | |
8717 v14 = this->bUserDirect3D; | |
8718 _this = (Render *)((char *)_this + 16); | |
8719 --v4; | |
8720 } | |
8721 while ( v4 ); | |
8722 } | |
8723 v5 = Billboard_ProbablyAddToListAndSortByZOrder(v14); | |
8724 v6 = 0; | |
8725 pBillboardRenderListD3D[v5].field_90 = 0; | |
8726 pBillboardRenderListD3D[v5].uParentBillboardID = -1; | |
8727 pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; | |
8728 if ( a1->field_10 > 0 ) | |
8729 { | |
8730 v7 = (char *)&a1->field_14[62]; | |
8731 v8 = (char *)&pBillboardRenderListD3D[v5].pQuards[0].pos.z; | |
8732 do | |
8733 { | |
8734 v9 = uCurrentlyLoadedLevelType == LEVEL_Indoor; | |
8735 *((int *)v8 - 2) = *((int *)v7 - 2); | |
8736 *((int *)v8 - 1) = *((int *)v7 - 1); | |
8737 v10 = *(float *)v7; | |
8738 if ( v9 ) | |
8739 v11 = v10 * 0.061758894; | |
8740 else | |
8741 v11 = v10 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8742 *(float *)v8 = 1.0 - 1.0 / v11; | |
8743 *((float *)v8 + 1) = 1.0 / *(float *)v7; | |
8744 if ( a2 & 0xFF000000 ) | |
8745 v12 = *((int *)v7 + 1); | |
8746 else | |
8747 v12 = a2; | |
8748 *((int *)v8 + 3) = 0; | |
8749 *((int *)v8 + 2) = v12; | |
8750 ++v6; | |
8751 v7 += 16; | |
8752 *((float *)v8 + 4) = 0.0; | |
8753 *((float *)v8 + 5) = 0.0; | |
8754 v8 += 32; | |
8755 } | |
8756 while ( v6 < a1->field_10 ); | |
8757 } | |
8758 v13 = a1->field_10; | |
8759 pBillboardRenderListD3D[v5].pTexture = 0; | |
8760 pBillboardRenderListD3D[v5].uNumVertices = v13; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8761 LODWORD(pBillboardRenderListD3D[v5].z_order) = v14; |
0 | 8762 } |
8763 } | |
8764 | |
8765 //----- (004A4DE1) -------------------------------------------------------- | |
8766 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
8767 { | |
8768 HRESULT v12; // eax@14 | |
8769 unsigned __int16 *v13; // ecx@19 | |
8770 unsigned __int16 *v14; // eax@19 | |
8771 DWORD v15; // edx@20 | |
8772 HRESULT v16; // eax@23 | |
8773 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
8774 | |
8775 auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); | |
8776 if ( pHWLTexture ) | |
8777 { | |
8778 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
8779 if ( !pRenderD3D->CreateTexture( | |
8780 pHWLTexture->uWidth, | |
8781 pHWLTexture->uHeight, | |
8782 pOutSurface, | |
8783 pOutTexture, | |
8784 true, | |
8785 bMipMaps, | |
8786 uMinDeviceTextureDim) ) | |
8787 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); | |
8788 //v10 = *pOutSurface; | |
8789 //v11 = 0; | |
8790 if ( bMipMaps ) | |
8791 { | |
8792 Dst._450DDE(); | |
8793 //v20 = 0; | |
8794 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
8795 | |
8796 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
8797 while ( 1 ) | |
8798 { | |
8799 DDSCAPS2 v19; | |
8800 memset(&v19, 0, sizeof(DDSCAPS2)); | |
8801 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
8802 | |
8803 DDSURFACEDESC2 desc; | |
8804 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
8805 desc.dwSize = sizeof(DDSURFACEDESC2); | |
8806 | |
168 | 8807 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 8808 { |
8809 Dst.sub_451007_scale_image_bicubic( | |
8810 pHWLTexture->pPixels, | |
8811 pHWLTexture->uWidth, | |
8812 pHWLTexture->uHeight, | |
8813 pHWLTexture->uWidth, | |
8814 (unsigned short *)desc.lpSurface, | |
8815 desc.dwWidth, | |
8816 desc.dwHeight, | |
8817 desc.lPitch >> 1, | |
8818 0, | |
8819 0); | |
8820 ErrD3D(pNextSurf->Unlock(0)); | |
8821 //bMipMaps = 0x4D86ACu; | |
8822 } | |
8823 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
8824 break; | |
8825 //v10 = (IDirectDrawSurface4 *)pName; | |
8826 //v11 = 0; | |
8827 } | |
8828 //v20 = -1; | |
8829 //nullsub_1(); | |
8830 } | |
8831 else | |
8832 { | |
8833 DDSCAPS2 v19; | |
8834 memset(&v19, 0, sizeof(DDSCAPS2)); | |
8835 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
8836 | |
8837 DDSURFACEDESC2 desc; | |
8838 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
8839 desc.dwSize = sizeof(DDSURFACEDESC2); | |
8840 | |
168 | 8841 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 8842 { |
8843 bMipMaps = 0; | |
8844 v13 = pHWLTexture->pPixels; | |
8845 v14 = (unsigned __int16 *)desc.lpSurface; | |
8846 if ( desc.dwHeight ) | |
8847 { | |
8848 do | |
8849 { | |
8850 v15 = 0; | |
8851 if ( desc.dwWidth ) | |
8852 { | |
8853 do | |
8854 { | |
8855 ++v15; | |
8856 *v14 = *v13; | |
8857 ++v14; | |
8858 ++v13; | |
8859 } | |
8860 while ( v15 < desc.dwWidth ); | |
8861 } | |
8862 ++bMipMaps; | |
8863 v14 += (desc.lPitch >> 1) - desc.dwWidth; | |
8864 } | |
8865 while ( bMipMaps < desc.dwHeight ); | |
8866 } | |
8867 ErrD3D((*pOutSurface)->Unlock(0)); | |
8868 } | |
8869 } | |
8870 delete [] pHWLTexture->pPixels; | |
8871 delete pHWLTexture; | |
8872 return true; | |
8873 } | |
8874 return false; | |
8875 } | |
8876 | |
8877 //----- (004A5048) -------------------------------------------------------- | |
670 | 8878 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
8879 { | |
8880 | |
8881 HWLTexture *sprite_texture; // eax@1 | |
0 | 8882 unsigned __int16 *v9; // edx@5 |
8883 LPVOID v10; // eax@5 | |
8884 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
8885 | |
670 | 8886 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
8887 if ( sprite_texture ) | |
8888 { | |
8889 _gpu_memory_used += 2 * sprite_texture->uWidth * sprite_texture->uHeight; | |
8890 pSprite->uAreaX = sprite_texture->uAreaX; | |
8891 pSprite->uAreaY = sprite_texture->uAreaY; | |
8892 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
8893 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
8894 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
8895 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8896 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8897 //v7 = v3->pRenderD3D; |
670 | 8898 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
0 | 8899 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
8900 //pSprite = v2->pTextureSurface; | |
8901 //pSprite = (Sprite *)pSprite->pName; | |
8902 //v8 = pSprite; | |
670 | 8903 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 8904 Dst.dwSize = 124; |
670 | 8905 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
8906 { | |
8907 v9 = sprite_texture->pPixels; | |
8908 v10 = Dst.lpSurface; | |
8909 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 8910 { |
670 | 8911 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
8912 { | |
0 | 8913 *(int *)v10 = *(int *)v9; |
8914 v9 += 2; | |
8915 v10 = (char *)v10 + 4; | |
670 | 8916 } |
8917 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 8918 } |
670 | 8919 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
8920 } | |
8921 free(sprite_texture->pPixels); | |
8922 free(sprite_texture); | |
8923 return true; | |
8924 } | |
8925 return false; | |
0 | 8926 } |
8927 | |
8928 //----- (004A51CB) -------------------------------------------------------- | |
8929 void Render::BeginScene() | |
8930 { | |
8931 Render *v1; // esi@1 | |
8932 unsigned int v2; // eax@1 | |
8933 int v3; // eax@5 | |
8934 unsigned __int16 **v4; // edi@6 | |
8935 char *v5; // ebx@7 | |
8936 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
8937 | |
8938 v1 = this; | |
8939 v2 = this->uNumSceneBegins; | |
8940 this->uNumSceneBegins = v2 + 1; | |
8941 if ( !v2 ) | |
8942 { | |
8943 if ( this->pRenderD3D ) | |
8944 { | |
8945 if ( this->bColorKeySupported ) | |
8946 { | |
8947 memset(&Dst, 0, 0x7Cu); | |
8948 Dst.dwSize = 124; | |
168 | 8949 if ( LockSurface_DDraw4(v1->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) ) |
0 | 8950 { |
8951 v1->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; | |
8952 v3 = Dst.lPitch >> 1; | |
8953 v1->uTargetSurfacePitch = Dst.lPitch >> 1; | |
8954 LABEL_10: | |
8955 v1->field_18_locked_pitch = v3; | |
8956 goto LABEL_11; | |
8957 } | |
8958 goto LABEL_8; | |
8959 } | |
8960 } | |
8961 else | |
8962 { | |
8963 v4 = &this->pTargetSurface; | |
8964 if ( !this->pTargetSurface ) | |
8965 { | |
8966 v5 = (char *)&this->uTargetSurfacePitch; | |
8967 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
8968 if ( *v4 ) | |
8969 { | |
8970 v3 = *(int *)v5; | |
8971 goto LABEL_10; | |
8972 } | |
8973 LABEL_8: | |
8974 --v1->uNumSceneBegins; | |
8975 return; | |
8976 } | |
8977 } | |
8978 LABEL_11: | |
8979 RestoreFrontBuffer(); | |
8980 } | |
8981 } | |
8982 | |
8983 //----- (004A527D) -------------------------------------------------------- | |
8984 void Render::EndScene() | |
8985 { | |
8986 unsigned int v1; // edx@1 | |
8987 unsigned int v2; // edx@2 | |
8988 HRESULT v3; // eax@5 | |
8989 | |
8990 v1 = this->uNumSceneBegins; | |
8991 if ( v1 ) | |
8992 { | |
8993 v2 = v1 - 1; | |
8994 this->uNumSceneBegins = v2; | |
8995 if ( !v2 ) | |
8996 { | |
8997 if ( this->pRenderD3D ) | |
8998 { | |
8999 if ( this->bColorKeySupported ) | |
9000 { | |
9001 this->pTargetSurface = 0; | |
9002 this->uTargetSurfacePitch = 0; | |
9003 this->field_18_locked_pitch = 0; | |
9004 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
9005 } | |
9006 } | |
9007 else | |
9008 { | |
9009 this->pTargetSurface = 0; | |
9010 this->uTargetSurfacePitch = 0; | |
9011 this->field_18_locked_pitch = 0; | |
9012 UnlockBackBuffer(); | |
9013 } | |
9014 } | |
9015 } | |
9016 } | |
9017 | |
9018 //----- ( ) -------------------------------------------------------- | |
9019 unsigned int Render::_4A52F1(unsigned int this_, float a3) | |
9020 { | |
9021 unsigned int v3; // esi@1 | |
9022 double v4; // st7@2 | |
9023 double v5; // st7@6 | |
9024 double v6; // st6@6 | |
9025 unsigned int v7; // eax@6 | |
9026 double v8; // st5@6 | |
9027 double v9; // st4@6 | |
9028 HRESULT v10; // eax@6 | |
9029 HRESULT v11; // eax@6 | |
9030 unsigned int result; // eax@6 | |
9031 unsigned int v13; // eax@7 | |
9032 unsigned __int16 *v14; // ecx@7 | |
9033 int *v15; // eax@7 | |
9034 unsigned int v16; // ecx@8 | |
9035 __int16 v17; // ax@10 | |
9036 int v18; // esi@10 | |
9037 float v19; // edi@10 | |
9038 void *v20; // esi@10 | |
9039 int v21; // edx@10 | |
9040 int v22; // ecx@11 | |
9041 int v23; // edx@12 | |
9042 __int16 v24; // ax@15 | |
9043 int v25; // esi@15 | |
9044 float v26; // edi@15 | |
9045 char *v27; // esi@15 | |
9046 int v28; // edx@15 | |
9047 int v29; // ecx@16 | |
9048 int v30; // edx@17 | |
9049 int v31; // [sp-Ch] [bp-ACh]@11 | |
9050 int v32; // [sp-Ch] [bp-ACh]@16 | |
9051 const char *v33; // [sp+0h] [bp-A0h]@0 | |
9052 int v34; // [sp+4h] [bp-9Ch]@0 | |
9053 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
9054 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
9055 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
9056 int v38; // [sp+90h] [bp-10h]@7 | |
9057 double v39; // [sp+94h] [bp-Ch]@6 | |
9058 float v40; // [sp+9Ch] [bp-4h]@6 | |
9059 | |
9060 auto ecx0 = this; | |
9061 v3 = 0; | |
9062 if ( ecx0->pRenderD3D ) | |
9063 { | |
9064 v4 = a3; | |
9065 if ( a3 <= 1.0 ) | |
9066 { | |
9067 if ( v4 < 0.0 ) | |
9068 v4 = 0.0; | |
9069 } | |
9070 else | |
9071 { | |
9072 v4 = 1.0; | |
9073 } | |
9074 a3 = v4 * 255.0; | |
9075 v39 = a3 + 6.7553994e15; | |
9076 LODWORD(v40) = LODWORD(v39); | |
693 | 9077 v5 = (double)(signed int)pViewport->uViewportTL_X; |
0 | 9078 v36[0].pos.x = v5; |
693 | 9079 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
0 | 9080 v7 = this_ | (LODWORD(v39) << 24); |
693 | 9081 this_ = pViewport->uViewportBR_Y + 1; |
0 | 9082 v36[0].specular = 0; |
9083 v36[0].pos.y = v6; | |
9084 v36[0].diffuse = v7; | |
9085 v36[1].diffuse = v7; | |
9086 v36[0].pos.z = 0.0; | |
9087 v36[2].diffuse = v7; | |
9088 v36[3].diffuse = v7; | |
9089 v36[0].rhw = 1.0; | |
9090 v36[1].specular = 0; | |
9091 v36[0].texcoord.x = 0.0; | |
9092 v36[2].specular = 0; | |
9093 v36[3].specular = 0; | |
9094 v36[0].texcoord.y = 0.0; | |
9095 v36[1].pos.x = v5; | |
693 | 9096 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 9097 v36[1].pos.y = v8; |
9098 v36[1].pos.z = 0.0; | |
9099 v36[1].rhw = 1.0; | |
9100 v36[1].texcoord.x = 0.0; | |
9101 v36[1].texcoord.y = 0.0; | |
693 | 9102 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 9103 v36[2].pos.x = v9; |
9104 v36[2].pos.y = v8; | |
9105 v36[2].pos.z = 0.0; | |
9106 v36[2].rhw = 1.0; | |
9107 v36[2].texcoord.x = 0.0; | |
9108 v36[2].texcoord.y = 0.0; | |
9109 v36[3].pos.x = v9; | |
9110 v36[3].pos.y = v6; | |
9111 v36[3].pos.z = 0.0; | |
9112 v36[3].rhw = 1.0; | |
9113 v36[3].texcoord.x = 0.0; | |
9114 v36[3].texcoord.y = 0.0; | |
9115 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 9116 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
9117 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9118 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9119 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
9120 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
9121 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9122 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 9123 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
9124 D3DPT_TRIANGLEFAN, | |
9125 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9126 v36, | |
9127 4, | |
9128 28)); | |
186 | 9129 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
9130 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9131 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9132 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9133 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9134 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
0 | 9135 } |
9136 else | |
9137 { | |
9138 v40 = (1.0 - a3) * 65536.0; | |
9139 v39 = v40 + 6.7553994e15; | |
9140 LODWORD(a3) = LODWORD(v39); | |
693 | 9141 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
9142 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
9143 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
9144 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 9145 v37 = 2 * v13; |
9146 LODWORD(v40) = (int)v14; | |
9147 | |
9148 int __i = 0; | |
9149 v15 = dword_F1B430; | |
9150 do | |
9151 { | |
9152 v16 = v3; | |
9153 v3 += LODWORD(a3); | |
9154 dword_F1B430[__i++] = v16 >> 16; | |
9155 } | |
9156 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
9157 while (__i < 32); | |
9158 | |
9159 if ( pRenderer->uTargetGBits == 6 ) | |
9160 { | |
9161 v17 = _42690D_colors_cvt(this_); | |
9162 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); | |
9163 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); | |
9164 v19 = v40; | |
9165 v20 = off_4EFDB0; | |
9166 v21 = HIDWORD(v39); | |
9167 do | |
9168 { | |
9169 v22 = v38; | |
9170 v31 = v21; | |
9171 do | |
9172 { | |
9173 v23 = (*(int *)((char *)v20 | |
9174 + ((((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; | |
9175 result = this_ | |
9176 + (*((int *)v20 | |
9177 + (((unsigned __int8)(*((char *)v20 | |
9178 + ((((unsigned __int16)(*(short *)((char *)v20 | |
9179 + ((*(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); | |
9180 *(unsigned int *)LODWORD(v19) = result; | |
9181 LODWORD(v19) += 4; | |
9182 --v22; | |
9183 } | |
9184 while ( v22 ); | |
9185 LODWORD(v19) += v37; | |
9186 v21 = v31 - 1; | |
9187 } | |
9188 while ( v31 != 1 ); | |
9189 } | |
9190 else | |
9191 { | |
9192 v24 = _4268E3_smthn_to_a1r5g5b5(this_); | |
9193 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); | |
9194 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
9195 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
9196 v26 = v40; | |
9197 v27 = (char *)off_4EFDB0; | |
9198 v28 = HIDWORD(v39); | |
9199 do | |
9200 { | |
9201 v29 = v38; | |
9202 v32 = v28; | |
9203 do | |
9204 { | |
9205 v30 = 32 | |
9206 * *(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; | |
9207 result = this_ | |
9208 + (*(int *)&v27[4 | |
9209 * (((unsigned __int8)(32 | |
9210 * 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); | |
9211 *(unsigned int *)LODWORD(v26) = result; | |
9212 LODWORD(v26) += 4; | |
9213 --v29; | |
9214 } | |
9215 while ( v29 ); | |
9216 LODWORD(v26) += v37; | |
9217 v28 = v32 - 1; | |
9218 } | |
9219 while ( v32 != 1 ); | |
9220 } | |
9221 } | |
9222 return result; | |
9223 } | |
9224 | |
9225 //----- (004A5B81) -------------------------------------------------------- | |
727 | 9226 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 9227 { |
9228 this->bClip = 1; | |
9229 this->uClipY = uY; | |
9230 this->uClipX = uX; | |
9231 this->uClipW = uW; | |
9232 this->uClipZ = uZ; | |
9233 } | |
9234 | |
9235 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 9236 void Render::ResetTextureClipRect() |
0 | 9237 { |
9238 this->uClipY = 0; | |
9239 this->uClipX = 0; | |
9240 this->bClip = 1; | |
9241 this->uClipW = 480; | |
9242 this->uClipZ = 640; | |
9243 } | |
9244 | |
9245 //----- (004A5BE3) -------------------------------------------------------- | |
9246 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
9247 { | |
9248 int v4; // edi@3 | |
9249 unsigned __int16 *v5; // edx@3 | |
9250 unsigned __int16 *v6; // esi@3 | |
9251 unsigned int v7; // ebx@4 | |
9252 unsigned int v8; // eax@5 | |
9253 unsigned int v9; // ebx@5 | |
9254 unsigned int v10; // eax@6 | |
9255 unsigned int v11; // eax@7 | |
9256 unsigned int v12; // ebx@8 | |
9257 unsigned int v13; // eax@10 | |
9258 unsigned int v14; // edi@11 | |
9259 unsigned int v15; // eax@14 | |
9260 unsigned int v16; // ebx@17 | |
9261 int v17; // eax@23 | |
9262 char v18; // zf@25 | |
9263 int v19; // [sp+10h] [bp-8h]@3 | |
9264 int v20; // [sp+14h] [bp-4h]@3 | |
9265 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
9266 int uOutXb; // [sp+20h] [bp+8h]@21 | |
9267 int v23; // [sp+28h] [bp+10h]@3 | |
9268 | |
9269 if ( this->uNumSceneBegins && a4 ) | |
9270 { | |
9271 v4 = a4->uWidth; | |
9272 v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
9273 v6 = a4->pPixels; | |
9274 v20 = v4; | |
9275 v23 = a4->uHeight; | |
9276 v19 = v4; | |
9277 if ( this->bClip ) | |
9278 { | |
9279 v7 = this->uClipX; | |
9280 if ( (signed int)uOutX < (signed int)v7 ) | |
9281 { | |
9282 v8 = v7 - uOutX; | |
9283 v9 = uOutX - v7; | |
9284 v8 *= 2; | |
9285 v4 += v9; | |
9286 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
9287 v20 += v9; | |
9288 v5 = (unsigned __int16 *)((char *)v5 + v8); | |
9289 } | |
9290 v10 = this->uClipY; | |
9291 if ( (signed int)uOutY < (signed int)v10 ) | |
9292 { | |
9293 v11 = v10 - uOutY; | |
9294 v6 += v19 * v11; | |
9295 v23 += uOutY - this->uClipY; | |
9296 v4 = v20; | |
9297 v5 += this->uTargetSurfacePitch * v11; | |
9298 } | |
9299 v12 = this->uClipX; | |
9300 if ( (signed int)v12 < (signed int)uOutX ) | |
9301 v12 = uOutX; | |
9302 v13 = this->uClipZ; | |
9303 if ( (signed int)(v4 + v12) > (signed int)v13 ) | |
9304 { | |
9305 v14 = this->uClipX; | |
9306 if ( (signed int)v14 < (signed int)uOutX ) | |
9307 v14 = uOutX; | |
9308 v4 = v13 - v14; | |
9309 } | |
9310 v15 = this->uClipY; | |
9311 if ( (signed int)v15 < (signed int)uOutY ) | |
9312 v15 = uOutY; | |
9313 uOutXa = this->uClipW; | |
9314 if ( (signed int)(v15 + v23) > (signed int)uOutXa ) | |
9315 { | |
9316 v16 = this->uClipY; | |
9317 if ( (signed int)v16 < (signed int)uOutY ) | |
9318 v16 = uOutY; | |
9319 v23 = uOutXa - v16; | |
9320 } | |
9321 } | |
9322 if ( v23 > 0 ) | |
9323 { | |
9324 uOutXb = v23; | |
9325 do | |
9326 { | |
9327 if ( v4 > 0 ) | |
9328 { | |
9329 v17 = v4; | |
9330 do | |
9331 { | |
9332 *v5 = *v6; | |
9333 ++v5; | |
9334 ++v6; | |
9335 --v17; | |
9336 } | |
9337 while ( v17 ); | |
9338 } | |
9339 v6 += v19 - v4; | |
9340 v18 = uOutXb-- == 1; | |
9341 v5 += this->uTargetSurfacePitch - v4; | |
9342 } | |
9343 while ( !v18 ); | |
9344 } | |
9345 } | |
9346 } | |
9347 | |
9348 //----- (004A5D33) -------------------------------------------------------- | |
9349 void Render::_4A5D33(unsigned int pX, unsigned int pY, int a4, int a5, RGBTexture *pTexture) | |
9350 { | |
9351 Render *v6; // esi@1 | |
9352 unsigned __int16 *v7; // ebx@3 | |
9353 int v8; // ecx@3 | |
9354 int v9; // edx@3 | |
9355 int v10; // ecx@3 | |
9356 int v11; // edi@3 | |
9357 signed int v12; // eax@4 | |
9358 unsigned int v13; // eax@5 | |
9359 signed int v14; // eax@6 | |
9360 unsigned int v15; // eax@7 | |
9361 unsigned int v16; // edx@8 | |
9362 int v17; // eax@10 | |
9363 unsigned int v18; // ecx@11 | |
9364 unsigned int v19; // ecx@14 | |
9365 int v20; // eax@16 | |
9366 unsigned int v21; // ecx@17 | |
9367 int v22; // eax@21 | |
9368 int v23; // edi@23 | |
9369 int v24; // [sp+Ch] [bp-4h]@3 | |
9370 int a2a; // [sp+18h] [bp+8h]@21 | |
9371 unsigned int teal; // [sp+1Ch] [bp+Ch]@20 | |
9372 int a4a; // [sp+20h] [bp+10h]@3 | |
9373 int a4b; // [sp+20h] [bp+10h]@21 | |
9374 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 | |
9375 | |
9376 v6 = this; | |
9377 if ( this->uNumSceneBegins && pTexture ) | |
9378 { | |
9379 v7 = &this->pTargetSurface[pX + pY * this->uTargetSurfacePitch]; | |
9380 v8 = pTexture->uWidth; | |
9381 v24 = pTexture->uWidth; | |
9382 v9 = a4 + a5 * v8; | |
9383 v10 = v8 - a4; | |
9384 a4a = v10; | |
9385 v11 = pTexture->uHeight - a5; | |
9386 pTexturea = &pTexture->pPixels[v9]; | |
9387 if ( v6->bClip ) | |
9388 { | |
9389 v12 = v6->uClipX; | |
9390 if ( (signed int)pX < v12 ) | |
9391 { | |
9392 v13 = 2 * (v12 - pX); | |
9393 pTexturea = (unsigned __int16 *)((char *)pTexturea + v13); | |
9394 v10 += pX - v6->uClipX; | |
9395 v7 = (unsigned __int16 *)((char *)v7 + v13); | |
9396 a4a = v10; | |
9397 } | |
9398 v14 = v6->uClipY; | |
9399 if ( (signed int)pY < v14 ) | |
9400 { | |
9401 v15 = v14 - pY; | |
9402 pTexturea += v24 * v15; | |
9403 v11 += pY - v6->uClipY; | |
9404 v10 = a4a; | |
9405 v7 += v6->uTargetSurfacePitch * v15; | |
9406 } | |
9407 v16 = v6->uClipX; | |
9408 if ( (signed int)v16 < (signed int)pX ) | |
9409 v16 = pX; | |
9410 v17 = v6->uClipZ; | |
9411 if ( (signed int)(v10 + v16) > v17 ) | |
9412 { | |
9413 v18 = v6->uClipX; | |
9414 if ( (signed int)v18 < (signed int)pX ) | |
9415 v18 = pX; | |
9416 a4a = v17 - v18; | |
9417 } | |
9418 v19 = v6->uClipY; | |
9419 if ( (signed int)v19 < (signed int)pY ) | |
9420 v19 = pY; | |
9421 v20 = v6->uClipW; | |
9422 if ( (signed int)(v11 + v19) > v20 ) | |
9423 { | |
9424 v21 = v6->uClipY; | |
9425 if ( (signed int)v21 < (signed int)pY ) | |
9426 v21 = pY; | |
9427 v11 = v20 - v21; | |
9428 } | |
9429 } | |
9430 teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu); | |
9431 if ( v11 > 0 ) | |
9432 { | |
9433 v22 = a4a; | |
9434 a2a = v11; | |
9435 a4b = 2 * (v24 - a4a); | |
9436 do | |
9437 { | |
9438 if ( v22 > 0 ) | |
9439 { | |
9440 v23 = v22; | |
9441 do | |
9442 { | |
9443 if ( *pTexturea != teal ) | |
9444 *v7 = *pTexturea; | |
9445 ++pTexturea; | |
9446 ++v7; | |
9447 --v23; | |
9448 } | |
9449 while ( v23 ); | |
9450 } | |
9451 v7 += v6->uTargetSurfacePitch - v22; | |
9452 pTexturea = (unsigned __int16 *)((char *)pTexturea + a4b); | |
9453 --a2a; | |
9454 } | |
9455 while ( a2a ); | |
9456 } | |
9457 } | |
9458 } | |
9459 | |
9460 //----- (004A6E7E) -------------------------------------------------------- | |
9461 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) | |
9462 { | |
9463 unsigned __int16 *v4; // eax@4 | |
9464 int v5; // edx@4 | |
9465 unsigned int v6; // edi@4 | |
9466 unsigned int v7; // edx@5 | |
9467 unsigned int v8; // edx@6 | |
9468 unsigned int v9; // edx@7 | |
9469 unsigned int v10; // edx@8 | |
9470 unsigned int v11; // ebx@9 | |
9471 unsigned int v12; // esi@11 | |
9472 unsigned int v13; // edx@12 | |
9473 unsigned int v14; // ebx@15 | |
9474 unsigned int v15; // esi@17 | |
9475 unsigned int v16; // edi@18 | |
9476 char v17; // zf@29 | |
9477 int v18; // [sp+14h] [bp-Ch]@4 | |
9478 int v19; // [sp+18h] [bp-8h]@4 | |
9479 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
9480 int v21; // [sp+28h] [bp+8h]@25 | |
9481 int v22; // [sp+28h] [bp+8h]@34 | |
9482 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
9483 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
9484 | |
9485 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
9486 { | |
9487 v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 9488 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 9489 v5 = a4->uTextureWidth; |
9490 v6 = a4->uTextureHeight; | |
9491 v19 = a4->uTextureWidth; | |
9492 v18 = a4->uTextureWidth; | |
9493 if ( this->bClip ) | |
9494 { | |
9495 v7 = this->uClipX; | |
9496 if ( (signed int)a2 < (signed int)v7 ) | |
9497 { | |
9498 v8 = v7 - a2; | |
9499 v20 += v8; | |
9500 v19 += a2 - this->uClipX; | |
9501 v4 += v8; | |
9502 } | |
9503 v9 = this->uClipY; | |
9504 if ( (signed int)a3 < (signed int)v9 ) | |
9505 { | |
9506 v10 = v9 - a3; | |
9507 v20 += v18 * v10; | |
9508 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
9509 v4 += this->uTargetSurfacePitch * v10; | |
9510 } | |
9511 v11 = this->uClipX; | |
9512 v5 = v19; | |
9513 if ( (signed int)v11 < (signed int)a2 ) | |
9514 v11 = a2; | |
9515 v12 = this->uClipZ; | |
9516 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
9517 { | |
9518 v13 = this->uClipX; | |
9519 if ( (signed int)v13 < (signed int)a2 ) | |
9520 v13 = a2; | |
9521 v5 = v12 - v13; | |
9522 } | |
9523 v14 = this->uClipY; | |
9524 if ( (signed int)v14 < (signed int)a3 ) | |
9525 v14 = a3; | |
9526 v15 = this->uClipW; | |
9527 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
9528 { | |
9529 v16 = this->uClipY; | |
9530 if ( (signed int)v16 < (signed int)a3 ) | |
9531 v16 = a3; | |
9532 v6 = v15 - v16; | |
9533 } | |
9534 } | |
9535 if ( pRenderer->uTargetGBits == 5 ) | |
9536 { | |
9537 if ( (signed int)v6 > 0 ) | |
9538 { | |
9539 v23 = v6; | |
9540 do | |
9541 { | |
9542 if ( v5 > 0 ) | |
9543 { | |
9544 v21 = v5; | |
9545 do | |
9546 { | |
9547 if ( *v20 ) | |
9548 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
9549 ++v4; | |
9550 ++v20; | |
9551 --v21; | |
9552 } | |
9553 while ( v21 ); | |
9554 } | |
9555 v20 += v18 - v5; | |
9556 v17 = v23-- == 1; | |
9557 v4 += this->uTargetSurfacePitch - v5; | |
9558 } | |
9559 while ( !v17 ); | |
9560 } | |
9561 } | |
9562 else | |
9563 { | |
9564 if ( (signed int)v6 > 0 ) | |
9565 { | |
9566 v24 = v6; | |
9567 do | |
9568 { | |
9569 if ( v5 > 0 ) | |
9570 { | |
9571 v22 = v5; | |
9572 do | |
9573 { | |
9574 if ( *v20 ) | |
9575 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
9576 ++v4; | |
9577 ++v20; | |
9578 --v22; | |
9579 } | |
9580 while ( v22 ); | |
9581 } | |
9582 v20 += v18 - v5; | |
9583 v17 = v24-- == 1; | |
9584 v4 += this->uTargetSurfacePitch - v5; | |
9585 } | |
9586 while ( !v17 ); | |
9587 } | |
9588 } | |
9589 } | |
9590 } | |
9591 | |
9592 //----- (004A6DF5) -------------------------------------------------------- | |
9593 int Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) | |
9594 { | |
9595 int result; // eax@0 | |
9596 int v8; // ecx@3 | |
9597 unsigned __int16 *v9; // edi@4 | |
9598 unsigned __int16 *v10; // ebx@4 | |
9599 int v11; // esi@4 | |
9600 unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3 | |
9601 unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3 | |
9602 | |
9603 if ( pBitmap ) | |
9604 { | |
9605 if ( pTarget ) | |
9606 { | |
9607 pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y]; | |
9608 pTargeta = &pTarget[a7->x + uTargetPitch * a7->y]; | |
9609 v8 = a7->z - a7->x; | |
9610 result = a7->w - a7->y; | |
9611 if ( result > 0 ) | |
9612 { | |
9613 v9 = pBitmapa; | |
9614 v10 = pTargeta; | |
9615 v11 = a7->w - a7->y; | |
9616 do | |
9617 { | |
9618 if ( v8 > 0 ) | |
9619 { | |
9620 result = v8; | |
9621 do | |
9622 { | |
9623 *v9 = *v10; | |
9624 ++v9; | |
9625 ++v10; | |
9626 --result; | |
9627 } | |
9628 while ( result ); | |
9629 } | |
9630 v9 += uBitmapPitch - v8; | |
9631 v10 += uTargetPitch - v8; | |
9632 --v11; | |
9633 } | |
9634 while ( v11 ); | |
9635 } | |
9636 } | |
9637 } | |
9638 return result; | |
9639 } | |
9640 | |
9641 //----- (004A6D87) -------------------------------------------------------- | |
9642 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
9643 { | |
9644 if (!uNumSceneBegins) | |
9645 return; | |
9646 | |
9647 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
9648 for (uint y = 0; y < uHeight; ++y) | |
9649 { | |
9650 auto pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch]; | |
9651 | |
9652 memset32(pDst, twoColors, uWidth / 2); | |
9653 if (uWidth & 1) | |
9654 pDst[uWidth - 1] = uColor16; | |
9655 } | |
9656 } | |
9657 | |
9658 //----- (004A6C4F) -------------------------------------------------------- | |
9659 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) | |
9660 { | |
9661 unsigned int v9; // edi@2 | |
9662 unsigned int v10; // esi@2 | |
9663 unsigned __int16 *v11; // eax@2 | |
9664 unsigned int v12; // ebx@3 | |
9665 signed int v13; // edx@5 | |
9666 int v14; // edx@6 | |
9667 signed int v15; // ebx@7 | |
9668 unsigned int v16; // edx@9 | |
9669 signed int v17; // edi@10 | |
9670 signed int v18; // ebx@13 | |
9671 unsigned int v19; // edx@15 | |
9672 signed int v20; // esi@16 | |
9673 unsigned int v21; // esi@22 | |
9674 unsigned __int16 v22; // dx@24 | |
9675 char v23; // zf@28 | |
9676 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 | |
9677 unsigned int uOutXa; // [sp+18h] [bp+8h]@20 | |
9678 | |
9679 if ( this->uNumSceneBegins ) | |
9680 { | |
9681 v9 = uCharWidth; | |
9682 v10 = uCharHeight; | |
9683 v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
9684 v24 = pFontPixels; | |
9685 if ( this->bClip ) | |
9686 { | |
9687 v12 = this->uClipX; | |
9688 if ( uOutX < (signed int)v12 ) | |
9689 { | |
9690 v24 = &pFontPixels[v12 - uOutX]; | |
9691 v11 += v12 - uOutX; | |
9692 v9 = uCharWidth + uOutX - v12; | |
9693 } | |
9694 v13 = this->uClipY; | |
9695 if ( uOutY < v13 ) | |
9696 { | |
9697 v14 = v13 - uOutY; | |
9698 v24 += uCharWidth * v14; | |
9699 v10 = uCharHeight + uOutY - this->uClipY; | |
9700 v11 += this->uTargetSurfacePitch * v14; | |
9701 } | |
9702 v15 = this->uClipX; | |
9703 if ( v15 < uOutX ) | |
9704 v15 = uOutX; | |
9705 v16 = this->uClipZ; | |
9706 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
9707 { | |
9708 v17 = this->uClipX; | |
9709 if ( v17 < uOutX ) | |
9710 v17 = uOutX; | |
9711 v9 = v16 - v17; | |
9712 } | |
9713 v18 = this->uClipY; | |
9714 if ( v18 < uOutY ) | |
9715 v18 = uOutY; | |
9716 v19 = this->uClipW; | |
9717 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
9718 { | |
9719 v20 = this->uClipY; | |
9720 if ( v20 < uOutY ) | |
9721 v20 = uOutY; | |
9722 v10 = v19 - v20; | |
9723 } | |
9724 } | |
9725 if ( (signed int)v10 > 0 ) | |
9726 { | |
9727 uOutXa = v10; | |
9728 do | |
9729 { | |
9730 if ( (signed int)v9 > 0 ) | |
9731 { | |
9732 v21 = v9; | |
9733 do | |
9734 { | |
9735 if ( *v24 ) | |
9736 { | |
9737 v22 = uShadowColor; | |
9738 if ( *v24 != 1 ) | |
9739 v22 = uFaceColor; | |
9740 *v11 = v22; | |
9741 } | |
9742 ++v11; | |
9743 ++v24; | |
9744 --v21; | |
9745 } | |
9746 while ( v21 ); | |
9747 } | |
9748 v24 += uCharWidth - v9; | |
9749 v23 = uOutXa-- == 1; | |
9750 v11 += this->uTargetSurfacePitch - v9; | |
9751 } | |
9752 while ( !v23 ); | |
9753 } | |
9754 } | |
9755 } | |
9756 | |
9757 //----- (004A6A68) -------------------------------------------------------- | |
9758 void Render::_4A6A68(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) | |
9759 { | |
9760 Render *v5; // ebx@1 | |
9761 unsigned __int16 v6; // ax@1 | |
9762 | |
9763 v5 = this; | |
9764 | |
9765 Texture tex; // [sp+Ch] [bp-48h]@1 | |
9766 //Texture::Texture(&tex); | |
9767 | |
9768 v6 = a4->uTextureHeight - height; | |
9769 memcpy(&tex, a4, sizeof(tex)); | |
9770 tex.uTextureHeight = v6; | |
9771 if ( (signed __int16)v6 > 0 ) | |
9772 DrawTextureIndexed(a2, a3, &tex); | |
9773 } | |
9774 | |
9775 //----- (004A6AB1) -------------------------------------------------------- | |
9776 void Render::DrawTextPalette(int x, int y, int a4, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8) | |
9777 { | |
9778 int v8; // edi@2 | |
9779 unsigned int v9; // esi@2 | |
9780 unsigned __int16 *v10; // eax@2 | |
9781 unsigned char *v11; // edx@2 | |
9782 unsigned int v12; // ebx@3 | |
9783 signed int v13; // edx@5 | |
9784 int v14; // edx@6 | |
9785 signed int v15; // ebx@7 | |
9786 unsigned int v16; // edx@9 | |
9787 signed int v17; // edi@10 | |
9788 signed int v18; // ebx@13 | |
9789 unsigned int v19; // edx@15 | |
9790 signed int v20; // esi@16 | |
9791 int v21; // ebx@22 | |
9792 char v22; // zf@28 | |
9793 int v23; // ebx@31 | |
9794 unsigned __int16 v24; // si@35 | |
9795 int v25; // [sp+Ch] [bp-4h]@2 | |
9796 int v26; // [sp+1Ch] [bp+Ch]@24 | |
9797 int v27; // [sp+1Ch] [bp+Ch]@33 | |
9798 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
9799 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
9800 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
9801 | |
9802 auto a2 = x; | |
9803 auto a3 = y; | |
9804 auto a6 = uFontHeight; | |
9805 if ( this->uNumSceneBegins ) | |
9806 { | |
9807 v8 = a5; | |
9808 v9 = a6; | |
9809 v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; | |
9810 v11 = (unsigned char *)a4; | |
9811 v25 = a4; | |
9812 if ( this->bClip ) | |
9813 { | |
9814 v12 = this->uClipX; | |
9815 if ( a2 < (signed int)v12 ) | |
9816 { | |
9817 v25 = v12 - a2 + a4; | |
9818 v10 += v12 - a2; | |
9819 v8 = a5 + a2 - v12; | |
9820 } | |
9821 v13 = this->uClipY; | |
9822 if ( a3 < v13 ) | |
9823 { | |
9824 v14 = v13 - a3; | |
9825 v25 += a5 * v14; | |
9826 v9 = a6 + a3 - this->uClipY; | |
9827 v10 += this->uTargetSurfacePitch * v14; | |
9828 } | |
9829 v15 = this->uClipX; | |
9830 if ( v15 < a2 ) | |
9831 v15 = a2; | |
9832 v16 = this->uClipZ; | |
9833 if ( v8 + v15 > (signed int)v16 ) | |
9834 { | |
9835 v17 = this->uClipX; | |
9836 if ( v17 < a2 ) | |
9837 v17 = a2; | |
9838 v8 = v16 - v17; | |
9839 } | |
9840 v18 = this->uClipY; | |
9841 if ( v18 < a3 ) | |
9842 v18 = a3; | |
9843 v19 = this->uClipW; | |
9844 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
9845 { | |
9846 v20 = this->uClipY; | |
9847 if ( v20 < a3 ) | |
9848 v20 = a3; | |
9849 v9 = v19 - v20; | |
9850 } | |
9851 v11 = (unsigned char *)v25; | |
9852 } | |
9853 if ( a8 ) | |
9854 { | |
9855 v28 = pRenderer->uTargetGMask | pRenderer->uTargetBMask; | |
9856 if ( (signed int)v9 > 0 ) | |
9857 { | |
9858 v23 = a5; | |
9859 v30 = v9; | |
9860 do | |
9861 { | |
9862 if ( v8 > 0 ) | |
9863 { | |
9864 v27 = v8; | |
9865 do | |
9866 { | |
9867 if ( *v11 ) | |
9868 v24 = pPalette[*v11]; | |
9869 else | |
9870 v24 = v28; | |
9871 *v10 = v24; | |
9872 ++v10; | |
9873 ++v11; | |
9874 --v27; | |
9875 } | |
9876 while ( v27 ); | |
9877 } | |
9878 v11 += v23 - v8; | |
9879 v22 = v30-- == 1; | |
9880 v10 += this->uTargetSurfacePitch - v8; | |
9881 } | |
9882 while ( !v22 ); | |
9883 } | |
9884 } | |
9885 else | |
9886 { | |
9887 if ( (signed int)v9 > 0 ) | |
9888 { | |
9889 v21 = a5; | |
9890 v29 = v9; | |
9891 do | |
9892 { | |
9893 if ( v8 > 0 ) | |
9894 { | |
9895 v26 = v8; | |
9896 do | |
9897 { | |
9898 if ( *v11 ) | |
9899 *v10 = pPalette[*v11]; | |
9900 ++v10; | |
9901 ++v11; | |
9902 --v26; | |
9903 } | |
9904 while ( v26 ); | |
9905 } | |
9906 v11 += v21 - v8; | |
9907 v22 = v29-- == 1; | |
9908 v10 += this->uTargetSurfacePitch - v8; | |
9909 } | |
9910 while ( !v22 ); | |
9911 } | |
9912 } | |
9913 } | |
9914 } | |
9915 | |
9916 //----- (004A68EF) -------------------------------------------------------- | |
9917 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
9918 { | |
9919 Texture *v4; // edi@2 | |
9920 unsigned int v5; // ebx@4 | |
9921 unsigned __int16 *v6; // eax@4 | |
9922 signed int v7; // edx@5 | |
9923 int v8; // edx@6 | |
9924 signed int v9; // edx@7 | |
9925 int v10; // edx@8 | |
9926 signed int v11; // edx@9 | |
9927 signed int v12; // esi@12 | |
9928 signed int v13; // esi@15 | |
9929 unsigned int v14; // edx@17 | |
9930 signed int v15; // esi@18 | |
9931 unsigned __int8 *v16; // ebx@22 | |
9932 char v17; // zf@28 | |
9933 int v18; // [sp+10h] [bp-10h]@4 | |
9934 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
9935 int v20; // [sp+1Ch] [bp-4h]@4 | |
9936 int v21; // [sp+28h] [bp+8h]@24 | |
9937 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
9938 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
9939 | |
9940 if ( this->uNumSceneBegins ) | |
9941 { | |
9942 v4 = pTexture; | |
9943 if ( pTexture ) | |
9944 { | |
9945 if ( pTexture->pPalette16 ) | |
9946 { | |
9947 v5 = pTexture->uTextureHeight; | |
9948 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 9949 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 9950 v20 = pTexture->uTextureWidth; |
9951 v18 = pTexture->uTextureWidth; | |
9952 if ( this->bClip ) | |
9953 { | |
9954 v7 = this->uClipX; | |
9955 if ( a2 < v7 ) | |
9956 { | |
9957 v8 = v7 - a2; | |
9958 v19 += v8; | |
9959 v20 += a2 - this->uClipX; | |
9960 v6 += v8; | |
9961 } | |
9962 v9 = this->uClipY; | |
9963 v5 = pTexture->uTextureHeight; | |
9964 if ( a3 < v9 ) | |
9965 { | |
9966 v10 = v9 - a3; | |
9967 v19 += v18 * v10; | |
9968 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
9969 v4 = pTexture; | |
9970 v6 += this->uTargetSurfacePitch * v10; | |
9971 } | |
9972 v11 = this->uClipX; | |
9973 if ( v11 < a2 ) | |
9974 v11 = a2; | |
9975 pTexturea = this->uClipZ; | |
9976 if ( v11 + v20 > (signed int)pTexturea ) | |
9977 { | |
9978 v12 = this->uClipX; | |
9979 if ( v12 < a2 ) | |
9980 v12 = a2; | |
9981 v20 = pTexturea - v12; | |
9982 } | |
9983 v13 = this->uClipY; | |
9984 if ( v13 < a3 ) | |
9985 v13 = a3; | |
9986 v14 = this->uClipW; | |
9987 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
9988 { | |
9989 v15 = this->uClipY; | |
9990 if ( v15 < a3 ) | |
9991 v15 = a3; | |
9992 v5 = v14 - v15; | |
9993 } | |
9994 } | |
9995 if ( (signed int)v5 > 0 ) | |
9996 { | |
9997 v22 = v5; | |
9998 v16 = v19; | |
9999 do | |
10000 { | |
10001 if ( v20 > 0 ) | |
10002 { | |
10003 v21 = v20; | |
10004 do | |
10005 { | |
10006 if ( *v16 ) | |
10007 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
10008 ++v6; | |
10009 ++v16; | |
10010 --v21; | |
10011 } | |
10012 while ( v21 ); | |
10013 } | |
10014 v16 += v18 - v20; | |
10015 v17 = v22-- == 1; | |
10016 v6 += this->uTargetSurfacePitch - v20; | |
10017 } | |
10018 while ( !v17 ); | |
10019 } | |
10020 } | |
10021 } | |
10022 } | |
10023 } | |
10024 | |
10025 //----- (004A6776) -------------------------------------------------------- | |
315 | 10026 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 10027 { |
10028 Texture *v4; // edi@2 | |
10029 unsigned int v5; // ebx@4 | |
10030 unsigned __int16 *v6; // eax@4 | |
10031 unsigned int v7; // edx@5 | |
10032 unsigned int v8; // edx@6 | |
10033 unsigned int v9; // edx@7 | |
10034 unsigned int v10; // edx@8 | |
10035 unsigned int v11; // edx@9 | |
10036 unsigned int v12; // esi@12 | |
10037 unsigned int v13; // esi@15 | |
10038 unsigned int v14; // edx@17 | |
10039 unsigned int v15; // esi@18 | |
10040 unsigned __int8 *v16; // ebx@22 | |
10041 char v17; // zf@28 | |
10042 int v18; // [sp+10h] [bp-10h]@4 | |
10043 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10044 int v20; // [sp+1Ch] [bp-4h]@4 | |
10045 int a2a; // [sp+28h] [bp+8h]@24 | |
10046 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
10047 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
10048 | |
10049 if ( this->uNumSceneBegins ) | |
10050 { | |
10051 v4 = a4; | |
10052 if ( a4 ) | |
10053 { | |
10054 if ( a4->pPalette16 ) | |
10055 { | |
10056 v5 = a4->uTextureHeight; | |
10057 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 10058 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10059 v20 = a4->uTextureWidth; |
10060 v18 = a4->uTextureWidth; | |
10061 if ( this->bClip ) | |
10062 { | |
10063 v7 = this->uClipX; | |
10064 if ( (signed int)a2 < (signed int)v7 ) | |
10065 { | |
10066 v8 = v7 - a2; | |
10067 v19 += v8; | |
10068 v20 += a2 - this->uClipX; | |
10069 v6 += v8; | |
10070 } | |
10071 v9 = this->uClipY; | |
10072 v5 = a4->uTextureHeight; | |
10073 if ( (signed int)a3 < (signed int)v9 ) | |
10074 { | |
10075 v10 = v9 - a3; | |
10076 v19 += v18 * v10; | |
10077 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
10078 v4 = a4; | |
10079 v6 += this->uTargetSurfacePitch * v10; | |
10080 } | |
10081 v11 = this->uClipX; | |
10082 if ( (signed int)v11 < (signed int)a2 ) | |
10083 v11 = a2; | |
10084 a4a = this->uClipZ; | |
10085 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
10086 { | |
10087 v12 = this->uClipX; | |
10088 if ( (signed int)v12 < (signed int)a2 ) | |
10089 v12 = a2; | |
10090 v20 = a4a - v12; | |
10091 } | |
10092 v13 = this->uClipY; | |
10093 if ( (signed int)v13 < (signed int)a3 ) | |
10094 v13 = a3; | |
10095 v14 = this->uClipW; | |
10096 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10097 { | |
10098 v15 = this->uClipY; | |
10099 if ( (signed int)v15 < (signed int)a3 ) | |
10100 v15 = a3; | |
10101 v5 = v14 - v15; | |
10102 } | |
10103 } | |
10104 if ( (signed int)v5 > 0 ) | |
10105 { | |
10106 a3a = v5; | |
10107 v16 = v19; | |
10108 do | |
10109 { | |
10110 if ( v20 > 0 ) | |
10111 { | |
10112 a2a = v20; | |
10113 do | |
10114 { | |
10115 if ( *v16 ) | |
10116 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
10117 ++v6; | |
10118 ++v16; | |
10119 --a2a; | |
10120 } | |
10121 while ( a2a ); | |
10122 } | |
10123 v16 += v18 - v20; | |
10124 v17 = a3a-- == 1; | |
10125 v6 += this->uTargetSurfacePitch - v20; | |
10126 } | |
10127 while ( !v17 ); | |
10128 } | |
10129 } | |
10130 } | |
10131 } | |
10132 } | |
10133 | |
10134 //----- (004A65CC) -------------------------------------------------------- | |
10135 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
10136 { | |
10137 unsigned __int16 *v8; // esi@6 | |
10138 unsigned int v9; // edi@6 | |
10139 unsigned int v10; // eax@7 | |
10140 unsigned int v11; // eax@8 | |
10141 unsigned int v12; // eax@9 | |
10142 unsigned int v13; // eax@10 | |
10143 unsigned int v14; // edx@11 | |
10144 unsigned int v15; // eax@13 | |
10145 unsigned int v16; // edx@14 | |
10146 unsigned int v17; // edx@17 | |
10147 unsigned int v18; // eax@19 | |
10148 unsigned int v19; // edx@20 | |
10149 int v20; // eax@27 | |
10150 int v21; // edx@29 | |
10151 int v22; // [sp+Ch] [bp-Ch]@6 | |
10152 int v23; // [sp+Ch] [bp-Ch]@24 | |
10153 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
10154 int xa; // [sp+20h] [bp+8h]@26 | |
10155 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
10156 int v27; // [sp+2Ch] [bp+14h]@6 | |
10157 | |
10158 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
10159 { | |
10160 v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch]; | |
710 | 10161 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10162 v27 = a4->uTextureWidth; |
10163 v9 = a4->uTextureHeight; | |
10164 v22 = a4->uTextureWidth; | |
10165 if ( this->bClip ) | |
10166 { | |
10167 v10 = this->uClipX; | |
10168 if ( (signed int)x < (signed int)v10 ) | |
10169 { | |
10170 v11 = v10 - x; | |
10171 v24 += v11; | |
10172 v27 += x - this->uClipX; | |
10173 v8 += v11; | |
10174 } | |
10175 v12 = this->uClipY; | |
10176 if ( (signed int)y < (signed int)v12 ) | |
10177 { | |
10178 v13 = v12 - y; | |
10179 v24 += v22 * v13; | |
10180 v9 = y - this->uClipY + a4->uTextureHeight; | |
10181 v8 += this->uTargetSurfacePitch * v13; | |
10182 } | |
10183 v14 = this->uClipX; | |
10184 if ( (signed int)v14 < (signed int)x ) | |
10185 v14 = x; | |
10186 v15 = this->uClipZ; | |
10187 if ( (signed int)(v27 + v14) > (signed int)v15 ) | |
10188 { | |
10189 v16 = this->uClipX; | |
10190 if ( (signed int)v16 < (signed int)x ) | |
10191 v16 = x; | |
10192 v27 = v15 - v16; | |
10193 } | |
10194 v17 = this->uClipY; | |
10195 if ( (signed int)v17 < (signed int)y ) | |
10196 v17 = y; | |
10197 v18 = this->uClipW; | |
10198 if ( (signed int)(v9 + v17) > (signed int)v18 ) | |
10199 { | |
10200 v19 = this->uClipY; | |
10201 if ( (signed int)v19 < (signed int)y ) | |
10202 v19 = y; | |
10203 v9 = v18 - v19; | |
10204 } | |
10205 } | |
10206 if ( (signed int)v9 > 0 ) | |
10207 { | |
10208 ya = v9; | |
10209 v23 = v22 - v27; | |
10210 do | |
10211 { | |
10212 if ( v27 > 0 ) | |
10213 { | |
10214 xa = v27; | |
10215 do | |
10216 { | |
10217 v20 = *v24; | |
10218 if ( v20 >= a7 && v20 <= a8 ) | |
10219 { | |
10220 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
10221 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
10222 v21 = 2 * a8 - v21 - a7; | |
10223 *v8 = a4->pPalette16[v21]; | |
10224 } | |
10225 ++v8; | |
10226 ++v24; | |
10227 --xa; | |
10228 } | |
10229 while ( xa ); | |
10230 } | |
10231 v8 += this->uTargetSurfacePitch - v27; | |
10232 v24 += v23; | |
10233 --ya; | |
10234 } | |
10235 while ( ya ); | |
10236 } | |
10237 } | |
10238 } | |
10239 | |
10240 //----- (004A63E6) -------------------------------------------------------- | |
10241 void Render::_4A63E6(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
10242 { | |
10243 Texture *v8; // eax@2 | |
10244 Texture *v9; // ebx@4 | |
10245 unsigned __int16 *v10; // esi@6 | |
10246 unsigned int v11; // edi@7 | |
10247 unsigned int v12; // eax@9 | |
10248 unsigned int v13; // eax@10 | |
10249 unsigned int v14; // edx@11 | |
10250 unsigned int v15; // eax@13 | |
10251 unsigned int v16; // edx@14 | |
10252 unsigned int v17; // edx@17 | |
10253 unsigned int v18; // eax@19 | |
10254 unsigned int v19; // edx@20 | |
10255 int v20; // eax@27 | |
10256 int v21; // edx@29 | |
10257 int v22; // [sp+Ch] [bp-Ch]@6 | |
10258 int v23; // [sp+Ch] [bp-Ch]@24 | |
10259 int v24; // [sp+10h] [bp-8h]@6 | |
10260 int v25; // [sp+14h] [bp-4h]@6 | |
10261 int i; // [sp+20h] [bp+8h]@25 | |
10262 int v27; // [sp+24h] [bp+Ch]@23 | |
10263 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
10264 | |
10265 if ( this->uNumSceneBegins ) | |
10266 { | |
10267 v8 = a4; | |
10268 if ( a4 ) | |
10269 { | |
10270 if ( a4->pPalette16 ) | |
10271 { | |
10272 v9 = a5; | |
10273 if ( a5 ) | |
10274 { | |
10275 if ( a5->pPalette16 ) | |
10276 { | |
10277 v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 10278 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10279 v25 = v8->uTextureWidth; |
10280 v24 = v8->uTextureHeight; | |
10281 v22 = v8->uTextureWidth; | |
10282 if ( this->bClip ) | |
10283 { | |
10284 v11 = this->uClipX; | |
10285 if ( (signed int)a2 < (signed int)v11 ) | |
10286 { | |
10287 v28 += v11 - a2; | |
10288 v25 += a2 - v11; | |
10289 v9 = a5; | |
10290 v10 += v11 - a2; | |
10291 } | |
10292 v12 = this->uClipY; | |
10293 if ( (signed int)a3 < (signed int)v12 ) | |
10294 { | |
10295 v13 = v12 - a3; | |
10296 v9 = a5; | |
10297 v28 += v22 * v13; | |
10298 v24 += a3 - this->uClipY; | |
10299 v10 += this->uTargetSurfacePitch * v13; | |
10300 } | |
10301 v14 = this->uClipX; | |
10302 if ( (signed int)v14 < (signed int)a2 ) | |
10303 v14 = a2; | |
10304 v15 = this->uClipZ; | |
10305 if ( (signed int)(v25 + v14) > (signed int)v15 ) | |
10306 { | |
10307 v16 = this->uClipX; | |
10308 if ( (signed int)v16 < (signed int)a2 ) | |
10309 v16 = a2; | |
10310 v25 = v15 - v16; | |
10311 } | |
10312 v17 = this->uClipY; | |
10313 if ( (signed int)v17 < (signed int)a3 ) | |
10314 v17 = a3; | |
10315 v18 = this->uClipW; | |
10316 if ( (signed int)(v24 + v17) > (signed int)v18 ) | |
10317 { | |
10318 v19 = this->uClipY; | |
10319 if ( (signed int)v19 < (signed int)a3 ) | |
10320 v19 = a3; | |
10321 v24 = v18 - v19; | |
10322 } | |
10323 } | |
10324 v27 = 0; | |
10325 if ( v24 > 0 ) | |
10326 { | |
10327 v23 = v22 - v25; | |
10328 do | |
10329 { | |
10330 for ( i = 0; i < v25; ++v28 ) | |
10331 { | |
10332 if ( *v28 ) | |
10333 { | |
710 | 10334 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 10335 if ( v20 >= a7 ) |
10336 { | |
10337 if ( v20 <= a8 ) | |
10338 { | |
10339 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
10340 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
10341 v21 = 2 * a8 - v21 - a7; | |
10342 v9 = a5; | |
10343 *v10 = a5->pPalette16[v21]; | |
10344 } | |
10345 } | |
10346 } | |
10347 ++i; | |
10348 ++v10; | |
10349 } | |
10350 ++v27; | |
10351 v10 += this->uTargetSurfacePitch - v25; | |
10352 v28 += v23; | |
10353 } | |
10354 while ( v27 < v24 ); | |
10355 } | |
10356 } | |
10357 } | |
10358 } | |
10359 } | |
10360 } | |
10361 } | |
10362 | |
10363 //----- (004A6274) -------------------------------------------------------- | |
10364 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
10365 { | |
10366 Texture *pCurrentTexture; // edi@2 | |
10367 int uHeight; // ebx@4 | |
10368 unsigned __int16 *v6; // eax@4 | |
10369 unsigned int v7; // edx@5 | |
10370 unsigned int v8; // edx@6 | |
10371 unsigned int v9; // edx@7 | |
10372 unsigned int v10; // edx@8 | |
10373 unsigned int v11; // edx@9 | |
10374 unsigned int v12; // esi@12 | |
10375 unsigned int v13; // esi@15 | |
10376 unsigned int v14; // edx@17 | |
10377 unsigned int v15; // esi@18 | |
10378 unsigned __int8 *v16; // ebx@22 | |
10379 char uFlag; // zf@28 | |
10380 int v18; // [sp+10h] [bp-10h]@4 | |
10381 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10382 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
10383 int uXa; // [sp+28h] [bp+8h]@24 | |
10384 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
10385 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
10386 | |
10387 if ( this->uNumSceneBegins ) | |
10388 { | |
10389 pCurrentTexture = pTexture; | |
10390 if ( pTexture ) | |
10391 { | |
10392 if ( pTexture->pPalette16 ) | |
10393 { | |
10394 uHeight = pTexture->uTextureHeight; | |
10395 v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 10396 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10397 uWidth = pTexture->uTextureWidth; |
10398 v18 = pTexture->uTextureWidth; | |
10399 if ( this->bClip ) | |
10400 { | |
10401 v7 = this->uClipX; | |
10402 if ( (signed int)uX < (signed int)v7 ) | |
10403 { | |
10404 v8 = v7 - uX; | |
10405 v19 += v8; | |
10406 uWidth += uX - this->uClipX; | |
10407 v6 += v8; | |
10408 } | |
10409 v9 = this->uClipY; | |
10410 uHeight = pTexture->uTextureHeight; | |
10411 if ( (signed int)uY < (signed int)v9 ) | |
10412 { | |
10413 v10 = v9 - uY; | |
10414 v19 += v18 * v10; | |
10415 uHeight = uY - this->uClipY + pTexture->uTextureHeight; | |
10416 pCurrentTexture = pTexture; | |
10417 v6 += this->uTargetSurfacePitch * v10; | |
10418 } | |
10419 v11 = this->uClipX; | |
10420 if ( (signed int)v11 < (signed int)uX ) | |
10421 v11 = uX; | |
10422 pTexturea = this->uClipZ; | |
10423 if ( (signed int)(v11 + uWidth) > (signed int)pTexturea ) | |
10424 { | |
10425 v12 = this->uClipX; | |
10426 if ( (signed int)v12 < (signed int)uX ) | |
10427 v12 = uX; | |
10428 uWidth = pTexturea - v12; | |
10429 } | |
10430 v13 = this->uClipY; | |
10431 if ( (signed int)v13 < (signed int)uY ) | |
10432 v13 = uY; | |
10433 v14 = this->uClipW; | |
10434 if ( (signed int)(uHeight + v13) > (signed int)v14 ) | |
10435 { | |
10436 v15 = this->uClipY; | |
10437 if ( (signed int)v15 < (signed int)uY ) | |
10438 v15 = uY; | |
10439 uHeight = v14 - v15; | |
10440 } | |
10441 } | |
10442 if ( (signed int)uHeight > 0 ) | |
10443 { | |
10444 uYa = uHeight; | |
10445 v16 = v19; | |
10446 do | |
10447 { | |
10448 if ( uWidth > 0 ) | |
10449 { | |
10450 uXa = uWidth; | |
10451 do | |
10452 { | |
10453 if ( *v16 ) | |
10454 *v6 = pCurrentTexture->pPalette16[*v16]; | |
10455 ++v6; | |
10456 ++v16; | |
10457 } | |
10458 while ( uXa-- !=1 ); | |
10459 } | |
10460 v16 += v18 - uWidth; | |
10461 uFlag = uYa-- == 1; | |
10462 v6 += this->uTargetSurfacePitch - uWidth; | |
10463 } | |
10464 while ( !uFlag ); | |
10465 } | |
10466 } | |
10467 } | |
10468 } | |
10469 } | |
10470 | |
10471 //----- (004A612A) -------------------------------------------------------- | |
710 | 10472 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 10473 { |
10474 Texture *v5; // eax@2 | |
10475 unsigned int v6; // edx@3 | |
10476 int v7; // ebx@3 | |
10477 int v8; // edi@3 | |
10478 signed int v9; // eax@4 | |
10479 int v10; // eax@5 | |
10480 unsigned int v11; // esi@6 | |
10481 signed int v12; // esi@8 | |
10482 unsigned int v13; // eax@10 | |
10483 signed int v14; // esi@11 | |
10484 unsigned int v15; // esi@14 | |
10485 unsigned int v16; // eax@16 | |
10486 unsigned int v17; // ecx@17 | |
10487 int v18; // edx@23 | |
10488 int v19; // [sp+Ch] [bp-Ch]@3 | |
10489 int v20; // [sp+10h] [bp-8h]@3 | |
10490 int uOutXa; // [sp+20h] [bp+8h]@21 | |
10491 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
10492 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
10493 | |
10494 if ( this->uNumSceneBegins ) | |
10495 { | |
10496 v5 = pTexture; | |
10497 if ( pTexture ) | |
10498 { | |
10499 v6 = uOutY; | |
10500 v7 = pTexture->uTextureHeight; | |
10501 pZBuffer = &this->pActiveZBuffer[uOutX + 640 * uOutY]; | |
710 | 10502 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10503 v8 = v5->uTextureWidth; |
10504 v20 = v5->uTextureWidth; | |
10505 v19 = v5->uTextureWidth; | |
10506 if ( this->bClip ) | |
10507 { | |
10508 v9 = this->uClipX; | |
10509 if ( uOutX < v9 ) | |
10510 { | |
10511 v10 = v9 - uOutX; | |
10512 uOutYa += v10; | |
10513 v8 += uOutX - this->uClipX; | |
10514 v20 = v8; | |
10515 pZBuffer += v10; | |
10516 } | |
10517 v11 = this->uClipY; | |
10518 if ( (signed int)v6 < (signed int)v11 ) | |
10519 { | |
10520 uOutYa += v19 * (v11 - v6); | |
10521 v7 += v6 - v11; | |
10522 pZBuffer += 640 * (v11 - v6); | |
10523 v8 = v20; | |
10524 } | |
10525 v12 = this->uClipX; | |
10526 if ( v12 < uOutX ) | |
10527 v12 = uOutX; | |
10528 v13 = this->uClipZ; | |
10529 if ( v8 + v12 > (signed int)v13 ) | |
10530 { | |
10531 v14 = this->uClipX; | |
10532 if ( v14 < uOutX ) | |
10533 v14 = uOutX; | |
10534 v8 = v13 - v14; | |
10535 } | |
10536 v15 = this->uClipY; | |
10537 if ( (signed int)v15 < (signed int)v6 ) | |
10538 v15 = v6; | |
10539 v16 = this->uClipW; | |
10540 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
10541 { | |
10542 v17 = this->uClipY; | |
10543 if ( (signed int)v17 >= (signed int)v6 ) | |
10544 v6 = v17; | |
10545 v7 = v16 - v6; | |
10546 } | |
10547 } | |
10548 if ( v7 > 0 ) | |
10549 { | |
10550 uOutXa = v7; | |
10551 do | |
10552 { | |
10553 if ( v8 > 0 ) | |
10554 { | |
10555 v18 = v8; | |
10556 do | |
10557 { | |
10558 if ( *uOutYa ) | |
10559 *pZBuffer = zVal; | |
10560 ++pZBuffer; | |
10561 ++uOutYa; | |
10562 --v18; | |
10563 } | |
10564 while ( v18 ); | |
10565 } | |
10566 pZBuffer += 640 - v8; | |
10567 uOutYa += v19 - v8; | |
10568 --uOutXa; | |
10569 } | |
10570 while ( uOutXa ); | |
10571 } | |
10572 } | |
10573 } | |
10574 } | |
10575 | |
10576 //----- (004A601E) -------------------------------------------------------- | |
10577 void Render::_4A601E(signed int a2, signed int a3, Texture *pTexture, int a5) | |
10578 { | |
10579 signed int v5; // edx@3 | |
10580 int v6; // ebx@3 | |
10581 int v7; // esi@3 | |
10582 void *v8; // esi@3 | |
10583 unsigned int v9; // eax@4 | |
10584 unsigned int v10; // eax@6 | |
10585 signed int v11; // edi@8 | |
10586 unsigned int v12; // eax@10 | |
10587 signed int v13; // edi@11 | |
10588 unsigned int v14; // edi@14 | |
10589 unsigned int v15; // eax@16 | |
10590 unsigned int v16; // ecx@17 | |
10591 int v17; // [sp+18h] [bp+Ch]@3 | |
10592 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
10593 | |
10594 if ( this->uNumSceneBegins && pTexture ) | |
10595 { | |
10596 v5 = a3; | |
10597 v6 = pTexture->uTextureHeight; | |
10598 v7 = 5 * a3; | |
10599 v17 = pTexture->uTextureHeight; | |
10600 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
10601 pTexturea = pTexture->uTextureWidth; | |
10602 if ( this->bClip ) | |
10603 { | |
10604 v9 = this->uClipX; | |
10605 if ( a2 < (signed int)v9 ) | |
10606 { | |
10607 pTexturea += a2 - v9; | |
10608 v8 = (char *)v8 + 4 * (v9 - a2); | |
10609 } | |
10610 v10 = this->uClipY; | |
10611 if ( v5 < (signed int)v10 ) | |
10612 { | |
10613 v17 += v5 - v10; | |
10614 v8 = (char *)v8 + 2560 * (v10 - v5); | |
10615 } | |
10616 v11 = this->uClipX; | |
10617 if ( v11 < a2 ) | |
10618 v11 = a2; | |
10619 v12 = this->uClipZ; | |
10620 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
10621 { | |
10622 v13 = this->uClipX; | |
10623 if ( v13 < a2 ) | |
10624 v13 = a2; | |
10625 pTexturea = v12 - v13; | |
10626 } | |
10627 v14 = this->uClipY; | |
10628 if ( (signed int)v14 < v5 ) | |
10629 v14 = v5; | |
10630 v6 = v17; | |
10631 v15 = this->uClipW; | |
10632 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
10633 { | |
10634 v16 = this->uClipY; | |
10635 if ( (signed int)v16 < v5 ) | |
10636 v16 = v5; | |
10637 v6 = v15 - v16; | |
10638 } | |
10639 } | |
10640 if ( v6 > 0 ) | |
10641 { | |
10642 do | |
10643 { | |
10644 if ( (signed int)pTexturea > 0 ) | |
10645 { | |
10646 memset32(v8, a5, pTexturea); | |
10647 v8 = (char *)v8 + 4 * pTexturea; | |
10648 } | |
10649 v8 = (char *)v8 + 4 * (640 - pTexturea); | |
10650 --v6; | |
10651 } | |
10652 while ( v6 ); | |
10653 } | |
10654 } | |
10655 } | |
10656 | |
10657 //----- (004A5EB2) -------------------------------------------------------- | |
10658 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
10659 { | |
10660 Texture *v4; // edi@2 | |
10661 unsigned int v5; // ebx@4 | |
10662 unsigned __int16 *pTarget; // eax@4 | |
10663 unsigned int v7; // edx@5 | |
10664 unsigned int v8; // edx@6 | |
10665 unsigned int v9; // edx@7 | |
10666 unsigned int v10; // edx@8 | |
10667 unsigned int v11; // edx@9 | |
10668 unsigned int v12; // esi@12 | |
10669 unsigned int v13; // esi@15 | |
10670 unsigned int v14; // edx@17 | |
10671 unsigned int v15; // esi@18 | |
10672 unsigned __int8 *v16; // edx@22 | |
10673 char v17; // zf@26 | |
10674 int v18; // [sp+10h] [bp-10h]@4 | |
10675 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10676 int v20; // [sp+1Ch] [bp-4h]@4 | |
10677 int uXa; // [sp+28h] [bp+8h]@24 | |
10678 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
10679 unsigned int v23; // [sp+30h] [bp+10h]@11 | |
10680 | |
10681 if ( this->uNumSceneBegins ) | |
10682 { | |
10683 v4 = a4; | |
10684 if ( a4 ) | |
10685 { | |
10686 if ( a4->pPalette16 ) | |
10687 { | |
10688 v5 = a4->uTextureHeight; | |
10689 pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 10690 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10691 v20 = a4->uTextureWidth; |
10692 v18 = a4->uTextureWidth; | |
10693 if ( this->bClip ) | |
10694 { | |
10695 v7 = this->uClipX; | |
10696 if ( (signed int)uX < (signed int)v7 ) | |
10697 { | |
10698 v8 = v7 - uX; | |
10699 v19 += v8; | |
10700 v20 += uX - this->uClipX; | |
10701 pTarget += v8; | |
10702 } | |
10703 v9 = this->uClipY; | |
10704 v5 = a4->uTextureHeight; | |
10705 if ( (signed int)uY < (signed int)v9 ) | |
10706 { | |
10707 v10 = v9 - uY; | |
10708 v19 += v18 * v10; | |
10709 v5 = uY - this->uClipY + a4->uTextureHeight; | |
10710 v4 = a4; | |
10711 pTarget += this->uTargetSurfacePitch * v10; | |
10712 } | |
10713 v11 = this->uClipX; | |
10714 if ( (signed int)v11 < (signed int)uX ) | |
10715 v11 = uX; | |
10716 v23 = this->uClipZ; | |
10717 if ( (signed int)(v11 + v20) > (signed int)v23 ) | |
10718 { | |
10719 v12 = this->uClipX; | |
10720 if ( (signed int)v12 < (signed int)uX ) | |
10721 v12 = uX; | |
10722 v20 = v23 - v12; | |
10723 } | |
10724 v13 = this->uClipY; | |
10725 if ( (signed int)v13 < (signed int)uY ) | |
10726 v13 = uY; | |
10727 v14 = this->uClipW; | |
10728 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10729 { | |
10730 v15 = this->uClipY; | |
10731 if ( (signed int)v15 < (signed int)uY ) | |
10732 v15 = uY; | |
10733 v5 = v14 - v15; | |
10734 } | |
10735 } | |
10736 if ( (signed int)v5 > 0 ) | |
10737 { | |
10738 uYa = v5; | |
10739 v16 = v19; | |
10740 do | |
10741 { | |
10742 if ( v20 > 0 ) | |
10743 { | |
10744 uXa = v20; | |
10745 do | |
10746 { | |
10747 *pTarget = v4->pPalette16[*v16]; | |
10748 ++pTarget; | |
10749 ++v16; | |
10750 --uXa; | |
10751 } | |
10752 while ( uXa ); | |
10753 } | |
10754 v16 += v18 - v20; | |
10755 v17 = uYa-- == 1; | |
10756 pTarget += this->uTargetSurfacePitch - v20; | |
10757 } | |
10758 while ( !v17 ); | |
10759 } | |
10760 } | |
10761 } | |
10762 } | |
10763 } | |
10764 | |
10765 //----- (004667E9) -------------------------------------------------------- | |
10766 void Render::ChangeBetweenWinFullscreenModes() | |
10767 { | |
10768 float v0; // ST14_4@17 | |
10769 int v1; // edx@24 | |
10770 signed int v2; // ecx@24 | |
10771 int v3; // esi@25 | |
10772 int v4; // edx@26 | |
10773 ObjectDesc *v5; // eax@26 | |
10774 RGBTexture *v6; // esi@33 | |
10775 const char *v7; // eax@34 | |
10776 const char *v8; // [sp-4h] [bp-28h]@33 | |
10777 int v9; // [sp+0h] [bp-24h]@33 | |
10778 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
10779 | |
10780 if ( pRenderer->bWindowMode ) | |
10781 goto LABEL_52; | |
10782 if ( dword_6BE364_game_settings_1 & 2 ) | |
10783 { | |
10784 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." | |
10785 return; | |
10786 } | |
10787 if ( !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) | |
10788 { | |
10789 LABEL_52: | |
10790 if ( pEventTimer->bPaused ) | |
10791 BYTE1(dword_6BE364_game_settings_1) |= 8u; | |
10792 else | |
10793 pEventTimer->Pause(); | |
10794 if ( pMiscTimer->bPaused ) | |
10795 BYTE1(dword_6BE364_game_settings_1) |= 0x10u; | |
10796 else | |
10797 pMiscTimer->Pause(); | |
10798 pMouse->bActive = 0; | |
10799 if ( pRenderer->pRenderD3D ) | |
10800 { | |
10801 pBitmaps_LOD->ReleaseHardwareTextures(); | |
10802 pSprites_LOD->ReleaseAll(); | |
10803 } | |
10804 if ( pRenderer->bWindowMode ) | |
10805 { | |
10806 if ( GetWindowRect(hWnd, &Rect) ) | |
10807 { | |
10808 WriteWindowsRegistryInt("window X", Rect.left); | |
10809 WriteWindowsRegistryInt("window Y", Rect.top); | |
10810 uWindowX = Rect.left; | |
10811 uWindowY = Rect.top; | |
10812 } | |
10813 SetMenu(hWnd, 0); | |
10814 SetWindowLongA(hWnd, -20, 0); | |
10815 SetWindowLongA(hWnd, -16, 0x10000000u); | |
10816 pRenderer->InitializeFullscreen(hWnd); | |
10817 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; | |
10818 pGame->pGammaController->Initialize(v0); | |
10819 } | |
10820 else | |
10821 { | |
10822 ClipCursor(0); | |
10823 pRenderer->SwitchToWindow(hWnd); | |
10824 SetWindowLongA(hWnd, -16, uWindowStyle); | |
10825 SetMenu(hWnd, hOSMenu); | |
10826 } | |
10827 if ( pRenderer->pRenderD3D ) | |
10828 { | |
10829 pBitmaps_LOD->_410423_move_textures_to_device(); | |
10830 pSprites_LOD->MoveSpritesToVideoMemory(); | |
10831 } | |
10832 if ( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits | |
10833 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits | |
10834 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits ) | |
10835 goto LABEL_38; | |
10836 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10837 pPaletteManager->RecalculateAll(); | |
10838 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10839 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10840 v2 = 0; | |
10841 if ( (signed int)pObjectList->uNumObjects > 0 ) | |
10842 { | |
10843 v3 = 0; | |
10844 do | |
10845 { | |
10846 BYTE3(v4) = 0; | |
10847 v5 = &pObjectList->pObjects[v3]; | |
10848 ++v3; | |
10849 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; | |
10850 LOBYTE(v4) = v5->uParticleTrailColorG; | |
10851 v1 = v5->uParticleTrailColorB | (v4 << 8); | |
10852 ++v2; | |
10853 v5->uParticleTrailColor = v1; | |
10854 } | |
10855 while ( v2 < (signed int)pObjectList->uNumObjects ); | |
10856 } | |
10857 LOBYTE(v1) = 1; | |
373 | 10858 SetUserInterface(pParty->alignment, v1); |
0 | 10859 if ( pVideoPlayer->pVideoFrame.pPixels ) |
10860 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); | |
10861 if ( uCurrentMenuID ) | |
10862 { | |
10863 if ( uCurrentMenuID != 6 ) | |
10864 { | |
10865 if ( uCurrentMenuID == 8 ) | |
10866 dword_A74C88 = 1; | |
10867 goto LABEL_38; | |
10868 } | |
10869 v6 = &pTexture_PCX; | |
10870 pTexture_PCX.Release(); | |
10871 v9 = 0; | |
10872 v8 = "makeme.pcx"; | |
10873 } | |
10874 else | |
10875 { | |
10876 v6 = &pTexture_PCX; | |
10877 pTexture_PCX.Release(); | |
10878 v7 = "title.pcx"; | |
10879 if ( uCurrentMenuID ) | |
10880 v7 = "lsave640.pcx"; | |
10881 v9 = 0; | |
10882 v8 = v7; | |
10883 } | |
10884 v6->Load(v8, v9); | |
10885 LABEL_38: | |
10886 viewparams->bRedrawGameUI = 1; | |
688 | 10887 viewparams->InitGrayPalette(); |
0 | 10888 pMouse->SetCurrentCursorBitmap(); |
10889 if ( pRenderer->bWindowMode ) | |
10890 { | |
10891 InvalidateRect(0, 0, 0); | |
10892 MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); | |
10893 ShowWindow(hWnd, 1); | |
10894 } | |
10895 pMouse->bActive = 1; | |
10896 if ( pVideoPlayer->AnyMovieLoaded() ) | |
10897 pVideoPlayer->_4BF73A(); | |
10898 if ( BYTE1(dword_6BE364_game_settings_1) & 8 ) | |
10899 BYTE1(dword_6BE364_game_settings_1) &= 0xF7u; | |
10900 else | |
10901 pEventTimer->Resume(); | |
10902 if ( BYTE1(dword_6BE364_game_settings_1) & 0x10 ) | |
10903 BYTE1(dword_6BE364_game_settings_1) &= 0xEFu; | |
10904 else | |
10905 pMiscTimer->Resume(); | |
10906 pAsyncMouse->Release(); | |
10907 CreateAsyncMouse(); | |
10908 if (pAsyncMouse) | |
10909 pAsyncMouse->Clip(); | |
10910 } | |
10911 } | |
10912 // 6BE364: using guessed type int dword_6BE364_game_settings_1; | |
10913 // A74C88: using guessed type int dword_A74C88; | |
10914 | |
10915 //----- (0044EC20) -------------------------------------------------------- | |
10916 bool RenderD3D::DoesRaiseExceptions() | |
10917 { | |
10918 return true; | |
10919 } | |
10920 | |
10921 //----- (0040DBD3) -------------------------------------------------------- | |
10922 void __fastcall Render::SetPixel(Vec2_int_ *pTargetXY, unsigned __int16 uColor) | |
10923 { | |
10924 Vec2_int_ *pTargetXY_; // esi@1 | |
10925 unsigned __int16 v3; // di@1 | |
10926 signed int v4; // ecx@2 | |
10927 signed int v5; // eax@4 | |
10928 | |
10929 pTargetXY_ = pTargetXY; | |
10930 v3 = uColor; | |
10931 pRenderer->BeginScene(); | |
10932 if ( pRenderer->uNumSceneBegins ) | |
10933 { | |
10934 v4 = pTargetXY_->x; | |
10935 if ( pTargetXY_->x >= 0 ) | |
10936 { | |
10937 if ( v4 <= 639 ) | |
10938 { | |
10939 v5 = pTargetXY_->y; | |
10940 if ( v5 >= 0 ) | |
10941 { | |
10942 if ( v5 <= 479 ) | |
10943 pRenderer->pTargetSurface[v4 + pRenderer->uTargetSurfacePitch * v5] = v3; | |
10944 } | |
10945 } | |
10946 } | |
10947 pRenderer->EndScene(); | |
10948 } | |
10949 } | |
10950 | |
10951 //----- (004524D8) -------------------------------------------------------- | |
10952 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
10953 { | |
10954 int v11; // eax@13 | |
10955 int v12; // ecx@13 | |
10956 void *v13; // eax@13 | |
10957 unsigned __int8 v14; // zf@13 | |
10958 unsigned __int8 v15; // sf@13 | |
10959 int v16; // esi@14 | |
10960 int v17; // ecx@16 | |
10961 int v18; // esi@16 | |
10962 unsigned __int16 *v19; // eax@16 | |
10963 int v20; // edx@16 | |
10964 int v21; // ecx@16 | |
10965 int v22; // eax@16 | |
10966 int v23; // esi@16 | |
10967 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
10968 int v27; // [sp+28h] [bp-Ch]@14 | |
10969 int v28; // [sp+2Ch] [bp-8h]@13 | |
10970 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
10971 | |
10972 //v3 = this; | |
10973 //sprintf(Str1, "%s", pName); | |
10974 //v4 = uNumItems; | |
10975 if (!uNumItems) | |
10976 return nullptr; | |
10977 | |
10978 //{ | |
10979 //v5 = 0, pDesta = uNumItems; | |
10980 uint idx1 = 0, | |
10981 idx2 = uNumItems; | |
10982 while (true) | |
10983 { | |
10984 auto i = idx1 + (idx2 - idx1) / 2; | |
10985 | |
10986 auto res = strcmpi(pName, pSpriteNames[i]); | |
10987 if (!res) | |
10988 { | |
10989 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
10990 break; | |
10991 } | |
10992 else if (res < 0) | |
10993 idx2 = idx1 + (idx2 - idx1) / 2; | |
10994 else | |
10995 idx1 = i + 1; | |
10996 | |
10997 if ( idx1 >= idx2 ) | |
10998 return false; | |
10999 } | |
11000 | |
11001 | |
11002 uint uCompressedSize = 0; | |
11003 fread(&uCompressedSize, 4, 1, pFile); | |
11004 | |
11005 auto pTex = new HWLTexture; | |
670 | 11006 fread(&pTex->uBufferWidth, 4, 1, pFile); |
11007 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
11008 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
11009 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 11010 fread(&pTex->uWidth, 4, 1, pFile); |
11011 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 11012 fread(&pTex->uAreaX, 4, 1, pFile); |
11013 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 11014 |
11015 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
11016 if (uCompressedSize) | |
11017 { | |
11018 auto pCompressedData = new char[uCompressedSize]; | |
11019 { | |
11020 fread(pCompressedData, 1, uCompressedSize, pFile); | |
11021 auto uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); | |
11022 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); | |
11023 } | |
11024 delete [] pCompressedData; | |
11025 } | |
11026 else | |
11027 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
11028 | |
11029 if ( field_61A94_scale_hwls_to_half ) | |
11030 { | |
11031 v11 = pTex->uHeight / 2; | |
11032 v12 = pTex->uWidth / 2; | |
11033 pTex->uHeight = v11; | |
11034 pTex->uWidth = v12; | |
11035 v13 = new unsigned __int16[v12 * v11]; | |
11036 v28 = 0; | |
11037 v14 = pTex->uHeight == 0; | |
11038 v15 = (pTex->uHeight & 0x80000000u) != 0; | |
11039 v26 = (unsigned __int16 *)v13; | |
11040 if ( !(v15 | v14) ) | |
11041 { | |
11042 v16 = pTex->uWidth; | |
11043 v27 = 1; | |
11044 do | |
11045 { | |
11046 pDestb = 0; | |
11047 if ( v16 > 0 ) | |
11048 { | |
11049 do | |
11050 { | |
11051 v17 = v16 * v27; | |
11052 v18 = v28 * v16; | |
11053 v19 = pTex->pPixels; | |
11054 v20 = pDestb + 2 * v18; | |
11055 v21 = (int)&v19[2 * (pDestb + v17)]; | |
11056 v22 = (int)&v19[2 * v20]; | |
11057 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
11058 LOWORD(v21) = *(unsigned short *)v21; | |
11059 v23 = pDestb++ + v18; | |
11060 v26[v23] = sub_452442(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
11061 v16 = pTex->uWidth; | |
11062 } | |
11063 while (pDestb < pTex->uWidth); | |
11064 } | |
11065 ++v28; | |
11066 v27 += 2; | |
11067 } | |
11068 while ( v28 < (signed int)pTex->uHeight ); | |
11069 } | |
11070 delete [] pTex->pPixels; | |
11071 pTex->pPixels = v26; | |
11072 } | |
11073 return pTex; | |
11074 //result = pTex; | |
11075 // } | |
11076 // else | |
11077 // { | |
11078 //LABEL_8: | |
11079 // return nullptr; | |
11080 // } | |
11081 } | |
11082 | |
11083 //----- (0045271F) -------------------------------------------------------- | |
11084 bool RenderHWLContainer::Release() | |
11085 { | |
11086 RenderHWLContainer *v1; // esi@1 | |
11087 int v2; // ebx@1 | |
11088 void **v3; // edi@3 | |
11089 __int32 v4; // eax@6 | |
11090 FILE *v5; // ST24_4@6 | |
11091 size_t *v6; // edi@6 | |
11092 int v7; // ebx@7 | |
11093 signed int v9; // [sp+0h] [bp-8h]@6 | |
11094 FILE *File; // [sp+4h] [bp-4h]@6 | |
11095 | |
11096 v1 = this; | |
11097 v2 = 0; | |
11098 if ( this->bDumpDebug ) | |
11099 { | |
11100 File = fopen("logd3d.txt", "w"); | |
11101 v4 = ftell(v1->pFile); | |
11102 v5 = v1->pFile; | |
11103 v6 = &v1->uNumItems; | |
11104 v1->uDataOffset = v4; | |
11105 fwrite(&v1->uNumItems, 4u, 1u, v5); | |
11106 v9 = 0; | |
11107 if ( (signed int)v1->uNumItems > 0 ) | |
11108 { | |
11109 v7 = (int)v1->pSpriteNames; | |
11110 do | |
11111 { | |
11112 fwrite(*(const void **)v7, 1u, 0x14u, v1->pFile); | |
11113 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", *(unsigned int *)v7, *(unsigned int *)(v7 + 200000)); | |
11114 ++v9; | |
11115 v7 += 4; | |
11116 } | |
11117 while ( v9 < (signed int)*v6 ); | |
11118 v2 = 0; | |
11119 } | |
11120 fwrite(v1->pSpriteOffsets, 4u, *v6, v1->pFile); | |
11121 fseek(v1->pFile, 4, v2); | |
11122 fwrite(&v1->uDataOffset, 4u, 1u, v1->pFile); | |
11123 fclose(v1->pFile); | |
11124 fclose(File); | |
11125 } | |
11126 else | |
11127 { | |
11128 fclose(this->pFile); | |
11129 if ( (signed int)v1->uNumItems > 0 ) | |
11130 { | |
11131 v3 = (void **)v1->pSpriteNames; | |
11132 do | |
11133 { | |
11134 free(*v3); | |
11135 ++v2; | |
11136 ++v3; | |
11137 } | |
11138 while ( v2 < (signed int)v1->uNumItems ); | |
11139 } | |
11140 } | |
11141 return 1; | |
11142 } | |
11143 | |
11144 //----- (00452347) -------------------------------------------------------- | |
11145 RenderHWLContainer::RenderHWLContainer(): | |
11146 bDumpDebug(false) | |
11147 { | |
11148 RenderHWLContainer *v1; // esi@1 | |
11149 | |
11150 v1 = this; | |
11151 this->pFile = 0; | |
11152 uSignature = 0; | |
11153 v1->uDataOffset = 0; | |
11154 memset(&v1->uNumItems, 0, 0x61A84u); | |
11155 v1->uNumItems = 0; | |
11156 v1->field_61A94_scale_hwls_to_half = 0; | |
11157 } | |
11158 | |
11159 //----- (0045237F) -------------------------------------------------------- | |
11160 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
11161 { | |
11162 pFile = _wfopen(pFilename, L"rb"); | |
11163 if (!pFile) | |
11164 { | |
11165 Log::Warning(L"Failed to open file: %s", pFilename); | |
11166 return false; | |
11167 } | |
11168 | |
11169 fread(&uSignature, 1, 4, pFile); | |
11170 if (uSignature != 'TD3D') | |
11171 { | |
11172 Log::Warning(L"Invalid format: %s", pFilename); | |
11173 return false; | |
11174 } | |
11175 | |
11176 fread(&uDataOffset, 4, 1, pFile); | |
11177 fseek(pFile, uDataOffset, SEEK_SET); | |
11178 fread(&uNumItems, 4, 1, pFile); | |
11179 | |
11180 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
11181 for (uint i = 0; i < uNumItems; ++i) | |
11182 { | |
11183 pSpriteNames[i] = new char[20]; | |
11184 fread(pSpriteNames[i], 1, 20, pFile); | |
11185 } | |
11186 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
11187 | |
11188 return true; | |
11189 } | |
11190 | |
11191 //----- (004A1C1E) -------------------------------------------------------- | |
11192 void DoRenderBillboards_D3D() | |
11193 { | |
186 | 11194 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
11195 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
11196 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11197 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11198 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11199 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11200 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11201 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11202 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11203 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11204 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
|
11205 //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
|
11206 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11207 p->pQuards[0].pos.x = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11208 p->pQuards[0].pos.y = 10; |
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 p->pQuards[1].pos.x = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11211 p->pQuards[1].pos.y = 200; |
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[2].pos.x = 100; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11214 p->pQuards[2].pos.y = 200; |
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[3].pos.x = 100; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11217 p->pQuards[3].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 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11220 SetBillboardBlendOptions(p->uOpacity); |
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 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11223 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11224 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11225 p->pQuards, p->uNumVertices, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11226 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
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 }*/ |
0 | 11229 |
11230 for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i) | |
11231 { | |
101 | 11232 auto p = &pRenderer->pBillboardRenderListD3D[i]; |
0 | 11233 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11234 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
0 | 11235 SetBillboardBlendOptions(p->uOpacity); |
11236 | |
101 | 11237 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11238 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11239 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11240 p->pQuards, p->uNumVertices, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11241 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
0 | 11242 } |
11243 | |
11244 if (pRenderer->bFogEnabled) | |
11245 { | |
11246 pRenderer->bFogEnabled = false; | |
186 | 11247 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 11248 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
11249 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
11250 } | |
186 | 11251 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
11252 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
11253 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
11254 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
11255 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
11256 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 11257 } |
11258 | |
11259 //----- (004A1DA8) -------------------------------------------------------- | |
11260 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) | |
11261 { | |
11262 switch (a1) | |
11263 { | |
11264 case RenderBillboardD3D::Transparent: | |
11265 { | |
11266 if (pRenderer->bFogEnabled) | |
11267 { | |
11268 pRenderer->bFogEnabled = false; | |
186 | 11269 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 11270 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
11271 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
11272 } | |
11273 | |
186 | 11274 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); |
11275 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
11276 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 11277 } |
11278 break; | |
11279 | |
11280 case RenderBillboardD3D::Opaque_1: | |
11281 case RenderBillboardD3D::Opaque_2: | |
11282 case RenderBillboardD3D::Opaque_3: | |
11283 { | |
11284 if (pRenderer->bUsingSpecular) | |
11285 { | |
11286 if (!pRenderer->bFogEnabled) | |
11287 { | |
11288 pRenderer->bFogEnabled = true; | |
186 | 11289 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
11290 } | |
11291 } | |
11292 | |
11293 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
11294 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
11295 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 11296 } |
11297 break; | |
11298 | |
11299 default: | |
11300 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11301 assert(false); |
0 | 11302 break; |
11303 } | |
11304 } | |
11305 |