Mercurial > mm7
annotate Render.cpp @ 840:6dd2b94efce7
DrawFan
author | Ritor1 |
---|---|
date | Fri, 29 Mar 2013 10:43:46 +0600 |
parents | f5156b8c61ad |
children | e3609dd06c15 |
rev | line source |
---|---|
140 | 1 #include <assert.h> |
2 | |
0 | 3 #include "Render.h" |
4 #include "OutdoorCamera.h" | |
5 #include "IndoorCamera.h" | |
6 #include "Outdoor.h" | |
7 #include "Party.h" | |
8 #include "LOD.h" | |
9 #include "Viewport.h" | |
10 #include "Math.h" | |
11 #include "PaletteManager.h" | |
12 #include "Time.h" | |
13 #include "Game.h" | |
14 #include "LightmapBuilder.h" | |
15 #include "stru220.h" | |
16 #include "ObjectList.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
17 #include "SpriteObject.h" |
0 | 18 #include "DecorationList.h" |
19 #include "Allocator.h" | |
20 #include "OSInfo.h" | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
21 #include "Actor.h" |
0 | 22 #include "Log.h" |
179 | 23 #include "TileFrameTable.h" |
189 | 24 #include "texts.h" |
0 | 25 #include "mm7_data.h" |
26 | |
27 #pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") | |
28 #pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") | |
29 | |
30 struct IDirectDrawClipper *pDDrawClipper; | |
31 struct Render *pRenderer; // idb | |
67 | 32 struct RenderVertexD3D3 pVertices[50]; |
0 | 33 int uNumDecorationsDrawnThisFrame; // weak |
34 RenderBillboard pBillboardRenderList[500]; | |
35 unsigned int uNumBillboardsToDraw; | |
36 int uNumSpritesDrawnThisFrame; // weak | |
37 | |
38 RenderVertexSoft array_507D30[50]; | |
39 RenderVertexSoft array_508690[50]; | |
40 RenderVertexSoft array_508FF0[50]; | |
41 RenderVertexSoft array_509950[50]; | |
42 RenderVertexSoft array_50A2B0[50]; | |
43 RenderVertexSoft array_50AC10[50]; | |
44 | |
45 RenderVertexSoft array_73D150[20]; | |
46 | |
186 | 47 RenderVertexD3D3 d3d_vertex_buffer[50]; |
0 | 48 |
49 RenderVertexSoft *ptr_801A04; | |
50 RenderVertexSoft *ptr_801A08; | |
51 | |
52 RenderVertexSoft pVerticesSR_801A10[384]; | |
53 RenderVertexSoft pVerticesSR_806210[384]; | |
54 | |
55 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); | |
56 | |
57 /* 384 */ | |
58 #pragma pack(push, 1) | |
59 struct PCXHeader_1 | |
60 { | |
61 char manufacturer; | |
62 char version; | |
63 char encoding; | |
64 char bpp; | |
65 __int16 left; | |
66 __int16 up; | |
67 __int16 right; | |
68 __int16 bottom; | |
69 __int16 hdpi; | |
70 __int16 vdpi; | |
71 }; | |
72 #pragma pack(pop) | |
73 | |
74 /* 385 */ | |
75 #pragma pack(push, 1) | |
76 struct PCXHeader_2 | |
77 { | |
78 char reserved; | |
79 char planes; | |
80 __int16 pitch; | |
81 __int16 palette_info; | |
82 }; | |
83 #pragma pack(pop) | |
84 | |
85 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst); | |
86 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | |
87 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | |
88 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | |
89 | |
90 //----- (0049E79F) -------------------------------------------------------- | |
91 bool __cdecl CheckTextureStages() | |
92 { | |
93 bool v0; // edi@1 | |
94 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | |
95 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | |
96 DWORD v4; // [sp+14h] [bp-Ch]@1 | |
97 IDirect3DTexture2 *pTexture2; // [sp+18h] [bp-8h]@1 | |
98 IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 | |
99 | |
100 v0 = false; | |
101 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); | |
102 pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); | |
103 | |
104 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture1)); | |
186 | 105 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 106 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2u)); |
107 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
108 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
109 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
110 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1u)); | |
111 | |
112 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture2)); | |
186 | 113 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
0 | 114 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1u)); |
115 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7u)); | |
116 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2u)); | |
117 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1u)); | |
118 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2u)); | |
119 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2u)); | |
120 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1u)); | |
121 | |
122 if ( !pRenderer->pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 ) | |
123 v0 = true; | |
124 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u)); | |
125 pTexture1->Release(); | |
126 pTexture2->Release(); | |
127 pSurface1->Release(); | |
128 pSurface2->Release(); | |
129 return v0; | |
130 } | |
131 | |
132 //----- (00440CB8) -------------------------------------------------------- | |
133 void Render::DrawBillboardList_BLV() | |
134 { | |
135 __int16 v2; // ax@3 | |
136 int v5; // eax@11 | |
137 RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1 | |
138 | |
139 soft_billboard.uParentBillboardID = -1; | |
140 soft_billboard.pTarget = pBLVRenderParams->pRenderTarget; | |
141 soft_billboard.pTargetZ = pBLVRenderParams->pTargetZBuffer; | |
142 soft_billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
143 soft_billboard.uViewportX = pBLVRenderParams->uViewportX; | |
144 soft_billboard.uViewportY = pBLVRenderParams->uViewportY; | |
145 soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1; | |
146 soft_billboard.uViewportW = pBLVRenderParams->uViewportW; | |
147 | |
617 | 148 pOutdoorCamera->uNumBillboards = ::uNumBillboardsToDraw; |
149 for (uint i = 0; i < ::uNumBillboardsToDraw; ++i) | |
0 | 150 { |
151 auto p = pBillboardRenderList + i; | |
152 | |
153 soft_billboard.uScreenSpaceX = p->uScreenSpaceX; | |
154 soft_billboard.uParentBillboardID = i; | |
155 soft_billboard.uScreenSpaceY = p->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
156 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
|
157 soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; |
0 | 158 soft_billboard.sZValue = p->sZValue; |
159 soft_billboard.uFlags = p->field_1E; | |
160 soft_billboard.uTintColor = p->uTintColor; | |
161 v2 = p->uHwSpriteID; | |
162 if ( v2 != -1 ) | |
163 { | |
164 if ( pRenderer->pRenderD3D ) | |
657 | 165 pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level); |
0 | 166 else |
167 { | |
657 | 168 soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1); |
0 | 169 if (p->field_1E & 0x0100) |
170 soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette]; | |
171 if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 ) | |
172 soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1); | |
173 v5 = p->uHwSpriteID; | |
174 if ( v5 >= 0 ) | |
733 | 175 pSprites_LOD->pSpriteHeaders[v5].DrawSprite_sw(&soft_billboard, 1); |
0 | 176 } |
177 } | |
178 } | |
179 } | |
180 | |
181 //----- (004A16A5) -------------------------------------------------------- | |
182 bool __cdecl AreRenderSurfacesOk() | |
183 { | |
184 char v0; // zf@4 | |
185 bool result; // eax@8 | |
186 | |
187 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
188 { | |
189 if ( !pRenderer->pBackBuffer4 ) | |
190 goto LABEL_9; | |
191 v0 = pRenderer->pFrontBuffer4 == 0; | |
192 } | |
193 else | |
194 { | |
195 if ( !pRenderer->pBackBuffer2 ) | |
196 goto LABEL_9; | |
197 v0 = pRenderer->pFrontBuffer2 == 0; | |
198 } | |
199 if ( !v0 ) | |
200 { | |
201 LOBYTE(result) = 1; | |
202 return result; | |
203 } | |
204 LABEL_9: | |
205 LOBYTE(result) = 0; | |
206 return result; | |
207 } | |
208 | |
209 //----- (00487389) -------------------------------------------------------- | |
210 __int16 Render::ExecOutdoorDrawSW() | |
211 { | |
212 unsigned __int16 *v0; // ebx@1 | |
213 unsigned int v1; // esi@1 | |
214 stru148 *v2; // eax@1 | |
215 Span *v3; // edi@6 | |
216 stru148 *v4; // esi@9 | |
217 Texture *v5; // ebp@10 | |
218 int v6; // esi@16 | |
219 unsigned int v7; // edx@16 | |
220 char *v8; // ecx@17 | |
221 unsigned int v9; // edi@22 | |
222 int v10; // eax@26 | |
223 int v11; // eax@27 | |
224 unsigned int v12; // ebp@32 | |
225 Span *v13; // esi@33 | |
226 int v14; // ecx@37 | |
227 int v15; // eax@40 | |
228 Texture *v16; // ebp@51 | |
229 unsigned int v17; // eax@51 | |
230 int v18; // eax@54 | |
231 char v19; // al@56 | |
232 unsigned int v20; // eax@57 | |
233 int v21; // ecx@57 | |
234 unsigned int v22; // eax@57 | |
235 stru149 *v23; // eax@65 | |
236 int v24; // eax@67 | |
237 ODMFace *v25; // eax@78 | |
238 signed int v26; // edx@79 | |
239 signed int v27; // ecx@79 | |
240 unsigned int v28; // eax@106 | |
241 unsigned int v29; // ebp@117 | |
242 Span *v30; // esi@118 | |
243 unsigned int v31; // ST04_4@124 | |
244 int v33; // [sp+18h] [bp-44h]@80 | |
245 signed int v34; // [sp+1Ch] [bp-40h]@3 | |
246 signed int v35; // [sp+20h] [bp-3Ch]@79 | |
247 Span **v36; // [sp+24h] [bp-38h]@4 | |
248 unsigned int v37; // [sp+28h] [bp-34h]@1 | |
249 unsigned __int16 *a1; // [sp+2Ch] [bp-30h]@1 | |
250 int a1a; // [sp+2Ch] [bp-30h]@26 | |
251 unsigned int a1b; // [sp+2Ch] [bp-30h]@116 | |
252 char v41; // [sp+30h] [bp-2Ch]@57 | |
253 | |
254 v0 = pRenderer->pTargetSurface; | |
255 v1 = pOutdoorCamera->numStru148s; | |
256 a1 = pRenderer->pTargetSurface; | |
257 v2 = array_77EC08; | |
258 v37 = pOutdoorCamera->numStru148s; | |
259 if ( !(pParty->uFlags & 2) ) | |
260 { | |
261 v1 = uNumElementsIn80AA28; | |
262 v2 = ptr_80AA28[0]; | |
263 v37 = uNumElementsIn80AA28; | |
264 } | |
265 v34 = 0; | |
266 if ( (signed int)v1 > 0 ) | |
267 { | |
268 v36 = &v2->prolly_head; | |
269 do | |
270 { | |
271 if ( pParty->uFlags & 2 ) | |
272 v3 = *v36; | |
273 else | |
274 v3 = ptr_80AA28[v34]->prolly_head; | |
275 if ( v3 ) | |
276 { | |
277 v4 = v3->pParent; | |
278 if ( v4 ) | |
279 { | |
280 v5 = v4->pTexture; | |
281 if ( v5 ) | |
282 { | |
693 | 283 if ( v3->field_8 >= (signed int)pViewport->uViewportTL_X || v3->field_C != pViewport->uViewportTL_X ) |
0 | 284 { |
285 LOBYTE(v4->field_32) |= 2u; | |
286 v14 = *(int *)&v4->flags; | |
287 if ( v14 & 0x10 && v4->field_59 != 5 ) | |
288 { | |
638 | 289 dword_80AA20 = (v4->terrain_grid_z - 64) << 25; |
0 | 290 dword_80AA1C = dword_80AA20 + 0x1FF0000; |
638 | 291 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 292 dword_80AA18 = dword_80AA14 - 0x1FF0000; |
293 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 294 v4->terrain_grid_z, |
295 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 296 if ( *(int *)&v4->flags & 2 || (v15 = *(int *)&v4->flags, BYTE1(v15) & 1) ) |
297 { | |
298 if ( *(int *)&v4->flags & 2 ) | |
299 { | |
300 while ( 1 ) | |
301 { | |
302 if ( pOutdoorCamera->outdoor_no_wavy_water ) | |
303 sr_sub_48408A_prolly_odm_water_no_waves(v3); | |
304 else | |
305 sr_sub_485407_prolly_odm_water_wavy(v3); | |
306 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
307 if ( v4->prolly_tail == v3 ) | |
308 break; | |
309 v3 = v3->pNext; | |
310 } | |
311 } | |
312 else | |
313 { | |
314 while ( 1 ) | |
315 { | |
316 v16 = v4->pTexture; | |
317 v17 = pBitmaps_LOD->LoadTexture("wtrtyl"); | |
318 v4->pTexture = (Texture *)(v17 != -1 ? (int)&pBitmaps_LOD->pTextures[v17] : 0); | |
319 if ( pOutdoorCamera->outdoor_no_wavy_water ) | |
320 sr_sub_48408A_prolly_odm_water_no_waves(v3); | |
321 else | |
322 sr_sub_485407_prolly_odm_water_wavy(v3); | |
638 | 323 v18 = v4->terrain_grid_z - 64; |
0 | 324 v4->pTexture = v16; |
325 dword_80AA20 = v18 << 25; | |
326 dword_80AA1C = (v18 << 25) + 0x1FF0000; | |
638 | 327 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 328 dword_80AA18 = dword_80AA14 - 0x1FF0000; |
329 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 330 v4->terrain_grid_z, |
331 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 332 sr_sub_484442(v3); |
333 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
334 if ( v4->prolly_tail == v3 ) | |
335 break; | |
336 v3 = v3->pNext; | |
337 } | |
338 } | |
339 } | |
340 else | |
341 { | |
342 while ( sr_sub_48408A_prolly_odm_water_no_waves(v3) ) | |
343 { | |
344 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
345 if ( v4->prolly_tail == v3 ) | |
346 break; | |
347 v3 = v3->pNext; | |
348 } | |
349 } | |
350 } | |
351 else | |
352 { | |
353 v19 = v4->field_59; | |
354 if ( v19 != 5 ) | |
355 { | |
356 if ( v14 & 2 ) | |
357 { | |
358 while ( 1 ) | |
359 { | |
360 v28 = pBitmaps_LOD->LoadTexture("wtrtyla"); | |
361 v4->pTexture = (Texture *)(v28 != -1 ? &pBitmaps_LOD->pTextures[v28] : 0); | |
362 if ( !sr_sub_4847EB(v3) ) | |
363 break; | |
364 v4->pTexture = v5; | |
365 if ( !sr_sub_484442(v3) ) | |
366 break; | |
367 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
368 if ( v4->prolly_tail == v3 ) | |
369 break; | |
370 v3 = v3->pNext; | |
371 v5 = v4->pTexture; | |
372 } | |
373 } | |
374 else | |
375 { | |
376 if ( v19 == 1 ) | |
377 { | |
638 | 378 dword_80AA20 = (v4->terrain_grid_z - 64) << 25; |
0 | 379 dword_80AA1C = dword_80AA20 + 33488896; |
638 | 380 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; |
0 | 381 dword_80AA18 = dword_80AA14 - 33488896; |
382 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( | |
638 | 383 v4->terrain_grid_z, |
384 v4->terrain_grid_x - 1) >> 9) & 1; | |
0 | 385 while ( 1 ) |
386 { | |
387 if ( !sr_sub_4847EB(v3) ) | |
388 sr_sub_48585C_mb_DrawSpan(v3, &pRenderer->pTargetSurface[v3->field_8 + 640 * v3->field_A], 0); | |
389 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
390 if ( v4->prolly_tail == v3 ) | |
391 break; | |
392 v3 = v3->pNext; | |
393 } | |
394 } | |
395 } | |
396 goto LABEL_14; | |
397 } | |
398 v4->ptr_38 = (stru149 *)&v41; | |
399 v4->_479295(); | |
400 v20 = GetTickCount(); | |
401 v21 = *(int *)&v4->flags; | |
402 v22 = v20 >> 3; | |
403 if ( BYTE1(v21) & 4 ) | |
404 { | |
405 v4->sTextureDeltaV -= v22 & v4->pTexture->uHeightMinus1; | |
406 } | |
407 else | |
408 { | |
409 if ( BYTE1(v21) & 8 ) | |
410 v4->sTextureDeltaV += v22 & v4->pTexture->uHeightMinus1; | |
411 } | |
412 if ( BYTE1(v21) & 0x10 ) | |
413 { | |
414 v4->sTextureDeltaU -= v22 & v4->pTexture->uWidthMinus1; | |
415 } | |
416 else | |
417 { | |
418 if ( BYTE1(v21) & 0x20 ) | |
419 v4->sTextureDeltaU += v22 & v4->pTexture->uWidthMinus1; | |
420 } | |
421 v23 = v4->ptr_38; | |
422 v4->field_52 = 32; | |
423 v4->field_5A = 5; | |
424 if ( (double)abs(v23->field_C) > 52428.8 ) | |
425 { | |
426 v4->field_52 = 8; | |
427 v4->field_5A = 3; | |
428 } | |
429 v24 = *(int *)&v4->flags; | |
430 if ( !(v24 & 0x10000) ) | |
431 { | |
432 if ( !(v24 & 2) ) | |
433 { | |
434 v25 = v4->pODMFace; | |
435 if ( v25->uPolygonType == 1 ) | |
436 { | |
437 v26 = v25->pTextureUIDs[0]; | |
438 dword_80AA1C = v26; | |
439 dword_80AA20 = v26; | |
440 v27 = v25->pTextureVIDs[0]; | |
441 dword_80AA14 = v27; | |
442 dword_80AA18 = v27; | |
443 v35 = 1; | |
444 if ( v25->uNumVertices > 1u ) | |
445 { | |
446 v33 = (int)&v25->pTextureVIDs[1]; | |
447 do | |
448 { | |
449 if ( dword_80AA20 > *(short *)(v33 - 40) ) | |
450 dword_80AA20 = *(short *)(v33 - 40); | |
451 if ( v26 < *(short *)(v33 - 40) ) | |
452 { | |
453 v26 = *(short *)(v33 - 40); | |
454 dword_80AA1C = *(short *)(v33 - 40); | |
455 } | |
456 if ( dword_80AA18 > *(short *)v33 ) | |
457 dword_80AA18 = *(short *)v33; | |
458 if ( v27 < *(short *)v33 ) | |
459 { | |
460 v27 = *(short *)v33; | |
461 dword_80AA14 = *(short *)v33; | |
462 } | |
463 ++v35; | |
464 v33 += 2; | |
465 } | |
466 while ( v35 < v25->uNumVertices ); | |
467 v0 = a1; | |
468 } | |
469 dword_80AA20 = (dword_80AA20 + v4->sTextureDeltaU) << 16; | |
470 dword_80AA1C = ((v26 + v4->sTextureDeltaU) << 16) - 65536; | |
471 dword_80AA18 = (dword_80AA18 + v4->sTextureDeltaV) << 16; | |
472 dword_80AA14 = ((v27 + v4->sTextureDeltaV) << 16) - 65536; | |
473 } | |
474 while ( 1 ) | |
475 { | |
476 if ( !sr_sub_482E07(v3, v0) ) | |
477 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
478 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
479 if ( v4->prolly_tail == v3 ) | |
480 break; | |
481 v3 = v3->pNext; | |
482 } | |
483 goto LABEL_14; | |
484 } | |
485 while ( 1 ) | |
486 { | |
487 LABEL_74: | |
488 if ( !sr_sub_4839BD(v3, v0) ) | |
489 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
490 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
491 if ( v4->prolly_tail == v3 ) | |
492 break; | |
493 v3 = v3->pNext; | |
494 } | |
495 goto LABEL_14; | |
496 } | |
497 if ( v24 & 2 ) | |
498 goto LABEL_74; | |
499 while ( 1 ) | |
500 { | |
501 if ( !sr_sub_482A94(v3) ) | |
502 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); | |
503 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
504 if ( v4->prolly_tail == v3 ) | |
505 break; | |
506 v3 = v3->pNext; | |
507 } | |
508 } | |
509 } | |
510 else | |
511 { | |
512 v3->field_E = LOWORD(unnamed_6BE060[1]); | |
513 } | |
514 } | |
515 } | |
516 } | |
517 LABEL_14: | |
518 ++v34; | |
519 LOWORD(v2) = v34; | |
520 v36 += 67; | |
521 } | |
522 while ( v34 < (signed int)v37 ); | |
523 } | |
524 if ( pParty->uFlags & 2 ) | |
525 { | |
526 v6 = pOutdoorCamera->numStru148s; | |
527 v7 = 0; | |
528 uNumElementsIn80AA28 = 0; | |
529 if ( pOutdoorCamera->numStru148s > 0 ) | |
530 { | |
531 v8 = (char *)&array_77EC08[0].flags; | |
532 do | |
533 { | |
534 v2 = *(stru148 **)v8; | |
535 if ( (unsigned int)v2 & 0x20000 ) | |
536 { | |
537 ++v7; | |
538 *(int *)v8 = (unsigned int)v2 & 0xFFFDFFFF; | |
539 LOWORD(v2) = (short)v8 - 48; | |
540 *(&uNumElementsIn80AA28 + v7) = (unsigned int)(v8 - 48); | |
541 } | |
542 v8 += 268; | |
543 --v6; | |
544 } | |
545 while ( v6 ); | |
546 uNumElementsIn80AA28 = v7; | |
547 } | |
548 } | |
549 v9 = pOutdoorCamera->uNumSpans; | |
550 unnamed_6BE060[0] = pOutdoorCamera->uNumSpans; | |
551 if ( pOutdoorCamera->numStru148s >= 1999 | |
552 || (array_77EC08[1999]._48607B(&stru_8019C8), | |
553 array_77EC08[1999].ptr_38->_48694B(), | |
554 v2 = (stru148 *)&pBitmaps_LOD->pTextures[pOutdoor->uMainTile_BitmapID], | |
555 (array_77EC08[1999].pTexture = (Texture *)(pOutdoor->uMainTile_BitmapID != -1 ? (int)v2 : 0)) == 0) ) | |
556 return (signed __int16)v2; | |
638 | 557 array_77EC08[1999].dimming_level = 23 - (-20 * pOutdoor->vSunlight.z >> 16); |
558 if ( array_77EC08[1999].dimming_level > 20 ) | |
559 array_77EC08[1999].dimming_level = 20; | |
323 | 560 v10 = stru_5C6E00->Sin(pIndoorCamera->sRotationX); |
0 | 561 array_77EC08[1999].v_18.y = 0; |
562 array_77EC08[1999].v_18.x = v10; | |
323 | 563 array_77EC08[1999].v_18.z = stru_5C6E00->Cos(pIndoorCamera->sRotationX); |
0 | 564 array_77EC08[1999].field_24 = 2048 - (pIndoorCamera->pos.z << 16); |
565 a1a = (signed __int64)((double)(pIndoorCamera->pos.z * pOutdoorCamera->int_fov_rad) | |
566 / ((double)pOutdoorCamera->int_fov_rad + 8192.0) | |
567 + (double)pViewport->uScreenCenterY); | |
568 cos((double)pIndoorCamera->sRotationX * 0.0030664064); | |
569 sin((double)pIndoorCamera->sRotationX * 0.0030664064); | |
570 array_77EC08[1999]._48607B(&stru_8019C8); | |
571 array_77EC08[1999].ptr_38->_48694B(); | |
572 v2 = (stru148 *)&pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID]; | |
573 array_77EC08[1999].pTexture = (Texture *)(pOutdoor->uSky_TextureID != -1 ? (int)v2 : 0); | |
574 if ( !(pOutdoor->uSky_TextureID != -1 ? (int)v2 : 0) ) | |
575 return (signed __int16)v2; | |
638 | 576 array_77EC08[1999].dimming_level = 0; |
323 | 577 v11 = stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16); |
0 | 578 array_77EC08[1999].v_18.y = 0; |
579 array_77EC08[1999].v_18.x = -v11; | |
323 | 580 array_77EC08[1999].v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16); |
0 | 581 LOWORD(v2) = 224 * LOWORD(pMiscTimer->uTotalGameTimeElapsed); |
582 array_77EC08[1999].field_24 = 0x2000000u; | |
583 array_77EC08[1999].sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
584 array_77EC08[1999].sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed; | |
767 | 585 if ( day_attrib & DAY_ATTRIB_FOG |
0 | 586 && (LOWORD(v2) = LOWORD(pParty->uCurrentHour), pParty->uCurrentHour >= 5) |
587 && pParty->uCurrentHour < 0x15 | |
588 || bUnderwater ) | |
589 { | |
590 v2 = (stru148 *)*(short *)PaletteManager::Get_Mist_or_Red_LUT(array_77EC08[1999].pTexture->palette_id2, 31, 1); | |
591 a1b = (unsigned int)v2; | |
592 if ( (signed int)v9 <= 0 ) | |
593 return (signed __int16)v2; | |
594 v29 = v9; | |
595 while ( 1 ) | |
596 { | |
597 v30 = &pSpans[v29 - 1]; | |
598 v2 = (stru148 *)v30->field_E; | |
599 if ( v2 != (stru148 *)unnamed_6BE060[1] ) | |
600 { | |
693 | 601 LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); |
602 if ( v30->field_8 >= (signed int)pViewport->uViewportTL_X ) | |
0 | 603 goto LABEL_124; |
693 | 604 if ( v30->field_C == pViewport->uViewportTL_X ) |
0 | 605 { |
606 v30->field_E = LOWORD(unnamed_6BE060[1]); | |
607 } | |
608 else | |
609 { | |
693 | 610 v30->field_8 = LOWORD(pViewport->uViewportTL_X); |
611 v30->field_C -= LOWORD(pViewport->uViewportTL_X); | |
0 | 612 if ( v30->field_C >= 0 ) |
613 { | |
614 LABEL_124: | |
615 v31 = v30->field_C; | |
616 v30->pParent = &array_77EC08[1999]; | |
617 fill_pixels_fast( | |
618 a1b, | |
619 &pRenderer->pTargetSurface[v30->field_8 + pRenderer->uTargetSurfacePitch * v30->field_A], | |
620 v31); | |
621 j_memset32(-65536, &pRenderer->pActiveZBuffer[v30->field_8 + 640 * v30->field_A], v30->field_C); | |
622 goto LABEL_125; | |
623 } | |
624 LOWORD(v2) = LOWORD(unnamed_6BE060[1]); | |
625 v30->field_E = LOWORD(unnamed_6BE060[1]); | |
626 } | |
627 } | |
628 LABEL_125: | |
629 --v29; | |
630 --v9; | |
631 if ( !v9 ) | |
632 return (signed __int16)v2; | |
633 } | |
634 } | |
635 if ( (signed int)v9 > 0 ) | |
636 { | |
637 v12 = v9; | |
638 do | |
639 { | |
640 v13 = &pSpans[v12 - 1]; | |
641 v2 = (stru148 *)v13->field_E; | |
642 if ( v2 != (stru148 *)unnamed_6BE060[1] ) | |
643 { | |
693 | 644 LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); |
645 if ( v13->field_8 >= (signed int)pViewport->uViewportTL_X ) | |
0 | 646 goto LABEL_109; |
693 | 647 if ( v13->field_C != pViewport->uViewportTL_X ) |
648 { | |
649 v13->field_8 = LOWORD(pViewport->uViewportTL_X); | |
650 v13->field_C -= LOWORD(pViewport->uViewportTL_X); | |
0 | 651 if ( v13->field_C >= 0 ) |
652 { | |
653 LABEL_109: | |
654 if ( pOutdoorCamera->bNoSky ) | |
655 { | |
656 const_1_0(); | |
657 } | |
658 else | |
659 { | |
660 v13->pParent = &array_77EC08[1999]; | |
661 if ( !Render::DrawSkySW(v13, &array_77EC08[1999], a1a) ) | |
662 j_memset32(-65536, &pRenderer->pActiveZBuffer[v13->field_8 + 640 * v13->field_A], v13->field_C); | |
663 } | |
664 } | |
665 LOWORD(v2) = LOWORD(unnamed_6BE060[1]); | |
666 v13->field_E = LOWORD(unnamed_6BE060[1]); | |
667 goto LABEL_114; | |
668 } | |
669 v13->field_E = LOWORD(unnamed_6BE060[1]); | |
670 } | |
671 LABEL_114: | |
672 --v12; | |
673 --v9; | |
674 } | |
675 while ( v9 ); | |
676 } | |
677 return (signed __int16)v2; | |
678 } | |
679 | |
680 //----- (00485044) -------------------------------------------------------- | |
681 int Render::DrawSkySW(Span *a1, stru148 *a2, int a3) | |
682 { | |
683 stru148 *v3; // esi@1 | |
684 Span *v4; // edi@1 | |
685 float v5; // ST2C_4@1 | |
686 signed int result; // eax@2 | |
687 int v7; // ST40_4@3 | |
688 stru149 *v8; // eax@3 | |
689 int v9; // ebx@3 | |
690 int v10; // ecx@3 | |
691 int v11; // edx@3 | |
692 int v12; // eax@3 | |
693 int v13; // ST28_4@5 | |
694 int v14; // eax@5 | |
695 signed __int64 v15; // qtt@11 | |
696 int v16; // ST28_4@11 | |
697 int v17; // eax@11 | |
698 signed int v18; // ecx@11 | |
699 int v19; // ST40_4@11 | |
700 int v20; // ST3C_4@11 | |
701 int v21; // ST30_4@11 | |
702 void *v22; // eax@11 | |
703 Texture *v23; // esi@11 | |
704 int v24; // ecx@11 | |
705 unsigned int v25; // esi@11 | |
706 int v26; // edi@11 | |
707 unsigned __int16 *v27; // eax@11 | |
708 int *v28; // ebx@12 | |
709 int v29; // edx@13 | |
710 unsigned __int16 v30; // cx@13 | |
711 int v31; // edx@14 | |
712 unsigned __int16 v32; // cx@14 | |
713 unsigned __int8 v33; // sf@15 | |
714 unsigned __int8 v34; // of@15 | |
715 double v35; // [sp+14h] [bp-38h]@1 | |
716 int v36; // [sp+18h] [bp-34h]@3 | |
717 signed int v37; // [sp+18h] [bp-34h]@11 | |
718 int v38; // [sp+1Ch] [bp-30h]@3 | |
719 signed int v39; // [sp+1Ch] [bp-30h]@11 | |
720 int v40; // [sp+20h] [bp-2Ch]@3 | |
721 void *v41; // [sp+20h] [bp-2Ch]@11 | |
722 int v42; // [sp+24h] [bp-28h]@3 | |
723 unsigned __int8 *v43; // [sp+24h] [bp-28h]@11 | |
724 int v44; // [sp+28h] [bp-24h]@11 | |
725 int v45; // [sp+2Ch] [bp-20h]@3 | |
726 signed int v46; // [sp+30h] [bp-1Ch]@3 | |
727 __int16 v47; // [sp+30h] [bp-1Ch]@11 | |
728 signed int v48; // [sp+34h] [bp-18h]@3 | |
729 int v49; // [sp+34h] [bp-18h]@11 | |
730 int v50; // [sp+38h] [bp-14h]@3 | |
731 unsigned __int16 *v51; // [sp+38h] [bp-14h]@11 | |
732 int v52; // [sp+3Ch] [bp-10h]@4 | |
733 int a1a; // [sp+40h] [bp-Ch]@3 | |
734 int v54; // [sp+44h] [bp-8h]@3 | |
735 int v55; // [sp+48h] [bp-4h]@3 | |
736 int v56; // [sp+54h] [bp+8h]@11 | |
737 int *v57; // [sp+54h] [bp+8h]@11 | |
738 | |
739 v3 = a2; | |
740 v4 = a1; | |
693 | 741 v5 = (double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5 / tan(0.6457717418670654) + 0.5; |
0 | 742 v35 = v5 + 6.7553994e15; |
743 if ( LODWORD(v35) ) | |
744 { | |
745 v55 = 65536 / SLODWORD(v35); | |
746 v7 = 65536 / SLODWORD(v35) * (a3 - v4->field_A); | |
747 v8 = v3->ptr_38; | |
748 v42 = ((unsigned __int64)(v3->ptr_38->field_14 * (signed __int64)v7) >> 16) + v8->field_C; | |
749 v40 = ((unsigned __int64)(v8->field_20 * (signed __int64)v7) >> 16) + v3->ptr_38->field_18; | |
750 v38 = pOutdoorCamera->camera_rotation_y_int_sine; | |
751 HIDWORD(v35) = pOutdoorCamera->camera_rotation_y_int_cosine; | |
752 v45 = v4->field_C; | |
753 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v7) >> 16) + v3->v_18.x; | |
754 v10 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); | |
755 v48 = 0; | |
756 v50 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); | |
757 v46 = -v3->field_24; | |
758 v11 = v4->field_A - 1; | |
759 v54 = v11; | |
760 v12 = 65536 / SLODWORD(v35) * (a3 - v11); | |
761 a1a = 65536 / SLODWORD(v35) * (a3 - v11); | |
762 while ( 1 ) | |
763 { | |
764 v52 = v9; | |
765 if ( v9 ) | |
766 { | |
767 v13 = abs(v46 >> 14); | |
768 v14 = abs(v9); | |
769 v11 = v54; | |
770 v10 = v50; | |
771 if ( v13 <= v14 ) | |
772 break; | |
773 v12 = a1a; | |
774 } | |
693 | 775 if ( v11 <= (signed int)pViewport->uViewportTL_Y ) |
0 | 776 break; |
777 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v12) >> 16) + v3->v_18.x; | |
778 --v54; | |
779 a1a += v55; | |
780 v12 = a1a; | |
781 v11 = v54; | |
782 v48 = 1; | |
783 } | |
784 if ( v48 ) | |
785 v52 = ((unsigned __int64)(v3->v_18.z * (signed __int64)(v55 * (a3 + (signed int)v4->field_A - 2 * v11))) >> 16) | |
786 + v3->v_18.x; | |
787 LODWORD(v15) = v46 << 16; | |
788 HIDWORD(v15) = v46 >> 16; | |
789 v16 = v42 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v10) >> 16); | |
790 v17 = v40 + ((unsigned __int64)(v3->ptr_38->field_1C * (signed __int64)v10) >> 16); | |
791 v18 = v15 / v52; | |
710 | 792 v43 = v3->pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 793 v19 = v3->sTextureDeltaU + ((signed int)((unsigned __int64)(v16 * v15 / v52) >> 16) >> 3); |
794 v56 = v15 / v52; | |
795 v20 = v3->sTextureDeltaV + ((signed int)((unsigned __int64)(v17 * v15 / v52) >> 16) >> 3); | |
796 v21 = (unsigned __int64)(v55 * (signed __int64)v56) >> 16; | |
797 v39 = (signed int)((unsigned __int64)(v21 * (signed __int64)v38) >> 16) >> 3; | |
798 v37 = (signed int)((unsigned __int64)(v21 * (signed __int64)v36) >> 16) >> 3; | |
799 v22 = sr_sub_47C178(v18, v3, 0, 1); | |
800 v23 = v3->pTexture; | |
801 v41 = v22; | |
802 v47 = 16 - v23->uWidthLn2; | |
803 v44 = v23->uTextureWidth - 1; | |
804 v49 = (v23->uTextureHeight << 16) - 65536; | |
805 v24 = v4->field_8; | |
806 v51 = &pRenderer->pTargetSurface[v24 + pRenderer->uTargetSurfacePitch * v4->field_A]; | |
807 v57 = &pRenderer->pActiveZBuffer[v24 + 640 * v4->field_A]; | |
808 v25 = v19; | |
809 v26 = v20; | |
810 v27 = v51; | |
811 if ( !(v45 & 1) ) | |
812 goto LABEL_15; | |
813 --v45; | |
814 v27 = v51 - 1; | |
815 v28 = v57; | |
816 ++v57; | |
817 while ( 1 ) | |
818 { | |
819 *v28 = -65536; | |
820 v31 = v44 & (v25 >> 16); | |
821 v27 += 2; | |
822 v25 += v39; | |
823 v32 = *((short *)v41 + *(&v43[v31] + ((v49 & (unsigned int)v26) >> v47))); | |
824 v26 += v37; | |
825 *(v27 - 1) = v32; | |
826 LABEL_15: | |
827 v34 = __OFSUB__(v45, 2); | |
828 v33 = v45 - 2 < 0; | |
829 v45 -= 2; | |
830 if ( v33 ^ v34 ) | |
831 break; | |
832 v29 = v44 & (v25 >> 16); | |
833 v25 += v39; | |
834 v30 = *((short *)v41 + *(&v43[v29] + ((v49 & (unsigned int)v26) >> v47))); | |
835 v26 += v37; | |
836 v28 = v57; | |
837 *v27 = v30; | |
838 v57 += 2; | |
839 v28[1] = -65536; | |
840 } | |
841 result = 1; | |
842 } | |
843 else | |
844 { | |
845 result = 0; | |
846 } | |
847 return result; | |
848 } | |
849 | |
850 //----- (0047F5C6) -------------------------------------------------------- | |
851 float Render::DrawBezierTerrain() | |
852 { | |
853 //__debugbreak();Ritor1: it's temporarily | |
854 //return 0; | |
855 | |
86 | 856 unsigned int pDirectionIndicator1; // ebx@1 |
857 unsigned int pDirectionIndicator2; // edi@1 | |
0 | 858 unsigned int v2; // eax@1 |
859 int v3; // eax@3 | |
860 int v4; // edi@3 | |
861 int v5; // ebx@3 | |
862 int v6; // esi@3 | |
863 unsigned int v7; // eax@3 | |
864 int v8; // eax@4 | |
865 unsigned int v9; // eax@6 | |
866 int v10; // eax@7 | |
867 int v11; // ebx@9 | |
868 int v12; // edi@9 | |
869 int v13; // eax@21 | |
870 int v14; // eax@31 | |
871 int v15; // edi@33 | |
67 | 872 int v16; // eax@34 |
0 | 873 int v17; // edx@34 |
874 int v18; // ebx@34 | |
875 int v19; // eax@36 | |
876 int v20; // eax@39 | |
877 int v21; // ecx@43 | |
878 char v22; // zf@44 | |
879 int v23; // ecx@47 | |
880 int v24; // edi@52 | |
67 | 881 int v25; // eax@54 |
0 | 882 int v26; // ecx@54 |
883 int v27; // eax@56 | |
884 int v28; // edx@60 | |
885 int v29; // ecx@61 | |
886 int v30; // ecx@64 | |
887 int v31; // ecx@68 | |
888 int v32; // eax@70 | |
889 int v33; // ecx@71 | |
890 int v34; // eax@73 | |
891 int v35; // ecx@77 | |
892 int v36; // ecx@81 | |
893 int v37; // ecx@86 | |
67 | 894 int v38; // eax@88 |
895 int v39; // ecx@88 | |
0 | 896 int v40; // eax@90 |
897 int v41; // edx@94 | |
898 int v42; // ecx@95 | |
899 int v43; // ecx@98 | |
900 int v44; // ecx@102 | |
901 int v45; // eax@104 | |
902 int v46; // eax@107 | |
903 int v47; // ecx@111 | |
904 int v48; // ecx@115 | |
905 int v49; // edi@120 | |
67 | 906 int v50; // eax@122 |
0 | 907 int v51; // ecx@122 |
908 int v52; // eax@124 | |
909 int v53; // edx@128 | |
910 int v54; // ecx@129 | |
911 int v55; // ecx@132 | |
912 int v56; // eax@139 | |
913 int v57; // ecx@140 | |
914 int v58; // eax@142 | |
915 int v59; // ecx@146 | |
916 int v60; // ecx@147 | |
917 int v61; // ecx@150 | |
918 int v62; // ecx@155 | |
67 | 919 int v63; // eax@157 |
920 int v64; // ecx@157 | |
0 | 921 int v65; // eax@159 |
922 int v66; // edx@163 | |
923 int v67; // ecx@164 | |
924 int v68; // ecx@167 | |
925 int v69; // eax@173 | |
926 int v70; // edi@178 | |
927 int v71; // eax@178 | |
928 int v72; // ecx@178 | |
86 | 929 int x; // ebx@180 |
0 | 930 int v74; // eax@182 |
931 int v75; // eax@184 | |
67 | 932 IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 |
86 | 933 int uStartZ; // ecx@184 |
0 | 934 int v79; // ebx@185 |
935 int v127; // esi@185 | |
936 int v86; // edi@196 | |
937 int v87; // eax@196 | |
938 int v88; // ecx@196 | |
939 int v89; // eax@198 | |
940 int v90; // ecx@200 | |
941 int v92; // ebx@203 | |
942 int v93; // ST08_4@204 | |
943 int v97; // ST08_4@204 | |
944 float result; // eax@212 | |
67 | 945 struct |
946 { | |
947 char v102[4]; // [sp+Ch] [bp-68h]@191 | |
0 | 948 __int16 v103; // [sp+10h] [bp-64h]@190 |
949 __int16 v104; // [sp+12h] [bp-62h]@190 | |
67 | 950 } v102; |
77 | 951 int v105; // [sp+1Ch] [bp-58h]@1 |
0 | 952 int v106; // [sp+20h] [bp-54h]@3 |
86 | 953 int uEndZ; // [sp+24h] [bp-50h]@3 |
0 | 954 int v108; // [sp+28h] [bp-4Ch]@9 |
955 int v109; // [sp+2Ch] [bp-48h]@9 | |
956 int v110; // [sp+30h] [bp-44h]@9 | |
957 int v111; // [sp+34h] [bp-40h]@3 | |
958 int v112; // [sp+38h] [bp-3Ch]@6 | |
67 | 959 IndoorCameraD3D *pIndoorCameraD3D_4; // [sp+3Ch] [bp-38h]@9 |
0 | 960 int v114; // [sp+40h] [bp-34h]@9 |
961 int v115; // [sp+44h] [bp-30h]@9 | |
962 int v116; // [sp+48h] [bp-2Ch]@9 | |
963 int v117; // [sp+4Ch] [bp-28h]@9 | |
964 int v118; // [sp+50h] [bp-24h]@9 | |
965 int v119; // [sp+54h] [bp-20h]@1 | |
966 int v120; // [sp+58h] [bp-1Ch]@1 | |
967 int i; // [sp+5Ch] [bp-18h]@1 | |
968 int v122; // [sp+60h] [bp-14h]@1 | |
969 int v123; // [sp+64h] [bp-10h]@1 | |
67 | 970 int v124; // [sp+68h] [bp-Ch]@1 |
0 | 971 int v125; // [sp+6Ch] [bp-8h]@9 |
67 | 972 int v126; // [sp+70h] [bp-4h]@9 |
973 | |
96 | 974 v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2 |
86 | 975 pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 |
976 pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512 | |
323 | 977 v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16; |
978 v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16; | |
67 | 979 v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X |
0 | 980 v119 = pOutdoorCamera->outdoor_grid_band_3 + v123; |
981 v2 = pOutdoorCamera->uCameraFovInDegrees + 15; | |
67 | 982 i = v124 - pOutdoorCamera->outdoor_grid_band_3; |
0 | 983 v122 = v123 - pOutdoorCamera->outdoor_grid_band_3; |
67 | 984 |
985 if ( v2 > 90 ) | |
0 | 986 v2 = 90; |
67 | 987 v3 = (v2 << 11) / 720; |
86 | 988 v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3); |
989 v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1); | |
323 | 990 v106 = stru_5C6E00->Cos(v4); |
991 uEndZ = stru_5C6E00->Sin(v4); | |
992 v111 = stru_5C6E00->Cos(v5); | |
993 v6 = stru_5C6E00->Sin(v5); | |
0 | 994 v7 = v4 & stru_5C6E00->uPiMask; |
67 | 995 |
996 if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) | |
0 | 997 v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7]; |
998 else | |
999 v8 = stru_5C6E00->pTanTable[v7]; | |
1000 v112 = abs(v8); | |
1001 v9 = v5 & stru_5C6E00->uPiMask; | |
67 | 1002 if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) |
0 | 1003 v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9]; |
1004 else | |
1005 v10 = stru_5C6E00->pTanTable[v9]; | |
1006 v108 = abs(v10); | |
67 | 1007 v11 = v124; |
0 | 1008 v12 = v123; |
1009 v114 = 0; | |
1010 v115 = 0; | |
67 | 1011 pIndoorCameraD3D_4 = 0; |
0 | 1012 v125 = 0; |
67 | 1013 v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; |
0 | 1014 v126 = v124; |
1015 v118 = v123; | |
86 | 1016 v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; |
1017 uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; | |
0 | 1018 terrain_76E1C8[0] = 65535; |
67 | 1019 //v116 = 1; |
1020 v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; | |
1021 //v117 = 1; | |
0 | 1022 terrain_76E3C8[0] = 65535; |
1023 terrain_76DDC8[0] = 65535; | |
1024 terrain_76DFC8[0] = 65535; | |
67 | 1025 for( v116=1; v116 < 128; v116++) |
1026 { | |
1027 if ( v112 >= 0x10000 ) | |
1028 { | |
1029 int v1, v2; | |
1030 /*v111 = 4294967296i64 / v112; | |
0 | 1031 v114 += v111; |
1032 if ( v114 >= 65536 ) | |
1033 { | |
1034 v11 += v110; | |
1035 v114 = (unsigned __int16)v114; | |
1036 } | |
67 | 1037 v12 += v109;*/ |
0 | 1038 } |
1039 else | |
1040 { | |
1041 v11 += v110; | |
1042 v115 += v112; | |
67 | 1043 if ( v112 + v115 >= 65536 ) |
0 | 1044 { |
1045 v12 += v109; | |
1046 v115 = (unsigned __int16)v115; | |
1047 } | |
1048 } | |
67 | 1049 if ( v11 < i || v11 > v120 || v12 < v122 || v12 > v119 ) |
0 | 1050 break; |
67 | 1051 //v13 = v116++; |
1052 terrain_76E3C8[v116] = v11; | |
1053 terrain_76E1C8[v116] = v12; | |
1054 } | |
1055 | |
1056 for( v117=1; v117 < 128; v117++ ) | |
0 | 1057 { |
1058 if ( v108 >= 65536 ) | |
1059 { | |
1060 v111 = 4294967296i64 / v108; | |
67 | 1061 v114 += v111;// |
1062 if ( v111 + v114 >= 65536 ) | |
1063 { | |
86 | 1064 v126 += uEndZ; |
67 | 1065 v114 = (unsigned __int16)v114;// |
0 | 1066 } |
1067 v118 += v106; | |
1068 } | |
1069 else | |
1070 { | |
1071 v125 += v108; | |
86 | 1072 v126 += uEndZ; |
0 | 1073 if ( v125 >= 65536 ) |
1074 { | |
1075 v118 += v106; | |
1076 v125 = (unsigned __int16)v125; | |
1077 } | |
1078 } | |
67 | 1079 //if ( v117 >= 128 ) |
1080 //break; | |
1081 if ( v126 < i ) | |
0 | 1082 break; |
67 | 1083 if ( v126 > v120 ) |
0 | 1084 break; |
1085 v14 = v118; | |
1086 if ( v118 < v122 ) | |
1087 break; | |
1088 if ( v118 > v119 ) | |
1089 break; | |
67 | 1090 terrain_76DFC8[v117] = v126; |
1091 terrain_76DDC8[v117] = v14; | |
1092 } | |
1093 v16 = 0; | |
1094 v126 = 0; | |
0 | 1095 v17 = v117 - 1; |
1096 v18 = v116 - 1; | |
77 | 1097 switch ( v105 ) |
0 | 1098 { |
1099 case 0: | |
1100 case 7: | |
67 | 1101 { |
0 | 1102 v116 = terrain_76DFC8[v17]; |
1103 if ( v120 > v116 ) | |
1104 { | |
1105 v125 = v120; | |
67 | 1106 memset32(terrain_76D9C8, v119 + 1, 4 * (v120 - v116 + 1)); |
0 | 1107 v19 = v120; |
1108 do | |
67 | 1109 terrain_76DBC8[v126++] = v19--; |
0 | 1110 while ( v19 >= v116 ); |
1111 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 + 127] ) | |
1112 { | |
1113 do | |
67 | 1114 v20 = terrain_76DDC8[v17-- -1]; |
1115 while ( v20 == terrain_76DDC8[v17 -1] ); | |
0 | 1116 } |
1117 v16 = v126; | |
1118 --v17; | |
1119 } | |
1120 if ( v17 < 0 ) | |
1121 v17 = 0; | |
1122 v21 = terrain_76DFC8[v17]; | |
1123 while ( 1 ) | |
1124 { | |
1125 v125 = v21; | |
67 | 1126 if ( v21 < v124 ) |
0 | 1127 break; |
67 | 1128 terrain_76DBC8[v16] = v21; |
0 | 1129 v22 = terrain_76DDC8[v17] == 65535; |
67 | 1130 terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1; |
0 | 1131 if ( v22 ) |
1132 { | |
67 | 1133 terrain_76D9C8[v16] = v123 + 1; |
0 | 1134 break; |
1135 } | |
1136 if ( !v17 ) | |
1137 break; | |
67 | 1138 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 - 1] ) |
0 | 1139 { |
1140 do | |
67 | 1141 v23 = terrain_76DDC8[v17-- -1]; |
1142 while ( v23 == terrain_76DDC8[v17 -1] ); | |
0 | 1143 } |
1144 --v17; | |
1145 v21 = v125 - 1; | |
67 | 1146 ++v16; |
1147 } | |
1148 v16 = 0; | |
0 | 1149 v24 = terrain_76E3C8[v18]; |
67 | 1150 v126 = 0; |
0 | 1151 if ( v120 > v24 ) |
1152 { | |
1153 v125 = v120; | |
67 | 1154 memset32(terrain_76D5C8, v122, 4 * (v120 - v24 + 1)); |
0 | 1155 do |
1156 { | |
1157 v25 = v126; | |
1158 v26 = v125--; | |
67 | 1159 ++v126; |
1160 terrain_76D7C8[v25] = v26; | |
0 | 1161 } |
1162 while ( v125 >= terrain_76E3C8[v18] ); | |
67 | 1163 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) |
0 | 1164 { |
1165 do | |
67 | 1166 v27 = terrain_76E1C8[v18-- -1]; |
1167 while ( v27 == terrain_76E1C8[v18 -1] ); | |
0 | 1168 } |
1169 v16 = v126; | |
1170 --v18; | |
1171 } | |
1172 if ( v18 < 0 ) | |
1173 v18 = 0; | |
1174 v28 = terrain_76E3C8[v18]; | |
67 | 1175 while ( v28 >= v124 ) |
0 | 1176 { |
1177 v29 = terrain_76E1C8[v18]; | |
67 | 1178 terrain_76D7C8[v16] = v28; |
1179 terrain_76D5C8[v16] = v29; | |
0 | 1180 if ( v29 == 65535 ) |
1181 { | |
1182 v31 = v123; | |
67 | 1183 terrain_76D5C8[v16] = v31; |
1184 break; | |
0 | 1185 } |
1186 if ( !v18 ) | |
1187 break; | |
67 | 1188 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) |
0 | 1189 { |
1190 do | |
67 | 1191 v30 = terrain_76E1C8[v18-- -1]; |
1192 while ( v30 == terrain_76E1C8[v18 -1] ); | |
0 | 1193 } |
1194 --v18; | |
1195 --v28; | |
67 | 1196 ++v16; |
0 | 1197 } |
1198 break; | |
67 | 1199 } |
0 | 1200 case 1: |
1201 case 2: | |
67 | 1202 { |
0 | 1203 v116 = terrain_76DDC8[v17]; |
1204 if ( v122 < v116 ) | |
1205 { | |
1206 v106 = v122; | |
67 | 1207 memset32(terrain_76DBC8, v120 + 1, 4 * (v116 - v122 + 1)); |
0 | 1208 v32 = v122; |
1209 do | |
1210 { | |
67 | 1211 v33 = v126++; |
0 | 1212 terrain_76D9C8[v33] = v32++; |
1213 } | |
1214 while ( v32 <= v116 ); | |
67 | 1215 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1216 { |
1217 do | |
67 | 1218 v34 = terrain_76DBC8[v17-- -1]; |
1219 while ( v34 == terrain_76DBC8[v17 -1] ); | |
0 | 1220 } |
1221 v16 = v126; | |
1222 --v17; | |
1223 } | |
1224 if ( v17 < 0 ) | |
1225 v17 = 0; | |
1226 v35 = terrain_76DDC8[v17]; | |
1227 v125 = terrain_76DDC8[v17]; | |
1228 while ( v35 <= v123 ) | |
1229 { | |
1230 v22 = terrain_76DFC8[v17] == 65535; | |
67 | 1231 terrain_76DBC8[v16] = terrain_76DFC8[v17] + 1; |
1232 terrain_76D9C8[v16] = v125; | |
0 | 1233 if ( v22 ) |
1234 { | |
67 | 1235 terrain_76DBC8[v16] = v124 + 1; |
0 | 1236 break; |
1237 } | |
1238 if ( !v17 ) | |
1239 break; | |
67 | 1240 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1241 { |
1242 do | |
67 | 1243 v36 = terrain_76DBC8[v17-- -1]; |
1244 while ( v36 == terrain_76DBC8[v17 -1] ); | |
0 | 1245 } |
1246 --v17; | |
1247 ++v125; | |
1248 v35 = v125; | |
67 | 1249 ++v16; |
1250 } | |
1251 v16 = 0; | |
1252 v126 = 0; | |
0 | 1253 v37 = terrain_76E1C8[v18]; |
1254 if ( v122 < v37 ) | |
1255 { | |
67 | 1256 v114 = v122; |
1257 memset32(terrain_76D7C8, i, 4 * (v37 - v122 + 1)); | |
0 | 1258 do |
1259 { | |
1260 v38 = v126; | |
67 | 1261 v39 = v114; |
1262 ++v126; | |
1263 ++v114; | |
1264 terrain_76D5C8[v38] = v39; | |
1265 } | |
1266 while ( v114 <= terrain_76E1C8[v18] ); | |
1267 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) | |
0 | 1268 { |
1269 do | |
67 | 1270 v40 = terrain_76DFC8[v18-- -1]; |
1271 while ( v40 == terrain_76DFC8[v18 -1] ); | |
0 | 1272 } |
1273 v16 = v126; | |
1274 --v18; | |
1275 } | |
1276 if ( v18 < 0 ) | |
1277 v18 = 0; | |
1278 v41 = terrain_76E1C8[v18]; | |
1279 while ( v41 <= v123 ) | |
1280 { | |
1281 v42 = terrain_76E3C8[v18]; | |
67 | 1282 terrain_76D5C8[v16] = v41; |
1283 terrain_76D7C8[v16] = v42; | |
0 | 1284 if ( v42 == 65535 ) |
1285 { | |
67 | 1286 terrain_76D7C8[v16] = v124; |
1287 break; | |
0 | 1288 } |
1289 if ( !v18 ) | |
1290 break; | |
67 | 1291 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) |
0 | 1292 { |
1293 do | |
67 | 1294 v43 = terrain_76DFC8[v18-- -1]; |
1295 while ( v43 == terrain_76DFC8[v18 -1] ); | |
0 | 1296 } |
1297 --v18; | |
1298 ++v41; | |
67 | 1299 ++v16; |
0 | 1300 } |
1301 break; | |
67 | 1302 } |
0 | 1303 case 5: |
1304 case 6: | |
67 | 1305 { |
0 | 1306 v116 = terrain_76DDC8[v17]; |
1307 if ( v119 > v116 ) | |
1308 { | |
1309 v106 = v119; | |
67 | 1310 memset32(terrain_76DBC8, i, 4 * (v119 - v116 + 1)); |
0 | 1311 v45 = v119; |
1312 do | |
67 | 1313 terrain_76D9C8[v126++] = v45--; |
0 | 1314 while ( v45 >= v116 ); |
67 | 1315 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1316 { |
1317 do | |
67 | 1318 v46 = terrain_76DBC8[v17-- -1]; |
1319 while ( v46 == terrain_76DBC8[v17 -1] ); | |
0 | 1320 } |
1321 v16 = v126; | |
1322 --v17; | |
1323 } | |
1324 if ( v17 < 0 ) | |
1325 v17 = 0; | |
1326 v47 = terrain_76DDC8[v17]; | |
1327 v125 = terrain_76DDC8[v17]; | |
1328 while ( v47 >= v123 ) | |
1329 { | |
1330 v22 = terrain_76DFC8[v17] == 65535; | |
67 | 1331 terrain_76DBC8[v16] = terrain_76DFC8[v17]; |
1332 terrain_76D9C8[v16] = v125; | |
0 | 1333 if ( v22 ) |
1334 { | |
67 | 1335 terrain_76DBC8[v16] = v124; |
0 | 1336 break; |
1337 } | |
1338 if ( !v17 ) | |
1339 break; | |
67 | 1340 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) |
0 | 1341 { |
1342 do | |
67 | 1343 v48 = terrain_76DBC8[v17-- -1]; |
1344 while ( v48 == terrain_76DBC8[v17 -1] ); | |
0 | 1345 } |
1346 --v17; | |
1347 --v125; | |
1348 v47 = v125; | |
67 | 1349 ++v16; |
1350 } | |
1351 v16 = 0; | |
0 | 1352 v49 = terrain_76E1C8[v18]; |
67 | 1353 v126 = 0; |
0 | 1354 if ( v119 > v49 ) |
1355 { | |
1356 v125 = v119; | |
67 | 1357 memset32(terrain_76D7C8, v120 + 1, 4 * (v119 - v49 + 1)); |
0 | 1358 do |
1359 { | |
1360 v50 = v126; | |
1361 v51 = v125--; | |
67 | 1362 ++v126; |
1363 terrain_76D5C8[v50] = v51; | |
0 | 1364 } |
1365 while ( v125 >= terrain_76E1C8[v18] ); | |
67 | 1366 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) |
0 | 1367 { |
1368 do | |
67 | 1369 v52 = terrain_76DFC8[v18-- -1]; |
1370 while ( v52 == terrain_76DFC8[v18 -1] ); | |
0 | 1371 } |
1372 v16 = v126; | |
1373 --v18; | |
1374 } | |
1375 if ( v18 < 0 ) | |
1376 v18 = 0; | |
1377 v53 = terrain_76E1C8[v18]; | |
1378 while ( v53 >= v123 ) | |
1379 { | |
1380 v54 = terrain_76E3C8[v18]; | |
67 | 1381 terrain_76D5C8[v16] = v53; |
1382 terrain_76D7C8[v16] = v54 + 1; | |
0 | 1383 if ( v54 == 65535 ) |
1384 { | |
67 | 1385 terrain_76D7C8[v16] = v124 + 1; |
1386 break; | |
0 | 1387 } |
1388 if ( !v18 ) | |
67 | 1389 break; |
1390 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) | |
0 | 1391 { |
1392 do | |
67 | 1393 v55 = terrain_76DFC8[v18-- -1]; |
1394 while ( v55 == terrain_76DFC8[v18 -1] ); | |
0 | 1395 } |
1396 --v18; | |
1397 --v53; | |
67 | 1398 ++v16; |
0 | 1399 } |
1400 break; | |
67 | 1401 } |
0 | 1402 case 3: |
1403 case 4: | |
67 | 1404 { |
0 | 1405 v116 = terrain_76DFC8[v17]; |
1406 if ( i < v116 ) | |
1407 { | |
1408 v106 = i; | |
67 | 1409 memset32(terrain_76D9C8, v122, 4 * (v116 - i + 1)); |
0 | 1410 v56 = i; |
1411 do | |
1412 { | |
67 | 1413 v57 = v126++; |
0 | 1414 terrain_76DBC8[v57] = v56++; |
1415 } | |
1416 while ( v56 <= v116 ); | |
67 | 1417 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) |
0 | 1418 { |
1419 do | |
67 | 1420 v58 = terrain_76DDC8[v17-- -1]; |
1421 while ( v58 == terrain_76DDC8[v17 -1] ); | |
0 | 1422 } |
1423 v16 = v126; | |
1424 --v17; | |
1425 } | |
1426 if ( v17 < 0 ) | |
1427 v17 = 0; | |
1428 v59 = terrain_76DFC8[v17]; | |
1429 while ( 1 ) | |
1430 { | |
1431 v125 = v59; | |
67 | 1432 if ( v59 > v124 ) |
0 | 1433 break; |
67 | 1434 terrain_76DBC8[v16] = v59; |
0 | 1435 v60 = terrain_76DDC8[v17]; |
67 | 1436 terrain_76D9C8[v16] = v60; |
0 | 1437 if ( v60 == 65535 ) |
1438 { | |
67 | 1439 terrain_76D9C8[v16] = v123; |
0 | 1440 break; |
1441 } | |
1442 if ( !v17 ) | |
1443 break; | |
67 | 1444 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) |
0 | 1445 { |
1446 do | |
67 | 1447 v61 = terrain_76DDC8[v17-- -1]; |
1448 while ( v61 == terrain_76DDC8[v17 -1] ); | |
0 | 1449 } |
1450 --v17; | |
1451 v59 = v125 + 1; | |
67 | 1452 ++v16; |
1453 } | |
1454 v16 = 0; | |
1455 v126 = 0; | |
0 | 1456 v62 = terrain_76E3C8[v18]; |
1457 if ( i < v62 ) | |
1458 { | |
67 | 1459 v114 = i; |
1460 memset32(terrain_76D5C8, v119 + 1, 4 * (v62 - i + 1)); | |
0 | 1461 do |
1462 { | |
1463 v63 = v126; | |
67 | 1464 v64 = v114; |
1465 ++v126; | |
1466 ++v114; | |
1467 terrain_76D7C8[v63] = v64; | |
1468 } | |
1469 while ( v114 <= terrain_76E3C8[v18] ); | |
1470 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) | |
0 | 1471 { |
1472 do | |
67 | 1473 v65 = terrain_76E1C8[v18-- -1]; |
1474 while ( v65 == terrain_76E1C8[v18 -1] ); | |
0 | 1475 } |
1476 v16 = v126; | |
1477 --v18; | |
1478 } | |
1479 if ( v18 < 0 ) | |
1480 v18 = 0; | |
1481 v66 = terrain_76E3C8[v18]; | |
67 | 1482 while ( v66 <= v124 ) |
0 | 1483 { |
1484 v67 = terrain_76E1C8[v18]; | |
67 | 1485 terrain_76D7C8[v16] = v66; |
1486 terrain_76D5C8[v16] = v67 + 1; | |
0 | 1487 if ( v67 == 65535 ) |
1488 { | |
1489 v31 = v123 + 1; | |
67 | 1490 terrain_76D5C8[v16] = v31; |
1491 break; | |
0 | 1492 } |
1493 if ( !v18 ) | |
67 | 1494 break; |
1495 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) | |
0 | 1496 { |
1497 do | |
67 | 1498 v68 = terrain_76E1C8[v18-- -1]; |
1499 while ( v68 == terrain_76E1C8[v18 -1] ); | |
0 | 1500 } |
1501 --v18; | |
1502 ++v66; | |
67 | 1503 ++v16; |
0 | 1504 } |
1505 break; | |
67 | 1506 } |
0 | 1507 default: |
1508 break; | |
1509 } | |
67 | 1510 v69 = v16 - 1; |
0 | 1511 ptr_801A08 = pVerticesSR_806210; |
1512 ptr_801A04 = pVerticesSR_801A10; | |
67 | 1513 v126 = v69; |
106 | 1514 if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//áëîê |
0 | 1515 { |
1516 for ( i = v69; i >= 1; --i ) | |
1517 { | |
67 | 1518 //v70 = i; |
86 | 1519 v71 = terrain_76D7C8[i];//88 |
1520 v72 = terrain_76DBC8[i];//0 | |
67 | 1521 if ( v71 < v72 )//swap |
1522 { | |
1523 terrain_76DBC8[i] = v71; | |
1524 terrain_76D7C8[i] = v72; | |
1525 } | |
86 | 1526 x = terrain_76DBC8[i];//0 |
0 | 1527 v111 = 0; |
86 | 1528 if ( x <= 0 ) |
1529 x = -x; | |
67 | 1530 v74 = terrain_76D7C8[i]; |
0 | 1531 if ( v74 <= 0 ) |
1532 v74 = -v74; | |
1533 v75 = v74 + 2; | |
67 | 1534 //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; |
86 | 1535 uEndZ = v75; |
67 | 1536 //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; |
86 | 1537 uStartZ = x - 2; |
1538 if ( x - 2 < v75 ) | |
0 | 1539 { |
1540 v127 = 0; | |
67 | 1541 //v79 = (v73 - 66) << 9; |
1542 //v116 = v77; | |
1543 //pHeight = v79; | |
86 | 1544 v111 = v75 - uStartZ; |
1545 for (int z = uStartZ; z < uEndZ; ++z) | |
1546 { | |
106 | 1547 ptr_801A08[v127].vWorldPosition.x = (-64 + x) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; |
67 | 1548 ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; |
86 | 1549 ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); |
1550 ptr_801A04[v127].vWorldPosition.x = (-64 + x) * 512; | |
67 | 1551 ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; |
86 | 1552 ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); |
0 | 1553 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1554 { | |
67 | 1555 pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); |
1556 pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); | |
1557 pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); | |
1558 pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0); | |
0 | 1559 } |
67 | 1560 //v79 += 512; |
1561 v127 ++; | |
1562 //++v116; | |
1563 //pHeight = v79; | |
106 | 1564 } |
67 | 1565 //while ( v116 < v107 ); |
1566 } | |
106 | 1567 v102.v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); |
67 | 1568 v102.v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); |
106 | 1569 if ( pRenderer->pRenderD3D )//Ritor1: do comment to test |
98 | 1570 Render::RenderTerrainD3D();//Render::DrawTerrainD3D(v111, 0, (int)&v102); |
67 | 1571 else |
1572 Render::DrawTerrainSW(v111, 0, (int)&v102); | |
1573 } | |
1574 } | |
1575 /* else | |
0 | 1576 { |
1577 for ( i = v69; i >= 1; --i ) | |
1578 { | |
1579 v86 = i; | |
1580 v87 = terrain_76D5C8[i]; | |
1581 v88 = terrain_76D9C8[i]; | |
1582 if ( v87 < v88 ) | |
1583 { | |
1584 terrain_76D9C8[v86] = v87; | |
1585 terrain_76D5C8[v86] = v88; | |
1586 } | |
1587 v89 = terrain_76D9C8[v86]; | |
1588 v111 = 0; | |
1589 if ( v89 <= 0 ) | |
1590 v89 = -v89; | |
1591 v90 = terrain_76D5C8[v86]; | |
1592 if ( v90 <= 0 ) | |
1593 v90 = -v90; | |
67 | 1594 pIndoorCameraD3D_4 = pGame->pIndoorCameraD3D; |
0 | 1595 v107 = v90 + 2; |
1596 if ( v89 - 2 < v90 + 2 ) | |
1597 { | |
1598 v86 = 0; | |
1599 v116 = v89 - 2; | |
1600 v92 = (66 - v89) << 9; | |
62 | 1601 pHeight = (66 - v89) << 9; |
0 | 1602 v111 = v90 + 2 - (v89 - 2); |
1603 do | |
1604 { | |
1605 v93 = v116; | |
1606 v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9; | |
1607 *(float *)((char *)&ptr_801A08->vWorldPosition.x + v86) = (double)v106; | |
62 | 1608 *(float *)&pHeight = (double)pHeight; |
1609 *(float *)((char *)&ptr_801A08->vWorldPosition.y + v86) = *(float *)&pHeight; | |
0 | 1610 v106 = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86), v93); |
1611 v97 = v116; | |
1612 *(float *)((char *)&ptr_801A08->vWorldPosition.z + v86) = (double)v106; | |
1613 v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9; | |
1614 *(float *)((char *)&ptr_801A04->vWorldPosition.x + v86) = (double)v106; | |
62 | 1615 *(float *)((char *)&ptr_801A04->vWorldPosition.y + v86) = *(float *)&pHeight; |
1616 pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97); | |
1617 *(float *)((char *)&ptr_801A04->vWorldPosition.z + v86) = (double)pHeight; | |
0 | 1618 if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) |
1619 { | |
67 | 1620 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1); |
1621 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1); | |
1622 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0); | |
1623 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0); | |
0 | 1624 } |
1625 v92 -= 512; | |
1626 v86 += 48; | |
1627 ++v116; | |
62 | 1628 pHeight = v92; |
0 | 1629 } |
1630 while ( v116 < v107 ); | |
1631 } | |
1632 v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]); | |
1633 v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]); | |
67 | 1634 if ( pRenderer->pRenderD3D ) |
1635 Render::DrawTerrainD3D(v111, 1, (int)&v102); | |
1636 else | |
1637 Render::DrawTerrainSW(v111, 1, (int)&v102); | |
1638 } | |
1639 }*/ | |
0 | 1640 result = v126; |
1641 pOutdoorCamera->field_40 = v126; | |
1642 return result; | |
1643 } | |
1644 // 47FFC4: inconsistent fpu stack | |
1645 // 4D864C: using guessed type char byte_4D864C; | |
1646 | |
88 | 1647 void Render::RenderTerrainD3D() // New function. It's temporary |
86 | 1648 { |
1649 char result; // al@3 | |
1650 //int v1; // eax@3 | |
1651 //int v2; // ebx@4 | |
1652 //struct ODMFace *v4; // esi@6 | |
1653 int v6; // ecx@8 | |
1654 //int v7; // ecx@8 | |
1655 struct stru148 *v8; // ebx@8 | |
179 | 1656 // RenderVertexSoft *v8a; // edi@3 |
86 | 1657 //char v11; // zf@8 |
1658 struct stru148 *v16; | |
1659 unsigned int v18; // edi@22 | |
1660 //int v20; // edi@34 | |
1661 //int v28; // eax@50 | |
1662 //int v29; // ecx@55 | |
1663 //int v30; // eax@57 | |
1664 int v31; // eax@57 | |
1665 int v35; // edi@63 | |
1666 int v37; // eax@73 | |
1667 int v39; // eax@80 | |
1668 char v40; // [sp-18h] [bp-70h]@2 | |
1669 int v41; // [sp-14h] [bp-6Ch]@2 | |
1670 int v42; // [sp-10h] [bp-68h]@2 | |
1671 int v43; // [sp-Ch] [bp-64h]@2 | |
1672 const char *v44; // [sp-8h] [bp-60h]@2 | |
1673 int v45; // [sp-4h] [bp-5Ch]@2 | |
1674 //float v48; // [sp+14h] [bp-44h]@8 | |
1675 //void *v52; // [sp+24h] [bp-34h]@3 | |
1676 bool v54; // [sp+2Ch] [bp-2Ch]@10 | |
1677 int v55; // [sp+30h] [bp-28h]@34 | |
1678 int v56; | |
1679 int v57; // [sp+38h] [bp-20h]@36 | |
1680 int v58; // [sp+3Ch] [bp-1Ch]@8 | |
1681 int v63; // [sp+50h] [bp-8h]@3 | |
1682 int v64; // [sp+57h] [bp-1h]@2 | |
1683 int v62; | |
121 | 1684 //struct IndoorCameraD3D *pIndoorCameraD3D; |
179 | 1685 //RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 |
86 | 1686 |
186 | 1687 |
1688 //warning: the game uses CW culling by default, ccw is incosistent | |
1689 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); | |
1690 | |
1691 | |
86 | 1692 v63 = 0; |
1693 // basic optimizations | |
577 | 1694 unsigned int uStartX, uEndX, uStartZ, uEndZ; |
106 | 1695 if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024) |
1696 { | |
1697 uStartX = 0, uEndX = 128; | |
1698 uStartZ = 0, uEndZ = 64 + 16; | |
1699 } | |
1700 else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536) | |
1701 { | |
1702 uStartX = 0, uEndX = 64 + 16; | |
1703 uStartZ = 0, uEndZ = 128; | |
1704 } | |
1705 else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512) | |
1706 { | |
1707 uStartX = 64 - 16, uEndX = 128; | |
1708 uStartZ = 0, uEndZ = 128; | |
1709 } | |
1710 else | |
1711 { | |
1712 uStartX = 0, uEndX = 128; | |
1713 uStartZ = 64 - 16, uEndZ = 128; | |
1714 } | |
147 | 1715 uStartX = 0, uEndX = 128; |
1716 uStartZ = 0, uEndZ = 128; | |
106 | 1717 static RenderVertexSoft pTerrainVertices[128 * 128]; |
1718 for (unsigned int z = uStartZ; z < uEndZ; ++z) | |
1719 { | |
1720 for (unsigned int x = uStartX; x < uEndX; ++x) | |
1721 { | |
1722 pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; | |
1723 pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512; | |
1724 pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; | |
121 | 1725 //pIndoorCameraD3D = pGame->pIndoorCameraD3D; |
1726 pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); | |
1727 pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); | |
106 | 1728 } |
1729 } | |
186 | 1730 |
106 | 1731 for (unsigned int z = uStartZ; z < uEndZ - 1; ++z) |
1732 { | |
1733 for (unsigned int x = uStartX; x < uEndX - 1; ++x) | |
1734 { | |
1735 v8 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
1736 v8->flags = 0; | |
1737 v8->field_32 = 0; | |
1738 //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x]; | |
179 | 1739 //struct TileDesc *pTile = pTileTable->GetTileById(uTileID); |
106 | 1740 v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); |
179 | 1741 //v6 = v8->uTileBitmapID; |
1742 v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v8->uTileBitmapID]; | |
106 | 1743 if (v8->uTileBitmapID == 0xFFFF) |
1744 continue; | |
186 | 1745 |
179 | 1746 v8->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
1747 v8->field_32 = 0; | |
1748 v8->field_59 = 1; | |
1749 //v8->field_5D = (char)WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8a->vWorldPosition.z) / 2 + 0.5f)); | |
1750 //v8->field_5C = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f));; | |
106 | 1751 v8->sTextureDeltaU = 0; |
1752 v8->sTextureDeltaV = 0; | |
1753 memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft)); | |
1754 array_73D150[0].u = 0; | |
1755 array_73D150[0].v = 0; | |
1756 memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1757 array_73D150[1].u = 1; | |
1758 array_73D150[1].v = 0; | |
1759 memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft)); | |
1760 array_73D150[2].u = 1; | |
1761 array_73D150[2].v = 1; | |
1762 memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft)); | |
1763 array_73D150[3].u = 0; | |
1764 array_73D150[3].v = 1; | |
86 | 1765 v55 = 0; |
1766 v54 = false; | |
1767 v58 = 0; | |
1768 if (v58 == 4) // if all y == first y; primitive in xz plane | |
1769 v8->field_32 |= 0x0001; | |
1770 v8->pODMFace = nullptr; | |
1771 v8->uNumVertices = 4; | |
1772 v8->field_59 = 5; | |
638 | 1773 |
1774 | |
1775 uint norm_idx = pTerrainNormalIndices[2 * (x + 128 * z) + 1]; | |
1776 assert(norm_idx < uNumTerrainNormals); | |
1777 | |
1778 auto norm = pTerrainNormals + norm_idx; | |
1779 float _f = (norm->x * (float)pOutdoor->vSunlight.x / 65536.0 - | |
1780 norm->y * (float)pOutdoor->vSunlight.y / 65536.0 - | |
1781 norm->z * (float)pOutdoor->vSunlight.z / 65536.0); | |
1782 v8->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); | |
1783 | |
86 | 1784 ++pOutdoorCamera->numStru148s; |
1785 ++pOutdoorCamera->field_44; | |
265 | 1786 assert(pOutdoorCamera->numStru148s < 20000); |
1787 | |
106 | 1788 v8->uBModelID = 0; |
1789 v8->uBModelFaceID = 0; | |
1790 v31 = (8 * (0 | (0 << 6))); | |
1791 v8->field_50 = v31 | 6; | |
265 | 1792 for (unsigned int k = 0; k < v8->uNumVertices; ++k) |
106 | 1793 { |
1794 memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); | |
168 | 1795 array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); |
106 | 1796 } |
140 | 1797 |
186 | 1798 bool transparent = false; |
265 | 1799 if ( v8->flags & 2 && v8->uTileBitmapID == pRenderer->hd_water_tile_id) |
179 | 1800 { |
1801 //v80 = false; | |
265 | 1802 v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
179 | 1803 } |
1804 else | |
1805 { | |
1806 v6 = v8->uTileBitmapID; | |
186 | 1807 transparent = true; |
179 | 1808 } |
1809 | |
140 | 1810 assert(v6 < 1000); // many random crashes here |
186 | 1811 |
1812 // for all shore tiles - draw a tile water under them since they're half-empty | |
1813 if (!strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX | |
1814 { | |
1815 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 | 1816 pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]], false, true); |
186 | 1817 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE); |
1818 | |
1819 } | |
1820 | |
1821 pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); | |
1822 | |
1823 | |
86 | 1824 --pOutdoorCamera->numStru148s; |
1825 --pOutdoorCamera->field_44; | |
106 | 1826 } |
1827 } | |
1828 } | |
0 | 1829 |
1830 //----- (0048034E) -------------------------------------------------------- | |
67 | 1831 void Render::DrawTerrainD3D(int a1, int a2, int a3) |
0 | 1832 { |
1833 int v3; // esi@1 | |
1834 int v4; // edi@1 | |
1835 int v5; // ebx@2 | |
1836 int v6; // eax@2 | |
1837 int v7; // eax@3 | |
1838 RenderVertexSoft *v8; // edi@3 | |
1839 RenderVertexSoft *v9; // ebx@4 | |
1840 RenderVertexSoft *v10; // ecx@4 | |
1841 float v11; // eax@6 | |
1842 double v12; // ST5C_8@6 | |
1843 double v13; // ST2C_8@6 | |
1844 int v14; // eax@6 | |
1845 double v15; // st7@6 | |
1846 stru148 *v16; // ebx@12 | |
1847 unsigned __int16 v17; // ax@12 | |
1848 int v18; // eax@13 | |
67 | 1849 int v19; // ecx@13 |
1850 int v20; // eax@13 | |
0 | 1851 int v21; // eax@13 |
1852 signed int v22; // eax@13 | |
1853 Vec3_float_ *v23; // eax@15 | |
1854 double v24; // st6@17 | |
1855 double v25; // ST54_8@17 | |
1856 unsigned __int8 v26; // sf@17 | |
1857 unsigned __int8 v27; // of@17 | |
1858 double v28; // st5@19 | |
1859 double v29; // st5@19 | |
1860 double v30; // st5@19 | |
1861 double v31; // st5@19 | |
67 | 1862 struct struct8 *v32; // esi@21 |
1863 double v3a; // st7@32 | |
0 | 1864 int v33; // edi@38 |
1865 unsigned int v34; // ecx@47 | |
1866 char v35; // zf@47 | |
1867 unsigned int v36; // eax@50 | |
1868 int v37; // eax@54 | |
1869 stru148 *v38; // ecx@55 | |
1870 unsigned int v39; // eax@59 | |
1871 stru148 *v40; // ebx@62 | |
86 | 1872 unsigned __int16 pTileBitmapsID; // ax@62 |
0 | 1873 int v42; // eax@63 |
1874 LightmapBuilder *v43; // ecx@63 | |
67 | 1875 int v44; // eax@63 |
0 | 1876 int v45; // eax@63 |
1877 int v46; // eax@63 | |
1878 signed int v47; // eax@63 | |
1879 Vec3_float_ *v48; // eax@65 | |
1880 double v49; // st6@67 | |
1881 double v50; // ST4C_8@67 | |
1882 double v51; // st5@71 | |
1883 double v52; // st5@71 | |
1884 double v53; // st5@71 | |
1885 double v54; // st7@84 | |
1886 unsigned int v55; // ecx@98 | |
1887 unsigned int v56; // eax@101 | |
1888 int v57; // eax@105 | |
1889 unsigned int v58; // eax@109 | |
1890 stru148 *v59; // esi@112 | |
1891 unsigned __int16 v60; // ax@112 | |
67 | 1892 int v61; // eax@113 |
0 | 1893 signed int v62; // eax@113 |
1894 Vec3_float_ *v63; // eax@114 | |
1895 double v64; // st6@116 | |
1896 double v65; // ST3C_8@116 | |
1897 double v66; // st5@120 | |
1898 double v67; // st5@120 | |
1899 double v68; // st5@120 | |
1900 double v69; // st7@133 | |
1901 int v70; // edi@138 | |
86 | 1902 stru148 *v71; // esi@147 |
0 | 1903 unsigned int v72; // ecx@147 |
1904 unsigned int v73; // eax@150 | |
67 | 1905 int v74; // eax@154 |
0 | 1906 unsigned int v75; // eax@158 |
1907 unsigned int v76; // [sp-10h] [bp-E0h]@61 | |
67 | 1908 int v77; // [sp-Ch] [bp-DCh]@61 |
0 | 1909 IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 |
1910 int v79; // [sp-4h] [bp-D4h]@61 | |
1911 int v80; // [sp+0h] [bp-D0h]@59 | |
1912 int v81; // [sp+0h] [bp-D0h]@109 | |
1913 int v82; // [sp+54h] [bp-7Ch]@1 | |
1914 int v83; // [sp+60h] [bp-70h]@1 | |
1915 int v84; // [sp+6Ch] [bp-64h]@1 | |
1916 int v85; // [sp+70h] [bp-60h]@63 | |
1917 int a4; // [sp+74h] [bp-5Ch]@73 | |
1918 float v87; // [sp+78h] [bp-58h]@122 | |
1919 int v88; // [sp+7Ch] [bp-54h]@1 | |
1920 int v89; // [sp+80h] [bp-50h]@6 | |
1921 float v90; // [sp+84h] [bp-4Ch]@1 | |
1922 float v91; // [sp+88h] [bp-48h]@1 | |
1923 float v92; // [sp+8Ch] [bp-44h]@1 | |
67 | 1924 int v93; // [sp+90h] [bp-40h]@2 |
0 | 1925 int X; // [sp+94h] [bp-3Ch]@1 |
1926 float v95; // [sp+98h] [bp-38h]@21 | |
1927 LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 | |
67 | 1928 int v97; // [sp+A0h] [bp-30h]@6 |
0 | 1929 int sX; // [sp+A4h] [bp-2Ch]@6 |
1930 unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 | |
1931 int v100; // [sp+ACh] [bp-24h]@122 | |
1932 int sY; // [sp+B0h] [bp-20h]@6 | |
67 | 1933 RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 |
0 | 1934 unsigned int a5; // [sp+B8h] [bp-18h]@21 |
1935 RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 | |
1936 Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 | |
1937 RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 | |
67 | 1938 RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 |
0 | 1939 char v108; // [sp+CFh] [bp-1h]@36 |
1940 float thisd; // [sp+D8h] [bp+8h]@6 | |
1941 float thise; // [sp+D8h] [bp+8h]@6 | |
1942 float thisf; // [sp+D8h] [bp+8h]@17 | |
1943 IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 | |
1944 float thisg; // [sp+D8h] [bp+8h]@67 | |
1945 IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 | |
1946 float thish; // [sp+D8h] [bp+8h]@116 | |
1947 IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 | |
1948 char this_3; // [sp+DBh] [bp+Bh]@30 | |
1949 char this_3a; // [sp+DBh] [bp+Bh]@82 | |
1950 char this_3b; // [sp+DBh] [bp+Bh]@131 | |
1951 | |
67 | 1952 static stru154 static_sub_0048034E_stru_154; |
1953 static stru154 stru_76D5A8; | |
0 | 1954 v3 = a1; |
67 | 1955 v82 = a2; |
0 | 1956 v83 = *(/*short **/_WORD *)(a3 + 4); |
1957 X = abs(*(/*short **/_WORD *)(a3 + 6)); | |
1958 v4 = 0; | |
1959 v88 = 0; | |
1960 v84 = v3 - 1; | |
638 | 1961 v90 = (float)pOutdoor->vSunlight.x / 65536.0; |
67 | 1962 v91 = (float)pOutdoor->vSunlight.y / 65536.0; |
1963 v92 = (float)pOutdoor->vSunlight.z / 65536.0; | |
0 | 1964 if ( v3 - 1 > 0 ) |
1965 { | |
1966 while ( 1 ) | |
1967 { | |
1968 v5 = abs(X);//v5 = 13108 | |
1969 v6 = abs(v83);//v6 = 13108 | |
1970 --X; | |
186 | 1971 __debugbreak(); // uncoment & refactor following large if |
67 | 1972 v93 = (int)&stru_76E5C8[(v5 << 7) + v6]; |
1973 /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), | |
0 | 1974 v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), |
1975 ((a8 = v9, | |
1976 pVertices = &pVerticesSR_801A10[1] + v7, | |
1977 v11 = v8->vWorldPosition.x, | |
1978 v101 = v10, | |
1979 v12 = v11 + 6.755399441055744e15, | |
1980 sX = LODWORD(v12), | |
1981 v13 = v8->vWorldPosition.y + 6.755399441055744e15, | |
1982 sY = LODWORD(v13), | |
1983 thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, | |
62 | 1984 v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X |
0 | 1985 v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, |
1986 v89 = v14, | |
1987 thise = v15 * 0.5, | |
62 | 1988 _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z |
0 | 1989 WorldPosToGridCellX(sX), |
1990 WorldPosToGridCellZ(sY), | |
1991 !byte_4D864C) | |
1992 || !(pGame->uFlags & 0x80)) | |
67 | 1993 && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ |
1994 if ( !&stru_76E5C8[(v5 << 7) + v6] ) | |
0 | 1995 goto LABEL_162; |
67 | 1996 v8 = &pVerticesSR_806210[v4]; |
1997 pVertices2 = &pVerticesSR_801A10[v4 + 1]; | |
1998 v102 = v8; | |
1999 if (!v82) | |
2000 { | |
86 | 2001 pVertices = &pVerticesSR_801A10[v4]; |
2002 v101 = &pVerticesSR_806210[v4 + 1]; | |
67 | 2003 } |
2004 else | |
2005 { | |
86 | 2006 pVertices = &pVerticesSR_801A10[v4 + 1]; |
2007 v101 = &pVerticesSR_806210[v4]; | |
2008 } | |
67 | 2009 sX = floorf(v8->vWorldPosition.x + 0.5f); |
2010 sY = floorf(v8->vWorldPosition.z + 0.5f); | |
2011 v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); | |
2012 v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); | |
2013 WorldPosToGridCellX(sX); | |
2014 WorldPosToGridCellZ(sY); | |
2015 if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) | |
86 | 2016 if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y |
2017 || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) | |
67 | 2018 break; |
2019 v16 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2020 v16->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
86 | 2021 if ( v16->uTileBitmapID != -1 ) |
2022 { | |
2023 v19 = v97; | |
2024 v16->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2025 v16->field_32 = 0; | |
2026 v20 = v93; | |
2027 v16->field_59 = 1; | |
638 | 2028 v16->terrain_grid_x = (char)v19; |
86 | 2029 v16->field_34 = *(_WORD *)(v20 + 2); |
2030 v21 = v89; | |
638 | 2031 v16->terrain_grid_z = v89; |
86 | 2032 v22 = pTerrainNormalIndices[2 * (v19 + 128 * v21) + 1]; |
2033 if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) | |
2034 v23 = 0; | |
2035 else | |
2036 v23 = &pTerrainNormals[v22]; | |
638 | 2037 v24 = v92 * v23->z; |
86 | 2038 //v99 = v23; |
638 | 2039 thisf = 20.0 - (-v24 - v91 * v23->y - v90 * v23->x) * 20.0; |
86 | 2040 //v25 = thisf + 6.7553994e15; |
2041 //v27 = pOutdoorCamera->numStru148s > 1999; | |
2042 //v26 = pOutdoorCamera->numStru148s - 1999 < 0; | |
638 | 2043 v16->dimming_level = floorf(thisf + 0.5f); |
86 | 2044 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2045 return; | |
2046 ++pOutdoorCamera->numStru148s; | |
96 | 2047 //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary |
4 | 2048 //goto LABEL_126; |
96 | 2049 //{ |
2050 //--pOutdoorCamera->numStru148s; | |
2051 //goto LABEL_162; | |
2052 //} | |
86 | 2053 memcpy(&array_50AC10[0], v102, 0x30u); |
168 | 2054 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2055 array_50AC10[0].u = 0.0; |
2056 array_50AC10[0].v = 0.0; | |
2057 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
168 | 2058 array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2059 array_50AC10[1].u = 0.0; |
2060 array_50AC10[1].v = 1.0; | |
2061 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
168 | 2062 array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2063 array_50AC10[2].u = 1.0; |
2064 array_50AC10[2].v = 1.0; | |
2065 memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); | |
168 | 2066 array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2067 array_50AC10[3].u = 1.0; |
2068 array_50AC10[3].v = 0.0; | |
2069 /*if ( !(byte_76D5C0 & 1) ) | |
2070 { | |
2071 byte_76D5C0 |= 1u; | |
2072 stru154(stru_76D5A8); | |
2073 atexit(loc_481199); | |
2074 }*/ | |
2075 v32 = (struct8 *)array_50AC10; | |
2076 v97 = (int)pGame->pLightmapBuilder; | |
2077 pGame->pLightmapBuilder->StackLights_TerrainFace(v23, &v95, array_50AC10, 4, 1); | |
2078 pDecalBuilder->_49BE8A(v16, *(float *)&v23, (int)&v95, array_50AC10, 4, 1); | |
2079 a5 = 4; | |
2080 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2081 { | |
2082 thisa = pGame->pIndoorCameraD3D; | |
2083 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) | |
2084 goto LABEL_162; | |
2085 thisa->ViewTransform(array_50AC10, a5); | |
2086 thisa->Project(array_50AC10, a5, 0); | |
2087 } | |
2088 this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 | |
2089 || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
2090 v3a = (double)pOutdoorCamera->shading_dist_mist; | |
2091 v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x | |
2092 || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; | |
2093 v33 = 0; | |
2094 pGame->pLightmapBuilder->std__vector_000004_size = 0; | |
2095 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
0 | 2096 { |
86 | 2097 if ( this_3 ) |
2098 v33 = 3; | |
2099 else | |
2100 v33 = v108 != 0 ? 5 : 0; | |
734 | 2101 static_sub_0048034E_stru_154.ClassifyPolygon(v23, v95); |
86 | 2102 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2103 pDecalBuilder->ApplyDecals(31 - v16->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); |
0 | 2104 } |
86 | 2105 if ( stru_F8AD28.uNumLightsApplied > 0 ) |
2106 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); | |
2107 v34 = a5; | |
2108 //v35 = byte_4D864C == 0; | |
2109 v16->uNumVertices = a5; | |
2110 if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) | |
0 | 2111 { |
86 | 2112 if ( this_3 ) |
2113 { | |
2114 v36 = sr_424CD7(v34); | |
2115 v16->uNumVertices = v36; | |
2116 OutdoorCamera::Project(v36); | |
2117 } | |
2118 if ( v108 ) | |
2119 { | |
2120 v36 = sr_424EE0_MakeFanFromTriangle(v34); | |
2121 v16->uNumVertices = v36; | |
2122 OutdoorCamera::Project(v36); | |
2123 } | |
0 | 2124 } |
86 | 2125 //v37 = *(int *)&v16->flags; |
2126 if ( ~v16->flags & 1 ) | |
2127 { | |
265 | 2128 if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2129 { |
2130 v80 = false; | |
265 | 2131 v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2132 } |
2133 else | |
2134 { | |
2135 v39 = v16->uTileBitmapID; | |
2136 v80 = true; | |
2137 } | |
2138 //v79 = 0; | |
2139 //v78 = pBitmaps_LOD->pHardwareTextures[v39]; | |
2140 v16->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary | |
2141 v77 = (int)v16; | |
2142 //v76 = v16->uNumVertices; | |
4 | 2143 //LABEL_161: |
186 | 2144 pRenderer->DrawTerrainPolygon(v16->uNumVertices, v16, pBitmaps_LOD->pHardwareTextures[v39], false, v80); |
86 | 2145 goto LABEL_162; |
2146 } | |
2147 v38 = v16; | |
0 | 2148 LABEL_56: |
86 | 2149 v38->_4811A3(); |
2150 } | |
0 | 2151 LABEL_162: |
86 | 2152 v4 = v88 + 1; |
2153 if ( ++v88 >= v84 ) | |
2154 return; | |
2155 } | |
2156 v40 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2157 v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
2158 if ( v40->uTileBitmapID == -1 ) | |
2159 goto LABEL_162; | |
2160 v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2161 BYTE1(v42) |= 0x80u; | |
2162 v43 = pGame->pLightmapBuilder; | |
2163 *(int *)&v40->flags = v42; | |
2164 v44 = v93; | |
2165 v40->field_59 = 1; | |
638 | 2166 v40->terrain_grid_x = (char)v43; |
86 | 2167 v40->field_34 = *(_WORD *)(v44 + 2); |
2168 v45 = v89; | |
638 | 2169 v40->terrain_grid_z = v89; |
86 | 2170 v46 = 4 * ((char)v43 + (v45 << 7)); |
2171 v85 = v46; | |
2172 v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; | |
2173 if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) | |
2174 v48 = 0; | |
2175 else | |
2176 v48 = &pTerrainNormals[v47]; | |
2177 v49 = v92 * v48->y; | |
2178 //v99 = v48; | |
2179 thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; | |
2180 v50 = thisg + 6.755399441055744e15; | |
638 | 2181 v40->dimming_level = LOBYTE(v50); |
86 | 2182 if ( LOBYTE(v50) < 0 ) |
638 | 2183 v40->dimming_level = 0; |
86 | 2184 if ( pOutdoorCamera->numStru148s >= 1999 ) |
0 | 2185 return; |
86 | 2186 ++pOutdoorCamera->numStru148s; |
2187 /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary | |
2188 //goto LABEL_77; | |
2189 { | |
2190 --pOutdoorCamera->numStru148s; | |
2191 goto LABEL_112; | |
2192 }*/ | |
2193 memcpy(&array_50AC10[0], v102, 0x30u); | |
168 | 2194 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2195 array_50AC10[0].u = 0.0; |
2196 array_50AC10[0].v = 0.0; | |
2197 memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); | |
168 | 2198 array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2199 array_50AC10[1].u = 0.0; |
2200 array_50AC10[1].v = 1.0; | |
2201 memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); | |
168 | 2202 array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2203 array_50AC10[2].u = 1.0; |
2204 array_50AC10[2].v = 1.0; | |
2205 static stru154 static_sub_0048034E_stru_76D590; | |
2206 /*static bool __init_flag2 = false; | |
2207 if (!__init_flag2) | |
2208 { | |
2209 __init_flag2 = true; | |
2210 stru154::stru154(&static_sub_0048034E_stru_76D590); | |
2211 }*/ | |
2212 /*if ( !(byte_76D5C0 & 2) ) | |
2213 { | |
2214 byte_76D5C0 |= 2; | |
2215 stru148(stru_76D590); | |
2216 atexit(loc_48118F); | |
2217 }*/ | |
2218 v96 = pGame->pLightmapBuilder; | |
2219 pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); | |
2220 pDecalBuilder->_49BE8A(v40, *(float *)&v48, (int)&a4, array_50AC10, 3, 0); | |
2221 uNumVertices = 3; | |
2222 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2223 { | |
2224 thisb = pGame->pIndoorCameraD3D; | |
2225 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) | |
2226 { | |
2227 //LABEL_77: | |
2228 --pOutdoorCamera->numStru148s; | |
2229 goto LABEL_112; | |
2230 } | |
2231 thisb->ViewTransform(array_50AC10, uNumVertices); | |
2232 thisb->Project(array_50AC10, uNumVertices, 0); | |
2233 } | |
2234 this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; | |
2235 v54 = (double)pOutdoorCamera->shading_dist_mist; | |
2236 v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; | |
2237 pVertices = 0; | |
2238 v96->std__vector_000004_size = 0; | |
2239 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
2240 { | |
2241 if ( this_3a ) | |
2242 pVertices = (RenderVertexSoft *)3; | |
2243 else | |
2244 pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); | |
2245 //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); | |
734 | 2246 static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); |
86 | 2247 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2248 pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); |
86 | 2249 } |
2250 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
2251 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); | |
2252 v55 = uNumVertices; | |
2253 //v35 = byte_4D864C == 0; | |
2254 v40->uNumVertices = uNumVertices; | |
2255 if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) | |
2256 { | |
2257 if ( this_3a ) | |
2258 { | |
2259 v56 = sr_424CD7(v55); | |
2260 } | |
2261 else | |
2262 { | |
2263 if ( !v108 ) | |
2264 goto LABEL_105; | |
2265 v56 = sr_424EE0_MakeFanFromTriangle(v55); | |
2266 } | |
2267 v40->uNumVertices = v56; | |
2268 OutdoorCamera::Project(v56); | |
2269 } | |
2270 LABEL_105: | |
2271 v57 = *(int *)&v40->flags; | |
2272 if ( BYTE1(v57) & 1 ) | |
2273 { | |
2274 v40->_4811A3(); | |
2275 } | |
2276 else | |
2277 { | |
265 | 2278 if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2279 { |
2280 v81 = 0; | |
265 | 2281 v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2282 } |
2283 else | |
2284 { | |
2285 v58 = v40->uTileBitmapID; | |
2286 v81 = 1; | |
2287 } | |
186 | 2288 pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); |
86 | 2289 } |
2290 LABEL_112: | |
2291 v59 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2292 //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->numStru148s]; | |
2293 v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); | |
2294 if ( v59->uTileBitmapID == -1 ) | |
2295 goto LABEL_162; | |
2296 *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); | |
2297 v61 = v93; | |
2298 v59->field_59 = 1; | |
2299 v59->field_34 = *(_WORD *)(v61 + 2); | |
638 | 2300 v59->terrain_grid_z = v89; |
2301 v59->terrain_grid_x = v97; | |
86 | 2302 v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); |
2303 if ( v62 > (signed int)(uNumTerrainNormals - 1) ) | |
2304 v63 = 0; | |
2305 else | |
2306 v63 = &pTerrainNormals[v62]; | |
2307 v64 = v92 * v63->y; | |
2308 //v99 = v63; | |
2309 thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; | |
638 | 2310 v59->dimming_level = floorf(thish + 0.5f); |
2311 if ( v59->dimming_level < 0 ) | |
2312 v59->dimming_level = 0; | |
86 | 2313 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2314 return; | |
2315 ++pOutdoorCamera->numStru148s; | |
2316 if ( !sub_481FC9(v101, v102, pVertices2, v59) ) | |
2317 { | |
2318 //LABEL_126: | |
4 | 2319 --pOutdoorCamera->numStru148s; |
86 | 2320 goto LABEL_162; |
2321 } | |
2322 memcpy(&array_50AC10[0], v102, 0x30u); | |
168 | 2323 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); |
86 | 2324 array_50AC10[0].u = 0.0; |
2325 array_50AC10[0].v = 0.0; | |
2326 memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); | |
168 | 2327 array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2328 array_50AC10[1].u = 1.0; |
2329 array_50AC10[1].v = 1.0; | |
2330 memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); | |
168 | 2331 array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; |
86 | 2332 array_50AC10[2].u = 1.0; |
2333 array_50AC10[2].v = 0.0; | |
2334 static stru154 static_sub_0048034E_stru_76D578; | |
2335 /*static bool __init_flag1 = false; | |
2336 if (!__init_flag1) | |
2337 { | |
2338 __init_flag1 = true; | |
2339 stru154::stru154(&static_sub_0048034E_stru_76D578); | |
2340 }*/ | |
2341 v96 = pGame->pLightmapBuilder; | |
2342 pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); | |
2343 pDecalBuilder->_49BE8A(v40, *(float *)&v63, (int)&v87, array_50AC10, 3, 1); | |
2344 v100 = 3; | |
2345 if ( byte_4D864C && pGame->uFlags & 0x80 ) | |
2346 { | |
2347 thisc = pGame->pIndoorCameraD3D; | |
2348 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) | |
2349 //goto LABEL_126; | |
2350 { | |
2351 --pOutdoorCamera->numStru148s; | |
2352 goto LABEL_162; | |
2353 } | |
2354 thisc->ViewTransform(array_50AC10, v100); | |
2355 thisc->Project(array_50AC10, v100, 0); | |
2356 } | |
2357 this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 | |
2358 || v101->vWorldViewPosition.x < 8.0; | |
2359 v69 = (double)pOutdoorCamera->shading_dist_mist; | |
2360 v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; | |
2361 v70 = 0; | |
2362 v96->std__vector_000004_size = 0; | |
2363 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) | |
2364 { | |
2365 if ( this_3b ) | |
2366 v70 = 3; | |
2367 else | |
2368 v70 = v108 != 0 ? 5 : 0; | |
734 | 2369 static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); |
86 | 2370 if ( pDecalBuilder->uNumDecals > 0 ) |
638 | 2371 pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); |
86 | 2372 } |
2373 if ( stru_F8AD28.uNumLightsApplied > 0 ) | |
2374 v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); | |
2375 v71 = v59; | |
2376 v72 = v100; | |
2377 //v35 = byte_4D864C == 0; | |
2378 v59->uNumVertices = v100;//??? | |
2379 if ( !byte_4D864C && pGame->uFlags & 0x80 ) | |
2380 goto LABEL_154; | |
2381 if ( this_3b ) | |
2382 { | |
2383 v73 = sr_424CD7(v72); | |
0 | 2384 } |
2385 else | |
2386 { | |
2387 if ( !v108 ) | |
86 | 2388 { |
2389 LABEL_154: | |
2390 v74 = v71->flags; | |
2391 if ( !(BYTE1(v74) & 1) ) | |
2392 { | |
265 | 2393 if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) |
86 | 2394 { |
2395 v80 = false; | |
265 | 2396 v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; |
86 | 2397 } |
2398 else | |
2399 { | |
2400 v75 = v71->uTileBitmapID; | |
2401 v80 = true; | |
2402 } | |
2403 //v79 = 0; | |
2404 //v78 = pBitmaps_LOD->pHardwareTextures[v75]; | |
2405 v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary | |
2406 //v77 = (int)v71; | |
2407 //v76 = v71->uNumVertices; | |
2408 //goto LABEL_161; | |
186 | 2409 pRenderer->DrawTerrainPolygon(v76, (stru148 *)v71, v78, v79, v80); |
86 | 2410 goto LABEL_162; |
2411 } | |
2412 v38 = (stru148 *)v71; | |
2413 goto LABEL_56; | |
2414 } | |
2415 v73 = sr_424EE0_MakeFanFromTriangle(v72); | |
2416 } | |
2417 v71->uNumVertices = v73; | |
2418 OutdoorCamera::Project(v73); | |
0 | 2419 goto LABEL_154; |
86 | 2420 } |
2421 } | |
0 | 2422 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); |
2423 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); | |
2424 // 4D864C: using guessed type char byte_4D864C; | |
2425 // 76D5C0: using guessed type char static_sub_0048034E_byte_76D5C0__init_flag; | |
2426 | |
2427 //----- (00481212) -------------------------------------------------------- | |
2428 void Render::DrawTerrainSW(int a1, int a2, int a3) | |
2429 { | |
2430 int v3; // esi@1 | |
2431 int v4; // ecx@1 | |
2432 int v5; // ST10_4@1 | |
2433 int v6; // edi@1 | |
2434 int v7; // ebx@2 | |
2435 int v8; // eax@2 | |
2436 int v9; // eax@3 | |
2437 RenderVertexSoft *v10; // edi@3 | |
2438 RenderVertexSoft *v11; // ebx@4 | |
2439 RenderVertexSoft *v12; // ecx@4 | |
2440 float v13; // eax@6 | |
2441 int v14; // eax@6 | |
2442 double v15; // st7@6 | |
2443 double v16; // st7@6 | |
2444 stru148 *v17; // ebx@12 | |
2445 unsigned __int16 v18; // ax@12 | |
2446 int v19; // eax@13 | |
2447 float v20; // ecx@13 | |
2448 stru220 *v21; // eax@13 | |
2449 int v22; // eax@13 | |
2450 signed int v23; // eax@13 | |
2451 Vec3_float_ *v24; // eax@15 | |
2452 double v25; // st7@18 | |
2453 double v26; // st5@24 | |
2454 double v27; // st5@24 | |
2455 double v28; // st5@24 | |
2456 double v29; // st5@24 | |
2457 Game *v30; // eax@25 | |
2458 RenderVertexSoft *v31; // edi@29 | |
2459 double v32; // st7@31 | |
2460 int v33; // esi@35 | |
2461 RenderVertexSoft *v34; // edx@36 | |
2462 RenderVertexSoft *v35; // ecx@36 | |
2463 signed int v36; // eax@39 | |
2464 signed int v37; // esi@40 | |
2465 stru148 *v38; // ebx@43 | |
2466 unsigned __int16 v39; // ax@43 | |
2467 int v40; // eax@44 | |
2468 float v41; // ecx@44 | |
2469 stru220 *v42; // eax@44 | |
2470 int v43; // eax@44 | |
2471 int v44; // eax@44 | |
2472 signed int v45; // eax@44 | |
2473 Vec3_float_ *v46; // eax@46 | |
2474 double v47; // st7@49 | |
2475 double v48; // st5@57 | |
2476 double v49; // st5@57 | |
2477 double v50; // st5@57 | |
2478 Game *v51; // eax@58 | |
2479 RenderVertexSoft *v52; // edi@62 | |
2480 double v53; // st7@63 | |
2481 int v54; // esi@66 | |
2482 signed int v55; // eax@69 | |
2483 signed int v56; // esi@71 | |
2484 unsigned __int16 v57; // ax@75 | |
2485 stru220 *v58; // eax@76 | |
2486 signed int v59; // eax@76 | |
2487 Vec3_float_ *v60; // eax@77 | |
2488 double v61; // st7@80 | |
2489 double v62; // st5@88 | |
2490 double v63; // st5@88 | |
2491 double v64; // st5@88 | |
2492 Game *v65; // eax@89 | |
2493 double v66; // st7@94 | |
2494 RenderVertexSoft *v67; // [sp-Ch] [bp-C4h]@36 | |
2495 stru148 *v68; // [sp-8h] [bp-C0h]@36 | |
2496 int v69; // [sp-4h] [bp-BCh]@36 | |
2497 float v70; // [sp+Ch] [bp-ACh]@88 | |
2498 double v71; // [sp+10h] [bp-A8h]@6 | |
2499 double v72; // [sp+18h] [bp-A0h]@82 | |
2500 double v73; // [sp+20h] [bp-98h]@6 | |
2501 double v74; // [sp+28h] [bp-90h]@51 | |
2502 double v75; // [sp+30h] [bp-88h]@6 | |
2503 double v76; // [sp+38h] [bp-80h]@20 | |
2504 double v77; // [sp+40h] [bp-78h]@6 | |
2505 float v78; // [sp+48h] [bp-70h]@57 | |
2506 float v79; // [sp+4Ch] [bp-6Ch]@6 | |
2507 float v80; // [sp+50h] [bp-68h]@6 | |
2508 int v81; // [sp+54h] [bp-64h]@1 | |
2509 int v82; // [sp+58h] [bp-60h]@6 | |
2510 int v83; // [sp+5Ch] [bp-5Ch]@82 | |
2511 int v84; // [sp+60h] [bp-58h]@20 | |
2512 int v85; // [sp+64h] [bp-54h]@1 | |
2513 int v86; // [sp+68h] [bp-50h]@1 | |
2514 int v87; // [sp+6Ch] [bp-4Ch]@51 | |
2515 float v88; // [sp+70h] [bp-48h]@51 | |
2516 int v89; // [sp+74h] [bp-44h]@6 | |
2517 int v90; // [sp+78h] [bp-40h]@1 | |
2518 float a3a; // [sp+7Ch] [bp-3Ch]@24 | |
2519 stru220 *v92; // [sp+80h] [bp-38h]@2 | |
2520 float v93; // [sp+84h] [bp-34h]@44 | |
2521 int v94; // [sp+88h] [bp-30h]@6 | |
2522 float v95; // [sp+8Ch] [bp-2Ch]@1 | |
2523 float v96; // [sp+90h] [bp-28h]@1 | |
2524 float v97; // [sp+94h] [bp-24h]@1 | |
2525 int X; // [sp+98h] [bp-20h]@1 | |
2526 float v99; // [sp+9Ch] [bp-1Ch]@6 | |
2527 int v100; // [sp+A0h] [bp-18h]@6 | |
2528 unsigned __int64 v101; // [sp+A4h] [bp-14h]@6 | |
2529 RenderVertexSoft *v102; // [sp+ACh] [bp-Ch]@6 | |
2530 RenderVertexSoft *v103; // [sp+B0h] [bp-8h]@6 | |
2531 RenderVertexSoft *v104; // [sp+B4h] [bp-4h]@3 | |
2532 float pNormalc; // [sp+C0h] [bp+8h]@6 | |
2533 float pNormald; // [sp+C0h] [bp+8h]@6 | |
2534 Vec3_float_ *pNormal; // [sp+C0h] [bp+8h]@17 | |
2535 Vec3_float_ *pNormala; // [sp+C0h] [bp+8h]@48 | |
2536 Vec3_float_ *pNormalb; // [sp+C0h] [bp+8h]@77 | |
2537 | |
2538 v3 = a1; | |
2539 //v4 = *(short *)(a3 + 4); | |
2540 //v5 = *(short *)(a3 + 6); | |
2541 v85 = a2; | |
2542 v86 = *(_WORD *)(a3 + 4); //v4; | |
2543 X = abs(*(_WORD *)(a3 + 6)); //v5 | |
2544 v6 = 0; | |
2545 v90 = 0; | |
2546 v81 = v3 - 1; | |
638 | 2547 v95 = (double)pOutdoor->vSunlight.x / 65536.0; |
2548 v96 = (double)pOutdoor->vSunlight.y / 65536.0; | |
2549 v97 = (double)pOutdoor->vSunlight.z / 65536.0; | |
0 | 2550 if ( v3 - 1 > 0 ) |
2551 { | |
2552 while ( 1 ) | |
2553 { | |
2554 v7 = abs(X); | |
2555 v8 = abs(v86); | |
2556 --X; | |
2557 v92 = &stru_76E5C8[(v7 << 7) + v8]; | |
2558 if ( !v92->field_0 | |
2559 || ((v9 = v6, v10 = &pVerticesSR_806210[v6], v104 = v10, !v85) ? (v11 = &pVerticesSR_801A10[v9], | |
2560 v12 = &pVerticesSR_806210[v9 + 1]) : (v11 = &pVerticesSR_806210[v9 + 1], v12 = &pVerticesSR_801A10[v9]), | |
2561 ((v103 = &pVerticesSR_801A10[v9 + 1], | |
2562 v13 = v10->vWorldPosition.x, | |
2563 v102 = v12, | |
2564 v80 = v13, | |
2565 v73 = v13 + 6.7553994e15, | |
2566 v101 = __PAIR__((unsigned int)v11, LODWORD(v73)), | |
2567 v79 = v10->vWorldPosition.y, | |
2568 v75 = v79 + 6.7553994e15, | |
2569 v100 = LODWORD(v75), | |
2570 pNormalc = (v12->vWorldPosition.x + v10->vWorldPosition.x) * 0.5, | |
2571 v71 = pNormalc + 6.7553994e15, | |
2572 v89 = LODWORD(v71), | |
2573 v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(pNormalc + 6.7553994e15)), | |
2574 v15 = v11->vWorldPosition.y + v10->vWorldPosition.y, | |
2575 v94 = v14, | |
2576 pNormald = v15 * 0.5, | |
2577 v16 = pNormald + 6.7553994e15, | |
2578 v77 = v16, | |
2579 v82 = LODWORD(v77), | |
2580 LODWORD(v99) = WorldPosToGridCellZ(LODWORD(v16)), | |
2581 WorldPosToGridCellX(v101), | |
2582 WorldPosToGridCellZ(v100), | |
2583 !byte_4D864C) | |
2584 || !(pGame->uFlags & 0x80)) | |
2585 && !sub_481EFA(v10, v11, v102, v103, 1)) ) | |
2586 goto LABEL_105; | |
2587 if ( v10->vWorldPosition.z != v11->vWorldPosition.z | |
2588 || v11->vWorldPosition.z != v103->vWorldPosition.z | |
2589 || v103->vWorldPosition.z != v102->vWorldPosition.z ) | |
2590 break; | |
2591 v17 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2592 v18 = pOutdoor->GetTileTexture(v101, v100); | |
2593 v17->uTileBitmapID = v18; | |
2594 if ( v18 != -1 ) | |
2595 { | |
2596 v19 = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2597 LOWORD(v19) = v19 | 0x8010; | |
2598 v20 = v99; | |
2599 *(int *)&v17->flags = v19; | |
2600 v21 = v92; | |
2601 v17->field_59 = 1; | |
638 | 2602 v17->terrain_grid_x = LOBYTE(v20); |
0 | 2603 v17->field_34 = v21->distance; |
2604 v22 = v94; | |
638 | 2605 v17->terrain_grid_z = v94; |
0 | 2606 v23 = pTerrainNormalIndices[2 * (LODWORD(v20) + (v22 << 7)) + 1]; |
2607 if ( v23 < 0 || v23 > (signed int)(uNumTerrainNormals - 1) ) | |
2608 v24 = 0; | |
2609 else | |
2610 v24 = &pTerrainNormals[v23]; | |
2611 pNormal = v24; | |
2612 if ( v24 ) | |
2613 { | |
2614 v25 = -(v97 * v24->z + v96 * v24->y + v95 * v24->x); | |
2615 if ( v25 < 0.0 ) | |
2616 v25 = 0.0; | |
2617 v99 = v25 * 31.0; | |
2618 v76 = v99 + 6.7553994e15; | |
2619 v84 = LODWORD(v76); | |
638 | 2620 v17->dimming_level = 31 - LOBYTE(v76); |
0 | 2621 } |
2622 else | |
2623 { | |
638 | 2624 v17->dimming_level = 0; |
0 | 2625 } |
2626 if ( pOutdoorCamera->numStru148s >= 1999 ) | |
2627 return; | |
2628 ++pOutdoorCamera->numStru148s; | |
2629 if ( !sub_481FC9(v10, (RenderVertexSoft *)HIDWORD(v101), v102, v17) ) | |
2630 goto LABEL_104; | |
2631 v26 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2632 memcpy(array_50AC10, v104, 0x30u); | |
168 | 2633 array_50AC10[0]._rhw = v26; |
0 | 2634 array_50AC10[0].u = 0.0; |
2635 array_50AC10[0].v = 0.0; | |
2636 v27 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; | |
2637 memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); | |
168 | 2638 array_50AC10[1]._rhw = 1.0 / v27; |
0 | 2639 array_50AC10[1].u = 0.0; |
2640 array_50AC10[1].v = 1.0; | |
2641 v28 = v103->vWorldViewPosition.x + 0.0000001; | |
2642 memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); | |
168 | 2643 array_50AC10[2]._rhw = 1.0 / v28; |
0 | 2644 array_50AC10[2].u = 1.0; |
2645 array_50AC10[2].v = 1.0; | |
2646 v29 = v102->vWorldViewPosition.x + 0.0000001; | |
2647 memcpy(&array_50AC10[3], v102, sizeof(array_50AC10[3])); | |
168 | 2648 array_50AC10[3]._rhw = 1.0 / v29; |
0 | 2649 array_50AC10[3].u = 1.0; |
2650 array_50AC10[3].v = 0.0; | |
2651 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormal, &a3a, array_50AC10, 4u, 1); | |
2652 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2653 { | |
2654 v17->field_108 = 0; | |
2655 } | |
2656 else | |
2657 { | |
2658 v30 = pGame; | |
2659 v17->field_108 = 1; | |
2660 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 4, pNormal); | |
2661 } | |
2662 if ( v104->vWorldViewPosition.x < 8.0 | |
2663 || *(float *)(HIDWORD(v101) + 12) < 8.0 | |
2664 || (v31 = v102, v102->vWorldViewPosition.x < 8.0) | |
2665 || v103->vWorldViewPosition.x < 8.0 ) | |
2666 { | |
2667 v36 = sr_4250FE(4u); | |
2668 } | |
2669 else | |
2670 { | |
2671 v32 = (double)pOutdoorCamera->shading_dist_mist; | |
2672 if ( v32 >= v104->vWorldViewPosition.x | |
2673 && v32 >= *(float *)(HIDWORD(v101) + 12) | |
2674 && v32 >= v102->vWorldViewPosition.x | |
2675 && v32 >= v103->vWorldViewPosition.x ) | |
2676 { | |
2677 v33 = sr_4254D2(4); | |
2678 v17->uNumVertices = v33; | |
2679 if ( !v33 ) | |
2680 goto LABEL_104; | |
2681 v34 = (RenderVertexSoft *)HIDWORD(v101); | |
2682 v35 = v104; | |
2683 v69 = 0; | |
2684 v68 = v17; | |
2685 v67 = v31; | |
2686 goto LABEL_37; | |
2687 } | |
2688 v36 = sr_4252E8(4u); | |
2689 } | |
2690 v37 = v36; | |
2691 if ( !v36 ) | |
2692 goto LABEL_104; | |
2693 LABEL_41: | |
2694 OutdoorCamera::Project(v37); | |
2695 LABEL_102: | |
2696 v33 = sr_4254D2(v37); | |
2697 v17->uNumVertices = v33; | |
2698 if ( !v33 ) | |
2699 goto LABEL_104; | |
2700 v17->_48276F_sr(); | |
2701 goto LABEL_38; | |
2702 } | |
2703 LABEL_105: | |
2704 v6 = v90++ + 1; | |
2705 if ( v90 >= v81 ) | |
2706 return; | |
2707 } | |
2708 v38 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2709 v39 = pOutdoor->GetTileTexture(v101, v100); | |
2710 v38->uTileBitmapID = v39; | |
2711 if ( v39 == -1 ) | |
2712 goto LABEL_105; | |
2713 v40 = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2714 BYTE1(v40) |= 0x80u; | |
2715 v41 = v99; | |
2716 *(int *)&v38->flags = v40; | |
2717 v42 = v92; | |
2718 v38->field_59 = 1; | |
638 | 2719 v38->terrain_grid_x = LOBYTE(v41); |
0 | 2720 v38->field_34 = v42->distance; |
2721 v43 = v94; | |
638 | 2722 v38->terrain_grid_z = v94; |
0 | 2723 v44 = 2 * (LODWORD(v41) + (v43 << 7)); |
2724 LODWORD(v93) = v44 * 2; | |
2725 v45 = pTerrainNormalIndices[v44 + 1]; | |
2726 if ( v45 < 0 || v45 > (signed int)(uNumTerrainNormals - 1) ) | |
2727 v46 = 0; | |
2728 else | |
2729 v46 = &pTerrainNormals[v45]; | |
2730 pNormala = v46; | |
2731 if ( v46 ) | |
2732 { | |
2733 v47 = -(v97 * v46->z + v96 * v46->y + v95 * v46->x); | |
2734 if ( v47 < 0.0 ) | |
2735 v47 = 0.0; | |
2736 v88 = v47 * 31.0; | |
2737 v74 = v88 + 6.7553994e15; | |
2738 v87 = LODWORD(v74); | |
638 | 2739 v38->dimming_level = 31 - LOBYTE(v74); |
0 | 2740 } |
2741 else | |
2742 { | |
638 | 2743 v38->dimming_level = 0; |
2744 } | |
2745 if ( v38->dimming_level < 0 ) | |
2746 v38->dimming_level = 0; | |
0 | 2747 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2748 return; | |
2749 ++pOutdoorCamera->numStru148s; | |
2750 if ( !sub_481FC9((RenderVertexSoft *)HIDWORD(v101), v103, v104, v38) ) | |
2751 goto LABEL_74; | |
2752 v48 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2753 memcpy(array_50AC10, v104, 0x30u); | |
168 | 2754 array_50AC10[0]._rhw = v48; |
0 | 2755 array_50AC10[0].u = 0.0; |
2756 array_50AC10[0].v = 0.0; | |
2757 v49 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; | |
2758 memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); | |
168 | 2759 array_50AC10[1]._rhw = 1.0 / v49; |
0 | 2760 array_50AC10[1].u = 0.0; |
2761 array_50AC10[1].v = 1.0; | |
2762 v50 = v103->vWorldViewPosition.x + 0.0000001; | |
2763 memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); | |
168 | 2764 array_50AC10[2]._rhw = 1.0 / v50; |
0 | 2765 array_50AC10[2].u = 1.0; |
2766 array_50AC10[2].v = 1.0; | |
2767 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormala, &v78, array_50AC10, 3u, 0); | |
2768 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2769 { | |
2770 v38->field_108 = 0; | |
2771 } | |
2772 else | |
2773 { | |
2774 v51 = pGame; | |
2775 v38->field_108 = 1; | |
2776 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormala); | |
2777 } | |
2778 if ( v104->vWorldViewPosition.x < 8.0 | |
2779 || *(float *)(HIDWORD(v101) + 12) < 8.0 | |
2780 || (v52 = v103, v103->vWorldViewPosition.x < 8.0) ) | |
2781 { | |
2782 v55 = sr_4250FE(3u); | |
2783 } | |
2784 else | |
2785 { | |
2786 v53 = (double)pOutdoorCamera->shading_dist_mist; | |
2787 if ( v53 >= v104->vWorldViewPosition.x | |
2788 && v53 >= *(float *)(HIDWORD(v101) + 12) | |
2789 && v53 >= v103->vWorldViewPosition.x ) | |
2790 { | |
2791 v54 = sr_4254D2(3); | |
2792 v38->uNumVertices = v54; | |
2793 if ( v54 ) | |
2794 { | |
2795 sr_sub_4829B9((RenderVertexSoft *)HIDWORD(v101), v52, v104, v38, 0); | |
2796 LABEL_68: | |
2797 sr_sub_481DB2(array_508690, v54, v38); | |
2798 LABEL_75: | |
2799 v17 = &array_77EC08[pOutdoorCamera->numStru148s]; | |
2800 v57 = pOutdoor->GetTileTexture(v101, v100); | |
2801 v17->uTileBitmapID = v57; | |
2802 if ( v57 == -1 ) | |
2803 goto LABEL_105; | |
2804 *(int *)&v17->flags = pOutdoor->GetSomeOtherTileInfo(v101, v100); | |
2805 v58 = v92; | |
2806 v17->field_59 = 1; | |
2807 v17->field_34 = v58->distance; | |
638 | 2808 v17->terrain_grid_z = v94; |
2809 v17->terrain_grid_x = LOBYTE(v99); | |
0 | 2810 v59 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + LODWORD(v93)); |
2811 if ( v59 > (signed int)(uNumTerrainNormals - 1) ) | |
2812 { | |
2813 pNormalb = 0; | |
2814 v60 = 0; | |
2815 } | |
2816 else | |
2817 { | |
2818 v60 = &pTerrainNormals[v59]; | |
2819 pNormalb = v60; | |
2820 } | |
2821 if ( v60 ) | |
2822 { | |
2823 v61 = -(v97 * v60->z + v96 * v60->y + v95 * v60->x); | |
2824 if ( v61 < 0.0 ) | |
2825 v61 = 0.0; | |
2826 v93 = v61 * 31.0; | |
2827 v72 = v93 + 6.7553994e15; | |
2828 v83 = LODWORD(v72); | |
638 | 2829 v17->dimming_level = 31 - LOBYTE(v72); |
0 | 2830 } |
2831 else | |
2832 { | |
638 | 2833 v17->dimming_level = 0; |
0 | 2834 } |
638 | 2835 if ( v17->dimming_level < 0 ) |
2836 v17->dimming_level = 0; | |
0 | 2837 if ( pOutdoorCamera->numStru148s >= 1999 ) |
2838 return; | |
2839 ++pOutdoorCamera->numStru148s; | |
2840 if ( !sub_481FC9(v102, v104, v103, v17) ) | |
2841 { | |
2842 LABEL_104: | |
2843 --pOutdoorCamera->numStru148s; | |
2844 goto LABEL_105; | |
2845 } | |
2846 v62 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); | |
2847 memcpy(array_50AC10, v104, 0x30u); | |
168 | 2848 array_50AC10[0]._rhw = v62; |
0 | 2849 array_50AC10[0].u = 0.0; |
2850 array_50AC10[0].v = 0.0; | |
2851 v63 = v103->vWorldViewPosition.x + 0.0000001; | |
2852 memcpy(&array_50AC10[1], v103, sizeof(array_50AC10[1])); | |
168 | 2853 array_50AC10[1]._rhw = 1.0 / v63; |
0 | 2854 array_50AC10[1].u = 1.0; |
2855 array_50AC10[1].v = 1.0; | |
2856 v64 = v102->vWorldViewPosition.x + 0.0000001; | |
2857 memcpy(&array_50AC10[2], v102, sizeof(array_50AC10[2])); | |
168 | 2858 array_50AC10[2]._rhw = 1.0 / v64; |
0 | 2859 array_50AC10[2].u = 1.0; |
2860 array_50AC10[2].v = 0.0; | |
2861 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormalb, &v70, array_50AC10, 3u, 1); | |
2862 if ( stru_F8AD28.uNumLightsApplied <= 0 ) | |
2863 { | |
2864 v17->field_108 = 0; | |
2865 } | |
2866 else | |
2867 { | |
2868 v65 = pGame; | |
2869 v17->field_108 = 1; | |
2870 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormalb); | |
2871 } | |
2872 if ( v104->vWorldViewPosition.x < 8.0 || v103->vWorldViewPosition.x < 8.0 || v102->vWorldViewPosition.x < 8.0 ) | |
2873 { | |
2874 v37 = sr_4250FE(3u); | |
2875 OutdoorCamera::Project(v37); | |
2876 if ( !v37 ) | |
2877 goto LABEL_104; | |
2878 goto LABEL_102; | |
2879 } | |
2880 v66 = (double)pOutdoorCamera->shading_dist_mist; | |
2881 if ( v66 < v104->vWorldViewPosition.x || v66 < v103->vWorldViewPosition.x || v66 < v102->vWorldViewPosition.x ) | |
2882 { | |
2883 v37 = sr_4252E8(3u); | |
2884 if ( !v37 ) | |
2885 goto LABEL_105; | |
2886 goto LABEL_41; | |
2887 } | |
2888 v33 = sr_4254D2(3); | |
2889 v17->uNumVertices = v33; | |
2890 if ( !v33 ) | |
2891 goto LABEL_104; | |
2892 v34 = v104; | |
2893 v35 = v102; | |
2894 v69 = 0; | |
2895 v68 = v17; | |
2896 v67 = v103; | |
2897 LABEL_37: | |
2898 sr_sub_4829B9(v35, v34, v67, v68, v69); | |
2899 LABEL_38: | |
2900 sr_sub_481DB2(array_508690, v33, v17); | |
2901 goto LABEL_105; | |
2902 } | |
2903 goto LABEL_74; | |
2904 } | |
2905 v55 = sr_4252E8(3u); | |
2906 } | |
2907 v56 = v55; | |
2908 if ( v55 ) | |
2909 { | |
2910 OutdoorCamera::Project(v55); | |
2911 v54 = sr_4254D2(v56); | |
2912 v38->uNumVertices = v54; | |
2913 if ( v54 ) | |
2914 { | |
2915 v38->_48276F_sr(); | |
2916 goto LABEL_68; | |
2917 } | |
2918 } | |
2919 LABEL_74: | |
2920 --pOutdoorCamera->numStru148s; | |
2921 goto LABEL_75; | |
2922 } | |
2923 } | |
2924 | |
2925 //----- (0047BACF) -------------------------------------------------------- | |
2926 void Render::TransformBillboardsAndSetPalettesODM() | |
2927 { | |
142 | 2928 //int v0; // edi@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2929 //char *v1; // esi@2 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2930 //unsigned int v2; // edx@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2931 //int v3; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2932 //int v4; // edi@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2933 //int v5; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2934 //__int16 v6; // di@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2935 //int v7; // eax@3 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2936 //int v8; // ebx@4 |
0 | 2937 unsigned __int16 *v9; // eax@7 |
2938 char v10; // zf@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2939 //DWORD v11; // eax@13 |
0 | 2940 int v12; // eax@13 |
2941 int v13; // eax@14 | |
2942 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 | |
2943 int v15; // [sp+54h] [bp-10h]@13 | |
142 | 2944 //int v16; // [sp+58h] [bp-Ch]@1 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2945 //int v17; // [sp+5Ch] [bp-8h]@2 |
0 | 2946 int v18; // [sp+60h] [bp-4h]@13 |
2947 | |
2948 billboard.uParentBillboardID = -1; | |
2949 billboard.pTarget = pRenderer->pTargetSurface; | |
2950 billboard.pTargetZ = pRenderer->pActiveZBuffer; | |
2951 billboard.uTargetPitch = pRenderer->uTargetSurfacePitch; | |
693 | 2952 billboard.uViewportX = pViewport->uViewportTL_X; |
2953 billboard.uViewportY = pViewport->uViewportTL_Y; | |
2954 billboard.uViewportZ = pViewport->uViewportBR_X - 1; | |
2955 billboard.uViewportW = pViewport->uViewportBR_Y; | |
0 | 2956 pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw; |
142 | 2957 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2958 for (int i = 0; i < ::uNumBillboardsToDraw; ++i) |
0 | 2959 { |
143 | 2960 auto pBillboard = pBillboardRenderList + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2961 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2962 billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2963 billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2964 billboard.uParentBillboardID = i; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2965 billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2966 billboard.uTintColor = pBillboard->uTintColor; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2967 billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2968 billboard.sZValue = pBillboard->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2969 billboard.uFlags = pBillboard->field_1E; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2970 if (pBillboard->uHwSpriteID != -1) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2971 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2972 if (pRenderer->pRenderD3D) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2973 pRenderer->TransformBillboard(&billboard, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2974 &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], |
657 | 2975 pBillboard->dimming_level, pBillboard); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2976 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2977 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2978 assert(false); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2979 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2980 auto v1 = (char *)&pBillboard->uScreenSpaceY; |
0 | 2981 if ( *(v1 - 10) & 2 ) |
2982 v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); | |
2983 else | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2984 v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); |
0 | 2985 v10 = (*(v1 - 9) & 1) == 0; |
2986 billboard.pPalette = v9; | |
2987 if ( !v10 ) | |
2988 billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; | |
2989 if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) | |
2990 { | |
323 | 2991 v12 = stru_5C6E00->Cos(i * 5 + GetTickCount()); |
0 | 2992 v15 = abs(v12); |
2993 v18 = (unsigned __int64)(15i64 * v15) >> 16; | |
2994 billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); | |
2995 } | |
2996 v13 = *((short *)v1 - 8); | |
2997 if ( v13 >= 0 ) | |
733 | 2998 pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
2999 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3000 } |
0 | 3001 } |
3002 } | |
3003 | |
3004 //----- (0047AF11) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3005 void Render::DrawSpriteObjects_ODM() |
0 | 3006 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3007 //char *v0; // edi@2 |
430 | 3008 //ObjectDesc *v1; // ebx@4 |
0 | 3009 __int16 v2; // cx@5 |
3010 RenderBillboard *v3; // esi@10 | |
3011 SpriteFrame *v4; // eax@10 | |
430 | 3012 //SpriteFrame *v5; // ebx@10 |
0 | 3013 unsigned int v6; // eax@10 |
430 | 3014 //int v7; // ecx@10 |
3015 //int v8; // edx@10 | |
0 | 3016 int v9; // ecx@10 |
3017 unsigned __int16 v10; // ax@10 | |
430 | 3018 //int *v11; // eax@14 |
0 | 3019 int v12; // eax@22 |
3020 int v13; // ST3C_4@23 | |
3021 int v14; // eax@23 | |
3022 int v15; // ecx@23 | |
3023 int v16; // ebx@23 | |
3024 int v17; // ecx@25 | |
3025 int v18; // eax@25 | |
3026 int v19; // ST40_4@26 | |
3027 int v20; // ecx@26 | |
3028 int v21; // ST44_4@28 | |
3029 int v22; // ST3C_4@29 | |
3030 signed __int64 v23; // qtt@30 | |
3031 int v24; // ebx@30 | |
3032 int v25; // ST3C_4@30 | |
3033 int v26; // eax@31 | |
3034 char v27; // zf@31 | |
430 | 3035 //SpriteFrame *v28; // [sp+Ch] [bp-34h]@10 |
3036 //__int16 a5; // [sp+10h] [bp-30h]@10 | |
0 | 3037 int v30; // [sp+14h] [bp-2Ch]@23 |
3038 int v31; // [sp+14h] [bp-2Ch]@29 | |
3039 __int16 v32; // [sp+14h] [bp-2Ch]@30 | |
3040 int v33; // [sp+18h] [bp-28h]@23 | |
3041 int v34; // [sp+18h] [bp-28h]@26 | |
3042 int v35; // [sp+18h] [bp-28h]@30 | |
3043 int v36; // [sp+1Ch] [bp-24h]@10 | |
3044 int v37; // [sp+1Ch] [bp-24h]@23 | |
3045 int a6; // [sp+20h] [bp-20h]@10 | |
3046 int a6a; // [sp+20h] [bp-20h]@23 | |
3047 int v40; // [sp+24h] [bp-1Ch]@25 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3048 //signed int v41; // [sp+28h] [bp-18h]@1 |
0 | 3049 int v42; // [sp+2Ch] [bp-14h]@23 |
3050 int y; // [sp+30h] [bp-10h]@10 | |
3051 int x; // [sp+34h] [bp-Ch]@10 | |
3052 int z; // [sp+38h] [bp-8h]@10 | |
3053 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 | |
3054 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3055 //v41 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3056 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
|
3057 { |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3058 auto object = pSpriteObjects + i; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3059 //auto v0 = (char *)&pSpriteObjects[i].uSectorID; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3060 //v0 = (char *)&pSpriteObjects[0].uSectorID; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3061 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3062 //{ |
430 | 3063 if (!object->uObjectDescID) // item probably pciked up |
3064 continue; | |
3065 | |
3066 assert(object->uObjectDescID < pObjectList->uNumObjects); | |
3067 auto object_desc = pObjectList->pObjects + object->uObjectDescID; | |
3068 if (object_desc->NoSprite()) | |
3069 continue; | |
3070 | |
3071 //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; | |
3072 //if ( !(v1->uFlags & 1) ) | |
3073 //{ | |
3074 //v2 = *((short *)v0 - 14) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3075 v2 = object->uType; |
430 | 3076 if ( (v2 < 1000 || v2 >= 10000) && (v2 < 500 || v2 >= 600) || pGame->pStru6Instance->_4A81CA(object) ) |
3077 { | |
3078 //a5 = *(short *)v0; | |
3079 x = object->vPosition.x; | |
3080 y = object->vPosition.y; | |
3081 z = object->vPosition.z; | |
3082 v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; | |
3083 v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); | |
3084 //v5 = v4; | |
3085 //v28 = v4; | |
3086 v36 = v4->uFlags; | |
3087 a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier; | |
3088 v6 = stru_5C6E00->Atan2(object->vPosition.x - pIndoorCamera->pos.x, object->vPosition.y - pIndoorCamera->pos.y); | |
3089 //LOWORD(v7) = object->uFacing; | |
3090 //v8 = v36; | |
3091 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; | |
3092 v10 = v4->pHwSpriteIDs[v9]; | |
0 | 3093 v3->uHwSpriteID = v10; |
3094 if ( v36 & 0x20 ) | |
3095 { | |
430 | 3096 //v8 = v36; |
3097 z -= (signed int)((unsigned __int64)(v4->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
0 | 3098 } |
3099 v46 = 0; | |
430 | 3100 if ( v36 & 2 ) |
0 | 3101 v46 = 2; |
430 | 3102 //v11 = (int *)(256 << v9); |
3103 if ( (256 << v9) & v36 ) | |
0 | 3104 v46 |= 4u; |
430 | 3105 if ( v36 & 0x40000 ) |
0 | 3106 v46 |= 0x40u; |
430 | 3107 if ( v36 & 0x20000 ) |
0 | 3108 LOBYTE(v46) = v46 | 0x80; |
3109 if ( a6 ) | |
3110 { | |
430 | 3111 //LOBYTE(v11) = byte_4E94D3; |
3112 pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); | |
0 | 3113 } |
3114 v12 = (x - pIndoorCamera->pos.x) << 16; | |
3115 if ( pIndoorCamera->sRotationX ) | |
3116 { | |
3117 v13 = (y - pIndoorCamera->pos.y) << 16; | |
3118 v30 = ((unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | |
3119 + ((unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3120 v37 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3121 a6a = (unsigned __int64)(v13 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3122 v33 = (z - pIndoorCamera->pos.z) << 16; | |
3123 v14 = (unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3124 v15 = (unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3125 v16 = v15 + v14; | |
3126 v42 = v15 + v14; | |
3127 if ( v15 + v14 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3128 { | |
3129 v17 = a6a - v37; | |
3130 v40 = a6a - v37; | |
3131 v18 = ((unsigned __int64)(v33 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) | |
3132 - ((unsigned __int64)(v30 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3133 goto LABEL_29; | |
3134 } | |
3135 } | |
3136 else | |
3137 { | |
3138 v34 = (y - pIndoorCamera->pos.y) << 16; | |
3139 v19 = (unsigned __int64)(v12 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3140 v20 = (unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3141 v16 = v20 + v19; | |
3142 v42 = v20 + v19; | |
3143 if ( v20 + v19 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3144 { | |
430 | 3145 v21 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; |
3146 v17 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
3147 v40 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; | |
0 | 3148 v18 = (z - pIndoorCamera->pos.z) << 16; |
3149 LABEL_29: | |
3150 v31 = v18; | |
3151 v22 = abs(v17); | |
3152 if ( abs(v16) >= v22 ) | |
3153 { | |
3154 LODWORD(v23) = 0; | |
3155 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3156 v24 = v23 / v42; | |
3157 v25 = v23 / v42; | |
3158 LODWORD(v23) = 0; | |
3159 HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
430 | 3160 v35 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); |
3161 v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); | |
3162 | |
3163 //if (::uNumBillboardsToDraw >= 500) | |
3164 // return; | |
3165 assert(::uNumBillboardsToDraw < 500); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3166 ++::uNumBillboardsToDraw; |
0 | 3167 ++uNumSpritesDrawnThisFrame; |
430 | 3168 |
3169 object->uAttributes |= 1; | |
3170 v3->uPalette = v4->uPaletteIndex; | |
3171 v3->uIndoorSectorID = object->uSectorID; | |
3172 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
3173 v26 = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; | |
3174 v3->pSpriteFrame = v4; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3175 v3->_screenspace_y_scaler_packedfloat = v26; |
0 | 3176 v3->field_1E = v46; |
430 | 3177 v3->world_x = x; |
3178 v3->world_y = y; | |
3179 v3->world_z = z; | |
0 | 3180 v3->uScreenSpaceX = v35; |
3181 v3->uScreenSpaceY = v32; | |
3182 HIWORD(v26) = HIWORD(v42); | |
3183 LOWORD(v26) = 0; | |
430 | 3184 v27 = (object->uAttributes & 0x20) == 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3185 v3->sZValue = v26 + (8 * i | OBJECT_Item); |
657 | 3186 v3->dimming_level = 0; |
0 | 3187 v3->uTintColor = 0; |
3188 if ( !v27 ) | |
3189 { | |
3190 if ( !pRenderer->pRenderD3D ) | |
3191 v3->sZValue = 0; | |
3192 } | |
3193 } | |
3194 goto LABEL_34; | |
3195 } | |
3196 } | |
3197 } | |
430 | 3198 //} |
0 | 3199 LABEL_34: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3200 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3201 //++v41; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3202 //v0 += 112; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3203 //} |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
3204 //while ( v41 < (signed int)uNumSpriteObjects ); |
0 | 3205 } |
3206 } | |
3207 // 4E94D3: using guessed type char byte_4E94D3; | |
3208 // 5187E4: using guessed type int uNumSpritesDrawnThisFrame; | |
3209 | |
3210 //----- (0049D9BC) -------------------------------------------------------- | |
3211 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut) | |
3212 { | |
3213 size_t v4; // eax@1 | |
3214 size_t v5; // eax@1 | |
3215 IUnknown *v6; // eax@10 | |
3216 size_t v7; // eax@13 | |
3217 DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11 | |
3218 DDSURFACEDESC2 v10;/*int v10; // [sp+42Ch] [bp-D0h]@16 | |
3219 int v11; // [sp+430h] [bp-CCh]@16 | |
3220 int v12; // [sp+434h] [bp-C8h]@16 | |
3221 int v13; // [sp+438h] [bp-C4h]@16 | |
3222 int v14; // [sp+474h] [bp-88h]@16*/ | |
3223 DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14 | |
3224 unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14 | |
3225 RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19 | |
3226 IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18 | |
3227 int v19; // [sp+4C8h] [bp-34h]@16 | |
3228 RenderD3D_D3DDevDesc v20; // [sp+4CCh] [bp-30h]@1 | |
3229 LPDIRECTDRAW pDirectDraw; // [sp+4F4h] [bp-8h]@4 | |
3230 IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7 | |
3231 | |
3232 v4 = strlen(lpDriverName); | |
3233 v20.pDriverName = new char[v4 + 1]; | |
3234 v5 = strlen(lpDevDesc); | |
3235 v20.pDeviceDesc = new char[v5 + 1]; | |
3236 strcpy(v20.pDriverName, lpDriverName); | |
3237 strcpy(v20.pDeviceDesc, lpDevDesc); | |
3238 if ( lpGUID ) | |
3239 { | |
3240 v20.pGUID = new GUID; | |
3241 memcpy(v20.pGUID, lpGUID, 0x10u); | |
3242 } | |
3243 else | |
3244 { | |
3245 v20.pGUID = 0; | |
3246 } | |
3247 | |
3248 if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) | |
3249 { | |
3250 delete [] v20.pDriverName; | |
3251 delete [] v20.pDeviceDesc; | |
3252 if ( v20.pGUID ) | |
3253 delete v20.pGUID; | |
3254 } | |
3255 else | |
3256 { | |
3257 if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pDirectDraw4))) | |
3258 { | |
3259 delete [] v20.pDriverName; | |
3260 delete [] v20.pDeviceDesc; | |
3261 if ( v20.pGUID ) | |
3262 delete v20.pGUID; | |
3263 v6 = (IUnknown *)pDirectDraw; | |
3264 } | |
3265 else | |
3266 { | |
3267 pDirectDraw->Release(); | |
3268 if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1u))) | |
3269 { | |
3270 v20.pDDraw4DevDesc = 0; | |
3271 } | |
3272 else | |
3273 { | |
3274 v7 = strlen(ddDevId.szDescription); | |
3275 v20.pDDraw4DevDesc = new char[v7 + 1]; | |
3276 strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription); | |
3277 } | |
3278 memset(&ddsCaps, 0, 0x10u); | |
3279 if (FAILED(pDirectDraw4->GetAvailableVidMem( | |
3280 &ddsCaps, | |
3281 (LPDWORD)&v20.uVideoMem, | |
3282 (LPDWORD)&uFreeVideoMem))) | |
3283 v20.uVideoMem = 0; | |
3284 memset(&v10, 0, 0x7Cu); | |
3285 v10.dwSize = 124; | |
3286 v10.dwFlags = 6; | |
3287 v10.dwHeight = 640; | |
3288 v10.dwWidth = 480; | |
3289 v10.ddpfPixelFormat.dwSize = 32; | |
3290 | |
3291 v19 = 0; | |
3292 if ( FAILED(pDirectDraw4->EnumDisplayModes( | |
3293 0, | |
3294 0, | |
3295 &v19, | |
3296 (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) | |
3297 || !v19 | |
3298 || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3))) | |
3299 { | |
3300 delete [] v20.pDriverName; | |
3301 delete [] v20.pDeviceDesc; | |
3302 if ( v20.pDDraw4DevDesc ) | |
3303 free(v20.pDDraw4DevDesc); | |
3304 if ( v20.pGUID ) | |
3305 delete v20.pGUID; | |
3306 v6 = (IUnknown *)pDirectDraw4; | |
3307 } | |
3308 else | |
3309 { | |
3310 aux.pInfo = pOut; | |
3311 aux.ptr_4 = &v20; | |
3312 pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); | |
3313 delete [] v20.pDriverName; | |
3314 delete [] v20.pDeviceDesc; | |
3315 if ( v20.pDDraw4DevDesc ) | |
3316 free(v20.pDDraw4DevDesc); | |
3317 if ( v20.pGUID ) | |
3318 delete v20.pGUID; | |
3319 pDirectDraw4->Release(); | |
3320 v6 = (IUnknown *)pDirect3D3; | |
3321 pDirectDraw4 = 0; | |
3322 } | |
3323 } | |
3324 v6->Release(); | |
3325 } | |
3326 return 1; | |
3327 } | |
3328 | |
3329 //----- (0049D784) -------------------------------------------------------- | |
3330 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6) | |
3331 { | |
3332 int v6; // eax@1 | |
3333 signed int v7; // edi@1 | |
3334 signed int v8; // edi@14 | |
3335 size_t v9; // eax@30 | |
3336 size_t v10; // eax@30 | |
3337 size_t v11; // eax@30 | |
3338 size_t v12; // eax@30 | |
3339 size_t v13; // eax@30 | |
3340 | |
3341 v6 = pHWDesc->dwFlags; | |
3342 v7 = -1; | |
3343 if ( v6 ) | |
3344 { | |
3345 if ( !a6->ptr_4->pGUID ) | |
3346 v7 = 0; | |
3347 if ( v6 && a6->ptr_4->pGUID ) | |
3348 v7 = 1; | |
3349 } | |
3350 if ( !strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID ) | |
3351 v7 = 2; | |
3352 if ( !strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID ) | |
3353 v7 = 3; | |
3354 if ( v7 != -1 ) | |
3355 { | |
3356 v8 = v7; | |
3357 a6->pInfo[v8].bIsDeviceCompatible = 1; | |
3358 a6->pInfo[v8].uCaps = 0; | |
3359 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
3360 a6->pInfo[v8].uCaps |= 2u; | |
3361 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2) ) | |
3362 a6->pInfo[v8].uCaps |= 4u; | |
3363 if ( !(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1) ) | |
3364 a6->pInfo[v8].uCaps |= 8u; | |
3365 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
3366 a6->pInfo[v8].uCaps |= 0x10u; | |
3367 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2) ) | |
3368 a6->pInfo[v8].uCaps |= 0x20u; | |
3369 if ( !(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4) ) | |
3370 a6->pInfo[v8].uCaps |= 0x40u; | |
3371 if ( !(BYTE1(pHWDesc->dwDevCaps) & 0x10) ) | |
3372 BYTE1(a6->pInfo[v8].uCaps) |= 1u; | |
3373 if ( pHWDesc->dpcTriCaps.dwTextureCaps & 0x20 ) | |
3374 LOBYTE(a6->pInfo[v8].uCaps) |= 0x80u; | |
3375 v9 = strlen(lpDeviceName); | |
3376 a6->pInfo[v8].pName = new char[v9 + 1]; | |
3377 strcpy(a6->pInfo[v8].pName, lpDeviceName); | |
3378 v10 = strlen(lpDeviceDesc); | |
3379 a6->pInfo[v8].pDescription = new char[v10 + 1]; | |
3380 strcpy(a6->pInfo[v8].pDescription, lpDeviceDesc); | |
3381 a6->pInfo[v8].pGUID = (GUID *)operator new(0x10u); | |
3382 memcpy(a6->pInfo[v8].pGUID, lpGUID, 0x10u); | |
3383 v11 = strlen(a6->ptr_4->pDriverName); | |
3384 a6->pInfo[v8].pDriverName = new char[v11 + 1]; | |
3385 strcpy(a6->pInfo[v8].pDriverName, a6->ptr_4->pDriverName); | |
3386 v12 = strlen(a6->ptr_4->pDeviceDesc); | |
3387 a6->pInfo[v8].pDeviceDesc = new char[v12 + 1]; | |
3388 strcpy(a6->pInfo[v8].pDeviceDesc, a6->ptr_4->pDeviceDesc); | |
3389 v13 = strlen(a6->ptr_4->pDDraw4DevDesc); | |
3390 a6->pInfo[v8].pDDraw4DevDesc = new char[v13 + 1]; | |
3391 strcpy(a6->pInfo[v8].pDDraw4DevDesc, a6->ptr_4->pDDraw4DevDesc); | |
3392 if ( a6->ptr_4->pGUID ) | |
3393 { | |
3394 a6->pInfo[v8].pDirectDrawGUID = new GUID; | |
3395 memcpy(a6->pInfo[v8].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10u); | |
3396 } | |
3397 else | |
3398 { | |
3399 a6->pInfo[v8].pDirectDrawGUID = 0; | |
3400 } | |
3401 a6->pInfo[v8].uVideoMem = a6->ptr_4->uVideoMem; | |
3402 } | |
3403 return 1; | |
3404 } | |
3405 | |
3406 //----- (0049D75C) -------------------------------------------------------- | |
3407 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2) | |
3408 { | |
3409 HRESULT result; // eax@3 | |
3410 | |
3411 if ( pSurfaceDesc->ddsCaps.dwCaps | 0x2000 && pSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 16 ) | |
3412 { | |
3413 *a2 = 1; | |
3414 result = 0; | |
3415 } | |
3416 else | |
3417 { | |
3418 result = 1; | |
3419 } | |
3420 return result; | |
3421 } | |
3422 | |
3423 //----- (0047A95E) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3424 void Render::PrepareDecorationsRenderList_ODM() |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3425 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3426 //char *v0; // esi@2 |
639 | 3427 //DecorationDesc *v1; // ebx@6 |
0 | 3428 __int16 v2; // ax@6 |
3429 double v3; // st7@7 | |
639 | 3430 //int v4; // eax@9 |
3431 //int v5; // edx@9 | |
0 | 3432 unsigned int v6; // edi@9 |
3433 int v7; // eax@9 | |
3434 SpriteFrame *v8; // eax@9 | |
635 | 3435 //SpriteFrame *v9; // edi@9 |
0 | 3436 unsigned __int16 *v10; // eax@9 |
3437 int v11; // ecx@9 | |
3438 int v12; // eax@9 | |
3439 int v13; // ecx@9 | |
3440 int v14; // ecx@20 | |
3441 char v15; // dl@20 | |
3442 signed int v16; // eax@20 | |
3443 int v17; // eax@23 | |
3444 int v18; // ecx@24 | |
3445 int v19; // eax@24 | |
3446 int v20; // ecx@24 | |
3447 int v21; // ebx@26 | |
3448 int v22; // eax@26 | |
3449 int v23; // eax@30 | |
3450 signed __int64 v24; // qtt@31 | |
3451 int v25; // ebx@31 | |
3452 int v26; // ecx@32 | |
3453 RenderBillboard *v27; // eax@37 | |
3454 __int16 v28; // dx@37 | |
3455 __int16 v29; // cx@37 | |
3456 int v30; // ecx@37 | |
3457 int v31; // ebx@37 | |
619 | 3458 Particle_sw local_0; // [sp+Ch] [bp-98h]@7 |
639 | 3459 //int x; // [sp+74h] [bp-30h]@9 |
3460 //int y; // [sp+78h] [bp-2Ch]@9 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3461 //int v35; // [sp+7Ch] [bp-28h]@1 |
639 | 3462 //int v36; // [sp+80h] [bp-24h]@9 |
0 | 3463 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 |
3464 int v38; // [sp+88h] [bp-1Ch]@9 | |
3465 int v39; // [sp+8Ch] [bp-18h]@24 | |
3466 int v40; // [sp+90h] [bp-14h]@24 | |
3467 int v41; // [sp+94h] [bp-10h]@24 | |
3468 int v42; // [sp+98h] [bp-Ch]@9 | |
3469 int a5; // [sp+9Ch] [bp-8h]@9 | |
3470 int b; // [sp+A0h] [bp-4h]@22 | |
3471 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3472 //v35 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3473 //if ( (signed int)uNumLevelDecorations > 0 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3474 //{ |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3475 //v0 = (char *)&pLevelDecorations[0].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3476 //do |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3477 for (int i = 0; i < uNumLevelDecorations; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3478 { |
635 | 3479 auto decor = pLevelDecorations + i; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3480 auto v0 = (char *)&pLevelDecorations[i].vPosition.y; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3481 |
639 | 3482 if ( (!(decor->field_2 & 0x40) || decor->_47A825()) && !(decor->field_2 & 0x20) ) |
3483 { | |
3484 //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID]; | |
3485 auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; | |
3486 v2 = decor_desc->uFlags; | |
0 | 3487 if ( (char)v2 >= 0 ) |
3488 { | |
3489 if ( !(v2 & 0x22) ) | |
3490 { | |
639 | 3491 //v4 = decor->vPosition.x; |
3492 //v5 = decor->vPosition.z; | |
0 | 3493 v6 = pMiscTimer->uTotalGameTimeElapsed; |
639 | 3494 //y = decor->vPosition.y; |
3495 //x = decor->vPosition.x; | |
3496 //v36 = decor->vPosition.z; | |
3497 v7 = abs(decor->vPosition.x + decor->vPosition.y); | |
635 | 3498 |
3499 | |
3500 #pragma region "New: seasons change" | |
3501 extern bool change_seasons; | |
3502 if (change_seasons) | |
3503 switch (pParty->uCurrentMonth) | |
3504 { | |
3505 // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites | |
3506 case 11: case 0: case 1: // winter | |
639 | 3507 switch (decor_desc->uSpriteID) |
635 | 3508 { |
3509 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
3510 case 548: // flower10 | |
3511 case 547: // flower09 | |
3512 case 541: // flower03 | |
3513 case 539: continue; // flower01 | |
3514 | |
3515 case 483: // tree01 | |
3516 case 486: // tree04 | |
3517 case 492: // tree10 | |
639 | 3518 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); |
3519 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); | |
635 | 3520 break; |
3521 | |
3522 default: | |
639 | 3523 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3524 } |
3525 break; | |
3526 | |
3527 case 2: case 3: case 4: // spring | |
639 | 3528 switch (decor_desc->uSpriteID) |
635 | 3529 { |
3530 } | |
639 | 3531 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3532 break; |
3533 | |
3534 case 8: case 9: case 10: // autumn | |
639 | 3535 switch (decor_desc->uSpriteID) |
635 | 3536 { |
3537 //case 468: //bush02 grows on swamps, which are evergreeen actually | |
3538 case 548: // flower10 | |
3539 case 547: // flower09 | |
3540 case 541: // flower03 | |
3541 case 539: continue; // flower01 | |
3542 | |
3543 case 483: // tree01 | |
3544 case 486: // tree04 | |
3545 case 492: // tree10 | |
639 | 3546 pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); |
3547 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); | |
635 | 3548 break; |
3549 | |
3550 default: | |
639 | 3551 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3552 } |
3553 break; | |
3554 | |
3555 case 5: case 6: case 7: // summer | |
3556 //all green by default | |
639 | 3557 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3558 break; |
3559 | |
3560 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
3561 } | |
637 | 3562 else |
639 | 3563 v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3564 #pragma endregion |
639 | 3565 //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); |
635 | 3566 |
3567 //v9 = v8; | |
0 | 3568 v42 = v8->uFlags; |
3569 a5 = v8->uGlowRadius; | |
639 | 3570 v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pIndoorCamera->pos.x, |
3571 decor->vPosition.y - pIndoorCamera->pos.y); | |
0 | 3572 v11 = *((int *)v0 + 2); |
3573 v37 = v10; | |
3574 v12 = v42; | |
3575 v38 = 0; | |
3576 v13 = ((signed int)(stru_5C6E00->uIntegerPi | |
3577 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
3578 + v11 | |
3579 - (signed int)v37) >> 8) & 7; | |
3580 v37 = (unsigned __int16 *)v13; | |
3581 if ( v42 & 2 ) | |
3582 v38 = 2; | |
3583 if ( (256 << v13) & v42 ) | |
3584 v38 |= 4u; | |
3585 if ( v12 & 0x40000 ) | |
3586 v38 |= 0x40u; | |
3587 if ( v12 & 0x20000 ) | |
3588 LOBYTE(v38) = v38 | 0x80; | |
3589 if ( a5 ) | |
3590 { | |
3591 if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) | |
3592 { | |
639 | 3593 v14 = decor_desc->uColoredLightRed; |
3594 v15 = decor_desc->uColoredLightGreen; | |
3595 v16 = decor_desc->uColoredLightBlue; | |
0 | 3596 } |
3597 else | |
3598 { | |
3599 v16 = 255; | |
3600 v14 = 255; | |
3601 v15 = 255; | |
3602 } | |
3603 b = v16; | |
3604 pStationaryLightsStack->AddLight( | |
639 | 3605 decor->vPosition.x, |
3606 decor->vPosition.y, | |
3607 decor->vPosition.z + decor_desc->uDecorationHeight / 2, | |
0 | 3608 a5, |
3609 v14, | |
3610 v15, | |
3611 v16, | |
3612 byte_4E94D0); | |
3613 } | |
639 | 3614 v17 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
0 | 3615 if ( pIndoorCamera->sRotationX ) |
3616 { | |
639 | 3617 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; |
0 | 3618 v18 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) |
3619 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3620 v42 = v18; | |
3621 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3622 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
639 | 3623 v40 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 3624 v41 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; |
3625 v19 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3626 v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3627 v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3628 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3629 { | |
3630 v21 = a5 - b; | |
3631 v41 = a5 - b; | |
3632 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; | |
3633 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; | |
3634 v22 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) - a5; | |
3635 LABEL_30: | |
3636 v42 = v22; | |
3637 v40 = 2 * abs(v20); | |
3638 v23 = abs(v21); | |
3639 if ( v40 >= v23 ) | |
3640 { | |
3641 LODWORD(v24) = 0; | |
3642 HIDWORD(v24) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3643 a5 = v24 / v39; | |
3644 v25 = pViewport->uScreenCenterX | |
3645 - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); | |
3646 b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; | |
3647 v41 = v24 / v39; | |
3648 v40 = pViewport->uScreenCenterY | |
3649 - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); | |
635 | 3650 v42 = v8->scale; |
0 | 3651 v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; |
635 | 3652 v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37]; |
0 | 3653 if ( pRenderer->pRenderD3D ) |
3654 { | |
3655 v26 = v41; | |
3656 v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; | |
3657 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
3658 } | |
3659 else | |
3660 { | |
3661 v26 = v41; | |
3662 v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; | |
3663 b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; | |
3664 } | |
693 | 3665 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) |
0 | 3666 { |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3667 if (::uNumBillboardsToDraw >= 500) |
0 | 3668 return; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3669 v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; |
0 | 3670 ++uNumDecorationsDrawnThisFrame; |
3671 v27->uHwSpriteID = *v37; | |
635 | 3672 v28 = v8->uPaletteIndex; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3673 v27->_screenspace_x_scaler_packedfloat = v26; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3674 v27->_screenspace_y_scaler_packedfloat = v26; |
0 | 3675 v29 = v38; |
3676 v27->uScreenSpaceX = v25; | |
3677 HIBYTE(v29) |= 2u; | |
3678 v27->uPalette = v28; | |
3679 v27->field_1E = v29; | |
639 | 3680 v27->world_x = decor->vPosition.x; |
3681 v27->world_y = decor->vPosition.y; | |
3682 v27->world_z = decor->vPosition.z; | |
0 | 3683 v27->uScreenSpaceY = v40; |
3684 HIWORD(v30) = HIWORD(v39); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3685 v31 = 8 * i | OBJECT_Decoration; |
0 | 3686 LOWORD(v30) = 0; |
3687 v27->uIndoorSectorID = 0; | |
3688 v27->sZValue = v30 + v31; | |
657 | 3689 v27->dimming_level = 0; |
635 | 3690 v27->pSpriteFrame = v8; |
0 | 3691 v27->uTintColor = 0; |
3692 } | |
3693 } | |
3694 goto LABEL_38; | |
3695 } | |
3696 } | |
3697 else | |
3698 { | |
639 | 3699 v42 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; |
3700 v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; | |
0 | 3701 b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; |
3702 a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3703 v20 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3704 v39 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3705 if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) | |
3706 { | |
3707 a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3708 b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3709 v21 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
3710 v41 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; | |
639 | 3711 v22 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; |
0 | 3712 goto LABEL_30; |
3713 } | |
3714 } | |
3715 } | |
3716 } | |
3717 else | |
3718 { | |
3719 memset(&local_0, 0, 0x68u); | |
3720 v3 = (double)*((signed int *)v0 - 1); | |
619 | 3721 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; |
3722 local_0.uDiffuse = 0xFF3C1E; | |
0 | 3723 local_0.x = v3; |
3724 local_0.y = (double)*(signed int *)v0; | |
3725 local_0.z = (double)*((signed int *)v0 + 1); | |
3726 local_0.flt_10 = 0.0; | |
3727 local_0.flt_14 = 0.0; | |
3728 local_0.flt_18 = 0.0; | |
3729 local_0.flt_28 = 1.0; | |
3730 local_0.timeToLive = (rand() & 0x80) + 128; | |
3731 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
3732 pGame->pParticleEngine->AddParticle(&local_0); | |
3733 } | |
3734 } | |
3735 LABEL_38: | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3736 ; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3737 //++v35; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3738 //v0 += 32; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3739 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
3740 //while ( v35 < (signed int)uNumLevelDecorations ); |
0 | 3741 } |
3742 // 4E94D0: using guessed type char byte_4E94D0; | |
3743 // 5187EC: using guessed type int uNumDecorationsDrawnThisFrame; | |
3744 | |
3745 //----- (0049D717) -------------------------------------------------------- | |
3746 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | |
3747 { | |
3748 HRESULT v2; // esi@2 | |
3749 | |
3750 if ( Src->dwFlags & 0x400 | 0x2000 ) | |
3751 { | |
3752 v2 = 0; | |
3753 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | |
3754 goto LABEL_6; | |
3755 if ( !Dst->dwSize ) | |
3756 { | |
3757 v2 = 1; | |
3758 LABEL_6: | |
3759 memcpy(Dst, Src, 0x20u); | |
3760 return v2; | |
3761 } | |
3762 } | |
3763 return 1; | |
3764 } | |
3765 | |
3766 //----- (0049DC28) -------------------------------------------------------- | |
3767 void RenderD3D::GetAvailableDevices(RenderD3D__DevInfo **pOutDevices) | |
3768 { | |
3769 RenderD3D__DevInfo *v2; // eax@1 | |
3770 | |
3771 v2 = new RenderD3D__DevInfo[4];// 4 items | |
3772 *pOutDevices = v2; | |
3773 memset(v2, 0, 0xA0u); | |
3774 DirectDrawEnumerateA((LPDDENUMCALLBACKA)RenderD3D__DeviceEnumerator, *pOutDevices); | |
3775 } | |
3776 | |
3777 //----- (0049DC58) -------------------------------------------------------- | |
3778 RenderD3D::RenderD3D() | |
3779 { | |
3780 RenderD3D *v1; // esi@1 | |
3781 | |
3782 v1 = this; | |
3783 this->pHost = 0; | |
3784 this->pDirect3D = 0; | |
3785 this->pUnk = 0; | |
3786 this->pBackBuffer = 0; | |
3787 this->pFrontBuffer = 0; | |
3788 this->pZBuffer = 0; | |
3789 this->pDevice = 0; | |
3790 this->pViewport = 0; | |
3791 this->field_40 = 1; | |
3792 this->field_44 = 10; | |
3793 GetAvailableDevices(&this->pAvailableDevices); | |
3794 } | |
3795 | |
3796 //----- (0049DC90) -------------------------------------------------------- | |
3797 void RenderD3D::Release() | |
3798 { | |
3799 RenderD3D *v1; // esi@1 | |
3800 IDirectDraw4 *v2; // eax@2 | |
3801 signed int v3; // edi@4 | |
3802 IDirect3DViewport3 *v4; // eax@22 | |
3803 IUnknown *v5; // eax@24 | |
3804 IDirectDrawSurface4 *v6; // eax@26 | |
3805 IDirect3DDevice3 *v7; // eax@28 | |
3806 IDirect3D3 *v8; // eax@30 | |
3807 IDirectDrawSurface4 *v9; // eax@32 | |
3808 IDirectDrawSurface4 *v10; // eax@34 | |
3809 IDirectDraw4 *v11; // eax@36 | |
3810 | |
3811 v1 = this; | |
3812 if ( !this->bWindowed ) | |
3813 { | |
3814 v2 = this->pHost; | |
3815 if ( v2 ) | |
3816 { | |
3817 v2->RestoreDisplayMode(); | |
3818 v1->pHost->SetCooperativeLevel(v1->hWindow, 8u); | |
3819 v1->pHost->FlipToGDISurface(); | |
3820 } | |
3821 } | |
3822 v3 = 0; | |
3823 do | |
3824 { | |
3825 if ( v1->pAvailableDevices[v3].pDriverName ) | |
3826 { | |
3827 free(v1->pAvailableDevices[v3].pDriverName); | |
3828 v1->pAvailableDevices[v3].pDriverName = 0; | |
3829 } | |
3830 if ( v1->pAvailableDevices[v3].pDeviceDesc ) | |
3831 { | |
3832 free(v1->pAvailableDevices[v3].pDeviceDesc); | |
3833 v1->pAvailableDevices[v3].pDeviceDesc = 0; | |
3834 } | |
3835 if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) | |
3836 { | |
3837 free(v1->pAvailableDevices[v3].pDDraw4DevDesc); | |
3838 v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; | |
3839 } | |
3840 if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) | |
3841 { | |
3842 free(v1->pAvailableDevices[v3].pDirectDrawGUID); | |
3843 v1->pAvailableDevices[v3].pDirectDrawGUID = 0; | |
3844 } | |
3845 if ( v1->pAvailableDevices[v3].pName ) | |
3846 { | |
3847 free(v1->pAvailableDevices[v3].pName); | |
3848 v1->pAvailableDevices[v3].pName = 0; | |
3849 } | |
3850 if ( v1->pAvailableDevices[v3].pDescription ) | |
3851 { | |
3852 free(v1->pAvailableDevices[v3].pDescription); | |
3853 v1->pAvailableDevices[v3].pDescription = 0; | |
3854 } | |
3855 if ( v1->pAvailableDevices[v3].pGUID ) | |
3856 { | |
3857 free(v1->pAvailableDevices[v3].pGUID); | |
3858 v1->pAvailableDevices[v3].pGUID = 0; | |
3859 } | |
3860 ++v3; | |
3861 } | |
3862 while ( v3 < 4 ); | |
3863 if ( v1->pAvailableDevices ) | |
3864 { | |
3865 free(v1->pAvailableDevices); | |
3866 v1->pAvailableDevices = 0; | |
3867 } | |
3868 v4 = v1->pViewport; | |
3869 if ( v4 ) | |
3870 { | |
3871 v4->Release(); | |
3872 v1->pViewport = 0; | |
3873 } | |
3874 v5 = v1->pUnk; | |
3875 if ( v5 ) | |
3876 { | |
3877 v5->Release(); | |
3878 v1->pUnk = 0; | |
3879 } | |
3880 v6 = v1->pZBuffer; | |
3881 if ( v6 ) | |
3882 { | |
3883 v6->Release(); | |
3884 v1->pZBuffer = 0; | |
3885 } | |
3886 v7 = v1->pDevice; | |
3887 if ( v7 ) | |
3888 { | |
3889 v7->Release(); | |
3890 v1->pDevice = 0; | |
3891 } | |
3892 v8 = v1->pDirect3D; | |
3893 if ( v8 ) | |
3894 { | |
3895 v8->Release(); | |
3896 v1->pDirect3D = 0; | |
3897 } | |
3898 v9 = v1->pBackBuffer; | |
3899 if ( v9 ) | |
3900 { | |
3901 v9->Release(); | |
3902 v1->pBackBuffer = 0; | |
3903 } | |
3904 v10 = v1->pFrontBuffer; | |
3905 if ( v10 ) | |
3906 { | |
3907 v10->Release(); | |
3908 v1->pFrontBuffer = 0; | |
3909 } | |
3910 v11 = v1->pHost; | |
3911 if ( v11 ) | |
3912 { | |
3913 v11->Release(); | |
3914 v1->pHost = 0; | |
3915 } | |
3916 } | |
3917 | |
3918 //----- (0049DE14) -------------------------------------------------------- | |
3919 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, HWND hWnd) | |
3920 { | |
3921 //IDirectDraw4 *v8; // eax@12 | |
3922 //IDirectDraw4 *v9; // eax@16 | |
3923 //IDirectDraw4 *v10; // eax@20 | |
3924 //IDirectDraw4 *v13; // eax@35 | |
3925 const char *v23; // [sp-4h] [bp-DCh]@9 | |
3926 const char *v24; // [sp-4h] [bp-DCh]@13 | |
3927 const char *v25; // [sp-4h] [bp-DCh]@19 | |
3928 DWORD v26; // [sp-4h] [bp-DCh]@30 | |
3929 DDSCAPS2 v27; // [sp+Ch] [bp-CCh]@37 | |
3930 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | |
3931 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | |
3932 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | |
3933 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | |
3934 | |
3935 this->bWindowed = bWindowed; | |
3936 this->hWindow = hWnd; | |
3937 | |
3938 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | |
3939 { | |
3940 sprintf(pErrorMessage, "Init - Failed to create DirectDraw interface.\n"); | |
3941 return 0; | |
3942 } | |
3943 | |
3944 if (FAILED(lpDD->QueryInterface(IID_IDirectDraw4, (LPVOID *)&pHost))) | |
3945 { | |
3946 sprintf(pErrorMessage, "Init - Failed to create DirectDraw4 interface.\n"); | |
3947 if (lpDD) | |
3948 lpDD->Release(); | |
3949 return 0; | |
3950 } | |
3951 lpDD->Release(); | |
3952 lpDD = 0; | |
3953 | |
3954 if (bWindowed && !pAvailableDevices[uDeviceID].pDirectDrawGUID) | |
3955 { | |
3956 if (FAILED(pHost->SetCooperativeLevel(hWnd, DDSCL_MULTITHREADED | DDSCL_NORMAL))) | |
3957 { | |
3958 v23 = "Init - Failed to set cooperative level.\n"; | |
3959 sprintf(pErrorMessage, v23); | |
3960 LABEL_65: | |
3961 if (pHost) | |
3962 { | |
3963 pHost->Release(); | |
3964 pHost = 0; | |
3965 } | |
3966 return 0; | |
3967 } | |
3968 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
3969 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
3970 ddsd2.dwFlags = DDSD_CAPS; | |
3971 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | |
3972 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
3973 { | |
3974 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
3975 pHost->GetDisplayMode(&ddsd2); | |
3976 if ( ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) | |
3977 { | |
3978 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | |
3979 goto LABEL_14; | |
3980 } | |
3981 | |
3982 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | |
3983 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | |
3984 ddsd2.dwWidth = 640; | |
3985 ddsd2.dwHeight = 480; | |
3986 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) | |
3987 { | |
3988 v24 = "Init - Failed to create back buffer.\n"; | |
3989 LABEL_14: | |
3990 sprintf(pErrorMessage, v24); | |
3991 if (pFrontBuffer) | |
3992 { | |
3993 pFrontBuffer->Release(); | |
3994 pFrontBuffer = 0; | |
3995 } | |
3996 goto LABEL_65; | |
3997 } | |
3998 if ( pHost->CreateClipper(0, &v30, 0) ) | |
3999 { | |
4000 v25 = "Init - Failed to create clipper.\n"; | |
4001 goto LABEL_45; | |
4002 } | |
4003 v30->SetHWnd(0, hWnd); | |
4004 pFrontBuffer->SetClipper(v30); | |
4005 | |
4006 v30->Release(); | |
4007 v30 = 0; | |
4008 | |
4009 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
4010 | |
4011 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4012 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
4013 ddsd2.dwWidth = 640; | |
4014 ddsd2.dwHeight = 480; | |
4015 | |
4016 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
4017 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
4018 &ddsd2.ddpfPixelFormat) ) | |
4019 goto LABEL_21; | |
4020 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
4021 ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; | |
4022 | |
4023 if ( !pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
4024 { | |
4025 if ( !pBackBuffer->AddAttachedSurface(pZBuffer) ) | |
4026 { | |
4027 if ( !pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
4028 pBackBuffer, | |
4029 &pDevice, | |
4030 0) ) | |
4031 { | |
4032 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
4033 d3dvp2.dvClipWidth = 2.0; | |
4034 d3dvp2.dvClipY = 1.0; | |
4035 d3dvp2.dvClipHeight = 2.0; | |
4036 d3dvp2.dvMaxZ = 1.0; | |
4037 d3dvp2.dvMinZ = 0.0; | |
4038 goto LABEL_54; | |
4039 } | |
4040 LABEL_51: | |
4041 sprintf(pErrorMessage, "Init - Failed to create D3D device.\n"); | |
4042 if (pDirect3D) | |
4043 { | |
4044 pDirect3D->Release(); | |
4045 pDirect3D = 0; | |
4046 } | |
4047 goto LABEL_59; | |
4048 } | |
4049 LABEL_48: | |
4050 sprintf(pErrorMessage, "Init - Failed to attach z-buffer to back buffer.\n"); | |
4051 if (pZBuffer) | |
4052 { | |
4053 pZBuffer->Release(); | |
4054 pZBuffer = 0; | |
4055 } | |
4056 goto LABEL_61; | |
4057 } | |
4058 goto LABEL_44; | |
4059 } | |
4060 LABEL_36: | |
4061 v23 = "Init - Failed to create front buffer.\n"; | |
4062 sprintf(pErrorMessage, v23); | |
4063 goto LABEL_65; | |
4064 } | |
4065 if ( uDeviceID == 1 ) | |
4066 v26 = 1045; | |
4067 else | |
4068 v26 = 1041; | |
4069 if (pHost->SetCooperativeLevel(hWnd, v26) ) | |
4070 { | |
4071 v23 = "Init - Failed to set cooperative level.\n"; | |
4072 sprintf(pErrorMessage, v23); | |
4073 goto LABEL_65; | |
4074 } | |
4075 if (pHost->SetDisplayMode(640u, 480u, 16u, 0, 0) ) | |
4076 { | |
4077 v23 = "Init - Failed to set display mode.\n"; | |
4078 sprintf(pErrorMessage, v23); | |
4079 goto LABEL_65; | |
4080 } | |
4081 | |
4082 memset(&ddsd2, 0, sizeof(DDSURFACEDESC2)); | |
4083 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | |
4084 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
4085 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | |
4086 ddsd2.dwBackBufferCount = 1; | |
4087 if ( pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | |
4088 goto LABEL_36; | |
4089 //a3a = &pBackBuffer; | |
4090 //v14 = *v34; | |
4091 memset(&v27, 0, sizeof(DDSCAPS2)); | |
4092 v27.dwCaps = DDSCAPS_BACKBUFFER; | |
4093 //v33 = (IDirect3DDevice3 **)v14->GetAttachedSurface(&v27, &pBackBuffer); | |
4094 //hWnda = &pDirect3D; | |
4095 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | |
4096 if (FAILED(pFrontBuffer->GetAttachedSurface(&v27, &pBackBuffer))) | |
4097 { | |
4098 v25 = "Init - Failed to get D3D interface.\n"; | |
4099 goto LABEL_45; | |
4100 } | |
4101 | |
4102 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4103 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | |
4104 ddsd2.dwWidth = 640; | |
4105 ddsd2.dwHeight = 480; | |
4106 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | |
4107 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | |
4108 &ddsd2.ddpfPixelFormat) ) | |
4109 { | |
4110 LABEL_21: | |
4111 v25 = "Init - Failed to enumerate Z buffer formats.\n"; | |
4112 goto LABEL_45; | |
4113 } | |
4114 if ( uDeviceID == 2 || uDeviceID == 3 ) | |
4115 BYTE1(ddsd2.ddsCaps.dwCaps) |= 8u; | |
4116 //uDeviceIDa = &pZBuffer; | |
4117 if (pHost->CreateSurface(&ddsd2, &pZBuffer, 0) ) | |
4118 { | |
4119 LABEL_44: | |
4120 v25 = "Init - Failed to create z-buffer.\n"; | |
4121 LABEL_45: | |
4122 sprintf(pErrorMessage, v25); | |
4123 if (pBackBuffer) | |
4124 { | |
4125 pBackBuffer->Release(); | |
4126 pBackBuffer = 0; | |
4127 } | |
4128 LABEL_63: | |
4129 //v19 = &pFrontBuffer; | |
4130 if (pFrontBuffer) | |
4131 { | |
4132 pFrontBuffer->Release(); | |
4133 pFrontBuffer= 0; | |
4134 } | |
4135 goto LABEL_65; | |
4136 } | |
4137 if (pBackBuffer->AddAttachedSurface(pZBuffer)) | |
4138 goto LABEL_48; | |
4139 //v33 = &pDevice; | |
4140 if (pDirect3D->CreateDevice(*pAvailableDevices[uDeviceID].pGUID, | |
4141 pBackBuffer, | |
4142 &pDevice, | |
4143 0) ) | |
4144 goto LABEL_51; | |
4145 memset(&d3dvp2, 0, sizeof(D3DVIEWPORT2)); | |
4146 d3dvp2.dvClipWidth = 2.0; | |
4147 d3dvp2.dvClipY = 1.0; | |
4148 d3dvp2.dvClipHeight = 2.0; | |
4149 d3dvp2.dvMaxZ = 1.0; | |
4150 | |
4151 LABEL_54: | |
4152 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | |
4153 //v17 = *hWnda; | |
4154 d3dvp2.dwWidth = 640; | |
4155 d3dvp2.dwHeight = 480; | |
4156 d3dvp2.dvClipX = -1.0; | |
4157 //v18 = v17->lpVtbl; | |
4158 //v32 = &v4->pViewport; | |
4159 if (pDirect3D->CreateViewport(&pViewport, 0)) | |
4160 { | |
4161 sprintf(pErrorMessage, "Init - Failed to create viewport.\n"); | |
4162 if (pDevice) | |
4163 { | |
4164 pDevice->Release(); | |
4165 pDevice = 0; | |
4166 } | |
4167 if (pDirect3D) | |
4168 { | |
4169 pDirect3D->Release(); | |
4170 pDirect3D = 0; | |
4171 } | |
4172 LABEL_59: | |
4173 if (pZBuffer) | |
4174 { | |
4175 pZBuffer->Release(); | |
4176 pZBuffer = 0; | |
4177 } | |
4178 LABEL_61: | |
4179 if (pBackBuffer) | |
4180 { | |
4181 pBackBuffer->Release(); | |
4182 pBackBuffer = 0; | |
4183 } | |
4184 goto LABEL_63; | |
4185 } | |
4186 | |
4187 pDevice->AddViewport(pViewport); | |
4188 pViewport->SetViewport2(&d3dvp2); | |
4189 pDevice->SetCurrentViewport(pViewport); | |
4190 return 1; | |
4191 } | |
4192 | |
4193 //----- (0049E444) -------------------------------------------------------- | |
4194 unsigned int RenderD3D::GetDeviceCaps() | |
4195 { | |
4196 unsigned int v1; // ebx@1 | |
4197 RenderD3D *v2; // edi@1 | |
4198 IDirect3DDevice3 *v3; // eax@1 | |
4199 unsigned int result; // eax@2 | |
4200 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-1F8h]@1 | |
4201 D3DDEVICEDESC halCaps; // [sp+108h] [bp-FCh]@1 | |
4202 | |
4203 v1 = 0; | |
4204 v2 = this; | |
4205 memset(&halCaps, 0, 0xFCu); | |
4206 halCaps.dwSize = 252; | |
4207 memset(&refCaps, 0, 0xFCu); | |
4208 v3 = v2->pDevice; | |
4209 refCaps.dwSize = 252; | |
4210 if ( v3->GetCaps(&halCaps, &refCaps) ) | |
4211 { | |
4212 result = 1; | |
4213 } | |
4214 else | |
4215 { | |
4216 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 0x10) ) | |
4217 v1 = 2; | |
4218 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 2) ) | |
4219 v1 |= 4u; | |
4220 if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 1) ) | |
4221 v1 |= 8u; | |
4222 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 0x20) ) | |
4223 v1 |= 0x10u; | |
4224 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 2) ) | |
4225 v1 |= 0x20u; | |
4226 if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 4) ) | |
4227 v1 |= 0x40u; | |
4228 if ( halCaps.dpcTriCaps.dwTextureCaps & 0x20 ) | |
4229 LOBYTE(v1) = v1 | 0x80; | |
4230 result = v1; | |
4231 } | |
4232 return result; | |
4233 } | |
4234 | |
4235 //----- (0049E4FC) -------------------------------------------------------- | |
4236 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | |
4237 { | |
4238 uint uClearFlags = 0; | |
4239 | |
4240 if (bClearColor) | |
4241 uClearFlags |= D3DCLEAR_TARGET; | |
4242 if (bClearDepth) | |
4243 uClearFlags |= D3DCLEAR_ZBUFFER; | |
4244 | |
4245 D3DRECT rects[] = {{0, 0, 640, 480}}; | |
4246 if (uClearFlags) | |
4247 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); | |
4248 } | |
4249 | |
4250 //----- (0049E54D) -------------------------------------------------------- | |
4251 void RenderD3D::Present(bool bForceBlit) | |
4252 { | |
4253 RECT v5; // [sp+18h] [bp-18h]@1 | |
4254 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | |
4255 | |
4256 v5.left = 0; | |
4257 v5.top = 0; | |
4258 v5.bottom = 480; | |
4259 v5.right = 640; | |
4260 | |
4261 if (bWindowed || bForceBlit) | |
4262 { | |
4263 RECT rc; | |
4264 GetClientRect(hWindow, &rc); | |
4265 Point.y = 0; | |
4266 Point.x = 0; | |
4267 ClientToScreen(hWindow, &Point); | |
4268 OffsetRect(&rc, Point.x, Point.y); | |
4269 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); | |
4270 } | |
4271 else | |
4272 pFrontBuffer->Flip(0, 1); | |
4273 } | |
4274 | |
4275 //----- (0049E5D4) -------------------------------------------------------- | |
4276 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | |
4277 { | |
4278 unsigned int v8; // edx@4 | |
4279 unsigned int v9; // ebx@5 | |
4280 unsigned int v10; // eax@5 | |
4281 DWORD v11; // edx@5 | |
4282 //int v12; // edx@7 | |
4283 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 | |
4284 //RenderD3D *v15; // [sp+88h] [bp-4h]@1 | |
4285 | |
4286 //v15 = this; | |
4287 memset(&ddsd2, 0, 0x7Cu); | |
4288 ddsd2.dwSize = 0x7Cu; | |
4289 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | |
4290 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; | |
4291 ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; | |
4292 ddsd2.dwHeight = uTextureHeight; | |
4293 ddsd2.dwWidth = uTextureWidth; | |
4294 if ( bMipmaps ) | |
4295 { | |
4296 if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) | |
4297 { | |
4298 v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); | |
4299 LABEL_8: | |
4300 ddsd2.dwMipMapCount = v8; | |
4301 if ( !v8 ) | |
4302 goto LABEL_12; | |
4303 goto LABEL_11; | |
4304 } | |
4305 if ( (signed int)uTextureWidth < (signed int)uMinDeviceTexDim ) | |
4306 { | |
4307 v8 = GetMaxMipLevels(uMinDeviceTexDim); | |
4308 goto LABEL_8; | |
4309 } | |
4310 v9 = GetMaxMipLevels(uTextureWidth); | |
4311 v10 = GetMaxMipLevels(uMinDeviceTexDim); | |
4312 ddsd2.dwMipMapCount = v9 - v10; | |
4313 if ( v9 == v10 ) | |
4314 { | |
4315 ddsd2.dwFlags = 0x1007u; | |
4316 ddsd2.ddsCaps.dwCaps = v11; | |
4317 goto LABEL_12; | |
4318 } | |
4319 } | |
4320 else | |
4321 { | |
4322 ddsd2.dwMipMapCount = 1; | |
4323 } | |
4324 LABEL_11: | |
4325 ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; | |
4326 ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; | |
4327 LABEL_12: | |
4328 ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; | |
4329 ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); | |
4330 if (bAlphaChannel) | |
4331 { | |
4332 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; | |
4333 ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; | |
4334 ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; | |
4335 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
4336 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; | |
4337 } | |
4338 else | |
4339 { | |
4340 ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; | |
4341 ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; | |
4342 ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; | |
4343 ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; | |
4344 ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; | |
4345 } | |
4346 if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) | |
4347 return false; | |
4348 if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) | |
4349 { | |
4350 (*pOutSurface)->Release(); | |
4351 *pOutSurface = 0; | |
4352 return false; | |
4353 } | |
4354 return true; | |
4355 } | |
4356 | |
4357 //----- (004A5190) -------------------------------------------------------- | |
4358 void RenderD3D::HandleLostResources() | |
4359 { | |
4360 pBitmaps_LOD->ReleaseLostHardwareTextures(); | |
4361 pBitmaps_LOD->_410423_move_textures_to_device(); | |
4362 pSprites_LOD->ReleaseLostHardwareSprites(); | |
4363 } | |
4364 | |
4365 //----- (004A2050) -------------------------------------------------------- | |
4366 void Render::DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) | |
4367 { | |
4368 Render *v5; // edi@1 | |
4369 unsigned int v6; // ebx@1 | |
4370 LightmapBuilder *v7; // esi@3 | |
4371 int v8; // eax@7 | |
4372 ODMFace *v9; // eax@12 | |
4373 char *v10; // esi@12 | |
4374 double v11; // st7@14 | |
4375 double v12; // st7@14 | |
4376 int v13; // eax@14 | |
4377 ODMFace *v14; // ecx@14 | |
4378 double v15; // st7@14 | |
4379 float v16; // ST48_4@15 | |
4380 int v17; // eax@15 | |
4381 char v18; // zf@17 | |
4382 HRESULT v19; // eax@18 | |
4383 HRESULT v20; // eax@18 | |
4384 HRESULT v21; // eax@20 | |
4385 HRESULT v22; // eax@20 | |
4386 unsigned int v23; // ecx@20 | |
4387 char *v24; // eax@21 | |
4388 HRESULT v25; // eax@23 | |
4389 HRESULT v26; // eax@23 | |
4390 HRESULT v27; // eax@24 | |
4391 HRESULT v28; // eax@25 | |
4392 HRESULT v29; // eax@25 | |
4393 HRESULT v30; // eax@25 | |
4394 HRESULT v31; // eax@25 | |
4395 HRESULT v32; // eax@26 | |
4396 unsigned int v33; // ecx@26 | |
4397 char *v34; // eax@27 | |
4398 int v35; // edx@28 | |
4399 HRESULT v36; // eax@29 | |
4400 HRESULT v37; // eax@29 | |
4401 HRESULT v38; // eax@29 | |
4402 HRESULT v39; // eax@29 | |
4403 //IDirect3DDevice3Vtbl *v40; // ebx@29 | |
4404 unsigned int v41; // eax@29 | |
4405 HRESULT v42; // eax@30 | |
4406 HRESULT v43; // eax@30 | |
4407 HRESULT v44; // eax@30 | |
4408 char *v45; // esi@34 | |
4409 int v46; // ecx@35 | |
4410 double v47; // st6@35 | |
4411 int v48; // eax@36 | |
4412 const char *v49; // [sp+4Ch] [bp-1Ch]@0 | |
4413 const char *v50; // [sp+4Ch] [bp-1Ch]@20 | |
4414 int v51; // [sp+50h] [bp-18h]@0 | |
4415 unsigned int v52; // [sp+54h] [bp-14h]@0 | |
4416 LightmapBuilder *v53; // [sp+58h] [bp-10h]@3 | |
4417 unsigned int v54; // [sp+5Ch] [bp-Ch]@3 | |
4418 unsigned int v55; // [sp+5Ch] [bp-Ch]@34 | |
4419 unsigned int v56; // [sp+60h] [bp-8h]@12 | |
4420 int v57; // [sp+60h] [bp-8h]@34 | |
638 | 4421 unsigned int a2; // [sp+64h] [bp-4h]@4 |
0 | 4422 |
4423 v5 = this; | |
4424 v6 = 0; | |
4425 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | |
4426 { | |
4427 v7 = pGame->pLightmapBuilder; | |
4428 v53 = v7; | |
4429 v54 = v7->std__vector_000004_size; | |
4430 if ( v7->std__vector_000004_size) | |
638 | 4431 a2 = 0xFFFFFFFF; |
4432 pGame->AlterGamma_ODM(a4, &a2); | |
0 | 4433 if ( byte_4D864C && pGame->uFlags & 1 ) |
4434 { | |
638 | 4435 v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
0 | 4436 v7->_45D74F_MessWithLight(v8, 0); |
4437 } | |
4438 else | |
4439 { | |
4440 if ( !v54 || byte_4D864C && pGame->uFlags & 2 ) | |
4441 { | |
323 | 4442 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4443 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
4444 if (bUsingSpecular) | |
4445 { | |
186 | 4446 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
4447 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
4448 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4449 } |
4450 if ( (signed int)uNumVertices > 0 ) | |
4451 { | |
4452 v45 = (char *)&array_50AC10[0].vWorldViewPosition; | |
186 | 4453 v57 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 4454 v55 = uNumVertices; |
4455 do | |
4456 { | |
638 | 4457 a2 = ::GetActorTintColor(a3->dimming_level, 0, *(float *)v45, 0, 0); |
4458 pGame->AlterGamma_ODM(a4, &a2); | |
0 | 4459 v46 = v57; |
4460 v47 = *(float *)v45 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
4461 *(int *)(v57 - 4) = *((int *)v45 + 3); | |
4462 *(int *)v57 = *((int *)v45 + 4); | |
4463 *(int *)(v57 + 12) = a2; | |
4464 *(float *)(v57 + 4) = 1.0 - 1.0 / v47; | |
4465 *(float *)(v57 + 8) = 1.0 / (*(float *)v45 + 0.0000001); | |
4466 if ( v5->bUsingSpecular ) | |
4467 { | |
4468 v48 = sub_47C3D7_get_fog_related_stuff(0, 0, *(float *)v45); | |
4469 v46 = v57; | |
4470 } | |
4471 else | |
4472 { | |
4473 v48 = 0; | |
4474 } | |
4475 *(int *)(v46 + 16) = v48; | |
4476 *(int *)(v46 + 20) = *((int *)v45 + 6); | |
4477 *(int *)(v46 + 24) = *((int *)v45 + 7); | |
4478 v45 += 48; | |
4479 v18 = v55-- == 1; | |
4480 v57 = v46 + 32; | |
4481 } | |
4482 while ( !v18 ); | |
4483 } | |
323 | 4484 |
4485 if (a4->uAttributes & FACE_OUTLINED) | |
4486 { | |
4487 int color; | |
4488 if (GetTickCount() % 300 >= 150) | |
4489 color = 0xFFFF2020; | |
4490 else color = 0xFF901010; | |
4491 | |
4492 for (uint i = 0; i < uNumVertices; ++i) | |
4493 d3d_vertex_buffer[i].diffuse = color; | |
4494 } | |
4495 | |
0 | 4496 pRenderD3D->pDevice->SetTexture(0, pTexture); |
4497 pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4498 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 4499 d3d_vertex_buffer, |
0 | 4500 uNumVertices, |
4501 D3DDP_DONOTLIGHT); | |
4502 } | |
4503 else | |
4504 { | |
4505 if ( (signed int)uNumVertices > 0 ) | |
4506 { | |
186 | 4507 v9 = (ODMFace *)&d3d_vertex_buffer[0].pos.y; |
0 | 4508 v10 = (char *)&array_50AC10[0].vWorldViewPosition; |
186 | 4509 a4 = (ODMFace *)&d3d_vertex_buffer[0].pos.y; |
0 | 4510 v56 = uNumVertices; |
4511 while ( 1 ) | |
4512 { | |
4513 v11 = *(float *)v10 * 1000.0; | |
4514 *((int *)v9 - 1) = *((int *)v10 + 3); | |
4515 v12 = v11 / (double)pOutdoorCamera->shading_dist_mist; | |
4516 v9->pFacePlane.vNormal.x = *((int *)v10 + 4); | |
4517 *(float *)&v9->pFacePlane.vNormal.y = 1.0 - 1.0 / v12; | |
4518 *(float *)&v9->pFacePlane.vNormal.z = 1.0 / (*(float *)v10 + 0.0000001); | |
638 | 4519 v13 = GetActorTintColor(a3->dimming_level, 0, *(float *)v10, 0, 0); |
0 | 4520 v14 = a4; |
4521 v15 = *(float *)v10; | |
4522 a4->pFacePlane.dist = v13; | |
4523 if ( v5->bUsingSpecular ) | |
4524 { | |
4525 v16 = v15; | |
4526 v17 = sub_47C3D7_get_fog_related_stuff(0, 0, v16); | |
4527 v14 = a4; | |
4528 } | |
4529 else | |
4530 { | |
4531 v17 = 0; | |
4532 } | |
4533 v14->zCalc1 = v17; | |
4534 v14->zCalc2 = *((int *)v10 + 6); | |
4535 v14->zCalc3 = *((int *)v10 + 7); | |
4536 v10 += 48; | |
4537 v18 = v56-- == 1; | |
4538 a4 = (ODMFace *)((char *)v14 + 32); | |
4539 if ( v18 ) | |
4540 break; | |
4541 v9 = a4; | |
4542 } | |
4543 } | |
186 | 4544 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
4545 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 4546 if (bUsingSpecular) |
186 | 4547 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
0 | 4548 |
4549 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
4550 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
4551 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4552 d3d_vertex_buffer, |
0 | 4553 uNumVertices, |
4554 D3DDP_DONOTLIGHT)); | |
4555 //v50 = (const char *)v5->pRenderD3D->pDevice; | |
4556 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
4557 //(*(void (**)(void))(*(int *)v50 + 88))(); | |
4558 v53->_45D74F_MessWithLight(-1, 0); | |
4559 v23 = uNumVertices; | |
4560 if ( (signed int)uNumVertices > 0 ) | |
4561 { | |
186 | 4562 v24 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 4563 do |
4564 { | |
4565 *(int *)v24 = a2; | |
4566 v24 += 32; | |
4567 --v23; | |
4568 } | |
4569 while ( v23 ); | |
4570 } | |
4571 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); | |
186 | 4572 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 4573 if ( !pRenderer->bUsingSpecular ) |
186 | 4574 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
4575 | |
4576 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
4577 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
4578 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
0 | 4579 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
4580 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4581 d3d_vertex_buffer, |
0 | 4582 uNumVertices, |
4583 D3DDP_DONOTLIGHT)); | |
4584 if (bUsingSpecular) | |
4585 { | |
186 | 4586 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 4587 |
4588 v33 = uNumVertices; | |
4589 if ( (signed int)uNumVertices > 0 ) | |
4590 { | |
186 | 4591 v34 = (char *)&d3d_vertex_buffer[0].specular; |
0 | 4592 do |
4593 { | |
4594 v35 = *(int *)v34; | |
4595 *(int *)v34 = 0; | |
4596 v34 += 32; | |
4597 --v33; | |
4598 *((int *)v34 - 9) = pRenderer->uFogColor | v35 & 0xFF000000; | |
4599 } | |
4600 while ( v33 ); | |
4601 } | |
4602 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
186 | 4603 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
4604 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
0 | 4605 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
4606 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, | |
186 | 4607 d3d_vertex_buffer, |
0 | 4608 uNumVertices, |
4609 D3DDP_DONOTLIGHT)); | |
186 | 4610 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 4611 //v40 = pRenderer->pRenderD3D->pDevice->lpVtbl; |
4612 v41 = GetLevelFogColor(); | |
4613 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF); | |
4614 v6 = 0; | |
4615 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
4616 } | |
186 | 4617 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
4618 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 4619 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v6)); |
4620 } | |
4621 } | |
4622 } | |
4623 } | |
4624 // 4D864C: using guessed type char byte_4D864C; | |
4625 | |
4626 //----- (0049EB79) -------------------------------------------------------- | |
4627 Render::~Render() | |
4628 { | |
4629 Render *v1; // esi@1 | |
4630 | |
4631 v1 = this; | |
4632 pAllocator->FreeChunk(this->pDefaultZBuffer); | |
4633 v1->pD3DBitmaps.Release(); | |
4634 v1->pD3DSprites.Release(); | |
4635 Release(); | |
4636 v1->bWindowMode = 1; | |
4637 //nullsub_1(); | |
4638 //nullsub_1(); | |
4639 } | |
4640 | |
4641 //----- (0049E756) -------------------------------------------------------- | |
4642 bool Render::IsColorKeySupported(IDirectDraw4 *this_) | |
4643 { | |
4644 DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1 | |
4645 DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1 | |
4646 | |
4647 halCaps.dwSize = 380; | |
4648 refCaps.dwSize = 380; | |
4649 this_->GetCaps(&halCaps, &refCaps); | |
4650 return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2; | |
4651 } | |
4652 | |
4653 //----- (0049E992) -------------------------------------------------------- | |
4654 Render::Render() | |
4655 { | |
4656 Render *v1; // esi@1 | |
4657 int v2; // eax@1 | |
4658 char v3; // zf@1 | |
4659 | |
4660 v1 = this; | |
4661 this->pDirectDraw4 = 0; | |
4662 this->pFrontBuffer4 = 0; | |
4663 this->pBackBuffer4 = 0; | |
4664 this->pColorKeySurface4 = 0; | |
4665 this->pDirectDraw2 = 0; | |
4666 this->pFrontBuffer2 = 0; | |
4667 this->pBackBuffer2 = 0; | |
4668 this->pSomeSurface2 = 0; | |
4669 //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps); | |
4670 //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites); | |
4671 v1->bWindowMode = 1; | |
4672 v1->field_40054 = 0; | |
4673 v1->field_10 = 640; | |
4674 v1->field_14 = 480; | |
4675 v1->field_40030 = 0; | |
4676 v1->field_4002C = 0; | |
4677 v1->pActiveZBuffer = 0; | |
4678 v1->pDefaultZBuffer = 0; | |
709 | 4679 v1->raster_clip_y = 0; |
4680 v1->raster_clip_x = 0; | |
4681 v1->raster_clip_z = 639; | |
4682 v1->raster_clip_w = 479; | |
0 | 4683 v1->field_4003C = (int)&unk_4EED80; |
4684 v1->field_40040 = dword_4EED78; | |
4685 v1->uClipZ = 640; | |
4686 v1->field_40044 = 2; | |
4687 v1->field_40048 = 6; | |
4688 v1->pFrontBuffer4 = 0; | |
4689 v1->pBackBuffer4 = 0; | |
4690 v1->pColorKeySurface4 = 0; | |
4691 v1->pDirectDraw4 = 0; | |
4692 v1->pRenderD3D = 0; | |
4693 v1->uNumSceneBegins = 0; | |
4694 v1->uNumD3DSceneBegins = 0; | |
4695 v1->field_40110 = 0; | |
4696 v1->pTargetSurface = 0; | |
4697 v1->uTargetSurfacePitch = 0; | |
4698 v1->uClipY = 0; | |
4699 v1->uClipX = 0; | |
4700 v1->uClipW = 480; | |
4701 v1->bClip = 1; | |
4702 v1->bColorKeySupported = 0; | |
4703 v1->bRequiredTextureStagesAvailable = 0; | |
4704 v1->bTinting = 1; | |
4705 LOBYTE(v1->field_103668) = 0; | |
4706 v1->field_1036B8 = 0; | |
4707 v1->_gpu_memory_used = 0; | |
4708 uNumBillboardsToDraw = 0; | |
4709 bFogEnabled = false; | |
265 | 4710 |
4711 hd_water_tile_id = -1; | |
4712 hd_water_current_frame = 0; | |
0 | 4713 } |
4714 | |
781 | 4715 bool Render::Initialize(bool bWindowed, uint uDefaultDevice, bool bColoredLights, uint uDetailLevel, uint bTinting) |
0 | 4716 { |
4717 bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | |
4718 bStartInWindow = bWindowed; | |
4719 | |
4720 uDesiredDirect3DDevice = uDefaultDevice;//ReadWindowsRegistryInt("D3D Device", 1); | |
4721 | |
4722 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | |
4723 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | |
4724 | |
4725 this->bTinting = bTinting; | |
4726 | |
4727 auto r1 = pD3DBitmaps.Load(L"data\\d3dbitmap.hwl"); | |
4728 auto r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | |
4729 | |
4730 return r1 && r2; | |
4731 } | |
4732 | |
4733 //----- (0049EBF1) -------------------------------------------------------- | |
4734 void Render::_49EBF1() | |
4735 { | |
4736 signed int uNumRedBits; // edx@1 | |
4737 signed int uNuGreenBits; // edi@1 | |
4738 signed int uNumBlueBits; // esi@1 | |
4739 unsigned int v4; // edx@4 | |
4740 unsigned int v5; // edi@4 | |
4741 int v6; // ebx@4 | |
4742 int v7; // edx@4 | |
4743 signed int v8; // [sp+8h] [bp-24h]@1 | |
4744 signed int v9; // [sp+Ch] [bp-20h]@1 | |
4745 signed int v10; // [sp+20h] [bp-Ch]@1 | |
4746 signed int i; // [sp+24h] [bp-8h]@2 | |
4747 signed int v12; // [sp+28h] [bp-4h]@3 | |
4748 | |
4749 v10 = 0; | |
4750 uNumRedBits = 1 << this->uTargetRBits; | |
4751 uNuGreenBits = 1 << this->uTargetGBits; | |
4752 uNumBlueBits = 1 << this->uTargetBBits; | |
4753 v9 = 1 << this->uTargetRBits; | |
4754 v8 = 1 << this->uTargetGBits; | |
4755 if ( uNumRedBits > 0 ) | |
4756 { | |
4757 do | |
4758 { | |
4759 for ( i = 0; i < uNuGreenBits; ++i ) | |
4760 { | |
4761 v12 = 0; | |
4762 if ( uNumBlueBits > 0 ) | |
4763 { | |
4764 do | |
4765 { | |
4766 v4 = this->uTargetBBits; | |
4767 v5 = v4 + this->uTargetGBits; | |
4768 v6 = (v12 >> 1) + (v10 >> 1 << v5) + (i >> 1 << this->uTargetBBits); | |
4769 v7 = (v10 << v5) + v12++ + (i << v4); | |
4770 this->field_2C[v7] = v6; | |
4771 } | |
4772 while ( v12 < uNumBlueBits ); | |
4773 uNumRedBits = v9; | |
4774 uNuGreenBits = v8; | |
4775 } | |
4776 } | |
4777 ++v10; | |
4778 } | |
4779 while ( v10 < uNumRedBits ); | |
4780 } | |
4781 } | |
4782 | |
4783 //----- (0049ECC4) -------------------------------------------------------- | |
4784 void Render::ClearBlack() | |
4785 { | |
4786 if (pRenderD3D) | |
4787 { | |
4788 if (field_40110) | |
4789 pRenderD3D->ClearTarget(true, 0, false, 0.0); | |
4790 } | |
4791 else | |
4792 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | |
4793 } | |
4794 | |
4795 //----- (0049ED18) -------------------------------------------------------- | |
4796 void Render::PresentBlackScreen() | |
4797 { | |
4798 LONG w; // edx@3 | |
4799 IDirectDrawSurface *v2; // eax@3 | |
4800 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | |
4801 RECT x; // [sp+68h] [bp-10h]@3 | |
4802 | |
4803 memset(&v3, 0, sizeof(DDBLTFX)); | |
4804 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
4805 pVersion->pVersionInfo.dwMajorVersion >= 5) | |
4806 { | |
4807 x.left = uWindowX; | |
4808 x.right = uWindowX + uWindowHeight; | |
4809 x.top = uWindowY; | |
4810 w = uWindowY + uWindowWidth; | |
4811 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | |
4812 } | |
4813 else | |
4814 { | |
4815 x.left = uWindowX; | |
4816 x.right = uWindowX + uWindowHeight; | |
4817 x.top = uWindowY; | |
4818 w = uWindowY + uWindowWidth; | |
4819 v2 = (IDirectDrawSurface *)this->pBackBuffer2; | |
4820 } | |
4821 x.bottom = w; | |
4822 v3.dwFillColor = 0; | |
4823 v3.dwSize = 100; | |
4824 v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3); | |
4825 pRenderer->Present(); | |
4826 } | |
4827 | |
4828 //----- (0049EDB6) -------------------------------------------------------- | |
4829 void Render::SavePCXScreenshot() | |
4830 { | |
4831 Render *v1; // esi@1 | |
4832 __int16 v2; // di@1 | |
4833 int v3; // eax@4 | |
4834 int v4; // ecx@4 | |
4835 int v5; // eax@8 | |
4836 FILE *v6; // edi@10 | |
4837 int v7; // ecx@11 | |
4838 int v8; // eax@11 | |
4839 int v9; // eax@13 | |
4840 int v10; // ecx@15 | |
4841 unsigned __int8 v11; // dl@15 | |
4842 signed int v12; // eax@18 | |
4843 char v13; // zf@27 | |
4844 HRESULT v14; // eax@29 | |
4845 char v15[56]; // [sp+Ch] [bp-158h]@10 | |
4846 __int16 v16; // [sp+44h] [bp-120h]@10 | |
4847 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 | |
4848 char color_map[48]; // [sp+C4h] [bp-A0h]@10 | |
4849 char Filename[40]; // [sp+F4h] [bp-70h]@3 | |
4850 char *v20; // [sp+11Ch] [bp-48h]@14 | |
4851 char *v21; // [sp+120h] [bp-44h]@14 | |
4852 int v24; // [sp+124h] [bp-40h]@11 | |
4853 FILE *File; // [sp+128h] [bp-3Ch]@3 | |
4854 int var38; // [sp+12Ch] [bp-38h]@4 | |
4855 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 | |
4856 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 | |
4857 void *ptr; // [sp+148h] [bp-1Ch]@10 | |
4858 void *v28; // [sp+14Ch] [bp-18h]@8 | |
4859 int v29; // [sp+150h] [bp-14h]@4 | |
4860 int v30; // [sp+154h] [bp-10h]@4 | |
4861 char v31; // [sp+15Ah] [bp-Ah]@25 | |
4862 unsigned __int8 v32; // [sp+15Bh] [bp-9h]@17 | |
4863 int i; // [sp+15Ch] [bp-8h]@10 | |
4864 unsigned __int8 v34; // [sp+163h] [bp-1h]@17 | |
4865 | |
4866 v1 = this; | |
4867 v2 = 0; | |
4868 if ( !this->pRenderD3D || this->field_40110 ) | |
4869 { | |
4870 sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100); | |
4871 File = fopen(Filename, "wb"); | |
4872 if ( File ) | |
4873 { | |
4874 v3 = v1->field_10; | |
4875 v4 = v1->field_14; | |
4876 var38 = v3; | |
4877 v29 = v4; | |
4878 v30 = v3; | |
4879 if ( v3 & 1 ) | |
4880 v30 = v3 + 1; | |
4881 if ( v1->pRenderD3D ) | |
4882 { | |
4883 memset(&Dst, 0, 0x7Cu); | |
4884 Dst.dwSize = 124; | |
168 | 4885 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
0 | 4886 return; |
4887 v28 = Dst.lpSurface; | |
4888 v5 = Dst.lPitch >> 1; | |
4889 v2 = 0; | |
4890 } | |
4891 else | |
4892 { | |
4893 pRenderer->BeginScene(); | |
4894 v28 = pRenderer->pTargetSurface; | |
4895 v5 = pRenderer->uTargetSurfacePitch; | |
4896 } | |
4897 i = v5; | |
4898 header1.right = var38 - 1; | |
4899 header1.left = v2; | |
4900 header1.bottom = v29 - 1; | |
4901 header1.up = v2; | |
4902 header2.pitch = v30; | |
4903 memset(color_map, 0, sizeof(color_map)); | |
4904 memset(v15, 0, sizeof(v15)); | |
4905 header2.reserved = 0; | |
4906 header1.manufacturer = 10; | |
4907 v16 = 0; | |
4908 v6 = File; | |
4909 header1.version = 5; | |
4910 header1.encoding = 1; | |
4911 header1.bpp = 8; | |
4912 header1.hdpi = 75; | |
4913 header1.vdpi = 75; | |
4914 header2.planes = 3; | |
4915 header2.palette_info = 1; | |
4916 fwrite(&header1, 1u, 1u, File); | |
4917 fwrite(&header1.version, 1u, 1u, v6); | |
4918 fwrite(&header1.encoding, 1u, 1u, v6); | |
4919 fwrite(&header1.bpp, 1u, 1u, v6); | |
4920 fwrite(&header1.left, 2u, 1u, v6); | |
4921 fwrite(&header1.up, 2u, 1u, v6); | |
4922 fwrite(&header1.right, 2u, 1u, v6); | |
4923 fwrite(&header1.bottom, 2u, 1u, v6); | |
4924 fwrite(&header1.hdpi, 2u, 1u, v6); | |
4925 fwrite(&header1.vdpi, 2u, 1u, v6); | |
4926 fwrite(color_map, 0x30u, 1u, v6); | |
4927 fwrite(&header2, 1u, 1u, v6); | |
4928 fwrite(&header2.planes, 1u, 1u, v6); | |
4929 fwrite(&header2.pitch, 2u, 1u, v6); | |
4930 fwrite(&header2.palette_info, 2u, 1u, v6); | |
4931 fwrite(v15, 0x3Au, 1u, v6); | |
4932 ptr = pAllocator->AllocNamedChunk(0, 3 * var38 + 6, 0); | |
4933 if ( v29 > 0 ) | |
4934 { | |
4935 v7 = v30; | |
4936 File = (FILE *)v29; | |
4937 v29 = 3 * v30; | |
4938 v24 = 2 * i; | |
4939 v8 = (int)v28; | |
4940 while ( 1 ) | |
4941 { | |
4942 i = v8; | |
4943 v9 = 0; | |
4944 if ( var38 > 0 ) | |
4945 { | |
4946 v21 = (char *)ptr + v7; | |
4947 v20 = (char *)ptr + 2 * v30; | |
4948 do | |
4949 { | |
4950 *((char *)ptr + v9) = (signed int)(v1->uTargetRMask & *(short *)i) >> (LOBYTE(v1->uTargetGBits) | |
4951 + LOBYTE(v1->uTargetBBits) | |
4952 + v1->uTargetRBits | |
4953 - 8); | |
4954 v21[v9] = (signed int)(v1->uTargetGMask & *(short *)i) >> (LOBYTE(v1->uTargetBBits) | |
4955 + LOBYTE(v1->uTargetGBits) | |
4956 - 8); | |
4957 v10 = i; | |
4958 v11 = LOBYTE(v1->uTargetBMask); | |
4959 i += 2; | |
4960 v20[v9++] = (*(char *)v10 & v11) << (8 - LOBYTE(v1->uTargetBBits)); | |
4961 } | |
4962 while ( v9 < var38 ); | |
4963 } | |
4964 for ( i = 0; i < v29; i += v34 ) | |
4965 { | |
4966 v34 = 1; | |
4967 v32 = *((char *)ptr + i); | |
4968 do | |
4969 { | |
4970 v12 = i + v34; | |
4971 if ( *((char *)ptr + v12) != v32 ) | |
4972 break; | |
4973 if ( !(v12 % v30) ) | |
4974 break; | |
4975 ++v34; | |
4976 } | |
4977 while ( v34 < 0x3Fu ); | |
4978 if ( i + v34 > v29 ) | |
4979 v34 = 3 * v30 - i; | |
4980 if ( v34 > 1u || v32 >= 0xC0u ) | |
4981 { | |
4982 v31 = v34 | 0xC0; | |
4983 fwrite(&v31, 1u, 1u, v6); | |
4984 } | |
4985 fwrite(&v32, 1u, 1u, v6); | |
4986 } | |
4987 v8 = (int)((char *)v28 + v24); | |
4988 v13 = File == (FILE *)1; | |
4989 File = (FILE *)((char *)File - 1); | |
4990 v28 = (char *)v28 + v24; | |
4991 if ( v13 ) | |
4992 break; | |
4993 v7 = v30; | |
4994 } | |
4995 } | |
4996 if ( v1->pRenderD3D ) | |
4997 { | |
4998 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
4999 } | |
5000 else | |
5001 { | |
5002 pRenderer->EndScene(); | |
5003 } | |
5004 | |
5005 pAllocator->FreeChunk(ptr); | |
5006 fclose(v6); | |
5007 } | |
5008 } | |
5009 } | |
5010 // 4EFA80: using guessed type int dword_4EFA80; | |
5011 | |
5012 //----- (0049F1BC) -------------------------------------------------------- | |
5013 void Render::_49F1BC(const char *a1) | |
5014 { | |
5015 Render *v2; // esi@1 | |
5016 __int16 v3; // di@1 | |
5017 int v4; // eax@4 | |
5018 char *v5; // ecx@4 | |
5019 unsigned int v6; // eax@8 | |
5020 FILE *v7; // edi@10 | |
5021 int v8; // ecx@11 | |
5022 int v9; // eax@11 | |
5023 int v10; // eax@13 | |
5024 const char *v11; // ecx@15 | |
5025 unsigned __int8 v12; // dl@15 | |
5026 signed int v13; // eax@18 | |
5027 char v14; // zf@27 | |
5028 HRESULT v15; // eax@29 | |
5029 char v16; // [sp+Ch] [bp-12Ch]@10 | |
5030 __int16 v17; // [sp+44h] [bp-F4h]@10 | |
5031 int Dst; // [sp+48h] [bp-F0h]@7 | |
5032 int v19; // [sp+58h] [bp-E0h]@8 | |
5033 unsigned __int16 *v20; // [sp+6Ch] [bp-CCh]@8 | |
5034 char v21; // [sp+C4h] [bp-74h]@10 | |
5035 unsigned int v22; // [sp+F4h] [bp-44h]@11 | |
5036 char *v23; // [sp+F8h] [bp-40h]@14 | |
5037 int v24; // [sp+FCh] [bp-3Ch]@11 | |
5038 int v25; // [sp+100h] [bp-38h]@4 | |
5039 FILE *File; // [sp+104h] [bp-34h]@3 | |
5040 char Str; // [sp+108h] [bp-30h]@10 | |
5041 char v28; // [sp+109h] [bp-2Fh]@10 | |
5042 char v29; // [sp+10Ah] [bp-2Eh]@10 | |
5043 char v30; // [sp+10Bh] [bp-2Dh]@10 | |
5044 __int16 v31; // [sp+10Ch] [bp-2Ch]@10 | |
5045 __int16 v32; // [sp+10Eh] [bp-2Ah]@10 | |
5046 __int16 v33; // [sp+110h] [bp-28h]@10 | |
5047 __int16 v34; // [sp+112h] [bp-26h]@10 | |
5048 __int16 v35; // [sp+114h] [bp-24h]@10 | |
5049 __int16 v36; // [sp+116h] [bp-22h]@10 | |
5050 char v37; // [sp+118h] [bp-20h]@10 | |
5051 char v38; // [sp+119h] [bp-1Fh]@10 | |
5052 __int16 v39; // [sp+11Ah] [bp-1Eh]@10 | |
5053 __int16 v40; // [sp+11Ch] [bp-1Ch]@10 | |
5054 void *ptr; // [sp+120h] [bp-18h]@10 | |
5055 unsigned __int16 *v42; // [sp+124h] [bp-14h]@8 | |
5056 int v43; // [sp+128h] [bp-10h]@4 | |
5057 char v44; // [sp+12Fh] [bp-9h]@25 | |
5058 char *i; // [sp+130h] [bp-8h]@10 | |
5059 unsigned __int8 v46; // [sp+137h] [bp-1h]@17 | |
5060 | |
5061 v2 = this; | |
5062 v3 = 0; | |
5063 if ( !this->pRenderD3D || this->field_40110 ) | |
5064 { | |
5065 ++dword_4EFA84; | |
5066 File = fopen(a1, "wb"); | |
5067 if ( File ) | |
5068 { | |
5069 v4 = v2->field_10; | |
5070 v5 = (char *)v2->field_14; | |
5071 v25 = v4; | |
5072 a1 = v5; | |
5073 v43 = v4; | |
5074 if ( v4 & 1 ) | |
5075 v43 = v4 + 1; | |
5076 if ( v2->pRenderD3D ) | |
5077 { | |
5078 memset(&Dst, 0, 0x7Cu); | |
5079 Dst = 124; | |
168 | 5080 if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) |
0 | 5081 return; |
5082 v42 = v20; | |
5083 v6 = v19 >> 1; | |
5084 v3 = 0; | |
5085 } | |
5086 else | |
5087 { | |
5088 pRenderer->BeginScene(); | |
5089 v42 = pRenderer->pTargetSurface; | |
5090 v6 = pRenderer->uTargetSurfacePitch; | |
5091 } | |
5092 i = (char *)v6; | |
5093 v33 = v25 - 1; | |
5094 v31 = v3; | |
5095 v34 = (short)a1 - 1; | |
5096 v32 = v3; | |
5097 v39 = v43; | |
5098 memset(&v21, 0, 0x30u); | |
5099 memset(&v16, 0, 0x38u); | |
5100 v37 = 0; | |
5101 Str = 10; | |
5102 v17 = 0; | |
5103 v7 = File; | |
5104 v28 = 5; | |
5105 v29 = 1; | |
5106 v30 = 8; | |
5107 v35 = 75; | |
5108 v36 = 75; | |
5109 v38 = 3; | |
5110 v40 = 1; | |
5111 fwrite(&Str, 1u, 1u, File); | |
5112 fwrite(&v28, 1u, 1u, v7); | |
5113 fwrite(&v29, 1u, 1u, v7); | |
5114 fwrite(&v30, 1u, 1u, v7); | |
5115 fwrite(&v31, 2u, 1u, v7); | |
5116 fwrite(&v32, 2u, 1u, v7); | |
5117 fwrite(&v33, 2u, 1u, v7); | |
5118 fwrite(&v34, 2u, 1u, v7); | |
5119 fwrite(&v35, 2u, 1u, v7); | |
5120 fwrite(&v36, 2u, 1u, v7); | |
5121 fwrite(&v21, 0x30u, 1u, v7); | |
5122 fwrite(&v37, 1u, 1u, v7); | |
5123 fwrite(&v38, 1u, 1u, v7); | |
5124 fwrite(&v39, 2u, 1u, v7); | |
5125 fwrite(&v40, 2u, 1u, v7); | |
5126 fwrite(&v16, 0x3Au, 1u, v7); | |
5127 ptr = pAllocator->AllocNamedChunk(0, 3 * v25 + 6, 0); | |
5128 if ( (signed int)a1 > 0 ) | |
5129 { | |
5130 v8 = v43; | |
5131 File = (FILE *)a1; | |
5132 v24 = 3 * v43; | |
5133 v22 = 2 * (int)i; | |
5134 v9 = (int)v42; | |
5135 while ( 1 ) | |
5136 { | |
5137 a1 = (const char *)v9; | |
5138 v10 = 0; | |
5139 if ( v25 > 0 ) | |
5140 { | |
5141 i = (char *)ptr + v8; | |
5142 v23 = (char *)ptr + 2 * v43; | |
5143 do | |
5144 { | |
5145 *((char *)ptr + v10) = (signed int)(v2->uTargetRMask & *(short *)a1) >> (LOBYTE(v2->uTargetGBits) | |
5146 + LOBYTE(v2->uTargetBBits) | |
5147 + v2->uTargetRBits | |
5148 - 8); | |
5149 i[v10] = (signed int)(v2->uTargetGMask & *(short *)a1) >> (LOBYTE(v2->uTargetBBits) | |
5150 + LOBYTE(v2->uTargetGBits) | |
5151 - 8); | |
5152 v11 = a1; | |
5153 v12 = LOBYTE(v2->uTargetBMask); | |
5154 a1 += 2; | |
5155 v23[v10++] = ((unsigned __int8)*v11 & v12) << (8 - LOBYTE(v2->uTargetBBits)); | |
5156 } | |
5157 while ( v10 < v25 ); | |
5158 } | |
5159 for ( i = 0; (signed int)i < v24; i += BYTE3(a1) ) | |
5160 { | |
5161 BYTE3(a1) = 1; | |
5162 v46 = *((char *)ptr + (int)i); | |
5163 do | |
5164 { | |
5165 v13 = (signed int)&i[BYTE3(a1)]; | |
5166 if ( *((char *)ptr + v13) != v46 ) | |
5167 break; | |
5168 if ( !(v13 % v43) ) | |
5169 break; | |
5170 ++BYTE3(a1); | |
5171 } | |
5172 while ( BYTE3(a1) < 0x3Fu ); | |
5173 if ( (signed int)&i[BYTE3(a1)] > v24 ) | |
5174 BYTE3(a1) = 3 * v43 - (char)i; | |
5175 if ( BYTE3(a1) > 1u || v46 >= 0xC0u ) | |
5176 { | |
5177 v44 = BYTE3(a1) | 0xC0; | |
5178 fwrite(&v44, 1u, 1u, v7); | |
5179 } | |
5180 fwrite(&v46, 1u, 1u, v7); | |
5181 } | |
5182 v9 = (int)&v42[v22 / 2]; | |
5183 v14 = File == (FILE *)1; | |
5184 File = (FILE *)((char *)File - 1); | |
5185 v42 = (unsigned __int16 *)((char *)v42 + v22); | |
5186 if ( v14 ) | |
5187 break; | |
5188 v8 = v43; | |
5189 } | |
5190 } | |
5191 if ( v2->pRenderD3D ) | |
5192 { | |
5193 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | |
5194 } | |
5195 else | |
5196 { | |
5197 pRenderer->EndScene(); | |
5198 } | |
5199 pAllocator->FreeChunk(ptr); | |
5200 fclose(v7); | |
5201 } | |
5202 } | |
5203 } | |
5204 // 4EFA84: using guessed type int dword_4EFA84; | |
5205 | |
5206 //----- (0049F5A2) -------------------------------------------------------- | |
810 | 5207 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) |
5208 { | |
0 | 5209 Render *v7; // ebx@1 |
5210 void *v8; // esi@3 | |
5211 void *v9; // esi@3 | |
5212 int v10; // ecx@4 | |
810 | 5213 unsigned short* v11; // eax@4 |
0 | 5214 int v12; // eax@6 |
5215 int v13; // eax@8 | |
5216 int v14; // ecx@8 | |
5217 signed int v15; // eax@11 | |
5218 char v16; // zf@20 | |
5219 int result; // eax@21 | |
5220 char v18[58]; // [sp+Ch] [bp-ACh]@3 | |
5221 // __int16 v19; // [sp+44h] [bp-74h]@3 | |
5222 char v20[48]; // [sp+48h] [bp-70h]@3 | |
810 | 5223 char *lineG; // [sp+78h] [bp-40h]@7 |
5224 char *lineB; // [sp+7Ch] [bp-3Ch]@7 | |
0 | 5225 int v23; // [sp+80h] [bp-38h]@4 |
5226 int v24; // [sp+84h] [bp-34h]@4 | |
5227 int v25; // [sp+88h] [bp-30h]@4 | |
5228 int v26; // [sp+8Ch] [bp-2Ch]@4 | |
810 | 5229 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 |
5230 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 | |
5231 char *lineRGB; // [sp+A8h] [bp-10h]@3 | |
5232 int pitch; // [sp+ACh] [bp-Ch]@1 | |
0 | 5233 char v43; // [sp+B3h] [bp-5h]@18 |
5234 int i; // [sp+B4h] [bp-4h]@6 | |
810 | 5235 unsigned short* line_pictute_data; |
5236 byte test_byte; | |
5237 unsigned char pict_byte; | |
0 | 5238 |
5239 v7 = this; | |
810 | 5240 pitch = wight; |
5241 if ( wight & 1 ) | |
5242 pitch = wight + 1; | |
5243 Src.left = 0; | |
5244 Src.up = 0; | |
5245 Src.right = wight - 1; | |
5246 Src.bottom = heidth - 1; | |
5247 v27.pitch = pitch; | |
0 | 5248 memset(&v20, 0, 0x30u); |
5249 memset(&v18, 0, 0x38u); | |
810 | 5250 v8 = data_buff; |
5251 v27.reserved = 0; | |
0 | 5252 *(_WORD *)&v18[56] = 0; |
810 | 5253 Src.manufacturer = 10; |
5254 Src.version = 5; | |
5255 Src.encoding = 1; | |
5256 Src.bpp = 8; | |
5257 Src.hdpi = 75; | |
5258 Src.vdpi = 75; | |
5259 v27.planes = 3; | |
5260 v27.palette_info = 1; | |
5261 memcpy(data_buff, &Src, 1u); | |
0 | 5262 v8 = (char *)v8 + 1; |
810 | 5263 memcpy(v8, &Src.version, 1u); |
0 | 5264 v8 = (char *)v8 + 1; |
810 | 5265 memcpy(v8, &Src.encoding, 1u); |
0 | 5266 v8 = (char *)v8 + 1; |
810 | 5267 memcpy(v8, &Src.bpp, 1u); |
0 | 5268 v8 = (char *)v8 + 1; |
810 | 5269 memcpy(v8, &Src.left, 2u); |
0 | 5270 v8 = (char *)v8 + 2; |
810 | 5271 memcpy(v8, &Src.up, 2u); |
0 | 5272 v8 = (char *)v8 + 2; |
810 | 5273 memcpy(v8, &Src.right, 2u); |
0 | 5274 v8 = (char *)v8 + 2; |
810 | 5275 memcpy(v8, &Src.bottom, 2u); |
0 | 5276 v8 = (char *)v8 + 2; |
810 | 5277 memcpy(v8, &Src.hdpi, 2u); |
0 | 5278 v8 = (char *)v8 + 2; |
810 | 5279 memcpy(v8, &Src.vdpi, 2u); |
0 | 5280 v8 = (char *)v8 + 2; |
5281 memcpy(v8, &v20, 0x30u); | |
5282 v8 = (char *)v8 + 48; | |
810 | 5283 memcpy(v8, &v27, 1u); |
0 | 5284 v8 = (char *)v8 + 1; |
810 | 5285 memcpy(v8, &v27.planes, 1u); |
0 | 5286 v8 = (char *)v8 + 1; |
810 | 5287 memcpy(v8, &v27.pitch, 2u); |
0 | 5288 v8 = (char *)v8 + 2; |
810 | 5289 memcpy(v8, &v27.palette_info, 2u); |
0 | 5290 v8 = (char *)v8 + 2; |
5291 memcpy(v8, &v18, 0x3Au); | |
5292 v9 = (char *)v8 + 58; | |
810 | 5293 |
5294 lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0); | |
5295 if ( heidth > 0 ) | |
5296 { | |
5297 v10 = pitch; | |
5298 v25 = heidth; | |
5299 v26 = 3 * pitch; | |
5300 v23 = 2 * wight; | |
5301 v11 = picture_data; | |
5302 v24 = (int)picture_data; | |
0 | 5303 while ( 1 ) |
5304 { | |
810 | 5305 line_pictute_data = v11; |
0 | 5306 v12 = 0; |
5307 i = 0; | |
810 | 5308 if ( wight > 0 ) |
5309 { | |
5310 lineG = (char *)lineRGB + pitch; | |
5311 lineB = (char *)lineRGB + 2 * pitch; | |
0 | 5312 do |
5313 { | |
810 | 5314 lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8); |
5315 lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8); | |
5316 lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits); | |
5317 | |
5318 v12++; | |
5319 } | |
5320 while ( v12 < wight ); | |
0 | 5321 } |
5322 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) | |
5323 { | |
810 | 5324 test_byte = 1; |
5325 pict_byte = lineRGB [i]; | |
0 | 5326 do |
5327 { | |
810 | 5328 v15 = i + test_byte; |
5329 if ( *((char *)lineRGB + v15) != pict_byte ) | |
0 | 5330 break; |
810 | 5331 if ( !(v15 % pitch) ) |
0 | 5332 break; |
810 | 5333 ++test_byte; |
5334 } | |
5335 while ( test_byte < 0x3Fu ); | |
5336 if ( i + test_byte > v26 ) | |
5337 test_byte = 3 * pitch - i; | |
5338 if ( test_byte > 1u || pict_byte >= 0xC0u ) | |
5339 { | |
5340 v43 = test_byte | 0xC0; | |
0 | 5341 memcpy(v9, &v43, 1u); |
5342 v9 = (char *)v9 + 1; | |
5343 } | |
810 | 5344 memcpy(v9, &pict_byte, 1u); |
5345 i += test_byte; | |
5346 } | |
5347 v11 +=wight ; | |
0 | 5348 v16 = v25-- == 1; |
810 | 5349 |
0 | 5350 if ( v16 ) |
5351 break; | |
810 | 5352 v10 = pitch; |
5353 } | |
5354 } | |
5355 pAllocator->FreeChunk(lineRGB); | |
5356 *(int *)packed_size = (char *)v9 - data_buff; | |
5357 | |
0 | 5358 } |
5359 | |
5360 //----- (0049F8B5) -------------------------------------------------------- | |
5361 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) | |
5362 { | |
5363 Render *v5; // esi@1 | |
5364 FILE *result; // eax@1 | |
5365 FILE *v7; // edi@4 | |
5366 int v8; // ecx@5 | |
5367 int v9; // eax@5 | |
5368 int v10; // eax@7 | |
5369 int v11; // ecx@9 | |
5370 signed int v12; // eax@12 | |
5371 char v13; // zf@21 | |
5372 char v14[56]; // [sp+4h] [bp-A0h]@4 | |
5373 __int16 v15; // [sp+3Ch] [bp-68h]@4 | |
5374 char color_map[48]; // [sp+40h] [bp-64h]@4 | |
5375 int v17; // [sp+70h] [bp-34h]@5 | |
5376 int v18; // [sp+74h] [bp-30h]@5 | |
5377 char *v19; // [sp+78h] [bp-2Ch]@5 | |
5378 int v20; // [sp+7Ch] [bp-28h]@5 | |
5379 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 | |
5380 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 | |
5381 void *ptr; // [sp+98h] [bp-Ch]@4 | |
5382 int v24; // [sp+9Ch] [bp-8h]@2 | |
5383 char *i; // [sp+A0h] [bp-4h]@8 | |
5384 | |
5385 v5 = this; | |
5386 result = fopen(Filename, "wb"); | |
5387 Filename = (const char *)result; | |
5388 if ( result ) | |
5389 { | |
5390 v24 = a4; | |
5391 if ( a4 & 1 ) | |
5392 v24 = a4 + 1; | |
5393 header1.left = 0; | |
5394 header1.up = 0; | |
5395 header1.right = a4 - 1; | |
5396 header1.bottom = a5 - 1; | |
5397 header2.pitch = v24; | |
5398 memset(color_map, 0, sizeof(color_map)); | |
5399 header2.reserved = 0; | |
5400 memset(v14, 0, sizeof(v14)); | |
5401 v15 = 0; | |
5402 header1.manufacturer = 10; | |
5403 header1.version = 5; | |
5404 header1.encoding = 1; | |
5405 header1.bpp = 8; | |
5406 header1.hdpi = 75; | |
5407 header1.vdpi = 75; | |
5408 header2.planes = 3; | |
5409 header2.palette_info = 1; | |
5410 fwrite(&header1, 1u, 1u, (FILE *)Filename); | |
5411 v7 = (FILE *)Filename; | |
5412 fwrite(&header1.version, 1u, 1u, (FILE *)Filename); | |
5413 fwrite(&header1.encoding, 1u, 1u, v7); | |
5414 fwrite(&header1.bpp, 1u, 1u, v7); | |
5415 fwrite(&header1.left, 2u, 1u, v7); | |
5416 fwrite(&header1.up, 2u, 1u, v7); | |
5417 fwrite(&header1.right, 2u, 1u, v7); | |
5418 fwrite(&header1.bottom, 2u, 1u, v7); | |
5419 fwrite(&header1.hdpi, 2u, 1u, v7); | |
5420 fwrite(&header1.vdpi, 2u, 1u, v7); | |
5421 fwrite(color_map, 0x30u, 1u, v7); | |
5422 fwrite(&header2, 1u, 1u, v7); | |
5423 fwrite(&header2.planes, 1u, 1u, v7); | |
5424 fwrite(&header2.pitch, 2u, 1u, v7); | |
5425 fwrite(&header2.palette_info, 2u, 1u, v7); | |
5426 fwrite(v14, 0x3Au, 1u, v7); | |
5427 ptr = pAllocator->AllocNamedChunk(0, 3 * a4 + 6, 0); | |
5428 if ( a5 > 0 ) | |
5429 { | |
5430 v8 = v24; | |
5431 v18 = a5; | |
5432 v20 = 3 * v24; | |
5433 v17 = 2 * a4; | |
5434 v9 = (int)a3; | |
5435 v19 = a3; | |
5436 while ( 1 ) | |
5437 { | |
5438 a5 = v9; | |
5439 v10 = 0; | |
5440 if ( a4 > 0 ) | |
5441 { | |
5442 a3 = (char *)ptr + v8; | |
5443 i = (char *)ptr + 2 * v24; | |
5444 do | |
5445 { | |
5446 *((char *)ptr + v10) = (signed int)(v5->uTargetRMask & *(short *)a5) >> (LOBYTE(v5->uTargetGBits) | |
5447 + LOBYTE(v5->uTargetBBits) | |
5448 + v5->uTargetRBits | |
5449 - 8); | |
5450 a3[v10] = (signed int)(v5->uTargetGMask & *(short *)a5) >> (LOBYTE(v5->uTargetBBits) | |
5451 + LOBYTE(v5->uTargetGBits) | |
5452 - 8); | |
5453 v11 = a5; | |
5454 a5 += 2; | |
5455 i[v10++] = (v5->uTargetBMask & *(char *)v11) << (8 - LOBYTE(v5->uTargetBBits)); | |
5456 } | |
5457 while ( v10 < a4 ); | |
5458 } | |
5459 for ( i = 0; (signed int)i < v20; i += BYTE3(a5) ) | |
5460 { | |
5461 BYTE3(a5) = 1; | |
5462 BYTE3(Filename) = *((char *)ptr + (int)i); | |
5463 do | |
5464 { | |
5465 v12 = (signed int)&i[BYTE3(a5)]; | |
5466 if ( *((char *)ptr + v12) != BYTE3(Filename) ) | |
5467 break; | |
5468 if ( !(v12 % v24) ) | |
5469 break; | |
5470 ++BYTE3(a5); | |
5471 } | |
5472 while ( BYTE3(a5) < 0x3Fu ); | |
5473 if ( (signed int)&i[BYTE3(a5)] > v20 ) | |
5474 BYTE3(a5) = 3 * v24 - (char)i; | |
5475 if ( BYTE3(a5) > 1u || BYTE3(Filename) >= 0xC0u ) | |
5476 { | |
5477 BYTE3(a3) = BYTE3(a5) | 0xC0; | |
5478 fwrite((char *)&a3 + 3, 1u, 1u, v7); | |
5479 } | |
5480 fwrite((char *)&Filename + 3, 1u, 1u, v7); | |
5481 } | |
5482 v9 = (int)&v19[v17]; | |
5483 v13 = v18-- == 1; | |
5484 v19 += v17; | |
5485 if ( v13 ) | |
5486 break; | |
5487 v8 = v24; | |
5488 } | |
5489 } | |
5490 pAllocator->FreeChunk(ptr); | |
5491 result = (FILE *)fclose(v7); | |
5492 } | |
5493 return result; | |
5494 } | |
5495 | |
5496 //----- (0049FBCD) -------------------------------------------------------- | |
5497 void Render::ClearTarget(unsigned int uColor) | |
5498 { | |
5499 if (pRenderD3D) | |
5500 { | |
5501 if (field_40110) | |
5502 pRenderD3D->ClearTarget(true, uColor, false, 0.0); | |
5503 } | |
5504 else | |
5505 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | |
5506 } | |
5507 | |
5508 //----- (0049FC23) -------------------------------------------------------- | |
5509 void Render::Release2() | |
5510 { | |
5511 Release(); | |
5512 bWindowMode = 1; | |
5513 } | |
5514 | |
5515 //----- (0049FC37) -------------------------------------------------------- | |
5516 void Render::Present() | |
5517 { | |
5518 Render *v1; // esi@1 | |
5519 struct tagRECT Rect; // [sp+8h] [bp-28h]@11 | |
5520 RECT a4; // [sp+18h] [bp-18h]@11 | |
5521 struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | |
5522 | |
5523 v1 = this; | |
5524 if ( !pRenderer->pRenderD3D || this->field_40110 ) | |
5525 { | |
5526 this->pBeforePresentFunction(); | |
5527 if ( v1->pRenderD3D ) | |
5528 { | |
5529 if ( v1->field_40110 ) | |
5530 { | |
5531 if (pAsyncMouse) | |
5532 pAsyncMouse->_46BAEC(); | |
5533 pRenderD3D->Present(false); | |
5534 if (pAsyncMouse) | |
5535 pAsyncMouse->_46BB0A(); | |
5536 } | |
5537 } | |
5538 else | |
5539 { | |
5540 if ( v1->bWindowMode ) | |
5541 { | |
5542 RestoreFrontBuffer(); | |
5543 GetClientRect(v1->hWnd, &Rect); | |
5544 Point.y = 0; | |
5545 Point.x = 0; | |
5546 ClientToScreen(v1->hWnd, &Point); | |
5547 OffsetRect(&Rect, Point.x, Point.y); | |
5548 a4.top = 0; | |
5549 a4.bottom = 480; | |
5550 a4.left = 0; | |
5551 a4.right = 640; | |
5552 PresentRect(&Rect, &a4); | |
5553 } | |
5554 else | |
5555 { | |
5556 RestoreFrontBuffer(); | |
5557 a4.top = 0; | |
5558 a4.bottom = 480; | |
5559 a4.left = 0; | |
5560 a4.right = 640; | |
5561 BltBackToFontFast(0, 0, &a4); | |
5562 } | |
5563 } | |
5564 } | |
5565 } | |
5566 | |
5567 //----- (0049FD3A) -------------------------------------------------------- | |
5568 void Render::_49FD3A() | |
5569 { | |
5570 Render *v2; // esi@1 | |
5571 IDirectDrawSurface4 *v3; // eax@6 | |
5572 IDirectDrawSurface4 *v4; // ST0C_4@6 | |
5573 RECT v5; // [sp+8h] [bp-10h]@6 | |
5574 | |
5575 auto a1 = this; | |
5576 v2 = a1; | |
5577 if ( a1->pRenderD3D ) | |
5578 { | |
5579 if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST) | |
5580 pFrontBuffer4->Restore(); | |
5581 if (pBackBuffer4->IsLost() == DDERR_SURFACELOST) | |
5582 pBackBuffer4->Restore(); | |
5583 v3 = v2->pBackBuffer4; | |
5584 v4 = v2->pFrontBuffer4; | |
5585 v5.top = 0; | |
5586 v5.bottom = 480; | |
5587 v5.left = 0; | |
5588 v5.right = 640; | |
5589 v3->BltFast(0, 0, v4, &v5, 16u); | |
5590 } | |
5591 } | |
5592 | |
5593 //----- (0049FDBF) -------------------------------------------------------- | |
5594 void Render::CreateZBuffer() | |
5595 { | |
5596 if (!pDefaultZBuffer) | |
5597 { | |
5598 pDefaultZBuffer = pActiveZBuffer = nullptr; | |
5599 pDefaultZBuffer = pActiveZBuffer = (int *)pAllocator->AllocNamedChunk(0, 0x12C000, "Z Buf."); | |
5600 memset32(pActiveZBuffer, 0xFFFF0000u, 0x4B000u); | |
5601 } | |
5602 } | |
5603 | |
5604 //----- (0049FE05) -------------------------------------------------------- | |
5605 void Render::Release() | |
5606 { | |
5607 Render *v1; // esi@1 | |
5608 RenderD3D *v2; // ecx@1 | |
5609 char v3; // zf@4 | |
5610 void *v4; // ebx@6 | |
5611 IDirectDraw *v5; // eax@10 | |
5612 IDirectDrawSurface2 *v6; // eax@11 | |
5613 IDirectDrawSurface2 *v7; // eax@13 | |
5614 IDirectDrawSurface2 *v8; // eax@15 | |
5615 IDirectDraw2 *v9; // eax@17 | |
5616 IDirectDraw4 *v10; // eax@19 | |
5617 IDirectDrawSurface4 *v11; // eax@20 | |
5618 IDirectDrawSurface4 *v12; // eax@22 | |
5619 IDirectDrawSurface4 *v13; // eax@24 | |
5620 IDirectDraw4 *v14; // eax@26 | |
5621 unsigned __int16 **v15; // ebx@28 | |
5622 void **v16; // esi@29 | |
5623 | |
5624 v1 = this; | |
5625 v2 = this->pRenderD3D; | |
5626 if ( v2 ) | |
5627 { | |
5628 if ( v1->field_40110 ) | |
5629 { | |
5630 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
5631 pRenderD3D->Present(0); | |
5632 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | |
5633 } | |
5634 v1->pColorKeySurface4 = 0; | |
5635 v1->pBackBuffer4 = 0; | |
5636 v3 = v1->pTargetSurface == 0; | |
5637 v1->pFrontBuffer4 = 0; | |
5638 v1->pDirectDraw4 = 0; | |
5639 if ( !v3 ) | |
5640 { | |
5641 free(v1->ptr_400E8); | |
5642 v1->pTargetSurface = 0; | |
5643 v1->ptr_400E8 = 0; | |
5644 } | |
5645 v4 = v1->pRenderD3D; | |
5646 if ( v4 ) | |
5647 { | |
5648 pRenderD3D->Release(); | |
5649 free(v4); | |
5650 } | |
5651 v1->pRenderD3D = 0; | |
5652 } | |
5653 else | |
5654 { | |
5655 if ( bWinNT4_0 == 1 ) | |
5656 { | |
5657 v5 = (IDirectDraw *)v1->pDirectDraw2; | |
5658 if ( !v5 ) | |
5659 return; | |
5660 v5->SetCooperativeLevel(v1->hWnd, 8u); | |
5661 v1->pDirectDraw2->FlipToGDISurface(); | |
5662 v6 = v1->pSomeSurface2; | |
5663 if ( v6 ) | |
5664 { | |
5665 v6->Release(); | |
5666 v1->pSomeSurface2 = 0; | |
5667 } | |
5668 v7 = v1->pBackBuffer2; | |
5669 if ( v7 ) | |
5670 { | |
5671 v7->Release(); | |
5672 v1->pBackBuffer2 = 0; | |
5673 } | |
5674 v8 = v1->pFrontBuffer2; | |
5675 if ( v8 ) | |
5676 { | |
5677 v8->Release(); | |
5678 v1->pFrontBuffer2 = 0; | |
5679 } | |
5680 v9 = v1->pDirectDraw2; | |
5681 if ( v9 ) | |
5682 { | |
5683 v9->Release(); | |
5684 v1->pDirectDraw2 = 0; | |
5685 } | |
5686 } | |
5687 else | |
5688 { | |
5689 v10 = v1->pDirectDraw4; | |
5690 if ( !v10 ) | |
5691 return; | |
5692 v10->SetCooperativeLevel(v1->hWnd, 1032u); | |
5693 v1->pDirectDraw4->FlipToGDISurface(); | |
5694 v11 = v1->pColorKeySurface4; | |
5695 if ( v11 ) | |
5696 { | |
5697 v11->Release(); | |
5698 v1->pColorKeySurface4 = 0; | |
5699 } | |
5700 v12 = v1->pBackBuffer4; | |
5701 if ( v12 ) | |
5702 { | |
5703 v12->Release(); | |
5704 v1->pBackBuffer4 = 0; | |
5705 } | |
5706 v13 = v1->pFrontBuffer4; | |
5707 if ( v13 ) | |
5708 { | |
5709 v13->Release(); | |
5710 v1->pFrontBuffer4 = 0; | |
5711 } | |
5712 v14 = v1->pDirectDraw4; | |
5713 if ( v14 ) | |
5714 { | |
5715 v14->Release(); | |
5716 v1->pDirectDraw4 = 0; | |
5717 } | |
5718 } | |
5719 v15 = &v1->pTargetSurface; | |
5720 if ( v1->pTargetSurface ) | |
5721 { | |
5722 v16 = (void **)&v1->ptr_400E8; | |
5723 free(*v16); | |
5724 *v15 = 0; | |
5725 *v16 = 0; | |
5726 } | |
5727 } | |
5728 } | |
5729 | |
5730 //----- (0049FFD7) -------------------------------------------------------- | |
5731 void Render::CreateSomeTexture() | |
5732 { | |
5733 pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); | |
5734 } | |
5735 | |
5736 //----- (0049FFFB) -------------------------------------------------------- | |
5737 bool Render::InitializeFullscreen(HWND hWnd) | |
5738 { | |
5739 //Render *v2; // esi@1 | |
5740 //HWND v3; // ebx@1 | |
5741 //void *v4; // eax@2 | |
5742 //RenderD3D *v5; // eax@3 | |
5743 unsigned int v6; // edx@5 | |
5744 RenderD3D__DevInfo *v7; // ecx@5 | |
5745 bool v8; // eax@6 | |
5746 RenderD3D *v9; // ecx@13 | |
5747 unsigned int v10; // eax@13 | |
5748 RenderD3D *v11; // eax@25 | |
5749 HRESULT v12; // eax@25 | |
5750 int v13; // ecx@25 | |
5751 int v14; // eax@27 | |
5752 signed int v15; // ebx@31 | |
5753 bool v16; // eax@35 | |
5754 char v17; // zf@35 | |
5755 IDirectDraw4 *v18; // eax@38 | |
5756 HRESULT v19; // eax@38 | |
5757 int *v20; // eax@39 | |
5758 int *v22; // eax@42 | |
5759 int v23; // ecx@42 | |
5760 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | |
5761 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | |
5762 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | |
5763 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | |
5764 void *v28; // [sp+2FCh] [bp-10h]@2 | |
5765 int v29; // [sp+308h] [bp-4h]@2 | |
5766 | |
5767 //v2 = this; | |
5768 this->field_40110 = 0; | |
5769 this->pColorKeySurface4 = 0; | |
5770 this->pBackBuffer4 = 0; | |
5771 this->pFrontBuffer4 = 0; | |
5772 this->pDirectDraw4 = 0; | |
5773 this->bColorKeySupported = 0; | |
5774 Release(); | |
5775 //v3 = hWnd; | |
5776 this->hWnd = hWnd; | |
5777 CreateZBuffer(); | |
5778 if ( bUserDirect3D ) | |
5779 { | |
5780 pRenderD3D = new RenderD3D; | |
5781 v28 = pRenderD3D; | |
5782 v6 = uDesiredDirect3DDevice; | |
5783 v29 = -1; | |
5784 v7 = pRenderD3D->pAvailableDevices; | |
5785 if ( v7[v6].bIsDeviceCompatible ) | |
5786 { | |
5787 v8 = pRenderD3D->CreateDevice(v6, 0, hWnd); | |
5788 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
5789 } | |
5790 else | |
5791 { | |
5792 if ( v7[1].bIsDeviceCompatible ) | |
5793 { | |
5794 v8 = pRenderD3D->CreateDevice(1u, 0, hWnd); | |
5795 uAcquiredDirect3DDevice = 1; | |
5796 } | |
5797 else | |
5798 { | |
5799 if ( !v7->bIsDeviceCompatible ) | |
5800 Abortf("There aren't any D3D devices to create."); | |
5801 v8 = pRenderD3D->CreateDevice(0, 0, hWnd); | |
5802 uAcquiredDirect3DDevice = 0; | |
5803 } | |
5804 } | |
5805 if ( !v8 ) | |
5806 Abortf("D3Drend->Init failed."); | |
5807 v9 = pRenderD3D; | |
5808 pBackBuffer4 = v9->pBackBuffer; | |
5809 pFrontBuffer4 = v9->pFrontBuffer; | |
5810 pDirectDraw4 = v9->pHost; | |
5811 v10 = pRenderD3D->GetDeviceCaps(); | |
5812 if ( v10 & 1 ) | |
5813 { | |
5814 if ( pRenderD3D ) | |
5815 { | |
5816 pRenderD3D->Release(); | |
5817 delete pRenderD3D; | |
5818 } | |
5819 pRenderD3D = 0; | |
5820 pBackBuffer4 = 0; | |
5821 pFrontBuffer4 = 0; | |
5822 pDirectDraw4 = 0; | |
5823 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
5824 } | |
5825 if ( v10 & 0x3E ) | |
5826 { | |
5827 if ( pRenderD3D ) | |
5828 { | |
5829 pRenderD3D->Release(); | |
5830 delete pRenderD3D; | |
5831 } | |
5832 pColorKeySurface4 = 0; | |
5833 pRenderD3D = 0; | |
5834 pBackBuffer4 = 0; | |
5835 pFrontBuffer4 = 0; | |
5836 pDirectDraw4 = 0; | |
5837 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
5838 } | |
5839 if ( (v10 & 0x80u) != 0 ) | |
5840 { | |
5841 if ( pRenderD3D ) | |
5842 { | |
5843 pRenderD3D->Release(); | |
5844 delete pRenderD3D; | |
5845 } | |
5846 pRenderD3D = 0; | |
5847 pBackBuffer4 = 0; | |
5848 pFrontBuffer4 = 0; | |
5849 pDirectDraw4 = 0; | |
5850 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
5851 } | |
5852 LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; | |
5853 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
5854 memset(&halCaps, 0, 0xFCu); | |
5855 halCaps.dwSize = 252; | |
5856 memset(&refCaps, 0, 0xFCu); | |
5857 v11 = pRenderD3D; | |
5858 refCaps.dwSize = 252; | |
5859 ErrD3D(v11->pDevice->GetCaps(&halCaps, &refCaps)); | |
5860 v13 = halCaps.dwMinTextureWidth; | |
5861 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
5862 v13 = halCaps.dwMinTextureHeight; | |
5863 v14 = halCaps.dwMaxTextureWidth; | |
5864 uMinDeviceTextureDim = v13; | |
5865 if ( (unsigned int)v14 < halCaps.dwMaxTextureHeight ) | |
5866 v14 = halCaps.dwMaxTextureHeight; | |
5867 uMaxDeviceTextureDim = v14; | |
5868 if ( (unsigned int)v13 < 4 ) | |
5869 uMinDeviceTextureDim = 4; | |
5870 CreateSomeTexture(); | |
5871 v15 = 1; | |
5872 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true)); | |
5873 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true)); | |
5874 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
5875 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false)); | |
5876 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false)); | |
5877 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false)); | |
5878 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
5879 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
5880 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
5881 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
5882 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
5883 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
5884 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
5885 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
5886 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
5887 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
5888 } | |
5889 else | |
5890 { | |
5891 CreateDirectDraw(); | |
5892 SetDirectDrawCooperationMode(hWnd, 1); | |
5893 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
5894 CreateDirectDrawPrimarySurface(); | |
5895 v15 = 1; | |
5896 } | |
5897 ddpfPrimareSuface.dwSize = 32; | |
5898 GetTargetPixelFormat(&ddpfPrimareSuface); | |
5899 ParseTargetPixelFormat(); | |
5900 _49EBF1(); | |
5901 if ( pRenderD3D ) | |
5902 { | |
5903 v16 = IsColorKeySupported(pDirectDraw4); | |
5904 v17 = uAcquiredDirect3DDevice == v15; | |
5905 bColorKeySupported = v16; | |
5906 if ( !v17 ) | |
5907 bColorKeySupported = 0; | |
5908 if ( bColorKeySupported ) | |
5909 { | |
5910 memset(&ddsd2, 0, 0x7Cu); | |
5911 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
5912 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
5913 v18 = pDirectDraw4; | |
5914 ddsd2.dwSize = 124; | |
5915 ddsd2.dwFlags = 65543; | |
5916 ddsd2.ddsCaps.dwCaps = 2112; | |
5917 ddsd2.dwWidth = 640; | |
5918 ddsd2.dwHeight = 480; | |
5919 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
5920 pBeforePresentFunction = Present_ColorKey; | |
5921 } | |
5922 else | |
5923 { | |
5924 pTargetSurface = 0; | |
5925 ptr_400E8 = 0; | |
5926 v20 = (int *)operator new(0x96020u); | |
5927 ptr_400E8 = v20; | |
5928 if ( !v20 | |
5929 || (memset(&pDesc, 0, 0x7Cu), | |
5930 pDesc.dwSize = 124, | |
5931 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | |
5932 return 0; | |
5933 pBackBuffer4->Unlock(0); | |
5934 v22 = ptr_400E8 + 4; | |
5935 v23 = (unsigned int)pDesc.lpSurface & 7; | |
5936 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | |
5937 uTargetSurfacePitch = 640; | |
5938 pBeforePresentFunction = Present_NoColorKey; | |
5939 v15 = 1; | |
5940 pTargetSurface = (unsigned __int16 *)((char *)v22 + 2 * v23); | |
5941 } | |
5942 field_40110 = v15; | |
5943 } | |
5944 else | |
5945 { | |
5946 pBeforePresentFunction = 0;//nullsub_1; | |
5947 } | |
5948 bWindowMode = 0; | |
5949 pParty->uFlags |= 2u; | |
5950 LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; | |
5951 pViewport->_4C02F8(36044); | |
5952 return v15; | |
5953 } | |
5954 // 6BE3A0: using guessed type float flt_6BE3A0; | |
5955 | |
5956 //----- (004A05F3) -------------------------------------------------------- | |
5957 bool Render::SwitchToWindow(HWND hWnd) | |
5958 { | |
5959 //Render *v2; // esi@1 | |
5960 //void *v3; // eax@2 | |
5961 //RenderD3D *v4; // eax@3 | |
5962 //unsigned int v5; // edx@5 | |
5963 //RenderD3D__DevInfo *v6; // ecx@5 | |
5964 bool v7; // eax@7 | |
5965 //RenderD3D *v8; // ecx@12 | |
5966 unsigned int v9; // eax@12 | |
5967 RenderD3D *v10; // eax@24 | |
5968 HRESULT v11; // eax@24 | |
5969 int v12; // eax@24 | |
5970 int v13; // eax@26 | |
5971 bool v14; // eax@32 | |
5972 char v15; // zf@32 | |
5973 IDirectDraw4 *v16; // eax@35 | |
5974 HRESULT v17; // eax@35 | |
5975 int *v18; // eax@36 | |
5976 int *v19; // edx@38 | |
5977 int v20; // eax@38 | |
5978 unsigned int v21; // ecx@38 | |
5979 int v22; // eax@41 | |
5980 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | |
5981 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 | |
5982 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | |
5983 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | |
5984 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | |
5985 int v29; // [sp+308h] [bp-4h]@2 | |
5986 | |
5987 pParty->uFlags |= 2u; | |
5988 //v2 = this; | |
5989 flt_6BE3A0 = 0.55000001f; | |
5990 pViewport->_4C02F8(36044); | |
5991 field_40110 = 0; | |
5992 Release(); | |
5993 pColorKeySurface4 = 0; | |
5994 pBackBuffer4 = 0; | |
5995 pFrontBuffer4 = 0; | |
5996 pDirectDraw4 = 0; | |
5997 bColorKeySupported = 0; | |
5998 CreateZBuffer(); | |
5999 if ( bUserDirect3D ) | |
6000 { | |
6001 /*v3 = operator new(0x148u); | |
6002 thisa = (RenderD3D *)v3; | |
6003 v29 = 0; | |
6004 if ( v3 ) | |
6005 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | |
6006 else | |
6007 v4 = 0;*/ | |
6008 pRenderD3D = new RenderD3D; | |
6009 //v4 = pRenderD3D; | |
6010 //v5 = uDesiredDirect3DDevice; | |
6011 v29 = -1; | |
6012 //v6 = pRenderD3D->pAvailableDevices; | |
6013 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | |
6014 uDesiredDirect3DDevice != 1 ) | |
6015 { | |
6016 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, hWnd); | |
6017 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | |
6018 } | |
6019 else | |
6020 { | |
6021 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | |
6022 Abortf("There aren't any D3D devices to init."); | |
6023 v7 = pRenderD3D->CreateDevice(0, 1, hWnd); | |
6024 uAcquiredDirect3DDevice = 0; | |
6025 } | |
6026 if ( !v7 ) | |
6027 Abortf("D3Drend->Init failed."); | |
6028 | |
6029 //v8 = pRenderD3D; | |
6030 pColorKeySurface4 = 0; | |
6031 pBackBuffer4 = pRenderD3D->pBackBuffer; | |
6032 pFrontBuffer4 = pRenderD3D->pFrontBuffer; | |
6033 pDirectDraw4 = pRenderD3D->pHost; | |
6034 v9 = pRenderD3D->GetDeviceCaps(); | |
6035 if ( v9 & 1 ) | |
6036 { | |
6037 if (pRenderD3D) | |
6038 { | |
6039 pRenderD3D->Release(); | |
6040 delete pRenderD3D; | |
6041 } | |
6042 pRenderD3D = 0; | |
6043 pBackBuffer4 = 0; | |
6044 pFrontBuffer4 = 0; | |
6045 pDirectDraw4 = 0; | |
6046 Abortf("Direct3D renderer: The device failed to return capabilities."); | |
6047 } | |
6048 if ( v9 & 0x3E ) | |
6049 { | |
6050 if (pRenderD3D) | |
6051 { | |
6052 pRenderD3D->Release(); | |
6053 delete pRenderD3D; | |
6054 } | |
6055 pColorKeySurface4 = 0; | |
6056 pRenderD3D = 0; | |
6057 pBackBuffer4 = 0; | |
6058 pFrontBuffer4 = 0; | |
6059 pDirectDraw4 = 0; | |
6060 Abortf("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); | |
6061 } | |
6062 if ( (v9 & 0x80u) != 0 ) | |
6063 { | |
6064 if (pRenderD3D) | |
6065 { | |
6066 pRenderD3D->Release(); | |
6067 delete pRenderD3D; | |
6068 } | |
6069 pRenderD3D = 0; | |
6070 pBackBuffer4 = 0; | |
6071 pFrontBuffer4 = 0; | |
6072 pDirectDraw4 = 0; | |
6073 Abortf("Direct3D renderer: The device doesn't support non-square textures."); | |
6074 } | |
6075 LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; | |
6076 bRequiredTextureStagesAvailable = CheckTextureStages(); | |
6077 memset(&halCaps, 0, 0xFCu); | |
6078 halCaps.dwSize = 252; | |
6079 memset(&refCaps, 0, 0xFCu); | |
6080 //v10 = v2->pRenderD3D; | |
6081 refCaps.dwSize = 252; | |
6082 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | |
6083 v12 = halCaps.dwMinTextureWidth; | |
6084 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | |
6085 v12 = halCaps.dwMinTextureHeight; | |
6086 uMinDeviceTextureDim = v12; | |
6087 v13 = halCaps.dwMaxTextureWidth; | |
6088 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | |
6089 v13 = halCaps.dwMaxTextureHeight; | |
6090 uMaxDeviceTextureDim = v13; | |
6091 CreateSomeTexture(); | |
6092 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u)); | |
6093 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
6094 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u)); | |
6095 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, 0)); | |
6096 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, 0)); | |
6097 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | |
6098 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u)); | |
6099 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u)); | |
6100 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u)); | |
6101 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u)); | |
6102 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | |
6103 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | |
6104 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | |
6105 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | |
6106 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | |
6107 } | |
6108 else | |
6109 { | |
6110 CreateDirectDraw(); | |
6111 SetDirectDrawCooperationMode(hWnd, 0); | |
6112 field_4004C = 1; | |
6113 CreateFrontBuffer(); | |
6114 CreateClipper(hWnd); | |
6115 CreateBackBuffer(); | |
6116 field_40030 = 0; | |
6117 field_18_locked_pitch = 0; | |
6118 } | |
6119 ddpfPrimareSuface.dwSize = 32; | |
6120 GetTargetPixelFormat(&ddpfPrimareSuface); | |
6121 ParseTargetPixelFormat(); | |
6122 _49EBF1(); | |
6123 if ( !pRenderD3D ) | |
6124 { | |
6125 pBeforePresentFunction = 0;//nullsub_1; | |
6126 goto LABEL_47; | |
6127 } | |
6128 v14 = IsColorKeySupported(pDirectDraw4); | |
6129 v15 = uAcquiredDirect3DDevice == 1; | |
6130 bColorKeySupported = v14; | |
6131 if ( !v15 ) | |
6132 bColorKeySupported = 0; | |
6133 if ( bColorKeySupported ) | |
6134 { | |
6135 memset(&ddsd2, 0, 0x7Cu); | |
6136 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | |
6137 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | |
6138 v16 = pDirectDraw4; | |
6139 ddsd2.dwSize = 124; | |
6140 ddsd2.dwFlags = 65543; | |
6141 ddsd2.ddsCaps.dwCaps = 2112; | |
6142 ddsd2.dwWidth = 640; | |
6143 ddsd2.dwHeight = 480; | |
6144 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | |
6145 pBeforePresentFunction = Present_ColorKey; | |
6146 LABEL_45: | |
6147 field_40110 = 1; | |
6148 LABEL_47: | |
6149 bWindowMode = 1; | |
6150 hWnd = hWnd; | |
6151 return 0; | |
6152 } | |
6153 pTargetSurface = 0; | |
6154 ptr_400E8 = 0; | |
6155 v18 = (int *)new char[0x96020]; | |
6156 memset(v18, -1, 0x96020); | |
6157 ptr_400E8 = v18; | |
6158 if ( v18 ) | |
6159 { | |
6160 memset(&pDesc, 0, 0x7Cu); | |
6161 pDesc.dwSize = 124; | |
168 | 6162 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT) ) |
0 | 6163 { |
6164 pRenderer->pBackBuffer4->Unlock(0); | |
6165 v19 = ptr_400E8; | |
6166 v20 = (unsigned int)pDesc.lpSurface & 7; | |
6167 v21 = (unsigned int)ptr_400E8 & 7; | |
6168 if ( v21 == v20 ) | |
6169 { | |
6170 pTargetSurface = (unsigned __int16 *)v19; | |
6171 } | |
6172 else | |
6173 { | |
6174 if ( (signed int)v21 >= v20 ) | |
6175 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | |
6176 else | |
6177 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | |
6178 pTargetSurface = (unsigned __int16 *)v22; | |
6179 } | |
6180 uTargetSurfacePitch = 640; | |
6181 pBeforePresentFunction = Present_NoColorKey; | |
6182 goto LABEL_45; | |
6183 } | |
6184 } | |
6185 return 0; | |
6186 } | |
6187 | |
6188 //----- (004A0BEE) -------------------------------------------------------- | |
709 | 6189 char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor) |
0 | 6190 { |
6191 int v6; // edi@1 | |
6192 int v7; // edx@5 | |
6193 unsigned int v8; // ebx@5 | |
6194 int v9; // eax@7 | |
6195 unsigned int v10; // ecx@9 | |
6196 unsigned int v11; // esi@13 | |
6197 int v12; // eax@17 | |
6198 int v13; // eax@21 | |
6199 Render *v14; // edi@21 | |
6200 int v15; // eax@25 | |
6201 int v16; // eax@27 | |
6202 signed int v17; // eax@28 | |
6203 signed int v18; // edi@30 | |
6204 signed __int64 v19; // qax@41 | |
6205 int v20; // edi@41 | |
6206 unsigned int v21; // edi@46 | |
6207 int v22; // esi@47 | |
6208 int v23; // ebx@47 | |
6209 signed int v24; // edx@50 | |
6210 signed int v25; // esi@52 | |
6211 unsigned __int16 *v26; // ecx@52 | |
6212 int v27; // ebx@54 | |
6213 int v28; // edi@55 | |
6214 int v29; // edx@55 | |
6215 int v30; // ebx@60 | |
6216 int v31; // edx@61 | |
6217 int v32; // edi@61 | |
6218 int v34; // [sp+Ch] [bp-10h]@3 | |
6219 Render *v35; // [sp+10h] [bp-Ch]@1 | |
6220 __int64 v36; // [sp+14h] [bp-8h]@1 | |
6221 signed int v37; // [sp+18h] [bp-4h]@28 | |
6222 unsigned int uXa; // [sp+24h] [bp+8h]@49 | |
6223 unsigned int uYa; // [sp+28h] [bp+Ch]@28 | |
6224 int uYb; // [sp+28h] [bp+Ch]@47 | |
6225 int uZa; // [sp+2Ch] [bp+10h]@38 | |
6226 | |
6227 v36 = 0i64; | |
709 | 6228 v6 = this->raster_clip_x; |
0 | 6229 v35 = this; |
6230 if ( (signed int)uX < v6 ) | |
6231 HIDWORD(v36) = 8; | |
709 | 6232 v34 = this->raster_clip_z; |
6233 if ( (signed int)uX > this->raster_clip_z ) | |
0 | 6234 HIDWORD(v36) |= 4u; |
709 | 6235 v7 = this->raster_clip_y; |
0 | 6236 v8 = uY; |
6237 if ( (signed int)uY < v7 ) | |
6238 HIDWORD(v36) |= 2u; | |
709 | 6239 v9 = this->raster_clip_w; |
0 | 6240 if ( (signed int)uY > v9 ) |
6241 HIDWORD(v36) |= 1u; | |
6242 v10 = uZ; | |
6243 if ( (signed int)uZ < v6 ) | |
6244 LODWORD(v36) = 8; | |
6245 if ( (signed int)uZ > v34 ) | |
6246 LODWORD(v36) = v36 | 4; | |
6247 v11 = uW; | |
6248 if ( (signed int)uW < v7 ) | |
6249 LODWORD(v36) = v36 | 2; | |
6250 if ( (signed int)uW > v9 ) | |
6251 LODWORD(v36) = v36 | 1; | |
6252 LOBYTE(v12) = v36; | |
6253 if ( (unsigned int)v36 & HIDWORD(v36) ) | |
6254 return v12; | |
6255 if ( !v36 ) | |
6256 { | |
6257 LABEL_46: | |
6258 v21 = pRenderer->uTargetSurfacePitch; | |
6259 if ( pRenderer->uTargetSurfacePitch ) | |
6260 { | |
6261 v12 = uX + v8 * pRenderer->uTargetSurfacePitch; | |
6262 v22 = v11 - v8; | |
6263 v23 = v22; | |
6264 uYb = v22; | |
6265 if ( v22 < 0 ) | |
6266 { | |
6267 v23 = -v22; | |
6268 uYb = -v22; | |
6269 v21 = -pRenderer->uTargetSurfacePitch; | |
6270 } | |
6271 uXa = v10 - uX; | |
6272 if ( (uXa & 0x80000000u) == 0 ) | |
6273 { | |
6274 v24 = 1; | |
6275 } | |
6276 else | |
6277 { | |
6278 uXa = -uXa; | |
6279 v24 = -1; | |
6280 } | |
6281 v25 = 0; | |
6282 v26 = v35->pTargetSurface; | |
6283 if ( v26 ) | |
6284 { | |
6285 if ( (signed int)uXa <= v23 ) | |
6286 { | |
6287 v30 = v23 + 1; | |
6288 if ( v30 > 0 ) | |
6289 { | |
6290 v31 = 2 * v24; | |
6291 v32 = 2 * v21; | |
6292 v12 = (int)&v26[v12]; | |
6293 do | |
6294 { | |
6295 v25 += uXa; | |
6296 *(short *)v12 = uColor; | |
6297 v12 += v32; | |
6298 if ( v25 > 0 ) | |
6299 { | |
6300 v25 -= uYb; | |
6301 v12 += v31; | |
6302 } | |
6303 --v30; | |
6304 } | |
6305 while ( v30 ); | |
6306 } | |
6307 } | |
6308 else | |
6309 { | |
6310 v27 = uXa + 1; | |
6311 if ( (signed int)(uXa + 1) > 0 ) | |
6312 { | |
6313 v28 = 2 * v21; | |
6314 v29 = 2 * v24; | |
6315 v12 = (int)&v26[v12]; | |
6316 do | |
6317 { | |
6318 v25 += uYb; | |
6319 *(short *)v12 = uColor; | |
6320 v12 += v29; | |
6321 if ( v25 > (signed int)uXa ) | |
6322 { | |
6323 v25 -= uXa; | |
6324 v12 += v28; | |
6325 } | |
6326 --v27; | |
6327 } | |
6328 while ( v27 ); | |
6329 } | |
6330 } | |
6331 } | |
6332 } | |
6333 return v12; | |
6334 } | |
6335 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 ) | |
6336 { | |
6337 if ( BYTE4(v36) & 8 ) | |
6338 { | |
6339 v13 = (signed int)((uW - uY) * (v6 - uX)) / (signed int)(uZ - uX); | |
6340 v14 = v35; | |
6341 v8 = v13 + uY; | |
709 | 6342 uX = v35->raster_clip_x; |
0 | 6343 goto LABEL_24; |
6344 } | |
6345 v10 = v6; | |
6346 v11 = (signed int)((uY - uW) * (v6 - uZ)) / (signed int)(uX - uZ) + uW; | |
6347 } | |
6348 v14 = v35; | |
6349 LABEL_24: | |
6350 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) | |
6351 { | |
709 | 6352 v15 = v14->raster_clip_z; |
0 | 6353 if ( BYTE4(v36) & 4 ) |
6354 { | |
6355 v14 = v35; | |
6356 v8 += (signed int)((v11 - v8) * (v15 - uX)) / (signed int)(v10 - uX); | |
709 | 6357 uX = v35->raster_clip_z; |
0 | 6358 } |
6359 else | |
6360 { | |
6361 v16 = (signed int)((v8 - v11) * (v15 - v10)) / (signed int)(uX - v10); | |
709 | 6362 v10 = v14->raster_clip_z; |
0 | 6363 v11 += v16; |
6364 } | |
6365 } | |
709 | 6366 v17 = v14->raster_clip_y; |
0 | 6367 v37 = 0; |
709 | 6368 uYa = v14->raster_clip_y; |
0 | 6369 if ( (signed int)v8 < v17 ) |
6370 v37 = 2; | |
709 | 6371 v18 = v14->raster_clip_w; |
0 | 6372 if ( (signed int)v8 > v18 ) |
6373 v37 |= 1u; | |
6374 if ( (signed int)v11 >= v17 ) | |
6375 v12 = 0; | |
6376 else | |
6377 v12 = 2; | |
6378 if ( (signed int)v11 > v18 ) | |
6379 LOBYTE(v12) = v12 | 1; | |
6380 if ( !(v12 & v37) ) | |
6381 { | |
6382 v12 ^= v37; | |
6383 uZa = v12; | |
6384 if ( v12 & 2 ) | |
6385 { | |
6386 if ( v37 & 2 ) | |
6387 { | |
6388 uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8); | |
6389 LOBYTE(v12) = (char)v35; | |
709 | 6390 v8 = v35->raster_clip_y; |
0 | 6391 } |
6392 else | |
6393 { | |
6394 v19 = (signed int)((uX - v10) * (uYa - v11)); | |
6395 v20 = v8 - v11; | |
6396 v11 = uYa; | |
6397 v12 = v19 / v20; | |
6398 v10 += v12; | |
6399 } | |
6400 } | |
6401 if ( uZa & 1 ) | |
6402 { | |
6403 if ( v37 & 1 ) | |
6404 { | |
709 | 6405 uX += (signed int)((v10 - uX) * (v35->raster_clip_w - v8)) / (signed int)(v11 - v8); |
0 | 6406 LOBYTE(v12) = (char)v35; |
709 | 6407 v8 = v35->raster_clip_w; |
0 | 6408 } |
6409 else | |
6410 { | |
709 | 6411 v12 = (signed int)((uX - v10) * (v35->raster_clip_w - v11)) / (signed int)(v8 - v11); |
6412 v11 = v35->raster_clip_w; | |
0 | 6413 v10 += v12; |
6414 } | |
6415 } | |
6416 goto LABEL_46; | |
6417 } | |
6418 return v12; | |
6419 } | |
6420 | |
6421 //----- (004A0E80) -------------------------------------------------------- | |
6422 void Render::ClearZBuffer(int a2, int a3) | |
6423 { | |
6424 memset32(this->pActiveZBuffer, -65536, 0x4B000u); | |
6425 } | |
6426 | |
6427 //----- (004A0E97) -------------------------------------------------------- | |
709 | 6428 void Render::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
6429 { | |
6430 this->raster_clip_x = uX; | |
6431 this->raster_clip_y = uY; | |
6432 this->raster_clip_z = uZ; | |
6433 this->raster_clip_w = uW; | |
0 | 6434 } |
6435 | |
6436 //----- (004A0EB6) -------------------------------------------------------- | |
6437 void Render::ParseTargetPixelFormat() | |
6438 { | |
6439 Render *v1; // eax@1 | |
6440 signed int v2; // ecx@1 | |
6441 DWORD uRedMask; // edx@1 | |
6442 unsigned int uGreenMask; // esi@5 | |
6443 signed int v5; // ecx@5 | |
6444 unsigned int uBlueMask; // edx@9 | |
6445 signed int v7; // ecx@9 | |
6446 unsigned int v8; // ecx@13 | |
6447 | |
6448 v1 = this; | |
6449 v2 = 0; | |
6450 uRedMask = v1->ddpfPrimareSuface.dwRBitMask; | |
6451 v1->uTargetBBits = 0; | |
6452 v1->uTargetGBits = 0; | |
6453 v1->uTargetRBits = 0; | |
6454 do | |
6455 { | |
6456 if ( (1 << v2) & uRedMask ) | |
6457 ++v1->uTargetRBits; | |
6458 ++v2; | |
6459 } | |
6460 while ( v2 < 16 ); | |
6461 uGreenMask = v1->ddpfPrimareSuface.dwGBitMask; | |
6462 v5 = 0; | |
6463 do | |
6464 { | |
6465 if ( (1 << v5) & uGreenMask ) | |
6466 ++v1->uTargetGBits; | |
6467 ++v5; | |
6468 } | |
6469 while ( v5 < 16 ); | |
6470 uBlueMask = v1->ddpfPrimareSuface.dwBBitMask; | |
6471 v7 = 0; | |
6472 do | |
6473 { | |
6474 if ( (1 << v7) & uBlueMask ) | |
6475 ++v1->uTargetBBits; | |
6476 ++v7; | |
6477 } | |
6478 while ( v7 < 16 ); | |
6479 v8 = v1->ddpfPrimareSuface.dwRBitMask; | |
6480 v1->uTargetGMask = uGreenMask; | |
6481 v1->uTargetRMask = v8; | |
6482 v1->uTargetBMask = uBlueMask; | |
6483 } | |
6484 | |
6485 //----- (004A0F40) -------------------------------------------------------- | |
6486 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | |
6487 { | |
6488 IDirectDrawSurface4 *v4; // esi@1 | |
168 | 6489 HRESULT result; // eax@1 |
0 | 6490 HRESULT v6; // eax@4 |
6491 int v7; // [sp-8h] [bp-14h]@10 | |
6492 unsigned int v8; // [sp-4h] [bp-10h]@10 | |
6493 char v9; // [sp+Bh] [bp-1h]@1 | |
6494 | |
6495 v4 = pSurface; | |
6496 v9 = 1; | |
6497 result = pSurface->Lock(0, pDesc, uLockFlags, 0); | |
6498 if ( result == DDERR_SURFACELOST ) | |
6499 { | |
6500 if (pAsyncMouse) | |
6501 pAsyncMouse->Suspend(); | |
6502 v6 = v4->Restore(); | |
6503 if ( v6 ) | |
6504 { | |
6505 if ( v6 != DDERR_IMPLICITLYCREATED ) | |
6506 { | |
6507 LABEL_20: | |
6508 v9 = 0; | |
6509 result = (bool)memset(pDesc, 0, 4u); | |
6510 goto LABEL_21; | |
6511 } | |
6512 pRenderer->pFrontBuffer4->Restore(); | |
6513 v4->Restore(); | |
6514 } | |
6515 result = v4->Lock(0, pDesc, DDLOCK_WAIT, 0); | |
6516 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
6517 goto LABEL_20; | |
6518 ErrD3D(result); | |
6519 if ( result ) | |
6520 { | |
6521 //v8 = 0; | |
6522 //v7 = 2161; | |
6523 LABEL_19: | |
6524 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
6525 goto LABEL_20; | |
6526 } | |
6527 if ( pRenderer->pRenderD3D ) | |
6528 pRenderD3D->HandleLostResources(); | |
6529 result = pRenderer->pDirectDraw4->RestoreAllSurfaces(); | |
6530 if (pAsyncMouse) | |
6531 pAsyncMouse->Resume(); | |
6532 } | |
6533 else | |
6534 { | |
6535 if ( result ) | |
6536 { | |
6537 if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) | |
6538 goto LABEL_20; | |
6539 ErrD3D(result); | |
6540 //v8 = 0; | |
6541 //v7 = 2199; | |
6542 //goto LABEL_19; | |
6543 } | |
6544 } | |
6545 LABEL_21: | |
6546 LOBYTE(result) = v9; | |
6547 return result; | |
6548 } | |
6549 | |
6550 //----- (004A1032) -------------------------------------------------------- | |
6551 bool Render::LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags) | |
6552 { | |
6553 IDirectDrawSurface2 *v4; // esi@1 | |
6554 bool v5; // eax@1 | |
6555 HRESULT v6; // eax@2 | |
6556 int v7; // [sp-8h] [bp-10h]@8 | |
6557 unsigned int v8; // [sp-4h] [bp-Ch]@8 | |
6558 | |
6559 v4 = pSurface; | |
6560 v5 = pSurface->Lock( | |
6561 0, | |
6562 pDesc, | |
6563 uLockFlags, | |
6564 0); | |
6565 BYTE3(pSurface) = 1; | |
6566 if ( v5 == DDERR_SURFACELOST ) | |
6567 { | |
6568 v6 = v4->Restore(); | |
6569 if ( !v6 ) | |
6570 goto LABEL_5; | |
6571 if ( v6 == DDERR_IMPLICITLYCREATED ) | |
6572 { | |
6573 pRenderer->pFrontBuffer2->Restore(); | |
6574 v4->Restore(); | |
6575 LABEL_5: | |
6576 v5 = v4->Lock(0, pDesc, 1u, 0) != 0; | |
6577 if ( v5 == DDERR_INVALIDRECT || v5 == DDERR_SURFACEBUSY ) | |
6578 goto LABEL_14; | |
6579 if ( !v5 ) | |
6580 return true; | |
6581 ErrD3D(v5); | |
6582 //v8 = 0; | |
6583 //v7 = 2247; | |
6584 goto LABEL_13; | |
6585 } | |
6586 else | |
6587 { | |
6588 pDesc->dwSize = 0; | |
6589 return false; | |
6590 } | |
6591 } | |
6592 else | |
6593 { | |
6594 if ( !v5 ) | |
6595 return true; | |
6596 if ( v5 != DDERR_INVALIDRECT && v5 != DDERR_SURFACEBUSY ) | |
6597 { | |
6598 //v8 = 0; | |
6599 //v7 = 2269; | |
6600 ErrD3D(v5); | |
6601 pDesc->dwSize = 0; | |
6602 return false; | |
6603 LABEL_13: | |
6604 //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, v5, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); | |
6605 goto LABEL_14; | |
6606 } | |
6607 } | |
6608 LABEL_14: | |
6609 return true; | |
6610 } | |
6611 | |
6612 //----- (004A10E4) -------------------------------------------------------- | |
6613 void Render::CreateDirectDraw() | |
6614 { | |
6615 Render *v1; // edi@1 | |
6616 HRESULT v2; // eax@1 | |
6617 HRESULT v3; // eax@5 | |
6618 int v6; // [sp-Ch] [bp-20h]@3 | |
6619 unsigned int v9; // [sp+0h] [bp-14h]@0 | |
6620 IDirectDraw *lpDD; // [sp+10h] [bp-4h]@1 | |
6621 | |
6622 v1 = this; | |
6623 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | |
6624 | |
6625 pDirectDraw2 = nullptr; | |
6626 pDirectDraw4 = nullptr; | |
6627 | |
6628 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6629 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); | |
6630 else | |
6631 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); | |
6632 | |
6633 lpDD->Release(); | |
6634 lpDD = nullptr; | |
6635 } | |
6636 | |
6637 //----- (004A1169) -------------------------------------------------------- | |
6638 void Render::SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen) | |
6639 { | |
6640 DWORD flags; // eax@1 | |
6641 IDirectDraw *v4; // ecx@3 | |
6642 HRESULT v5; // eax@5 | |
6643 int v6; // [sp-8h] [bp-8h]@3 | |
6644 unsigned int v7; // [sp-4h] [bp-4h]@3 | |
6645 | |
6646 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | |
6647 DDSCL_NORMAL; | |
6648 | |
6649 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6650 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); | |
6651 else | |
6652 ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); | |
6653 } | |
6654 | |
6655 //----- (004A11C6) -------------------------------------------------------- | |
6656 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | |
6657 { | |
6658 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6659 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
6660 else | |
6661 ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | |
6662 } | |
6663 | |
6664 //----- (004A121C) -------------------------------------------------------- | |
6665 void Render::CreateFrontBuffer() | |
6666 { | |
6667 Render *v1; // esi@1 | |
6668 IDirectDraw *pDD; // eax@3 | |
6669 IDirectDrawSurface **pOutSurf; // esi@3 | |
6670 struct _DDSURFACEDESC *v4; // edx@3 | |
6671 HRESULT v5; // eax@5 | |
6672 int v6; // [sp-8h] [bp-8Ch]@3 | |
6673 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
6674 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
6675 | |
6676 v1 = this; | |
6677 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6678 { | |
6679 memset(&a2, 0, 0x7Cu); | |
6680 pDD = (IDirectDraw *)v1->pDirectDraw4; | |
6681 a2.dwSize = 124; | |
6682 a2.dwFlags = 1; | |
6683 v7 = 0; | |
6684 a2.ddsCaps.dwCaps = 512; | |
6685 v6 = 2357; | |
6686 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4; | |
6687 v4 = (struct _DDSURFACEDESC *)&a2; | |
6688 } | |
6689 else | |
6690 { | |
6691 memset(&a2.lPitch, 0, 0x6Cu); // DDSURFACEDESC here | |
6692 pDD = (IDirectDraw *)v1->pDirectDraw2; | |
6693 a2.lPitch = 108; | |
6694 a2.dwBackBufferCount = 1; | |
6695 v7 = 0; | |
6696 a2.dwTextureStage = 512; | |
6697 v6 = 2346; | |
6698 pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2; | |
6699 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; | |
6700 } | |
6701 ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0)); | |
6702 } | |
6703 | |
6704 //----- (004A12CD) -------------------------------------------------------- | |
6705 void Render::CreateBackBuffer() | |
6706 { | |
6707 Render *v1; // esi@1 | |
6708 IDirectDraw *v2; // eax@3 | |
6709 IDirectDrawSurface **ppBackBuffer; // esi@3 | |
6710 struct _DDSURFACEDESC *v4; // edx@3 | |
6711 HRESULT v5; // eax@5 | |
6712 int v6; // [sp-8h] [bp-8Ch]@3 | |
6713 unsigned int v7; // [sp-4h] [bp-88h]@3 | |
6714 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | |
6715 | |
6716 v1 = this; | |
6717 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6718 { | |
6719 memset(&a2, 0, 0x7Cu); | |
6720 v2 = (IDirectDraw *)v1->pDirectDraw4; | |
6721 a2.dwSize = 124; | |
6722 a2.dwFlags = 7; | |
6723 v7 = 0; | |
6724 a2.ddsCaps.dwCaps = 2112; | |
6725 a2.dwWidth = 640; | |
6726 a2.dwHeight = 480; | |
6727 v6 = 2387; | |
6728 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
6729 v4 = (struct _DDSURFACEDESC *)&a2; | |
6730 } | |
6731 else | |
6732 { | |
6733 memset(&a2.lPitch, 0, 0x6Cu); | |
6734 v2 = (IDirectDraw *)v1->pDirectDraw2; | |
6735 a2.lPitch = 108; | |
6736 a2.dwBackBufferCount = 7; | |
6737 v7 = 0; | |
6738 a2.dwTextureStage = 2112; | |
6739 a2.dwAlphaBitDepth = 640; | |
6740 a2.dwMipMapCount = 480; | |
6741 v6 = 2374; | |
6742 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
6743 v4 = (struct _DDSURFACEDESC *)&a2.lPitch; // //DDSURFACEDESC here fo ddraw2 | |
6744 } | |
6745 ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0)); | |
6746 } | |
6747 | |
6748 //----- (004A139A) -------------------------------------------------------- | |
6749 void Render::CreateDirectDrawPrimarySurface() | |
6750 { | |
6751 Render *v1; // esi@1 | |
6752 int v2; // ebx@3 | |
6753 IDirectDraw2 *v3; // eax@3 | |
6754 HRESULT v4; // eax@3 | |
6755 IDirectDrawSurface *pFrontBuffer; // eax@3 | |
6756 DDSCAPS2 *v6; // edx@3 | |
6757 IDirectDraw4 *v7; // eax@4 | |
6758 HRESULT v8; // eax@4 | |
6759 int v9; // ST14_4@5 | |
6760 IDirectDrawSurface *v10; // ST10_4@5 | |
6761 HRESULT v11; // eax@5 | |
6762 IDirectDrawSurface **ppBackBuffer; // [sp-4h] [bp-A4h]@3 | |
6763 const char *v13; // [sp+0h] [bp-A0h]@0 | |
6764 int v14; // [sp+4h] [bp-9Ch]@0 | |
6765 unsigned int v15; // [sp+8h] [bp-98h]@0 | |
6766 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | |
6767 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | |
6768 int a4; // [sp+98h] [bp-8h]@3 | |
6769 | |
6770 v1 = this; | |
6771 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6772 { | |
6773 v2 = 0; | |
6774 this->field_4004C = 1; | |
6775 memset(&ddsd2, 0, 0x7Cu); | |
6776 v7 = v1->pDirectDraw4; | |
6777 ddsd2.dwBackBufferCount = 1; | |
6778 ddsd2.dwSize = 0x7Cu; | |
6779 ddsd2.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | |
6780 ddsd2.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_3DDEVICE | DDSCAPS_PRIMARYSURFACE; | |
6781 ErrD3D(v7->CreateSurface( | |
6782 &ddsd2, | |
6783 &pFrontBuffer4, | |
6784 0)); | |
6785 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4; | |
6786 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4; | |
6787 } | |
6788 else | |
6789 { | |
6790 v2 = 0; | |
6791 this->field_4004C = 1; | |
6792 | |
6793 DDSURFACEDESC ddsd; | |
6794 memset(&ddsd, 0, sizeof(DDSURFACEDESC)); | |
6795 | |
6796 ddsd.lpSurface = (LPVOID)1; | |
6797 ddsd.lPitch = 108; | |
6798 ddsd.dwBackBufferCount = 33; | |
6799 ddsd.ddsCaps.dwCaps = 8728; | |
6800 ErrD3D(pDirectDraw2->CreateSurface( | |
6801 &ddsd, | |
6802 (IDirectDrawSurface **)&pFrontBuffer2, | |
6803 0)); | |
6804 | |
6805 pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; | |
6806 ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; | |
6807 } | |
6808 v9 = (int)v6; | |
6809 v10 = pFrontBuffer; // BUG | |
6810 | |
6811 v17.dwCaps = 4; | |
6812 ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));// hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer); | |
6813 //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer); | |
6814 v1->field_40030 = v2; | |
6815 v1->field_18_locked_pitch = v2; | |
6816 } | |
6817 | |
6818 //----- (004A14F4) -------------------------------------------------------- | |
6819 void Render::CreateClipper(HWND a2) | |
6820 { | |
6821 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6822 { | |
6823 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); | |
6824 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
6825 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | |
6826 } | |
6827 else | |
6828 { | |
6829 ErrD3D(pDirectDraw2->CreateClipper(0, &pDDrawClipper, 0)); | |
6830 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | |
6831 } | |
6832 } | |
6833 | |
6834 //----- (004A15D8) -------------------------------------------------------- | |
6835 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | |
6836 { | |
6837 IDirectDrawSurface *v2; // eax@3 | |
6838 | |
6839 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6840 v2 = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6841 else | |
6842 v2 = (IDirectDrawSurface *)this->pFrontBuffer2; | |
6843 v2->GetPixelFormat(pOut); | |
6844 } | |
6845 | |
6846 //----- (004A1605) -------------------------------------------------------- | |
6847 void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) | |
6848 { | |
6849 Render *v3; // esi@1 | |
6850 signed int v4; // eax@3 | |
6851 | |
6852 v3 = this; | |
6853 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6854 { | |
6855 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
6856 memset(&pDesc, 0, 0x7Cu); | |
6857 pDesc.dwSize = 124; | |
168 | 6858 LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 6859 *pOutSurfacePtr = pDesc.lpSurface; |
6860 v4 = pDesc.lPitch; | |
6861 } | |
6862 else | |
6863 { | |
6864 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
6865 memset(&pDesc.lPitch, 0, 0x6Cu); | |
6866 pDesc.lPitch = 108; | |
6867 LockSurface_DDraw2(v3->pBackBuffer2, &pDesc, 1u); | |
6868 *pOutSurfacePtr = (void *)pDesc.lpSurface; | |
6869 v4 = pDesc.dwReserved; | |
6870 } | |
6871 *pOutPixelsPerRow = v4 >> 1; | |
6872 } | |
6873 | |
6874 //----- (004A169E) -------------------------------------------------------- | |
6875 bool Render::UsingDirect3D() | |
6876 { | |
6877 return bUserDirect3D == 0; | |
6878 } | |
6879 | |
6880 //----- (004A16E1) -------------------------------------------------------- | |
6881 void Render::UnlockBackBuffer() | |
6882 { | |
6883 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6884 ErrD3D(pBackBuffer4->Unlock(0)); | |
6885 else | |
6886 ErrD3D(pBackBuffer2->Unlock(0)); | |
6887 } | |
6888 | |
6889 //----- (004A172E) -------------------------------------------------------- | |
6890 void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) | |
6891 { | |
6892 Render *v3; // esi@1 | |
6893 signed int v4; // eax@3 | |
6894 | |
6895 v3 = this; | |
6896 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6897 { | |
6898 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | |
6899 memset(&pDesc, 0, 0x7Cu); | |
6900 pDesc.dwSize = 124; | |
168 | 6901 LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, DDLOCK_WAIT); |
0 | 6902 *pOutSurface = pDesc.lpSurface; |
6903 v4 = pDesc.lPitch; | |
6904 } | |
6905 else | |
6906 { | |
6907 DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 | |
6908 memset(&pDesc.lPitch, 0, 0x6Cu); | |
6909 pDesc.lPitch = 108; | |
6910 LockSurface_DDraw2(v3->pFrontBuffer2, &pDesc, 1u); | |
6911 *pOutSurface = (void *)pDesc.lpSurface; | |
6912 v4 = pDesc.dwReserved; | |
6913 } | |
6914 *pOutPixelsPerRow = v4 >> 1; | |
6915 } | |
6916 | |
6917 //----- (004A17C7) -------------------------------------------------------- | |
6918 void Render::UnlockFrontBuffer() | |
6919 { | |
6920 IDirectDrawSurface *pFront; // eax@3 | |
6921 HRESULT v2; // eax@5 | |
6922 signed int v3; // [sp-8h] [bp-Ch]@3 | |
6923 int v4; // [sp-4h] [bp-8h]@3 | |
6924 | |
6925 auto a5 = this; | |
6926 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6927 { | |
6928 pFront = (IDirectDrawSurface *)a5->pFrontBuffer4; | |
6929 v4 = 0; | |
6930 v3 = 2615; | |
6931 } | |
6932 else | |
6933 { | |
6934 pFront = (IDirectDrawSurface *)a5->pFrontBuffer2; | |
6935 v4 = 0; | |
6936 v3 = 2611; | |
6937 } | |
6938 ErrD3D(pFront->Unlock(0)); | |
6939 } | |
6940 | |
6941 //----- (004A1814) -------------------------------------------------------- | |
6942 void Render::RestoreFrontBuffer() | |
6943 { | |
6944 IDirectDrawSurface **v1; // esi@2 | |
6945 | |
6946 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
6947 || (v1 = (IDirectDrawSurface **)&this->pFrontBuffer2, pVersion->pVersionInfo.dwMajorVersion >= 5u) ) | |
6948 v1 = (IDirectDrawSurface **)&this->pFrontBuffer4; | |
6949 if ( (*v1)->IsLost() == DDERR_SURFACELOST ) | |
6950 (*v1)->Restore(); | |
6951 } | |
6952 | |
6953 //----- (004A184C) -------------------------------------------------------- | |
6954 HRESULT Render::_4A184C() | |
6955 { | |
6956 IDirectDrawSurface **pBack; // esi@2 | |
6957 HRESULT result; // eax@4 | |
6958 | |
6959 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT | |
6960 || (pBack = (IDirectDrawSurface **)&this->pBackBuffer2, pVersion->pVersionInfo.dwMajorVersion != 4) ) | |
6961 pBack = (IDirectDrawSurface **)&this->pBackBuffer4; | |
6962 result = (*pBack)->IsLost(); | |
6963 if ( result == DDERR_SURFACELOST ) | |
6964 result = (*pBack)->Restore(); | |
6965 return result; | |
6966 } | |
6967 | |
6968 //----- (004A1884) -------------------------------------------------------- | |
6969 void Render::PresentRect(RECT *a2, RECT *a3) | |
6970 { | |
6971 IDirectDrawSurface *pFront; // eax@3 | |
6972 HRESULT v4; // eax@5 | |
6973 IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3 | |
6974 struct tagRECT *v6; // [sp-18h] [bp-18h]@3 | |
6975 DWORD v7; // [sp-14h] [bp-14h]@3 | |
6976 DDBLTFX *v8; // [sp-10h] [bp-10h]@3 | |
6977 const char *v9; // [sp-Ch] [bp-Ch]@3 | |
6978 int v10; // [sp-8h] [bp-8h]@3 | |
6979 unsigned int v11; // [sp-4h] [bp-4h]@3 | |
6980 | |
6981 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
6982 { | |
6983 v11 = 0; | |
6984 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
6985 v10 = 2657; | |
6986 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
6987 v8 = 0; | |
6988 v7 = DDBLT_WAIT; | |
6989 v6 = a3; | |
6990 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
6991 } | |
6992 else | |
6993 { | |
6994 v11 = 0; | |
6995 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
6996 v10 = 2653; | |
6997 v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; | |
6998 v8 = 0; | |
6999 v7 = DDBLT_WAIT; | |
7000 v6 = a3; | |
7001 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
7002 } | |
7003 ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8)); | |
7004 } | |
7005 | |
7006 //----- (004A18F5) -------------------------------------------------------- | |
7007 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) | |
7008 { | |
7009 IDirectDrawSurface *pFront; // eax@3 | |
7010 HRESULT v6; // eax@5 | |
7011 int v7; // [sp-8h] [bp-8h]@3 | |
7012 unsigned int v8; // [sp-4h] [bp-4h]@3 | |
7013 | |
7014 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) | |
7015 ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
7016 else | |
7017 ErrD3D(pFrontBuffer2->Blt(pDstRect, (IDirectDrawSurface2 *)pSrcSurface, pSrcRect, uBltFlags, nullptr)); | |
7018 } | |
7019 | |
7020 //----- (004A194A) -------------------------------------------------------- | |
7021 void Render::BltBackToFontFast(int a2, int a3, RECT *a4) | |
7022 { | |
7023 IDirectDrawSurface *pFront; // eax@3 | |
7024 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 | |
7025 | |
7026 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
7027 { | |
7028 pFront = (IDirectDrawSurface *)this->pFrontBuffer4; | |
7029 pBack = (IDirectDrawSurface *)this->pBackBuffer4; | |
7030 } | |
7031 else | |
7032 { | |
7033 pFront = (IDirectDrawSurface *)this->pFrontBuffer2; | |
7034 pBack = (IDirectDrawSurface *)this->pBackBuffer2; | |
7035 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7036 pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); |
0 | 7037 } |
7038 | |
7039 //----- (004A1B22) -------------------------------------------------------- | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7040 unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7041 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7042 //unsigned int v2; // ebx@1 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7043 //double v4; // st7@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7044 //unsigned int v5; // esi@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7045 //int v6; // ecx@5 |
0 | 7046 unsigned int v7; // edx@6 |
7047 char *v8; // ecx@12 | |
7048 void *v9; // edi@16 | |
7049 unsigned int v10; // eax@16 | |
7050 void *v11; // edi@21 | |
7051 unsigned int v12; // eax@21 | |
7052 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7053 //v2 = uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7054 if (uNumBillboardsToDraw >= 999 ) |
0 | 7055 return 0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7056 if (!uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7057 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7058 uNumBillboardsToDraw = 1; |
0 | 7059 return 0; |
7060 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7061 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7062 //v4 = *(float *)&a1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7063 //v5 = pRenderer->uNumBillboardsToDraw; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7064 //v6 = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7065 for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7066 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7067 v7 = left + (right - left) / 2; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7068 if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7069 right = v7; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7070 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7071 left = v7 + 1; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7072 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7073 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7074 v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].z_order; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7075 if (z > *(float *)v8 ) |
0 | 7076 { |
7077 if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) | |
7078 { | |
7079 v7 = pRenderer->uNumBillboardsToDraw; | |
7080 } | |
7081 else | |
7082 { | |
7083 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
7084 { | |
7085 v9 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
7086 v10 = pRenderer->uNumBillboardsToDraw - v7; | |
7087 do | |
7088 { | |
7089 memcpy(v9, (char *)v9 - 156, 0x9Cu); | |
7090 v9 = (char *)v9 - 156; | |
7091 --v10; | |
7092 } | |
7093 while ( v10 ); | |
7094 } | |
7095 ++v7; | |
7096 } | |
717 | 7097 //LABEL_23: |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7098 uNumBillboardsToDraw++; |
0 | 7099 return v7; |
7100 } | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
7101 if (z <= *(float *)v8 ) |
0 | 7102 { |
7103 if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) | |
7104 { | |
7105 v11 = &pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw]; | |
7106 v12 = pRenderer->uNumBillboardsToDraw - v7; | |
7107 do | |
7108 { | |
7109 memcpy(v11, (char *)v11 - 156, 0x9Cu); | |
7110 v11 = (char *)v11 - 156; | |
7111 --v12; | |
7112 } | |
7113 while ( v12 ); | |
7114 } | |
717 | 7115 //goto LABEL_23; |
7116 uNumBillboardsToDraw++; | |
7117 return v7; | |
0 | 7118 } |
7119 return v7; | |
7120 } | |
7121 | |
7122 //----- (004A1E9D) -------------------------------------------------------- | |
7123 unsigned int Render::GetBillboardDrawListSize() | |
7124 { | |
7125 return pRenderer->uNumBillboardsToDraw; | |
7126 } | |
7127 | |
7128 //----- (004A1EA3) -------------------------------------------------------- | |
7129 unsigned int Render::GetParentBillboardID(unsigned int uBillboardID) | |
7130 { | |
7131 return pRenderer->pBillboardRenderListD3D[uBillboardID].uParentBillboardID; | |
7132 } | |
7133 | |
7134 //----- (004A1EB6) -------------------------------------------------------- | |
7135 void Render::BeginSceneD3D() | |
7136 { | |
7137 if (!uNumD3DSceneBegins++) | |
7138 { | |
7139 if (pRenderD3D) | |
7140 { | |
7141 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); | |
7142 pRenderer->uNumBillboardsToDraw = 0; | |
7143 pRenderD3D->pDevice->BeginScene(); | |
7144 if (!pRenderD3D->DoesRaiseExceptions()) | |
7145 { | |
7146 MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0); | |
7147 } | |
7148 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
7149 uFogColor = GetLevelFogColor(); | |
7150 else | |
7151 uFogColor = 0; | |
7152 | |
7153 if ( uFogColor & 0xFF000000 ) | |
7154 { | |
7155 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
7156 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF); | |
7157 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0); | |
7158 bUsingSpecular = true; | |
7159 } | |
7160 else | |
7161 { | |
7162 pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
7163 bUsingSpecular = 0; | |
7164 } | |
7165 } | |
7166 else | |
7167 { | |
7168 LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch); | |
7169 if (pTargetSurface) | |
7170 field_18_locked_pitch = uTargetSurfacePitch; | |
7171 else | |
7172 --uNumD3DSceneBegins; | |
7173 } | |
7174 } | |
7175 } | |
7176 | |
7177 //----- (004A1FE1) -------------------------------------------------------- | |
7178 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() | |
7179 { | |
7180 --uNumD3DSceneBegins; | |
7181 if (uNumD3DSceneBegins) | |
7182 return; | |
7183 | |
7184 if (pRenderD3D) | |
7185 { | |
7186 pGame->draw_debug_outlines(); | |
161 | 7187 DoRenderBillboards_D3D(); |
0 | 7188 pGame->pStru6Instance->RenderSpecialEffects(); |
7189 pRenderD3D->pDevice->EndScene(); | |
7190 } | |
7191 else | |
7192 pGame->pStru6Instance->RenderSpecialEffects(); | |
7193 } | |
7194 | |
7195 //----- (004A2031) -------------------------------------------------------- | |
349 | 7196 unsigned int Render::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) |
7197 { | |
638 | 7198 __debugbreak(); // should not fire outside decal builder |
349 | 7199 return ::GetActorTintColor(tint, a4, a2, a5, a6); |
0 | 7200 } |
7201 | |
186 | 7202 /*void Render::DrawTerrainPolygon_new(stru148 *a3, IDirect3DTexture2 *pTexture)//new function |
86 | 7203 { |
7204 int v5; // ebx@1 | |
7205 int v6; // edi@1 | |
7206 int v8; // eax@7 | |
7207 float v9; // eax@12 | |
7208 float *v10; // esi@12 | |
7209 float v11; // ecx@14 | |
7210 double v12; // st7@14 | |
7211 double v13; // st7@14 | |
7212 double v14; // st7@14 | |
7213 signed int v15; // eax@14 | |
7214 int v16; // eax@15 | |
7215 float v17; // ST48_4@15 | |
7216 char v18; // zf@17 | |
7217 int v19; // eax@18 | |
7218 int v20; // eax@18 | |
7219 int v21; // edx@20 | |
7220 signed int v22; // ecx@20 | |
7221 int v23; // eax@20 | |
7222 const char *v24; // ST4C_4@20 | |
7223 unsigned int v25; // ST50_4@20 | |
7224 int v26; // ST54_4@20 | |
7225 int v27; // eax@20 | |
7226 _UNKNOWN *v28; // eax@21 | |
7227 int v29; // ecx@23 | |
7228 int v30; // eax@23 | |
7229 int v31; // eax@23 | |
7230 int v32; // eax@24 | |
7231 int v33; // eax@25 | |
7232 int v34; // eax@25 | |
7233 int v35; // eax@25 | |
7234 int v36; // eax@25 | |
7235 signed int v37; // ecx@26 | |
7236 int v38; // eax@26 | |
7237 _UNKNOWN *v39; // eax@27 | |
7238 int v40; // edx@28 | |
7239 int v41; // eax@29 | |
7240 int v42; // eax@29 | |
7241 int v43; // eax@29 | |
7242 int v44; // eax@29 | |
7243 unsigned int v46; // eax@29 | |
7244 int v47; // eax@30 | |
7245 int v48; // eax@30 | |
7246 int v49; // eax@30 | |
7247 double v52; // st6@35 | |
7248 const char *v55; // [sp+4Ch] [bp-1Ch]@20 | |
7249 int v57; // [sp+5Ch] [bp-Ch]@3 | |
7250 signed int v59; // [sp+60h] [bp-8h]@12 | |
7251 int v61; // [sp+64h] [bp-4h]@4 | |
7252 int i; | |
7253 | |
7254 v6 = (int)this; | |
7255 v5 = 0; | |
7256 if (!this->uNumD3DSceneBegins) | |
7257 return; | |
7258 | |
7259 | |
7260 | |
7261 | |
186 | 7262 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
86 | 7263 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); |
7264 if (this->bUsingSpecular) | |
7265 { | |
186 | 7266 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
7267 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
7268 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
86 | 7269 } |
7270 | |
7271 pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; | |
7272 pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; | |
7273 pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7274 pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); | |
7275 pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); | |
7276 pVertices[0].specular = 0; | |
7277 pVertices[0].texcoord.x = array_50AC10[0].u; | |
7278 pVertices[0].texcoord.y = array_50AC10[0].v; | |
7279 | |
7280 pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; | |
7281 pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; | |
7282 pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7283 pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); | |
7284 pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); | |
7285 pVertices[1].specular = 0; | |
7286 pVertices[1].texcoord.x = array_50AC10[3].u; | |
7287 pVertices[1].texcoord.y = array_50AC10[3].v; | |
7288 | |
7289 pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; | |
7290 pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; | |
7291 pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7292 pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); | |
7293 pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); | |
7294 pVertices[2].specular = 0; | |
7295 pVertices[2].texcoord.x = array_50AC10[1].u; | |
7296 pVertices[2].texcoord.y = array_50AC10[1].v; | |
7297 | |
7298 memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); | |
7299 memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); | |
7300 | |
7301 pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; | |
7302 pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; | |
7303 pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); | |
7304 pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); | |
7305 pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); | |
7306 pVertices[5].specular = 0; | |
7307 pVertices[5].texcoord.x = array_50AC10[2].u; | |
7308 pVertices[5].texcoord.y = array_50AC10[2].v; | |
7309 | |
7310 | |
7311 this->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7312 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); | |
7313 | |
186 | 7314 }*/ |
7315 | |
0 | 7316 //----- (004A26BC) -------------------------------------------------------- |
186 | 7317 void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) |
7318 { | |
7319 //RenderVertexSoft *pVertices; // esi@0 | |
7320 //int v7; // edi@1 | |
0 | 7321 unsigned int v8; // ebx@1 |
7322 LightmapBuilder *v9; // esi@3 | |
7323 unsigned int v10; // edx@3 | |
7324 int v11; // eax@5 | |
7325 int v12; // eax@11 | |
7326 char *v13; // esi@11 | |
7327 double v14; // st7@13 | |
7328 double v15; // st7@13 | |
7329 signed int v16; // eax@13 | |
7330 int v17; // ecx@13 | |
7331 double v18; // st7@13 | |
7332 float v19; // ST78_4@14 | |
7333 int v20; // eax@14 | |
7334 char v21; // zf@16 | |
7335 HRESULT v22; // eax@17 | |
7336 HRESULT v23; // eax@17 | |
7337 HRESULT v24; // eax@19 | |
7338 HRESULT v25; // eax@19 | |
7339 unsigned int v26; // ecx@19 | |
7340 char *v27; // eax@20 | |
7341 HRESULT v28; // eax@22 | |
7342 HRESULT v29; // eax@22 | |
7343 HRESULT v30; // eax@23 | |
7344 HRESULT v31; // eax@24 | |
7345 HRESULT v32; // eax@24 | |
7346 HRESULT v33; // eax@24 | |
7347 HRESULT v34; // eax@24 | |
7348 HRESULT v35; // eax@25 | |
7349 HRESULT v36; // eax@25 | |
7350 unsigned int v37; // ecx@25 | |
7351 char *v38; // eax@26 | |
7352 int v39; // edx@27 | |
7353 HRESULT v40; // eax@28 | |
7354 HRESULT v41; // eax@28 | |
7355 HRESULT v42; // eax@28 | |
7356 HRESULT v43; // eax@28 | |
7357 //IDirect3DDevice3Vtbl *v44; // ebx@28 | |
7358 unsigned int v45; // eax@28 | |
7359 HRESULT v46; // eax@29 | |
7360 HRESULT v47; // eax@29 | |
7361 HRESULT v48; // eax@29 | |
186 | 7362 //IDirect3DDevice3 *v49; // eax@35 |
0 | 7363 //IDirect3DDevice3Vtbl *v50; // ecx@35 |
7364 int v51; // eax@40 | |
7365 char *v52; // esi@40 | |
7366 double v53; // st7@42 | |
7367 double v54; // st7@42 | |
7368 signed int v55; // eax@42 | |
7369 int v56; // ecx@42 | |
7370 double v57; // st7@42 | |
7371 float v58; // ST7C_4@43 | |
7372 int v59; // eax@43 | |
186 | 7373 //signed int v60; // [sp+78h] [bp-14h]@31 |
7374 //RenderVertexSoft *v61; // [sp+7Ch] [bp-10h]@3 | |
0 | 7375 const char *v62; // [sp+80h] [bp-Ch]@0 |
7376 const char *v63; // [sp+80h] [bp-Ch]@19 | |
7377 int v64; // [sp+84h] [bp-8h]@0 | |
7378 LightmapBuilder *v65; // [sp+88h] [bp-4h]@3 | |
7379 unsigned int v66; // [sp+88h] [bp-4h]@40 | |
7380 unsigned int a6a; // [sp+A0h] [bp+14h]@11 | |
186 | 7381 int a7; |
7382 | |
7383 //v7 = (int)this; | |
0 | 7384 v8 = 0; |
186 | 7385 if (!this->uNumD3DSceneBegins) |
75 | 7386 return; |
7387 if ( uNumVertices < 3) | |
7388 return; | |
7389 | |
186 | 7390 //v61 = pVertices; |
7391 | |
75 | 7392 /* v9 = pGame->pLightmapBuilder; |
0 | 7393 v65 = v9; |
75 | 7394 v10 = v9->std__vector_000004_size;*/ |
0 | 7395 if ( byte_4D864C && pGame->uFlags & 1 ) |
7396 { | |
638 | 7397 v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); |
75 | 7398 pGame->pLightmapBuilder->_45D74F_MessWithLight(v11, 0); |
0 | 7399 } |
7400 else | |
7401 { | |
186 | 7402 if (transparent || !pGame->pLightmapBuilder->std__vector_000004_size || |
75 | 7403 byte_4D864C && pGame->uFlags & 2 ) |
7404 { | |
186 | 7405 if (clampAtTextureBorders) |
7406 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); | |
0 | 7407 else |
186 | 7408 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
7409 | |
7410 if (transparent || this->bUsingSpecular) | |
7411 { | |
7412 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); | |
7413 if (transparent) | |
0 | 7414 { |
186 | 7415 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA); |
7416 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); | |
7417 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); | |
7418 //this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); | |
0 | 7419 } |
7420 else | |
7421 { | |
186 | 7422 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); |
7423 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
0 | 7424 } |
186 | 7425 } |
7426 if (uNumVertices > 0) | |
7427 { | |
7428 v51 = (int)&d3d_vertex_buffer[0].pos.y; | |
0 | 7429 v52 = (char *)&array_50AC10[0].vWorldViewPosition; |
186 | 7430 a7 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 7431 v66 = uNumVertices; |
7432 while ( 1 ) | |
7433 { | |
7434 v53 = *(float *)v52 * 1000.0; | |
7435 *(int *)(v51 - 4) = *((int *)v52 + 3); | |
7436 v54 = v53 / (double)pOutdoorCamera->shading_dist_mist; | |
7437 *(int *)v51 = *((int *)v52 + 4); | |
7438 *(float *)(v51 + 4) = 1.0 - 1.0 / v54; | |
7439 *(float *)(v51 + 8) = 1.0 / (*(float *)v52 + 0.0000001); | |
638 | 7440 v55 = ::GetActorTintColor(a4->dimming_level, 0, *(float *)v52, 0, 0); |
0 | 7441 v56 = a7; |
7442 v57 = *(float *)v52; | |
7443 *(int *)(a7 + 12) = v55; | |
75 | 7444 if ( this->bUsingSpecular ) |
0 | 7445 { |
7446 v58 = v57; | |
7447 v59 = sub_47C3D7_get_fog_related_stuff(0, 0, v58); | |
7448 v56 = a7; | |
7449 } | |
7450 else | |
7451 { | |
7452 v59 = 0; | |
7453 } | |
7454 *(int *)(v56 + 16) = v59; | |
7455 *(int *)(v56 + 20) = *((int *)v52 + 6); | |
7456 *(int *)(v56 + 24) = *((int *)v52 + 7); | |
7457 v52 += 48; | |
7458 v21 = v66-- == 1; | |
7459 a7 = v56 + 32; | |
7460 if ( v21 ) | |
7461 break; | |
7462 v51 = a7; | |
7463 } | |
7464 } | |
86 | 7465 this->pRenderD3D->pDevice->SetTexture(0, a5); |
186 | 7466 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); |
7467 if (transparent) | |
7468 { | |
7469 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
7470 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
7471 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 7472 } |
7473 } | |
7474 else | |
7475 { | |
7476 if ( (signed int)uNumVertices > 0 ) | |
7477 { | |
186 | 7478 v12 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 7479 v13 = (char *)&array_50AC10[0].vWorldViewPosition; |
186 | 7480 a7 = (int)&d3d_vertex_buffer[0].pos.y; |
0 | 7481 a6a = uNumVertices; |
7482 while ( 1 ) | |
7483 { | |
7484 v14 = *(float *)v13 * 1000.0; | |
7485 *(int *)(v12 - 4) = *((int *)v13 + 3); | |
7486 v15 = v14 / (double)pOutdoorCamera->shading_dist_mist; | |
7487 *(int *)v12 = *((int *)v13 + 4); | |
7488 *(float *)(v12 + 4) = 1.0 - 1.0 / v15; | |
7489 *(float *)(v12 + 8) = 1.0 / (*(float *)v13 + 0.0000001); | |
638 | 7490 v16 = GetActorTintColor(a4->dimming_level, 0, *(float *)v13, 0, 0); |
0 | 7491 v17 = a7; |
7492 v18 = *(float *)v13; | |
7493 *(int *)(a7 + 12) = v16; | |
75 | 7494 if ( this->bUsingSpecular ) |
0 | 7495 { |
7496 v19 = v18; | |
7497 v20 = sub_47C3D7_get_fog_related_stuff(0, 0, v19); | |
7498 v17 = a7; | |
7499 } | |
7500 else | |
7501 { | |
7502 v20 = 0; | |
7503 } | |
7504 *(int *)(v17 + 16) = v20; | |
7505 *(int *)(v17 + 20) = *((int *)v13 + 6); | |
7506 *(int *)(v17 + 24) = *((int *)v13 + 7); | |
7507 v13 += 48; | |
7508 v21 = a6a-- == 1; | |
7509 a7 = v17 + 32; | |
7510 if ( v21 ) | |
7511 break; | |
7512 v12 = a7; | |
7513 } | |
7514 } | |
186 | 7515 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); |
7516 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
7517 if (pRenderer->bUsingSpecular) | |
7518 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); | |
0 | 7519 |
7520 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 7521 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7522 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7523 d3d_vertex_buffer, |
0 | 7524 uNumVertices, |
7525 16)); | |
7526 //v63 = (const char *)v7->pRenderD3D->pDevice; | |
186 | 7527 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
0 | 7528 //(*(void (**)(void))(*(int *)v63 + 88))(); |
7529 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
7530 v26 = uNumVertices; | |
7531 if ( (signed int)uNumVertices > 0 ) | |
7532 { | |
186 | 7533 v27 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 7534 do |
7535 { | |
7536 *(int *)v27 = -1; | |
7537 v27 += 32; | |
7538 --v26; | |
7539 } | |
7540 while ( v26 ); | |
7541 } | |
7542 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); | |
186 | 7543 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7544 if ( !pRenderer->bUsingSpecular ) |
7545 { | |
186 | 7546 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
7547 } | |
7548 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
7549 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
7550 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
7551 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7552 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7553 d3d_vertex_buffer, |
0 | 7554 uNumVertices, |
7555 16)); | |
7556 if ( pRenderer->bUsingSpecular ) | |
7557 { | |
186 | 7558 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); |
0 | 7559 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
7560 v37 = uNumVertices; | |
7561 if ( (signed int)uNumVertices > 0 ) | |
7562 { | |
186 | 7563 v38 = (char *)&d3d_vertex_buffer[0].specular; |
0 | 7564 do |
7565 { | |
7566 v39 = *(int *)v38; | |
7567 *(int *)v38 = 0; | |
7568 v38 += 32; | |
7569 --v37; | |
7570 *((int *)v38 - 9) = pRenderer->uFogColor | v39 & 0xFF000000; | |
7571 } | |
7572 while ( v37 ); | |
7573 } | |
75 | 7574 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem |
186 | 7575 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); |
7576 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); | |
7577 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7578 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7579 d3d_vertex_buffer, |
0 | 7580 uNumVertices, |
7581 16)); | |
186 | 7582 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 7583 //v44 = pRenderer->pRenderD3D->pDevice; |
7584 v45 = GetLevelFogColor(); | |
7585 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v45 & 0xFFFFFF)); | |
7586 v8 = 0; | |
7587 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
7588 } | |
186 | 7589 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
7590 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
0 | 7591 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, v8)); |
7592 } | |
7593 } | |
186 | 7594 |
791 | 7595 if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) |
186 | 7596 pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); |
0 | 7597 } |
7598 // 4A26BC: could not find valid save-restore pair for esi | |
7599 // 4D864C: using guessed type char byte_4D864C; | |
7600 | |
7601 //----- (004A2DA3) -------------------------------------------------------- | |
67 | 7602 void Render::DrawStrip(unsigned int uNumVertices, struct stru148 *a3, IDirect3DTexture2 *pTexture) |
7603 { | |
840 | 7604 //int v4; // ebx@1 |
67 | 7605 int v7; // eax@7 |
7606 float v12; // ST3C_4@8 | |
7607 int i; | |
7608 | |
840 | 7609 //v4 = (int)this; |
67 | 7610 if (!this->uNumD3DSceneBegins) |
7611 return; | |
7612 | |
7613 if (uNumVertices >= 3) | |
7614 { | |
186 | 7615 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 7616 if (this->bUsingSpecular) |
7617 { | |
186 | 7618 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
7619 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
7620 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 7621 } |
7622 | |
7623 for (i = 0; i < uNumVertices; ++i) | |
7624 { | |
7625 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
7626 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
7627 pVertices[i].pos.z = 0.99989998; | |
168 | 7628 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 7629 |
638 | 7630 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, true, false); |
67 | 7631 v7 = 0; |
7632 if (this->bUsingSpecular) | |
7633 { | |
7634 v12 = array_50AC10[i].vWorldViewPosition.x; | |
7635 v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v12); | |
7636 } | |
7637 pVertices[i].specular = v7; | |
7638 pVertices[i].texcoord.x = array_50AC10[i].u; | |
7639 pVertices[i].texcoord.y = array_50AC10[i].v; | |
7640 } | |
7641 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
840 | 7642 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
7643 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); | |
67 | 7644 } |
7645 } | |
781 | 7646 |
67 | 7647 //----- (004A2DA3) -------------------------------------------------------- |
7648 void Render::DrawFan(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *pTexture) | |
7649 { | |
840 | 7650 //int v4; // ebx@1 |
67 | 7651 int v7; // eax@7 |
0 | 7652 float v13; // ST3C_4@8 |
67 | 7653 int i; |
7654 | |
840 | 7655 //v4 = (int)this; |
67 | 7656 if ( !this->uNumD3DSceneBegins ) |
7657 return; | |
7658 if ( uNumVertices >= 3 ) | |
7659 { | |
186 | 7660 this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); |
67 | 7661 if ( this->bUsingSpecular ) |
7662 { | |
186 | 7663 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); |
7664 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); | |
7665 this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); | |
67 | 7666 } |
840 | 7667 for ( i = 0; i < uNumVertices; ++i ) |
67 | 7668 { |
7669 pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; | |
7670 pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; | |
7671 pVertices[i].pos.z = 0.99989998; | |
168 | 7672 pVertices[i].rhw = array_50AC10[i]._rhw; |
67 | 7673 |
840 | 7674 pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); |
67 | 7675 v7 = 0; |
7676 if (this->bUsingSpecular) | |
7677 { | |
7678 v13 = array_50AC10[i].vWorldViewPosition.x; | |
7679 v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v13); | |
7680 } | |
7681 pVertices[i].specular = v7; | |
7682 pVertices[i].texcoord.x = array_50AC10[i].u; | |
7683 pVertices[i].texcoord.y = array_50AC10[i].v; | |
7684 } | |
7685 pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); | |
7686 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
840 | 7687 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); |
0 | 7688 } |
7689 } | |
7690 | |
7691 //----- (004A2ED5) -------------------------------------------------------- | |
7692 void Render::_4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex) | |
7693 { | |
7694 signed int v4; // edi@2 | |
7695 int v5; // eax@3 | |
7696 int v6; // edx@5 | |
7697 char *v7; // eax@6 | |
7698 char *v8; // ecx@6 | |
7699 double v9; // st6@7 | |
7700 int v10; // ebx@7 | |
7701 int v11; // ebx@7 | |
7702 | |
7703 if ( this->uNumD3DSceneBegins ) | |
7704 { | |
7705 v4 = a2; | |
7706 if ( a2 >= 3 ) | |
7707 { | |
186 | 7708 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
638 | 7709 v5 = 31 - (a3->dimming_level & 0x1F); |
7710 if ( v5 < pOutdoor->max_terrain_dimming_level ) | |
7711 v5 = pOutdoor->max_terrain_dimming_level; | |
0 | 7712 v6 = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8); |
7713 if ( a2 > 0 ) | |
7714 { | |
186 | 7715 v7 = (char *)&d3d_vertex_buffer[0].pos.y; |
0 | 7716 v8 = (char *)&array_507D30[0].vWorldViewProjY; |
7717 do | |
7718 { | |
7719 v9 = *((float *)v8 - 4) * 0.061758894; | |
7720 v10 = *((int *)v8 - 1); | |
7721 *((int *)v7 + 4) = 0; | |
7722 *((int *)v7 - 1) = v10; | |
7723 *(int *)v7 = *(int *)v8; | |
7724 *((int *)v7 + 2) = *((int *)v8 + 1); | |
7725 *((int *)v7 + 5) = *((int *)v8 + 2); | |
7726 v11 = *((int *)v8 + 3); | |
7727 *((int *)v7 + 3) = v6; | |
7728 *((int *)v7 + 6) = v11; | |
7729 v8 += 48; | |
7730 v7 += 32; | |
7731 --v4; | |
7732 *((float *)v7 - 7) = 1.0 - 1.0 / v9; | |
7733 } | |
7734 while ( v4 ); | |
7735 } | |
7736 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); | |
186 | 7737 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7738 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7739 d3d_vertex_buffer, |
0 | 7740 a2, |
7741 28)); | |
7742 } | |
7743 } | |
7744 } | |
7745 | |
7746 //----- (004A2FC0) -------------------------------------------------------- | |
7747 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | |
7748 { | |
7749 //Render *v8; // edi@1 | |
7750 //unsigned int v9; // esi@3 | |
7751 char *v12; // ecx@9 | |
7752 char *v13; // eax@9 | |
7753 double v14; // st6@10 | |
7754 int v15; // edx@10 | |
7755 Texture *v16; // edx@10 | |
7756 double v17; // st6@10 | |
7757 //char v18; // zf@10 | |
7758 Texture *v19; // edx@10 | |
595 | 7759 //Texture *v23; // edx@16 |
7760 //char *v24; // ecx@16 | |
7761 //char *v25; // eax@16 | |
7762 //double v26; // st6@17 | |
7763 //int v27; // esi@17 | |
7764 //double v28; // st6@17 | |
7765 //unsigned int v33; // ecx@18 | |
7766 //char *v34; // eax@19 | |
0 | 7767 //Texture *v45; // edx@23 |
7768 //char *v46; // ecx@23 | |
7769 //char *v47; // eax@23 | |
7770 //double v48; // st6@24 | |
7771 //int v49; // esi@24 | |
7772 //double v50; // st6@24 | |
7773 const char *v53; // [sp-Ch] [bp-20h]@21 | |
7774 //int v54; // [sp-8h] [bp-1Ch]@21 | |
7775 //unsigned int v55; // [sp-4h] [bp-18h]@21 | |
7776 const char *v56; // [sp+0h] [bp-14h]@0 | |
7777 int v57; // [sp+4h] [bp-10h]@0 | |
7778 unsigned int v58; // [sp+8h] [bp-Ch]@0 | |
7779 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | |
7780 //int a3a; // [sp+10h] [bp-4h]@4 | |
7781 | |
7782 //v8 = this; | |
7783 if (!uNumD3DSceneBegins || uNumVertices < 3) | |
7784 return; | |
7785 | |
7786 //auto a3 = pFace; | |
7787 //auto a6 = uPackedID; | |
7788 //v59 = pGame->pLightmapBuilder; | |
7789 //v9 = v59->std__vector_000004_size; | |
7790 | |
7791 auto uCorrectedColor = uColor; | |
7792 if (pGame->pLightmapBuilder->std__vector_000004_size) | |
7793 uCorrectedColor = 0xFFFFFFFF; | |
638 | 7794 pGame->AlterGamma_BLV(pFace, &uCorrectedColor); |
0 | 7795 |
792 | 7796 |
7797 if (pFace->uAttributes & FACE_OUTLINED) | |
7798 { | |
7799 int color; | |
7800 if (GetTickCount() % 300 >= 150) | |
7801 uColor = uCorrectedColor = 0xFF20FF20; | |
7802 else uColor = uCorrectedColor = 0xFF109010; | |
7803 } | |
7804 | |
0 | 7805 if (byte_4D864C && pGame->uFlags & 1) |
7806 { | |
7807 __debugbreak(); | |
7808 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
186 | 7809 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7810 if ( (signed int)uNumVertices > 0 ) |
7811 { | |
7812 v12 = (char *)&array_507D30[0].vWorldViewPosition; | |
186 | 7813 v13 = (char *)&d3d_vertex_buffer[0].pos.y; |
0 | 7814 auto a7 = uNumVertices; |
7815 uint v18; | |
7816 do | |
7817 { | |
7818 v14 = *(float *)v12 * 0.061758894; | |
7819 v15 = *((int *)v12 + 3); | |
7820 *((int *)v13 + 4) = 0; | |
7821 *((int *)v13 - 1) = v15; | |
7822 *(int *)v13 = *((int *)v12 + 4); | |
7823 *((int *)v13 + 3) = uCorrectedColor; | |
7824 v16 = pTex; | |
7825 v13 += 32; | |
7826 *((float *)v13 - 7) = 1.0 - 1.0 / v14; | |
7827 v17 = 1.0 / *(float *)v12; | |
7828 v12 += 48; | |
7829 v18 = a7-- == 1; | |
7830 *((float *)v13 - 6) = v17; | |
7831 pHwTex = (IDirect3DTexture2 *)v16->uTextureWidth; | |
7832 v19 = pTex; | |
7833 *((float *)v13 - 3) = *((float *)v12 - 6) / (double)(signed int)pHwTex; | |
7834 pHwTex = (IDirect3DTexture2 *)v19->uTextureHeight; | |
7835 *((float *)v13 - 2) = *((float *)v12 - 5) / (double)(signed int)pHwTex; | |
7836 } | |
7837 while ( !v18 ); | |
7838 } | |
186 | 7839 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7840 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
7841 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7842 D3DPT_TRIANGLEFAN, | |
7843 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 7844 d3d_vertex_buffer, |
0 | 7845 uNumVertices, |
7846 28)); | |
7847 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); | |
7848 } | |
7849 else | |
7850 { | |
7851 if (!pGame->pLightmapBuilder->std__vector_000004_size || | |
7852 byte_4D864C && pGame->uFlags & 2) | |
7853 { | |
7854 for (uint i = 0; i < uNumVertices; ++i) | |
7855 { | |
186 | 7856 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; |
7857 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7858 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
7859 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
7860 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
7861 d3d_vertex_buffer[i].specular = 0; | |
7862 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
7863 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
7864 } | |
7865 | |
7866 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); | |
0 | 7867 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
7868 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
7869 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
186 | 7870 d3d_vertex_buffer, |
0 | 7871 uNumVertices, |
7872 28)); | |
7873 } | |
7874 else | |
7875 { | |
595 | 7876 for (uint i = 0; i < uNumVertices; ++i) |
7877 { | |
7878 d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; | |
7879 d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; | |
7880 d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); | |
7881 d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; | |
7882 d3d_vertex_buffer[i].diffuse = uColor; | |
7883 d3d_vertex_buffer[i].specular = 0; | |
7884 d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; | |
7885 d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; | |
7886 } | |
7887 //__debugbreak(); | |
7888 //if ( (signed int)uNumVertices > 0 ) | |
7889 //{ | |
7890 //v23 = pTex; | |
7891 //v24 = (char *)&array_507D30[0].vWorldViewPosition; | |
7892 //v25 = (char *)&d3d_vertex_buffer[0].pos.y; | |
7893 //pTex = (Texture *)uNumVertices; | |
7894 //uint v18; | |
7895 //do | |
7896 //{ | |
7897 //v26 = *(float *)v24 * 0.061758894; | |
7898 //v27 = *((int *)v24 + 3); | |
7899 //*((int *)v25 + 4) = 0; | |
7900 //*((int *)v25 - 1) = v27; | |
7901 //*(int *)v25 = *((int *)v24 + 4); | |
7902 //*((int *)v25 + 3) = uColor; | |
7903 //v25 += 32; | |
7904 //*((float *)v25 - 7) = 1.0 - 1.0 / v26; | |
7905 //v28 = 1.0 / *(float *)v24; | |
7906 //v24 += 48; | |
7907 //v18 = pTex == (Texture *)1; | |
7908 //pTex = (Texture *)((char *)pTex - 1); | |
7909 //*((float *)v25 - 6) = v28; | |
0 | 7910 //a3 = (BLVFace *)v23->uTextureWidth; |
595 | 7911 //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
0 | 7912 //a3 = (BLVFace *)v23->uTextureHeight; |
595 | 7913 //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
7914 //} | |
7915 //while ( !v18 ); | |
7916 //} | |
0 | 7917 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
186 | 7918 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
0 | 7919 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
186 | 7920 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
0 | 7921 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7922 d3d_vertex_buffer, |
0 | 7923 uNumVertices, |
7924 28)); | |
595 | 7925 |
7926 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 7927 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); |
595 | 7928 |
7929 for (uint i = 0; i < uNumVertices; ++i) | |
7930 d3d_vertex_buffer[i].diffuse = uCorrectedColor; | |
7931 /*v33 = uNumVertices; | |
0 | 7932 if ( (signed int)uNumVertices > 0 ) |
7933 { | |
186 | 7934 v34 = (char *)&d3d_vertex_buffer[0].diffuse; |
0 | 7935 do |
7936 { | |
7937 *(int *)v34 = uCorrectedColor; | |
7938 v34 += 32; | |
7939 --v33; | |
7940 } | |
7941 while ( v33 ); | |
595 | 7942 }*/ |
0 | 7943 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
186 | 7944 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); |
7945 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
7946 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
7947 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO)); | |
7948 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR)); | |
7949 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
0 | 7950 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
186 | 7951 d3d_vertex_buffer, |
0 | 7952 uNumVertices, |
7953 28)); | |
186 | 7954 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
7955 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
7956 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
0 | 7957 } |
7958 } | |
7959 } | |
7960 // 4D864C: using guessed type char byte_4D864C; | |
7961 | |
7962 //----- (004A43B1) -------------------------------------------------------- | |
717 | 7963 void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) |
7964 { | |
7965 //RenderBillboardTransform_local0 *v4; // ebx@2 | |
7966 //double v5; // st7@2 | |
7967 //float v6; // ST08_4@2 | |
0 | 7968 unsigned int v7; // eax@2 |
717 | 7969 //int v8; // ecx@2 |
7970 //unsigned int v9; // esi@2 | |
7971 //Sprite *v10; // edi@5 | |
0 | 7972 signed int v11; // eax@9 |
7973 signed int v12; // eax@9 | |
717 | 7974 //double v13; // st7@12 |
7975 //double v14; // st6@12 | |
0 | 7976 double v15; // st5@12 |
7977 double v16; // st4@12 | |
7978 double v17; // st3@12 | |
7979 double v18; // st2@12 | |
7980 int v19; // ecx@14 | |
7981 double v20; // st3@14 | |
7982 int v21; // ecx@16 | |
7983 double v22; // st3@16 | |
717 | 7984 //IDirect3DTexture2 *v23; // eax@18 |
7985 //signed int v24; // [sp+18h] [bp-18h]@5 | |
7986 //signed int v25; // [sp+1Ch] [bp-14h]@5 | |
7987 //Render *v26; // [sp+20h] [bp-10h]@1 | |
0 | 7988 float v27; // [sp+24h] [bp-Ch]@5 |
7989 int v28; // [sp+28h] [bp-8h]@2 | |
7990 float v29; // [sp+2Ch] [bp-4h]@5 | |
717 | 7991 //float pSoftBillboarda; // [sp+38h] [bp+8h]@2 |
0 | 7992 float v31; // [sp+3Ch] [bp+Ch]@5 |
717 | 7993 //float v32; // [sp+3Ch] [bp+Ch]@12 |
0 | 7994 float a1; // [sp+40h] [bp+10h]@5 |
7995 | |
717 | 7996 //v26 = this; |
0 | 7997 if ( this->uNumD3DSceneBegins ) |
7998 { | |
717 | 7999 //v4 = pSoftBillboard; |
8000 //v5 = (double)pSoftBillboard->zbuffer_depth; | |
8001 //pSoftBillboarda = pSoftBillboard->zbuffer_depth; | |
8002 //v6 = pSoftBillboard->zbuffer_depth; | |
8003 v7 = Billboard_ProbablyAddToListAndSortByZOrder(pSoftBillboard->zbuffer_depth); | |
8004 //v8 = dimming_level; | |
8005 //v9 = v7; | |
657 | 8006 v28 = dimming_level & 0xFF000000; |
8007 if ( dimming_level & 0xFF000000 ) | |
717 | 8008 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Opaque_3; |
0 | 8009 else |
717 | 8010 pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Transparent; |
8011 //v10 = a3; | |
8012 pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; | |
8013 pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; | |
8014 pBillboardRenderListD3D[v7].uParentBillboardID = pSoftBillboard->uParentBillboardID; | |
8015 //v25 = pSoftBillboard->uScreenSpaceX; | |
8016 //v24 = pSoftBillboard->uScreenSpaceY; | |
8017 a1 = (pSoftBillboard->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_x_scaler_packedfloat); | |
8018 v29 = (pSoftBillboard->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(pSoftBillboard->_screenspace_y_scaler_packedfloat); | |
8019 v31 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
8020 v27 = (double)(pSprite->uBufferHeight - pSprite->uAreaY); | |
8021 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8022 v31 = v31 * -1.0; |
717 | 8023 if ( pSoftBillboard->uTintColor && this->bTinting ) |
8024 { | |
8025 v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); | |
737 | 8026 v12 = BlendColors(pSoftBillboard->uTintColor, v11); |
0 | 8027 if ( v28 ) |
8028 v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); | |
8029 } | |
8030 else | |
8031 { | |
717 | 8032 v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); |
8033 } | |
8034 //v13 = (double)v25; | |
8035 pBillboardRenderListD3D[v7].pQuards[0].specular = 0; | |
8036 pBillboardRenderListD3D[v7].pQuards[0].diffuse = v12; | |
8037 pBillboardRenderListD3D[v7].pQuards[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; | |
8038 //v14 = (double)v24; | |
8039 //v32 = v14; | |
8040 pBillboardRenderListD3D[v7].pQuards[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; | |
8041 v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); | |
8042 pBillboardRenderListD3D[v7].pQuards[0].pos.z = v15; | |
8043 v16 = 1.0 / pSoftBillboard->zbuffer_depth; | |
8044 pBillboardRenderListD3D[v7].pQuards[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; | |
8045 pBillboardRenderListD3D[v7].pQuards[0].texcoord.x = 0.0; | |
8046 pBillboardRenderListD3D[v7].pQuards[0].texcoord.y = 0.0; | |
8047 v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); | |
8048 v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); | |
8049 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8050 v17 = v17 * -1.0; |
717 | 8051 pBillboardRenderListD3D[v7].pQuards[1].specular = 0; |
8052 pBillboardRenderListD3D[v7].pQuards[1].diffuse = v12; | |
8053 pBillboardRenderListD3D[v7].pQuards[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; | |
8054 pBillboardRenderListD3D[v7].pQuards[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; | |
8055 pBillboardRenderListD3D[v7].pQuards[1].pos.z = v15; | |
8056 pBillboardRenderListD3D[v7].pQuards[1].rhw = v16; | |
8057 pBillboardRenderListD3D[v7].pQuards[1].texcoord.x = 0.0; | |
8058 pBillboardRenderListD3D[v7].pQuards[1].texcoord.y = 1.0; | |
8059 v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; | |
8060 v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
8061 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8062 v20 = v20 * -1.0; |
717 | 8063 pBillboardRenderListD3D[v7].pQuards[2].specular = 0; |
8064 pBillboardRenderListD3D[v7].pQuards[2].diffuse = v12; | |
8065 pBillboardRenderListD3D[v7].pQuards[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; | |
8066 pBillboardRenderListD3D[v7].pQuards[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; | |
8067 pBillboardRenderListD3D[v7].pQuards[2].pos.z = v15; | |
8068 pBillboardRenderListD3D[v7].pQuards[2].rhw = v16; | |
8069 pBillboardRenderListD3D[v7].pQuards[2].texcoord.x = 1.0; | |
8070 pBillboardRenderListD3D[v7].pQuards[2].texcoord.y = 1.0; | |
8071 v21 = pSprite->uBufferHeight - pSprite->uAreaY; | |
8072 v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); | |
8073 if ( pSoftBillboard->uFlags & 4 ) | |
0 | 8074 v22 = v22 * -1.0; |
717 | 8075 pBillboardRenderListD3D[v7].pQuards[3].specular = 0; |
8076 pBillboardRenderListD3D[v7].pQuards[3].diffuse = v12; | |
8077 pBillboardRenderListD3D[v7].pQuards[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; | |
8078 pBillboardRenderListD3D[v7].pQuards[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; | |
8079 pBillboardRenderListD3D[v7].pQuards[3].pos.z = v15; | |
8080 pBillboardRenderListD3D[v7].pQuards[3].rhw = v16; | |
8081 pBillboardRenderListD3D[v7].pQuards[3].texcoord.x = 1.0; | |
8082 pBillboardRenderListD3D[v7].pQuards[3].texcoord.y = 0.0; | |
8083 //v23 = pSprite->pTexture; | |
8084 pBillboardRenderListD3D[v7].uNumVertices = 4; | |
8085 pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; | |
8086 pBillboardRenderListD3D[v7].pTexture = pSprite->pTexture; | |
0 | 8087 } |
8088 } | |
8089 | |
8090 //----- (004A354F) -------------------------------------------------------- | |
8091 void Render::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
8092 { | |
743 | 8093 //double v5; // st7@3 |
8094 //float v6; // ST20_4@3 | |
8095 //float v7; // ST00_4@3 | |
0 | 8096 unsigned int v8; // esi@3 |
743 | 8097 //int v9; // eax@3 |
8098 //int v10; // ebx@3 | |
0 | 8099 float v11; // ST28_4@3 |
743 | 8100 //double v12; // st7@3 |
8101 //float v13; // ST24_4@3 | |
8102 //double v14; // st6@3 | |
8103 //float v15; // ST1C_4@3 | |
0 | 8104 float v16; // ST2C_4@3 |
8105 float v17; // ST30_4@3 | |
8106 signed int v18; // ST18_4@3 | |
8107 signed int v19; // ST14_4@3 | |
8108 signed int v20; // ST10_4@3 | |
8109 signed int v21; // eax@3 | |
8110 double v22; // st6@3 | |
8111 float v23; // ST2C_4@3 | |
8112 float v24; // ST30_4@3 | |
8113 signed int v25; // ST10_4@3 | |
8114 signed int v26; // ST14_4@3 | |
8115 signed int v27; // ST18_4@3 | |
8116 signed int v28; // eax@3 | |
8117 double v29; // st6@3 | |
8118 float v30; // ecx@3 | |
8119 float v31; // ST2C_4@3 | |
8120 float v32; // ST30_4@3 | |
8121 signed int v33; // ST10_4@3 | |
8122 signed int v34; // ST14_4@3 | |
8123 signed int v35; // ST18_4@3 | |
8124 signed int v36; // eax@3 | |
8125 float v37; // ecx@3 | |
8126 double v38; // st6@3 | |
8127 float v39; // ST2C_4@3 | |
8128 float v40; // ST30_4@3 | |
8129 signed int v41; // ST10_4@3 | |
8130 signed int v42; // ST14_4@3 | |
8131 signed int v43; // ST18_4@3 | |
8132 signed int v44; // eax@3 | |
8133 double v45; // st6@3 | |
8134 float v46; // eax@3 | |
8135 | |
8136 if ( this->uNumD3DSceneBegins ) | |
8137 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8138 if (a2->zbuffer_depth) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8139 { |
743 | 8140 //v5 = (double)a2->zbuffer_depth; |
8141 //v6 = v5; | |
8142 //v7 = v5; | |
8143 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); | |
0 | 8144 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; |
8145 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
8146 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
8147 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
743 | 8148 //v9 = a2->uScreenSpaceX; |
8149 //v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8150 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
743 | 8151 //v12 = (double) a2->uScreenSpaceX; |
8152 //v13 = v12; | |
8153 //v14 = (double)(a2->uScreenSpaceY - 12); | |
8154 //v15 = v14; | |
8155 v16 = (double)( a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; | |
8156 v17 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 8157 v18 = stru_5C6E00->Cos(angle); |
8158 v19 = stru_5C6E00->Sin(angle); | |
8159 v20 = stru_5C6E00->Sin(angle); | |
8160 v21 = stru_5C6E00->Cos(angle); | |
0 | 8161 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
8162 + (double)(v18 >> 16)) | |
8163 * v16 | |
8164 - ((double)(unsigned __int16)v19 * 0.000015259022 | |
8165 + (double)(v19 >> 16)) | |
8166 * v17) | |
743 | 8167 * v11 + (double) a2->uScreenSpaceX; |
0 | 8168 v22 = (((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v17 |
8169 + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16 | |
8170 - 12.0) | |
8171 * v11 | |
8172 + (double)a2->uScreenSpaceY; | |
8173 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; | |
8174 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; | |
8175 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v22; | |
743 | 8176 pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); |
8177 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; | |
0 | 8178 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; |
8179 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; | |
743 | 8180 v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
8181 v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 8182 v25 = stru_5C6E00->Cos(angle); |
8183 v26 = stru_5C6E00->Sin(angle); | |
8184 v27 = stru_5C6E00->Sin(angle); | |
8185 v28 = stru_5C6E00->Cos(angle); | |
0 | 8186 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 |
8187 + (double)(v25 >> 16)) | |
740 | 8188 * v31 |
0 | 8189 - ((double)(unsigned __int16)v26 * 0.000015259022 |
8190 + (double)(v26 >> 16)) | |
740 | 8191 * v32) |
743 | 8192 * v11 + (double) a2->uScreenSpaceX; |
740 | 8193 v29 = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v32 |
8194 + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v31 | |
0 | 8195 - 12.0) |
8196 * v11 | |
8197 + (double)a2->uScreenSpaceY; | |
8198 pBillboardRenderListD3D[v8].pQuards[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8199 v30 = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8200 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v29; | |
8201 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; | |
8202 pBillboardRenderListD3D[v8].pQuards[1].rhw = v30; | |
8203 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; | |
8204 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; | |
8205 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
743 | 8206 v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; |
8207 v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); | |
323 | 8208 v33 = stru_5C6E00->Cos(angle); |
8209 v34 = stru_5C6E00->Sin(angle); | |
8210 v35 = stru_5C6E00->Sin(angle); | |
8211 v36 = stru_5C6E00->Cos(angle); | |
0 | 8212 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 |
8213 + (double)(v33 >> 16)) | |
740 | 8214 * v23 |
0 | 8215 - ((double)(unsigned __int16)v34 * 0.000015259022 |
8216 + (double)(v34 >> 16)) | |
740 | 8217 * v24) |
743 | 8218 * v11 + (double) a2->uScreenSpaceX; |
0 | 8219 v37 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; |
740 | 8220 v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 |
8221 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 | |
0 | 8222 - 12.0) |
8223 * v11 | |
8224 + (double)a2->uScreenSpaceY; | |
8225 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; | |
8226 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v37; | |
8227 pBillboardRenderListD3D[v8].pQuards[2].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8228 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; | |
8229 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v38; | |
8230 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; | |
8231 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
743 | 8232 v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; |
8233 v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); | |
323 | 8234 v41 = stru_5C6E00->Cos(angle); |
8235 v42 = stru_5C6E00->Sin(angle); | |
8236 v43 = stru_5C6E00->Sin(angle); | |
8237 v44 = stru_5C6E00->Cos(angle); | |
0 | 8238 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 |
8239 + (double)(v41 >> 16)) | |
8240 * v39 | |
8241 - ((double)(unsigned __int16)v42 * 0.000015259022 | |
8242 + (double)(v42 >> 16)) | |
8243 * v40) | |
743 | 8244 * v11 + (double) a2->uScreenSpaceX; |
0 | 8245 v45 = (((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 |
8246 + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39 | |
8247 - 12.0) | |
8248 * v11 | |
8249 + (double)a2->uScreenSpaceY; | |
8250 v46 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; | |
8251 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; | |
8252 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v46; | |
8253 pBillboardRenderListD3D[v8].pQuards[3].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; | |
8254 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; | |
8255 pBillboardRenderListD3D[v8].pTexture = a3; | |
743 | 8256 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
0 | 8257 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8258 pBillboardRenderListD3D[v8].pQuards[3].pos.y = v45; | |
8259 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; | |
8260 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
8261 } | |
8262 } | |
8263 } | |
8264 | |
8265 //----- (004A3AD9) -------------------------------------------------------- | |
8266 void Render::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) | |
8267 { | |
8268 double v5; // st7@2 | |
8269 float v6; // ST28_4@2 | |
8270 float v7; // ST00_4@2 | |
8271 unsigned int v8; // esi@2 | |
8272 int v9; // eax@2 | |
8273 int v10; // ebx@2 | |
8274 float v11; // ST34_4@2 | |
8275 double v12; // st7@2 | |
8276 float v13; // ST2C_4@2 | |
8277 double v14; // st6@2 | |
8278 float v15; // ST24_4@2 | |
8279 float v16; // ST38_4@2 | |
8280 float v17; // ST3C_4@2 | |
8281 signed int v18; // ST1C_4@2 | |
8282 int v19; // ST30_4@2 | |
8283 signed int v20; // ST20_4@2 | |
8284 signed int v21; // ST18_4@2 | |
8285 signed int v22; // eax@2 | |
8286 double v23; // st6@2 | |
8287 float v24; // ST20_4@2 | |
8288 float v25; // ST1C_4@2 | |
8289 float v26; // ST38_4@2 | |
8290 float v27; // ST3C_4@2 | |
8291 signed int v28; // ST18_4@2 | |
8292 signed int v29; // ST14_4@2 | |
8293 signed int v30; // ST10_4@2 | |
8294 signed int v31; // eax@2 | |
8295 double v32; // st6@2 | |
8296 float v33; // ST38_4@2 | |
8297 float v34; // ST3C_4@2 | |
8298 signed int v35; // ST10_4@2 | |
8299 signed int v36; // ST14_4@2 | |
8300 signed int v37; // ST18_4@2 | |
8301 signed int v38; // eax@2 | |
8302 double v39; // st6@2 | |
8303 float v40; // ST38_4@2 | |
8304 float v41; // ST3C_4@2 | |
8305 signed int v42; // ST10_4@2 | |
8306 signed int v43; // ST14_4@2 | |
8307 signed int v44; // ST18_4@2 | |
8308 signed int v45; // eax@2 | |
8309 double v46; // st6@2 | |
8310 | |
8311 if ( this->uNumD3DSceneBegins ) | |
8312 { | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8313 v5 = (double)a2->zbuffer_depth; |
0 | 8314 v6 = v5; |
8315 v7 = v5; | |
8316 v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); | |
8317 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; | |
8318 pBillboardRenderListD3D[v8].field_90 = a2->field_44; | |
8319 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; | |
8320 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; | |
8321 v9 = a2->uScreenSpaceX; | |
8322 v10 = a2->uScreenSpaceY; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8323 v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); |
0 | 8324 v12 = (double)v9; |
8325 v13 = v12; | |
8326 v14 = (double)(v10 - 12); | |
8327 v15 = v14; | |
8328 v16 = (double)(v9 - 12) - v12; | |
8329 v17 = (double)(v10 - 25) - v14; | |
323 | 8330 v18 = stru_5C6E00->Cos(angle); |
0 | 8331 v19 = angle - stru_5C6E00->uIntegerHalfPi; |
323 | 8332 v20 = stru_5C6E00->Sin(angle); |
8333 v21 = stru_5C6E00->Sin(angle); | |
8334 v22 = stru_5C6E00->Cos(angle); | |
0 | 8335 pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 |
8336 + (double)(v18 >> 16)) | |
8337 * v16 | |
8338 - ((double)(unsigned __int16)v20 * 0.000015259022 | |
8339 + (double)(v20 >> 16)) | |
8340 * v17) | |
8341 * v11 + v13; | |
8342 v23 = (((double)(unsigned __int16)v22 * 0.000015259022 + (double)(v22 >> 16)) * v17 | |
8343 + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16 | |
8344 - 12.0) | |
8345 * v11 | |
8346 + (double)a2->uScreenSpaceY; | |
8347 pBillboardRenderListD3D[v8].pQuards[0].specular = 0; | |
8348 pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; | |
8349 pBillboardRenderListD3D[v8].pQuards[0].pos.y = v23; | |
8350 v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); | |
8351 pBillboardRenderListD3D[v8].pQuards[0].pos.z = v24; | |
8352 v25 = 1.0 / v6; | |
8353 pBillboardRenderListD3D[v8].pQuards[0].rhw = v25; | |
8354 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; | |
8355 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; | |
8356 v26 = (double)(a2->uScreenSpaceX - 12) - v13; | |
8357 v27 = (double)a2->uScreenSpaceY - v15; | |
323 | 8358 v28 = stru_5C6E00->Cos(angle); |
8359 v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8360 v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8361 v31 = stru_5C6E00->Cos(angle); | |
0 | 8362 pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 |
8363 + (double)(v28 >> 16)) | |
8364 * v26 | |
8365 - ((double)(unsigned __int16)v29 * 0.000015259022 | |
8366 + (double)(v29 >> 16)) | |
8367 * v27) | |
8368 * v11 + v13; | |
8369 v32 = (((double)(unsigned __int16)v31 * 0.000015259022 + (double)(v31 >> 16)) * v27 | |
8370 + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26 | |
8371 - 12.0) | |
8372 * v11 | |
8373 + (double)a2->uScreenSpaceY; | |
8374 pBillboardRenderListD3D[v8].pQuards[1].pos.z = v24; | |
8375 pBillboardRenderListD3D[v8].pQuards[1].pos.y = v32; | |
8376 pBillboardRenderListD3D[v8].pQuards[1].specular = 0; | |
8377 pBillboardRenderListD3D[v8].pQuards[1].rhw = v25; | |
8378 pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; | |
8379 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; | |
8380 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
8381 v33 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8382 v34 = (double)a2->uScreenSpaceY - v15; | |
323 | 8383 v35 = stru_5C6E00->Cos(angle); |
8384 v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8385 v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8386 v38 = stru_5C6E00->Cos(angle); | |
0 | 8387 pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 |
8388 + (double)(v35 >> 16)) | |
8389 * v33 | |
8390 - ((double)(unsigned __int16)v36 * 0.000015259022 | |
8391 + (double)(v36 >> 16)) | |
8392 * v34) | |
8393 * v11 + v13; | |
8394 v39 = (((double)(unsigned __int16)v38 * 0.000015259022 + (double)(v38 >> 16)) * v34 | |
8395 + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33 | |
8396 - 12.0) | |
8397 * v11 | |
8398 + (double)a2->uScreenSpaceY; | |
8399 pBillboardRenderListD3D[v8].pQuards[2].specular = 0; | |
8400 pBillboardRenderListD3D[v8].pQuards[2].pos.z = v24; | |
8401 pBillboardRenderListD3D[v8].pQuards[2].rhw = v25; | |
8402 pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; | |
8403 pBillboardRenderListD3D[v8].pQuards[2].pos.y = v39; | |
8404 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; | |
8405 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
8406 v40 = (double)(a2->uScreenSpaceX + 12) - v13; | |
8407 v41 = (double)(a2->uScreenSpaceY - 25) - v15; | |
323 | 8408 v42 = stru_5C6E00->Cos(angle); |
8409 v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8410 v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); | |
8411 v45 = stru_5C6E00->Cos(angle); | |
0 | 8412 pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 |
8413 + (double)(v42 >> 16)) | |
8414 * v40 | |
8415 - ((double)(unsigned __int16)v43 * 0.000015259022 | |
8416 + (double)(v43 >> 16)) | |
8417 * v41) | |
8418 * v11 + v13; | |
8419 v46 = (((double)(unsigned __int16)v45 * 0.000015259022 + (double)(v45 >> 16)) * v41 | |
8420 + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40 | |
8421 - 12.0) | |
8422 * v11 | |
8423 + (double)a2->uScreenSpaceY; | |
8424 pBillboardRenderListD3D[v8].pQuards[3].specular = 0; | |
8425 pBillboardRenderListD3D[v8].pQuards[3].pos.z = v24; | |
8426 pBillboardRenderListD3D[v8].pQuards[3].rhw = v25; | |
8427 pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; | |
8428 pBillboardRenderListD3D[v8].pTexture = a3; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8429 pBillboardRenderListD3D[v8].z_order = v6; |
0 | 8430 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8431 pBillboardRenderListD3D[v8].pQuards[3].pos.y = v46; | |
8432 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; | |
8433 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
8434 } | |
8435 } | |
8436 | |
8437 //----- (004A4023) -------------------------------------------------------- | |
657 | 8438 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
|
8439 { |
0 | 8440 unsigned int v8; // esi@2 |
8441 double v14; // st6@14 | |
8442 double v15; // st5@14 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8443 //unsigned int v16; // ecx@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8444 //double v17; // st7@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8445 //double v18; // st5@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8446 //double v19; // st4@16 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8447 //double v20; // st5@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8448 //double v21; // st4@18 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8449 //signed int v23; // [sp+18h] [bp-18h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8450 //signed int v24; // [sp+1Ch] [bp-14h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8451 //float v26; // [sp+20h] [bp-10h]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8452 //float v27; // [sp+20h] [bp-10h]@12 |
0 | 8453 float v29; // [sp+28h] [bp-8h]@5 |
8454 float v30; // [sp+2Ch] [bp-4h]@5 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8455 //float pSpritea; // [sp+3Ch] [bp+Ch]@5 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8456 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8457 if (!uNumD3DSceneBegins) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8458 return; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8459 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8460 v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8461 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8462 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
|
8463 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
|
8464 |
657 | 8465 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
|
8466 if (a2->uTintColor & 0x00FFFFFF && bTinting) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8467 { |
737 | 8468 diffuse = BlendColors(a2->uTintColor, diffuse); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8469 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8470 diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8471 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8472 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8473 unsigned int specular = 0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8474 if (bUsingSpecular) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8475 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
|
8476 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8477 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8478 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8479 if (a2->uFlags & 4) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8480 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8481 pBillboardRenderListD3D[v8].pQuards[0].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8482 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
|
8483 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
|
8484 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
|
8485 pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8486 pBillboardRenderListD3D[v8].pQuards[0].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8487 pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8488 pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8489 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8490 v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8491 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8492 if ( a2->uFlags & 4 ) |
0 | 8493 v14 = v14 * -1.0; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8494 pBillboardRenderListD3D[v8].pQuards[1].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8495 pBillboardRenderListD3D[v8].pQuards[1].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8496 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
|
8497 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
|
8498 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
|
8499 pBillboardRenderListD3D[v8].pQuards[1].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8500 pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; |
8501 pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8502 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8503 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
|
8504 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8505 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8506 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8507 pBillboardRenderListD3D[v8].pQuards[2].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8508 pBillboardRenderListD3D[v8].pQuards[2].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8509 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
|
8510 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
|
8511 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
|
8512 pBillboardRenderListD3D[v8].pQuards[2].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8513 pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; |
8514 pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8515 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8516 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
|
8517 v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8518 if ( a2->uFlags & 4 ) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8519 v14 *= -1.0; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8520 pBillboardRenderListD3D[v8].pQuards[3].diffuse = diffuse; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8521 pBillboardRenderListD3D[v8].pQuards[3].specular = specular; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8522 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
|
8523 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
|
8524 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
|
8525 pBillboardRenderListD3D[v8].pQuards[3].rhw = 1.0 / a2->zbuffer_depth; |
0 | 8526 pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; |
8527 pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8528 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8529 pBillboardRenderListD3D[v8].uNumVertices = 4; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8530 pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8531 pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8532 pBillboardRenderListD3D[v8].field_90 = a2->field_44; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8533 pBillboardRenderListD3D[v8].sZValue = a2->sZValue; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8534 pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8535 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8536 if (a2->uTintColor & 0xFF000000) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8537 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8538 else |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8539 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; |
0 | 8540 } |
8541 | |
8542 //----- (004A48E4) -------------------------------------------------------- | |
8543 int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6) | |
8544 { | |
8545 int v6; // ecx@1 | |
8546 int v7; // ebx@1 | |
8547 int v8; // ecx@1 | |
8548 int v9; // edx@1 | |
8549 int v10; // edi@1 | |
8550 unsigned int x; // esi@1 | |
8551 int result; // eax@8 | |
8552 int v13; // [sp+Ch] [bp-10h]@1 | |
8553 int v14; // [sp+10h] [bp-Ch]@1 | |
8554 int v15; // [sp+14h] [bp-8h]@1 | |
8555 int v16; // [sp+18h] [bp-4h]@1 | |
8556 int v17; // [sp+24h] [bp+8h]@1 | |
8557 unsigned int v18; // [sp+28h] [bp+Ch]@1 | |
8558 int v19; // [sp+34h] [bp+18h]@1 | |
8559 | |
8560 v6 = screenSpaceX; | |
8561 v7 = (a6 >> 1) + screenSpaceY; | |
8562 v17 = 0; | |
8563 v15 = 0; | |
8564 v8 = (a6 >> 1) + v6; | |
8565 v14 = (a6 >> 1) * (a6 >> 1); | |
8566 v9 = 2 * (a6 >> 1); | |
8567 v10 = (a6 >> 1) * ((a6 >> 1) - 1); | |
8568 x = v8 - (a6 >> 1); | |
8569 v16 = (a6 >> 1) + screenSpaceY - v8; | |
8570 v19 = a6 >> 1; | |
8571 v13 = v9; | |
8572 v18 = v8; | |
8573 do | |
8574 { | |
8575 sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor); | |
8576 if ( v15 ) | |
8577 sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor); | |
8578 v14 -= v15; | |
8579 if ( v14 <= v10 ) | |
8580 { | |
8581 if ( v19 != v17 ) | |
8582 { | |
8583 sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor); | |
8584 sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor); | |
8585 } | |
8586 --v19; | |
8587 v13 -= 2; | |
8588 ++x; | |
8589 v10 -= v13; | |
8590 } | |
8591 result = v17++; | |
8592 v15 += 2; | |
8593 --v18; | |
8594 } | |
8595 while ( result < v19 ); | |
8596 return result; | |
8597 } | |
8598 | |
8599 //----- (004A49D0) -------------------------------------------------------- | |
8600 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | |
8601 { | |
8602 int v10; // eax@1 | |
8603 unsigned int v11; // ebx@1 | |
8604 unsigned int v12; // ecx@1 | |
8605 int v13; // edx@2 | |
8606 int v14; // edx@4 | |
8607 unsigned int v15; // edx@6 | |
8608 double v16; // st7@7 | |
8609 double v17; // st7@7 | |
8610 double v18; // st6@7 | |
8611 double v19; // st4@7 | |
8612 double v20; // st4@8 | |
8613 double v21; // st4@10 | |
8614 double v22; // st4@10 | |
8615 double v23; // st4@10 | |
8616 double v24; // st4@10 | |
8617 double v25; // st4@11 | |
8618 double v26; // st4@13 | |
8619 double v27; // st5@13 | |
8620 double v28; // st4@13 | |
8621 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 | |
8622 double v30; // [sp+80h] [bp-14h]@1 | |
8623 int v31; // [sp+88h] [bp-Ch]@1 | |
8624 signed int v32; // [sp+8Ch] [bp-8h]@1 | |
8625 int X; // [sp+90h] [bp-4h]@1 | |
8626 float a3a; // [sp+A4h] [bp+10h]@10 | |
8627 float a4a; // [sp+A8h] [bp+14h]@10 | |
8628 | |
8629 *(float *)&X = dstX - srcX; | |
8630 v30 = *(float *)&X + 6.7553994e15; | |
8631 v31 = LODWORD(v30); | |
8632 *(float *)&v32 = dstY - srcY; | |
8633 v30 = *(float *)&v32 + 6.7553994e15; | |
8634 X = LODWORD(v30); | |
8635 HIDWORD(v30) = abs(COERCE_UNSIGNED_INT64(*(float *)&v32 + 6.7553994e15)); | |
8636 v10 = abs(v31); | |
8637 v32 = v10; | |
8638 v11 = HIDWORD(v30); | |
8639 v12 = 0; | |
8640 if ( v10 < SHIDWORD(v30) ) | |
8641 { | |
8642 v13 = v10; | |
8643 v10 = HIDWORD(v30); | |
8644 v11 = v13; | |
8645 } | |
8646 if ( v10 < 0 ) | |
8647 { | |
8648 v14 = v10; | |
8649 v10 = 0; | |
8650 v12 = v14; | |
8651 } | |
8652 if ( (signed int)v11 < (signed int)v12 ) | |
8653 { | |
8654 v15 = v12; | |
8655 v12 = v11; | |
8656 v11 = v15; | |
8657 } | |
8658 v32 = (11 * v11 >> 5) + (v12 >> 2) + v10; | |
8659 v16 = 1.0 / (double)v32; | |
8660 *(float *)&v31 = (double)v31 * v16; | |
8661 *(float *)&X = (double)X * v16; | |
8662 v17 = *(float *)&X * a4; | |
8663 v29[0].pos.x = srcX + v17; | |
8664 v18 = *(float *)&v31 * a4; | |
8665 v29[0].pos.y = srcY - v18; | |
8666 v19 = a3; | |
8667 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
8668 v20 = v19 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8669 else | |
8670 v20 = v19 * 0.061758894; | |
8671 v29[0].diffuse = -1; | |
8672 v29[0].specular = 0; | |
8673 v29[0].pos.z = 1.0 - 1.0 / v20; | |
8674 v21 = 1.0 / a3; | |
8675 *((float *)&v30 + 1) = v21; | |
8676 v29[0].rhw = v21; | |
8677 v29[0].texcoord.x = 1.0; | |
8678 v29[0].texcoord.y = 0.0; | |
8679 v22 = *(float *)&X * a8; | |
8680 a3a = v22; | |
8681 v29[1].pos.x = v22 + dstX; | |
8682 v23 = *(float *)&v31 * a8; | |
8683 a4a = v23; | |
8684 v29[1].pos.y = dstY - v23; | |
8685 v24 = a7; | |
8686 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
8687 v25 = v24 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8688 else | |
8689 v25 = v24 * 0.061758894; | |
8690 v29[2].diffuse = -1; | |
8691 v29[3].diffuse = -1; | |
8692 *(_QWORD *)&v29[3].pos.z = __PAIR__(HIDWORD(v30), LODWORD(v29[0].pos.z)); | |
8693 v29[1].diffuse = -16711936; | |
8694 v29[1].specular = 0; | |
8695 v29[2].specular = 0; | |
8696 v29[3].specular = 0; | |
8697 v26 = 1.0 - 1.0 / v25; | |
8698 v29[1].pos.z = v26; | |
8699 v27 = v26; | |
8700 v28 = 1.0 / a7; | |
8701 v29[1].rhw = v28; | |
8702 v29[1].texcoord.x = 1.0; | |
8703 v29[1].texcoord.y = 1.0; | |
8704 v29[2].pos.x = dstX - a3a; | |
8705 v29[2].pos.y = a4a + dstY; | |
8706 v29[2].pos.z = v27; | |
8707 v29[2].rhw = v28; | |
8708 v29[2].texcoord.x = 0.0; | |
8709 v29[2].texcoord.y = 1.0; | |
8710 v29[3].pos.x = srcX - v17; | |
8711 v29[3].pos.y = v18 + srcY; | |
8712 v29[3].texcoord.x = 0.0; | |
8713 v29[3].texcoord.y = 0.0; | |
186 | 8714 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); |
8715 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8716 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
8717 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
8718 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
8719 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); | |
0 | 8720 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
8721 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
8722 D3DPT_TRIANGLEFAN, | |
8723 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
8724 v29, | |
8725 4, | |
8726 24)); | |
186 | 8727 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); |
8728 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
8729 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
8730 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
8731 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
8732 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); | |
0 | 8733 } |
8734 | |
8735 //----- (004A4CC9) -------------------------------------------------------- | |
8736 void Render::_4A4CC9(stru6_stru1_indoor_sw_billboard *a1, int a2) | |
8737 { | |
8738 int v3; // eax@1 | |
8739 int v4; // edx@3 | |
8740 unsigned int v5; // eax@7 | |
8741 int v6; // edi@7 | |
8742 char *v7; // edx@8 | |
8743 char *v8; // ecx@8 | |
8744 char v9; // zf@9 | |
8745 double v10; // st6@9 | |
8746 double v11; // st6@10 | |
8747 int v12; // ebx@13 | |
8748 int v13; // ecx@16 | |
8749 unsigned int v14; // [sp+Ch] [bp-4h]@1 | |
8750 | |
8751 auto _this = this; | |
8752 | |
8753 *(float *)&v14 = 1000000.0; | |
8754 v3 = a1->field_10; | |
8755 if ( v3 >= 3 ) | |
8756 { | |
8757 if ( v3 > 0 ) | |
8758 { | |
8759 _this = (Render *)&a1->field_14[62]; | |
8760 v4 = a1->field_10; | |
8761 do | |
8762 { | |
8763 if ( *(float *)&this->bUserDirect3D < (double)*(float *)&v14 ) | |
8764 v14 = this->bUserDirect3D; | |
8765 _this = (Render *)((char *)_this + 16); | |
8766 --v4; | |
8767 } | |
8768 while ( v4 ); | |
8769 } | |
8770 v5 = Billboard_ProbablyAddToListAndSortByZOrder(v14); | |
8771 v6 = 0; | |
8772 pBillboardRenderListD3D[v5].field_90 = 0; | |
8773 pBillboardRenderListD3D[v5].uParentBillboardID = -1; | |
8774 pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; | |
8775 if ( a1->field_10 > 0 ) | |
8776 { | |
8777 v7 = (char *)&a1->field_14[62]; | |
8778 v8 = (char *)&pBillboardRenderListD3D[v5].pQuards[0].pos.z; | |
8779 do | |
8780 { | |
8781 v9 = uCurrentlyLoadedLevelType == LEVEL_Indoor; | |
8782 *((int *)v8 - 2) = *((int *)v7 - 2); | |
8783 *((int *)v8 - 1) = *((int *)v7 - 1); | |
8784 v10 = *(float *)v7; | |
8785 if ( v9 ) | |
8786 v11 = v10 * 0.061758894; | |
8787 else | |
8788 v11 = v10 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; | |
8789 *(float *)v8 = 1.0 - 1.0 / v11; | |
8790 *((float *)v8 + 1) = 1.0 / *(float *)v7; | |
8791 if ( a2 & 0xFF000000 ) | |
8792 v12 = *((int *)v7 + 1); | |
8793 else | |
8794 v12 = a2; | |
8795 *((int *)v8 + 3) = 0; | |
8796 *((int *)v8 + 2) = v12; | |
8797 ++v6; | |
8798 v7 += 16; | |
8799 *((float *)v8 + 4) = 0.0; | |
8800 *((float *)v8 + 5) = 0.0; | |
8801 v8 += 32; | |
8802 } | |
8803 while ( v6 < a1->field_10 ); | |
8804 } | |
8805 v13 = a1->field_10; | |
8806 pBillboardRenderListD3D[v5].pTexture = 0; | |
8807 pBillboardRenderListD3D[v5].uNumVertices = v13; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8808 LODWORD(pBillboardRenderListD3D[v5].z_order) = v14; |
0 | 8809 } |
8810 } | |
8811 | |
8812 //----- (004A4DE1) -------------------------------------------------------- | |
8813 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) | |
8814 { | |
8815 HRESULT v12; // eax@14 | |
8816 unsigned __int16 *v13; // ecx@19 | |
8817 unsigned __int16 *v14; // eax@19 | |
8818 DWORD v15; // edx@20 | |
8819 HRESULT v16; // eax@23 | |
8820 stru350 Dst; // [sp+Ch] [bp-F8h]@12 | |
8821 | |
8822 auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); | |
8823 if ( pHWLTexture ) | |
8824 { | |
8825 bMipMaps = !strncmp(pName, "HDWTR", 5); | |
8826 if ( !pRenderD3D->CreateTexture( | |
8827 pHWLTexture->uWidth, | |
8828 pHWLTexture->uHeight, | |
8829 pOutSurface, | |
8830 pOutTexture, | |
8831 true, | |
8832 bMipMaps, | |
8833 uMinDeviceTextureDim) ) | |
8834 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); | |
8835 //v10 = *pOutSurface; | |
8836 //v11 = 0; | |
8837 if ( bMipMaps ) | |
8838 { | |
8839 Dst._450DDE(); | |
8840 //v20 = 0; | |
8841 Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); | |
8842 | |
8843 IDirectDrawSurface4 *pNextSurf = *pOutSurface; | |
8844 while ( 1 ) | |
8845 { | |
8846 DDSCAPS2 v19; | |
8847 memset(&v19, 0, sizeof(DDSCAPS2)); | |
8848 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
8849 | |
8850 DDSURFACEDESC2 desc; | |
8851 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
8852 desc.dwSize = sizeof(DDSURFACEDESC2); | |
8853 | |
168 | 8854 if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 8855 { |
8856 Dst.sub_451007_scale_image_bicubic( | |
8857 pHWLTexture->pPixels, | |
8858 pHWLTexture->uWidth, | |
8859 pHWLTexture->uHeight, | |
8860 pHWLTexture->uWidth, | |
8861 (unsigned short *)desc.lpSurface, | |
8862 desc.dwWidth, | |
8863 desc.dwHeight, | |
8864 desc.lPitch >> 1, | |
8865 0, | |
8866 0); | |
8867 ErrD3D(pNextSurf->Unlock(0)); | |
8868 //bMipMaps = 0x4D86ACu; | |
8869 } | |
8870 if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) | |
8871 break; | |
8872 //v10 = (IDirectDrawSurface4 *)pName; | |
8873 //v11 = 0; | |
8874 } | |
8875 //v20 = -1; | |
8876 //nullsub_1(); | |
8877 } | |
8878 else | |
8879 { | |
8880 DDSCAPS2 v19; | |
8881 memset(&v19, 0, sizeof(DDSCAPS2)); | |
8882 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; | |
8883 | |
8884 DDSURFACEDESC2 desc; | |
8885 memset(&desc, 0, sizeof(DDSURFACEDESC2)); | |
8886 desc.dwSize = sizeof(DDSURFACEDESC2); | |
8887 | |
168 | 8888 if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
0 | 8889 { |
8890 bMipMaps = 0; | |
8891 v13 = pHWLTexture->pPixels; | |
8892 v14 = (unsigned __int16 *)desc.lpSurface; | |
8893 if ( desc.dwHeight ) | |
8894 { | |
8895 do | |
8896 { | |
8897 v15 = 0; | |
8898 if ( desc.dwWidth ) | |
8899 { | |
8900 do | |
8901 { | |
8902 ++v15; | |
8903 *v14 = *v13; | |
8904 ++v14; | |
8905 ++v13; | |
8906 } | |
8907 while ( v15 < desc.dwWidth ); | |
8908 } | |
8909 ++bMipMaps; | |
8910 v14 += (desc.lPitch >> 1) - desc.dwWidth; | |
8911 } | |
8912 while ( bMipMaps < desc.dwHeight ); | |
8913 } | |
8914 ErrD3D((*pOutSurface)->Unlock(0)); | |
8915 } | |
8916 } | |
8917 delete [] pHWLTexture->pPixels; | |
8918 delete pHWLTexture; | |
8919 return true; | |
8920 } | |
8921 return false; | |
8922 } | |
8923 | |
8924 //----- (004A5048) -------------------------------------------------------- | |
670 | 8925 bool Render::MoveSpriteToDevice( Sprite *pSprite ) |
8926 { | |
8927 | |
8928 HWLTexture *sprite_texture; // eax@1 | |
0 | 8929 unsigned __int16 *v9; // edx@5 |
8930 LPVOID v10; // eax@5 | |
8931 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
8932 | |
670 | 8933 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID); |
8934 if ( sprite_texture ) | |
8935 { | |
8936 _gpu_memory_used += 2 * sprite_texture->uWidth * sprite_texture->uHeight; | |
8937 pSprite->uAreaX = sprite_texture->uAreaX; | |
8938 pSprite->uAreaY = sprite_texture->uAreaY; | |
8939 pSprite->uBufferWidth = sprite_texture->uBufferWidth; | |
8940 pSprite->uBufferHeight = sprite_texture->uBufferHeight; | |
8941 pSprite->uAreaWidth = sprite_texture->uAreaWidth; | |
8942 pSprite->uAreaHeight = sprite_texture->uAreaHeigth; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8943 //v6 = v3->uMinDeviceTextureDim; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
8944 //v7 = v3->pRenderD3D; |
670 | 8945 if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) |
0 | 8946 Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); |
8947 //pSprite = v2->pTextureSurface; | |
8948 //pSprite = (Sprite *)pSprite->pName; | |
8949 //v8 = pSprite; | |
670 | 8950 memset(&Dst, 0, sizeof(DDSURFACEDESC2)); |
0 | 8951 Dst.dwSize = 124; |
670 | 8952 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) |
8953 { | |
8954 v9 = sprite_texture->pPixels; | |
8955 v10 = Dst.lpSurface; | |
8956 for (int i=0; i<sprite_texture->uHeight; ++i) | |
0 | 8957 { |
670 | 8958 for (int j=0; j<sprite_texture->uWidth/2; ++j) |
8959 { | |
0 | 8960 *(int *)v10 = *(int *)v9; |
8961 v9 += 2; | |
8962 v10 = (char *)v10 + 4; | |
670 | 8963 } |
8964 v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; | |
0 | 8965 } |
670 | 8966 ErrD3D(pSprite->pTextureSurface->Unlock(0)); |
8967 } | |
8968 free(sprite_texture->pPixels); | |
8969 free(sprite_texture); | |
8970 return true; | |
8971 } | |
8972 return false; | |
0 | 8973 } |
8974 | |
8975 //----- (004A51CB) -------------------------------------------------------- | |
8976 void Render::BeginScene() | |
8977 { | |
8978 Render *v1; // esi@1 | |
8979 unsigned int v2; // eax@1 | |
8980 int v3; // eax@5 | |
8981 unsigned __int16 **v4; // edi@6 | |
8982 char *v5; // ebx@7 | |
8983 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4 | |
8984 | |
8985 v1 = this; | |
8986 v2 = this->uNumSceneBegins; | |
8987 this->uNumSceneBegins = v2 + 1; | |
8988 if ( !v2 ) | |
8989 { | |
8990 if ( this->pRenderD3D ) | |
8991 { | |
8992 if ( this->bColorKeySupported ) | |
8993 { | |
8994 memset(&Dst, 0, 0x7Cu); | |
8995 Dst.dwSize = 124; | |
168 | 8996 if ( LockSurface_DDraw4(v1->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) ) |
0 | 8997 { |
8998 v1->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; | |
8999 v3 = Dst.lPitch >> 1; | |
9000 v1->uTargetSurfacePitch = Dst.lPitch >> 1; | |
9001 LABEL_10: | |
9002 v1->field_18_locked_pitch = v3; | |
9003 goto LABEL_11; | |
9004 } | |
9005 goto LABEL_8; | |
9006 } | |
9007 } | |
9008 else | |
9009 { | |
9010 v4 = &this->pTargetSurface; | |
9011 if ( !this->pTargetSurface ) | |
9012 { | |
9013 v5 = (char *)&this->uTargetSurfacePitch; | |
9014 LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch); | |
9015 if ( *v4 ) | |
9016 { | |
9017 v3 = *(int *)v5; | |
9018 goto LABEL_10; | |
9019 } | |
9020 LABEL_8: | |
9021 --v1->uNumSceneBegins; | |
9022 return; | |
9023 } | |
9024 } | |
9025 LABEL_11: | |
9026 RestoreFrontBuffer(); | |
9027 } | |
9028 } | |
9029 | |
9030 //----- (004A527D) -------------------------------------------------------- | |
9031 void Render::EndScene() | |
9032 { | |
9033 unsigned int v1; // edx@1 | |
9034 unsigned int v2; // edx@2 | |
9035 HRESULT v3; // eax@5 | |
9036 | |
9037 v1 = this->uNumSceneBegins; | |
9038 if ( v1 ) | |
9039 { | |
9040 v2 = v1 - 1; | |
9041 this->uNumSceneBegins = v2; | |
9042 if ( !v2 ) | |
9043 { | |
9044 if ( this->pRenderD3D ) | |
9045 { | |
9046 if ( this->bColorKeySupported ) | |
9047 { | |
9048 this->pTargetSurface = 0; | |
9049 this->uTargetSurfacePitch = 0; | |
9050 this->field_18_locked_pitch = 0; | |
9051 ErrD3D(this->pColorKeySurface4->Unlock(0)); | |
9052 } | |
9053 } | |
9054 else | |
9055 { | |
9056 this->pTargetSurface = 0; | |
9057 this->uTargetSurfacePitch = 0; | |
9058 this->field_18_locked_pitch = 0; | |
9059 UnlockBackBuffer(); | |
9060 } | |
9061 } | |
9062 } | |
9063 } | |
9064 | |
9065 //----- ( ) -------------------------------------------------------- | |
9066 unsigned int Render::_4A52F1(unsigned int this_, float a3) | |
9067 { | |
9068 unsigned int v3; // esi@1 | |
9069 double v4; // st7@2 | |
9070 double v5; // st7@6 | |
9071 double v6; // st6@6 | |
9072 unsigned int v7; // eax@6 | |
9073 double v8; // st5@6 | |
9074 double v9; // st4@6 | |
9075 HRESULT v10; // eax@6 | |
9076 HRESULT v11; // eax@6 | |
9077 unsigned int result; // eax@6 | |
9078 unsigned int v13; // eax@7 | |
9079 unsigned __int16 *v14; // ecx@7 | |
9080 int *v15; // eax@7 | |
9081 unsigned int v16; // ecx@8 | |
9082 __int16 v17; // ax@10 | |
9083 int v18; // esi@10 | |
9084 float v19; // edi@10 | |
9085 void *v20; // esi@10 | |
9086 int v21; // edx@10 | |
9087 int v22; // ecx@11 | |
9088 int v23; // edx@12 | |
9089 __int16 v24; // ax@15 | |
9090 int v25; // esi@15 | |
9091 float v26; // edi@15 | |
9092 char *v27; // esi@15 | |
9093 int v28; // edx@15 | |
9094 int v29; // ecx@16 | |
9095 int v30; // edx@17 | |
9096 int v31; // [sp-Ch] [bp-ACh]@11 | |
9097 int v32; // [sp-Ch] [bp-ACh]@16 | |
9098 const char *v33; // [sp+0h] [bp-A0h]@0 | |
9099 int v34; // [sp+4h] [bp-9Ch]@0 | |
9100 unsigned int v35; // [sp+8h] [bp-98h]@0 | |
9101 RenderVertexD3D3 v36[4]; // [sp+Ch] [bp-94h]@6 | |
9102 unsigned int v37; // [sp+8Ch] [bp-14h]@7 | |
9103 int v38; // [sp+90h] [bp-10h]@7 | |
9104 double v39; // [sp+94h] [bp-Ch]@6 | |
9105 float v40; // [sp+9Ch] [bp-4h]@6 | |
9106 | |
9107 auto ecx0 = this; | |
9108 v3 = 0; | |
9109 if ( ecx0->pRenderD3D ) | |
9110 { | |
9111 v4 = a3; | |
9112 if ( a3 <= 1.0 ) | |
9113 { | |
9114 if ( v4 < 0.0 ) | |
9115 v4 = 0.0; | |
9116 } | |
9117 else | |
9118 { | |
9119 v4 = 1.0; | |
9120 } | |
9121 a3 = v4 * 255.0; | |
9122 v39 = a3 + 6.7553994e15; | |
9123 LODWORD(v40) = LODWORD(v39); | |
693 | 9124 v5 = (double)(signed int)pViewport->uViewportTL_X; |
0 | 9125 v36[0].pos.x = v5; |
693 | 9126 v6 = (double)(signed int)pViewport->uViewportTL_Y; |
0 | 9127 v7 = this_ | (LODWORD(v39) << 24); |
693 | 9128 this_ = pViewport->uViewportBR_Y + 1; |
0 | 9129 v36[0].specular = 0; |
9130 v36[0].pos.y = v6; | |
9131 v36[0].diffuse = v7; | |
9132 v36[1].diffuse = v7; | |
9133 v36[0].pos.z = 0.0; | |
9134 v36[2].diffuse = v7; | |
9135 v36[3].diffuse = v7; | |
9136 v36[0].rhw = 1.0; | |
9137 v36[1].specular = 0; | |
9138 v36[0].texcoord.x = 0.0; | |
9139 v36[2].specular = 0; | |
9140 v36[3].specular = 0; | |
9141 v36[0].texcoord.y = 0.0; | |
9142 v36[1].pos.x = v5; | |
693 | 9143 v8 = (double)(pViewport->uViewportBR_Y + 1); |
0 | 9144 v36[1].pos.y = v8; |
9145 v36[1].pos.z = 0.0; | |
9146 v36[1].rhw = 1.0; | |
9147 v36[1].texcoord.x = 0.0; | |
9148 v36[1].texcoord.y = 0.0; | |
693 | 9149 v9 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 9150 v36[2].pos.x = v9; |
9151 v36[2].pos.y = v8; | |
9152 v36[2].pos.z = 0.0; | |
9153 v36[2].rhw = 1.0; | |
9154 v36[2].texcoord.x = 0.0; | |
9155 v36[2].texcoord.y = 0.0; | |
9156 v36[3].pos.x = v9; | |
9157 v36[3].pos.y = v6; | |
9158 v36[3].pos.z = 0.0; | |
9159 v36[3].rhw = 1.0; | |
9160 v36[3].texcoord.x = 0.0; | |
9161 v36[3].texcoord.y = 0.0; | |
9162 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | |
186 | 9163 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
9164 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
9165 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
9166 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
9167 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
9168 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
9169 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); | |
0 | 9170 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
9171 D3DPT_TRIANGLEFAN, | |
9172 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
9173 v36, | |
9174 4, | |
9175 28)); | |
186 | 9176 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); |
9177 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
9178 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
9179 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
9180 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
9181 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); | |
0 | 9182 } |
9183 else | |
9184 { | |
9185 v40 = (1.0 - a3) * 65536.0; | |
9186 v39 = v40 + 6.7553994e15; | |
9187 LODWORD(a3) = LODWORD(v39); | |
693 | 9188 v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1; |
9189 HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1; | |
9190 v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X; | |
9191 v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch]; | |
0 | 9192 v37 = 2 * v13; |
9193 LODWORD(v40) = (int)v14; | |
9194 | |
9195 int __i = 0; | |
9196 v15 = dword_F1B430; | |
9197 do | |
9198 { | |
9199 v16 = v3; | |
9200 v3 += LODWORD(a3); | |
9201 dword_F1B430[__i++] = v16 >> 16; | |
9202 } | |
9203 //while ( (signed int)v15 < (signed int)&Aureal3D_SplashScreen ); | |
9204 while (__i < 32); | |
9205 | |
9206 if ( pRenderer->uTargetGBits == 6 ) | |
9207 { | |
9208 v17 = _42690D_colors_cvt(this_); | |
9209 v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); | |
9210 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); | |
9211 v19 = v40; | |
9212 v20 = off_4EFDB0; | |
9213 v21 = HIDWORD(v39); | |
9214 do | |
9215 { | |
9216 v22 = v38; | |
9217 v31 = v21; | |
9218 do | |
9219 { | |
9220 v23 = (*(int *)((char *)v20 | |
9221 + ((((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; | |
9222 result = this_ | |
9223 + (*((int *)v20 | |
9224 + (((unsigned __int8)(*((char *)v20 | |
9225 + ((((unsigned __int16)(*(short *)((char *)v20 | |
9226 + ((*(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); | |
9227 *(unsigned int *)LODWORD(v19) = result; | |
9228 LODWORD(v19) += 4; | |
9229 --v22; | |
9230 } | |
9231 while ( v22 ); | |
9232 LODWORD(v19) += v37; | |
9233 v21 = v31 - 1; | |
9234 } | |
9235 while ( v31 != 1 ); | |
9236 } | |
9237 else | |
9238 { | |
9239 v24 = _4268E3_smthn_to_a1r5g5b5(this_); | |
9240 v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); | |
9241 this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) | |
9242 * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); | |
9243 v26 = v40; | |
9244 v27 = (char *)off_4EFDB0; | |
9245 v28 = HIDWORD(v39); | |
9246 do | |
9247 { | |
9248 v29 = v38; | |
9249 v32 = v28; | |
9250 do | |
9251 { | |
9252 v30 = 32 | |
9253 * *(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; | |
9254 result = this_ | |
9255 + (*(int *)&v27[4 | |
9256 * (((unsigned __int8)(32 | |
9257 * 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); | |
9258 *(unsigned int *)LODWORD(v26) = result; | |
9259 LODWORD(v26) += 4; | |
9260 --v29; | |
9261 } | |
9262 while ( v29 ); | |
9263 LODWORD(v26) += v37; | |
9264 v28 = v32 - 1; | |
9265 } | |
9266 while ( v32 != 1 ); | |
9267 } | |
9268 } | |
9269 return result; | |
9270 } | |
9271 | |
9272 //----- (004A5B81) -------------------------------------------------------- | |
727 | 9273 void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) |
0 | 9274 { |
9275 this->bClip = 1; | |
9276 this->uClipY = uY; | |
9277 this->uClipX = uX; | |
9278 this->uClipW = uW; | |
9279 this->uClipZ = uZ; | |
9280 } | |
9281 | |
9282 //----- (004A5BB6) -------------------------------------------------------- | |
727 | 9283 void Render::ResetTextureClipRect() |
0 | 9284 { |
9285 this->uClipY = 0; | |
9286 this->uClipX = 0; | |
9287 this->bClip = 1; | |
9288 this->uClipW = 480; | |
9289 this->uClipZ = 640; | |
9290 } | |
9291 | |
9292 //----- (004A5BE3) -------------------------------------------------------- | |
9293 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | |
9294 { | |
9295 int v4; // edi@3 | |
9296 unsigned __int16 *v5; // edx@3 | |
9297 unsigned __int16 *v6; // esi@3 | |
9298 unsigned int v7; // ebx@4 | |
9299 unsigned int v8; // eax@5 | |
9300 unsigned int v9; // ebx@5 | |
9301 unsigned int v10; // eax@6 | |
9302 unsigned int v11; // eax@7 | |
9303 unsigned int v12; // ebx@8 | |
9304 unsigned int v13; // eax@10 | |
9305 unsigned int v14; // edi@11 | |
9306 unsigned int v15; // eax@14 | |
9307 unsigned int v16; // ebx@17 | |
9308 int v17; // eax@23 | |
9309 char v18; // zf@25 | |
9310 int v19; // [sp+10h] [bp-8h]@3 | |
9311 int v20; // [sp+14h] [bp-4h]@3 | |
9312 unsigned int uOutXa; // [sp+20h] [bp+8h]@16 | |
9313 int uOutXb; // [sp+20h] [bp+8h]@21 | |
9314 int v23; // [sp+28h] [bp+10h]@3 | |
9315 | |
9316 if ( this->uNumSceneBegins && a4 ) | |
9317 { | |
9318 v4 = a4->uWidth; | |
9319 v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
9320 v6 = a4->pPixels; | |
9321 v20 = v4; | |
9322 v23 = a4->uHeight; | |
9323 v19 = v4; | |
9324 if ( this->bClip ) | |
9325 { | |
9326 v7 = this->uClipX; | |
9327 if ( (signed int)uOutX < (signed int)v7 ) | |
9328 { | |
9329 v8 = v7 - uOutX; | |
9330 v9 = uOutX - v7; | |
9331 v8 *= 2; | |
9332 v4 += v9; | |
9333 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
9334 v20 += v9; | |
9335 v5 = (unsigned __int16 *)((char *)v5 + v8); | |
9336 } | |
9337 v10 = this->uClipY; | |
9338 if ( (signed int)uOutY < (signed int)v10 ) | |
9339 { | |
9340 v11 = v10 - uOutY; | |
9341 v6 += v19 * v11; | |
9342 v23 += uOutY - this->uClipY; | |
9343 v4 = v20; | |
9344 v5 += this->uTargetSurfacePitch * v11; | |
9345 } | |
9346 v12 = this->uClipX; | |
9347 if ( (signed int)v12 < (signed int)uOutX ) | |
9348 v12 = uOutX; | |
9349 v13 = this->uClipZ; | |
9350 if ( (signed int)(v4 + v12) > (signed int)v13 ) | |
9351 { | |
9352 v14 = this->uClipX; | |
9353 if ( (signed int)v14 < (signed int)uOutX ) | |
9354 v14 = uOutX; | |
9355 v4 = v13 - v14; | |
9356 } | |
9357 v15 = this->uClipY; | |
9358 if ( (signed int)v15 < (signed int)uOutY ) | |
9359 v15 = uOutY; | |
9360 uOutXa = this->uClipW; | |
9361 if ( (signed int)(v15 + v23) > (signed int)uOutXa ) | |
9362 { | |
9363 v16 = this->uClipY; | |
9364 if ( (signed int)v16 < (signed int)uOutY ) | |
9365 v16 = uOutY; | |
9366 v23 = uOutXa - v16; | |
9367 } | |
9368 } | |
9369 if ( v23 > 0 ) | |
9370 { | |
9371 uOutXb = v23; | |
9372 do | |
9373 { | |
9374 if ( v4 > 0 ) | |
9375 { | |
9376 v17 = v4; | |
9377 do | |
9378 { | |
9379 *v5 = *v6; | |
9380 ++v5; | |
9381 ++v6; | |
9382 --v17; | |
9383 } | |
9384 while ( v17 ); | |
9385 } | |
9386 v6 += v19 - v4; | |
9387 v18 = uOutXb-- == 1; | |
9388 v5 += this->uTargetSurfacePitch - v4; | |
9389 } | |
9390 while ( !v18 ); | |
9391 } | |
9392 } | |
9393 } | |
9394 | |
9395 //----- (004A5D33) -------------------------------------------------------- | |
9396 void Render::_4A5D33(unsigned int pX, unsigned int pY, int a4, int a5, RGBTexture *pTexture) | |
9397 { | |
9398 Render *v6; // esi@1 | |
9399 unsigned __int16 *v7; // ebx@3 | |
9400 int v8; // ecx@3 | |
9401 int v9; // edx@3 | |
9402 int v10; // ecx@3 | |
9403 int v11; // edi@3 | |
9404 signed int v12; // eax@4 | |
9405 unsigned int v13; // eax@5 | |
9406 signed int v14; // eax@6 | |
9407 unsigned int v15; // eax@7 | |
9408 unsigned int v16; // edx@8 | |
9409 int v17; // eax@10 | |
9410 unsigned int v18; // ecx@11 | |
9411 unsigned int v19; // ecx@14 | |
9412 int v20; // eax@16 | |
9413 unsigned int v21; // ecx@17 | |
9414 int v22; // eax@21 | |
9415 int v23; // edi@23 | |
9416 int v24; // [sp+Ch] [bp-4h]@3 | |
9417 int a2a; // [sp+18h] [bp+8h]@21 | |
9418 unsigned int teal; // [sp+1Ch] [bp+Ch]@20 | |
9419 int a4a; // [sp+20h] [bp+10h]@3 | |
9420 int a4b; // [sp+20h] [bp+10h]@21 | |
9421 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 | |
9422 | |
9423 v6 = this; | |
9424 if ( this->uNumSceneBegins && pTexture ) | |
9425 { | |
9426 v7 = &this->pTargetSurface[pX + pY * this->uTargetSurfacePitch]; | |
9427 v8 = pTexture->uWidth; | |
9428 v24 = pTexture->uWidth; | |
9429 v9 = a4 + a5 * v8; | |
9430 v10 = v8 - a4; | |
9431 a4a = v10; | |
9432 v11 = pTexture->uHeight - a5; | |
9433 pTexturea = &pTexture->pPixels[v9]; | |
9434 if ( v6->bClip ) | |
9435 { | |
9436 v12 = v6->uClipX; | |
9437 if ( (signed int)pX < v12 ) | |
9438 { | |
9439 v13 = 2 * (v12 - pX); | |
9440 pTexturea = (unsigned __int16 *)((char *)pTexturea + v13); | |
9441 v10 += pX - v6->uClipX; | |
9442 v7 = (unsigned __int16 *)((char *)v7 + v13); | |
9443 a4a = v10; | |
9444 } | |
9445 v14 = v6->uClipY; | |
9446 if ( (signed int)pY < v14 ) | |
9447 { | |
9448 v15 = v14 - pY; | |
9449 pTexturea += v24 * v15; | |
9450 v11 += pY - v6->uClipY; | |
9451 v10 = a4a; | |
9452 v7 += v6->uTargetSurfacePitch * v15; | |
9453 } | |
9454 v16 = v6->uClipX; | |
9455 if ( (signed int)v16 < (signed int)pX ) | |
9456 v16 = pX; | |
9457 v17 = v6->uClipZ; | |
9458 if ( (signed int)(v10 + v16) > v17 ) | |
9459 { | |
9460 v18 = v6->uClipX; | |
9461 if ( (signed int)v18 < (signed int)pX ) | |
9462 v18 = pX; | |
9463 a4a = v17 - v18; | |
9464 } | |
9465 v19 = v6->uClipY; | |
9466 if ( (signed int)v19 < (signed int)pY ) | |
9467 v19 = pY; | |
9468 v20 = v6->uClipW; | |
9469 if ( (signed int)(v11 + v19) > v20 ) | |
9470 { | |
9471 v21 = v6->uClipY; | |
9472 if ( (signed int)v21 < (signed int)pY ) | |
9473 v21 = pY; | |
9474 v11 = v20 - v21; | |
9475 } | |
9476 } | |
9477 teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu); | |
9478 if ( v11 > 0 ) | |
9479 { | |
9480 v22 = a4a; | |
9481 a2a = v11; | |
9482 a4b = 2 * (v24 - a4a); | |
9483 do | |
9484 { | |
9485 if ( v22 > 0 ) | |
9486 { | |
9487 v23 = v22; | |
9488 do | |
9489 { | |
9490 if ( *pTexturea != teal ) | |
9491 *v7 = *pTexturea; | |
9492 ++pTexturea; | |
9493 ++v7; | |
9494 --v23; | |
9495 } | |
9496 while ( v23 ); | |
9497 } | |
9498 v7 += v6->uTargetSurfacePitch - v22; | |
9499 pTexturea = (unsigned __int16 *)((char *)pTexturea + a4b); | |
9500 --a2a; | |
9501 } | |
9502 while ( a2a ); | |
9503 } | |
9504 } | |
9505 } | |
9506 | |
9507 //----- (004A6E7E) -------------------------------------------------------- | |
9508 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) | |
9509 { | |
9510 unsigned __int16 *v4; // eax@4 | |
9511 int v5; // edx@4 | |
9512 unsigned int v6; // edi@4 | |
9513 unsigned int v7; // edx@5 | |
9514 unsigned int v8; // edx@6 | |
9515 unsigned int v9; // edx@7 | |
9516 unsigned int v10; // edx@8 | |
9517 unsigned int v11; // ebx@9 | |
9518 unsigned int v12; // esi@11 | |
9519 unsigned int v13; // edx@12 | |
9520 unsigned int v14; // ebx@15 | |
9521 unsigned int v15; // esi@17 | |
9522 unsigned int v16; // edi@18 | |
9523 char v17; // zf@29 | |
9524 int v18; // [sp+14h] [bp-Ch]@4 | |
9525 int v19; // [sp+18h] [bp-8h]@4 | |
9526 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 | |
9527 int v21; // [sp+28h] [bp+8h]@25 | |
9528 int v22; // [sp+28h] [bp+8h]@34 | |
9529 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | |
9530 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | |
9531 | |
9532 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | |
9533 { | |
9534 v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 9535 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 9536 v5 = a4->uTextureWidth; |
9537 v6 = a4->uTextureHeight; | |
9538 v19 = a4->uTextureWidth; | |
9539 v18 = a4->uTextureWidth; | |
9540 if ( this->bClip ) | |
9541 { | |
9542 v7 = this->uClipX; | |
9543 if ( (signed int)a2 < (signed int)v7 ) | |
9544 { | |
9545 v8 = v7 - a2; | |
9546 v20 += v8; | |
9547 v19 += a2 - this->uClipX; | |
9548 v4 += v8; | |
9549 } | |
9550 v9 = this->uClipY; | |
9551 if ( (signed int)a3 < (signed int)v9 ) | |
9552 { | |
9553 v10 = v9 - a3; | |
9554 v20 += v18 * v10; | |
9555 v6 = a3 - this->uClipY + a4->uTextureHeight; | |
9556 v4 += this->uTargetSurfacePitch * v10; | |
9557 } | |
9558 v11 = this->uClipX; | |
9559 v5 = v19; | |
9560 if ( (signed int)v11 < (signed int)a2 ) | |
9561 v11 = a2; | |
9562 v12 = this->uClipZ; | |
9563 if ( (signed int)(v19 + v11) > (signed int)v12 ) | |
9564 { | |
9565 v13 = this->uClipX; | |
9566 if ( (signed int)v13 < (signed int)a2 ) | |
9567 v13 = a2; | |
9568 v5 = v12 - v13; | |
9569 } | |
9570 v14 = this->uClipY; | |
9571 if ( (signed int)v14 < (signed int)a3 ) | |
9572 v14 = a3; | |
9573 v15 = this->uClipW; | |
9574 if ( (signed int)(v6 + v14) > (signed int)v15 ) | |
9575 { | |
9576 v16 = this->uClipY; | |
9577 if ( (signed int)v16 < (signed int)a3 ) | |
9578 v16 = a3; | |
9579 v6 = v15 - v16; | |
9580 } | |
9581 } | |
9582 if ( pRenderer->uTargetGBits == 5 ) | |
9583 { | |
9584 if ( (signed int)v6 > 0 ) | |
9585 { | |
9586 v23 = v6; | |
9587 do | |
9588 { | |
9589 if ( v5 > 0 ) | |
9590 { | |
9591 v21 = v5; | |
9592 do | |
9593 { | |
9594 if ( *v20 ) | |
9595 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x3DEF; | |
9596 ++v4; | |
9597 ++v20; | |
9598 --v21; | |
9599 } | |
9600 while ( v21 ); | |
9601 } | |
9602 v20 += v18 - v5; | |
9603 v17 = v23-- == 1; | |
9604 v4 += this->uTargetSurfacePitch - v5; | |
9605 } | |
9606 while ( !v17 ); | |
9607 } | |
9608 } | |
9609 else | |
9610 { | |
9611 if ( (signed int)v6 > 0 ) | |
9612 { | |
9613 v24 = v6; | |
9614 do | |
9615 { | |
9616 if ( v5 > 0 ) | |
9617 { | |
9618 v22 = v5; | |
9619 do | |
9620 { | |
9621 if ( *v20 ) | |
9622 *v4 = ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF; | |
9623 ++v4; | |
9624 ++v20; | |
9625 --v22; | |
9626 } | |
9627 while ( v22 ); | |
9628 } | |
9629 v20 += v18 - v5; | |
9630 v17 = v24-- == 1; | |
9631 v4 += this->uTargetSurfacePitch - v5; | |
9632 } | |
9633 while ( !v17 ); | |
9634 } | |
9635 } | |
9636 } | |
9637 } | |
9638 | |
9639 //----- (004A6DF5) -------------------------------------------------------- | |
9640 int Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) | |
9641 { | |
9642 int result; // eax@0 | |
9643 int v8; // ecx@3 | |
9644 unsigned __int16 *v9; // edi@4 | |
9645 unsigned __int16 *v10; // ebx@4 | |
9646 int v11; // esi@4 | |
9647 unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3 | |
9648 unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3 | |
9649 | |
9650 if ( pBitmap ) | |
9651 { | |
9652 if ( pTarget ) | |
9653 { | |
9654 pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y]; | |
9655 pTargeta = &pTarget[a7->x + uTargetPitch * a7->y]; | |
9656 v8 = a7->z - a7->x; | |
9657 result = a7->w - a7->y; | |
9658 if ( result > 0 ) | |
9659 { | |
9660 v9 = pBitmapa; | |
9661 v10 = pTargeta; | |
9662 v11 = a7->w - a7->y; | |
9663 do | |
9664 { | |
9665 if ( v8 > 0 ) | |
9666 { | |
9667 result = v8; | |
9668 do | |
9669 { | |
9670 *v9 = *v10; | |
9671 ++v9; | |
9672 ++v10; | |
9673 --result; | |
9674 } | |
9675 while ( result ); | |
9676 } | |
9677 v9 += uBitmapPitch - v8; | |
9678 v10 += uTargetPitch - v8; | |
9679 --v11; | |
9680 } | |
9681 while ( v11 ); | |
9682 } | |
9683 } | |
9684 } | |
9685 return result; | |
9686 } | |
9687 | |
9688 //----- (004A6D87) -------------------------------------------------------- | |
9689 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | |
9690 { | |
9691 if (!uNumSceneBegins) | |
9692 return; | |
9693 | |
9694 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | |
9695 for (uint y = 0; y < uHeight; ++y) | |
9696 { | |
9697 auto pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch]; | |
9698 | |
9699 memset32(pDst, twoColors, uWidth / 2); | |
9700 if (uWidth & 1) | |
9701 pDst[uWidth - 1] = uColor16; | |
9702 } | |
9703 } | |
9704 | |
9705 //----- (004A6C4F) -------------------------------------------------------- | |
9706 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) | |
9707 { | |
9708 unsigned int v9; // edi@2 | |
9709 unsigned int v10; // esi@2 | |
9710 unsigned __int16 *v11; // eax@2 | |
9711 unsigned int v12; // ebx@3 | |
9712 signed int v13; // edx@5 | |
9713 int v14; // edx@6 | |
9714 signed int v15; // ebx@7 | |
9715 unsigned int v16; // edx@9 | |
9716 signed int v17; // edi@10 | |
9717 signed int v18; // ebx@13 | |
9718 unsigned int v19; // edx@15 | |
9719 signed int v20; // esi@16 | |
9720 unsigned int v21; // esi@22 | |
9721 unsigned __int16 v22; // dx@24 | |
9722 char v23; // zf@28 | |
9723 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 | |
9724 unsigned int uOutXa; // [sp+18h] [bp+8h]@20 | |
9725 | |
9726 if ( this->uNumSceneBegins ) | |
9727 { | |
9728 v9 = uCharWidth; | |
9729 v10 = uCharHeight; | |
9730 v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | |
9731 v24 = pFontPixels; | |
9732 if ( this->bClip ) | |
9733 { | |
9734 v12 = this->uClipX; | |
9735 if ( uOutX < (signed int)v12 ) | |
9736 { | |
9737 v24 = &pFontPixels[v12 - uOutX]; | |
9738 v11 += v12 - uOutX; | |
9739 v9 = uCharWidth + uOutX - v12; | |
9740 } | |
9741 v13 = this->uClipY; | |
9742 if ( uOutY < v13 ) | |
9743 { | |
9744 v14 = v13 - uOutY; | |
9745 v24 += uCharWidth * v14; | |
9746 v10 = uCharHeight + uOutY - this->uClipY; | |
9747 v11 += this->uTargetSurfacePitch * v14; | |
9748 } | |
9749 v15 = this->uClipX; | |
9750 if ( v15 < uOutX ) | |
9751 v15 = uOutX; | |
9752 v16 = this->uClipZ; | |
9753 if ( (signed int)(v9 + v15) > (signed int)v16 ) | |
9754 { | |
9755 v17 = this->uClipX; | |
9756 if ( v17 < uOutX ) | |
9757 v17 = uOutX; | |
9758 v9 = v16 - v17; | |
9759 } | |
9760 v18 = this->uClipY; | |
9761 if ( v18 < uOutY ) | |
9762 v18 = uOutY; | |
9763 v19 = this->uClipW; | |
9764 if ( (signed int)(v10 + v18) > (signed int)v19 ) | |
9765 { | |
9766 v20 = this->uClipY; | |
9767 if ( v20 < uOutY ) | |
9768 v20 = uOutY; | |
9769 v10 = v19 - v20; | |
9770 } | |
9771 } | |
9772 if ( (signed int)v10 > 0 ) | |
9773 { | |
9774 uOutXa = v10; | |
9775 do | |
9776 { | |
9777 if ( (signed int)v9 > 0 ) | |
9778 { | |
9779 v21 = v9; | |
9780 do | |
9781 { | |
9782 if ( *v24 ) | |
9783 { | |
9784 v22 = uShadowColor; | |
9785 if ( *v24 != 1 ) | |
9786 v22 = uFaceColor; | |
9787 *v11 = v22; | |
9788 } | |
9789 ++v11; | |
9790 ++v24; | |
9791 --v21; | |
9792 } | |
9793 while ( v21 ); | |
9794 } | |
9795 v24 += uCharWidth - v9; | |
9796 v23 = uOutXa-- == 1; | |
9797 v11 += this->uTargetSurfacePitch - v9; | |
9798 } | |
9799 while ( !v23 ); | |
9800 } | |
9801 } | |
9802 } | |
9803 | |
9804 //----- (004A6A68) -------------------------------------------------------- | |
9805 void Render::_4A6A68(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) | |
9806 { | |
9807 Render *v5; // ebx@1 | |
9808 unsigned __int16 v6; // ax@1 | |
9809 | |
9810 v5 = this; | |
9811 | |
9812 Texture tex; // [sp+Ch] [bp-48h]@1 | |
9813 //Texture::Texture(&tex); | |
9814 | |
9815 v6 = a4->uTextureHeight - height; | |
9816 memcpy(&tex, a4, sizeof(tex)); | |
9817 tex.uTextureHeight = v6; | |
9818 if ( (signed __int16)v6 > 0 ) | |
9819 DrawTextureIndexed(a2, a3, &tex); | |
9820 } | |
9821 | |
9822 //----- (004A6AB1) -------------------------------------------------------- | |
9823 void Render::DrawTextPalette(int x, int y, int a4, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8) | |
9824 { | |
9825 int v8; // edi@2 | |
9826 unsigned int v9; // esi@2 | |
9827 unsigned __int16 *v10; // eax@2 | |
9828 unsigned char *v11; // edx@2 | |
9829 unsigned int v12; // ebx@3 | |
9830 signed int v13; // edx@5 | |
9831 int v14; // edx@6 | |
9832 signed int v15; // ebx@7 | |
9833 unsigned int v16; // edx@9 | |
9834 signed int v17; // edi@10 | |
9835 signed int v18; // ebx@13 | |
9836 unsigned int v19; // edx@15 | |
9837 signed int v20; // esi@16 | |
9838 int v21; // ebx@22 | |
9839 char v22; // zf@28 | |
9840 int v23; // ebx@31 | |
9841 unsigned __int16 v24; // si@35 | |
9842 int v25; // [sp+Ch] [bp-4h]@2 | |
9843 int v26; // [sp+1Ch] [bp+Ch]@24 | |
9844 int v27; // [sp+1Ch] [bp+Ch]@33 | |
9845 unsigned int v28; // [sp+20h] [bp+10h]@30 | |
9846 unsigned int v29; // [sp+24h] [bp+14h]@22 | |
9847 unsigned int v30; // [sp+24h] [bp+14h]@31 | |
9848 | |
9849 auto a2 = x; | |
9850 auto a3 = y; | |
9851 auto a6 = uFontHeight; | |
9852 if ( this->uNumSceneBegins ) | |
9853 { | |
9854 v8 = a5; | |
9855 v9 = a6; | |
9856 v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; | |
9857 v11 = (unsigned char *)a4; | |
9858 v25 = a4; | |
9859 if ( this->bClip ) | |
9860 { | |
9861 v12 = this->uClipX; | |
9862 if ( a2 < (signed int)v12 ) | |
9863 { | |
9864 v25 = v12 - a2 + a4; | |
9865 v10 += v12 - a2; | |
9866 v8 = a5 + a2 - v12; | |
9867 } | |
9868 v13 = this->uClipY; | |
9869 if ( a3 < v13 ) | |
9870 { | |
9871 v14 = v13 - a3; | |
9872 v25 += a5 * v14; | |
9873 v9 = a6 + a3 - this->uClipY; | |
9874 v10 += this->uTargetSurfacePitch * v14; | |
9875 } | |
9876 v15 = this->uClipX; | |
9877 if ( v15 < a2 ) | |
9878 v15 = a2; | |
9879 v16 = this->uClipZ; | |
9880 if ( v8 + v15 > (signed int)v16 ) | |
9881 { | |
9882 v17 = this->uClipX; | |
9883 if ( v17 < a2 ) | |
9884 v17 = a2; | |
9885 v8 = v16 - v17; | |
9886 } | |
9887 v18 = this->uClipY; | |
9888 if ( v18 < a3 ) | |
9889 v18 = a3; | |
9890 v19 = this->uClipW; | |
9891 if ( (signed int)(v9 + v18) > (signed int)v19 ) | |
9892 { | |
9893 v20 = this->uClipY; | |
9894 if ( v20 < a3 ) | |
9895 v20 = a3; | |
9896 v9 = v19 - v20; | |
9897 } | |
9898 v11 = (unsigned char *)v25; | |
9899 } | |
9900 if ( a8 ) | |
9901 { | |
9902 v28 = pRenderer->uTargetGMask | pRenderer->uTargetBMask; | |
9903 if ( (signed int)v9 > 0 ) | |
9904 { | |
9905 v23 = a5; | |
9906 v30 = v9; | |
9907 do | |
9908 { | |
9909 if ( v8 > 0 ) | |
9910 { | |
9911 v27 = v8; | |
9912 do | |
9913 { | |
9914 if ( *v11 ) | |
9915 v24 = pPalette[*v11]; | |
9916 else | |
9917 v24 = v28; | |
9918 *v10 = v24; | |
9919 ++v10; | |
9920 ++v11; | |
9921 --v27; | |
9922 } | |
9923 while ( v27 ); | |
9924 } | |
9925 v11 += v23 - v8; | |
9926 v22 = v30-- == 1; | |
9927 v10 += this->uTargetSurfacePitch - v8; | |
9928 } | |
9929 while ( !v22 ); | |
9930 } | |
9931 } | |
9932 else | |
9933 { | |
9934 if ( (signed int)v9 > 0 ) | |
9935 { | |
9936 v21 = a5; | |
9937 v29 = v9; | |
9938 do | |
9939 { | |
9940 if ( v8 > 0 ) | |
9941 { | |
9942 v26 = v8; | |
9943 do | |
9944 { | |
9945 if ( *v11 ) | |
9946 *v10 = pPalette[*v11]; | |
9947 ++v10; | |
9948 ++v11; | |
9949 --v26; | |
9950 } | |
9951 while ( v26 ); | |
9952 } | |
9953 v11 += v21 - v8; | |
9954 v22 = v29-- == 1; | |
9955 v10 += this->uTargetSurfacePitch - v8; | |
9956 } | |
9957 while ( !v22 ); | |
9958 } | |
9959 } | |
9960 } | |
9961 } | |
9962 | |
9963 //----- (004A68EF) -------------------------------------------------------- | |
9964 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | |
9965 { | |
9966 Texture *v4; // edi@2 | |
9967 unsigned int v5; // ebx@4 | |
9968 unsigned __int16 *v6; // eax@4 | |
9969 signed int v7; // edx@5 | |
9970 int v8; // edx@6 | |
9971 signed int v9; // edx@7 | |
9972 int v10; // edx@8 | |
9973 signed int v11; // edx@9 | |
9974 signed int v12; // esi@12 | |
9975 signed int v13; // esi@15 | |
9976 unsigned int v14; // edx@17 | |
9977 signed int v15; // esi@18 | |
9978 unsigned __int8 *v16; // ebx@22 | |
9979 char v17; // zf@28 | |
9980 int v18; // [sp+10h] [bp-10h]@4 | |
9981 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
9982 int v20; // [sp+1Ch] [bp-4h]@4 | |
9983 int v21; // [sp+28h] [bp+8h]@24 | |
9984 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
9985 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
9986 | |
9987 if ( this->uNumSceneBegins ) | |
9988 { | |
9989 v4 = pTexture; | |
9990 if ( pTexture ) | |
9991 { | |
9992 if ( pTexture->pPalette16 ) | |
9993 { | |
9994 v5 = pTexture->uTextureHeight; | |
9995 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 9996 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 9997 v20 = pTexture->uTextureWidth; |
9998 v18 = pTexture->uTextureWidth; | |
9999 if ( this->bClip ) | |
10000 { | |
10001 v7 = this->uClipX; | |
10002 if ( a2 < v7 ) | |
10003 { | |
10004 v8 = v7 - a2; | |
10005 v19 += v8; | |
10006 v20 += a2 - this->uClipX; | |
10007 v6 += v8; | |
10008 } | |
10009 v9 = this->uClipY; | |
10010 v5 = pTexture->uTextureHeight; | |
10011 if ( a3 < v9 ) | |
10012 { | |
10013 v10 = v9 - a3; | |
10014 v19 += v18 * v10; | |
10015 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
10016 v4 = pTexture; | |
10017 v6 += this->uTargetSurfacePitch * v10; | |
10018 } | |
10019 v11 = this->uClipX; | |
10020 if ( v11 < a2 ) | |
10021 v11 = a2; | |
10022 pTexturea = this->uClipZ; | |
10023 if ( v11 + v20 > (signed int)pTexturea ) | |
10024 { | |
10025 v12 = this->uClipX; | |
10026 if ( v12 < a2 ) | |
10027 v12 = a2; | |
10028 v20 = pTexturea - v12; | |
10029 } | |
10030 v13 = this->uClipY; | |
10031 if ( v13 < a3 ) | |
10032 v13 = a3; | |
10033 v14 = this->uClipW; | |
10034 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10035 { | |
10036 v15 = this->uClipY; | |
10037 if ( v15 < a3 ) | |
10038 v15 = a3; | |
10039 v5 = v14 - v15; | |
10040 } | |
10041 } | |
10042 if ( (signed int)v5 > 0 ) | |
10043 { | |
10044 v22 = v5; | |
10045 v16 = v19; | |
10046 do | |
10047 { | |
10048 if ( v20 > 0 ) | |
10049 { | |
10050 v21 = v20; | |
10051 do | |
10052 { | |
10053 if ( *v16 ) | |
10054 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
10055 ++v6; | |
10056 ++v16; | |
10057 --v21; | |
10058 } | |
10059 while ( v21 ); | |
10060 } | |
10061 v16 += v18 - v20; | |
10062 v17 = v22-- == 1; | |
10063 v6 += this->uTargetSurfacePitch - v20; | |
10064 } | |
10065 while ( !v17 ); | |
10066 } | |
10067 } | |
10068 } | |
10069 } | |
10070 } | |
10071 | |
10072 //----- (004A6776) -------------------------------------------------------- | |
315 | 10073 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
0 | 10074 { |
10075 Texture *v4; // edi@2 | |
10076 unsigned int v5; // ebx@4 | |
10077 unsigned __int16 *v6; // eax@4 | |
10078 unsigned int v7; // edx@5 | |
10079 unsigned int v8; // edx@6 | |
10080 unsigned int v9; // edx@7 | |
10081 unsigned int v10; // edx@8 | |
10082 unsigned int v11; // edx@9 | |
10083 unsigned int v12; // esi@12 | |
10084 unsigned int v13; // esi@15 | |
10085 unsigned int v14; // edx@17 | |
10086 unsigned int v15; // esi@18 | |
10087 unsigned __int8 *v16; // ebx@22 | |
10088 char v17; // zf@28 | |
10089 int v18; // [sp+10h] [bp-10h]@4 | |
10090 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10091 int v20; // [sp+1Ch] [bp-4h]@4 | |
10092 int a2a; // [sp+28h] [bp+8h]@24 | |
10093 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
10094 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
10095 | |
10096 if ( this->uNumSceneBegins ) | |
10097 { | |
10098 v4 = a4; | |
10099 if ( a4 ) | |
10100 { | |
10101 if ( a4->pPalette16 ) | |
10102 { | |
10103 v5 = a4->uTextureHeight; | |
10104 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 10105 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10106 v20 = a4->uTextureWidth; |
10107 v18 = a4->uTextureWidth; | |
10108 if ( this->bClip ) | |
10109 { | |
10110 v7 = this->uClipX; | |
10111 if ( (signed int)a2 < (signed int)v7 ) | |
10112 { | |
10113 v8 = v7 - a2; | |
10114 v19 += v8; | |
10115 v20 += a2 - this->uClipX; | |
10116 v6 += v8; | |
10117 } | |
10118 v9 = this->uClipY; | |
10119 v5 = a4->uTextureHeight; | |
10120 if ( (signed int)a3 < (signed int)v9 ) | |
10121 { | |
10122 v10 = v9 - a3; | |
10123 v19 += v18 * v10; | |
10124 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
10125 v4 = a4; | |
10126 v6 += this->uTargetSurfacePitch * v10; | |
10127 } | |
10128 v11 = this->uClipX; | |
10129 if ( (signed int)v11 < (signed int)a2 ) | |
10130 v11 = a2; | |
10131 a4a = this->uClipZ; | |
10132 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
10133 { | |
10134 v12 = this->uClipX; | |
10135 if ( (signed int)v12 < (signed int)a2 ) | |
10136 v12 = a2; | |
10137 v20 = a4a - v12; | |
10138 } | |
10139 v13 = this->uClipY; | |
10140 if ( (signed int)v13 < (signed int)a3 ) | |
10141 v13 = a3; | |
10142 v14 = this->uClipW; | |
10143 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10144 { | |
10145 v15 = this->uClipY; | |
10146 if ( (signed int)v15 < (signed int)a3 ) | |
10147 v15 = a3; | |
10148 v5 = v14 - v15; | |
10149 } | |
10150 } | |
10151 if ( (signed int)v5 > 0 ) | |
10152 { | |
10153 a3a = v5; | |
10154 v16 = v19; | |
10155 do | |
10156 { | |
10157 if ( v20 > 0 ) | |
10158 { | |
10159 a2a = v20; | |
10160 do | |
10161 { | |
10162 if ( *v16 ) | |
10163 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
10164 ++v6; | |
10165 ++v16; | |
10166 --a2a; | |
10167 } | |
10168 while ( a2a ); | |
10169 } | |
10170 v16 += v18 - v20; | |
10171 v17 = a3a-- == 1; | |
10172 v6 += this->uTargetSurfacePitch - v20; | |
10173 } | |
10174 while ( !v17 ); | |
10175 } | |
10176 } | |
10177 } | |
10178 } | |
10179 } | |
10180 | |
10181 //----- (004A65CC) -------------------------------------------------------- | |
10182 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
10183 { | |
10184 unsigned __int16 *v8; // esi@6 | |
10185 unsigned int v9; // edi@6 | |
10186 unsigned int v10; // eax@7 | |
10187 unsigned int v11; // eax@8 | |
10188 unsigned int v12; // eax@9 | |
10189 unsigned int v13; // eax@10 | |
10190 unsigned int v14; // edx@11 | |
10191 unsigned int v15; // eax@13 | |
10192 unsigned int v16; // edx@14 | |
10193 unsigned int v17; // edx@17 | |
10194 unsigned int v18; // eax@19 | |
10195 unsigned int v19; // edx@20 | |
10196 int v20; // eax@27 | |
10197 int v21; // edx@29 | |
10198 int v22; // [sp+Ch] [bp-Ch]@6 | |
10199 int v23; // [sp+Ch] [bp-Ch]@24 | |
10200 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 | |
10201 int xa; // [sp+20h] [bp+8h]@26 | |
10202 unsigned int ya; // [sp+24h] [bp+Ch]@24 | |
10203 int v27; // [sp+2Ch] [bp+14h]@6 | |
10204 | |
10205 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | |
10206 { | |
10207 v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch]; | |
710 | 10208 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10209 v27 = a4->uTextureWidth; |
10210 v9 = a4->uTextureHeight; | |
10211 v22 = a4->uTextureWidth; | |
10212 if ( this->bClip ) | |
10213 { | |
10214 v10 = this->uClipX; | |
10215 if ( (signed int)x < (signed int)v10 ) | |
10216 { | |
10217 v11 = v10 - x; | |
10218 v24 += v11; | |
10219 v27 += x - this->uClipX; | |
10220 v8 += v11; | |
10221 } | |
10222 v12 = this->uClipY; | |
10223 if ( (signed int)y < (signed int)v12 ) | |
10224 { | |
10225 v13 = v12 - y; | |
10226 v24 += v22 * v13; | |
10227 v9 = y - this->uClipY + a4->uTextureHeight; | |
10228 v8 += this->uTargetSurfacePitch * v13; | |
10229 } | |
10230 v14 = this->uClipX; | |
10231 if ( (signed int)v14 < (signed int)x ) | |
10232 v14 = x; | |
10233 v15 = this->uClipZ; | |
10234 if ( (signed int)(v27 + v14) > (signed int)v15 ) | |
10235 { | |
10236 v16 = this->uClipX; | |
10237 if ( (signed int)v16 < (signed int)x ) | |
10238 v16 = x; | |
10239 v27 = v15 - v16; | |
10240 } | |
10241 v17 = this->uClipY; | |
10242 if ( (signed int)v17 < (signed int)y ) | |
10243 v17 = y; | |
10244 v18 = this->uClipW; | |
10245 if ( (signed int)(v9 + v17) > (signed int)v18 ) | |
10246 { | |
10247 v19 = this->uClipY; | |
10248 if ( (signed int)v19 < (signed int)y ) | |
10249 v19 = y; | |
10250 v9 = v18 - v19; | |
10251 } | |
10252 } | |
10253 if ( (signed int)v9 > 0 ) | |
10254 { | |
10255 ya = v9; | |
10256 v23 = v22 - v27; | |
10257 do | |
10258 { | |
10259 if ( v27 > 0 ) | |
10260 { | |
10261 xa = v27; | |
10262 do | |
10263 { | |
10264 v20 = *v24; | |
10265 if ( v20 >= a7 && v20 <= a8 ) | |
10266 { | |
10267 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
10268 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
10269 v21 = 2 * a8 - v21 - a7; | |
10270 *v8 = a4->pPalette16[v21]; | |
10271 } | |
10272 ++v8; | |
10273 ++v24; | |
10274 --xa; | |
10275 } | |
10276 while ( xa ); | |
10277 } | |
10278 v8 += this->uTargetSurfacePitch - v27; | |
10279 v24 += v23; | |
10280 --ya; | |
10281 } | |
10282 while ( ya ); | |
10283 } | |
10284 } | |
10285 } | |
10286 | |
10287 //----- (004A63E6) -------------------------------------------------------- | |
10288 void Render::_4A63E6(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) | |
10289 { | |
10290 Texture *v8; // eax@2 | |
10291 Texture *v9; // ebx@4 | |
10292 unsigned __int16 *v10; // esi@6 | |
10293 unsigned int v11; // edi@7 | |
10294 unsigned int v12; // eax@9 | |
10295 unsigned int v13; // eax@10 | |
10296 unsigned int v14; // edx@11 | |
10297 unsigned int v15; // eax@13 | |
10298 unsigned int v16; // edx@14 | |
10299 unsigned int v17; // edx@17 | |
10300 unsigned int v18; // eax@19 | |
10301 unsigned int v19; // edx@20 | |
10302 int v20; // eax@27 | |
10303 int v21; // edx@29 | |
10304 int v22; // [sp+Ch] [bp-Ch]@6 | |
10305 int v23; // [sp+Ch] [bp-Ch]@24 | |
10306 int v24; // [sp+10h] [bp-8h]@6 | |
10307 int v25; // [sp+14h] [bp-4h]@6 | |
10308 int i; // [sp+20h] [bp+8h]@25 | |
10309 int v27; // [sp+24h] [bp+Ch]@23 | |
10310 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | |
10311 | |
10312 if ( this->uNumSceneBegins ) | |
10313 { | |
10314 v8 = a4; | |
10315 if ( a4 ) | |
10316 { | |
10317 if ( a4->pPalette16 ) | |
10318 { | |
10319 v9 = a5; | |
10320 if ( a5 ) | |
10321 { | |
10322 if ( a5->pPalette16 ) | |
10323 { | |
10324 v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
710 | 10325 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10326 v25 = v8->uTextureWidth; |
10327 v24 = v8->uTextureHeight; | |
10328 v22 = v8->uTextureWidth; | |
10329 if ( this->bClip ) | |
10330 { | |
10331 v11 = this->uClipX; | |
10332 if ( (signed int)a2 < (signed int)v11 ) | |
10333 { | |
10334 v28 += v11 - a2; | |
10335 v25 += a2 - v11; | |
10336 v9 = a5; | |
10337 v10 += v11 - a2; | |
10338 } | |
10339 v12 = this->uClipY; | |
10340 if ( (signed int)a3 < (signed int)v12 ) | |
10341 { | |
10342 v13 = v12 - a3; | |
10343 v9 = a5; | |
10344 v28 += v22 * v13; | |
10345 v24 += a3 - this->uClipY; | |
10346 v10 += this->uTargetSurfacePitch * v13; | |
10347 } | |
10348 v14 = this->uClipX; | |
10349 if ( (signed int)v14 < (signed int)a2 ) | |
10350 v14 = a2; | |
10351 v15 = this->uClipZ; | |
10352 if ( (signed int)(v25 + v14) > (signed int)v15 ) | |
10353 { | |
10354 v16 = this->uClipX; | |
10355 if ( (signed int)v16 < (signed int)a2 ) | |
10356 v16 = a2; | |
10357 v25 = v15 - v16; | |
10358 } | |
10359 v17 = this->uClipY; | |
10360 if ( (signed int)v17 < (signed int)a3 ) | |
10361 v17 = a3; | |
10362 v18 = this->uClipW; | |
10363 if ( (signed int)(v24 + v17) > (signed int)v18 ) | |
10364 { | |
10365 v19 = this->uClipY; | |
10366 if ( (signed int)v19 < (signed int)a3 ) | |
10367 v19 = a3; | |
10368 v24 = v18 - v19; | |
10369 } | |
10370 } | |
10371 v27 = 0; | |
10372 if ( v24 > 0 ) | |
10373 { | |
10374 v23 = v22 - v25; | |
10375 do | |
10376 { | |
10377 for ( i = 0; i < v25; ++v28 ) | |
10378 { | |
10379 if ( *v28 ) | |
10380 { | |
710 | 10381 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); |
0 | 10382 if ( v20 >= a7 ) |
10383 { | |
10384 if ( v20 <= a8 ) | |
10385 { | |
10386 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
10387 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
10388 v21 = 2 * a8 - v21 - a7; | |
10389 v9 = a5; | |
10390 *v10 = a5->pPalette16[v21]; | |
10391 } | |
10392 } | |
10393 } | |
10394 ++i; | |
10395 ++v10; | |
10396 } | |
10397 ++v27; | |
10398 v10 += this->uTargetSurfacePitch - v25; | |
10399 v28 += v23; | |
10400 } | |
10401 while ( v27 < v24 ); | |
10402 } | |
10403 } | |
10404 } | |
10405 } | |
10406 } | |
10407 } | |
10408 } | |
10409 | |
10410 //----- (004A6274) -------------------------------------------------------- | |
10411 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | |
10412 { | |
10413 Texture *pCurrentTexture; // edi@2 | |
10414 int uHeight; // ebx@4 | |
10415 unsigned __int16 *v6; // eax@4 | |
10416 unsigned int v7; // edx@5 | |
10417 unsigned int v8; // edx@6 | |
10418 unsigned int v9; // edx@7 | |
10419 unsigned int v10; // edx@8 | |
10420 unsigned int v11; // edx@9 | |
10421 unsigned int v12; // esi@12 | |
10422 unsigned int v13; // esi@15 | |
10423 unsigned int v14; // edx@17 | |
10424 unsigned int v15; // esi@18 | |
10425 unsigned __int8 *v16; // ebx@22 | |
10426 char uFlag; // zf@28 | |
10427 int v18; // [sp+10h] [bp-10h]@4 | |
10428 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10429 int uWidth; // [sp+1Ch] [bp-4h]@4 | |
10430 int uXa; // [sp+28h] [bp+8h]@24 | |
10431 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
10432 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
10433 | |
10434 if ( this->uNumSceneBegins ) | |
10435 { | |
10436 pCurrentTexture = pTexture; | |
10437 if ( pTexture ) | |
10438 { | |
10439 if ( pTexture->pPalette16 ) | |
10440 { | |
10441 uHeight = pTexture->uTextureHeight; | |
10442 v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 10443 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10444 uWidth = pTexture->uTextureWidth; |
10445 v18 = pTexture->uTextureWidth; | |
10446 if ( this->bClip ) | |
10447 { | |
10448 v7 = this->uClipX; | |
10449 if ( (signed int)uX < (signed int)v7 ) | |
10450 { | |
10451 v8 = v7 - uX; | |
10452 v19 += v8; | |
10453 uWidth += uX - this->uClipX; | |
10454 v6 += v8; | |
10455 } | |
10456 v9 = this->uClipY; | |
10457 uHeight = pTexture->uTextureHeight; | |
10458 if ( (signed int)uY < (signed int)v9 ) | |
10459 { | |
10460 v10 = v9 - uY; | |
10461 v19 += v18 * v10; | |
10462 uHeight = uY - this->uClipY + pTexture->uTextureHeight; | |
10463 pCurrentTexture = pTexture; | |
10464 v6 += this->uTargetSurfacePitch * v10; | |
10465 } | |
10466 v11 = this->uClipX; | |
10467 if ( (signed int)v11 < (signed int)uX ) | |
10468 v11 = uX; | |
10469 pTexturea = this->uClipZ; | |
10470 if ( (signed int)(v11 + uWidth) > (signed int)pTexturea ) | |
10471 { | |
10472 v12 = this->uClipX; | |
10473 if ( (signed int)v12 < (signed int)uX ) | |
10474 v12 = uX; | |
10475 uWidth = pTexturea - v12; | |
10476 } | |
10477 v13 = this->uClipY; | |
10478 if ( (signed int)v13 < (signed int)uY ) | |
10479 v13 = uY; | |
10480 v14 = this->uClipW; | |
10481 if ( (signed int)(uHeight + v13) > (signed int)v14 ) | |
10482 { | |
10483 v15 = this->uClipY; | |
10484 if ( (signed int)v15 < (signed int)uY ) | |
10485 v15 = uY; | |
10486 uHeight = v14 - v15; | |
10487 } | |
10488 } | |
10489 if ( (signed int)uHeight > 0 ) | |
10490 { | |
10491 uYa = uHeight; | |
10492 v16 = v19; | |
10493 do | |
10494 { | |
10495 if ( uWidth > 0 ) | |
10496 { | |
10497 uXa = uWidth; | |
10498 do | |
10499 { | |
10500 if ( *v16 ) | |
10501 *v6 = pCurrentTexture->pPalette16[*v16]; | |
10502 ++v6; | |
10503 ++v16; | |
10504 } | |
10505 while ( uXa-- !=1 ); | |
10506 } | |
10507 v16 += v18 - uWidth; | |
10508 uFlag = uYa-- == 1; | |
10509 v6 += this->uTargetSurfacePitch - uWidth; | |
10510 } | |
10511 while ( !uFlag ); | |
10512 } | |
10513 } | |
10514 } | |
10515 } | |
10516 } | |
10517 | |
10518 //----- (004A612A) -------------------------------------------------------- | |
710 | 10519 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) |
0 | 10520 { |
10521 Texture *v5; // eax@2 | |
10522 unsigned int v6; // edx@3 | |
10523 int v7; // ebx@3 | |
10524 int v8; // edi@3 | |
10525 signed int v9; // eax@4 | |
10526 int v10; // eax@5 | |
10527 unsigned int v11; // esi@6 | |
10528 signed int v12; // esi@8 | |
10529 unsigned int v13; // eax@10 | |
10530 signed int v14; // esi@11 | |
10531 unsigned int v15; // esi@14 | |
10532 unsigned int v16; // eax@16 | |
10533 unsigned int v17; // ecx@17 | |
10534 int v18; // edx@23 | |
10535 int v19; // [sp+Ch] [bp-Ch]@3 | |
10536 int v20; // [sp+10h] [bp-8h]@3 | |
10537 int uOutXa; // [sp+20h] [bp+8h]@21 | |
10538 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | |
10539 int *pZBuffer; // [sp+28h] [bp+10h]@3 | |
10540 | |
10541 if ( this->uNumSceneBegins ) | |
10542 { | |
10543 v5 = pTexture; | |
10544 if ( pTexture ) | |
10545 { | |
10546 v6 = uOutY; | |
10547 v7 = pTexture->uTextureHeight; | |
10548 pZBuffer = &this->pActiveZBuffer[uOutX + 640 * uOutY]; | |
710 | 10549 uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10550 v8 = v5->uTextureWidth; |
10551 v20 = v5->uTextureWidth; | |
10552 v19 = v5->uTextureWidth; | |
10553 if ( this->bClip ) | |
10554 { | |
10555 v9 = this->uClipX; | |
10556 if ( uOutX < v9 ) | |
10557 { | |
10558 v10 = v9 - uOutX; | |
10559 uOutYa += v10; | |
10560 v8 += uOutX - this->uClipX; | |
10561 v20 = v8; | |
10562 pZBuffer += v10; | |
10563 } | |
10564 v11 = this->uClipY; | |
10565 if ( (signed int)v6 < (signed int)v11 ) | |
10566 { | |
10567 uOutYa += v19 * (v11 - v6); | |
10568 v7 += v6 - v11; | |
10569 pZBuffer += 640 * (v11 - v6); | |
10570 v8 = v20; | |
10571 } | |
10572 v12 = this->uClipX; | |
10573 if ( v12 < uOutX ) | |
10574 v12 = uOutX; | |
10575 v13 = this->uClipZ; | |
10576 if ( v8 + v12 > (signed int)v13 ) | |
10577 { | |
10578 v14 = this->uClipX; | |
10579 if ( v14 < uOutX ) | |
10580 v14 = uOutX; | |
10581 v8 = v13 - v14; | |
10582 } | |
10583 v15 = this->uClipY; | |
10584 if ( (signed int)v15 < (signed int)v6 ) | |
10585 v15 = v6; | |
10586 v16 = this->uClipW; | |
10587 if ( (signed int)(v7 + v15) > (signed int)v16 ) | |
10588 { | |
10589 v17 = this->uClipY; | |
10590 if ( (signed int)v17 >= (signed int)v6 ) | |
10591 v6 = v17; | |
10592 v7 = v16 - v6; | |
10593 } | |
10594 } | |
10595 if ( v7 > 0 ) | |
10596 { | |
10597 uOutXa = v7; | |
10598 do | |
10599 { | |
10600 if ( v8 > 0 ) | |
10601 { | |
10602 v18 = v8; | |
10603 do | |
10604 { | |
10605 if ( *uOutYa ) | |
10606 *pZBuffer = zVal; | |
10607 ++pZBuffer; | |
10608 ++uOutYa; | |
10609 --v18; | |
10610 } | |
10611 while ( v18 ); | |
10612 } | |
10613 pZBuffer += 640 - v8; | |
10614 uOutYa += v19 - v8; | |
10615 --uOutXa; | |
10616 } | |
10617 while ( uOutXa ); | |
10618 } | |
10619 } | |
10620 } | |
10621 } | |
10622 | |
10623 //----- (004A601E) -------------------------------------------------------- | |
10624 void Render::_4A601E(signed int a2, signed int a3, Texture *pTexture, int a5) | |
10625 { | |
10626 signed int v5; // edx@3 | |
10627 int v6; // ebx@3 | |
10628 int v7; // esi@3 | |
10629 void *v8; // esi@3 | |
10630 unsigned int v9; // eax@4 | |
10631 unsigned int v10; // eax@6 | |
10632 signed int v11; // edi@8 | |
10633 unsigned int v12; // eax@10 | |
10634 signed int v13; // edi@11 | |
10635 unsigned int v14; // edi@14 | |
10636 unsigned int v15; // eax@16 | |
10637 unsigned int v16; // ecx@17 | |
10638 int v17; // [sp+18h] [bp+Ch]@3 | |
10639 unsigned int pTexturea; // [sp+1Ch] [bp+10h]@3 | |
10640 | |
10641 if ( this->uNumSceneBegins && pTexture ) | |
10642 { | |
10643 v5 = a3; | |
10644 v6 = pTexture->uTextureHeight; | |
10645 v7 = 5 * a3; | |
10646 v17 = pTexture->uTextureHeight; | |
10647 v8 = &this->pActiveZBuffer[a2 + (v7 << 7)]; | |
10648 pTexturea = pTexture->uTextureWidth; | |
10649 if ( this->bClip ) | |
10650 { | |
10651 v9 = this->uClipX; | |
10652 if ( a2 < (signed int)v9 ) | |
10653 { | |
10654 pTexturea += a2 - v9; | |
10655 v8 = (char *)v8 + 4 * (v9 - a2); | |
10656 } | |
10657 v10 = this->uClipY; | |
10658 if ( v5 < (signed int)v10 ) | |
10659 { | |
10660 v17 += v5 - v10; | |
10661 v8 = (char *)v8 + 2560 * (v10 - v5); | |
10662 } | |
10663 v11 = this->uClipX; | |
10664 if ( v11 < a2 ) | |
10665 v11 = a2; | |
10666 v12 = this->uClipZ; | |
10667 if ( (signed int)(pTexturea + v11) > (signed int)v12 ) | |
10668 { | |
10669 v13 = this->uClipX; | |
10670 if ( v13 < a2 ) | |
10671 v13 = a2; | |
10672 pTexturea = v12 - v13; | |
10673 } | |
10674 v14 = this->uClipY; | |
10675 if ( (signed int)v14 < v5 ) | |
10676 v14 = v5; | |
10677 v6 = v17; | |
10678 v15 = this->uClipW; | |
10679 if ( (signed int)(v17 + v14) > (signed int)v15 ) | |
10680 { | |
10681 v16 = this->uClipY; | |
10682 if ( (signed int)v16 < v5 ) | |
10683 v16 = v5; | |
10684 v6 = v15 - v16; | |
10685 } | |
10686 } | |
10687 if ( v6 > 0 ) | |
10688 { | |
10689 do | |
10690 { | |
10691 if ( (signed int)pTexturea > 0 ) | |
10692 { | |
10693 memset32(v8, a5, pTexturea); | |
10694 v8 = (char *)v8 + 4 * pTexturea; | |
10695 } | |
10696 v8 = (char *)v8 + 4 * (640 - pTexturea); | |
10697 --v6; | |
10698 } | |
10699 while ( v6 ); | |
10700 } | |
10701 } | |
10702 } | |
10703 | |
10704 //----- (004A5EB2) -------------------------------------------------------- | |
10705 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | |
10706 { | |
10707 Texture *v4; // edi@2 | |
10708 unsigned int v5; // ebx@4 | |
10709 unsigned __int16 *pTarget; // eax@4 | |
10710 unsigned int v7; // edx@5 | |
10711 unsigned int v8; // edx@6 | |
10712 unsigned int v9; // edx@7 | |
10713 unsigned int v10; // edx@8 | |
10714 unsigned int v11; // edx@9 | |
10715 unsigned int v12; // esi@12 | |
10716 unsigned int v13; // esi@15 | |
10717 unsigned int v14; // edx@17 | |
10718 unsigned int v15; // esi@18 | |
10719 unsigned __int8 *v16; // edx@22 | |
10720 char v17; // zf@26 | |
10721 int v18; // [sp+10h] [bp-10h]@4 | |
10722 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
10723 int v20; // [sp+1Ch] [bp-4h]@4 | |
10724 int uXa; // [sp+28h] [bp+8h]@24 | |
10725 unsigned int uYa; // [sp+2Ch] [bp+Ch]@22 | |
10726 unsigned int v23; // [sp+30h] [bp+10h]@11 | |
10727 | |
10728 if ( this->uNumSceneBegins ) | |
10729 { | |
10730 v4 = a4; | |
10731 if ( a4 ) | |
10732 { | |
10733 if ( a4->pPalette16 ) | |
10734 { | |
10735 v5 = a4->uTextureHeight; | |
10736 pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | |
710 | 10737 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
0 | 10738 v20 = a4->uTextureWidth; |
10739 v18 = a4->uTextureWidth; | |
10740 if ( this->bClip ) | |
10741 { | |
10742 v7 = this->uClipX; | |
10743 if ( (signed int)uX < (signed int)v7 ) | |
10744 { | |
10745 v8 = v7 - uX; | |
10746 v19 += v8; | |
10747 v20 += uX - this->uClipX; | |
10748 pTarget += v8; | |
10749 } | |
10750 v9 = this->uClipY; | |
10751 v5 = a4->uTextureHeight; | |
10752 if ( (signed int)uY < (signed int)v9 ) | |
10753 { | |
10754 v10 = v9 - uY; | |
10755 v19 += v18 * v10; | |
10756 v5 = uY - this->uClipY + a4->uTextureHeight; | |
10757 v4 = a4; | |
10758 pTarget += this->uTargetSurfacePitch * v10; | |
10759 } | |
10760 v11 = this->uClipX; | |
10761 if ( (signed int)v11 < (signed int)uX ) | |
10762 v11 = uX; | |
10763 v23 = this->uClipZ; | |
10764 if ( (signed int)(v11 + v20) > (signed int)v23 ) | |
10765 { | |
10766 v12 = this->uClipX; | |
10767 if ( (signed int)v12 < (signed int)uX ) | |
10768 v12 = uX; | |
10769 v20 = v23 - v12; | |
10770 } | |
10771 v13 = this->uClipY; | |
10772 if ( (signed int)v13 < (signed int)uY ) | |
10773 v13 = uY; | |
10774 v14 = this->uClipW; | |
10775 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
10776 { | |
10777 v15 = this->uClipY; | |
10778 if ( (signed int)v15 < (signed int)uY ) | |
10779 v15 = uY; | |
10780 v5 = v14 - v15; | |
10781 } | |
10782 } | |
10783 if ( (signed int)v5 > 0 ) | |
10784 { | |
10785 uYa = v5; | |
10786 v16 = v19; | |
10787 do | |
10788 { | |
10789 if ( v20 > 0 ) | |
10790 { | |
10791 uXa = v20; | |
10792 do | |
10793 { | |
10794 *pTarget = v4->pPalette16[*v16]; | |
10795 ++pTarget; | |
10796 ++v16; | |
10797 --uXa; | |
10798 } | |
10799 while ( uXa ); | |
10800 } | |
10801 v16 += v18 - v20; | |
10802 v17 = uYa-- == 1; | |
10803 pTarget += this->uTargetSurfacePitch - v20; | |
10804 } | |
10805 while ( !v17 ); | |
10806 } | |
10807 } | |
10808 } | |
10809 } | |
10810 } | |
10811 | |
10812 //----- (004667E9) -------------------------------------------------------- | |
10813 void Render::ChangeBetweenWinFullscreenModes() | |
10814 { | |
10815 float v0; // ST14_4@17 | |
10816 int v1; // edx@24 | |
10817 signed int v2; // ecx@24 | |
10818 int v3; // esi@25 | |
10819 int v4; // edx@26 | |
10820 ObjectDesc *v5; // eax@26 | |
10821 RGBTexture *v6; // esi@33 | |
10822 const char *v7; // eax@34 | |
10823 const char *v8; // [sp-4h] [bp-28h]@33 | |
10824 int v9; // [sp+0h] [bp-24h]@33 | |
10825 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 | |
10826 | |
10827 if ( pRenderer->bWindowMode ) | |
10828 goto LABEL_52; | |
10829 if ( dword_6BE364_game_settings_1 & 2 ) | |
10830 { | |
10831 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." | |
10832 return; | |
10833 } | |
10834 if ( !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) | |
10835 { | |
10836 LABEL_52: | |
10837 if ( pEventTimer->bPaused ) | |
10838 BYTE1(dword_6BE364_game_settings_1) |= 8u; | |
10839 else | |
10840 pEventTimer->Pause(); | |
10841 if ( pMiscTimer->bPaused ) | |
10842 BYTE1(dword_6BE364_game_settings_1) |= 0x10u; | |
10843 else | |
10844 pMiscTimer->Pause(); | |
10845 pMouse->bActive = 0; | |
10846 if ( pRenderer->pRenderD3D ) | |
10847 { | |
10848 pBitmaps_LOD->ReleaseHardwareTextures(); | |
10849 pSprites_LOD->ReleaseAll(); | |
10850 } | |
10851 if ( pRenderer->bWindowMode ) | |
10852 { | |
10853 if ( GetWindowRect(hWnd, &Rect) ) | |
10854 { | |
10855 WriteWindowsRegistryInt("window X", Rect.left); | |
10856 WriteWindowsRegistryInt("window Y", Rect.top); | |
10857 uWindowX = Rect.left; | |
10858 uWindowY = Rect.top; | |
10859 } | |
10860 SetMenu(hWnd, 0); | |
10861 SetWindowLongA(hWnd, -20, 0); | |
10862 SetWindowLongA(hWnd, -16, 0x10000000u); | |
10863 pRenderer->InitializeFullscreen(hWnd); | |
10864 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; | |
10865 pGame->pGammaController->Initialize(v0); | |
10866 } | |
10867 else | |
10868 { | |
10869 ClipCursor(0); | |
10870 pRenderer->SwitchToWindow(hWnd); | |
10871 SetWindowLongA(hWnd, -16, uWindowStyle); | |
10872 SetMenu(hWnd, hOSMenu); | |
10873 } | |
10874 if ( pRenderer->pRenderD3D ) | |
10875 { | |
10876 pBitmaps_LOD->_410423_move_textures_to_device(); | |
10877 pSprites_LOD->MoveSpritesToVideoMemory(); | |
10878 } | |
10879 if ( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits | |
10880 && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits | |
10881 && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits ) | |
10882 goto LABEL_38; | |
10883 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10884 pPaletteManager->RecalculateAll(); | |
10885 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10886 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
10887 v2 = 0; | |
10888 if ( (signed int)pObjectList->uNumObjects > 0 ) | |
10889 { | |
10890 v3 = 0; | |
10891 do | |
10892 { | |
10893 BYTE3(v4) = 0; | |
10894 v5 = &pObjectList->pObjects[v3]; | |
10895 ++v3; | |
10896 *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; | |
10897 LOBYTE(v4) = v5->uParticleTrailColorG; | |
10898 v1 = v5->uParticleTrailColorB | (v4 << 8); | |
10899 ++v2; | |
10900 v5->uParticleTrailColor = v1; | |
10901 } | |
10902 while ( v2 < (signed int)pObjectList->uNumObjects ); | |
10903 } | |
10904 LOBYTE(v1) = 1; | |
373 | 10905 SetUserInterface(pParty->alignment, v1); |
0 | 10906 if ( pVideoPlayer->pVideoFrame.pPixels ) |
10907 pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); | |
10908 if ( uCurrentMenuID ) | |
10909 { | |
10910 if ( uCurrentMenuID != 6 ) | |
10911 { | |
10912 if ( uCurrentMenuID == 8 ) | |
10913 dword_A74C88 = 1; | |
10914 goto LABEL_38; | |
10915 } | |
10916 v6 = &pTexture_PCX; | |
10917 pTexture_PCX.Release(); | |
10918 v9 = 0; | |
10919 v8 = "makeme.pcx"; | |
10920 } | |
10921 else | |
10922 { | |
10923 v6 = &pTexture_PCX; | |
10924 pTexture_PCX.Release(); | |
10925 v7 = "title.pcx"; | |
10926 if ( uCurrentMenuID ) | |
10927 v7 = "lsave640.pcx"; | |
10928 v9 = 0; | |
10929 v8 = v7; | |
10930 } | |
10931 v6->Load(v8, v9); | |
10932 LABEL_38: | |
10933 viewparams->bRedrawGameUI = 1; | |
688 | 10934 viewparams->InitGrayPalette(); |
0 | 10935 pMouse->SetCurrentCursorBitmap(); |
10936 if ( pRenderer->bWindowMode ) | |
10937 { | |
10938 InvalidateRect(0, 0, 0); | |
10939 MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); | |
10940 ShowWindow(hWnd, 1); | |
10941 } | |
10942 pMouse->bActive = 1; | |
10943 if ( pVideoPlayer->AnyMovieLoaded() ) | |
10944 pVideoPlayer->_4BF73A(); | |
10945 if ( BYTE1(dword_6BE364_game_settings_1) & 8 ) | |
10946 BYTE1(dword_6BE364_game_settings_1) &= 0xF7u; | |
10947 else | |
10948 pEventTimer->Resume(); | |
10949 if ( BYTE1(dword_6BE364_game_settings_1) & 0x10 ) | |
10950 BYTE1(dword_6BE364_game_settings_1) &= 0xEFu; | |
10951 else | |
10952 pMiscTimer->Resume(); | |
10953 pAsyncMouse->Release(); | |
10954 CreateAsyncMouse(); | |
10955 if (pAsyncMouse) | |
10956 pAsyncMouse->Clip(); | |
10957 } | |
10958 } | |
10959 // 6BE364: using guessed type int dword_6BE364_game_settings_1; | |
10960 // A74C88: using guessed type int dword_A74C88; | |
10961 | |
10962 //----- (0044EC20) -------------------------------------------------------- | |
10963 bool RenderD3D::DoesRaiseExceptions() | |
10964 { | |
10965 return true; | |
10966 } | |
10967 | |
10968 //----- (0040DBD3) -------------------------------------------------------- | |
10969 void __fastcall Render::SetPixel(Vec2_int_ *pTargetXY, unsigned __int16 uColor) | |
10970 { | |
10971 Vec2_int_ *pTargetXY_; // esi@1 | |
10972 unsigned __int16 v3; // di@1 | |
10973 signed int v4; // ecx@2 | |
10974 signed int v5; // eax@4 | |
10975 | |
10976 pTargetXY_ = pTargetXY; | |
10977 v3 = uColor; | |
10978 pRenderer->BeginScene(); | |
10979 if ( pRenderer->uNumSceneBegins ) | |
10980 { | |
10981 v4 = pTargetXY_->x; | |
10982 if ( pTargetXY_->x >= 0 ) | |
10983 { | |
10984 if ( v4 <= 639 ) | |
10985 { | |
10986 v5 = pTargetXY_->y; | |
10987 if ( v5 >= 0 ) | |
10988 { | |
10989 if ( v5 <= 479 ) | |
10990 pRenderer->pTargetSurface[v4 + pRenderer->uTargetSurfacePitch * v5] = v3; | |
10991 } | |
10992 } | |
10993 } | |
10994 pRenderer->EndScene(); | |
10995 } | |
10996 } | |
10997 | |
10998 //----- (004524D8) -------------------------------------------------------- | |
10999 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | |
11000 { | |
11001 int v11; // eax@13 | |
11002 int v12; // ecx@13 | |
11003 void *v13; // eax@13 | |
11004 unsigned __int8 v14; // zf@13 | |
11005 unsigned __int8 v15; // sf@13 | |
11006 int v16; // esi@14 | |
11007 int v17; // ecx@16 | |
11008 int v18; // esi@16 | |
11009 unsigned __int16 *v19; // eax@16 | |
11010 int v20; // edx@16 | |
11011 int v21; // ecx@16 | |
11012 int v22; // eax@16 | |
11013 int v23; // esi@16 | |
11014 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 | |
11015 int v27; // [sp+28h] [bp-Ch]@14 | |
11016 int v28; // [sp+2Ch] [bp-8h]@13 | |
11017 int pDestb; // [sp+3Ch] [bp+8h]@15 | |
11018 | |
11019 //v3 = this; | |
11020 //sprintf(Str1, "%s", pName); | |
11021 //v4 = uNumItems; | |
11022 if (!uNumItems) | |
11023 return nullptr; | |
11024 | |
11025 //{ | |
11026 //v5 = 0, pDesta = uNumItems; | |
11027 uint idx1 = 0, | |
11028 idx2 = uNumItems; | |
11029 while (true) | |
11030 { | |
11031 auto i = idx1 + (idx2 - idx1) / 2; | |
11032 | |
11033 auto res = strcmpi(pName, pSpriteNames[i]); | |
11034 if (!res) | |
11035 { | |
11036 fseek(pFile, pSpriteOffsets[i], SEEK_SET); | |
11037 break; | |
11038 } | |
11039 else if (res < 0) | |
11040 idx2 = idx1 + (idx2 - idx1) / 2; | |
11041 else | |
11042 idx1 = i + 1; | |
11043 | |
11044 if ( idx1 >= idx2 ) | |
11045 return false; | |
11046 } | |
11047 | |
11048 | |
11049 uint uCompressedSize = 0; | |
11050 fread(&uCompressedSize, 4, 1, pFile); | |
11051 | |
11052 auto pTex = new HWLTexture; | |
670 | 11053 fread(&pTex->uBufferWidth, 4, 1, pFile); |
11054 fread(&pTex->uBufferHeight, 4, 1, pFile); | |
11055 fread(&pTex->uAreaWidth, 4, 1, pFile); | |
11056 fread(&pTex->uAreaHeigth, 4, 1, pFile); | |
0 | 11057 fread(&pTex->uWidth, 4, 1, pFile); |
11058 fread(&pTex->uHeight, 4, 1, pFile); | |
670 | 11059 fread(&pTex->uAreaX, 4, 1, pFile); |
11060 fread(&pTex->uAreaY, 4, 1, pFile); | |
0 | 11061 |
11062 pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; | |
11063 if (uCompressedSize) | |
11064 { | |
11065 auto pCompressedData = new char[uCompressedSize]; | |
11066 { | |
11067 fread(pCompressedData, 1, uCompressedSize, pFile); | |
11068 auto uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); | |
11069 zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); | |
11070 } | |
11071 delete [] pCompressedData; | |
11072 } | |
11073 else | |
11074 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | |
11075 | |
11076 if ( field_61A94_scale_hwls_to_half ) | |
11077 { | |
11078 v11 = pTex->uHeight / 2; | |
11079 v12 = pTex->uWidth / 2; | |
11080 pTex->uHeight = v11; | |
11081 pTex->uWidth = v12; | |
11082 v13 = new unsigned __int16[v12 * v11]; | |
11083 v28 = 0; | |
11084 v14 = pTex->uHeight == 0; | |
11085 v15 = (pTex->uHeight & 0x80000000u) != 0; | |
11086 v26 = (unsigned __int16 *)v13; | |
11087 if ( !(v15 | v14) ) | |
11088 { | |
11089 v16 = pTex->uWidth; | |
11090 v27 = 1; | |
11091 do | |
11092 { | |
11093 pDestb = 0; | |
11094 if ( v16 > 0 ) | |
11095 { | |
11096 do | |
11097 { | |
11098 v17 = v16 * v27; | |
11099 v18 = v28 * v16; | |
11100 v19 = pTex->pPixels; | |
11101 v20 = pDestb + 2 * v18; | |
11102 v21 = (int)&v19[2 * (pDestb + v17)]; | |
11103 v22 = (int)&v19[2 * v20]; | |
11104 LOWORD(v20) = *(unsigned short *)(v21 + 2); | |
11105 LOWORD(v21) = *(unsigned short *)v21; | |
11106 v23 = pDestb++ + v18; | |
11107 v26[v23] = sub_452442(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
11108 v16 = pTex->uWidth; | |
11109 } | |
11110 while (pDestb < pTex->uWidth); | |
11111 } | |
11112 ++v28; | |
11113 v27 += 2; | |
11114 } | |
11115 while ( v28 < (signed int)pTex->uHeight ); | |
11116 } | |
11117 delete [] pTex->pPixels; | |
11118 pTex->pPixels = v26; | |
11119 } | |
11120 return pTex; | |
11121 //result = pTex; | |
11122 // } | |
11123 // else | |
11124 // { | |
11125 //LABEL_8: | |
11126 // return nullptr; | |
11127 // } | |
11128 } | |
11129 | |
11130 //----- (0045271F) -------------------------------------------------------- | |
11131 bool RenderHWLContainer::Release() | |
11132 { | |
11133 RenderHWLContainer *v1; // esi@1 | |
11134 int v2; // ebx@1 | |
11135 void **v3; // edi@3 | |
11136 __int32 v4; // eax@6 | |
11137 FILE *v5; // ST24_4@6 | |
11138 size_t *v6; // edi@6 | |
11139 int v7; // ebx@7 | |
11140 signed int v9; // [sp+0h] [bp-8h]@6 | |
11141 FILE *File; // [sp+4h] [bp-4h]@6 | |
11142 | |
11143 v1 = this; | |
11144 v2 = 0; | |
11145 if ( this->bDumpDebug ) | |
11146 { | |
11147 File = fopen("logd3d.txt", "w"); | |
11148 v4 = ftell(v1->pFile); | |
11149 v5 = v1->pFile; | |
11150 v6 = &v1->uNumItems; | |
11151 v1->uDataOffset = v4; | |
11152 fwrite(&v1->uNumItems, 4u, 1u, v5); | |
11153 v9 = 0; | |
11154 if ( (signed int)v1->uNumItems > 0 ) | |
11155 { | |
11156 v7 = (int)v1->pSpriteNames; | |
11157 do | |
11158 { | |
11159 fwrite(*(const void **)v7, 1u, 0x14u, v1->pFile); | |
11160 fprintf(File, "D3D texture name: %s\t\toffset: %x\n", *(unsigned int *)v7, *(unsigned int *)(v7 + 200000)); | |
11161 ++v9; | |
11162 v7 += 4; | |
11163 } | |
11164 while ( v9 < (signed int)*v6 ); | |
11165 v2 = 0; | |
11166 } | |
11167 fwrite(v1->pSpriteOffsets, 4u, *v6, v1->pFile); | |
11168 fseek(v1->pFile, 4, v2); | |
11169 fwrite(&v1->uDataOffset, 4u, 1u, v1->pFile); | |
11170 fclose(v1->pFile); | |
11171 fclose(File); | |
11172 } | |
11173 else | |
11174 { | |
11175 fclose(this->pFile); | |
11176 if ( (signed int)v1->uNumItems > 0 ) | |
11177 { | |
11178 v3 = (void **)v1->pSpriteNames; | |
11179 do | |
11180 { | |
11181 free(*v3); | |
11182 ++v2; | |
11183 ++v3; | |
11184 } | |
11185 while ( v2 < (signed int)v1->uNumItems ); | |
11186 } | |
11187 } | |
11188 return 1; | |
11189 } | |
11190 | |
11191 //----- (00452347) -------------------------------------------------------- | |
11192 RenderHWLContainer::RenderHWLContainer(): | |
11193 bDumpDebug(false) | |
11194 { | |
11195 RenderHWLContainer *v1; // esi@1 | |
11196 | |
11197 v1 = this; | |
11198 this->pFile = 0; | |
11199 uSignature = 0; | |
11200 v1->uDataOffset = 0; | |
11201 memset(&v1->uNumItems, 0, 0x61A84u); | |
11202 v1->uNumItems = 0; | |
11203 v1->field_61A94_scale_hwls_to_half = 0; | |
11204 } | |
11205 | |
11206 //----- (0045237F) -------------------------------------------------------- | |
11207 bool RenderHWLContainer::Load(const wchar_t *pFilename) | |
11208 { | |
11209 pFile = _wfopen(pFilename, L"rb"); | |
11210 if (!pFile) | |
11211 { | |
11212 Log::Warning(L"Failed to open file: %s", pFilename); | |
11213 return false; | |
11214 } | |
11215 | |
11216 fread(&uSignature, 1, 4, pFile); | |
11217 if (uSignature != 'TD3D') | |
11218 { | |
11219 Log::Warning(L"Invalid format: %s", pFilename); | |
11220 return false; | |
11221 } | |
11222 | |
11223 fread(&uDataOffset, 4, 1, pFile); | |
11224 fseek(pFile, uDataOffset, SEEK_SET); | |
11225 fread(&uNumItems, 4, 1, pFile); | |
11226 | |
11227 memset(pSpriteNames, 0, 50000 * sizeof(char *)); | |
11228 for (uint i = 0; i < uNumItems; ++i) | |
11229 { | |
11230 pSpriteNames[i] = new char[20]; | |
11231 fread(pSpriteNames[i], 1, 20, pFile); | |
11232 } | |
11233 fread(pSpriteOffsets, 4, uNumItems, pFile); | |
11234 | |
11235 return true; | |
11236 } | |
11237 | |
11238 //----- (004A1C1E) -------------------------------------------------------- | |
11239 void DoRenderBillboards_D3D() | |
11240 { | |
186 | 11241 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); |
11242 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
11243 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11244 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11245 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11246 /*if (pRenderer->uNumBillboardsToDraw) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11247 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11248 auto p = &pRenderer->pBillboardRenderListD3D[0]; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11249 for (int i = 0; i < p->uNumVertices; ++i) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11250 { |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11251 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
|
11252 //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
|
11253 } |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11254 p->pQuards[0].pos.x = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11255 p->pQuards[0].pos.y = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11256 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11257 p->pQuards[1].pos.x = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11258 p->pQuards[1].pos.y = 200; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11259 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11260 p->pQuards[2].pos.x = 100; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11261 p->pQuards[2].pos.y = 200; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11262 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11263 p->pQuards[3].pos.x = 100; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11264 p->pQuards[3].pos.y = 10; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11265 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11266 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11267 SetBillboardBlendOptions(p->uOpacity); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11268 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11269 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11270 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11271 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11272 p->pQuards, p->uNumVertices, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11273 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11274 |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11275 }*/ |
0 | 11276 |
11277 for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i) | |
11278 { | |
101 | 11279 auto p = &pRenderer->pBillboardRenderListD3D[i]; |
0 | 11280 |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11281 if (p->uOpacity != RenderBillboardD3D::NoBlend) |
0 | 11282 SetBillboardBlendOptions(p->uOpacity); |
11283 | |
101 | 11284 pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11285 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11286 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11287 p->pQuards, p->uNumVertices, |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11288 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); |
0 | 11289 } |
11290 | |
11291 if (pRenderer->bFogEnabled) | |
11292 { | |
11293 pRenderer->bFogEnabled = false; | |
186 | 11294 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 11295 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
11296 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
11297 } | |
186 | 11298 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); |
11299 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
11300 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
11301 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
11302 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
11303 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 11304 } |
11305 | |
11306 //----- (004A1DA8) -------------------------------------------------------- | |
11307 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1) | |
11308 { | |
11309 switch (a1) | |
11310 { | |
11311 case RenderBillboardD3D::Transparent: | |
11312 { | |
11313 if (pRenderer->bFogEnabled) | |
11314 { | |
11315 pRenderer->bFogEnabled = false; | |
186 | 11316 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); |
0 | 11317 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF)); |
11318 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); | |
11319 } | |
11320 | |
186 | 11321 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); |
11322 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
11323 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); | |
0 | 11324 } |
11325 break; | |
11326 | |
11327 case RenderBillboardD3D::Opaque_1: | |
11328 case RenderBillboardD3D::Opaque_2: | |
11329 case RenderBillboardD3D::Opaque_3: | |
11330 { | |
11331 if (pRenderer->bUsingSpecular) | |
11332 { | |
11333 if (!pRenderer->bFogEnabled) | |
11334 { | |
11335 pRenderer->bFogEnabled = true; | |
186 | 11336 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); |
11337 } | |
11338 } | |
11339 | |
11340 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
11341 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); | |
11342 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); | |
0 | 11343 } |
11344 break; | |
11345 | |
11346 default: | |
11347 Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
143
diff
changeset
|
11348 assert(false); |
0 | 11349 break; |
11350 } | |
11351 } | |
11352 |