Mercurial > mm7
annotate Render.cpp @ 1113:39eaa6b00141
something to bool cast (performance warning) mostly fixed
author | Grumpy7 |
---|---|
date | Tue, 28 May 2013 00:19:45 +0200 |
parents | cf6cd674c398 |
children | ad89d1905b48 |
rev | line source |
---|---|
140 | 1 #include <assert.h> |
2 | |
1016 | 3 #include "VideoPlayer.h" |
4 #include "Sprites.h" | |
5 #include "Mouse.h" | |
6 #include "GammaControl.h" | |
7 #include "stru6.h" | |
8 | |
9 #include "DecalBuilder.h" | |
10 #include "ParticleEngine.h" | |
0 | 11 #include "Render.h" |
12 #include "OutdoorCamera.h" | |
13 #include "IndoorCamera.h" | |
14 #include "Outdoor.h" | |
15 #include "Party.h" | |
16 #include "LOD.h" | |
17 #include "Viewport.h" | |
18 #include "Math.h" | |
19 #include "PaletteManager.h" | |
20 #include "Time.h" | |
21 #include "Game.h" | |
22 #include "LightmapBuilder.h" | |
23 #include "stru220.h" | |
24 #include "ObjectList.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
25 #include "SpriteObject.h" |
0 | 26 #include "DecorationList.h" |
27 #include "Allocator.h" | |
28 #include "OSInfo.h" | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
29 #include "Actor.h" |
0 | 30 #include "Log.h" |
179 | 31 #include "TileFrameTable.h" |
189 | 32 #include "texts.h" |
0 | 33 #include "mm7_data.h" |
860 | 34 #include "MM7.h" |
0 | 35 |
36 #pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") | |
37 #pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") | |
38 | |
39 struct IDirectDrawClipper *pDDrawClipper; | |
40 struct Render *pRenderer; // idb | |
67 | 41 struct RenderVertexD3D3 pVertices[50]; |
0 | 42 int uNumDecorationsDrawnThisFrame; // weak |
43 RenderBillboard pBillboardRenderList[500]; | |
44 unsigned int uNumBillboardsToDraw; | |
45 int uNumSpritesDrawnThisFrame; // weak | |
46 | |
47 RenderVertexSoft array_507D30[50]; | |
48 RenderVertexSoft array_508690[50]; | |
49 RenderVertexSoft array_508FF0[50]; | |
50 RenderVertexSoft array_509950[50]; | |
51 RenderVertexSoft array_50A2B0[50]; | |
52 RenderVertexSoft array_50AC10[50]; | |
53 | |
54 RenderVertexSoft array_73D150[20]; | |
55 | |
186 | 56 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 57 |
58 RenderVertexSoft *ptr_801A04; | |
59 RenderVertexSoft *ptr_801A08; | |
60 | |
61 RenderVertexSoft pVerticesSR_801A10[384]; | |
62 RenderVertexSoft pVerticesSR_806210[384]; | |
63 | |
64 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); | |
65 | |
66 /* 384 */ | |
67 #pragma pack(push, 1) | |
68 struct PCXHeader_1 | |
69 { | |
70 char manufacturer; | |
71 char version; | |
72 char encoding; | |
73 char bpp; | |
74 __int16 left; | |
75 __int16 up; | |
76 __int16 right; | |
77 __int16 bottom; | |
78 __int16 hdpi; | |
79 __int16 vdpi; | |
80 }; | |
81 #pragma pack(pop) | |
82 | |
83 /* 385 */ | |
84 #pragma pack(push, 1) | |
85 struct PCXHeader_2 | |
86 { | |
87 char reserved; | |
88 char planes; | |
89 __int16 pitch; | |
90 __int16 palette_info; | |
91 }; | |
92 #pragma pack(pop) | |
93 | |
94 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
95 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
96 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
97 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
98 | |
99 //----- (0049E79F) -------------------------------------------------------- | |
100 bool __cdecl CheckTextureStages() | |
101 { | |
102 bool v0; // edi@1 | |
103 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
104 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
105 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
106 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
107 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
108 | |
109 v0 = false; | |
110 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); | |
111 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
112 | |
113 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
186 | 114 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 115 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2u)); |
116 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
117 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
118 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
119 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1u)); | |
120 | |
121 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
186 | 122 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
0 | 123 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1u)); |
124 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7u)); | |
125 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2u)); | |
126 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1u)); | |
127 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2u)); | |
128 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2u)); | |
129 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1u)); | |
130 | |
131 if ( !pRenderer->pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
132 v0 = true; | |
133 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); | |
134 pTexture1->Release(); | |
135 pTexture2->Release(); | |
136 pSurface1->Release(); | |
137 pSurface2->Release(); | |
138 return v0; | |
139 } | |
140 | |
141 //----- (00440CB8) -------------------------------------------------------- | |
142 void Render::DrawBillboardList_BLV() | |
143 { | |
144 __int16 v2; // ax@3 | |
145 int v5; // eax@11 | |
146 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
147 | |
148 soft_billboard.uParentBillboardID = -1; | |
149 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; | |
150 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
151 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
152 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
153 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
154 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
155 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
156 | |
617 | 157 pOutdoorCamera->uNumBillboards = ::uNumBillboardsToDraw; |
158 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) | |
0 | 159 { |
160 auto p = pBillboardRenderList + i; | |
161 | |
162 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
163 soft_billboard.uParentBillboardID = i; | |
164 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
165 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
|
166 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 167 soft_billboard.sZValue = p->sZValue; |
168 soft_billboard.uFlags = p->field_1E; | |
169 soft_billboard.uTintColor = p->uTintColor; | |
170 v2 = p->uHwSpriteID; | |
171 if ( v2 != -1 ) | |
172 { | |
173 if ( pRenderer->pRenderD3D ) | |
657 | 174 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 175 else |
176 { | |
657 | 177 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 178 if (p->field_1E & 0x0100) |
179 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
180 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
181 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1); | |
182 v5 = p->uHwSpriteID; | |
183 if ( v5 >= 0 ) | |
733 | 184 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 185 } |
186 } | |
187 } | |
188 } | |
189 | |
190 //----- (004A16A5) -------------------------------------------------------- | |
191 bool __cdecl AreRenderSurfacesOk() | |
192 { | |
193 char v0; // zf@4 | |
194 bool result; // eax@8 | |
195 | |
196 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
197 { | |
198 if ( !pRenderer->pBackBuffer4 ) | |
199 goto LABEL_9; | |
200 v0 = pRenderer->pFrontBuffer4 == 0; | |
201 } | |
202 else | |
203 { | |
204 if ( !pRenderer->pBackBuffer2 ) | |
205 goto LABEL_9; | |
206 v0 = pRenderer->pFrontBuffer2 == 0; | |
207 } | |
208 if ( !v0 ) | |
209 { | |
210 LOBYTE(result) = 1; | |
211 return result; | |
212 } | |
213 LABEL_9: | |
214 LOBYTE(result) = 0; | |
215 return result; | |
216 } | |
217 | |
218 //----- (00487389) -------------------------------------------------------- | |
973 | 219 void Render::ExecOutdoorDrawSW() |
0 | 220 { |
221 unsigned __int16 *v0; // ebx@1 | |
222 unsigned int v1; // esi@1 | |
223 stru148 *v2; // eax@1 | |
224 Span *v3; // edi@6 | |
225 stru148 *v4; // esi@9 | |
226 Texture *v5; // ebp@10 | |
227 int v6; // esi@16 | |
228 unsigned int v7; // edx@16 | |
229 char *v8; // ecx@17 | |
230 unsigned int v9; // edi@22 | |
231 int v10; // eax@26 | |
232 int v11; // eax@27 | |
233 unsigned int v12; // ebp@32 | |
234 Span *v13; // esi@33 | |
235 int v14; // ecx@37 | |
236 int v15; // eax@40 | |
237 Texture *v16; // ebp@51 | |
973 | 238 //unsigned int v17; // eax@51 |
0 | 239 int v18; // eax@54 |
240 char v19; // al@56 | |
241 unsigned int v20; // eax@57 | |
242 int v21; // ecx@57 | |
243 unsigned int v22; // eax@57 | |
244 stru149 *v23; // eax@65 | |
245 int v24; // eax@67 | |
246 ODMFace *v25; // eax@78 | |
247 signed int v26; // edx@79 | |
248 signed int v27; // ecx@79 | |
249 unsigned int v28; // eax@106 | |
250 unsigned int v29; // ebp@117 | |
251 Span *v30; // esi@118 | |
252 unsigned int v31; // ST04_4@124 | |
253 int v33; // [sp+18h] [bp-44h]@80 | |
254 signed int v34; // [sp+1Ch] [bp-40h]@3 | |
255 signed int v35; // [sp+20h] [bp-3Ch]@79 | |
256 Span **v36; // [sp+24h] [bp-38h]@4 | |
257 unsigned int v37; // [sp+28h] [bp-34h]@1 | |
258 unsigned __int16 *a1; // [sp+2Ch] [bp-30h]@1 | |
259 int a1a; // [sp+2Ch] [bp-30h]@26 | |
260 unsigned int a1b; // [sp+2Ch] [bp-30h]@116 | |
261 char v41; // [sp+30h] [bp-2Ch]@57 | |
262 | |
263 v0 = pRenderer->pTargetSurface; | |
264 v1 = pOutdoorCamera->numStru148s; | |
265 a1 = pRenderer->pTargetSurface; | |
266 v2 = array_77EC08; | |
267 v37 = pOutdoorCamera->numStru148s; | |
268 if ( !(pParty->uFlags & 2) ) | |
269 { | |
270 v1 = uNumElementsIn80AA28; | |
271 v2 = ptr_80AA28[0]; | |
272 v37 = uNumElementsIn80AA28; | |
273 } | |
274 v34 = 0; | |
275 if ( (signed int)v1 > 0 ) | |
276 { | |
277 v36 = &v2->prolly_head; | |
278 do | |
279 { | |
280 if ( pParty->uFlags & 2 ) | |
281 v3 = *v36; | |
282 else | |
283 v3 = ptr_80AA28[v34]->prolly_head; | |
284 if ( v3 ) | |
285 { | |
286 v4 = v3->pParent; | |
287 if ( v4 ) | |
288 { | |
289 v5 = v4->pTexture; | |
290 if ( v5 ) | |
291 { | |
693 | 292 if ( v3->field_8 >= (signed int)pViewport->uViewportTL_X || v3->field_C != pViewport->uViewportTL_X ) |
0 | 293 { |
294 LOBYTE(v4->field_32) |= 2u; | |
295 v14 = *(int *)&v4->flags; | |
296 if ( v14 & 0x10 && v4->field_59 != 5 ) | |
297 { | |
638 | 298 dword_80AA20 = (v4->terrain_grid_z - 64) << 25; |
0 | 299 dword_80AA1C = dword_80AA20 + 0x1FF0000; |
638 | 300 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 301 dword_80AA18 = dword_80AA14 - 0x1FF0000; |
302 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 303 v4->terrain_grid_z, |
304 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 305 if ( *(int *)&v4->flags & 2 || (v15 = *(int *)&v4->flags, BYTE1(v15) & 1) ) |
306 { | |
307 if ( *(int *)&v4->flags & 2 ) | |
308 { | |
309 while ( 1 ) | |
310 { | |
311 if ( pOutdoorCamera->outdoor_no_wavy_water ) | |
312 sr_sub_48408A_prolly_odm_water_no_waves(v3); | |
313 else | |
314 sr_sub_485407_prolly_odm_water_wavy(v3); | |
315 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
316 if ( v4->prolly_tail == v3 ) | |
317 break; | |
318 v3 = v3->pNext; | |
319 } | |
320 } | |
321 else | |
322 { | |
323 while ( 1 ) | |
324 { | |
325 v16 = v4->pTexture; | |
973 | 326 v4->pTexture = pBitmaps_LOD->LoadTexturePtr("wtrtyl"); |
0 | 327 if ( pOutdoorCamera->outdoor_no_wavy_water ) |
328 sr_sub_48408A_prolly_odm_water_no_waves(v3); | |
329 else | |
330 sr_sub_485407_prolly_odm_water_wavy(v3); | |
638 | 331 v18 = v4->terrain_grid_z - 64; |
0 | 332 v4->pTexture = v16; |
333 dword_80AA20 = v18 << 25; | |
334 dword_80AA1C = (v18 << 25) + 0x1FF0000; | |
638 | 335 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 336 dword_80AA18 = dword_80AA14 - 0x1FF0000; |
337 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 338 v4->terrain_grid_z, |
339 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 340 sr_sub_484442(v3); |
341 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
342 if ( v4->prolly_tail == v3 ) | |
343 break; | |
344 v3 = v3->pNext; | |
345 } | |
346 } | |
347 } | |
348 else | |
349 { | |
350 while ( sr_sub_48408A_prolly_odm_water_no_waves(v3) ) | |
351 { | |
352 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
353 if ( v4->prolly_tail == v3 ) | |
354 break; | |
355 v3 = v3->pNext; | |
356 } | |
357 } | |
358 } | |
359 else | |
360 { | |
361 v19 = v4->field_59; | |
362 if ( v19 != 5 ) | |
363 { | |
364 if ( v14 & 2 ) | |
365 { | |
366 while ( 1 ) | |
367 { | |
368 v28 = pBitmaps_LOD->LoadTexture("wtrtyla"); | |
369 v4->pTexture = (Texture *)(v28 != -1 ? &pBitmaps_LOD->pTextures[v28] : 0); | |
370 if ( !sr_sub_4847EB(v3) ) | |
371 break; | |
372 v4->pTexture = v5; | |
373 if ( !sr_sub_484442(v3) ) | |
374 break; | |
375 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
376 if ( v4->prolly_tail == v3 ) | |
377 break; | |
378 v3 = v3->pNext; | |
379 v5 = v4->pTexture; | |
380 } | |
381 } | |
382 else | |
383 { | |
384 if ( v19 == 1 ) | |
385 { | |
638 | 386 dword_80AA20 = (v4->terrain_grid_z - 64) << 25; |
0 | 387 dword_80AA1C = dword_80AA20 + 33488896; |
638 | 388 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 389 dword_80AA18 = dword_80AA14 - 33488896; |
390 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 391 v4->terrain_grid_z, |
392 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 393 while ( 1 ) |
394 { | |
395 if ( !sr_sub_4847EB(v3) ) | |
396 sr_sub_48585C_mb_DrawSpan(v3, &pRenderer->pTargetSurface[v3->field_8 + 640 * v3->field_A], 0); | |
397 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
398 if ( v4->prolly_tail == v3 ) | |
399 break; | |
400 v3 = v3->pNext; | |
401 } | |
402 } | |
403 } | |
404 goto LABEL_14; | |
405 } | |
406 v4->ptr_38 = (stru149 *)&v41; | |
407 v4->_479295(); | |
408 v20 = GetTickCount(); | |
409 v21 = *(int *)&v4->flags; | |
410 v22 = v20 >> 3; | |
411 if ( BYTE1(v21) & 4 ) | |
412 { | |
413 v4->sTextureDeltaV -= v22 & v4->pTexture->uHeightMinus1; | |
414 } | |
415 else | |
416 { | |
417 if ( BYTE1(v21) & 8 ) | |
418 v4->sTextureDeltaV += v22 & v4->pTexture->uHeightMinus1; | |
419 } | |
420 if ( BYTE1(v21) & 0x10 ) | |
421 { | |
422 v4->sTextureDeltaU -= v22 & v4->pTexture->uWidthMinus1; | |
423 } | |
424 else | |
425 { | |
426 if ( BYTE1(v21) & 0x20 ) | |
427 v4->sTextureDeltaU += v22 & v4->pTexture->uWidthMinus1; | |
428 } | |
429 v23 = v4->ptr_38; | |
430 v4->field_52 = 32; | |
431 v4->field_5A = 5; | |
432 if ( (double)abs(v23->field_C) > 52428.8 ) | |
433 { | |
434 v4->field_52 = 8; | |
435 v4->field_5A = 3; | |
436 } | |
437 v24 = *(int *)&v4->flags; | |
438 if ( !(v24 & 0x10000) ) | |
439 { | |
440 if ( !(v24 & 2) ) | |
441 { | |
442 v25 = v4->pODMFace; | |
443 if ( v25->uPolygonType == 1 ) | |
444 { | |
445 v26 = v25->pTextureUIDs[0]; | |
446 dword_80AA1C = v26; | |
447 dword_80AA20 = v26; | |
448 v27 = v25->pTextureVIDs[0]; | |
449 dword_80AA14 = v27; | |
450 dword_80AA18 = v27; | |
451 v35 = 1; | |
452 if ( v25->uNumVertices > 1u ) | |
453 { | |
454 v33 = (int)&v25->pTextureVIDs[1]; | |
455 do | |
456 { | |
457 if ( dword_80AA20 > *(short *)(v33 - 40) ) | |
458 dword_80AA20 = *(short *)(v33 - 40); | |
459 if ( v26 < *(short *)(v33 - 40) ) | |
460 { | |
461 v26 = *(short *)(v33 - 40); | |
462 dword_80AA1C = *(short *)(v33 - 40); | |
463 } | |
464 if ( dword_80AA18 > *(short *)v33 ) | |
465 dword_80AA18 = *(short *)v33; | |
466 if ( v27 < *(short *)v33 ) | |
467 { | |
468 v27 = *(short *)v33; | |
469 dword_80AA14 = *(short *)v33; | |
470 } | |
471 ++v35; | |
472 v33 += 2; | |
473 } | |
474 while ( v35 < v25->uNumVertices ); | |
475 v0 = a1; | |
476 } | |
477 dword_80AA20 = (dword_80AA20 + v4->sTextureDeltaU) << 16; | |
478 dword_80AA1C = ((v26 + v4->sTextureDeltaU) << 16) - 65536; | |
479 dword_80AA18 = (dword_80AA18 + v4->sTextureDeltaV) << 16; | |
480 dword_80AA14 = ((v27 + v4->sTextureDeltaV) << 16) - 65536; | |
481 } | |
482 while ( 1 ) | |
483 { | |
484 if ( !sr_sub_482E07(v3, v0) ) | |
485 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
486 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
487 if ( v4->prolly_tail == v3 ) | |
488 break; | |
489 v3 = v3->pNext; | |
490 } | |
491 goto LABEL_14; | |
492 } | |
493 while ( 1 ) | |
494 { | |
495 LABEL_74: | |
496 if ( !sr_sub_4839BD(v3, v0) ) | |
497 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
498 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
499 if ( v4->prolly_tail == v3 ) | |
500 break; | |
501 v3 = v3->pNext; | |
502 } | |
503 goto LABEL_14; | |
504 } | |
505 if ( v24 & 2 ) | |
506 goto LABEL_74; | |
507 while ( 1 ) | |
508 { | |
509 if ( !sr_sub_482A94(v3) ) | |
510 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
511 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
512 if ( v4->prolly_tail == v3 ) | |
513 break; | |
514 v3 = v3->pNext; | |
515 } | |
516 } | |
517 } | |
518 else | |
519 { | |
520 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
521 } | |
522 } | |
523 } | |
524 } | |
525 LABEL_14: | |
526 ++v34; | |
527 LOWORD(v2) = v34; | |
528 v36 += 67; | |
529 } | |
530 while ( v34 < (signed int)v37 ); | |
531 } | |
532 if ( pParty->uFlags & 2 ) | |
533 { | |
534 v6 = pOutdoorCamera->numStru148s; | |
535 v7 = 0; | |
536 uNumElementsIn80AA28 = 0; | |
537 if ( pOutdoorCamera->numStru148s > 0 ) | |
538 { | |
539 v8 = (char *)&array_77EC08[0].flags; | |
540 do | |
541 { | |
542 v2 = *(stru148 **)v8; | |
543 if ( (unsigned int)v2 & 0x20000 ) | |
544 { | |
545 ++v7; | |
546 *(int *)v8 = (unsigned int)v2 & 0xFFFDFFFF; | |
547 LOWORD(v2) = (short)v8 - 48; | |
548 *(&uNumElementsIn80AA28 + v7) = (unsigned int)(v8 - 48); | |
549 } | |
550 v8 += 268; | |
551 --v6; | |
552 } | |
553 while ( v6 ); | |
554 uNumElementsIn80AA28 = v7; | |
555 } | |
556 } | |
557 v9 = pOutdoorCamera->uNumSpans; | |
558 unnamed_6BE060[0] = pOutdoorCamera->uNumSpans; | |
973 | 559 if (pOutdoorCamera->numStru148s >= 1999) |
560 return; | |
561 | |
562 array_77EC08[1999]._48607B(&stru_8019C8); | |
563 array_77EC08[1999].ptr_38->_48694B(); | |
564 | |
565 if (pOutdoor->uMainTile_BitmapID == -1) | |
566 { | |
567 array_77EC08[1999].pTexture = nullptr; | |
568 return; | |
569 } | |
570 else | |
571 array_77EC08[1999].pTexture = pBitmaps_LOD->GetTexture(pOutdoor->uMainTile_BitmapID); | |
638 | 572 array_77EC08[1999].dimming_level = 23 - (-20 * pOutdoor->vSunlight.z >> 16); |
573 if ( array_77EC08[1999].dimming_level > 20 ) | |
574 array_77EC08[1999].dimming_level = 20; | |
323 | 575 v10 = stru_5C6E00->Sin(pIndoorCamera->sRotationX); |
0 | 576 array_77EC08[1999].v_18.y = 0; |
577 array_77EC08[1999].v_18.x = v10; | |
323 | 578 array_77EC08[1999].v_18.z = stru_5C6E00->Cos(pIndoorCamera->sRotationX); |
0 | 579 array_77EC08[1999].field_24 = 2048 - (pIndoorCamera->pos.z << 16); |
580 a1a = (signed __int64)((double)(pIndoorCamera->pos.z * pOutdoorCamera->int_fov_rad) | |
581 / ((double)pOutdoorCamera->int_fov_rad + 8192.0) | |
582 + (double)pViewport->uScreenCenterY); | |
583 cos((double)pIndoorCamera->sRotationX * 0.0030664064); | |
584 sin((double)pIndoorCamera->sRotationX * 0.0030664064); | |
585 array_77EC08[1999]._48607B(&stru_8019C8); | |
586 array_77EC08[1999].ptr_38->_48694B(); | |
973 | 587 |
588 if (pOutdoor->uSky_TextureID == -1) | |
589 { | |
590 array_77EC08[1999].pTexture = nullptr; | |
591 return; | |
592 } | |
593 else | |
594 array_77EC08[1999].pTexture = pBitmaps_LOD->GetTexture(pOutdoor->uSky_TextureID); | |
638 | 595 array_77EC08[1999].dimming_level = 0; |
323 | 596 v11 = stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16); |
0 | 597 array_77EC08[1999].v_18.y = 0; |
598 array_77EC08[1999].v_18.x = -v11; | |
323 | 599 array_77EC08[1999].v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16); |
0 | 600 LOWORD(v2) = 224 * LOWORD(pMiscTimer->uTotalGameTimeElapsed); |
601 array_77EC08[1999].field_24 = 0x2000000u; | |
602 array_77EC08[1999].sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
603 array_77EC08[1999].sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
767 | 604 if ( day_attrib & DAY_ATTRIB_FOG |
0 | 605 && (LOWORD(v2) = LOWORD(pParty->uCurrentHour), pParty->uCurrentHour >= 5) |
606 && pParty->uCurrentHour < 0x15 | |
607 || bUnderwater ) | |
608 { | |
609 v2 = (stru148 *)*(short *)PaletteManager::Get_Mist_or_Red_LUT(array_77EC08[1999].pTexture->palette_id2, 31, 1); | |
610 a1b = (unsigned int)v2; | |
611 if ( (signed int)v9 <= 0 ) | |
973 | 612 return; |
0 | 613 v29 = v9; |
614 while ( 1 ) | |
615 { | |
616 v30 = &pSpans[v29 - 1]; | |
617 v2 = (stru148 *)v30->field_E; | |
618 if ( v2 != (stru148 *)unnamed_6BE060[1] ) | |
619 { | |
693 | 620 LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); |
621 if ( v30->field_8 >= (signed int)pViewport->uViewportTL_X ) | |
0 | 622 goto LABEL_124; |
693 | 623 if ( v30->field_C == pViewport->uViewportTL_X ) |
0 | 624 { |
625 v30->field_E = LOWORD(unnamed_6BE060[1]); | |
626 } | |
627 else | |
628 { | |
693 | 629 v30->field_8 = LOWORD(pViewport->uViewportTL_X); |
630 v30->field_C -= LOWORD(pViewport->uViewportTL_X); | |
0 | 631 if ( v30->field_C >= 0 ) |
632 { | |
633 LABEL_124: | |
634 v31 = v30->field_C; | |
635 v30->pParent = &array_77EC08[1999]; | |
636 fill_pixels_fast( | |
637 a1b, | |
638 &pRenderer->pTargetSurface[v30->field_8 + pRenderer->uTargetSurfacePitch * v30->field_A], | |
639 v31); | |
640 j_memset32(-65536, &pRenderer->pActiveZBuffer[v30->field_8 + 640 * v30->field_A], v30->field_C); | |
641 goto LABEL_125; | |
642 } | |
643 LOWORD(v2) = LOWORD(unnamed_6BE060[1]); | |
644 v30->field_E = LOWORD(unnamed_6BE060[1]); | |
645 } | |
646 } | |
647 LABEL_125: | |
648 --v29; | |
649 --v9; | |
650 if ( !v9 ) | |
973 | 651 return; |
0 | 652 } |
653 } | |
654 if ( (signed int)v9 > 0 ) | |
655 { | |
656 v12 = v9; | |
657 do | |
658 { | |
659 v13 = &pSpans[v12 - 1]; | |
660 v2 = (stru148 *)v13->field_E; | |
661 if ( v2 != (stru148 *)unnamed_6BE060[1] ) | |
662 { | |
693 | 663 LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); |
664 if ( v13->field_8 >= (signed int)pViewport->uViewportTL_X ) | |
0 | 665 goto LABEL_109; |
693 | 666 if ( v13->field_C != pViewport->uViewportTL_X ) |
667 { | |
668 v13->field_8 = LOWORD(pViewport->uViewportTL_X); | |
669 v13->field_C -= LOWORD(pViewport->uViewportTL_X); | |
0 | 670 if ( v13->field_C >= 0 ) |
671 { | |
672 LABEL_109: | |
673 if ( pOutdoorCamera->bNoSky ) | |
674 { | |
675 const_1_0(); | |
676 } | |
677 else | |
678 { | |
679 v13->pParent = &array_77EC08[1999]; | |
680 if ( !Render::DrawSkySW(v13, &array_77EC08[1999], a1a) ) | |
681 j_memset32(-65536, &pRenderer->pActiveZBuffer[v13->field_8 + 640 * v13->field_A], v13->field_C); | |
682 } | |
683 } | |
684 LOWORD(v2) = LOWORD(unnamed_6BE060[1]); | |
685 v13->field_E = LOWORD(unnamed_6BE060[1]); | |
686 goto LABEL_114; | |
687 } | |
688 v13->field_E = LOWORD(unnamed_6BE060[1]); | |
689 } | |
690 LABEL_114: | |
691 --v12; | |
692 --v9; | |
693 } | |
694 while ( v9 ); | |
695 } | |
696 } | |
697 | |
698 //----- (00485044) -------------------------------------------------------- | |
699 int Render::DrawSkySW(Span *a1, stru148 *a2, int a3) | |
700 { | |
701 stru148 *v3; // esi@1 | |
702 Span *v4; // edi@1 | |
703 float v5; // ST2C_4@1 | |
704 signed int result; // eax@2 | |
705 int v7; // ST40_4@3 | |
706 stru149 *v8; // eax@3 | |
707 int v9; // ebx@3 | |
708 int v10; // ecx@3 | |
709 int v11; // edx@3 | |
710 int v12; // eax@3 | |
711 int v13; // ST28_4@5 | |
712 int v14; // eax@5 | |
713 signed __int64 v15; // qtt@11 | |
714 int v16; // ST28_4@11 | |
715 int v17; // eax@11 | |
716 signed int v18; // ecx@11 | |
717 int v19; // ST40_4@11 | |
718 int v20; // ST3C_4@11 | |
719 int v21; // ST30_4@11 | |
720 void *v22; // eax@11 | |
721 Texture *v23; // esi@11 | |
722 int v24; // ecx@11 | |
723 unsigned int v25; // esi@11 | |
724 int v26; // edi@11 | |
725 unsigned __int16 *v27; // eax@11 | |
726 int *v28; // ebx@12 | |
727 int v29; // edx@13 | |
728 unsigned __int16 v30; // cx@13 | |
729 int v31; // edx@14 | |
730 unsigned __int16 v32; // cx@14 | |
731 unsigned __int8 v33; // sf@15 | |
732 unsigned __int8 v34; // of@15 | |
733 double v35; // [sp+14h] [bp-38h]@1 | |
734 int v36; // [sp+18h] [bp-34h]@3 | |
735 signed int v37; // [sp+18h] [bp-34h]@11 | |
736 int v38; // [sp+1Ch] [bp-30h]@3 | |
737 signed int v39; // [sp+1Ch] [bp-30h]@11 | |
738 int v40; // [sp+20h] [bp-2Ch]@3 | |
739 void *v41; // [sp+20h] [bp-2Ch]@11 | |
740 int v42; // [sp+24h] [bp-28h]@3 | |
741 unsigned __int8 *v43; // [sp+24h] [bp-28h]@11 | |
742 int v44; // [sp+28h] [bp-24h]@11 | |
743 int v45; // [sp+2Ch] [bp-20h]@3 | |
744 signed int v46; // [sp+30h] [bp-1Ch]@3 | |
745 __int16 v47; // [sp+30h] [bp-1Ch]@11 | |
746 signed int v48; // [sp+34h] [bp-18h]@3 | |
747 int v49; // [sp+34h] [bp-18h]@11 | |
748 int v50; // [sp+38h] [bp-14h]@3 | |
749 unsigned __int16 *v51; // [sp+38h] [bp-14h]@11 | |
750 int v52; // [sp+3Ch] [bp-10h]@4 | |
751 int a1a; // [sp+40h] [bp-Ch]@3 | |
752 int v54; // [sp+44h] [bp-8h]@3 | |
753 int v55; // [sp+48h] [bp-4h]@3 | |
754 int v56; // [sp+54h] [bp+8h]@11 | |
755 int *v57; // [sp+54h] [bp+8h]@11 | |
756 | |
757 v3 = a2; | |
758 v4 = a1; | |
693 | 759 v5 = (double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5 / tan(0.6457717418670654) + 0.5; |
0 | 760 v35 = v5 + 6.7553994e15; |
761 if ( LODWORD(v35) ) | |
762 { | |
763 v55 = 65536 / SLODWORD(v35); | |
764 v7 = 65536 / SLODWORD(v35) * (a3 - v4->field_A); | |
765 v8 = v3->ptr_38; | |
766 v42 = ((unsigned __int64)(v3->ptr_38->field_14 * (signed __int64)v7) >> 16) + v8->field_C; | |
767 v40 = ((unsigned __int64)(v8->field_20 * (signed __int64)v7) >> 16) + v3->ptr_38->field_18; | |
768 v38 = pOutdoorCamera->camera_rotation_y_int_sine; | |
769 HIDWORD(v35) = pOutdoorCamera->camera_rotation_y_int_cosine; | |
770 v45 = v4->field_C; | |
771 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v7) >> 16) + v3->v_18.x; | |
772 v10 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); | |
773 v48 = 0; | |
774 v50 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); | |
775 v46 = -v3->field_24; | |
776 v11 = v4->field_A - 1; | |
777 v54 = v11; | |
778 v12 = 65536 / SLODWORD(v35) * (a3 - v11); | |
779 a1a = 65536 / SLODWORD(v35) * (a3 - v11); | |
780 while ( 1 ) | |
781 { | |
782 v52 = v9; | |
783 if ( v9 ) | |
784 { | |
785 v13 = abs(v46 >> 14); | |
786 v14 = abs(v9); | |
787 v11 = v54; | |
788 v10 = v50; | |
789 if ( v13 <= v14 ) | |
790 break; | |
791 v12 = a1a; | |
792 } | |
693 | 793 if ( v11 <= (signed int)pViewport->uViewportTL_Y ) |
0 | 794 break; |
795 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v12) >> 16) + v3->v_18.x; | |
796 --v54; | |
797 a1a += v55; | |
798 v12 = a1a; | |
799 v11 = v54; | |
800 v48 = 1; | |
801 } | |
802 if ( v48 ) | |
803 v52 = ((unsigned __int64)(v3->v_18.z * (signed __int64)(v55 * (a3 + (signed int)v4->field_A - 2 * v11))) >> 16) | |
804 + v3->v_18.x; | |
805 LODWORD(v15) = v46 << 16; | |
806 HIDWORD(v15) = v46 >> 16; | |
807 v16 = v42 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v10) >> 16); | |
808 v17 = v40 + ((unsigned __int64)(v3->ptr_38->field_1C * (signed __int64)v10) >> 16); | |
809 v18 = v15 / v52; | |
710 | 810 v43 = v3->pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 811 v19 = v3->sTextureDeltaU + ((signed int)((unsigned __int64)(v16 * v15 / v52) >> 16) >> 3); |
812 v56 = v15 / v52; | |
813 v20 = v3->sTextureDeltaV + ((signed int)((unsigned __int64)(v17 * v15 / v52) >> 16) >> 3); | |
814 v21 = (unsigned __int64)(v55 * (signed __int64)v56) >> 16; | |
815 v39 = (signed int)((unsigned __int64)(v21 * (signed __int64)v38) >> 16) >> 3; | |
816 v37 = (signed int)((unsigned __int64)(v21 * (signed __int64)v36) >> 16) >> 3; | |
817 v22 = sr_sub_47C178(v18, v3, 0, 1); | |
818 v23 = v3->pTexture; | |
819 v41 = v22; | |
820 v47 = 16 - v23->uWidthLn2; | |
821 v44 = v23->uTextureWidth - 1; | |
822 v49 = (v23->uTextureHeight << 16) - 65536; | |
823 v24 = v4->field_8; | |
824 v51 = &pRenderer->pTargetSurface[v24 + pRenderer->uTargetSurfacePitch * v4->field_A]; | |
825 v57 = &pRenderer->pActiveZBuffer[v24 + 640 * v4->field_A]; | |
826 v25 = v19; | |
827 v26 = v20; | |
828 v27 = v51; | |
829 if ( !(v45 & 1) ) | |
830 goto LABEL_15; | |
831 --v45; | |
832 v27 = v51 - 1; | |
833 v28 = v57; | |
834 ++v57; | |
835 while ( 1 ) | |
836 { | |
837 *v28 = -65536; | |
838 v31 = v44 & (v25 >> 16); | |
839 v27 += 2; | |
840 v25 += v39; | |
841 v32 = *((short *)v41 + *(&v43[v31] + ((v49 & (unsigned int)v26) >> v47))); | |
842 v26 += v37; | |
843 *(v27 - 1) = v32; | |
844 LABEL_15: | |
845 v34 = __OFSUB__(v45, 2); | |
846 v33 = v45 - 2 < 0; | |
847 v45 -= 2; | |
848 if ( v33 ^ v34 ) | |
849 break; | |
850 v29 = v44 & (v25 >> 16); | |
851 v25 += v39; | |
852 v30 = *((short *)v41 + *(&v43[v29] + ((v49 & (unsigned int)v26) >> v47))); | |
853 v26 += v37; | |
854 v28 = v57; | |
855 *v27 = v30; | |
856 v57 += 2; | |
857 v28[1] = -65536; | |
858 } | |
859 result = 1; | |
860 } | |
861 else | |
862 { | |
863 result = 0; | |
864 } | |
865 return result; | |
866 } | |
867 | |
868 //----- (0047F5C6) -------------------------------------------------------- | |
869 float Render::DrawBezierTerrain() | |
870 { | |
871 //__debugbreak();Ritor1: it's temporarily | |
872 //return 0; | |
873 | |
86 | 874 unsigned int pDirectionIndicator1; // ebx@1 |
875 unsigned int pDirectionIndicator2; // edi@1 | |
0 | 876 unsigned int v2; // eax@1 |
877 int v3; // eax@3 | |
878 int v4; // edi@3 | |
879 int v5; // ebx@3 | |
880 int v6; // esi@3 | |
881 unsigned int v7; // eax@3 | |
882 int v8; // eax@4 | |
883 unsigned int v9; // eax@6 | |
884 int v10; // eax@7 | |
985 | 885 //int v11; // ebx@9 |
886 //int v12; // edi@9 | |
0 | 887 int v13; // eax@21 |
888 int v14; // eax@31 | |
889 int v15; // edi@33 | |
67 | 890 int v16; // eax@34 |
0 | 891 int v17; // edx@34 |
892 int v18; // ebx@34 | |
893 int v19; // eax@36 | |
894 int v20; // eax@39 | |
895 int v21; // ecx@43 | |
985 | 896 //char v22; // zf@44 |
0 | 897 int v23; // ecx@47 |
990 | 898 //int v24; // edi@52 |
67 | 899 int v25; // eax@54 |
0 | 900 int v26; // ecx@54 |
901 int v27; // eax@56 | |
902 int v28; // edx@60 | |
903 int v29; // ecx@61 | |
904 int v30; // ecx@64 | |
905 int v31; // ecx@68 | |
906 int v32; // eax@70 | |
907 int v33; // ecx@71 | |
908 int v34; // eax@73 | |
909 int v35; // ecx@77 | |
910 int v36; // ecx@81 | |
911 int v37; // ecx@86 | |
67 | 912 int v38; // eax@88 |
913 int v39; // ecx@88 | |
0 | 914 int v40; // eax@90 |
915 int v41; // edx@94 | |
916 int v42; // ecx@95 | |
917 int v43; // ecx@98 | |
918 int v44; // ecx@102 | |
919 int v45; // eax@104 | |
920 int v46; // eax@107 | |
921 int v47; // ecx@111 | |
922 int v48; // ecx@115 | |
923 int v49; // edi@120 | |
67 | 924 int v50; // eax@122 |
0 | 925 int v51; // ecx@122 |
926 int v52; // eax@124 | |
927 int v53; // edx@128 | |
928 int v54; // ecx@129 | |
929 int v55; // ecx@132 | |
930 int v56; // eax@139 | |
931 int v57; // ecx@140 | |
932 int v58; // eax@142 | |
933 int v59; // ecx@146 | |
934 int v60; // ecx@147 | |
935 int v61; // ecx@150 | |
936 int v62; // ecx@155 | |
67 | 937 int v63; // eax@157 |
938 int v64; // ecx@157 | |
0 | 939 int v65; // eax@159 |
940 int v66; // edx@163 | |
941 int v67; // ecx@164 | |
942 int v68; // ecx@167 | |
990 | 943 //int v69; // eax@173 |
0 | 944 int v70; // edi@178 |
985 | 945 //int v71; // eax@178 |
946 //int v72; // ecx@178 | |
947 //int x; // ebx@180 | |
948 //int v74; // eax@182 | |
0 | 949 int v75; // eax@184 |
67 | 950 IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 |
86 | 951 int uStartZ; // ecx@184 |
0 | 952 int v79; // ebx@185 |
953 int v127; // esi@185 | |
954 int v86; // edi@196 | |
985 | 955 //int v87; // eax@196 |
956 //int v88; // ecx@196 | |
957 //int v89; // eax@198 | |
958 //int v90; // ecx@200 | |
0 | 959 int v92; // ebx@203 |
985 | 960 //int v93; // ST08_4@204 |
0 | 961 int v97; // ST08_4@204 |
962 float result; // eax@212 | |
985 | 963 //struct |
964 //{ | |
965 int v106; // [sp+Ch] [bp-68h]@191 | |
966 int v103; // [sp+10h] [bp-64h]@190 | |
967 int v104; // [sp+12h] [bp-62h]@190 | |
968 //} v102; | |
77 | 969 int v105; // [sp+1Ch] [bp-58h]@1 |
985 | 970 int v107; // [sp+20h] [bp-54h]@3 |
86 | 971 int uEndZ; // [sp+24h] [bp-50h]@3 |
0 | 972 int v108; // [sp+28h] [bp-4Ch]@9 |
973 int v109; // [sp+2Ch] [bp-48h]@9 | |
974 int v110; // [sp+30h] [bp-44h]@9 | |
975 int v111; // [sp+34h] [bp-40h]@3 | |
976 int v112; // [sp+38h] [bp-3Ch]@6 | |
67 | 977 IndoorCameraD3D *pIndoorCameraD3D_4; // [sp+3Ch] [bp-38h]@9 |
0 | 978 int v114; // [sp+40h] [bp-34h]@9 |
979 int v115; // [sp+44h] [bp-30h]@9 | |
980 int v116; // [sp+48h] [bp-2Ch]@9 | |
985 | 981 //int v117; // [sp+4Ch] [bp-28h]@9 |
0 | 982 int v118; // [sp+50h] [bp-24h]@9 |
983 int v119; // [sp+54h] [bp-20h]@1 | |
984 int v120; // [sp+58h] [bp-1Ch]@1 | |
985 int i; // [sp+5Ch] [bp-18h]@1 | |
986 int v122; // [sp+60h] [bp-14h]@1 | |
987 int v123; // [sp+64h] [bp-10h]@1 | |
67 | 988 int v124; // [sp+68h] [bp-Ch]@1 |
0 | 989 int v125; // [sp+6Ch] [bp-8h]@9 |
67 | 990 int v126; // [sp+70h] [bp-4h]@9 |
991 | |
96 | 992 v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2 |
86 | 993 pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 |
994 pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512 | |
323 | 995 v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16; |
996 v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16; | |
67 | 997 v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X |
0 | 998 v119 = pOutdoorCamera->outdoor_grid_band_3 + v123; |
999 v2 = pOutdoorCamera->uCameraFovInDegrees + 15; | |
67 | 1000 i = v124 - pOutdoorCamera->outdoor_grid_band_3; |
0 | 1001 v122 = v123 - pOutdoorCamera->outdoor_grid_band_3; |
67 | 1002 |
1003 if ( v2 > 90 ) | |
0 | 1004 v2 = 90; |
67 | 1005 v3 = (v2 << 11) / 720; |
86 | 1006 v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3); |
1007 v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1); | |
323 | 1008 v106 = stru_5C6E00->Cos(v4); |
1009 uEndZ = stru_5C6E00->Sin(v4); | |
1010 v111 = stru_5C6E00->Cos(v5); | |
1011 v6 = stru_5C6E00->Sin(v5); | |
0 | 1012 v7 = v4 & stru_5C6E00->uPiMask; |
67 | 1013 |
1014 if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) | |
0 | 1015 v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7]; |
1016 else | |
1017 v8 = stru_5C6E00->pTanTable[v7]; | |
1018 v112 = abs(v8); | |
1019 v9 = v5 & stru_5C6E00->uPiMask; | |
67 | 1020 if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) |
0 | 1021 v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9]; |
1022 else | |
1023 v10 = stru_5C6E00->pTanTable[v9]; | |
1024 v108 = abs(v10); | |
985 | 1025 //v11 = v124; |
1026 //v12 = v123; | |
0 | 1027 v114 = 0; |
1028 v115 = 0; | |
67 | 1029 pIndoorCameraD3D_4 = 0; |
0 | 1030 v125 = 0; |
67 | 1031 v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; |
0 | 1032 v126 = v124; |
1033 v118 = v123; | |
86 | 1034 v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; |
1035 uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; | |
0 | 1036 terrain_76E1C8[0] = 65535; |
985 | 1037 uint _i = 1; |
67 | 1038 v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; |
985 | 1039 uint j = 1; |
0 | 1040 terrain_76E3C8[0] = 65535; |
1041 terrain_76DDC8[0] = 65535; | |
1042 terrain_76DFC8[0] = 65535; | |
985 | 1043 for( _i = 1; _i < 128; _i++) |
67 | 1044 { |
1045 if ( v112 >= 0x10000 ) | |
1046 { | |
1047 int v1, v2; | |
1048 /*v111 = 4294967296i64 / v112; | |
0 | 1049 v114 += v111; |
1050 if ( v114 >= 65536 ) | |
1051 { | |
1052 v11 += v110; | |
1053 v114 = (unsigned __int16)v114; | |
1054 } | |
67 | 1055 v12 += v109;*/ |
0 | 1056 } |
1057 else | |
1058 { | |
985 | 1059 v124 += v110; |
0 | 1060 v115 += v112; |
67 | 1061 if ( v112 + v115 >= 65536 ) |
0 | 1062 { |
985 | 1063 v123 += v109; |
0 | 1064 v115 = (unsigned __int16)v115; |
1065 } | |
1066 } | |
985 | 1067 if ( v124 < _i || v124 > v120 || v123 < v122 || v123 > v119 ) |
0 | 1068 break; |
67 | 1069 //v13 = v116++; |
985 | 1070 terrain_76E3C8[_i] = v124; |
1071 terrain_76E1C8[_i] = v123; | |
1072 } | |
1073 | |
1074 for( j = 1; j < 128; j++ ) | |
0 | 1075 { |
1076 if ( v108 >= 65536 ) | |
1077 { | |
1078 v111 = 4294967296i64 / v108; | |
67 | 1079 v114 += v111;// |
1080 if ( v111 + v114 >= 65536 ) | |
1081 { | |
86 | 1082 v126 += uEndZ; |
67 | 1083 v114 = (unsigned __int16)v114;// |
0 | 1084 } |
1085 v118 += v106; | |
1086 } | |
1087 else | |
1088 { | |
1089 v125 += v108; | |
86 | 1090 v126 += uEndZ; |
0 | 1091 if ( v125 >= 65536 ) |
1092 { | |
1093 v118 += v106; | |
1094 v125 = (unsigned __int16)v125; | |
1095 } | |
1096 } | |
67 | 1097 //if ( v117 >= 128 ) |
1098 //break; | |
985 | 1099 if ( v126 < _i ) |
0 | 1100 break; |
67 | 1101 if ( v126 > v120 ) |
0 | 1102 break; |
1103 v14 = v118; | |
1104 if ( v118 < v122 ) | |
1105 break; | |
1106 if ( v118 > v119 ) | |
1107 break; | |
985 | 1108 terrain_76DFC8[j] = v126; |
1109 terrain_76DDC8[j] = v14; | |
67 | 1110 } |
1111 v16 = 0; | |
1112 v126 = 0; | |
985 | 1113 v17 = j - 1; |
1114 v18 = _i - 1; | |
77 | 1115 switch ( v105 ) |
0 | 1116 { |
1117 case 0: | |
1118 case 7: | |
67 | 1119 { |
985 | 1120 //v116 = terrain_76DFC8[v17]; |
1121 if ( v120 > terrain_76DFC8[v17] ) | |
0 | 1122 { |
1123 v125 = v120; | |
985 | 1124 memset32(terrain_76D9C8, v119 + 1, 4 * (v120 - terrain_76DFC8[v17] + 1)); |
0 | 1125 v19 = v120; |
1126 do | |
67 | 1127 terrain_76DBC8[v126++] = v19--; |
985 | 1128 while ( v19 >= terrain_76DFC8[v17] ); |
0 | 1129 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 + 127] ) |
1130 { | |
1131 do | |
67 | 1132 v20 = terrain_76DDC8[v17-- -1]; |
1133 while ( v20 == terrain_76DDC8[v17 -1] ); | |
0 | 1134 } |
1135 v16 = v126; | |
1136 --v17; | |
1137 } | |
1138 if ( v17 < 0 ) | |
1139 v17 = 0; | |
1140 v21 = terrain_76DFC8[v17]; | |
1141 while ( 1 ) | |
1142 { | |
990 | 1143 v125 = terrain_76DFC8[v17]; |
67 | 1144 if ( v21 < v124 ) |
0 | 1145 break; |
67 | 1146 terrain_76DBC8[v16] = v21; |
985 | 1147 //v22 = terrain_76DDC8[v17] == 65535; |
67 | 1148 terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1; |
985 | 1149 if ( terrain_76DDC8[v17] == 65535 ) |
0 | 1150 { |
67 | 1151 terrain_76D9C8[v16] = v123 + 1; |
0 | 1152 break; |
1153 } | |
1154 if ( !v17 ) | |
1155 break; | |
67 | 1156 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 - 1] ) |
0 | 1157 { |
1158 do | |
67 | 1159 v23 = terrain_76DDC8[v17-- -1]; |
1160 while ( v23 == terrain_76DDC8[v17 -1] ); | |
0 | 1161 } |
1162 --v17; | |
1163 v21 = v125 - 1; | |
67 | 1164 ++v16; |
1165 } | |
1166 v16 = 0; | |
990 | 1167 //v24 = terrain_76E3C8[v18]; |
67 | 1168 v126 = 0; |
990 | 1169 if ( v120 > terrain_76E3C8[v18] ) |
0 | 1170 { |
1171 v125 = v120; | |
990 | 1172 memset32(terrain_76D5C8, v122, 4 * (v120 - terrain_76E3C8[v18] + 1)); |
0 | 1173 do |
1174 { | |
1175 v25 = v126; | |
1176 v26 = v125--; | |
67 | 1177 ++v126; |
1178 terrain_76D7C8[v25] = v26; | |
0 | 1179 } |
1180 while ( v125 >= terrain_76E3C8[v18] ); | |
67 | 1181 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) |
0 | 1182 { |
1183 do | |
67 | 1184 v27 = terrain_76E1C8[v18-- -1]; |
1185 while ( v27 == terrain_76E1C8[v18 -1] ); | |
0 | 1186 } |
1187 v16 = v126; | |
1188 --v18; | |
1189 } | |
1190 if ( v18 < 0 ) | |
1191 v18 = 0; | |
1192 v28 = terrain_76E3C8[v18]; | |
67 | 1193 while ( v28 >= v124 ) |
0 | 1194 { |
1195 v29 = terrain_76E1C8[v18]; | |
67 | 1196 terrain_76D7C8[v16] = v28; |
1197 terrain_76D5C8[v16] = v29; | |
0 | 1198 if ( v29 == 65535 ) |
1199 { | |
1200 v31 = v123; | |
67 | 1201 terrain_76D5C8[v16] = v31; |
1202 break; | |
0 | 1203 } |
1204 if ( !v18 ) | |
1205 break; | |
67 | 1206 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) |
0 | 1207 { |
1208 do | |
67 | 1209 v30 = terrain_76E1C8[v18-- -1]; |
1210 while ( v30 == terrain_76E1C8[v18 -1] ); | |
0 | 1211 } |
1212 --v18; | |
1213 --v28; | |
67 | 1214 ++v16; |
0 | 1215 } |
1216 break; | |
67 | 1217 } |
0 | 1218 case 1: |
1219 case 2: | |
67 | 1220 { |
985 | 1221 //v116 = terrain_76DDC8[v17]; |
1222 if ( v122 < terrain_76DDC8[v17] ) | |
0 | 1223 { |
1224 v106 = v122; | |
985 | 1225 memset32(terrain_76DBC8, v120 + 1, 4 * (terrain_76DDC8[v17] - v122 + 1)); |
0 | 1226 v32 = v122; |
1227 do | |
1228 { | |
67 | 1229 v33 = v126++; |
0 | 1230 terrain_76D9C8[v33] = v32++; |
1231 } | |
985 | 1232 while ( v32 <= terrain_76DDC8[v17] ); |
67 | 1233 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1234 { |
1235 do | |
67 | 1236 v34 = terrain_76DBC8[v17-- -1]; |
1237 while ( v34 == terrain_76DBC8[v17 -1] ); | |
0 | 1238 } |
1239 v16 = v126; | |
1240 --v17; | |
1241 } | |
1242 if ( v17 < 0 ) | |
1243 v17 = 0; | |
1244 v35 = terrain_76DDC8[v17]; | |
1245 v125 = terrain_76DDC8[v17]; | |
1246 while ( v35 <= v123 ) | |
1247 { | |
985 | 1248 //v22 = terrain_76DFC8[v17] == 65535; |
67 | 1249 terrain_76DBC8[v16] = terrain_76DFC8[v17] + 1; |
1250 terrain_76D9C8[v16] = v125; | |
985 | 1251 if ( terrain_76DFC8[v17] == 65535 ) |
0 | 1252 { |
67 | 1253 terrain_76DBC8[v16] = v124 + 1; |
0 | 1254 break; |
1255 } | |
1256 if ( !v17 ) | |
1257 break; | |
67 | 1258 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1259 { |
1260 do | |
67 | 1261 v36 = terrain_76DBC8[v17-- -1]; |
1262 while ( v36 == terrain_76DBC8[v17 -1] ); | |
0 | 1263 } |
1264 --v17; | |
1265 ++v125; | |
1266 v35 = v125; | |
67 | 1267 ++v16; |
1268 } | |
1269 v16 = 0; | |
1270 v126 = 0; | |
0 | 1271 v37 = terrain_76E1C8[v18]; |
1272 if ( v122 < v37 ) | |
1273 { | |
67 | 1274 v114 = v122; |
1275 memset32(terrain_76D7C8, i, 4 * (v37 - v122 + 1)); | |
0 | 1276 do |
1277 { | |
1278 v38 = v126; | |
67 | 1279 v39 = v114; |
1280 ++v126; | |
1281 ++v114; | |
1282 terrain_76D5C8[v38] = v39; | |
1283 } | |
1284 while ( v114 <= terrain_76E1C8[v18] ); | |
1285 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) | |
0 | 1286 { |
1287 do | |
67 | 1288 v40 = terrain_76DFC8[v18-- -1]; |
1289 while ( v40 == terrain_76DFC8[v18 -1] ); | |
0 | 1290 } |
1291 v16 = v126; | |
1292 --v18; | |
1293 } | |
1294 if ( v18 < 0 ) | |
1295 v18 = 0; | |
1296 v41 = terrain_76E1C8[v18]; | |
1297 while ( v41 <= v123 ) | |
1298 { | |
1299 v42 = terrain_76E3C8[v18]; | |
67 | 1300 terrain_76D5C8[v16] = v41; |
1301 terrain_76D7C8[v16] = v42; | |
0 | 1302 if ( v42 == 65535 ) |
1303 { | |
67 | 1304 terrain_76D7C8[v16] = v124; |
1305 break; | |
0 | 1306 } |
1307 if ( !v18 ) | |
1308 break; | |
67 | 1309 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) |
0 | 1310 { |
1311 do | |
67 | 1312 v43 = terrain_76DFC8[v18-- -1]; |
1313 while ( v43 == terrain_76DFC8[v18 -1] ); | |
0 | 1314 } |
1315 --v18; | |
1316 ++v41; | |
67 | 1317 ++v16; |
0 | 1318 } |
1319 break; | |
67 | 1320 } |
0 | 1321 case 5: |
1322 case 6: | |
67 | 1323 { |
985 | 1324 //v116 = terrain_76DDC8[v17]; |
1325 if ( v119 > terrain_76DDC8[v17] ) | |
0 | 1326 { |
1327 v106 = v119; | |
985 | 1328 memset32(terrain_76DBC8, i, 4 * (v119 - terrain_76DDC8[v17] + 1)); |
0 | 1329 v45 = v119; |
1330 do | |
67 | 1331 terrain_76D9C8[v126++] = v45--; |
985 | 1332 while ( v45 >= terrain_76DDC8[v17] ); |
67 | 1333 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1334 { |
1335 do | |
67 | 1336 v46 = terrain_76DBC8[v17-- -1]; |
1337 while ( v46 == terrain_76DBC8[v17 -1] ); | |
0 | 1338 } |
1339 v16 = v126; | |
1340 --v17; | |
1341 } | |
1342 if ( v17 < 0 ) | |
1343 v17 = 0; | |
1344 v47 = terrain_76DDC8[v17]; | |
1345 v125 = terrain_76DDC8[v17]; | |
1346 while ( v47 >= v123 ) | |
1347 { | |
985 | 1348 //v22 = terrain_76DFC8[v17] == 65535; |
67 | 1349 terrain_76DBC8[v16] = terrain_76DFC8[v17]; |
1350 terrain_76D9C8[v16] = v125; | |
985 | 1351 if ( terrain_76DFC8[v17] == 65535 ) |
0 | 1352 { |
67 | 1353 terrain_76DBC8[v16] = v124; |
0 | 1354 break; |
1355 } | |
1356 if ( !v17 ) | |
1357 break; | |
67 | 1358 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1359 { |
1360 do | |
67 | 1361 v48 = terrain_76DBC8[v17-- -1]; |
1362 while ( v48 == terrain_76DBC8[v17 -1] ); | |
0 | 1363 } |
1364 --v17; | |
1365 --v125; | |
1366 v47 = v125; | |
67 | 1367 ++v16; |
1368 } | |
1369 v16 = 0; | |
0 | 1370 v49 = terrain_76E1C8[v18]; |
67 | 1371 v126 = 0; |
0 | 1372 if ( v119 > v49 ) |
1373 { | |
1374 v125 = v119; | |
67 | 1375 memset32(terrain_76D7C8, v120 + 1, 4 * (v119 - v49 + 1)); |
0 | 1376 do |
1377 { | |
1378 v50 = v126; | |
1379 v51 = v125--; | |
67 | 1380 ++v126; |
1381 terrain_76D5C8[v50] = v51; | |
0 | 1382 } |
1383 while ( v125 >= terrain_76E1C8[v18] ); | |
67 | 1384 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) |
0 | 1385 { |
1386 do | |
67 | 1387 v52 = terrain_76DFC8[v18-- -1]; |
1388 while ( v52 == terrain_76DFC8[v18 -1] ); | |
0 | 1389 } |
1390 v16 = v126; | |
1391 --v18; | |
1392 } | |
1393 if ( v18 < 0 ) | |
1394 v18 = 0; | |
1395 v53 = terrain_76E1C8[v18]; | |
1396 while ( v53 >= v123 ) | |
1397 { | |
1398 v54 = terrain_76E3C8[v18]; | |
67 | 1399 terrain_76D5C8[v16] = v53; |
1400 terrain_76D7C8[v16] = v54 + 1; | |
0 | 1401 if ( v54 == 65535 ) |
1402 { | |
67 | 1403 terrain_76D7C8[v16] = v124 + 1; |
1404 break; | |
0 | 1405 } |
1406 if ( !v18 ) | |
67 | 1407 break; |
1408 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) | |
0 | 1409 { |
1410 do | |
67 | 1411 v55 = terrain_76DFC8[v18-- -1]; |
1412 while ( v55 == terrain_76DFC8[v18 -1] ); | |
0 | 1413 } |
1414 --v18; | |
1415 --v53; | |
67 | 1416 ++v16; |
0 | 1417 } |
1418 break; | |
67 | 1419 } |
0 | 1420 case 3: |
1421 case 4: | |
67 | 1422 { |
985 | 1423 //v116 = terrain_76DFC8[v17]; |
1424 if ( i < terrain_76DFC8[v17] ) | |
0 | 1425 { |
1426 v106 = i; | |
985 | 1427 memset32(terrain_76D9C8, v122, 4 * (terrain_76DFC8[v17] - i + 1)); |
0 | 1428 v56 = i; |
1429 do | |
1430 { | |
67 | 1431 v57 = v126++; |
0 | 1432 terrain_76DBC8[v57] = v56++; |
1433 } | |
985 | 1434 while ( v56 <= terrain_76DFC8[v17] ); |
67 | 1435 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) |
0 | 1436 { |
1437 do | |
67 | 1438 v58 = terrain_76DDC8[v17-- -1]; |
1439 while ( v58 == terrain_76DDC8[v17 -1] ); | |
0 | 1440 } |
1441 v16 = v126; | |
1442 --v17; | |
1443 } | |
1444 if ( v17 < 0 ) | |
1445 v17 = 0; | |
1446 v59 = terrain_76DFC8[v17]; | |
1447 while ( 1 ) | |
1448 { | |
1449 v125 = v59; | |
67 | 1450 if ( v59 > v124 ) |
0 | 1451 break; |
67 | 1452 terrain_76DBC8[v16] = v59; |
0 | 1453 v60 = terrain_76DDC8[v17]; |
67 | 1454 terrain_76D9C8[v16] = v60; |
0 | 1455 if ( v60 == 65535 ) |
1456 { | |
67 | 1457 terrain_76D9C8[v16] = v123; |
0 | 1458 break; |
1459 } | |
1460 if ( !v17 ) | |
1461 break; | |
67 | 1462 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) |
0 | 1463 { |
1464 do | |
67 | 1465 v61 = terrain_76DDC8[v17-- -1]; |
1466 while ( v61 == terrain_76DDC8[v17 -1] ); | |
0 | 1467 } |
1468 --v17; | |
1469 v59 = v125 + 1; | |
67 | 1470 ++v16; |
1471 } | |
1472 v16 = 0; | |
1473 v126 = 0; | |
0 | 1474 v62 = terrain_76E3C8[v18]; |
1475 if ( i < v62 ) | |
1476 { | |
67 | 1477 v114 = i; |
1478 memset32(terrain_76D5C8, v119 + 1, 4 * (v62 - i + 1)); | |
0 | 1479 do |
1480 { | |
1481 v63 = v126; | |
67 | 1482 v64 = v114; |
1483 ++v126; | |
1484 ++v114; | |
1485 terrain_76D7C8[v63] = v64; | |
1486 } | |
1487 while ( v114 <= terrain_76E3C8[v18] ); | |
1488 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) | |
0 | 1489 { |
1490 do | |
67 | 1491 v65 = terrain_76E1C8[v18-- -1]; |
1492 while ( v65 == terrain_76E1C8[v18 -1] ); | |
0 | 1493 } |
1494 v16 = v126; | |
1495 --v18; | |
1496 } | |
1497 if ( v18 < 0 ) | |
1498 v18 = 0; | |
1499 v66 = terrain_76E3C8[v18]; | |
67 | 1500 while ( v66 <= v124 ) |
0 | 1501 { |
1502 v67 = terrain_76E1C8[v18]; | |
67 | 1503 terrain_76D7C8[v16] = v66; |
1504 terrain_76D5C8[v16] = v67 + 1; | |
985 | 1505 if ( terrain_76E1C8[v18] == 65535 ) |
0 | 1506 { |
1507 v31 = v123 + 1; | |
67 | 1508 terrain_76D5C8[v16] = v31; |
1509 break; | |
0 | 1510 } |
1511 if ( !v18 ) | |
67 | 1512 break; |
1513 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) | |
0 | 1514 { |
1515 do | |
67 | 1516 v68 = terrain_76E1C8[v18-- -1]; |
1517 while ( v68 == terrain_76E1C8[v18 -1] ); | |
0 | 1518 } |
1519 --v18; | |
1520 ++v66; | |
67 | 1521 ++v16; |
0 | 1522 } |
1523 break; | |
67 | 1524 } |
0 | 1525 default: |
1526 break; | |
1527 } | |
990 | 1528 //v69 = v16 - 1; |
0 | 1529 ptr_801A08 = pVerticesSR_806210; |
1530 ptr_801A04 = pVerticesSR_801A10; | |
990 | 1531 //v126 = v69; |
1532 | |
106 | 1533 if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//áëîê |
0 | 1534 { |
990 | 1535 for ( i = v16 - 1; i >= 1; --i ) |
0 | 1536 { |
67 | 1537 //v70 = i; |
985 | 1538 //v71 = terrain_76D7C8[i];//88 |
1539 //v72 = terrain_76DBC8[i];//0 | |
1540 if ( terrain_76D7C8[i] < terrain_76DBC8[i] )//swap | |
1541 { | |
1542 terrain_76DBC8[i] = terrain_76D7C8[i]; | |
1543 terrain_76D7C8[i] = terrain_76DBC8[i]; | |
1544 } | |
1545 //x = terrain_76DBC8[i];//0 | |
0 | 1546 v111 = 0; |
985 | 1547 if ( terrain_76DBC8[i] <= 0 ) |
1548 terrain_76DBC8[i] = -terrain_76DBC8[i]; | |
1549 //v74 = terrain_76D7C8[i]; | |
1550 if ( terrain_76D7C8[i] <= 0 ) | |
1551 terrain_76D7C8[i] = -terrain_76D7C8[i]; | |
1552 v75 = terrain_76D7C8[i] + 2; | |
67 | 1553 //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; |
86 | 1554 uEndZ = v75; |
67 | 1555 //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; |
985 | 1556 uStartZ = terrain_76DBC8[i] - 2; |
1557 if ( terrain_76DBC8[i] - 2 < v75 ) | |
0 | 1558 { |
1559 v127 = 0; | |
67 | 1560 //v79 = (v73 - 66) << 9; |
1561 //v116 = v77; | |
1562 //pHeight = v79; | |
86 | 1563 v111 = v75 - uStartZ; |
1564 for (int z = uStartZ; z < uEndZ; ++z) | |
1565 { | |
985 | 1566 ptr_801A08[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; |
67 | 1567 ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; |
86 | 1568 ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); |
985 | 1569 ptr_801A04[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512; |
67 | 1570 ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; |
86 | 1571 ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); |
0 | 1572 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1573 { | |
67 | 1574 pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); |
1575 pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); | |
1576 pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); | |
1577 pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0); | |
0 | 1578 } |
67 | 1579 //v79 += 512; |
1580 v127 ++; | |
1581 //++v116; | |
1582 //pHeight = v79; | |
106 | 1583 } |
67 | 1584 //while ( v116 < v107 ); |
1585 } | |
985 | 1586 v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); |
1587 v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); | |
106 | 1588 if ( pRenderer->pRenderD3D )//Ritor1: do comment to test |
985 | 1589 Render::DrawTerrainD3D(v111, 0, v103, v104);//Render::RenderTerrainD3D(); |
67 | 1590 else |
985 | 1591 Render::DrawTerrainSW(v111, 0, v103, v104); |
1592 } | |
1593 } | |
1594 else | |
0 | 1595 { |
990 | 1596 for ( i = v16 - 1; i >= 1; --i ) |
0 | 1597 { |
985 | 1598 //v86 = i; |
1599 //v87 = terrain_76D5C8[i]; | |
1600 //v88 = terrain_76D9C8[i]; | |
1601 if ( terrain_76D5C8[i] < terrain_76D9C8[i] ) | |
1602 { | |
1603 terrain_76D9C8[i] = terrain_76D5C8[i]; | |
1604 terrain_76D5C8[i] = terrain_76D9C8[i]; | |
1605 } | |
1606 //v89 = terrain_76D9C8[i]; | |
0 | 1607 v111 = 0; |
985 | 1608 if ( terrain_76D9C8[i] <= 0 ) |
1609 terrain_76D9C8[i] = -terrain_76D9C8[i]; | |
1610 //v90 = terrain_76D5C8[i]; | |
1611 if ( terrain_76D5C8[i] <= 0 ) | |
1612 terrain_76D5C8[i] = -terrain_76D5C8[i]; | |
67 | 1613 pIndoorCameraD3D_4 = pGame->pIndoorCameraD3D; |
985 | 1614 v107 = terrain_76D5C8[i] + 2; |
1615 if ( terrain_76D9C8[i] - 2 < terrain_76D5C8[i] + 2 ) | |
0 | 1616 { |
1617 v86 = 0; | |
985 | 1618 //v116 = terrain_76D9C8[i] - 2; |
1619 v92 = (66 - terrain_76D9C8[i]) << 9; | |
1620 //pHeight = (66 - terrain_76D9C8[i]) << 9; | |
1621 v111 = terrain_76D5C8[i] + 2 - (terrain_76D9C8[i] - 2); | |
1622 //do | |
1623 for ( v116 = terrain_76D9C8[i] - 2; v116 < v107; ++v116 ) | |
1624 { | |
1625 //v93 = v116; | |
1626 //v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9; | |
1110 | 1627 ptr_801A08[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 64) << 9; |
985 | 1628 //*(float *)&pHeight = (double)pHeight; |
1629 ptr_801A08[v86].vWorldPosition.y = v92; | |
1630 //v106 = ; | |
1631 //v97 = v116; | |
1632 ptr_801A08[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v116); | |
1633 //v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9; | |
1110 | 1634 ptr_801A04[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 63) << 9; |
985 | 1635 ptr_801A04[v86].vWorldPosition.y = v92; |
1636 //pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97); | |
1637 ptr_801A04[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v116); | |
0 | 1638 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1639 { | |
67 | 1640 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1); |
1641 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1); | |
1642 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0); | |
1643 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0); | |
0 | 1644 } |
1645 v92 -= 512; | |
1646 v86 += 48; | |
985 | 1647 //++v116; |
1648 //pHeight = v92; | |
1649 } | |
1650 //while ( v116 < v107 ); | |
0 | 1651 } |
1652 v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]); | |
1653 v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]); | |
67 | 1654 if ( pRenderer->pRenderD3D ) |
985 | 1655 Render::DrawTerrainD3D(v111, 1, v103, v104); |
67 | 1656 else |
985 | 1657 Render::DrawTerrainSW(v111, 1, v103, v104); |
1658 } | |
1659 } | |
0 | 1660 result = v126; |
1661 pOutdoorCamera->field_40 = v126; | |
1662 return result; | |
1663 } | |
1664 // 47FFC4: inconsistent fpu stack | |
1665 // 4D864C: using guessed type char byte_4D864C; | |
1666 | |
988 | 1667 |
88 | 1668 void Render::RenderTerrainD3D() // New function. It's temporary |
86 | 1669 { |
1670 char result; // al@3 | |
1671 //int v1; // eax@3 | |
1672 //int v2; // ebx@4 | |
1673 //struct ODMFace *v4; // esi@6 | |
1674 int v6; // ecx@8 | |
1675 //int v7; // ecx@8 | |
1676 struct stru148 *v8; // ebx@8 | |
179 | 1677 // RenderVertexSoft *v8a; // edi@3 |
86 | 1678 //char v11; // zf@8 |
1679 struct stru148 *v16; | |
1680 unsigned int v18; // edi@22 | |
1681 //int v20; // edi@34 | |
1682 //int v28; // eax@50 | |
1683 //int v29; // ecx@55 | |
1684 //int v30; // eax@57 | |
1685 int v31; // eax@57 | |
1686 int v35; // edi@63 | |
1687 int v37; // eax@73 | |
1688 int v39; // eax@80 | |
1689 char v40; // [sp-18h] [bp-70h]@2 | |
1690 int v41; // [sp-14h] [bp-6Ch]@2 | |
1691 int v42; // [sp-10h] [bp-68h]@2 | |
1692 int v43; // [sp-Ch] [bp-64h]@2 | |
1693 const char *v44; // [sp-8h] [bp-60h]@2 | |
1694 int v45; // [sp-4h] [bp-5Ch]@2 | |
1695 //float v48; // [sp+14h] [bp-44h]@8 | |
1696 //void *v52; // [sp+24h] [bp-34h]@3 | |
1697 bool v54; // [sp+2Ch] [bp-2Ch]@10 | |
1698 int v55; // [sp+30h] [bp-28h]@34 | |
1699 int v56; | |
1700 int v57; // [sp+38h] [bp-20h]@36 | |
1701 int v58; // [sp+3Ch] [bp-1Ch]@8 | |
1702 int v63; // [sp+50h] [bp-8h]@3 | |
1703 int v64; // [sp+57h] [bp-1h]@2 | |
1704 int v62; | |
121 | 1705 //struct IndoorCameraD3D *pIndoorCameraD3D; |
179 | 1706 //RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 |
86 | 1707 |
186 | 1708 |
1709 //warning: the game uses CW culling by default, ccw is incosistent | |
1710 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
1711 | |
1712 | |
86 | 1713 v63 = 0; |
1714 // basic optimizations | |
577 | 1715 unsigned int uStartX, uEndX, uStartZ, uEndZ; |
106 | 1716 if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024) |
1717 { | |
1718 uStartX = 0, uEndX = 128; | |
1719 uStartZ = 0, uEndZ = 64 + 16; | |
1720 } | |
1721 else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536) | |
1722 { | |
1723 uStartX = 0, uEndX = 64 + 16; | |
1724 uStartZ = 0, uEndZ = 128; | |
1725 } | |
1726 else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512) | |
1727 { | |
1728 uStartX = 64 - 16, uEndX = 128; | |
1729 uStartZ = 0, uEndZ = 128; | |
1730 } | |
1731 else | |
1732 { | |
1733 uStartX = 0, uEndX = 128; | |
1734 uStartZ = 64 - 16, uEndZ = 128; | |
1735 } | |
147 | 1736 uStartX = 0, uEndX = 128; |
1737 uStartZ = 0, uEndZ = 128; | |
106 | 1738 static RenderVertexSoft pTerrainVertices[128 * 128]; |
1739 for (unsigned int z = uStartZ; z < uEndZ; ++z) | |
1740 { | |
1741 for (unsigned int x = uStartX; x < uEndX; ++x) | |
1742 { | |
1743 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; | |
1744 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512; | |
1745 pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 1746 //pIndoorCameraD3D = pGame->pIndoorCameraD3D; |
1747 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); | |
1748 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 1749 } |
1750 } | |
186 | 1751 |
106 | 1752 for (unsigned int z = uStartZ; z < uEndZ - 1; ++z) |
1753 { | |
1754 for (unsigned int x = uStartX; x < uEndX - 1; ++x) | |
1755 { | |
1756 v8 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
1757 v8->flags = 0; | |
1758 v8->field_32 = 0; | |
1759 //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x]; | |
179 | 1760 //struct TileDesc *pTile = pTileTable->GetTileById(uTileID); |
106 | 1761 v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); |
179 | 1762 //v6 = v8->uTileBitmapID; |
1763 v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v8->uTileBitmapID]; | |
106 | 1764 if (v8->uTileBitmapID == 0xFFFF) |
1765 continue; | |
186 | 1766 |
179 | 1767 v8->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
1768 v8->field_32 = 0; | |
1769 v8->field_59 = 1; | |
1770 //v8->field_5D = (char)WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8a->vWorldPosition.z) / 2 + 0.5f)); | |
1771 //v8->field_5C = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f));; | |
106 | 1772 v8->sTextureDeltaU = 0; |
1773 v8->sTextureDeltaV = 0; | |
1774 memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft)); | |
1775 array_73D150[0].u = 0; | |
1776 array_73D150[0].v = 0; | |
1777 memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1778 array_73D150[1].u = 1; | |
1779 array_73D150[1].v = 0; | |
1780 memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1781 array_73D150[2].u = 1; | |
1782 array_73D150[2].v = 1; | |
1783 memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft)); | |
1784 array_73D150[3].u = 0; | |
1785 array_73D150[3].v = 1; | |
86 | 1786 v55 = 0; |
1787 v54 = false; | |
1788 v58 = 0; | |
1789 if (v58 == 4) // if all y == first y; primitive in xz plane | |
1790 v8->field_32 |= 0x0001; | |
1791 v8->pODMFace = nullptr; | |
1792 v8->uNumVertices = 4; | |
1793 v8->field_59 = 5; | |
638 | 1794 |
1795 | |
1796 uint norm_idx = pTerrainNormalIndices[2 * (x + 128 * z) + 1]; | |
1797 assert(norm_idx < uNumTerrainNormals); | |
1798 | |
1799 auto norm = pTerrainNormals + norm_idx; | |
1800 float _f = (norm->x * (float)pOutdoor->vSunlight.x / 65536.0 - | |
1801 norm->y * (float)pOutdoor->vSunlight.y / 65536.0 - | |
1802 norm->z * (float)pOutdoor->vSunlight.z / 65536.0); | |
1803 v8->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); | |
1804 | |
86 | 1805 ++pOutdoorCamera->numStru148s; |
1806 ++pOutdoorCamera->field_44; | |
265 | 1807 assert(pOutdoorCamera->numStru148s < 20000); |
1808 | |
106 | 1809 v8->uBModelID = 0; |
1810 v8->uBModelFaceID = 0; | |
1811 v31 = (8 * (0 | (0 << 6))); | |
1812 v8->field_50 = v31 | 6; | |
265 | 1813 for (unsigned int k = 0; k < v8->uNumVertices; ++k) |
106 | 1814 { |
1815 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 1816 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 1817 } |
140 | 1818 |
186 | 1819 bool transparent = false; |
265 | 1820 if ( v8->flags & 2 && v8->uTileBitmapID == pRenderer->hd_water_tile_id) |
179 | 1821 { |
1822 //v80 = false; | |
265 | 1823 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
179 | 1824 } |
1825 else | |
1826 { | |
1827 v6 = v8->uTileBitmapID; | |
186 | 1828 transparent = true; |
179 | 1829 } |
1830 | |
140 | 1831 assert(v6 < 1000); // many random crashes here |
186 | 1832 |
1833 // for all shore tiles - draw a tile water under them since they're half-empty | |
1834 if (!strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX | |
1835 { | |
1836 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 | 1837 pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]], false, true); |
186 | 1838 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE); |
1839 | |
1840 } | |
1841 | |
1842 pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
1843 | |
1844 | |
86 | 1845 --pOutdoorCamera->numStru148s; |
1846 --pOutdoorCamera->field_44; | |
106 | 1847 } |
1848 } | |
1849 } | |
0 | 1850 |
1851 //----- (0048034E) -------------------------------------------------------- | |
985 | 1852 void Render::DrawTerrainD3D(int a1, int a2, int a3, int unk4) |
1853 { | |
1854 //int v3; // esi@1 | |
0 | 1855 int v4; // edi@1 |
1856 int v5; // ebx@2 | |
1857 int v6; // eax@2 | |
1858 int v7; // eax@3 | |
1859 RenderVertexSoft *v8; // edi@3 | |
1860 RenderVertexSoft *v9; // ebx@4 | |
1861 RenderVertexSoft *v10; // ecx@4 | |
1862 float v11; // eax@6 | |
1863 double v12; // ST5C_8@6 | |
1864 double v13; // ST2C_8@6 | |
1865 int v14; // eax@6 | |
1866 double v15; // st7@6 | |
1867 stru148 *v16; // ebx@12 | |
1868 unsigned __int16 v17; // ax@12 | |
1869 int v18; // eax@13 | |
67 | 1870 int v19; // ecx@13 |
1871 int v20; // eax@13 | |
0 | 1872 int v21; // eax@13 |
1873 signed int v22; // eax@13 | |
1874 Vec3_float_ *v23; // eax@15 | |
1875 double v24; // st6@17 | |
1876 double v25; // ST54_8@17 | |
1877 unsigned __int8 v26; // sf@17 | |
1878 unsigned __int8 v27; // of@17 | |
1879 double v28; // st5@19 | |
1880 double v29; // st5@19 | |
1881 double v30; // st5@19 | |
1882 double v31; // st5@19 | |
67 | 1883 struct struct8 *v32; // esi@21 |
1884 double v3a; // st7@32 | |
0 | 1885 int v33; // edi@38 |
1886 unsigned int v34; // ecx@47 | |
1887 char v35; // zf@47 | |
1888 unsigned int v36; // eax@50 | |
1889 int v37; // eax@54 | |
1890 stru148 *v38; // ecx@55 | |
1891 unsigned int v39; // eax@59 | |
1892 stru148 *v40; // ebx@62 | |
86 | 1893 unsigned __int16 pTileBitmapsID; // ax@62 |
0 | 1894 int v42; // eax@63 |
1895 LightmapBuilder *v43; // ecx@63 | |
67 | 1896 int v44; // eax@63 |
0 | 1897 int v45; // eax@63 |
1898 int v46; // eax@63 | |
1899 signed int v47; // eax@63 | |
1900 Vec3_float_ *v48; // eax@65 | |
1901 double v49; // st6@67 | |
1902 double v50; // ST4C_8@67 | |
1903 double v51; // st5@71 | |
1904 double v52; // st5@71 | |
1905 double v53; // st5@71 | |
1906 double v54; // st7@84 | |
1907 unsigned int v55; // ecx@98 | |
1908 unsigned int v56; // eax@101 | |
1909 int v57; // eax@105 | |
1910 unsigned int v58; // eax@109 | |
1911 stru148 *v59; // esi@112 | |
1912 unsigned __int16 v60; // ax@112 | |
67 | 1913 int v61; // eax@113 |
0 | 1914 signed int v62; // eax@113 |
1915 Vec3_float_ *v63; // eax@114 | |
1916 double v64; // st6@116 | |
1917 double v65; // ST3C_8@116 | |
1918 double v66; // st5@120 | |
1919 double v67; // st5@120 | |
1920 double v68; // st5@120 | |
1921 double v69; // st7@133 | |
1922 int v70; // edi@138 | |
86 | 1923 stru148 *v71; // esi@147 |
0 | 1924 unsigned int v72; // ecx@147 |
1925 unsigned int v73; // eax@150 | |
67 | 1926 int v74; // eax@154 |
0 | 1927 unsigned int v75; // eax@158 |
985 | 1928 //unsigned int v76; // [sp-10h] [bp-E0h]@61 |
67 | 1929 int v77; // [sp-Ch] [bp-DCh]@61 |
0 | 1930 IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 |
985 | 1931 //int v79; // [sp-4h] [bp-D4h]@61 |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
1932 bool v80; // [sp+0h] [bp-D0h]@59 |
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
1933 bool v81; // [sp+0h] [bp-D0h]@109 |
0 | 1934 int v82; // [sp+54h] [bp-7Ch]@1 |
1935 int v83; // [sp+60h] [bp-70h]@1 | |
1936 int v84; // [sp+6Ch] [bp-64h]@1 | |
1937 int v85; // [sp+70h] [bp-60h]@63 | |
1075 | 1938 float a4; // [sp+74h] [bp-5Ch]@73 |
0 | 1939 float v87; // [sp+78h] [bp-58h]@122 |
1940 int v88; // [sp+7Ch] [bp-54h]@1 | |
1941 int v89; // [sp+80h] [bp-50h]@6 | |
1942 float v90; // [sp+84h] [bp-4Ch]@1 | |
1943 float v91; // [sp+88h] [bp-48h]@1 | |
1944 float v92; // [sp+8Ch] [bp-44h]@1 | |
67 | 1945 int v93; // [sp+90h] [bp-40h]@2 |
0 | 1946 int X; // [sp+94h] [bp-3Ch]@1 |
1947 float v95; // [sp+98h] [bp-38h]@21 | |
1948 LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 | |
67 | 1949 int v97; // [sp+A0h] [bp-30h]@6 |
0 | 1950 int sX; // [sp+A4h] [bp-2Ch]@6 |
1951 unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 | |
1952 int v100; // [sp+ACh] [bp-24h]@122 | |
1953 int sY; // [sp+B0h] [bp-20h]@6 | |
67 | 1954 RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 |
0 | 1955 unsigned int a5; // [sp+B8h] [bp-18h]@21 |
1956 RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 | |
1957 Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 | |
1958 RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 | |
67 | 1959 RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 |
0 | 1960 char v108; // [sp+CFh] [bp-1h]@36 |
1961 float thisd; // [sp+D8h] [bp+8h]@6 | |
1962 float thise; // [sp+D8h] [bp+8h]@6 | |
1963 float thisf; // [sp+D8h] [bp+8h]@17 | |
1964 IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 | |
1965 float thisg; // [sp+D8h] [bp+8h]@67 | |
1966 IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 | |
1967 float thish; // [sp+D8h] [bp+8h]@116 | |
1968 IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 | |
1969 char this_3; // [sp+DBh] [bp+Bh]@30 | |
1970 char this_3a; // [sp+DBh] [bp+Bh]@82 | |
1971 char this_3b; // [sp+DBh] [bp+Bh]@131 | |
1972 | |
67 | 1973 static stru154 static_sub_0048034E_stru_154; |
1974 static stru154 stru_76D5A8; | |
985 | 1975 //v3 = a1; |
67 | 1976 v82 = a2; |
985 | 1977 v83 = a3; |
1978 X = abs(unk4); | |
0 | 1979 v4 = 0; |
1980 v88 = 0; | |
985 | 1981 v84 = a1 - 1; |
638 | 1982 v90 = (float)pOutdoor->vSunlight.x / 65536.0; |
67 | 1983 v91 = (float)pOutdoor->vSunlight.y / 65536.0; |
1984 v92 = (float)pOutdoor->vSunlight.z / 65536.0; | |
985 | 1985 if ( a1 - 1 > 0 ) |
0 | 1986 { |
1987 while ( 1 ) | |
1988 { | |
1989 v5 = abs(X);//v5 = 13108 | |
1990 v6 = abs(v83);//v6 = 13108 | |
1991 --X; | |
985 | 1992 //__debugbreak(); // uncoment & refactor following large if |
67 | 1993 v93 = (int)&stru_76E5C8[(v5 << 7) + v6]; |
1994 /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), | |
0 | 1995 v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), |
1996 ((a8 = v9, | |
1997 pVertices = &pVerticesSR_801A10[1] + v7, | |
1998 v11 = v8->vWorldPosition.x, | |
1999 v101 = v10, | |
2000 v12 = v11 + 6.755399441055744e15, | |
2001 sX = LODWORD(v12), | |
2002 v13 = v8->vWorldPosition.y + 6.755399441055744e15, | |
2003 sY = LODWORD(v13), | |
2004 thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, | |
62 | 2005 v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X |
0 | 2006 v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, |
2007 v89 = v14, | |
2008 thise = v15 * 0.5, | |
62 | 2009 _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z |
0 | 2010 WorldPosToGridCellX(sX), |
2011 WorldPosToGridCellZ(sY), | |
2012 !byte_4D864C) | |
2013 || !(pGame->uFlags & 0x80)) | |
67 | 2014 && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ |
2015 if ( !&stru_76E5C8[(v5 << 7) + v6] ) | |
0 | 2016 goto LABEL_162; |
67 | 2017 v8 = &pVerticesSR_806210[v4]; |
2018 pVertices2 = &pVerticesSR_801A10[v4 + 1]; | |
2019 v102 = v8; | |
2020 if (!v82) | |
2021 { | |
86 | 2022 pVertices = &pVerticesSR_801A10[v4]; |
2023 v101 = &pVerticesSR_806210[v4 + 1]; | |
67 | 2024 } |
2025 else | |
2026 { | |
86 | 2027 pVertices = &pVerticesSR_801A10[v4 + 1]; |
2028 v101 = &pVerticesSR_806210[v4]; | |
2029 } | |
67 | 2030 sX = floorf(v8->vWorldPosition.x + 0.5f); |
2031 sY = floorf(v8->vWorldPosition.z + 0.5f); | |
2032 v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); | |
2033 v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); | |
2034 WorldPosToGridCellX(sX); | |
2035 WorldPosToGridCellZ(sY); | |
2036 if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) | |
86 | 2037 if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y |
2038 || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) | |
67 | 2039 break; |
2040 v16 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2041 v16->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
86 | 2042 if ( v16->uTileBitmapID != -1 ) |
2043 { | |
2044 v19 = v97; | |
2045 v16->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2046 v16->field_32 = 0; | |
2047 v20 = v93; | |
2048 v16->field_59 = 1; | |
638 | 2049 v16->terrain_grid_x = (char)v19; |
86 | 2050 v16->field_34 = *(_WORD *)(v20 + 2); |
2051 v21 = v89; | |
638 | 2052 v16->terrain_grid_z = v89; |
86 | 2053 v22 = pTerrainNormalIndices[2 * (v19 + 128 * v21) + 1]; |
2054 if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) | |
2055 v23 = 0; | |
2056 else | |
2057 v23 = &pTerrainNormals[v22]; | |
638 | 2058 v24 = v92 * v23->z; |
86 | 2059 //v99 = v23; |
638 | 2060 thisf = 20.0 - (-v24 - v91 * v23->y - v90 * v23->x) * 20.0; |
86 | 2061 //v25 = thisf + 6.7553994e15; |
2062 //v27 = pOutdoorCamera->numStru148s > 1999; | |
2063 //v26 = pOutdoorCamera->numStru148s - 1999 < 0; | |
638 | 2064 v16->dimming_level = floorf(thisf + 0.5f); |
86 | 2065 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2066 return; | |
2067 ++pOutdoorCamera->numStru148s; | |
96 | 2068 //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary |
4 | 2069 //goto LABEL_126; |
96 | 2070 //{ |
2071 //--pOutdoorCamera->numStru148s; | |
2072 //goto LABEL_162; | |
2073 //} | |
86 | 2074 memcpy(&array_50AC10[0], v102, 0x30u); |
168 | 2075 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2076 array_50AC10[0].u = 0.0; |
2077 array_50AC10[0].v = 0.0; | |
2078 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
168 | 2079 array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2080 array_50AC10[1].u = 0.0; |
2081 array_50AC10[1].v = 1.0; | |
2082 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
168 | 2083 array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2084 array_50AC10[2].u = 1.0; |
2085 array_50AC10[2].v = 1.0; | |
2086 memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); | |
168 | 2087 array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2088 array_50AC10[3].u = 1.0; |
2089 array_50AC10[3].v = 0.0; | |
2090 /*if ( !(byte_76D5C0 & 1) ) | |
2091 { | |
2092 byte_76D5C0 |= 1u; | |
2093 stru154(stru_76D5A8); | |
2094 atexit(loc_481199); | |
2095 }*/ | |
2096 v32 = (struct8 *)array_50AC10; | |
2097 v97 = (int)pGame->pLightmapBuilder; | |
2098 pGame->pLightmapBuilder->StackLights_TerrainFace(v23, &v95, array_50AC10, 4, 1); | |
1075 | 2099 pDecalBuilder->_49BE8A(v16, v23, &v95, array_50AC10, 4, 1); |
86 | 2100 a5 = 4; |
2101 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2102 { | |
2103 thisa = pGame->pIndoorCameraD3D; | |
2104 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) | |
2105 goto LABEL_162; | |
2106 thisa->ViewTransform(array_50AC10, a5); | |
2107 thisa->Project(array_50AC10, a5, 0); | |
2108 } | |
2109 this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 | |
2110 || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
2111 v3a = (double)pOutdoorCamera->shading_dist_mist; | |
2112 v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x | |
2113 || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; | |
2114 v33 = 0; | |
2115 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
2116 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
0 | 2117 { |
86 | 2118 if ( this_3 ) |
2119 v33 = 3; | |
2120 else | |
2121 v33 = v108 != 0 ? 5 : 0; | |
734 | 2122 static_sub_0048034E_stru_154.ClassifyPolygon(v23, v95); |
86 | 2123 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2124 pDecalBuilder->ApplyDecals(31 - v16->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); |
0 | 2125 } |
86 | 2126 if ( stru_F8AD28.uNumLightsApplied > 0 ) |
2127 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); | |
2128 v34 = a5; | |
2129 //v35 = byte_4D864C == 0; | |
2130 v16->uNumVertices = a5; | |
2131 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) | |
0 | 2132 { |
86 | 2133 if ( this_3 ) |
2134 { | |
2135 v36 = sr_424CD7(v34); | |
2136 v16->uNumVertices = v36; | |
2137 OutdoorCamera::Project(v36); | |
2138 } | |
2139 if ( v108 ) | |
2140 { | |
2141 v36 = sr_424EE0_MakeFanFromTriangle(v34); | |
2142 v16->uNumVertices = v36; | |
2143 OutdoorCamera::Project(v36); | |
2144 } | |
0 | 2145 } |
86 | 2146 //v37 = *(int *)&v16->flags; |
2147 if ( ~v16->flags & 1 ) | |
2148 { | |
265 | 2149 if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2150 { |
2151 v80 = false; | |
265 | 2152 v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2153 } |
2154 else | |
2155 { | |
2156 v39 = v16->uTileBitmapID; | |
2157 v80 = true; | |
2158 } | |
2159 //v79 = 0; | |
2160 //v78 = pBitmaps_LOD->pHardwareTextures[v39]; | |
2161 v16->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary | |
2162 v77 = (int)v16; | |
2163 //v76 = v16->uNumVertices; | |
4 | 2164 //LABEL_161: |
186 | 2165 pRenderer->DrawTerrainPolygon(v16->uNumVertices, v16, pBitmaps_LOD->pHardwareTextures[v39], false, v80); |
86 | 2166 goto LABEL_162; |
2167 } | |
2168 v38 = v16; | |
0 | 2169 LABEL_56: |
86 | 2170 v38->_4811A3(); |
2171 } | |
0 | 2172 LABEL_162: |
86 | 2173 v4 = v88 + 1; |
2174 if ( ++v88 >= v84 ) | |
2175 return; | |
2176 } | |
2177 v40 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2178 v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
2179 if ( v40->uTileBitmapID == -1 ) | |
2180 goto LABEL_162; | |
2181 v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2182 BYTE1(v42) |= 0x80u; | |
2183 v43 = pGame->pLightmapBuilder; | |
2184 *(int *)&v40->flags = v42; | |
2185 v44 = v93; | |
2186 v40->field_59 = 1; | |
638 | 2187 v40->terrain_grid_x = (char)v43; |
86 | 2188 v40->field_34 = *(_WORD *)(v44 + 2); |
2189 v45 = v89; | |
638 | 2190 v40->terrain_grid_z = v89; |
86 | 2191 v46 = 4 * ((char)v43 + (v45 << 7)); |
2192 v85 = v46; | |
2193 v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; | |
2194 if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) | |
2195 v48 = 0; | |
2196 else | |
2197 v48 = &pTerrainNormals[v47]; | |
2198 v49 = v92 * v48->y; | |
2199 //v99 = v48; | |
2200 thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; | |
2201 v50 = thisg + 6.755399441055744e15; | |
638 | 2202 v40->dimming_level = LOBYTE(v50); |
86 | 2203 if ( LOBYTE(v50) < 0 ) |
638 | 2204 v40->dimming_level = 0; |
86 | 2205 if ( pOutdoorCamera->numStru148s >= 1999 ) |
0 | 2206 return; |
86 | 2207 ++pOutdoorCamera->numStru148s; |
2208 /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary | |
2209 //goto LABEL_77; | |
2210 { | |
2211 --pOutdoorCamera->numStru148s; | |
2212 goto LABEL_112; | |
2213 }*/ | |
2214 memcpy(&array_50AC10[0], v102, 0x30u); | |
168 | 2215 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2216 array_50AC10[0].u = 0.0; |
2217 array_50AC10[0].v = 0.0; | |
2218 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
168 | 2219 array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2220 array_50AC10[1].u = 0.0; |
2221 array_50AC10[1].v = 1.0; | |
2222 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
168 | 2223 array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2224 array_50AC10[2].u = 1.0; |
2225 array_50AC10[2].v = 1.0; | |
2226 static stru154 static_sub_0048034E_stru_76D590; | |
2227 /*static bool __init_flag2 = false; | |
2228 if (!__init_flag2) | |
2229 { | |
2230 __init_flag2 = true; | |
2231 stru154::stru154(&static_sub_0048034E_stru_76D590); | |
2232 }*/ | |
2233 /*if ( !(byte_76D5C0 & 2) ) | |
2234 { | |
2235 byte_76D5C0 |= 2; | |
2236 stru148(stru_76D590); | |
2237 atexit(loc_48118F); | |
2238 }*/ | |
2239 v96 = pGame->pLightmapBuilder; | |
2240 pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); | |
1075 | 2241 pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0); |
86 | 2242 uNumVertices = 3; |
2243 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2244 { | |
2245 thisb = pGame->pIndoorCameraD3D; | |
2246 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) | |
2247 { | |
2248 //LABEL_77: | |
2249 --pOutdoorCamera->numStru148s; | |
2250 goto LABEL_112; | |
2251 } | |
2252 thisb->ViewTransform(array_50AC10, uNumVertices); | |
2253 thisb->Project(array_50AC10, uNumVertices, 0); | |
2254 } | |
2255 this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
2256 v54 = (double)pOutdoorCamera->shading_dist_mist; | |
2257 v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; | |
2258 pVertices = 0; | |
2259 v96->std__vector_000004_size = 0; | |
2260 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
2261 { | |
2262 if ( this_3a ) | |
2263 pVertices = (RenderVertexSoft *)3; | |
2264 else | |
2265 pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); | |
2266 //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); | |
734 | 2267 static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); |
86 | 2268 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2269 pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); |
86 | 2270 } |
2271 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
2272 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); | |
2273 v55 = uNumVertices; | |
2274 //v35 = byte_4D864C == 0; | |
2275 v40->uNumVertices = uNumVertices; | |
2276 if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) | |
2277 { | |
2278 if ( this_3a ) | |
2279 { | |
2280 v56 = sr_424CD7(v55); | |
2281 } | |
2282 else | |
2283 { | |
2284 if ( !v108 ) | |
2285 goto LABEL_105; | |
2286 v56 = sr_424EE0_MakeFanFromTriangle(v55); | |
2287 } | |
2288 v40->uNumVertices = v56; | |
2289 OutdoorCamera::Project(v56); | |
2290 } | |
2291 LABEL_105: | |
2292 v57 = *(int *)&v40->flags; | |
2293 if ( BYTE1(v57) & 1 ) | |
2294 { | |
2295 v40->_4811A3(); | |
2296 } | |
2297 else | |
2298 { | |
265 | 2299 if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2300 { |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
2301 v81 = false; |
265 | 2302 v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2303 } |
2304 else | |
2305 { | |
2306 v58 = v40->uTileBitmapID; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
2307 v81 = true; |
86 | 2308 } |
186 | 2309 pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); |
86 | 2310 } |
2311 LABEL_112: | |
2312 v59 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2313 //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->numStru148s]; | |
2314 v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
2315 if ( v59->uTileBitmapID == -1 ) | |
2316 goto LABEL_162; | |
2317 *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2318 v61 = v93; | |
2319 v59->field_59 = 1; | |
2320 v59->field_34 = *(_WORD *)(v61 + 2); | |
638 | 2321 v59->terrain_grid_z = v89; |
2322 v59->terrain_grid_x = v97; | |
86 | 2323 v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); |
2324 if ( v62 > (signed int)(uNumTerrainNormals - 1) ) | |
2325 v63 = 0; | |
2326 else | |
2327 v63 = &pTerrainNormals[v62]; | |
2328 v64 = v92 * v63->y; | |
2329 //v99 = v63; | |
2330 thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; | |
638 | 2331 v59->dimming_level = floorf(thish + 0.5f); |
2332 if ( v59->dimming_level < 0 ) | |
2333 v59->dimming_level = 0; | |
86 | 2334 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2335 return; | |
2336 ++pOutdoorCamera->numStru148s; | |
2337 if ( !sub_481FC9(v101, v102, pVertices2, v59) ) | |
2338 { | |
2339 //LABEL_126: | |
4 | 2340 --pOutdoorCamera->numStru148s; |
86 | 2341 goto LABEL_162; |
2342 } | |
2343 memcpy(&array_50AC10[0], v102, 0x30u); | |
168 | 2344 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2345 array_50AC10[0].u = 0.0; |
2346 array_50AC10[0].v = 0.0; | |
2347 memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); | |
168 | 2348 array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2349 array_50AC10[1].u = 1.0; |
2350 array_50AC10[1].v = 1.0; | |
2351 memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); | |
168 | 2352 array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2353 array_50AC10[2].u = 1.0; |
2354 array_50AC10[2].v = 0.0; | |
2355 static stru154 static_sub_0048034E_stru_76D578; | |
2356 /*static bool __init_flag1 = false; | |
2357 if (!__init_flag1) | |
2358 { | |
2359 __init_flag1 = true; | |
2360 stru154::stru154(&static_sub_0048034E_stru_76D578); | |
2361 }*/ | |
2362 v96 = pGame->pLightmapBuilder; | |
2363 pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); | |
1075 | 2364 pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1); |
86 | 2365 v100 = 3; |
2366 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2367 { | |
2368 thisc = pGame->pIndoorCameraD3D; | |
2369 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) | |
2370 //goto LABEL_126; | |
2371 { | |
2372 --pOutdoorCamera->numStru148s; | |
2373 goto LABEL_162; | |
2374 } | |
2375 thisc->ViewTransform(array_50AC10, v100); | |
2376 thisc->Project(array_50AC10, v100, 0); | |
2377 } | |
2378 this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 | |
2379 || v101->vWorldViewPosition.x < 8.0; | |
2380 v69 = (double)pOutdoorCamera->shading_dist_mist; | |
2381 v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; | |
2382 v70 = 0; | |
2383 v96->std__vector_000004_size = 0; | |
2384 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
2385 { | |
2386 if ( this_3b ) | |
2387 v70 = 3; | |
2388 else | |
2389 v70 = v108 != 0 ? 5 : 0; | |
734 | 2390 static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); |
86 | 2391 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2392 pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); |
86 | 2393 } |
2394 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
2395 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); | |
2396 v71 = v59; | |
2397 v72 = v100; | |
2398 //v35 = byte_4D864C == 0; | |
2399 v59->uNumVertices = v100;//??? | |
2400 if ( !byte_4D864C && pGame->uFlags & 0x80 ) | |
2401 goto LABEL_154; | |
2402 if ( this_3b ) | |
2403 { | |
2404 v73 = sr_424CD7(v72); | |
0 | 2405 } |
2406 else | |
2407 { | |
2408 if ( !v108 ) | |
86 | 2409 { |
2410 LABEL_154: | |
2411 v74 = v71->flags; | |
2412 if ( !(BYTE1(v74) & 1) ) | |
2413 { | |
265 | 2414 if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2415 { |
2416 v80 = false; | |
265 | 2417 v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2418 } |
2419 else | |
2420 { | |
2421 v75 = v71->uTileBitmapID; | |
2422 v80 = true; | |
2423 } | |
2424 //v79 = 0; | |
985 | 2425 v78 = pBitmaps_LOD->pHardwareTextures[v75]; |
86 | 2426 v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary |
2427 //v77 = (int)v71; | |
2428 //v76 = v71->uNumVertices; | |
2429 //goto LABEL_161; | |
985 | 2430 pRenderer->DrawTerrainPolygon(v71->uNumVertices, (stru148 *)v71, v78, 0, v80); |
86 | 2431 goto LABEL_162; |
2432 } | |
2433 v38 = (stru148 *)v71; | |
2434 goto LABEL_56; | |
2435 } | |
2436 v73 = sr_424EE0_MakeFanFromTriangle(v72); | |
2437 } | |
2438 v71->uNumVertices = v73; | |
2439 OutdoorCamera::Project(v73); | |
0 | 2440 goto LABEL_154; |
86 | 2441 } |
2442 } | |
0 | 2443 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); |
2444 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); | |
2445 // 4D864C: using guessed type char byte_4D864C; | |
2446 // 76D5C0: using guessed type char static_sub_0048034E_byte_76D5C0__init_flag; | |
2447 | |
2448 //----- (00481212) -------------------------------------------------------- | |
985 | 2449 void Render::DrawTerrainSW(int a1, int a2, int a3, int a4) |
0 | 2450 { |
2451 int v3; // esi@1 | |
2452 int v4; // ecx@1 | |
2453 int v5; // ST10_4@1 | |
2454 int v6; // edi@1 | |
2455 int v7; // ebx@2 | |
2456 int v8; // eax@2 | |
2457 int v9; // eax@3 | |
2458 RenderVertexSoft *v10; // edi@3 | |
2459 RenderVertexSoft *v11; // ebx@4 | |
2460 RenderVertexSoft *v12; // ecx@4 | |
2461 float v13; // eax@6 | |
2462 int v14; // eax@6 | |
2463 double v15; // st7@6 | |
2464 double v16; // st7@6 | |
2465 stru148 *v17; // ebx@12 | |
2466 unsigned __int16 v18; // ax@12 | |
2467 int v19; // eax@13 | |
2468 float v20; // ecx@13 | |
2469 stru220 *v21; // eax@13 | |
2470 int v22; // eax@13 | |
2471 signed int v23; // eax@13 | |
2472 Vec3_float_ *v24; // eax@15 | |
2473 double v25; // st7@18 | |
2474 double v26; // st5@24 | |
2475 double v27; // st5@24 | |
2476 double v28; // st5@24 | |
2477 double v29; // st5@24 | |
2478 Game *v30; // eax@25 | |
2479 RenderVertexSoft *v31; // edi@29 | |
2480 double v32; // st7@31 | |
2481 int v33; // esi@35 | |
2482 RenderVertexSoft *v34; // edx@36 | |
2483 RenderVertexSoft *v35; // ecx@36 | |
2484 signed int v36; // eax@39 | |
2485 signed int v37; // esi@40 | |
2486 stru148 *v38; // ebx@43 | |
2487 unsigned __int16 v39; // ax@43 | |
2488 int v40; // eax@44 | |
2489 float v41; // ecx@44 | |
2490 stru220 *v42; // eax@44 | |
2491 int v43; // eax@44 | |
2492 int v44; // eax@44 | |
2493 signed int v45; // eax@44 | |
2494 Vec3_float_ *v46; // eax@46 | |
2495 double v47; // st7@49 | |
2496 double v48; // st5@57 | |
2497 double v49; // st5@57 | |
2498 double v50; // st5@57 | |
2499 Game *v51; // eax@58 | |
2500 RenderVertexSoft *v52; // edi@62 | |
2501 double v53; // st7@63 | |
2502 int v54; // esi@66 | |
2503 signed int v55; // eax@69 | |
2504 signed int v56; // esi@71 | |
2505 unsigned __int16 v57; // ax@75 | |
2506 stru220 *v58; // eax@76 | |
2507 signed int v59; // eax@76 | |
2508 Vec3_float_ *v60; // eax@77 | |
2509 double v61; // st7@80 | |
2510 double v62; // st5@88 | |
2511 double v63; // st5@88 | |
2512 double v64; // st5@88 | |
2513 Game *v65; // eax@89 | |
2514 double v66; // st7@94 | |
2515 RenderVertexSoft *v67; // [sp-Ch] [bp-C4h]@36 | |
2516 stru148 *v68; // [sp-8h] [bp-C0h]@36 | |
2517 int v69; // [sp-4h] [bp-BCh]@36 | |
2518 float v70; // [sp+Ch] [bp-ACh]@88 | |
2519 double v71; // [sp+10h] [bp-A8h]@6 | |
2520 double v72; // [sp+18h] [bp-A0h]@82 | |
2521 double v73; // [sp+20h] [bp-98h]@6 | |
2522 double v74; // [sp+28h] [bp-90h]@51 | |
2523 double v75; // [sp+30h] [bp-88h]@6 | |
2524 double v76; // [sp+38h] [bp-80h]@20 | |
2525 double v77; // [sp+40h] [bp-78h]@6 | |
2526 float v78; // [sp+48h] [bp-70h]@57 | |
2527 float v79; // [sp+4Ch] [bp-6Ch]@6 | |
2528 float v80; // [sp+50h] [bp-68h]@6 | |
2529 int v81; // [sp+54h] [bp-64h]@1 | |
2530 int v82; // [sp+58h] [bp-60h]@6 | |
2531 int v83; // [sp+5Ch] [bp-5Ch]@82 | |
2532 int v84; // [sp+60h] [bp-58h]@20 | |
2533 int v85; // [sp+64h] [bp-54h]@1 | |
2534 int v86; // [sp+68h] [bp-50h]@1 | |
2535 int v87; // [sp+6Ch] [bp-4Ch]@51 | |
2536 float v88; // [sp+70h] [bp-48h]@51 | |
2537 int v89; // [sp+74h] [bp-44h]@6 | |
2538 int v90; // [sp+78h] [bp-40h]@1 | |
2539 float a3a; // [sp+7Ch] [bp-3Ch]@24 | |
2540 stru220 *v92; // [sp+80h] [bp-38h]@2 | |
2541 float v93; // [sp+84h] [bp-34h]@44 | |
2542 int v94; // [sp+88h] [bp-30h]@6 | |
2543 float v95; // [sp+8Ch] [bp-2Ch]@1 | |
2544 float v96; // [sp+90h] [bp-28h]@1 | |
2545 float v97; // [sp+94h] [bp-24h]@1 | |
2546 int X; // [sp+98h] [bp-20h]@1 | |
2547 float v99; // [sp+9Ch] [bp-1Ch]@6 | |
2548 int v100; // [sp+A0h] [bp-18h]@6 | |
2549 unsigned __int64 v101; // [sp+A4h] [bp-14h]@6 | |
2550 RenderVertexSoft *v102; // [sp+ACh] [bp-Ch]@6 | |
2551 RenderVertexSoft *v103; // [sp+B0h] [bp-8h]@6 | |
2552 RenderVertexSoft *v104; // [sp+B4h] [bp-4h]@3 | |
2553 float pNormalc; // [sp+C0h] [bp+8h]@6 | |
2554 float pNormald; // [sp+C0h] [bp+8h]@6 | |
2555 Vec3_float_ *pNormal; // [sp+C0h] [bp+8h]@17 | |
2556 Vec3_float_ *pNormala; // [sp+C0h] [bp+8h]@48 | |
2557 Vec3_float_ *pNormalb; // [sp+C0h] [bp+8h]@77 | |
2558 | |
2559 v3 = a1; | |
2560 //v4 = *(short *)(a3 + 4); | |
2561 //v5 = *(short *)(a3 + 6); | |
2562 v85 = a2; | |
985 | 2563 v86 = a3; //v4; |
2564 X = abs(a4); //v5 | |
0 | 2565 v6 = 0; |
2566 v90 = 0; | |
2567 v81 = v3 - 1; | |
638 | 2568 v95 = (double)pOutdoor->vSunlight.x / 65536.0; |
2569 v96 = (double)pOutdoor->vSunlight.y / 65536.0; | |
2570 v97 = (double)pOutdoor->vSunlight.z / 65536.0; | |
0 | 2571 if ( v3 - 1 > 0 ) |
2572 { | |
2573 while ( 1 ) | |
2574 { | |
2575 v7 = abs(X); | |
2576 v8 = abs(v86); | |
2577 --X; | |
2578 v92 = &stru_76E5C8[(v7 << 7) + v8]; | |
2579 if ( !v92->field_0 | |
2580 || ((v9 = v6, v10 = &pVerticesSR_806210[v6], v104 = v10, !v85) ? (v11 = &pVerticesSR_801A10[v9], | |
2581 v12 = &pVerticesSR_806210[v9 + 1]) : (v11 = &pVerticesSR_806210[v9 + 1], v12 = &pVerticesSR_801A10[v9]), | |
2582 ((v103 = &pVerticesSR_801A10[v9 + 1], | |
2583 v13 = v10->vWorldPosition.x, | |
2584 v102 = v12, | |
2585 v80 = v13, | |
2586 v73 = v13 + 6.7553994e15, | |
2587 v101 = __PAIR__((unsigned int)v11, LODWORD(v73)), | |
2588 v79 = v10->vWorldPosition.y, | |
2589 v75 = v79 + 6.7553994e15, | |
2590 v100 = LODWORD(v75), | |
2591 pNormalc = (v12->vWorldPosition.x + v10->vWorldPosition.x) * 0.5, | |
2592 v71 = pNormalc + 6.7553994e15, | |
2593 v89 = LODWORD(v71), | |
2594 v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(pNormalc + 6.7553994e15)), | |
2595 v15 = v11->vWorldPosition.y + v10->vWorldPosition.y, | |
2596 v94 = v14, | |
2597 pNormald = v15 * 0.5, | |
2598 v16 = pNormald + 6.7553994e15, | |
2599 v77 = v16, | |
2600 v82 = LODWORD(v77), | |
2601 LODWORD(v99) = WorldPosToGridCellZ(LODWORD(v16)), | |
2602 WorldPosToGridCellX(v101), | |
2603 WorldPosToGridCellZ(v100), | |
2604 !byte_4D864C) | |
2605 || !(pGame->uFlags & 0x80)) | |
2606 && !sub_481EFA(v10, v11, v102, v103, 1)) ) | |
2607 goto LABEL_105; | |
2608 if ( v10->vWorldPosition.z != v11->vWorldPosition.z | |
2609 || v11->vWorldPosition.z != v103->vWorldPosition.z | |
2610 || v103->vWorldPosition.z != v102->vWorldPosition.z ) | |
2611 break; | |
2612 v17 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2613 v18 = pOutdoor->GetTileTexture(v101, v100); | |
2614 v17->uTileBitmapID = v18; | |
2615 if ( v18 != -1 ) | |
2616 { | |
2617 v19 = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2618 LOWORD(v19) = v19 | 0x8010; | |
2619 v20 = v99; | |
2620 *(int *)&v17->flags = v19; | |
2621 v21 = v92; | |
2622 v17->field_59 = 1; | |
638 | 2623 v17->terrain_grid_x = LOBYTE(v20); |
0 | 2624 v17->field_34 = v21->distance; |
2625 v22 = v94; | |
638 | 2626 v17->terrain_grid_z = v94; |
0 | 2627 v23 = pTerrainNormalIndices[2 * (LODWORD(v20) + (v22 << 7)) + 1]; |
2628 if ( v23 < 0 || v23 > (signed int)(uNumTerrainNormals - 1) ) | |
2629 v24 = 0; | |
2630 else | |
2631 v24 = &pTerrainNormals[v23]; | |
2632 pNormal = v24; | |
2633 if ( v24 ) | |
2634 { | |
2635 v25 = -(v97 * v24->z + v96 * v24->y + v95 * v24->x); | |
2636 if ( v25 < 0.0 ) | |
2637 v25 = 0.0; | |
2638 v99 = v25 * 31.0; | |
2639 v76 = v99 + 6.7553994e15; | |
2640 v84 = LODWORD(v76); | |
638 | 2641 v17->dimming_level = 31 - LOBYTE(v76); |
0 | 2642 } |
2643 else | |
2644 { | |
638 | 2645 v17->dimming_level = 0; |
0 | 2646 } |
2647 if ( pOutdoorCamera->numStru148s >= 1999 ) | |
2648 return; | |
2649 ++pOutdoorCamera->numStru148s; | |
2650 if ( !sub_481FC9(v10, (RenderVertexSoft *)HIDWORD(v101), v102, v17) ) | |
2651 goto LABEL_104; | |
2652 v26 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2653 memcpy(array_50AC10, v104, 0x30u); | |
168 | 2654 array_50AC10[0]._rhw = v26; |
0 | 2655 array_50AC10[0].u = 0.0; |
2656 array_50AC10[0].v = 0.0; | |
2657 v27 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; | |
2658 memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); | |
168 | 2659 array_50AC10[1]._rhw = 1.0 / v27; |
0 | 2660 array_50AC10[1].u = 0.0; |
2661 array_50AC10[1].v = 1.0; | |
2662 v28 = v103->vWorldViewPosition.x + 0.0000001; | |
2663 memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); | |
168 | 2664 array_50AC10[2]._rhw = 1.0 / v28; |
0 | 2665 array_50AC10[2].u = 1.0; |
2666 array_50AC10[2].v = 1.0; | |
2667 v29 = v102->vWorldViewPosition.x + 0.0000001; | |
2668 memcpy(&array_50AC10[3], v102, sizeof(array_50AC10[3])); | |
168 | 2669 array_50AC10[3]._rhw = 1.0 / v29; |
0 | 2670 array_50AC10[3].u = 1.0; |
2671 array_50AC10[3].v = 0.0; | |
2672 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormal, &a3a, array_50AC10, 4u, 1); | |
2673 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2674 { | |
2675 v17->field_108 = 0; | |
2676 } | |
2677 else | |
2678 { | |
2679 v30 = pGame; | |
2680 v17->field_108 = 1; | |
2681 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 4, pNormal); | |
2682 } | |
2683 if ( v104->vWorldViewPosition.x < 8.0 | |
2684 || *(float *)(HIDWORD(v101) + 12) < 8.0 | |
2685 || (v31 = v102, v102->vWorldViewPosition.x < 8.0) | |
2686 || v103->vWorldViewPosition.x < 8.0 ) | |
2687 { | |
2688 v36 = sr_4250FE(4u); | |
2689 } | |
2690 else | |
2691 { | |
2692 v32 = (double)pOutdoorCamera->shading_dist_mist; | |
2693 if ( v32 >= v104->vWorldViewPosition.x | |
2694 && v32 >= *(float *)(HIDWORD(v101) + 12) | |
2695 && v32 >= v102->vWorldViewPosition.x | |
2696 && v32 >= v103->vWorldViewPosition.x ) | |
2697 { | |
2698 v33 = sr_4254D2(4); | |
2699 v17->uNumVertices = v33; | |
2700 if ( !v33 ) | |
2701 goto LABEL_104; | |
2702 v34 = (RenderVertexSoft *)HIDWORD(v101); | |
2703 v35 = v104; | |
2704 v69 = 0; | |
2705 v68 = v17; | |
2706 v67 = v31; | |
2707 goto LABEL_37; | |
2708 } | |
2709 v36 = sr_4252E8(4u); | |
2710 } | |
2711 v37 = v36; | |
2712 if ( !v36 ) | |
2713 goto LABEL_104; | |
2714 LABEL_41: | |
2715 OutdoorCamera::Project(v37); | |
2716 LABEL_102: | |
2717 v33 = sr_4254D2(v37); | |
2718 v17->uNumVertices = v33; | |
2719 if ( !v33 ) | |
2720 goto LABEL_104; | |
2721 v17->_48276F_sr(); | |
2722 goto LABEL_38; | |
2723 } | |
2724 LABEL_105: | |
2725 v6 = v90++ + 1; | |
2726 if ( v90 >= v81 ) | |
2727 return; | |
2728 } | |
2729 v38 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2730 v39 = pOutdoor->GetTileTexture(v101, v100); | |
2731 v38->uTileBitmapID = v39; | |
2732 if ( v39 == -1 ) | |
2733 goto LABEL_105; | |
2734 v40 = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2735 BYTE1(v40) |= 0x80u; | |
2736 v41 = v99; | |
2737 *(int *)&v38->flags = v40; | |
2738 v42 = v92; | |
2739 v38->field_59 = 1; | |
638 | 2740 v38->terrain_grid_x = LOBYTE(v41); |
0 | 2741 v38->field_34 = v42->distance; |
2742 v43 = v94; | |
638 | 2743 v38->terrain_grid_z = v94; |
0 | 2744 v44 = 2 * (LODWORD(v41) + (v43 << 7)); |
2745 LODWORD(v93) = v44 * 2; | |
2746 v45 = pTerrainNormalIndices[v44 + 1]; | |
2747 if ( v45 < 0 || v45 > (signed int)(uNumTerrainNormals - 1) ) | |
2748 v46 = 0; | |
2749 else | |
2750 v46 = &pTerrainNormals[v45]; | |
2751 pNormala = v46; | |
2752 if ( v46 ) | |
2753 { | |
2754 v47 = -(v97 * v46->z + v96 * v46->y + v95 * v46->x); | |
2755 if ( v47 < 0.0 ) | |
2756 v47 = 0.0; | |
2757 v88 = v47 * 31.0; | |
2758 v74 = v88 + 6.7553994e15; | |
2759 v87 = LODWORD(v74); | |
638 | 2760 v38->dimming_level = 31 - LOBYTE(v74); |
0 | 2761 } |
2762 else | |
2763 { | |
638 | 2764 v38->dimming_level = 0; |
2765 } | |
2766 if ( v38->dimming_level < 0 ) | |
2767 v38->dimming_level = 0; | |
0 | 2768 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2769 return; | |
2770 ++pOutdoorCamera->numStru148s; | |
2771 if ( !sub_481FC9((RenderVertexSoft *)HIDWORD(v101), v103, v104, v38) ) | |
2772 goto LABEL_74; | |
2773 v48 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2774 memcpy(array_50AC10, v104, 0x30u); | |
168 | 2775 array_50AC10[0]._rhw = v48; |
0 | 2776 array_50AC10[0].u = 0.0; |
2777 array_50AC10[0].v = 0.0; | |
2778 v49 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; | |
2779 memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); | |
168 | 2780 array_50AC10[1]._rhw = 1.0 / v49; |
0 | 2781 array_50AC10[1].u = 0.0; |
2782 array_50AC10[1].v = 1.0; | |
2783 v50 = v103->vWorldViewPosition.x + 0.0000001; | |
2784 memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); | |
168 | 2785 array_50AC10[2]._rhw = 1.0 / v50; |
0 | 2786 array_50AC10[2].u = 1.0; |
2787 array_50AC10[2].v = 1.0; | |
2788 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormala, &v78, array_50AC10, 3u, 0); | |
2789 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2790 { | |
2791 v38->field_108 = 0; | |
2792 } | |
2793 else | |
2794 { | |
2795 v51 = pGame; | |
2796 v38->field_108 = 1; | |
2797 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormala); | |
2798 } | |
2799 if ( v104->vWorldViewPosition.x < 8.0 | |
2800 || *(float *)(HIDWORD(v101) + 12) < 8.0 | |
2801 || (v52 = v103, v103->vWorldViewPosition.x < 8.0) ) | |
2802 { | |
2803 v55 = sr_4250FE(3u); | |
2804 } | |
2805 else | |
2806 { | |
2807 v53 = (double)pOutdoorCamera->shading_dist_mist; | |
2808 if ( v53 >= v104->vWorldViewPosition.x | |
2809 && v53 >= *(float *)(HIDWORD(v101) + 12) | |
2810 && v53 >= v103->vWorldViewPosition.x ) | |
2811 { | |
2812 v54 = sr_4254D2(3); | |
2813 v38->uNumVertices = v54; | |
2814 if ( v54 ) | |
2815 { | |
2816 sr_sub_4829B9((RenderVertexSoft *)HIDWORD(v101), v52, v104, v38, 0); | |
2817 LABEL_68: | |
2818 sr_sub_481DB2(array_508690, v54, v38); | |
2819 LABEL_75: | |
2820 v17 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2821 v57 = pOutdoor->GetTileTexture(v101, v100); | |
2822 v17->uTileBitmapID = v57; | |
2823 if ( v57 == -1 ) | |
2824 goto LABEL_105; | |
2825 *(int *)&v17->flags = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2826 v58 = v92; | |
2827 v17->field_59 = 1; | |
2828 v17->field_34 = v58->distance; | |
638 | 2829 v17->terrain_grid_z = v94; |
2830 v17->terrain_grid_x = LOBYTE(v99); | |
0 | 2831 v59 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + LODWORD(v93)); |
2832 if ( v59 > (signed int)(uNumTerrainNormals - 1) ) | |
2833 { | |
2834 pNormalb = 0; | |
2835 v60 = 0; | |
2836 } | |
2837 else | |
2838 { | |
2839 v60 = &pTerrainNormals[v59]; | |
2840 pNormalb = v60; | |
2841 } | |
2842 if ( v60 ) | |
2843 { | |
2844 v61 = -(v97 * v60->z + v96 * v60->y + v95 * v60->x); | |
2845 if ( v61 < 0.0 ) | |
2846 v61 = 0.0; | |
2847 v93 = v61 * 31.0; | |
2848 v72 = v93 + 6.7553994e15; | |
2849 v83 = LODWORD(v72); | |
638 | 2850 v17->dimming_level = 31 - LOBYTE(v72); |
0 | 2851 } |
2852 else | |
2853 { | |
638 | 2854 v17->dimming_level = 0; |
0 | 2855 } |
638 | 2856 if ( v17->dimming_level < 0 ) |
2857 v17->dimming_level = 0; | |
0 | 2858 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2859 return; | |
2860 ++pOutdoorCamera->numStru148s; | |
2861 if ( !sub_481FC9(v102, v104, v103, v17) ) | |
2862 { | |
2863 LABEL_104: | |
2864 --pOutdoorCamera->numStru148s; | |
2865 goto LABEL_105; | |
2866 } | |
2867 v62 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2868 memcpy(array_50AC10, v104, 0x30u); | |
168 | 2869 array_50AC10[0]._rhw = v62; |
0 | 2870 array_50AC10[0].u = 0.0; |
2871 array_50AC10[0].v = 0.0; | |
2872 v63 = v103->vWorldViewPosition.x + 0.0000001; | |
2873 memcpy(&array_50AC10[1], v103, sizeof(array_50AC10[1])); | |
168 | 2874 array_50AC10[1]._rhw = 1.0 / v63; |
0 | 2875 array_50AC10[1].u = 1.0; |
2876 array_50AC10[1].v = 1.0; | |
2877 v64 = v102->vWorldViewPosition.x + 0.0000001; | |
2878 memcpy(&array_50AC10[2], v102, sizeof(array_50AC10[2])); | |
168 | 2879 array_50AC10[2]._rhw = 1.0 / v64; |
0 | 2880 array_50AC10[2].u = 1.0; |
2881 array_50AC10[2].v = 0.0; | |
2882 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormalb, &v70, array_50AC10, 3u, 1); | |
2883 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2884 { | |
2885 v17->field_108 = 0; | |
2886 } | |
2887 else | |
2888 { | |
2889 v65 = pGame; | |
2890 v17->field_108 = 1; | |
2891 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormalb); | |
2892 } | |
2893 if ( v104->vWorldViewPosition.x < 8.0 || v103->vWorldViewPosition.x < 8.0 || v102->vWorldViewPosition.x < 8.0 ) | |
2894 { | |
2895 v37 = sr_4250FE(3u); | |
2896 OutdoorCamera::Project(v37); | |
2897 if ( !v37 ) | |
2898 goto LABEL_104; | |
2899 goto LABEL_102; | |
2900 } | |
2901 v66 = (double)pOutdoorCamera->shading_dist_mist; | |
2902 if ( v66 < v104->vWorldViewPosition.x || v66 < v103->vWorldViewPosition.x || v66 < v102->vWorldViewPosition.x ) | |
2903 { | |
2904 v37 = sr_4252E8(3u); | |
2905 if ( !v37 ) | |
2906 goto LABEL_105; | |
2907 goto LABEL_41; | |
2908 } | |
2909 v33 = sr_4254D2(3); | |
2910 v17->uNumVertices = v33; | |
2911 if ( !v33 ) | |
2912 goto LABEL_104; | |
2913 v34 = v104; | |
2914 v35 = v102; | |
2915 v69 = 0; | |
2916 v68 = v17; | |
2917 v67 = v103; | |
2918 LABEL_37: | |
2919 sr_sub_4829B9(v35, v34, v67, v68, v69); | |
2920 LABEL_38: | |
2921 sr_sub_481DB2(array_508690, v33, v17); | |
2922 goto LABEL_105; | |
2923 } | |
2924 goto LABEL_74; | |
2925 } | |
2926 v55 = sr_4252E8(3u); | |
2927 } | |
2928 v56 = v55; | |
2929 if ( v55 ) | |
2930 { | |
2931 OutdoorCamera::Project(v55); | |
2932 v54 = sr_4254D2(v56); | |
2933 v38->uNumVertices = v54; | |
2934 if ( v54 ) | |
2935 { | |
2936 v38->_48276F_sr(); | |
2937 goto LABEL_68; | |
2938 } | |
2939 } | |
2940 LABEL_74: | |
2941 --pOutdoorCamera->numStru148s; | |
2942 goto LABEL_75; | |
2943 } | |
2944 } | |
2945 | |
2946 //----- (0047BACF) -------------------------------------------------------- | |
2947 void Render::TransformBillboardsAndSetPalettesODM() | |
2948 { | |
142 | 2949 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2950 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2951 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2952 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2953 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2954 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2955 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2956 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2957 //int v8; // ebx@4 |
0 | 2958 unsigned __int16 *v9; // eax@7 |
2959 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2960 //DWORD v11; // eax@13 |
0 | 2961 int v12; // eax@13 |
2962 int v13; // eax@14 | |
2963 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
2964 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 2965 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2966 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 2967 int v18; // [sp+60h] [bp-4h]@13 |
2968 | |
2969 billboard.uParentBillboardID = -1; | |
2970 billboard.pTarget = pRenderer->pTargetSurface; | |
2971 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
2972 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 2973 billboard.uViewportX = pViewport->uViewportTL_X; |
2974 billboard.uViewportY = pViewport->uViewportTL_Y; | |
2975 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
2976 billboard.uViewportW = pViewport->uViewportBR_Y; | |
0 | 2977 pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw; |
142 | 2978 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2979 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 2980 { |
143 | 2981 auto pBillboard = pBillboardRenderList + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2982 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2983 billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2984 billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2985 billboard.uParentBillboardID = i; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2986 billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2987 billboard.uTintColor = pBillboard->uTintColor; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2988 billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2989 billboard.sZValue = pBillboard->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2990 billboard.uFlags = pBillboard->field_1E; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2991 if (pBillboard->uHwSpriteID != -1) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2992 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2993 if (pRenderer->pRenderD3D) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2994 pRenderer->TransformBillboard(&billboard, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2995 &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], |
657 | 2996 pBillboard->dimming_level, pBillboard); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2997 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2998 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2999 assert(false); |
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 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 3002 if ( *(v1 - 10) & 2 ) |
3003 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
3004 else | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3005 v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 3006 v10 = (*(v1 - 9) & 1) == 0; |
3007 billboard.pPalette = v9; | |
3008 if ( !v10 ) | |
3009 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
3010 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
3011 { | |
323 | 3012 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 3013 v15 = abs(v12); |
3014 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
3015 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
3016 } | |
3017 v13 = *((short *)v1 - 8); | |
3018 if ( v13 >= 0 ) | |
733 | 3019 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3020 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3021 } |
0 | 3022 } |
3023 } | |
3024 | |
3025 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3026 void Render::DrawSpriteObjects_ODM() |
0 | 3027 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3028 //char *v0; // edi@2 |
430 | 3029 //ObjectDesc *v1; // ebx@4 |
0 | 3030 __int16 v2; // cx@5 |
3031 RenderBillboard *v3; // esi@10 | |
3032 SpriteFrame *v4; // eax@10 | |
430 | 3033 //SpriteFrame *v5; // ebx@10 |
0 | 3034 unsigned int v6; // eax@10 |
430 | 3035 //int v7; // ecx@10 |
3036 //int v8; // edx@10 | |
0 | 3037 int v9; // ecx@10 |
3038 unsigned __int16 v10; // ax@10 | |
430 | 3039 //int *v11; // eax@14 |
0 | 3040 int v12; // eax@22 |
3041 int v13; // ST3C_4@23 | |
3042 int v14; // eax@23 | |
3043 int v15; // ecx@23 | |
3044 int v16; // ebx@23 | |
3045 int v17; // ecx@25 | |
3046 int v18; // eax@25 | |
3047 int v19; // ST40_4@26 | |
3048 int v20; // ecx@26 | |
3049 int v21; // ST44_4@28 | |
3050 int v22; // ST3C_4@29 | |
3051 signed __int64 v23; // qtt@30 | |
3052 int v24; // ebx@30 | |
3053 int v25; // ST3C_4@30 | |
3054 int v26; // eax@31 | |
3055 char v27; // zf@31 | |
430 | 3056 //SpriteFrame *v28; // [sp+Ch] [bp-34h]@10 |
3057 //__int16 a5; // [sp+10h] [bp-30h]@10 | |
0 | 3058 int v30; // [sp+14h] [bp-2Ch]@23 |
3059 int v31; // [sp+14h] [bp-2Ch]@29 | |
3060 __int16 v32; // [sp+14h] [bp-2Ch]@30 | |
3061 int v33; // [sp+18h] [bp-28h]@23 | |
3062 int v34; // [sp+18h] [bp-28h]@26 | |
3063 int v35; // [sp+18h] [bp-28h]@30 | |
3064 int v36; // [sp+1Ch] [bp-24h]@10 | |
3065 int v37; // [sp+1Ch] [bp-24h]@23 | |
3066 int a6; // [sp+20h] [bp-20h]@10 | |
3067 int a6a; // [sp+20h] [bp-20h]@23 | |
3068 int v40; // [sp+24h] [bp-1Ch]@25 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3069 //signed int v41; // [sp+28h] [bp-18h]@1 |
0 | 3070 int v42; // [sp+2Ch] [bp-14h]@23 |
3071 int y; // [sp+30h] [bp-10h]@10 | |
3072 int x; // [sp+34h] [bp-Ch]@10 | |
3073 int z; // [sp+38h] [bp-8h]@10 | |
3074 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
3075 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3076 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3077 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
|
3078 { |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3079 auto object = pSpriteObjects + i; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3080 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3081 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3082 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3083 //{ |
430 | 3084 if (!object->uObjectDescID) // item probably pciked up |
3085 continue; | |
3086 | |
3087 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
3088 auto object_desc = pObjectList->pObjects + object->uObjectDescID; | |
3089 if (object_desc->NoSprite()) | |
3090 continue; | |
3091 | |
3092 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
3093 //if ( !(v1->uFlags & 1) ) | |
3094 //{ | |
3095 //v2 = *((short *)v0 - 14) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3096 v2 = object->uType; |
430 | 3097 if ( (v2 < 1000 || v2 >= 10000) && (v2 < 500 || v2 >= 600) || pGame->pStru6Instance->_4A81CA(object) ) |
3098 { | |
3099 //a5 = *(short *)v0; | |
3100 x = object->vPosition.x; | |
3101 y = object->vPosition.y; | |
3102 z = object->vPosition.z; | |
3103 v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; | |
3104 v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); | |
3105 //v5 = v4; | |
3106 //v28 = v4; | |
3107 v36 = v4->uFlags; | |
3108 a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier; | |
3109 v6 = stru_5C6E00->Atan2(object->vPosition.x - pIndoorCamera->pos.x, object->vPosition.y - pIndoorCamera->pos.y); | |
3110 //LOWORD(v7) = object->uFacing; | |
3111 //v8 = v36; | |
3112 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; | |
3113 v10 = v4->pHwSpriteIDs[v9]; | |
0 | 3114 v3->uHwSpriteID = v10; |
3115 if ( v36 & 0x20 ) | |
3116 { | |
430 | 3117 //v8 = v36; |
3118 z -= (signed int)((unsigned __int64)(v4->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
0 | 3119 } |
3120 v46 = 0; | |
430 | 3121 if ( v36 & 2 ) |
0 | 3122 v46 = 2; |
430 | 3123 //v11 = (int *)(256 << v9); |
3124 if ( (256 << v9) & v36 ) | |
0 | 3125 v46 |= 4u; |
430 | 3126 if ( v36 & 0x40000 ) |
0 | 3127 v46 |= 0x40u; |
430 | 3128 if ( v36 & 0x20000 ) |
0 | 3129 LOBYTE(v46) = v46 | 0x80; |
3130 if ( a6 ) | |
3131 { | |
430 | 3132 //LOBYTE(v11) = byte_4E94D3; |
3133 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); | |
0 | 3134 } |
3135 v12 = (x - pIndoorCamera->pos.x) << 16; | |
3136 if ( pIndoorCamera->sRotationX ) | |
3137 { | |
3138 v13 = (y - pIndoorCamera->pos.y) << 16; | |
3139 v30 = ((unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | |
3140 + ((unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3141 v37 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3142 a6a = (unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3143 v33 = (z - pIndoorCamera->pos.z) << 16; | |
3144 v14 = (unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3145 v15 = (unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3146 v16 = v15 + v14; | |
3147 v42 = v15 + v14; | |
3148 if ( v15 + v14 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3149 { | |
3150 v17 = a6a - v37; | |
3151 v40 = a6a - v37; | |
3152 v18 = ((unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) | |
3153 - ((unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3154 goto LABEL_29; | |
3155 } | |
3156 } | |
3157 else | |
3158 { | |
3159 v34 = (y - pIndoorCamera->pos.y) << 16; | |
3160 v19 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3161 v20 = (unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3162 v16 = v20 + v19; | |
3163 v42 = v20 + v19; | |
3164 if ( v20 + v19 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3165 { | |
430 | 3166 v21 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; |
3167 v17 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
3168 v40 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
0 | 3169 v18 = (z - pIndoorCamera->pos.z) << 16; |
3170 LABEL_29: | |
3171 v31 = v18; | |
3172 v22 = abs(v17); | |
3173 if ( abs(v16) >= v22 ) | |
3174 { | |
3175 LODWORD(v23) = 0; | |
3176 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3177 v24 = v23 / v42; | |
3178 v25 = v23 / v42; | |
3179 LODWORD(v23) = 0; | |
3180 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
430 | 3181 v35 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); |
3182 v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); | |
3183 | |
3184 //if (::uNumBillboardsToDraw >= 500) | |
3185 // return; | |
3186 assert(::uNumBillboardsToDraw < 500); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3187 ++::uNumBillboardsToDraw; |
0 | 3188 ++uNumSpritesDrawnThisFrame; |
430 | 3189 |
3190 object->uAttributes |= 1; | |
3191 v3->uPalette = v4->uPaletteIndex; | |
3192 v3->uIndoorSectorID = object->uSectorID; | |
3193 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
3194 v26 = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
3195 v3->pSpriteFrame = v4; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3196 v3->_screenspace_y_scaler_packedfloat = v26; |
0 | 3197 v3->field_1E = v46; |
430 | 3198 v3->world_x = x; |
3199 v3->world_y = y; | |
3200 v3->world_z = z; | |
0 | 3201 v3->uScreenSpaceX = v35; |
3202 v3->uScreenSpaceY = v32; | |
3203 HIWORD(v26) = HIWORD(v42); | |
3204 LOWORD(v26) = 0; | |
430 | 3205 v27 = (object->uAttributes & 0x20) == 0; |
862 | 3206 v3->sZValue = v26 + (PID(OBJECT_Item,i)); |
657 | 3207 v3->dimming_level = 0; |
0 | 3208 v3->uTintColor = 0; |
3209 if ( !v27 ) | |
3210 { | |
3211 if ( !pRenderer->pRenderD3D ) | |
3212 v3->sZValue = 0; | |
3213 } | |
3214 } | |
3215 goto LABEL_34; | |
3216 } | |
3217 } | |
3218 } | |
430 | 3219 //} |
0 | 3220 LABEL_34: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3221 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3222 //++v41; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3223 //v0 += 112; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3224 //} |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3225 //while ( v41 < (signed int)uNumSpriteObjects ); |
0 | 3226 } |
3227 } | |
3228 // 4E94D3: using guessed type char byte_4E94D3; | |
3229 // 5187E4: using guessed type int uNumSpritesDrawnThisFrame; | |
3230 | |
3231 //----- (0049D9BC) -------------------------------------------------------- | |
3232 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
3233 { | |
3234 size_t v4; // eax@1 | |
3235 size_t v5; // eax@1 | |
3236 IUnknown *v6; // eax@10 | |
3237 size_t v7; // eax@13 | |
3238 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
3239 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
3240 int v11; // [sp+430h] [bp-CCh]@16 | |
3241 int v12; // [sp+434h] [bp-C8h]@16 | |
3242 int v13; // [sp+438h] [bp-C4h]@16 | |
3243 int v14; // [sp+474h] [bp-88h]@16*/ | |
3244 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
3245 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
3246 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
3247 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
3248 int v19; // [sp+4C8h] [bp-34h]@16 | |
3249 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
3250 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
3251 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
3252 | |
3253 v4 = strlen(lpDriverName); | |
3254 v20.pDriverName = new char[v4 + 1]; | |
3255 v5 = strlen(lpDevDesc); | |
3256 v20.pDeviceDesc = new char[v5 + 1]; | |
3257 strcpy(v20.pDriverName, lpDriverName); | |
3258 strcpy(v20.pDeviceDesc, lpDevDesc); | |
3259 if ( lpGUID ) | |
3260 { | |
3261 v20.pGUID = new GUID; | |
3262 memcpy(v20.pGUID, lpGUID, 0x10u); | |
3263 } | |
3264 else | |
3265 { | |
3266 v20.pGUID = 0; | |
3267 } | |
3268 | |
3269 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
3270 { | |
3271 delete [] v20.pDriverName; | |
3272 delete [] v20.pDeviceDesc; | |
3273 if ( v20.pGUID ) | |
3274 delete v20.pGUID; | |
3275 } | |
3276 else | |
3277 { | |
3278 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
3279 { | |
3280 delete [] v20.pDriverName; | |
3281 delete [] v20.pDeviceDesc; | |
3282 if ( v20.pGUID ) | |
3283 delete v20.pGUID; | |
3284 v6 = (IUnknown *)pDirectDraw; | |
3285 } | |
3286 else | |
3287 { | |
3288 pDirectDraw->Release(); | |
3289 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1u))) | |
3290 { | |
3291 v20.pDDraw4DevDesc = 0; | |
3292 } | |
3293 else | |
3294 { | |
3295 v7 = strlen(ddDevId.szDescription); | |
3296 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
3297 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
3298 } | |
3299 memset(&ddsCaps, 0, 0x10u); | |
3300 if (FAILED(pDirectDraw4->GetAvailableVidMem( | |
3301 &ddsCaps, | |
3302 (LPDWORD)&v20.uVideoMem, | |
3303 (LPDWORD)&uFreeVideoMem))) | |
3304 v20.uVideoMem = 0; | |
3305 memset(&v10, 0, 0x7Cu); | |
3306 v10.dwSize = 124; | |
3307 v10.dwFlags = 6; | |
3308 v10.dwHeight = 640; | |
3309 v10.dwWidth = 480; | |
3310 v10.ddpfPixelFormat.dwSize = 32; | |
3311 | |
3312 v19 = 0; | |
3313 if ( FAILED(pDirectDraw4->EnumDisplayModes( | |
3314 0, | |
3315 0, | |
3316 &v19, | |
3317 (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) | |
3318 || !v19 | |
3319 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
3320 { | |
3321 delete [] v20.pDriverName; | |
3322 delete [] v20.pDeviceDesc; | |
3323 if ( v20.pDDraw4DevDesc ) | |
3324 free(v20.pDDraw4DevDesc); | |
3325 if ( v20.pGUID ) | |
3326 delete v20.pGUID; | |
3327 v6 = (IUnknown *)pDirectDraw4; | |
3328 } | |
3329 else | |
3330 { | |
3331 aux.pInfo = pOut; | |
3332 aux.ptr_4 = &v20; | |
3333 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
3334 delete [] v20.pDriverName; | |
3335 delete [] v20.pDeviceDesc; | |
3336 if ( v20.pDDraw4DevDesc ) | |
3337 free(v20.pDDraw4DevDesc); | |
3338 if ( v20.pGUID ) | |
3339 delete v20.pGUID; | |
3340 pDirectDraw4->Release(); | |
3341 v6 = (IUnknown *)pDirect3D3; | |
3342 pDirectDraw4 = 0; | |
3343 } | |
3344 } | |
3345 v6->Release(); | |
3346 } | |
3347 return 1; | |
3348 } | |
3349 | |
3350 //----- (0049D784) -------------------------------------------------------- | |
3351 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
3352 { | |
3353 int v6; // eax@1 | |
3354 signed int v7; // edi@1 | |
3355 signed int v8; // edi@14 | |
3356 size_t v9; // eax@30 | |
3357 size_t v10; // eax@30 | |
3358 size_t v11; // eax@30 | |
3359 size_t v12; // eax@30 | |
3360 size_t v13; // eax@30 | |
3361 | |
3362 v6 = pHWDesc->dwFlags; | |
3363 v7 = -1; | |
3364 if ( v6 ) | |
3365 { | |
3366 if ( !a6->ptr_4->pGUID ) | |
3367 v7 = 0; | |
3368 if ( v6 && a6->ptr_4->pGUID ) | |
3369 v7 = 1; | |
3370 } | |
3371 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
3372 v7 = 2; | |
3373 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
3374 v7 = 3; | |
3375 if ( v7 != -1 ) | |
3376 { | |
3377 v8 = v7; | |
3378 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
3379 a6->pInfo[v8].uCaps = 0; | |
3380 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
3381 a6->pInfo[v8].uCaps |= 2u; | |
3382 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
3383 a6->pInfo[v8].uCaps |= 4u; | |
3384 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
3385 a6->pInfo[v8].uCaps |= 8u; | |
3386 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
3387 a6->pInfo[v8].uCaps |= 0x10u; | |
3388 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
3389 a6->pInfo[v8].uCaps |= 0x20u; | |
3390 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
3391 a6->pInfo[v8].uCaps |= 0x40u; | |
3392 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
3393 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
3394 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
3395 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
3396 v9 = strlen(lpDeviceName); | |
3397 a6->pInfo[v8].pName = new char[v9 + 1]; | |
3398 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
3399 v10 = strlen(lpDeviceDesc); | |
3400 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
3401 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
3402 a6->pInfo[v8].pGUID = (GUID *)operator new(0x10u); | |
3403 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); | |
3404 v11 = strlen(a6->ptr_4->pDriverName); | |
3405 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
3406 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
3407 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
3408 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
3409 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
3410 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
3411 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
3412 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
3413 if ( a6->ptr_4->pGUID ) | |
3414 { | |
3415 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
3416 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
3417 } | |
3418 else | |
3419 { | |
3420 a6->pInfo[v8].pDirectDrawGUID = 0; | |
3421 } | |
3422 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
3423 } | |
3424 return 1; | |
3425 } | |
3426 | |
3427 //----- (0049D75C) -------------------------------------------------------- | |
3428 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
3429 { | |
3430 HRESULT result; // eax@3 | |
3431 | |
3432 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
3433 { | |
3434 *a2 = 1; | |
3435 result = 0; | |
3436 } | |
3437 else | |
3438 { | |
3439 result = 1; | |
3440 } | |
3441 return result; | |
3442 } | |
3443 | |
3444 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3445 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3446 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3447 //char *v0; // esi@2 |
639 | 3448 //DecorationDesc *v1; // ebx@6 |
0 | 3449 __int16 v2; // ax@6 |
3450 double v3; // st7@7 | |
639 | 3451 //int v4; // eax@9 |
3452 //int v5; // edx@9 | |
0 | 3453 unsigned int v6; // edi@9 |
3454 int v7; // eax@9 | |
3455 SpriteFrame *v8; // eax@9 | |
635 | 3456 //SpriteFrame *v9; // edi@9 |
0 | 3457 unsigned __int16 *v10; // eax@9 |
3458 int v11; // ecx@9 | |
3459 int v12; // eax@9 | |
3460 int v13; // ecx@9 | |
3461 int v14; // ecx@20 | |
3462 char v15; // dl@20 | |
3463 signed int v16; // eax@20 | |
3464 int v17; // eax@23 | |
3465 int v18; // ecx@24 | |
3466 int v19; // eax@24 | |
3467 int v20; // ecx@24 | |
3468 int v21; // ebx@26 | |
3469 int v22; // eax@26 | |
3470 int v23; // eax@30 | |
3471 signed __int64 v24; // qtt@31 | |
3472 int v25; // ebx@31 | |
3473 int v26; // ecx@32 | |
3474 RenderBillboard *v27; // eax@37 | |
3475 __int16 v28; // dx@37 | |
3476 __int16 v29; // cx@37 | |
3477 int v30; // ecx@37 | |
3478 int v31; // ebx@37 | |
619 | 3479 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
639 | 3480 //int x; // [sp+74h] [bp-30h]@9 |
3481 //int y; // [sp+78h] [bp-2Ch]@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3482 //int v35; // [sp+7Ch] [bp-28h]@1 |
639 | 3483 //int v36; // [sp+80h] [bp-24h]@9 |
0 | 3484 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
3485 int v38; // [sp+88h] [bp-1Ch]@9 | |
3486 int v39; // [sp+8Ch] [bp-18h]@24 | |
3487 int v40; // [sp+90h] [bp-14h]@24 | |
3488 int v41; // [sp+94h] [bp-10h]@24 | |
3489 int v42; // [sp+98h] [bp-Ch]@9 | |
3490 int a5; // [sp+9Ch] [bp-8h]@9 | |
3491 int b; // [sp+A0h] [bp-4h]@22 | |
3492 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3493 //v35 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3494 //if ( (signed int)uNumLevelDecorations > 0 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3495 //{ |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3496 //v0 = (char *)&pLevelDecorations[0].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3497 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3498 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3499 { |
635 | 3500 auto decor = pLevelDecorations + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3501 auto v0 = (char *)&pLevelDecorations[i].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3502 |
639 | 3503 if ( (!(decor->field_2 & 0x40) || decor->_47A825()) && !(decor->field_2 & 0x20) ) |
3504 { | |
3505 //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID]; | |
3506 auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; | |
3507 v2 = decor_desc->uFlags; | |
0 | 3508 if ( (char)v2 >= 0 ) |
3509 { | |
3510 if ( !(v2 & 0x22) ) | |
3511 { | |
639 | 3512 //v4 = decor->vPosition.x; |
3513 //v5 = decor->vPosition.z; | |
0 | 3514 v6 = pMiscTimer->uTotalGameTimeElapsed; |
639 | 3515 //y = decor->vPosition.y; |
3516 //x = decor->vPosition.x; | |
3517 //v36 = decor->vPosition.z; | |
3518 v7 = abs(decor->vPosition.x + decor->vPosition.y); | |
635 | 3519 |
3520 | |
3521 #pragma region "New: seasons change" | |
3522 extern bool change_seasons; | |
3523 if (change_seasons) | |
3524 switch (pParty->uCurrentMonth) | |
3525 { | |
3526 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
3527 case 11: case 0: case 1: // winter | |
639 | 3528 switch (decor_desc->uSpriteID) |
635 | 3529 { |
3530 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
3531 case 548: // flower10 | |
3532 case 547: // flower09 | |
3533 case 541: // flower03 | |
3534 case 539: continue; // flower01 | |
3535 | |
3536 case 483: // tree01 | |
3537 case 486: // tree04 | |
3538 case 492: // tree10 | |
639 | 3539 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); |
3540 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
635 | 3541 break; |
3542 | |
3543 default: | |
639 | 3544 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3545 } |
3546 break; | |
3547 | |
3548 case 2: case 3: case 4: // spring | |
639 | 3549 switch (decor_desc->uSpriteID) |
635 | 3550 { |
3551 } | |
639 | 3552 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3553 break; |
3554 | |
3555 case 8: case 9: case 10: // autumn | |
639 | 3556 switch (decor_desc->uSpriteID) |
635 | 3557 { |
3558 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
3559 case 548: // flower10 | |
3560 case 547: // flower09 | |
3561 case 541: // flower03 | |
3562 case 539: continue; // flower01 | |
3563 | |
3564 case 483: // tree01 | |
3565 case 486: // tree04 | |
3566 case 492: // tree10 | |
639 | 3567 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); |
3568 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
635 | 3569 break; |
3570 | |
3571 default: | |
639 | 3572 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3573 } |
3574 break; | |
3575 | |
3576 case 5: case 6: case 7: // summer | |
3577 //all green by default | |
639 | 3578 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3579 break; |
3580 | |
3581 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
3582 } | |
637 | 3583 else |
639 | 3584 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3585 #pragma endregion |
639 | 3586 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3587 |
3588 //v9 = v8; | |
0 | 3589 v42 = v8->uFlags; |
3590 a5 = v8->uGlowRadius; | |
639 | 3591 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pIndoorCamera->pos.x, |
3592 decor->vPosition.y - pIndoorCamera->pos.y); | |
0 | 3593 v11 = *((int *)v0 + 2); |
3594 v37 = v10; | |
3595 v12 = v42; | |
3596 v38 = 0; | |
3597 v13 = ((signed int)(stru_5C6E00->uIntegerPi | |
3598 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
3599 + v11 | |
3600 - (signed int)v37) >> 8) & 7; | |
3601 v37 = (unsigned __int16 *)v13; | |
3602 if ( v42 & 2 ) | |
3603 v38 = 2; | |
3604 if ( (256 << v13) & v42 ) | |
3605 v38 |= 4u; | |
3606 if ( v12 & 0x40000 ) | |
3607 v38 |= 0x40u; | |
3608 if ( v12 & 0x20000 ) | |
3609 LOBYTE(v38) = v38 | 0x80; | |
3610 if ( a5 ) | |
3611 { | |
3612 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) | |
3613 { | |
639 | 3614 v14 = decor_desc->uColoredLightRed; |
3615 v15 = decor_desc->uColoredLightGreen; | |
3616 v16 = decor_desc->uColoredLightBlue; | |
0 | 3617 } |
3618 else | |
3619 { | |
3620 v16 = 255; | |
3621 v14 = 255; | |
3622 v15 = 255; | |
3623 } | |
3624 b = v16; | |
3625 pStationaryLightsStack->AddLight( | |
639 | 3626 decor->vPosition.x, |
3627 decor->vPosition.y, | |
3628 decor->vPosition.z + decor_desc->uDecorationHeight / 2, | |
0 | 3629 a5, |
3630 v14, | |
3631 v15, | |
3632 v16, | |
3633 byte_4E94D0); | |
3634 } | |
639 | 3635 v17 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
0 | 3636 if ( pIndoorCamera->sRotationX ) |
3637 { | |
639 | 3638 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; |
0 | 3639 v18 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) |
3640 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3641 v42 = v18; | |
3642 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3643 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
639 | 3644 v40 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 3645 v41 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; |
3646 v19 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3647 v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3648 v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3649 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3650 { | |
3651 v21 = a5 - b; | |
3652 v41 = a5 - b; | |
3653 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3654 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3655 v22 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) - a5; | |
3656 LABEL_30: | |
3657 v42 = v22; | |
3658 v40 = 2 * abs(v20); | |
3659 v23 = abs(v21); | |
3660 if ( v40 >= v23 ) | |
3661 { | |
3662 LODWORD(v24) = 0; | |
3663 HIDWORD(v24) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3664 a5 = v24 / v39; | |
3665 v25 = pViewport->uScreenCenterX | |
3666 - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); | |
3667 b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; | |
3668 v41 = v24 / v39; | |
3669 v40 = pViewport->uScreenCenterY | |
3670 - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); | |
635 | 3671 v42 = v8->scale; |
0 | 3672 v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; |
635 | 3673 v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37]; |
0 | 3674 if ( pRenderer->pRenderD3D ) |
3675 { | |
3676 v26 = v41; | |
3677 v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; | |
3678 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
3679 } | |
3680 else | |
3681 { | |
3682 v26 = v41; | |
3683 v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; | |
3684 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
3685 } | |
693 | 3686 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
0 | 3687 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3688 if (::uNumBillboardsToDraw >= 500) |
0 | 3689 return; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3690 v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; |
0 | 3691 ++uNumDecorationsDrawnThisFrame; |
3692 v27->uHwSpriteID = *v37; | |
635 | 3693 v28 = v8->uPaletteIndex; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3694 v27->_screenspace_x_scaler_packedfloat = v26; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3695 v27->_screenspace_y_scaler_packedfloat = v26; |
0 | 3696 v29 = v38; |
3697 v27->uScreenSpaceX = v25; | |
3698 HIBYTE(v29) |= 2u; | |
3699 v27->uPalette = v28; | |
3700 v27->field_1E = v29; | |
639 | 3701 v27->world_x = decor->vPosition.x; |
3702 v27->world_y = decor->vPosition.y; | |
3703 v27->world_z = decor->vPosition.z; | |
0 | 3704 v27->uScreenSpaceY = v40; |
3705 HIWORD(v30) = HIWORD(v39); | |
862 | 3706 v31 = PID(OBJECT_Decoration,i); |
0 | 3707 LOWORD(v30) = 0; |
3708 v27->uIndoorSectorID = 0; | |
3709 v27->sZValue = v30 + v31; | |
657 | 3710 v27->dimming_level = 0; |
635 | 3711 v27->pSpriteFrame = v8; |
0 | 3712 v27->uTintColor = 0; |
3713 } | |
3714 } | |
3715 goto LABEL_38; | |
3716 } | |
3717 } | |
3718 else | |
3719 { | |
639 | 3720 v42 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
3721 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; | |
0 | 3722 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; |
3723 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3724 v20 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3725 v39 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3726 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3727 { | |
3728 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3729 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3730 v21 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
3731 v41 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
639 | 3732 v22 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 3733 goto LABEL_30; |
3734 } | |
3735 } | |
3736 } | |
3737 } | |
3738 else | |
3739 { | |
3740 memset(&local_0, 0, 0x68u); | |
3741 v3 = (double)*((signed int *)v0 - 1); | |
619 | 3742 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; |
3743 local_0.uDiffuse = 0xFF3C1E; | |
0 | 3744 local_0.x = v3; |
3745 local_0.y = (double)*(signed int *)v0; | |
3746 local_0.z = (double)*((signed int *)v0 + 1); | |
3747 local_0.flt_10 = 0.0; | |
3748 local_0.flt_14 = 0.0; | |
3749 local_0.flt_18 = 0.0; | |
3750 local_0.flt_28 = 1.0; | |
3751 local_0.timeToLive = (rand() & 0x80) + 128; | |
3752 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
3753 pGame->pParticleEngine->AddParticle(&local_0); | |
3754 } | |
3755 } | |
3756 LABEL_38: | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3757 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3758 //++v35; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3759 //v0 += 32; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3760 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3761 //while ( v35 < (signed int)uNumLevelDecorations ); |
0 | 3762 } |
3763 // 4E94D0: using guessed type char byte_4E94D0; | |
3764 // 5187EC: using guessed type int uNumDecorationsDrawnThisFrame; | |
3765 | |
3766 //----- (0049D717) -------------------------------------------------------- | |
3767 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
3768 { | |
3769 HRESULT v2; // esi@2 | |
3770 | |
3771 if ( Src->dwFlags & 0x400 | 0x2000 ) | |
3772 { | |
3773 v2 = 0; | |
3774 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
3775 goto LABEL_6; | |
3776 if ( !Dst->dwSize ) | |
3777 { | |
3778 v2 = 1; | |
3779 LABEL_6: | |
3780 memcpy(Dst, Src, 0x20u); | |
3781 return v2; | |
3782 } | |
3783 } | |
3784 return 1; | |
3785 } | |
3786 | |
3787 //----- (0049DC28) -------------------------------------------------------- | |
3788 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
3789 { | |
3790 RenderD3D__DevInfo *v2; // eax@1 | |
3791 | |
3792 v2 = new RenderD3D__DevInfo[4];// 4 items | |
3793 *pOutDevices = v2; | |
3794 memset(v2, 0, 0xA0u); | |
3795 DirectDrawEnumerateA((LPDDENUMCALLBACKA)RenderD3D__DeviceEnumerator, *pOutDevices); | |
3796 } | |
3797 | |
3798 //----- (0049DC58) -------------------------------------------------------- | |
3799 RenderD3D::RenderD3D() | |
3800 { | |
3801 RenderD3D *v1; // esi@1 | |
3802 | |
3803 v1 = this; | |
3804 this->pHost = 0; | |
3805 this->pDirect3D = 0; | |
3806 this->pUnk = 0; | |
3807 this->pBackBuffer = 0; | |
3808 this->pFrontBuffer = 0; | |
3809 this->pZBuffer = 0; | |
3810 this->pDevice = 0; | |
3811 this->pViewport = 0; | |
3812 this->field_40 = 1; | |
3813 this->field_44 = 10; | |
3814 GetAvailableDevices(&this->pAvailableDevices); | |
3815 } | |
3816 | |
3817 //----- (0049DC90) -------------------------------------------------------- | |
3818 void RenderD3D::Release() | |
3819 { | |
3820 RenderD3D *v1; // esi@1 | |
3821 IDirectDraw4 *v2; // eax@2 | |
3822 signed int v3; // edi@4 | |
3823 IDirect3DViewport3 *v4; // eax@22 | |
3824 IUnknown *v5; // eax@24 | |
3825 IDirectDrawSurface4 *v6; // eax@26 | |
3826 IDirect3DDevice3 *v7; // eax@28 | |
3827 IDirect3D3 *v8; // eax@30 | |
3828 IDirectDrawSurface4 *v9; // eax@32 | |
3829 IDirectDrawSurface4 *v10; // eax@34 | |
3830 IDirectDraw4 *v11; // eax@36 | |
3831 | |
3832 v1 = this; | |
3833 if ( !this->bWindowed ) | |
3834 { | |
3835 v2 = this->pHost; | |
3836 if ( v2 ) | |
3837 { | |
3838 v2->RestoreDisplayMode(); | |
3839 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
3840 v1->pHost->FlipToGDISurface(); | |
3841 } | |
3842 } | |
3843 v3 = 0; | |
3844 do | |
3845 { | |
3846 if ( v1->pAvailableDevices[v3].pDriverName ) | |
3847 { | |
3848 free(v1->pAvailableDevices[v3].pDriverName); | |
3849 v1->pAvailableDevices[v3].pDriverName = 0; | |
3850 } | |
3851 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
3852 { | |
3853 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
3854 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
3855 } | |
3856 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
3857 { | |
3858 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
3859 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
3860 } | |
3861 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
3862 { | |
3863 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
3864 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
3865 } | |
3866 if ( v1->pAvailableDevices[v3].pName ) | |
3867 { | |
3868 free(v1->pAvailableDevices[v3].pName); | |
3869 v1->pAvailableDevices[v3].pName = 0; | |
3870 } | |
3871 if ( v1->pAvailableDevices[v3].pDescription ) | |
3872 { | |
3873 free(v1->pAvailableDevices[v3].pDescription); | |
3874 v1->pAvailableDevices[v3].pDescription = 0; | |
3875 } | |
3876 if ( v1->pAvailableDevices[v3].pGUID ) | |
3877 { | |
3878 free(v1->pAvailableDevices[v3].pGUID); | |
3879 v1->pAvailableDevices[v3].pGUID = 0; | |
3880 } | |
3881 ++v3; | |
3882 } | |
3883 while ( v3 < 4 ); | |
3884 if ( v1->pAvailableDevices ) | |
3885 { | |
3886 free(v1->pAvailableDevices); | |
3887 v1->pAvailableDevices = 0; | |
3888 } | |
3889 v4 = v1->pViewport; | |
3890 if ( v4 ) | |
3891 { | |
3892 v4->Release(); | |
3893 v1->pViewport = 0; | |
3894 } | |
3895 v5 = v1->pUnk; | |
3896 if ( v5 ) | |
3897 { | |
3898 v5->Release(); | |
3899 v1->pUnk = 0; | |
3900 } | |
3901 v6 = v1->pZBuffer; | |
3902 if ( v6 ) | |
3903 { | |
3904 v6->Release(); | |
3905 v1->pZBuffer = 0; | |
3906 } | |
3907 v7 = v1->pDevice; | |
3908 if ( v7 ) | |
3909 { | |
3910 v7->Release(); | |
3911 v1->pDevice = 0; | |
3912 } | |
3913 v8 = v1->pDirect3D; | |
3914 if ( v8 ) | |
3915 { | |
3916 v8->Release(); | |
3917 v1->pDirect3D = 0; | |
3918 } | |
3919 v9 = v1->pBackBuffer; | |
3920 if ( v9 ) | |
3921 { | |
3922 v9->Release(); | |
3923 v1->pBackBuffer = 0; | |
3924 } | |
3925 v10 = v1->pFrontBuffer; | |
3926 if ( v10 ) | |
3927 { | |
3928 v10->Release(); | |
3929 v1->pFrontBuffer = 0; | |
3930 } | |
3931 v11 = v1->pHost; | |
3932 if ( v11 ) | |
3933 { | |
3934 v11->Release(); | |
3935 v1->pHost = 0; | |
3936 } | |
3937 } | |
3938 | |
3939 //----- (0049DE14) -------------------------------------------------------- | |
3940 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, HWND hWnd) | |
3941 { | |
3942 //IDirectDraw4 *v8; // eax@12 | |
3943 //IDirectDraw4 *v9; // eax@16 | |
3944 //IDirectDraw4 *v10; // eax@20 | |
3945 //IDirectDraw4 *v13; // eax@35 | |
3946 const char *v23; // [sp-4h] [bp-DCh]@9 | |
3947 const char *v24; // [sp-4h] [bp-DCh]@13 | |
3948 const char *v25; // [sp-4h] [bp-DCh]@19 | |
3949 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
3950 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
3951 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
3952 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
3953 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
3954 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
3955 | |
3956 this->bWindowed = bWindowed; | |
3957 this->hWindow = hWnd; | |
3958 | |
3959 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
3960 { | |
3961 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
3962 return 0; | |
3963 } | |
3964 | |
3965 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
3966 { | |
3967 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
3968 if (lpDD) | |
3969 lpDD->Release(); | |
3970 return 0; | |
3971 } | |
3972 lpDD->Release(); | |
3973 lpDD = 0; | |
3974 | |
3975 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
3976 { | |
3977 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
3978 { | |
3979 v23 = "Init - Failed to set cooperative level.\n"; | |
3980 sprintf(pErrorMessage, v23); | |
3981 LABEL_65: | |
3982 if (pHost) | |
3983 { | |
3984 pHost->Release(); | |
3985 pHost = 0; | |
3986 } | |
3987 return 0; | |
3988 } | |
3989 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
3990 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
3991 ddsd2.dwFlags = DDSD_CAPS; | |
3992 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
3993 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
3994 { | |
3995 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
3996 pHost->GetDisplayMode(&ddsd2); | |
3997 if ( ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) | |
3998 { | |
3999 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
4000 goto LABEL_14; | |
4001 } | |
4002 | |
4003 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
4004 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
4005 ddsd2.dwWidth = 640; | |
4006 ddsd2.dwHeight = 480; | |
4007 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) | |
4008 { | |
4009 v24 = "Init - Failed to create back buffer.\n"; | |
4010 LABEL_14: | |
4011 sprintf(pErrorMessage, v24); | |
4012 if (pFrontBuffer) | |
4013 { | |
4014 pFrontBuffer->Release(); | |
4015 pFrontBuffer = 0; | |
4016 } | |
4017 goto LABEL_65; | |
4018 } | |
4019 if ( pHost->CreateClipper(0, &v30, 0) ) | |
4020 { | |
4021 v25 = "Init - Failed to create clipper.\n"; | |
4022 goto LABEL_45; | |
4023 } | |
4024 v30->SetHWnd(0, hWnd); | |
4025 pFrontBuffer->SetClipper(v30); | |
4026 | |
4027 v30->Release(); | |
4028 v30 = 0; | |
4029 | |
4030 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
4031 | |
4032 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4033 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
4034 ddsd2.dwWidth = 640; | |
4035 ddsd2.dwHeight = 480; | |
4036 | |
4037 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
4038 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
4039 &ddsd2.ddpfPixelFormat) ) | |
4040 goto LABEL_21; | |
4041 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
4042 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
4043 | |
4044 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
4045 { | |
4046 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
4047 { | |
4048 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
4049 pBackBuffer, | |
4050 &pDevice, | |
4051 0) ) | |
4052 { | |
4053 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
4054 d3dvp2.dvClipWidth = 2.0; | |
4055 d3dvp2.dvClipY = 1.0; | |
4056 d3dvp2.dvClipHeight = 2.0; | |
4057 d3dvp2.dvMaxZ = 1.0; | |
4058 d3dvp2.dvMinZ = 0.0; | |
4059 goto LABEL_54; | |
4060 } | |
4061 LABEL_51: | |
4062 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
4063 if (pDirect3D) | |
4064 { | |
4065 pDirect3D->Release(); | |
4066 pDirect3D = 0; | |
4067 } | |
4068 goto LABEL_59; | |
4069 } | |
4070 LABEL_48: | |
4071 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
4072 if (pZBuffer) | |
4073 { | |
4074 pZBuffer->Release(); | |
4075 pZBuffer = 0; | |
4076 } | |
4077 goto LABEL_61; | |
4078 } | |
4079 goto LABEL_44; | |
4080 } | |
4081 LABEL_36: | |
4082 v23 = "Init - Failed to create front buffer.\n"; | |
4083 sprintf(pErrorMessage, v23); | |
4084 goto LABEL_65; | |
4085 } | |
4086 if ( uDeviceID == 1 ) | |
4087 v26 = 1045; | |
4088 else | |
4089 v26 = 1041; | |
4090 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
4091 { | |
4092 v23 = "Init - Failed to set cooperative level.\n"; | |
4093 sprintf(pErrorMessage, v23); | |
4094 goto LABEL_65; | |
4095 } | |
4096 if (pHost->SetDisplayMode(640u, 480u, 16u, 0, 0) ) | |
4097 { | |
4098 v23 = "Init - Failed to set display mode.\n"; | |
4099 sprintf(pErrorMessage, v23); | |
4100 goto LABEL_65; | |
4101 } | |
4102 | |
4103 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
4104 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
4105 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4106 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
4107 ddsd2.dwBackBufferCount = 1; | |
4108 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
4109 goto LABEL_36; | |
4110 //a3a = &pBackBuffer; | |
4111 //v14 = *v34; | |
4112 memset(&v27, 0, sizeof(DDSCAPS2)); | |
4113 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
4114 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
4115 //hWnda = &pDirect3D; | |
4116 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
4117 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
4118 { | |
4119 v25 = "Init - Failed to get D3D interface.\n"; | |
4120 goto LABEL_45; | |
4121 } | |
4122 | |
4123 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4124 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
4125 ddsd2.dwWidth = 640; | |
4126 ddsd2.dwHeight = 480; | |
4127 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
4128 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
4129 &ddsd2.ddpfPixelFormat) ) | |
4130 { | |
4131 LABEL_21: | |
4132 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
4133 goto LABEL_45; | |
4134 } | |
4135 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
4136 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
4137 //uDeviceIDa = &pZBuffer; | |
4138 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
4139 { | |
4140 LABEL_44: | |
4141 v25 = "Init - Failed to create z-buffer.\n"; | |
4142 LABEL_45: | |
4143 sprintf(pErrorMessage, v25); | |
4144 if (pBackBuffer) | |
4145 { | |
4146 pBackBuffer->Release(); | |
4147 pBackBuffer = 0; | |
4148 } | |
4149 LABEL_63: | |
4150 //v19 = &pFrontBuffer; | |
4151 if (pFrontBuffer) | |
4152 { | |
4153 pFrontBuffer->Release(); | |
4154 pFrontBuffer= 0; | |
4155 } | |
4156 goto LABEL_65; | |
4157 } | |
4158 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
4159 goto LABEL_48; | |
4160 //v33 = &pDevice; | |
4161 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
4162 pBackBuffer, | |
4163 &pDevice, | |
4164 0) ) | |
4165 goto LABEL_51; | |
4166 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
4167 d3dvp2.dvClipWidth = 2.0; | |
4168 d3dvp2.dvClipY = 1.0; | |
4169 d3dvp2.dvClipHeight = 2.0; | |
4170 d3dvp2.dvMaxZ = 1.0; | |
4171 | |
4172 LABEL_54: | |
4173 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
4174 //v17 = *hWnda; | |
4175 d3dvp2.dwWidth = 640; | |
4176 d3dvp2.dwHeight = 480; | |
4177 d3dvp2.dvClipX = -1.0; | |
4178 //v18 = v17->lpVtbl; | |
4179 //v32 = &v4->pViewport; | |
4180 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
4181 { | |
4182 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
4183 if (pDevice) | |
4184 { | |
4185 pDevice->Release(); | |
4186 pDevice = 0; | |
4187 } | |
4188 if (pDirect3D) | |
4189 { | |
4190 pDirect3D->Release(); | |
4191 pDirect3D = 0; | |
4192 } | |
4193 LABEL_59: | |
4194 if (pZBuffer) | |
4195 { | |
4196 pZBuffer->Release(); | |
4197 pZBuffer = 0; | |
4198 } | |
4199 LABEL_61: | |
4200 if (pBackBuffer) | |
4201 { | |
4202 pBackBuffer->Release(); | |
4203 pBackBuffer = 0; | |
4204 } | |
4205 goto LABEL_63; | |
4206 } | |
4207 | |
4208 pDevice->AddViewport(pViewport); | |
4209 pViewport->SetViewport2(&d3dvp2); | |
4210 pDevice->SetCurrentViewport(pViewport); | |
4211 return 1; | |
4212 } | |
4213 | |
4214 //----- (0049E444) -------------------------------------------------------- | |
4215 unsigned int RenderD3D::GetDeviceCaps() | |
4216 { | |
4217 unsigned int v1; // ebx@1 | |
4218 RenderD3D *v2; // edi@1 | |
4219 IDirect3DDevice3 *v3; // eax@1 | |
4220 unsigned int result; // eax@2 | |
4221 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
4222 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
4223 | |
4224 v1 = 0; | |
4225 v2 = this; | |
4226 memset(&halCaps, 0, 0xFCu); | |
4227 halCaps.dwSize = 252; | |
4228 memset(&refCaps, 0, 0xFCu); | |
4229 v3 = v2->pDevice; | |
4230 refCaps.dwSize = 252; | |
4231 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
4232 { | |
4233 result = 1; | |
4234 } | |
4235 else | |
4236 { | |
4237 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
4238 v1 = 2; | |
4239 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 2) ) | |
4240 v1 |= 4u; | |
4241 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 1) ) | |
4242 v1 |= 8u; | |
4243 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
4244 v1 |= 0x10u; | |
4245 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 2) ) | |
4246 v1 |= 0x20u; | |
4247 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 4) ) | |
4248 v1 |= 0x40u; | |
4249 if ( halCaps.dpcTriCaps.dwTextureCaps & 0x20 ) | |
4250 LOBYTE(v1) = v1 | 0x80; | |
4251 result = v1; | |
4252 } | |
4253 return result; | |
4254 } | |
4255 | |
4256 //----- (0049E4FC) -------------------------------------------------------- | |
4257 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
4258 { | |
4259 uint uClearFlags = 0; | |
4260 | |
4261 if (bClearColor) | |
4262 uClearFlags |= D3DCLEAR_TARGET; | |
4263 if (bClearDepth) | |
4264 uClearFlags |= D3DCLEAR_ZBUFFER; | |
4265 | |
4266 D3DRECT rects[] = {{0, 0, 640, 480}}; | |
4267 if (uClearFlags) | |
4268 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
4269 } | |
4270 | |
4271 //----- (0049E54D) -------------------------------------------------------- | |
4272 void RenderD3D::Present(bool bForceBlit) | |
4273 { | |
4274 RECT v5; // [sp+18h] [bp-18h]@1 | |
4275 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
4276 | |
4277 v5.left = 0; | |
4278 v5.top = 0; | |
4279 v5.bottom = 480; | |
4280 v5.right = 640; | |
4281 | |
4282 if (bWindowed || bForceBlit) | |
4283 { | |
4284 RECT rc; | |
4285 GetClientRect(hWindow, &rc); | |
4286 Point.y = 0; | |
4287 Point.x = 0; | |
4288 ClientToScreen(hWindow, &Point); | |
4289 OffsetRect(&rc, Point.x, Point.y); | |
4290 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
4291 } | |
4292 else | |
4293 pFrontBuffer->Flip(0, 1); | |
4294 } | |
4295 | |
4296 //----- (0049E5D4) -------------------------------------------------------- | |
4297 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
4298 { | |
4299 unsigned int v8; // edx@4 | |
4300 unsigned int v9; // ebx@5 | |
4301 unsigned int v10; // eax@5 | |
4302 DWORD v11; // edx@5 | |
4303 //int v12; // edx@7 | |
4304 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
4305 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
4306 | |
4307 //v15 = this; | |
4308 memset(&ddsd2, 0, 0x7Cu); | |
4309 ddsd2.dwSize = 0x7Cu; | |
4310 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4311 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
4312 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
4313 ddsd2.dwHeight = uTextureHeight; | |
4314 ddsd2.dwWidth = uTextureWidth; | |
4315 if ( bMipmaps ) | |
4316 { | |
4317 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
4318 { | |
4319 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
4320 LABEL_8: | |
4321 ddsd2.dwMipMapCount = v8; | |
4322 if ( !v8 ) | |
4323 goto LABEL_12; | |
4324 goto LABEL_11; | |
4325 } | |
4326 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
4327 { | |
4328 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
4329 goto LABEL_8; | |
4330 } | |
4331 v9 = GetMaxMipLevels(uTextureWidth); | |
4332 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
4333 ddsd2.dwMipMapCount = v9 - v10; | |
4334 if ( v9 == v10 ) | |
4335 { | |
4336 ddsd2.dwFlags = 0x1007u; | |
4337 ddsd2.ddsCaps.dwCaps = v11; | |
4338 goto LABEL_12; | |
4339 } | |
4340 } | |
4341 else | |
4342 { | |
4343 ddsd2.dwMipMapCount = 1; | |
4344 } | |
4345 LABEL_11: | |
4346 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
4347 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
4348 LABEL_12: | |
4349 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
4350 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
4351 if (bAlphaChannel) | |
4352 { | |
4353 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
4354 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
4355 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
4356 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
4357 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
4358 } | |
4359 else | |
4360 { | |
4361 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
4362 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
4363 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
4364 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
4365 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
4366 } | |
4367 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
4368 return false; | |
4369 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
4370 { | |
4371 (*pOutSurface)->Release(); | |
4372 *pOutSurface = 0; | |
4373 return false; | |
4374 } | |
4375 return true; | |
4376 } | |
4377 | |
4378 //----- (004A5190) -------------------------------------------------------- | |
4379 void RenderD3D::HandleLostResources() | |
4380 { | |
4381 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
4382 pBitmaps_LOD->_410423_move_textures_to_device(); | |
4383 pSprites_LOD->ReleaseLostHardwareSprites(); | |
4384 } | |
4385 | |
4386 //----- (004A2050) -------------------------------------------------------- | |
4387 void Render::DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) | |
4388 { | |
4389 Render *v5; // edi@1 | |
4390 unsigned int v6; // ebx@1 | |
4391 LightmapBuilder *v7; // esi@3 | |
4392 int v8; // eax@7 | |
4393 ODMFace *v9; // eax@12 | |
4394 char *v10; // esi@12 | |
4395 double v11; // st7@14 | |
4396 double v12; // st7@14 | |
4397 int v13; // eax@14 | |
4398 ODMFace *v14; // ecx@14 | |
4399 double v15; // st7@14 | |
4400 float v16; // ST48_4@15 | |
4401 int v17; // eax@15 | |
4402 char v18; // zf@17 | |
4403 HRESULT v19; // eax@18 | |
4404 HRESULT v20; // eax@18 | |
4405 HRESULT v21; // eax@20 | |
4406 HRESULT v22; // eax@20 | |
4407 unsigned int v23; // ecx@20 | |
4408 char *v24; // eax@21 | |
4409 HRESULT v25; // eax@23 | |
4410 HRESULT v26; // eax@23 | |
4411 HRESULT v27; // eax@24 | |
4412 HRESULT v28; // eax@25 | |
4413 HRESULT v29; // eax@25 | |
4414 HRESULT v30; // eax@25 | |
4415 HRESULT v31; // eax@25 | |
4416 HRESULT v32; // eax@26 | |
4417 unsigned int v33; // ecx@26 | |
4418 char *v34; // eax@27 | |
4419 int v35; // edx@28 | |
4420 HRESULT v36; // eax@29 | |
4421 HRESULT v37; // eax@29 | |
4422 HRESULT v38; // eax@29 | |
4423 HRESULT v39; // eax@29 | |
4424 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
4425 unsigned int v41; // eax@29 | |
4426 HRESULT v42; // eax@30 | |
4427 HRESULT v43; // eax@30 | |
4428 HRESULT v44; // eax@30 | |
4429 char *v45; // esi@34 | |
4430 int v46; // ecx@35 | |
4431 double v47; // st6@35 | |
4432 int v48; // eax@36 | |
4433 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
4434 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
4435 int v51; // [sp+50h] [bp-18h]@0 | |
4436 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
4437 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
4438 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
4439 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
4440 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
4441 int v57; // [sp+60h] [bp-8h]@34 | |
638 | 4442 unsigned int a2; // [sp+64h] [bp-4h]@4 |
0 | 4443 |
4444 v5 = this; | |
4445 v6 = 0; | |
4446 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
4447 { | |
4448 v7 = pGame->pLightmapBuilder; | |
4449 v53 = v7; | |
4450 v54 = v7->std__vector_000004_size; | |
4451 if ( v7->std__vector_000004_size) | |
638 | 4452 a2 = 0xFFFFFFFF; |
4453 pGame->AlterGamma_ODM(a4, &a2); | |
0 | 4454 if ( byte_4D864C && pGame->uFlags & 1 ) |
4455 { | |
638 | 4456 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
0 | 4457 v7->_45D74F_MessWithLight(v8, 0); |
4458 } | |
4459 else | |
4460 { | |
4461 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
4462 { | |
323 | 4463 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4464 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
4465 if (bUsingSpecular) | |
4466 { | |
186 | 4467 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
4468 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4469 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4470 } |
1073 | 4471 for (uint i = 0; i < uNumVertices; ++i) |
4472 { | |
4473 | |
4474 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4475 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
4476 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); | |
4477 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | |
4478 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4479 pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); | |
4480 | |
4481 if ( this->bUsingSpecular ) | |
0 | 4482 { |
1073 | 4483 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4484 } |
1073 | 4485 else |
4486 { | |
4487 d3d_vertex_buffer[i].specular = 0; | |
4488 } | |
4489 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4490 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4491 | |
4492 } | |
323 | 4493 |
4494 if (a4->uAttributes & FACE_OUTLINED) | |
4495 { | |
4496 int color; | |
4497 if (GetTickCount() % 300 >= 150) | |
4498 color = 0xFFFF2020; | |
4499 else color = 0xFF901010; | |
4500 | |
4501 for (uint i = 0; i < uNumVertices; ++i) | |
4502 d3d_vertex_buffer[i].diffuse = color; | |
4503 } | |
4504 | |
0 | 4505 pRenderD3D->pDevice->SetTexture(0, pTexture); |
4506 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4507 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 4508 d3d_vertex_buffer, |
0 | 4509 uNumVertices, |
4510 D3DDP_DONOTLIGHT); | |
4511 } | |
4512 else | |
4513 { | |
1073 | 4514 for (uint i = 0; i < uNumVertices; ++i) |
4515 { | |
4516 | |
4517 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
4518 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
4519 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); | |
4520 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | |
4521 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
4522 if ( this->bUsingSpecular ) | |
0 | 4523 { |
1073 | 4524 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 4525 } |
1073 | 4526 else |
4527 { | |
4528 d3d_vertex_buffer[i].specular = 0; | |
4529 } | |
4530 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
4531 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
4532 | |
4533 } | |
4534 | |
186 | 4535 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4536 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 4537 if (bUsingSpecular) |
186 | 4538 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 4539 |
4540 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
4541 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4542 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4543 d3d_vertex_buffer, |
0 | 4544 uNumVertices, |
4545 D3DDP_DONOTLIGHT)); | |
4546 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
4547 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
4548 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
4549 v53->_45D74F_MessWithLight(-1, 0); | |
1073 | 4550 for (uint i = 0; i < uNumVertices; ++i) |
4551 { | |
4552 d3d_vertex_buffer[i].diffuse = a2; | |
4553 } | |
0 | 4554 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); |
186 | 4555 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4556 if ( !pRenderer->bUsingSpecular ) |
186 | 4557 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4558 | |
4559 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4560 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4561 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 4562 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
4563 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4564 d3d_vertex_buffer, |
0 | 4565 uNumVertices, |
4566 D3DDP_DONOTLIGHT)); | |
4567 if (bUsingSpecular) | |
4568 { | |
186 | 4569 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4570 |
1073 | 4571 for (uint i = 0; i < uNumVertices; ++i) |
4572 { | |
4573 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
4574 d3d_vertex_buffer[i].specular = 0; | |
4575 } | |
4576 | |
0 | 4577 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 4578 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4579 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
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)); | |
186 | 4585 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4586 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
4587 v41 = GetLevelFogColor(); | |
4588 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
4589 v6 = 0; | |
4590 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4591 } | |
186 | 4592 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4593 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4594 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
4595 } | |
4596 } | |
4597 } | |
4598 } | |
4599 // 4D864C: using guessed type char byte_4D864C; | |
4600 | |
4601 //----- (0049EB79) -------------------------------------------------------- | |
4602 Render::~Render() | |
4603 { | |
4604 Render *v1; // esi@1 | |
4605 | |
4606 v1 = this; | |
4607 pAllocator->FreeChunk(this->pDefaultZBuffer); | |
4608 v1->pD3DBitmaps.Release(); | |
4609 v1->pD3DSprites.Release(); | |
4610 Release(); | |
4611 v1->bWindowMode = 1; | |
4612 //nullsub_1(); | |
4613 //nullsub_1(); | |
4614 } | |
4615 | |
4616 //----- (0049E756) -------------------------------------------------------- | |
4617 bool Render::IsColorKeySupported(IDirectDraw4 *this_) | |
4618 { | |
4619 DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1 | |
4620 DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1 | |
4621 | |
4622 halCaps.dwSize = 380; | |
4623 refCaps.dwSize = 380; | |
4624 this_->GetCaps(&halCaps, &refCaps); | |
4625 return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2; | |
4626 } | |
4627 | |
4628 //----- (0049E992) -------------------------------------------------------- | |
4629 Render::Render() | |
4630 { | |
4631 Render *v1; // esi@1 | |
4632 int v2; // eax@1 | |
4633 char v3; // zf@1 | |
4634 | |
4635 v1 = this; | |
4636 this->pDirectDraw4 = 0; | |
4637 this->pFrontBuffer4 = 0; | |
4638 this->pBackBuffer4 = 0; | |
4639 this->pColorKeySurface4 = 0; | |
4640 this->pDirectDraw2 = 0; | |
4641 this->pFrontBuffer2 = 0; | |
4642 this->pBackBuffer2 = 0; | |
4643 this->pSomeSurface2 = 0; | |
4644 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); | |
4645 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
4646 v1->bWindowMode = 1; | |
4647 v1->field_40054 = 0; | |
4648 v1->field_10 = 640; | |
4649 v1->field_14 = 480; | |
4650 v1->field_40030 = 0; | |
4651 v1->field_4002C = 0; | |
4652 v1->pActiveZBuffer = 0; | |
4653 v1->pDefaultZBuffer = 0; | |
709 | 4654 v1->raster_clip_y = 0; |
4655 v1->raster_clip_x = 0; | |
4656 v1->raster_clip_z = 639; | |
4657 v1->raster_clip_w = 479; | |
0 | 4658 v1->field_4003C = (int)&unk_4EED80; |
4659 v1->field_40040 = dword_4EED78; | |
4660 v1->uClipZ = 640; | |
4661 v1->field_40044 = 2; | |
4662 v1->field_40048 = 6; | |
4663 v1->pFrontBuffer4 = 0; | |
4664 v1->pBackBuffer4 = 0; | |
4665 v1->pColorKeySurface4 = 0; | |
4666 v1->pDirectDraw4 = 0; | |
4667 v1->pRenderD3D = 0; | |
4668 v1->uNumSceneBegins = 0; | |
4669 v1->uNumD3DSceneBegins = 0; | |
4670 v1->field_40110 = 0; | |
4671 v1->pTargetSurface = 0; | |
4672 v1->uTargetSurfacePitch = 0; | |
4673 v1->uClipY = 0; | |
4674 v1->uClipX = 0; | |
4675 v1->uClipW = 480; | |
4676 v1->bClip = 1; | |
4677 v1->bColorKeySupported = 0; | |
4678 v1->bRequiredTextureStagesAvailable = 0; | |
4679 v1->bTinting = 1; | |
4680 LOBYTE(v1->field_103668) = 0; | |
4681 v1->field_1036B8 = 0; | |
4682 v1->_gpu_memory_used = 0; | |
4683 uNumBillboardsToDraw = 0; | |
4684 bFogEnabled = false; | |
265 | 4685 |
4686 hd_water_tile_id = -1; | |
4687 hd_water_current_frame = 0; | |
0 | 4688 } |
4689 | |
781 | 4690 bool Render::Initialize(bool bWindowed, uint uDefaultDevice, bool bColoredLights, uint uDetailLevel, uint bTinting) |
0 | 4691 { |
4692 bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | |
4693 bStartInWindow = bWindowed; | |
4694 | |
4695 uDesiredDirect3DDevice = uDefaultDevice;//ReadWindowsRegistryInt("D3D Device", 1); | |
4696 | |
4697 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
4698 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
4699 | |
4700 this->bTinting = bTinting; | |
4701 | |
4702 auto r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); | |
4703 auto r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
4704 | |
4705 return r1 && r2; | |
4706 } | |
4707 | |
4708 //----- (0049EBF1) -------------------------------------------------------- | |
4709 void Render::_49EBF1() | |
4710 { | |
4711 signed int uNumRedBits; // edx@1 | |
4712 signed int uNuGreenBits; // edi@1 | |
4713 signed int uNumBlueBits; // esi@1 | |
4714 unsigned int v4; // edx@4 | |
4715 unsigned int v5; // edi@4 | |
4716 int v6; // ebx@4 | |
4717 int v7; // edx@4 | |
4718 signed int v8; // [sp+8h] [bp-24h]@1 | |
4719 signed int v9; // [sp+Ch] [bp-20h]@1 | |
4720 signed int v10; // [sp+20h] [bp-Ch]@1 | |
4721 signed int i; // [sp+24h] [bp-8h]@2 | |
4722 signed int v12; // [sp+28h] [bp-4h]@3 | |
4723 | |
4724 v10 = 0; | |
4725 uNumRedBits = 1 << this->uTargetRBits; | |
4726 uNuGreenBits = 1 << this->uTargetGBits; | |
4727 uNumBlueBits = 1 << this->uTargetBBits; | |
4728 v9 = 1 << this->uTargetRBits; | |
4729 v8 = 1 << this->uTargetGBits; | |
4730 if ( uNumRedBits > 0 ) | |
4731 { | |
4732 do | |
4733 { | |
4734 for ( i = 0; i < uNuGreenBits; ++i ) | |
4735 { | |
4736 v12 = 0; | |
4737 if ( uNumBlueBits > 0 ) | |
4738 { | |
4739 do | |
4740 { | |
4741 v4 = this->uTargetBBits; | |
4742 v5 = v4 + this->uTargetGBits; | |
4743 v6 = (v12 >> 1) + (v10 >> 1 << v5) + (i >> 1 << this->uTargetBBits); | |
4744 v7 = (v10 << v5) + v12++ + (i << v4); | |
4745 this->field_2C[v7] = v6; | |
4746 } | |
4747 while ( v12 < uNumBlueBits ); | |
4748 uNumRedBits = v9; | |
4749 uNuGreenBits = v8; | |
4750 } | |
4751 } | |
4752 ++v10; | |
4753 } | |
4754 while ( v10 < uNumRedBits ); | |
4755 } | |
4756 } | |
4757 | |
4758 //----- (0049ECC4) -------------------------------------------------------- | |
4759 void Render::ClearBlack() | |
4760 { | |
4761 if (pRenderD3D) | |
4762 { | |
4763 if (field_40110) | |
4764 pRenderD3D->ClearTarget(true, 0, false, 0.0); | |
4765 } | |
4766 else | |
4767 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
4768 } | |
4769 | |
4770 //----- (0049ED18) -------------------------------------------------------- | |
4771 void Render::PresentBlackScreen() | |
4772 { | |
4773 LONG w; // edx@3 | |
4774 IDirectDrawSurface *v2; // eax@3 | |
4775 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
4776 RECT x; // [sp+68h] [bp-10h]@3 | |
4777 | |
4778 memset(&v3, 0, sizeof(DDBLTFX)); | |
4779 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
4780 pVersion->pVersionInfo.dwMajorVersion >= 5) | |
4781 { | |
4782 x.left = uWindowX; | |
4783 x.right = uWindowX + uWindowHeight; | |
4784 x.top = uWindowY; | |
4785 w = uWindowY + uWindowWidth; | |
4786 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
4787 } | |
4788 else | |
4789 { | |
4790 x.left = uWindowX; | |
4791 x.right = uWindowX + uWindowHeight; | |
4792 x.top = uWindowY; | |
4793 w = uWindowY + uWindowWidth; | |
4794 v2 = (IDirectDrawSurface *)this->pBackBuffer2; | |
4795 } | |
4796 x.bottom = w; | |
4797 v3.dwFillColor = 0; | |
4798 v3.dwSize = 100; | |
4799 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
4800 pRenderer->Present(); | |
4801 } | |
4802 | |
4803 //----- (0049EDB6) -------------------------------------------------------- | |
4804 void Render::SavePCXScreenshot() | |
4805 { | |
4806 Render *v1; // esi@1 | |
4807 __int16 v2; // di@1 | |
4808 int v3; // eax@4 | |
4809 int v4; // ecx@4 | |
4810 int v5; // eax@8 | |
4811 FILE *v6; // edi@10 | |
4812 int v7; // ecx@11 | |
4813 int v8; // eax@11 | |
4814 int v9; // eax@13 | |
4815 int v10; // ecx@15 | |
4816 unsigned __int8 v11; // dl@15 | |
4817 signed int v12; // eax@18 | |
4818 char v13; // zf@27 | |
4819 HRESULT v14; // eax@29 | |
4820 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
4821 __int16 v16; // [sp+44h] [bp-120h]@10 | |
4822 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
4823 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
4824 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
4825 char *v20; // [sp+11Ch] [bp-48h]@14 | |
4826 char *v21; // [sp+120h] [bp-44h]@14 | |
4827 int v24; // [sp+124h] [bp-40h]@11 | |
4828 FILE *File; // [sp+128h] [bp-3Ch]@3 | |
4829 int var38; // [sp+12Ch] [bp-38h]@4 | |
4830 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
4831 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
4832 void *ptr; // [sp+148h] [bp-1Ch]@10 | |
4833 void *v28; // [sp+14Ch] [bp-18h]@8 | |
4834 int v29; // [sp+150h] [bp-14h]@4 | |
4835 int v30; // [sp+154h] [bp-10h]@4 | |
4836 char v31; // [sp+15Ah] [bp-Ah]@25 | |
4837 unsigned __int8 v32; // [sp+15Bh] [bp-9h]@17 | |
4838 int i; // [sp+15Ch] [bp-8h]@10 | |
4839 unsigned __int8 v34; // [sp+163h] [bp-1h]@17 | |
4840 | |
4841 v1 = this; | |
4842 v2 = 0; | |
4843 if ( !this->pRenderD3D || this->field_40110 ) | |
4844 { | |
4845 sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100); | |
4846 File = fopen(Filename, "wb"); | |
4847 if ( File ) | |
4848 { | |
4849 v3 = v1->field_10; | |
4850 v4 = v1->field_14; | |
4851 var38 = v3; | |
4852 v29 = v4; | |
4853 v30 = v3; | |
4854 if ( v3 & 1 ) | |
4855 v30 = v3 + 1; | |
4856 if ( v1->pRenderD3D ) | |
4857 { | |
4858 memset(&Dst, 0, 0x7Cu); | |
4859 Dst.dwSize = 124; | |
168 | 4860 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 4861 return; |
4862 v28 = Dst.lpSurface; | |
4863 v5 = Dst.lPitch >> 1; | |
4864 v2 = 0; | |
4865 } | |
4866 else | |
4867 { | |
4868 pRenderer->BeginScene(); | |
4869 v28 = pRenderer->pTargetSurface; | |
4870 v5 = pRenderer->uTargetSurfacePitch; | |
4871 } | |
4872 i = v5; | |
4873 header1.right = var38 - 1; | |
4874 header1.left = v2; | |
4875 header1.bottom = v29 - 1; | |
4876 header1.up = v2; | |
4877 header2.pitch = v30; | |
4878 memset(color_map, 0, sizeof(color_map)); | |
4879 memset(v15, 0, sizeof(v15)); | |
4880 header2.reserved = 0; | |
4881 header1.manufacturer = 10; | |
4882 v16 = 0; | |
4883 v6 = File; | |
4884 header1.version = 5; | |
4885 header1.encoding = 1; | |
4886 header1.bpp = 8; | |
4887 header1.hdpi = 75; | |
4888 header1.vdpi = 75; | |
4889 header2.planes = 3; | |
4890 header2.palette_info = 1; | |
4891 fwrite(&header1, 1u, 1u, File); | |
4892 fwrite(&header1.version, 1u, 1u, v6); | |
4893 fwrite(&header1.encoding, 1u, 1u, v6); | |
4894 fwrite(&header1.bpp, 1u, 1u, v6); | |
4895 fwrite(&header1.left, 2u, 1u, v6); | |
4896 fwrite(&header1.up, 2u, 1u, v6); | |
4897 fwrite(&header1.right, 2u, 1u, v6); | |
4898 fwrite(&header1.bottom, 2u, 1u, v6); | |
4899 fwrite(&header1.hdpi, 2u, 1u, v6); | |
4900 fwrite(&header1.vdpi, 2u, 1u, v6); | |
4901 fwrite(color_map, 0x30u, 1u, v6); | |
4902 fwrite(&header2, 1u, 1u, v6); | |
4903 fwrite(&header2.planes, 1u, 1u, v6); | |
4904 fwrite(&header2.pitch, 2u, 1u, v6); | |
4905 fwrite(&header2.palette_info, 2u, 1u, v6); | |
4906 fwrite(v15, 0x3Au, 1u, v6); | |
4907 ptr = pAllocator->AllocNamedChunk(0, 3 * var38 + 6, 0); | |
4908 if ( v29 > 0 ) | |
4909 { | |
4910 v7 = v30; | |
4911 File = (FILE *)v29; | |
4912 v29 = 3 * v30; | |
4913 v24 = 2 * i; | |
4914 v8 = (int)v28; | |
4915 while ( 1 ) | |
4916 { | |
4917 i = v8; | |
4918 v9 = 0; | |
4919 if ( var38 > 0 ) | |
4920 { | |
4921 v21 = (char *)ptr + v7; | |
4922 v20 = (char *)ptr + 2 * v30; | |
4923 do | |
4924 { | |
4925 *((char *)ptr + v9) = (signed int)(v1->uTargetRMask & *(short *)i) >> (LOBYTE(v1->uTargetGBits) | |
4926 + LOBYTE(v1->uTargetBBits) | |
4927 + v1->uTargetRBits | |
4928 - 8); | |
4929 v21[v9] = (signed int)(v1->uTargetGMask & *(short *)i) >> (LOBYTE(v1->uTargetBBits) | |
4930 + LOBYTE(v1->uTargetGBits) | |
4931 - 8); | |
4932 v10 = i; | |
4933 v11 = LOBYTE(v1->uTargetBMask); | |
4934 i += 2; | |
4935 v20[v9++] = (*(char *)v10 & v11) << (8 - LOBYTE(v1->uTargetBBits)); | |
4936 } | |
4937 while ( v9 < var38 ); | |
4938 } | |
4939 for ( i = 0; i < v29; i += v34 ) | |
4940 { | |
4941 v34 = 1; | |
4942 v32 = *((char *)ptr + i); | |
4943 do | |
4944 { | |
4945 v12 = i + v34; | |
4946 if ( *((char *)ptr + v12) != v32 ) | |
4947 break; | |
4948 if ( !(v12 % v30) ) | |
4949 break; | |
4950 ++v34; | |
4951 } | |
4952 while ( v34 < 0x3Fu ); | |
4953 if ( i + v34 > v29 ) | |
4954 v34 = 3 * v30 - i; | |
4955 if ( v34 > 1u || v32 >= 0xC0u ) | |
4956 { | |
4957 v31 = v34 | 0xC0; | |
4958 fwrite(&v31, 1u, 1u, v6); | |
4959 } | |
4960 fwrite(&v32, 1u, 1u, v6); | |
4961 } | |
4962 v8 = (int)((char *)v28 + v24); | |
4963 v13 = File == (FILE *)1; | |
4964 File = (FILE *)((char *)File - 1); | |
4965 v28 = (char *)v28 + v24; | |
4966 if ( v13 ) | |
4967 break; | |
4968 v7 = v30; | |
4969 } | |
4970 } | |
4971 if ( v1->pRenderD3D ) | |
4972 { | |
4973 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
4974 } | |
4975 else | |
4976 { | |
4977 pRenderer->EndScene(); | |
4978 } | |
4979 | |
4980 pAllocator->FreeChunk(ptr); | |
4981 fclose(v6); | |
4982 } | |
4983 } | |
4984 } | |
4985 // 4EFA80: using guessed type int dword_4EFA80; | |
4986 | |
4987 //----- (0049F1BC) -------------------------------------------------------- | |
4988 void Render::_49F1BC(const char *a1) | |
4989 { | |
4990 Render *v2; // esi@1 | |
4991 __int16 v3; // di@1 | |
4992 int v4; // eax@4 | |
4993 char *v5; // ecx@4 | |
4994 unsigned int v6; // eax@8 | |
4995 FILE *v7; // edi@10 | |
4996 int v8; // ecx@11 | |
4997 int v9; // eax@11 | |
4998 int v10; // eax@13 | |
4999 const char *v11; // ecx@15 | |
5000 unsigned __int8 v12; // dl@15 | |
5001 signed int v13; // eax@18 | |
5002 char v14; // zf@27 | |
5003 HRESULT v15; // eax@29 | |
5004 char v16; // [sp+Ch] [bp-12Ch]@10 | |
5005 __int16 v17; // [sp+44h] [bp-F4h]@10 | |
5006 int Dst; // [sp+48h] [bp-F0h]@7 | |
5007 int v19; // [sp+58h] [bp-E0h]@8 | |
5008 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
5009 char v21; // [sp+C4h] [bp-74h]@10 | |
5010 unsigned int v22; // [sp+F4h] [bp-44h]@11 | |
5011 char *v23; // [sp+F8h] [bp-40h]@14 | |
5012 int v24; // [sp+FCh] [bp-3Ch]@11 | |
5013 int v25; // [sp+100h] [bp-38h]@4 | |
5014 FILE *File; // [sp+104h] [bp-34h]@3 | |
5015 char Str; // [sp+108h] [bp-30h]@10 | |
5016 char v28; // [sp+109h] [bp-2Fh]@10 | |
5017 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
5018 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
5019 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
5020 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
5021 __int16 v33; // [sp+110h] [bp-28h]@10 | |
5022 __int16 v34; // [sp+112h] [bp-26h]@10 | |
5023 __int16 v35; // [sp+114h] [bp-24h]@10 | |
5024 __int16 v36; // [sp+116h] [bp-22h]@10 | |
5025 char v37; // [sp+118h] [bp-20h]@10 | |
5026 char v38; // [sp+119h] [bp-1Fh]@10 | |
5027 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
5028 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
5029 void *ptr; // [sp+120h] [bp-18h]@10 | |
5030 unsigned __int16 *v42; // [sp+124h] [bp-14h]@8 | |
5031 int v43; // [sp+128h] [bp-10h]@4 | |
5032 char v44; // [sp+12Fh] [bp-9h]@25 | |
5033 char *i; // [sp+130h] [bp-8h]@10 | |
5034 unsigned __int8 v46; // [sp+137h] [bp-1h]@17 | |
5035 | |
5036 v2 = this; | |
5037 v3 = 0; | |
5038 if ( !this->pRenderD3D || this->field_40110 ) | |
5039 { | |
5040 ++dword_4EFA84; | |
5041 File = fopen(a1, "wb"); | |
5042 if ( File ) | |
5043 { | |
5044 v4 = v2->field_10; | |
5045 v5 = (char *)v2->field_14; | |
5046 v25 = v4; | |
5047 a1 = v5; | |
5048 v43 = v4; | |
5049 if ( v4 & 1 ) | |
5050 v43 = v4 + 1; | |
5051 if ( v2->pRenderD3D ) | |
5052 { | |
5053 memset(&Dst, 0, 0x7Cu); | |
5054 Dst = 124; | |
168 | 5055 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 5056 return; |
5057 v42 = v20; | |
5058 v6 = v19 >> 1; | |
5059 v3 = 0; | |
5060 } | |
5061 else | |
5062 { | |
5063 pRenderer->BeginScene(); | |
5064 v42 = pRenderer->pTargetSurface; | |
5065 v6 = pRenderer->uTargetSurfacePitch; | |
5066 } | |
5067 i = (char *)v6; | |
5068 v33 = v25 - 1; | |
5069 v31 = v3; | |
5070 v34 = (short)a1 - 1; | |
5071 v32 = v3; | |
5072 v39 = v43; | |
5073 memset(&v21, 0, 0x30u); | |
5074 memset(&v16, 0, 0x38u); | |
5075 v37 = 0; | |
5076 Str = 10; | |
5077 v17 = 0; | |
5078 v7 = File; | |
5079 v28 = 5; | |
5080 v29 = 1; | |
5081 v30 = 8; | |
5082 v35 = 75; | |
5083 v36 = 75; | |
5084 v38 = 3; | |
5085 v40 = 1; | |
5086 fwrite(&Str, 1u, 1u, File); | |
5087 fwrite(&v28, 1u, 1u, v7); | |
5088 fwrite(&v29, 1u, 1u, v7); | |
5089 fwrite(&v30, 1u, 1u, v7); | |
5090 fwrite(&v31, 2u, 1u, v7); | |
5091 fwrite(&v32, 2u, 1u, v7); | |
5092 fwrite(&v33, 2u, 1u, v7); | |
5093 fwrite(&v34, 2u, 1u, v7); | |
5094 fwrite(&v35, 2u, 1u, v7); | |
5095 fwrite(&v36, 2u, 1u, v7); | |
5096 fwrite(&v21, 0x30u, 1u, v7); | |
5097 fwrite(&v37, 1u, 1u, v7); | |
5098 fwrite(&v38, 1u, 1u, v7); | |
5099 fwrite(&v39, 2u, 1u, v7); | |
5100 fwrite(&v40, 2u, 1u, v7); | |
5101 fwrite(&v16, 0x3Au, 1u, v7); | |
5102 ptr = pAllocator->AllocNamedChunk(0, 3 * v25 + 6, 0); | |
5103 if ( (signed int)a1 > 0 ) | |
5104 { | |
5105 v8 = v43; | |
5106 File = (FILE *)a1; | |
5107 v24 = 3 * v43; | |
5108 v22 = 2 * (int)i; | |
5109 v9 = (int)v42; | |
5110 while ( 1 ) | |
5111 { | |
5112 a1 = (const char *)v9; | |
5113 v10 = 0; | |
5114 if ( v25 > 0 ) | |
5115 { | |
5116 i = (char *)ptr + v8; | |
5117 v23 = (char *)ptr + 2 * v43; | |
5118 do | |
5119 { | |
5120 *((char *)ptr + v10) = (signed int)(v2->uTargetRMask & *(short *)a1) >> (LOBYTE(v2->uTargetGBits) | |
5121 + LOBYTE(v2->uTargetBBits) | |
5122 + v2->uTargetRBits | |
5123 - 8); | |
5124 i[v10] = (signed int)(v2->uTargetGMask & *(short *)a1) >> (LOBYTE(v2->uTargetBBits) | |
5125 + LOBYTE(v2->uTargetGBits) | |
5126 - 8); | |
5127 v11 = a1; | |
5128 v12 = LOBYTE(v2->uTargetBMask); | |
5129 a1 += 2; | |
5130 v23[v10++] = ((unsigned __int8)*v11 & v12) << (8 - LOBYTE(v2->uTargetBBits)); | |
5131 } | |
5132 while ( v10 < v25 ); | |
5133 } | |
5134 for ( i = 0; (signed int)i < v24; i += BYTE3(a1) ) | |
5135 { | |
5136 BYTE3(a1) = 1; | |
5137 v46 = *((char *)ptr + (int)i); | |
5138 do | |
5139 { | |
5140 v13 = (signed int)&i[BYTE3(a1)]; | |
5141 if ( *((char *)ptr + v13) != v46 ) | |
5142 break; | |
5143 if ( !(v13 % v43) ) | |
5144 break; | |
5145 ++BYTE3(a1); | |
5146 } | |
5147 while ( BYTE3(a1) < 0x3Fu ); | |
5148 if ( (signed int)&i[BYTE3(a1)] > v24 ) | |
5149 BYTE3(a1) = 3 * v43 - (char)i; | |
5150 if ( BYTE3(a1) > 1u || v46 >= 0xC0u ) | |
5151 { | |
5152 v44 = BYTE3(a1) | 0xC0; | |
5153 fwrite(&v44, 1u, 1u, v7); | |
5154 } | |
5155 fwrite(&v46, 1u, 1u, v7); | |
5156 } | |
5157 v9 = (int)&v42[v22 / 2]; | |
5158 v14 = File == (FILE *)1; | |
5159 File = (FILE *)((char *)File - 1); | |
5160 v42 = (unsigned __int16 *)((char *)v42 + v22); | |
5161 if ( v14 ) | |
5162 break; | |
5163 v8 = v43; | |
5164 } | |
5165 } | |
5166 if ( v2->pRenderD3D ) | |
5167 { | |
5168 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
5169 } | |
5170 else | |
5171 { | |
5172 pRenderer->EndScene(); | |
5173 } | |
5174 pAllocator->FreeChunk(ptr); | |
5175 fclose(v7); | |
5176 } | |
5177 } | |
5178 } | |
5179 // 4EFA84: using guessed type int dword_4EFA84; | |
5180 | |
5181 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 5182 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
5183 { | |
0 | 5184 Render *v7; // ebx@1 |
5185 void *v8; // esi@3 | |
5186 void *v9; // esi@3 | |
5187 int v10; // ecx@4 | |
810 | 5188 unsigned short* v11; // eax@4 |
0 | 5189 int v12; // eax@6 |
5190 int v13; // eax@8 | |
5191 int v14; // ecx@8 | |
5192 signed int v15; // eax@11 | |
5193 char v16; // zf@20 | |
5194 int result; // eax@21 | |
5195 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
5196 // __int16 v19; // [sp+44h] [bp-74h]@3 | |
5197 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 5198 char *lineG; // [sp+78h] [bp-40h]@7 |
5199 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 5200 int v23; // [sp+80h] [bp-38h]@4 |
5201 int v24; // [sp+84h] [bp-34h]@4 | |
5202 int v25; // [sp+88h] [bp-30h]@4 | |
5203 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 5204 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
5205 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
5206 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
5207 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 5208 char v43; // [sp+B3h] [bp-5h]@18 |
5209 int i; // [sp+B4h] [bp-4h]@6 | |
810 | 5210 unsigned short* line_pictute_data; |
5211 byte test_byte; | |
5212 unsigned char pict_byte; | |
0 | 5213 |
5214 v7 = this; | |
810 | 5215 pitch = wight; |
5216 if ( wight & 1 ) | |
5217 pitch = wight + 1; | |
5218 Src.left = 0; | |
5219 Src.up = 0; | |
5220 Src.right = wight - 1; | |
5221 Src.bottom = heidth - 1; | |
5222 v27.pitch = pitch; | |
0 | 5223 memset(&v20, 0, 0x30u); |
5224 memset(&v18, 0, 0x38u); | |
810 | 5225 v8 = data_buff; |
5226 v27.reserved = 0; | |
0 | 5227 *(_WORD *)&v18[56] = 0; |
810 | 5228 Src.manufacturer = 10; |
5229 Src.version = 5; | |
5230 Src.encoding = 1; | |
5231 Src.bpp = 8; | |
5232 Src.hdpi = 75; | |
5233 Src.vdpi = 75; | |
5234 v27.planes = 3; | |
5235 v27.palette_info = 1; | |
5236 memcpy(data_buff, &Src, 1u); | |
0 | 5237 v8 = (char *)v8 + 1; |
810 | 5238 memcpy(v8, &Src.version, 1u); |
0 | 5239 v8 = (char *)v8 + 1; |
810 | 5240 memcpy(v8, &Src.encoding, 1u); |
0 | 5241 v8 = (char *)v8 + 1; |
810 | 5242 memcpy(v8, &Src.bpp, 1u); |
0 | 5243 v8 = (char *)v8 + 1; |
810 | 5244 memcpy(v8, &Src.left, 2u); |
0 | 5245 v8 = (char *)v8 + 2; |
810 | 5246 memcpy(v8, &Src.up, 2u); |
0 | 5247 v8 = (char *)v8 + 2; |
810 | 5248 memcpy(v8, &Src.right, 2u); |
0 | 5249 v8 = (char *)v8 + 2; |
810 | 5250 memcpy(v8, &Src.bottom, 2u); |
0 | 5251 v8 = (char *)v8 + 2; |
810 | 5252 memcpy(v8, &Src.hdpi, 2u); |
0 | 5253 v8 = (char *)v8 + 2; |
810 | 5254 memcpy(v8, &Src.vdpi, 2u); |
0 | 5255 v8 = (char *)v8 + 2; |
5256 memcpy(v8, &v20, 0x30u); | |
5257 v8 = (char *)v8 + 48; | |
810 | 5258 memcpy(v8, &v27, 1u); |
0 | 5259 v8 = (char *)v8 + 1; |
810 | 5260 memcpy(v8, &v27.planes, 1u); |
0 | 5261 v8 = (char *)v8 + 1; |
810 | 5262 memcpy(v8, &v27.pitch, 2u); |
0 | 5263 v8 = (char *)v8 + 2; |
810 | 5264 memcpy(v8, &v27.palette_info, 2u); |
0 | 5265 v8 = (char *)v8 + 2; |
5266 memcpy(v8, &v18, 0x3Au); | |
5267 v9 = (char *)v8 + 58; | |
810 | 5268 |
5269 lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0); | |
5270 if ( heidth > 0 ) | |
5271 { | |
5272 v10 = pitch; | |
5273 v25 = heidth; | |
5274 v26 = 3 * pitch; | |
5275 v23 = 2 * wight; | |
5276 v11 = picture_data; | |
5277 v24 = (int)picture_data; | |
0 | 5278 while ( 1 ) |
5279 { | |
810 | 5280 line_pictute_data = v11; |
0 | 5281 v12 = 0; |
5282 i = 0; | |
810 | 5283 if ( wight > 0 ) |
5284 { | |
5285 lineG = (char *)lineRGB + pitch; | |
5286 lineB = (char *)lineRGB + 2 * pitch; | |
0 | 5287 do |
5288 { | |
810 | 5289 lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8); |
5290 lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8); | |
5291 lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits); | |
5292 | |
5293 v12++; | |
5294 } | |
5295 while ( v12 < wight ); | |
0 | 5296 } |
5297 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
5298 { | |
810 | 5299 test_byte = 1; |
5300 pict_byte = lineRGB [i]; | |
0 | 5301 do |
5302 { | |
810 | 5303 v15 = i + test_byte; |
5304 if ( *((char *)lineRGB + v15) != pict_byte ) | |
0 | 5305 break; |
810 | 5306 if ( !(v15 % pitch) ) |
0 | 5307 break; |
810 | 5308 ++test_byte; |
5309 } | |
5310 while ( test_byte < 0x3Fu ); | |
5311 if ( i + test_byte > v26 ) | |
5312 test_byte = 3 * pitch - i; | |
5313 if ( test_byte > 1u || pict_byte >= 0xC0u ) | |
5314 { | |
5315 v43 = test_byte | 0xC0; | |
0 | 5316 memcpy(v9, &v43, 1u); |
5317 v9 = (char *)v9 + 1; | |
5318 } | |
810 | 5319 memcpy(v9, &pict_byte, 1u); |
5320 i += test_byte; | |
5321 } | |
5322 v11 +=wight ; | |
0 | 5323 v16 = v25-- == 1; |
810 | 5324 |
0 | 5325 if ( v16 ) |
5326 break; | |
810 | 5327 v10 = pitch; |
5328 } | |
5329 } | |
5330 pAllocator->FreeChunk(lineRGB); | |
5331 *(int *)packed_size = (char *)v9 - data_buff; | |
5332 | |
0 | 5333 } |
5334 | |
5335 //----- (0049F8B5) -------------------------------------------------------- | |
5336 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) | |
5337 { | |
5338 Render *v5; // esi@1 | |
5339 FILE *result; // eax@1 | |
5340 FILE *v7; // edi@4 | |
5341 int v8; // ecx@5 | |
5342 int v9; // eax@5 | |
5343 int v10; // eax@7 | |
5344 int v11; // ecx@9 | |
5345 signed int v12; // eax@12 | |
5346 char v13; // zf@21 | |
5347 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
5348 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
5349 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
5350 int v17; // [sp+70h] [bp-34h]@5 | |
5351 int v18; // [sp+74h] [bp-30h]@5 | |
5352 char *v19; // [sp+78h] [bp-2Ch]@5 | |
5353 int v20; // [sp+7Ch] [bp-28h]@5 | |
5354 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 | |
5355 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
5356 void *ptr; // [sp+98h] [bp-Ch]@4 | |
5357 int v24; // [sp+9Ch] [bp-8h]@2 | |
5358 char *i; // [sp+A0h] [bp-4h]@8 | |
5359 | |
5360 v5 = this; | |
5361 result = fopen(Filename, "wb"); | |
5362 Filename = (const char *)result; | |
5363 if ( result ) | |
5364 { | |
5365 v24 = a4; | |
5366 if ( a4 & 1 ) | |
5367 v24 = a4 + 1; | |
5368 header1.left = 0; | |
5369 header1.up = 0; | |
5370 header1.right = a4 - 1; | |
5371 header1.bottom = a5 - 1; | |
5372 header2.pitch = v24; | |
5373 memset(color_map, 0, sizeof(color_map)); | |
5374 header2.reserved = 0; | |
5375 memset(v14, 0, sizeof(v14)); | |
5376 v15 = 0; | |
5377 header1.manufacturer = 10; | |
5378 header1.version = 5; | |
5379 header1.encoding = 1; | |
5380 header1.bpp = 8; | |
5381 header1.hdpi = 75; | |
5382 header1.vdpi = 75; | |
5383 header2.planes = 3; | |
5384 header2.palette_info = 1; | |
5385 fwrite(&header1, 1u, 1u, (FILE *)Filename); | |
5386 v7 = (FILE *)Filename; | |
5387 fwrite(&header1.version, 1u, 1u, (FILE *)Filename); | |
5388 fwrite(&header1.encoding, 1u, 1u, v7); | |
5389 fwrite(&header1.bpp, 1u, 1u, v7); | |
5390 fwrite(&header1.left, 2u, 1u, v7); | |
5391 fwrite(&header1.up, 2u, 1u, v7); | |
5392 fwrite(&header1.right, 2u, 1u, v7); | |
5393 fwrite(&header1.bottom, 2u, 1u, v7); | |
5394 fwrite(&header1.hdpi, 2u, 1u, v7); | |
5395 fwrite(&header1.vdpi, 2u, 1u, v7); | |
5396 fwrite(color_map, 0x30u, 1u, v7); | |
5397 fwrite(&header2, 1u, 1u, v7); | |
5398 fwrite(&header2.planes, 1u, 1u, v7); | |
5399 fwrite(&header2.pitch, 2u, 1u, v7); | |
5400 fwrite(&header2.palette_info, 2u, 1u, v7); | |
5401 fwrite(v14, 0x3Au, 1u, v7); | |
5402 ptr = pAllocator->AllocNamedChunk(0, 3 * a4 + 6, 0); | |
5403 if ( a5 > 0 ) | |
5404 { | |
5405 v8 = v24; | |
5406 v18 = a5; | |
5407 v20 = 3 * v24; | |
5408 v17 = 2 * a4; | |
5409 v9 = (int)a3; | |
5410 v19 = a3; | |
5411 while ( 1 ) | |
5412 { | |
5413 a5 = v9; | |
5414 v10 = 0; | |
5415 if ( a4 > 0 ) | |
5416 { | |
5417 a3 = (char *)ptr + v8; | |
5418 i = (char *)ptr + 2 * v24; | |
5419 do | |
5420 { | |
5421 *((char *)ptr + v10) = (signed int)(v5->uTargetRMask & *(short *)a5) >> (LOBYTE(v5->uTargetGBits) | |
5422 + LOBYTE(v5->uTargetBBits) | |
5423 + v5->uTargetRBits | |
5424 - 8); | |
5425 a3[v10] = (signed int)(v5->uTargetGMask & *(short *)a5) >> (LOBYTE(v5->uTargetBBits) | |
5426 + LOBYTE(v5->uTargetGBits) | |
5427 - 8); | |
5428 v11 = a5; | |
5429 a5 += 2; | |
5430 i[v10++] = (v5->uTargetBMask & *(char *)v11) << (8 - LOBYTE(v5->uTargetBBits)); | |
5431 } | |
5432 while ( v10 < a4 ); | |
5433 } | |
5434 for ( i = 0; (signed int)i < v20; i += BYTE3(a5) ) | |
5435 { | |
5436 BYTE3(a5) = 1; | |
5437 BYTE3(Filename) = *((char *)ptr + (int)i); | |
5438 do | |
5439 { | |
5440 v12 = (signed int)&i[BYTE3(a5)]; | |
5441 if ( *((char *)ptr + v12) != BYTE3(Filename) ) | |
5442 break; | |
5443 if ( !(v12 % v24) ) | |
5444 break; | |
5445 ++BYTE3(a5); | |
5446 } | |
5447 while ( BYTE3(a5) < 0x3Fu ); | |
5448 if ( (signed int)&i[BYTE3(a5)] > v20 ) | |
5449 BYTE3(a5) = 3 * v24 - (char)i; | |
5450 if ( BYTE3(a5) > 1u || BYTE3(Filename) >= 0xC0u ) | |
5451 { | |
5452 BYTE3(a3) = BYTE3(a5) | 0xC0; | |
5453 fwrite((char *)&a3 + 3, 1u, 1u, v7); | |
5454 } | |
5455 fwrite((char *)&Filename + 3, 1u, 1u, v7); | |
5456 } | |
5457 v9 = (int)&v19[v17]; | |
5458 v13 = v18-- == 1; | |
5459 v19 += v17; | |
5460 if ( v13 ) | |
5461 break; | |
5462 v8 = v24; | |
5463 } | |
5464 } | |
5465 pAllocator->FreeChunk(ptr); | |
5466 result = (FILE *)fclose(v7); | |
5467 } | |
5468 return result; | |
5469 } | |
5470 | |
5471 //----- (0049FBCD) -------------------------------------------------------- | |
5472 void Render::ClearTarget(unsigned int uColor) | |
5473 { | |
5474 if (pRenderD3D) | |
5475 { | |
5476 if (field_40110) | |
5477 pRenderD3D->ClearTarget(true, uColor, false, 0.0); | |
5478 } | |
5479 else | |
5480 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
5481 } | |
5482 | |
5483 //----- (0049FC23) -------------------------------------------------------- | |
5484 void Render::Release2() | |
5485 { | |
5486 Release(); | |
5487 bWindowMode = 1; | |
5488 } | |
5489 | |
5490 //----- (0049FC37) -------------------------------------------------------- | |
5491 void Render::Present() | |
5492 { | |
5493 Render *v1; // esi@1 | |
5494 struct tagRECT Rect; // [sp+8h] [bp-28h]@11 | |
5495 RECT a4; // [sp+18h] [bp-18h]@11 | |
5496 struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
5497 | |
5498 v1 = this; | |
5499 if ( !pRenderer->pRenderD3D || this->field_40110 ) | |
5500 { | |
5501 this->pBeforePresentFunction(); | |
5502 if ( v1->pRenderD3D ) | |
5503 { | |
5504 if ( v1->field_40110 ) | |
5505 { | |
5506 pRenderD3D->Present(false); | |
5507 } | |
5508 } | |
5509 else | |
5510 { | |
5511 if ( v1->bWindowMode ) | |
5512 { | |
5513 RestoreFrontBuffer(); | |
5514 GetClientRect(v1->hWnd, &Rect); | |
5515 Point.y = 0; | |
5516 Point.x = 0; | |
5517 ClientToScreen(v1->hWnd, &Point); | |
5518 OffsetRect(&Rect, Point.x, Point.y); | |
5519 a4.top = 0; | |
5520 a4.bottom = 480; | |
5521 a4.left = 0; | |
5522 a4.right = 640; | |
5523 PresentRect(&Rect, &a4); | |
5524 } | |
5525 else | |
5526 { | |
5527 RestoreFrontBuffer(); | |
5528 a4.top = 0; | |
5529 a4.bottom = 480; | |
5530 a4.left = 0; | |
5531 a4.right = 640; | |
5532 BltBackToFontFast(0, 0, &a4); | |
5533 } | |
5534 } | |
5535 } | |
5536 } | |
5537 | |
5538 //----- (0049FD3A) -------------------------------------------------------- | |
5539 void Render::_49FD3A() | |
5540 { | |
5541 Render *v2; // esi@1 | |
5542 IDirectDrawSurface4 *v3; // eax@6 | |
5543 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
5544 RECT v5; // [sp+8h] [bp-10h]@6 | |
5545 | |
5546 auto a1 = this; | |
5547 v2 = a1; | |
5548 if ( a1->pRenderD3D ) | |
5549 { | |
5550 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
5551 pFrontBuffer4->Restore(); | |
5552 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
5553 pBackBuffer4->Restore(); | |
5554 v3 = v2->pBackBuffer4; | |
5555 v4 = v2->pFrontBuffer4; | |
5556 v5.top = 0; | |
5557 v5.bottom = 480; | |
5558 v5.left = 0; | |
5559 v5.right = 640; | |
5560 v3->BltFast(0, 0, v4, &v5, 16u); | |
5561 } | |
5562 } | |
5563 | |
5564 //----- (0049FDBF) -------------------------------------------------------- | |
5565 void Render::CreateZBuffer() | |
5566 { | |
5567 if (!pDefaultZBuffer) | |
5568 { | |
5569 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
5570 pDefaultZBuffer = pActiveZBuffer = (int *)pAllocator->AllocNamedChunk(0, 0x12C000, "Z Buf."); | |
871 | 5571 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
0 | 5572 } |
5573 } | |
5574 | |
5575 //----- (0049FE05) -------------------------------------------------------- | |
5576 void Render::Release() | |
5577 { | |
5578 Render *v1; // esi@1 | |
5579 RenderD3D *v2; // ecx@1 | |
5580 char v3; // zf@4 | |
5581 void *v4; // ebx@6 | |
5582 IDirectDraw *v5; // eax@10 | |
5583 IDirectDrawSurface2 *v6; // eax@11 | |
5584 IDirectDrawSurface2 *v7; // eax@13 | |
5585 IDirectDrawSurface2 *v8; // eax@15 | |
5586 IDirectDraw2 *v9; // eax@17 | |
5587 IDirectDraw4 *v10; // eax@19 | |
5588 IDirectDrawSurface4 *v11; // eax@20 | |
5589 IDirectDrawSurface4 *v12; // eax@22 | |
5590 IDirectDrawSurface4 *v13; // eax@24 | |
5591 IDirectDraw4 *v14; // eax@26 | |
5592 unsigned __int16 **v15; // ebx@28 | |
5593 void **v16; // esi@29 | |
5594 | |
5595 v1 = this; | |
5596 v2 = this->pRenderD3D; | |
5597 if ( v2 ) | |
5598 { | |
5599 if ( v1->field_40110 ) | |
5600 { | |
5601 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
5602 pRenderD3D->Present(0); | |
5603 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
5604 } | |
5605 v1->pColorKeySurface4 = 0; | |
5606 v1->pBackBuffer4 = 0; | |
5607 v3 = v1->pTargetSurface == 0; | |
5608 v1->pFrontBuffer4 = 0; | |
5609 v1->pDirectDraw4 = 0; | |
5610 if ( !v3 ) | |
5611 { | |
5612 free(v1->ptr_400E8); | |
5613 v1->pTargetSurface = 0; | |
5614 v1->ptr_400E8 = 0; | |
5615 } | |
5616 v4 = v1->pRenderD3D; | |
5617 if ( v4 ) | |
5618 { | |
5619 pRenderD3D->Release(); | |
5620 free(v4); | |
5621 } | |
5622 v1->pRenderD3D = 0; | |
5623 } | |
5624 else | |
5625 { | |
5626 if ( bWinNT4_0 == 1 ) | |
5627 { | |
5628 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
5629 if ( !v5 ) | |
5630 return; | |
5631 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
5632 v1->pDirectDraw2->FlipToGDISurface(); | |
5633 v6 = v1->pSomeSurface2; | |
5634 if ( v6 ) | |
5635 { | |
5636 v6->Release(); | |
5637 v1->pSomeSurface2 = 0; | |
5638 } | |
5639 v7 = v1->pBackBuffer2; | |
5640 if ( v7 ) | |
5641 { | |
5642 v7->Release(); | |
5643 v1->pBackBuffer2 = 0; | |
5644 } | |
5645 v8 = v1->pFrontBuffer2; | |
5646 if ( v8 ) | |
5647 { | |
5648 v8->Release(); | |
5649 v1->pFrontBuffer2 = 0; | |
5650 } | |
5651 v9 = v1->pDirectDraw2; | |
5652 if ( v9 ) | |
5653 { | |
5654 v9->Release(); | |
5655 v1->pDirectDraw2 = 0; | |
5656 } | |
5657 } | |
5658 else | |
5659 { | |
5660 v10 = v1->pDirectDraw4; | |
5661 if ( !v10 ) | |
5662 return; | |
5663 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
5664 v1->pDirectDraw4->FlipToGDISurface(); | |
5665 v11 = v1->pColorKeySurface4; | |
5666 if ( v11 ) | |
5667 { | |
5668 v11->Release(); | |
5669 v1->pColorKeySurface4 = 0; | |
5670 } | |
5671 v12 = v1->pBackBuffer4; | |
5672 if ( v12 ) | |
5673 { | |
5674 v12->Release(); | |
5675 v1->pBackBuffer4 = 0; | |
5676 } | |
5677 v13 = v1->pFrontBuffer4; | |
5678 if ( v13 ) | |
5679 { | |
5680 v13->Release(); | |
5681 v1->pFrontBuffer4 = 0; | |
5682 } | |
5683 v14 = v1->pDirectDraw4; | |
5684 if ( v14 ) | |
5685 { | |
5686 v14->Release(); | |
5687 v1->pDirectDraw4 = 0; | |
5688 } | |
5689 } | |
5690 v15 = &v1->pTargetSurface; | |
5691 if ( v1->pTargetSurface ) | |
5692 { | |
5693 v16 = (void **)&v1->ptr_400E8; | |
5694 free(*v16); | |
5695 *v15 = 0; | |
5696 *v16 = 0; | |
5697 } | |
5698 } | |
5699 } | |
5700 | |
5701 //----- (0049FFD7) -------------------------------------------------------- | |
5702 void Render::CreateSomeTexture() | |
5703 { | |
5704 pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); | |
5705 } | |
5706 | |
5707 //----- (0049FFFB) -------------------------------------------------------- | |
5708 bool Render::InitializeFullscreen(HWND hWnd) | |
5709 { | |
5710 //Render *v2; // esi@1 | |
5711 //HWND v3; // ebx@1 | |
5712 //void *v4; // eax@2 | |
5713 //RenderD3D *v5; // eax@3 | |
5714 unsigned int v6; // edx@5 | |
5715 RenderD3D__DevInfo *v7; // ecx@5 | |
5716 bool v8; // eax@6 | |
5717 RenderD3D *v9; // ecx@13 | |
5718 unsigned int v10; // eax@13 | |
5719 RenderD3D *v11; // eax@25 | |
5720 HRESULT v12; // eax@25 | |
5721 int v13; // ecx@25 | |
5722 int v14; // eax@27 | |
5723 signed int v15; // ebx@31 | |
5724 bool v16; // eax@35 | |
5725 char v17; // zf@35 | |
5726 IDirectDraw4 *v18; // eax@38 | |
5727 HRESULT v19; // eax@38 | |
5728 int *v20; // eax@39 | |
5729 int *v22; // eax@42 | |
5730 int v23; // ecx@42 | |
5731 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
5732 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
5733 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
5734 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
5735 void *v28; // [sp+2FCh] [bp-10h]@2 | |
5736 int v29; // [sp+308h] [bp-4h]@2 | |
5737 | |
5738 //v2 = this; | |
5739 this->field_40110 = 0; | |
5740 this->pColorKeySurface4 = 0; | |
5741 this->pBackBuffer4 = 0; | |
5742 this->pFrontBuffer4 = 0; | |
5743 this->pDirectDraw4 = 0; | |
5744 this->bColorKeySupported = 0; | |
5745 Release(); | |
5746 //v3 = hWnd; | |
5747 this->hWnd = hWnd; | |
5748 CreateZBuffer(); | |
5749 if ( bUserDirect3D ) | |
5750 { | |
5751 pRenderD3D = new RenderD3D; | |
5752 v28 = pRenderD3D; | |
5753 v6 = uDesiredDirect3DDevice; | |
5754 v29 = -1; | |
5755 v7 = pRenderD3D->pAvailableDevices; | |
5756 if ( v7[v6].bIsDeviceCompatible ) | |
5757 { | |
5758 v8 = pRenderD3D->CreateDevice(v6, 0, hWnd); | |
5759 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
5760 } | |
5761 else | |
5762 { | |
5763 if ( v7[1].bIsDeviceCompatible ) | |
5764 { | |
5765 v8 = pRenderD3D->CreateDevice(1u, 0, hWnd); | |
5766 uAcquiredDirect3DDevice = 1; | |
5767 } | |
5768 else | |
5769 { | |
5770 if ( !v7->bIsDeviceCompatible ) | |
5771 Abortf("There aren't any D3D devices to create."); | |
5772 v8 = pRenderD3D->CreateDevice(0, 0, hWnd); | |
5773 uAcquiredDirect3DDevice = 0; | |
5774 } | |
5775 } | |
5776 if ( !v8 ) | |
5777 Abortf("D3Drend->Init failed."); | |
5778 v9 = pRenderD3D; | |
5779 pBackBuffer4 = v9->pBackBuffer; | |
5780 pFrontBuffer4 = v9->pFrontBuffer; | |
5781 pDirectDraw4 = v9->pHost; | |
5782 v10 = pRenderD3D->GetDeviceCaps(); | |
5783 if ( v10 & 1 ) | |
5784 { | |
5785 if ( pRenderD3D ) | |
5786 { | |
5787 pRenderD3D->Release(); | |
5788 delete pRenderD3D; | |
5789 } | |
5790 pRenderD3D = 0; | |
5791 pBackBuffer4 = 0; | |
5792 pFrontBuffer4 = 0; | |
5793 pDirectDraw4 = 0; | |
5794 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
5795 } | |
5796 if ( v10 & 0x3E ) | |
5797 { | |
5798 if ( pRenderD3D ) | |
5799 { | |
5800 pRenderD3D->Release(); | |
5801 delete pRenderD3D; | |
5802 } | |
5803 pColorKeySurface4 = 0; | |
5804 pRenderD3D = 0; | |
5805 pBackBuffer4 = 0; | |
5806 pFrontBuffer4 = 0; | |
5807 pDirectDraw4 = 0; | |
5808 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
5809 } | |
5810 if ( (v10 & 0x80u) != 0 ) | |
5811 { | |
5812 if ( pRenderD3D ) | |
5813 { | |
5814 pRenderD3D->Release(); | |
5815 delete pRenderD3D; | |
5816 } | |
5817 pRenderD3D = 0; | |
5818 pBackBuffer4 = 0; | |
5819 pFrontBuffer4 = 0; | |
5820 pDirectDraw4 = 0; | |
5821 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
5822 } | |
5823 LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; | |
5824 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
5825 memset(&halCaps, 0, 0xFCu); | |
5826 halCaps.dwSize = 252; | |
5827 memset(&refCaps, 0, 0xFCu); | |
5828 v11 = pRenderD3D; | |
5829 refCaps.dwSize = 252; | |
5830 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
5831 v13 = halCaps.dwMinTextureWidth; | |
5832 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
5833 v13 = halCaps.dwMinTextureHeight; | |
5834 v14 = halCaps.dwMaxTextureWidth; | |
5835 uMinDeviceTextureDim = v13; | |
5836 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
5837 v14 = halCaps.dwMaxTextureHeight; | |
5838 uMaxDeviceTextureDim = v14; | |
5839 if ( (unsigned int)v13 < 4 ) | |
5840 uMinDeviceTextureDim = 4; | |
5841 CreateSomeTexture(); | |
5842 v15 = 1; | |
5843 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
5844 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
5845 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
5846 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); | |
5847 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
5848 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
5849 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
5850 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
5851 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
5852 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
5853 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
5854 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
5855 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
5856 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
5857 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
5858 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
5859 } | |
5860 else | |
5861 { | |
5862 CreateDirectDraw(); | |
5863 SetDirectDrawCooperationMode(hWnd, 1); | |
5864 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
5865 CreateDirectDrawPrimarySurface(); | |
5866 v15 = 1; | |
5867 } | |
5868 ddpfPrimareSuface.dwSize = 32; | |
5869 GetTargetPixelFormat(&ddpfPrimareSuface); | |
5870 ParseTargetPixelFormat(); | |
5871 _49EBF1(); | |
5872 if ( pRenderD3D ) | |
5873 { | |
5874 v16 = IsColorKeySupported(pDirectDraw4); | |
5875 v17 = uAcquiredDirect3DDevice == v15; | |
5876 bColorKeySupported = v16; | |
5877 if ( !v17 ) | |
5878 bColorKeySupported = 0; | |
5879 if ( bColorKeySupported ) | |
5880 { | |
5881 memset(&ddsd2, 0, 0x7Cu); | |
5882 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
5883 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
5884 v18 = pDirectDraw4; | |
5885 ddsd2.dwSize = 124; | |
5886 ddsd2.dwFlags = 65543; | |
5887 ddsd2.ddsCaps.dwCaps = 2112; | |
5888 ddsd2.dwWidth = 640; | |
5889 ddsd2.dwHeight = 480; | |
5890 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
5891 pBeforePresentFunction = Present_ColorKey; | |
5892 } | |
5893 else | |
5894 { | |
5895 pTargetSurface = 0; | |
5896 ptr_400E8 = 0; | |
5897 v20 = (int *)operator new(0x96020u); | |
5898 ptr_400E8 = v20; | |
5899 if ( !v20 | |
5900 || (memset(&pDesc, 0, 0x7Cu), | |
5901 pDesc.dwSize = 124, | |
5902 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
5903 return 0; | |
5904 pBackBuffer4->Unlock(0); | |
5905 v22 = ptr_400E8 + 4; | |
5906 v23 = (unsigned int)pDesc.lpSurface & 7; | |
5907 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
5908 uTargetSurfacePitch = 640; | |
5909 pBeforePresentFunction = Present_NoColorKey; | |
5910 v15 = 1; | |
5911 pTargetSurface = (unsigned __int16 *)((char *)v22 + 2 * v23); | |
5912 } | |
5913 field_40110 = v15; | |
5914 } | |
5915 else | |
5916 { | |
5917 pBeforePresentFunction = 0;//nullsub_1; | |
5918 } | |
5919 bWindowMode = 0; | |
5920 pParty->uFlags |= 2u; | |
5921 LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; | |
5922 pViewport->_4C02F8(36044); | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
5923 return v15 != 0; |
0 | 5924 } |
5925 // 6BE3A0: using guessed type float flt_6BE3A0; | |
5926 | |
5927 //----- (004A05F3) -------------------------------------------------------- | |
5928 bool Render::SwitchToWindow(HWND hWnd) | |
5929 { | |
5930 //Render *v2; // esi@1 | |
5931 //void *v3; // eax@2 | |
5932 //RenderD3D *v4; // eax@3 | |
5933 //unsigned int v5; // edx@5 | |
5934 //RenderD3D__DevInfo *v6; // ecx@5 | |
5935 bool v7; // eax@7 | |
5936 //RenderD3D *v8; // ecx@12 | |
5937 unsigned int v9; // eax@12 | |
5938 RenderD3D *v10; // eax@24 | |
5939 HRESULT v11; // eax@24 | |
5940 int v12; // eax@24 | |
5941 int v13; // eax@26 | |
5942 bool v14; // eax@32 | |
5943 char v15; // zf@32 | |
5944 IDirectDraw4 *v16; // eax@35 | |
5945 HRESULT v17; // eax@35 | |
5946 int *v18; // eax@36 | |
5947 int *v19; // edx@38 | |
5948 int v20; // eax@38 | |
5949 unsigned int v21; // ecx@38 | |
5950 int v22; // eax@41 | |
5951 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
5952 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
5953 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
5954 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
5955 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
5956 int v29; // [sp+308h] [bp-4h]@2 | |
5957 | |
5958 pParty->uFlags |= 2u; | |
5959 //v2 = this; | |
5960 flt_6BE3A0 = 0.55000001f; | |
5961 pViewport->_4C02F8(36044); | |
5962 field_40110 = 0; | |
5963 Release(); | |
5964 pColorKeySurface4 = 0; | |
5965 pBackBuffer4 = 0; | |
5966 pFrontBuffer4 = 0; | |
5967 pDirectDraw4 = 0; | |
5968 bColorKeySupported = 0; | |
5969 CreateZBuffer(); | |
5970 if ( bUserDirect3D ) | |
5971 { | |
5972 /*v3 = operator new(0x148u); | |
5973 thisa = (RenderD3D *)v3; | |
5974 v29 = 0; | |
5975 if ( v3 ) | |
5976 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
5977 else | |
5978 v4 = 0;*/ | |
5979 pRenderD3D = new RenderD3D; | |
5980 //v4 = pRenderD3D; | |
5981 //v5 = uDesiredDirect3DDevice; | |
5982 v29 = -1; | |
5983 //v6 = pRenderD3D->pAvailableDevices; | |
5984 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
5985 uDesiredDirect3DDevice != 1 ) | |
5986 { | |
5987 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, hWnd); | |
5988 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
5989 } | |
5990 else | |
5991 { | |
5992 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
5993 Abortf("There aren't any D3D devices to init."); | |
5994 v7 = pRenderD3D->CreateDevice(0, 1, hWnd); | |
5995 uAcquiredDirect3DDevice = 0; | |
5996 } | |
5997 if ( !v7 ) | |
5998 Abortf("D3Drend->Init failed."); | |
5999 | |
6000 //v8 = pRenderD3D; | |
6001 pColorKeySurface4 = 0; | |
6002 pBackBuffer4 = pRenderD3D->pBackBuffer; | |
6003 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
6004 pDirectDraw4 = pRenderD3D->pHost; | |
6005 v9 = pRenderD3D->GetDeviceCaps(); | |
6006 if ( v9 & 1 ) | |
6007 { | |
6008 if (pRenderD3D) | |
6009 { | |
6010 pRenderD3D->Release(); | |
6011 delete pRenderD3D; | |
6012 } | |
6013 pRenderD3D = 0; | |
6014 pBackBuffer4 = 0; | |
6015 pFrontBuffer4 = 0; | |
6016 pDirectDraw4 = 0; | |
6017 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
6018 } | |
6019 if ( v9 & 0x3E ) | |
6020 { | |
6021 if (pRenderD3D) | |
6022 { | |
6023 pRenderD3D->Release(); | |
6024 delete pRenderD3D; | |
6025 } | |
6026 pColorKeySurface4 = 0; | |
6027 pRenderD3D = 0; | |
6028 pBackBuffer4 = 0; | |
6029 pFrontBuffer4 = 0; | |
6030 pDirectDraw4 = 0; | |
6031 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
6032 } | |
6033 if ( (v9 & 0x80u) != 0 ) | |
6034 { | |
6035 if (pRenderD3D) | |
6036 { | |
6037 pRenderD3D->Release(); | |
6038 delete pRenderD3D; | |
6039 } | |
6040 pRenderD3D = 0; | |
6041 pBackBuffer4 = 0; | |
6042 pFrontBuffer4 = 0; | |
6043 pDirectDraw4 = 0; | |
6044 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
6045 } | |
6046 LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; | |
6047 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
6048 memset(&halCaps, 0, 0xFCu); | |
6049 halCaps.dwSize = 252; | |
6050 memset(&refCaps, 0, 0xFCu); | |
6051 //v10 = v2->pRenderD3D; | |
6052 refCaps.dwSize = 252; | |
6053 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
6054 v12 = halCaps.dwMinTextureWidth; | |
6055 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
6056 v12 = halCaps.dwMinTextureHeight; | |
6057 uMinDeviceTextureDim = v12; | |
6058 v13 = halCaps.dwMaxTextureWidth; | |
6059 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
6060 v13 = halCaps.dwMaxTextureHeight; | |
6061 uMaxDeviceTextureDim = v13; | |
6062 CreateSomeTexture(); | |
6063 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
6064 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
6065 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
6066 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
6067 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
6068 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
6069 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
6070 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
6071 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
6072 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
6073 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
6074 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
6075 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
6076 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
6077 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
6078 } | |
6079 else | |
6080 { | |
6081 CreateDirectDraw(); | |
6082 SetDirectDrawCooperationMode(hWnd, 0); | |
6083 field_4004C = 1; | |
6084 CreateFrontBuffer(); | |
6085 CreateClipper(hWnd); | |
6086 CreateBackBuffer(); | |
6087 field_40030 = 0; | |
6088 field_18_locked_pitch = 0; | |
6089 } | |
6090 ddpfPrimareSuface.dwSize = 32; | |
6091 GetTargetPixelFormat(&ddpfPrimareSuface); | |
6092 ParseTargetPixelFormat(); | |
6093 _49EBF1(); | |
6094 if ( !pRenderD3D ) | |
6095 { | |
6096 pBeforePresentFunction = 0;//nullsub_1; | |
6097 goto LABEL_47; | |
6098 } | |
6099 v14 = IsColorKeySupported(pDirectDraw4); | |
6100 v15 = uAcquiredDirect3DDevice == 1; | |
6101 bColorKeySupported = v14; | |
6102 if ( !v15 ) | |
6103 bColorKeySupported = 0; | |
6104 if ( bColorKeySupported ) | |
6105 { | |
6106 memset(&ddsd2, 0, 0x7Cu); | |
6107 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
6108 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
6109 v16 = pDirectDraw4; | |
6110 ddsd2.dwSize = 124; | |
6111 ddsd2.dwFlags = 65543; | |
6112 ddsd2.ddsCaps.dwCaps = 2112; | |
6113 ddsd2.dwWidth = 640; | |
6114 ddsd2.dwHeight = 480; | |
6115 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
6116 pBeforePresentFunction = Present_ColorKey; | |
6117 LABEL_45: | |
6118 field_40110 = 1; | |
6119 LABEL_47: | |
6120 bWindowMode = 1; | |
6121 hWnd = hWnd; | |
6122 return 0; | |
6123 } | |
6124 pTargetSurface = 0; | |
6125 ptr_400E8 = 0; | |
6126 v18 = (int *)new char[0x96020]; | |
6127 memset(v18, -1, 0x96020); | |
6128 ptr_400E8 = v18; | |
6129 if ( v18 ) | |
6130 { | |
6131 memset(&pDesc, 0, 0x7Cu); | |
6132 pDesc.dwSize = 124; | |
168 | 6133 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT) ) |
0 | 6134 { |
6135 pRenderer->pBackBuffer4->Unlock(0); | |
6136 v19 = ptr_400E8; | |
6137 v20 = (unsigned int)pDesc.lpSurface & 7; | |
6138 v21 = (unsigned int)ptr_400E8 & 7; | |
6139 if ( v21 == v20 ) | |
6140 { | |
6141 pTargetSurface = (unsigned __int16 *)v19; | |
6142 } | |
6143 else | |
6144 { | |
6145 if ( (signed int)v21 >= v20 ) | |
6146 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
6147 else | |
6148 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
6149 pTargetSurface = (unsigned __int16 *)v22; | |
6150 } | |
6151 uTargetSurfacePitch = 640; | |
6152 pBeforePresentFunction = Present_NoColorKey; | |
6153 goto LABEL_45; | |
6154 } | |
6155 } | |
6156 return 0; | |
6157 } | |
6158 | |
6159 //----- (004A0BEE) -------------------------------------------------------- | |
709 | 6160 char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor) |
0 | 6161 { |
6162 int v6; // edi@1 | |
6163 int v7; // edx@5 | |
6164 unsigned int v8; // ebx@5 | |
6165 int v9; // eax@7 | |
6166 unsigned int v10; // ecx@9 | |
6167 unsigned int v11; // esi@13 | |
6168 int v12; // eax@17 | |
6169 int v13; // eax@21 | |
6170 Render *v14; // edi@21 | |
6171 int v15; // eax@25 | |
6172 int v16; // eax@27 | |
6173 signed int v17; // eax@28 | |
6174 signed int v18; // edi@30 | |
6175 signed __int64 v19; // qax@41 | |
6176 int v20; // edi@41 | |
6177 unsigned int v21; // edi@46 | |
6178 int v22; // esi@47 | |
6179 int v23; // ebx@47 | |
6180 signed int v24; // edx@50 | |
6181 signed int v25; // esi@52 | |
6182 unsigned __int16 *v26; // ecx@52 | |
6183 int v27; // ebx@54 | |
6184 int v28; // edi@55 | |
6185 int v29; // edx@55 | |
6186 int v30; // ebx@60 | |
6187 int v31; // edx@61 | |
6188 int v32; // edi@61 | |
6189 int v34; // [sp+Ch] [bp-10h]@3 | |
6190 Render *v35; // [sp+10h] [bp-Ch]@1 | |
6191 __int64 v36; // [sp+14h] [bp-8h]@1 | |
6192 signed int v37; // [sp+18h] [bp-4h]@28 | |
6193 unsigned int uXa; // [sp+24h] [bp+8h]@49 | |
6194 unsigned int uYa; // [sp+28h] [bp+Ch]@28 | |
6195 int uYb; // [sp+28h] [bp+Ch]@47 | |
6196 int uZa; // [sp+2Ch] [bp+10h]@38 | |
6197 | |
6198 v36 = 0i64; | |
709 | 6199 v6 = this->raster_clip_x; |
0 | 6200 v35 = this; |
6201 if ( (signed int)uX < v6 ) | |
6202 HIDWORD(v36) = 8; | |
709 | 6203 v34 = this->raster_clip_z; |
6204 if ( (signed int)uX > this->raster_clip_z ) | |
0 | 6205 HIDWORD(v36) |= 4u; |
709 | 6206 v7 = this->raster_clip_y; |
0 | 6207 v8 = uY; |
6208 if ( (signed int)uY < v7 ) | |
6209 HIDWORD(v36) |= 2u; | |
709 | 6210 v9 = this->raster_clip_w; |
0 | 6211 if ( (signed int)uY > v9 ) |
6212 HIDWORD(v36) |= 1u; | |
6213 v10 = uZ; | |
6214 if ( (signed int)uZ < v6 ) | |
6215 LODWORD(v36) = 8; | |
6216 if ( (signed int)uZ > v34 ) | |
6217 LODWORD(v36) = v36 | 4; | |
6218 v11 = uW; | |
6219 if ( (signed int)uW < v7 ) | |
6220 LODWORD(v36) = v36 | 2; | |
6221 if ( (signed int)uW > v9 ) | |
6222 LODWORD(v36) = v36 | 1; | |
6223 LOBYTE(v12) = v36; | |
6224 if ( (unsigned int)v36 & HIDWORD(v36) ) | |
6225 return v12; | |
6226 if ( !v36 ) | |
6227 { | |
6228 LABEL_46: | |
6229 v21 = pRenderer->uTargetSurfacePitch; | |
6230 if ( pRenderer->uTargetSurfacePitch ) | |
6231 { | |
6232 v12 = uX + v8 * pRenderer->uTargetSurfacePitch; | |
6233 v22 = v11 - v8; | |
6234 v23 = v22; | |
6235 uYb = v22; | |
6236 if ( v22 < 0 ) | |
6237 { | |
6238 v23 = -v22; | |
6239 uYb = -v22; | |
6240 v21 = -pRenderer->uTargetSurfacePitch; | |
6241 } | |
6242 uXa = v10 - uX; | |
6243 if ( (uXa & 0x80000000u) == 0 ) | |
6244 { | |
6245 v24 = 1; | |
6246 } | |
6247 else | |
6248 { | |
6249 uXa = -uXa; | |
6250 v24 = -1; | |
6251 } | |
6252 v25 = 0; | |
6253 v26 = v35->pTargetSurface; | |
6254 if ( v26 ) | |
6255 { | |
6256 if ( (signed int)uXa <= v23 ) | |
6257 { | |
6258 v30 = v23 + 1; | |
6259 if ( v30 > 0 ) | |
6260 { | |
6261 v31 = 2 * v24; | |
6262 v32 = 2 * v21; | |
6263 v12 = (int)&v26[v12]; | |
6264 do | |
6265 { | |
6266 v25 += uXa; | |
6267 *(short *)v12 = uColor; | |
6268 v12 += v32; | |
6269 if ( v25 > 0 ) | |
6270 { | |
6271 v25 -= uYb; | |
6272 v12 += v31; | |
6273 } | |
6274 --v30; | |
6275 } | |
6276 while ( v30 ); | |
6277 } | |
6278 } | |
6279 else | |
6280 { | |
6281 v27 = uXa + 1; | |
6282 if ( (signed int)(uXa + 1) > 0 ) | |
6283 { | |
6284 v28 = 2 * v21; | |
6285 v29 = 2 * v24; | |
6286 v12 = (int)&v26[v12]; | |
6287 do | |
6288 { | |
6289 v25 += uYb; | |
6290 *(short *)v12 = uColor; | |
6291 v12 += v29; | |
6292 if ( v25 > (signed int)uXa ) | |
6293 { | |
6294 v25 -= uXa; | |
6295 v12 += v28; | |
6296 } | |
6297 --v27; | |
6298 } | |
6299 while ( v27 ); | |
6300 } | |
6301 } | |
6302 } | |
6303 } | |
6304 return v12; | |
6305 } | |
6306 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 ) | |
6307 { | |
6308 if ( BYTE4(v36) & 8 ) | |
6309 { | |
6310 v13 = (signed int)((uW - uY) * (v6 - uX)) / (signed int)(uZ - uX); | |
6311 v14 = v35; | |
6312 v8 = v13 + uY; | |
709 | 6313 uX = v35->raster_clip_x; |
0 | 6314 goto LABEL_24; |
6315 } | |
6316 v10 = v6; | |
6317 v11 = (signed int)((uY - uW) * (v6 - uZ)) / (signed int)(uX - uZ) + uW; | |
6318 } | |
6319 v14 = v35; | |
6320 LABEL_24: | |
6321 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) | |
6322 { | |
709 | 6323 v15 = v14->raster_clip_z; |
0 | 6324 if ( BYTE4(v36) & 4 ) |
6325 { | |
6326 v14 = v35; | |
6327 v8 += (signed int)((v11 - v8) * (v15 - uX)) / (signed int)(v10 - uX); | |
709 | 6328 uX = v35->raster_clip_z; |
0 | 6329 } |
6330 else | |
6331 { | |
6332 v16 = (signed int)((v8 - v11) * (v15 - v10)) / (signed int)(uX - v10); | |
709 | 6333 v10 = v14->raster_clip_z; |
0 | 6334 v11 += v16; |
6335 } | |
6336 } | |
709 | 6337 v17 = v14->raster_clip_y; |
0 | 6338 v37 = 0; |
709 | 6339 uYa = v14->raster_clip_y; |
0 | 6340 if ( (signed int)v8 < v17 ) |
6341 v37 = 2; | |
709 | 6342 v18 = v14->raster_clip_w; |
0 | 6343 if ( (signed int)v8 > v18 ) |
6344 v37 |= 1u; | |
6345 if ( (signed int)v11 >= v17 ) | |
6346 v12 = 0; | |
6347 else | |
6348 v12 = 2; | |
6349 if ( (signed int)v11 > v18 ) | |
6350 LOBYTE(v12) = v12 | 1; | |
6351 if ( !(v12 & v37) ) | |
6352 { | |
6353 v12 ^= v37; | |
6354 uZa = v12; | |
6355 if ( v12 & 2 ) | |
6356 { | |
6357 if ( v37 & 2 ) | |
6358 { | |
6359 uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8); | |
6360 LOBYTE(v12) = (char)v35; | |
709 | 6361 v8 = v35->raster_clip_y; |
0 | 6362 } |
6363 else | |
6364 { | |
6365 v19 = (signed int)((uX - v10) * (uYa - v11)); | |
6366 v20 = v8 - v11; | |
6367 v11 = uYa; | |
6368 v12 = v19 / v20; | |
6369 v10 += v12; | |
6370 } | |
6371 } | |
6372 if ( uZa & 1 ) | |
6373 { | |
6374 if ( v37 & 1 ) | |
6375 { | |
709 | 6376 uX += (signed int)((v10 - uX) * (v35->raster_clip_w - v8)) / (signed int)(v11 - v8); |
0 | 6377 LOBYTE(v12) = (char)v35; |
709 | 6378 v8 = v35->raster_clip_w; |
0 | 6379 } |
6380 else | |
6381 { | |
709 | 6382 v12 = (signed int)((uX - v10) * (v35->raster_clip_w - v11)) / (signed int)(v8 - v11); |
6383 v11 = v35->raster_clip_w; | |
0 | 6384 v10 += v12; |
6385 } | |
6386 } | |
6387 goto LABEL_46; | |
6388 } | |
6389 return v12; | |
6390 } | |
6391 | |
6392 //----- (004A0E80) -------------------------------------------------------- | |
6393 void Render::ClearZBuffer(int a2, int a3) | |
6394 { | |
6395 memset32(this->pActiveZBuffer, -65536, 0x4B000u); | |
6396 } | |
6397 | |
6398 //----- (004A0E97) -------------------------------------------------------- | |
709 | 6399 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
6400 { | |
6401 this->raster_clip_x = uX; | |
6402 this->raster_clip_y = uY; | |
6403 this->raster_clip_z = uZ; | |
6404 this->raster_clip_w = uW; | |
0 | 6405 } |
6406 | |
6407 //----- (004A0EB6) -------------------------------------------------------- | |
6408 void Render::ParseTargetPixelFormat() | |
6409 { | |
6410 Render *v1; // eax@1 | |
6411 signed int v2; // ecx@1 | |
6412 DWORD uRedMask; // edx@1 | |
6413 unsigned int uGreenMask; // esi@5 | |
6414 signed int v5; // ecx@5 | |
6415 unsigned int uBlueMask; // edx@9 | |
6416 signed int v7; // ecx@9 | |
6417 unsigned int v8; // ecx@13 | |
6418 | |
6419 v1 = this; | |
6420 v2 = 0; | |
6421 uRedMask = v1->ddpfPrimareSuface.dwRBitMask; | |
6422 v1->uTargetBBits = 0; | |
6423 v1->uTargetGBits = 0; | |
6424 v1->uTargetRBits = 0; | |
6425 do | |
6426 { | |
6427 if ( (1 << v2) & uRedMask ) | |
6428 ++v1->uTargetRBits; | |
6429 ++v2; | |
6430 } | |
6431 while ( v2 < 16 ); | |
6432 uGreenMask = v1->ddpfPrimareSuface.dwGBitMask; | |
6433 v5 = 0; | |
6434 do | |
6435 { | |
6436 if ( (1 << v5) & uGreenMask ) | |
6437 ++v1->uTargetGBits; | |
6438 ++v5; | |
6439 } | |
6440 while ( v5 < 16 ); | |
6441 uBlueMask = v1->ddpfPrimareSuface.dwBBitMask; | |
6442 v7 = 0; | |
6443 do | |
6444 { | |
6445 if ( (1 << v7) & uBlueMask ) | |
6446 ++v1->uTargetBBits; | |
6447 ++v7; | |
6448 } | |
6449 while ( v7 < 16 ); | |
6450 v8 = v1->ddpfPrimareSuface.dwRBitMask; | |
6451 v1->uTargetGMask = uGreenMask; | |
6452 v1->uTargetRMask = v8; | |
6453 v1->uTargetBMask = uBlueMask; | |
6454 } | |
6455 | |
6456 //----- (004A0F40) -------------------------------------------------------- | |
6457 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
6458 { | |
6459 IDirectDrawSurface4 *v4; // esi@1 | |
168 | 6460 HRESULT result; // eax@1 |
0 | 6461 HRESULT v6; // eax@4 |
6462 int v7; // [sp-8h] [bp-14h]@10 | |
6463 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
6464 char v9; // [sp+Bh] [bp-1h]@1 | |
6465 | |
6466 v4 = pSurface; | |
6467 v9 = 1; | |
6468 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
6469 if ( result == DDERR_SURFACELOST ) | |
6470 { | |
6471 v6 = v4->Restore(); | |
6472 if ( v6 ) | |
6473 { | |
6474 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
6475 { | |
6476 LABEL_20: | |
6477 v9 = 0; | |
6478 result = (bool)memset(pDesc, 0, 4u); | |
6479 goto LABEL_21; | |
6480 } | |
6481 pRenderer->pFrontBuffer4->Restore(); | |
6482 v4->Restore(); | |
6483 } | |
6484 result = v4->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
6485 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
6486 goto LABEL_20; | |
6487 ErrD3D(result); | |
6488 if ( result ) | |
6489 { | |
6490 //v8 = 0; | |
6491 //v7 = 2161; | |
6492 LABEL_19: | |
6493 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
6494 goto LABEL_20; | |
6495 } | |
6496 if ( pRenderer->pRenderD3D ) | |
6497 pRenderD3D->HandleLostResources(); | |
6498 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
6499 } | |
6500 else | |
6501 { | |
6502 if ( result ) | |
6503 { | |
6504 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
6505 goto LABEL_20; | |
6506 ErrD3D(result); | |
6507 //v8 = 0; | |
6508 //v7 = 2199; | |
6509 //goto LABEL_19; | |
6510 } | |
6511 } | |
6512 LABEL_21: | |
6513 LOBYTE(result) = v9; | |
6514 return result; | |
6515 } | |
6516 | |
6517 //----- (004A1032) -------------------------------------------------------- | |
6518 bool Render::LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags) | |
6519 { | |
6520 IDirectDrawSurface2 *v4; // esi@1 | |
6521 bool v5; // eax@1 | |
6522 HRESULT v6; // eax@2 | |
6523 int v7; // [sp-8h] [bp-10h]@8 | |
6524 unsigned int v8; // [sp-4h] [bp-Ch]@8 | |
6525 | |
6526 v4 = pSurface; | |
6527 v5 = pSurface->Lock( | |
6528 0, | |
6529 pDesc, | |
6530 uLockFlags, | |
6531 0); | |
6532 BYTE3(pSurface) = 1; | |
6533 if ( v5 == DDERR_SURFACELOST ) | |
6534 { | |
6535 v6 = v4->Restore(); | |
6536 if ( !v6 ) | |
6537 goto LABEL_5; | |
6538 if ( v6 == DDERR_IMPLICITLYCREATED ) | |
6539 { | |
6540 pRenderer->pFrontBuffer2->Restore(); | |
6541 v4->Restore(); | |
6542 LABEL_5: | |
6543 v5 = v4->Lock(0, pDesc, 1u, 0) != 0; | |
6544 if ( v5 == DDERR_INVALIDRECT || v5 == DDERR_SURFACEBUSY ) | |
6545 goto LABEL_14; | |
6546 if ( !v5 ) | |
6547 return true; | |
6548 ErrD3D(v5); | |
6549 //v8 = 0; | |
6550 //v7 = 2247; | |
6551 goto LABEL_13; | |
6552 } | |
6553 else | |
6554 { | |
6555 pDesc->dwSize = 0; | |
6556 return false; | |
6557 } | |
6558 } | |
6559 else | |
6560 { | |
6561 if ( !v5 ) | |
6562 return true; | |
6563 if ( v5 != DDERR_INVALIDRECT && v5 != DDERR_SURFACEBUSY ) | |
6564 { | |
6565 //v8 = 0; | |
6566 //v7 = 2269; | |
6567 ErrD3D(v5); | |
6568 pDesc->dwSize = 0; | |
6569 return false; | |
6570 LABEL_13: | |
6571 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, v5, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
6572 goto LABEL_14; | |
6573 } | |
6574 } | |
6575 LABEL_14: | |
6576 return true; | |
6577 } | |
6578 | |
6579 //----- (004A10E4) -------------------------------------------------------- | |
6580 void Render::CreateDirectDraw() | |
6581 { | |
6582 Render *v1; // edi@1 | |
6583 HRESULT v2; // eax@1 | |
6584 HRESULT v3; // eax@5 | |
6585 int v6; // [sp-Ch] [bp-20h]@3 | |
6586 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
6587 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
6588 | |
6589 v1 = this; | |
6590 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
6591 | |
6592 pDirectDraw2 = nullptr; | |
6593 pDirectDraw4 = nullptr; | |
6594 | |
6595 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6596 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); | |
6597 else | |
6598 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); | |
6599 | |
6600 lpDD->Release(); | |
6601 lpDD = nullptr; | |
6602 } | |
6603 | |
6604 //----- (004A1169) -------------------------------------------------------- | |
6605 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
6606 { | |
6607 DWORD flags; // eax@1 | |
6608 IDirectDraw *v4; // ecx@3 | |
6609 HRESULT v5; // eax@5 | |
6610 int v6; // [sp-8h] [bp-8h]@3 | |
6611 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
6612 | |
6613 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
6614 DDSCL_NORMAL; | |
6615 | |
6616 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6617 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); | |
6618 else | |
6619 ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); | |
6620 } | |
6621 | |
6622 //----- (004A11C6) -------------------------------------------------------- | |
6623 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
6624 { | |
6625 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6626 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
6627 else | |
6628 ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
6629 } | |
6630 | |
6631 //----- (004A121C) -------------------------------------------------------- | |
6632 void Render::CreateFrontBuffer() | |
6633 { | |
6634 Render *v1; // esi@1 | |
6635 IDirectDraw *pDD; // eax@3 | |
6636 IDirectDrawSurface **pOutSurf; // esi@3 | |
6637 struct _DDSURFACEDESC *v4; // edx@3 | |
6638 HRESULT v5; // eax@5 | |
6639 int v6; // [sp-8h] [bp-8Ch]@3 | |
6640 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
6641 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
6642 | |
6643 v1 = this; | |
6644 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6645 { | |
6646 memset(&a2, 0, 0x7Cu); | |
6647 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
6648 a2.dwSize = 124; | |
6649 a2.dwFlags = 1; | |
6650 v7 = 0; | |
6651 a2.ddsCaps.dwCaps = 512; | |
6652 v6 = 2357; | |
6653 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
6654 v4 = (struct _DDSURFACEDESC *)&a2; | |
6655 } | |
6656 else | |
6657 { | |
6658 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
6659 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
6660 a2.lPitch = 108; | |
6661 a2.dwBackBufferCount = 1; | |
6662 v7 = 0; | |
6663 a2.dwTextureStage = 512; | |
6664 v6 = 2346; | |
6665 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
6666 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
6667 } | |
6668 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); | |
6669 } | |
6670 | |
6671 //----- (004A12CD) -------------------------------------------------------- | |
6672 void Render::CreateBackBuffer() | |
6673 { | |
6674 Render *v1; // esi@1 | |
6675 IDirectDraw *v2; // eax@3 | |
6676 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
6677 struct _DDSURFACEDESC *v4; // edx@3 | |
6678 HRESULT v5; // eax@5 | |
6679 int v6; // [sp-8h] [bp-8Ch]@3 | |
6680 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
6681 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
6682 | |
6683 v1 = this; | |
6684 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6685 { | |
6686 memset(&a2, 0, 0x7Cu); | |
6687 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
6688 a2.dwSize = 124; | |
6689 a2.dwFlags = 7; | |
6690 v7 = 0; | |
6691 a2.ddsCaps.dwCaps = 2112; | |
6692 a2.dwWidth = 640; | |
6693 a2.dwHeight = 480; | |
6694 v6 = 2387; | |
6695 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
6696 v4 = (struct _DDSURFACEDESC *)&a2; | |
6697 } | |
6698 else | |
6699 { | |
6700 memset(&a2.lPitch, 0, 0x6Cu); | |
6701 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
6702 a2.lPitch = 108; | |
6703 a2.dwBackBufferCount = 7; | |
6704 v7 = 0; | |
6705 a2.dwTextureStage = 2112; | |
6706 a2.dwAlphaBitDepth = 640; | |
6707 a2.dwMipMapCount = 480; | |
6708 v6 = 2374; | |
6709 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
6710 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
6711 } | |
6712 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); | |
6713 } | |
6714 | |
6715 //----- (004A139A) -------------------------------------------------------- | |
6716 void Render::CreateDirectDrawPrimarySurface() | |
6717 { | |
6718 Render *v1; // esi@1 | |
6719 int v2; // ebx@3 | |
6720 IDirectDraw2 *v3; // eax@3 | |
6721 HRESULT v4; // eax@3 | |
6722 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
6723 DDSCAPS2 *v6; // edx@3 | |
6724 IDirectDraw4 *v7; // eax@4 | |
6725 HRESULT v8; // eax@4 | |
6726 int v9; // ST14_4@5 | |
6727 IDirectDrawSurface *v10; // ST10_4@5 | |
6728 HRESULT v11; // eax@5 | |
6729 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
6730 const char *v13; // [sp+0h] [bp-A0h]@0 | |
6731 int v14; // [sp+4h] [bp-9Ch]@0 | |
6732 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
6733 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
6734 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
6735 int a4; // [sp+98h] [bp-8h]@3 | |
6736 | |
6737 v1 = this; | |
6738 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6739 { | |
6740 v2 = 0; | |
6741 this->field_4004C = 1; | |
6742 memset(&ddsd2, 0, 0x7Cu); | |
6743 v7 = v1->pDirectDraw4; | |
6744 ddsd2.dwBackBufferCount = 1; | |
6745 ddsd2.dwSize = 0x7Cu; | |
6746 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
6747 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
6748 ErrD3D(v7->CreateSurface( | |
6749 &ddsd2, | |
6750 &pFrontBuffer4, | |
6751 0)); | |
6752 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
6753 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
6754 } | |
6755 else | |
6756 { | |
6757 v2 = 0; | |
6758 this->field_4004C = 1; | |
6759 | |
6760 DDSURFACEDESC ddsd; | |
6761 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
6762 | |
6763 ddsd.lpSurface = (LPVOID)1; | |
6764 ddsd.lPitch = 108; | |
6765 ddsd.dwBackBufferCount = 33; | |
6766 ddsd.ddsCaps.dwCaps = 8728; | |
6767 ErrD3D(pDirectDraw2->CreateSurface( | |
6768 &ddsd, | |
6769 (IDirectDrawSurface **)&pFrontBuffer2, | |
6770 0)); | |
6771 | |
6772 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
6773 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
6774 } | |
6775 v9 = (int)v6; | |
6776 v10 = pFrontBuffer; // BUG | |
6777 | |
6778 v17.dwCaps = 4; | |
6779 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
6780 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
6781 v1->field_40030 = v2; | |
6782 v1->field_18_locked_pitch = v2; | |
6783 } | |
6784 | |
6785 //----- (004A14F4) -------------------------------------------------------- | |
6786 void Render::CreateClipper(HWND a2) | |
6787 { | |
6788 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6789 { | |
6790 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); | |
6791 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
6792 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
6793 } | |
6794 else | |
6795 { | |
6796 ErrD3D(pDirectDraw2->CreateClipper(0, &pDDrawClipper, 0)); | |
6797 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
6798 } | |
6799 } | |
6800 | |
6801 //----- (004A15D8) -------------------------------------------------------- | |
6802 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
6803 { | |
6804 IDirectDrawSurface *v2; // eax@3 | |
6805 | |
6806 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6807 v2 = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6808 else | |
6809 v2 = (IDirectDrawSurface *)this->pFrontBuffer2; | |
6810 v2->GetPixelFormat(pOut); | |
6811 } | |
6812 | |
6813 //----- (004A1605) -------------------------------------------------------- | |
6814 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
6815 { | |
6816 Render *v3; // esi@1 | |
6817 signed int v4; // eax@3 | |
6818 | |
6819 v3 = this; | |
6820 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6821 { | |
6822 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
6823 memset(&pDesc, 0, 0x7Cu); | |
6824 pDesc.dwSize = 124; | |
168 | 6825 LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 6826 *pOutSurfacePtr = pDesc.lpSurface; |
6827 v4 = pDesc.lPitch; | |
6828 } | |
6829 else | |
6830 { | |
6831 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
6832 memset(&pDesc.lPitch, 0, 0x6Cu); | |
6833 pDesc.lPitch = 108; | |
6834 LockSurface_DDraw2(v3->pBackBuffer2, &pDesc, 1u); | |
6835 *pOutSurfacePtr = (void *)pDesc.lpSurface; | |
6836 v4 = pDesc.dwReserved; | |
6837 } | |
6838 *pOutPixelsPerRow = v4 >> 1; | |
6839 } | |
6840 | |
6841 //----- (004A169E) -------------------------------------------------------- | |
6842 bool Render::UsingDirect3D() | |
6843 { | |
6844 return bUserDirect3D == 0; | |
6845 } | |
6846 | |
6847 //----- (004A16E1) -------------------------------------------------------- | |
6848 void Render::UnlockBackBuffer() | |
6849 { | |
6850 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6851 ErrD3D(pBackBuffer4->Unlock(0)); | |
6852 else | |
6853 ErrD3D(pBackBuffer2->Unlock(0)); | |
6854 } | |
6855 | |
6856 //----- (004A172E) -------------------------------------------------------- | |
6857 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
6858 { | |
6859 Render *v3; // esi@1 | |
6860 signed int v4; // eax@3 | |
6861 | |
6862 v3 = this; | |
6863 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6864 { | |
6865 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
6866 memset(&pDesc, 0, 0x7Cu); | |
6867 pDesc.dwSize = 124; | |
168 | 6868 LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 6869 *pOutSurface = pDesc.lpSurface; |
6870 v4 = pDesc.lPitch; | |
6871 } | |
6872 else | |
6873 { | |
6874 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
6875 memset(&pDesc.lPitch, 0, 0x6Cu); | |
6876 pDesc.lPitch = 108; | |
6877 LockSurface_DDraw2(v3->pFrontBuffer2, &pDesc, 1u); | |
6878 *pOutSurface = (void *)pDesc.lpSurface; | |
6879 v4 = pDesc.dwReserved; | |
6880 } | |
6881 *pOutPixelsPerRow = v4 >> 1; | |
6882 } | |
6883 | |
6884 //----- (004A17C7) -------------------------------------------------------- | |
6885 void Render::UnlockFrontBuffer() | |
6886 { | |
6887 IDirectDrawSurface *pFront; // eax@3 | |
6888 HRESULT v2; // eax@5 | |
6889 signed int v3; // [sp-8h] [bp-Ch]@3 | |
6890 int v4; // [sp-4h] [bp-8h]@3 | |
6891 | |
6892 auto a5 = this; | |
6893 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6894 { | |
6895 pFront = (IDirectDrawSurface *)a5->pFrontBuffer4; | |
6896 v4 = 0; | |
6897 v3 = 2615; | |
6898 } | |
6899 else | |
6900 { | |
6901 pFront = (IDirectDrawSurface *)a5->pFrontBuffer2; | |
6902 v4 = 0; | |
6903 v3 = 2611; | |
6904 } | |
6905 ErrD3D(pFront->Unlock(0)); | |
6906 } | |
6907 | |
6908 //----- (004A1814) -------------------------------------------------------- | |
6909 void Render::RestoreFrontBuffer() | |
6910 { | |
6911 IDirectDrawSurface **v1; // esi@2 | |
6912 | |
6913 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
6914 || (v1 = (IDirectDrawSurface **)&this->pFrontBuffer2, pVersion->pVersionInfo.dwMajorVersion >= 5u) ) | |
6915 v1 = (IDirectDrawSurface **)&this->pFrontBuffer4; | |
6916 if ( (*v1)->IsLost() == DDERR_SURFACELOST ) | |
6917 (*v1)->Restore(); | |
6918 } | |
6919 | |
6920 //----- (004A184C) -------------------------------------------------------- | |
6921 HRESULT Render::_4A184C() | |
6922 { | |
6923 IDirectDrawSurface **pBack; // esi@2 | |
6924 HRESULT result; // eax@4 | |
6925 | |
6926 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
6927 || (pBack = (IDirectDrawSurface **)&this->pBackBuffer2, pVersion->pVersionInfo.dwMajorVersion != 4) ) | |
6928 pBack = (IDirectDrawSurface **)&this->pBackBuffer4; | |
6929 result = (*pBack)->IsLost(); | |
6930 if ( result == DDERR_SURFACELOST ) | |
6931 result = (*pBack)->Restore(); | |
6932 return result; | |
6933 } | |
6934 | |
6935 //----- (004A1884) -------------------------------------------------------- | |
6936 void Render::PresentRect(RECT *a2, RECT *a3) | |
6937 { | |
6938 IDirectDrawSurface *pFront; // eax@3 | |
6939 HRESULT v4; // eax@5 | |
6940 IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3 | |
6941 struct tagRECT *v6; // [sp-18h] [bp-18h]@3 | |
6942 DWORD v7; // [sp-14h] [bp-14h]@3 | |
6943 DDBLTFX *v8; // [sp-10h] [bp-10h]@3 | |
6944 const char *v9; // [sp-Ch] [bp-Ch]@3 | |
6945 int v10; // [sp-8h] [bp-8h]@3 | |
6946 unsigned int v11; // [sp-4h] [bp-4h]@3 | |
6947 | |
6948 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6949 { | |
6950 v11 = 0; | |
6951 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6952 v10 = 2657; | |
6953 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
6954 v8 = 0; | |
6955 v7 = DDBLT_WAIT; | |
6956 v6 = a3; | |
6957 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
6958 } | |
6959 else | |
6960 { | |
6961 v11 = 0; | |
6962 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
6963 v10 = 2653; | |
6964 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
6965 v8 = 0; | |
6966 v7 = DDBLT_WAIT; | |
6967 v6 = a3; | |
6968 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
6969 } | |
6970 ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8)); | |
6971 } | |
6972 | |
6973 //----- (004A18F5) -------------------------------------------------------- | |
6974 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
6975 { | |
6976 IDirectDrawSurface *pFront; // eax@3 | |
6977 HRESULT v6; // eax@5 | |
6978 int v7; // [sp-8h] [bp-8h]@3 | |
6979 unsigned int v8; // [sp-4h] [bp-4h]@3 | |
6980 | |
6981 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) | |
6982 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
6983 else | |
6984 ErrD3D(pFrontBuffer2->Blt(pDstRect, (IDirectDrawSurface2 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
6985 } | |
6986 | |
6987 //----- (004A194A) -------------------------------------------------------- | |
6988 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
6989 { | |
6990 IDirectDrawSurface *pFront; // eax@3 | |
6991 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
6992 | |
6993 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6994 { | |
6995 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6996 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
6997 } | |
6998 else | |
6999 { | |
7000 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
7001 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
7002 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7003 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 7004 } |
7005 | |
7006 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7007 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7008 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7009 //unsigned int v2; // ebx@1 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7010 //double v4; // st7@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7011 //unsigned int v5; // esi@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7012 //int v6; // ecx@5 |
0 | 7013 unsigned int v7; // edx@6 |
7014 char *v8; // ecx@12 | |
7015 void *v9; // edi@16 | |
7016 unsigned int v10; // eax@16 | |
7017 void *v11; // edi@21 | |
7018 unsigned int v12; // eax@21 | |
7019 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7020 //v2 = uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7021 if (uNumBillboardsToDraw >= 999 ) |
0 | 7022 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7023 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7024 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7025 uNumBillboardsToDraw = 1; |
0 | 7026 return 0; |
7027 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7028 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7029 //v4 = *(float *)&a1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7030 //v5 = pRenderer->uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7031 //v6 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7032 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7033 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7034 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7035 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7036 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7037 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7038 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7039 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7040 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7041 v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].z_order; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7042 if (z > *(float *)v8 ) |
0 | 7043 { |
7044 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
7045 { | |
7046 v7 = pRenderer->uNumBillboardsToDraw; | |
7047 } | |
7048 else | |
7049 { | |
7050 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
7051 { | |
7052 v9 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
7053 v10 = pRenderer->uNumBillboardsToDraw - v7; | |
7054 do | |
7055 { | |
7056 memcpy(v9, (char *)v9 - 156, 0x9Cu); | |
7057 v9 = (char *)v9 - 156; | |
7058 --v10; | |
7059 } | |
7060 while ( v10 ); | |
7061 } | |
7062 ++v7; | |
7063 } | |
717 | 7064 //LABEL_23: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7065 uNumBillboardsToDraw++; |
0 | 7066 return v7; |
7067 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7068 if (z <= *(float *)v8 ) |
0 | 7069 { |
7070 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
7071 { | |
7072 v11 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
7073 v12 = pRenderer->uNumBillboardsToDraw - v7; | |
7074 do | |
7075 { | |
7076 memcpy(v11, (char *)v11 - 156, 0x9Cu); | |
7077 v11 = (char *)v11 - 156; | |
7078 --v12; | |
7079 } | |
7080 while ( v12 ); | |
7081 } | |
717 | 7082 //goto LABEL_23; |
7083 uNumBillboardsToDraw++; | |
7084 return v7; | |
0 | 7085 } |
7086 return v7; | |
7087 } | |
7088 | |
7089 //----- (004A1E9D) -------------------------------------------------------- | |
7090 unsigned int Render::GetBillboardDrawListSize() | |
7091 { | |
7092 return pRenderer->uNumBillboardsToDraw; | |
7093 } | |
7094 | |
7095 //----- (004A1EA3) -------------------------------------------------------- | |
7096 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
7097 { | |
7098 return pRenderer->pBillboardRenderListD3D[uBillboardID].uParentBillboardID; | |
7099 } | |
7100 | |
7101 //----- (004A1EB6) -------------------------------------------------------- | |
7102 void Render::BeginSceneD3D() | |
7103 { | |
7104 if (!uNumD3DSceneBegins++) | |
7105 { | |
7106 if (pRenderD3D) | |
7107 { | |
7108 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
7109 pRenderer->uNumBillboardsToDraw = 0; | |
7110 pRenderD3D->pDevice->BeginScene(); | |
7111 if (!pRenderD3D->DoesRaiseExceptions()) | |
7112 { | |
7113 MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0); | |
7114 } | |
7115 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
7116 uFogColor = GetLevelFogColor(); | |
7117 else | |
7118 uFogColor = 0; | |
7119 | |
7120 if ( uFogColor & 0xFF000000 ) | |
7121 { | |
7122 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
7123 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
7124 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
7125 bUsingSpecular = true; | |
7126 } | |
7127 else | |
7128 { | |
7129 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
7130 bUsingSpecular = 0; | |
7131 } | |
7132 } | |
7133 else | |
7134 { | |
7135 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
7136 if (pTargetSurface) | |
7137 field_18_locked_pitch = uTargetSurfacePitch; | |
7138 else | |
7139 --uNumD3DSceneBegins; | |
7140 } | |
7141 } | |
7142 } | |
7143 | |
7144 //----- (004A1FE1) -------------------------------------------------------- | |
7145 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
7146 { | |
7147 --uNumD3DSceneBegins; | |
7148 if (uNumD3DSceneBegins) | |
7149 return; | |
7150 | |
7151 if (pRenderD3D) | |
7152 { | |
7153 pGame->draw_debug_outlines(); | |
161 | 7154 DoRenderBillboards_D3D(); |
0 | 7155 pGame->pStru6Instance->RenderSpecialEffects(); |
7156 pRenderD3D->pDevice->EndScene(); | |
7157 } | |
7158 else | |
7159 pGame->pStru6Instance->RenderSpecialEffects(); | |
7160 } | |
7161 | |
7162 //----- (004A2031) -------------------------------------------------------- | |
349 | 7163 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
7164 { | |
638 | 7165 __debugbreak(); // should not fire outside decal builder |
349 | 7166 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 7167 } |
7168 | |
186 | 7169 /*void Render::DrawTerrainPolygon_new(stru148 *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 7170 { |
7171 int v5; // ebx@1 | |
7172 int v6; // edi@1 | |
7173 int v8; // eax@7 | |
7174 float v9; // eax@12 | |
7175 float *v10; // esi@12 | |
7176 float v11; // ecx@14 | |
7177 double v12; // st7@14 | |
7178 double v13; // st7@14 | |
7179 double v14; // st7@14 | |
7180 signed int v15; // eax@14 | |
7181 int v16; // eax@15 | |
7182 float v17; // ST48_4@15 | |
7183 char v18; // zf@17 | |
7184 int v19; // eax@18 | |
7185 int v20; // eax@18 | |
7186 int v21; // edx@20 | |
7187 signed int v22; // ecx@20 | |
7188 int v23; // eax@20 | |
7189 const char *v24; // ST4C_4@20 | |
7190 unsigned int v25; // ST50_4@20 | |
7191 int v26; // ST54_4@20 | |
7192 int v27; // eax@20 | |
7193 _UNKNOWN *v28; // eax@21 | |
7194 int v29; // ecx@23 | |
7195 int v30; // eax@23 | |
7196 int v31; // eax@23 | |
7197 int v32; // eax@24 | |
7198 int v33; // eax@25 | |
7199 int v34; // eax@25 | |
7200 int v35; // eax@25 | |
7201 int v36; // eax@25 | |
7202 signed int v37; // ecx@26 | |
7203 int v38; // eax@26 | |
7204 _UNKNOWN *v39; // eax@27 | |
7205 int v40; // edx@28 | |
7206 int v41; // eax@29 | |
7207 int v42; // eax@29 | |
7208 int v43; // eax@29 | |
7209 int v44; // eax@29 | |
7210 unsigned int v46; // eax@29 | |
7211 int v47; // eax@30 | |
7212 int v48; // eax@30 | |
7213 int v49; // eax@30 | |
7214 double v52; // st6@35 | |
7215 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
7216 int v57; // [sp+5Ch] [bp-Ch]@3 | |
7217 signed int v59; // [sp+60h] [bp-8h]@12 | |
7218 int v61; // [sp+64h] [bp-4h]@4 | |
7219 int i; | |
7220 | |
7221 v6 = (int)this; | |
7222 v5 = 0; | |
7223 if (!this->uNumD3DSceneBegins) | |
7224 return; | |
7225 | |
7226 | |
7227 | |
7228 | |
186 | 7229 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 7230 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
7231 if (this->bUsingSpecular) | |
7232 { | |
186 | 7233 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
7234 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
7235 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 7236 } |
7237 | |
7238 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
7239 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
7240 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7241 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); | |
7242 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
7243 pVertices[0].specular = 0; | |
7244 pVertices[0].texcoord.x = array_50AC10[0].u; | |
7245 pVertices[0].texcoord.y = array_50AC10[0].v; | |
7246 | |
7247 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
7248 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
7249 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7250 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); | |
7251 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
7252 pVertices[1].specular = 0; | |
7253 pVertices[1].texcoord.x = array_50AC10[3].u; | |
7254 pVertices[1].texcoord.y = array_50AC10[3].v; | |
7255 | |
7256 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
7257 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
7258 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7259 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); | |
7260 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
7261 pVertices[2].specular = 0; | |
7262 pVertices[2].texcoord.x = array_50AC10[1].u; | |
7263 pVertices[2].texcoord.y = array_50AC10[1].v; | |
7264 | |
7265 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
7266 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
7267 | |
7268 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
7269 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
7270 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7271 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); | |
7272 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
7273 pVertices[5].specular = 0; | |
7274 pVertices[5].texcoord.x = array_50AC10[2].u; | |
7275 pVertices[5].texcoord.y = array_50AC10[2].v; | |
7276 | |
7277 | |
7278 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7279 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
7280 | |
186 | 7281 }*/ |
7282 | |
0 | 7283 //----- (004A26BC) -------------------------------------------------------- |
186 | 7284 void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
7285 { | |
7286 //RenderVertexSoft *pVertices; // esi@0 | |
7287 //int v7; // edi@1 | |
0 | 7288 unsigned int v8; // ebx@1 |
7289 LightmapBuilder *v9; // esi@3 | |
7290 unsigned int v10; // edx@3 | |
7291 int v11; // eax@5 | |
7292 int v12; // eax@11 | |
7293 char *v13; // esi@11 | |
7294 double v14; // st7@13 | |
7295 double v15; // st7@13 | |
7296 signed int v16; // eax@13 | |
7297 int v17; // ecx@13 | |
7298 double v18; // st7@13 | |
7299 float v19; // ST78_4@14 | |
7300 int v20; // eax@14 | |
7301 char v21; // zf@16 | |
7302 HRESULT v22; // eax@17 | |
7303 HRESULT v23; // eax@17 | |
7304 HRESULT v24; // eax@19 | |
7305 HRESULT v25; // eax@19 | |
7306 unsigned int v26; // ecx@19 | |
7307 char *v27; // eax@20 | |
7308 HRESULT v28; // eax@22 | |
7309 HRESULT v29; // eax@22 | |
7310 HRESULT v30; // eax@23 | |
7311 HRESULT v31; // eax@24 | |
7312 HRESULT v32; // eax@24 | |
7313 HRESULT v33; // eax@24 | |
7314 HRESULT v34; // eax@24 | |
7315 HRESULT v35; // eax@25 | |
7316 HRESULT v36; // eax@25 | |
7317 unsigned int v37; // ecx@25 | |
7318 char *v38; // eax@26 | |
7319 int v39; // edx@27 | |
7320 HRESULT v40; // eax@28 | |
7321 HRESULT v41; // eax@28 | |
7322 HRESULT v42; // eax@28 | |
7323 HRESULT v43; // eax@28 | |
7324 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
7325 unsigned int v45; // eax@28 | |
7326 HRESULT v46; // eax@29 | |
7327 HRESULT v47; // eax@29 | |
7328 HRESULT v48; // eax@29 | |
186 | 7329 //IDirect3DDevice3 *v49; // eax@35 |
0 | 7330 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
7331 int v51; // eax@40 | |
7332 char *v52; // esi@40 | |
7333 double v53; // st7@42 | |
7334 double v54; // st7@42 | |
7335 signed int v55; // eax@42 | |
7336 int v56; // ecx@42 | |
7337 double v57; // st7@42 | |
7338 float v58; // ST7C_4@43 | |
7339 int v59; // eax@43 | |
186 | 7340 //signed int v60; // [sp+78h] [bp-14h]@31 |
7341 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
0 | 7342 const char *v62; // [sp+80h] [bp-Ch]@0 |
7343 const char *v63; // [sp+80h] [bp-Ch]@19 | |
7344 int v64; // [sp+84h] [bp-8h]@0 | |
7345 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
7346 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
7347 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
186 | 7348 int a7; |
7349 | |
7350 //v7 = (int)this; | |
0 | 7351 v8 = 0; |
186 | 7352 if (!this->uNumD3DSceneBegins) |
75 | 7353 return; |
7354 if ( uNumVertices < 3) | |
7355 return; | |
7356 | |
186 | 7357 //v61 = pVertices; |
7358 | |
75 | 7359 /* v9 = pGame->pLightmapBuilder; |
0 | 7360 v65 = v9; |
75 | 7361 v10 = v9->std__vector_000004_size;*/ |
0 | 7362 if ( byte_4D864C && pGame->uFlags & 1 ) |
7363 { | |
638 | 7364 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
75 | 7365 pGame->pLightmapBuilder->_45D74F_MessWithLight(v11, 0); |
0 | 7366 } |
7367 else | |
7368 { | |
186 | 7369 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 7370 byte_4D864C && pGame->uFlags & 2 ) |
7371 { | |
186 | 7372 if (clampAtTextureBorders) |
7373 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 7374 else |
186 | 7375 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
7376 | |
7377 if (transparent || this->bUsingSpecular) | |
7378 { | |
7379 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
7380 if (transparent) | |
0 | 7381 { |
186 | 7382 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
7383 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
7384 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
7385 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 7386 } |
7387 else | |
7388 { | |
186 | 7389 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
7390 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 7391 } |
186 | 7392 } |
1073 | 7393 |
7394 for (uint i = 0; i < uNumVertices; ++i) | |
7395 { | |
7396 | |
7397 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
7398 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
7399 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); | |
7400 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | |
7401 d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
7402 if ( this->bUsingSpecular ) | |
0 | 7403 { |
1073 | 7404 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 7405 } |
1073 | 7406 else |
7407 { | |
7408 d3d_vertex_buffer[i].specular = 0; | |
7409 } | |
7410 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
7411 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
7412 } | |
7413 | |
7414 this->pRenderD3D->pDevice->SetTexture(0, a5); | |
186 | 7415 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
7416 if (transparent) | |
7417 { | |
7418 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
7419 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
7420 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 7421 } |
7422 } | |
7423 else | |
7424 { | |
1073 | 7425 for (uint i = 0; i < uNumVertices; ++i) |
7426 { | |
7427 | |
7428 d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
7429 d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
7430 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); | |
7431 d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); | |
7432 d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); | |
7433 if ( this->bUsingSpecular ) | |
0 | 7434 { |
1073 | 7435 d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); |
0 | 7436 } |
1073 | 7437 else |
7438 { | |
7439 d3d_vertex_buffer[i].specular = 0; | |
7440 } | |
7441 d3d_vertex_buffer[i].specular = v20; | |
7442 d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; | |
7443 d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; | |
7444 } | |
186 | 7445 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
7446 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
7447 if (pRenderer->bUsingSpecular) | |
7448 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 7449 |
7450 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 7451 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7452 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7453 d3d_vertex_buffer, |
0 | 7454 uNumVertices, |
7455 16)); | |
7456 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 7457 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 7458 //(*(void (**)(void))(*(int *)v63 + 88))(); |
7459 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
1073 | 7460 for (uint i = 0; i < uNumVertices; ++i) |
7461 { | |
7462 d3d_vertex_buffer[i].diffuse = -1; | |
7463 } | |
0 | 7464 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); |
186 | 7465 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7466 if ( !pRenderer->bUsingSpecular ) |
7467 { | |
186 | 7468 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
7469 } | |
7470 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
7471 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
7472 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
7473 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7474 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7475 d3d_vertex_buffer, |
0 | 7476 uNumVertices, |
7477 16)); | |
7478 if ( pRenderer->bUsingSpecular ) | |
7479 { | |
186 | 7480 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 7481 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
1073 | 7482 for (uint i = 0; i < uNumVertices; ++i) |
7483 { | |
7484 d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; | |
7485 d3d_vertex_buffer[i].specular = 0; | |
7486 } | |
7487 | |
75 | 7488 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 7489 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
7490 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
7491 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7492 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7493 d3d_vertex_buffer, |
0 | 7494 uNumVertices, |
7495 16)); | |
186 | 7496 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 7497 //v44 = pRenderer->pRenderD3D->pDevice; |
7498 v45 = GetLevelFogColor(); | |
7499 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
7500 v8 = 0; | |
7501 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
7502 } | |
186 | 7503 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
7504 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 7505 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
7506 } | |
7507 } | |
186 | 7508 |
791 | 7509 if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
186 | 7510 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 7511 } |
7512 // 4A26BC: could not find valid save-restore pair for esi | |
7513 // 4D864C: using guessed type char byte_4D864C; | |
7514 | |
7515 //----- (004A2DA3) -------------------------------------------------------- | |
852 | 7516 void Render::DrawSkyPolygon(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *pTexture) |
7517 { | |
67 | 7518 int v7; // eax@7 |
0 | 7519 float v13; // ST3C_4@8 |
67 | 7520 int i; |
7521 | |
7522 if ( !this->uNumD3DSceneBegins ) | |
7523 return; | |
7524 if ( uNumVertices >= 3 ) | |
7525 { | |
186 | 7526 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 7527 if ( this->bUsingSpecular ) |
7528 { | |
186 | 7529 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
7530 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
7531 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 7532 } |
840 | 7533 for ( i = 0; i < uNumVertices; ++i ) |
67 | 7534 { |
7535 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
7536 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
7537 pVertices[i].pos.z = 0.99989998; | |
168 | 7538 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 7539 |
840 | 7540 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 7541 v7 = 0; |
7542 if (this->bUsingSpecular) | |
7543 { | |
7544 v13 = array_50AC10[i].vWorldViewPosition.x; | |
7545 v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v13); | |
7546 } | |
7547 pVertices[i].specular = v7; | |
7548 pVertices[i].texcoord.x = array_50AC10[i].u; | |
7549 pVertices[i].texcoord.y = array_50AC10[i].v; | |
7550 } | |
7551 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7552 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 7553 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 7554 } |
7555 } | |
7556 | |
7557 //----- (004A2ED5) -------------------------------------------------------- | |
7558 void Render::_4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex) | |
7559 { | |
7560 signed int v4; // edi@2 | |
7561 int v5; // eax@3 | |
7562 int v6; // edx@5 | |
1072 | 7563 RenderVertexD3D3 *v7; // eax@6 |
7564 RenderVertexSoft *v8; // ecx@6 | |
7565 //double v9; // st6@7 | |
7566 //int v10; // ebx@7 | |
7567 //int v11; // ebx@7 | |
0 | 7568 |
7569 if ( this->uNumD3DSceneBegins ) | |
7570 { | |
7571 v4 = a2; | |
7572 if ( a2 >= 3 ) | |
7573 { | |
186 | 7574 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
638 | 7575 v5 = 31 - (a3->dimming_level & 0x1F); |
7576 if ( v5 < pOutdoor->max_terrain_dimming_level ) | |
7577 v5 = pOutdoor->max_terrain_dimming_level; | |
0 | 7578 v6 = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); |
1072 | 7579 for (uint i = 0; i < a2; ++i) |
7580 { | |
7581 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
7582 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7583 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / array_507D30[i].vWorldViewPosition.y; | |
7584 d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw; | |
7585 d3d_vertex_buffer[i].diffuse = v6; | |
7586 d3d_vertex_buffer[i].specular = 0; | |
7587 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u; | |
7588 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v; | |
7589 } | |
7590 | |
0 | 7591 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 7592 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7593 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7594 d3d_vertex_buffer, |
0 | 7595 a2, |
7596 28)); | |
7597 } | |
7598 } | |
7599 } | |
7600 | |
7601 //----- (004A2FC0) -------------------------------------------------------- | |
7602 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
7603 { | |
7604 //Render *v8; // edi@1 | |
7605 //unsigned int v9; // esi@3 | |
1072 | 7606 RenderVertexSoft *v12; // ecx@9 |
7607 RenderVertexD3D3 *v13; // eax@9 | |
0 | 7608 double v14; // st6@10 |
7609 int v15; // edx@10 | |
7610 Texture *v16; // edx@10 | |
7611 double v17; // st6@10 | |
7612 //char v18; // zf@10 | |
7613 Texture *v19; // edx@10 | |
595 | 7614 //Texture *v23; // edx@16 |
7615 //char *v24; // ecx@16 | |
7616 //char *v25; // eax@16 | |
7617 //double v26; // st6@17 | |
7618 //int v27; // esi@17 | |
7619 //double v28; // st6@17 | |
7620 //unsigned int v33; // ecx@18 | |
7621 //char *v34; // eax@19 | |
0 | 7622 //Texture *v45; // edx@23 |
7623 //char *v46; // ecx@23 | |
7624 //char *v47; // eax@23 | |
7625 //double v48; // st6@24 | |
7626 //int v49; // esi@24 | |
7627 //double v50; // st6@24 | |
7628 const char *v53; // [sp-Ch] [bp-20h]@21 | |
7629 //int v54; // [sp-8h] [bp-1Ch]@21 | |
7630 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
7631 const char *v56; // [sp+0h] [bp-14h]@0 | |
7632 int v57; // [sp+4h] [bp-10h]@0 | |
7633 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
7634 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
7635 //int a3a; // [sp+10h] [bp-4h]@4 | |
7636 | |
7637 //v8 = this; | |
7638 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
7639 return; | |
7640 | |
7641 //auto a3 = pFace; | |
7642 //auto a6 = uPackedID; | |
7643 //v59 = pGame->pLightmapBuilder; | |
7644 //v9 = v59->std__vector_000004_size; | |
7645 | |
7646 auto uCorrectedColor = uColor; | |
7647 if (pGame->pLightmapBuilder->std__vector_000004_size) | |
7648 uCorrectedColor = 0xFFFFFFFF; | |
638 | 7649 pGame->AlterGamma_BLV(pFace, &uCorrectedColor); |
0 | 7650 |
792 | 7651 |
7652 if (pFace->uAttributes & FACE_OUTLINED) | |
7653 { | |
7654 int color; | |
7655 if (GetTickCount() % 300 >= 150) | |
7656 uColor = uCorrectedColor = 0xFF20FF20; | |
7657 else uColor = uCorrectedColor = 0xFF109010; | |
7658 } | |
7659 | |
0 | 7660 if (byte_4D864C && pGame->uFlags & 1) |
7661 { | |
7662 __debugbreak(); | |
7663 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 7664 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
1072 | 7665 for (uint i = 0; i < uNumVertices; ++i) |
7666 { | |
7667 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
7668 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7669 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
7670 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
7671 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
7672 d3d_vertex_buffer[i].specular = 0; | |
7673 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
7674 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
7675 } | |
7676 | |
186 | 7677 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7678 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
7679 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7680 D3DPT_TRIANGLEFAN, | |
7681 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 7682 d3d_vertex_buffer, |
0 | 7683 uNumVertices, |
7684 28)); | |
7685 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
7686 } | |
7687 else | |
7688 { | |
7689 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
7690 byte_4D864C && pGame->uFlags & 2) | |
7691 { | |
7692 for (uint i = 0; i < uNumVertices; ++i) | |
7693 { | |
186 | 7694 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
7695 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7696 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
7697 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
7698 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
7699 d3d_vertex_buffer[i].specular = 0; | |
7700 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
7701 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
7702 } | |
7703 | |
7704 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 7705 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
7706 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
7707 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 7708 d3d_vertex_buffer, |
0 | 7709 uNumVertices, |
7710 28)); | |
7711 } | |
7712 else | |
7713 { | |
595 | 7714 for (uint i = 0; i < uNumVertices; ++i) |
7715 { | |
7716 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
7717 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7718 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
7719 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
7720 d3d_vertex_buffer[i].diffuse = uColor; | |
7721 d3d_vertex_buffer[i].specular = 0; | |
7722 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
7723 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
7724 } | |
7725 //__debugbreak(); | |
7726 //if ( (signed int)uNumVertices > 0 ) | |
7727 //{ | |
7728 //v23 = pTex; | |
7729 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
7730 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
7731 //pTex = (Texture *)uNumVertices; | |
7732 //uint v18; | |
7733 //do | |
7734 //{ | |
7735 //v26 = *(float *)v24 * 0.061758894; | |
7736 //v27 = *((int *)v24 + 3); | |
7737 //*((int *)v25 + 4) = 0; | |
7738 //*((int *)v25 - 1) = v27; | |
7739 //*(int *)v25 = *((int *)v24 + 4); | |
7740 //*((int *)v25 + 3) = uColor; | |
7741 //v25 += 32; | |
7742 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
7743 //v28 = 1.0 / *(float *)v24; | |
7744 //v24 += 48; | |
7745 //v18 = pTex == (Texture *)1; | |
7746 //pTex = (Texture *)((char *)pTex - 1); | |
7747 //*((float *)v25 - 6) = v28; | |
0 | 7748 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 7749 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 7750 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 7751 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
7752 //} | |
7753 //while ( !v18 ); | |
7754 //} | |
0 | 7755 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 7756 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7757 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 7758 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7759 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7760 d3d_vertex_buffer, |
0 | 7761 uNumVertices, |
7762 28)); | |
595 | 7763 |
7764 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 7765 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); |
595 | 7766 |
7767 for (uint i = 0; i < uNumVertices; ++i) | |
7768 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
7769 /*v33 = uNumVertices; | |
0 | 7770 if ( (signed int)uNumVertices > 0 ) |
7771 { | |
186 | 7772 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 7773 do |
7774 { | |
7775 *(int *)v34 = uCorrectedColor; | |
7776 v34 += 32; | |
7777 --v33; | |
7778 } | |
7779 while ( v33 ); | |
595 | 7780 }*/ |
0 | 7781 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 7782 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
7783 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
7784 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
7785 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
7786 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
7787 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7788 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7789 d3d_vertex_buffer, |
0 | 7790 uNumVertices, |
7791 28)); | |
186 | 7792 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
7793 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
7794 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 7795 } |
7796 } | |
7797 } | |
7798 // 4D864C: using guessed type char byte_4D864C; | |
7799 | |
7800 //----- (004A43B1) -------------------------------------------------------- | |
717 | 7801 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
7802 { | |
7803 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
7804 //double v5; // st7@2 | |
7805 //float v6; // ST08_4@2 | |
0 | 7806 unsigned int v7; // eax@2 |
717 | 7807 //int v8; // ecx@2 |
7808 //unsigned int v9; // esi@2 | |
7809 //Sprite *v10; // edi@5 | |
0 | 7810 signed int v11; // eax@9 |
7811 signed int v12; // eax@9 | |
717 | 7812 //double v13; // st7@12 |
7813 //double v14; // st6@12 | |
0 | 7814 double v15; // st5@12 |
7815 double v16; // st4@12 | |
7816 double v17; // st3@12 | |
7817 double v18; // st2@12 | |
7818 int v19; // ecx@14 | |
7819 double v20; // st3@14 | |
7820 int v21; // ecx@16 | |
7821 double v22; // st3@16 | |
717 | 7822 //IDirect3DTexture2 *v23; // eax@18 |
7823 //signed int v24; // [sp+18h] [bp-18h]@5 | |
7824 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
7825 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 7826 float v27; // [sp+24h] [bp-Ch]@5 |
7827 int v28; // [sp+28h] [bp-8h]@2 | |
7828 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 7829 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 7830 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 7831 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 7832 float a1; // [sp+40h] [bp+10h]@5 |
7833 | |
717 | 7834 //v26 = this; |
0 | 7835 if ( this->uNumD3DSceneBegins ) |
7836 { | |
717 | 7837 //v4 = pSoftBillboard; |
7838 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
7839 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
7840 //v6 = pSoftBillboard->zbuffer_depth; | |
7841 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
7842 //v8 = dimming_level; | |
7843 //v9 = v7; | |
657 | 7844 v28 = dimming_level & 0xFF000000; |
7845 if ( dimming_level & 0xFF000000 ) | |
717 | 7846 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Opaque_3; |
0 | 7847 else |
717 | 7848 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Transparent; |
7849 //v10 = a3; | |
7850 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
7851 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
7852 pBillboardRenderListD3D[v7].uParentBillboardID = pSoftBillboard->uParentBillboardID; | |
7853 //v25 = pSoftBillboard->uScreenSpaceX; | |
7854 //v24 = pSoftBillboard->uScreenSpaceY; | |
7855 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
7856 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
7857 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
7858 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
7859 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 7860 v31 = v31 * -1.0; |
717 | 7861 if ( pSoftBillboard->uTintColor && this->bTinting ) |
7862 { | |
7863 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
737 | 7864 v12 = BlendColors(pSoftBillboard->uTintColor, v11); |
0 | 7865 if ( v28 ) |
7866 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
7867 } | |
7868 else | |
7869 { | |
717 | 7870 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
7871 } | |
7872 //v13 = (double)v25; | |
7873 pBillboardRenderListD3D[v7].pQuards[0].specular = 0; | |
7874 pBillboardRenderListD3D[v7].pQuards[0].diffuse = v12; | |
7875 pBillboardRenderListD3D[v7].pQuards[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
7876 //v14 = (double)v24; | |
7877 //v32 = v14; | |
7878 pBillboardRenderListD3D[v7].pQuards[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; | |
7879 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); | |
7880 pBillboardRenderListD3D[v7].pQuards[0].pos.z = v15; | |
7881 v16 = 1.0 / pSoftBillboard->zbuffer_depth; | |
7882 pBillboardRenderListD3D[v7].pQuards[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; | |
7883 pBillboardRenderListD3D[v7].pQuards[0].texcoord.x = 0.0; | |
7884 pBillboardRenderListD3D[v7].pQuards[0].texcoord.y = 0.0; | |
7885 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
7886 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
7887 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 7888 v17 = v17 * -1.0; |
717 | 7889 pBillboardRenderListD3D[v7].pQuards[1].specular = 0; |
7890 pBillboardRenderListD3D[v7].pQuards[1].diffuse = v12; | |
7891 pBillboardRenderListD3D[v7].pQuards[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
7892 pBillboardRenderListD3D[v7].pQuards[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
7893 pBillboardRenderListD3D[v7].pQuards[1].pos.z = v15; | |
7894 pBillboardRenderListD3D[v7].pQuards[1].rhw = v16; | |
7895 pBillboardRenderListD3D[v7].pQuards[1].texcoord.x = 0.0; | |
7896 pBillboardRenderListD3D[v7].pQuards[1].texcoord.y = 1.0; | |
7897 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; | |
7898 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
7899 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 7900 v20 = v20 * -1.0; |
717 | 7901 pBillboardRenderListD3D[v7].pQuards[2].specular = 0; |
7902 pBillboardRenderListD3D[v7].pQuards[2].diffuse = v12; | |
7903 pBillboardRenderListD3D[v7].pQuards[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
7904 pBillboardRenderListD3D[v7].pQuards[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
7905 pBillboardRenderListD3D[v7].pQuards[2].pos.z = v15; | |
7906 pBillboardRenderListD3D[v7].pQuards[2].rhw = v16; | |
7907 pBillboardRenderListD3D[v7].pQuards[2].texcoord.x = 1.0; | |
7908 pBillboardRenderListD3D[v7].pQuards[2].texcoord.y = 1.0; | |
7909 v21 = pSprite->uBufferHeight - pSprite->uAreaY; | |
7910 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
7911 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 7912 v22 = v22 * -1.0; |
717 | 7913 pBillboardRenderListD3D[v7].pQuards[3].specular = 0; |
7914 pBillboardRenderListD3D[v7].pQuards[3].diffuse = v12; | |
7915 pBillboardRenderListD3D[v7].pQuards[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
7916 pBillboardRenderListD3D[v7].pQuards[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
7917 pBillboardRenderListD3D[v7].pQuards[3].pos.z = v15; | |
7918 pBillboardRenderListD3D[v7].pQuards[3].rhw = v16; | |
7919 pBillboardRenderListD3D[v7].pQuards[3].texcoord.x = 1.0; | |
7920 pBillboardRenderListD3D[v7].pQuards[3].texcoord.y = 0.0; | |
7921 //v23 = pSprite->pTexture; | |
7922 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
7923 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
7924 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 7925 } |
7926 } | |
7927 | |
7928 //----- (004A354F) -------------------------------------------------------- | |
7929 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
7930 { | |
743 | 7931 //double v5; // st7@3 |
7932 //float v6; // ST20_4@3 | |
7933 //float v7; // ST00_4@3 | |
0 | 7934 unsigned int v8; // esi@3 |
743 | 7935 //int v9; // eax@3 |
7936 //int v10; // ebx@3 | |
0 | 7937 float v11; // ST28_4@3 |
743 | 7938 //double v12; // st7@3 |
7939 //float v13; // ST24_4@3 | |
7940 //double v14; // st6@3 | |
7941 //float v15; // ST1C_4@3 | |
0 | 7942 float v16; // ST2C_4@3 |
7943 float v17; // ST30_4@3 | |
7944 signed int v18; // ST18_4@3 | |
7945 signed int v19; // ST14_4@3 | |
7946 signed int v20; // ST10_4@3 | |
7947 signed int v21; // eax@3 | |
7948 double v22; // st6@3 | |
7949 float v23; // ST2C_4@3 | |
7950 float v24; // ST30_4@3 | |
7951 signed int v25; // ST10_4@3 | |
7952 signed int v26; // ST14_4@3 | |
7953 signed int v27; // ST18_4@3 | |
7954 signed int v28; // eax@3 | |
7955 double v29; // st6@3 | |
7956 float v30; // ecx@3 | |
7957 float v31; // ST2C_4@3 | |
7958 float v32; // ST30_4@3 | |
7959 signed int v33; // ST10_4@3 | |
7960 signed int v34; // ST14_4@3 | |
7961 signed int v35; // ST18_4@3 | |
7962 signed int v36; // eax@3 | |
7963 float v37; // ecx@3 | |
7964 double v38; // st6@3 | |
7965 float v39; // ST2C_4@3 | |
7966 float v40; // ST30_4@3 | |
7967 signed int v41; // ST10_4@3 | |
7968 signed int v42; // ST14_4@3 | |
7969 signed int v43; // ST18_4@3 | |
7970 signed int v44; // eax@3 | |
7971 double v45; // st6@3 | |
7972 float v46; // eax@3 | |
7973 | |
7974 if ( this->uNumD3DSceneBegins ) | |
7975 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7976 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7977 { |
743 | 7978 //v5 = (double)a2->zbuffer_depth; |
7979 //v6 = v5; | |
7980 //v7 = v5; | |
7981 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
0 | 7982 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; |
7983 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
7984 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
7985 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
743 | 7986 //v9 = a2->uScreenSpaceX; |
7987 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7988 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 7989 //v12 = (double) a2->uScreenSpaceX; |
7990 //v13 = v12; | |
7991 //v14 = (double)(a2->uScreenSpaceY - 12); | |
7992 //v15 = v14; | |
7993 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
7994 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 7995 v18 = stru_5C6E00->Cos(angle); |
7996 v19 = stru_5C6E00->Sin(angle); | |
7997 v20 = stru_5C6E00->Sin(angle); | |
7998 v21 = stru_5C6E00->Cos(angle); | |
0 | 7999 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
8000 + (double)(v18 >> 16)) | |
8001 * v16 | |
8002 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
8003 + (double)(v19 >> 16)) | |
8004 * v17) | |
743 | 8005 * v11 + (double) a2->uScreenSpaceX; |
0 | 8006 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
8007 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
8008 - 12.0) | |
8009 * v11 | |
8010 + (double)a2->uScreenSpaceY; | |
8011 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; | |
8012 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; | |
8013 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v22; | |
743 | 8014 pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); |
8015 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; | |
0 | 8016 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; |
8017 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; | |
743 | 8018 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
8019 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 8020 v25 = stru_5C6E00->Cos(angle); |
8021 v26 = stru_5C6E00->Sin(angle); | |
8022 v27 = stru_5C6E00->Sin(angle); | |
8023 v28 = stru_5C6E00->Cos(angle); | |
0 | 8024 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
8025 + (double)(v25 >> 16)) | |
740 | 8026 * v31 |
0 | 8027 - ((double)(unsigned __int16)v26 * 0.000015259022 |
8028 + (double)(v26 >> 16)) | |
740 | 8029 * v32) |
743 | 8030 * v11 + (double) a2->uScreenSpaceX; |
740 | 8031 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
8032 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 8033 - 12.0) |
8034 * v11 | |
8035 + (double)a2->uScreenSpaceY; | |
8036 pBillboardRenderListD3D[v8].pQuards[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8037 v30 = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8038 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v29; | |
8039 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; | |
8040 pBillboardRenderListD3D[v8].pQuards[1].rhw = v30; | |
8041 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; | |
8042 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; | |
8043 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
743 | 8044 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
8045 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 8046 v33 = stru_5C6E00->Cos(angle); |
8047 v34 = stru_5C6E00->Sin(angle); | |
8048 v35 = stru_5C6E00->Sin(angle); | |
8049 v36 = stru_5C6E00->Cos(angle); | |
0 | 8050 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
8051 + (double)(v33 >> 16)) | |
740 | 8052 * v23 |
0 | 8053 - ((double)(unsigned __int16)v34 * 0.000015259022 |
8054 + (double)(v34 >> 16)) | |
740 | 8055 * v24) |
743 | 8056 * v11 + (double) a2->uScreenSpaceX; |
0 | 8057 v37 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; |
740 | 8058 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
8059 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 8060 - 12.0) |
8061 * v11 | |
8062 + (double)a2->uScreenSpaceY; | |
8063 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; | |
8064 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v37; | |
8065 pBillboardRenderListD3D[v8].pQuards[2].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8066 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; | |
8067 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v38; | |
8068 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; | |
8069 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
743 | 8070 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
8071 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 8072 v41 = stru_5C6E00->Cos(angle); |
8073 v42 = stru_5C6E00->Sin(angle); | |
8074 v43 = stru_5C6E00->Sin(angle); | |
8075 v44 = stru_5C6E00->Cos(angle); | |
0 | 8076 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
8077 + (double)(v41 >> 16)) | |
8078 * v39 | |
8079 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
8080 + (double)(v42 >> 16)) | |
8081 * v40) | |
743 | 8082 * v11 + (double) a2->uScreenSpaceX; |
0 | 8083 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
8084 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
8085 - 12.0) | |
8086 * v11 | |
8087 + (double)a2->uScreenSpaceY; | |
8088 v46 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8089 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; | |
8090 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v46; | |
8091 pBillboardRenderListD3D[v8].pQuards[3].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8092 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; | |
8093 pBillboardRenderListD3D[v8].pTexture = a3; | |
743 | 8094 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 8095 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8096 pBillboardRenderListD3D[v8].pQuards[3].pos.y = v45; | |
8097 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; | |
8098 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
8099 } | |
8100 } | |
8101 } | |
8102 | |
8103 //----- (004A3AD9) -------------------------------------------------------- | |
8104 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
8105 { | |
8106 double v5; // st7@2 | |
8107 float v6; // ST28_4@2 | |
8108 float v7; // ST00_4@2 | |
8109 unsigned int v8; // esi@2 | |
8110 int v9; // eax@2 | |
8111 int v10; // ebx@2 | |
8112 float v11; // ST34_4@2 | |
8113 double v12; // st7@2 | |
8114 float v13; // ST2C_4@2 | |
8115 double v14; // st6@2 | |
8116 float v15; // ST24_4@2 | |
8117 float v16; // ST38_4@2 | |
8118 float v17; // ST3C_4@2 | |
8119 signed int v18; // ST1C_4@2 | |
8120 int v19; // ST30_4@2 | |
8121 signed int v20; // ST20_4@2 | |
8122 signed int v21; // ST18_4@2 | |
8123 signed int v22; // eax@2 | |
8124 double v23; // st6@2 | |
8125 float v24; // ST20_4@2 | |
8126 float v25; // ST1C_4@2 | |
8127 float v26; // ST38_4@2 | |
8128 float v27; // ST3C_4@2 | |
8129 signed int v28; // ST18_4@2 | |
8130 signed int v29; // ST14_4@2 | |
8131 signed int v30; // ST10_4@2 | |
8132 signed int v31; // eax@2 | |
8133 double v32; // st6@2 | |
8134 float v33; // ST38_4@2 | |
8135 float v34; // ST3C_4@2 | |
8136 signed int v35; // ST10_4@2 | |
8137 signed int v36; // ST14_4@2 | |
8138 signed int v37; // ST18_4@2 | |
8139 signed int v38; // eax@2 | |
8140 double v39; // st6@2 | |
8141 float v40; // ST38_4@2 | |
8142 float v41; // ST3C_4@2 | |
8143 signed int v42; // ST10_4@2 | |
8144 signed int v43; // ST14_4@2 | |
8145 signed int v44; // ST18_4@2 | |
8146 signed int v45; // eax@2 | |
8147 double v46; // st6@2 | |
8148 | |
8149 if ( this->uNumD3DSceneBegins ) | |
8150 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8151 v5 = (double)a2->zbuffer_depth; |
0 | 8152 v6 = v5; |
8153 v7 = v5; | |
8154 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
8155 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | |
8156 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
8157 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
8158 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
8159 v9 = a2->uScreenSpaceX; | |
8160 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8161 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 8162 v12 = (double)v9; |
8163 v13 = v12; | |
8164 v14 = (double)(v10 - 12); | |
8165 v15 = v14; | |
8166 v16 = (double)(v9 - 12) - v12; | |
8167 v17 = (double)(v10 - 25) - v14; | |
323 | 8168 v18 = stru_5C6E00->Cos(angle); |
0 | 8169 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 8170 v20 = stru_5C6E00->Sin(angle); |
8171 v21 = stru_5C6E00->Sin(angle); | |
8172 v22 = stru_5C6E00->Cos(angle); | |
0 | 8173 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
8174 + (double)(v18 >> 16)) | |
8175 * v16 | |
8176 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
8177 + (double)(v20 >> 16)) | |
8178 * v17) | |
8179 * v11 + v13; | |
8180 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
8181 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
8182 - 12.0) | |
8183 * v11 | |
8184 + (double)a2->uScreenSpaceY; | |
8185 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; | |
8186 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; | |
8187 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v23; | |
8188 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
8189 pBillboardRenderListD3D[v8].pQuards[0].pos.z = v24; | |
8190 v25 = 1.0 / v6; | |
8191 pBillboardRenderListD3D[v8].pQuards[0].rhw = v25; | |
8192 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; | |
8193 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; | |
8194 v26 = (double)(a2->uScreenSpaceX - 12) - v13; | |
8195 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 8196 v28 = stru_5C6E00->Cos(angle); |
8197 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8198 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8199 v31 = stru_5C6E00->Cos(angle); | |
0 | 8200 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
8201 + (double)(v28 >> 16)) | |
8202 * v26 | |
8203 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
8204 + (double)(v29 >> 16)) | |
8205 * v27) | |
8206 * v11 + v13; | |
8207 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
8208 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
8209 - 12.0) | |
8210 * v11 | |
8211 + (double)a2->uScreenSpaceY; | |
8212 pBillboardRenderListD3D[v8].pQuards[1].pos.z = v24; | |
8213 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v32; | |
8214 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; | |
8215 pBillboardRenderListD3D[v8].pQuards[1].rhw = v25; | |
8216 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; | |
8217 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; | |
8218 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
8219 v33 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8220 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 8221 v35 = stru_5C6E00->Cos(angle); |
8222 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8223 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8224 v38 = stru_5C6E00->Cos(angle); | |
0 | 8225 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
8226 + (double)(v35 >> 16)) | |
8227 * v33 | |
8228 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
8229 + (double)(v36 >> 16)) | |
8230 * v34) | |
8231 * v11 + v13; | |
8232 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
8233 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
8234 - 12.0) | |
8235 * v11 | |
8236 + (double)a2->uScreenSpaceY; | |
8237 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; | |
8238 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v24; | |
8239 pBillboardRenderListD3D[v8].pQuards[2].rhw = v25; | |
8240 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; | |
8241 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v39; | |
8242 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; | |
8243 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
8244 v40 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8245 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 8246 v42 = stru_5C6E00->Cos(angle); |
8247 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8248 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8249 v45 = stru_5C6E00->Cos(angle); | |
0 | 8250 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
8251 + (double)(v42 >> 16)) | |
8252 * v40 | |
8253 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
8254 + (double)(v43 >> 16)) | |
8255 * v41) | |
8256 * v11 + v13; | |
8257 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
8258 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
8259 - 12.0) | |
8260 * v11 | |
8261 + (double)a2->uScreenSpaceY; | |
8262 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; | |
8263 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v24; | |
8264 pBillboardRenderListD3D[v8].pQuards[3].rhw = v25; | |
8265 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; | |
8266 pBillboardRenderListD3D[v8].pTexture = a3; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8267 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 8268 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8269 pBillboardRenderListD3D[v8].pQuards[3].pos.y = v46; | |
8270 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; | |
8271 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
8272 } | |
8273 } | |
8274 | |
8275 //----- (004A4023) -------------------------------------------------------- | |
657 | 8276 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
|
8277 { |
0 | 8278 unsigned int v8; // esi@2 |
8279 double v14; // st6@14 | |
8280 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8281 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8282 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8283 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8284 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8285 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8286 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8287 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8288 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8289 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8290 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 8291 float v29; // [sp+28h] [bp-8h]@5 |
8292 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8293 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8294 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8295 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8296 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8297 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8298 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8299 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8300 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
|
8301 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
|
8302 |
657 | 8303 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
|
8304 if (a2->uTintColor & 0x00FFFFFF && bTinting) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8305 { |
737 | 8306 diffuse = BlendColors(a2->uTintColor, diffuse); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8307 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8308 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8309 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8310 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8311 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8312 if (bUsingSpecular) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8313 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
|
8314 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8315 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8316 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8317 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8318 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8319 pBillboardRenderListD3D[v8].pQuards[0].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8320 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
|
8321 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
|
8322 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
|
8323 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8324 pBillboardRenderListD3D[v8].pQuards[0].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8325 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8326 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8327 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8328 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8329 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8330 if ( a2->uFlags & 4 ) |
0 | 8331 v14 = v14 * -1.0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8332 pBillboardRenderListD3D[v8].pQuards[1].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8333 pBillboardRenderListD3D[v8].pQuards[1].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8334 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
|
8335 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
|
8336 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
|
8337 pBillboardRenderListD3D[v8].pQuards[1].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8338 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; |
8339 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8340 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8341 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
|
8342 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8343 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8344 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8345 pBillboardRenderListD3D[v8].pQuards[2].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8346 pBillboardRenderListD3D[v8].pQuards[2].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8347 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
|
8348 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
|
8349 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
|
8350 pBillboardRenderListD3D[v8].pQuards[2].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8351 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; |
8352 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8353 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8354 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
|
8355 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8356 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8357 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8358 pBillboardRenderListD3D[v8].pQuards[3].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8359 pBillboardRenderListD3D[v8].pQuards[3].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8360 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
|
8361 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
|
8362 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
|
8363 pBillboardRenderListD3D[v8].pQuards[3].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8364 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; |
8365 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8366 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8367 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8368 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8369 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8370 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8371 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8372 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8373 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8374 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8375 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8376 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8377 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; |
0 | 8378 } |
8379 | |
8380 //----- (004A48E4) -------------------------------------------------------- | |
8381 int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6) | |
8382 { | |
8383 int v6; // ecx@1 | |
8384 int v7; // ebx@1 | |
8385 int v8; // ecx@1 | |
8386 int v9; // edx@1 | |
8387 int v10; // edi@1 | |
8388 unsigned int x; // esi@1 | |
8389 int result; // eax@8 | |
8390 int v13; // [sp+Ch] [bp-10h]@1 | |
8391 int v14; // [sp+10h] [bp-Ch]@1 | |
8392 int v15; // [sp+14h] [bp-8h]@1 | |
8393 int v16; // [sp+18h] [bp-4h]@1 | |
8394 int v17; // [sp+24h] [bp+8h]@1 | |
8395 unsigned int v18; // [sp+28h] [bp+Ch]@1 | |
8396 int v19; // [sp+34h] [bp+18h]@1 | |
8397 | |
8398 v6 = screenSpaceX; | |
8399 v7 = (a6 >> 1) + screenSpaceY; | |
8400 v17 = 0; | |
8401 v15 = 0; | |
8402 v8 = (a6 >> 1) + v6; | |
8403 v14 = (a6 >> 1) * (a6 >> 1); | |
8404 v9 = 2 * (a6 >> 1); | |
8405 v10 = (a6 >> 1) * ((a6 >> 1) - 1); | |
8406 x = v8 - (a6 >> 1); | |
8407 v16 = (a6 >> 1) + screenSpaceY - v8; | |
8408 v19 = a6 >> 1; | |
8409 v13 = v9; | |
8410 v18 = v8; | |
8411 do | |
8412 { | |
8413 sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor); | |
8414 if ( v15 ) | |
8415 sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor); | |
8416 v14 -= v15; | |
8417 if ( v14 <= v10 ) | |
8418 { | |
8419 if ( v19 != v17 ) | |
8420 { | |
8421 sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor); | |
8422 sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor); | |
8423 } | |
8424 --v19; | |
8425 v13 -= 2; | |
8426 ++x; | |
8427 v10 -= v13; | |
8428 } | |
8429 result = v17++; | |
8430 v15 += 2; | |
8431 --v18; | |
8432 } | |
8433 while ( result < v19 ); | |
8434 return result; | |
8435 } | |
8436 | |
8437 //----- (004A49D0) -------------------------------------------------------- | |
8438 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
8439 { | |
8440 int v10; // eax@1 | |
8441 unsigned int v11; // ebx@1 | |
8442 unsigned int v12; // ecx@1 | |
8443 int v13; // edx@2 | |
8444 int v14; // edx@4 | |
8445 unsigned int v15; // edx@6 | |
8446 double v16; // st7@7 | |
8447 double v17; // st7@7 | |
8448 double v18; // st6@7 | |
8449 double v19; // st4@7 | |
8450 double v20; // st4@8 | |
8451 double v21; // st4@10 | |
8452 double v22; // st4@10 | |
8453 double v23; // st4@10 | |
8454 double v24; // st4@10 | |
8455 double v25; // st4@11 | |
8456 double v26; // st4@13 | |
8457 double v27; // st5@13 | |
8458 double v28; // st4@13 | |
8459 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
8460 double v30; // [sp+80h] [bp-14h]@1 | |
8461 int v31; // [sp+88h] [bp-Ch]@1 | |
8462 signed int v32; // [sp+8Ch] [bp-8h]@1 | |
8463 int X; // [sp+90h] [bp-4h]@1 | |
8464 float a3a; // [sp+A4h] [bp+10h]@10 | |
8465 float a4a; // [sp+A8h] [bp+14h]@10 | |
8466 | |
8467 *(float *)&X = dstX - srcX; | |
8468 v30 = *(float *)&X + 6.7553994e15; | |
8469 v31 = LODWORD(v30); | |
8470 *(float *)&v32 = dstY - srcY; | |
8471 v30 = *(float *)&v32 + 6.7553994e15; | |
8472 X = LODWORD(v30); | |
8473 HIDWORD(v30) = abs(COERCE_UNSIGNED_INT64(*(float *)&v32 + 6.7553994e15)); | |
8474 v10 = abs(v31); | |
8475 v32 = v10; | |
8476 v11 = HIDWORD(v30); | |
8477 v12 = 0; | |
8478 if ( v10 < SHIDWORD(v30) ) | |
8479 { | |
8480 v13 = v10; | |
8481 v10 = HIDWORD(v30); | |
8482 v11 = v13; | |
8483 } | |
8484 if ( v10 < 0 ) | |
8485 { | |
8486 v14 = v10; | |
8487 v10 = 0; | |
8488 v12 = v14; | |
8489 } | |
8490 if ( (signed int)v11 < (signed int)v12 ) | |
8491 { | |
8492 v15 = v12; | |
8493 v12 = v11; | |
8494 v11 = v15; | |
8495 } | |
8496 v32 = (11 * v11 >> 5) + (v12 >> 2) + v10; | |
8497 v16 = 1.0 / (double)v32; | |
8498 *(float *)&v31 = (double)v31 * v16; | |
8499 *(float *)&X = (double)X * v16; | |
8500 v17 = *(float *)&X * a4; | |
8501 v29[0].pos.x = srcX + v17; | |
8502 v18 = *(float *)&v31 * a4; | |
8503 v29[0].pos.y = srcY - v18; | |
8504 v19 = a3; | |
8505 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
8506 v20 = v19 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8507 else | |
8508 v20 = v19 * 0.061758894; | |
8509 v29[0].diffuse = -1; | |
8510 v29[0].specular = 0; | |
8511 v29[0].pos.z = 1.0 - 1.0 / v20; | |
8512 v21 = 1.0 / a3; | |
8513 *((float *)&v30 + 1) = v21; | |
8514 v29[0].rhw = v21; | |
8515 v29[0].texcoord.x = 1.0; | |
8516 v29[0].texcoord.y = 0.0; | |
8517 v22 = *(float *)&X * a8; | |
8518 a3a = v22; | |
8519 v29[1].pos.x = v22 + dstX; | |
8520 v23 = *(float *)&v31 * a8; | |
8521 a4a = v23; | |
8522 v29[1].pos.y = dstY - v23; | |
8523 v24 = a7; | |
8524 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
8525 v25 = v24 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8526 else | |
8527 v25 = v24 * 0.061758894; | |
8528 v29[2].diffuse = -1; | |
8529 v29[3].diffuse = -1; | |
8530 *(_QWORD *)&v29[3].pos.z = __PAIR__(HIDWORD(v30), LODWORD(v29[0].pos.z)); | |
8531 v29[1].diffuse = -16711936; | |
8532 v29[1].specular = 0; | |
8533 v29[2].specular = 0; | |
8534 v29[3].specular = 0; | |
8535 v26 = 1.0 - 1.0 / v25; | |
8536 v29[1].pos.z = v26; | |
8537 v27 = v26; | |
8538 v28 = 1.0 / a7; | |
8539 v29[1].rhw = v28; | |
8540 v29[1].texcoord.x = 1.0; | |
8541 v29[1].texcoord.y = 1.0; | |
8542 v29[2].pos.x = dstX - a3a; | |
8543 v29[2].pos.y = a4a + dstY; | |
8544 v29[2].pos.z = v27; | |
8545 v29[2].rhw = v28; | |
8546 v29[2].texcoord.x = 0.0; | |
8547 v29[2].texcoord.y = 1.0; | |
8548 v29[3].pos.x = srcX - v17; | |
8549 v29[3].pos.y = v18 + srcY; | |
8550 v29[3].texcoord.x = 0.0; | |
8551 v29[3].texcoord.y = 0.0; | |
186 | 8552 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
8553 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8554 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8555 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
8556 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8557 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 8558 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
8559 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
8560 D3DPT_TRIANGLEFAN, | |
8561 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8562 v29, | |
8563 4, | |
8564 24)); | |
186 | 8565 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
8566 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8567 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8568 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
8569 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8570 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 8571 } |
8572 | |
8573 //----- (004A4CC9) -------------------------------------------------------- | |
8574 void Render::_4A4CC9(stru6_stru1_indoor_sw_billboard *a1, int a2) | |
8575 { | |
8576 int v3; // eax@1 | |
8577 int v4; // edx@3 | |
8578 unsigned int v5; // eax@7 | |
8579 int v6; // edi@7 | |
8580 char *v7; // edx@8 | |
8581 char *v8; // ecx@8 | |
8582 char v9; // zf@9 | |
8583 double v10; // st6@9 | |
8584 double v11; // st6@10 | |
8585 int v12; // ebx@13 | |
8586 int v13; // ecx@16 | |
8587 unsigned int v14; // [sp+Ch] [bp-4h]@1 | |
8588 | |
8589 auto _this = this; | |
8590 | |
8591 *(float *)&v14 = 1000000.0; | |
8592 v3 = a1->field_10; | |
8593 if ( v3 >= 3 ) | |
8594 { | |
8595 if ( v3 > 0 ) | |
8596 { | |
8597 _this = (Render *)&a1->field_14[62]; | |
8598 v4 = a1->field_10; | |
8599 do | |
8600 { | |
8601 if ( *(float *)&this->bUserDirect3D < (double)*(float *)&v14 ) | |
8602 v14 = this->bUserDirect3D; | |
8603 _this = (Render *)((char *)_this + 16); | |
8604 --v4; | |
8605 } | |
8606 while ( v4 ); | |
8607 } | |
8608 v5 = Billboard_ProbablyAddToListAndSortByZOrder(v14); | |
8609 v6 = 0; | |
8610 pBillboardRenderListD3D[v5].field_90 = 0; | |
8611 pBillboardRenderListD3D[v5].uParentBillboardID = -1; | |
8612 pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; | |
8613 if ( a1->field_10 > 0 ) | |
8614 { | |
8615 v7 = (char *)&a1->field_14[62]; | |
8616 v8 = (char *)&pBillboardRenderListD3D[v5].pQuards[0].pos.z; | |
8617 do | |
8618 { | |
8619 v9 = uCurrentlyLoadedLevelType == LEVEL_Indoor; | |
8620 *((int *)v8 - 2) = *((int *)v7 - 2); | |
8621 *((int *)v8 - 1) = *((int *)v7 - 1); | |
8622 v10 = *(float *)v7; | |
8623 if ( v9 ) | |
8624 v11 = v10 * 0.061758894; | |
8625 else | |
8626 v11 = v10 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8627 *(float *)v8 = 1.0 - 1.0 / v11; | |
8628 *((float *)v8 + 1) = 1.0 / *(float *)v7; | |
8629 if ( a2 & 0xFF000000 ) | |
8630 v12 = *((int *)v7 + 1); | |
8631 else | |
8632 v12 = a2; | |
8633 *((int *)v8 + 3) = 0; | |
8634 *((int *)v8 + 2) = v12; | |
8635 ++v6; | |
8636 v7 += 16; | |
8637 *((float *)v8 + 4) = 0.0; | |
8638 *((float *)v8 + 5) = 0.0; | |
8639 v8 += 32; | |
8640 } | |
8641 while ( v6 < a1->field_10 ); | |
8642 } | |
8643 v13 = a1->field_10; | |
8644 pBillboardRenderListD3D[v5].pTexture = 0; | |
8645 pBillboardRenderListD3D[v5].uNumVertices = v13; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8646 LODWORD(pBillboardRenderListD3D[v5].z_order) = v14; |
0 | 8647 } |
8648 } | |
8649 | |
8650 //----- (004A4DE1) -------------------------------------------------------- | |
8651 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
8652 { | |
8653 HRESULT v12; // eax@14 | |
8654 unsigned __int16 *v13; // ecx@19 | |
8655 unsigned __int16 *v14; // eax@19 | |
8656 DWORD v15; // edx@20 | |
8657 HRESULT v16; // eax@23 | |
8658 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
8659 | |
8660 auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); | |
8661 if ( pHWLTexture ) | |
8662 { | |
8663 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
8664 if ( !pRenderD3D->CreateTexture( | |
8665 pHWLTexture->uWidth, | |
8666 pHWLTexture->uHeight, | |
8667 pOutSurface, | |
8668 pOutTexture, | |
8669 true, | |
8670 bMipMaps, | |
8671 uMinDeviceTextureDim) ) | |
8672 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); | |
8673 //v10 = *pOutSurface; | |
8674 //v11 = 0; | |
8675 if ( bMipMaps ) | |
8676 { | |
8677 Dst._450DDE(); | |
8678 //v20 = 0; | |
8679 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
8680 | |
8681 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
8682 while ( 1 ) | |
8683 { | |
8684 DDSCAPS2 v19; | |
8685 memset(&v19, 0, sizeof(DDSCAPS2)); | |
8686 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
8687 | |
8688 DDSURFACEDESC2 desc; | |
8689 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
8690 desc.dwSize = sizeof(DDSURFACEDESC2); | |
8691 | |
168 | 8692 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 8693 { |
8694 Dst.sub_451007_scale_image_bicubic( | |
8695 pHWLTexture->pPixels, | |
8696 pHWLTexture->uWidth, | |
8697 pHWLTexture->uHeight, | |
8698 pHWLTexture->uWidth, | |
8699 (unsigned short *)desc.lpSurface, | |
8700 desc.dwWidth, | |
8701 desc.dwHeight, | |
8702 desc.lPitch >> 1, | |
8703 0, | |
8704 0); | |
8705 ErrD3D(pNextSurf->Unlock(0)); | |
8706 //bMipMaps = 0x4D86ACu; | |
8707 } | |
8708 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
8709 break; | |
8710 //v10 = (IDirectDrawSurface4 *)pName; | |
8711 //v11 = 0; | |
8712 } | |
8713 //v20 = -1; | |
8714 //nullsub_1(); | |
8715 } | |
8716 else | |
8717 { | |
8718 DDSCAPS2 v19; | |
8719 memset(&v19, 0, sizeof(DDSCAPS2)); | |
8720 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
8721 | |
8722 DDSURFACEDESC2 desc; | |
8723 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
8724 desc.dwSize = sizeof(DDSURFACEDESC2); | |
8725 | |
168 | 8726 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 8727 { |
8728 bMipMaps = 0; | |
8729 v13 = pHWLTexture->pPixels; | |
8730 v14 = (unsigned __int16 *)desc.lpSurface; | |
8731 if ( desc.dwHeight ) | |
8732 { | |
8733 do | |
8734 { | |
8735 v15 = 0; | |
8736 if ( desc.dwWidth ) | |
8737 { | |
8738 do | |
8739 { | |
8740 ++v15; | |
8741 *v14 = *v13; | |
8742 ++v14; | |
8743 ++v13; | |
8744 } | |
8745 while ( v15 < desc.dwWidth ); | |
8746 } | |
8747 ++bMipMaps; | |
8748 v14 += (desc.lPitch >> 1) - desc.dwWidth; | |
8749 } | |
8750 while ( bMipMaps < desc.dwHeight ); | |
8751 } | |
8752 ErrD3D((*pOutSurface)->Unlock(0)); | |
8753 } | |
8754 } | |
8755 delete [] pHWLTexture->pPixels; | |
8756 delete pHWLTexture; | |
8757 return true; | |
8758 } | |
8759 return false; | |
8760 } | |
8761 | |
8762 //----- (004A5048) -------------------------------------------------------- | |
670 | 8763 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
8764 { | |
8765 | |
8766 HWLTexture *sprite_texture; // eax@1 | |
0 | 8767 unsigned __int16 *v9; // edx@5 |
8768 LPVOID v10; // eax@5 | |
8769 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
8770 | |
670 | 8771 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
8772 if ( sprite_texture ) | |
8773 { | |
8774 _gpu_memory_used += 2 * sprite_texture->uWidth * sprite_texture->uHeight; | |
8775 pSprite->uAreaX = sprite_texture->uAreaX; | |
8776 pSprite->uAreaY = sprite_texture->uAreaY; | |
8777 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
8778 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
8779 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
8780 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8781 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8782 //v7 = v3->pRenderD3D; |
670 | 8783 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
0 | 8784 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
8785 //pSprite = v2->pTextureSurface; | |
8786 //pSprite = (Sprite *)pSprite->pName; | |
8787 //v8 = pSprite; | |
670 | 8788 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 8789 Dst.dwSize = 124; |
670 | 8790 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
8791 { | |
8792 v9 = sprite_texture->pPixels; | |
8793 v10 = Dst.lpSurface; | |
8794 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 8795 { |
670 | 8796 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
8797 { | |
0 | 8798 *(int *)v10 = *(int *)v9; |
8799 v9 += 2; | |
8800 v10 = (char *)v10 + 4; | |
670 | 8801 } |
8802 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 8803 } |
670 | 8804 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
8805 } | |
8806 free(sprite_texture->pPixels); | |
8807 free(sprite_texture); | |
8808 return true; | |
8809 } | |
8810 return false; | |
0 | 8811 } |
8812 | |
8813 //----- (004A51CB) -------------------------------------------------------- | |
8814 void Render::BeginScene() | |
8815 { | |
8816 Render *v1; // esi@1 | |
8817 unsigned int v2; // eax@1 | |
8818 int v3; // eax@5 | |
8819 unsigned __int16 **v4; // edi@6 | |
8820 char *v5; // ebx@7 | |
8821 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
8822 | |
8823 v1 = this; | |
8824 v2 = this->uNumSceneBegins; | |
8825 this->uNumSceneBegins = v2 + 1; | |
8826 if ( !v2 ) | |
8827 { | |
8828 if ( this->pRenderD3D ) | |
8829 { | |
8830 if ( this->bColorKeySupported ) | |
8831 { | |
8832 memset(&Dst, 0, 0x7Cu); | |
8833 Dst.dwSize = 124; | |
168 | 8834 if ( LockSurface_DDraw4(v1->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) ) |
0 | 8835 { |
8836 v1->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; | |
8837 v3 = Dst.lPitch >> 1; | |
8838 v1->uTargetSurfacePitch = Dst.lPitch >> 1; | |
8839 LABEL_10: | |
8840 v1->field_18_locked_pitch = v3; | |
8841 goto LABEL_11; | |
8842 } | |
8843 goto LABEL_8; | |
8844 } | |
8845 } | |
8846 else | |
8847 { | |
8848 v4 = &this->pTargetSurface; | |
8849 if ( !this->pTargetSurface ) | |
8850 { | |
8851 v5 = (char *)&this->uTargetSurfacePitch; | |
8852 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
8853 if ( *v4 ) | |
8854 { | |
8855 v3 = *(int *)v5; | |
8856 goto LABEL_10; | |
8857 } | |
8858 LABEL_8: | |
8859 --v1->uNumSceneBegins; | |
8860 return; | |
8861 } | |
8862 } | |
8863 LABEL_11: | |
8864 RestoreFrontBuffer(); | |
8865 } | |
8866 } | |
8867 | |
8868 //----- (004A527D) -------------------------------------------------------- | |
8869 void Render::EndScene() | |
8870 { | |
8871 unsigned int v1; // edx@1 | |
8872 unsigned int v2; // edx@2 | |
8873 HRESULT v3; // eax@5 | |
8874 | |
8875 v1 = this->uNumSceneBegins; | |
8876 if ( v1 ) | |
8877 { | |
8878 v2 = v1 - 1; | |
8879 this->uNumSceneBegins = v2; | |
8880 if ( !v2 ) | |
8881 { | |
8882 if ( this->pRenderD3D ) | |
8883 { | |
8884 if ( this->bColorKeySupported ) | |
8885 { | |
8886 this->pTargetSurface = 0; | |
8887 this->uTargetSurfacePitch = 0; | |
8888 this->field_18_locked_pitch = 0; | |
8889 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
8890 } | |
8891 } | |
8892 else | |
8893 { | |
8894 this->pTargetSurface = 0; | |
8895 this->uTargetSurfacePitch = 0; | |
8896 this->field_18_locked_pitch = 0; | |
8897 UnlockBackBuffer(); | |
8898 } | |
8899 } | |
8900 } | |
8901 } | |
8902 | |
8903 //----- ( ) -------------------------------------------------------- | |
8904 unsigned int Render::_4A52F1(unsigned int this_, float a3) | |
8905 { | |
8906 unsigned int v3; // esi@1 | |
8907 double v4; // st7@2 | |
8908 double v5; // st7@6 | |
8909 double v6; // st6@6 | |
8910 unsigned int v7; // eax@6 | |
8911 double v8; // st5@6 | |
8912 double v9; // st4@6 | |
8913 HRESULT v10; // eax@6 | |
8914 HRESULT v11; // eax@6 | |
8915 unsigned int result; // eax@6 | |
8916 unsigned int v13; // eax@7 | |
8917 unsigned __int16 *v14; // ecx@7 | |
8918 int *v15; // eax@7 | |
8919 unsigned int v16; // ecx@8 | |
8920 __int16 v17; // ax@10 | |
8921 int v18; // esi@10 | |
8922 float v19; // edi@10 | |
8923 void *v20; // esi@10 | |
8924 int v21; // edx@10 | |
8925 int v22; // ecx@11 | |
8926 int v23; // edx@12 | |
8927 __int16 v24; // ax@15 | |
8928 int v25; // esi@15 | |
8929 float v26; // edi@15 | |
8930 char *v27; // esi@15 | |
8931 int v28; // edx@15 | |
8932 int v29; // ecx@16 | |
8933 int v30; // edx@17 | |
8934 int v31; // [sp-Ch] [bp-ACh]@11 | |
8935 int v32; // [sp-Ch] [bp-ACh]@16 | |
8936 const char *v33; // [sp+0h] [bp-A0h]@0 | |
8937 int v34; // [sp+4h] [bp-9Ch]@0 | |
8938 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
8939 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
8940 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
8941 int v38; // [sp+90h] [bp-10h]@7 | |
8942 double v39; // [sp+94h] [bp-Ch]@6 | |
8943 float v40; // [sp+9Ch] [bp-4h]@6 | |
8944 | |
8945 auto ecx0 = this; | |
8946 v3 = 0; | |
8947 if ( ecx0->pRenderD3D ) | |
8948 { | |
8949 v4 = a3; | |
8950 if ( a3 <= 1.0 ) | |
8951 { | |
8952 if ( v4 < 0.0 ) | |
8953 v4 = 0.0; | |
8954 } | |
8955 else | |
8956 { | |
8957 v4 = 1.0; | |
8958 } | |
8959 a3 = v4 * 255.0; | |
8960 v39 = a3 + 6.7553994e15; | |
8961 LODWORD(v40) = LODWORD(v39); | |
693 | 8962 v5 = (double)(signed int)pViewport->uViewportTL_X; |
0 | 8963 v36[0].pos.x = v5; |
693 | 8964 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
0 | 8965 v7 = this_ | (LODWORD(v39) << 24); |
693 | 8966 this_ = pViewport->uViewportBR_Y + 1; |
0 | 8967 v36[0].specular = 0; |
8968 v36[0].pos.y = v6; | |
8969 v36[0].diffuse = v7; | |
8970 v36[1].diffuse = v7; | |
8971 v36[0].pos.z = 0.0; | |
8972 v36[2].diffuse = v7; | |
8973 v36[3].diffuse = v7; | |
8974 v36[0].rhw = 1.0; | |
8975 v36[1].specular = 0; | |
8976 v36[0].texcoord.x = 0.0; | |
8977 v36[2].specular = 0; | |
8978 v36[3].specular = 0; | |
8979 v36[0].texcoord.y = 0.0; | |
8980 v36[1].pos.x = v5; | |
693 | 8981 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 8982 v36[1].pos.y = v8; |
8983 v36[1].pos.z = 0.0; | |
8984 v36[1].rhw = 1.0; | |
8985 v36[1].texcoord.x = 0.0; | |
8986 v36[1].texcoord.y = 0.0; | |
693 | 8987 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 8988 v36[2].pos.x = v9; |
8989 v36[2].pos.y = v8; | |
8990 v36[2].pos.z = 0.0; | |
8991 v36[2].rhw = 1.0; | |
8992 v36[2].texcoord.x = 0.0; | |
8993 v36[2].texcoord.y = 0.0; | |
8994 v36[3].pos.x = v9; | |
8995 v36[3].pos.y = v6; | |
8996 v36[3].pos.z = 0.0; | |
8997 v36[3].rhw = 1.0; | |
8998 v36[3].texcoord.x = 0.0; | |
8999 v36[3].texcoord.y = 0.0; | |
9000 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 9001 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
9002 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9003 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9004 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
9005 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
9006 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9007 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 9008 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
9009 D3DPT_TRIANGLEFAN, | |
9010 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9011 v36, | |
9012 4, | |
9013 28)); | |
186 | 9014 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
9015 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9016 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9017 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9018 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9019 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
0 | 9020 } |
9021 else | |
9022 { | |
9023 v40 = (1.0 - a3) * 65536.0; | |
9024 v39 = v40 + 6.7553994e15; | |
9025 LODWORD(a3) = LODWORD(v39); | |
693 | 9026 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
9027 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
9028 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
9029 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 9030 v37 = 2 * v13; |
9031 LODWORD(v40) = (int)v14; | |
9032 | |
9033 int __i = 0; | |
9034 v15 = dword_F1B430; | |
9035 do | |
9036 { | |
9037 v16 = v3; | |
9038 v3 += LODWORD(a3); | |
9039 dword_F1B430[__i++] = v16 >> 16; | |
9040 } | |
9041 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
9042 while (__i < 32); | |
9043 | |
9044 if ( pRenderer->uTargetGBits == 6 ) | |
9045 { | |
9046 v17 = _42690D_colors_cvt(this_); | |
9047 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); | |
9048 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); | |
9049 v19 = v40; | |
9050 v20 = off_4EFDB0; | |
9051 v21 = HIDWORD(v39); | |
9052 do | |
9053 { | |
9054 v22 = v38; | |
9055 v31 = v21; | |
9056 do | |
9057 { | |
9058 v23 = (*(int *)((char *)v20 | |
9059 + ((((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; | |
9060 result = this_ | |
9061 + (*((int *)v20 | |
9062 + (((unsigned __int8)(*((char *)v20 | |
9063 + ((((unsigned __int16)(*(short *)((char *)v20 | |
9064 + ((*(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); | |
9065 *(unsigned int *)LODWORD(v19) = result; | |
9066 LODWORD(v19) += 4; | |
9067 --v22; | |
9068 } | |
9069 while ( v22 ); | |
9070 LODWORD(v19) += v37; | |
9071 v21 = v31 - 1; | |
9072 } | |
9073 while ( v31 != 1 ); | |
9074 } | |
9075 else | |
9076 { | |
9077 v24 = _4268E3_smthn_to_a1r5g5b5(this_); | |
9078 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); | |
9079 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
9080 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
9081 v26 = v40; | |
9082 v27 = (char *)off_4EFDB0; | |
9083 v28 = HIDWORD(v39); | |
9084 do | |
9085 { | |
9086 v29 = v38; | |
9087 v32 = v28; | |
9088 do | |
9089 { | |
9090 v30 = 32 | |
9091 * *(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; | |
9092 result = this_ | |
9093 + (*(int *)&v27[4 | |
9094 * (((unsigned __int8)(32 | |
9095 * 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); | |
9096 *(unsigned int *)LODWORD(v26) = result; | |
9097 LODWORD(v26) += 4; | |
9098 --v29; | |
9099 } | |
9100 while ( v29 ); | |
9101 LODWORD(v26) += v37; | |
9102 v28 = v32 - 1; | |
9103 } | |
9104 while ( v32 != 1 ); | |
9105 } | |
9106 } | |
9107 return result; | |
9108 } | |
9109 | |
9110 //----- (004A5B81) -------------------------------------------------------- | |
727 | 9111 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 9112 { |
9113 this->bClip = 1; | |
9114 this->uClipY = uY; | |
9115 this->uClipX = uX; | |
9116 this->uClipW = uW; | |
9117 this->uClipZ = uZ; | |
9118 } | |
9119 | |
9120 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 9121 void Render::ResetTextureClipRect() |
0 | 9122 { |
9123 this->uClipY = 0; | |
9124 this->uClipX = 0; | |
9125 this->bClip = 1; | |
9126 this->uClipW = 480; | |
9127 this->uClipZ = 640; | |
9128 } | |
9129 | |
9130 //----- (004A5BE3) -------------------------------------------------------- | |
9131 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
9132 { | |
9133 int v4; // edi@3 | |
9134 unsigned __int16 *v5; // edx@3 | |
9135 unsigned __int16 *v6; // esi@3 | |
9136 unsigned int v7; // ebx@4 | |
9137 unsigned int v8; // eax@5 | |
9138 unsigned int v9; // ebx@5 | |
9139 unsigned int v10; // eax@6 | |
9140 unsigned int v11; // eax@7 | |
9141 unsigned int v12; // ebx@8 | |
9142 unsigned int v13; // eax@10 | |
9143 unsigned int v14; // edi@11 | |
9144 unsigned int v15; // eax@14 | |
9145 unsigned int v16; // ebx@17 | |
9146 int v17; // eax@23 | |
9147 char v18; // zf@25 | |
9148 int v19; // [sp+10h] [bp-8h]@3 | |
9149 int v20; // [sp+14h] [bp-4h]@3 | |
9150 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
9151 int uOutXb; // [sp+20h] [bp+8h]@21 | |
9152 int v23; // [sp+28h] [bp+10h]@3 | |
9153 | |
9154 if ( this->uNumSceneBegins && a4 ) | |
9155 { | |
9156 v4 = a4->uWidth; | |
9157 v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
9158 v6 = a4->pPixels; | |
9159 v20 = v4; | |
9160 v23 = a4->uHeight; | |
9161 v19 = v4; | |
9162 if ( this->bClip ) | |
9163 { | |
9164 v7 = this->uClipX; | |
9165 if ( (signed int)uOutX < (signed int)v7 ) | |
9166 { | |
9167 v8 = v7 - uOutX; | |
9168 v9 = uOutX - v7; | |
9169 v8 *= 2; | |
9170 v4 += v9; | |
9171 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
9172 v20 += v9; | |
9173 v5 = (unsigned __int16 *)((char *)v5 + v8); | |
9174 } | |
9175 v10 = this->uClipY; | |
9176 if ( (signed int)uOutY < (signed int)v10 ) | |
9177 { | |
9178 v11 = v10 - uOutY; | |
9179 v6 += v19 * v11; | |
9180 v23 += uOutY - this->uClipY; | |
9181 v4 = v20; | |
9182 v5 += this->uTargetSurfacePitch * v11; | |
9183 } | |
9184 v12 = this->uClipX; | |
9185 if ( (signed int)v12 < (signed int)uOutX ) | |
9186 v12 = uOutX; | |
9187 v13 = this->uClipZ; | |
9188 if ( (signed int)(v4 + v12) > (signed int)v13 ) | |
9189 { | |
9190 v14 = this->uClipX; | |
9191 if ( (signed int)v14 < (signed int)uOutX ) | |
9192 v14 = uOutX; | |
9193 v4 = v13 - v14; | |
9194 } | |
9195 v15 = this->uClipY; | |
9196 if ( (signed int)v15 < (signed int)uOutY ) | |
9197 v15 = uOutY; | |
9198 uOutXa = this->uClipW; | |
9199 if ( (signed int)(v15 + v23) > (signed int)uOutXa ) | |
9200 { | |
9201 v16 = this->uClipY; | |
9202 if ( (signed int)v16 < (signed int)uOutY ) | |
9203 v16 = uOutY; | |
9204 v23 = uOutXa - v16; | |
9205 } | |
9206 } | |
9207 if ( v23 > 0 ) | |
9208 { | |
9209 uOutXb = v23; | |
9210 do | |
9211 { | |
9212 if ( v4 > 0 ) | |
9213 { | |
9214 v17 = v4; | |
9215 do | |
9216 { | |
9217 *v5 = *v6; | |
9218 ++v5; | |
9219 ++v6; | |
9220 --v17; | |
9221 } | |
9222 while ( v17 ); | |
9223 } | |
9224 v6 += v19 - v4; | |
9225 v18 = uOutXb-- == 1; | |
9226 v5 += this->uTargetSurfacePitch - v4; | |
9227 } | |
9228 while ( !v18 ); | |
9229 } | |
9230 } | |
9231 } | |
9232 | |
9233 //----- (004A5D33) -------------------------------------------------------- | |
9234 void Render::_4A5D33(unsigned int pX, unsigned int pY, int a4, int a5, RGBTexture *pTexture) | |
9235 { | |
9236 Render *v6; // esi@1 | |
9237 unsigned __int16 *v7; // ebx@3 | |
9238 int v8; // ecx@3 | |
9239 int v9; // edx@3 | |
9240 int v10; // ecx@3 | |
9241 int v11; // edi@3 | |
9242 signed int v12; // eax@4 | |
9243 unsigned int v13; // eax@5 | |
9244 signed int v14; // eax@6 | |
9245 unsigned int v15; // eax@7 | |
9246 unsigned int v16; // edx@8 | |
9247 int v17; // eax@10 | |
9248 unsigned int v18; // ecx@11 | |
9249 unsigned int v19; // ecx@14 | |
9250 int v20; // eax@16 | |
9251 unsigned int v21; // ecx@17 | |
9252 int v22; // eax@21 | |
9253 int v23; // edi@23 | |
9254 int v24; // [sp+Ch] [bp-4h]@3 | |
9255 int a2a; // [sp+18h] [bp+8h]@21 | |
9256 unsigned int teal; // [sp+1Ch] [bp+Ch]@20 | |
9257 int a4a; // [sp+20h] [bp+10h]@3 | |
9258 int a4b; // [sp+20h] [bp+10h]@21 | |
9259 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 | |
9260 | |
9261 v6 = this; | |
9262 if ( this->uNumSceneBegins && pTexture ) | |
9263 { | |
9264 v7 = &this->pTargetSurface[pX + pY * this->uTargetSurfacePitch]; | |
9265 v8 = pTexture->uWidth; | |
9266 v24 = pTexture->uWidth; | |
9267 v9 = a4 + a5 * v8; | |
9268 v10 = v8 - a4; | |
9269 a4a = v10; | |
9270 v11 = pTexture->uHeight - a5; | |
9271 pTexturea = &pTexture->pPixels[v9]; | |
9272 if ( v6->bClip ) | |
9273 { | |
9274 v12 = v6->uClipX; | |
9275 if ( (signed int)pX < v12 ) | |
9276 { | |
9277 v13 = 2 * (v12 - pX); | |
9278 pTexturea = (unsigned __int16 *)((char *)pTexturea + v13); | |
9279 v10 += pX - v6->uClipX; | |
9280 v7 = (unsigned __int16 *)((char *)v7 + v13); | |
9281 a4a = v10; | |
9282 } | |
9283 v14 = v6->uClipY; | |
9284 if ( (signed int)pY < v14 ) | |
9285 { | |
9286 v15 = v14 - pY; | |
9287 pTexturea += v24 * v15; | |
9288 v11 += pY - v6->uClipY; | |
9289 v10 = a4a; | |
9290 v7 += v6->uTargetSurfacePitch * v15; | |
9291 } | |
9292 v16 = v6->uClipX; | |
9293 if ( (signed int)v16 < (signed int)pX ) | |
9294 v16 = pX; | |
9295 v17 = v6->uClipZ; | |
9296 if ( (signed int)(v10 + v16) > v17 ) | |
9297 { | |
9298 v18 = v6->uClipX; | |
9299 if ( (signed int)v18 < (signed int)pX ) | |
9300 v18 = pX; | |
9301 a4a = v17 - v18; | |
9302 } | |
9303 v19 = v6->uClipY; | |
9304 if ( (signed int)v19 < (signed int)pY ) | |
9305 v19 = pY; | |
9306 v20 = v6->uClipW; | |
9307 if ( (signed int)(v11 + v19) > v20 ) | |
9308 { | |
9309 v21 = v6->uClipY; | |
9310 if ( (signed int)v21 < (signed int)pY ) | |
9311 v21 = pY; | |
9312 v11 = v20 - v21; | |
9313 } | |
9314 } | |
949 | 9315 teal = TargetColor(0, 0xFFu, 0xFFu); |
0 | 9316 if ( v11 > 0 ) |
9317 { | |
9318 v22 = a4a; | |
9319 a2a = v11; | |
9320 a4b = 2 * (v24 - a4a); | |
9321 do | |
9322 { | |
9323 if ( v22 > 0 ) | |
9324 { | |
9325 v23 = v22; | |
9326 do | |
9327 { | |
9328 if ( *pTexturea != teal ) | |
9329 *v7 = *pTexturea; | |
9330 ++pTexturea; | |
9331 ++v7; | |
9332 --v23; | |
9333 } | |
9334 while ( v23 ); | |
9335 } | |
9336 v7 += v6->uTargetSurfacePitch - v22; | |
9337 pTexturea = (unsigned __int16 *)((char *)pTexturea + a4b); | |
9338 --a2a; | |
9339 } | |
9340 while ( a2a ); | |
9341 } | |
9342 } | |
9343 } | |
9344 | |
9345 //----- (004A6E7E) -------------------------------------------------------- | |
9346 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) | |
9347 { | |
9348 unsigned __int16 *v4; // eax@4 | |
9349 int v5; // edx@4 | |
9350 unsigned int v6; // edi@4 | |
9351 unsigned int v7; // edx@5 | |
9352 unsigned int v8; // edx@6 | |
9353 unsigned int v9; // edx@7 | |
9354 unsigned int v10; // edx@8 | |
9355 unsigned int v11; // ebx@9 | |
9356 unsigned int v12; // esi@11 | |
9357 unsigned int v13; // edx@12 | |
9358 unsigned int v14; // ebx@15 | |
9359 unsigned int v15; // esi@17 | |
9360 unsigned int v16; // edi@18 | |
9361 char v17; // zf@29 | |
9362 int v18; // [sp+14h] [bp-Ch]@4 | |
9363 int v19; // [sp+18h] [bp-8h]@4 | |
9364 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
9365 int v21; // [sp+28h] [bp+8h]@25 | |
9366 int v22; // [sp+28h] [bp+8h]@34 | |
9367 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
9368 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
9369 | |
9370 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
9371 { | |
9372 v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 9373 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 9374 v5 = a4->uTextureWidth; |
9375 v6 = a4->uTextureHeight; | |
9376 v19 = a4->uTextureWidth; | |
9377 v18 = a4->uTextureWidth; | |
9378 if ( this->bClip ) | |
9379 { | |
9380 v7 = this->uClipX; | |
9381 if ( (signed int)a2 < (signed int)v7 ) | |
9382 { | |
9383 v8 = v7 - a2; | |
9384 v20 += v8; | |
9385 v19 += a2 - this->uClipX; | |
9386 v4 += v8; | |
9387 } | |
9388 v9 = this->uClipY; | |
9389 if ( (signed int)a3 < (signed int)v9 ) | |
9390 { | |
9391 v10 = v9 - a3; | |
9392 v20 += v18 * v10; | |
9393 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
9394 v4 += this->uTargetSurfacePitch * v10; | |
9395 } | |
9396 v11 = this->uClipX; | |
9397 v5 = v19; | |
9398 if ( (signed int)v11 < (signed int)a2 ) | |
9399 v11 = a2; | |
9400 v12 = this->uClipZ; | |
9401 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
9402 { | |
9403 v13 = this->uClipX; | |
9404 if ( (signed int)v13 < (signed int)a2 ) | |
9405 v13 = a2; | |
9406 v5 = v12 - v13; | |
9407 } | |
9408 v14 = this->uClipY; | |
9409 if ( (signed int)v14 < (signed int)a3 ) | |
9410 v14 = a3; | |
9411 v15 = this->uClipW; | |
9412 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
9413 { | |
9414 v16 = this->uClipY; | |
9415 if ( (signed int)v16 < (signed int)a3 ) | |
9416 v16 = a3; | |
9417 v6 = v15 - v16; | |
9418 } | |
9419 } | |
9420 if ( pRenderer->uTargetGBits == 5 ) | |
9421 { | |
9422 if ( (signed int)v6 > 0 ) | |
9423 { | |
9424 v23 = v6; | |
9425 do | |
9426 { | |
9427 if ( v5 > 0 ) | |
9428 { | |
9429 v21 = v5; | |
9430 do | |
9431 { | |
9432 if ( *v20 ) | |
9433 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
9434 ++v4; | |
9435 ++v20; | |
9436 --v21; | |
9437 } | |
9438 while ( v21 ); | |
9439 } | |
9440 v20 += v18 - v5; | |
9441 v17 = v23-- == 1; | |
9442 v4 += this->uTargetSurfacePitch - v5; | |
9443 } | |
9444 while ( !v17 ); | |
9445 } | |
9446 } | |
9447 else | |
9448 { | |
9449 if ( (signed int)v6 > 0 ) | |
9450 { | |
9451 v24 = v6; | |
9452 do | |
9453 { | |
9454 if ( v5 > 0 ) | |
9455 { | |
9456 v22 = v5; | |
9457 do | |
9458 { | |
9459 if ( *v20 ) | |
9460 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
9461 ++v4; | |
9462 ++v20; | |
9463 --v22; | |
9464 } | |
9465 while ( v22 ); | |
9466 } | |
9467 v20 += v18 - v5; | |
9468 v17 = v24-- == 1; | |
9469 v4 += this->uTargetSurfacePitch - v5; | |
9470 } | |
9471 while ( !v17 ); | |
9472 } | |
9473 } | |
9474 } | |
9475 } | |
9476 | |
9477 //----- (004A6DF5) -------------------------------------------------------- | |
9478 int Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) | |
9479 { | |
9480 int result; // eax@0 | |
9481 int v8; // ecx@3 | |
9482 unsigned __int16 *v9; // edi@4 | |
9483 unsigned __int16 *v10; // ebx@4 | |
9484 int v11; // esi@4 | |
9485 unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3 | |
9486 unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3 | |
9487 | |
9488 if ( pBitmap ) | |
9489 { | |
9490 if ( pTarget ) | |
9491 { | |
9492 pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y]; | |
9493 pTargeta = &pTarget[a7->x + uTargetPitch * a7->y]; | |
9494 v8 = a7->z - a7->x; | |
9495 result = a7->w - a7->y; | |
9496 if ( result > 0 ) | |
9497 { | |
9498 v9 = pBitmapa; | |
9499 v10 = pTargeta; | |
9500 v11 = a7->w - a7->y; | |
9501 do | |
9502 { | |
9503 if ( v8 > 0 ) | |
9504 { | |
9505 result = v8; | |
9506 do | |
9507 { | |
9508 *v9 = *v10; | |
9509 ++v9; | |
9510 ++v10; | |
9511 --result; | |
9512 } | |
9513 while ( result ); | |
9514 } | |
9515 v9 += uBitmapPitch - v8; | |
9516 v10 += uTargetPitch - v8; | |
9517 --v11; | |
9518 } | |
9519 while ( v11 ); | |
9520 } | |
9521 } | |
9522 } | |
9523 return result; | |
9524 } | |
9525 | |
9526 //----- (004A6D87) -------------------------------------------------------- | |
9527 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
9528 { | |
9529 if (!uNumSceneBegins) | |
9530 return; | |
9531 | |
9532 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
9533 for (uint y = 0; y < uHeight; ++y) | |
9534 { | |
9535 auto pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch]; | |
9536 | |
9537 memset32(pDst, twoColors, uWidth / 2); | |
9538 if (uWidth & 1) | |
9539 pDst[uWidth - 1] = uColor16; | |
9540 } | |
9541 } | |
9542 | |
9543 //----- (004A6C4F) -------------------------------------------------------- | |
9544 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) | |
9545 { | |
9546 unsigned int v9; // edi@2 | |
9547 unsigned int v10; // esi@2 | |
9548 unsigned __int16 *v11; // eax@2 | |
9549 unsigned int v12; // ebx@3 | |
9550 signed int v13; // edx@5 | |
9551 int v14; // edx@6 | |
9552 signed int v15; // ebx@7 | |
9553 unsigned int v16; // edx@9 | |
9554 signed int v17; // edi@10 | |
9555 signed int v18; // ebx@13 | |
9556 unsigned int v19; // edx@15 | |
9557 signed int v20; // esi@16 | |
9558 unsigned int v21; // esi@22 | |
9559 unsigned __int16 v22; // dx@24 | |
9560 char v23; // zf@28 | |
9561 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 | |
9562 unsigned int uOutXa; // [sp+18h] [bp+8h]@20 | |
9563 | |
9564 if ( this->uNumSceneBegins ) | |
9565 { | |
9566 v9 = uCharWidth; | |
9567 v10 = uCharHeight; | |
9568 v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
9569 v24 = pFontPixels; | |
9570 if ( this->bClip ) | |
9571 { | |
9572 v12 = this->uClipX; | |
9573 if ( uOutX < (signed int)v12 ) | |
9574 { | |
9575 v24 = &pFontPixels[v12 - uOutX]; | |
9576 v11 += v12 - uOutX; | |
9577 v9 = uCharWidth + uOutX - v12; | |
9578 } | |
9579 v13 = this->uClipY; | |
9580 if ( uOutY < v13 ) | |
9581 { | |
9582 v14 = v13 - uOutY; | |
9583 v24 += uCharWidth * v14; | |
9584 v10 = uCharHeight + uOutY - this->uClipY; | |
9585 v11 += this->uTargetSurfacePitch * v14; | |
9586 } | |
9587 v15 = this->uClipX; | |
9588 if ( v15 < uOutX ) | |
9589 v15 = uOutX; | |
9590 v16 = this->uClipZ; | |
9591 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
9592 { | |
9593 v17 = this->uClipX; | |
9594 if ( v17 < uOutX ) | |
9595 v17 = uOutX; | |
9596 v9 = v16 - v17; | |
9597 } | |
9598 v18 = this->uClipY; | |
9599 if ( v18 < uOutY ) | |
9600 v18 = uOutY; | |
9601 v19 = this->uClipW; | |
9602 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
9603 { | |
9604 v20 = this->uClipY; | |
9605 if ( v20 < uOutY ) | |
9606 v20 = uOutY; | |
9607 v10 = v19 - v20; | |
9608 } | |
9609 } | |
9610 if ( (signed int)v10 > 0 ) | |
9611 { | |
9612 uOutXa = v10; | |
9613 do | |
9614 { | |
9615 if ( (signed int)v9 > 0 ) | |
9616 { | |
9617 v21 = v9; | |
9618 do | |
9619 { | |
9620 if ( *v24 ) | |
9621 { | |
9622 v22 = uShadowColor; | |
9623 if ( *v24 != 1 ) | |
9624 v22 = uFaceColor; | |
9625 *v11 = v22; | |
9626 } | |
9627 ++v11; | |
9628 ++v24; | |
9629 --v21; | |
9630 } | |
9631 while ( v21 ); | |
9632 } | |
9633 v24 += uCharWidth - v9; | |
9634 v23 = uOutXa-- == 1; | |
9635 v11 += this->uTargetSurfacePitch - v9; | |
9636 } | |
9637 while ( !v23 ); | |
9638 } | |
9639 } | |
9640 } | |
9641 | |
9642 //----- (004A6A68) -------------------------------------------------------- | |
9643 void Render::_4A6A68(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) | |
9644 { | |
9645 Render *v5; // ebx@1 | |
9646 unsigned __int16 v6; // ax@1 | |
9647 | |
9648 v5 = this; | |
9649 | |
9650 Texture tex; // [sp+Ch] [bp-48h]@1 | |
9651 //Texture::Texture(&tex); | |
9652 | |
9653 v6 = a4->uTextureHeight - height; | |
9654 memcpy(&tex, a4, sizeof(tex)); | |
9655 tex.uTextureHeight = v6; | |
9656 if ( (signed __int16)v6 > 0 ) | |
9657 DrawTextureIndexed(a2, a3, &tex); | |
9658 } | |
9659 | |
9660 //----- (004A6AB1) -------------------------------------------------------- | |
9661 void Render::DrawTextPalette(int x, int y, int a4, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8) | |
9662 { | |
9663 int v8; // edi@2 | |
9664 unsigned int v9; // esi@2 | |
9665 unsigned __int16 *v10; // eax@2 | |
9666 unsigned char *v11; // edx@2 | |
9667 unsigned int v12; // ebx@3 | |
9668 signed int v13; // edx@5 | |
9669 int v14; // edx@6 | |
9670 signed int v15; // ebx@7 | |
9671 unsigned int v16; // edx@9 | |
9672 signed int v17; // edi@10 | |
9673 signed int v18; // ebx@13 | |
9674 unsigned int v19; // edx@15 | |
9675 signed int v20; // esi@16 | |
9676 int v21; // ebx@22 | |
9677 char v22; // zf@28 | |
9678 int v23; // ebx@31 | |
9679 unsigned __int16 v24; // si@35 | |
9680 int v25; // [sp+Ch] [bp-4h]@2 | |
9681 int v26; // [sp+1Ch] [bp+Ch]@24 | |
9682 int v27; // [sp+1Ch] [bp+Ch]@33 | |
9683 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
9684 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
9685 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
9686 | |
9687 auto a2 = x; | |
9688 auto a3 = y; | |
9689 auto a6 = uFontHeight; | |
9690 if ( this->uNumSceneBegins ) | |
9691 { | |
9692 v8 = a5; | |
9693 v9 = a6; | |
9694 v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; | |
9695 v11 = (unsigned char *)a4; | |
9696 v25 = a4; | |
9697 if ( this->bClip ) | |
9698 { | |
9699 v12 = this->uClipX; | |
9700 if ( a2 < (signed int)v12 ) | |
9701 { | |
9702 v25 = v12 - a2 + a4; | |
9703 v10 += v12 - a2; | |
9704 v8 = a5 + a2 - v12; | |
9705 } | |
9706 v13 = this->uClipY; | |
9707 if ( a3 < v13 ) | |
9708 { | |
9709 v14 = v13 - a3; | |
9710 v25 += a5 * v14; | |
9711 v9 = a6 + a3 - this->uClipY; | |
9712 v10 += this->uTargetSurfacePitch * v14; | |
9713 } | |
9714 v15 = this->uClipX; | |
9715 if ( v15 < a2 ) | |
9716 v15 = a2; | |
9717 v16 = this->uClipZ; | |
9718 if ( v8 + v15 > (signed int)v16 ) | |
9719 { | |
9720 v17 = this->uClipX; | |
9721 if ( v17 < a2 ) | |
9722 v17 = a2; | |
9723 v8 = v16 - v17; | |
9724 } | |
9725 v18 = this->uClipY; | |
9726 if ( v18 < a3 ) | |
9727 v18 = a3; | |
9728 v19 = this->uClipW; | |
9729 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
9730 { | |
9731 v20 = this->uClipY; | |
9732 if ( v20 < a3 ) | |
9733 v20 = a3; | |
9734 v9 = v19 - v20; | |
9735 } | |
9736 v11 = (unsigned char *)v25; | |
9737 } | |
9738 if ( a8 ) | |
9739 { | |
9740 v28 = pRenderer->uTargetGMask | pRenderer->uTargetBMask; | |
9741 if ( (signed int)v9 > 0 ) | |
9742 { | |
9743 v23 = a5; | |
9744 v30 = v9; | |
9745 do | |
9746 { | |
9747 if ( v8 > 0 ) | |
9748 { | |
9749 v27 = v8; | |
9750 do | |
9751 { | |
9752 if ( *v11 ) | |
9753 v24 = pPalette[*v11]; | |
9754 else | |
9755 v24 = v28; | |
9756 *v10 = v24; | |
9757 ++v10; | |
9758 ++v11; | |
9759 --v27; | |
9760 } | |
9761 while ( v27 ); | |
9762 } | |
9763 v11 += v23 - v8; | |
9764 v22 = v30-- == 1; | |
9765 v10 += this->uTargetSurfacePitch - v8; | |
9766 } | |
9767 while ( !v22 ); | |
9768 } | |
9769 } | |
9770 else | |
9771 { | |
9772 if ( (signed int)v9 > 0 ) | |
9773 { | |
9774 v21 = a5; | |
9775 v29 = v9; | |
9776 do | |
9777 { | |
9778 if ( v8 > 0 ) | |
9779 { | |
9780 v26 = v8; | |
9781 do | |
9782 { | |
9783 if ( *v11 ) | |
9784 *v10 = pPalette[*v11]; | |
9785 ++v10; | |
9786 ++v11; | |
9787 --v26; | |
9788 } | |
9789 while ( v26 ); | |
9790 } | |
9791 v11 += v21 - v8; | |
9792 v22 = v29-- == 1; | |
9793 v10 += this->uTargetSurfacePitch - v8; | |
9794 } | |
9795 while ( !v22 ); | |
9796 } | |
9797 } | |
9798 } | |
9799 } | |
9800 | |
9801 //----- (004A68EF) -------------------------------------------------------- | |
9802 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
9803 { | |
9804 Texture *v4; // edi@2 | |
9805 unsigned int v5; // ebx@4 | |
9806 unsigned __int16 *v6; // eax@4 | |
9807 signed int v7; // edx@5 | |
9808 int v8; // edx@6 | |
9809 signed int v9; // edx@7 | |
9810 int v10; // edx@8 | |
9811 signed int v11; // edx@9 | |
9812 signed int v12; // esi@12 | |
9813 signed int v13; // esi@15 | |
9814 unsigned int v14; // edx@17 | |
9815 signed int v15; // esi@18 | |
9816 unsigned __int8 *v16; // ebx@22 | |
9817 char v17; // zf@28 | |
9818 int v18; // [sp+10h] [bp-10h]@4 | |
9819 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
9820 int v20; // [sp+1Ch] [bp-4h]@4 | |
9821 int v21; // [sp+28h] [bp+8h]@24 | |
9822 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
9823 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
9824 | |
9825 if ( this->uNumSceneBegins ) | |
9826 { | |
9827 v4 = pTexture; | |
9828 if ( pTexture ) | |
9829 { | |
9830 if ( pTexture->pPalette16 ) | |
9831 { | |
9832 v5 = pTexture->uTextureHeight; | |
9833 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 9834 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 9835 v20 = pTexture->uTextureWidth; |
9836 v18 = pTexture->uTextureWidth; | |
9837 if ( this->bClip ) | |
9838 { | |
9839 v7 = this->uClipX; | |
9840 if ( a2 < v7 ) | |
9841 { | |
9842 v8 = v7 - a2; | |
9843 v19 += v8; | |
9844 v20 += a2 - this->uClipX; | |
9845 v6 += v8; | |
9846 } | |
9847 v9 = this->uClipY; | |
9848 v5 = pTexture->uTextureHeight; | |
9849 if ( a3 < v9 ) | |
9850 { | |
9851 v10 = v9 - a3; | |
9852 v19 += v18 * v10; | |
9853 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
9854 v4 = pTexture; | |
9855 v6 += this->uTargetSurfacePitch * v10; | |
9856 } | |
9857 v11 = this->uClipX; | |
9858 if ( v11 < a2 ) | |
9859 v11 = a2; | |
9860 pTexturea = this->uClipZ; | |
9861 if ( v11 + v20 > (signed int)pTexturea ) | |
9862 { | |
9863 v12 = this->uClipX; | |
9864 if ( v12 < a2 ) | |
9865 v12 = a2; | |
9866 v20 = pTexturea - v12; | |
9867 } | |
9868 v13 = this->uClipY; | |
9869 if ( v13 < a3 ) | |
9870 v13 = a3; | |
9871 v14 = this->uClipW; | |
9872 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
9873 { | |
9874 v15 = this->uClipY; | |
9875 if ( v15 < a3 ) | |
9876 v15 = a3; | |
9877 v5 = v14 - v15; | |
9878 } | |
9879 } | |
9880 if ( (signed int)v5 > 0 ) | |
9881 { | |
9882 v22 = v5; | |
9883 v16 = v19; | |
9884 do | |
9885 { | |
9886 if ( v20 > 0 ) | |
9887 { | |
9888 v21 = v20; | |
9889 do | |
9890 { | |
9891 if ( *v16 ) | |
9892 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
9893 ++v6; | |
9894 ++v16; | |
9895 --v21; | |
9896 } | |
9897 while ( v21 ); | |
9898 } | |
9899 v16 += v18 - v20; | |
9900 v17 = v22-- == 1; | |
9901 v6 += this->uTargetSurfacePitch - v20; | |
9902 } | |
9903 while ( !v17 ); | |
9904 } | |
9905 } | |
9906 } | |
9907 } | |
9908 } | |
9909 | |
9910 //----- (004A6776) -------------------------------------------------------- | |
315 | 9911 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 9912 { |
9913 Texture *v4; // edi@2 | |
9914 unsigned int v5; // ebx@4 | |
9915 unsigned __int16 *v6; // eax@4 | |
9916 unsigned int v7; // edx@5 | |
9917 unsigned int v8; // edx@6 | |
9918 unsigned int v9; // edx@7 | |
9919 unsigned int v10; // edx@8 | |
9920 unsigned int v11; // edx@9 | |
9921 unsigned int v12; // esi@12 | |
9922 unsigned int v13; // esi@15 | |
9923 unsigned int v14; // edx@17 | |
9924 unsigned int v15; // esi@18 | |
9925 unsigned __int8 *v16; // ebx@22 | |
9926 char v17; // zf@28 | |
9927 int v18; // [sp+10h] [bp-10h]@4 | |
9928 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
9929 int v20; // [sp+1Ch] [bp-4h]@4 | |
9930 int a2a; // [sp+28h] [bp+8h]@24 | |
9931 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
9932 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
9933 | |
9934 if ( this->uNumSceneBegins ) | |
9935 { | |
9936 v4 = a4; | |
9937 if ( a4 ) | |
9938 { | |
9939 if ( a4->pPalette16 ) | |
9940 { | |
9941 v5 = a4->uTextureHeight; | |
9942 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 9943 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 9944 v20 = a4->uTextureWidth; |
9945 v18 = a4->uTextureWidth; | |
9946 if ( this->bClip ) | |
9947 { | |
9948 v7 = this->uClipX; | |
9949 if ( (signed int)a2 < (signed int)v7 ) | |
9950 { | |
9951 v8 = v7 - a2; | |
9952 v19 += v8; | |
9953 v20 += a2 - this->uClipX; | |
9954 v6 += v8; | |
9955 } | |
9956 v9 = this->uClipY; | |
9957 v5 = a4->uTextureHeight; | |
9958 if ( (signed int)a3 < (signed int)v9 ) | |
9959 { | |
9960 v10 = v9 - a3; | |
9961 v19 += v18 * v10; | |
9962 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
9963 v4 = a4; | |
9964 v6 += this->uTargetSurfacePitch * v10; | |
9965 } | |
9966 v11 = this->uClipX; | |
9967 if ( (signed int)v11 < (signed int)a2 ) | |
9968 v11 = a2; | |
9969 a4a = this->uClipZ; | |
9970 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
9971 { | |
9972 v12 = this->uClipX; | |
9973 if ( (signed int)v12 < (signed int)a2 ) | |
9974 v12 = a2; | |
9975 v20 = a4a - v12; | |
9976 } | |
9977 v13 = this->uClipY; | |
9978 if ( (signed int)v13 < (signed int)a3 ) | |
9979 v13 = a3; | |
9980 v14 = this->uClipW; | |
9981 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
9982 { | |
9983 v15 = this->uClipY; | |
9984 if ( (signed int)v15 < (signed int)a3 ) | |
9985 v15 = a3; | |
9986 v5 = v14 - v15; | |
9987 } | |
9988 } | |
9989 if ( (signed int)v5 > 0 ) | |
9990 { | |
9991 a3a = v5; | |
9992 v16 = v19; | |
9993 do | |
9994 { | |
9995 if ( v20 > 0 ) | |
9996 { | |
9997 a2a = v20; | |
9998 do | |
9999 { | |
10000 if ( *v16 ) | |
10001 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
10002 ++v6; | |
10003 ++v16; | |
10004 --a2a; | |
10005 } | |
10006 while ( a2a ); | |
10007 } | |
10008 v16 += v18 - v20; | |
10009 v17 = a3a-- == 1; | |
10010 v6 += this->uTargetSurfacePitch - v20; | |
10011 } | |
10012 while ( !v17 ); | |
10013 } | |
10014 } | |
10015 } | |
10016 } | |
10017 } | |
10018 | |
10019 //----- (004A65CC) -------------------------------------------------------- | |
10020 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
10021 { | |
10022 unsigned __int16 *v8; // esi@6 | |
10023 unsigned int v9; // edi@6 | |
10024 unsigned int v10; // eax@7 | |
10025 unsigned int v11; // eax@8 | |
10026 unsigned int v12; // eax@9 | |
10027 unsigned int v13; // eax@10 | |
10028 unsigned int v14; // edx@11 | |
10029 unsigned int v15; // eax@13 | |
10030 unsigned int v16; // edx@14 | |
10031 unsigned int v17; // edx@17 | |
10032 unsigned int v18; // eax@19 | |
10033 unsigned int v19; // edx@20 | |
10034 int v20; // eax@27 | |
10035 int v21; // edx@29 | |
10036 int v22; // [sp+Ch] [bp-Ch]@6 | |
10037 int v23; // [sp+Ch] [bp-Ch]@24 | |
10038 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
10039 int xa; // [sp+20h] [bp+8h]@26 | |
10040 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
10041 int v27; // [sp+2Ch] [bp+14h]@6 | |
10042 | |
10043 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
10044 { | |
10045 v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch]; | |
710 | 10046 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10047 v27 = a4->uTextureWidth; |
10048 v9 = a4->uTextureHeight; | |
10049 v22 = a4->uTextureWidth; | |
10050 if ( this->bClip ) | |
10051 { | |
10052 v10 = this->uClipX; | |
10053 if ( (signed int)x < (signed int)v10 ) | |
10054 { | |
10055 v11 = v10 - x; | |
10056 v24 += v11; | |
10057 v27 += x - this->uClipX; | |
10058 v8 += v11; | |
10059 } | |
10060 v12 = this->uClipY; | |
10061 if ( (signed int)y < (signed int)v12 ) | |
10062 { | |
10063 v13 = v12 - y; | |
10064 v24 += v22 * v13; | |
10065 v9 = y - this->uClipY + a4->uTextureHeight; | |
10066 v8 += this->uTargetSurfacePitch * v13; | |
10067 } | |
10068 v14 = this->uClipX; | |
10069 if ( (signed int)v14 < (signed int)x ) | |
10070 v14 = x; | |
10071 v15 = this->uClipZ; | |
10072 if ( (signed int)(v27 + v14) > (signed int)v15 ) | |
10073 { | |
10074 v16 = this->uClipX; | |
10075 if ( (signed int)v16 < (signed int)x ) | |
10076 v16 = x; | |
10077 v27 = v15 - v16; | |
10078 } | |
10079 v17 = this->uClipY; | |
10080 if ( (signed int)v17 < (signed int)y ) | |
10081 v17 = y; | |
10082 v18 = this->uClipW; | |
10083 if ( (signed int)(v9 + v17) > (signed int)v18 ) | |
10084 { | |
10085 v19 = this->uClipY; | |
10086 if ( (signed int)v19 < (signed int)y ) | |
10087 v19 = y; | |
10088 v9 = v18 - v19; | |
10089 } | |
10090 } | |
10091 if ( (signed int)v9 > 0 ) | |
10092 { | |
10093 ya = v9; | |
10094 v23 = v22 - v27; | |
10095 do | |
10096 { | |
10097 if ( v27 > 0 ) | |
10098 { | |
10099 xa = v27; | |
10100 do | |
10101 { | |
10102 v20 = *v24; | |
10103 if ( v20 >= a7 && v20 <= a8 ) | |
10104 { | |
10105 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
10106 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
10107 v21 = 2 * a8 - v21 - a7; | |
10108 *v8 = a4->pPalette16[v21]; | |
10109 } | |
10110 ++v8; | |
10111 ++v24; | |
10112 --xa; | |
10113 } | |
10114 while ( xa ); | |
10115 } | |
10116 v8 += this->uTargetSurfacePitch - v27; | |
10117 v24 += v23; | |
10118 --ya; | |
10119 } | |
10120 while ( ya ); | |
10121 } | |
10122 } | |
10123 } | |
10124 | |
10125 //----- (004A63E6) -------------------------------------------------------- | |
10126 void Render::_4A63E6(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
10127 { | |
10128 Texture *v8; // eax@2 | |
10129 Texture *v9; // ebx@4 | |
10130 unsigned __int16 *v10; // esi@6 | |
10131 unsigned int v11; // edi@7 | |
10132 unsigned int v12; // eax@9 | |
10133 unsigned int v13; // eax@10 | |
10134 unsigned int v14; // edx@11 | |
10135 unsigned int v15; // eax@13 | |
10136 unsigned int v16; // edx@14 | |
10137 unsigned int v17; // edx@17 | |
10138 unsigned int v18; // eax@19 | |
10139 unsigned int v19; // edx@20 | |
10140 int v20; // eax@27 | |
10141 int v21; // edx@29 | |
10142 int v22; // [sp+Ch] [bp-Ch]@6 | |
10143 int v23; // [sp+Ch] [bp-Ch]@24 | |
10144 int v24; // [sp+10h] [bp-8h]@6 | |
10145 int v25; // [sp+14h] [bp-4h]@6 | |
10146 int i; // [sp+20h] [bp+8h]@25 | |
10147 int v27; // [sp+24h] [bp+Ch]@23 | |
10148 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
10149 | |
10150 if ( this->uNumSceneBegins ) | |
10151 { | |
10152 v8 = a4; | |
10153 if ( a4 ) | |
10154 { | |
10155 if ( a4->pPalette16 ) | |
10156 { | |
10157 v9 = a5; | |
10158 if ( a5 ) | |
10159 { | |
10160 if ( a5->pPalette16 ) | |
10161 { | |
10162 v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 10163 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10164 v25 = v8->uTextureWidth; |
10165 v24 = v8->uTextureHeight; | |
10166 v22 = v8->uTextureWidth; | |
10167 if ( this->bClip ) | |
10168 { | |
10169 v11 = this->uClipX; | |
10170 if ( (signed int)a2 < (signed int)v11 ) | |
10171 { | |
10172 v28 += v11 - a2; | |
10173 v25 += a2 - v11; | |
10174 v9 = a5; | |
10175 v10 += v11 - a2; | |
10176 } | |
10177 v12 = this->uClipY; | |
10178 if ( (signed int)a3 < (signed int)v12 ) | |
10179 { | |
10180 v13 = v12 - a3; | |
10181 v9 = a5; | |
10182 v28 += v22 * v13; | |
10183 v24 += a3 - this->uClipY; | |
10184 v10 += this->uTargetSurfacePitch * v13; | |
10185 } | |
10186 v14 = this->uClipX; | |
10187 if ( (signed int)v14 < (signed int)a2 ) | |
10188 v14 = a2; | |
10189 v15 = this->uClipZ; | |
10190 if ( (signed int)(v25 + v14) > (signed int)v15 ) | |
10191 { | |
10192 v16 = this->uClipX; | |
10193 if ( (signed int)v16 < (signed int)a2 ) | |
10194 v16 = a2; | |
10195 v25 = v15 - v16; | |
10196 } | |
10197 v17 = this->uClipY; | |
10198 if ( (signed int)v17 < (signed int)a3 ) | |
10199 v17 = a3; | |
10200 v18 = this->uClipW; | |
10201 if ( (signed int)(v24 + v17) > (signed int)v18 ) | |
10202 { | |
10203 v19 = this->uClipY; | |
10204 if ( (signed int)v19 < (signed int)a3 ) | |
10205 v19 = a3; | |
10206 v24 = v18 - v19; | |
10207 } | |
10208 } | |
10209 v27 = 0; | |
10210 if ( v24 > 0 ) | |
10211 { | |
10212 v23 = v22 - v25; | |
10213 do | |
10214 { | |
10215 for ( i = 0; i < v25; ++v28 ) | |
10216 { | |
10217 if ( *v28 ) | |
10218 { | |
710 | 10219 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 10220 if ( v20 >= a7 ) |
10221 { | |
10222 if ( v20 <= a8 ) | |
10223 { | |
10224 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
10225 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
10226 v21 = 2 * a8 - v21 - a7; | |
10227 v9 = a5; | |
10228 *v10 = a5->pPalette16[v21]; | |
10229 } | |
10230 } | |
10231 } | |
10232 ++i; | |
10233 ++v10; | |
10234 } | |
10235 ++v27; | |
10236 v10 += this->uTargetSurfacePitch - v25; | |
10237 v28 += v23; | |
10238 } | |
10239 while ( v27 < v24 ); | |
10240 } | |
10241 } | |
10242 } | |
10243 } | |
10244 } | |
10245 } | |
10246 } | |
10247 | |
10248 //----- (004A6274) -------------------------------------------------------- | |
10249 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
10250 { | |
10251 Texture *pCurrentTexture; // edi@2 | |
10252 int uHeight; // ebx@4 | |
10253 unsigned __int16 *v6; // eax@4 | |
10254 unsigned int v7; // edx@5 | |
10255 unsigned int v8; // edx@6 | |
10256 unsigned int v9; // edx@7 | |
10257 unsigned int v10; // edx@8 | |
10258 unsigned int v11; // edx@9 | |
10259 unsigned int v12; // esi@12 | |
10260 unsigned int v13; // esi@15 | |
10261 unsigned int v14; // edx@17 | |
10262 unsigned int v15; // esi@18 | |
10263 unsigned __int8 *v16; // ebx@22 | |
10264 char uFlag; // zf@28 | |
10265 int v18; // [sp+10h] [bp-10h]@4 | |
10266 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10267 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
10268 int uXa; // [sp+28h] [bp+8h]@24 | |
10269 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
10270 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
10271 | |
10272 if ( this->uNumSceneBegins ) | |
10273 { | |
10274 pCurrentTexture = pTexture; | |
10275 if ( pTexture ) | |
10276 { | |
10277 if ( pTexture->pPalette16 ) | |
10278 { | |
10279 uHeight = pTexture->uTextureHeight; | |
10280 v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 10281 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10282 uWidth = pTexture->uTextureWidth; |
10283 v18 = pTexture->uTextureWidth; | |
10284 if ( this->bClip ) | |
10285 { | |
10286 v7 = this->uClipX; | |
10287 if ( (signed int)uX < (signed int)v7 ) | |
10288 { | |
10289 v8 = v7 - uX; | |
10290 v19 += v8; | |
10291 uWidth += uX - this->uClipX; | |
10292 v6 += v8; | |
10293 } | |
10294 v9 = this->uClipY; | |
10295 uHeight = pTexture->uTextureHeight; | |
10296 if ( (signed int)uY < (signed int)v9 ) | |
10297 { | |
10298 v10 = v9 - uY; | |
10299 v19 += v18 * v10; | |
10300 uHeight = uY - this->uClipY + pTexture->uTextureHeight; | |
10301 pCurrentTexture = pTexture; | |
10302 v6 += this->uTargetSurfacePitch * v10; | |
10303 } | |
10304 v11 = this->uClipX; | |
10305 if ( (signed int)v11 < (signed int)uX ) | |
10306 v11 = uX; | |
10307 pTexturea = this->uClipZ; | |
10308 if ( (signed int)(v11 + uWidth) > (signed int)pTexturea ) | |
10309 { | |
10310 v12 = this->uClipX; | |
10311 if ( (signed int)v12 < (signed int)uX ) | |
10312 v12 = uX; | |
10313 uWidth = pTexturea - v12; | |
10314 } | |
10315 v13 = this->uClipY; | |
10316 if ( (signed int)v13 < (signed int)uY ) | |
10317 v13 = uY; | |
10318 v14 = this->uClipW; | |
10319 if ( (signed int)(uHeight + v13) > (signed int)v14 ) | |
10320 { | |
10321 v15 = this->uClipY; | |
10322 if ( (signed int)v15 < (signed int)uY ) | |
10323 v15 = uY; | |
10324 uHeight = v14 - v15; | |
10325 } | |
10326 } | |
10327 if ( (signed int)uHeight > 0 ) | |
10328 { | |
10329 uYa = uHeight; | |
10330 v16 = v19; | |
10331 do | |
10332 { | |
10333 if ( uWidth > 0 ) | |
10334 { | |
10335 uXa = uWidth; | |
10336 do | |
10337 { | |
10338 if ( *v16 ) | |
10339 *v6 = pCurrentTexture->pPalette16[*v16]; | |
10340 ++v6; | |
10341 ++v16; | |
10342 } | |
10343 while ( uXa-- !=1 ); | |
10344 } | |
10345 v16 += v18 - uWidth; | |
10346 uFlag = uYa-- == 1; | |
10347 v6 += this->uTargetSurfacePitch - uWidth; | |
10348 } | |
10349 while ( !uFlag ); | |
10350 } | |
10351 } | |
10352 } | |
10353 } | |
10354 } | |
10355 | |
10356 //----- (004A612A) -------------------------------------------------------- | |
710 | 10357 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 10358 { |
10359 Texture *v5; // eax@2 | |
10360 unsigned int v6; // edx@3 | |
10361 int v7; // ebx@3 | |
10362 int v8; // edi@3 | |
10363 signed int v9; // eax@4 | |
10364 int v10; // eax@5 | |
10365 unsigned int v11; // esi@6 | |
10366 signed int v12; // esi@8 | |
10367 unsigned int v13; // eax@10 | |
10368 signed int v14; // esi@11 | |
10369 unsigned int v15; // esi@14 | |
10370 unsigned int v16; // eax@16 | |
10371 unsigned int v17; // ecx@17 | |
10372 int v18; // edx@23 | |
10373 int v19; // [sp+Ch] [bp-Ch]@3 | |
10374 int v20; // [sp+10h] [bp-8h]@3 | |
10375 int uOutXa; // [sp+20h] [bp+8h]@21 | |
10376 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
10377 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
10378 | |
10379 if ( this->uNumSceneBegins ) | |
10380 { | |
10381 v5 = pTexture; | |
10382 if ( pTexture ) | |
10383 { | |
10384 v6 = uOutY; | |
10385 v7 = pTexture->uTextureHeight; | |
10386 pZBuffer = &this->pActiveZBuffer[uOutX + 640 * uOutY]; | |
710 | 10387 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10388 v8 = v5->uTextureWidth; |
10389 v20 = v5->uTextureWidth; | |
10390 v19 = v5->uTextureWidth; | |
10391 if ( this->bClip ) | |
10392 { | |
10393 v9 = this->uClipX; | |
10394 if ( uOutX < v9 ) | |
10395 { | |
10396 v10 = v9 - uOutX; | |
10397 uOutYa += v10; | |
10398 v8 += uOutX - this->uClipX; | |
10399 v20 = v8; | |
10400 pZBuffer += v10; | |
10401 } | |
10402 v11 = this->uClipY; | |
10403 if ( (signed int)v6 < (signed int)v11 ) | |
10404 { | |
10405 uOutYa += v19 * (v11 - v6); | |
10406 v7 += v6 - v11; | |
10407 pZBuffer += 640 * (v11 - v6); | |
10408 v8 = v20; | |
10409 } | |
10410 v12 = this->uClipX; | |
10411 if ( v12 < uOutX ) | |
10412 v12 = uOutX; | |
10413 v13 = this->uClipZ; | |
10414 if ( v8 + v12 > (signed int)v13 ) | |
10415 { | |
10416 v14 = this->uClipX; | |
10417 if ( v14 < uOutX ) | |
10418 v14 = uOutX; | |
10419 v8 = v13 - v14; | |
10420 } | |
10421 v15 = this->uClipY; | |
10422 if ( (signed int)v15 < (signed int)v6 ) | |
10423 v15 = v6; | |
10424 v16 = this->uClipW; | |
10425 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
10426 { | |
10427 v17 = this->uClipY; | |
10428 if ( (signed int)v17 >= (signed int)v6 ) | |
10429 v6 = v17; | |
10430 v7 = v16 - v6; | |
10431 } | |
10432 } | |
10433 if ( v7 > 0 ) | |
10434 { | |
10435 uOutXa = v7; | |
10436 do | |
10437 { | |
10438 if ( v8 > 0 ) | |
10439 { | |
10440 v18 = v8; | |
10441 do | |
10442 { | |
10443 if ( *uOutYa ) | |
10444 *pZBuffer = zVal; | |
10445 ++pZBuffer; | |
10446 ++uOutYa; | |
10447 --v18; | |
10448 } | |
10449 while ( v18 ); | |
10450 } | |
10451 pZBuffer += 640 - v8; | |
10452 uOutYa += v19 - v8; | |
10453 --uOutXa; | |
10454 } | |
10455 while ( uOutXa ); | |
10456 } | |
10457 } | |
10458 } | |
10459 } | |
10460 | |
10461 //----- (004A601E) -------------------------------------------------------- | |
991 | 10462 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5) |
0 | 10463 { |
10464 signed int v5; // edx@3 | |
10465 int v6; // ebx@3 | |
10466 int v7; // esi@3 | |
10467 void *v8; // esi@3 | |
10468 unsigned int v9; // eax@4 | |
10469 unsigned int v10; // eax@6 | |
10470 signed int v11; // edi@8 | |
10471 unsigned int v12; // eax@10 | |
10472 signed int v13; // edi@11 | |
10473 unsigned int v14; // edi@14 | |
10474 unsigned int v15; // eax@16 | |
10475 unsigned int v16; // ecx@17 | |
10476 int v17; // [sp+18h] [bp+Ch]@3 | |
10477 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
10478 | |
10479 if ( this->uNumSceneBegins && pTexture ) | |
10480 { | |
10481 v5 = a3; | |
10482 v6 = pTexture->uTextureHeight; | |
10483 v7 = 5 * a3; | |
10484 v17 = pTexture->uTextureHeight; | |
10485 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
10486 pTexturea = pTexture->uTextureWidth; | |
10487 if ( this->bClip ) | |
10488 { | |
10489 v9 = this->uClipX; | |
10490 if ( a2 < (signed int)v9 ) | |
10491 { | |
10492 pTexturea += a2 - v9; | |
10493 v8 = (char *)v8 + 4 * (v9 - a2); | |
10494 } | |
10495 v10 = this->uClipY; | |
10496 if ( v5 < (signed int)v10 ) | |
10497 { | |
10498 v17 += v5 - v10; | |
10499 v8 = (char *)v8 + 2560 * (v10 - v5); | |
10500 } | |
10501 v11 = this->uClipX; | |
10502 if ( v11 < a2 ) | |
10503 v11 = a2; | |
10504 v12 = this->uClipZ; | |
10505 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
10506 { | |
10507 v13 = this->uClipX; | |
10508 if ( v13 < a2 ) | |
10509 v13 = a2; | |
10510 pTexturea = v12 - v13; | |
10511 } | |
10512 v14 = this->uClipY; | |
10513 if ( (signed int)v14 < v5 ) | |
10514 v14 = v5; | |
10515 v6 = v17; | |
10516 v15 = this->uClipW; | |
10517 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
10518 { | |
10519 v16 = this->uClipY; | |
10520 if ( (signed int)v16 < v5 ) | |
10521 v16 = v5; | |
10522 v6 = v15 - v16; | |
10523 } | |
10524 } | |
10525 if ( v6 > 0 ) | |
10526 { | |
10527 do | |
10528 { | |
10529 if ( (signed int)pTexturea > 0 ) | |
10530 { | |
10531 memset32(v8, a5, pTexturea); | |
10532 v8 = (char *)v8 + 4 * pTexturea; | |
10533 } | |
10534 v8 = (char *)v8 + 4 * (640 - pTexturea); | |
10535 --v6; | |
10536 } | |
10537 while ( v6 ); | |
10538 } | |
10539 } | |
10540 } | |
10541 | |
10542 //----- (004A5EB2) -------------------------------------------------------- | |
10543 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
10544 { | |
10545 Texture *v4; // edi@2 | |
10546 unsigned int v5; // ebx@4 | |
10547 unsigned __int16 *pTarget; // eax@4 | |
10548 unsigned int v7; // edx@5 | |
10549 unsigned int v8; // edx@6 | |
10550 unsigned int v9; // edx@7 | |
10551 unsigned int v10; // edx@8 | |
10552 unsigned int v11; // edx@9 | |
10553 unsigned int v12; // esi@12 | |
10554 unsigned int v13; // esi@15 | |
10555 unsigned int v14; // edx@17 | |
10556 unsigned int v15; // esi@18 | |
10557 unsigned __int8 *v16; // edx@22 | |
10558 char v17; // zf@26 | |
10559 int v18; // [sp+10h] [bp-10h]@4 | |
10560 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10561 int v20; // [sp+1Ch] [bp-4h]@4 | |
10562 int uXa; // [sp+28h] [bp+8h]@24 | |
10563 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
10564 unsigned int v23; // [sp+30h] [bp+10h]@11 | |
10565 | |
10566 if ( this->uNumSceneBegins ) | |
10567 { | |
10568 v4 = a4; | |
10569 if ( a4 ) | |
10570 { | |
10571 if ( a4->pPalette16 ) | |
10572 { | |
10573 v5 = a4->uTextureHeight; | |
10574 pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 10575 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10576 v20 = a4->uTextureWidth; |
10577 v18 = a4->uTextureWidth; | |
10578 if ( this->bClip ) | |
10579 { | |
10580 v7 = this->uClipX; | |
10581 if ( (signed int)uX < (signed int)v7 ) | |
10582 { | |
10583 v8 = v7 - uX; | |
10584 v19 += v8; | |
10585 v20 += uX - this->uClipX; | |
10586 pTarget += v8; | |
10587 } | |
10588 v9 = this->uClipY; | |
10589 v5 = a4->uTextureHeight; | |
10590 if ( (signed int)uY < (signed int)v9 ) | |
10591 { | |
10592 v10 = v9 - uY; | |
10593 v19 += v18 * v10; | |
10594 v5 = uY - this->uClipY + a4->uTextureHeight; | |
10595 v4 = a4; | |
10596 pTarget += this->uTargetSurfacePitch * v10; | |
10597 } | |
10598 v11 = this->uClipX; | |
10599 if ( (signed int)v11 < (signed int)uX ) | |
10600 v11 = uX; | |
10601 v23 = this->uClipZ; | |
10602 if ( (signed int)(v11 + v20) > (signed int)v23 ) | |
10603 { | |
10604 v12 = this->uClipX; | |
10605 if ( (signed int)v12 < (signed int)uX ) | |
10606 v12 = uX; | |
10607 v20 = v23 - v12; | |
10608 } | |
10609 v13 = this->uClipY; | |
10610 if ( (signed int)v13 < (signed int)uY ) | |
10611 v13 = uY; | |
10612 v14 = this->uClipW; | |
10613 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10614 { | |
10615 v15 = this->uClipY; | |
10616 if ( (signed int)v15 < (signed int)uY ) | |
10617 v15 = uY; | |
10618 v5 = v14 - v15; | |
10619 } | |
10620 } | |
10621 if ( (signed int)v5 > 0 ) | |
10622 { | |
10623 uYa = v5; | |
10624 v16 = v19; | |
10625 do | |
10626 { | |
10627 if ( v20 > 0 ) | |
10628 { | |
10629 uXa = v20; | |
10630 do | |
10631 { | |
10632 *pTarget = v4->pPalette16[*v16]; | |
10633 ++pTarget; | |
10634 ++v16; | |
10635 --uXa; | |
10636 } | |
10637 while ( uXa ); | |
10638 } | |
10639 v16 += v18 - v20; | |
10640 v17 = uYa-- == 1; | |
10641 pTarget += this->uTargetSurfacePitch - v20; | |
10642 } | |
10643 while ( !v17 ); | |
10644 } | |
10645 } | |
10646 } | |
10647 } | |
10648 } | |
10649 | |
10650 //----- (004667E9) -------------------------------------------------------- | |
10651 void Render::ChangeBetweenWinFullscreenModes() | |
10652 { | |
10653 float v0; // ST14_4@17 | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
10654 bool v1; // edx@24 |
0 | 10655 signed int v2; // ecx@24 |
10656 int v3; // esi@25 | |
10657 int v4; // edx@26 | |
10658 ObjectDesc *v5; // eax@26 | |
10659 RGBTexture *v6; // esi@33 | |
10660 const char *v7; // eax@34 | |
10661 const char *v8; // [sp-4h] [bp-28h]@33 | |
10662 int v9; // [sp+0h] [bp-24h]@33 | |
10663 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
10664 | |
10665 if ( pRenderer->bWindowMode ) | |
10666 goto LABEL_52; | |
10667 if ( dword_6BE364_game_settings_1 & 2 ) | |
10668 { | |
10669 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." | |
10670 return; | |
10671 } | |
10672 if ( !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) | |
10673 { | |
10674 LABEL_52: | |
10675 if ( pEventTimer->bPaused ) | |
10676 BYTE1(dword_6BE364_game_settings_1) |= 8u; | |
10677 else | |
10678 pEventTimer->Pause(); | |
10679 if ( pMiscTimer->bPaused ) | |
10680 BYTE1(dword_6BE364_game_settings_1) |= 0x10u; | |
10681 else | |
10682 pMiscTimer->Pause(); | |
10683 pMouse->bActive = 0; | |
10684 if ( pRenderer->pRenderD3D ) | |
10685 { | |
10686 pBitmaps_LOD->ReleaseHardwareTextures(); | |
10687 pSprites_LOD->ReleaseAll(); | |
10688 } | |
10689 if ( pRenderer->bWindowMode ) | |
10690 { | |
10691 if ( GetWindowRect(hWnd, &Rect) ) | |
10692 { | |
10693 WriteWindowsRegistryInt("window X", Rect.left); | |
10694 WriteWindowsRegistryInt("window Y", Rect.top); | |
10695 uWindowX = Rect.left; | |
10696 uWindowY = Rect.top; | |
10697 } | |
10698 SetMenu(hWnd, 0); | |
10699 SetWindowLongA(hWnd, -20, 0); | |
10700 SetWindowLongA(hWnd, -16, 0x10000000u); | |
10701 pRenderer->InitializeFullscreen(hWnd); | |
10702 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; | |
10703 pGame->pGammaController->Initialize(v0); | |
10704 } | |
10705 else | |
10706 { | |
10707 ClipCursor(0); | |
10708 pRenderer->SwitchToWindow(hWnd); | |
10709 SetWindowLongA(hWnd, -16, uWindowStyle); | |
10710 SetMenu(hWnd, hOSMenu); | |
10711 } | |
10712 if ( pRenderer->pRenderD3D ) | |
10713 { | |
10714 pBitmaps_LOD->_410423_move_textures_to_device(); | |
10715 pSprites_LOD->MoveSpritesToVideoMemory(); | |
10716 } | |
10717 if ( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits | |
10718 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits | |
10719 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits ) | |
10720 goto LABEL_38; | |
10721 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10722 pPaletteManager->RecalculateAll(); | |
10723 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10724 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10725 v2 = 0; | |
10726 if ( (signed int)pObjectList->uNumObjects > 0 ) | |
10727 { | |
10728 v3 = 0; | |
10729 do | |
10730 { | |
10731 BYTE3(v4) = 0; | |
10732 v5 = &pObjectList->pObjects[v3]; | |
10733 ++v3; | |
10734 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; | |
10735 LOBYTE(v4) = v5->uParticleTrailColorG; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1110
diff
changeset
|
10736 v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8); |
0 | 10737 ++v2; |
10738 } | |
10739 while ( v2 < (signed int)pObjectList->uNumObjects ); | |
10740 } | |
10741 LOBYTE(v1) = 1; | |
373 | 10742 SetUserInterface(pParty->alignment, v1); |
0 | 10743 if ( pVideoPlayer->pVideoFrame.pPixels ) |
10744 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); | |
10745 if ( uCurrentMenuID ) | |
10746 { | |
10747 if ( uCurrentMenuID != 6 ) | |
10748 { | |
10749 if ( uCurrentMenuID == 8 ) | |
10750 dword_A74C88 = 1; | |
10751 goto LABEL_38; | |
10752 } | |
10753 v6 = &pTexture_PCX; | |
10754 pTexture_PCX.Release(); | |
10755 v9 = 0; | |
10756 v8 = "makeme.pcx"; | |
10757 } | |
10758 else | |
10759 { | |
10760 v6 = &pTexture_PCX; | |
10761 pTexture_PCX.Release(); | |
10762 v7 = "title.pcx"; | |
10763 if ( uCurrentMenuID ) | |
10764 v7 = "lsave640.pcx"; | |
10765 v9 = 0; | |
10766 v8 = v7; | |
10767 } | |
10768 v6->Load(v8, v9); | |
10769 LABEL_38: | |
10770 viewparams->bRedrawGameUI = 1; | |
688 | 10771 viewparams->InitGrayPalette(); |
0 | 10772 pMouse->SetCurrentCursorBitmap(); |
10773 if ( pRenderer->bWindowMode ) | |
10774 { | |
10775 InvalidateRect(0, 0, 0); | |
10776 MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); | |
10777 ShowWindow(hWnd, 1); | |
10778 } | |
10779 pMouse->bActive = 1; | |
10780 if ( pVideoPlayer->AnyMovieLoaded() ) | |
898 | 10781 pVideoPlayer->SelectMovieType(); |
0 | 10782 if ( BYTE1(dword_6BE364_game_settings_1) & 8 ) |
10783 BYTE1(dword_6BE364_game_settings_1) &= 0xF7u; | |
10784 else | |
10785 pEventTimer->Resume(); | |
10786 if ( BYTE1(dword_6BE364_game_settings_1) & 0x10 ) | |
10787 BYTE1(dword_6BE364_game_settings_1) &= 0xEFu; | |
10788 else | |
10789 pMiscTimer->Resume(); | |
10790 } | |
10791 } | |
10792 // 6BE364: using guessed type int dword_6BE364_game_settings_1; | |
10793 // A74C88: using guessed type int dword_A74C88; | |
10794 | |
10795 //----- (0044EC20) -------------------------------------------------------- | |
10796 bool RenderD3D::DoesRaiseExceptions() | |
10797 { | |
10798 return true; | |
10799 } | |
10800 | |
10801 //----- (0040DBD3) -------------------------------------------------------- | |
10802 void __fastcall Render::SetPixel(Vec2_int_ *pTargetXY, unsigned __int16 uColor) | |
10803 { | |
10804 Vec2_int_ *pTargetXY_; // esi@1 | |
10805 unsigned __int16 v3; // di@1 | |
10806 signed int v4; // ecx@2 | |
10807 signed int v5; // eax@4 | |
10808 | |
10809 pTargetXY_ = pTargetXY; | |
10810 v3 = uColor; | |
10811 pRenderer->BeginScene(); | |
10812 if ( pRenderer->uNumSceneBegins ) | |
10813 { | |
10814 v4 = pTargetXY_->x; | |
10815 if ( pTargetXY_->x >= 0 ) | |
10816 { | |
10817 if ( v4 <= 639 ) | |
10818 { | |
10819 v5 = pTargetXY_->y; | |
10820 if ( v5 >= 0 ) | |
10821 { | |
10822 if ( v5 <= 479 ) | |
10823 pRenderer->pTargetSurface[v4 + pRenderer->uTargetSurfacePitch * v5] = v3; | |
10824 } | |
10825 } | |
10826 } | |
10827 pRenderer->EndScene(); | |
10828 } | |
10829 } | |
10830 | |
10831 //----- (004524D8) -------------------------------------------------------- | |
10832 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
10833 { | |
10834 int v11; // eax@13 | |
10835 int v12; // ecx@13 | |
10836 void *v13; // eax@13 | |
10837 unsigned __int8 v14; // zf@13 | |
10838 unsigned __int8 v15; // sf@13 | |
10839 int v16; // esi@14 | |
10840 int v17; // ecx@16 | |
10841 int v18; // esi@16 | |
10842 unsigned __int16 *v19; // eax@16 | |
10843 int v20; // edx@16 | |
10844 int v21; // ecx@16 | |
10845 int v22; // eax@16 | |
10846 int v23; // esi@16 | |
10847 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
10848 int v27; // [sp+28h] [bp-Ch]@14 | |
10849 int v28; // [sp+2Ch] [bp-8h]@13 | |
10850 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
10851 | |
10852 //v3 = this; | |
10853 //sprintf(Str1, "%s", pName); | |
10854 //v4 = uNumItems; | |
10855 if (!uNumItems) | |
10856 return nullptr; | |
10857 | |
10858 //{ | |
10859 //v5 = 0, pDesta = uNumItems; | |
10860 uint idx1 = 0, | |
10861 idx2 = uNumItems; | |
10862 while (true) | |
10863 { | |
10864 auto i = idx1 + (idx2 - idx1) / 2; | |
10865 | |
10866 auto res = strcmpi(pName, pSpriteNames[i]); | |
10867 if (!res) | |
10868 { | |
10869 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
10870 break; | |
10871 } | |
10872 else if (res < 0) | |
10873 idx2 = idx1 + (idx2 - idx1) / 2; | |
10874 else | |
10875 idx1 = i + 1; | |
10876 | |
10877 if ( idx1 >= idx2 ) | |
10878 return false; | |
10879 } | |
10880 | |
10881 | |
10882 uint uCompressedSize = 0; | |
10883 fread(&uCompressedSize, 4, 1, pFile); | |
10884 | |
10885 auto pTex = new HWLTexture; | |
670 | 10886 fread(&pTex->uBufferWidth, 4, 1, pFile); |
10887 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
10888 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
10889 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 10890 fread(&pTex->uWidth, 4, 1, pFile); |
10891 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 10892 fread(&pTex->uAreaX, 4, 1, pFile); |
10893 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 10894 |
10895 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
10896 if (uCompressedSize) | |
10897 { | |
10898 auto pCompressedData = new char[uCompressedSize]; | |
10899 { | |
10900 fread(pCompressedData, 1, uCompressedSize, pFile); | |
10901 auto uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); | |
10902 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); | |
10903 } | |
10904 delete [] pCompressedData; | |
10905 } | |
10906 else | |
10907 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
10908 | |
10909 if ( field_61A94_scale_hwls_to_half ) | |
10910 { | |
10911 v11 = pTex->uHeight / 2; | |
10912 v12 = pTex->uWidth / 2; | |
10913 pTex->uHeight = v11; | |
10914 pTex->uWidth = v12; | |
10915 v13 = new unsigned __int16[v12 * v11]; | |
10916 v28 = 0; | |
10917 v14 = pTex->uHeight == 0; | |
10918 v15 = (pTex->uHeight & 0x80000000u) != 0; | |
10919 v26 = (unsigned __int16 *)v13; | |
10920 if ( !(v15 | v14) ) | |
10921 { | |
10922 v16 = pTex->uWidth; | |
10923 v27 = 1; | |
10924 do | |
10925 { | |
10926 pDestb = 0; | |
10927 if ( v16 > 0 ) | |
10928 { | |
10929 do | |
10930 { | |
10931 v17 = v16 * v27; | |
10932 v18 = v28 * v16; | |
10933 v19 = pTex->pPixels; | |
10934 v20 = pDestb + 2 * v18; | |
10935 v21 = (int)&v19[2 * (pDestb + v17)]; | |
10936 v22 = (int)&v19[2 * v20]; | |
10937 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
10938 LOWORD(v21) = *(unsigned short *)v21; | |
10939 v23 = pDestb++ + v18; | |
10940 v26[v23] = sub_452442(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
10941 v16 = pTex->uWidth; | |
10942 } | |
10943 while (pDestb < pTex->uWidth); | |
10944 } | |
10945 ++v28; | |
10946 v27 += 2; | |
10947 } | |
10948 while ( v28 < (signed int)pTex->uHeight ); | |
10949 } | |
10950 delete [] pTex->pPixels; | |
10951 pTex->pPixels = v26; | |
10952 } | |
10953 return pTex; | |
10954 //result = pTex; | |
10955 // } | |
10956 // else | |
10957 // { | |
10958 //LABEL_8: | |
10959 // return nullptr; | |
10960 // } | |
10961 } | |
10962 | |
10963 //----- (0045271F) -------------------------------------------------------- | |
10964 bool RenderHWLContainer::Release() | |
10965 { | |
10966 RenderHWLContainer *v1; // esi@1 | |
10967 int v2; // ebx@1 | |
10968 void **v3; // edi@3 | |
10969 __int32 v4; // eax@6 | |
10970 FILE *v5; // ST24_4@6 | |
10971 size_t *v6; // edi@6 | |
10972 int v7; // ebx@7 | |
10973 signed int v9; // [sp+0h] [bp-8h]@6 | |
10974 FILE *File; // [sp+4h] [bp-4h]@6 | |
10975 | |
10976 v1 = this; | |
10977 v2 = 0; | |
10978 if ( this->bDumpDebug ) | |
10979 { | |
10980 File = fopen("logd3d.txt", "w"); | |
10981 v4 = ftell(v1->pFile); | |
10982 v5 = v1->pFile; | |
10983 v6 = &v1->uNumItems; | |
10984 v1->uDataOffset = v4; | |
10985 fwrite(&v1->uNumItems, 4u, 1u, v5); | |
10986 v9 = 0; | |
10987 if ( (signed int)v1->uNumItems > 0 ) | |
10988 { | |
10989 v7 = (int)v1->pSpriteNames; | |
10990 do | |
10991 { | |
10992 fwrite(*(const void **)v7, 1u, 0x14u, v1->pFile); | |
10993 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", *(unsigned int *)v7, *(unsigned int *)(v7 + 200000)); | |
10994 ++v9; | |
10995 v7 += 4; | |
10996 } | |
10997 while ( v9 < (signed int)*v6 ); | |
10998 v2 = 0; | |
10999 } | |
11000 fwrite(v1->pSpriteOffsets, 4u, *v6, v1->pFile); | |
11001 fseek(v1->pFile, 4, v2); | |
11002 fwrite(&v1->uDataOffset, 4u, 1u, v1->pFile); | |
11003 fclose(v1->pFile); | |
11004 fclose(File); | |
11005 } | |
11006 else | |
11007 { | |
11008 fclose(this->pFile); | |
11009 if ( (signed int)v1->uNumItems > 0 ) | |
11010 { | |
11011 v3 = (void **)v1->pSpriteNames; | |
11012 do | |
11013 { | |
11014 free(*v3); | |
11015 ++v2; | |
11016 ++v3; | |
11017 } | |
11018 while ( v2 < (signed int)v1->uNumItems ); | |
11019 } | |
11020 } | |
1093 | 11021 return true; |
0 | 11022 } |
11023 | |
11024 //----- (00452347) -------------------------------------------------------- | |
11025 RenderHWLContainer::RenderHWLContainer(): | |
11026 bDumpDebug(false) | |
11027 { | |
11028 RenderHWLContainer *v1; // esi@1 | |
11029 | |
11030 v1 = this; | |
11031 this->pFile = 0; | |
11032 uSignature = 0; | |
11033 v1->uDataOffset = 0; | |
11034 memset(&v1->uNumItems, 0, 0x61A84u); | |
11035 v1->uNumItems = 0; | |
11036 v1->field_61A94_scale_hwls_to_half = 0; | |
11037 } | |
11038 | |
11039 //----- (0045237F) -------------------------------------------------------- | |
11040 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
11041 { | |
11042 pFile = _wfopen(pFilename, L"rb"); | |
11043 if (!pFile) | |
11044 { | |
11045 Log::Warning(L"Failed to open file: %s", pFilename); | |
11046 return false; | |
11047 } | |
11048 | |
11049 fread(&uSignature, 1, 4, pFile); | |
11050 if (uSignature != 'TD3D') | |
11051 { | |
11052 Log::Warning(L"Invalid format: %s", pFilename); | |
11053 return false; | |
11054 } | |
11055 | |
11056 fread(&uDataOffset, 4, 1, pFile); | |
11057 fseek(pFile, uDataOffset, SEEK_SET); | |
11058 fread(&uNumItems, 4, 1, pFile); | |
11059 | |
11060 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
11061 for (uint i = 0; i < uNumItems; ++i) | |
11062 { | |
11063 pSpriteNames[i] = new char[20]; | |
11064 fread(pSpriteNames[i], 1, 20, pFile); | |
11065 } | |
11066 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
11067 | |
11068 return true; | |
11069 } | |
11070 | |
11071 //----- (004A1C1E) -------------------------------------------------------- | |
11072 void DoRenderBillboards_D3D() | |
11073 { | |
186 | 11074 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
11075 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
11076 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11077 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11078 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11079 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11080 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11081 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11082 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11083 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11084 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
|
11085 //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
|
11086 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11087 p->pQuards[0].pos.x = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11088 p->pQuards[0].pos.y = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11089 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11090 p->pQuards[1].pos.x = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11091 p->pQuards[1].pos.y = 200; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11092 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11093 p->pQuards[2].pos.x = 100; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11094 p->pQuards[2].pos.y = 200; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11095 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11096 p->pQuards[3].pos.x = 100; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11097 p->pQuards[3].pos.y = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11098 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11099 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11100 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11101 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11102 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11103 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11104 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11105 p->pQuards, p->uNumVertices, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11106 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11107 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11108 }*/ |
0 | 11109 |
11110 for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i) | |
11111 { | |
101 | 11112 auto p = &pRenderer->pBillboardRenderListD3D[i]; |
0 | 11113 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11114 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
0 | 11115 SetBillboardBlendOptions(p->uOpacity); |
11116 | |
101 | 11117 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11118 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11119 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11120 p->pQuards, p->uNumVertices, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11121 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
0 | 11122 } |
11123 | |
11124 if (pRenderer->bFogEnabled) | |
11125 { | |
11126 pRenderer->bFogEnabled = false; | |
186 | 11127 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 11128 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
11129 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
11130 } | |
186 | 11131 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
11132 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
11133 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
11134 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
11135 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
11136 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 11137 } |
11138 | |
11139 //----- (004A1DA8) -------------------------------------------------------- | |
11140 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) | |
11141 { | |
11142 switch (a1) | |
11143 { | |
11144 case RenderBillboardD3D::Transparent: | |
11145 { | |
11146 if (pRenderer->bFogEnabled) | |
11147 { | |
11148 pRenderer->bFogEnabled = false; | |
186 | 11149 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 11150 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
11151 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
11152 } | |
11153 | |
186 | 11154 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); |
11155 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
11156 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 11157 } |
11158 break; | |
11159 | |
11160 case RenderBillboardD3D::Opaque_1: | |
11161 case RenderBillboardD3D::Opaque_2: | |
11162 case RenderBillboardD3D::Opaque_3: | |
11163 { | |
11164 if (pRenderer->bUsingSpecular) | |
11165 { | |
11166 if (!pRenderer->bFogEnabled) | |
11167 { | |
11168 pRenderer->bFogEnabled = true; | |
186 | 11169 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
11170 } | |
11171 } | |
11172 | |
11173 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
11174 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
11175 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 11176 } |
11177 break; | |
11178 | |
11179 default: | |
11180 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11181 assert(false); |
0 | 11182 break; |
11183 } | |
11184 } | |
11185 |